Debian Codegraph @

test-suite/bugs/bug_3618.v

raw
1 Definition compose {A B C : Type} (g : B -> C) (f : A -> B) := fun x => g (f x).
2 Inductive paths {A : Type} (a : A) : A -> Type := idpath : paths a a.
3 Notation "x = y" := (@paths _ x y) : type_scope.
4 Definition concat {A} {x y z : A} : x = y -> y = z -> x = z. Admitted.
5 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x. Admitted.
6 Notation "p @ q" := (concat p q) (at level 20).
7 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y. Admitted.
8 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y. Admitted.
9
10 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
11 equiv_inv : B -> A ;
12 eisretr : forall x, f (equiv_inv x) = x;
13 eissect : forall x, equiv_inv (f x) = x
14 }.
15
16 Class Contr_internal (A : Type).
17
18 Inductive trunc_index : Type :=
19 | minus_two : trunc_index
20 | trunc_S : trunc_index -> trunc_index.
21
22 Fixpoint IsTrunc_internal (n : trunc_index) (A : Type) : Type :=
23 match n with
24 | minus_two => Contr_internal A
25 | trunc_S n' => forall (x y : A), IsTrunc_internal n' (x = y)
26 end.
27
28 Class IsTrunc (n : trunc_index) (A : Type) : Type :=
29 Trunc_is_trunc : IsTrunc_internal n A.
30 Definition istrunc_paths (A : Type) n `{H : IsTrunc (trunc_S n) A} (x y : A)
31 : IsTrunc n (x = y).
32 Admitted.
33
34 #[export] Hint Extern 4 (IsTrunc _ (_ = _)) => eapply @istrunc_paths : typeclass_instances.
35
36 Class Funext.
37
38 #[export] Instance isequiv_compose A B C f g `{IsEquiv A B f} `{IsEquiv B C g}
39 : IsEquiv (compose g f) | 1000.
40 Admitted.
41
42 Section IsEquivHomotopic.
43 Context (A B : Type) `(f : A -> B) `(g : A -> B) `{IsEquiv A B f} (h : forall x:A, f x = g x).
44 Let sect := (fun b:B => inverse (h (@equiv_inv _ _ f _ b)) @ @eisretr _ _ f _ b).
45 Let retr := (fun a:A => inverse (ap (@equiv_inv _ _ f _) (h a)) @ @eissect _ _ f _ a).
46 Global Instance isequiv_homotopic : IsEquiv g | 10000
47 := ( BuildIsEquiv _ _ g (@equiv_inv _ _ f _) sect retr).
48 End IsEquivHomotopic.
49
50 #[export] Instance trunc_succ A n `{IsTrunc n A} : IsTrunc (trunc_S n) A | 1000. Admitted.
51
52 Global Instance trunc_forall A n `{P : A -> Type} `{forall a, IsTrunc n (P a)}
53 : IsTrunc n (forall a, P a) | 100.
54 Admitted.
55
56 #[export] Instance trunc_prod A B n `{IsTrunc n A} `{IsTrunc n B} : IsTrunc n (A * B) | 100.
57 Admitted.
58
59 Global Instance trunc_arrow n {A B : Type} `{IsTrunc n B} : IsTrunc n (A -> B) | 100.
60 Admitted.
61
62 #[export] Instance isequiv_pr1_contr {A} {P : A -> Type} `{forall a, IsTrunc minus_two (P a)}
63 : IsEquiv (@projT1 A P) | 100.
64 Admitted.
65
66 #[export] Instance trunc_sigma n A `{P : A -> Type} `{IsTrunc n A} `{forall a, IsTrunc n (P a)}
67 : IsTrunc n (sigT P) | 100.
68 Admitted.
69
70 Global Instance trunc_trunc `{Funext} A m n : IsTrunc (trunc_S n) (IsTrunc m A) | 0.
71 Admitted.
72
73 Definition BiInv {A B} (f : A -> B) : Type
74 := ( {g : B -> A & forall x, g (f x) = x} * {h : B -> A & forall x, f (h x) = x}).
75
76 Global Instance isprop_biinv {A B} (f : A -> B) : IsTrunc (trunc_S minus_two) (BiInv f) | 0.
77 Admitted.
78
79 #[export] Instance isequiv_path {A B : Type} (p : A = B)
80 : IsEquiv (transport (fun X:Type => X) p) | 0.
81 Admitted.
82
83 Class ReflectiveSubuniverse_internal :=
84 { inO_internal : Type -> Type ;
85 O : Type -> Type ;
86 O_unit : forall T, T -> O T }.
87
88 Class ReflectiveSubuniverse :=
89 ReflectiveSubuniverse_wrap : Funext -> ReflectiveSubuniverse_internal.
90 Global Existing Instance ReflectiveSubuniverse_wrap.
91
92 Class inO {fs : Funext} {subU : ReflectiveSubuniverse} (T : Type) :=
93 isequiv_inO : inO_internal T.
94
95 Global Instance hprop_inO {fs : Funext} {subU : ReflectiveSubuniverse} (T : Type) : IsTrunc (trunc_S minus_two) (inO T) .
96 Admitted.
97
98 (* To avoid looping class resolution *)
99 #[export] Hint Mode IsEquiv - - + : typeclass_instances.
100
101 Fail Definition equiv_O_rectnd {fs : Funext} {subU : ReflectiveSubuniverse}
102 (P Q : Type) {Q_inO : inO_internal Q}
103 : IsEquiv (fun f : O P -> P => compose f (O_unit P)) := _.