nLab
maybe monad

Contents

Context

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

logiccategory theorytype theory
trueterminal object/(-2)-truncated objecth-level 0-type/unit type
falseinitial objectempty type
proposition(-1)-truncated objecth-proposition, mere proposition
proofgeneralized elementprogram
cut rulecomposition of classifying morphisms / pullback of display mapssubstitution
cut elimination for implicationcounit for hom-tensor adjunctionbeta reduction
introduction rule for implicationunit for hom-tensor adjunctioneta conversion
logical conjunctionproductproduct type
disjunctioncoproduct ((-1)-truncation of)sum type (bracket type of)
implicationinternal homfunction type
negationinternal hom into initial objectfunction type into empty type
universal quantificationdependent productdependent product type
existential quantificationdependent sum ((-1)-truncation of)dependent sum type (bracket type of)
equivalencepath space objectidentity type
equivalence classquotientquotient type
inductioncolimitinductive type, W-type, M-type
higher inductionhigher colimithigher inductive type
completely presented setdiscrete object/0-truncated objecth-level 2-type/preset/h-set
setinternal 0-groupoidBishop set/setoid
universeobject classifiertype of types
modalityclosure operator, (idemponent) 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 “exceptions” indicating the failure of a computation in terms of functional programming.

On the type system the maybe monad is the operation XX*X \mapsto X \coprod \ast.

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.

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 September 30, 2014 at 05:14:44. See the history of this page for a list of all contributions to it.