Tag. F-coalgebra

Notes (6)

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.

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-coalgebra tag