Tag. F-algebra

Notes (10)

Algebras as a displayed category algebras-displayed

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. The 𝐹-algebras form a displayed category AlgStr(𝐹) over π’žοΈ€.

Over an object π‘₯, a displayed object of AlgStr(𝐹) is a structure map

π›Όβˆˆπ’žοΈ€(𝐹π‘₯,π‘₯).

Over 𝑓:π‘₯→𝑦, a displayed morphism from 𝛼 to 𝛽 is the proposition that 𝑓 is an algebra homomorphism:

𝛼⋆𝑓=𝐹𝑓⋆𝛽.

The total category Alg(𝐹)=∫AlgStr(𝐹) is the category of 𝐹-algebras.

The co-Eilenberg–Moore category as a displayed category co-eilenberg-moore-displayed

A comonad on π’žοΈ€ is a monad π‘Š on π’žοΈ€op. Everything about its coalgebras is then inherited from the Eilenberg–Moore construction, instantiated at the opposite category β€” nothing is defined twice.

Algebras of π‘Š over π’žοΈ€op are coalgebras π›Ύβˆˆπ’žοΈ€(π‘₯,π‘Šπ‘₯) of the underlying endofunctor, and the monad algebra laws, read in π’žοΈ€op, are the comonad coalgebra laws β€” the unit and multiplication of π‘Š, viewed in π’žοΈ€, are the counit πœ€ and comultiplication 𝛿:

π›Ύβ‹†πœ€π‘₯=𝗂𝖽π‘₯𝛾⋆𝛿π‘₯=π›Ύβ‹†π‘Šπ›Ύ.

The co-Eilenberg–Moore category is the opposite of the total category:

coEM(π‘Š)=(EM(π‘Š))op.

Coalgebras as a displayed category coalgebras-displayed

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. Coalgebras require no new construction: a coalgebra is an algebra in the opposite category. Define

CoalgStr(𝐹)=AlgStr(𝐹op),

a displayed category over π’žοΈ€op, where 𝐹op:π’žοΈ€opβ†’π’žοΈ€op is 𝐹 acting on the opposite category.

Concretely, over an object π‘₯ a displayed object is a structure map

π›Ύβˆˆπ’žοΈ€(π‘₯,𝐹π‘₯).

The category of coalgebras is the opposite of the total category:

Coalg(𝐹)=(∫CoalgStr(𝐹))op.

The outer opposite returns morphisms to the direction of π’žοΈ€: a morphism (π‘₯,𝛾)β†’(𝑦,𝛿) is a map 𝑓:π‘₯→𝑦 with

𝑓⋆𝛿=𝛾⋆𝐹𝑓.

The Eilenberg–Moore category as a displayed category eilenberg-moore-displayed

Fix a monad (𝑇,πœ‚,πœ‡) on π’žοΈ€. Its Eilenberg–Moore category arises in two displayed layers. The first layer is the displayed category of algebras AlgStr(𝑇) of the underlying endofunctor.

The second layer, EMStr(𝑇), is displayed over the total category Alg(𝑇). Over an algebra (π‘₯,𝛼) the displayed objects are the propositions that 𝛼 satisfies the monad algebra laws:

πœ‚π‘₯⋆𝛼=𝗂𝖽π‘₯πœ‡π‘₯⋆𝛼=𝑇𝛼⋆𝛼.

The Eilenberg–Moore category is the total category of the tower:

EM(𝑇)=∫EMStr(𝑇).

Definition. Initial algebra initial-algebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. An initial 𝐹-algebra, written πœ‡πΉ, is an initial object of the category of algebras Alg(𝐹).

Unfolding the universal property: an initial algebra is an algebra (πœ‡πΉ,in) such that every algebra (π‘₯,𝛼) admits a unique morphism fold𝛼:πœ‡πΉβ†’π‘₯ satisfying

in⋆(fold𝛼)=𝐹(fold𝛼)⋆𝛼.

Definition. Terminal coalgebra terminal-coalgebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. A terminal 𝐹-coalgebra, written 𝜈𝐹, is a terminal object of the category of coalgebras Coalg(𝐹) β€” equivalently, an initial algebra for 𝐹op.

Unfolding the universal property: a terminal coalgebra is a coalgebra (𝜈𝐹,out) such that every coalgebra (π‘₯,𝛾) admits a unique morphism unfold𝛾:π‘₯β†’πœˆπΉ satisfying

(unfold𝛾)⋆out=𝛾⋆𝐹(unfold𝛾).

Definition. Corecursive algebra corecursive-algebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. An algebra 𝛼:𝐹𝐡→𝐡 is corecursive when for every coalgebra 𝛾:𝑋→𝐹𝑋 there is exactly one hylomorphism from 𝛾 to 𝛼. Equivalently, the functor π–§π—’π—…π—ˆ(βˆ’,𝛼) of the hylomorphism profunctor is constantly a singleton. It is the dual of a recursive coalgebra: an 𝐹-algebra in π’žοΈ€ is corecursive exactly when it is recursive as an 𝐹op-coalgebra in π’žοΈ€op.

Example. If (𝜈𝐹,π—ˆπ—Žπ—) is a terminal coalgebra, then π—ˆπ—Žπ— is invertible and π—ˆπ—Žπ—βˆ’1:𝐹(𝜈𝐹)β†’πœˆπΉ is a corecursive algebra: a solution of β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π—ˆπ—Žπ—βˆ’1 is the same thing as a solution of β„Žβ‹†π—ˆπ—Žπ—=π›Ύβ‹†πΉβ„Ž, that is, a coalgebra map into the terminal coalgebra, and there is exactly one, π—Žπ—‡π–Ώπ—ˆπ—…π–½π›Ύ.

Definition. Hylomorphism hylomorphism

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€, a coalgebra 𝛾:𝑋→𝐹𝑋 and an algebra 𝛼:𝐹𝐡→𝐡. A hylomorphism (or coalgebra-to-algebra morphism) from 𝛾 to 𝛼 is a morphism β„Ž:𝑋→𝐡 satisfying

β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π›Ό.

Definition. The hylomorphism profunctor hylomorphism-profunctor

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. Hylomorphisms form a profunctor from coalgebras to algebras,

π–§π—’π—…π—ˆ:π–’π—ˆπ–Ίπ—…π—€(𝐹)op×𝖠𝗅𝗀(𝐹)β†’π’πžπ­,

where π–§π—’π—…π—ˆ((𝑋,𝛾),(𝐡,𝛼)) is the set of β„Ž:𝑋→𝐡 with β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π›Ό.

The action is by composition. If 𝑔:(π‘Œ,𝛿)β†’(𝑋,𝛾) is a coalgebra morphism (𝑔⋆𝛾=𝛿⋆𝐹𝑔) and π‘˜:(𝐡,𝛼)β†’(𝐡′,𝛼′) is an algebra morphism (π›Όβ‹†π‘˜=πΉπ‘˜β‹†π›Όβ€²), then π‘”β‹†β„Žβ‹†π‘˜ is again a hylomorphism:

𝛿⋆𝐹(π‘”β‹†β„Žβ‹†π‘˜)⋆𝛼′=π›Ώβ‹†πΉπ‘”β‹†πΉβ„Žβ‹†π›Όβ‹†π‘˜=π‘”β‹†π›Ύβ‹†πΉβ„Žβ‹†π›Όβ‹†π‘˜=π‘”β‹†β„Žβ‹†π‘˜.

In these terms, a coalgebra 𝛾 is recursive when π–§π—’π—…π—ˆ(𝛾,βˆ’) is the terminal functor, and an algebra 𝛼 is corecursive when π–§π—’π—…π—ˆ(βˆ’,𝛼) is. For the inverse of an initial algebra the profunctor is representable, π–§π—’π—…π—ˆ(π—‚π—‡βˆ’1,βˆ’)≅𝖠𝗅𝗀(𝐹)(𝗂𝗇,βˆ’), and dually π–§π—’π—…π—ˆ(βˆ’,π—ˆπ—Žπ—βˆ’1)β‰…π–’π—ˆπ–Ίπ—…π—€(𝐹)(βˆ’,π—ˆπ—Žπ—) for a terminal coalgebra.

When every value of π–§π—’π—…π—ˆ is a singleton, every divide-and-conquer specification over 𝐹 has exactly one solution. This is what local contractivity guarantees.

Definition. Recursive coalgebra recursive-coalgebra

Fix an endofunctor 𝐹:π’žοΈ€β†’π’žοΈ€. A coalgebra 𝛾:𝑋→𝐹𝑋 is recursive when for every algebra 𝛼:𝐹𝐡→𝐡 there is exactly one hylomorphism β„Ž:𝑋→𝐡 from 𝛾 to 𝛼, that is, exactly one solution of

β„Ž=π›Ύβ‹†πΉβ„Žβ‹†π›Ό.

Equivalently, the functor π–§π—’π—…π—ˆ(𝛾,βˆ’) of the hylomorphism profunctor is constantly a singleton.

Recursiveness is a coalgebraic form of well-foundedness: 𝛾 decomposes each input into subproblems, and recursiveness says that every divide-and-conquer program built on this decomposition has a unique meaning, without mentioning an order on inputs. [1] use recursive coalgebras on categories of indexed families to obtain algorithms that are correct by the type of the map they compute.

Example. If (πœ‡πΉ,𝗂𝗇) is an initial algebra, then 𝗂𝗇 is invertible (Lambek’s lemma) and π—‚π—‡βˆ’1:πœ‡πΉβ†’πΉ(πœ‡πΉ) is a recursive coalgebra. Precomposing with the isomorphism 𝗂𝗇, the equation β„Ž=π—‚π—‡βˆ’1β‹†πΉβ„Žβ‹†π›Ό is equivalent to π—‚π—‡β‹†β„Ž=πΉβ„Žβ‹†π›Ό, which says β„Ž is an algebra map out of the initial algebra; there is exactly one, π–Ώπ—ˆπ—…π–½π›Ό.

The dual notion is a corecursive algebra.

tag-F-algebra tag