Documentation

Linglib.Syntax.DependencyGrammar.Basic

Dependency grammar substrate #

Core data types for dependency grammar: words connected by typed directed edges (Dependency), trees built over them (DepTree), and enhanced graphs allowing multiple incoming arcs (DepGraph). Argument structures (ArgStr) record direction and selectional category for each slot.

Dependency relations use UD.DepRel from Core/UD.lean (Universal Dependencies v2). [Hud10], [Gib25].

Main declarations #

Implementation notes #

inductive DepGrammar.Dir :

Direction of a dependent relative to head.

Instances For
    def DepGrammar.instReprDir.repr :
    DirStd.Format
    Equations
    Instances For
      @[implicit_reducible]
      Equations
      @[implicit_reducible]
      instance DepGrammar.instDecidableEqDir :
      DecidableEq Dir
      Equations
      @[implicit_reducible]
      instance DepGrammar.instInhabitedDir :
      Inhabited Dir
      Equations

      A single argument slot in an argument structure.

      Instances For
        def DepGrammar.instReprArgSlot.repr :
        ArgSlotStd.Format
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[implicit_reducible]
          Equations
          def DepGrammar.instDecidableEqArgSlot.decEq (x✝ x✝¹ : ArgSlot) :
          Decidable (x✝ = x✝¹)
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Argument structure: what dependents a word requires/allows.

            Instances For
              @[implicit_reducible]
              Equations
              def DepGrammar.instReprArgStr.repr :
              ArgStrStd.Format
              Equations
              • DepGrammar.instReprArgStr.repr x✝ prec✝ = Std.Format.bracket "{ " (Std.Format.nil ++ Std.Format.text "slots" ++ Std.Format.text " := " ++ (Std.Format.nest 9 (repr x✝.slots)).group) " }"
              Instances For
                def DepGrammar.instDecidableEqArgStr.decEq (x✝ x✝¹ : ArgStr) :
                Decidable (x✝ = x✝¹)
                Equations
                Instances For

                  Dependencies and trees #

                  A dependency: directed edge from head to dependent. Uses UD.DepRel for the relation label.

                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def DepGrammar.instDecidableEqDependency.decEq (x✝ x✝¹ : Dependency) :
                      Decidable (x✝ = x✝¹)
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        A dependency tree for a sentence. frames carries the DG-specific lexical argument-structure premises, aligned with words (missing/short = no frame): the frame is framework apparatus (like HPSG's ARG-ST), so it lives on DG's tree, not on the shared Word token. Frames come from the lexical carrier at tree construction (complementToArgStr applied to a verb's complementType).

                        Instances For
                          @[implicit_reducible]
                          Equations
                          def DepGrammar.instReprDepTree.repr :
                          DepTreeStd.Format
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def DepGrammar.DepTree.frame (t : DepTree) (i : ) :
                            Option ArgStr

                            The argument-structure frame at position i, if one was supplied.

                            Equations
                            Instances For

                              An enhanced dependency graph: like DepTree but allows multiple heads per word. Relaxes the unique-heads constraint.

                              Instances For
                                def DepGrammar.instReprDepGraph.repr :
                                DepGraphStd.Format
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Every DepTree is trivially a DepGraph.

                                  Equations
                                  Instances For

                                    Intransitive verb: subject to the left

                                    Equations
                                    Instances For

                                      Transitive verb: subject left, object right

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

                                        Ditransitive verb: subject left, indirect object right, object right

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

                                          Passive transitive: subject left (was patient), optional by-phrase right

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

                                            Map a complement type to the corresponding standard DG argument structure. Returns none for frames without a standard schema: clause-embedding types take xcomp/ccomp, not obj, and .np_pp has no fixture here.

                                            Equations
                                            Instances For

                                              Check if every word except root has exactly one head.

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

                                                Check for cycles: no word is its own ancestor.

                                                Equations
                                                Instances For
                                                  def DepGrammar.isAcyclic.follow (t : DepTree) (current : ) (visited : List ) (fuel : ) :
                                                  Bool
                                                  Equations
                                                  Instances For

                                                    Bundled well-formedness: unique heads + valid index bounds. Collects the three hypotheses that most dominance/planarity theorems need.

                                                    Instances For

                                                      Check subject-verb number agreement.

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

                                                        Check determiner-noun number agreement.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          def DepGrammar.satisfiesArgStr (t : DepTree) (headIdx : ) (argStr : ArgStr) :
                                                          Bool

                                                          Check if a dependency tree satisfies an argument structure

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

                                                            Core argument relations governed by lexical frames.

                                                            Equations
                                                            Instances For
                                                              def DepGrammar.coreArgsLicensed (t : DepTree) (headIdx : ) (argStr : ArgStr) :
                                                              Bool

                                                              Every core-argument dependent of headIdx is licensed by a slot of argStr — the closed-world half of frame checking (satisfiesArgStr only checks that required slots are filled).

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

                                                                Check each verb's dependents against its lexical frame: required slots filled in the right direction (satisfiesArgStr) and no unlicensed core arguments (coreArgsLicensed). Verbs without a frame are skipped.

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  def DepGrammar.mkSVTree (subj verb : Word) (frame : Option ArgStr := none) :

                                                                  Create a simple SV tree: subject -> verb.

                                                                  Equations
                                                                  Instances For
                                                                    def DepGrammar.mkSVOTree (subj verb obj : Word) (frame : Option ArgStr := none) :

                                                                    Create a simple SVO tree: subject -> verb <- object.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      def DepGrammar.mkDetNVTree (det noun verb : Word) (frame : Option ArgStr := none) :

                                                                      Create Det-N-V tree: det -> noun -> verb.

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        def DepGrammar.mkDitransTree (subj verb iobj obj : Word) (frame : Option ArgStr := none) :

                                                                        Create a ditransitive tree: subj -> verb <- iobj <- obj.

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