| 1 |
Require Import Corelib.Setoids.Setoid. |
| 2 |
Require Import Ltac2.Ltac2. |
| 3 |
|
| 4 |
Axiom f: nat -> nat. |
| 5 |
Definition g := f. |
| 6 |
|
| 7 |
Axiom Foo1: nat -> Prop. |
| 8 |
Axiom Foo2: nat -> Prop. |
| 9 |
Axiom Impl: forall n: nat, Foo1 (f n) -> Foo2 (f n). |
| 10 |
|
| 11 |
Create HintDb foo discriminated. |
| 12 |
#[export] Hint Constants Opaque : foo. |
| 13 |
#[export] Hint Resolve Impl : foo. |
| 14 |
|
| 15 |
Goal forall x, Foo1 (f x) -> Foo2 (g x). |
| 16 |
Proof. |
| 17 |
auto with foo. |
| 18 |
#[export] Hint Transparent g : foo. |
| 19 |
auto with foo. |
| 20 |
Qed. |
| 21 |
|
| 22 |
Goal forall (x: nat), exists y, f x = g y. |
| 23 |
Proof. |
| 24 |
intros. |
| 25 |
eexists. |
| 26 |
unify f g. |
| 27 |
lazy_match! goal with |
| 28 |
| [ |- ?a ?b = ?rhs ] => unify ($a $b) $rhs |
| 29 |
end. |
| 30 |
Abort. |
| 31 |
|
| 32 |
Goal forall (x: nat), exists y, f x = g y. |
| 33 |
Proof. |
| 34 |
intros. |
| 35 |
eexists. |
| 36 |
Unification.unify TransparentState.full 'f 'g. |
| 37 |
lazy_match! goal with |
| 38 |
| [ |- ?a ?b = ?rhs ] => Unification.unify_with_full_ts '($a $b) rhs |
| 39 |
end. |
| 40 |
Abort. |
| 41 |
|
| 42 |
Goal True. |
| 43 |
Proof. |
| 44 |
Fail Unification.unify TransparentState.empty '(1 + 1) '2. |
| 45 |
Unification.unify TransparentState.full '(1 + 1) '2. |
| 46 |
Unification.unify (TransparentState.current ()) '(1 + 1) '2. |
| 47 |
Opaque Nat.add. |
| 48 |
Fail Unification.unify (TransparentState.current ()) '(1 + 1) '2. |
| 49 |
Succeed Unification.unify TransparentState.full '(1 + 1) '2. |
| 50 |
exact I. |
| 51 |
Qed. |
| 52 |
|
| 53 |
|
| 54 |
(* Test that by clause of assert doesn't eat all semicolons: |
| 55 |
https://github.com/rocq-prover/rocq/issues/17491 *) |
| 56 |
Goal forall (a: nat), a = a. |
| 57 |
Proof. |
| 58 |
intros. |
| 59 |
assert (a = a) by Std.reflexivity (); |
| 60 |
assumption. |
| 61 |
Qed. |
| 62 |
|
| 63 |
(* Test that notations in by clause still work: *) |
| 64 |
Goal forall (a: nat), a = a. |
| 65 |
Proof. |
| 66 |
intros. |
| 67 |
assert (a = a) by exact eq_refl; |
| 68 |
assumption. |
| 69 |
Qed. |
| 70 |
|
| 71 |
Goal forall x, (forall (y : unit), y = x) -> forall (x: unit), x = x. |
| 72 |
Proof. |
| 73 |
intros x H y. |
| 74 |
rewrite -> H at 1 2. |
| 75 |
reflexivity. |
| 76 |
Qed. |
| 77 |
|
| 78 |
Goal forall x, (forall (y : unit), x = y) -> forall (x: unit), x = x. |
| 79 |
Proof. |
| 80 |
intros x H y. |
| 81 |
rewrite <- H at 1 2. |
| 82 |
reflexivity. |
| 83 |
Qed. |
| 84 |
|
| 85 |
Goal forall x, (forall y : unit, y = x) -> forall y : unit, y = y. |
| 86 |
Proof. |
| 87 |
intros x H y. |
| 88 |
setoid_rewrite H at 1 2. |
| 89 |
setoid_rewrite <- (H y) at 1 2. |
| 90 |
setoid_rewrite H. |
| 91 |
reflexivity. |
| 92 |
Qed. |
| 93 |
|
| 94 |
Axiom x : unit. |
| 95 |
Axiom H : forall y : unit, y = x. |
| 96 |
Goal forall y : unit, y = y. |
| 97 |
Proof. |
| 98 |
assert (H2 : tt = x). |
| 99 |
{ setoid_rewrite H with (y := tt). |
| 100 |
reflexivity. } |
| 101 |
setoid_rewrite H with (y := tt) at 1 in H2. |
| 102 |
intros y. |
| 103 |
setoid_rewrite H with (y := y) at 1. |
| 104 |
setoid_rewrite H with (y := y) at 1. |
| 105 |
reflexivity. |
| 106 |
Qed. |
| 107 |
|
| 108 |
|
| 109 |
(* view intro patterns *) |
| 110 |
Axiom lem : forall x:nat, bool -> x = x. |
| 111 |
|
| 112 |
Axiom lem' : 3 = 3 -> False. |
| 113 |
|
| 114 |
Goal bool -> 2 = 2. |
| 115 |
Proof. |
| 116 |
Fail intros a%lem. |
| 117 |
eintros a%lem. |
| 118 |
revert a. |
| 119 |
intros b%lem'. |
| 120 |
destruct b. |
| 121 |
Qed. |
| 122 |
|
| 123 |
(* assert interns and typechecks the type as a type |
| 124 |
(bug #15094) *) |
| 125 |
|
| 126 |
Inductive my_type := |
| 127 |
| my_el : my_type. |
| 128 |
|
| 129 |
Definition my_coercion (_ : my_type) := True. |
| 130 |
|
| 131 |
Coercion my_coercion : my_type >-> Sortclass. |
| 132 |
|
| 133 |
Goal False. |
| 134 |
Proof. |
| 135 |
(* expected type is sortclass -> coercion inserted *) |
| 136 |
assert my_el by exact I. |
| 137 |
|
| 138 |
(* interned as with type scope locally open *) |
| 139 |
assert (H' : nat * (0 * 0 = 0)) by (split; first [exact 0 | reflexivity]). |
| 140 |
Abort. |
| 141 |
|
| 142 |
Goal nat. |
| 143 |
Proof. |
| 144 |
Std.apply true false [fun () => Control.plus (fun () => 'I) (fun _ => '0), Std.NoBindings] None. |
| 145 |
Qed. |
| 146 |
|
| 147 |
(* eassumption *) |
| 148 |
Goal forall (x : nat) y z, x = y -> y = z -> x = z. |
| 149 |
Proof. |
| 150 |
intros **. |
| 151 |
etransitivity; eassumption. |
| 152 |
Qed. |
| 153 |
|
| 154 |
(* cycle *) |
| 155 |
Goal nat * bool. |
| 156 |
Proof. |
| 157 |
split. |
| 158 |
all: cycle 1. |
| 159 |
- exact true. |
| 160 |
- exact 0. |
| 161 |
Qed. |
| 162 |
|
| 163 |
(* focus *) |
| 164 |
Goal bool * nat * nat. |
| 165 |
Proof. |
| 166 |
repeat split. |
| 167 |
all: Control.focus 2 3 (fun () => exact 0). |
| 168 |
exact true. |
| 169 |
Qed. |
| 170 |
|
| 171 |
(* exfalso *) |
| 172 |
Goal False -> nat * nat. |
| 173 |
Proof. |
| 174 |
intros oops. |
| 175 |
split. |
| 176 |
all: exfalso; assumption. |
| 177 |
Qed. |