# An Introduction to N-Categories

Tom Leinster

N = 0 : 0-Cat

• => Set, 0-morphism = function

N= 1: 1-Cat

• => Cat, 1-morphism = functor

N= 2: 2-Cat

• => 2-morphism = Natural Transformation

$\text {f, g : 1-morphism }$

$\alpha \:\: \beta \text { Natural Transformations : 2-morphism }$

Definition of n-Category:

Composition:

0-Cat : Set
1-Cat : Cat

Examples of n-Categories:

• Manifold
• Top (Topological Space) : 2-morphism = homotopy

Ref:

Best Technical Category Theory Book (2016) by Tom Leinster (Cambridge Press): “Basic Category Theory”

# Program = Category

2017 : (PhD Math made simple for IT programmers)

Keywords

• Category
• Monad = Monoid + Endofunctor
• Lewvere Theory

Category Theory is replacing Set Theory as the foundation of Math. Nowadays,  few Advanced Math papers are written without using Category to explain, and this trend is spreading to IT  through Functional Programming languages (Google’s Kotlin, Haskell, Clojure…)  – the latest paradigm to replace Object-Oriented languages like Java, C++, etc, as a safer “Strong Typed” languages for AI, BIG DATA…

$\boxed {\text {Type = Category }}$

Examples of “Types” in IT:

• Integers
• Real
• Double
• Boolean
• String
• etc

T-program defined in the following 6 examples:

• list (X), eg. {2, 5 , 3, 7, 1 }
• partial (X), eg: +1 (error msg)
• side-effect, eg: update a record
• continuation (X),
• non-det (X),
• prob-dist (X)

A Monad : a T-program which turns an arrow to a “Category” (ie + 2 properties:  Identity &  Associative).

Proof: List Computation is a Category

Proof: Partial operation is a Category

$\boxed {\text {Monad = Lawvere Theory }}$

Monad is for only one Category. Lawvere Theory is more general.

Ref
:

Ref:

# Math in Neural Network

Key maths used:

• Functions & composition,
• Matrix,

# Parallel & Concurrent Haskell (2)

Continued from : (Part 1)

2.2 Data Structure

Function (+) ::  D -> D -> D
inc  x  = 1 + x ~ (+) ::  1 + x

Section (Partial appl) : inc  = (+ 1)

Type ~ Set {values} : Integer Set / Boolean Set {0,1} / Empty Set “Void” { } / …

Type of Singleton (1 element) : Unit ( )

Declare a new Type : data

data () = ()
1st () = Type of Unit
2nd () = constructor of Unit

Haskell convention : Type name = constructor name

(To avoid having too many nsmes)

Define cares Ian product of Types (Sets):

data Product a b = P a b

Product : Type constructor
P : Data constructor (function with 2 args of types a, b)
P :: a -> b -> Product a b

Data Immutable : remember how it was constructed.

(+) :: Num a => a -> a -> a

sqDist ‘ ‘ (P x y ) = x^2 + y^2
sqDist ‘ ‘ :: Num a =-> Product a a -> a

Built-in for “pair”:

data ( , ) a b =( , ) a b

eg.
( , ) 1 2 gives (1, 2)

All data (Types) are formed by only 2 methods : Product or Sum.

$\boxed {\text {Algebraic Data : by Product, Sum}}$