@@ -264,7 +264,7 @@ let rec as_subst (p : list (term & term))
264264
265265
266266
267- 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 ) =
268268 (* We only use the rewrites_to substitution if there is no tactic attached to the
269269 rewrite. Otherwise, tactics may become brittle as the goal is changed unexpectedly
270270 by other things in the context. See tests/Match.fst. *)
@@ -275,7 +275,10 @@ let rewrite_all (is_source:bool) (g:env) (p: list (term & term)) (t:term) tac_op
275275 let t = dfst <| Pulse.Checker.Prover. normalize_slprop g t use_rwr in
276276 t
277277 in
278+ let maybe_purify t = if elaborated then t else purify_term g { ctxt_now = pre ; ctxt_old = None } t in
278279 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
279282 let lhs , lhs_typ = Pulse.Checker.Pure. instantiate_term_implicits g lhs None true in
280283 let rhs , rhs_typ = Pulse.Checker.Pure. instantiate_term_implicits g rhs ( Some lhs_typ ) true in
281284 let lhs = norm lhs in
@@ -304,7 +307,7 @@ let check_renaming
304307 })
305308: T. Tac st_term
306309= let Tm_ProofHintWithBinders ht = st . term in
307- 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
308311 match bs , goal with
309312 | _ :: _ , None ->
310313 //if there are binders, we must have a goal
@@ -324,7 +327,7 @@ let check_renaming
324327
325328 | [], None ->
326329 // if there is no goal, take the goal to be the full current pre
327- 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
328331 let t = { st with term = Tm_Rewrite { t1 = lhs ; t2 = rhs ; tac_opt ; elaborated = true };
329332 source = Sealed. seal false ; } in
330333 { st with
@@ -334,7 +337,7 @@ let check_renaming
334337
335338 | [], Some goal -> (
336339 let goal , _ = PC. instantiate_term_implicits g goal None false in
337- 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
338341 let t = { st with term = Tm_Rewrite { t1 = lhs ; t2 = rhs ; tac_opt ; elaborated = true };
339342 source = Sealed. seal false ; } in
340343 { st with term = Tm_Bind { binder = as_binder tm_unit ; head = t ; body };
0 commit comments