Definition. Grammar Quotients

For formal grammars 𝐴 and 𝐡, the quotient of 𝐡 by 𝐴 is the grammar of what is left of 𝐡 once an 𝐴 has been read off the front:

(𝐷𝐴𝐡)(𝑣)=Σ𝑒𝐴(𝑒)×𝐡(𝑒·𝑣)

A parse of the quotient consists of an 𝐴-parses at prefix 𝑒 and a 𝐡-parse of the full string 𝑒·𝑣.

This operation has a right adjoint:

(𝐢𝐴)(𝑀)=Π𝑒,𝑣(𝑒·𝑣=𝑀)→𝐴(𝑒)→𝐢(𝑣)

Intuitively, 𝐢𝐴 parses 𝑀 if: for all splittings of 𝑀 into a prefix and suffix, if the prefix matches 𝐴 then the suffix must match 𝐢.

Together, these form the adjunction:

𝐷𝐴𝐡⊒𝐢⟺𝐡⊒𝐢𝐴

This is an instance of the Day quotient over the discrete monoidal category of strings.

grammar-quotients definition entries/parsing/grammar-quotients.hel