Debian Codegraph @

test-suite/output/nested_eliminators.v

raw
1 (* Some prelude to be able to test the file without being able to compile the prelude *)
2
3 Notation "A -> B" := (forall (_ : A), B) (right associativity, at level 99).
4
5 Inductive nat : Type :=
6 | zero : nat
7 | S : nat -> nat.
8
9 Inductive bool : Type :=
10 | true : bool
11 | false : bool.
12
13 (* The type unit needs to be defined and registered to instantiate partial nesting. *)
14 Inductive unit : Set :=
15 tt : unit.
16
17 Register unit as core.unit.type.
18 Register tt as core.unit.tt.
19
20 Set Printing Universes.
21
22 Module Template.
23
24 (* Example with Template Inductive Types *)
25
26 Set Depth Scheme All 2.
27
28 Inductive True := c.
29
30 Fail Check True_all.
31
32 (* Example with list *)
33 Inductive list (A : Type) : Type :=
34 | nil : list A
35 | cons : A -> list A -> list A.
36
37 Print list_all.
38 About list_all_forall.
39 Print list_all_all.
40 About list_all_all_forall.
41
42 Arguments nil {_}.
43 Arguments cons {_}.
44
45 Inductive MRT : Set :=
46 | MRTnode : list MRT -> MRT.
47
48 About MRT_ind.
49
50 Inductive RoseTree A : Type :=
51 | RTleaf (a : A) : RoseTree A
52 | RTnode (l : list (RoseTree A)) : RoseTree A.
53
54 About RoseTree_ind.
55 Print RoseTree_all.
56 About RoseTree_all_forall.
57
58 Inductive RoseTreeMut A :=
59 | node_mut : forest A -> RoseTreeMut A
60 with forest A :=
61 | forest_nil : forest A
62 | forest_cons : A -> RoseTreeMut A -> forest A.
63
64 Print RoseTreeMut_all.
65 About RoseTreeMut_all_forall.
66 Print RoseTreeMut_all_all.
67 About RoseTreeMut_all_all_forall.
68
69 Print forest_all.
70 About forest_all_forall.
71 Print forest_all_all.
72 About forest_all_all_forall.
73
74 Inductive RoseRoseTree A : Type :=
75 | Nleaf (a : A) : RoseRoseTree A
76 | Nnode (p : (list (list (RoseRoseTree A)))) : RoseRoseTree A.
77
78 About RoseRoseTree_ind.
79 Print RoseRoseTree_all.
80 About RoseRoseTree_all_forall.
81
82 Inductive ArrowTree1 A : Type :=
83 | ATleaf1 (a : A) : ArrowTree1 A
84 | ATnode1 (l : (bool -> list (ArrowTree1 A))) : ArrowTree1 A.
85
86 About ArrowTree1_ind.
87 Print ArrowTree1_all.
88 About ArrowTree1_all_forall.
89
90 Inductive ArrowTree2 A : Type :=
91 | ATleaf2 (a : A) : ArrowTree2 A
92 | ATnode2 (l : list (nat -> ArrowTree2 A)) : ArrowTree2 A.
93
94 About ArrowTree2_ind.
95 Print ArrowTree2_all.
96 About ArrowTree2_all_forall.
97
98 Inductive ArrowTree3 A : Type :=
99 | ATleaf3 (a : A) : ArrowTree3 A
100 | ATnode3 (l : (bool -> list (nat -> ArrowTree3 A))) : ArrowTree3 A.
101
102 About ArrowTree3_ind.
103 Print ArrowTree3_all.
104 About ArrowTree3_all_forall.
105
106
107 (* Example Prod *)
108 Inductive prod (A B : Type) : Type :=
109 pair : A -> B -> prod A B.
110
111 Print prod_all.
112 About prod_all_forall.
113 Print prod_all_all.
114 About prod_all_all_forall.
115
116 Arguments pair {_ _}.
117
118 Inductive PairTree A : Type :=
119 | Pleaf (a : A) : PairTree A
120 | Pnode (p : prod (PairTree A) (PairTree A)) : PairTree A.
121
122 About PairTree_ind.
123 Print PairTree_all.
124 About PairTree_all_forall.
125
126 Module AutoGeneratedScheme.
127
128 Inductive LeftTree A : Type :=
129 | Lleaf (a : A) : LeftTree A
130 | Lnode (p : prod (LeftTree A) nat) : LeftTree A.
131
132 About LeftTree_ind.
133 Print LeftTree_all.
134 About LeftTree_all_forall.
135
136 End AutoGeneratedScheme.
137
138 Module Scheme.
139
140 Unset Elimination Schemes.
141
142 Inductive LeftTree A : Type :=
143 | Lleaf (a : A) : LeftTree A
144 | Lnode (p : prod (LeftTree A) nat) : LeftTree A.
145
146 Scheme Induction for LeftTree Sort Prop.
147
148 About LeftTree_ind.
149 Print LeftTree_all.
150 About LeftTree_all_forall.
151
152 End Scheme.
153
154 Module PartialAll.
155
156 Scheme All for prod over A.
157 Print prod_all_10.
158 About prod_all_forall_10.
159 Print prod_all_10_all.
160 About prod_all_10_all_forall.
161
162 Inductive LeftTree A : Type :=
163 | Lleaf (a : A) : LeftTree A
164 | Lnode (p : prod (LeftTree A) nat) : LeftTree A.
165
166 About LeftTree_ind.
167 Print LeftTree_all.
168 About LeftTree_all_forall.
169
170 End PartialAll.
171
172 Inductive RightTree A : Type :=
173 | Rleaf (a : A) : RightTree A
174 | Rnode (p : prod nat (RightTree A)) : RightTree A.
175
176 About RightTree_ind.
177 Print RightTree_all.
178 About RightTree_all_forall.
179
180
181 (* Nesting with vec *)
182 Inductive vec A : nat -> Type :=
183 | vnil : vec A zero
184 | vcons : A -> forall n, vec A n -> vec A (S n).
185
186 Print vec_all.
187 About vec_all_forall.
188 Print vec_all_all.
189 About vec_all_all_forall.
190
191 Inductive VecTree A : Type :=
192 | VNleaf (a : A) : VecTree A
193 | VNnode n (p : vec (VecTree A) n) : VecTree A.
194
195 About VecTree_ind.
196 Print VecTree_all.
197 About VecTree_all_forall.
198
199
200
201 (* Example All2i *)
202 Inductive All2i (A B : Type) (R : nat -> A -> B -> Type) (n : nat) : list A -> list B -> Type :=
203 | All2i_nil : All2i A B R n nil nil
204 | All2i_cons : forall (a : A) (b : B) (lA : list A) (lB : list B),
205 R n a b -> All2i A B R (S n) lA lB -> All2i A B R n (cons a lA) (cons b lB).
206
207 Print All2i_all.
208 About All2i_all_forall.
209 Print All2i_all_all.
210 About All2i_all_all_forall.
211
212 Fail Scheme All for All2i over A.
213
214 Inductive typing A B (n : nat) (a : A) (b : B) : Type :=
215 | typ_nil : typing A B n a b
216 | typ_cons : forall (lA : list A) (lB : list B),
217 All2i A B (fun n => typing A B n) n lA lB -> typing A B n a b.
218
219 About typing_ind.
220
221
222 (* Example All2i_bis_bis with trivial nesting on R *)
223 Inductive All2i_bis (A B C : Type) (R : nat -> A -> B -> Type) (n : nat) : list A -> list B -> Type :=
224 | All2i_bis_nil : C -> All2i_bis A B C R n nil nil
225 | All2i_bis_cons : forall (a : A) (b : B) (lA : list A) (lB : list B),
226 R n a b -> All2i_bis A B C R (S n) lA lB -> All2i_bis A B C R n (cons a lA) (cons b lB).
227
228 Print All2i_bis_all.
229 About All2i_bis_all_forall.
230 Print All2i_bis_all_all.
231 About All2i_bis_all_all_forall.
232
233 Inductive triv_All2_bis : Type :=
234 | ctriv_All2_bis : All2i_bis bool bool triv_All2_bis (fun _ _ _ => nat) zero (@nil bool) (@nil bool) ->
235 triv_All2_bis.
236
237 About triv_All2_bis_ind.
238
239
240 (* sig *)
241 Inductive sig (A : Type) (P : A -> Prop) : Type :=
242 | exist : forall x : A, P x -> sig A P.
243
244 Print sig_all.
245 About sig_all_forall.
246
247 Scheme All for sig over A.
248 Print sig_all_10.
249 About sig_all_forall_10.
250
251 Scheme All for sig over P.
252 Print sig_all_01.
253 About sig_all_forall_01.
254
255
256 (* Test collapse above prop *)
257 Inductive and (A B : Prop) : Prop :=
258 | conj : A -> B -> and A B.
259
260 Inductive or (A B : Prop) : Prop :=
261 | or_introl : A -> or A B
262 | or_intror : B -> or A B.
263
264 Inductive NestRel A (R : A -> A -> Prop) :=
265 | mkR : forall x, or (and (R x x) (R x x)) True -> NestRel A R.
266
267 Print NestRel_all.
268 About NestRel_all_forall.
269
270
271 (* Test Primtive Projections *)
272 Module PrimRecord.
273
274 Set Primitive Projections.
275
276 Inductive X (U:Type) := { b : U }.
277
278 Fail Scheme All for X.
279
280 End PrimRecord.
281
282
283 (* Test Deeply Nested + variable binding *)
284 Inductive ex (A:Type) (P:A -> Prop) : Prop :=
285 ex_intro : forall x:A, P x -> ex A P.
286
287 Print ex_all.
288 About ex_all_forall.
289
290 Record language := Language {
291 expr : Type;
292 prim_step : expr -> Prop;
293 }.
294
295 Inductive adequate L (φ : unit -> Type) :=
296 | cadequate : prod False (ex (expr L) (fun e2 => prim_step L e2)) -> adequate L φ.
297
298 About adequate_ind.
299 About adequate_all.
300
301 (* ISSUE 21710 *)
302 Inductive casenat (P : nat -> Set) : Set :=
303 | casenat_fold : (forall m, P m) -> casenat P.
304
305 About casenat_all.
306
307 Inductive casenat' (A : nat -> Set) (PZ : Set) (PS : forall n, A n -> Set) : Set :=
308 | casenat'_fold : (forall m a, PS m a) -> casenat' A PZ PS.
309
310 About casenat'_all.
311
312 End Template.
313
314
315 Module UnivPoly.
316
317 (* Example with Template Inductive Types *)
318
319 Set Universe Polymorphism.
320
321 Set Depth Scheme All 2.
322
323 Inductive True := c.
324
325 Fail Check True_all.
326
327 (* Example with list *)
328 Inductive list (A : Type) : Type :=
329 | nil : list A
330 | cons : A -> list A -> list A.
331
332 Print list_all.
333 About list_all_forall.
334 Print list_all_all.
335 About list_all_all_forall.
336
337 Inductive MRT : Set :=
338 | MRTnode : list MRT -> MRT.
339
340 About MRT_ind.
341
342 Inductive RoseTree A : Type :=
343 | RTleaf (a : A) : RoseTree A
344 | RTnode (l : list (RoseTree A)) : RoseTree A.
345
346 About RoseTree_ind.
347 Print RoseTree_all.
348 About RoseTree_all_forall.
349
350 Inductive RoseRoseTree A : Type :=
351 | Nleaf (a : A) : RoseRoseTree A
352 | Nnode (p : (list (list (RoseRoseTree A)))) : RoseRoseTree A.
353
354 About RoseRoseTree_ind.
355 Print RoseRoseTree_all.
356 About RoseRoseTree_all_forall.
357
358 Inductive ArrowTree3 A : Type :=
359 | ATleaf3 (a : A) : ArrowTree3 A
360 | ATnode3 (l : (bool -> list (nat -> ArrowTree3 A))) : ArrowTree3 A.
361
362 About ArrowTree3_ind.
363 Print ArrowTree3_all.
364 About ArrowTree3_all_forall.
365
366 End UnivPoly.
367
368
369 Module SortPoly.
370
371 (* Example with a sort polymorphic containers *)
372 Set Universe Polymorphism.
373
374 Inductive list@{sA;uA uR} (A : Type@{sA;uA}) : Type@{sA; uR} :=
375 | nil : list A
376 | cons : A -> list A -> list A.
377
378 Scheme All for list.
379 Print list_all.
380 About list_all_forall.
381
382 Scheme All for list_all.
383 Print list_all_all.
384 About list_all_all_forall.
385
386 Inductive MRT : Set :=
387 | MRTnode : list MRT -> MRT.
388
389 About MRT_ind.
390
391 Inductive SRT : SProp :=
392 | SRTnode : list SRT -> SRT.
393
394 About SRT_sind.
395
396 End SortPoly.
397
398
399
400 Module TestWarning.
401
402 Set Warnings "+register-all".
403
404 Inductive list (A : Type) : Type :=
405 | nil : list A
406 | cons : A -> list A -> list A.
407
408 Fail Inductive MRT : Set :=
409 | MRTnode : list MRT -> MRT.
410
411 Set Warnings "-register-all".
412
413 Inductive MRT : Set :=
414 | MRTnode : list MRT -> MRT.
415
416 About MRT_ind.
417
418 End TestWarning.
419
420
421
422 Module DeepArities.
423 Definition P A := A -> Type.
424
425 Inductive Nester (X : unit -> P unit) : Type :=
426 | nester_intro : X tt tt -> Nester X.
427 Scheme All for Nester.
428
429 About Nester_all.
430 End DeepArities.