Debian Codegraph @

test-suite/bugs/HoTT_coq_090.v

raw
1 Require Import TestSuite.admit.
2 (** I'm not sure if this tests what I want it to test... *)
3 Set Implicit Arguments.
4 Set Universe Polymorphism.
5
6 Notation idmap := (fun x => x).
7
8 Inductive paths {A : Type} (a : A) : A -> Type :=
9 idpath : paths a a.
10
11 Arguments idpath {A a} , [A] a.
12
13 Arguments paths_ind [A] a P f y p : rename.
14 Arguments paths_rec [A] a P f y p : rename.
15 Arguments paths_rect [A] a P f y p : rename.
16
17 Notation "x = y :> A" := (@paths A x y) : type_scope.
18 Notation "x = y" := (x = y :>_) : type_scope.
19
20 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
21 forall x : A, r (s x) = x.
22
23 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
24 := match p with idpath => idpath end.
25
26 (** A typeclass that includes the data making [f] into an adjoint equivalence. *)
27 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
28 equiv_inv : B -> A ;
29 eisretr : Sect equiv_inv f;
30 eissect : Sect f equiv_inv;
31 eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
32 }.
33
34 Arguments eisretr {A B} f {_} _.
35 Arguments eissect {A B} f {_} _.
36 Arguments eisadj {A B} f {_} _.
37
38
39 Record Equiv A B := BuildEquiv {
40 equiv_fun :> A -> B ;
41 equiv_isequiv :> IsEquiv equiv_fun
42 }.
43
44 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
45 match p, q with idpath, idpath => idpath end.
46
47 (** See above for the meaning of [simpl nomatch]. *)
48 Arguments concat {A x y z} p q : simpl nomatch.
49
50 (** The inverse of a path. *)
51 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
52 := match p with idpath => idpath end.
53
54 (** Declaring this as [simpl nomatch] prevents the tactic [simpl] from expanding it out into [match] statements. We only want [inverse] to simplify when applied to an identity path. *)
55 Arguments inverse {A x y} p : simpl nomatch.
56
57 (** Note that you can use the built-in Coq tactics [reflexivity] and [transitivity] when working with paths, but not [symmetry], because it is too smart for its own good. Instead, you can write [apply symmetry] or [eapply symmetry]. *)
58
59 (** The identity path. *)
60 Notation "1" := idpath : path_scope.
61
62 (** The composition of two paths. *)
63 Notation "p @ q" := (concat p q) (at level 20) : path_scope.
64
65 (** The inverse of a path. *)
66 Notation "p ^" := (inverse p) (at level 3) : path_scope.
67
68 (** An alternative notation which puts each path on its own line. Useful as a temporary device during proofs of equalities between very long composites; to turn it on inside a section, say [Open Scope long_path_scope]. *)
69 Notation "p @' q" := (concat p q) (at level 21, left associativity,
70 format "'[v' p '/' '@'' q ']'") : long_path_scope.
71
72
73 (** An important instance of [paths_rect] is that given any dependent type, one can _transport_ elements of instances of the type along equalities in the base.
74
75 [transport P p u] transports [u : P x] to [P y] along [p : x = y]. *)
76 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y :=
77 match p with idpath => u end.
78
79 (** See above for the meaning of [simpl nomatch]. *)
80 Arguments transport {A} P {x y} p%_path_scope u : simpl nomatch.
81
82
83
84 #[export] Instance isequiv_path {A B : Type} (p : A = B)
85 : IsEquiv (transport (fun X:Type => X) p) | 0.
86 Proof.
87 unshelve refine (@BuildIsEquiv _ _ _ (transport (fun X:Type => X) p^) _ _ _);
88 admit.
89 Defined.
90
91 Definition equiv_path (A B : Type) (p : A = B) : Equiv A B
92 := @BuildEquiv _ _ (transport (fun X:Type => X) p) _.
93
94 Arguments equiv_path : clear implicits.
95
96 Definition equiv_adjointify A B (f : A -> B) (g : B -> A) (r : Sect g f) (s : Sect f g) : Equiv A B.
97 Proof.
98 refine (@BuildEquiv A B f (@BuildIsEquiv A B f g r s _)).
99 admit.
100 Defined.
101
102
103 Set Printing Universes.
104
105 Definition lift_id_type : Type.
106 Proof.
107 let U0 := constr:(Type) in
108 let U1 := constr:(Type) in
109 let unif := constr:(U0 : U1) in
110 exact (forall (A : Type) (B : Type), @paths U0 A B -> @paths U1 A B).
111 Defined.
112
113 Definition lower_id_type : Type.
114 Proof.
115 let U0 := constr:(Type) in
116 let U1 := constr:(Type) in
117 let unif := constr:(U0 : U1) in
118 exact ((forall (A : Type) (B : Type), IsEquiv (equiv_path (A : U0) (B : U0)))
119 -> forall (A : Type) (B : Type), @paths U1 A B -> @paths U0 A B).
120 Defined.
121
122 Definition lift_id : lift_id_type :=
123 fun A B p => match p in @paths _ _ B return @paths Type (A : Type) (B : Type) with
124 | idpath => idpath
125 end.
126
127 Definition lower_id : lower_id_type.
128 Proof.
129 intros ua A B p.
130 specialize (ua A B).
131 apply (@equiv_inv _ _ (equiv_path A B) _).
132 simpl.
133 pose (f := transport idmap p : A -> B).
134 pose (g := transport idmap p^ : B -> A).
135 refine (@equiv_adjointify
136 _ _
137 f g
138 _ _);
139 subst f g; unfold transport, inverse;
140 clear ua;
141 [ intro x
142 | exact match p as p in (_ = B) return
143 (forall x : (A : Type),
144 @paths (* Top.904 *)
145 A
146 match
147 match
148 p in (paths _ a)
149 return (@paths (* Top.906 *) Type (* Top.900 *) a A)
150 with
151 | idpath => @idpath (* Top.906 *) Type (* Top.900 *) A
152 end in (paths _ a) return a
153 with
154 | idpath => match p in (paths _ a) return a with
155 | idpath => x
156 end
157 end x)
158 with
159 | idpath => fun _ => idpath
160 end ].
161
162 - pose proof (match p as p in (_ = B) return
163 (forall x : (B : Type),
164 match p in (_ = a) return (a : Type) with
165 | idpath =>
166 match
167 match p in (_ = a) return (@paths Type (a : Type) (A : Type)) with
168 | idpath => idpath
169 end in (_ = a) return (a : Type)
170 with
171 | idpath => x
172 end
173 end = x)
174 with
175 | idpath => fun _ => idpath
176 end x) as p'.
177 admit.
178 Defined.
179 (* Error: Illegal application:
180 The term "paths (* Top.96 *)" of type
181 "forall A : Type (* Top.96 *), A -> A -> Type (* Top.96 *)"
182 cannot be applied to the terms
183 "Type (* Top.100 *)" : "Type (* Top.100+1 *)"
184 "a" : "Type (* Top.60 *)"
185 "A" : "Type (* Top.57 *)"
186 The 2nd term has type "Type (* Top.60 *)" which should be coercible to
187 "Type (* Top.100 *)".
188 *)