| 1 |
Set Implicit Arguments. |
| 2 |
|
| 3 |
Definition err : Type := unit. |
| 4 |
|
| 5 |
Inductive res (A: Type) : Type := |
| 6 |
| OK: A -> res A |
| 7 |
| Error: err -> res A. |
| 8 |
|
| 9 |
Arguments Error [A]. |
| 10 |
|
| 11 |
Set Printing Universes. |
| 12 |
|
| 13 |
Section FOO. |
| 14 |
|
| 15 |
Inductive ftyp : Type := |
| 16 |
| Funit : ftyp |
| 17 |
| Ffun : list ftyp -> ftyp |
| 18 |
| Fref : area -> ftyp |
| 19 |
with area : Type := |
| 20 |
| Stored : ftyp -> area |
| 21 |
. |
| 22 |
|
| 23 |
Print ftyp. |
| 24 |
(* yields: |
| 25 |
Inductive ftyp : Type (* Top.27429 *) := |
| 26 |
Funit : ftyp | Ffun : list ftyp -> ftyp | Fref : area -> ftyp |
| 27 |
with area : Type (* Set *) := Stored : ftyp -> area |
| 28 |
*) |
| 29 |
|
| 30 |
Fixpoint tc_wf_type (ftype: ftyp) {struct ftype}: res unit := |
| 31 |
match ftype with |
| 32 |
| Funit => OK tt |
| 33 |
| Ffun args => |
| 34 |
((fix tc_wf_types (ftypes: list ftyp){struct ftypes}: res unit := |
| 35 |
match ftypes with |
| 36 |
| nil => OK tt |
| 37 |
| cons t ts => |
| 38 |
match tc_wf_type t with |
| 39 |
| OK tt => tc_wf_types ts |
| 40 |
| Error m => Error m |
| 41 |
end |
| 42 |
end) args) |
| 43 |
| Fref a => tc_wf_area a |
| 44 |
end |
| 45 |
with tc_wf_area (ar:area): res unit := |
| 46 |
match ar with |
| 47 |
| Stored c => tc_wf_type c |
| 48 |
end. |
| 49 |
|
| 50 |
End FOO. |
| 51 |
|
| 52 |
Print ftyp. |
| 53 |
(* yields: |
| 54 |
Inductive ftyp : Type (* Top.27465 *) := |
| 55 |
Funit : ftyp | Ffun : list ftyp -> ftyp | Fref : area -> ftyp |
| 56 |
with area : Set := Stored : ftyp -> area |
| 57 |
*) |
| 58 |
|
| 59 |
Fixpoint tc_wf_type' (ftype: ftyp) {struct ftype}: res unit := |
| 60 |
match ftype with |
| 61 |
| Funit => OK tt |
| 62 |
| Ffun args => |
| 63 |
((fix tc_wf_types (ftypes: list ftyp){struct ftypes}: res unit := |
| 64 |
match ftypes with |
| 65 |
| nil => OK tt |
| 66 |
| cons t ts => |
| 67 |
match tc_wf_type' t with |
| 68 |
| OK tt => tc_wf_types ts |
| 69 |
| Error m => Error m |
| 70 |
end |
| 71 |
end) args) |
| 72 |
| Fref a => tc_wf_area' a |
| 73 |
end |
| 74 |
with tc_wf_area' (ar:area): res unit := |
| 75 |
match ar with |
| 76 |
| Stored c => tc_wf_type' c |
| 77 |
end. |
| 78 |
|
| 79 |
(* yields: |
| 80 |
Error: |
| 81 |
Incorrect elimination of "ar" in the inductive type "area": |
| 82 |
the return type has sort "Type (* max(Set, Top.27424) *)" while it |
| 83 |
should be "Prop" or "Set". |
| 84 |
Elimination of an inductive object of sort Set |
| 85 |
is not allowed on a predicate in sort Type |
| 86 |
because strong elimination on non-small inductive types leads to paradoxes. |
| 87 |
*) |