Debian Codegraph @

test-suite/bugs/bug_20902_1.v

raw
1 (* -*- mode: coq; coq-prog-args: ("-noinit" "-indices-matter") -*- *)
2
3 (* File reduced by coq-bug-minimizer from original input, then from 839 lines to 73 lines, then from 86 lines to 629 lines, then from 635 lines to 73 lines, then from 86 lines to 677 lines, then from 682 lines to 82 lines, then from 95 lines to 148 lines, then from 154 lines to 82 lines, then from 95 lines to 693 lines, then from 699 lines to 85 lines, then from 98 lines to 137 lines, then from 143 lines to 86 lines, then from 99 lines to 697 lines, then from 703 lines to 150 lines, then from 163 lines to 301 lines, then from 304 lines to 227 lines, then from 240 lines to 282 lines, then from 288 lines to 238 lines, then from 251 lines to 515 lines, then from 521 lines to 268 lines, then from 281 lines to 519 lines, then from 525 lines to 328 lines, then from 341 lines to 418 lines, then from 424 lines to 330 lines, then from 343 lines to 1116 lines, then from 1121 lines to 436 lines, then from 449 lines to 539 lines, then from 545 lines to 443 lines, then from 456 lines to 771 lines, then from 773 lines to 465 lines, then from 479 lines to 464 lines *)
4 (* coqc version 9.2+alpha compiled with OCaml 4.14.2
5 coqtop version runner-wbcqh1i1-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at 7c064a87db8257) (7c064a87db8257cb769d52951346663e9d8a438e)
6 Expected coqc runtime on this file: 0.159 sec *)
7 Declare Scope type_scope.
8 Reserved Notation "'exists' x .. y , p"
9 (at level 200, x binder, right associativity,
10 format "'[' 'exists' '/ ' x .. y , '/ ' p ']'").
11
12 Reserved Notation "x -> y" (at level 99, right associativity, y at level 200).
13 Reserved Notation "x <-> y" (at level 95, no associativity).
14 Reserved Notation "~ x" (at level 35, right associativity).
15
16 Reserved Notation "x = y :> T"
17 (at level 70, y at next level, no associativity).
18 Reserved Notation "x < y" (at level 70, no associativity).
19
20 Reserved Notation "{ x : A & P }" (at level 0, x at level 99).
21 Reserved Notation "f == g" (at level 70, no associativity).
22
23 Reserved Notation "A <~> B" (at level 85).
24 Reserved Notation "g 'o' f" (at level 40, left associativity).
25 Delimit Scope function_scope with function.
26 Delimit Scope trunc_scope with trunc.
27
28 Global Open Scope trunc_scope.
29 Global Open Scope type_scope.
30
31 Declare ML Module "ltac_plugin:coq-core.plugins.ltac".
32
33 Declare ML Module "number_string_notation_plugin:coq-core.plugins.number_string_notation".
34
35 Global Set Default Proof Mode "Classic".
36
37 Global Set Universe Polymorphism.
38
39 Global Unset Strict Universe Declaration.
40 Create HintDb typeclass_instances discriminated.
41
42 Notation "A -> B" := (forall (_ : A), B) : type_scope.
43
44 Inductive option (A : Type) : Type :=
45 | Some : A -> option A
46 | None : option A.
47
48 Arguments Some {A} a.
49 Arguments None {A}.
50
51 Register option as core.option.type.
52
53 Record prod (A B : Type) := pair { fst : A ; snd : B }.
54
55 Definition Relation (A : Type) := A -> A -> Type.
56
57 Class Reflexive {A} (R : Relation A) :=
58 reflexivity : forall x : A, R x x.
59
60 Class Transitive {A} (R : Relation A) :=
61 transitivity : forall x y z, R x y -> R y z -> R x z.
62
63 Notation Type0 := Set.
64
65 Notation idmap := (fun x => x).
66
67 Record sig {A} (P : A -> Type) := exist {
68 proj1 : A ;
69 proj2 : P proj1 ;
70 }.
71 Notation "'exists' x .. y , p" := (sig (fun x => .. (sig (fun y => p)) ..)) : type_scope.
72 Notation "{ x : A & P }" := (sig (fun x:A => P)) : type_scope.
73
74 Notation compose := (fun g f x => g (f x)).
75
76 Notation "g 'o' f" := (compose g%function f%function) : function_scope.
77
78 Inductive paths {A : Type} (a : A) : A -> Type :=
79 idpath : paths a a.
80
81 Notation "x = y :> A" := (@paths A x y) : type_scope.
82 Notation "x = y" := (x = y :>_) : type_scope.
83 Definition ap {A B : Type} (f : A -> B) {x y : A} (p : x = y) : f x = f y.
84 Admitted.
85
86 Definition pointwise_paths A (P : A -> Type) (f g : forall x, P x)
87 := forall x, f x = g x.
88
89 Global Arguments pointwise_paths {A}%_type_scope {P} (f g)%_function_scope.
90
91 Notation "f == g" := (pointwise_paths f g) : type_scope.
92
93 Class IsEquiv {A B : Type} (f : A -> B) := {
94 equiv_inv : B -> A ;
95 eisretr : f o equiv_inv == idmap ;
96 eissect : equiv_inv o f == idmap ;
97 eisadj : forall x : A, eisretr (f x) = ap f (eissect x) ;
98 }.
99
100 Record Equiv A B := {
101 equiv_fun : A -> B ;
102 equiv_isequiv :: IsEquiv equiv_fun
103 }.
104
105 Notation "A <~> B" := (Equiv A B) : type_scope.
106
107 Inductive trunc_index : Type0 :=
108 | minus_two : trunc_index
109 | trunc_S : trunc_index -> trunc_index.
110
111 Notation "n .+1" := (trunc_S n) : trunc_scope.
112 Notation "n .+2" := (n.+1.+1)%trunc : trunc_scope.
113
114 Inductive IsTrunc_internal (A : Type@{u}) : trunc_index -> Type@{u} :=
115 | Build_Contr : forall (center : A) (contr : forall y, center = y), IsTrunc_internal A minus_two
116 | istrunc_S : forall {n:trunc_index}, (forall x y:A, IsTrunc_internal (x = y) n) -> IsTrunc_internal A (trunc_S n).
117
118 Existing Class IsTrunc_internal.
119
120 Notation IsTrunc n A := (IsTrunc_internal A n).
121 Notation IsHProp A := (IsTrunc minus_two.+1 A).
122 Notation IsHSet A := (IsTrunc minus_two.+2 A).
123
124 Notation is_mere_relation A R := (forall (x y : A), IsHProp (R x y)).
125
126 Inductive nat : Type0 :=
127 | O : nat
128 | S : nat -> nat.
129 Delimit Scope nat_scope with nat.
130 Bind Scope nat_scope with nat.
131
132 Inductive Empty : Type0 := .
133
134 Definition not (A : Type) := A -> Empty.
135 Notation "~ x" := (not x) : type_scope.
136 Definition complement {A} (R : Relation A) : Relation A.
137 exact (fun x y => ~ (R x y)).
138 Defined.
139
140 Class Irreflexive {A} (R : Relation A) :=
141 irreflexivity : Reflexive (complement R).
142
143 Monomorphic Axiom PropResizing : Type0.
144 Existing Class PropResizing.
145
146 Definition iff (A B : Type) := prod (A -> B) (B -> A).
147
148 Notation "A <-> B" := (iff A B) : type_scope.
149 Module Export Decimal.
150
151 Inductive uint : Type0 :=
152 | Nil
153 | D0 (_:uint)
154 | D1 (_:uint)
155 | D2 (_:uint)
156 | D3 (_:uint)
157 | D4 (_:uint)
158 | D5 (_:uint)
159 | D6 (_:uint)
160 | D7 (_:uint)
161 | D8 (_:uint)
162 | D9 (_:uint).
163
164 Notation zero := (D0 Nil).
165
166 Variant int : Type0 := Pos (d:uint) | Neg (d:uint).
167
168 Variant decimal : Type0 :=
169 | Decimal (i:int) (f:uint)
170 | DecimalExp (i:int) (f:uint) (e:int).
171
172 Register uint as num.uint.type.
173 Register int as num.int.type.
174 Register decimal as num.decimal.type.
175
176 Fixpoint revapp (d d' : uint) :=
177 match d with
178 | Nil => d'
179 | D0 d => revapp d (D0 d')
180 | D1 d => revapp d (D1 d')
181 | D2 d => revapp d (D2 d')
182 | D3 d => revapp d (D3 d')
183 | D4 d => revapp d (D4 d')
184 | D5 d => revapp d (D5 d')
185 | D6 d => revapp d (D6 d')
186 | D7 d => revapp d (D7 d')
187 | D8 d => revapp d (D8 d')
188 | D9 d => revapp d (D9 d')
189 end.
190
191 Definition rev d := revapp d Nil.
192
193 Module Export Little.
194
195 Fixpoint succ d :=
196 match d with
197 | Nil => D1 Nil
198 | D0 d => D1 d
199 | D1 d => D2 d
200 | D2 d => D3 d
201 | D3 d => D4 d
202 | D4 d => D5 d
203 | D5 d => D6 d
204 | D6 d => D7 d
205 | D7 d => D8 d
206 | D8 d => D9 d
207 | D9 d => D0 (succ d)
208 end.
209 End Little.
210 End Decimal.
211
212 Module Export Hexadecimal.
213
214 Inductive uint : Type0 :=
215 | Nil
216 | D0 (_:uint)
217 | D1 (_:uint)
218 | D2 (_:uint)
219 | D3 (_:uint)
220 | D4 (_:uint)
221 | D5 (_:uint)
222 | D6 (_:uint)
223 | D7 (_:uint)
224 | D8 (_:uint)
225 | D9 (_:uint)
226 | Da (_:uint)
227 | Db (_:uint)
228 | Dc (_:uint)
229 | Dd (_:uint)
230 | De (_:uint)
231 | Df (_:uint).
232
233 Variant int : Type0 := Pos (d:uint) | Neg (d:uint).
234
235 Variant hexadecimal : Type0 :=
236 | Hexadecimal (i:int) (f:uint)
237 | HexadecimalExp (i:int) (f:uint) (e:Decimal.int).
238
239 Register uint as num.hexadecimal_uint.type.
240 Register int as num.hexadecimal_int.type.
241 Register hexadecimal as num.hexadecimal.type.
242
243 End Hexadecimal.
244
245 Module Export Numeral.
246
247 Variant uint : Type0 := UIntDec (u:Decimal.uint) | UIntHex (u:Hexadecimal.uint).
248
249 Variant int : Type0 := IntDec (i:Decimal.int) | IntHex (i:Hexadecimal.int).
250
251 Variant numeral : Type0 := Dec (d:Decimal.decimal) | Hex (h:Hexadecimal.hexadecimal).
252
253 Register uint as num.num_uint.type.
254 Register int as num.num_int.type.
255 Register numeral as num.number.type.
256 End Numeral.
257
258 Module Export Nat.
259
260 Fixpoint tail_add n m :=
261 match n with
262 | O => m
263 | S n => tail_add n (S m)
264 end.
265
266 Fixpoint tail_addmul r n m :=
267 match n with
268 | O => r
269 | S n => tail_addmul (tail_add m r) n m
270 end.
271
272 Definition tail_mul n m := tail_addmul O n m.
273
274 Local Notation ten := (S (S (S (S (S (S (S (S (S (S O)))))))))).
275
276 Fixpoint of_uint_acc (d:Decimal.uint)(acc:nat) :=
277 match d with
278 | Decimal.Nil => acc
279 | Decimal.D0 d => of_uint_acc d (tail_mul ten acc)
280 | Decimal.D1 d => of_uint_acc d (S (tail_mul ten acc))
281 | Decimal.D2 d => of_uint_acc d (S (S (tail_mul ten acc)))
282 | Decimal.D3 d => of_uint_acc d (S (S (S (tail_mul ten acc))))
283 | Decimal.D4 d => of_uint_acc d (S (S (S (S (tail_mul ten acc)))))
284 | Decimal.D5 d => of_uint_acc d (S (S (S (S (S (tail_mul ten acc))))))
285 | Decimal.D6 d => of_uint_acc d (S (S (S (S (S (S (tail_mul ten acc)))))))
286 | Decimal.D7 d => of_uint_acc d (S (S (S (S (S (S (S (tail_mul ten acc))))))))
287 | Decimal.D8 d => of_uint_acc d (S (S (S (S (S (S (S (S (tail_mul ten acc)))))))))
288 | Decimal.D9 d => of_uint_acc d (S (S (S (S (S (S (S (S (S (tail_mul ten acc))))))))))
289 end.
290
291 Definition of_uint (d:Decimal.uint) := of_uint_acc d O.
292
293 Local Notation sixteen := (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S O)))))))))))))))).
294
295 Fixpoint of_hex_uint_acc (d:Hexadecimal.uint)(acc:nat) :=
296 match d with
297 | Hexadecimal.Nil => acc
298 | Hexadecimal.D0 d => of_hex_uint_acc d (tail_mul sixteen acc)
299 | Hexadecimal.D1 d => of_hex_uint_acc d (S (tail_mul sixteen acc))
300 | Hexadecimal.D2 d => of_hex_uint_acc d (S (S (tail_mul sixteen acc)))
301 | Hexadecimal.D3 d => of_hex_uint_acc d (S (S (S (tail_mul sixteen acc))))
302 | Hexadecimal.D4 d => of_hex_uint_acc d (S (S (S (S (tail_mul sixteen acc)))))
303 | Hexadecimal.D5 d => of_hex_uint_acc d (S (S (S (S (S (tail_mul sixteen acc))))))
304 | Hexadecimal.D6 d => of_hex_uint_acc d (S (S (S (S (S (S (tail_mul sixteen acc)))))))
305 | Hexadecimal.D7 d => of_hex_uint_acc d (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))
306 | Hexadecimal.D8 d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))
307 | Hexadecimal.D9 d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))
308 | Hexadecimal.Da d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))))
309 | Hexadecimal.Db d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))))
310 | Hexadecimal.Dc d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))))))
311 | Hexadecimal.Dd d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))))))
312 | Hexadecimal.De d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))))))))
313 | Hexadecimal.Df d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))))))))
314 end.
315
316 Definition of_hex_uint (d:Hexadecimal.uint) := of_hex_uint_acc d O.
317
318 Definition of_num_uint (d:Numeral.uint) :=
319 match d with
320 | Numeral.UIntDec d => of_uint d
321 | Numeral.UIntHex d => of_hex_uint d
322 end.
323
324 Fixpoint to_little_uint n acc :=
325 match n with
326 | O => acc
327 | S n => to_little_uint n (Decimal.Little.succ acc)
328 end.
329
330 Definition to_uint n :=
331 Decimal.rev (to_little_uint n Decimal.zero).
332
333 Definition to_num_uint n := Numeral.UIntDec (to_uint n).
334
335 End Nat.
336
337 Number Notation nat of_num_uint to_num_uint (abstract after 5001) : nat_scope.
338 Fixpoint trunc_index_inc@{} (k : trunc_index) (n : nat)
339 : trunc_index.
340 exact (match n with
341 | O => k
342 | S m => (trunc_index_inc k m).+1
343 end).
344 Defined.
345 Definition nat_to_trunc_index@{} (n : nat) : trunc_index.
346 exact ((trunc_index_inc minus_two n).+2).
347 Defined.
348 Definition int_to_trunc_index@{} (v : Decimal.int) : option trunc_index.
349 exact (match v with
350 | Decimal.Pos d => Some (nat_to_trunc_index (Nat.of_uint d))
351 | Decimal.Neg d => match Nat.of_uint d with
352 | 2%nat => Some minus_two
353 | 1%nat => Some (minus_two.+1)
354 | 0%nat => Some (minus_two.+2)
355 | _ => None
356 end
357 end).
358 Defined.
359 Definition num_int_to_trunc_index@{} (v : Numeral.int) : option trunc_index.
360 exact (match v with
361 | Numeral.IntDec v => int_to_trunc_index v
362 | Numeral.IntHex _ => None
363 end).
364 Defined.
365
366 Fixpoint trunc_index_to_little_uint@{} n acc :=
367 match n with
368 | minus_two => acc
369 | minus_two.+1 => acc
370 | minus_two.+2 => acc
371 | trunc_S n => trunc_index_to_little_uint n (Decimal.Little.succ acc)
372 end.
373
374 Definition trunc_index_to_int@{} n :=
375 match n with
376 | minus_two => Decimal.Neg (Nat.to_uint 2)
377 | minus_two.+1 => Decimal.Neg (Nat.to_uint 1)
378 | n => Decimal.Pos (Decimal.rev (trunc_index_to_little_uint n Decimal.zero))
379 end.
380
381 Definition trunc_index_to_num_int@{} n :=
382 Numeral.IntDec (trunc_index_to_int n).
383
384 Number Notation trunc_index num_int_to_trunc_index trunc_index_to_num_int
385 : trunc_scope.
386
387 Record TruncType (n : trunc_index) := {
388 trunctype_type : Type ;
389 trunctype_istrunc :: IsTrunc n trunctype_type
390 }.
391
392 Arguments Build_TruncType _ _ {_}.
393
394 Coercion trunctype_type : TruncType >-> Sortclass.
395
396 Notation "n -Type" := (TruncType n) : type_scope.
397 Notation HSet := 0-Type.
398 Notation Build_HSet := (Build_TruncType 0).
399
400 Monomorphic Axiom Univalence : Type0.
401 Existing Class Univalence.
402
403 Declare Scope mc_scope.
404
405 Open Scope mc_scope.
406 Class Lt A := lt: Relation A.
407
408 Infix "<" := lt : mc_scope.
409 Notation "(<)" := lt (only parsing) : mc_scope.
410
411 Inductive Accessible {A} (R : Lt A) (a : A) :=
412 acc : (forall b, b < a -> Accessible R b) -> Accessible R a.
413
414 Class WellFounded {A} (R : Relation A) :=
415 well_foundedness : forall a : A, Accessible R a.
416
417 Class Extensional {A} (R : Lt A) :=
418 extensionality : forall a b : A, (forall c : A, c < a <-> c < b) -> a = b.
419
420 Class IsOrdinal@{carrier relation} (A : Type@{carrier}) (R : Relation@{carrier relation} A) := {
421 ordinal_is_hset :: IsHSet A ;
422 ordinal_relation_is_mere :: is_mere_relation A R ;
423 ordinal_extensionality :: Extensional R ;
424 ordinal_well_foundedness :: WellFounded R ;
425 ordinal_transitivity :: Transitive R ;
426 }.
427
428 Record Ordinal@{carrier relation +} :=
429 { ordinal_carrier : Type@{carrier}
430 ; ordinal_relation :: Lt@{carrier relation} ordinal_carrier
431 ; ordinal_property :: IsOrdinal@{carrier relation} ordinal_carrier (<)
432 }.
433 Coercion ordinal_as_hset (A : Ordinal) : HSet.
434 exact (Build_HSet (ordinal_carrier A)).
435 Defined.
436
437 Instance irreflexive_ordinal_relation A R
438 : IsOrdinal A R -> Irreflexive R.
439 Proof.
440 intros is_ordinal a H. Check (well_foundedness a).
441 induction (well_foundedness a) as [a _ IH].
442 apply (IH a); assumption.
443 Qed.
444
445 Definition TypeWithRelation
446 := { A : Type & Relation A }.
447 Coercion ordinal_as_type_with_relation (A : Ordinal) : TypeWithRelation.
448 Admitted.
449 Definition Isomorphism : TypeWithRelation -> TypeWithRelation -> Type.
450 Admitted.
451
452 Definition equiv_path_Ordinal `{Univalence} (A B : Ordinal)
453 : Isomorphism A B <~> A = B.
454 Admitted.
455
456 Definition initial_segment `{PropResizing}
457 {A : Type} {R : Lt A} `{IsOrdinal A R} (a : A)
458 : Ordinal.
459 Admitted.
460
461 Declare Scope Ordinals.
462 Open Scope Ordinals.
463
464 Notation "↓ a" := (initial_segment a) (at level 4, format "↓ a") : Ordinals.
465 Instance lt_Ordinal@{carrier relation +} `{PropResizing}
466 : Lt Ordinal@{carrier relation}.
467 exact (fun A B => exists b : B, A = ↓b).
468 Defined.
469
470 Instance Ordinal_is_ordinal `{PropResizing} `{Univalence}
471 : IsOrdinal Ordinal (<).
472 Admitted.
473
474 Lemma ordinal_initial `{PropResizing} `{Univalence} (O : Ordinal) (a : O)
475 (p : O = ↓a)
476 (HO : O < O)
477 : Empty.
478 Proof.
479 exact (irreflexive_ordinal_relation _ _ _ _ HO).
480 Qed.