Proposition 3.7.4 (encoding and decoding are mutually inverse)
ProvedGYGraphTheory.prop_3_7_4Proposition 3.7.4 (Gross–Yellen, p. 161). For every : decoding the Prüfer sequence of any labeled tree on vertices reproduces exactly (pruferDecode (pruferEncode T) = T), and encoding the tree obtained by decoding any Prüfer sequence reproduces exactly (pruferEncode (pruferDecode s) = s). Together with Proposition 3.7.3, this establishes that pruferEncode and pruferDecode are mutually inverse bijections between labeled trees on vertices and Prüfer sequences of length . The source proves each direction by induction on , in both cases peeling off the smallest-labeled leaf / first sequence entry and applying the inductive hypothesis to the remainder.
import Definitions.Def_GYGraphTheory import Mathlib
namespace GYGraphTheory
theorem prop_3_7_4 {n : ℕ} (hn : 2 ≤ n) :
haveI : NeZero n := ⟨by omega⟩
(∀ T : SimpleGraph (Fin n), T.IsTree → pruferDecode (pruferEncode T) = T) ∧
(∀ s : Fin (n - 2) → Fin n, pruferEncode (pruferDecode s) = s) := by sorry
end GYGraphTheoryRead-back
What the Lean code literally says, in plain math · claude-sonnet-5
Read-back.
For a natural number with an implicit assumption (which trivially yields , contributing no further content beyond itself), the statement is a conjunction of two universally quantified claims about a pair of maps between simple graphs on the labeled vertex set and functions (with truncated subtraction, so when ), where these maps are defined by a specific leaf-pruning algorithm: for a graph and a subset , define ; call an active leaf of if and ; let be the least (in the standard order on ) active leaf of , defaulting to if has no active leaf, and let be the least element of , again defaulting to if that set is empty. Starting from , iterate ; then , for , is the -th entry (0-indexed, defaulting to if out of range) of — i.e. the neighbor recorded at the -st leaf-removal step. Conversely, given , form the list and, starting from the full label set , decode recursively: on an empty remaining list, take = least element of and = least element of and output the single-edge graph on (which degenerates to the empty graph if , since a simple graph has no self-loops); on a list with head and tail , let be the least element of not occurring in , output the graph obtained by adjoining the edge (via graph-union ) to the recursive decoding of with replaced by ; is this recursion run on the full list with . The theorem then asserts, first, that for every simple graph on that is a tree (connected and acyclic) in the sense of SimpleGraph.IsTree, decoding the encoding of returns exactly (same adjacency relation), with no hypothesis restricting beyond (so this includes the case , where the only trees are on a two-vertex set and the sequence type is empty); and second, that for every function whatsoever — with no constraint that arise from any actual tree — encoding the decoding of returns exactly. Jointly these two clauses assert that and , as literally defined (including their -valued fallbacks whenever a Finset.min is taken of an empty set or a list index falls out of range, fallbacks whose actual invocation on the relevant inputs is not addressed one way or the other by the statement), are mutually inverse bijections between trees on and arbitrary functions .
Confirmed by the mission captain (proposal self-audit).