Mathematics

Counting Trees Without Listing Them: A Machine-Checked Proof of Kirchhoff's Matrix-Tree Theorem in Lean 4 (Part V)

Carles Marín Muñoz

DOI 10.5281/zenodo.20629746CC BY 4.0

Combinatorics & graphs Lean 4 Graphs, walks and matchings, machine-checked

Abstract

Part V of the godsil-gutman-lean series. A machine-checked, sorry-free proof in Lean 4 over Mathlib of Kirchhoff's matrix-tree theorem: over any integral domain, the determinant of the reduced Laplacian of a finite simple graph equals its number of spanning trees (SimpleGraph.det_reducedLapMatrix_eq_card_spanningTrees).

The proof is assembled from four formalized pieces, each of independent use: a self-contained Cauchy–Binet formula (Matrix.det_mul_cauchyBinet; not in Mathlib — an independent formalization exists in the Grinberg-textbook project and is discussed in the paper); the oriented incidence matrix and its Gram factorization N·Nᵀ = D − A (orientedIncMatrix_mul_transpose; Mathlib has only the unoriented incidence matrix); the reduced sum-of-squared-minors expansion; and a spanning-tree minor dichotomy proved by sorting (parent edges plus a distance key make the minor triangular) instead of the textbook leaf-deletion induction. To the best of the author's knowledge, this is the first machine-checked proof of the matrix-tree theorem in any proof assistant.

All headline theorems depend only on the three standard axioms (propext, Classical.choice, Quot.sound). Every design was validated numerically in exact arithmetic (SageMath) before formalization; the verification battery is reported in the paper. English and Spanish editions, plus the LaTeX sources.

Methodology note: formalized with AI assistance (Claude, Anthropic); the mathematics and all claims are the author's responsibility.

Full text

Read the PDF (597 kB)

Identical to the file matrix-tree-lean.pdf of the Zenodo record (same MD5 checksum).

Cite

Carles Marín Muñoz, Counting Trees Without Listing Them: A Machine-Checked Proof of Kirchhoff's Matrix-Tree Theorem in Lean 4 (Part V). Zenodo, 2026. doi:10.5281/zenodo.20629746

BibTeX
@misc{Carles2026counting,
  author    = {Carles Marín Muñoz},
  title     = {Counting Trees Without Listing Them: A Machine-Checked Proof of Kirchhoff's Matrix-Tree Theorem in Lean 4 (Part V)},
  year      = {2026},
  publisher = {Zenodo},
  doi       = {10.5281/zenodo.20629746},
  url       = {https://doi.org/10.5281/zenodo.20629746}
}