Finite trees in canonical offspring coordinates #
The existing PlaneTree uses zero-based child indices. The locally finite
carrier uses positive indices to match the existing BGW-law construction.
positiveAddress is the explicit conversion; zero is always an invalid index
on the locally finite side. All finite-tree reasoning uses the public list API.
Convert a zero-based address to its positive-index counterpart.
Equations
Instances For
Offspring count at a positive-index address; invalid addresses have count zero.
Equations
- x✝.offspringAt [] = x✝.rootDegree
- x✝.offspringAt (0 :: tail) = 0
- x✝.offspringAt (i.succ :: u) = (Option.map (fun (s : BGW.PlaneTree) => s.offspringAt u) x✝.children[i]?).getD 0
Instances For
View a finite plane tree as a canonical, possibly-infinite-tree value.
Equations
- t.toLocallyFinite = ⟨t.offspringAt, ⋯⟩
Instances For
The positive-index coordinates agree with the original fringe lookup.
Vertex membership is preserved, including the root and leaves.
Distinct finite trees stay distinct in the canonical offspring representation.
Every present positive-index address has a zero-based preimage.
A finite tree has a uniform bound on the depth of its vertices.
Adapted from Freezing1/PlaneFiniteExtinction.lean, without its model imports.
Cut at a deterministic depth, keeping the root and the order of children.
Equations
- BGW.LocallyFinite.truncate 0 x✝ = BGW.PlaneTree.leaf
- BGW.LocallyFinite.truncate n.succ x✝ = BGW.PlaneTree.node (List.ofFn fun (i : Fin (BGW.LocallyFinite.degree x✝)) => BGW.LocallyFinite.truncate n (BGW.LocallyFinite.child x✝ (↑i + 1)))
Instances For
Once the truncation depth bounds all vertices, no information is lost.
The finite plane trees are exactly the locally finite trees with finitely many vertices.
The existing finite-tree type is equivalent to the finite part of the canonical carrier.