nLab continuation monad

Contents

Context

Computation

Categorical algebra

Type theory

natural deduction metalanguage, practical foundations

  1. type formation rule
  2. term introduction rule
  3. term elimination rule
  4. computation rule

type theory (dependent, intensional, observational type theory, homotopy type theory)

syntax object language

computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory

logicset theory (internal logic of)category theorytype theory
propositionsetobjecttype
predicatefamily of setsdisplay morphismdependent type
proofelementgeneralized elementterm/program
cut rulecomposition of classifying morphisms / pullback of display mapssubstitution
introduction rule for implicationcounit for hom-tensor adjunctionlambda
elimination rule for implicationunit for hom-tensor adjunctionapplication
cut elimination for implicationone of the zigzag identities for hom-tensor adjunctionbeta reduction
identity elimination for implicationthe other zigzag identity for hom-tensor adjunctioneta conversion
truesingletonterminal object/(-2)-truncated objecth-level 0-type/unit type
falseempty setinitial objectempty type
proposition, truth valuesubsingletonsubterminal object/(-1)-truncated objecth-proposition, mere proposition
logical conjunctioncartesian productproductproduct type
disjunctiondisjoint union (support of)coproduct ((-1)-truncation of)sum type (bracket type of)
implicationfunction set (into subsingleton)internal hom (into subterminal object)function type (into h-proposition)
negationfunction set into empty setinternal hom into initial objectfunction type into empty type
universal quantificationindexed cartesian product (of family of subsingletons)dependent product (of family of subterminal objects)dependent product type (of family of h-propositions)
existential quantificationindexed disjoint union (support of)dependent sum ((-1)-truncation of)dependent sum type (bracket type of)
logical equivalencebijection setobject of isomorphismsequivalence type
support setsupport object/(-1)-truncationpropositional truncation/bracket type
n-image of morphism into terminal object/n-truncationn-truncation modality
equalitydiagonal function/diagonal subset/diagonal relationpath space objectidentity type/path type
completely presented setsetdiscrete object/0-truncated objecth-level 2-type/set/h-set
setset with equivalence relationinternal 0-groupoidBishop set/setoid with its pseudo-equivalence relation an actual equivalence relation
equivalence class/quotient setquotientquotient type
inductioncolimitinductive type, W-type, M-type
higher inductionhigher colimithigher inductive type
-0-truncated higher colimitquotient inductive type
coinductionlimitcoinductive type
presettype without identity types
set of truth valuessubobject classifiertype of propositions
domain of discourseuniverseobject classifiertype universe
modalityclosure operator, (idempotent) monadmodal type theory, monad (in computer science)
linear logic(symmetric, closed) monoidal categorylinear type theory/quantum computation
proof netstring diagramquantum circuit
(absence of) contraction rule(absence of) diagonalno-cloning theorem
synthetic mathematicsdomain specific embedded programming language

homotopy levels

semantics

Contents

Idea

In a category with internal homs [,][-,-], given an object SS, the continuation monad is the endofunctor X[[X,S],S]X \mapsto [[X, S], S].

In computer science this monad (in computer science) is used to model continuation-passing style of programming, and therefore this is called the continuation monad. The idea here is that a morphism f:XYf \colon X \to Y in the Kleisli category of the continuation monad, hence a morphism in the original category of the form X[[Y,S],S]X\longrightarrow [[Y,S],S] is much like a map from XX to YY only that instead of “returning” its output directly it instead feeds it into a given function YSY \to S which hence continues the computation.

Algebras

Proposition

On the category of sets, the functor [,S]:Set opSet[-,S] \colon\mathbf{Set}^{op}\to \mathbf{Set} is monadic (with left adjoint [,S] op:SetSet op[-, S]^{op} \colon \mathbf{Set} \to \mathbf{Set}^{op}) whenever |S|2{|S|}\geq 2.

Thus the Eilenberg-Moore algebras of the continuation monad are equivalent to complete atomic Boolean algebras, as the category of these is equivalent to the opposite of the category of sets.

(This incidentally illustrates the fact that a category can be monadic over Set\mathbf{Set} in multiple ways. In other words, one should not refer to a category CC as monadic over SetSet, unless everyone agrees to which “forgetful functor” U:CSetU\colon C \to \mathbf{Set} is being considered – better is to refer to a functor as monadic.)

Proof

This boils down to the assertion that such an SS is an injective cogenerator in the category of sets. It is injective because it is a retract of an injective object 2 S2^S (using the fact that the subobject classifier 22 is injective), and it cogenerates because there is an injection 2S2 \to S and 22 cogenerates.

In more detail: an object SS is (internally) injective if [,S]:Set opSet[-, S]: Set^{op} \to Set takes (coreflexive) equalizers in SetSet to coequalizers in SetSet. The subobject classifier 22 is injective (by, for example, the proof of Paré’s theorem for constructing finite colimits in an elementary topos). Since S×:SetSetS \times -: Set \to Set preserves connected limits such as equalizers, we have that [S×,2][,2 S][S \times -, 2] \cong [-, 2^S] takes equalizers to coequalizers, i.e., 2 S2^S is injective for any SS. Then SS, being a retract of 2 S2^S, has the property that [,S][-, S] takes equalizers in SetSet to coequalizers, i.e., preserves coequalizers Set opSetSet^{op} \to Set.

Also [,S][-, S] reflects isomorphisms. This is because isomorphisms in SetSet are precisely epi-monos, and SS being an internal cogenerator means exactly that [,S][-, S] is faithful, and faithful functors reflect monos and epis.

Since [,S][-, S] preserves coequalizers and reflects isomorphisms, we conclude that it is monadic by Beck’s crude monadicity theorem.

Examples

References

As a monad in computer science:

The continuation monad is discussed in the generality of linear type theory as the linear double negation monad in

  • Paul-André Melliès, Nicolas Tabareau, Linear continuation and duality, 2008 (pdf)

  • Paul-André Melliès, The parametric continuation monad, Mathematical Structures in Computer Science, Festschrift in honor of Corrado Böhm for his 90th birthday (2013). (pdf)

The characterization of algebras is Proposition 10 of

A characterisation of (enriched) monads isomorphic to continuation monads is given in:

  • Christopher Townsend, When are enriched strong monads double exponential monads?, Bulletin of the Belgian Mathematical Society-Simon Stevin 23.2 (2016): 311-319.

Last revised on December 30, 2023 at 12:46:12. See the history of this page for a list of all contributions to it.