Section SD · Volatility: same-time and temporal
Proved in Lean
Lemma SD.16 (Closed walks on trees)
Let \(T\) be a finite tree with \(n\) edges and \(W=(W_0,\dots,W_{2n})\) a closed walk in \(T\) that traverses every edge exactly twice. Root \(T\) at \(W_0\) and order the children of every vertex by the time of their first visit. Then \(W\) is the contour of this ordered tree.
Proof.
Each subtree is visited during exactly one time interval. Let \(e=\{x,x'\}\) be an edge with \(x'\) farther from \(W_0\), and \(T_e\) the component of \(T-e\) containing \(x'\). The walk starts and ends outside \(T_e\) and can enter or leave \(T_e\) only through \(e\), and entries and exits alternate. Since \(e\) is traversed exactly twice, there is one entry and one exit. So \(W\) lies in \(T_e\) during one time interval \(I_e\), on which it is a closed walk from \(x'\) in \(T_e\) traversing every edge of \(T_e\) exactly twice.
We argue by induction on \(n\), the case \(n=0\) being trivial. Let \(x_1,\dots,x_m\) be the children of the root \(v=W_0\), in the order of first visits, and \(e_r=\{v,x_r\}\). The intervals \(I_{e_r}\) are disjoint and appear in this order. At every time outside them the walk is at \(v\), since the vertex set is \(\{v\}\cup\bigcup_rT_{e_r}\). Consecutive vertices of a walk are adjacent, hence distinct, so the walk is at \(v\) exactly once between consecutive intervals, once before the first and once after the last. Thus \(W\) is \(v\), the walk on \(I_{e_1}\), \(v\), …, the walk on \(I_{e_m}\), \(v\). By induction each inner walk is the contour of \(T_{e_r}\) with its children ordered by first visits, and so \(W\) is the contour of \(T\).
Used by
- Lemma SD.17 Encoding of retained pairings
Lean
Proved in Lean
Muon.Volatility.lem_app_vol_closed_contourMuon.Volatility.PlaneTree source
inductive PlaneTree : Type where
Muon.Volatility.PlaneTree.vtxs source
def PlaneTree.vtxs : PlaneTree → List (List ℕ) | .node cs => [] :: vtxsForest cs 0 /-- Vertex addresses of a list of subtrees, the first subtree having child index `i`. -/ def vtxsForest : List PlaneTree → ℕ → List (List ℕ) | [], _ => [] | c :: cs, i => (PlaneTree.vtxs c).map (List.cons i) ++ vtxsForest cs (i + 1) end mutual /-- The contour of a plane tree (l.2069–2077), as a list of addresses: the contour of a vertex `x` with children `x₁,…,x_m` is `x`, the contour of `x₁`, `x`, …, the contour of `x_m`, `x`. Its length is `2n+1` for `n` edges. -/ def PlaneTree.contour : PlaneTree → List (List ℕ) | .node cs => [] :: contourForest cs 0 /-- Contour of a list of subtrees, the first subtree having child index `i`; each subtree is followed by the parent's visit. -/ def contourForest : List PlaneTree → ℕ → List (List ℕ) | [], _ => [] | c :: cs, i => (PlaneTree.contour c).map (List.cons i) ++ [[]] ++ contourForest cs (i + 1) end /-- Number of children of the address `u` in `P`. -/ def PlaneTree.childCount (P : PlaneTree) (u : List ℕ) : ℕ :=
Muon.Volatility.vtxsForest source
def vtxsForest : List PlaneTree → ℕ → List (List ℕ) | [], _ => [] | c :: cs, i => (PlaneTree.vtxs c).map (List.cons i) ++ vtxsForest cs (i + 1) end mutual /-- The contour of a plane tree (l.2069–2077), as a list of addresses: the contour of a vertex `x` with children `x₁,…,x_m` is `x`, the contour of `x₁`, `x`, …, the contour of `x_m`, `x`. Its length is `2n+1` for `n` edges. -/ def PlaneTree.contour : PlaneTree → List (List ℕ) | .node cs => [] :: contourForest cs 0 /-- Contour of a list of subtrees, the first subtree having child index `i`; each subtree is followed by the parent's visit. -/ def contourForest : List PlaneTree → ℕ → List (List ℕ) | [], _ => [] | c :: cs, i => (PlaneTree.contour c).map (List.cons i) ++ [[]] ++ contourForest cs (i + 1) end /-- Number of children of the address `u` in `P`. -/ def PlaneTree.childCount (P : PlaneTree) (u : List ℕ) : ℕ :=
Muon.Volatility.PlaneTree.contourMuon.Volatility.contourForestMuon.Volatility.firstVisit