nLab maybe 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

What is called the maybe monad is a simple monad in computer science which is used to implement the most basic kind of “exceptions” indicating the failure of a computation in terms of functional programming: The maybe monad models the exception which witnesses a failure without however producing any further information.

On the type system the maybe monad is the operation XX*X \mapsto X \sqcup \ast of forming the coproduct type with the unit type. (The exception monad for the unit type.)

The idea here is that a function XYX \longrightarrow Y in its Kleisli category is in the original category a function of the form XY*X \longrightarrow Y \coprod \ast so either returns indeed a value in YY or else returns the unique element of the unit type/terminal object *\ast – it is a partial function. The latter case is naturally interpreted as “no value returned”, hence as indicating a “failure in computation”.

Properties

under construction

Kleisli category

The Kleisli category of the maybe monad on SetSet is the category whose objects are sets, and whose morphisms are partial functions.

This observation generalizes as follows: if C\mathbf{C} is an extensive category and has a terminal object *\ast, then a morphism g:XY*g: X \to Y \coprod \ast as an object of the overcategory (C)/(Y*)\mathbf(C)/(Y \coprod \ast) determines (uniquely up to canonical isomorphism) an object

(f:X 1Y,!:X 2*)C/Y×C/*(f: X_1 \to Y, !: X_2 \to \ast) \in \mathbf{C}/Y \times \mathbf{C}/\ast

such that g=f!g = f \coprod !, in other words a partial morphism f:XYf: X \rightharpoonup Y whose domain of definition is a subobject X 1XX_1 \hookrightarrow X with complement X 2XX_2 \hookrightarrow X. In brief, maps in the Kleisli category are partial maps with complemented domain.

In particular, in the case of a Boolean topos, the Kleisli category is the category of objects and partial maps; see also partial map classifier.

EM-category and Relation to pointed objects

The algebras over the maybe monad are pointed objects.

Moreover, assuming C\mathbf{C} has finite products and an appropriate form of distributivity (which obtains if for example C\mathbf{C} is lextensive), the maybe monad on C\mathbf{C} is a monoidal monad on the cartesian monoidal category C\mathbf{C}. It follows (by the discussion at commutative monad, see also (Seal 12)) that its Eilenberg-Moore category of algebras canonically inherits the structure of a monoidal category, at least under the mild assumption that it has reflexive coequalizers. Note that the maybe monad TT preserves reflexive coequalizers, so the monadic functor creates reflexive coequalizers if the base category has them; in this abstract setting the monoidal product on algebras (X,α:TXX)(X, \alpha: T X \to X), (Y,β:TYY)(Y, \beta: T Y \to Y) is given explicitly as the coequalizer of T(α×β):T(TX×TY)T(X×Y)T(\alpha \times \beta): T(T X \times T Y) \to T(X \times Y) and

T(TX×TY)T(ϕ X,Y)TT(X×Y)μT(X×Y)T(T X \times T Y) \stackrel{T(\phi_{X, Y})}{\to} T T(X \times Y) \stackrel{\mu}{\to} T(X \times Y)

where ϕ\phi is one of the structural constraints on the monoidal monad TT and μ\mu is the multiplication on TT. One finds that this coequalizer yields the usual smash product of pointed objects.

Remark

The smash product as the correct monoidal product can also be deduced in a perhaps more perspicuous manner if we assume more of the base category: that it is cartesian closed, finitely complete, and finitely cocomplete. In that case we construct the internal hom of TT-algebras, i.e., the internal hom of pointed objects (Y,β:TYY)(Y, \beta: T Y \to Y) and (Z,γ:TZZ)(Z, \gamma: T Z \to Z) directly as an equalizer of maps

Z Y TZ TY Z β γ TY Z TY\array{ Z^Y & \to & T Z^{T Y} \\ & \mathllap{Z^\beta} \searrow & \downarrow \mathrlap{\gamma^{T Y}} \\ & & Z^{T Y} }

where the top arrow expresses enriched functoriality of TT (which in turn is closely related to the strength on TT). The success of this is guaranteed by the commutativity of the monad (which here takes a particularly simple form, being given by the commutative monoid *\ast with respect to coproduct \coprod). Then, by taking the monoidal product that is adjoint to the internal hom, one is led to the smash product (XY) *(X \wedge Y)_\ast all the same: that is, one can read off the smash product from the fact that pointed maps X *hom *(Y *,Z *)X_\ast \to \hom_\ast(Y_\ast, Z_\ast) should correspond to pointed maps (XY) *Z *(X \wedge Y)_\ast \to Z_\ast.

Relation to natural number objects

Regarding just the underlying endofunctor of the maybe monad, its initial algebra over an endofunctor is a natural numbers object.

On the augmented simplex category

We may view the augmented simplex category as the subcategory of Set\Set whose objects are the finite von Neumann ordinals and whose morphisms are the monotone functions between them. Then the maybe monad on Set\Set restricts to Δ a\Delta_a to give the monad that sends the object n\mathbf{n} to n+1\mathbf{n+1} and the morphism f:nmf:\mathbf{n}\to\mathbf{m} to the morphism T(f):n+1m+1T(f):\mathbf{n+1}\to\mathbf{m+1} defined by

T(f)(k)={f(k) k<n m k=nT(f)(k) = \begin{cases} f(k) & k \lt n\\ m & k = n \end{cases}

In fact, Δ a\Delta_a is freely generated by this structure and 0\mathbf{0} in the sense that its objects are given by n=T n0\mathbf{n}=T^n\mathbf{0}, the face maps are given by δ i n=T ni1η i\delta_i^n=T^{n-i-1}\eta_\mathbf{i}, the degeneracy maps are given by σ i n=T ni1μ i\sigma_i^n=T^{n-i-1}\mu_\mathbf{i}, and the simplicial identities are precisely the monad axioms. Another way to put this is that (Δ a,T,0)(\Delta_a,T,\mathbf{0}) is the initial object of the 22-category whose objects are categories equipped with a monad and an object.

This means that if C is some other category equipped with a comonad and an object then we get a canonical functor Δ a opC\Delta_a^\mathrm{op}\to C and hence an augmented simplicial object in CC. In particular when CC is the category of algebras of a monad on DD we get a simplicial object for each algebra, whose underlying simplicial object in DD is the bar construction.

The comonad T opT^\mathrm{op} on Δ a op\Delta_a^\mathrm{op} induces the Décalage comonad.

References

Around (0.4.24.2) in

the algebraic structure of the would be “field with one element” is regarded as being the maybe monad, hence modules over 𝔽 1\mathbb{F}_1 are defined to be monad-algebras over the maybe monad, hence pointed sets.

Last revised on November 2, 2022 at 08:36:42. See the history of this page for a list of all contributions to it.