Path-based vertex addressing for Planar α #
@cite{foissy-typed-decorated-rooted-trees-2018} @cite{chapoton-livernet-2001}
Path-based replacement for the indexed-inductive Vertex T / VertexList cs
machinery in Vertex.lean. A vertex is addressed by a Path = List ℕ of
child indices from the root. The non-dependent representation lets
List.map_append, List.Perm, and related mathlib API fire directly on
vertices outputs without the have h := List.map_append; rw [h]
workarounds that the dependent-typed version forced.
Lives under namespace RootedTree.Planar.Pathed to coexist with the old
Vertex.lean (also RootedTree.Planar-scoped) during the migration. Once
consumers move over, the Pathed sub-namespace will be hoisted up.
File scope #
- §1:
Path,IsValidPath,Decidableinstance. - §2:
verticesenumeration + length theorem + validity sanity check.
Path-based code uses Path and IsValidPath directly. A subtype
wrapper { p : Path // IsValidPath p T } can be inlined at use sites
that need it; no global Vertex def is needed.
Status #
[UPSTREAM] candidate. Sorry-free, no noncomputable.
A path from the root: list of child indices. [] addresses the root.
Equations
- RootedTree.Planar.Pathed.Path = List ℕ
Instances For
IsValidPath p T means p addresses an existing vertex in T.
Recurses on the path: empty path is always valid; i :: rest requires
i to be in bounds and rest to be valid in the i-th child.
Equations
- RootedTree.Planar.Pathed.IsValidPath [] x✝ = True
- RootedTree.Planar.Pathed.IsValidPath (i :: rest) (RootedTree.Planar.node a cs) = ∃ (h : i < cs.length), RootedTree.Planar.Pathed.IsValidPath rest cs[i]
Instances For
Decidability of IsValidPath, by recursion on the path.
Equations
- One or more equations did not get rendered due to their size.
- RootedTree.Planar.Pathed.decValidPath [] x✝ = isTrue trivial
Instances For
§2: Vertex enumeration #
vertices T : List Path lists the valid paths into T in DFS root-first
order: the empty path, then for each child cs[i] the i-prepended
recursion. Mutual with an aux running over the children list paired with
an offset index.
The mutual style is the same shape as vertices / verticesList in the
old Vertex.lean — exchange of the dependent inductive for a path list.
All valid paths into T in root-first order.
Equations
Instances For
Auxiliary: paths into a children list, with a starting index. The paths returned are already prefixed with the corresponding child index.
Equations
- RootedTree.Planar.Pathed.verticesAux x✝ [] = []
- RootedTree.Planar.Pathed.verticesAux x✝ (c :: cs) = List.map (fun (x : List ℕ) => x✝ :: x) (RootedTree.Planar.Pathed.vertices c) ++ RootedTree.Planar.Pathed.verticesAux (x✝ + 1) cs
Instances For
verticesAux distributes over list ++. The right summand's start
index shifts by the left list's length.
Length theorem #
The total number of enumerated paths equals the tree's weight (total
vertex count). Mirrors length_vertices_eq_weight in the dependent-typed
substrate.
Validity sanity check #
Every path enumerated by vertices T is in fact valid in T. Proved via
a mutual recursion through an aux that decomposes paths in
verticesAux i₀ cs as (i₀ + k) :: rest with rest ∈ vertices cs[k].