Documentation

Linglib.Syntax.CCG.Grammar

CCG grammars and their languages #

This file defines CCG grammars and their string languages. A grammar is a finite lexicon, a start atom, and its rule system, given as permission gates on the generalized composition schema; the formalisms of the literature are choices of gate. Grammar.targetRestricted is VW-CCG ([VSW94], [WJ88]), where the grammar owns a degree bound and a target restriction; Grammar.multimodal is the radically lexicalized modern formalism ([Bal02], [Ste19]), whose rule system is universal — a grammar is nothing but its lexicon and start symbol. The restriction modelled is the one [KKS15]'s generative-capacity results turn on, a target restriction: a rule fires only when the target of its primary input category (the leftmost atom, after stripping all arguments) is a distinguished atom s.

Rules are the generalized-composition schema CCG.Cat.generalizedForwardComp / CCG.Cat.generalizedBackwardComp, gated on the target: a derivation node records only its degree and direction, per the [VSW94] rule form — degree 0 is application, and the harmonic/crossed distinction is a consequence of the slash directions rather than a separate rule class. The schema is modality-blind (VW-CCG predates slash typing); grammars instantiate categories at the unrestricted modality.

The two rule-control mechanisms differ in expressive power ([KKS15]): with target restrictions VW-CCG is weakly equivalent to TAG, without them it is strictly weaker, and the slash-typing variant is likewise slightly less expressive than TAG. [SM21] upgrade the equivalence to strong equivalence (the same tree languages, modulo relabeling) for the modern capacity object: CCG without empty-string lexicon entries and with rules of degree at most 2 — with unbounded degree the formalism is Turing-complete. The Grammar of this file is that object (yields are token lists, so ε-entries are inexpressible by construction), and this file is the substrate for the constructions of CCGs for non-context-free languages in Studies/KuhlmannKollerSatta2015.

Main definitions #

Main statements #

Implementation notes #

Derivability is an inductive Prop, mathlib's form for grammar formalisms (ContextFreeGrammar.Derives), in contrast to the intrinsically typed CCG.Derivation of the interpreted theory: capacity arguments quantify over all derivations, and induction on Derives is exactly that quantification.

Grammars and their languages #

structure CCG.Grammar (α : Type u_2) :
Type u_2

A CCG grammar: a finite lexicon, a distinguished start atom, and the grammar's rule system, given as permission gates — allowsFwd n a b says forward composition of degree n may combine primary a with secondary b (mirrored by allowsBwd). The formalisms of the literature are choices of gate: Grammar.targetRestricted (VW-CCG) and Grammar.multimodal (the universal modality-controlled rules).

  • lexicon : List (String × Cat α)

    Lexical entries, pairing a token with a category.

  • start : α

    The distinguished atom: the language collects derivations of this category.

  • allowsFwd : Cat αCat αProp

    May forward composition of degree n combine primary a with secondary b?

  • allowsBwd : Cat αCat αProp

    May backward composition of degree n combine secondary a with primary b?

Instances For
    def CCG.Grammar.targetRestricted {α : Type u_1} (lexicon : List (String × Cat α)) (start : α) (degree : ) :

    A target-restricted (VW-CCG) grammar ([VSW94], [KKS15]): rules up to a degree bound, gated on the primary input's target (degree = 2 in [SM21]'s normal form).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def CCG.Multimodal.allowsFwd {α : Type u_1} :
      Cat αCat αProp

      The universal rule system of multimodal CCG ([Bal02], [Ste19]): degree at most 2, harmonic and crossing composition gated by the primary slash's modality, uniform secondary spines.

      Equations
      Instances For
        def CCG.Multimodal.allowsBwd {α : Type u_1} :
        Cat αCat αProp

        The mirror of Multimodal.allowsFwd.

        Equations
        Instances For
          def CCG.Grammar.multimodal {α : Type u_1} (lexicon : List (String × Cat α)) (start : α) :

          A multimodal grammar: the radically lexicalized formalism of [Ste19], where a grammar is nothing but a lexicon and a start symbol — its rule system is the universal modality-controlled one. Strictly less expressive than the target-restricted grammars ([KKS15]).

          Equations
          Instances For
            inductive CCG.Grammar.Derives {α : Type u_1} [DecidableEq α] (G : Grammar α) :
            Cat αList StringProp

            G.Derives c w: the grammar derives token string w at category c — a lexical entry, or a generalized composition of two adjacent derivations permitted by the grammar's gates. Capacity arguments proceed by induction on this relation.

            Instances For
              def CCG.Grammar.language {α : Type u_1} [DecidableEq α] (G : Grammar α) :
              Set (List String)

              The string language of a grammar: the token strings derived at the distinguished atom. Strings are token lists, so empty-string lexical entries are inexpressible — the ε-freeness of [SM21]'s normal form holds by construction.

              Equations
              Instances For

                The multimodal gate and the tree calculus #

                A multimodal grammar's derivability coincides with the existence of an intrinsically typed Derivation tree over its lexicon: the trees are the proof-relevant calculus (what Derivation.interp consumes), the relation is its string-language shadow.

                theorem CCG.Derivation.derives_multimodal {α : Type u_1} [DecidableEq α] {L : List (String × Cat α)} {s : α} {c : Cat α} (d : Derivation α c) :

                Every Derivation tree over the lexicon witnesses multimodal derivability.

                theorem CCG.Grammar.Derives.to_derivation {α : Type u_1} [DecidableEq α] {L : List (String × Cat α)} {s : α} {c₀ : Cat α} {w : List String} (h : (multimodal L s).Derives c₀ w) :
                ∃ (d : Derivation α c₀), Derivation.LexIn L d d.yield = w

                Multimodal derivability yields a Derivation tree over the lexicon: the gate and the schema equation jointly force the shape of a rule of the modern inventory.

                theorem CCG.Grammar.multimodal_derives_iff {α : Type u_1} [DecidableEq α] {L : List (String × Cat α)} {s : α} {c : Cat α} {w : List String} :
                (multimodal L s).Derives c w ∃ (d : Derivation α c), Derivation.LexIn L d d.yield = w

                Multimodal derivability is the tree calculus: G.Derives c w for a multimodal grammar iff some intrinsically typed derivation over its lexicon has yield w.