constructive mathematics, realizability, computability
propositions as types, proofs as programs, computational trinitarianism
A duploid is a category-like structure where objects have a specific polarity and composition is not necessarily associative.
Duploids are models of programming languages with side effects and explicitly polarized positive and negative types, accomodating both call-by-value? and call-by-name? programming paradigms. Duploids axiomatize the algebraic structure of effectful morphisms, and to a certain extent βpureβ morphisms (those with no side effects) can be characterized by equational properties as thunkable and linear morphisms. Contrast with call-by-push-value which directly provides a syntax for the pure morphisms (as values and stacks).
A duploid can be constructed from an adjunction and the category of duploids is coreflective in the category of adjunctions, equivalent to the subcategory of adjunctions satisfying an equalizing requirement. The intuition is that a duploid is what is left of an adjunction if we only consider (co)Kleisli morphisms and duploids can be identified with adjunctions whose categories can be recovered from the Kleisli morphisms.
A pre-duploid consists of
Note that when restricted to positive objects or negative objects, composition and identities form a category, written and . When the polarity is known we write positive objects as and negative objects as . We call composition where the middle object is positive βpositive compositionβ or βby-value compositionβ and notate it as and when the middle object is negative we call it βnegative compositionβ or βby-name compositionβ and notate it as . Then the associativity laws can be restated as:
and we can see that the only obstacle to associativity is that is not necessarily equal to .
A duploid is a pre-duploid plus two polarity shifts , and for each , morphisms:
such that
In light of the definition of linear and thunkable morphisms, these identities are equivalent to saying
Just as thunkable morphisms can be defined in a thunk-force category and linear morphisms can be defined in a category with a runnable monad, they can be defined in a duploid in a similar way using in place of the thunk and in place of the run morphism. However, thunkable and linear morphisms can also be defined in a pre-duploid, giving a simple characterization just in terms of associativity of composition.
A morphism is thunkable if for all compatible ,
and a morphism is linear if for all compatible ,
Observe that all are trivially linear and are trivially thunkable. Further thunkable and linear morphisms form (non-full) subcategories .
To understand these concepts, consider the non-trivial situation where is thunkable:
on the left side, since we have a by-name composition, is βevaluated firstβ, whereas on the right side we have a by-value composition, so is evaluated first. Thus these two morphisms being equal implies in many semantics cannot perform any side-effect?. For instance if prints to the screen and so does , then each composite will print in a different order. Furthermore, if can manipulate its continuation? explicitly, it has to treat it linearly otherwise may be evaluated twice or not at all.
In the dual, if and is linear:
holds and similarly is evaluated first in the left morphism and is evaluated first in the right. Then as above it cannot perform any effects and has to treat its input linearly, as duplicating or dropping would make the equation fail to hold.
Briefly, the category of duploids and duploid functors is a reflective subcategory of the category of adjunctions and morphisms of adjunctions.
First, we construct a duploid from an adjunction, which we think of as a forgetful functor that only remembers the Kleisli morphisms of the adjunction. To keep the proof unbiased, we start with a profunctor that the adjunction represents. This gives us a notion of βoblique-β or hetero-morphism from a positive object to a negative object as and can be used to define the Kleisli and coKleisli categories. In programming applications these are the βpossibly effectfulβ morphisms. Then let be adjoint functors representing , i.e. there is a natural equivalence:
The pre-duploid has as objects with . The morphisms are defined as:
where
and identities are given by the identities/unit and counit of the adjunction:
To define composition of , we inspect . If is positive, composition is interpreted as composition in , or equivalently in the Kleisli category of , using
and similarly if is negative, composition is interpreted as composition in , or equivalently in the Kleisli category of , using
This definition makes it clear that the identities are identity and the and laws hold from identity and associativity of .
From a duploid, we can construct the βcofreeβ adjunction: i.e., a right adjoint to the forgetful functor just defined. Intuitively, we want to recover the homomorphisms just from the heteromorphisms. The maximal choice is to consider all thunkable morphisms between positive types and linear morphisms between negative types to be homomorphisms.
Furthermore, this functor is fully faithful, making the category of duploids a reflective subcategory of adjunctions: they can be identified with exactly those adjunctions in which the unit and counit are mono and epi respectively and in which all thunkable heteromorphisms are the image under of some homomorphism and vice-versa all linear heteromorphisms are in the image of . This is equivalent to saying that the unit is the equalizer of and and dually that the counit is the coequalizer of and
Duploids were introduced in chapter II of
Last revised on July 19, 2022 at 14:25:53. See the history of this page for a list of all contributions to it.