2014-10-09 01:44:01 +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
|
|
|
|
|
|
|
|
import logic.axioms.funext
|
|
|
|
|
|
|
|
open eq eq.ops
|
|
|
|
|
|
|
|
inductive category [class] (ob : Type) : Type :=
|
2014-10-11 22:49:34 +00:00
|
|
|
mk : Π (hom : ob → ob → Type)
|
2014-10-09 01:44:01 +00:00
|
|
|
(comp : Π⦃a b c : ob⦄, hom b c → hom a b → hom a c)
|
|
|
|
(id : Π {a : ob}, hom a a),
|
|
|
|
(Π ⦃a b c d : ob⦄ {h : hom c d} {g : hom b c} {f : hom a b},
|
|
|
|
comp h (comp g f) = comp (comp h g) f) →
|
|
|
|
(Π ⦃a b : ob⦄ {f : hom a b}, comp id f = f) →
|
|
|
|
(Π ⦃a b : ob⦄ {f : hom a b}, comp f id = f) →
|
|
|
|
category ob
|
|
|
|
|
|
|
|
namespace category
|
2014-10-12 20:06:00 +00:00
|
|
|
variables {ob : Type} [C : category ob]
|
2014-10-11 22:49:34 +00:00
|
|
|
variables {a b c d : ob}
|
2014-10-10 01:01:06 +00:00
|
|
|
include C
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2014-10-09 01:44:01 +00:00
|
|
|
definition hom [reducible] : ob → ob → Type := rec (λ hom compose id assoc idr idl, hom) C
|
|
|
|
-- note: needs to be reducible to typecheck composition in opposite category
|
|
|
|
definition compose [reducible] : Π {a b c : ob}, hom b c → hom a b → hom a c :=
|
|
|
|
rec (λ hom compose id assoc idr idl, compose) C
|
|
|
|
|
|
|
|
definition id [reducible] : Π {a : ob}, hom a a := rec (λ hom compose id assoc idr idl, id) C
|
2014-11-04 00:22:30 +00:00
|
|
|
definition ID [reducible] (a : ob) : hom a a := id
|
2014-10-09 01:44:01 +00:00
|
|
|
|
2014-11-28 13:11:23 +00:00
|
|
|
infixr `∘` := compose
|
2014-10-09 05:57:41 +00:00
|
|
|
infixl `⟶`:25 := hom -- input ⟶ using \--> (this is a different arrow than \-> (→))
|
2014-10-09 01:44:01 +00:00
|
|
|
|
|
|
|
variables {h : hom c d} {g : hom b c} {f : hom a b} {i : hom a a}
|
|
|
|
|
2014-10-11 22:49:34 +00:00
|
|
|
theorem assoc : Π ⦃a b c d : ob⦄ (h : hom c d) (g : hom b c) (f : hom a b),
|
2014-10-09 01:44:01 +00:00
|
|
|
h ∘ (g ∘ f) = (h ∘ g) ∘ f :=
|
|
|
|
rec (λ hom comp id assoc idr idl, assoc) C
|
|
|
|
|
|
|
|
theorem id_left : Π ⦃a b : ob⦄ (f : hom a b), id ∘ f = f :=
|
|
|
|
rec (λ hom comp id assoc idl idr, idl) C
|
|
|
|
theorem id_right : Π ⦃a b : ob⦄ (f : hom a b), f ∘ id = f :=
|
|
|
|
rec (λ hom comp id assoc idl idr, idr) C
|
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
--the following is the only theorem for which "include C" is necessary if C is a variable (why?)
|
2014-10-09 01:44:01 +00:00
|
|
|
theorem id_compose (a : ob) : (ID a) ∘ id = id := !id_left
|
|
|
|
|
|
|
|
theorem left_id_unique (H : Π{b} {f : hom b a}, i ∘ f = f) : i = id :=
|
2014-10-31 15:41:42 +00:00
|
|
|
calc i = i ∘ id : id_right
|
|
|
|
... = id : H
|
2014-10-09 01:44:01 +00:00
|
|
|
|
|
|
|
theorem right_id_unique (H : Π{b} {f : hom a b}, f ∘ i = f) : i = id :=
|
2014-10-31 15:41:42 +00:00
|
|
|
calc i = id ∘ i : id_left
|
|
|
|
... = id : H
|
2014-10-11 22:49:34 +00:00
|
|
|
end category
|
2014-10-09 01:44:01 +00:00
|
|
|
|
2014-10-11 22:49:34 +00:00
|
|
|
inductive Category : Type := mk : Π (ob : Type), category ob → Category
|
2014-10-09 01:44:01 +00:00
|
|
|
|
2014-10-11 22:49:34 +00:00
|
|
|
namespace category
|
2014-11-04 00:22:30 +00:00
|
|
|
definition Mk {ob} (C) : Category := Category.mk ob C
|
|
|
|
definition MK (a b c d e f g) : Category := Category.mk a (category.mk b c d e f g)
|
|
|
|
|
2014-11-28 13:11:23 +00:00
|
|
|
definition objects [coercion] [reducible] (C : Category) : Type
|
2014-10-09 01:44:01 +00:00
|
|
|
:= Category.rec (fun c s, c) C
|
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
definition category_instance [instance] [coercion] [reducible] (C : Category) : category (objects C)
|
2014-10-09 01:44:01 +00:00
|
|
|
:= Category.rec (fun c s, s) C
|
2014-11-04 00:22:30 +00:00
|
|
|
|
2014-10-09 01:44:01 +00:00
|
|
|
end category
|
|
|
|
|
|
|
|
open category
|
|
|
|
|
2014-11-04 00:22:30 +00:00
|
|
|
theorem Category.equal (C : Category) : Category.mk C C = C :=
|
|
|
|
Category.rec (λ ob c, rfl) C
|