Use this theorem
Create a project
lake +leanprover/lean4:v4.35.0 new myproject std.toml cd myprojectStandard template, not
math: themathtemplate adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.Add the dependency to
lakefile.toml[[require]] name = "formalizations" git = "https://github.com/karlesmarin/formalizations" rev = "v0.15.0"Import the minimal module
import Formalizations.Reusable.CombinatoricsIn a file of the project, e.g.
Example.lean.Paste the example
open Formalizations.Reusable Filter Topology Classical /-- `ihara_Nk_explicit` gives the positive Hashimoto traces by coefficient extraction over `ℚ`. -/ example {V : Type*} [Fintype V] [DecidableEq V] [LinearOrder V] (G : SimpleGraph V) [DecidableRel G.Adj] (k : ℕ) : let X : Polynomial ℚ := Polynomial.X let vertexFactor : PowerSeries ℚ := ((1 - X ^ 2) ^ Fintype.card V : Polynomial ℚ) let edgeFactor : PowerSeries ℚ := ((1 - X ^ 2) ^ G.edgeFinset.card : Polynomial ℚ) let hashimotoDet : PowerSeries ℚ := (1 - X • (G.hashimoto ℚ).map Polynomial.C).det let bassDet : PowerSeries ℚ := (1 - X • (G.adjMatrix ℚ).map Polynomial.C + X ^ 2 • ((G.degMatrix ℚ - 1).map Polynomial.C)).det (G.hashimoto ℚ ^ (k + 1)).trace = PowerSeries.coeff k (PowerSeries.invOfUnit (vertexFactor * hashimotoDet) 1 * (hashimotoDet * PowerSeries.derivative vertexFactor - edgeFactor * PowerSeries.derivative bassDet - bassDet * PowerSeries.derivative edgeFactor)) := by simpa only [PowerSeries.coeff_mk] using congrArg (PowerSeries.coeff k) (ihara_Nk_explicit G ℚ)Steps 3 and 4 together are a complete Lean file:
FormalizationsTest/ReusableCombinatoricsExample.leanat v0.15.0, compiled by the CI.Fetch and check
lake update lake lean Example.leanlake updatefetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get).lake lean Example.leanbuilds the imports of the file (steps 3 and 4) and checks it. If the file belongs to alean_libof your project,lake build <lib>does the same. Avoid a barelake buildin a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Leanv4.35.0, Mathlibf0b4c81.
Alternative: import Formalizations.Reusable imports the whole layer (all areas).
The series with coefficient tr(B^(k+1)) at X^k for the Hashimoto matrix B is given by differentiating Bass’s determinant identity and inverting its unit factor.
Lean statement
theorem ihara_Nk_explicit {V : Type*} [Fintype V] [DecidableEq V] [LinearOrder V]
(G : SimpleGraph V) [DecidableRel G.Adj] (R : Type*) [Field R] [Infinite R] :
let X : Polynomial R := Polynomial.X
let vertexFactor : PowerSeries R := ((1 - X ^ 2) ^ Fintype.card V : Polynomial R)
let edgeFactor : PowerSeries R := ((1 - X ^ 2) ^ G.edgeFinset.card : Polynomial R)
let hashimotoDet : PowerSeries R := (1 - X • (G.hashimoto R).map Polynomial.C).det
let bassDet : PowerSeries R := (1 - X • (G.adjMatrix R).map Polynomial.C
+ X ^ 2 • ((G.degMatrix R - 1).map Polynomial.C)).det
PowerSeries.mk (fun k => (G.hashimoto R ^ (k + 1)).trace) =
PowerSeries.invOfUnit (vertexFactor * hashimotoDet) 1 *
(hashimotoDet * PowerSeries.derivative vertexFactor - edgeFactor * PowerSeries.derivative bassDet -
bassDet * PowerSeries.derivative edgeFactor)Links
Lean docstring
Ihara trace generating function. Let B, A and D be the Hashimoto, adjacency and degree matrices. Differentiating Bass's determinant identity gives the series whose coefficient at X^k is tr(B^(k+1)). The inverse is taken in the formal power series ring and its argument has constant coefficient 1.
- Archive:
SimpleGraph.ihara_Nk_explicit. - Classical reference: H. Bass, The Ihara–Selberg zeta function of a tree lattice, Internat. J. Math. 3 (1992) 717–797.
- Example: extracting the coefficient of
X^koverℚgives the trace at lengthk + 1.
Upstream
Uses the archive’s Hashimoto matrix with Mathlib’s graph matrices, determinants and formal power series.
Depends on, in this repository
Formalizations.Combinatorics.SimpleGraph.Ihara.Bass