Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Corollary 3.7.2 (leaves are exactly the absent labels)

Proved
GYGraphTheory.corollary_3_7_2

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

combinatoricsgraph-theorytrees

Corollary 3.7.2 (Gross–Yellen, p. 159). For every n≥2n \geq 2n≥2 and labeled tree TTT on nnn vertices, a label kkk occurs in the Prüfer sequence of TTT (pruferEncode T, Algorithm 3.7.1) if and only if the vertex labeled kkk is not a leaf of TTT (i.e. has degree different from 111). This is the direct restatement of Proposition 3.7.1 in the case dk=0d_k = 0dk​=0; the hypothesis n≥2n \geq 2n≥2 is inherited from Proposition 3.7.1 for the same reason.

Preamble
import Definitions.Def_GYGraphTheory
import Mathlib

open scoped Classical
Formal statement
namespace GYGraphTheory
theorem corollary_3_7_2 {n : ℕ} (hn : 2 ≤ n) (T : SimpleGraph (Fin n)) (hT : T.IsTree) (k : Fin n) :
    haveI : NeZero n := ⟨by omega⟩
    k ∈ List.ofFn (pruferEncode T) ↔ T.degree k ≠ 1 := by sorry
end GYGraphTheory
Source
J.L. Gross and J. Yellen, Graph Theory and Its Applications, 3rd ed., CRC Press, 2018, Section 3.7, Corollary 3.7.2, p. 159
Read-back

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

Read-back of corollary_3_7_2.

Fix n∈Nn\in\mathbb Nn∈N with n≥2n\ge 2n≥2 (so in particular n≠0n\neq 0n=0, which is all the NeZero n instance records), a simple graph TTT on the vertex set Fin n={0,1,…,n−1}\mathrm{Fin}\,n=\{0,1,\dots,n-1\}Finn={0,1,…,n−1} that is a tree (connected and acyclic), and an arbitrary vertex k∈Fin nk\in\mathrm{Fin}\,nk∈Finn. The theorem asserts the biconditional

k∈L  ⟺  deg⁡T(k)≠1,k\in L \iff \deg_T(k)\neq 1,k∈L⟺degT​(k)=1,

where deg⁡T(k)\deg_T(k)degT​(k) is the ordinary degree of kkk in the full graph TTT (the number of vertices of TTT adjacent to kkk), and LLL is a specific list of length n−2n-2n−2 built as follows. For a subset S⊆Fin nS\subseteq\mathrm{Fin}\,nS⊆Finn and a vertex vvv, let activeNeighbors(S,v)={w∈S:T.Adj(v,w)}\mathrm{activeNeighbors}(S,v)=\{w\in S: T.Adj(v,w)\}activeNeighbors(S,v)={w∈S:T.Adj(v,w)}, the neighbors of vvv in TTT that also lie in SSS; call vvv an active leaf of SSS if v∈Sv\in Sv∈S and ∣activeNeighbors(S,v)∣=1|\mathrm{activeNeighbors}(S,v)|=1∣activeNeighbors(S,v)∣=1 (i.e. vvv has exactly one neighbor remaining inside SSS). Starting from S0=Fin nS_0=\mathrm{Fin}\,nS0​=Finn and an empty accumulator, repeat for j=0,1,2,…j=0,1,2,\dotsj=0,1,2,…: let ℓj\ell_jℓj​ be the smallest-indexed active leaf of SjS_jSj​ under the standard order on Fin n\mathrm{Fin}\,nFinn — or, if SjS_jSj​ happens to have no active leaf, the junk default 000 — let mjm_jmj​ be the smallest-indexed member of activeNeighbors(Sj,ℓj)\mathrm{activeNeighbors}(S_j,\ell_j)activeNeighbors(Sj​,ℓj​) (again defaulting to 000 if that set is empty), set Sj+1=Sj∖{ℓj}S_{j+1}=S_j\setminus\{\ell_j\}Sj+1​=Sj​∖{ℓj​}, and append mjm_jmj​ to the accumulator. After i+1i+1i+1 such steps the accumulator has length i+1i+1i+1 and its last entry is, by definition, pruferEncode(T)(i)\mathrm{pruferEncode}(T)(i)pruferEncode(T)(i) for each i<n−2i<n-2i<n−2 (formally extracted via List.getD with a junk default 000 that is never actually triggered, since the index iii is always in range of the length-(i+1)(i+1)(i+1) accumulator); then L=[pruferEncode(T)(0),…,pruferEncode(T)(n−3)]L=[\mathrm{pruferEncode}(T)(0),\dots,\mathrm{pruferEncode}(T)(n-3)]L=[pruferEncode(T)(0),…,pruferEncode(T)(n−3)], i.e. exactly this length-(n−2)(n-2)(n−2) record of successively-peeled leaves' neighbors — the standard Prüfer-sequence construction (repeatedly strip the least-labeled degree-one vertex of the shrinking vertex set and record its unique surviving neighbor), here made total by the two getD 0 fallbacks for the edge cases where no active leaf, or no active neighbor, exists in SjS_jSj​. In the boundary case n=2n=2n=2, n−2=0n-2=0n−2=0, so LLL is the empty list and the left-hand side is false for every kkk; correspondingly the unique tree on two vertices is the single edge, so both vertices have degree 111 and the right-hand side is false as well, so the iff holds trivially there. For n≥3n\ge3n≥3 the statement is the classical fact that a vertex occurs in the Prüfer sequence of a tree iff it is not a leaf of the tree (equivalently, its total degree is at least 222), asserted here as an exact iff (membership in LLL, not multiplicity, versus degree being different from — not merely at most — 111).

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