/-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