| 1 |
(* An example involving a first-order unification triggering a cyclic constraint *) |
| 2 |
|
| 3 |
Module A. |
| 4 |
Notation "{ x : A | P }" := (sigT (fun x:A => P)). |
| 5 |
Notation "( x ; y )" := (existT _ x y) : fibration_scope. |
| 6 |
Open Scope fibration_scope. |
| 7 |
Notation "p @ q" := (eq_trans p q) (at level 20). |
| 8 |
Notation "p ^" := (eq_sym p) (at level 3). |
| 9 |
Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) |
| 10 |
: P y := |
| 11 |
match p with eq_refl => u end. |
| 12 |
Notation "p # x" := (transport _ p x) (right associativity, at level 65, only |
| 13 |
parsing). |
| 14 |
Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y |
| 15 |
:= match p with eq_refl => eq_refl end. |
| 16 |
Definition apD {A:Type} {B:A->Type} (f:forall a:A, B a) {x y:A} (p:x=y): p # (f |
| 17 |
x) = f y |
| 18 |
:= match p with eq_refl => eq_refl end. |
| 19 |
Axiom transport_compose |
| 20 |
: forall {A B} {x y : A} (P : B -> Type) (f : A -> B) (p : x = y) (z : P (f |
| 21 |
x)), |
| 22 |
transport (fun x => P (f x)) p z = transport P (ap f p) z. |
| 23 |
Delimit Scope morphism_scope with morphism. |
| 24 |
Delimit Scope category_scope with category. |
| 25 |
Delimit Scope object_scope with object. |
| 26 |
Record PreCategory := { object :> Type ; morphism : object -> object -> Type }. |
| 27 |
Delimit Scope functor_scope with functor. |
| 28 |
Record Functor (C D : PreCategory) := |
| 29 |
{ object_of :> C -> D; |
| 30 |
morphism_of : forall s d, morphism C s d -> morphism D (object_of s) |
| 31 |
(object_of d) }. |
| 32 |
Arguments object_of {C%_category D%_category} f%_functor c%_object : rename, simpl |
| 33 |
nomatch. |
| 34 |
Arguments morphism_of [C%_category] [D%_category] f%_functor [s%_object d%_object] |
| 35 |
m%morphism : rename, simpl nomatch. |
| 36 |
Section path_functor. |
| 37 |
Variable C : PreCategory. |
| 38 |
Variable D : PreCategory. |
| 39 |
|
| 40 |
Local Notation path_functor'_T F G |
| 41 |
:= { HO : object_of F = object_of G |
| 42 |
| transport (fun GO => forall s d, morphism C s d -> morphism D (GO s) |
| 43 |
(GO d)) |
| 44 |
HO |
| 45 |
(morphism_of F) |
| 46 |
= morphism_of G } |
| 47 |
(only parsing). |
| 48 |
Definition path_functor'_sig_inv (F G : Functor C D) : F = G -> |
| 49 |
path_functor'_T F G |
| 50 |
:= fun H' |
| 51 |
=> (ap object_of H'; |
| 52 |
(transport_compose _ object_of _ _) ^ @ apD (@morphism_of _ _) H'). |
| 53 |
|
| 54 |
End path_functor. |
| 55 |
End A. |
| 56 |
|
| 57 |
(* A variant of it with more axioms *) |
| 58 |
|
| 59 |
Module B. |
| 60 |
Notation "{ x : A | P }" := (sigT (fun x:A => P)). |
| 61 |
Notation "( x ; y )" := (existT _ x y). |
| 62 |
Notation "p @ q" := (eq_trans p q) (at level 20). |
| 63 |
Notation "p ^" := (eq_sym p) (at level 3). |
| 64 |
Axiom transport : forall {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x), P y. |
| 65 |
Notation "p # x" := (transport _ p x) (right associativity, at level 65, only |
| 66 |
parsing). |
| 67 |
Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y |
| 68 |
:= match p with eq_refl => eq_refl end. |
| 69 |
Axiom apD : forall {A:Type} {B:A->Type} (f:forall a:A, B a) {x y:A} (p:x=y), p # (f |
| 70 |
x) = f y. |
| 71 |
Axiom transport_compose |
| 72 |
: forall {A B} {x y : A} (P : B -> Type) (f : A -> B) (p : x = y) (z : P (f |
| 73 |
x)), |
| 74 |
transport (fun x => P (f x)) p z = transport P (ap f p) z. |
| 75 |
Record PreCategory := { object :> Type ; morphism : object -> object -> Type }. |
| 76 |
Record Functor (C D : PreCategory) := |
| 77 |
{ object_of :> C -> D; |
| 78 |
morphism_of : forall s d, morphism C s d -> morphism D (object_of s) |
| 79 |
(object_of d) }. |
| 80 |
Arguments object_of {C D} f c : rename, simpl nomatch. |
| 81 |
Arguments morphism_of [C] [D] f [s d] m : rename, simpl nomatch. |
| 82 |
Section path_functor. |
| 83 |
Variable C D : PreCategory. |
| 84 |
Local Notation path_functor'_T F G |
| 85 |
:= { HO : object_of F = object_of G |
| 86 |
| transport (fun GO => forall s d, morphism C s d -> morphism D (GO s) |
| 87 |
(GO d)) |
| 88 |
HO |
| 89 |
(morphism_of F) |
| 90 |
= morphism_of G }. |
| 91 |
Definition path_functor'_sig_inv (F G : Functor C D) : F = G -> |
| 92 |
path_functor'_T F G |
| 93 |
:= fun H' |
| 94 |
=> (ap object_of H'; |
| 95 |
(transport_compose _ object_of _ _) ^ @ apD (@morphism_of _ _) H'). |
| 96 |
|
| 97 |
End path_functor. |
| 98 |
End B. |