Subterm enumeration and containment for syntactic objects #
[MCB25] §1.1–1.2. The containment / subterm theory of the
SyntacticObject carrier, mirroring the legacy Basic.lean theory on
FreeCommMagma (LIToken ⊕ Nat). Imports only the carrier skeleton (no Merge algebra).
Contents #
SyntacticObject.immediatelyContains— membership in the root children (viaNonplanar.rootChildren).SyntacticObject.subtrees/SyntacticObject.Acc— subterm enumeration (incl. root) and MCB's accessible termsAcc(T)(Def 1.2.2, root excluded).SyntacticObject.contains/isTermOf/containsOrEq— dominance and its reflexive/term-of variants.- subtree ↔ containment bridges, and tree-relative c-command (
cCommandsIn).
Immediate containment (via Nonplanar.rootChildren) #
x immediately contains y: y is one of x's root daughters
([MCB25] §1.1; Definition 13 of the legacy theory).
Equations
- x.immediatelyContains y = (↑y ∈ (↑x).rootChildren)
Instances For
Subterm enumeration #
Nonplanar.rootChildren is single-level, so deep enumeration is built fresh at the
planar level and lifted. The result is a multiset of nonplanar subtrees; its
Perm-invariance lets it descend to the quotient.
All subtrees of a planar tree (incl. the root), as nonplanar trees.
Equations
- Minimalist.subtreesNPlanar (RoseTree.node a cs) = RoseTree.Nonplanar.mk (RoseTree.node a cs) ::ₘ Minimalist.subtreesNPlanarList cs
Instances For
Auxiliary: union of subtree-multisets across a child list.
Equations
Instances For
subtreesNPlanar is Perm-invariant, so it descends to Nonplanar. At a node the
root mk-image is fixed by mk_eq_mk_iff and the child-list sum by the PermList
companion.
The child-list subtree sum is PermList-invariant: it is a multiset sum, and the
List.Perm-style case split matches heads by the mutual subtreesNPlanar_perm and
reorders by add_left_comm.
All subtrees of a nonplanar tree (incl. the root).
Instances For
subtreesN on a bare binary node: the node plus the subtrees of each child.
Membership in subtreesN of a leaf.
Membership in subtreesN of a bare binary node.
Every nonplanar tree is among its own subtrees.
Subtrees of a syntactic object are themselves syntactic objects.
All subtrees of a syntactic object (incl. the root), as syntactic objects
([MCB25] §1.2; the legacy SyntacticObject.subtrees).
Equations
- s.subtrees = Multiset.pmap (fun (m : RoseTree.Nonplanar Minimalist.SOLabel) (h : Minimalist.IsSO m) => ⟨m, h⟩) (Minimalist.subtreesN ↑s) ⋯
Instances For
The root is among its own subtrees.
Subtree membership at a bare binary node: the node itself, or a subtree of a daughter.
subtrees is downward-closed along the subtree relation: every subtree of a
subtree of s is a subtree of s.
Cardinality (MCB's vertex/accessible-term counts, Def 1.2.2 eq. 1.2.5) #
subtreesN has one element per vertex: its cardinality is the node count.
Auxiliary list version.
subtrees enumerates the vertices ([MCB25] Def 1.2.2:
subtrees = Acc'(T), so its size is #V(T), the MCB workspace-size primitive).
Accessible terms Acc(T) (Def 1.2.2) #
MCB counting identity (eq. 1.2.5, one-component case): #Acc(T) = #V(T) − 1.
Containment / dominance #
Weight of a bare binary node is one more than the sum of its daughters'.
Containment (dominance) is the transitive closure of immediate containment
([MCB25] §1.1; the legacy contains).
- imm (x y : SyntacticObject) : x.immediatelyContains y → x.contains y
- trans (x y z : SyntacticObject) : x.immediatelyContains z → z.contains y → x.contains y
Instances For
Immediate containment strictly decreases weight.
Containment strictly decreases weight; hence it is irreflexive.
Subtree ↔ containment bridge #
A subtree of x is either x itself or properly contained in x.
Containment ↔ proper subtree membership. Gives a decision procedure for
contains without well-founded recursion: y is properly contained in x iff
it is a subtree distinct from x.
Equations
- x.instDecidableContains y = decidable_of_iff (y ∈ x.subtrees ∧ y ≠ x) ⋯
Term-of and reflexive containment #
x is a term of y: x = y or y contains x.
Instances For
Equations
x and y are sisters in root: distinct co-daughters of some subtree.
Equations
- root.areSistersIn x y = ∃ z ∈ root.subtrees, z.immediatelyContains x ∧ z.immediatelyContains y ∧ x ≠ y
Instances For
Equations
- root.instDecidableAreSistersIn x y = Multiset.decidableExistsMultiset
x c-commands y in root: x has a sister (in root) that
contains-or-equals y.
Equations
- root.cCommandsIn x y = ∃ z ∈ root.subtrees, root.areSistersIn x z ∧ z.containsOrEq y
Instances For
Equations
- root.instDecidableCCommandsIn x y = Multiset.decidableExistsMultiset
x asymmetrically c-commands y in root.
Equations
- root.asymCCommandsIn x y = (root.cCommandsIn x y ∧ ¬root.cCommandsIn y x)
Instances For
Equations
decide demonstrations #
The containment / c-command decision procedures reduce on concrete trees built
via Nonplanar.mk ∘ RoseTree.node (not the noncomputable SyntacticObject.node), confirming the
"state result trees directly" discipline carries through to the relational layer.