Skip to content
Snippets Groups Projects
Commit e0492901 authored by Ralf Jung's avatar Ralf Jung
Browse files

add mk_evar tactic (to replace Coq's strange evar tactic) and use it

parent fb2e3c8e
No related branches found
No related tags found
1 merge request!289add mk_evar tactic (to replace Coq's strange evar tactic) and use it
...@@ -3198,10 +3198,9 @@ Tactic Notation "simpl_map" "by" tactic3(tac) := repeat ...@@ -3198,10 +3198,9 @@ Tactic Notation "simpl_map" "by" tactic3(tac) := repeat
| H : context[ (_ <$> _) !! _ ] |- _ => rewrite lookup_fmap in H | H : context[ (_ <$> _) !! _ ] |- _ => rewrite lookup_fmap in H
| H : context[ (omap _ _) !! _ ] |- _ => rewrite lookup_omap in H | H : context[ (omap _ _) !! _ ] |- _ => rewrite lookup_omap in H
| H : context[ lookup (A:=?A) ?i (?m1 ?m2) ] |- _ => | H : context[ lookup (A:=?A) ?i (?m1 ?m2) ] |- _ =>
let x := fresh in evar (x:A); let x := mk_evar A in
let x' := eval unfold x in x in clear x;
let E := fresh in let E := fresh in
assert ((m1 m2) !! i = Some x') as E by (clear H; by tac); assert ((m1 m2) !! i = Some x) as E by (clear H; by tac);
rewrite E in H; clear E rewrite E in H; clear E
| |- context[ !! _ ] => rewrite lookup_empty | |- context[ !! _ ] => rewrite lookup_empty
| |- context[ (<[_:=_]>_) !! _ ] => | |- context[ (<[_:=_]>_) !! _ ] =>
...@@ -3215,10 +3214,9 @@ Tactic Notation "simpl_map" "by" tactic3(tac) := repeat ...@@ -3215,10 +3214,9 @@ Tactic Notation "simpl_map" "by" tactic3(tac) := repeat
| |- context[ (_ <$> _) !! _ ] => rewrite lookup_fmap | |- context[ (_ <$> _) !! _ ] => rewrite lookup_fmap
| |- context[ (omap _ _) !! _ ] => rewrite lookup_omap | |- context[ (omap _ _) !! _ ] => rewrite lookup_omap
| |- context [ lookup (A:=?A) ?i ?m ] => | |- context [ lookup (A:=?A) ?i ?m ] =>
let x := fresh in evar (x:A); let x := mk_evar A in
let x' := eval unfold x in x in clear x;
let E := fresh in let E := fresh in
assert (m !! i = Some x') as E by tac; assert (m !! i = Some x) as E by tac;
rewrite E; clear E rewrite E; clear E
end. end.
......
...@@ -273,10 +273,9 @@ End multiset_unfold. ...@@ -273,10 +273,9 @@ End multiset_unfold.
Ltac multiset_instantiate := Ltac multiset_instantiate :=
repeat match goal with repeat match goal with
| H : ( x : ?A, @?P x) |- _ => | H : ( x : ?A, @?P x) |- _ =>
let e := fresh in evar (e:A); let e := mk_evar A in
let e' := eval unfold e in e in clear e; lazymatch constr:(P e) with
lazymatch constr:(P e') with | context [ {[+ ?y +]} ] => unify y e; learn_hyp (H y)
| context [ {[+ ?y +]} ] => unify y e'; learn_hyp (H y)
end end
| H : ( x : ?A, _), _ : context [multiplicity ?y _] |- _ => learn_hyp (H y) | H : ( x : ?A, _), _ : context [multiplicity ?y _] |- _ => learn_hyp (H y)
| H : ( x : ?A, _) |- context [multiplicity ?y _] => learn_hyp (H y) | H : ( x : ?A, _) |- context [multiplicity ?y _] => learn_hyp (H y)
......
...@@ -360,8 +360,8 @@ Proof. intros [??]. repeat case_option_guard; intuition. Qed. ...@@ -360,8 +360,8 @@ Proof. intros [??]. repeat case_option_guard; intuition. Qed.
Tactic Notation "simpl_option" "by" tactic3(tac) := Tactic Notation "simpl_option" "by" tactic3(tac) :=
let assert_Some_None A mx H := first let assert_Some_None A mx H := first
[ let x := fresh in evar (x:A); let x' := eval unfold x in x in clear x; [ let x := mk_evar A in
assert (mx = Some x') as H by tac assert (mx = Some x) as H by tac
| assert (mx = None) as H by tac ] | assert (mx = None) as H by tac ]
in repeat match goal with in repeat match goal with
| H : context [@mret _ _ ?A] |- _ => | H : context [@mret _ _ ?A] |- _ =>
......
...@@ -217,6 +217,14 @@ does the converse. *) ...@@ -217,6 +217,14 @@ does the converse. *)
Ltac var_eq x1 x2 := match x1 with x2 => idtac | _ => fail 1 end. Ltac var_eq x1 x2 := match x1 with x2 => idtac | _ => fail 1 end.
Ltac var_neq x1 x2 := match x1 with x2 => fail 1 | _ => idtac end. Ltac var_neq x1 x2 := match x1 with x2 => fail 1 | _ => idtac end.
(** The tactic [mk_evar T] returns a new evar of type [T], without affecting the
current context.
This is usually a more useful behavior than Coq's [evar], which is a
side-effecting tactic (not returning anything) that introduces a local
definition into the context that holds the evar. *)
Ltac mk_evar T := open_constr:(_ : T).
(** The tactic [eunify x y] succeeds if [x] and [y] can be unified, and fails (** The tactic [eunify x y] succeeds if [x] and [y] can be unified, and fails
otherwise. If it succeeds, it will instantiate necessary evars in [x] and [y]. otherwise. If it succeeds, it will instantiate necessary evars in [x] and [y].
...@@ -483,9 +491,8 @@ Tactic Notation "efeed" constr(H) "using" tactic3(tac) "by" tactic3 (bytac) := ...@@ -483,9 +491,8 @@ Tactic Notation "efeed" constr(H) "using" tactic3(tac) "by" tactic3 (bytac) :=
let HT1 := fresh "feed" in assert T1 as HT1; let HT1 := fresh "feed" in assert T1 as HT1;
[bytac | go (H HT1); clear HT1 ] [bytac | go (H HT1); clear HT1 ]
| ?T1 _ => | ?T1 _ =>
let e := fresh "feed" in evar (e:T1); let e := mk_evar T1 in
let e' := eval unfold e in e in go (H e)
clear e; go (H e')
| ?T1 => tac H | ?T1 => tac H
end in go H. end in go H.
Tactic Notation "efeed" constr(H) "using" tactic3(tac) := Tactic Notation "efeed" constr(H) "using" tactic3(tac) :=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment