It seems inevitable that, after one learned Haskell, there’s a good possibility she will become a victim of category theory. This is a series(hopefully) of notes about category theory.
Category Theory is the theory using formal method to study the semantics of cats a language that is spoken by mathematicians, just like Design Pattern is a language spoken by senior software engineers. Of course, the latter one reads less exotic and sometimes harmful.
Definition of Category
A category
A collection of objects,
;- A collection of morphisms(arrows),
;- For each morphism(arrow)
, a domain object and a codomain object . and . - The collection of morphisms(arrows) between two objects: domain
and codomain , is denoted as .
- For each morphism(arrow)
- A binary operator
called composition, satisfying:- For any pair of arrows
and , an arrow . - (Associativity) For any
, we have . - (Identity) For each object
, an identity arrow , such that for any arrow , .
- For any pair of arrows
Examples of Category
-
Objects: sets,
.- Arrows: total functions,
. - Composition: function composition.
-
- Objects: partially-ordered sets,
. is a set. is a reflexive, transitive, antisymmetric relation on .
- Arrows: total order-preserving functions,
, such that . - Composition: function composition.
- Objects: partially-ordered sets,
-
- Objects: monoids,
. is a set. is an associative binary operator on .- an identity element
such that .
- Arrows: monoid homomorphisms,
, such that and . - Composition: homomorphism composition.
- Objects: monoids,
-
- Objects: group,
is a set. is an associative binary operator.- an identity element
such that . - inverse:
.
- Arrows: group homomorphisms,
, such that , - Composition: homomorphism composition.
- Objects: group,
-
- Objects: Ω-Algebras,
. is a set called carrier. is an interpretation. is a set of operator (signature). is the arity of .
- Arrows:
-homomorphisms, , such that . - Composition: homomorphism composition.
- Objects: Ω-Algebras,
More examples:
Categorical Logic
Objects: formulas,
.Arrows: proofs,
.Composition: transitivity of implication.
- Functional Programming Language
- Objects: types,
. - Arrows: functions,
- Composition: function composition
- Objects: types,
- Dual Category
of- Objects:
- Arrows: opposite of arrows in
. from , we have in
- Composition: trivial.
- Objects:
- Product category
- Objects: objects pairs
where is a -object and is a -object. - Arrows: arrows pairs
where is a -arrow and is an -arrow. - Composition: pairwise composition,
.
- Objects: objects pairs
- Subcategory
of- Objects: each
-object in is a -object - Arrows: for all
-objects and , - Composition: same as
- Objects: each
Commutative Diagrams
Definition
A diagram in a category
A diagram is said to commute if for every pair of objects
Example
This diagram commutes:
- In the inner left squre:
- In the inner right squre:
- In the outer rectangle:
Comments powered by Disqus.