| 1 |
From elpi.apps Require Import eltac.rewrite. |
| 2 |
|
| 3 |
Axiom add_comm : forall x y, x + y = y + x. |
| 4 |
Axiom mul_comm : forall x y, x * y = y * x. |
| 5 |
|
| 6 |
Goal (forall x : nat, 1 + x = x + 1) -> |
| 7 |
forall y, 2 * ((y+y) + 1) = ((y + y)+1) * 2. |
| 8 |
Proof. |
| 9 |
intro H. |
| 10 |
intro x. |
| 11 |
eltac.rewrite H. |
| 12 |
eltac.rewrite mul_comm. |
| 13 |
exact eq_refl. |
| 14 |
Defined. |
| 15 |
|
| 16 |
Section Example_rewrite. |
| 17 |
Variable A : Type. |
| 18 |
Variable B : A -> Type. |
| 19 |
Variable C : forall (a : A) (b : B a), Type. |
| 20 |
Variable add : forall {a : A} {b : B a}, C a b -> C a b -> C a b. |
| 21 |
Variable sym : forall {a : A} {b : B a} (c c' : C a b), add c c' = add c' c. |
| 22 |
|
| 23 |
Goal forall (a : A) (b : B a) (x y : C a b), |
| 24 |
add x y = add y x /\ add x y = add y x. |
| 25 |
Proof. |
| 26 |
intros a b x y. |
| 27 |
eltac.rewrite @sym. (* @sym is a gref *) |
| 28 |
(** [add y x = add y x /\ add y x = add y x] *) |
| 29 |
easy. |
| 30 |
Defined. |
| 31 |
|
| 32 |
Goal forall (a : A) (b : B a) (x y : C a b), |
| 33 |
add x y = add y x /\ add x y = add y x. |
| 34 |
Proof. |
| 35 |
intros a b x y. |
| 36 |
eltac.rewrite sym. (* because of implicit arguments, this is sym _ _, which is a term *) |
| 37 |
easy. |
| 38 |
Defined. |
| 39 |
|
| 40 |
Goal forall n, 2 * n = n * 2. |
| 41 |
Proof. |
| 42 |
intro n. |
| 43 |
Fail eltac.rewrite add_comm. |
| 44 |
eltac.rewrite add_comm "strong". |
| 45 |
Abort. |
| 46 |
|
| 47 |
End Example_rewrite. |