Debian Codegraph @

test-suite/success/sort_poly_elab.v

raw
1 Set Universe Polymorphism.
2
3 Inductive sum@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) : Type@{s;max(ul,ur)} :=
4 | inl : A -> sum A B
5 | inr : B -> sum A B.
6
7 Arguments inl {A B} _ , [A] B _.
8 Arguments inr {A B} _ , A [B] _.
9
10 (* Elimination constraint left explicitly empty. Definition fails because of missing constraint. *)
11 Fail Definition sum_elim@{sl sr s0 s0';ul ur v|}
12 (A : Type@{sl;ul}) (B : Type@{sr;ur}) (P : sum@{sl sr s0;ul ur} A B -> Type@{s0';v})
13 (fl : forall a, P (inl a)) (fr : forall b, P (inr b)) (x : sum@{sl sr s0;ul ur} A B) :=
14 match x with
15 | inl a => fl a
16 | inr b => fr b
17 end.
18 (* The command has indeed failed with message:
19 Elimination constraints are not implied by the ones declared: s0->s0' *)
20
21 (* Using + to elaborate missing constraints. Definition passes *)
22 Definition sum_elim@{sl sr s0 s0';ul ur v|+}
23 (A : Type@{sl;ul}) (B : Type@{sr;ur}) (P : sum@{sl sr s0;ul ur} A B -> Type@{s0';v})
24 (fl : forall a, P (inl a)) (fr : forall b, P (inr b)) (x : sum@{sl sr s0;ul ur} A B) :=
25 match x with
26 | inl a => fl a
27 | inr b => fr b
28 end.
29 (* sl sr s0 s0' ; ul ur v |= s0->s0' *)
30
31 Definition sum_sind := sum_elim@{Type Type Type SProp;_ _ _}.
32 Definition sum_rect := sum_elim@{Type Type Type Type;_ _ _}.
33 Definition sum_ind := sum_elim@{Type Type Type Prop;_ _ _}.
34
35 Definition or_ind := sum_elim@{Prop Prop Prop Prop;_ _ _}.
36 Definition or_sind := sum_elim@{Prop Prop Prop SProp;_ _ _}.
37 Fail Definition or_rect := sum_elim@{Prop Prop Prop Type;_ _ _}.
38 (* The command has indeed failed with message:
39 The quality constraints are inconsistent: cannot enforce Prop -> Type because it would identifyType and Prop which is inconsistent.
40 This is introduced by the constraints Type -> Prop *)
41
42 Definition sumor := sum@{Type Prop Type;_ _}.
43
44 Definition sumor_sind := sum_elim@{Type Prop Type SProp;_ _ _}.
45 Definition sumor_rect := sum_elim@{Type Prop Type Type;_ _ _}.
46 Definition sumor_ind := sum_elim@{Type Prop Type Prop;_ _ _}.
47
48 (* Implicit constraints are elaborated *)
49 Definition idT@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) (x : sum@{sl sr s;ul ur} A B)
50 : sum@{sl sr Type;ul ur} A B :=
51 match x return sum@{sl sr Type;ul ur} A B with
52 | inl a => inl a
53 | inr b => inr b
54 end.
55 (* sl sr s ; ul ur |= s->Type *)
56
57 (* Implicit constraints are elaborated *)
58 Definition idP@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) (x : sum@{sl sr s;ul ur} A B)
59 : sum@{sl sr Prop;ul ur} A B :=
60 match x return sum@{sl sr Prop;ul ur} A B with
61 | inl a => inl a
62 | inr b => inr b
63 end.
64 (* sl sr s ; ul ur |= s->Prop *)
65
66 (* Implicit constraints are elaborated *)
67 Definition idS@{sl sr s;ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) (x : sum@{sl sr s;ul ur} A B)
68 : sum@{sl sr SProp;ul ur} A B :=
69 match x return sum@{sl sr SProp;ul ur} A B with
70 | inl a => inl a
71 | inr b => inr b
72 end.
73 (* sl sr s ; ul ur |= s->SProp *)
74
75 (* Implicit constraints are elaborated *)
76 Definition idV@{sl sr s s';ul ur} (A : Type@{sl;ul}) (B : Type@{sr;ur}) (x : sum@{sl sr s;ul ur} A B)
77 : sum@{sl sr s';ul ur} A B :=
78 match x return sum@{sl sr s';ul ur} A B with
79 | inl a => inl a
80 | inr b => inr b
81 end.
82 (* sl sr s s' ; ul ur |= s->s' *)
83
84 Inductive List'@{s s';l} (A : Type@{s;l}) : Type@{s';l} :=
85 | nil' : List' A
86 | cons' : A -> List' A -> List' A.
87
88 Arguments nil' {A}.
89 Arguments cons' {A} _ _.
90
91 Definition list'_elim@{s s0 s';l l'}
92 (A : Type@{s;l}) (P : List'@{s s0;l} A -> Type@{s';l'})
93 (fn : P nil') (fc : forall (x : A) (l : List' A), P l -> P (cons' x l)) :=
94 fix F (l : List'@{s s0;l} A) : P l :=
95 match l with
96 | nil' => fn
97 | cons' x l => fc x l (F l)
98 end.
99 (* s s0 s' ; l l' |= s0->s' *)
100
101 Fixpoint list'_idT@{s s';l} {A : Type@{s;l}} (l : List'@{s s';l} A) : List'@{s Type;l} A :=
102 match l with
103 | nil' => nil'
104 | cons' x l => cons' x (list'_idT l)
105 end.
106 (* s s' ; l |= s'->Type *)
107
108 Fixpoint list'_idP@{s s';l} {A : Type@{s;l}} (l : List'@{s s';l} A) : List'@{s Prop;l} A :=
109 match l with
110 | nil' => nil'
111 | cons' x l => cons' x (list'_idP l)
112 end.
113 (* s s' ; l |= s'->Prop *)
114
115 Fixpoint list'_idS@{s s';l} {A : Type@{s;l}} (l : List'@{s s';l} A) : List'@{s SProp;l} A :=
116 match l with
117 | nil' => nil'
118 | cons' x l => cons' x (list'_idS l)
119 end.
120 (* s s' ; l |= s'->SProp *)
121
122 (* Elimination constraint left explicitly empty. Definition fails because of missing constraint. *)
123 Fail Fixpoint list'_idV@{s s0 s';l l'|l <= l'} {A : Type@{s;l}} (l : List'@{s s0;l} A) : List'@{s s';l'} A :=
124 match l with
125 | nil' => nil'
126 | cons' x l => cons' x (list'_idV l)
127 end.
128 (* The command has indeed failed with message:
129 Elimination constraints are not implied by the ones declared: s0->s' *)
130
131 (* Using + to elaborate missing constraints. Definition passes *)
132 Fixpoint list'_idV@{s s0 s';l l'|l <= l' + } {A : Type@{s;l}} (l : List'@{s s0;l} A) : List'@{s s';l'} A :=
133 match l with
134 | nil' => nil'
135 | cons' x l => cons' x (list'_idV l)
136 end.
137 (* s s0 s' ; l l' |= s0->s', l <= l' *)
138
139
140 Inductive False'@{s;u} : Type@{s;u} :=.
141
142 Definition False'_False@{s; +|+} (x : False'@{s;_}) : False := match x return False with end.
143 (* s ; u |= s->Prop *)
144
145 Inductive bool@{s;u} : Type@{s;u} := true | false.
146
147 Definition bool_to_Prop@{s;u} (b : bool@{s;u}) : Prop.
148 Proof.
149 destruct b.
150 - exact True.
151 - exact False.
152 Defined.
153 (* s ; u |= s->Type *)
154
155 Definition bool_to_True_conj@{s;u} (b : bool@{s;u}) : True \/ True.
156 Proof.
157 destruct b.
158 - exact (or_introl I).
159 - exact (or_intror I).
160 Defined.
161 (* s ; u |= s->Prop *)
162
163 Program Definition bool_to_Prop'@{s;u} (b : bool@{s;u}) : Prop := _.
164 Next Obligation.
165 intro b; destruct b.
166 - exact True.
167 - exact False.
168 Defined.
169 (* s ; u |= s->Type *)
170
171 Inductive unit@{s;u} : Type@{s;u} := tt.
172
173 #[universes(polymorphic=no)]
174 Sort Test.
175 Check (match true@{Test;Set} return ?[P] with true => tt | false => tt end).