Rebinarization: contracting unary (non-branching) nodes #
contractUnary collapses every unary node (a vertex with exactly one child)
into that child, the edge-contraction that takes a syntactic object to its
unique maximal binary rooted tree (MCB Def. 1.2.5). It is the second step
of MCB's deletion quotient T/ᵈF_v: delete the cut subtrees (leaving the
not-necessarily-binary T/ᵖF_v), then contractUnary to rebinarize.
Each contracted unary node removes exactly one vertex, so
numNodes (contractUnary t) + unaryCount t = numNodes t.
Contracting unary nodes #
contractUnary is a catamorphism over RoseTree.fold: rebuild each node from its
already-contracted children, but a lone child replaces the parent — that is
where a unary node collapses.
Rebuild a node from its (contracted) children: a single child replaces the node, otherwise the node is kept.
Equations
- RoseTree.contractCombine a [c] = c
- RoseTree.contractCombine a x✝ = RoseTree.node a x✝
Instances For
Contract every unary node into its child (rebinarize to maximal binary), MCB's Δᵈ (Def. 1.2.5).
Instances For
On a node with ≥ 2 children contractUnary keeps the root and recurses.
The number of unary (single-child) nodes.
Equations
- RoseTree.unaryCount = RoseTree.fold fun (x : α) (ns : List ℕ) => (if ns.length = 1 then 1 else 0) + ns.sum
Instances For
Node-count conservation: each contracted unary node drops one vertex #
Every contracted unary node removes exactly one vertex. A single
RoseTree.rec' induction: the per-child hypotheses combine over the child list via
List.sum_map_add; the two ifs (contractCombine drops the root of a lone
child, unaryCount counts it) always sum to one.
unaryCount is PermEquiv-invariant #
contractUnary is PermEquiv-invariant #
Nonplanar contractUnary / unaryCount #
The number of unary nodes of a nonplanar tree.
Instances For
Rebinarize: contract every unary node (MCB Δᵈ, Def. 1.2.5).
Equations
- RootedTree.Nonplanar.contractUnary = Quotient.map RoseTree.contractUnary ⋯
Instances For
Each contracted unary node drops one vertex.