# User:Michiexile/MATH198/Lecture 5

(Difference between revisions)

IMPORTANT NOTE: THESE NOTES ARE STILL UNDER DEVELOPMENT. PLEASE WAIT UNTIL AFTER THE LECTURE WITH HANDING ANYTHING IN, OR TREATING THE NOTES AS READY TO READ.

## Contents

### 1 Cartesian Closed Categories and typed lambda-calculus

A category is said to have pairwise products if for any objects A,B, there is a product object $A\times B$.

A category is said to have pairwise coproducts if for any objects A,B, there is a coproduct object A + B.

Recall when we talked about internal homs in Lecture 2. We can now define what we mean, formally, by the concept:

Definition An object C in a category D is an internal hom object or an exponential object $[A\to B]$ or BA if it comes equipped with an arrow $ev: [A\to B] \times A \to B$, called the evaluation arrow, such that for any other arrow $f: C\times A\to B$, there is a unique arrow $\lambda f: C\to [A\to B]$ such that the composite

$C\times A\to^{\lambda f\times 1_A} [A\to B]\times A\to^{ev} B$

is f.

The idea here is that with something in an exponential object, and something in the source of the arrows we imagine live inside the exponential, we can produce the evaluation of the arrow at the source to produce something in the target. Using global elements, this reasoning comes through in a more natural manner: given $f: 1\to [A\to B]$ and $x: 1\to A$ we can produce the global element $f(x) = ev \circ f\times x: 1\to B$. Furthermore, we can always produce something in the exponential whenever we have something that looks as if it should be there.

And with this we can define

Definition A category C is a Cartesian Closed Category or a CCC if:

1. C has a terminal object 1
2. Each pair of objects $A, B\in C_0$ has a product $A\times B$ and projections $p_1:A\times B\to A$, $p_2:A\times B\to B$.
3. For every pair $A, B\in C_0$ of objects, there is an exponential object $[A\to B]$ with an evaluation map $[A\to B]\times A\to B$.

#### 1.1 Currying

Note that the exponential as described here is exactly what we need in order to discuss the Haskell concept of multi-parameter functions. If we consider the type of a binary function in Haskell:

binFunction :: a -> a -> a
This function really lives in the Haskell type
a -> (a -> a)
, and thus is an element in the repeated exponential object $[A \to [A\to A]]$. Evaluating once gives us a single-parameter function, the first parameter consumed by the first evaluation, and we can evaluate a second time, feeding in the second parameter to get an end result from the function.

On the other hand, we can feed in both values at once, and get

binFunction' :: (a,a) -> a

which lives in the exponential object $[A\times A\to A]$.

These are genuinely different objects, but they seem to do the same thing: consume two distinct values to produce a third value. The resolution of the difference lies, again, in a recognition from Set theory: there is an isomorphism

$Hom(S, Hom(T, V)) = Hom(S\times T, V)$

which we can use as inspiration for an isomorphism $Hom(S,[T\to V]) = Hom(S\times T, V)$ valid in Cartesian Closed Categories.

As it turns out, this is exactly what we need for λ-calculus. Any typed λ-calculus gives rise to a CCC in a natural manner, and any CCC has an internal language which satisfies, by the axioms for the CCC, all requirements to be a typed λ-calculus.

More importantly, by stating λ-calculus in terms of a CCC instead of in terms of terms and rewriting rules is that you can escape worrying about variable clashes, alpha reductions and composability - the categorical translation ignores, at least superficially, the variables, reduces terms with morphisms that have equality built in, and provides associative composition for free.

At this point, I'd reccomend reading more on Wikipedia [1] and [2], as well as in Lambek & Scott: Introduction to Higher Order Categorical Logic. The book by Lambek & Scott goes into great depth on these issues, but may be less than friendly to a novice.

### 2 Limits and colimits

• Generalizing these constructions
• Diagram and universal object mapping to (from) the diagram
• Express product/coproduct as limit/colimit
• No dependent types
• No compiler-enforced equational conditions
• Can be simulated but not enforced, e.g. using QuickCheck.

#### 2.1 Useful limits and colimits

##### 2.1.1 Equalizer, coequalizer
• Kernels, cokernels, images, coimages
• connect to linear algebra: null spaces et.c.
##### 2.1.2 Pushout and pullback squares
• Computer science applications

### 3 Homework

1. Prove that currying/uncurrying are isomorphisms in a CCC. Hint: the map $f\mapsto\lambda f$ is a map $Hom(C\times A, B)\to Hom(C,[A\to B])$.