Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set Implicit Arguments.
- Ltac hypothesis := match goal with [ H : _ |- _ ] => apply H end.
- Section PublicService.
- Inductive False : Type :=.
- Definition Not (P : Type) := P -> False.
- Inductive True : Type :=
- | I : True.
- Inductive Identity (T : Type) (t : T) : T -> Type :=
- | identical : Identity t t.
- Inductive And (P Q : Type) : Type :=
- | both : P -> Q -> And P Q.
- Definition proj1 {P Q} (a : And P Q) : P :=
- match a with both p q => p end.
- Definition proj2 {P Q} (a : And P Q) : Q :=
- match a with both p q => q end.
- Definition And_idem (P : Type) : P -> And P P.
- intro p; apply (both p p).
- Defined.
- Inductive Or (P Q : Type) : Type :=
- | inleft : P -> Or P Q
- | inright : Q -> Or P Q.
- Definition Decidable (P : Type) := Or P (Not P).
- Inductive Sigma (T : Type) (P : T -> Type) : Type :=
- | witness : forall t : T, P t -> Sigma P.
- Definition pi1 {T P} (s : @Sigma T P) : T :=
- match s with
- | witness t _ => t
- end.
- Definition pi2 {T P} (s : @Sigma T P) : P (pi1 s) :=
- match s with
- | witness _ p => p
- end.
- Definition Relation (T : Type) := T -> T -> Type.
- Record Equivalence {T : Type} (R : Relation T)
- := { equivalence_reflexivity : forall x, R x x
- ; equivalence_symmetry : forall x y, R x y -> R y x
- ; equivalence_transitivity : forall x y z, R x y -> R y z -> R x z
- }.
- Theorem Equivalence_Identity {T : Type} : Equivalence (@Identity T).
- apply Build_Equivalence.
- intros x; apply identical.
- intros x y; intro E; elim E; apply identical.
- intros x y z; intros E F; elim F; elim E; apply identical.
- Defined.
- Theorem Equivalence_Pullback {X T} (R : Relation T) (f : X -> T) : Equivalence R -> Equivalence (fun x y => R (f x) (f y)).
- intros [Erefl Esymm Etrans].
- apply Build_Equivalence.
- intros; apply Erefl.
- intros; apply Esymm; assumption.
- intros; apply Etrans with (y := f y); assumption.
- Defined.
- Theorem Equivalence_Identity_Pullback {X T : Type} (f : X -> T) : Equivalence (fun x x' => @Identity T (f x) (f x')).
- apply Equivalence_Pullback.
- apply Equivalence_Identity.
- Defined.
- Theorem Equivalence_Product {T} (R R' : Relation T) :
- Equivalence R -> Equivalence R' -> Equivalence (fun x y => And (R x y) (R' x y)).
- intros E1 E2; destruct E1; destruct E2.
- apply Build_Equivalence;
- intros; constructor;
- try match goal with H : _ |- _ => solve [ apply H;
- match goal with H : _ |- _ => solve [ apply H ] end ] end.
- destruct X; eapply equivalence_transitivity0; hypothesis.
- destruct X0; eapply equivalence_transitivity1; hypothesis.
- Defined.
- End PublicService.
- Section CategoryTheory.
- Record Category
- (Ob : Type)
- (Hom : Ob -> Ob -> Type)
- (Hom_eq : forall X Y, Relation (Hom X Y))
- := { identity : forall X, Hom X X
- ; compose : forall X Y Z, Hom X Y -> Hom Y Z -> Hom X Z
- ; Compose_respectful_left : forall X Y Z (f f' : Hom X Y) (g : Hom Y Z),
- Hom_eq _ _ f f' ->
- Hom_eq _ _ (compose f g) (compose f' g)
- ; Compose_respectful_right : forall X Y Z (f : Hom X Y) (g g' : Hom Y Z),
- Hom_eq _ _ g g' ->
- Hom_eq _ _ (compose f g) (compose f g')
- ; category_equivalence : forall X Y, Equivalence (Hom_eq X Y)
- ; category_left_identity : forall X Y (f : Hom X Y),
- Hom_eq _ _ (compose (identity _) f) f
- ; category_right_identity : forall X Y (f : Hom X Y),
- Hom_eq _ _ (compose f (identity _)) f
- ; category_associativity : forall X Y Z W (f : Hom X Y) (g : Hom Y Z) (h : Hom Z W),
- Hom_eq _ _ (compose f (compose g h))
- (compose (compose f g) h)
- }.
- End CategoryTheory.
- Notation "f '[' C ']' g" := (compose C _ _ _ f g) (at level 20).
- Notation "'Id[' C ']'" := (identity C _) (at level 20).
- Section Functor.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Record Functor
- := { Map_Ob : C_Ob -> D_Ob
- ; Map_Hom : forall X Y,
- C_Hom X Y -> D_Hom (Map_Ob X) (Map_Ob Y)
- ; functor_identity : forall X,
- D_Hom_eq (Map_Hom (identity C X)) (identity D (Map_Ob X))
- ; functor_compose : forall X Y Z (f : C_Hom X Y) (g : C_Hom Y Z),
- D_Hom_eq (Map_Hom (compose C _ _ _ f g)) (compose D _ _ _ (Map_Hom f) (Map_Hom g))
- ; Map_Hom_respectful : forall X Y (f f' : C_Hom X Y),
- C_Hom_eq f f' -> D_Hom_eq (Map_Hom f) (Map_Hom f')
- }.
- End Functor.
- Notation "F '@' x" := (Map_Ob F x) (at level 20).
- Notation "F '$' f" := (Map_Hom F _ _ f) (at level 20).
- Section SYMBOLIC.
- Context {Ob Hom Hom_eq} (C : @Category Ob Hom Hom_eq).
- Inductive Syntax : Ob -> Ob -> Type :=
- | idSYM : forall X : Ob, Syntax X X
- | compSYM : forall X Y Z : Ob, Syntax X Y -> Syntax Y Z -> Syntax X Z
- | injSYM : forall X Y, Hom X Y -> Syntax X Y.
- Inductive Semantics : Ob -> Ob -> Type :=
- | nilSYM : forall X : Ob, Semantics X X
- | consSYM : forall X Y Z : Ob, Hom X Y -> Semantics Y Z -> Semantics X Z.
- Fixpoint append {X Y Z : Ob} (f : Semantics X Y) : Semantics Y Z -> Semantics X Z :=
- match f with
- | nilSYM _ => fun g => g
- | consSYM _ _ _ s f => fun g => consSYM s (append f g)
- end.
- Lemma append_nil :
- forall (X Y : Ob) (x : Semantics X Y),
- Identity (append x (nilSYM Y)) x.
- induction x; simpl.
- apply identical.
- elim (equivalence_symmetry Equivalence_Identity _ _ IHx).
- apply identical.
- Defined.
- Lemma append_associative :
- forall (X Y Z W : Ob) (f : Semantics X Y) (g : Semantics Y Z) (h : Semantics Z W),
- Identity (append f (append g h))
- (append (append f g) h).
- intros; induction f; simpl.
- apply identical.
- elim (IHf _).
- apply identical.
- Defined.
- Fixpoint evalSYN {X Y} (s : Syntax X Y) : Semantics X Y :=
- match s with
- | idSYM _ => nilSYM _
- | compSYM _ _ _ f g => append (evalSYN f) (evalSYN g)
- | injSYM _ _ f => consSYM f (nilSYM _)
- end.
- Fixpoint quoteSYN {X Y} (s : Semantics X Y) : Syntax X Y :=
- match s with
- | nilSYM _ => idSYM _
- | consSYM _ _ _ f s => compSYM (injSYM f) (quoteSYN s)
- end.
- Definition Syntax_eq {X Y : Ob} (f f' : Syntax X Y) :=
- Identity (evalSYN f) (evalSYN f').
- Theorem Equivalence_Syntax_eq {X Y} : Equivalence (@Syntax_eq X Y).
- apply (Equivalence_Identity_Pullback evalSYN).
- Defined.
- Definition SYNTAX_category : Category Syntax (@Syntax_eq).
- apply (Build_Category Syntax (@Syntax_eq)
- idSYM
- compSYM); unfold Syntax_eq; simpl.
- intros X Y Z f f' g E; elim E; apply identical.
- intros X Y Z f g g' E; elim E; apply identical.
- intros X Y; apply Equivalence_Syntax_eq.
- intros X Y f; apply identical.
- intros X Y f; apply append_nil.
- intros X Y Z W f g h; apply append_associative.
- Defined.
- Theorem quote_eval_equal {X Y : Ob} (f : Syntax X Y) :
- Syntax_eq (quoteSYN (evalSYN f)) f.
- induction f; simpl in *;
- try apply identical.
- Lemma quote_eval_equal_lemma {X Y Z} (e1 : Semantics X Y) (e2 : Semantics Y Z) :
- Syntax_eq (quoteSYN (append e1 e2)) (compSYM (quoteSYN e1) (quoteSYN e2)).
- intros; induction e1; simpl.
- apply identical.
- elim (IHe1 e2).
- eapply (equivalence_transitivity (category_equivalence SYNTAX_category _ _)).
- Focus 2.
- apply (category_associativity SYNTAX_category _ _).
- apply (Compose_respectful_right SYNTAX_category).
- apply IHe1.
- Defined.
- eapply (equivalence_transitivity Equivalence_Syntax_eq).
- apply quote_eval_equal_lemma.
- eapply (equivalence_transitivity (category_equivalence SYNTAX_category _ _)).
- apply (Compose_respectful_left SYNTAX_category).
- apply IHf1.
- eapply (equivalence_transitivity (category_equivalence SYNTAX_category _ _)).
- apply (Compose_respectful_right SYNTAX_category).
- apply IHf2.
- apply (equivalence_reflexivity (category_equivalence SYNTAX_category _ _)).
- Defined.
- Fixpoint interpret_Syntax {X Y} (f : Syntax X Y) : Hom X Y :=
- match f with
- | idSYM _ => identity C _
- | compSYM _ _ _ f g => compose C _ _ _ (interpret_Syntax f) (interpret_Syntax g)
- | injSYM _ _ f => f
- end.
- Fixpoint interpret_Semantics {X Y} (f : Semantics X Y) : Hom X Y :=
- match f with
- | nilSYM _ => identity C _
- | consSYM _ _ _ s f => compose C _ _ _ s (interpret_Semantics f)
- end.
- Theorem interpretation_factors_through_evaluation {X Y} (f : Syntax X Y) :
- Hom_eq (interpret_Syntax f)
- (interpret_Semantics (evalSYN f)).
- induction f; simpl.
- apply (equivalence_reflexivity (category_equivalence C _ _)).
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply Compose_respectful_left.
- apply IHf1.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply Compose_respectful_right.
- apply IHf2.
- Lemma append_pushthrough_compose {X Y Z} (f : Semantics X Y) (g : Semantics Y Z) :
- Hom_eq (compose C _ _ _ (interpret_Semantics f) (interpret_Semantics g))
- (interpret_Semantics (append f g)).
- induction f; simpl.
- apply category_left_identity.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply (equivalence_symmetry (category_equivalence C _ _)).
- apply (category_associativity C).
- apply Compose_respectful_right.
- apply IHf.
- Defined.
- apply append_pushthrough_compose.
- apply (equivalence_symmetry (category_equivalence C _ _)).
- apply category_right_identity.
- Defined.
- Definition Interpret : Functor SYNTAX_category C.
- Print Build_Functor.
- apply (Build_Functor
- SYNTAX_category C
- (fun X => X)
- (fun X Y f => interpret_Syntax f)
- ).
- intros; apply (equivalence_reflexivity (category_equivalence C _ _)).
- intros; apply (equivalence_reflexivity (category_equivalence C _ _)).
- intros X Y f f' E.
- pose (quote_eval_equal f) as A.
- pose (quote_eval_equal f') as B.
- pose (interpretation_factors_through_evaluation f) as U.
- pose (interpretation_factors_through_evaluation f') as V.
- unfold Syntax_eq in *.
- assert (
- Hom_eq (interpret_Syntax f) (interpret_Semantics (evalSYN f'))
- ) as P.
- elim E.
- assumption.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply P.
- apply (equivalence_symmetry (category_equivalence C _ _)).
- apply V.
- Defined.
- End SYMBOLIC.
- Section Trinkets.
- Context {Ob Hom Hom_eq} (C : @Category Ob Hom Hom_eq).
- Definition Isomorphism (X Y : Ob) (f : Hom X Y) :=
- @Sigma (Hom Y X)
- (fun (g : Hom Y X) =>
- And (Hom_eq (compose C _ _ _ f g) (identity C _))
- (Hom_eq (compose C _ _ _ g f) (identity C _))).
- Definition Exists {X Y : Ob} (P : Hom X Y -> Type) :=
- @Sigma (Hom X Y) P.
- Definition ExistsUnique {X Y : Ob} (P : Hom X Y -> Type) :=
- And (Exists P)
- (forall f f' : Hom X Y,
- P f -> P f' -> Hom_eq f f').
- Definition Terminal (C : @Category Ob Hom Hom_eq) (T : Ob) :=
- forall X, ExistsUnique (fun f : Hom X T => True).
- Definition Initial (C : @Category Ob Hom Hom_eq) (T : Ob) :=
- forall X, ExistsUnique (fun f : Hom T X => True).
- End Trinkets.
- Section OppositeCategory.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Definition OppositeCategory : @Category C_Ob (fun Y X => C_Hom X Y) (fun Y X f => C_Hom_eq f).
- apply (Build_Category
- (fun Y X => C_Hom X Y) (fun Y X f => C_Hom_eq f)
- (fun X => identity C X)
- (fun X Y Z f g => compose C Z Y X g f)).
- intros; apply Compose_respectful_right; assumption.
- intros; apply Compose_respectful_left; assumption.
- intros;
- apply Build_Equivalence; destruct (category_equivalence C X Y);
- hypothesis.
- intros; apply category_right_identity.
- intros; apply category_left_identity.
- intros.
- apply (equivalence_symmetry (category_equivalence C _ _)).
- apply category_associativity.
- Defined.
- End OppositeCategory.
- Section Terminal_Initial_Stuff.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Definition Cop := OppositeCategory C.
- Theorem TerminalOp_Initial (L : C_Ob) :
- Terminal Cop L -> Initial C L.
- unfold Terminal; unfold Initial.
- intros f X; destruct (f X) as [[g IPrf] gPrf].
- constructor.
- apply (witness _ g).
- constructor.
- apply gPrf.
- Defined.
- Theorem InitialOp_Terminal (L : C_Ob) :
- Initial Cop L -> Terminal C L.
- unfold Terminal; unfold Initial.
- intros f X; destruct (f X) as [[g IPrf] gPrf].
- constructor.
- apply (witness _ g).
- constructor.
- apply gPrf.
- Defined.
- Theorem Terminal_unique_up_to_unique_isomorphism (T T' : C_Ob) :
- Terminal C T -> Terminal C T' ->
- ExistsUnique (Hom_eq := C_Hom_eq) (Isomorphism C T T').
- unfold Terminal; unfold ExistsUnique.
- intros Tprf T'prf.
- destruct (Tprf T') as [[TprfA _] TprfB].
- destruct (T'prf T) as [[T'prfA _] T'prfB].
- constructor.
- apply (witness _ T'prfA).
- apply (witness _ TprfA).
- constructor; hypothesis; apply I.
- intros f f'; intros.
- apply (T'prfB f f'); apply I.
- Defined.
- End Terminal_Initial_Stuff.
- Section BijectionSubcategory.
- Context {Ob Hom Hom_eq} (C : @Category Ob Hom Hom_eq).
- Definition Bijection (X Y : Ob) := Exists (Isomorphism C X Y).
- Definition Invert_Bijection (X Y : Ob) : Bijection X Y -> Bijection Y X.
- intros [f [g [p1 p2]]].
- apply (witness _ g).
- apply (witness _ f).
- constructor; assumption.
- Defined.
- Definition Identity_Bijection (X : Ob) : Bijection X X.
- apply (witness _ (identity C X)).
- apply (witness _ (identity C X)).
- apply And_idem.
- apply category_left_identity.
- Defined.
- Definition Compose_Bijection (X Y Z : Ob)
- (f : Bijection X Y) (g : Bijection Y Z) :
- Bijection X Z.
- unfold Bijection in *.
- destruct f as [fTo [fFrom [fPrf fPrf']]].
- destruct g as [gTo [gFrom [gPrf gPrf']]].
- apply (witness _ (compose C _ _ _ fTo gTo)).
- apply (witness _ (compose C _ _ _ gFrom fFrom)).
- Lemma Compose_Bijection_Lemma
- (X Y Z : Ob)
- (fTo : Hom X Y)
- (fFrom : Hom Y X)
- (fPrf : Hom_eq (compose C X Y X fTo fFrom) (identity C X))
- (fPrf' : Hom_eq (compose C Y X Y fFrom fTo) (identity C Y))
- (gTo : Hom Y Z)
- (gFrom : Hom Z Y)
- (gPrf : Hom_eq (compose C Y Z Y gTo gFrom) (identity C Y))
- :
- (Hom_eq
- (compose C X Z X (compose C X Y Z fTo gTo)
- (compose C Z Y X gFrom fFrom)) (identity C X)).
- pose (@SYNTAX_category Ob Hom) as SYN.
- assert (
- Syntax_eq
- (compose SYN X Z X (compose SYN X Y Z (injSYM _ _ fTo) (injSYM _ _ gTo)) (compose SYN Z Y X (injSYM _ _ gFrom) (injSYM _ _ fFrom)))
- (compose SYN _ _ _ (injSYM _ _ fTo)
- (compose SYN _ _ _
- (compose SYN _ _ _ (injSYM _ _ gTo) (injSYM _ _ gFrom))
- (injSYM _ _ fFrom)))
- ) as EQUATION by apply identical.
- pose (Map_Hom_respectful (Interpret C) _ _ _ _ EQUATION) as EQUATION'; simpl in EQUATION'.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply EQUATION'.
- clear EQUATION'; clear EQUATION.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply Compose_respectful_right.
- apply Compose_respectful_left.
- apply gPrf.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply Compose_respectful_right.
- apply category_left_identity.
- apply fPrf.
- Defined.
- apply both; apply Compose_Bijection_Lemma;
- assumption.
- Defined.
- Definition BijectionSubcategory :
- @Category Ob Bijection
- (fun (X Y : Ob) (f g : Bijection X Y) =>
- Hom_eq (pi1 f) (pi1 g)).
- apply (Build_Category
- Bijection
- (fun (X Y : Ob) (f g : Bijection X Y) =>
- Hom_eq (pi1 f) (pi1 g))
- (fun X => Identity_Bijection X)
- (fun X Y Z f g => Compose_Bijection f g)).
- intros X Y Z f f' g.
- destruct f as [fTo [fFrom [fPrfTo fPrfFrom]]].
- destruct f' as [f'To [f'From [f'PrfTo f'PrfFrom]]].
- destruct g as [gTo [gFrom [gPrfTo gPrfFrom]]].
- simpl.
- apply Compose_respectful_left.
- intros X Y Z f f' g.
- destruct f as [fTo [fFrom [fPrfTo fPrfFrom]]].
- destruct f' as [f'To [f'From [f'PrfTo f'PrfFrom]]].
- destruct g as [gTo [gFrom [gPrfTo gPrfFrom]]].
- simpl.
- apply Compose_respectful_right.
- intros; apply Equivalence_Pullback.
- apply (category_equivalence C).
- intros X Y.
- destruct f as [fTo [fFrom [fPrfTo fPrfFrom]]].
- simpl.
- apply category_left_identity.
- intros X Y.
- destruct f as [fTo [fFrom [fPrfTo fPrfFrom]]].
- simpl.
- apply category_right_identity.
- intros X Y Z W.
- destruct f as [fTo [fFrom [fPrfTo fPrfFrom]]].
- destruct g as [gTo [gFrom [gPrfTo gPrfFrom]]].
- destruct h as [hTo [hFrom [hPrfTo hPrfFrom]]].
- simpl.
- apply category_associativity.
- Defined.
- Definition BijectionSubcategory_Embedding : Functor BijectionSubcategory C.
- apply (Build_Functor BijectionSubcategory C
- (fun X => X)
- (fun X Y f => pi1 f)); simpl; intros.
- apply (equivalence_reflexivity (category_equivalence C _ _)).
- destruct f as [fTo [fFrom [fPrfTo fPrfFrom]]].
- destruct g as [gTo [gFrom [gPrfTo gPrfFrom]]].
- simpl.
- apply (equivalence_reflexivity (category_equivalence C _ _)).
- assumption.
- Defined.
- End BijectionSubcategory.
- Section Functors.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Context {E_Ob E_Hom E_Hom_eq} (E : @Category E_Ob E_Hom E_Hom_eq).
- Definition Constant_Functor (V : D_Ob) : Functor C D.
- apply (Build_Functor C D
- (fun _ => V)
- (fun _ _ _ => identity D V)); intros.
- apply (equivalence_reflexivity (category_equivalence D _ _)).
- apply (equivalence_symmetry (category_equivalence D _ _)).
- apply category_left_identity.
- apply (equivalence_reflexivity (category_equivalence D _ _)).
- Defined.
- Definition Identity_Functor : Functor C C.
- apply (Build_Functor C C
- (fun X => X)
- (fun _ _ f => f)); intros.
- apply (equivalence_reflexivity (category_equivalence C _ _)).
- apply (equivalence_reflexivity (category_equivalence C _ _)).
- assumption.
- Defined.
- Definition Compose_Functors (F : Functor C D) (G : Functor D E) : Functor C E.
- apply (Build_Functor C E
- (fun X => Map_Ob G (Map_Ob F X))
- (fun _ _ f => Map_Hom G _ _ (Map_Hom F _ _ f))); intros.
- apply (equivalence_transitivity (category_equivalence E _ _))
- with (y := Map_Hom G _ _ (identity D _)).
- apply Map_Hom_respectful.
- apply (functor_identity F).
- apply (functor_identity G).
- apply (equivalence_transitivity (category_equivalence E _ _))
- with (y := Map_Hom G _ _ (compose D _ _ _
- (Map_Hom F _ _ f) (Map_Hom F _ _ g))).
- apply Map_Hom_respectful.
- apply (functor_compose F).
- apply (functor_compose G).
- apply Map_Hom_respectful.
- apply Map_Hom_respectful.
- assumption.
- Defined.
- Definition Equal_Functors (F F' : Functor C D) : Type :=
- @Sigma (forall X, Exists (Isomorphism D (Map_Ob F X) (Map_Ob F' X)))
- (fun iso =>
- forall X Y (f : C_Hom X Y),
- D_Hom_eq
- (compose D _ _ _ (Map_Hom F _ _ f) (pi1 (iso Y)))
- (compose D _ _ _ (pi1 (iso X)) (Map_Hom F' _ _ f))).
- Theorem Equivalence_Equal_Functors : Equivalence Equal_Functors.
- unfold Equal_Functors; apply Build_Equivalence.
- intro F; apply (witness _ (fun X => identity (BijectionSubcategory D) (Map_Ob F X))); simpl.
- intros X Y f.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply category_right_identity.
- apply (equivalence_symmetry (category_equivalence D _ _)).
- apply category_left_identity.
- intros F G [a b].
- apply (witness _ (fun X => Invert_Bijection (a X))).
- intros X Y f.
- generalize (b _ _ f).
- destruct (a X) as [ax' [ax'' [ax''' ax'''']]].
- destruct (a Y) as [ay' [ay'' [ay''' ay'''']]].
- simpl.
- Lemma eq_functors_lemma1
- (F : Functor C D) (G : Functor C D)
- (X : C_Ob) (Y : C_Ob) (f : C_Hom X Y)
- (ax' : D_Hom (F @ X) (G @ X))
- (ax'' : D_Hom (G @ X) (F @ X))
- (ax''' : D_Hom_eq (ax' [D] ax'') (Id[D]))
- (ax'''' : D_Hom_eq (ax'' [D] ax') (Id[D]))
- (ay' : D_Hom (F @ Y) (G @ Y))
- (ay'' : D_Hom (G @ Y) (F @ Y))
- (ay''' : D_Hom_eq (ay' [D] ay'') (Id[D]))
- (ay'''' : D_Hom_eq (ay'' [D] ay') (Id[D])) :
- D_Hom_eq ((F $ f) [D] ay') (ax' [D] (G $ f)) ->
- D_Hom_eq ((G $ f) [D] ay'') (ax'' [D] (F $ f)).
- pose (@SYNTAX_category D_Ob D_Hom) as SYN.
- intro Q.
- assert (
- D_Hom_eq (ax'' [D] (((F $ f) [D] ay') [D] ay''))
- (ax'' [D] ((ax' [D] (G $ f)) [D] ay''))
- ).
- apply Compose_respectful_right.
- apply Compose_respectful_left.
- apply Q.
- assert (
- D_Hom_eq (ax'' [D] ((ax' [D] (G $ f)) [D] ay''))
- (ax'' [D] (((F $ f) [D] ay') [D] ay''))
- ).
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply Compose_respectful_right.
- apply Compose_respectful_left.
- apply (equivalence_symmetry (category_equivalence D _ _)).
- apply Q.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- Focus 2.
- apply Compose_respectful_right.
- apply Compose_respectful_left.
- apply (equivalence_symmetry (category_equivalence D _ _)).
- apply Q.
- assumption.
- assert (
- D_Hom_eq (ax'' [D] (((F $ f) [D] ay') [D] ay''))
- (ax'' [D] (F $ f))
- ).
- assert (
- Syntax_eq ((injSYM _ _ ax'') [SYN] (((injSYM _ _ ((F $ f))) [SYN] (injSYM _ _ ay')) [SYN] (injSYM _ _ ay'')))
- (((injSYM _ _ ax'') [SYN] (injSYM _ _ ((F $ f)))) [SYN] ((injSYM _ _ ay') [SYN] (injSYM _ _ ay'')))
- ) as EQUATION by apply identical.
- pose (Map_Hom_respectful (Interpret D) _ _ _ _ EQUATION) as EQUATION'; simpl in EQUATION'.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply EQUATION'.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- Focus 2.
- apply category_right_identity.
- apply Compose_respectful_right.
- assumption.
- assert (
- D_Hom_eq (ax'' [D] ((ax' [D] (G $ f)) [D] ay''))
- ((G $ f) [D] ay'')
- ).
- assert (
- Syntax_eq ((injSYM _ _ ax'') [SYN] (((injSYM _ _ ax') [SYN] (injSYM _ _ ((G $ f)))) [SYN] (injSYM _ _ ay'')))
- (((injSYM _ _ ax'') [SYN] (injSYM _ _ ax')) [SYN] ((injSYM _ _ ((G $ f)) [SYN] (injSYM _ _ ay''))))
- ) as EQUATION by apply identical.
- pose (Map_Hom_respectful (Interpret D) _ _ _ _ EQUATION) as EQUATION'; simpl in EQUATION'.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply EQUATION'.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- Focus 2.
- apply category_left_identity.
- apply Compose_respectful_left.
- assumption.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- eapply (equivalence_symmetry (category_equivalence D _ _)).
- apply X3.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply X1.
- assumption.
- Defined.
- apply eq_functors_lemma1; assumption.
- intros F G H [fg FG] [gh GH].
- apply (witness _ (fun X => compose (BijectionSubcategory D) _ _ _
- (fg X) (gh X))); simpl.
- intros X Y f.
- generalize (FG _ _ f).
- generalize (GH _ _ f).
- destruct (fg X) as [fgXF [fgXG [fgXPrf fpXPrf']]].
- destruct (gh X) as [ghXF [ghXG [ghXPrf ghXPrf']]].
- destruct (fg Y) as [fgYF [fgYG [fgYPrf fpYPrf']]].
- destruct (gh Y) as [ghYF [ghYG [ghYPrf ghYPrf']]].
- simpl.
- intros A B.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply (category_associativity D).
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- Focus 2.
- apply (category_associativity D).
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply Compose_respectful_left.
- apply B.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply (equivalence_symmetry (category_equivalence D _ _)).
- apply (category_associativity D).
- apply Compose_respectful_right.
- apply A.
- Defined.
- End Functors.
- Section NaturalTransformation.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Context (F G : Functor C D).
- Record NaturalTransformation
- := { Component : forall X : C_Ob, D_Hom (Map_Ob F X) (Map_Ob G X)
- ; naturality : forall X Y (f : C_Hom X Y),
- D_Hom_eq ((F $ f) [D] Component Y)
- (Component X [D] (G $ f))
- }.
- End NaturalTransformation.
- Section NaturalTransformations.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Context (F G H : Functor C D).
- Definition Identity_NaturalTransformation : NaturalTransformation F F.
- apply (Build_NaturalTransformation F F
- (fun X => identity D (F @ X))).
- intros X Y f.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply category_right_identity.
- eapply (equivalence_symmetry (category_equivalence D _ _)).
- apply category_left_identity.
- Defined.
- Definition Compose_NaturalTransformations
- (FG : NaturalTransformation F G)
- (GH : NaturalTransformation G H) :
- NaturalTransformation F H.
- apply (Build_NaturalTransformation F H
- (fun X => Component FG X [D] Component GH X)).
- intros X Y f.
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply (category_associativity D).
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- Focus 2.
- apply (category_associativity D).
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- apply Compose_respectful_left.
- apply (naturality FG).
- eapply (equivalence_transitivity (category_equivalence D _ _)).
- eapply (equivalence_symmetry (category_equivalence D _ _)).
- apply (category_associativity D).
- apply Compose_respectful_right.
- apply (naturality GH).
- Defined.
- End NaturalTransformations.
- Section FunctorCategory.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Definition Funct : @Category (Functor C D) (fun F G => NaturalTransformation F G)
- (fun F G eta nu =>
- forall X, D_Hom_eq (Component eta X) (Component nu X)).
- apply (@Build_Category (Functor C D) (fun F G => NaturalTransformation F G)
- (fun F G eta nu =>
- forall X, D_Hom_eq (Component eta X) (Component nu X))
- (fun F => Identity_NaturalTransformation F)
- (fun F G H eta nu => Compose_NaturalTransformations eta nu)); simpl.
- intros; apply Compose_respectful_left; hypothesis.
- intros; apply Compose_respectful_right; hypothesis.
- intros; apply Build_Equivalence.
- intros; apply (equivalence_reflexivity (category_equivalence D _ _)).
- intros; apply (equivalence_symmetry (category_equivalence D _ _));
- hypothesis.
- intros; eapply (equivalence_transitivity (category_equivalence D _ _));
- hypothesis.
- intros; apply category_left_identity.
- intros; apply category_right_identity.
- intros; apply category_associativity.
- Defined.
- End FunctorCategory.
- Section NaturalIsomorphism.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Definition AUX_Category := Funct C D.
- Context (F G : Functor C D).
- Context (eta : NaturalTransformation F G).
- Definition NaturalIsomorphism :=
- Isomorphism AUX_Category _ _ eta.
- Definition NaturalIsomorphism' :=
- forall X, Isomorphism D _ _ (Component eta X).
- Theorem NaturalIsomorphism_imp_NaturalIsomorphism' :
- NaturalIsomorphism -> NaturalIsomorphism'.
- unfold NaturalIsomorphism; unfold NaturalIsomorphism'.
- unfold Isomorphism; simpl.
- intros [f [prfF prfG]].
- intro X.
- apply (witness _ (Component f X)).
- constructor; hypothesis.
- Defined.
- Theorem NaturalIsomorphism'_imp_NaturalIsomorphism :
- NaturalIsomorphism' -> NaturalIsomorphism.
- unfold NaturalIsomorphism'; unfold NaturalIsomorphism.
- unfold Isomorphism; intros S.
- Lemma NaturalIsomorphism'_imp_NaturalIsomorphism_lemma
- (S : forall X : C_Ob,
- Sigma
- (fun g : D_Hom (G @ X) (F @ X) =>
- And (D_Hom_eq (Component eta X [D] g) (Id[D]))
- (D_Hom_eq (g [D] Component eta X) (Id[D])))) :
- NaturalTransformation G F.
- apply (Build_NaturalTransformation G F
- (fun X => pi1 (S X))).
- intros X Y f.
- pose (naturality eta _ _ f).
- destruct (pi2 (S X)) as [p q].
- simpl in *.
- destruct (pi2 (S Y)) as [m n].
- eapply (eq_functors_lemma1 F G); hypothesis.
- Defined.
- apply (witness _ (NaturalIsomorphism'_imp_NaturalIsomorphism_lemma S)).
- constructor; intro X;
- unfold NaturalIsomorphism'_imp_NaturalIsomorphism_lemma; simpl;
- destruct (S X) as [t [u v]]; simpl;
- assumption.
- Defined.
- End NaturalIsomorphism.
- Section Cone.
- Context {II_Ob II_Hom II_Hom_eq} (II : @Category II_Ob II_Hom II_Hom_eq).
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Definition Cone (U : C_Ob) (D : Functor II C) := NaturalTransformation (Constant_Functor II C U) D.
- Definition DiagonalFunctor : Functor C (Funct II C).
- Lemma DiagonalFunctor_lemma X Y :
- C_Hom X Y -> NaturalTransformation (Constant_Functor II C X) (Constant_Functor II C Y).
- intro f.
- apply (Build_NaturalTransformation (Constant_Functor II C X) (Constant_Functor II C Y)
- (fun X => f)).
- intros X' Y' f'.
- unfold Constant_Functor; simpl.
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply category_left_identity.
- eapply (equivalence_symmetry (category_equivalence C _ _)).
- eapply (equivalence_transitivity (category_equivalence C _ _)).
- apply category_right_identity.
- eapply (equivalence_reflexivity (category_equivalence C _ _)).
- Defined.
- apply (Build_Functor C (Funct II C)
- (fun V => Constant_Functor II C V)
- (fun X Y f => DiagonalFunctor_lemma f)); simpl.
- intros; apply (equivalence_reflexivity (category_equivalence C _ _)).
- intros; apply (equivalence_reflexivity (category_equivalence C _ _)).
- intros; assumption.
- Defined.
- End Cone.
- Section CommaCategory.
- Context {C_Ob C_Hom C_Hom_eq} (C : @Category C_Ob C_Hom C_Hom_eq).
- Context {D_Ob D_Hom D_Hom_eq} (D : @Category D_Ob D_Hom D_Hom_eq).
- Context {E_Ob E_Hom E_Hom_eq} (E : @Category E_Ob E_Hom E_Hom_eq).
- Context (F : Functor C E) (G : Functor D E).
- Definition Comma_Ob :=
- @Sigma C_Ob (fun X =>
- @Sigma D_Ob (fun Y =>
- E_Hom (F @ X) (G @ Y))).
- Definition Comma_Map (P Q : Comma_Ob) :=
- @Sigma (C_Hom (pi1 P) (pi1 Q)) (fun x =>
- @Sigma (D_Hom (pi1 (pi2 P)) (pi1 (pi2 Q))) (fun y =>
- E_Hom_eq ((F $ x) [E] (pi2 (pi2 Q)))
- ((pi2 (pi2 P)) [E] (G $ y)))).
- Definition Comma_eq P Q (f g : Comma_Map P Q) :=
- And (C_Hom_eq (pi1 f) (pi1 g))
- (D_Hom_eq (pi1 (pi2 f)) (pi1 (pi2 g))).
- Definition Comma_identity : forall X : Comma_Ob, Comma_Map X X.
- unfold Comma_Ob; unfold Comma_Map.
- intros [c [d p]]; simpl in *.
- apply (witness _ (identity C _)).
- apply (witness _ (identity D _)).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply Compose_respectful_left.
- apply (functor_identity F).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply category_left_identity.
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- Focus 2.
- apply Compose_respectful_right.
- eapply (equivalence_symmetry (category_equivalence E _ _)).
- apply (functor_identity G).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- Focus 2.
- eapply (equivalence_symmetry (category_equivalence E _ _)).
- apply category_right_identity.
- eapply (equivalence_reflexivity (category_equivalence E _ _)).
- Defined.
- Definition Comma_compose : forall X Y Z : Comma_Ob,
- Comma_Map X Y -> Comma_Map Y Z -> Comma_Map X Z.
- unfold Comma_Ob; unfold Comma_Map.
- intros
- [X [X' X'']]
- [Y [Y' Y'']]
- [Z [Z' Z'']]
- [f [f' f'']]
- [g [g' g'']]; simpl in *.
- apply (witness _ (f [C] g)).
- apply (witness _ (f' [D] g')).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply Compose_respectful_left.
- apply (functor_compose F).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- eapply (equivalence_symmetry (category_equivalence E _ _)).
- apply (category_associativity E).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply Compose_respectful_right.
- hypothesis.
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply (category_associativity E).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply Compose_respectful_left.
- hypothesis.
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- eapply (equivalence_symmetry (category_equivalence E _ _)).
- apply (category_associativity E).
- eapply (equivalence_transitivity (category_equivalence E _ _)).
- apply Compose_respectful_right.
- eapply (equivalence_symmetry (category_equivalence E _ _)).
- apply (functor_compose G).
- eapply (equivalence_reflexivity (category_equivalence E _ _)).
- Defined.
- Definition Comma : @Category Comma_Ob Comma_Map Comma_eq.
- apply (@Build_Category Comma_Ob Comma_Map Comma_eq
- Comma_identity Comma_compose).
- intros
- [X [X' X'']]
- [Y [Y' Y'']]
- [Z [Z' Z'']]
- [f [f' f'']]
- [fp [fp' fp'']]
- [g [g' g'']]; unfold Comma_eq in *; simpl in *.
- intros [q q'].
- constructor;
- apply Compose_respectful_left; assumption.
- intros
- [X [X' X'']]
- [Y [Y' Y'']]
- [Z [Z' Z'']]
- [f [f' f'']]
- [g [g' g'']]
- [gp [gp' gp'']]; unfold Comma_eq in *; simpl in *.
- intros [q q'].
- constructor;
- apply Compose_respectful_right; assumption.
- intros X Y.
- apply (Equivalence_Product
- (Equivalence_Pullback (fun f : Comma_Map X Y => pi1 f) (category_equivalence C _ _))
- (Equivalence_Pullback (fun f : Comma_Map X Y => pi1 (pi2 f)) (category_equivalence D _ _))).
- intros
- [X [X' X'']]
- [Y [Y' Y'']]
- [f [f' f'']]; unfold Comma_eq in *; simpl in *.
- constructor; apply category_left_identity.
- intros
- [X [X' X'']]
- [Y [Y' Y'']]
- [f [f' f'']]; unfold Comma_eq in *; simpl in *.
- constructor; apply category_right_identity.
- intros
- [X [X' X'']]
- [Y [Y' Y'']]
- [Z [Z' Z'']]
- [W [W' W'']]
- [f [f' f'']]
- [g [g' g'']]
- [h [h' h'']]; unfold Comma_eq in *; simpl in *.
- constructor; apply category_associativity.
- Defined.
- End CommaCategory.
- (*
- *** Local Variables: ***
- *** coq-prog-args: ("-emacs-U" "-nois") ***
- *** End: ***
- *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement