Contracting unary vertices of a rose tree #
contractUnary collapses every unary vertex (one with exactly one child) into that
child — the series reduction normalizing a rooted tree to one with no unary vertices.
Each contracted vertex disappears whole, so the vertex count drops by exactly the
number of unary vertices.
Main definitions #
RoseTree.contractUnary,RoseTree.numUnary: the contraction and the unary-vertex count, with descents to theNonplanarquotient.
Main results #
RoseTree.numUnary_contractUnary: the result has no unary vertices.RoseTree.contractUnary_eq_self_iff: the fixed points are exactly the unary-free trees; hencecontractUnary_idem.RoseTree.numNodes_contractUnary_add_numUnary: each contraction removes one vertex.
[UPSTREAM] candidate alongside the RoseTree carrier.
The contraction #
Contract every unary (single-child) vertex into its child.
Instances For
The number of unary (single-child) vertices.
Equations
- RoseTree.numUnary = RoseTree.fold fun (x : α) (ns : List ℕ) => (if ns.length = 1 then 1 else 0) + ns.sum
Instances For
Vertex-count conservation #
The unary tick exactly compensates the root count: at a unary node the root is
contracted away and the tick is 1; otherwise the root survives and the tick is 0.
Each contracted unary vertex removes exactly one vertex.
contractUnary normalizes: no unary vertices remain #
Contraction never creates a unary root: a unary root collapses away, and any other root keeps its arity, so the unary count at a node is the children's total.
After contraction no unary vertices remain.
The fixed points of contractUnary are exactly the unary-free trees.
contractUnary is idempotent.
Perm invariance #
contractUnary respects Perm: contraction descends to the nonplanar quotient
(fold_rel at S := Perm; the algebra congruence is the inline match).
Descent to Nonplanar #
The number of unary vertices of a nonplanar tree.
Instances For
Contract every unary vertex into its child.
Equations
- RootedTree.Nonplanar.contractUnary = Quotient.map RoseTree.contractUnary ⋯
Instances For
Each contracted unary vertex removes exactly one vertex.
After contraction no unary vertices remain.
contractUnary is idempotent.