Debian Codegraph @

test-suite/ltac2/example2.v

raw
1 Require Import Ltac2.Ltac2.
2
3 Import Ltac2.Notations.
4
5 Set Default Goal Selector "all".
6
7 Goal exists n, n = 0.
8 Proof.
9 split with (x := 0).
10 reflexivity.
11 Qed.
12
13 Goal exists n, n = 0.
14 Proof.
15 split with 0.
16 split.
17 Qed.
18
19 Goal exists n, n = 0.
20 Proof.
21 let myvar := Std.NamedHyp @x in split with ($myvar := 0).
22 split.
23 Qed.
24
25 Goal (forall n : nat, n = 0 -> False) -> True.
26 Proof.
27 intros H.
28 eelim &H.
29 split.
30 Qed.
31
32 Goal (forall n : nat, n = 0 -> False) -> True.
33 Proof.
34 intros H.
35 elim &H with 0.
36 split.
37 Qed.
38
39 Goal forall (P : nat -> Prop), (forall n m, n = m -> P n) -> P 0.
40 Proof.
41 intros P H.
42 Fail apply &H.
43 apply &H with (m := 0).
44 split.
45 Qed.
46
47 Goal forall (P : nat -> Prop), (forall n m, n = m -> P n) -> (0 = 1) -> P 0.
48 Proof.
49 intros P H e.
50 apply &H with (m := 1) in e.
51 exact e.
52 Qed.
53
54 Goal forall (P : nat -> Prop), (forall n m, n = m -> P n) -> P 0.
55 Proof.
56 intros P H.
57 eapply &H.
58 split.
59 Qed.
60
61 Goal exists n, n = 0.
62 Proof.
63 Fail constructor 1.
64 constructor 1 with (x := 0).
65 split.
66 Qed.
67
68 Goal exists n, n = 0.
69 Proof.
70 econstructor 1.
71 split.
72 Qed.
73
74 Goal forall n, 0 + n = n.
75 Proof.
76 intros n.
77 induction &n as [|n] using nat_rect; split.
78 Qed.
79
80 Goal forall n, 0 + n = n.
81 Proof.
82 intros n.
83 let n := @X in
84 let q := Std.NamedHyp @P in
85 induction &n as [|$n] using nat_rect with ($q := fun m => 0 + m = m); split.
86 Qed.
87
88 Goal forall n, 0 + n = n.
89 Proof.
90 intros n.
91 destruct &n as [|n] using nat_rect; split.
92 Qed.
93
94 Goal forall n, 0 + n = n.
95 Proof.
96 intros n.
97 let n := @X in
98 let q := Std.NamedHyp @P in
99 destruct &n as [|$n] using nat_rect with ($q := fun m => 0 + m = m); split.
100 Qed.
101
102 Goal forall b1 b2, andb b1 b2 = andb b2 b1.
103 Proof.
104 intros b1 b2.
105 destruct &b1 as [|], &b2 as [|]; split.
106 Qed.
107
108 Goal forall n m, n = 0 -> n + m = m.
109 Proof.
110 intros n m Hn.
111 rewrite &Hn; split.
112 Qed.
113
114 Goal forall n m p, n = m -> p = m -> 0 = n -> p = 0.
115 Proof.
116 intros n m p He He' Hn.
117 rewrite &He, <- &He' in Hn.
118 rewrite &Hn.
119 split.
120 Qed.
121
122 Goal forall n m, (m = n -> n = m) -> m = n -> n = 0 -> m = 0.
123 Proof.
124 intros n m He He' He''.
125 rewrite <- &He by assumption.
126 Control.refine (fun () => &He'').
127 Qed.
128
129 Goal forall n (r := if true then n else 0), r = n.
130 Proof.
131 intros n r.
132 hnf in r.
133 split.
134 Qed.
135
136 Goal 1 = 0 -> 0 = 0.
137 Proof.
138 intros H.
139 pattern 0 at 1.
140 let occ := 2 in pattern 1 at 1, 0 at $occ in H.
141 reflexivity.
142 Qed.
143
144 Goal 1 + 1 = 2.
145 Proof.
146 vm_compute.
147 reflexivity.
148 Qed.
149
150 Goal 1 + 1 = 2.
151 Proof.
152 native_compute.
153 reflexivity.
154 Qed.
155
156 Goal 1 + 1 = 2 - 0 -> True.
157 Proof.
158 intros H.
159 vm_compute plus in H.
160 reflexivity.
161 Qed.
162
163 Goal 1 = 0 -> True /\ True.
164 Proof.
165 intros H.
166 split; fold (1 + 0) (1 + 0) in H.
167 reflexivity.
168 Qed.
169
170 Goal 1 + 1 = 2.
171 Proof.
172 cbv [ Nat.add ].
173 reflexivity.
174 Qed.
175
176 Goal 1 + 1 = 2.
177 Proof.
178 let x := reference:(Nat.add) in
179 cbn beta iota delta [ $x ].
180 reflexivity.
181 Qed.
182
183 Goal 1 + 1 = 2.
184 Proof.
185 simpl beta.
186 reflexivity.
187 Qed.
188
189 Goal 1 + 1 = 2.
190 Proof.
191 lazy.
192 reflexivity.
193 Qed.
194
195 Goal let x := 1 + 1 - 1 in x = x.
196 Proof.
197 intros x.
198 unfold &x at 1.
199 let x := reference:(Nat.sub) in unfold Nat.add, $x in x.
200 reflexivity.
201 Qed.
202
203 Goal exists x y : nat, x = y.
204 Proof.
205 exists 0, 0; reflexivity.
206 Qed.
207
208 Goal exists x y : nat, x = y.
209 Proof.
210 eexists _, 0; reflexivity.
211 Qed.
212
213 Goal exists x y : nat, x = y.
214 Proof.
215 refine '(let x := 0 in _).
216 eexists; exists &x; reflexivity.
217 Qed.
218
219 Goal True.
220 Proof.
221 pose (X := True).
222 constructor.
223 Qed.
224
225 Goal True.
226 Proof.
227 pose True as X.
228 constructor.
229 Qed.
230
231 Goal True.
232 Proof.
233 let x := @foo in
234 set ($x := True) in * |-.
235 constructor.
236 Qed.
237
238 Goal 0 = 0.
239 Proof.
240 remember 0 as n eqn: foo at 1.
241 rewrite foo.
242 reflexivity.
243 Qed.
244
245 Goal True.
246 Proof.
247 assert (H := 0 + 0).
248 constructor.
249 Qed.
250
251 Goal True.
252 Proof.
253 assert (exists n, n = 0) as [n Hn].
254 + exists 0; reflexivity.
255 + exact I.
256 Qed.
257
258 Goal True -> True.
259 Proof.
260 assert (H : 0 + 0 = 0) by reflexivity.
261 intros x; exact x.
262 Qed.
263
264 Goal True.
265 Proof.
266 enough (H := 0 + 0).
267 constructor.
268 Qed.
269
270 Goal True.
271 Proof.
272 enough (exists n, n = 0) as [n Hn].
273 + exact I.
274 + exists 0; reflexivity.
275 Qed.
276
277 Goal True -> True.
278 Proof.
279 enough (H : 0 + 0 = 0) by (intros x; exact x).
280 reflexivity.
281 Qed.
282
283 Goal 1 + 1 = 2.
284 Proof.
285 change (?a + 1 = 2) with (2 = $a + 1).
286 reflexivity.
287 Qed.
288
289 Goal (forall n, n = 0 -> False) -> False.
290 Proof.
291 intros H.
292 specialize (H 0 eq_refl).
293 destruct H.
294 Qed.
295
296 Goal (forall n, n = 0 -> False) -> False.
297 Proof.
298 intros H.
299 specialize (H 0 eq_refl) as [].
300 Qed.