πŸ›οΈ Atlasβœ’οΈFormalizations.Combinatorics.SimpleGraph.MatchingPolynomial.RamanujanBound view on GitHub β†—8 theorems
/-Copyright (c) 2026 Carles MarΓ­n. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles MarΓ­n-/module public import Mathlib.Analysis.SpecialFunctions.Pow.Realpublic import Mathlib.Combinatorics.SimpleGraph.AdjMatrixpublic import Mathlib.Combinatorics.SimpleGraph.Finitepublic import Mathlib.LinearAlgebra.Eigenspace.Basic /-!# The Ramanujan bound `2√(k - 1)` The number `2√(k - 1)` is the spectral radius of the `k`-regular infinite tree; a `k`-regular graphis Ramanujan when every adjacency eigenvalue `Ξ»` has `|Ξ»| = k` or `|Ξ»| ≀ 2√(k - 1)`. This filedefines the bound and the predicate and proves elementary inequalities. ## Main definitions * `SimpleGraph.bruhatTitsBound k`: `2√(k - 1)`.* `SimpleGraph.IsRamanujan G k`: `G` is `k`-regular and its eigenvalues satisfy the Ramanujan bound. ## Main results * `SimpleGraph.bruhatTitsBound_le`, `SimpleGraph.bruhatTitsBound_lt`: `2√(k - 1) ≀ k` for `k β‰₯ 1`,  strictly for `k β‰₯ 3`.* `SimpleGraph.bruhatTitsBound_mono`: monotonicity in `k`.* `SimpleGraph.IsRamanujan.abs_eigenvalue_le`: the eigenvalues of a Ramanujan graph satisfy  `|Ξ»| ≀ k`. ## References * A. Lubotzky, R. Phillips, P. Sarnak, *Ramanujan graphs*, Combinatorica 8 (1988) 261–277.-/ @[expose] public section namespace SimpleGraph /-- The **Bruhat-Tits spectral bound** `2 Β· √(k βˆ’ 1)`. For `k = p + 1`prime, this is the spectral radius of the `p + 1`-regular infinite treeacting on `β„“Β²` of its vertices. -/noncomputable def bruhatTitsBound (k : β„•) : ℝ :=  2 * Real.sqrt (k - 1 : ℝ) @[simp] theorem bruhatTitsBound_zero : bruhatTitsBound 0 = 0 := by  unfold bruhatTitsBound  simp [Real.sqrt_eq_zero'] @[simp] theorem bruhatTitsBound_one : bruhatTitsBound 1 = 0 := by  unfold bruhatTitsBound  simp theorem bruhatTitsBound_nonneg (k : β„•) : 0 ≀ bruhatTitsBound k := by  unfold bruhatTitsBound  positivity /-- **Main theorem.** For `k β‰₯ 1`, `2√(kβˆ’1) ≀ k`. Equality holds iff`k = 2`. This is the algebraic content of why the Ramanujan bound isstructurally meaningful: it is the *strictest possible* bound onnon-trivial eigenvalues below the Frobenius eigenvalue `k`, achieved at`k = 2`, and otherwise strictly less than `k`. -/theorem bruhatTitsBound_le (k : β„•) (hk : 1 ≀ k) : bruhatTitsBound k ≀ k := by  rcases Nat.eq_or_lt_of_le hk with h | h  Β· -- k = 1: bound = 0 ≀ 1    rw [← h]    simp  Β· -- k β‰₯ 2: use sqrt(k-1) ≀ k/2 ⟺ (k-2)Β² β‰₯ 0    unfold bruhatTitsBound    have hk2 : (2 : ℝ) ≀ (k : ℝ) := by exact_mod_cast h    have hkm1 : (0 : ℝ) ≀ (k : ℝ) - 1 := by linarith    have hk_half : (0 : ℝ) ≀ (k : ℝ) / 2 := by linarith    -- Show sqrt(k-1) ≀ k/2    have h_sqrt_bound : Real.sqrt ((k : ℝ) - 1) ≀ (k : ℝ) / 2 := by      rw [show ((k : ℝ) / 2) = Real.sqrt (((k : ℝ) / 2) ^ 2) from        (Real.sqrt_sq hk_half).symm]      apply Real.sqrt_le_sqrt      nlinarith [sq_nonneg ((k : ℝ) - 2)]    linarith /-- **Strict bound.** For `k β‰₯ 3`, `2√(kβˆ’1) < k`. The strict-inequalitycompanion to `bruhatTitsBound_le`. At `k ∈ {0, 1, 2}` equality (or trivial)holds, but from `k = 3` onward there is a genuine spectral gap between theFrobenius eigenvalue `k` and the Ramanujan bound. -/theorem bruhatTitsBound_lt (k : β„•) (hk : 3 ≀ k) : bruhatTitsBound k < k := by  unfold bruhatTitsBound  have hk3 : (3 : ℝ) ≀ (k : ℝ) := by exact_mod_cast hk  have hkm1 : (0 : ℝ) ≀ (k : ℝ) - 1 := by linarith  have hk_half : (0 : ℝ) < (k : ℝ) / 2 := by linarith  have h_sqrt_strict : Real.sqrt ((k : ℝ) - 1) < (k : ℝ) / 2 := by    rw [show ((k : ℝ) / 2) = Real.sqrt (((k : ℝ) / 2) ^ 2) from      (Real.sqrt_sq hk_half.le).symm]    apply Real.sqrt_lt_sqrt hkm1    nlinarith [sq_nonneg ((k : ℝ) - 2)]  linarith /-- **Squared form.** `(2√(kβˆ’1))Β² = 4(kβˆ’1)` for `k β‰₯ 1`. Useful forspectral arguments that compare bounds via second moments. -/theorem bruhatTitsBound_sq (k : β„•) (hk : 1 ≀ k) :    bruhatTitsBound k ^ 2 = 4 * ((k : ℝ) - 1) := by  unfold bruhatTitsBound  have hk' : (1 : ℝ) ≀ (k : ℝ) := by exact_mod_cast hk  have hkm1 : (0 : ℝ) ≀ (k : ℝ) - 1 := by linarith  rw [mul_pow, Real.sq_sqrt hkm1]  ring /-- **Monotonicity.** The Bruhat-Tits bound is monotone in regularity. -/theorem bruhatTitsBound_mono {k k' : β„•} (h : k ≀ k') :    bruhatTitsBound k ≀ bruhatTitsBound k' := by  unfold bruhatTitsBound  have hkk' : ((k : ℝ)) ≀ ((k' : ℝ)) := by exact_mod_cast h  have hsub : ((k : ℝ) - 1) ≀ ((k' : ℝ) - 1) := by linarith  have := Real.sqrt_le_sqrt hsub  linarith /-- A `k`-regular `SimpleGraph` `G` is **Ramanujan** if every adjacency-matrixeigenvalue `Ξ»` (over `ℝ`) satisfies `|Ξ»| = k` (the trivial eigenvalues comingfrom `k`-regularity) or `|Ξ»| ≀ 2 Β· √(k βˆ’ 1)` (bounded by the Bruhat-Titsspectral bound). The eigenvalue condition is stated using `Module.End.HasEigenvalue` on thelinear endomorphism associated to the adjacency matrix. -/def IsRamanujan    {V : Type*} [Fintype V] [DecidableEq V]    (G : SimpleGraph V) [DecidableRel G.Adj] (k : β„•) : Prop :=  G.IsRegularOfDegree k ∧    βˆ€ ΞΌ : ℝ, Module.End.HasEigenvalue (Matrix.toLin' (G.adjMatrix ℝ)) ΞΌ β†’      |ΞΌ| = (k : ℝ) ∨ |ΞΌ| ≀ bruhatTitsBound k /-- Every adjacency-matrix eigenvalue of a `k`-regular **Ramanujan** graphsatisfies the spectral bound `|Ξ»| ≀ k`. This packages the Frobenius caseand the Bruhat-Tits case into a single absolute-value bound. -/theorem IsRamanujan.abs_eigenvalue_le    {V : Type*} [Fintype V] [DecidableEq V]    {G : SimpleGraph V} [DecidableRel G.Adj] {k : β„•}    (hk : 1 ≀ k) (hG : IsRamanujan G k)    {ΞΌ : ℝ} (hΞΌ : Module.End.HasEigenvalue (Matrix.toLin' (G.adjMatrix ℝ)) ΞΌ) :    |ΞΌ| ≀ (k : ℝ) := by  rcases hG.2 ΞΌ hΞΌ with h | h  Β· exact h.le  Β· exact h.trans (bruhatTitsBound_le k hk) end SimpleGraph