@@ -19,6 +19,7 @@ module Pulse.Checker.AssertWithBinders
1919open Pulse.Syntax
2020open Pulse.Typing
2121open Pulse.Checker.Base
22+ open Pulse.Checker.ImpureSpec
2223open Pulse.Elaborate.Pure
2324open Pulse.Typing.Env
2425
@@ -263,7 +264,7 @@ let rec as_subst (p : list (term & term))
263264
264265
265266
266- let rewrite_all ( is_source :bool) ( g : env ) ( p : list ( term & term )) ( t : term ) tac_opt : T. Tac ( term & term ) =
267+ let rewrite_all ( is_source :bool) ( g : env ) ( p : list ( term & term )) ( t : term ) pre elaborated tac_opt : T. Tac ( term & term ) =
267268 (* We only use the rewrites_to substitution if there is no tactic attached to the
268269 rewrite. Otherwise, tactics may become brittle as the goal is changed unexpectedly
269270 by other things in the context. See tests/Match.fst. *)
@@ -274,7 +275,10 @@ let rewrite_all (is_source:bool) (g:env) (p: list (term & term)) (t:term) tac_op
274275 let t = dfst <| Pulse.Checker.Prover. normalize_slprop g t use_rwr in
275276 t
276277 in
278+ let maybe_purify t = if elaborated then t else purify_term g { ctxt_now = pre ; ctxt_old = None } t in
277279 let elab_pair ( lhs rhs : R. term ) : T. Tac ( R. term & R. term ) =
280+ let lhs = maybe_purify lhs in
281+ let rhs = maybe_purify rhs in
278282 let lhs , lhs_typ = Pulse.Checker.Pure. instantiate_term_implicits g lhs None true in
279283 let rhs , rhs_typ = Pulse.Checker.Pure. instantiate_term_implicits g rhs ( Some lhs_typ ) true in
280284 let lhs = norm lhs in
@@ -303,7 +307,7 @@ let check_renaming
303307 })
304308: T. Tac st_term
305309= let Tm_ProofHintWithBinders ht = st . term in
306- let { hint_type = RENAME { pairs ; goal ; tac_opt }; binders = bs ; t = body } = ht in
310+ let { hint_type = RENAME { pairs ; goal ; tac_opt ; elaborated }; binders = bs ; t = body } = ht in
307311 match bs , goal with
308312 | _ :: _ , None ->
309313 //if there are binders, we must have a goal
@@ -323,7 +327,7 @@ let check_renaming
323327
324328 | [], None ->
325329 // if there is no goal, take the goal to be the full current pre
326- let lhs , rhs = rewrite_all ( T. unseal st . source ) g pairs pre tac_opt in
330+ let lhs , rhs = rewrite_all ( T. unseal st . source ) g pairs pre pre elaborated tac_opt in
327331 let t = { st with term = Tm_Rewrite { t1 = lhs ; t2 = rhs ; tac_opt ; elaborated = true };
328332 source = Sealed. seal false ; } in
329333 { st with
@@ -333,7 +337,7 @@ let check_renaming
333337
334338 | [], Some goal -> (
335339 let goal , _ = PC. instantiate_term_implicits g goal None false in
336- let lhs , rhs = rewrite_all ( T. unseal st . source ) g pairs goal tac_opt in
340+ let lhs , rhs = rewrite_all ( T. unseal st . source ) g pairs goal pre elaborated tac_opt in
337341 let t = { st with term = Tm_Rewrite { t1 = lhs ; t2 = rhs ; tac_opt ; elaborated = true };
338342 source = Sealed. seal false ; } in
339343 { st with term = Tm_Bind { binder = as_binder tm_unit ; head = t ; body };
@@ -486,6 +490,7 @@ let check
486490
487491 check_unfoldable g v ;
488492
493+ let v_opened = purify_term g { ctxt_now = pre ; ctxt_old = None } v_opened in
489494 let v_opened , t_rem = PC. instantiate_term_implicits ( push_env g uvs ) v_opened None false in
490495
491496 let uvs , v_opened =
0 commit comments