Subtrees and contractions of plane Hepp trees #
This file provides the structural API used by the collapse induction in
paper §5.4.1. Positions in a PlaneTree are paths from the root, so the
subtree at a valid position is obtained by following that path. Contracting
at a position replaces the whole rooted subtree there by one leaf.
The API is deliberately independent of markings, multiplicities, and embeddings. Those data are transported in the later collapse layers.
The rooted subtree at a position #
The subtree rooted at p. At an invalid position this returns the bare
leaf; all mathematical uses supply IsPos t p, under which the fallback is
unreachable.
Equations
Instances For
Child counts are unchanged when a vertex is viewed inside a rooted subtree.
Vertex, leaf, and branch transport #
Vertices of the rooted subtree are exactly descendants of its root in the original tree.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Child count is preserved by the subtree vertex inclusion.
Leaves of t below r, represented as descendant vertices.
Equations
Instances For
Branch vertices of t below r, represented as descendant vertices.
Equations
Instances For
Leaves of the rooted subtree are exactly descendant leaves.
Equations
Instances For
Branch vertices of the rooted subtree are exactly descendant branch vertices.
Equations
Instances For
Descendant leaves are the same carrier as membership in leavesUnder.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Paper-facing leaf equivalence: the leaves of the actual rooted subtree
are precisely the original leaves in leavesUnder r.
Equations
Instances For
The recursive leaf count of the actual rooted subtree is the cardinality
of the previously used prefix-defined leavesUnder finset.
Contracting a rooted subtree #
Replace the rooted subtree at p by a single leaf. At an invalid step
the tree is left unchanged; all structural theorems below assume
IsPos t p.
Equations
- x✝.contractAt [] = Anderson4D.PlaneTree.leaf
- (Anderson4D.PlaneTree.node cs).contractAt (i :: p) = if h : i < cs.length then Anderson4D.PlaneTree.node (cs.set i (cs[i].contractAt p)) else Anderson4D.PlaneTree.node cs
Instances For
q lies strictly below p when it properly extends p.
Equations
- Anderson4D.PlaneTree.IsStrictDescendant p q = (p <+: q ∧ p ≠ q)
Instances For
Contracting at p removes exactly the vertices strictly below p.
The position p itself remains as the replacement leaf.
Vertices retained by contraction: all original vertices except those strictly below the contraction position.
Equations
- t.RetainedVertices p = { v : t.VPos // ¬Anderson4D.PlaneTree.IsStrictDescendant p ↑v }
Instances For
Include a vertex of the contracted tree into the original tree. Its position path is unchanged.
Equations
- Anderson4D.PlaneTree.contractVertex hp v = ⟨↑v, ⋯⟩
Instances For
Vertices of the contracted tree are exactly the retained vertices of the original tree.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The contraction position remains a valid position in the contracted tree.
The vertex replacing the contracted subtree.
Equations
- t.contractMarker p hp = ⟨p, ⋯⟩
Instances For
The replacement vertex is a leaf.
Away from the replacement vertex, contraction preserves child counts at every retained vertex.
Original branch vertices surviving contraction. The root of the removed subtree is excluded because it becomes the marker leaf.
Equations
- t.BranchesOutside p = { v : ↥t.BranchNodes // ¬p <+: ↑↑v }
Instances For
A branch vertex of the contracted tree cannot lie weakly below the contraction position: the only retained vertex there is the marker leaf.
A retained vertex distinct from the marker lies completely outside the contracted rooted subtree.
Branch vertices of the contracted tree are exactly the original branch vertices outside the removed rooted subtree.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cardinal form of contractBranchEquiv.
Leaves of the contracted tree consist of the new marker leaf together
with the original leaves outside the removed rooted subtree. none denotes
the marker and some l denotes an unchanged outside leaf.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cardinal form of contractLeafEquiv.
Looking below the replacement vertex gives the bare leaf.
Exact vertex-count ledger for contraction: the contracted tree and the removed subtree overlap in precisely their common replacement/root vertex.
Exact leaf-count ledger for contraction. The marker replaces all leaves
of the removed subtree, hence the correction term + 1.
A subtree rooted at a branch vertex has more than one vertex.
Contracting at a branch vertex strictly decreases tree size.