Documentation

Linglib.Syntax.CCG.Basic

Combinatory Categorial Grammar (CCG) #

A lexicalized grammar in which categories encode argument structure and a small fixed set of combinatory rules (>, <, B, T, S) derive phrases ([Ste00a]).

Main definitions #

Notation #

/ and \ build directional slash categories. Because / overloads Lean's division, categories are written fully parenthesized ((S \ NP) / NP) rather than relying on the Steedman left-to-right reading.

inductive CCG.Atom :

Atomic categories.

Instances For
    @[implicit_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
      @[implicit_reducible]
      instance CCG.instDecidableEqAtom :
      DecidableEq Atom
      Equations
      inductive CCG.Cat :

      CCG categories.

      Instances For
        def CCG.instReprCat.repr :
        CatStd.Format
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[implicit_reducible]
          instance CCG.instReprCat :
          Repr Cat
          Equations
          def CCG.instDecidableEqCat.decEq (x✝ x✝¹ : Cat) :
          Decidable (x✝ = x✝¹)
          Equations
          Instances For
            @[implicit_reducible]
            instance CCG.instDecidableEqCat :
            DecidableEq Cat
            Equations
            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.S :
                Equations
                Instances For
                  def CCG.NP :
                  Equations
                  Instances For
                    def CCG.N :
                    Equations
                    Instances For
                      def CCG.PP :
                      Equations
                      Instances For
                        def CCG.IV :
                        Equations
                        Instances For
                          def CCG.TV :
                          Equations
                          Instances For
                            Equations
                            Instances For
                              Equations
                              Instances For
                                Equations
                                Instances For
                                  Equations
                                  Instances For
                                    def CCG.forwardApp :
                                    CatCatOption Cat

                                    Forward application: X/Y Y => X.

                                    Equations
                                    Instances For
                                      def CCG.backwardApp :
                                      CatCatOption Cat

                                      Backward application: Y X\Y => X.

                                      Equations
                                      Instances For
                                        def CCG.forwardComp :
                                        CatCatOption Cat

                                        Forward composition: X/Y Y/Z => X/Z.

                                        Equations
                                        Instances For
                                          def CCG.backwardComp :
                                          CatCatOption Cat

                                          Backward composition: Y\Z X\Y => X\Z.

                                          Equations
                                          Instances For
                                            def CCG.forwardCompX :
                                            CatCatOption Cat

                                            Forward crossed composition (>B×): X/Y Y\Z => X\Z.

                                            In [Ste00a] this rule is language-specific and restricted (for Dutch, to Y = VP₋SUB; ch. 6 appendix) — unrestricted crossed composition licenses scrambling. The toy Cat carries no features, so the rule is stated unrestricted here; the rule-restricted variant lives in CCG.Classical.fcompX1.

                                            Equations
                                            Instances For
                                              def CCG.combine :
                                              CatCatOption Cat

                                              Try to combine two categories using all available rules.

                                              Equations
                                              Instances For

                                                Forward type-raising: X => T/(T\X).

                                                Equations
                                                Instances For

                                                  Backward type-raising: X => T(T/X).

                                                  Equations
                                                  Instances For
                                                    def CCG.coordinate :
                                                    CatCatOption Cat

                                                    Coordination: X conj X => X.

                                                    Equations
                                                    • CCG.coordinate x✝¹ x✝ = if (x✝¹ == x✝) = true then some x✝¹ else none
                                                    Instances For
                                                      structure CCG.LexEntry :

                                                      A CCG lexical entry.

                                                      • form : String
                                                      • cat : Cat
                                                      Instances For
                                                        def CCG.instReprLexEntry.repr :
                                                        LexEntryStd.Format
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          @[implicit_reducible]
                                                          Equations

                                                          A CCG lexicon.

                                                          Equations
                                                          Instances For
                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              inductive CCG.DerivStep :

                                                              A derivation step.

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

                                                                  Get the category of a derivation.

                                                                  Equations
                                                                  Instances For
                                                                    def CCG.DerivStep.yield :
                                                                    DerivStepList String

                                                                    The surface string a derivation spells out: its leaf forms, left to right.

                                                                    Combinatory rules concatenate their daughters and type-raising leaves the string untouched, so the yield is independent of the derivation's combinatory structure — the property that lets a CCG derivation witness a string language. (Coordination elides the conjunction's surface form in the yield; DerivStep.coord carries the coordinator's role, not its spelled-out word.)

                                                                    Equations
                                                                    Instances For
                                                                      Equations
                                                                      Instances For
                                                                        Equations
                                                                        Instances For
                                                                          Equations
                                                                          Instances For
                                                                            Equations
                                                                            Instances For
                                                                              Equations
                                                                              Instances For
                                                                                Equations
                                                                                Instances For
                                                                                  def CCG.derivesS (d : DerivStep) :
                                                                                  Bool

                                                                                  Check if a derivation yields category S.

                                                                                  Equations
                                                                                  Instances For

                                                                                    Count combinatory operations in a derivation.

                                                                                    Equations
                                                                                    Instances For

                                                                                      Depth of derivation tree.

                                                                                      Equations
                                                                                      Instances For
                                                                                        Equations
                                                                                        Instances For
                                                                                          Equations
                                                                                          Instances For
                                                                                            Equations
                                                                                            Instances For
                                                                                              Equations
                                                                                              Instances For