Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Proposition 3.7.1 (degree via Prüfer occurrence count)

Proved
GYGraphTheory.prop_3_7_1

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

combinatoricsgraph-theorytrees

Proposition 3.7.1 (Gross–Yellen, p. 159). For every n≥2n \geq 2n≥2: let TTT be a labeled tree on nnn vertices and let dkd_kdk​ denote the number of occurrences of the label kkk in the Prüfer sequence of TTT (pruferEncode T, Algorithm 3.7.1). Then the degree of the vertex labeled kkk in TTT equals dk+1d_k + 1dk​+1.

The source proves this by induction on nnn: the claim holds trivially for the 2-vertex tree (empty Prüfer sequence, every vertex has degree 1), and for the inductive step, removing the smallest-labeled leaf vvv (whose neighbor www becomes the first entry of the sequence) decreases deg⁡(w)\deg(w)deg(w) by exactly one while leaving every other vertex's degree, and every other label's occurrence count in the remaining sequence, unchanged. (The hypothesis n≥2n \geq 2n≥2 is needed: a 1-vertex tree has a degree-0 vertex, for which this formula would be false.)

Preamble
import Definitions.Def_GYGraphTheory
import Mathlib

open scoped Classical
Formal statement
namespace GYGraphTheory
theorem prop_3_7_1 {n : ℕ} (hn : 2 ≤ n) (T : SimpleGraph (Fin n)) (hT : T.IsTree) (k : Fin n) :
    haveI : NeZero n := ⟨by omega⟩
    T.degree k = (List.ofFn (pruferEncode T)).count 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, Proposition 3.7.1, p. 159
Read-back

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

Read-back. For every natural number nnn with n≥2n \ge 2n≥2, every 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 (i.e. TTT is connected and acyclic, per Mathlib's SimpleGraph.IsTree), and every vertex k∈Fin nk \in \mathrm{Fin}\,nk∈Finn, the statement asserts T.degree(k)=(Pru¨fer sequence of T).count(k)+1T.\mathrm{degree}(k) = \big(\text{Prüfer sequence of } T\big).\mathrm{count}(k) + 1T.degree(k)=(Pru¨fer sequence of T).count(k)+1, where "Prüfer sequence of TTT" is the explicit length-(n−2)(n-2)(n−2) list produced as follows. Build a sequence of pairs (active vertex set, accumulated list) starting from S0=Fin nS_0=\mathrm{Fin}\,nS0​=Finn (all vertices), L0=[ ]L_0=[\,]L0​=[]; at each step j↦j+1j\mapsto j+1j↦j+1, among v∈Sjv\in S_jv∈Sj​ let Nj(v):={w∈Sj:v∼Tw}N_j(v):=\{w\in S_j : v\sim_T w\}Nj​(v):={w∈Sj​:v∼T​w} (its "active neighbors"), call vvv an active leaf of SjS_jSj​ if v∈Sjv\in S_jv∈Sj​ and ∣Nj(v)∣=1|N_j(v)|=1∣Nj​(v)∣=1, let ℓj\ell_jℓj​ be the least active leaf of SjS_jSj​ in the standard order on Fin n\mathrm{Fin}\,nFinn (or the junk value 000 if no active leaf of SjS_jSj​ exists), let mjm_jmj​ be the least element of Nj(ℓj)N_j(\ell_j)Nj​(ℓj​) (again 000 by convention if that set is empty), and set Sj+1=Sj∖{ℓj}S_{j+1}=S_j\setminus\{\ell_j\}Sj+1​=Sj​∖{ℓj​}, Lj+1=Lj+ ⁣ ⁣+[mj]L_{j+1}=L_j\mathbin{+\!\!+}[m_j]Lj+1​=Lj​++[mj​]; the Prüfer sequence is then [m0,m1,…,mn−3][m_0,m_1,\dots,m_{n-3}][m0​,m1​,…,mn−3​] (the entry at position iii is literally the last, and only newly-appended, element of Li+1L_{i+1}Li+1​, so the getD 0 fallback used in pruferEncode is never actually triggered on this indexing). The right-hand side counts how many times the fixed vertex kkk occurs among m0,…,mn−3m_0,\dots,m_{n-3}m0​,…,mn−3​, and the left-hand side is the ordinary graph degree of kkk in TTT (the cardinality of its neighbor set). No claim is made about existence/uniqueness of active leaves at each stage beyond what the hypothesis T.IsTreeT.\mathrm{IsTree}T.IsTree and the definitions force; in the boundary case n=2n=2n=2, Fin(n−2)=Fin 0\mathrm{Fin}(n-2)=\mathrm{Fin}\,0Fin(n−2)=Fin0 is empty, so the Prüfer sequence is the empty list, every count is 000, and the statement reduces to asserting T.degree(k)=1T.\mathrm{degree}(k)=1T.degree(k)=1 for each of the two vertices kkk.

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