Freyd’s adjoint functor theorem. Let be a Functor from a (small-)cocomplete, locally small category that preserves colimits. If for every there is a solution set — a set-indexed family such that every factors as for some and (a weakly terminal set in the Comma Category ) — then has a right adjoint. Dually, a limit-preserving functor from a complete category with solution sets has a left adjoint.
Sources: DaoFP §10.8 (“Freyd’s adjoint functor theorem”, “Freyd’s theorem in a preorder”, “Solution set condition”, “Defunctionalization”), §9.5 (“The existence of the terminal object”); preorder case: 7 Sketches Theorem 1.115 (Adjoint Functor Theorem for Preorders).
Idea of proof. Since left adjoints preserve colimits, must. To build the right adjoint we need, for every , a Universal Arrow from to , i.e. a Terminal Object of . Preorder case (all colimits exist, a preorder): the comma category is a cocone in with apex ; project its base back to via and take . Since preserves colimits, , so there is a unique cocone morphism ; any is part of the diagram, giving the wire with , unique because is a preorder. General case: comma categories are large, so we cannot take their colimit; but in a cocomplete locally small category a weakly terminal set yields a terminal object (take the coproduct , then the colimit of the full subcategory on the ; DaoFP §9.5). Applying this in to the solution set produces the universal arrow.
Programming: Defunctionalization. The function type is the right adjoint to ; the adjoint functor theorem says it can be approximated by a solution set of environments. A finite program has finitely many function definitions, which (with their captured environments) form the solution set; this replaces higher-order functions by data plus an apply — the technique behind serializing continuations in distributed systems.
#check CategoryTheory.SolutionSetCondition
#check CategoryTheory.isRightAdjoint_of_preservesLimits_of_solutionSetCondition -- Freyd's theorem (right adjoint form)-- see [[Defunctionalization]] for the worked example (sumK with continuations replaced by data Kont)