Documentation

Linglib.Syntax.CCG.Cat

CCG categories #

This file defines the categories of Combinatory Categorial Grammar in their modern form ([Ste19]): atoms plus directional slashes, each slash carrying a Baldridge modality ([Bal02]) — the shared substrate of the rule theory (Syntax/CCG/Derivation) and the capacity theory (Syntax/CCG/Grammar).

Categories are stated over an arbitrary type α of atomic categories, so a grammar needing featured atoms (agreement, case) can instantiate a richer inventory than the featureless core CCG.Atom. Each slash carries a Modality from the Baldridge hierarchy — dot (unrestricted), diamond (order-preserving), cross (permuting), star (application-only) — ordered by restrictiveness: a rule class indexed m applies to a functor whose slash has modality s iff s ≤ m. The lexicon controls combinatory potential through the modalities it assigns, the modern replacement for per-grammar rule restrictions (compare CCG.Grammar).

Main definitions #

Notation #

All are scoped to the CCG namespace. Because / overloads Lean's division, categories are written fully parenthesized ((S \ NP) / NP) rather than relying on the Steedman left-to-right reading.

Slash modalities #

inductive CCG.Modality :

The modality a slash carries, determining which rule classes it licenses. The order is reverse inclusion of licenses — s ≤ m iff s licenses every rule class m does — so composition gates on s ≤ diamond (harmonic) and s ≤ cross (crossing), while application is licensed by every modality (s ≤ ⊤).

  • dot : Modality

    Unrestricted (written as an unannotated slash): combines by any rule.

  • diamond : Modality

    Order-preserving : licenses application and harmonic composition.

  • cross : Modality

    Permuting ×: licenses application and crossing composition.

  • star : Modality

    : licenses application only.

Instances For
    @[instance_reducible]
    Equations
    def CCG.instReprModality.repr :
    ModalityStd.Format
    Equations
    Instances For
      @[instance_reducible]
      Equations
      @[instance_reducible]
      Equations
      @[instance_reducible]
      Equations
      @[instance_reducible]
      Equations
      @[instance_reducible]
      Equations
      • One or more equations did not get rendered due to their size.

      Categories #

      inductive CCG.Atom :

      The core atomic categories of the English fragment (S, NP, N, PP, as in [Ste00a]), stated without features.

      • S : Atom

        Sentence.

      • NP : Atom

        Noun phrase.

      • N : Atom

        Common noun.

      • PP : Atom

        Prepositional phrase.

      Instances For
        @[instance_reducible]
        instance CCG.instReprAtom :
        Repr Atom
        Equations
        def CCG.instReprAtom.repr :
        AtomStd.Format
        Equations
        • CCG.instReprAtom.repr CCG.Atom.S prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ 1024 then 1 else 2) (Std.Format.text "CCG.Atom.S")).group prec✝
        • CCG.instReprAtom.repr CCG.Atom.NP prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ 1024 then 1 else 2) (Std.Format.text "CCG.Atom.NP")).group prec✝
        • CCG.instReprAtom.repr CCG.Atom.N prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ 1024 then 1 else 2) (Std.Format.text "CCG.Atom.N")).group prec✝
        • CCG.instReprAtom.repr CCG.Atom.PP prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ 1024 then 1 else 2) (Std.Format.text "CCG.Atom.PP")).group prec✝
        Instances For
          @[instance_reducible]
          instance CCG.instDecidableEqAtom :
          DecidableEq Atom
          Equations
          inductive CCG.Cat (α : Type u_1) :
          Type u_1

          CCG categories over a type α of atomic categories: atoms plus directional slashes, each carrying a Modality.

          • atom {α : Type u_1} : αCat α

            An atomic category.

          • rslash {α : Type u_1} : Cat αModalityCat αCat α

            X/ₘY: looking right for a Y to give an X, at modality m.

          • lslash {α : Type u_1} : Cat αModalityCat αCat α

            X\ₘY: looking left for a Y to give an X, at modality m.

          Instances For
            def CCG.instReprCat.repr {α✝ : Type u_1} [Repr α✝] :
            Cat α✝Std.Format
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[instance_reducible]
              instance CCG.instReprCat {α✝ : Type u_1} [Repr α✝] :
              Repr (Cat α✝)
              Equations
              @[instance_reducible]
              instance CCG.instDecidableEqCat {α✝ : Type u_1} [DecidableEq α✝] :
              DecidableEq (Cat α✝)
              Equations
              def CCG.instDecidableEqCat.decEq {α✝ : Type u_1} [DecidableEq α✝] (x✝ x✝¹ : Cat α✝) :
              Decidable (x✝ = x✝¹)
              Equations
              Instances For
                def CCG.«term_/_» :
                Lean.TrailingParserDescr
                Equations
                • CCG.«term_/_» = Lean.ParserDescr.trailingNode `CCG.«term_/_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "/") (Lean.ParserDescr.cat `term 0))
                Instances For
                  def CCG.«term_\_» :
                  Lean.TrailingParserDescr
                  Equations
                  • CCG.«term_\_» = Lean.ParserDescr.trailingNode `CCG.«term_\_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "\\") (Lean.ParserDescr.cat `term 0))
                  Instances For
                    def CCG.«term_/⋄_» :
                    Lean.TrailingParserDescr
                    Equations
                    • CCG.«term_/⋄_» = Lean.ParserDescr.trailingNode `CCG.«term_/⋄_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "/⋄") (Lean.ParserDescr.cat `term 0))
                    Instances For
                      def CCG.«term_\⋄_» :
                      Lean.TrailingParserDescr
                      Equations
                      • CCG.«term_\⋄_» = Lean.ParserDescr.trailingNode `CCG.«term_\⋄_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "\\⋄") (Lean.ParserDescr.cat `term 0))
                      Instances For
                        def CCG.«term_/×_» :
                        Lean.TrailingParserDescr
                        Equations
                        • CCG.«term_/×_» = Lean.ParserDescr.trailingNode `CCG.«term_/×_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "/×") (Lean.ParserDescr.cat `term 0))
                        Instances For
                          def CCG.«term_\×_» :
                          Lean.TrailingParserDescr
                          Equations
                          • CCG.«term_\×_» = Lean.ParserDescr.trailingNode `CCG.«term_\×_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "\\×") (Lean.ParserDescr.cat `term 0))
                          Instances For
                            def CCG.«term_/⋆_» :
                            Lean.TrailingParserDescr
                            Equations
                            • CCG.«term_/⋆_» = Lean.ParserDescr.trailingNode `CCG.«term_/⋆_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "/⋆") (Lean.ParserDescr.cat `term 0))
                            Instances For
                              def CCG.«term_\⋆_» :
                              Lean.TrailingParserDescr
                              Equations
                              • CCG.«term_\⋆_» = Lean.ParserDescr.trailingNode `CCG.«term_\⋆_» 60 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "\\⋆") (Lean.ParserDescr.cat `term 0))
                              Instances For
                                Equations
                                Instances For
                                  Equations
                                  Instances For
                                    Equations
                                    Instances For
                                      Equations
                                      Instances For

                                        The generalized composition schema #

                                        def CCG.Cat.generalizedForwardComp {α : Type u_1} [DecidableEq α] :
                                        Cat αCat αOption (Cat α)

                                        generalizedForwardComp n f g is forward composition of degree n (>Bⁿ): when f = X/Y and g = Y|Z₁…|Zₙ, the result is X|Z₁…|Zₙ with each argument keeping its own slash direction and modality, and none otherwise. Modality-blind — the schema of the grammars in Syntax/CCG/Grammar, where rule control is per-grammar rather than lexical.

                                        Equations
                                        Instances For
                                          def CCG.Cat.generalizedBackwardComp {α : Type u_1} [DecidableEq α] :
                                          Cat αCat αOption (Cat α)

                                          generalizedBackwardComp n g f is backward composition of degree n (<Bⁿ), the mirror of generalizedForwardComp: when g = Y|Z₁…|Zₙ and f = X\Y, the result is X|Z₁…|Zₙ, and none otherwise.

                                          Equations
                                          Instances For
                                            @[simp]
                                            theorem CCG.Cat.generalizedForwardComp_atom {α : Type u_1} [DecidableEq α] (n : ) (x : α) (b : Cat α) :

                                            The schema requires an atomic primary to fail: an atom has no argument to cancel.

                                            @[simp]
                                            theorem CCG.Cat.generalizedForwardComp_lslash {α : Type u_1} [DecidableEq α] (n : ) (x y : Cat α) (m : Modality) (b : Cat α) :
                                            generalizedForwardComp n (x.lslash m y) b = none

                                            A leftward primary fails forward composition at every degree.

                                            @[simp]
                                            theorem CCG.Cat.generalizedBackwardComp_atom {α : Type u_1} [DecidableEq α] (n : ) (a : Cat α) (x : α) :

                                            The mirror of generalizedForwardComp_atom.

                                            @[simp]
                                            theorem CCG.Cat.generalizedBackwardComp_rslash {α : Type u_1} [DecidableEq α] (n : ) (a x y : Cat α) (m : Modality) :
                                            generalizedBackwardComp n a (x.rslash m y) = none

                                            A rightward primary fails backward composition at every degree.

                                            @[simp]
                                            theorem CCG.Cat.generalizedForwardComp_succ_atom {α : Type u_1} [DecidableEq α] (n : ) (f : Cat α) (x : α) :
                                            generalizedForwardComp (n + 1) f (atom x) = none

                                            An atomic secondary offers no argument spine to peel.

                                            @[simp]
                                            theorem CCG.Cat.generalizedBackwardComp_succ_atom {α : Type u_1} [DecidableEq α] (n : ) (x : α) (b : Cat α) :
                                            generalizedBackwardComp (n + 1) (atom x) b = none

                                            The mirror of generalizedForwardComp_succ_atom.

                                            Type-raising #

                                            Type-raising is morpholexical in [Ste19] — the work of case morphemes rather than a syntactic rule — so these build the categories raised lexical entries carry; there is no corresponding Derivation constructor.

                                            def CCG.Cat.forwardTypeRaise {α : Type u_1} (x t : Cat α) :
                                            Cat α

                                            forwardTypeRaise x t is t / (t \ x) — the forward-raised (>T) category of x at target t.

                                            Equations
                                            Instances For
                                              def CCG.Cat.backwardTypeRaise {α : Type u_1} (x t : Cat α) :
                                              Cat α

                                              backwardTypeRaise x t is t \ (t / x) — the backward-raised (<T) category of x at target t.

                                              Equations
                                              Instances For

                                                Targets #

                                                Each category has a target — its leftmost atom, "similar to the return type of a function" ([Ste19]) — the locus of the per-grammar rule restrictions of Syntax/CCG/Grammar.

                                                def CCG.Cat.target {α : Type u_1} :
                                                Cat αα

                                                The target of a category: its leftmost atom, after stripping all arguments.

                                                Equations
                                                Instances For
                                                  @[simp]
                                                  theorem CCG.Cat.target_atom {α : Type u_1} (a : α) :
                                                  (atom a).target = a
                                                  @[simp]
                                                  theorem CCG.Cat.target_rslash {α : Type u_1} (x y : Cat α) (m : Modality) :
                                                  (x.rslash m y).target = x.target
                                                  @[simp]
                                                  theorem CCG.Cat.target_lslash {α : Type u_1} (x y : Cat α) (m : Modality) :
                                                  (x.lslash m y).target = x.target