Debian Codegraph @

test-suite/bugs/bug_4089.v

raw
1 Unset Strict Universe Declaration.
2 Require Import TestSuite.admit.
3 (* -*- mode: coq; coq-prog-args: ("-indices-matter") -*- *)
4 (* File reduced by coq-bug-finder from original input, then from 6522 lines to 318 lines, then from 1139 lines to 361 lines *)
5 (* coqc version 8.5beta1 (February 2015) compiled on Feb 23 2015 18:32:3 with OCaml 4.01.0
6 coqtop version cagnode15:/afs/csail.mit.edu/u/j/jgross/coq-8.5,v8.5 (ebfc19d792492417b129063fb511aa423e9d9e08) *)
7 Open Scope type_scope.
8
9 Global Set Universe Polymorphism.
10 Module Export Datatypes.
11
12 Set Implicit Arguments.
13
14 Record prod (A B : Type) := pair { fst : A ; snd : B }.
15
16 Notation "x * y" := (prod x y) : type_scope.
17 Notation "( x , y , .. , z )" := (pair .. (pair x y) .. z) : core_scope.
18
19 End Datatypes.
20 Module Export Specif.
21
22 Set Implicit Arguments.
23
24 Record sig {A} (P : A -> Type) := exist { proj1_sig : A ; proj2_sig : P proj1_sig }.
25
26 Notation sigT := sig (only parsing).
27 Notation existT := exist (only parsing).
28
29 Notation "{ x : A & P }" := (sigT (fun x:A => P)) : type_scope.
30
31 Notation projT1 := proj1_sig (only parsing).
32 Notation projT2 := proj2_sig (only parsing).
33
34 End Specif.
35
36 Ltac rapply p :=
37 refine (p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
38 refine (p _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
39 refine (p _ _ _ _ _ _ _ _ _ _ _ _ _) ||
40 refine (p _ _ _ _ _ _ _ _ _ _ _ _) ||
41 refine (p _ _ _ _ _ _ _ _ _ _ _) ||
42 refine (p _ _ _ _ _ _ _ _ _ _) ||
43 refine (p _ _ _ _ _ _ _ _ _) ||
44 refine (p _ _ _ _ _ _ _ _) ||
45 refine (p _ _ _ _ _ _ _) ||
46 refine (p _ _ _ _ _ _) ||
47 refine (p _ _ _ _ _) ||
48 refine (p _ _ _ _) ||
49 refine (p _ _ _) ||
50 refine (p _ _) ||
51 refine (p _) ||
52 refine p.
53
54 Local Unset Elimination Schemes.
55
56 Definition relation (A : Type) := A -> A -> Type.
57
58 Class Symmetric {A} (R : relation A) :=
59 symmetry : forall x y, R x y -> R y x.
60
61 Class Transitive {A} (R : relation A) :=
62 transitivity : forall x y z, R x y -> R y z -> R x z.
63
64 Tactic Notation "etransitivity" open_constr(y) :=
65 let R := match goal with |- ?R ?x ?z => constr:(R) end in
66 let x := match goal with |- ?R ?x ?z => constr:(x) end in
67 let z := match goal with |- ?R ?x ?z => constr:(z) end in
68 let pre_proof_term_head := constr:(@transitivity _ R _) in
69 let proof_term_head := (eval cbn in pre_proof_term_head) in
70 refine (proof_term_head x y z _ _); [ change (R x y) | change (R y z) ].
71
72 Ltac transitivity x := etransitivity x.
73
74 Definition Type1 := Eval hnf in let gt := (Set : Type@{i}) in Type@{i}.
75
76 Notation idmap := (fun x => x).
77 Delimit Scope function_scope with function.
78 Delimit Scope path_scope with path.
79 Delimit Scope fibration_scope with fibration.
80 Open Scope fibration_scope.
81 Open Scope function_scope.
82
83 Notation "( x ; y )" := (existT _ x y) : fibration_scope.
84
85 Notation pr1 := projT1.
86 Notation pr2 := projT2.
87
88 Notation "x .1" := (pr1 x) : fibration_scope.
89 Notation "x .2" := (pr2 x) : fibration_scope.
90
91 Notation compose := (fun g f x => g (f x)).
92
93 Notation "g 'o' f" := (compose g%function f%function) (at level 40, left associativity) : function_scope.
94
95 Inductive paths {A : Type} (a : A) : A -> Type :=
96 idpath : paths a a.
97
98 Arguments idpath {A a} , [A] a.
99
100 Scheme paths_ind := Induction for paths Sort Type.
101
102 Definition paths_rect := paths_ind.
103
104 Scheme Rewriting for paths.
105
106 Notation "x = y :> A" := (@paths A x y) : type_scope.
107 Notation "x = y" := (x = y :>_) : type_scope.
108
109 Local Open Scope path_scope.
110
111 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
112 := match p with idpath => idpath end.
113
114 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
115 match p, q with idpath, idpath => idpath end.
116
117 Arguments concat {A x y z} p q : simpl nomatch.
118
119 Notation "1" := idpath : path_scope.
120
121 Notation "p @ q" := (concat p%path q%path) (at level 20, left associativity) : path_scope.
122
123 Notation "p ^" := (inverse p%path) (at level 3, format "p '^'") : path_scope.
124
125 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y :=
126 match p with idpath => u end.
127
128 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
129 := match p with idpath => idpath end.
130
131 Definition pointwise_paths {A} {P:A->Type} (f g:forall x:A, P x)
132 := forall x:A, f x = g x.
133
134 Notation "f == g" := (pointwise_paths f g) (at level 70, no associativity) : type_scope.
135
136 Definition apD10 {A} {B:A->Type} {f g : forall x, B x} (h:f=g)
137 : f == g
138 := fun x => match h with idpath => 1 end.
139
140 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
141 forall x : A, r (s x) = x.
142
143 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
144 equiv_inv : B -> A ;
145 eisretr : Sect equiv_inv f;
146 eissect : Sect f equiv_inv;
147 eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
148 }.
149
150 Arguments eisretr {A B}%_type_scope f%_function_scope {_} _.
151 Arguments eissect {A B}%_type_scope f%_function_scope {_} _.
152 Arguments eisadj {A B}%_type_scope f%_function_scope {_} _.
153
154 Record Equiv A B := BuildEquiv {
155 equiv_fun : A -> B ;
156 equiv_isequiv : IsEquiv equiv_fun
157 }.
158
159 Coercion equiv_fun : Equiv >-> Funclass.
160
161 Global Existing Instance equiv_isequiv.
162
163 Bind Scope equiv_scope with Equiv.
164
165 Notation "A <~> B" := (Equiv A B) (at level 85) : type_scope.
166
167 Notation "f ^-1" := (@equiv_inv _ _ f _) (at level 3, format "f '^-1'") : function_scope.
168
169 Inductive Unit : Set :=
170 tt : Unit.
171
172 Ltac done :=
173 trivial; intros; solve
174 [ repeat first
175 [ solve [trivial]
176 | solve [symmetry; trivial]
177 | reflexivity
178
179 | contradiction
180 | split ]
181 | match goal with
182 H : ~ _ |- _ => solve [destruct H; trivial]
183 end ].
184 Tactic Notation "by" tactic(tac) :=
185 tac; done.
186
187 Definition concat_p1 {A : Type} {x y : A} (p : x = y) :
188 p @ 1 = p
189 :=
190 match p with idpath => 1 end.
191
192 Definition concat_1p {A : Type} {x y : A} (p : x = y) :
193 1 @ p = p
194 :=
195 match p with idpath => 1 end.
196
197 Definition ap_pp {A B : Type} (f : A -> B) {x y z : A} (p : x = y) (q : y = z) :
198 ap f (p @ q) = (ap f p) @ (ap f q)
199 :=
200 match q with
201 idpath =>
202 match p with idpath => 1 end
203 end.
204
205 Definition ap_compose {A B C : Type} (f : A -> B) (g : B -> C) {x y : A} (p : x = y) :
206 ap (g o f) p = ap g (ap f p)
207 :=
208 match p with idpath => 1 end.
209
210 Definition concat_A1p {A : Type} {f : A -> A} (p : forall x, f x = x) {x y : A} (q : x = y) :
211 (ap f q) @ (p y) = (p x) @ q
212 :=
213 match q with
214 | idpath => concat_1p _ @ ((concat_p1 _) ^)
215 end.
216
217 Definition concat2 {A} {x y z : A} {p p' : x = y} {q q' : y = z} (h : p = p') (h' : q = q')
218 : p @ q = p' @ q'
219 := match h, h' with idpath, idpath => 1 end.
220
221 Notation "p @@ q" := (concat2 p q)%path (at level 20) : path_scope.
222
223 Definition whiskerL {A : Type} {x y z : A} (p : x = y)
224 {q r : y = z} (h : q = r) : p @ q = p @ r
225 := 1 @@ h.
226
227 Definition ap02 {A B : Type} (f:A->B) {x y:A} {p q:x=y} (r:p=q) : ap f p = ap f q
228 := match r with idpath => 1 end.
229 Module Export Equivalences.
230
231 Generalizable Variables A B C f g.
232
233 Global Instance isequiv_idmap (A : Type) : IsEquiv idmap | 0 :=
234 BuildIsEquiv A A idmap idmap (fun _ => 1) (fun _ => 1) (fun _ => 1).
235
236 Definition equiv_idmap (A : Type) : A <~> A := BuildEquiv A A idmap _.
237
238 Arguments equiv_idmap {A} , A.
239
240 Notation "1" := equiv_idmap : equiv_scope.
241
242 Global Instance isequiv_compose `{IsEquiv A B f} `{IsEquiv B C g}
243 : IsEquiv (compose g f) | 1000
244 := BuildIsEquiv A C (compose g f)
245 (compose f^-1 g^-1)
246 (fun c => ap g (eisretr f (g^-1 c)) @ eisretr g c)
247 (fun a => ap (f^-1) (eissect g (f a)) @ eissect f a)
248 (fun a =>
249 (whiskerL _ (eisadj g (f a))) @
250 (ap_pp g _ _)^ @
251 ap02 g
252 ( (concat_A1p (eisretr f) (eissect g (f a)))^ @
253 (ap_compose f^-1 f _ @@ eisadj f a) @
254 (ap_pp f _ _)^
255 ) @
256 (ap_compose f g _)^
257 ).
258
259 Definition equiv_compose {A B C : Type} (g : B -> C) (f : A -> B)
260 `{IsEquiv B C g} `{IsEquiv A B f}
261 : A <~> C
262 := BuildEquiv A C (compose g f) _.
263
264 Global Instance transitive_equiv : Transitive Equiv | 0 :=
265 fun _ _ _ f g => equiv_compose g f.
266
267 Theorem equiv_inverse {A B : Type} : (A <~> B) -> (B <~> A).
268 admit.
269 Defined.
270
271 Global Instance symmetric_equiv : Symmetric Equiv | 0 := @equiv_inverse.
272
273 End Equivalences.
274
275 Definition path_prod_uncurried {A B : Type} (z z' : A * B)
276 (pq : (fst z = fst z') * (snd z = snd z'))
277 : (z = z').
278 admit.
279 Defined.
280
281 Global Instance isequiv_path_prod {A B : Type} {z z' : A * B}
282 : IsEquiv (path_prod_uncurried z z') | 0.
283 admit.
284 Defined.
285
286 Definition equiv_path_prod {A B : Type} (z z' : A * B)
287 : (fst z = fst z') * (snd z = snd z') <~> (z = z')
288 := BuildEquiv _ _ (path_prod_uncurried z z') _.
289
290 Generalizable Variables X A B C f g n.
291
292 Definition functor_sigma `{P : A -> Type} `{Q : B -> Type}
293 (f : A -> B) (g : forall a, P a -> Q (f a))
294 : sigT P -> sigT Q
295 := fun u => (f u.1 ; g u.1 u.2).
296
297 Global Instance isequiv_functor_sigma `{P : A -> Type} `{Q : B -> Type}
298 `{IsEquiv A B f} `{forall a, @IsEquiv (P a) (Q (f a)) (g a)}
299 : IsEquiv (functor_sigma f g) | 1000.
300 admit.
301 Defined.
302
303 Definition equiv_functor_sigma `{P : A -> Type} `{Q : B -> Type}
304 (f : A -> B) `{IsEquiv A B f}
305 (g : forall a, P a -> Q (f a))
306 `{forall a, @IsEquiv (P a) (Q (f a)) (g a)}
307 : sigT P <~> sigT Q
308 := BuildEquiv _ _ (functor_sigma f g) _.
309
310 Definition equiv_functor_sigma' `{P : A -> Type} `{Q : B -> Type}
311 (f : A <~> B)
312 (g : forall a, P a <~> Q (f a))
313 : sigT P <~> sigT Q
314 := equiv_functor_sigma f g.
315
316 Definition equiv_functor_sigma_id `{P : A -> Type} `{Q : A -> Type}
317 (g : forall a, P a <~> Q a)
318 : sigT P <~> sigT Q
319 := equiv_functor_sigma' 1 g.
320
321 Definition Bip : Type := { C : Type & C * C }.
322
323 Definition BipMor (X Y : Bip) : Type :=
324 match X, Y with (C;(c0,c1)), (D;(d0,d1)) =>
325 { f : C -> D & (f c0 = d0) * (f c1 = d1) }
326 end.
327
328 Definition bipmor2map {X Y : Bip} : BipMor X Y -> X.1 -> Y.1 :=
329 match X, Y with (C;(c0,c1)), (D;(d0,d1)) => fun i =>
330 match i with (f;_) => f end
331 end.
332
333 Definition bipidmor {X : Bip} : BipMor X X :=
334 match X with (C;(c0,c1)) => (idmap; (1, 1)) end.
335
336 Definition bipcompmor {X Y Z : Bip} : BipMor X Y -> BipMor Y Z -> BipMor X Z :=
337 match X, Y, Z with (C;(c0,c1)), (D;(d0,d1)), (E;(e0,e1)) => fun i j =>
338 match i, j with (f;(f0,f1)), (g;(g0,g1)) =>
339 (g o f; (ap g f0 @ g0, ap g f1 @ g1))
340 end
341 end.
342
343 Definition isbipequiv {X Y : Bip} (i : BipMor X Y) : Type :=
344 { l : BipMor Y X & bipcompmor i l = bipidmor } *
345 { r : BipMor Y X & bipcompmor r i = bipidmor }.
346
347 Lemma bipequivEQequiv : forall {X Y : Bip} (i : BipMor X Y),
348 isbipequiv i <~> IsEquiv (bipmor2map i).
349 Proof.
350 assert (equivcompmor : forall {X Y : Bip} (i : BipMor X Y) j,
351 (bipcompmor i j = bipidmor) <~> Unit).
352 intros; set (U := X); set (V := Y); destruct X as [C [c0 c1]], Y as [D [d0 d1]].
353 transitivity { n : (bipcompmor i j).1 = (@bipidmor U).1 &
354 (bipcompmor i j).2 = transport (fun h => (h c0 = c0) * (h c1 = c1)) n^ (@bipidmor U).2}.
355 admit.
356 destruct i as [f [f0 f1]]; destruct j as [g [g0 g1]].
357
358 transitivity { n : g o f = idmap & (ap g f0 @ g0 = apD10 n c0 @ 1) *
359 (ap g f1 @ g1 = apD10 n c1 @ 1)}.
360 apply equiv_functor_sigma_id; intro n.
361 assert (Ggen : forall (h0 h1 : C -> C) (p : h0 = h1) u0 u1 v0 v1,
362 ((u0, u1) = transport (fun h => (h c0 = c0) * (h c1 = c1)) p^ (v0, v1)) <~>
363 (u0 = apD10 p c0 @ v0) * (u1 = apD10 p c1 @ v1)).
364 induction p; intros; simpl; rewrite !concat_1p; apply symmetry.
365 by apply (equiv_path_prod (u0,u1) (v0,v1)).
366 rapply Ggen.
367 pose (@paths C).
368 Check (@paths C).
369 Undo.
370 Check (@paths C). (* Toplevel input, characters 0-17:
371 Error: Illegal application:
372 The term "@paths" of type "forall A : Type, A -> A -> Type"
373 cannot be applied to the term
374 "C" : "Type"
375 This term has type "Type@{Top.892}" which should be coercible to
376 "Type@{Top.882}".
377 *)
378 Abort.