blob: 6207e2c6927cda25d09872e56ad5895a8c53bde1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
(*i $Id$ i*)
Require Import Notations.
Require Import Logic.
(** Useful tactics *)
(* Rewriting in all hypothesis. *)
Ltac rewrite_all Eq := match type of Eq with
?a = ?b =>
generalize Eq; clear Eq;
match goal with
| H : context [a] |- _ => intro Eq; rewrite Eq in H; rewrite_all Eq
| _ => intro Eq; try rewrite Eq
end
end.
Ltac rewrite_all_rev Eq := match type of Eq with
?a = ?b =>
generalize Eq; clear Eq;
match goal with
| H : context [b] |- _ => intro Eq; rewrite <- Eq in H; rewrite_all_rev Eq
| _ => intro Eq; try rewrite <- Eq
end
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
| |- ?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.
|