Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Proposition 3.7.3 (decoding always yields a tree)

Proved
GYGraphTheory.prop_3_7_3

by xbgxjack · Sep 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

combinatoricsgraph-theorytrees

Proposition 3.7.3 (Gross–Yellen, p. 161). For every n≥2n \geq 2n≥2 and every sequence of labels s:{1,…,n−2}→{1,…,n}s : \{1,\dots,n-2\} \to \{1,\dots,n\}s:{1,…,n−2}→{1,…,n} (a Prüfer sequence), the graph produced by Prüfer decoding (pruferDecode s, Algorithm 3.7.3) is a genuine tree on the nnn labeled vertices — i.e. it is connected and acyclic. The source proves this by induction on nnn: the base case (n=2n=2n=2) is a single edge, and the inductive step observes that adding a new vertex kkk, absent from the smaller-vertex-set subtree already built by recursion, joined by one edge to an existing vertex of that subtree, cannot create a cycle and keeps the graph connected.

Preamble
import Definitions.Def_GYGraphTheory
import Mathlib
Formal statement
namespace GYGraphTheory
theorem prop_3_7_3 {n : ℕ} (hn : 2 ≤ n) (s : Fin (n - 2) → Fin n) :
    haveI : NeZero n := ⟨by omega⟩
    (pruferDecode s).IsTree := by sorry
end GYGraphTheory
Source
J.L. Gross and J. Yellen, Graph Theory and Its Applications, 3rd ed., CRC Press, 2018, Section 3.7, Proposition 3.7.3, p. 161
Read-back

What the Lean code literally says, in plain math · claude-sonnet-5

Read‑back of GYGraphTheory.prop_3_7_3.

Fix a natural number nnn with n≥2n\ge 2n≥2 and an arbitrary function s:Fin(n−2)→Fin ns:\mathrm{Fin}(n-2)\to\mathrm{Fin}\,ns:Fin(n−2)→Finn — no injectivity, surjectivity, or any other condition is imposed on sss; it may repeat values or even be constant (e.g. s≡0s\equiv 0s≡0). Write P=[s0,…,sn−3]P=[s_0,\dots,s_{n-3}]P=[s0​,…,sn−3​] for the list List.ofFn s (empty when n=2n=2n=2, since Fin(0)\mathrm{Fin}(0)Fin(0) has no elements). Define a graph pruferDecodeAux P L on vertex set Fin n\mathrm{Fin}\,nFinn by recursion on the list argument, starting from L={0,…,n−1}L=\{0,\dots,n-1\}L={0,…,n−1} (all of Fin n\mathrm{Fin}\,nFinn): given a nonempty remaining list with head ppp and tail ps\mathit{ps}ps and current set LLL, let kkk be the least element of L∖({p}∪{elements of ps})L\setminus(\{p\}\cup\{\text{elements of }\mathit{ps}\})L∖({p}∪{elements of ps}) — i.e. the smallest label still "available" that does not occur anywhere in the as‑yet‑unprocessed part of the sequence — defaulting to 000 if that set happens to be empty; add the edge {k,p}\{k,p\}{k,p} (silently dropped if k=pk=pk=p, since fromEdgeSet discards self‑loops) and recurse on ps\mathit{ps}ps with kkk removed from LLL, taking the union (of edge sets, via ⊔\sqcup⊔) with this edge. When the list is exhausted, take a=min⁡La=\min La=minL and b=min⁡(L∖{a})b=\min(L\setminus\{a\})b=min(L∖{a}) (each defaulting to 000 if the relevant set is empty) and output the single edge {a,b}\{a,b\}{a,b} (again dropped if a=ba=ba=b). This produces up to n−2n-2n−2 edges from the recursive steps plus one final edge from the base case — the standard Prüfer‑sequence decoding procedure. pruferDecode s is this graph run on the full input PPP starting from L=Fin nL=\mathrm{Fin}\,nL=Finn (as a Finset). (The hypothesis hn : 2 ≤ n is used only to derive the typeclass instance NeZero n via omega, so that Fin n and the decoding are well‑formed; it contributes no separate mathematical content beyond enabling the statement to typecheck.)

The theorem asserts: for every n≥2n\ge 2n≥2 and for every function s:Fin(n−2)→Fin ns:\mathrm{Fin}(n-2)\to\mathrm{Fin}\,ns:Fin(n−2)→Finn whatsoever (with no further hypotheses), the graph pruferDecode s on the nnn‑element vertex set Fin n\mathrm{Fin}\,nFinn is a tree in Mathlib's sense — that is, it is connected (any two vertices are joined by a path) and acyclic (it contains no cycle), which in particular forces it to have exactly n−1n-1n−1 edges and forces the vertex type Fin n\mathrm{Fin}\,nFinn to be nonempty (automatic here since n≥2n\ge 2n≥2). No claim is made about the relationship between sss and the tree beyond this: the statement covers every conceivable input sequence uniformly, including degenerate ones such as n=2n=2n=2 (where Fin(0)\mathrm{Fin}(0)Fin(0) is empty, so the "decoding" is forced to be the single base‑case edge {0,1}\{0,1\}{0,1} regardless of sss) and constant or repeated‑value sequences, and it says nothing about uniqueness of sss for a given tree or about any inverse (encoding) map.

Human review
  • Endorsed by Shuze Chen · Sep 8, 2026

  • Endorsed by xbgxjack · Sep 8, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me