2014-12-22 20:33:29 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Floris van Doorn. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Floris van Doorn
|
|
|
|
-/
|
2014-11-04 00:22:30 +00:00
|
|
|
import .basic
|
2015-07-06 14:29:56 +00:00
|
|
|
import logic.cast
|
2014-11-06 23:54:18 +00:00
|
|
|
open function
|
2014-11-04 00:22:30 +00:00
|
|
|
open category eq eq.ops heq
|
|
|
|
|
2014-11-25 01:24:30 +00:00
|
|
|
structure functor (C D : Category) : Type :=
|
|
|
|
(object : C → D)
|
|
|
|
(morphism : Π⦃a b : C⦄, hom a b → hom (object a) (object b))
|
|
|
|
(respect_id : Π (a : C), morphism (ID a) = ID (object a))
|
|
|
|
(respect_comp : Π ⦃a b c : C⦄ (g : hom b c) (f : hom a b),
|
|
|
|
morphism (g ∘ f) = morphism g ∘ morphism f)
|
2014-11-04 00:22:30 +00:00
|
|
|
|
|
|
|
infixl `⇒`:25 := functor
|
|
|
|
|
|
|
|
namespace functor
|
2015-01-26 19:31:12 +00:00
|
|
|
attribute object [coercion]
|
|
|
|
attribute morphism [coercion]
|
|
|
|
attribute respect_id [irreducible]
|
|
|
|
attribute respect_comp [irreducible]
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2014-11-25 01:24:30 +00:00
|
|
|
variables {A B C D : Category}
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2014-11-25 01:24:30 +00:00
|
|
|
protected definition compose [reducible] (G : functor B C) (F : functor A B) : functor A C :=
|
2014-11-04 00:22:30 +00:00
|
|
|
functor.mk
|
|
|
|
(λx, G (F x))
|
|
|
|
(λ a b f, G (F f))
|
2014-11-25 01:24:30 +00:00
|
|
|
(λ a, proof calc
|
|
|
|
G (F (ID a)) = G id : {respect_id F a}
|
|
|
|
--not giving the braces explicitly makes the elaborator compute a couple more seconds
|
|
|
|
... = id : respect_id G (F a) qed)
|
|
|
|
(λ a b c g f, proof calc
|
2014-11-04 00:22:30 +00:00
|
|
|
G (F (g ∘ f)) = G (F g ∘ F f) : respect_comp F g f
|
2014-11-25 01:24:30 +00:00
|
|
|
... = G (F g) ∘ G (F f) : respect_comp G (F g) (F f) qed)
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2015-05-19 05:35:18 +00:00
|
|
|
infixr `∘f`:60 := functor.compose
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2014-11-25 01:24:30 +00:00
|
|
|
protected theorem assoc (H : functor C D) (G : functor B C) (F : functor A B) :
|
2014-11-04 00:22:30 +00:00
|
|
|
H ∘f (G ∘f F) = (H ∘f G) ∘f F :=
|
|
|
|
rfl
|
|
|
|
|
2014-11-25 01:24:30 +00:00
|
|
|
protected definition id [reducible] {C : Category} : functor C C :=
|
2014-11-04 00:22:30 +00:00
|
|
|
mk (λa, a) (λ a b f, f) (λ a, rfl) (λ a b c f g, rfl)
|
2015-05-19 05:35:18 +00:00
|
|
|
protected definition ID [reducible] (C : Category) : functor C C := @functor.id C
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2015-05-19 05:35:18 +00:00
|
|
|
protected theorem id_left (F : functor C D) : (@functor.id D) ∘f F = F :=
|
2014-11-04 00:22:30 +00:00
|
|
|
functor.rec (λ obF homF idF compF, dcongr_arg4 mk rfl rfl !proof_irrel !proof_irrel) F
|
2015-05-19 05:35:18 +00:00
|
|
|
protected theorem id_right (F : functor C D) : F ∘f (@functor.id C) = F :=
|
2014-11-04 00:22:30 +00:00
|
|
|
functor.rec (λ obF homF idF compF, dcongr_arg4 mk rfl rfl !proof_irrel !proof_irrel) F
|
|
|
|
|
|
|
|
end functor
|
|
|
|
|
|
|
|
namespace category
|
|
|
|
open functor
|
|
|
|
definition category_of_categories [reducible] : category Category :=
|
|
|
|
mk (λ a b, functor a b)
|
|
|
|
(λ a b c g f, functor.compose g f)
|
|
|
|
(λ a, functor.id)
|
|
|
|
(λ a b c d h g f, !functor.assoc)
|
|
|
|
(λ a b f, !functor.id_left)
|
|
|
|
(λ a b f, !functor.id_right)
|
2014-11-25 01:24:30 +00:00
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
definition Category_of_categories [reducible] := Mk category_of_categories
|
|
|
|
|
|
|
|
namespace ops
|
|
|
|
notation `Cat`:max := Category_of_categories
|
2015-01-26 19:31:12 +00:00
|
|
|
attribute category_of_categories [instance]
|
2014-11-04 00:22:30 +00:00
|
|
|
end ops
|
|
|
|
end category
|
|
|
|
|
|
|
|
namespace functor
|
2014-11-25 01:24:30 +00:00
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
variables {C D : Category}
|
|
|
|
|
|
|
|
theorem mk_heq {obF obG : C → D} {homF homG idF idG compF compG} (Hob : ∀x, obF x = obG x)
|
|
|
|
(Hmor : ∀(a b : C) (f : a ⟶ b), homF a b f == homG a b f)
|
|
|
|
: mk obF homF idF compF = mk obG homG idG compG :=
|
|
|
|
hddcongr_arg4 mk
|
|
|
|
(funext Hob)
|
|
|
|
(hfunext (λ a, hfunext (λ b, hfunext (λ f, !Hmor))))
|
|
|
|
!proof_irrel
|
|
|
|
!proof_irrel
|
|
|
|
|
|
|
|
protected theorem hequal {F G : C ⇒ D} : Π (Hob : ∀x, F x = G x)
|
|
|
|
(Hmor : ∀a b (f : a ⟶ b), F f == G f), F = G :=
|
|
|
|
functor.rec
|
|
|
|
(λ obF homF idF compF,
|
|
|
|
functor.rec
|
|
|
|
(λ obG homG idG compG Hob Hmor, mk_heq Hob Hmor)
|
|
|
|
G)
|
|
|
|
F
|
|
|
|
|
|
|
|
-- theorem mk_eq {obF obG : C → D} {homF homG idF idG compF compG} (Hob : ∀x, obF x = obG x)
|
|
|
|
-- (Hmor : ∀(a b : C) (f : a ⟶ b), cast (congr_arg (λ x, x a ⟶ x b) (funext Hob)) (homF a b f)
|
|
|
|
-- = homG a b f)
|
|
|
|
-- : mk obF homF idF compF = mk obG homG idG compG :=
|
|
|
|
-- dcongr_arg4 mk
|
|
|
|
-- (funext Hob)
|
|
|
|
-- (funext (λ a, funext (λ b, funext (λ f, sorry ⬝ Hmor a b f))))
|
|
|
|
-- -- to fill this sorry use (a generalization of) cast_pull
|
|
|
|
-- !proof_irrel
|
|
|
|
-- !proof_irrel
|
|
|
|
|
|
|
|
-- protected theorem equal {F G : C ⇒ D} : Π (Hob : ∀x, F x = G x)
|
|
|
|
-- (Hmor : ∀a b (f : a ⟶ b), cast (congr_arg (λ x, x a ⟶ x b) (funext Hob)) (F f) = G f), F = G :=
|
|
|
|
-- functor.rec
|
|
|
|
-- (λ obF homF idF compF,
|
|
|
|
-- functor.rec
|
|
|
|
-- (λ obG homG idG compG Hob Hmor, mk_eq Hob Hmor)
|
|
|
|
-- G)
|
|
|
|
-- F
|
|
|
|
|
|
|
|
|
|
|
|
end functor
|