Debian Codegraph @

test-suite/bugs/bug_4533.v

raw
1 (* -*- mode: coq; coq-prog-args: ("-nois" "-indices-matter") -*- *)
2 (* File reduced by coq-bug-finder from original input, then from 1125 lines to
3 346 lines, then from 360 lines to 346 lines, then from 822 lines to 271 lines,
4 then from 285 lines to 271 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 Import Corelib.Init.Notations.
14 Global Set Universe Polymorphism.
15 Global Set Primitive Projections.
16 Notation "A -> B" := (forall (_ : A), B) : type_scope.
17 Module Export Datatypes.
18 Set Implicit Arguments.
19 Notation nat := Corelib.Init.Datatypes.nat.
20 Notation O := Corelib.Init.Datatypes.O.
21 Notation S := Corelib.Init.Datatypes.S.
22 Notation one := (S O).
23 Notation two := (S one).
24 Record prod (A B : Type) := pair { fst : A ; snd : B }.
25 Notation "x * y" := (prod x y) : type_scope.
26 Delimit Scope nat_scope with nat.
27 Open Scope nat_scope.
28 End Datatypes.
29 Module Export Specif.
30 Set Implicit Arguments.
31 Record sig {A} (P : A -> Type) := exist { proj1_sig : A ; proj2_sig : P
32 proj1_sig }.
33 Notation sigT := sig (only parsing).
34 Notation "{ x : A & P }" := (sigT (fun x:A => P)) : type_scope.
35 Notation projT1 := proj1_sig (only parsing).
36 Notation projT2 := proj2_sig (only parsing).
37 End Specif.
38 Global Set Keyed Unification.
39 Global Unset Strict Universe Declaration.
40 Definition Type1@{i} := Eval hnf in let gt := (Set : Type@{i}) in Type@{i}.
41 Definition Type2@{i j} := Eval hnf in let gt := (Type1@{j} : Type@{i}) in
42 Type@{i}.
43 Definition Type2le@{i j} := Eval hnf in let gt := (Set : Type@{i}) in
44 let ge := ((fun x => x) : Type1@{j} ->
45 Type@{i}) in Type@{i}.
46 Notation idmap := (fun x => x).
47 Delimit Scope function_scope with function.
48 Delimit Scope path_scope with path.
49 Delimit Scope fibration_scope with fibration.
50 Open Scope fibration_scope.
51 Open Scope function_scope.
52 Notation pr1 := projT1.
53 Notation pr2 := projT2.
54 Notation "x .1" := (pr1 x) : fibration_scope.
55 Notation "x .2" := (pr2 x) : fibration_scope.
56 Notation compose := (fun g f x => g (f x)).
57 Notation "g 'o' f" := (compose g%function f%function) (at level 40, left
58 associativity) : function_scope.
59 Inductive paths {A : Type} (a : A) : A -> Type := idpath : paths a a.
60 Arguments idpath {A a} , [A] a.
61 Scheme Rewriting for paths.
62 Notation "x = y :> A" := (@paths A x y) : type_scope.
63 Notation "x = y" := (x = y :>_) : type_scope.
64 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
65 := match p with idpath => idpath end.
66 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
67 match p, q with idpath, idpath => idpath end.
68 Notation "1" := idpath : path_scope.
69 Notation "p @ q" := (concat p%path q%path) (at level 20, left associativity) : path_scope.
70 Notation "p ^" := (inverse p%path) (at level 3, format "p '^'") : path_scope.
71 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
72 := match p with idpath => idpath end.
73 Definition pointwise_paths {A} {P:A->Type} (f g:forall x:A, P x)
74 := forall x:A, f x = g x.
75 Notation "f == g" := (pointwise_paths f g) (at level 70, no associativity) :
76 type_scope.
77 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
78 forall x : A, r (s x) = x.
79 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
80 equiv_inv : B -> A ;
81 eisretr : Sect equiv_inv f;
82 eissect : Sect f equiv_inv;
83 eisadj : forall x : A, eisretr
84 (f x) = ap f (eissect x)
85 }.
86 Arguments eissect {A B}%_type_scope f%_function_scope {_} _.
87 Inductive Unit : Type1 := tt : Unit.
88 Local Open Scope path_scope.
89 Definition concat_p_pp {A : Type} {x y z t : A} (p : x = y) (q : y = z) (r : z
90 = t) :
91 p @ (q @ r) = (p @ q) @ r :=
92 match r with idpath =>
93 match q with idpath =>
94 match p with idpath => 1
95 end end end.
96 Section Adjointify.
97 Context {A B : Type} (f : A -> B) (g : B -> A).
98 Context (isretr : Sect g f) (issect : Sect f g).
99 Let issect' := fun x =>
100 ap g (ap f (issect x)^) @ ap g (isretr (f x)) @ issect x.
101
102 Let is_adjoint' (a : A) : isretr (f a) = ap f (issect' a).
103 admit.
104 Defined.
105
106 Definition isequiv_adjointify : IsEquiv f
107 := BuildIsEquiv A B f g isretr issect' is_adjoint'.
108 End Adjointify.
109 Definition ExtensionAlong {A B : Type} (f : A -> B)
110 (P : B -> Type) (d : forall x:A, P (f x))
111 := { s : forall y:B, P y & forall x:A, s (f x) = d x }.
112 Fixpoint ExtendableAlong@{i j k l}
113 (n : nat) {A : Type@{i}} {B : Type@{j}}
114 (f : A -> B) (C : B -> Type@{k}) : Type@{l}
115 := match n with
116 | O => Unit@{l}
117 | S n => (forall (g : forall a, C (f a)),
118 ExtensionAlong@{i j k l l} f C g) *
119 forall (h k : forall b, C b),
120 ExtendableAlong n f (fun b => h b = k b)
121 end.
122
123 Definition ooExtendableAlong@{i j k l}
124 {A : Type@{i}} {B : Type@{j}}
125 (f : A -> B) (C : B -> Type@{k}) : Type@{l}
126 := forall n, ExtendableAlong@{i j k l} n f C.
127
128 Module Type ReflectiveSubuniverses.
129
130 Parameter ReflectiveSubuniverse@{u a} : Type2@{u a}.
131
132 Parameter O_reflector@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
133 Type2le@{i a} -> Type2le@{i a}.
134
135 Parameter In@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
136 Type2le@{i a} -> Type2le@{i a}.
137
138 Parameter O_inO@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T :
139 Type@{i}),
140 In@{u a i} O (O_reflector@{u a i} O T).
141
142 Parameter to@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T :
143 Type@{i}),
144 T -> O_reflector@{u a i} O T.
145
146 Parameter extendable_to_O@{u a i j k}
147 : forall (O : ReflectiveSubuniverse@{u a}) {P : Type2le@{i a}} {Q :
148 Type2le@{j a}} {Q_inO : In@{u a j} O Q},
149 ooExtendableAlong@{i i j k} (to O P) (fun _ => Q).
150
151 End ReflectiveSubuniverses.
152
153 Create HintDb typeclass_instances discriminated.
154
155 Module ReflectiveSubuniverses_Theory (Os : ReflectiveSubuniverses).
156 Export Os.
157 Existing Class In.
158 Module Export Coercions.
159 Coercion O_reflector : ReflectiveSubuniverse >-> Funclass.
160 End Coercions.
161 Global Existing Instance O_inO.
162
163 Section ORecursion.
164 Context {O : ReflectiveSubuniverse}.
165
166 Definition O_rec {P Q : Type} {Q_inO : In O Q}
167 (f : P -> Q)
168 : O P -> Q
169 := (fst (extendable_to_O O one) f).1.
170
171 Definition O_rec_beta {P Q : Type} {Q_inO : In O Q}
172 (f : P -> Q) (x : P)
173 : O_rec f (to O P x) = f x
174 := (fst (extendable_to_O O one) f).2 x.
175
176 Definition O_indpaths {P Q : Type} {Q_inO : In O Q}
177 (g h : O P -> Q) (p : g o to O P == h o to O P)
178 : g == h
179 := (fst (snd (extendable_to_O O two) g h) p).1.
180
181 End ORecursion.
182
183
184 Section Reflective_Subuniverse.
185 Context (O : ReflectiveSubuniverse@{Ou Oa}).
186
187 Definition isequiv_to_O_inO@{u a i} (T : Type@{i}) `{In@{u a i} O T} :
188 IsEquiv@{i i} (to O T).
189 Proof.
190
191 pose (g := O_rec@{u a i i i i i} idmap).
192 refine (isequiv_adjointify (to O T) g _ _).
193 -
194 refine (O_indpaths@{u a i i i i i} (to O T o g) idmap _).
195 intros x.
196 apply ap.
197 apply O_rec_beta.
198 -
199 intros x.
200 apply O_rec_beta.
201 Defined.
202 Global Existing Instance isequiv_to_O_inO.
203
204 End Reflective_Subuniverse.
205
206 End ReflectiveSubuniverses_Theory.
207
208 Module Type Preserves_Fibers (Os : ReflectiveSubuniverses).
209 Module Export Os_Theory := ReflectiveSubuniverses_Theory Os.
210 End Preserves_Fibers.
211
212 Opaque eissect.
213 Module Lex_Reflective_Subuniverses
214 (Os : ReflectiveSubuniverses) (Opf : Preserves_Fibers Os).
215 Import Opf.
216 Goal forall (O : ReflectiveSubuniverse) (A : Type) (B : A -> Type) (A_inO :
217 In O A),
218
219 forall g,
220 forall (x : O {x : A & B x}) v v' v'' (p2 : v'' = v') (p0 : v' = v) (p1 :
221 v = _) r,
222 (p2
223 @ (p0
224 @ p1))
225 @ eissect (to O A) (g x) = r.
226 intros.
227 cbv zeta.
228 rewrite concat_p_pp.
229 match goal with
230 | [ |- p2 @ p0 @ p1 @ eissect (to O A) (g x) = r ] => idtac "good"
231 | [ |- ?G ] => fail 1 "bad" G
232 end.
233 Fail rewrite concat_p_pp.
234 Abort.
235 End Lex_Reflective_Subuniverses.