# Category Theory for Functional Programming

Category Theory is called “The Mathematics of Mathematics“, also the “Abstract Nonsense“.

Key Motivations for Category Theory 范畴 :
1. Programming is Math.
2. Object-Oriented is based on Set Theory which has 2 weaknesses:

Data Immutability for Concurrent Processing : OO can’t control the mutable state of objects, making debugging impossible.

Category (“cat“) has 3 properties:
1. Objects
eg. Set, List, Group, Vector Space, anything…
2. Arrows (“Morphism”, between Objects) which are Associative
eg. function, sheaf, etc
3. Identity Object

Note: If the Identity is “0” or “Nothing”, then it is called Free Category.

Extensions :
1. “Cat” = Category of categories, is also a category.
2. Functor 函子 = Arrows between Categories.
3. Monoid = A Category with ONLY 1 Object.

Monoid (么半群) is a very powerful concept (used in Natural Language Processing) — basically it is a Group with No ‘I‘nverse (Mo‘No‘-‘I‘-d).

Note: In the pure Functional Programming Language Haskell:
Monad (单子) = Monoid with endo-functor.
Endo- = to itself (自己) eg. “f : A -> A”

Recommended :
1. The Best Book on Category Theory : Lawvere et al, Cambridge (2009, 2nd Edition)

2. A humorous book on Category Theory by Dr. Eugenia Cheng (2016): (found in Singapore NLB Loan book #501.1 CHE)

# Math Education Evolution: From Function to Set to Category

Interesting Math education evolves since 19th century.

“Elementary Math from An Advanced Standpoint” (3 volumes) was proposed by German Göttingen School Felix Klein (19th century) :
1)  Math teaching based on Function (graph) which is visible to students. This has influenced  all Secondary school Math worldwide.

2) Geometry = Group

After WW1, French felt being  behind the German school, the “Bourbaki” Ecole Normale Supérieure students rewrote all Math teachings – aka “Abstract Math” – based on the structure “Set” as the foundation to build further algebraic structures (group, ring, field, vector space…) and all Math.

After WW2, the American prof MacLane & Eilenburg summarised all these Bourbaki structures into one super-structure: “Category” (范畴) with a “morphism” (aka ‘relation’) between them.

Grothendieck proposed rewriting the Bourbaki Abstract Math from ‘Set’ to ‘Category’, but was rejected by the jealous Bourbaki founder Andre Weil.

Category is still a graduate syllabus Math,  also called “Abstract Nonsense”! It is very useful in IT  Functional Programming for “Artificial Intelligence” – the next revolution in “Our Human Brain” !

# Category: Natural Transformation

Prof S. Roman (Lecture 5)

# Category Theory in Music

Lesson 1.1 : Overview

Lesson 1.2 : Maps

Lesson 1.3 [Video] : Commute, Identity Morphism

Lesson 1.4 [Video] : Identity Law (Set Endomorphism), Associativity Law

Lesson 1.5 : [Video] Category of Sets (Concrete Category)
$f : A \rightarrow B$
$f^{op} : B \rightarrow A$

Number of Set Mappings: $\displaystyle \boxed { |f |= |B|^{|A}= |f^{op}|}$

Universal Mappings Properties (UMP)

Initial Object: $0 \rightarrow X$

Terminal Object: $X\rightarrow 1$