Lesson 8.11,481 words

Cartesian Closed Categories

A cartesian closed category has a terminal object, binary products, and for every pair of objects an exponential object that internalizes the hom-set as an object of the category. The defining data is an evaluation arrow and a currying operation, packaged by the adjunction between product-with-A and exponential-by-A.

╌╌╌╌

In Set, a function of two variables can be traded for a function of one variable whose values are themselves functions. Fix the first argument and what remains, , is a function . Letting vary produces a single function

where is the set of all functions from to . The passage from to is called currying . It is reversible: a function induces , and the two operations are mutually inverse. In one line, currying is a bijection of hom-sets,

natural in every variable.1 A cartesian closed category is a category in which this bijection is available for all objects, with an object standing in for the set of functions and an arrow standing in for the operation of applying a function to an argument.

The definition

A cartesian closed category has a terminal object, all binary products, and an exponential object whose evaluation arrow satisfies a universal property.

By Proposition 5.3.10 on finite products, CCC-1 and CCC-2 together say that has all finite products, the terminal object being the empty product. So a cartesian closed category is a category with finite products plus exponentials.2

The exponential is traditionally written rather than , with called the exponent. The notation is faithful to the finite case: in , if then is the set of -tuples of elements of , i.e. the functions . There is a distinct arrow for each pair ; the subscript and superscript are dropped when the objects are clear. The arrow is called the adjoint transpose or the curry of .

The exponential universal property: eval applied after currying (in its first factor) recovers , and is the only arrow that does this.

Here denotes (the adjoint transpose), and is the product of with the identity on . CCC-3 says that every arrow out of a product factors uniquely through evaluation once its first factor has been curried.

Currying is a bijection

The uniqueness clause of CCC-3 says exactly that

is a bijection: every has one and only one transpose , and conversely every un-curries to . The two directions invert each other.

Currying and its inverse exchange an arrow out of a product for an arrow into an exponential; the two hom-sets are in bijection for all .

Taking specializes the bijection to , since . The right-hand side is the set of global elements of the exponential. So the points of correspond exactly to the arrows : the exponential internalizes the hom-set as an object.

Evaluation as a universal element

The bijection is natural, and the source of that naturality is a single universal element. Fix and and let be the contravariant functor sending an object to and an arrow to precomposition with .

A universal element represents a functor, and representing objects are unique up to unique isomorphism. This forces the cartesian closed structure to be essentially unique.3

A category with finite products can be made cartesian closed in at most one way. This is the special case for exponentials of the general fact that adjoints are unique.

The product-exponential adjunction

Naturality in the second variable upgrades the same statement into an adjunction. For a fixed object , the operation extends to a functor : on an arrow it acts by

This is one of the two internal hom functors; the other, , is contravariant and acts by precomposition inside the exponential.4 With these the hom-set bijection becomes natural in all three variables, and the statement becomes an adjunction.

Product-with- is left adjoint to exponential-by-; currying moves an arrow across the adjunction and evaluation is the counit at .

Because it is a right adjoint, preserves limits; this is the source of the exponential laws collected below. Because is a left adjoint it preserves colimits, which is why a cartesian closed category with finite sums is automatically distributive: .

Examples

The definition holds across quite different mathematics, with the exponential in each case the object that represents arrows from .

  • Set. The first example. is the set of all functions , which is , and is the apply map .
  • Heyting algebras. A poset seen as a thin category is cartesian closed exactly when it is a Heyting algebra. Meet gives products, the top element is terminal, and the exponential is the largest with , the relative pseudocomplement, read as intuitionistic implication. Heyting algebras stand to intuitionistic logic as Boolean algebras stand to classical logic.
  • Boolean algebras. The special case with , where implication is . Reading the exponential laws off a Boolean algebra yields the tautologies of classical propositional logic.
  • Functor categories. For a small category , the category of set-valued functors and natural transformations is cartesian closed. Products are pointwise; the exponential has value at the set of natural transformations .
  • Cat. The category of small categories and functors is cartesian closed. For categories the exponential is the functor category: its objects are functors and its arrows are natural transformations.
  • Domains. The category of -CPOs (countably directed-complete posets) and continuous functions is cartesian closed. This is what makes it a candidate for programming-language semantics; the fixed-point lesson returns to it.

First-class functions and modus ponens

When a functional programming language is presented as a category (types as objects, programs as arrows) and that category is cartesian closed, every pair of types yields a type . Since is itself a type, programs may take it as input and produce it as output: functions become data on the same footing as everything else. This is the categorical content of the slogan that functions are first-class objects. The uniqueness proposition adds a constraint: if the function type must satisfy the currying law, there is essentially one way to build it.

When a deduction system is a cartesian closed category, the exponential turns into implication. Read as the formula implies . Then evaluation is a proof of from and , i.e. modus ponens. Currying an arrow , a proof of from and , produces , a proof of from . This is the deduction (or detachment) rule of propositional logic.

In a deduction system that is a CCC, evaluation is modus ponens: from a proof of and a proof of implies it produces a proof of .

The exponential laws

Because is a right adjoint it behaves like a hom-functor, and the familiar arithmetic of exponents holds up to isomorphism. Writing for makes the pattern unmistakable.

Isomorphism (bracket form)Exponential formCondition
always
always
always
always
needs initial object
needs sum

The third row is currying stated as an object isomorphism: an arrow of two arguments is the same as a curried arrow of one. Each isomorphism is natural in every variable, and each can be proved by evaluating both sides against the Yoneda embedding. For the third row, for fixed and ,

and fullness of Yoneda promotes the natural isomorphism of representables to an isomorphism of the representing objects.5 Rewritten as rules of inference under the implication reading, the same table lists tautologies of propositional logic: is the equivalence of with , and is reasoning by cases.

A cartesian closed category carries three readings at once: a calculus of functions of several variables, a fragment of intuitionistic propositional logic, and a model of typed programs. That these are one structure is the Curry–Howard–Lambek correspondence — propositions correspond to types correspond to objects, and proofs to terms to arrows. The typed lambda calculus makes the programs reading exact, matching a term to each arrow.

Footnotes

  1. Barr & Wells, Category Theory for Computing Science, §6.1.2 — currying a function of two variables and the resulting hom-set isomorphism .
  2. Barr & Wells, §6.1.3–6.1.5 — the definition CCC-1 through CCC-3, the notation for the exponential, and the reduction of CCC-1/CCC-2 to the existence of finite products.
  3. Barr & Wells, §6.1.7–6.1.8 — evaluation as a universal element for , and the resulting uniqueness of the cartesian closed structure up to unique isomorphism.
  4. Barr & Wells, §6.2.1–6.2.3 — the internal hom functors and , and the restatement of CCC-3 as the adjunction ; distributivity in §6.2.3.
  5. Barr & Wells, §6.2.4 — the six exponential isomorphisms and the proof of by fullness of the Yoneda embedding.

╌╌ END ╌╌