Nonplanar n-ary rooted trees as a quotient of RoseTree α #
A nonplanar rooted tree is a RoseTree α modulo the equivalence
relation generated by:
- swapping two adjacent children of any vertex
- replacing a child with a nonplanar-equivalent tree (recursive step)
The quotient Nonplanar α := Quotient RoseTree.isSetoid gives the carrier MCB §1.1.2 +
§1.10 actually wants for syntactic objects: trees with unordered
children at each node.
Strategy #
The identity criterion is RoseTree.Perm (Core/Data/RoseTree/Perm.lean), the
List.Perm of trees; this file owns only the quotient: the projection mk, the
lifting API, the lifted invariants, and the smart node constructor on
Multiset-children. Invariance obligations are discharged by the relation's own
theory (fold_perm, Perm.children_rel, the _perm invariants), never by a
bespoke induction here.
Foissy connection #
With Nonplanar α as carrier, B+_a : Multiset (Nonplanar α) → Nonplanar α
becomes well-defined: graft the multiset of children under a new root
labeled a. (For RoseTree α with multiset forests, B+ wasn't well-defined
because the resulting tree's child-list ordering depended on choice of
multiset representative.) This unblocks Foissy's clean cocycle proof of
Δ^p coassoc on the nonplanar Hopf algebra (Phase A.7).
MCB anchor #
[MCB25] §1.1.3 (book p. 20) — explicit
caveat: {α, {β, γ}} = α △ β γ = α △ γ β = γ β △ α. This file's
Nonplanar α realizes that unordered-children semantics for general
arity.
Status #
[UPSTREAM] candidate. No sorries.
Nonplanar — the quotient type #
A nonplanar n-ary rooted tree with α-labeled vertices: the quotient
of RoseTree α by RoseTree.Perm.
Equations
- RootedTree.Nonplanar α = Quotient RoseTree.isSetoid
Instances For
The canonical projection from ordered to nonplanar trees.
Equations
- RootedTree.Nonplanar.mk t = ⟦t⟧
Instances For
Two trees give the same nonplanar tree iff they're RoseTree.Perm-related.
Lift a function RoseTree α → β that's invariant under RoseTree.Perm
to Nonplanar α → β.
Equations
- RootedTree.Nonplanar.lift f h = Quotient.lift f h
Instances For
Smart leaf constructor + lifted counts #
A leaf in Nonplanar α is mk (RoseTree.leaf a). numNodes is the
canonical first lifted invariant.
A nonplanar leaf labeled a.
Equations
Instances For
The node count (number of vertices) of a nonplanar tree, lifted
from RoseTree.numNodes via RoseTree.Perm-invariance.
Instances For
The leaf count (number of childless vertices) of a nonplanar tree,
lifted from RoseTree.numLeaves via RoseTree.Perm-invariance. MCB's
complexity grading #L (Def. 1.6.2) is built on this.
Instances For
The arity (root child count) of a nonplanar tree.
Instances For
The depth (longest root-to-leaf path in vertices) of a nonplanar tree.
Instances For
A nonplanar tree is a leaf if its root has no children. (Audit
item: queue migrate to Prop + [DecidablePred] once the matching
RoseTree.isLeaf is migrated.)
Instances For
Destructors and node injectivity #
The root value and the children (as a multiset of nonplanar trees) are
RoseTree.Perm-invariant, so they descend to Nonplanar. congrArg on these destructors
inverts mk-equality at a node with no induction, giving the injectivity
characterization mk_node_eq_mk_node_iff.
The root value of a nonplanar tree.
Instances For
The children of a nonplanar tree, as a multiset of nonplanar trees.
Equations
- RootedTree.Nonplanar.children = RootedTree.Nonplanar.lift (fun (t : RoseTree α) => ↑(List.map RootedTree.Nonplanar.mk t.children)) ⋯
Instances For
Injectivity of the node constructor on the quotient: mk-images of two nodes are
equal iff the root values agree and the children agree as multisets of nonplanar
trees. The forward direction is congrArg on the value and children
destructors; the backward direction assembles a RoseTree.Perm componentwise.
Smart node constructor #
The B+ operator (Phase A.7) and the Δ^c trace coproduct (Phase D) both
require building a Nonplanar α from a label and an unordered
collection of children. The smart constructor node a cs does this on
Multiset (Nonplanar α); well-definedness follows from
RoseTree.Perm.node_of_perm (children-list permutation invariance).
The characterization node_mk_tree_list then bridges back to the
underlying RoseTree node via Quotient.mk_out componentwise.
Build a Nonplanar α from a label and an unordered multiset of
children. Implementation: pick a list representative of the
multiset (Quotient.liftOn), then per-child tree representatives
via Quotient.out, and quotient back.
Equations
- RootedTree.Nonplanar.node a cs = Quotient.liftOn cs (fun (lst : List (RootedTree.Nonplanar α)) => RootedTree.Nonplanar.mk (RoseTree.node a (List.map Quotient.out lst))) ⋯
Instances For
Binary case of node_mk_tree_list: a bare pair of mk-lifted trees.
Choose planar representatives for a whole forest at once: every
Multiset (Nonplanar α) is the mk-image of a list of planar trees. Descent
proofs that use this eliminator meet node_mk_tree_list on the nose, with no
Quotient.out repair.
Sanity tests #
Root value and children #
Root-level projections, lifted through the quotient: RoseTree.value is
RoseTree.Perm-invariant on the nose (Perm.value_eq), and the mk-image of
RoseTree.children is invariant as a multiset (perm_children_map_mk).
The root value of a nonplanar tree.
Instances For
The multiset of root children of a nonplanar tree.
Equations
- RootedTree.Nonplanar.rootChildren = RootedTree.Nonplanar.lift (fun (t : RoseTree α) => ↑(List.map RootedTree.Nonplanar.mk t.children)) ⋯
Instances For
Eta law: every tree is the node of its root value and root children.
Functoriality #
Lift RoseTree.map through the quotient. Counterpart of List.map for
lists: a function f : α → β lifts to Nonplanar α → Nonplanar β by
relabeling every vertex.
Map a function over the vertex labels of a nonplanar rooted tree.
Lifted from RoseTree.map via Quotient.map.
Equations
- RootedTree.Nonplanar.map f = Quotient.map (RoseTree.map f) ⋯
Instances For
Quotient-unfolding for Nonplanar.map. Plain lemma (not @[simp])
since mathlib's generic Quotient.map_mk covers the same ground.