One of my favorite categorical structures is a thing called a closed cartesian category, or CCC for short. Since I'm a computer scientist/software engineer, it's a natural: CCCs are, basically, the categorical structure of lambda calculus - and thus, effectively, a categorical model of computation. However, before we can talk about the CCCs, we need - what else? - more definitions.
A cartesian category (note not cartesian closed category) is a category:
- With a terminal object , and
- , the objects and arrows of the categorical product .
So, a cartesian category is a category closed with respect to product. Many of the common categories are cartesian: the category of sets, and the category of enumerable sets, And of course, the meaning of the categorical product in set? Cartesian product of sets.
To get from cartesian categories to cartesian closed categories, we also need to define categorical exponentials. Like categorical product, the value of a categorical exponential is not required to included in a category. The exponential is a complicated definition, and it's a bit hard to really get your head around, but it's well worth the effort. If categorical products are the categorical generalization of set products, then the categorical exponential is the categorical version of a function space. It gives us the ability to talk about structures that are the generalized version of "all functions from A to B".
Given two objects x and y from a category C, their categorical exponential xy, if it exists in the category, is defined by a set of values:
- An object ,
- An arrow , called an evaluation map.
- , an operation . (That is, an operation mapping from arrows to arrows.)
These values must have the following properties:
To make that a bit easier to understand, let's turn it into a diagram.
As I alluded to earlier, you can also think of it as a generalization of a function space. is the set of all functions from y to x. The evaluation map is simple description in categorical terms of an operation that applies a function from a to b (an arrow) to a value from a, resulting in an a value from b.
So what does the categorical exponential mean? I think it's easiest to explain in terms of sets and functions first, and then just step it back to the more general case of objects and arrows.
If X and Y are sets, then is the set of functions from Y to X.
Now, look at the diagram:
- The top part says, basically, that is a function from to to : so takes a member of , and uses it to select a function from to .
- The vertical arrow says:
- given the pair , maps to a value in .
- given a pair , we're going through a function. It's almost like currying:
- The vertical arrow going down is basically taking , and currying it to .
- Per the top part of the diagram, selects a function from to . (That is, a member of .)
- So, at the end of the vertical arrow, we have a pair .
- The "eval" arrow maps from the pair of a function and a value to the result of applying the function to the value.
Cartesian Closed Categories
Now - the abstraction step is actually kind of easy: all we're doing is saying that there is a structure of mappings from object to object here. This particular structure has the essential properties of what it means to apply a function to a value. The internal values and precise meanings of the arrows connecting the values can end up being different things, but no matter what, it will come down to something very much like function application.
With exponentials and products, we can finally say what the cartesian closed categories (CCCs). A Cartesian closed category is a category that is closed with respect to both products and exponentials.
Why do we care? Well, the CCCs are in a pretty deep sense equivalent to the simply typed lambda calculus. That means that the CCCs are deeply tied to the fundamental nature of computation. The structure of the CCCs - with its closure WRT product and exponential - is an expression of the basic capability of an effective computing system. So next, we'll take a look at a couple of examples of what we can do with the CCCs as a categorical model of computation.