Debian Codegraph @

test-suite/bugs/bug_4527.v

raw
1 (* -*- mode: coq; coq-prog-args: ("-nois" "-indices-matter") -*- *)
2 (* File reduced by coq-bug-finder from original input, then from 1199 lines to
3 430 lines, then from 444 lines to 430 lines, then from 964 lines to 255 lines,
4 then from 269 lines to 255 lines *)
5 (* coqc version 8.5 (January 2016) compiled on Jan 23 2016 16:15:22 with OCaml
6 4.01.0
7 coqtop version 8.5 (January 2016) *)
8 Require Import Corelib.Init.Ltac.
9 Inductive False := .
10 Axiom proof_admitted : False.
11 Tactic Notation "admit" := case proof_admitted.
12 Require Corelib.Init.Datatypes.
13 Require Import Corelib.Init.Tactics.
14
15 Import Corelib.Init.Notations.
16
17 Global Set Universe Polymorphism.
18
19 Notation "A -> B" := (forall (_ : A), B) : type_scope.
20
21 Inductive True : Type :=
22 I : True.
23 Module Export Datatypes.
24
25 Set Implicit Arguments.
26 Notation nat := Corelib.Init.Datatypes.nat.
27 Notation O := Corelib.Init.Datatypes.O.
28 Notation S := Corelib.Init.Datatypes.S.
29 Notation two := (S (S O)).
30
31 Record prod (A B : Type) := pair { fst : A ; snd : B }.
32
33 Notation "x * y" := (prod x y) : type_scope.
34
35 Open Scope nat_scope.
36
37 End Datatypes.
38 Module Export Specif.
39
40 Set Implicit Arguments.
41
42 Record sig {A} (P : A -> Type) := exist { proj1_sig : A ; proj2_sig : P
43 proj1_sig }.
44
45 Notation sigT := sig (only parsing).
46
47 Notation "{ x : A & P }" := (sigT (fun x:A => P)) : type_scope.
48
49 Notation projT1 := proj1_sig (only parsing).
50 Notation projT2 := proj2_sig (only parsing).
51
52 End Specif.
53 Definition Type1@{i} := Eval hnf in let gt := (Set : Type@{i}) in Type@{i}.
54
55 Definition Type2@{i j} := Eval hnf in let gt := (Type1@{j} : Type@{i}) in
56 Type@{i}.
57
58 Definition Type2le@{i j} := Eval hnf in let gt := (Set : Type@{i}) in
59 let ge := ((fun x => x) : Type1@{j} ->
60 Type@{i}) in Type@{i}.
61
62 Notation idmap := (fun x => x).
63 Delimit Scope function_scope with function.
64 Delimit Scope path_scope with path.
65 Delimit Scope fibration_scope with fibration.
66 Open Scope fibration_scope.
67 Open Scope function_scope.
68
69 Notation pr1 := projT1.
70 Notation pr2 := projT2.
71
72 Notation "x .1" := (pr1 x) : fibration_scope.
73 Notation "x .2" := (pr2 x) : fibration_scope.
74
75 Notation compose := (fun g f x => g (f x)).
76
77 Notation "g 'o' f" := (compose g%function f%function) (at level 40, left
78 associativity) : function_scope.
79
80 Inductive paths {A : Type} (a : A) : A -> Type :=
81 idpath : paths a a.
82
83 Arguments idpath {A a} , [A] a.
84
85 Notation "x = y :> A" := (@paths A x y) : type_scope.
86 Notation "x = y" := (x = y :>_) : type_scope.
87
88 Scheme Rewriting for paths.
89
90 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
91 := match p with idpath => idpath end.
92
93 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
94 match p, q with idpath, idpath => idpath end.
95
96 Notation "p @ q" := (concat p%path q%path) (at level 20, left associativity) : path_scope.
97
98 Notation "p ^" := (inverse p%path) (at level 3, format "p '^'") : path_scope.
99
100 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
101 := match p with idpath => idpath end.
102
103 Definition pointwise_paths {A} {P:A->Type} (f g:forall x:A, P x)
104 := forall x:A, f x = g x.
105
106 Notation "f == g" := (pointwise_paths f g) (at level 70, no associativity) :
107 type_scope.
108
109 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
110 forall x : A, r (s x) = x.
111
112 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
113 equiv_inv : B -> A ;
114 eisretr : Sect equiv_inv f;
115 eissect : Sect f equiv_inv;
116 eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
117 }.
118
119 Arguments eisretr {A B}%_type_scope f%_function_scope {_} _.
120 Arguments eissect {A B}%_type_scope f%_function_scope {_} _.
121
122 Notation "f ^-1" := (@equiv_inv _ _ f _) (at level 3, format "f '^-1'") :
123 function_scope.
124
125 Inductive Unit : Type1 :=
126 tt : Unit.
127
128 Local Open Scope path_scope.
129
130 Section EquivInverse.
131
132 Context {A B : Type} (f : A -> B) {feq : IsEquiv f}.
133
134 Theorem other_adj (b : B) : eissect f (f^-1 b) = ap f^-1 (eisretr f b).
135 admit.
136 Defined.
137
138 Global Instance isequiv_inverse : IsEquiv f^-1 | 10000
139 := BuildIsEquiv B A f^-1 f (eissect f) (eisretr f) other_adj.
140 End EquivInverse.
141
142 Section Adjointify.
143
144 Context {A B : Type} (f : A -> B) (g : B -> A).
145 Context (isretr : Sect g f) (issect : Sect f g).
146
147 Let issect' := fun x =>
148 ap g (ap f (issect x)^) @ ap g (isretr (f x)) @ issect x.
149
150 Let is_adjoint' (a : A) : isretr (f a) = ap f (issect' a).
151 admit.
152 Defined.
153
154 Definition isequiv_adjointify : IsEquiv f
155 := BuildIsEquiv A B f g isretr issect' is_adjoint'.
156
157 End Adjointify.
158
159 Definition ExtensionAlong {A B : Type} (f : A -> B)
160 (P : B -> Type) (d : forall x:A, P (f x))
161 := { s : forall y:B, P y & forall x:A, s (f x) = d x }.
162
163 Fixpoint ExtendableAlong@{i j k l}
164 (n : nat) {A : Type@{i}} {B : Type@{j}}
165 (f : A -> B) (C : B -> Type@{k}) : Type@{l}
166 := match n with
167 | O => Unit@{l}
168 | S n => (forall (g : forall a, C (f a)),
169 ExtensionAlong@{i j k l l} f C g) *
170 forall (h k : forall b, C b),
171 ExtendableAlong n f (fun b => h b = k b)
172 end.
173
174 Definition ooExtendableAlong@{i j k l}
175 {A : Type@{i}} {B : Type@{j}}
176 (f : A -> B) (C : B -> Type@{k}) : Type@{l}
177 := forall n, ExtendableAlong@{i j k l} n f C.
178
179 Module Type ReflectiveSubuniverses.
180
181 Parameter ReflectiveSubuniverse@{u a} : Type2@{u a}.
182
183 Parameter O_reflector@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
184 Type2le@{i a} -> Type2le@{i a}.
185
186 Parameter In@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
187 Type2le@{i a} -> Type2le@{i a}.
188
189 Parameter O_inO@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T :
190 Type@{i}),
191 In@{u a i} O (O_reflector@{u a i} O T).
192
193 Parameter to@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T :
194 Type@{i}),
195 T -> O_reflector@{u a i} O T.
196
197 Parameter inO_equiv_inO@{u a i j k} :
198 forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}) (U : Type@{j})
199 (T_inO : In@{u a i} O T) (f : T -> U) (feq : IsEquiv f),
200
201 let gei := ((fun x => x) : Type@{i} -> Type@{k}) in
202 let gej := ((fun x => x) : Type@{j} -> Type@{k}) in
203 In@{u a j} O U.
204
205 Parameter extendable_to_O@{u a i j k}
206 : forall (O : ReflectiveSubuniverse@{u a}) {P : Type2le@{i a}} {Q :
207 Type2le@{j a}} {Q_inO : In@{u a j} O Q},
208 ooExtendableAlong@{i i j k} (to O P) (fun _ => Q).
209
210 End ReflectiveSubuniverses.
211
212 Module ReflectiveSubuniverses_Theory (Os : ReflectiveSubuniverses).
213 Export Os.
214
215 Existing Class In.
216
217 Coercion O_reflector : ReflectiveSubuniverse >-> Funclass.
218
219 Arguments inO_equiv_inO {O} T {U} {_} f {_}.
220 Global Existing Instance O_inO.
221
222 Section ORecursion.
223 Context {O : ReflectiveSubuniverse}.
224
225 Definition O_indpaths {P Q : Type} {Q_inO : In O Q}
226 (g h : O P -> Q) (p : g o to O P == h o to O P)
227 : g == h
228 := (fst (snd (extendable_to_O O two) g h) p).1.
229
230 Definition O_indpaths_beta {P Q : Type} {Q_inO : In O Q}
231 (g h : O P -> Q) (p : g o (to O P) == h o (to O P)) (x : P)
232 : O_indpaths g h p (to O P x) = p x
233 := (fst (snd (extendable_to_O O two) g h) p).2 x.
234
235 End ORecursion.
236
237 Section Reflective_Subuniverse.
238 Universes Ou Oa.
239 Context (O : ReflectiveSubuniverse@{Ou Oa}).
240
241 Definition inO_isequiv_to_O (T:Type)
242 : IsEquiv (to O T) -> In O T
243 := fun _ => inO_equiv_inO (O T) (to O T)^-1.
244
245 Definition inO_to_O_retract (T:Type) (mu : O T -> T)
246 : Sect (to O T) mu -> In O T.
247 Proof.
248 unfold Sect; intros H.
249 apply inO_isequiv_to_O.
250 apply isequiv_adjointify with (g:=mu).
251 -
252 refine (O_indpaths (to O T o mu) idmap _).
253 intros x; exact (ap (to O T) (H x)).
254 -
255 exact H.
256 Defined.
257
258 Definition inO_paths@{i} (S : Type@{i}) {S_inO : In@{Ou Oa i} O S} (x y :
259 S) : In@{Ou Oa i} O (x=y).
260 Proof.
261 simple refine (inO_to_O_retract@{i} _ _ _); intro u.
262 -
263 assert (p : (fun _ : O (x=y) => x) == (fun _=> y)).
264 {
265 refine (O_indpaths _ _ _); simpl.
266 intro v; exact v.
267 }
268 exact (p u).
269 -
270 hnf.
271 rewrite O_indpaths_beta; reflexivity.
272 Qed.
273 Check inO_paths@{Type}.
274 End Reflective_Subuniverse.
275 End ReflectiveSubuniverses_Theory.