Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Theorem 3.7.5 — Cayley's Tree Formula

Proved
GYGraphTheory.cayley_tree_formula

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

combinatoricsenumerative-combinatoricsgraph-theorytrees

Theorem 3.7.5 [Cayley's Tree Formula] (Gross–Yellen, p. 162). For every n≥2n \geq 2n≥2, the number of distinct labeled trees on the vertex set {1,…,n}\{1,\dots,n\}{1,…,n} is nn−2n^{n-2}nn−2. Two labeled trees are considered distinct exactly when their edge sets differ. The source derives this immediately from Proposition 3.7.4: since Prüfer encoding and decoding are mutually inverse bijections between labeled trees on nnn vertices and Prüfer sequences of length n−2n-2n−2 over an nnn-element label alphabet, and there are nn−2n^{n-2}nn−2 such sequences by the rule of product, the two sets have equal cardinality.

Preamble
import Definitions.Def_GYGraphTheory
import Mathlib
Formal statement
namespace GYGraphTheory
theorem cayley_tree_formula (n : ℕ) (hn : 2 ≤ n) :
    Nat.card {T : SimpleGraph (Fin n) // T.IsTree} = n ^ (n - 2) := by sorry
end GYGraphTheory
Source
J.L. Gross and J. Yellen, Graph Theory and Its Applications, 3rd ed., CRC Press, 2018, Section 3.7, Theorem 3.7.5, p. 162
Read-back

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

For every natural number nnn satisfying 2≤n2 \le n2≤n, the statement asserts that the number of simple graphs on the vertex set {0,1,…,n−1}\{0,1,\dots,n-1\}{0,1,…,n−1} (i.e. Fin n\mathrm{Fin}\ nFin n) that are trees — meaning, per Mathlib's SimpleGraph.IsTree, that the graph is both connected and acyclic (contains no cycles) — equals n n−2n^{\,n-2}nn−2. Concretely, the quantity on the left is Nat.card⁡\operatorname{Nat.card}Nat.card applied to the subtype {T:SimpleGraph(Fin n)∣T.IsTree}\{T : \mathrm{SimpleGraph}(\mathrm{Fin}\ n) \mid T.\mathrm{IsTree}\}{T:SimpleGraph(Fin n)∣T.IsTree}, i.e. the cardinality of the set of all such tree-graphs on this fixed nnn-element vertex set (where a "simple graph" here is an irreflexive symmetric relation on Fin n\mathrm{Fin}\ nFin n, so no loops and no multi-edges, and two such graphs are counted as distinct objects whenever their edge relations differ, i.e. this counts labeled trees on distinguishable vertices 0,…,n−10,\dots,n-10,…,n−1, not trees up to isomorphism). Since SimpleGraph(Fin n)\mathrm{SimpleGraph}(\mathrm{Fin}\ n)SimpleGraph(Fin n) is a finite type for every nnn, this subtype is finite as well, so Nat.card⁡\operatorname{Nat.card}Nat.card here denotes the ordinary (finite) cardinality of this set of graphs, not the degenerate value 000 that Nat.card⁡\operatorname{Nat.card}Nat.card assigns to infinite types. The hypothesis 2≤n2 \le n2≤n restricts the claim to n≥2n \ge 2n≥2, so the potentially degenerate cases n=0n=0n=0 (empty vertex set) and n=1n=1n=1 (single vertex, where n−2n-2n−2 would require care as a natural-number subtraction) are excluded from what is being asserted; note also that n−2n-2n−2 is natural-number subtraction, which for n=2n=2n=2 evaluates to 000, giving right-hand side 20=12^0=120=1. The proof of this equality is not supplied — the body is sorry, so the statement is asserted but unproved.

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