Blueprint

🔍 Explore view: explanations, figures, other mathematical languages and labs are shown, marked commentary; they are not part of the paper. Switch to Paper for the statements, proofs and evidence only.

What a Determinant’s Derivative Knows: Jacobi’s Formula and Newton’s Identity for Matrix Traces in Lean 4

🏷️ Linear algebra · characteristic polynomials (formalized)

Carles Marín

At a glance

What the paper contributes

A machine-checked formalization, in Lean 4 / Mathlib, of Jacobi's formula and Newton's identity for matrix traces, composed with Bass's formula. The mathematics is classical; the contribution is the formalization.

  • Jacobi's formula in its algebraic form, (det M)′ = tr(adj M · M′) for a matrix of polynomials over a commutative ring (Theorem 1), for which the paper found no prior proof in any proof assistant. Axioms: propext, Classical.choice, Quot.sound.
  • Newton's identity for matrix traces to all orders, eigenvalue-free: (charpolyRev M)′ = −charpolyRev M · Σk tr(Mk+1) Xk (Theorem 2), through the resolvent series (I − XM)−1 = Σk MkXk over formal power series (Lemma 1).
  • Matrix powers count walks, also for directed graphs (Lemma 2), with the trace rewritten over cyclic walks and its weight invariant under rotation.
  • Composed with Bass's formula: the generating function of the non-backtracking counts Nk = tr(Bk) from the adjacency data (A, D) (Theorem 3), and tr(Bk) counts rooted closed non-backtracking walks (Theorem 4).
  • The boundary, as the paper states it: rooted walks, not geodesic classes; the prime-geodesic Euler product is mapped, not built.

🚀 Start here: Theorem 1: Jacobi's formula: (det M)′ = tr(adj M · M′) for a matrix of polynomials.

Main results:

  • Theorem 1: Jacobi's formula: (det M)′ = tr(adj M · M′) for a matrix of polynomials
  • Theorem 2: Newton's identity for matrix traces: (charpolyRev M)′ = −charpolyRev M · Σ tr(Mᵏ⁺¹)Xᵏ
  • Theorem 3: the Ihara Nₖ identity: Σ tr(Bᵏ⁺¹)Xᵏ from the adjacency data (A, D)
7 results ✅ 7 entirely in Lean ◐ 0 partly in Lean 💻 4 checked by a program written proof only (a result can carry several tags)
🗺️ Map of the results (click a box to go to it)

Dependencies in the written proof: an arrow A → B means that this proof of B uses A. Every result rests on its written proof; the tags record what was checked besides, and each statement's “Evidence & scope” block says how far. The colour of a box is its strongest tag, in the order above; the tags in the box give the rest. Boxes with a thick border are the main results; click a box to read the statement.

📐 Setting (copied from the paper, §2)

For a matrix \(M\) whose entries are polynomials in a formal variable, write \(M'\) for the entrywise derivative and \(\det M\) for the determinant (a polynomial). \(\operatorname {adj}M\) is the adjugate (the transpose of the cofactor matrix) (§1). (§4) Write \(\operatorname {charpolyRev}M\) for the reversed characteristic polynomial \(\det (I-XM)\)—a polynomial with constant term \(1\), hence a unit in the power-series ring. (§6) Let \(B\) be Hashimoto’s operator, \(A\) the adjacency and \(D\) the degree matrix; Bass’s formula reads \((1-X^2)^{|V|}\det (I-XB)=(1-X^2)^{|E|}\det (I-XA+X^2(D-I))\).

Abstract.

A one-line rule from a linear-algebra course—the derivative of a determinant is the trace of the adjugate times the derivative of the matrix—turns out to be the seed from which the characteristic polynomial’s coefficients, the power sums of a matrix’s traces, and ultimately the closed-walk counts of a graph all grow. This paper formalizes that seed and its first fruits in Lean 4 / Mathlib, all sorry-free. The headline is Jacobi’s formula \((\det M)'={\operatorname {tr}}({\operatorname {adj}}M\cdot M')\) for a matrix of polynomials, for which I could find no prior proof in any proof assistant; Mathlib had only the analytic derivative of \(\det \) between normed spaces, never the algebraic identity. From it I derive Newton’s identity for matrix traces—the logarithmic derivative of the reversed characteristic polynomial collects the trace power sums—an all-orders statement that Mathlib provided only at the linear coefficient, and that needs no eigenvalues. The engine is a resolvent series \((I-XM)^{-1}=\sum _k M^kX^k\) over formal power series, also new to the library. As an application I compose these with my earlier formalization of Bass’s determinant formula to read the Ihara non-backtracking counts \(N_k={\operatorname {tr}}(B^k)\) off the adjacency spectrum, and to prove combinatorially that \({\operatorname {tr}}(B^k)\) counts closed non-backtracking walks. I am exact about the boundary: none of this is new mathematics; the prime-geodesic counting that the cyclic structure sets up is built only as far as the rotation-invariant weight, not the Euler product; and \({\operatorname {tr}}(B^k)\) counts rooted closed walks, not geodesic classes. The contribution is the formalization, and a handful of certified lemmas that fill missing pieces of Mathlib’s linear-algebra ecosystem—Jacobi’s algebraic formula, the matrix-trace Newton identity, the resolvent series, and the directed walk count.

Reader’s map. If you read only two things, read Theorem 1 (Jacobi) and Theorem 2 (Newton): the first says a determinant’s derivative is a trace; the second says, taken to all orders, that single fact is the bridge between a matrix’s traces and its characteristic polynomial. Everything else—the resolvent engine (Section 3), the walk count (Section 5), the Ihara application (Section 6)—hangs from those two. The load-bearing formulas are framed; the honest limits are stated as plainly as the results. 1

🖼️ Figure 1
The spine of the paper. One elementary fact—a determinant’s derivative is a trace (Jacobi)—taken to all orders becomes the dictionary between a matrix’s traces and its characteristic polynomial (Newton), and composed with Bass’s determinant formula reaches the closed non-backtracking walk counts \(…

The spine of the paper. One elementary fact—a determinant’s derivative is a trace (Jacobi)—taken to all orders becomes the dictionary between a matrix’s traces and its characteristic polynomial (Newton), and composed with Bass’s determinant formula reaches the closed non-backtracking walk counts \(N_k={\operatorname {tr}}(B^k)\) of a graph. Each arrow is a theorem of this paper.

1 Introduction: a short history, and why this paper

Could a rule for differentiating a determinant—a fact so elementary it is often set as an exercise—be the engine that, taken to all orders, recovers the characteristic polynomial from a matrix’s traces, and then counts the closed walks of a graph? The answer is yes, and following it requires three short histories to meet.

The first is Jacobi’s formula. In the nineteenth century Jacobi recorded how the determinant of a matrix changes as its entries vary: \(\mathrm{d}(\det M)={\operatorname {tr}}({\operatorname {adj}}M\cdot \mathrm{d}M)\), where \({\operatorname {adj}}M\) is the adjugate (the transpose of the cofactor matrix)  [ 4 ] . It is the matrix calculus  [ 13 ] behind Liouville’s formula for the Wronskian of a linear ODE, behind the Faddeev–LeVerrier algorithm that computes a characteristic polynomial from traces  [ 5 ] , and behind every first-order perturbation of an eigenvalue. It is also, in its algebraic form—over an arbitrary commutative ring, with the formal derivative of polynomials rather than a limit—absent from the largest formal library of mathematics. Mathlib knew how to differentiate a determinant analytically, as a smooth map between normed spaces; it did not know the one-line algebraic identity.

The second is Newton’s identities  [ 12 ] . Newton related the power sums \(p_k=\sum _i\lambda _i^k\) of a collection of numbers to their elementary symmetric functions \(e_k\)—equivalently, the coefficients of the polynomial \(\prod _i(X-\lambda _i)\). Specialized to the eigenvalues of a matrix, the power sums are exactly the traces \({\operatorname {tr}}(M^k)\), and the elementary symmetric functions are exactly the coefficients of the characteristic polynomial. So Newton’s identities, in this guise, are a bridge: they let you compute the characteristic polynomial from the traces of powers, and conversely. Mathlib has Newton’s identities, but only in the abstract—for symmetric polynomials in free variables—never connected to a matrix’s traces. The bridge existed; its matrix end was missing, recorded only at the very first coefficient as \({\operatorname {tr}}M=-\, (\text{next coefficient of the charpoly})\).

The third thread ties this to graphs, and to my earlier work. The Ihara zeta function of a graph counts its closed non-backtracking walks; its reciprocal is the determinant \(\det (I-XB)\) of Hashimoto’s non-backtracking operator \(B\), and I formalized Bass’s reduction of that determinant to vertex-sized data in a companion paper  [ 17 ] . The counts \(N_k={\operatorname {tr}}(B^k)\) are exactly the trace power sums that Newton’s identity governs. The same derivative that powers Jacobi and Newton therefore reaches, when applied to Bass’s identity, all the way to the cycle counts of a graph.

This paper formalizes that chain—Jacobi, then Newton, then the Ihara counts—in Lean 4  [ 10 ] , and is exact about where the road, for now, ends.

2 Jacobi’s formula

If you nudge one entry of a matrix, how does its determinant move—and why should the answer involve the trace of anything?

For a matrix \(M\) whose entries are polynomials in a formal variable, write \(M'\) for the entrywise derivative and \(\det M\) for the determinant (a polynomial). The answer is a trace.

Theorem 1✅ Lean Jacobi’s formula, in Lean 4
✓
#
📕 p. 3📍 map❝ cite⚠ report

For an \(n\times n\) matrix \(M\) of polynomials over a commutative ring,

\(\displaystyle (\det M)'\; =\; {\operatorname {tr}}\! \bigl({\operatorname {adj}}M\cdot M'\bigr).\)

The statement is sorry-free (Matrix.derivative_det); #print axioms reports only propext, Classical.choice, Quot.sound.

Lean · oursshow

✅ Checked when this page was built: Jacobi.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — derivative_det: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean Jacobi.lean (SHA-256 of the compiled file: 6ec866e48406ee3e…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 1 result, standard axioms only

Proof: in this note·Formalized: Lean 4, by the author (public formalizations repository)·Covers: the whole statement·Cite: Theorem 1, p. 3, doi:10.5281/zenodo.20578470

🆕 Classical and new: classical; the paper claims the first machine-checked proof it is aware of of the algebraic formula (N1), after searching Mathlib, the AFP, Coq/Rocq, HOL Light and Mizar; Mathlib had only the analytic derivative of det.

↳ Used in: Theorem 2, Theorem 3

Proof ▼

Formalized in Lean (see the linked declarations).

🛡️ Evidence & scope
  • Program: Jacobi on one 3×3 matrix of polynomials, exact (SymPy). verify_jacobi_newton.py

The proof is the determinant’s own multilinearity, made one column at a time. Differentiating \(\det M=\sum _\sigma \varepsilon _\sigma \prod _i M_{\sigma (i),i}\) by the Leibniz rule and regrouping shows that \((\det M)'\) is the sum, over columns \(k\), of the determinant of \(M\) with column \(k\) replaced by its derivative; Cramer’s rule reads each of those single-column determinants off the adjugate, and the sum reassembles as a trace. (In Lean the regrouping uses the product form of the Leibniz formula, det_apply’, to keep every coefficient a genuine ring element rather than a signed permutation—a small choice that makes the whole proof a chain of rewrites.)

Why this is useful, plainly.

A determinant’s derivative appears wherever a matrix moves. Three places it earns its keep: Liouville’s formula—the Wronskian of a linear system evolves as \(\det (\Phi )'={\operatorname {tr}}(A)\, \det (\Phi )\), which is Jacobi’s formula for \(\Phi '=A\Phi \); eigenvalue perturbation—the first-order change of a simple eigenvalue is a trace against its spectral projection; and the Faddeev–LeVerrier algorithm, which extracts a characteristic polynomial and a matrix inverse from nothing but traces of powers, and whose correctness rests on exactly this identity. Each is a theorem someone may one day wish to certify; each now has its first stone.

3 The resolvent series: an eigenvalue-free engine

Can one talk about \((I-XM)^{-1}\) without ever inverting anything—and without ever mentioning an eigenvalue?

Over formal power series, yes. The geometric series \(\sum _k M^kX^k\) is an honest matrix of power series, and it is the inverse of \(I-XM\).

Definition 1✅ Lean Resolvent series
✓
#
📕 p. 3📍 map❝ cite⚠ report

For an \(n\times n\) matrix \(M\) over a commutative ring, the resolvent series is the matrix of formal power series \(\bigl(\, \sum _k M^k X^k\, \bigr)\), written resolventSeries M.

Lean · oursshow

✅ Checked when this page was built: Jacobi.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — resolventSeries: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean Jacobi.lean (SHA-256 of the compiled file: 6ec866e48406ee3e…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 1 result, standard axioms only

Cite: Definition 1, p. 3, doi:10.5281/zenodo.20578470

↳ Used in: Lemma 1

Proof ▼

Formalized in Lean (see the linked declarations).

Lemma 1✅ Lean The resolvent inverts \(I-XM\), and its trace is the trace generating function
✓
📕 p. 3📍 map❝ cite⚠ report
\(\displaystyle (I-XM)\cdot \textstyle \sum _k M^kX^k\; =\; I,\qquad {\operatorname {tr}}\! \bigl(\textstyle \sum _k M^kX^k\bigr)\; =\; \sum _k {\operatorname {tr}}(M^k)\, X^k.\)

Both are sorry-free (one_sub_smul_mul_resolventSeries, trace_resolventSeries). The inverse identity is proved from the fixed-point equation \(R=I+XM\! \cdot \! R\) by a single rearrangement—no eigenvalues, no algebraic closure, over any commutative ring.

Lean · oursshow

✅ Checked when this page was built: Jacobi.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — one_sub_X_smul_mul_resolventSeries, trace_resolventSeries: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean Jacobi.lean (SHA-256 of the compiled file: 6ec866e48406ee3e…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 2 results, standard axioms only

Proof: in this note·Formalized: Lean 4, by the author (public formalizations repository)·Covers: the whole statement·Cite: Lemma 1, p. 3, doi:10.5281/zenodo.20578470

🆕 Classical and new: the paper counts the resolvent series among the pieces not in the library (N3).

↳ Used in: Theorem 2

Proof ▼

Formalized in Lean (see the linked declarations).

This is the engine of Section 4. Its point is exactly its modesty: the standard way to relate traces of powers to the characteristic polynomial passes through eigenvalues, and so needs the matrix to split—an algebraically closed field, or a generic-matrix detour. The resolvent series dispenses with all of it. The trace of \((I-XM)^{-1}\) is, by construction, the trace generating function \(\sum _k{\operatorname {tr}}(M^k)X^k\), and that is the object Newton’s identity is about.

Why this is useful, plainly.

A formal resolvent is the natural home of any quantity one wants to read “order by order” in a perturbation: the moments \({\operatorname {tr}}(M^k)\) of a matrix, the Green’s function of a discrete operator, the generating function of walks (Section 5). Having \((I-XM)^{-1}\) available as certified formal-power-series infrastructure—rather than re-deriving the geometric series each time—is a small convenience that compounds.

4 Newton’s identity for matrix traces

The traces \({\operatorname {tr}}(M),{\operatorname {tr}}(M^2),\dots \) and the coefficients of the characteristic polynomial are two descriptions of the same matrix. What, exactly, is the dictionary between them?

It is a single power-series identity, and it is Jacobi’s formula taken to all orders. Write \(\operatorname{charpolyRev}M\) for the reversed characteristic polynomial \(\det (I-XM)\)—a polynomial with constant term \(1\), hence a unit in the power-series ring.

Theorem 2✅ Lean Newton’s identity for matrix traces, in Lean 4
✓
📕 p. 4📍 map❝ cite⚠ report

For an \(n\times n\) matrix \(M\) over a commutative ring, in the ring of formal power series,

\(\displaystyle (\operatorname{charpolyRev}M)'\; =\; -\, \operatorname{charpolyRev}M\cdot \sum _{k\ge 0}{\operatorname {tr}}(M^{k+1})\, X^k.\)

Equivalently \(\sum _{k\ge 1}{\operatorname {tr}}(M^k)X^k=-X\, (\operatorname{charpolyRev}M)'/\operatorname{charpolyRev}M\), the logarithmic derivative. The statement is sorry-free (Matrix.charpolyRev_logDeriv), over any commutative ring, eigenvalue-free. At the linear coefficient it specializes to the lemma Mathlib already had, \({\operatorname {tr}}M=-\, [\, X^1\, ]\, \operatorname{charpolyRev}M\).

Lean · oursshow

✅ Checked when this page was built: Jacobi.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — coe_derivative_charpolyRev_eq_neg_mul_mk_trace_pow, derivative_coe_charpolyRev: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean Jacobi.lean (SHA-256 of the compiled file: 6ec866e48406ee3e…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 2 results, standard axioms only

Proof: in this note·Formalized: Lean 4, by the author (public formalizations repository)·Covers: the whole statement·Cite: Theorem 2, p. 4, doi:10.5281/zenodo.20578470

🆕 Classical and new: classical; the matrix-trace form, which Mathlib had only at the linear coefficient (N2).

↳ Used in: Theorem 3

Proof ▼

Formalized in Lean (see the linked declarations).

🛡️ Evidence & scope
  • Program: the identity modulo X⁸ for one 3×3 and one 2×2 integer matrix, exact (SymPy). verify_jacobi_newton.py

The proof is the chain promised in the introduction. Differentiate \(\operatorname{charpolyRev}M=\det (I-XM)\) by Jacobi (Theorem 1); the derivative of \(I-XM\) is \(-M\), so \((\operatorname{charpolyRev}M)'\) is \(-{\operatorname {tr}}({\operatorname {adj}}(I-XM)\cdot M)\). The adjugate of \(I-XM\) is \(\det (I-XM)\) times its inverse—which, by Lemma 1, is \(\operatorname{charpolyRev}M\) times the resolvent series; the trace of the resolvent against \(M\) is the shifted generating function \(\sum _k{\operatorname {tr}}(M^{k+1})X^k\). Transporting the polynomial Jacobi identity along the coercion into power series and substituting closes the loop. The whole argument never names an eigenvalue.

Why this is useful, plainly.

This is the dictionary itself. Reading it one way, it computes the coefficients of the characteristic polynomial—and hence the determinant, the trace, and (via Cayley–Hamilton) the inverse—from the traces of powers; reading it the other way, it computes those traces from the polynomial. It is the matrix-trace form of Newton’s identities, the form a working mathematician actually meets, and the form that Mathlib’s symmetric-function version did not reach. The logarithmic-derivative shape \(\sum {\operatorname {tr}}(M^k)X^k=-X(\operatorname{charpolyRev})'/\operatorname{charpolyRev}\) is, moreover, the universal pattern behind zeta functions: a determinant’s reciprocal, log-differentiated, yields a count—which is precisely how Section 6 reaches the graph.

5 Matrix powers count walks

Before counting cycles, what does a single entry of \(M^k\) count?

The classical answer—walks—needs a formal home, and for directed graphs Mathlib did not have one. It records that a power of a simple (undirected) graph’s adjacency matrix counts walks; the directed analogue, which the non-backtracking operator demands, was missing.

For a matrix \(M\) over a commutative semiring, the \((i,j)\) entry of \(M^k\) is the sum, over length-\(k\) vertex walks from \(i\) to \(j\), of the product of the edge weights (pow_apply_eq_sum). For the \(0\)–\(1\) adjacency matrix of a decidable relation—a finite directed graph—this is a genuine count: \(\bigl((\text{adjacency})^k\bigr)_{ij}\) is the number of length-\(k\) directed walks from \(i\) to \(j\) (relMatrix_pow_apply). Both are sorry-free.

Lean · oursshow

✅ Checked when this page was built: WalkCount.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — pow_apply_eq_sum, relMatrix_pow_apply, trace_pow_eq_sum_cyclicProd, cyclicProd_comp_finRotate, cyclicProd_comp_finRotate_iterate: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean WalkCount.lean (SHA-256 of the compiled file: 7b1bf7dcaf36423e…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 5 results, standard axioms only

Proof: in this note·Formalized: Lean 4, by the author (public formalizations repository)·Covers: the whole statement·Cite: Lemma 2, p. 5, doi:10.5281/zenodo.20578470

🆕 Classical and new: the directed-graph walk count is among the pieces not in the library (N3).

↳ Used in: Theorem 4

Proof ▼

Formalized in Lean (see the linked declarations).

The trace then counts closed walks, and—summing the diagonal—closed walks rooted at a vertex. The same statement, reorganized over the cyclic index \({\mathbb {Z}}/(m{+}1)\), becomes a sum over cyclic walks (trace_pow_eq_sum_cyclicProd), and the weight of a cyclic walk is invariant under rotating its basepoint (cyclicProd_comp_finRotate, and under the whole rotation group). That rotation invariance is the door to geodesics—closed walks counted up to cyclic rotation—though, as Section 7 is careful to say, only the door.

🖼️ Figure 2
Closed non-backtracking walks, and the rotation that groups them. Left: the triangle \(K_3\) has six darts; one closed non-backtracking walk of length \(3\) is shown in amber (the reverse darts, in grey, would backtrack). Right: rotating the basepoint by the cyclic shift \(\rho =\mathtt{finRotate}\…

Closed non-backtracking walks, and the rotation that groups them. Left: the triangle \(K_3\) has six darts; one closed non-backtracking walk of length \(3\) is shown in amber (the reverse darts, in grey, would backtrack). Right: rotating the basepoint by the cyclic shift \(\rho =\mathtt{finRotate}\) permutes the three rooted walks of this orbit while leaving the cyclic weight fixed (cyclicProd_comp_finRotate)—so a single geodesic accounts for an orbit of rooted walks. Here \({\operatorname {tr}}(B^3)=6\): two orbits (the cycle and its reverse), three basepoints each.

Why this is useful, plainly.

“Entry of a matrix power = number of walks” is the workhorse of spectral graph theory  [ 2 ] : mixing times, the method of moments for eigenvalue distributions, expander estimates, and the trace formulas this paper composes all rest on it. Having it for directed graphs, not only undirected ones, is what lets the non-backtracking operator—an inherently directed object on oriented edges—be counted at all.

6 The Ihara counts, composed

If Jacobi differentiates a determinant into traces, and Bass collapses the Ihara determinant to vertex data, what does their composition say?

It says the non-backtracking counts of a graph are spectral. Let \(B\) be Hashimoto’s operator, \(A\) the adjacency and \(D\) the degree matrix; Bass’s formula  [ 17 ] reads \((1-X^2)^{|V|}\det (I-XB)=(1-X^2)^{|E|}\det (I-XA+X^2(D-I))\). Differentiating both sides (Theorem 1, on each determinant) and substituting Newton’s identity (Theorem 2) on the non-backtracking side isolates the count generating function.

Theorem 3✅ Lean The Ihara \(N_k\) identity, in Lean 4
✓
#
📕 p. 5📍 map❝ cite⚠ report

With \(Q=\det (I-XA+X^2(D-I))\), in the power-series ring,

\(\displaystyle \sum _k{\operatorname {tr}}(B^{k+1})X^k\; =\; \frac{\det (I-XB)\, \bigl((1-X^2)^{|V|}\bigr)'-(1-X^2)^{|E|}Q'-Q\, \bigl((1-X^2)^{|E|}\bigr)'}{(1-X^2)^{|V|}\det (I-XB)}.\)

The two \((1-X^2)\)-powers and both determinants are units, so the division is the formal \(\mathtt{invOfUnit}\); the identity is sorry-free (ihara_Nk_explicit). It expresses the non-backtracking counts \(N_k={\operatorname {tr}}(B^k)\) purely through the adjacency data \((A,D)\).

Lean · oursshow

✅ Checked when this page was built: TraceFormula.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — ihara_Nk_explicit: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean TraceFormula.lean (SHA-256 of the compiled file: 2a7348dcd68d3e94…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 1 result, standard axioms only

Proof: in this note·Formalized: Lean 4, by the author (public formalizations repository)·Covers: the whole statement·Cite: Theorem 3, p. 5, doi:10.5281/zenodo.20578470

🆕 Classical and new: composition of Jacobi and Newton with the author’s Bass formalization; Bass’s theorem is classical.

↳ Not used by another result of the paper.

Proof ▼

Formalized in Lean (see the linked declarations).

🛡️ Evidence & scope
  • Program: Bass’s identity on K₃, exact (SymPy). verify_jacobi_newton.py

And the counts are combinatorial. Because \(B\) is the \(0\)–\(1\) adjacency matrix of the non-backtracking relation on darts (\(d\rightsquigarrow e\) when the head of \(d\) is the tail of \(e\) and \(e\) is not the reverse of \(d\)), Lemma 2 specializes:

Theorem 4✅ Lean \({\operatorname {tr}}(B^k)\) counts non-backtracking walks, in Lean 4
✓
#
📕 p. 6📍 map❝ cite⚠ report
\(\displaystyle {\operatorname {tr}}(B^k)\; =\; \# \{ \text{closed non-backtracking walks of length }k,\ \text{rooted at a dart}\} .\)

sorry-free (trace_hashimoto_pow).

Lean · oursshow

✅ Checked when this page was built: NbWalkCount.lean compiles with Lean 4.35.0, no errors, no sorry. Axioms — trace_hashimoto_pow: propext, Classical.choice, Quot.sound.
Reproduce: Lean 4.35.0, Mathlib f0b4c8150aa0; in that Lean project, lake env lean NbWalkCount.lean (SHA-256 of the compiled file: 234ce32e57f69492…; a source page on this site may show it with comments edited, under its own hash).

Trust base: 🔒 kernel only. Lean: 1 result, standard axioms only

Proof: in this note·Formalized: Lean 4, by the author (public formalizations repository)·Covers: the whole statement·Cite: Theorem 4, p. 6, doi:10.5281/zenodo.20578470

↳ Not used by another result of the paper.

Proof ▼

Formalized in Lean (see the linked declarations).

🛡️ Evidence & scope
  • Program: tr(Bᵏ) against a brute-force count of rooted closed non-backtracking walks on K₃, k = 1..6: 0, 0, 6, 0, 0, 6. verify_jacobi_newton.py

So the same derivative that began as a one-line linear-algebra fact ends, four compositions later, as the statement that a graph’s non-backtracking walks of length \(k\) number \({\operatorname {tr}}(B^k)\), and that this number is computable from the graph’s adjacency spectrum alone.

Why this is useful, plainly.

Non-backtracking counts and spectra underpin sharp epidemic and percolation thresholds  [ 8 ] , spectral community detection  [ 9 ] , and—through the Ihara analogue of the Riemann hypothesis—the very definition of a Ramanujan graph as an optimal expander  [ 11 , 3 ] . Theorem 3 certifies the bridge between those counts and the adjacency data they are usually computed from; Theorem 4 certifies that the counts mean what they are said to mean.

Table 1 Every machine-checked ingredient. All are sorry-free; #print axioms reports only [propext, Classical.choice, Quot.sound]. Sources: Ihara/TraceFormula.lean and MathlibPR/MatrixWalkCount.lean.
2ggband!30white

Lean name

Statement

§

Matrix.derivative_det

\((\det M)'={\operatorname {tr}}({\operatorname {adj}}M\cdot M')\) (Jacobi)

2

one_sub_smul_mul_resolventSeries

\((I-XM)\sum _k M^kX^k=I\)

3

trace_resolventSeries

\({\operatorname {tr}}\sum _k M^kX^k=\sum _k{\operatorname {tr}}(M^k)X^k\)

3

Matrix.charpolyRev_logDeriv

\((\operatorname{charpolyRev}M)'=-\operatorname{charpolyRev}M\sum _k{\operatorname {tr}}(M^{k+1})X^k\) (Newton)

4

pow_apply_eq_sum

\((M^k)_{ij}=\sum _{\text{walks}}\prod (\text{weights})\)

5

relMatrix_pow_apply

directed walk count, \(0\)–\(1\) case

5

trace_pow_eq_sum_cyclicProd

\({\operatorname {tr}}(M^{m+1})=\sum _{\text{cyclic }w}\text{cyclicProd}\)

5

cyclicProd_comp_finRotate_iterate

rotation invariance (full group)

5

ihara_Nk_explicit

\(\sum _k{\operatorname {tr}}(B^{k+1})X^k\) from \((A,D)\)

6

trace_hashimoto_pow

\({\operatorname {tr}}(B^k)=\# \) closed nb-walks

6

Colour: blue shade = the number’s size within its column.

Table 2 Independent numerical cross-checks (SymPy), exact symbolic equality. The graph row is the triangle \(K_3\): the trace of \(B^k\) matches a brute-force enumeration of rooted closed non-backtracking walks, \(0,0,6,0,0,6\) for \(k=1,\dots ,6\) (the cycle and its reverse, three basepoints each).
2ggband!30white

Identity

Instance

Result

Jacobi \((\det M)'={\operatorname {tr}}({\operatorname {adj}}M\, M')\)

\(3\times 3\) matrix of polynomials

exact

Newton (log-derivative)

\(3\times 3\) and \(2\times 2\), mod \(X^8\)

exact

\({\operatorname {tr}}(B^k)=\# \{ \text{rooted nb-walks}\} \)

\(K_3\), \(k=1,\dots ,6\)

\(0,0,6,0,0,6\) both

Bass \((1{-}u^2)^{|V|}\det (I{-}uB)=\dots \)

\(K_3\)

exact

7 What I claim, and what I do not

The mathematics is classical throughout: Jacobi’s formula, Newton’s identities, the walk count, and Bass’s theorem are all old. The contribution is the formalization, and I separate the two on purpose.

What I claim as new (as formalization).

(N1) the first machine-checked proof I am aware of, in any proof assistant—I searched Mathlib, the Isabelle/HOL Archive of Formal Proofs, Coq/Rocq’s opam and coqdoc indices, HOL Light, and Mizar’s MML—of Jacobi’s algebraic formula \((\det M)'={\operatorname {tr}}({\operatorname {adj}}M\cdot M')\); (N2) the matrix-trace form of Newton’s identities, \((\operatorname{charpolyRev}M)'=-\operatorname{charpolyRev}M\sum _k{\operatorname {tr}}(M^{k+1})X^k\), which Mathlib had only at the linear coefficient; (N3) the resolvent series \((I-XM)^{-1}=\sum _k M^kX^k\) and the directed-graph walk count, neither in the library. All are formalization contributions; none is new mathematics.

And, plainly, what this is not.

\({\operatorname {tr}}(B^k)\) counts rooted closed non-backtracking walks—walks with a chosen basepoint dart—not closed geodesics, which are the cyclic equivalence classes of such walks, and not the prime geodesics whose Euler product is the analytic Ihara zeta. The cyclic structure that distinguishes them is set up here: the trace is rewritten as a sum over cyclic walks, and the weight is proved invariant under the whole rotation group, so each weight is a class function on the rotation orbits. But the orbit-counting, the primitive-period bookkeeping, the Möbius inversion, and the Euler product that turn rooted counts into prime-geodesic counts are not built. I have laid the combinatorial floor; the number-theoretic superstructure is mapped, not raised.

8 Implications

Three kinds, in decreasing order of how firmly I can claim them, and a methodological aside.

Reusable, certified building blocks.

Jacobi’s algebraic formula, the resolvent series, the matrix-trace Newton identity, and the directed walk count are now machine-checked and available to anyone formalizing characteristic polynomials, the Faddeev–LeVerrier algorithm, zeta functions of graphs, or expander spectra. Mathlib had none of the four in usable form. This is the implication I can state most firmly, and the one I would point a future formalizer to first.

A foothold for what these unlock.

Newton’s identity is the gateway to computing characteristic-polynomial coefficients from traces and back; Jacobi underlies Faddeev–LeVerrier and Liouville’s formula; the Ihara composition is one step from the prime-geodesic counting it sets up. Each is a landmark these stones could support.

The mathematics, with a note of caution.

These identities matter because the objects downstream of them—characteristic polynomials, non-backtracking spectra, Ramanujan expanders—matter. I am wary of borrowing that importance: certifying a foundational identity ships no algorithm and no network. Its value is in certified foundations and in the growing corpus of formalized mathematics, not in immediate application; I claim the former, not the latter.

A methodological aside.

I carried out this development using an AI system as a research instrument. I set the targets—which identities to formalize, the proof strategy for each, the boundary to claim and the boundary to refuse—and the assistant proposed candidate definitions, lemmas and tactics, which a build-as-oracle loop then accepted or rejected against the kernel. The mathematical decisions, the scope, and every claim in this paper are mine and are my responsibility; the careful accounting that results—each statement sized to exactly what was proved, the rooted-versus-geodesic distinction drawn as sharply as the theorems—is part of what I hope the work shows: that AI-assisted formalization, directed and audited by a human, can be held to a higher standard of honesty than informal mathematics, precisely because the proof assistant, not the assistant, has the last word.

9 Where this stops being useful

Honesty cuts both ways, so the limits are stated as plainly as the results. Theorem 3 is a generating-function identity, not the analytic zeta; it locates no pole and names no prime. Theorem 4 counts rooted walks, and the gap to geodesics—an entire necklace-counting and Möbius-inversion theory—is real, not cosmetic. Newton’s identity is proved over a commutative ring but says nothing about when the characteristic polynomial splits; Jacobi is for matrices of polynomials, and the smooth-manifold version remains a separate object. This paper is a handful of certified stones near the start of a long road, and I would rather name the road than overstate the stones.

10 Related work

The mathematics is classical: Jacobi’s formula and Liouville’s  [ 4 , 13 ] , Newton’s identities  [ 12 ] and the Faddeev–LeVerrier algorithm built on them  [ 5 ] , the walk-counting reading of matrix powers  [ 2 ] , and—for the application—Ihara’s zeta function  [ 7 ] , Hashimoto’s edge operator  [ 6 ] , Bass’s determinant formula  [ 1 ] , and Terras’s modern account  [ 18 ] . On the formalization side, Mathlib  [ 14 ] provides determinants, the adjugate, Cramer’s rule, the reversed characteristic polynomial (at the linear coefficient only), Newton’s identities for symmetric polynomials, and walk counts for simple graphs—but not Jacobi’s algebraic formula, the matrix-trace Newton identity, the resolvent series, or the directed walk count. This development is a companion to my earlier Lean formalizations of the matching polynomial  [ 15 , 16 ] and of Bass’s formula  [ 17 ] . After searching Mathlib, the Isabelle/HOL Archive of Formal Proofs, Coq/Rocq, HOL Light, and Mizar, I am not aware of a prior machine-checked proof of Jacobi’s algebraic formula or of the matrix-trace Newton identity in any of them; I state this as a search result, not a theorem, and would welcome a pointer to anything I missed.

11 Conclusion

I set out from the most elementary fact I could name—how a determinant moves when its matrix moves—and followed it, in a proof assistant, through Newton’s dictionary between traces and characteristic polynomials, and on to the closed-walk counts of a graph. None of this is new mathematics; the contribution is that Jacobi’s algebraic formula, the matrix-trace Newton identity, the resolvent series, and the directed walk count are now machine-verified where I could find no prior formalization, and that they compose, all the way to the Ihara counts. The prime-geodesic counting they set up, and full spectral generality, remain ahead—mapped, but unraised. I offer this as a pearl and an invitation.

Artifacts.

All Lean sources (sorry-free, depending only on the three standard axioms), are available at

in Ihara/TraceFormula.lean (Jacobi, Newton, the Ihara composition) and MathlibPR/MatrixWalkCount.lean (the resolvent series, the walk count, the cyclic structure). Verify the axiom footprint with, e.g., #print axioms Matrix.charpolyRev_logDeriv \(\rightsquigarrow \) [propext, Classical.choice, Quot.sound].

📊 Tables

Every table of the paper, in its order: click one to unfold it, with where the paper cites it, how its numbers were checked, and its data as CSV. The typeset table is one click away, on its page of the PDF.

Table 1. Every machine-checked ingredient. All are sorry-free; #print axioms reports only [propext, Classical.choice, Quot.sound]. Sources: Ihara/TraceFormula.lean and MathlibPR/MatrixWalkCount.lean.
whiteLean namewhiteStatementwhite§
Matrix.derivative_det$(\det M)'={\operatorname{tr}}({\operatorname{adj}} M\cdot M')$ (Jacobi)2
one_sub_smul_mul_resolventSeries$(I-XM)\sum_k M^kX^k=I$3
trace_resolventSeries${\operatorname{tr}}\sum_k M^kX^k=\sum_k{\operatorname{tr}}(M^k)X^k$3
Matrix.charpolyRev_logDeriv$(\operatorname{charpolyRev} M)'=-\operatorname{charpolyRev} M\sum_k{\operatorname{tr}}(M^{k+1})X^k$ (Newton)4
pow_apply_eq_sum$(M^k)_{ij}=\sum_{\text{walks}}\prod(\text{weights})$5
relMatrix_pow_applydirected walk count, $0$–$1$ case5
trace_pow_eq_sum_cyclicProd${\operatorname{tr}}(M^{m+1})=\sum_{\text{cyclic }w}\text{cyclicProd}$5
cyclicProd_comp_finRotate_iteraterotation invariance (full group)5
ihara_Nk_explicit$\sum_k{\operatorname{tr}}(B^{k+1})X^k$ from $(A,D)$6
trace_hashimoto_pow${\operatorname{tr}}(B^k)=\#$ closed nb-walks6

Colour: blue shade = the number’s size within its column.

📄 p. 6 in the PDF⬇ CSVnot cited in the text
Table 2. Independent numerical cross-checks (SymPy), exact symbolic equality. The graph row is the triangle $K_3$: the trace of $B^k$ matches a brute-force enumeration of rooted closed non-backtracking walks, $0,0,6,0,0,6$ for $k=1,\dots,6$ (the cycle and its reverse, three basepoints each).
whiteIdentitywhiteInstancewhiteResult
Jacobi $(\det M)'={\operatorname{tr}}({\operatorname{adj}} M\,M')$$3\times3$ matrix of polynomialsexact
Newton (log-derivative)$3\times3$ and $2\times2$, mod $X^8$exact
${\operatorname{tr}}(B^k)=\#\{\text{rooted nb-walks}\}$$K_3$, $k=1,\dots,6$$0,0,6,0,0,6$ both
Bass $(1{-}u^2)^{|V|}\det(I{-}uB)=\dots$$K_3$exact
📄 p. 7 in the PDF⬇ CSVcited in the opening, before §1

References

1

H. Bass, The Ihara–Selberg zeta function of a tree lattice, Internat. J. Math. 3 (1992), 717–797. 🔎 find it

2

A. E. Brouwer and W. H. Haemers, Spectra of Graphs, Universitext, Springer, 2012. 🔎 find it

3

S. Hoory, N. Linial, and A. Wigderson, Expander graphs and their applications, Bull. Amer. Math. Soc. 43 (2006), 439–561. 🔎 find it

4

R. A. Horn and C. R. Johnson, Matrix Analysis, 2nd ed., Cambridge University Press, 2013. 🔎 find it

5

S.-H. Hou, Classroom note: a simple proof of the Leverrier–Faddeev characteristic polynomial algorithm, SIAM Rev. 40 (1998), 706–709. 🔎 find it

6

K. Hashimoto, Zeta functions of finite graphs and representations of \(p\)-adic groups, in Automorphic forms and geometry of arithmetic varieties, Adv. Stud. Pure Math. 15 (1989), 211–280. 🔎 find it

7

Y. Ihara, On discrete subgroups of the two by two projective linear group over \(\mathfrak {p}\)-adic fields, J. Math. Soc. Japan 18 (1966), 219–235. 🔎 find it

8

B. Karrer, M. E. J. Newman, and L. Zdeborová, Percolation on sparse networks, Phys. Rev. Lett. 113 (2014), 208702. 🔎 find it

9

F. Krzakala, C. Moore, E. Mossel, J. Neeman, A. Sly, L. Zdeborová, and P. Zhang, Spectral redemption in clustering sparse networks, Proc. Natl. Acad. Sci. USA 110 (2013), 20935–20940. 🔎 find it

10

L. de Moura and S. Ullrich, The Lean 4 theorem prover and programming language, in Automated Deduction—CADE 28, LNCS 12699, Springer, 2021, 625–635. 🔎 find it

11

A. Lubotzky, R. Phillips, and P. Sarnak, Ramanujan graphs, Combinatorica 8 (1988), 261–277. 🔎 find it

12

I. G. Macdonald, Symmetric Functions and Hall Polynomials, 2nd ed., Oxford University Press, 1995. 🔎 find it

13

J. R. Magnus and H. Neudecker, Matrix Differential Calculus with Applications in Statistics and Econometrics, 3rd ed., Wiley, 2019. 🔎 find it

14

The mathlib Community, The Lean mathematical library, in Proc. 9th ACM SIGPLAN Int. Conf. on Certified Programs and Proofs (CPP 2020), 367–381. 🔎 find it

15

C. Marín, Random Signs into Matchings: a machine-checked Godsil–Gutman identity in Lean 4 (2026). 🔎 find it

16

C. Marín, Unfolding a Graph into a Tree: Heilmann–Lieb real-rootedness in Lean 4 (2026). 🔎 find it

17

C. Marín, Folding Edges into Vertices: a machine-checked proof of Bass’s determinant formula for the Ihara zeta in Lean 4 (2026), Zenodo DOI 10.5281/zenodo.20573120. 🔎 find it

18

A. Terras, Zeta Functions of Graphs: A Stroll through the Garden, Cambridge Studies in Advanced Mathematics 128, Cambridge Univ. Press, 2011. 🔎 find it

Notes (1)
  1. Reproducibility. All Lean sources are public at https://github.com/karlesmarin/godsil-gutman-lean (commit \texttt{67d7d0a}), built against Lean \texttt{v4.30.0-rc2} and the pinned Mathlib commit \texttt{701fb6e9c3}. Reproduce with \texttt{lake exe cache get \&\& lake build}; check the axiom footprint of any result with \lean{\#print axioms}. The numerical cross-checks of Table \ref{tab:checks} are in \texttt{verify\_jacobi\_newton.py}. ↩
fin