definition example theorem

In a Category with products, the exponential (function object, internal hom) (also or ) of objects is an object with an evaluation morphism such that for every there is a unique (the curried ) with . Equivalently, a natural isomorphism

i.e. — the currying adjunction. A category with all exponentials (and finite products) is a Cartesian Closed Category.

Sources: DaoFP §1.4 (“The Object of Arrows”), Chapter 6 (“Function Types”: elimination rule, introduction rule, currying, modus ponens, functoriality), §9.4 (“Exponentials”), §10.1, §10.5; 7 Sketches Example 3.72 ( in , ), Exercise 3.73, §7.2.1; Definition 2.79 (hom-elements are the preorder shadow); CTfS Notation 2.7.2.1, Proposition 2.7.2.3, Exercises 2.7.2.2, 2.7.2.5, Proposition 2.7.3.1

Examples and rules (DaoFP Chapter 6)

  • In , is the set of functions ; in Haskell a -> b. “We have arrows which connect and — these form a set; and we have an object of arrows, whose elements are arrows from the terminal object”: f :: a -> b is . In logic is the proposition “if then ” — an element of it is a proof (the counterfactual “if wishes were horses, beggars would ride” has a proof but an unprovable premise).
  • Elimination rule: evaluation/apply :: (a -> b, a) -> b, modus ponens. Introduction rule: currying, curry :: ((x, a) -> b) -> (x -> a -> b), from a two-argument function to a function returning a function. A function of is an expression in environment with a free variable of type ; the exponential is a closure capturing (DaoFP §10.1).
  • Yoneda trick (DaoFP §9.4): substituting and picking , the commuting condition gives uncurry id, and the naturality square then yields . The unit of the adjunction is , curry id.
  • Functoriality: is covariant in and contravariant in — a Profunctor, dimap f g h = g . h . f; “the function object can be visualized as a lookup table keyed by : to use a related key you need a converter “. Sums and products revisited: , , , , .
  • Counting (CTfS Exercise 2.7.2.2): for finite sets , including the edge cases (the empty function) and for ; so . All the laws of exponents hold as isomorphisms of sets — see Arithmetic of Sets.
  • In a Bicartesian Closed Category products distribute over sums, since is a left adjoint (left adjoints preserve colimits).
  • is the representing object of ; the “logarithm” intuition: (DaoFP §9.8). Internal homs make self-enriched (DaoFP §20.1). Defunctionalization approximates by a solution set of environments.
  • Generalization: Monoidal Closed Category ( right adjoint to ); Compact Closed Category (duals with ).

Docs: Theories (Catlab)

# Julia functions are values: the exponential object is the (abstract) function type
curry(f) = x -> a -> f((x, a))
uncurry(h) = ((x, a),) -> h(x)(a)
apply(fa) = fa[1](fa[2])                     # evaluation ε : b^a × a → b
plus = ((x, a),) -> x + a
p = curry(plus); p(3)(4)                     # 7  (7 Sketches Exercise 3.73: p(3) = "add three")

Catlab version (run in a fresh Julia session — Catlab exports its own compose, id, FinFunction, …):

# Catlab: FinSet is cartesian closed; the exponential of finite sets
using Catlab
# (not a built-in constructor in 0.16; |C^B| = |C|^|B|)
import Mathlib
open CategoryTheory
universe u
#check @ihom                  -- ihom A : C ⥤ C, the exponential A ⟹ (−), notation A ⟹ B
#check @ihom.adjunction       -- tensorLeft A ⊣ ihom A  (here A ⊗ − is A × −)
#check @MonoidalClosed.curry
#check @MonoidalClosed.uncurry
#check @ihom.ev               -- evaluation A ⊗ (A ⟹ B) ⟶ B
example : MonoidalClosed (Type u) := inferInstance
-- DaoFP Chapter 6: the function type is the exponential object
apply :: (a -> b, a) -> b            -- elimination rule / evaluation / modus ponens
apply (f, x) = f x
apply' = uncurry id                  -- the Yoneda trick: ε = α⁻¹(id)
 
curry' :: ((x, a) -> b) -> (x -> a -> b)      -- introduction rule
curry' f x a = f (x, a)
uncurry' :: (x -> a -> b) -> ((x, a) -> b)
uncurry' h (x, a) = h x a
 
-- functoriality (the function type is a profunctor)
dimap :: (a' -> a) -> (b -> b') -> (a -> b) -> (a' -> b')
dimap f g h = g . h . f