definition theorem proof

A bicartesian closed category is a Cartesian Closed Category that also has all finite coproducts (an Initial Object and binary sums ). It is the categorical model of a typed programming language with product, sum and function types (and, via Curry–Howard, of intuitionistic propositional logic with ).

Sources: DaoFP §6.3 (“Bicartesian Closed Categories”, “Distributivity”), §10.2 (“Distributivity”), §10.7.

Distributivity theorem. In a bicartesian closed category, and .

Proof (DaoFP §10.2, via Yoneda). For arbitrary ,

using the currying adjunction, the sum adjunction, currying backwards and the sum adjunction backwards; every step is natural in , so by the Yoneda Lemma the objects are isomorphic. Shorter proof (§10.7): is a left adjoint, and left adjoints preserve colimits (Right Adjoints Preserve Limits); a coproduct is a colimit.

In Haskell the isomorphism is (Either b c, a) ≅ Either (b, a) (c, a); DaoFP Chapter 6 gives the direct construction of one direction using the universal properties and notes the other direction needs the exponential. The identities , (“sum and product revisited”) are further consequences.

-- Mathlib: distributivity of products over coproducts in a cartesian closed category
#check CategoryTheory.prodCoprodDistrib     -- (X ⨯ Y) ⨿ (X ⨯ Z) ≅ X ⨯ (Y ⨿ Z) in a CCC
distribute :: (Either b c, a) -> Either (b, a) (c, a)
distribute (Left b, a)  = Left (b, a)
distribute (Right c, a) = Right (c, a)
 
undistribute :: Either (b, a) (c, a) -> (Either b c, a)
undistribute (Left (b, a))  = (Left b, a)
undistribute (Right (c, a)) = (Right c, a)