Skip to content

Commit 06ad2a7

Browse files
committed
Fixing rewrite/subst when the subterm to rewrite is argument of an Evar.
This was broken by the attempt to use the same algorithm for rewriting closed subterms than for rewriting subterms with evars: the algorithm to find subterms (w_unify_to_subterm) did not go through evars. But what to do when looking say, for a pattern "S ?n" in a goal "S ?x[a:=S ?y]"? Should we unify ?x[a:=S ?y] with ?n or consider ?x as rigid and look in the instance? If we adopt the first approach, then, what to do when looking for "S ?n" in a goal "?x[a:=S ?y]"? Failing? Looking in the instance? Is it normal that an evar behaves as a rigid constant when it cannot be unified with the pattern?
1 parent 71def2f commit 06ad2a7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pretyping/unification.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,12 @@ let w_unify_to_subterm_list env evd flags hdmeta oplist t =
17801780
try
17811781
(* This is up to delta for subterms w/o metas ... *)
17821782
w_unify_to_subterm env evd ~flags (strip_outer_cast op,t)
1783-
with PretypeError (env,_,NoOccurrenceFound _) when allow_K -> (evd,op)
1783+
with PretypeError (env,_,NoOccurrenceFound _) when
1784+
allow_K ||
1785+
(* w_unify_to_subterm does not go through evars, so
1786+
the next step, which was already in <= 8.4, is
1787+
needed at least for compatibility of rewrite *)
1788+
dependent op t -> (evd,op)
17841789
in
17851790
if not allow_K &&
17861791
(* ensure we found a different instance *)

test-suite/success/rewrite.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,13 @@ eexists. intro H.
148148
rewrite H.
149149
reflexivity.
150150
Abort.
151+
152+
(* Check that rewriting within evars still work (was broken in 8.5beta1) *)
153+
154+
155+
Goal forall (a: unit) (H: a = tt), exists x y:nat, x = y.
156+
intros; eexists; eexists.
157+
rewrite H.
158+
Undo.
159+
subst.
160+
Abort.

0 commit comments

Comments
 (0)