Tag. well-founded

Notes (12)

Predecessors simplify later predecessors-simplify-later

A predecessor of π‘₯ is a top element of its strict downset: a strict morphism 𝜌:𝑝→π‘₯ through which every strict morphism into π‘₯ factors uniquely. Equivalently, π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯)≅𝗒𝑝 β€” the downset is representable.

The Yoneda lemma then collapses later to evaluation:

βŠ³π‘ƒ(π‘₯)=π–―π—Œπ—π’žοΈ€(π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯),𝑃)β‰…π–―π—Œπ—π’žοΈ€(𝗒𝑝,𝑃)≅𝑃(𝑝),

with 𝗇𝖾𝗑𝗍 becoming restriction along 𝜌. The name is from the naturals: every strict map into 𝑛+1 factors through 𝑛→𝑛+1, so on πœ” β€” in the topos of trees β€” later is just the shift

βŠ³π‘ƒ(0)β‰…βŠ€,βŠ³π‘ƒ(𝑛+1)≅𝑃(𝑛),

and a LΓΆb step is a base value together with a rule producing the value at 𝑛+1 from the value at 𝑛.

When this predecessor exists, we can give a simpler description of later, as in the topos of trees, but this may not be possible in all direct categories.

Definition. Direct categories direct-category

A well-founded order is a set 𝐷 with a proposition-valued transitive relation < admitting no infinite descent: every element is accessible. Write π‘Žβ‰€π‘ for (π‘Ž<𝑏)∨(π‘Ž=𝑏).

A direct structure on a category π’žοΈ€ over (𝐷,<) is a functor

deg:π’žοΈ€β†’(𝐷,≀)

into the well-founded order viewed as a poset category. The functor organizes two pieces of data at once: an ordering on the objects, and the invariant that morphisms respect it β€” 𝑓:π‘₯→𝑦 forces degπ‘₯≀deg𝑦.

A direct structure equips the objects with a well-founded strict relation

π‘₯β‰Ίπ‘¦βŸΊdegπ‘₯<deg𝑦.

Intuitively, direct categories are the right generalization of well-foundedness to the categorical setting: a direct category is essentially one whose underlying graph is a directed acyclic graph, layered by degree, so that data at an object may be defined by recursion from data at all objects strictly below it.

The degrees order the objects, while the morphisms of π’žοΈ€ say how an object sits over its predecessors.

Definition. Earlier on presheaves earlier-presheaf

Later takes a limit over smaller indices. Dually, the earlier modality takes a colimit over larger indices: an element of βŠ²π‘ƒ at π‘₯ is a 𝑃-element sitting at some object 𝑦 strictly above π‘₯, carried down along a chosen morphism π‘₯→𝑦.

Earlier is left adjoint to later:

⊲⊣⊳

Under this adjunction, 𝗇𝖾𝗑𝗍:π‘ƒβ†’βŠ³π‘ƒ corresponds to

𝗉𝗋𝖾𝗏:βŠ²π‘ƒβ†’π‘ƒ,

.

Definition. Later on families later-family

Conjugation with the adjunction between presheaves and families π‘ˆβŠ£Cofree lets us induce a later construction on families from the one on presheaves,

⊳Fam=π‘ˆβˆ˜βŠ³βˆ˜Cofree:Fam(π’žοΈ€)β†’Fam(π’žοΈ€).

Concretely, later on families evaluates to

⊳Fam𝐴(π‘₯)β‰…βˆπ‘¦β‰Ίπ‘₯Β βˆπ‘“:𝑦→π‘₯𝐴(𝑦)

Definition. Later on presheaves later-presheaf

The later modality for presheaves on a direct category is given by the presheaf of natural transformations

out of the strict downset.

(βŠ³π‘ƒ)(π‘₯)=π–―π—Œπ—π’žοΈ€(π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯),𝑃).

An element of βŠ³π‘ƒ at π‘₯ is a coherent choice of 𝑃-elements at all objects strictly smaller than π‘₯.

Restriction in βŠ³π‘ƒ along 𝑓:𝑦→π‘₯ precomposes with the induced map π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(𝑦)β†’π–²π—π—‹π—‚π–Όπ—π–£π—ˆπ—π—‡(π‘₯). At an object of minimal degree the strict downset is empty, so βŠ³π‘ƒ is trivial there.

Via functoriality, every presheaf restricts to smaller indices. Thus we may define the map

𝗇𝖾𝗑𝗍:π‘ƒβ†’βŠ³π‘ƒ

that sends an element 𝑝 over π‘₯ to the family of all its restrictions along morphisms from strictly lower objects.

Theorem. LΓΆb induction on families lob-family

Like later on families, the recursion principle for families is inherited from that on presheaves. Given a family 𝐴 and a step

πœ‘π‘₯:⊳Fam𝐴(π‘₯)→𝐴(π‘₯)for each π‘₯,

the construction is a chain of transpositions with LΓΆb for presheaves used in the middle:

Just as for presheaves, the fixed point constructed above is unique: the two transpositions are bijections, and the presheaf-level fixed point is already unique.

Theorem. LΓΆb induction for presheaves on a direct category lob-presheaf

Let π’žοΈ€ be a direct category and 𝑃 a presheaf on it. Every map

πœ‘:βŠ³π‘ƒβ†’π‘ƒ

has a fixed point: a global element π—…ΓΆπ–»πœ‘:βŠ€β†’π‘ƒ with

π—…ΓΆπ–»πœ‘=π—…ΓΆπ–»πœ‘β‹†π—‡π–Ύπ—‘π—β‹†πœ‘,

and this fixed point is unique.

The hypothesis says: the value of 𝑃 at any object is determined by its values over the strict past β€” πœ‘ turns a coherent family over the strict downset of π‘₯ into a value at π‘₯. The proof is recursion along the well-founded β‰Ί: at each π‘₯, the section already constructed over the past assembles into an element of (βŠ³π‘ƒ)(π‘₯), and πœ‘ extends it to π‘₯.

Definition. Locally contractive endofunctors locally-contractive-functor

Write π‘‹β‡’π‘Œ for the presheaf of morphisms π‘‹β†’π‘Œ. An endofunctor 𝐹 on presheaves is locally contractive when its action on morphisms factors through later: there is a map

𝐹𝛿:⊳(π‘‹β‡’π‘Œ)β†’(πΉπ‘‹β‡’πΉπ‘Œ)

Well-founded posets are thin direct categories well-founded-poset-as-thin

Every poset forms a thin category. Similarly, if the poset is well-founded then it induces a thin direct category.

Definition. Later on Grammars grammar-later

Write π‘’βŠπ‘£ when 𝑒 is a proper suffix of 𝑣, that is, 𝑣=π‘₯++𝑒 with π‘₯β‰ πœ€. The later of a grammar 𝐴 is

(▷𝐴)𝑣=βˆπ‘’βŠπ‘£π΄π‘’.

A parse of ▷𝐴 over 𝑣 is a parse of 𝐴 over every proper suffix of 𝑣. In particular (▷𝐴)πœ€ is a singleton.

This is later on families for strings under the proper-suffix order. That order is well-founded because it strictly decreases length, so it is a thin direct category. There is at most one map 𝑒→𝑣, so the product over maps from the strict past has one factor per proper suffix. Guarded recursion is modelled by presheaves on πœ”, the topos of trees, and more generally by sheaves over a well-founded base [1]. Here the later acts on families, which is what grammars are, and there is no clock.

Later is the right adjoint of the proper-suffix derivative. Let 𝖭𝖀𝖲=⨁π‘₯β‰ πœ€βŒˆπ‘₯βŒ‰ be the grammar of non-empty strings. Then the derivative (πœ•π–­π–€π–²π΅)π‘’β‰…βˆ‘π‘₯β‰ πœ€π΅(π‘₯++𝑒) has the right adjoint

πΆπ–­π–€π–²π‘£β‰…βˆπ‘₯++𝑒=𝑣𝖭𝖀𝖲π‘₯→𝐢𝑒≅(▷𝐢)𝑣,

so πœ•π–­π–€π–²βˆ’βŠ£β–·. Splitting 𝖭𝖀𝖲 into its summands gives the form of β–· that the calculus can define:

▷𝐴≅&π‘€β‰ πœ€π΄βŒˆπ‘€βŒ‰,π΄βŒˆπ‘€βŒ‰β‰…(βŒˆπ‘€βŒ‰βŠ—βŠ€)β‡’(βŒˆπ‘€βŒ‰βŠ—π΄).

The component at 𝑀 says: if the string begins with 𝑀, then the rest parses as 𝐴.

The restriction to non-empty 𝑀 is what makes this a later. At 𝑀=πœ€ the component is π΄βŒˆπœ€βŒ‰β‰…π΄. Including it would give a projection β–·π΄βŠ’π΄, and LΓΆb would then prove every grammar. For the same reason the later is a product over suffixes. A sum such as β¨π‘βŒˆπ‘βŒ‰βŠΈπ΄ is empty at πœ€, and at 𝐴=βŠ₯ it is βŠ₯. The identity step βŠ₯⊒βŠ₯ would then give LΓΆb a proof of ⊀⊒βŠ₯.

In the Agda this is β–· in Grammar/Later/Base.agda, which is defined as the indexed conjunction of √l-string. The mirror image β–·r, over proper prefixes, is defined in the same way. See also the bilateral later and the later along an arbitrary well-founded order.

Theorem. LΓΆb Induction for Grammars grammar-lob

For every grammar 𝐴 and every term πœ‘:β–·π΄βŠ’π΄, where β–· is the later on grammars, there is a unique global parse π—…ΓΆπ–»πœ‘:⊀⊒𝐴 with

π—…ΓΆπ–»πœ‘=πœ‘βˆ˜π—‡π–Ύπ—‘π—(π—…ΓΆπ–»πœ‘).

Here 𝗇𝖾𝗑𝗍𝑑:βŠ€βŠ’β–·π΄ restricts a global parse 𝑑 to every proper suffix.

The proof is recursion on the length of the string. At 𝑣, the parses already built at the proper suffixes of 𝑣 form an element of (▷𝐴)𝑣, and πœ‘ turns it into a parse at 𝑣. Uniqueness is LΓΆb for families over the proper-suffix order. In the Agda, lob in Grammar/Later/Base.agda is this recursion, done by well-founded induction on length.

To prove an entailment 𝐡⊒𝐢 this way, apply LΓΆb to 𝐴=𝐡⇒𝐢. The hypothesis β–·(𝐡⇒𝐢) is the induction hypothesis at every proper suffix. It becomes usable once a non-nullable grammar has been consumed. If πœ€&𝐡⊒βŠ₯, then

(π΅βŠ—βŠ€)&β–·π΄βŠ’π΅βŠ—π΄

because a parse of π΅βŠ—βŠ€ over 𝑣 splits 𝑣=π‘₯++𝑒 with π‘₯ non-empty, so π‘’βŠπ‘£. This is β–·-app-NE in Grammar/Later/Properties.agda. Induction on a Kleene star is the standard use.

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-well-founded tag