diff options
| author | letouzey | 2006-02-27 12:10:03 +0000 |
|---|---|---|
| committer | letouzey | 2006-02-27 12:10:03 +0000 |
| commit | 9e4e390c440a359adaf83a934ae2594f62968e3e (patch) | |
| tree | eee3f34395aa5ece17f63a3fb07eccd2c8627788 /theories/Init | |
| parent | 7499754463892397bc4e9894ad514bea46f2d3ef (diff) | |
quelques raccourcis commodes + un f_equal plus efficace
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@8100 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'theories/Init')
| -rw-r--r-- | theories/Init/Tactics.v | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/theories/Init/Tactics.v b/theories/Init/Tactics.v index f221aa8b42..d8590e4b59 100644 --- a/theories/Init/Tactics.v +++ b/theories/Init/Tactics.v @@ -13,6 +13,42 @@ Require Import Logic. (** Useful tactics *) +(* A shorter name for generalize + clear, can be seen as an anti-intro *) + +Ltac revert H := generalize H; clear H. + +(* to contradict an hypothesis without copying its type. *) + +Ltac absurd_hyp h := + let T := type of h in + absurd T. + +(* Transforming a negative goal [ H:~A |- ~B ] into a positive one [ B |- A ]*) + +Ltac swap H := intro; apply H; clear H. + +(* A case with no loss of information. *) + +Ltac case_eq x := generalize (refl_equal x); pattern x at -1; case x. + +(* A tactic for easing the use of lemmas f_equal, f_equal2, ... *) + +Ltac f_equal := + let cg := try congruence in + let r := try reflexivity in + match goal with + | |- ?f ?a = ?f' ?a' => cut (a=a'); [cg|r] + | |- ?f ?a ?b = ?f' ?a' ?b' => + cut (b=b');[cut (a=a');[cg|r]|r] + | |- ?f ?a ?b ?c = ?f' ?a' ?b' ?c'=> + cut (c=c');[cut (b=b');[cut (a=a');[cg|r]|r]|r] + | |- ?f ?a ?b ?c ?d= ?f' ?a' ?b' ?c' ?d'=> + cut (d=d');[cut (c=c');[cut (b=b');[cut (a=a');[cg|r]|r]|r]|r] + | |- ?f ?a ?b ?c ?d ?e= ?f' ?a' ?b' ?c' ?d' ?e'=> + cut (e=e');[cut (d=d');[cut (c=c');[cut (b=b');[cut (a=a');[cg|r]|r]|r]|r]|r] + | _ => idtac + end. + (* Rewriting in all hypothesis. *) Ltac rewrite_all Eq := match type of Eq with @@ -34,25 +70,3 @@ Ltac rewrite_all_rev Eq := match type of Eq with end. Tactic Notation "rewrite_all" "<-" constr(H) := rewrite_all_rev H. - -(* A case with no loss of information. *) - -Ltac case_eq x := generalize (refl_equal x); pattern x at -1; case x. - -(* A tactic for easing the use of lemmas f_equal, f_equal2, ... *) - -Ltac f_equal := - let des := destruct 1 || intro in - let r := try reflexivity in - match goal with - | |- ?f ?a = ?f' ?a' => cut (a=a'); [des; r|r] - | |- ?f ?a ?b = ?f' ?a' ?b' => - cut (b=b');[cut (a=a');[do 2 des; r|r]|r] - | |- ?f ?a ?b ?c = ?f' ?a' ?b' ?c'=> - cut (c=c');[cut (b=b');[cut (a=a');[do 3 des; r|r]|r]|r] - | |- ?f ?a ?b ?c ?d= ?f' ?a' ?b' ?c' ?d'=> - cut (d=d');[cut (c=c');[cut (b=b');[cut (a=a');[do 4 des; r|r]|r]|r]|r] - | |- ?f ?a ?b ?c ?d ?e= ?f' ?a' ?b' ?c' ?d' ?e'=> - cut (e=e');[cut (d=d');[cut (c=c');[cut (b=b');[cut (a=a');[do 5 des; r|r]|r]|r]|r]|r] - | _ => idtac - end. |
