Trees #
Unified tree type parameterized by node labels (C) and terminal content (W).
Tree C W — The Y-Model Tree #
N-ary branching with categories on every node. Supports both:
- Compositional interpretation (LF):
interp/evalTreeinComposition/Tree.lean— type-driven, ignores categories - Structural operations (PF): @cite{katzir-2007}
StructOp(substitution, deletion, contraction) inAlternatives/Structural.lean— category-aware
Parameterized by category type C (UD tags, CCG categories, feature
bundles, Unit for unlabeled, ...) and terminal type W.
Instantiations #
Tree Unit String— category-free, for H&K composition. Use convenience constructors.leaf,.bin,.un,.tr,.binder.Tree Cat String— UD-grounded categories, for Katzir structural alternatives.Tree Unit LIToken— bare phrase structure, for Minimalist syntax (categories insideLIToken, not on nodes).
Cat — Default Category System #
Grounded in Universal Dependencies UPOS. Word-level categories via
head : UPOS → Cat, phrasal via proj : UPOS → Cat, plus S and CP.
Default syntactic category system grounded in Universal Dependencies UPOS (@cite{de-marneffe-zeman-2021}).
head pos— word-level (terminal): wraps a UPOS tag directlyproj pos— maximal X-bar projection of a UPOS headS— sentence/clause (not a projection of a single lexical head)CP— complementizer phrase
Phrasal categories are derived systematically: NP = proj .NOUN,
VP = proj .VERB, DP = proj .DET, ConjP = proj .CCONJ, etc.
This is one possible instantiation of Tree's C parameter.
Framework-specific category systems (CCG functors, Minimalist
feature bundles, etc.) can be used instead.
Instances For
Equations
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.head a) (Core.Tree.Cat.head b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.head a) (Core.Tree.Cat.proj a_1) = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.head a) Core.Tree.Cat.S = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.head a) Core.Tree.Cat.CP = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.proj a) (Core.Tree.Cat.head a_1) = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.proj a) (Core.Tree.Cat.proj b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.proj a) Core.Tree.Cat.S = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq (Core.Tree.Cat.proj a) Core.Tree.Cat.CP = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.S (Core.Tree.Cat.head a) = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.S (Core.Tree.Cat.proj a) = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.S Core.Tree.Cat.S = isTrue ⋯
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.S Core.Tree.Cat.CP = isFalse Core.Tree.instDecidableEqCat.decEq._proof_13
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.CP (Core.Tree.Cat.head a) = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.CP (Core.Tree.Cat.proj a) = isFalse ⋯
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.CP Core.Tree.Cat.S = isFalse Core.Tree.instDecidableEqCat.decEq._proof_16
- Core.Tree.instDecidableEqCat.decEq Core.Tree.Cat.CP Core.Tree.Cat.CP = isTrue ⋯
Instances For
Equations
- Core.Tree.instReprCat = { reprPrec := Core.Tree.instReprCat.repr }
Equations
- One or more equations did not get rendered due to their size.
- Core.Tree.instReprCat.repr Core.Tree.Cat.S prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Core.Tree.Cat.S")).group prec✝
- Core.Tree.instReprCat.repr Core.Tree.Cat.CP prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Core.Tree.Cat.CP")).group prec✝
Instances For
Equations
- Core.Tree.instInhabitedCat = { default := Core.Tree.Cat.S }
Equations
- Core.Tree.instBEqCat = { beq := fun (a b : Core.Tree.Cat) => decide (a = b) }
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Instances For
Equations
Instances For
Framework-neutral tree, parameterized by node label type C
and terminal word type W.
terminal c w— leaf carrying categorycand wordwnode c cs— internal node with categorycand childrencstrace n c— movement trace with indexnand categorycbind n c body— λ-abstraction with indexn, categoryc, scopebody
The node constructor takes a List of children, subsuming both
binary branching (for Heim & Kratzer composition) and n-ary structure
(for Katzir's deletion operation). Binary nodes are node c [l, r].
trace and bind support Quantifier Raising and variable binding.
Frameworks without movement (CCG, HPSG) simply never construct these.
For category-free trees (C = Unit), use the convenience constructors
leaf, bin, un, tr, binder which hide the Unit parameter.
- terminal {C W : Type} : C → W → Tree C W
- node {C W : Type} : C → List (Tree C W) → Tree C W
- trace {C W : Type} : Nat → C → Tree C W
- bind {C W : Type} : Nat → C → Tree C W → Tree C W
Instances For
Equations
- Core.Tree.instReprTree = { reprPrec := Core.Tree.instReprTree.repr }
Equations
Instances For
Equations
Instances For
Equations
- Core.Tree.Tree.binder n body = Core.Tree.Tree.bind n () body
Instances For
Category label of the root node. Total: every constructor carries
a category (including bind, where it labels the result of PA).
Equations
- (Core.Tree.Tree.terminal a a_1).cat = a
- (Core.Tree.Tree.node a a_1).cat = a
- (Core.Tree.Tree.trace a a_1).cat = a_1
- (Core.Tree.Tree.bind a a_1 a_2).cat = a_1
Instances For
Structural equality for trees (mutual recursion through List).
Equations
- (Core.Tree.Tree.terminal c₁ w₁).beq (Core.Tree.Tree.terminal c₂ w₂) = (c₁ == c₂ && w₁ == w₂)
- (Core.Tree.Tree.node c₁ cs₁).beq (Core.Tree.Tree.node c₂ cs₂) = (c₁ == c₂ && Core.Tree.Tree.beq.beqList cs₁ cs₂)
- (Core.Tree.Tree.trace n₁ c₁).beq (Core.Tree.Tree.trace n₂ c₂) = (n₁ == n₂ && c₁ == c₂)
- (Core.Tree.Tree.bind n₁ c₁ b₁).beq (Core.Tree.Tree.bind n₂ c₂ b₂) = (n₁ == n₂ && c₁ == c₂ && b₁.beq b₂)
- x✝¹.beq x✝ = false
Instances For
Equations
- Core.Tree.Tree.beq.beqList [] [] = true
- Core.Tree.Tree.beq.beqList (a :: as) (b :: bs) = (a.beq b && Core.Tree.Tree.beq.beqList as bs)
- Core.Tree.Tree.beq.beqList x✝¹ x✝ = false
Instances For
Equations
- Core.Tree.Tree.instBEq = { beq := Core.Tree.Tree.beq }
Number of nodes in the tree.
Equations
- (Core.Tree.Tree.terminal a a_1).size = 1
- (Core.Tree.Tree.node a a_1).size = 1 + Core.Tree.Tree.size.sizeList a_1
- (Core.Tree.Tree.trace a a_1).size = 1
- (Core.Tree.Tree.bind a a_1 a_2).size = 1 + a_2.size
Instances For
Equations
Instances For
All subtrees including self (pre-order traversal).
Equations
- (Core.Tree.Tree.terminal a a_1).subtrees = [Core.Tree.Tree.terminal a a_1]
- (Core.Tree.Tree.node a cs).subtrees = Core.Tree.Tree.node a cs :: Core.Tree.Tree.subtrees.subtreesList cs
- (Core.Tree.Tree.trace a a_1).subtrees = [Core.Tree.Tree.trace a a_1]
- (Core.Tree.Tree.bind a a_1 body).subtrees = Core.Tree.Tree.bind a a_1 body :: body.subtrees
Instances For
Equations
Instances For
Whether a category appears anywhere in the tree.
Equations
- Core.Tree.Tree.containsCat target (Core.Tree.Tree.terminal a a_1) = (target == a)
- Core.Tree.Tree.containsCat target (Core.Tree.Tree.node a a_1) = (target == a || Core.Tree.Tree.containsCat.containsCatList target a_1)
- Core.Tree.Tree.containsCat target (Core.Tree.Tree.trace a a_1) = (target == a_1)
- Core.Tree.Tree.containsCat target (Core.Tree.Tree.bind a a_1 a_2) = (target == a_1 || Core.Tree.Tree.containsCat target a_2)
Instances For
Equations
- Core.Tree.Tree.containsCat.containsCatList target [] = false
- Core.Tree.Tree.containsCat.containsCatList target (t :: ts) = (Core.Tree.Tree.containsCat target t || Core.Tree.Tree.containsCat.containsCatList target ts)
Instances For
Substitute all terminals of category c carrying word target
with replacement. This is the most common structural operation:
replacing one scalar item with another of the same category.
Equations
- Core.Tree.Tree.leafSubst target replacement c (Core.Tree.Tree.terminal a a_1) = if (c == a && a_1 == target) = true then Core.Tree.Tree.terminal a replacement else Core.Tree.Tree.terminal a a_1
- Core.Tree.Tree.leafSubst target replacement c (Core.Tree.Tree.node a a_1) = Core.Tree.Tree.node a (Core.Tree.Tree.leafSubst.leafSubstList target replacement c a_1)
- Core.Tree.Tree.leafSubst target replacement c (Core.Tree.Tree.trace a a_1) = Core.Tree.Tree.trace a a_1
- Core.Tree.Tree.leafSubst target replacement c (Core.Tree.Tree.bind a a_1 a_2) = Core.Tree.Tree.bind a a_1 (Core.Tree.Tree.leafSubst target replacement c a_2)
Instances For
Equations
- Core.Tree.Tree.leafSubst.leafSubstList target replacement c [] = []
- Core.Tree.Tree.leafSubst.leafSubstList target replacement c (t :: ts) = Core.Tree.Tree.leafSubst target replacement c t :: Core.Tree.Tree.leafSubst.leafSubstList target replacement c ts