Cours 6: Algebraic theories

Free monads

Pointed set:

a set A equipped with an element

One should think of as a 0-ary operation 1=A0A.

n-ary operation:

element of AnA

Monoid:

  • set equipped with binary operation A2A
  • with associativity law: m(m(x,y),z)=m(x,m(y,z))

Partiality monad: 1+A ⟺ the “free pointed set” monad

Algebraic theories

A signature Σ:

is a family (Σn)n of sets

An element fΣn is called an “operation of arity n

fΣ2f(f(x,y),f(f(x,y),y))
A term of a signature Σ with variables in X:

is a finite tree of which nodes are the operations of Σ and leaves are in XΣ0

NB: notation: Term(Σ,X)

An algebraic theory of signature Σ:

is a family of pairs (t,n) (also written t=u)

  • X={x0,,xn}
  • tTerm(Σ,X)
  • uTerm(Σ,X)
Given a set X of variables and algebraic theory:
T(X)=Term(Σ,X)/

where is the equivalence relation generated by the equations of the theory

Ex: The algebraic theory of monoids

  • Σ2={m}
  • Σ0={e}

  • Signature:

    • Σn= for n0,2
    • Σ={m:2,e:0}
  • Equations:

    • associativity: m(m(x,y),z)
    • unit laws: m(e,x)=x=m(x,e)

In the case of the algebraic theory of monoids:

T(X)={trees generated by m, e with leaves in X}/assoc, unit laws={finite words on X}=nAn

Ex: Magmas

Magma:

a set equipped with a binary operation m:A2A

(no associativity, no unit)

T(X)={binary trees with leaves in X}=Term(Σ,X)
Commutative monoids:
m(x,y)=m(y,x)
T(X)={finite multiset on the alphabet X}

Th: algebraic theory defines a monad T:SetSet in that way

η:{ATAathe equivalence class of aTerm(Σ,A)

and

μ:TTATA

natural in A.

An element of T(TA):

is a tree of signature Σ with leaves in TA (and also in Σ0) modulo the equations of the algebraic theory.

For every such leaf [ti]TA, one can pick an element tiTerm(Σ,A) such that [Ai] is the equivalence class of ti

Substitute t1,,tn in the tree ATerm(Σ,TA) to obtain t[t1,,tn]Term(Σ,A)

The equivalence class [t[t1,,tn]Term(Σ,A)]T(A)

does not depend on the choice of t1,,tn but only on their equivalence classes

[t]TTA,[ti]TA

Algebraic theory of the commutative rings

Σ={0:0,1:1,:1,×:2,+:2}
  • +,× are associative and commutative
  • 0,1: neutral elements
  • : inverse law
  • distributivity
T(X)=[X]

since we can push the × under the + and , by distributivity.

Algebras of algebraic theories

An algebra of an algebraic theory:

is a set A equipped with a function opf:AnA for every operation fΣn of arity n, and satisfies the equations of the theory.

A homomorphism AB between such algebras:

is a function h:AB such that h(opA(a1,,an))=opB(h(a1),,h(an)) for all opΣn,a1,,anA

Th: TA is the free algebra generated by the set A in the sense that for every function f:AB where B is an algebra, there exists a unique homomorphism h:TAB such that

TAhBAηAf

commutes

The state monad

Fact: the state monad can be defined as the monad associated to a specific algebraic theory of mnemoids.

The free mnemoid generated by A = S(S×A)

To make things simpler, let us take V=S={true,false}

lookup:{A2A(M,N){M if the register is trueN else

and

  • updatetrue:AA
  • updatefalse:AA
lookup(updatetrue,updatefalse)=x

How does one recover the algebra of a given alg. theory from the monad T?

For instance: can we recover the notion of monoid from the monad TA=nAn?

  • unit of the monad: ηA:ATA
  • multiplication of the monad: μA:TTATA
An algebra of a monad T:𝒞𝒞:

is an object A of the category 𝒞 equipped with a morphism h:TAA s.t. the following diagrams commute: TAhAηAidAA

and

TTAThμATAhTAhA
A homomorphism between T-algebras f:(A,hA)(B,hB):

is a morphism f:AB s.t. the following diagram commutes: TATfhATBhBAfB

This defines a category Alg whose objects are the T-algebras whose morphisms are the homomorphisms between them.

Th: for every algebraic theory, the category of algebras (and homomorphisms) of the theory is isomorphic to the category of T-algebras for the associated monad T.

Example: in the case of the “free monoid monad” T:SetSet, TAnAn

a function h:TAA is the same thing as a family of functions hn:AnA

NB: hn(a1,,an) can be thought of as a1an

In particular:

  • neutral element: h0:A0={}A
  • multiplication: h2:A2A

Claim: h2(h2(a,b),c)=h3(a,b,c)

Because of [[a,b],c]TTAThμATA[h2(a,b),h1(c)]h[a,b,c]TAhAh2(h2(a,b),h1(c))=h3(a,b,c)

Claim: h1(a)=a

Because of [a]TAhaAηAidAAh1(a)=a

More generally:

h2(hp(a1,,ap),hq(a1,,aq))=hp+q(a1,,ap,a1,,aq)

Hence: a T-algebra for the free monoid monad T is entirely determined by h0 and h1:

hn(a1,,an)=h2(a1,h2(a2,,an))

Associativity comes from the equation h2(a,h2(b,c))=h3(a,b,c)=h2(h2(a,b),c)

We can recover the monad from the notion of T-algebra ⟶ the monad is an invariant of an algebraic theory.

From Monads to categories of T-algebras

For every monad T:𝒞𝒞 , there is an adjunction

𝒞F FreeAlgT𝒰 forget 𝒰:(A,h)A F:A(TA,μA:TTATA)

Observation:

every object A of the category 𝒞 induces a T-algebra (TA,μA)

μA:TTATA

The monad T=𝒰F is recovered from the adjunction.

A monoid is a topological space equipped with a contractible space of operations ⟹ operads (A-algebras)

Operads: generalization of algebraic theories to a topological space of operations

Back to homorphisms: why are they so simple?

nAn=TATfhATB=nBnhBAfB

means that

Anfn(hA)nBn(hB)nAfB

In other words:

hn(fa1,,fan)=f(hn(a1,,an))

Leave a comment