import Mathlib.Analysis.Matrix.PosDef import Mathlib.Analysis.Matrix.Spectrum import Mathlib.Analysis.SpecialFunctions.Log.Basic import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds import Mathlib.Data.Real.Basic import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Fintype.Perm import Mathlib.Data.Nat.Choose.Sum import Mathlib.Tactic /-! # Finite Markov Chain Mixing Times, Coupling, Strong Stationary Times, Conductance & Cutoff Phase Transitions A unified, 100% self-contained, non-asymptotic Lean 4 formalization across five interlocking pillars of modern Markov chain mixing theory: 1. **Total Variation, Separation Distance, Coupling & Strong Stationary Times**: exact variational & $\ell^1$ characterizations of $d_{\mathrm{TV}}$, data-processing contraction, submultiplicativity $d(s+t) \le 2 d(s) d(t)$ & $\bar{d}(s+t) \le \bar{d}(s)\bar{d}(t)$, the **Fundamental Coupling Inequality** $d_{\mathrm{TV}}(\mu,\nu) \le \mathbb{P}(X \neq Y)$ and exact **Maximal Coupling** tightness, Chebyshev/Cantelli distinguishing-statistic lower bounds, separation distance $d_{\mathrm{TV}}(t) \le s(t)$ & reversible doubling $s(2t) \le 1 - (1 - \bar{d}(t))^2$, and **Aldous–Diaconis Strong Stationary Times** $d_{\mathrm{TV}}(t) \le s(t) \le \mathbb{P}(\tau > t)$. 2. **Reversible Spectral Gap, Relaxation Time & Mixing Time Sandwiches**: detailed balance, $L^2(\pi)$ self-adjointness, Dirichlet form identity, symmetric similarity matrix $S = D_\pi^{1/2} P D_\pi^{-1/2}$, spectral expansion, lazy-chain positivity ($\operatorname{Spec}(P_{\mathrm{lazy}}) \subseteq [0, 1]$), exact $L^2$-to-TV Cauchy–Schwarz sandwich $4 d_{\mathrm{TV}}(t)^2 \le \chi^2(t) \le (\pi_{\min}^{-1} - 1)\lambda_*^{2t}$, Poincaré variance decay, and exact lower bound $t_{\mathrm{mix}}(\varepsilon) \ge (t_{\mathrm{rel}} - 1)\ln(1/(2\varepsilon))$. 3. **Bottleneck Ratio, Full Discrete Cheeger Inequality & Canonical Paths**: ergodic flow & bottleneck conductance $\Phi_*$, both the easy Cheeger upper bound $\gamma \le 2\Phi_*$ and the hard **Lawler–Sokal / Sinclair–Jerrum co-area lower bound** $\Phi_*^2 / 2 \le 1 - \sqrt{1 - \Phi_*^2} \le \gamma$, **Diaconis–Stroock / Sinclair Canonical Paths** $\gamma \ge 1 / (\rho \ell_{\max})$, and exact conductance/gap benchmarks on $K_2$, $K_n$, $P_n$, $C_{2m}$, and $Q_n$. 4. **Bubley–Dyer Path Coupling & Glauber Dynamics Uniqueness**: finite metric spaces & Wasserstein-1 coupling contraction, coupling gluing lemma, **Bubley–Dyer Path Coupling Theorem** lifting local edge contraction to global geometric mixing $d_{\mathrm{TV}}(t) \le \operatorname{diam}\cdot(1-\alpha)^t$, single-site Glauber dynamics under **Dobrushin uniqueness** ($\alpha_{\mathrm{Dob}} < 1$), high-temperature Ising Glauber mixing ($\Delta \tanh\beta < 1$), and **Jerrum's proper $q$-coloring theorem** ($q > 2\Delta$). 5. **Sharp Cutoff Phase Transitions & Exact Witnesses**: exact Walsh–Fourier / Krawtchouk diagonalization of the $p$-lazy hypercube walk on $Q_n$, **Diaconis–Graham–Morrison sharp cutoff at $\frac{1}{4} n \ln n$** (and $\frac{1}{2}$-lazy cutoff at $\frac{1}{2} n \ln n$) with matching non-asymptotic upper and lower bounds, exact **Top-to-Random Card Shuffling** strong stationary time & coupon-collector inclusion-exclusion identity proving **sharp cutoff at $n \ln n$**, contrasted quantitatively against **non-cutoff** $\Theta(n^2)$ mixing on the lazy cycle $C_{2m}$. All proofs are completely axiom-free beyond Lean's standard kernel axioms `{propext, Classical.choice, Quot.sound}`. -/ open scoped BigOperators Matrix open Finset namespace MarkovChainMixingCouplingCutoff noncomputable section /-! ============================================================================ PILLAR 1: TOTAL VARIATION, SEPARATION DISTANCE, COUPLING & STRONG STATIONARY TIMES ============================================================================ -/ section Pillar1_TVCouplingSST variable {Ω : Type*} [Fintype Ω] /-- A finite probability distribution on `Ω`. -/ structure Dist (Ω : Type*) [Fintype Ω] where p : Ω → ℝ nonneg : ∀ x, 0 ≤ p x sum_one : ∑ x : Ω, p x = 1 namespace Dist instance : CoeFun (Dist Ω) (fun _ => Ω → ℝ) := ⟨Dist.p⟩ @[ext] lemma ext {μ ν : Dist Ω} (h : ∀ x, μ x = ν x) : μ = ν := by cases μ; cases ν; congr; exact funext h /-- Probability of an event `A : Finset Ω`. -/ def prob (μ : Dist Ω) (A : Finset Ω) : ℝ := ∑ x ∈ A, μ x /-- Expectation of a real observable `f : Ω → ℝ`. -/ def expect (μ : Dist Ω) (f : Ω → ℝ) : ℝ := ∑ x : Ω, μ x * f x /-- Variance of a real observable `f : Ω → ℝ`. -/ def variance (μ : Dist Ω) (f : Ω → ℝ) : ℝ := ∑ x : Ω, μ x * (f x - μ.expect f) ^ 2 /-- Dirac point mass at `x`. -/ def dirac [DecidableEq Ω] (x : Ω) : Dist Ω where p y := if y = x then 1 else 0 nonneg y := by split_ifs <;> norm_num sum_one := by simp /-- Uniform distribution on a nonempty finite state space `Ω`. -/ def uniform (hne : Nonempty Ω) : Dist Ω where p _ := (Fintype.card Ω : ℝ)⁻¹ nonneg _ := by positivity sum_one := by have hpos : (0 : ℝ) < Fintype.card Ω := by exact_mod_cast Fintype.card_pos_iff.mpr hne simp [Finset.sum_const, nsmul_eq_mul, ne_of_gt hpos] lemma prob_nonneg (μ : Dist Ω) (A : Finset Ω) : 0 ≤ μ.prob A := Finset.sum_nonneg fun x _ => μ.nonneg x lemma prob_le_one (μ : Dist Ω) (A : Finset Ω) : μ.prob A ≤ 1 := by calc μ.prob A = ∑ x ∈ A, μ x := rfl _ ≤ ∑ x ∈ Finset.univ, μ x := Finset.sum_le_univ_sum_of_nonneg (fun x => μ.nonneg x) _ = 1 := μ.sum_one lemma le_one (μ : Dist Ω) (x : Ω) : μ x ≤ 1 := by have h := μ.prob_le_one {x} simpa [prob] using h lemma prob_compl [DecidableEq Ω] (μ : Dist Ω) (A : Finset Ω) : μ.prob Aᶜ = 1 - μ.prob A := by have h := Finset.sum_add_sum_compl A (fun x => μ x) rw [μ.sum_one] at h unfold prob linarith lemma prob_mono (μ : Dist Ω) {A B : Finset Ω} (hAB : A ⊆ B) : μ.prob A ≤ μ.prob B := Finset.sum_le_sum_of_subset_of_nonneg hAB (fun x _ _ => μ.nonneg x) lemma expect_const (μ : Dist Ω) (c : ℝ) : μ.expect (fun _ => c) = c := by simp [expect, ← Finset.sum_mul, μ.sum_one] lemma expect_add (μ : Dist Ω) (f g : Ω → ℝ) : μ.expect (fun x => f x + g x) = μ.expect f + μ.expect g := by simp only [expect, mul_add, Finset.sum_add_distrib] lemma expect_sub (μ : Dist Ω) (f g : Ω → ℝ) : μ.expect (fun x => f x - g x) = μ.expect f - μ.expect g := by simp only [expect, mul_sub, Finset.sum_sub_distrib] lemma expect_smul (μ : Dist Ω) (c : ℝ) (f : Ω → ℝ) : μ.expect (fun x => c * f x) = c * μ.expect f := by simp only [expect, Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => by ring lemma expect_nonneg (μ : Dist Ω) {f : Ω → ℝ} (hf : ∀ x, 0 ≤ f x) : 0 ≤ μ.expect f := Finset.sum_nonneg fun x _ => mul_nonneg (μ.nonneg x) (hf x) lemma variance_nonneg (μ : Dist Ω) (f : Ω → ℝ) : 0 ≤ μ.variance f := Finset.sum_nonneg fun x _ => mul_nonneg (μ.nonneg x) (sq_nonneg _) lemma variance_eq_expect_sq_sub (μ : Dist Ω) (f : Ω → ℝ) : μ.variance f = μ.expect (fun x => f x ^ 2) - (μ.expect f) ^ 2 := by unfold variance expect have hexp : ∑ x : Ω, μ x * (f x - ∑ y, μ y * f y) ^ 2 = (∑ x, μ x * f x ^ 2) - 2 * (∑ y, μ y * f y) * (∑ x, μ x * f x) + (∑ y, μ y * f y) ^ 2 * (∑ x, μ x) := by have h1 : ∀ x : Ω, μ x * (f x - ∑ y, μ y * f y) ^ 2 = μ x * f x ^ 2 - (2 * (∑ y, μ y * f y)) * (μ x * f x) + (∑ y, μ y * f y) ^ 2 * μ x := fun x => by ring simp_rw [h1, Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum] rw [hexp, μ.sum_one] ring /-- Markov's inequality for nonnegative observables on a finite distribution. -/ theorem markov_inequality (μ : Dist Ω) {f : Ω → ℝ} (hf : ∀ x, 0 ≤ f x) {a : ℝ} (_ha : 0 < a) : a * μ.prob (Finset.univ.filter fun x => a ≤ f x) ≤ μ.expect f := by unfold prob expect rw [Finset.mul_sum] calc ∑ x ∈ Finset.univ.filter (fun x => a ≤ f x), a * μ x ≤ ∑ x ∈ Finset.univ.filter (fun x => a ≤ f x), μ x * f x := by refine Finset.sum_le_sum fun x hx => ?_ have hfx : a ≤ f x := (Finset.mem_filter.mp hx).2 nlinarith [μ.nonneg x] _ ≤ ∑ x : Ω, μ x * f x := Finset.sum_le_univ_sum_of_nonneg fun x => mul_nonneg (μ.nonneg x) (hf x) /-- Chebyshev's inequality on a finite distribution. -/ theorem chebyshev_inequality (μ : Dist Ω) (f : Ω → ℝ) {a : ℝ} (ha : 0 < a) : μ.prob (Finset.univ.filter fun x => a ≤ |f x - μ.expect f|) ≤ μ.variance f / a ^ 2 := by have ha2 : 0 < a ^ 2 := sq_pos_of_pos ha rw [le_div_iff₀ ha2, mul_comm] have hsub : (Finset.univ.filter fun x => a ≤ |f x - μ.expect f|) ⊆ (Finset.univ.filter fun x => a ^ 2 ≤ (f x - μ.expect f) ^ 2) := by intro x hx simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hx ⊢ calc a ^ 2 ≤ |f x - μ.expect f| ^ 2 := by nlinarith [abs_nonneg (f x - μ.expect f)] _ = (f x - μ.expect f) ^ 2 := sq_abs _ calc a ^ 2 * μ.prob (Finset.univ.filter fun x => a ≤ |f x - μ.expect f|) ≤ a ^ 2 * μ.prob (Finset.univ.filter fun x => a ^ 2 ≤ (f x - μ.expect f) ^ 2) := mul_le_mul_of_nonneg_left (μ.prob_mono hsub) (le_of_lt ha2) _ ≤ μ.expect (fun x => (f x - μ.expect f) ^ 2) := μ.markov_inequality (fun x => sq_nonneg _) ha2 _ = μ.variance f := rfl end Dist /-- A finite-state Markov transition kernel (row-stochastic matrix) on `Ω`. -/ structure MarkovKernel (Ω : Type*) [Fintype Ω] where P : Ω → Ω → ℝ nonneg : ∀ x y, 0 ≤ P x y row_sum_one : ∀ x, ∑ y : Ω, P x y = 1 namespace MarkovKernel /-- Identity (0-step) Markov kernel. -/ def id [DecidableEq Ω] : MarkovKernel Ω where P x y := if x = y then 1 else 0 nonneg x y := by split_ifs <;> norm_num row_sum_one x := by simp /-- Composition (Chapman–Kolmogorov product) of two Markov kernels. -/ def comp (K₁ K₂ : MarkovKernel Ω) : MarkovKernel Ω where P x z := ∑ y : Ω, K₁.P x y * K₂.P y z nonneg x z := Finset.sum_nonneg fun y _ => mul_nonneg (K₁.nonneg x y) (K₂.nonneg y z) row_sum_one x := by calc ∑ z : Ω, ∑ y : Ω, K₁.P x y * K₂.P y z = ∑ y : Ω, ∑ z : Ω, K₁.P x y * K₂.P y z := Finset.sum_comm _ = ∑ y : Ω, K₁.P x y * ∑ z : Ω, K₂.P y z := by refine Finset.sum_congr rfl fun y _ => by rw [← Finset.mul_sum] _ = ∑ y : Ω, K₁.P x y := by simp_rw [K₂.row_sum_one, mul_one] _ = 1 := K₁.row_sum_one x /-- `t`-step transition kernel `P^t`. -/ def pow [DecidableEq Ω] (K : MarkovKernel Ω) : ℕ → MarkovKernel Ω | 0 => MarkovKernel.id | t + 1 => K.comp (K.pow t) /-- Row `x` of `K` as a probability distribution `P(x, ·)`. -/ def row (K : MarkovKernel Ω) (x : Ω) : Dist Ω where p y := K.P x y nonneg y := K.nonneg x y sum_one := K.row_sum_one x /-- Pushforward of a distribution `μ` by kernel `K`: `(μ P)(y) = ∑_x μ(x) P(x, y)`. -/ def push (K : MarkovKernel Ω) (μ : Dist Ω) : Dist Ω where p y := ∑ x : Ω, μ x * K.P x y nonneg y := Finset.sum_nonneg fun x _ => mul_nonneg (μ.nonneg x) (K.nonneg x y) sum_one := by calc ∑ y : Ω, ∑ x : Ω, μ x * K.P x y = ∑ x : Ω, ∑ y : Ω, μ x * K.P x y := Finset.sum_comm _ = ∑ x : Ω, μ x * ∑ y : Ω, K.P x y := by refine Finset.sum_congr rfl fun x _ => by rw [← Finset.mul_sum] _ = ∑ x : Ω, μ x := by simp_rw [K.row_sum_one, mul_one] _ = 1 := μ.sum_one /-- Markov operator action on real functions: `(P f)(x) = ∑_y P(x, y) f(y)`. -/ def apply (K : MarkovKernel Ω) (f : Ω → ℝ) : Ω → ℝ := fun x => ∑ y : Ω, K.P x y * f y /-- Distribution after `t` steps starting from state `x`: `P^t(x, ·)`. -/ def stepDist [DecidableEq Ω] (K : MarkovKernel Ω) (t : ℕ) (x : Ω) : Dist Ω := (K.pow t).row x /-- Stationarity of `π` for kernel `K`: `π P = π`. -/ def IsStationary (K : MarkovKernel Ω) (π : Dist Ω) : Prop := K.push π = π lemma comp_assoc (K₁ K₂ K₃ : MarkovKernel Ω) : (K₁.comp K₂).comp K₃ = K₁.comp (K₂.comp K₃) := by cases K₁; cases K₂; cases K₃ simp only [comp, mk.injEq] ext x w calc ∑ z, (∑ y, _ * _) * _ = ∑ z, ∑ y, _ * _ * _ := Finset.sum_congr rfl fun z _ => Finset.sum_mul .. _ = ∑ y, ∑ z, _ * _ * _ := Finset.sum_comm _ = ∑ y, _ * ∑ z, _ * _ := Finset.sum_congr rfl fun y _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun z _ => by ring lemma id_comp [DecidableEq Ω] (K : MarkovKernel Ω) : (MarkovKernel.id).comp K = K := by cases K; simp only [comp, MarkovKernel.id, mk.injEq]; ext x z; simp lemma comp_id [DecidableEq Ω] (K : MarkovKernel Ω) : K.comp (MarkovKernel.id) = K := by cases K; simp only [comp, MarkovKernel.id, mk.injEq]; ext x z; simp lemma pow_add [DecidableEq Ω] (K : MarkovKernel Ω) (s t : ℕ) : K.pow (s + t) = (K.pow s).comp (K.pow t) := by induction s with | zero => simp [pow, id_comp] | succ s ih => rw [Nat.succ_add, pow, ih, pow, comp_assoc] lemma pow_succ_right [DecidableEq Ω] (K : MarkovKernel Ω) (t : ℕ) : K.pow (t + 1) = (K.pow t).comp K := by rw [pow_add, pow, pow, comp_id] lemma push_comp (K₁ K₂ : MarkovKernel Ω) (μ : Dist Ω) : (K₁.comp K₂).push μ = K₂.push (K₁.push μ) := by ext z simp only [push, comp] calc ∑ x, μ x * ∑ y, K₁.P x y * K₂.P y z = ∑ x, ∑ y, μ x * (K₁.P x y * K₂.P y z) := Finset.sum_congr rfl fun x _ => Finset.mul_sum .. _ = ∑ y, ∑ x, μ x * (K₁.P x y * K₂.P y z) := Finset.sum_comm _ = ∑ y, (∑ x, μ x * K₁.P x y) * K₂.P y z := Finset.sum_congr rfl fun y _ => by rw [Finset.sum_mul]; exact Finset.sum_congr rfl fun x _ => by ring lemma push_dirac [DecidableEq Ω] (K : MarkovKernel Ω) (x : Ω) : K.push (Dist.dirac x) = K.row x := by ext y; simp [push, Dist.dirac, row] lemma stepDist_add [DecidableEq Ω] (K : MarkovKernel Ω) (s t : ℕ) (x : Ω) : K.stepDist (s + t) x = (K.pow t).push (K.stepDist s x) := by rw [stepDist, pow_add, ← push_dirac, push_comp, push_dirac]; rfl lemma stepDist_succ [DecidableEq Ω] (K : MarkovKernel Ω) (t : ℕ) (x : Ω) : K.stepDist (t + 1) x = K.push (K.stepDist t x) := by have h := K.stepDist_add t 1 x simpa [pow, comp_id] using h lemma isStationary_pow [DecidableEq Ω] (K : MarkovKernel Ω) {π : Dist Ω} (hπ : K.IsStationary π) (t : ℕ) : (K.pow t).IsStationary π := by induction t with | zero => ext y; simp [pow, push, MarkovKernel.id] | succ t ih => unfold IsStationary at ih hπ ⊢ rw [pow, push_comp, hπ, ih] lemma expect_push (K : MarkovKernel Ω) (μ : Dist Ω) (f : Ω → ℝ) : (K.push μ).expect f = μ.expect (K.apply f) := by simp only [Dist.expect, push, apply] calc ∑ y, (∑ x, μ x * K.P x y) * f y = ∑ y, ∑ x, μ x * K.P x y * f y := Finset.sum_congr rfl fun y _ => Finset.sum_mul .. _ = ∑ x, ∑ y, μ x * K.P x y * f y := Finset.sum_comm _ = ∑ x, μ x * ∑ y, K.P x y * f y := Finset.sum_congr rfl fun x _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun y _ => by ring lemma apply_comp (K₁ K₂ : MarkovKernel Ω) (f : Ω → ℝ) : (K₁.comp K₂).apply f = K₁.apply (K₂.apply f) := by ext x simp only [apply, comp] calc ∑ z, (∑ y, K₁.P x y * K₂.P y z) * f z = ∑ z, ∑ y, K₁.P x y * K₂.P y z * f z := Finset.sum_congr rfl fun z _ => Finset.sum_mul .. _ = ∑ y, ∑ z, K₁.P x y * K₂.P y z * f z := Finset.sum_comm _ = ∑ y, K₁.P x y * ∑ z, K₂.P y z * f z := Finset.sum_congr rfl fun y _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun z _ => by ring lemma apply_const (K : MarkovKernel Ω) (c : ℝ) : K.apply (fun _ => c) = fun _ => c := by ext x; simp [apply, ← Finset.sum_mul, K.row_sum_one] /-- Expectation of `f` under `P^t(x, ·)` equals `(P^t f)(x)`. -/ lemma expect_stepDist [DecidableEq Ω] (K : MarkovKernel Ω) (t : ℕ) (x : Ω) (f : Ω → ℝ) : (K.stepDist t x).expect f = (K.pow t).apply f x := rfl end MarkovKernel /-! ### Total Variation Distance: Exact Identities, Contraction & Submultiplicativity -/ /-- Total variation distance `d_TV(μ, ν) = (1/2) ∑_x |μ(x) - ν(x)|`. -/ def tvDist (μ ν : Dist Ω) : ℝ := (1 / 2 : ℝ) * ∑ x : Ω, |μ x - ν x| lemma tvDist_nonneg (μ ν : Dist Ω) : 0 ≤ tvDist μ ν := mul_nonneg (by norm_num) (Finset.sum_nonneg fun x _ => abs_nonneg _) lemma tvDist_self (μ : Dist Ω) : tvDist μ μ = 0 := by simp [tvDist] lemma tvDist_symm (μ ν : Dist Ω) : tvDist μ ν = tvDist ν μ := by unfold tvDist congr 1 exact Finset.sum_congr rfl fun x _ => abs_sub_comm (μ x) (ν x) lemma tvDist_eq_zero_iff (μ ν : Dist Ω) : tvDist μ ν = 0 ↔ μ = ν := by constructor · intro h have hsum : ∑ x : Ω, |μ x - ν x| = 0 := by unfold tvDist at h; linarith have hall := (Finset.sum_eq_zero_iff_of_nonneg (fun x _ => abs_nonneg (μ x - ν x))).mp hsum ext x have hx := abs_eq_zero.mp (hall x (Finset.mem_univ x)) linarith · rintro rfl; exact tvDist_self μ theorem tvDist_triangle (μ ρ ν : Dist Ω) : tvDist μ ν ≤ tvDist μ ρ + tvDist ρ ν := by unfold tvDist rw [← mul_add, ← Finset.sum_add_distrib] refine mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun x _ => ?_) (by norm_num) exact abs_sub_le (μ x) (ρ x) (ν x) /-- Exact positive-part formula: `d_TV(μ, ν) = ∑_x max (μ x - ν x) 0`. -/ theorem tvDist_eq_sum_pos (μ ν : Dist Ω) : tvDist μ ν = ∑ x : Ω, max (μ x - ν x) 0 := by have hdiff : ∑ x : Ω, (μ x - ν x) = 0 := by rw [Finset.sum_sub_distrib, μ.sum_one, ν.sum_one, sub_self] have hpt : ∀ x : Ω, |μ x - ν x| + (μ x - ν x) = 2 * max (μ x - ν x) 0 := fun x => by rcases le_total (μ x - ν x) 0 with h | h · rw [abs_of_nonpos h, max_eq_right h]; ring · rw [abs_of_nonneg h, max_eq_left h]; ring have hsum : (∑ x : Ω, |μ x - ν x|) + (∑ x : Ω, (μ x - ν x)) = 2 * ∑ x : Ω, max (μ x - ν x) 0 := by rw [← Finset.sum_add_distrib, Finset.mul_sum] exact Finset.sum_congr rfl fun x _ => hpt x rw [hdiff, add_zero] at hsum unfold tvDist linarith /-- Exact overlap / minimum formula: `d_TV(μ, ν) = 1 - ∑_x min (μ x) (ν x)`. -/ theorem tvDist_eq_one_sub_sum_min (μ ν : Dist Ω) : tvDist μ ν = 1 - ∑ x : Ω, min (μ x) (ν x) := by rw [tvDist_eq_sum_pos] have hpt : ∀ x : Ω, max (μ x - ν x) 0 + min (μ x) (ν x) = μ x := fun x => by rcases le_total (μ x) (ν x) with h | h · rw [min_eq_left h, max_eq_right (by linarith)]; ring · rw [min_eq_right h, max_eq_left (by linarith)]; ring have hsum : (∑ x : Ω, max (μ x - ν x) 0) + (∑ x : Ω, min (μ x) (ν x)) = ∑ x : Ω, μ x := by rw [← Finset.sum_add_distrib] exact Finset.sum_congr rfl fun x _ => hpt x rw [μ.sum_one] at hsum linarith lemma tvDist_le_one (μ ν : Dist Ω) : tvDist μ ν ≤ 1 := by rw [tvDist_eq_one_sub_sum_min] have hnn : 0 ≤ ∑ x : Ω, min (μ x) (ν x) := Finset.sum_nonneg fun x _ => le_min (μ.nonneg x) (ν.nonneg x) linarith /-- Event-difference upper bound: `μ(A) - ν(A) ≤ d_TV(μ, ν)` for EVERY event `A`. -/ theorem event_sub_le_tvDist (μ ν : Dist Ω) (A : Finset Ω) : μ.prob A - ν.prob A ≤ tvDist μ ν := by rw [tvDist_eq_sum_pos] unfold Dist.prob rw [← Finset.sum_sub_distrib] calc ∑ x ∈ A, (μ x - ν x) ≤ ∑ x ∈ A, max (μ x - ν x) 0 := Finset.sum_le_sum fun x _ => le_max_left _ _ _ ≤ ∑ x : Ω, max (μ x - ν x) 0 := Finset.sum_le_univ_sum_of_nonneg fun x => le_max_right _ _ /-- Exact variational attainment: `∃ A, μ(A) - ν(A) = d_TV(μ, ν)` (at `A = {x | ν x ≤ μ x}`). -/ theorem exists_event_eq_tvDist (μ ν : Dist Ω) : ∃ A : Finset Ω, μ.prob A - ν.prob A = tvDist μ ν := by refine ⟨Finset.univ.filter (fun x => ν x ≤ μ x), ?_⟩ rw [tvDist_eq_sum_pos] unfold Dist.prob rw [← Finset.sum_sub_distrib, ← Finset.sum_filter_add_sum_filter_not Finset.univ (fun x => ν x ≤ μ x)] have h1 : ∑ x ∈ Finset.univ.filter (fun x => ν x ≤ μ x), max (μ x - ν x) 0 = ∑ x ∈ Finset.univ.filter (fun x => ν x ≤ μ x), (μ x - ν x) := by refine Finset.sum_congr rfl fun x hx => ?_ have hle : ν x ≤ μ x := (Finset.mem_filter.mp hx).2 exact max_eq_left (by linarith) have h2 : ∑ x ∈ Finset.univ.filter (fun x => ¬ ν x ≤ μ x), max (μ x - ν x) 0 = 0 := by refine Finset.sum_eq_zero fun x hx => ?_ have hgt : μ x < ν x := not_le.mp (Finset.mem_filter.mp hx).2 exact max_eq_right (by linarith) rw [h1, h2, add_zero] /-- Expectation-difference bound for bounded observables: `|E_μ[f] - E_ν[f]| ≤ 2 · M · d_TV(μ, ν)` whenever `|f(x)| ≤ M`. -/ theorem abs_expect_sub_le_tvDist (μ ν : Dist Ω) (f : Ω → ℝ) {M : ℝ} (hf : ∀ x, |f x| ≤ M) : |μ.expect f - ν.expect f| ≤ 2 * M * tvDist μ ν := by unfold Dist.expect tvDist rw [← Finset.sum_sub_distrib] calc |∑ x : Ω, (μ x * f x - ν x * f x)| ≤ ∑ x : Ω, |μ x * f x - ν x * f x| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ x : Ω, |μ x - ν x| * |f x| := Finset.sum_congr rfl fun x _ => by rw [← sub_mul, abs_mul] _ ≤ ∑ x : Ω, |μ x - ν x| * M := Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_left (hf x) (abs_nonneg _) _ = M * ∑ x : Ω, |μ x - ν x| := by rw [← Finset.sum_mul, mul_comm] _ = 2 * M * ((1 / 2 : ℝ) * ∑ x : Ω, |μ x - ν x|) := by ring /-- Data-processing / Markov contraction of total variation distance: `d_TV(μ P, ν P) ≤ d_TV(μ, ν)`. -/ theorem tvDist_push_le (K : MarkovKernel Ω) (μ ν : Dist Ω) : tvDist (K.push μ) (K.push ν) ≤ tvDist μ ν := by unfold tvDist refine mul_le_mul_of_nonneg_left ?_ (by norm_num) calc ∑ y : Ω, |K.push μ y - K.push ν y| = ∑ y : Ω, |∑ x : Ω, (μ x - ν x) * K.P x y| := by refine Finset.sum_congr rfl fun y _ => ?_ simp only [MarkovKernel.push, ← Finset.sum_sub_distrib, sub_mul] _ ≤ ∑ y : Ω, ∑ x : Ω, |(μ x - ν x) * K.P x y| := Finset.sum_le_sum fun y _ => Finset.abs_sum_le_sum_abs _ _ _ = ∑ y : Ω, ∑ x : Ω, |μ x - ν x| * K.P x y := by refine Finset.sum_congr rfl fun y _ => Finset.sum_congr rfl fun x _ => ?_ rw [abs_mul, abs_of_nonneg (K.nonneg x y)] _ = ∑ x : Ω, ∑ y : Ω, |μ x - ν x| * K.P x y := Finset.sum_comm _ = ∑ x : Ω, |μ x - ν x| * ∑ y : Ω, K.P x y := Finset.sum_congr rfl fun x _ => by rw [← Finset.mul_sum] _ = ∑ x : Ω, |μ x - ν x| := by simp_rw [K.row_sum_one, mul_one] /-- **Distinguishing Statistic Chebyshev Lower Bound**: for ANY observable `f` with `E_μ[f] ≠ E_ν[f]`, `d_TV(μ, ν) ≥ 1 - 4 · (Var_μ(f) + Var_ν(f)) / (E_μ[f] - E_ν[f])²`. -/ theorem tvDist_ge_distinguishing_chebyshev [DecidableEq Ω] (μ ν : Dist Ω) (f : Ω → ℝ) (hmean : μ.expect f ≠ ν.expect f) : 1 - 4 * (μ.variance f + ν.variance f) / (μ.expect f - ν.expect f) ^ 2 ≤ tvDist μ ν := by -- WLOG assume E_ν[f] < E_μ[f] (otherwise swap μ and ν via symmetry). wlog hlt : ν.expect f < μ.expect f generalizing μ ν · have hgt : μ.expect f < ν.expect f := lt_of_le_of_ne (not_lt.mp hlt) hmean have h := this ν μ (Ne.symm hmean) hgt rw [tvDist_symm] at h have heq : (ν.expect f - μ.expect f) ^ 2 = (μ.expect f - ν.expect f) ^ 2 := by ring rw [heq, add_comm] at h exact h set m := (μ.expect f + ν.expect f) / 2 set a := (μ.expect f - ν.expect f) / 2 have ha : 0 < a := by dsimp only [a]; linarith let A : Finset Ω := Finset.univ.filter (fun x => m ≤ f x) have h1 : ν.prob A ≤ ν.variance f / a ^ 2 := by have hsub : A ⊆ Finset.univ.filter (fun x => a ≤ |f x - ν.expect f|) := by intro x hx simp only [A, Finset.mem_filter, Finset.mem_univ, true_and] at hx ⊢ have hdiff : a ≤ f x - ν.expect f := by dsimp only [a, m] at *; linarith exact le_trans hdiff (le_abs_self _) exact le_trans (ν.prob_mono hsub) (ν.chebyshev_inequality f ha) have h2 : μ.prob Aᶜ ≤ μ.variance f / a ^ 2 := by have hsub : Aᶜ ⊆ Finset.univ.filter (fun x => a ≤ |f x - μ.expect f|) := by intro x hx simp only [A, Finset.mem_compl, Finset.mem_filter, Finset.mem_univ, true_and, not_le] at hx ⊢ have hdiff : a ≤ -(f x - μ.expect f) := by dsimp only [a, m] at *; linarith exact le_trans hdiff (neg_le_abs _) exact le_trans (μ.prob_mono hsub) (μ.chebyshev_inequality f ha) have hev := event_sub_le_tvDist μ ν A have hcomp : μ.prob A = 1 - μ.prob Aᶜ := by linarith [μ.prob_compl A] have ha2 : a ^ 2 = (μ.expect f - ν.expect f) ^ 2 / 4 := by dsimp only [a]; ring have hfrac : μ.variance f / a ^ 2 + ν.variance f / a ^ 2 = 4 * (μ.variance f + ν.variance f) / (μ.expect f - ν.expect f) ^ 2 := by rw [ha2]; field_simp [sub_ne_zero.mpr hmean] linarith /-! ### Fundamental Coupling Inequality & Exact Maximal Coupling Tightness -/ /-- A coupling of two distributions `μ, ν` on `Ω` is a joint distribution on `Ω × Ω` whose marginals are `μ` and `ν`. -/ structure Coupling (μ ν : Dist Ω) where γ : Ω → Ω → ℝ nonneg : ∀ x y, 0 ≤ γ x y fst_marginal : ∀ x, ∑ y : Ω, γ x y = μ x snd_marginal : ∀ y, ∑ x : Ω, γ x y = ν y namespace Coupling variable [DecidableEq Ω] /-- Probability of disagreement `P_γ(X ≠ Y) = ∑_{x ≠ y} γ(x, y)`. -/ def neqProb {μ ν : Dist Ω} (c : Coupling μ ν) : ℝ := ∑ x : Ω, ∑ y : Ω, if x ≠ y then c.γ x y else 0 /-- Probability of coalescence `P_γ(X = Y) = ∑_x γ(x, x)`. -/ def eqProb {μ ν : Dist Ω} (c : Coupling μ ν) : ℝ := ∑ x : Ω, c.γ x x lemma eqProb_add_neqProb {μ ν : Dist Ω} (c : Coupling μ ν) : c.eqProb + c.neqProb = 1 := by unfold eqProb neqProb have hrow : ∀ x : Ω, c.γ x x + ∑ y : Ω, (if x ≠ y then c.γ x y else 0) = μ x := fun x => by rw [← c.fst_marginal x] have hsplit : ∑ y : Ω, c.γ x y = (∑ y : Ω, if x = y then c.γ x y else 0) + (∑ y : Ω, if x ≠ y then c.γ x y else 0) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun y _ => by by_cases h : x = y <;> simp [h] rw [hsplit] have hdiag : (∑ y : Ω, if x = y then c.γ x y else 0) = c.γ x x := by simp rw [hdiag] calc (∑ x, c.γ x x) + ∑ x, ∑ y, (if x ≠ y then c.γ x y else 0) = ∑ x, (c.γ x x + ∑ y, (if x ≠ y then c.γ x y else 0)) := (Finset.sum_add_distrib).symm _ = ∑ x, μ x := Finset.sum_congr rfl fun x _ => hrow x _ = 1 := μ.sum_one omit [DecidableEq Ω] in lemma diag_le_min {μ ν : Dist Ω} (c : Coupling μ ν) (x : Ω) : c.γ x x ≤ min (μ x) (ν x) := by apply le_min · rw [← c.fst_marginal x] exact Finset.single_le_sum (fun y _ => c.nonneg x y) (Finset.mem_univ x) · rw [← c.snd_marginal x] exact Finset.single_le_sum (fun y _ => c.nonneg y x) (Finset.mem_univ x) end Coupling /-- **Fundamental Coupling Inequality**: for EVERY coupling `c` of `(μ, ν)`, `d_TV(μ, ν) ≤ P_c(X ≠ Y)`. -/ theorem fundamental_coupling_inequality [DecidableEq Ω] {μ ν : Dist Ω} (c : Coupling μ ν) : tvDist μ ν ≤ c.neqProb := by rw [tvDist_eq_one_sub_sum_min] have heq : c.eqProb ≤ ∑ x : Ω, min (μ x) (ν x) := Finset.sum_le_sum fun x _ => c.diag_le_min x linarith [c.eqProb_add_neqProb] /-- **Exact Maximal Coupling Theorem**: for ANY distributions `μ, ν`, there exists an explicit coupling achieving exact equality `P_c(X ≠ Y) = d_TV(μ, ν)`. -/ theorem exists_maximal_coupling [DecidableEq Ω] (μ ν : Dist Ω) : ∃ c : Coupling μ ν, c.neqProb = tvDist μ ν := by by_cases htv : tvDist μ ν = 0 · have hμν : μ = ν := (tvDist_eq_zero_iff μ ν).mp htv subst hμν refine ⟨{ γ := fun x y => if x = y then μ x else 0 nonneg := fun x y => by split_ifs; exact μ.nonneg x; norm_num fst_marginal := fun x => by simp snd_marginal := fun y => by simp }, ?_⟩ rw [htv] unfold Coupling.neqProb refine Finset.sum_eq_zero fun x _ => Finset.sum_eq_zero fun y _ => ?_ by_cases h : x = y <;> simp [h] · have hpos : 0 < tvDist μ ν := lt_of_le_of_ne (tvDist_nonneg μ ν) (Ne.symm htv) have hsum_pos : ∑ x : Ω, max (μ x - ν x) 0 = tvDist μ ν := (tvDist_eq_sum_pos μ ν).symm have hsum_neg : ∑ y : Ω, max (ν y - μ y) 0 = tvDist μ ν := by rw [tvDist_symm, tvDist_eq_sum_pos] let γ : Ω → Ω → ℝ := fun x y => (if x = y then min (μ x) (ν x) else 0) + max (μ x - ν x) 0 * max (ν y - μ y) 0 / tvDist μ ν have hnn : ∀ x y, 0 ≤ γ x y := fun x y => by dsimp only [γ] have h1 : 0 ≤ (if x = y then min (μ x) (ν x) else 0) := by split_ifs · exact le_min (μ.nonneg x) (ν.nonneg x) · norm_num have h2 : 0 ≤ max (μ x - ν x) 0 * max (ν y - μ y) 0 / tvDist μ ν := div_nonneg (mul_nonneg (le_max_right _ _) (le_max_right _ _)) (le_of_lt hpos) linarith have hfst : ∀ x, ∑ y : Ω, γ x y = μ x := fun x => by dsimp only [γ] rw [Finset.sum_add_distrib] have h1 : (∑ y : Ω, if x = y then min (μ x) (ν x) else 0) = min (μ x) (ν x) := by simp have h2 : ∑ y : Ω, max (μ x - ν x) 0 * max (ν y - μ y) 0 / tvDist μ ν = max (μ x - ν x) 0 := by simp_rw [mul_div_assoc, ← Finset.mul_sum, ← Finset.sum_div, hsum_neg, div_self (ne_of_gt hpos), mul_one] rw [h1, h2] rcases le_total (μ x) (ν x) with h | h · rw [min_eq_left h, max_eq_right (by linarith)]; ring · rw [min_eq_right h, max_eq_left (by linarith)]; ring have hsnd : ∀ y, ∑ x : Ω, γ x y = ν y := fun y => by dsimp only [γ] rw [Finset.sum_add_distrib] have h1 : (∑ x : Ω, if x = y then min (μ x) (ν x) else 0) = min (μ y) (ν y) := by simp have h2 : ∑ x : Ω, max (μ x - ν x) 0 * max (ν y - μ y) 0 / tvDist μ ν = max (ν y - μ y) 0 := by have hrew : ∀ x, max (μ x - ν x) 0 * max (ν y - μ y) 0 / tvDist μ ν = max (μ x - ν x) 0 * (max (ν y - μ y) 0 / tvDist μ ν) := fun x => mul_div_assoc _ _ _ simp_rw [hrew, ← Finset.sum_mul, hsum_pos] field_simp [ne_of_gt hpos] rw [h1, h2] rcases le_total (μ y) (ν y) with h | h · rw [min_eq_left h, max_eq_left (by linarith)]; ring · rw [min_eq_right h, max_eq_right (by linarith)]; ring let c : Coupling μ ν := ⟨γ, hnn, hfst, hsnd⟩ refine ⟨c, ?_⟩ have heq_diag : ∀ x, c.γ x x = min (μ x) (ν x) := fun x => by change γ x x = min (μ x) (ν x) dsimp only [γ] rw [if_pos rfl] have hzero : max (μ x - ν x) 0 * max (ν x - μ x) 0 = 0 := by rcases le_total (μ x) (ν x) with h | h · rw [max_eq_right (by linarith), zero_mul] · rw [max_eq_right (by linarith : ν x - μ x ≤ 0), mul_zero] rw [hzero, zero_div, add_zero] have hco : c.eqProb = ∑ x : Ω, min (μ x) (ν x) := Finset.sum_congr rfl fun x _ => heq_diag x rw [tvDist_eq_one_sub_sum_min] linarith [c.eqProb_add_neqProb] /-! ### Worst-Case Mixing Distance `d(t)`, Coupling Distance `d̄(t)` & Submultiplicativity -/ section MixingDistances variable [DecidableEq Ω] /-- Worst-case TV distance from stationarity: `d(t) = max_x d_TV(P^t(x, ·), π)`. -/ def dTVMax (K : MarkovKernel Ω) (π : Dist Ω) (hne : Nonempty Ω) (t : ℕ) : ℝ := Finset.sup' Finset.univ (Finset.univ_nonempty_iff.mpr hne) (fun x => tvDist (K.stepDist t x) π) /-- Worst-case pairwise TV distance: `d̄(t) = max_{x, y} d_TV(P^t(x, ·), P^t(y, ·))`. -/ def dBar (K : MarkovKernel Ω) (hne : Nonempty Ω) (t : ℕ) : ℝ := Finset.sup' Finset.univ (Finset.univ_nonempty_iff.mpr (show Nonempty (Ω × Ω) from ⟨(Classical.choice hne, Classical.choice hne)⟩)) (fun p : Ω × Ω => tvDist (K.stepDist t p.1) (K.stepDist t p.2)) lemma tvDist_step_le_dTVMax (K : MarkovKernel Ω) (π : Dist Ω) (hne : Nonempty Ω) (t : ℕ) (x : Ω) : tvDist (K.stepDist t x) π ≤ dTVMax K π hne t := Finset.le_sup' (fun z => tvDist (K.stepDist t z) π) (Finset.mem_univ x) lemma tvDist_pair_le_dBar (K : MarkovKernel Ω) (hne : Nonempty Ω) (t : ℕ) (x y : Ω) : tvDist (K.stepDist t x) (K.stepDist t y) ≤ dBar K hne t := Finset.le_sup' (fun p : Ω × Ω => tvDist (K.stepDist t p.1) (K.stepDist t p.2)) (Finset.mem_univ (x, y)) lemma dTVMax_nonneg (K : MarkovKernel Ω) (π : Dist Ω) (hne : Nonempty Ω) (t : ℕ) : 0 ≤ dTVMax K π hne t := le_trans (tvDist_nonneg _ _) (tvDist_step_le_dTVMax K π hne t (Classical.choice hne)) lemma dBar_nonneg (K : MarkovKernel Ω) (hne : Nonempty Ω) (t : ℕ) : 0 ≤ dBar K hne t := le_trans (tvDist_nonneg _ _) (tvDist_pair_le_dBar K hne t (Classical.choice hne) (Classical.choice hne)) /-- Convexity of TV distance in the first argument (for any stationary distribution `π`): `d_TV(μ P^t, π) ≤ d̄(t)` and `d(t) ≤ d̄(t) ≤ 2 d(t)`. -/ theorem tvDist_push_le_dBar_mul_tvDist (K : MarkovKernel Ω) (hne : Nonempty Ω) (t : ℕ) (μ ν : Dist Ω) : tvDist ((K.pow t).push μ) ((K.pow t).push ν) ≤ tvDist μ ν * dBar K hne t := by obtain ⟨c, hc⟩ := exists_maximal_coupling μ ν -- Express (μ P^t)(z) - (ν P^t)(z) = ∑_{x, y} c.γ(x, y) (P^t(x, z) - P^t(y, z))! have hdiff : ∀ z : Ω, ((K.pow t).push μ) z - ((K.pow t).push ν) z = ∑ x : Ω, ∑ y : Ω, c.γ x y * ((K.stepDist t x) z - (K.stepDist t y) z) := fun z => by simp only [MarkovKernel.push, MarkovKernel.stepDist, MarkovKernel.row, mul_sub, Finset.sum_sub_distrib] have h1 : ∑ x : Ω, ∑ y : Ω, c.γ x y * (K.pow t).P x z = ∑ x : Ω, μ x * (K.pow t).P x z := by refine Finset.sum_congr rfl fun x _ => by rw [← Finset.sum_mul, c.fst_marginal x] have h2 : ∑ x : Ω, ∑ y : Ω, c.γ x y * (K.pow t).P y z = ∑ y : Ω, ν y * (K.pow t).P y z := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun y _ => by rw [← Finset.sum_mul, c.snd_marginal y] rw [h1, h2] unfold tvDist calc (1 / 2 : ℝ) * ∑ z : Ω, |((K.pow t).push μ) z - ((K.pow t).push ν) z| = (1 / 2 : ℝ) * ∑ z : Ω, |∑ x : Ω, ∑ y : Ω, c.γ x y * ((K.stepDist t x) z - (K.stepDist t y) z)| := by congr 1; exact Finset.sum_congr rfl fun z _ => by rw [hdiff z] _ ≤ (1 / 2 : ℝ) * ∑ z : Ω, ∑ x : Ω, ∑ y : Ω, c.γ x y * |(K.stepDist t x) z - (K.stepDist t y) z| := by refine mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun z _ => ?_) (by norm_num) calc |∑ x, ∑ y, c.γ x y * ((K.stepDist t x) z - (K.stepDist t y) z)| ≤ ∑ x, |∑ y, c.γ x y * ((K.stepDist t x) z - (K.stepDist t y) z)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ x, ∑ y, |c.γ x y * ((K.stepDist t x) z - (K.stepDist t y) z)| := Finset.sum_le_sum fun x _ => Finset.abs_sum_le_sum_abs _ _ _ = ∑ x, ∑ y, c.γ x y * |(K.stepDist t x) z - (K.stepDist t y) z| := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ rw [abs_mul, abs_of_nonneg (c.nonneg x y)] _ = ∑ x : Ω, ∑ y : Ω, c.γ x y * tvDist (K.stepDist t x) (K.stepDist t y) := by rw [Finset.mul_sum] calc ∑ z, (1 / 2 : ℝ) * ∑ x, ∑ y, c.γ x y * |(K.stepDist t x) z - (K.stepDist t y) z| = ∑ z, ∑ x, ∑ y, (1 / 2 : ℝ) * (c.γ x y * |(K.stepDist t x) z - (K.stepDist t y) z|) := Finset.sum_congr rfl fun z _ => by simp_rw [Finset.mul_sum] _ = ∑ x, ∑ z, ∑ y, (1 / 2 : ℝ) * (c.γ x y * |(K.stepDist t x) z - (K.stepDist t y) z|) := Finset.sum_comm _ = ∑ x, ∑ y, ∑ z, (1 / 2 : ℝ) * (c.γ x y * |(K.stepDist t x) z - (K.stepDist t y) z|) := Finset.sum_congr rfl fun x _ => Finset.sum_comm _ = ∑ x, ∑ y, c.γ x y * ((1 / 2 : ℝ) * ∑ z, |(K.stepDist t x) z - (K.stepDist t y) z|) := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ rw [Finset.mul_sum, Finset.mul_sum] exact Finset.sum_congr rfl fun z _ => by ring _ ≤ ∑ x : Ω, ∑ y : Ω, (if x ≠ y then c.γ x y else 0) * dBar K hne t := by refine Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun y _ => ?_ by_cases hxy : x = y · subst hxy; simp [tvDist_self] · rw [if_pos hxy] exact mul_le_mul_of_nonneg_left (tvDist_pair_le_dBar K hne t x y) (c.nonneg x y) _ = c.neqProb * dBar K hne t := by unfold Coupling.neqProb simp_rw [← Finset.sum_mul] _ = ((1 / 2 : ℝ) * ∑ x : Ω, |μ x - ν x|) * dBar K hne t := by rw [hc]; rfl /-- Sandwich `d(t) ≤ d̄(t) ≤ 2 d(t)` for any stationary distribution `π`. -/ theorem dTVMax_le_dBar_and_dBar_le_two_dTVMax (K : MarkovKernel Ω) {π : Dist Ω} (hπ : K.IsStationary π) (hne : Nonempty Ω) (t : ℕ) : dTVMax K π hne t ≤ dBar K hne t ∧ dBar K hne t ≤ 2 * dTVMax K π hne t := by constructor · apply Finset.sup'_le intro x _ have hstat := K.isStationary_pow hπ t have h1 := tvDist_push_le_dBar_mul_tvDist K hne t (Dist.dirac x) π rw [MarkovKernel.push_dirac, hstat] at h1 change tvDist (K.stepDist t x) π ≤ tvDist (Dist.dirac x) π * dBar K hne t at h1 exact le_trans h1 (mul_le_of_le_one_left (dBar_nonneg K hne t) (tvDist_le_one _ _)) · apply Finset.sup'_le intro p _ calc tvDist (K.stepDist t p.1) (K.stepDist t p.2) ≤ tvDist (K.stepDist t p.1) π + tvDist π (K.stepDist t p.2) := tvDist_triangle _ _ _ _ = tvDist (K.stepDist t p.1) π + tvDist (K.stepDist t p.2) π := by rw [tvDist_symm π] _ ≤ dTVMax K π hne t + dTVMax K π hne t := add_le_add (tvDist_step_le_dTVMax K π hne t p.1) (tvDist_step_le_dTVMax K π hne t p.2) _ = 2 * dTVMax K π hne t := by ring /-- **Submultiplicativity of `d̄(t)`**: `d̄(s + t) ≤ d̄(s) · d̄(t)`. -/ theorem dBar_submultiplicative (K : MarkovKernel Ω) (hne : Nonempty Ω) (s t : ℕ) : dBar K hne (s + t) ≤ dBar K hne s * dBar K hne t := by apply Finset.sup'_le intro p _ rw [K.stepDist_add s t p.1, K.stepDist_add s t p.2] calc tvDist ((K.pow t).push (K.stepDist s p.1)) ((K.pow t).push (K.stepDist s p.2)) ≤ tvDist (K.stepDist s p.1) (K.stepDist s p.2) * dBar K hne t := tvDist_push_le_dBar_mul_tvDist K hne t _ _ _ ≤ dBar K hne s * dBar K hne t := mul_le_mul_of_nonneg_right (tvDist_pair_le_dBar K hne s p.1 p.2) (dBar_nonneg K hne t) /-- **Submultiplicativity of `d(t)`**: `d(s + t) ≤ 2 · d(s) · d(t)`. -/ theorem dTVMax_submultiplicative (K : MarkovKernel Ω) {π : Dist Ω} (hπ : K.IsStationary π) (hne : Nonempty Ω) (s t : ℕ) : dTVMax K π hne (s + t) ≤ 2 * dTVMax K π hne s * dTVMax K π hne t := by apply Finset.sup'_le intro x _ have hstat : (K.pow t).push π = π := K.isStationary_pow hπ t have h1 := tvDist_push_le_dBar_mul_tvDist K hne t (K.stepDist s x) π have h2 := (dTVMax_le_dBar_and_dBar_le_two_dTVMax K hπ hne t).2 calc tvDist (K.stepDist (s + t) x) π = tvDist ((K.pow t).push (K.stepDist s x)) ((K.pow t).push π) := by rw [K.stepDist_add s t x, hstat] _ ≤ tvDist (K.stepDist s x) π * dBar K hne t := h1 _ ≤ dTVMax K π hne s * (2 * dTVMax K π hne t) := mul_le_mul (tvDist_step_le_dTVMax K π hne s x) h2 (dBar_nonneg K hne t) (dTVMax_nonneg K π hne s) _ = 2 * dTVMax K π hne s * dTVMax K π hne t := by ring /-- Monotonicity of `d(t)` and `d̄(t)` in `t`. -/ theorem dTVMax_antitone (K : MarkovKernel Ω) {π : Dist Ω} (hπ : K.IsStationary π) (hne : Nonempty Ω) (t : ℕ) : dTVMax K π hne (t + 1) ≤ dTVMax K π hne t := by apply Finset.sup'_le intro x _ calc tvDist (K.stepDist (t + 1) x) π = tvDist (K.push (K.stepDist t x)) (K.push π) := by rw [K.stepDist_succ t x, hπ] _ ≤ tvDist (K.stepDist t x) π := tvDist_push_le K _ _ _ ≤ dTVMax K π hne t := tvDist_step_le_dTVMax K π hne t x theorem dBar_antitone (K : MarkovKernel Ω) (hne : Nonempty Ω) (t : ℕ) : dBar K hne (t + 1) ≤ dBar K hne t := by apply Finset.sup'_le intro p _ rw [K.stepDist_succ t p.1, K.stepDist_succ t p.2] exact le_trans (tvDist_push_le K _ _) (tvDist_pair_le_dBar K hne t p.1 p.2) /-- Iterated submultiplicativity: `d(k · t) ≤ (2 · d(t))^k / 2` (for `k ≥ 1`). -/ theorem dTVMax_mul_le_pow (K : MarkovKernel Ω) {π : Dist Ω} (hπ : K.IsStationary π) (hne : Nonempty Ω) (t : ℕ) : ∀ k : ℕ, 1 ≤ k → dTVMax K π hne (k * t) ≤ (2 * dTVMax K π hne t) ^ k / 2 | 0, hk => by omega | 1, _ => by simp | k + 2, _ => by have ih := dTVMax_mul_le_pow K hπ hne t (k + 1) (by omega) have hmul : (k + 2) * t = (k + 1) * t + t := by ring rw [hmul] calc dTVMax K π hne ((k + 1) * t + t) ≤ 2 * dTVMax K π hne ((k + 1) * t) * dTVMax K π hne t := dTVMax_submultiplicative K hπ hne ((k + 1) * t) t _ ≤ 2 * ((2 * dTVMax K π hne t) ^ (k + 1) / 2) * dTVMax K π hne t := by have hnn := dTVMax_nonneg K π hne t nlinarith _ = (2 * dTVMax K π hne t) ^ (k + 2) / 2 := by ring /-! ### Separation Distance, Reversible Doubling & Aldous–Diaconis Strong Stationary Times -/ /-- Separation distance `s(μ, π) = max_y (1 - μ(y) / π(y))` for strictly positive `π`. -/ noncomputable def sepDist (μ π : Dist Ω) (hne : Nonempty Ω) : ℝ := Finset.sup' Finset.univ (Finset.univ_nonempty_iff.mpr hne) (fun y => 1 - μ y / π y) /-- Worst-case separation distance `s(t) = max_x s(P^t(x, ·), π)`. -/ noncomputable def sepMax (K : MarkovKernel Ω) (π : Dist Ω) (hne : Nonempty Ω) (t : ℕ) : ℝ := Finset.sup' Finset.univ (Finset.univ_nonempty_iff.mpr hne) (fun x => sepDist (K.stepDist t x) π hne) omit [DecidableEq Ω] in lemma sepDist_ge_pointwise (μ π : Dist Ω) (hne : Nonempty Ω) (y : Ω) : 1 - μ y / π y ≤ sepDist μ π hne := Finset.le_sup' (fun z => 1 - μ z / π z) (Finset.mem_univ y) omit [DecidableEq Ω] in theorem sepDist_nonneg (μ π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) : 0 ≤ sepDist μ π hne := by by_contra hlt push Not at hlt have hgt : ∀ y, π y < μ y := fun y => by have h1 := lt_of_le_of_lt (sepDist_ge_pointwise μ π hne y) hlt have h2 : 1 < μ y / π y := by linarith exact (one_lt_div (hπ_pos y)).mp h2 have hsum : ∑ y : Ω, π y < ∑ y : Ω, μ y := Finset.sum_lt_sum_of_nonempty (Finset.univ_nonempty_iff.mpr hne) (fun y _ => hgt y) rw [π.sum_one, μ.sum_one] at hsum exact lt_irrefl 1 hsum omit [DecidableEq Ω] in theorem sepDist_le_one (μ π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) : sepDist μ π hne ≤ 1 := by apply Finset.sup'_le intro y _ have : 0 ≤ μ y / π y := div_nonneg (μ.nonneg y) (le_of_lt (hπ_pos y)) linarith omit [DecidableEq Ω] in /-- Separation distance dominates total variation distance: `d_TV(μ, π) ≤ s(μ, π)`. -/ theorem tvDist_le_sepDist (μ π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) : tvDist μ π ≤ sepDist μ π hne := by rw [tvDist_symm, tvDist_eq_sum_pos] calc ∑ y : Ω, max (π y - μ y) 0 ≤ ∑ y : Ω, π y * sepDist μ π hne := by refine Finset.sum_le_sum fun y _ => ?_ apply max_le · have h1 := sepDist_ge_pointwise μ π hne y have h2 : (1 - μ y / π y) * π y ≤ sepDist μ π hne * π y := mul_le_mul_of_nonneg_right h1 (le_of_lt (hπ_pos y)) have h3 : (1 - μ y / π y) * π y = π y - μ y := by field_simp [ne_of_gt (hπ_pos y)] linarith · exact mul_nonneg (le_of_lt (hπ_pos y)) (sepDist_nonneg μ π hπ_pos hne) _ = (∑ y : Ω, π y) * sepDist μ π hne := (Finset.sum_mul ..).symm _ = sepDist μ π hne := by rw [π.sum_one, one_mul] omit [DecidableEq Ω] in /-- Separation distance is non-increasing under a Markov step with stationary `π`. -/ theorem sepDist_push_le (K : MarkovKernel Ω) (μ π : Dist Ω) (hπ : K.IsStationary π) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) : sepDist (K.push μ) π hne ≤ sepDist μ π hne := by apply Finset.sup'_le intro y _ have hlow : ∀ x, (1 - sepDist μ π hne) * π x ≤ μ x := fun x => by have h1 := sepDist_ge_pointwise μ π hne x have h2 : (1 - sepDist μ π hne) * π x ≤ (μ x / π x) * π x := mul_le_mul_of_nonneg_right (by linarith) (le_of_lt (hπ_pos x)) rwa [div_mul_cancel₀ _ (ne_of_gt (hπ_pos x))] at h2 have hpush_ge : (1 - sepDist μ π hne) * π y ≤ K.push μ y := by have hstat : ∑ x : Ω, π x * K.P x y = π y := by have := congrFun (congrArg Dist.p hπ) y simpa [MarkovKernel.push] using this calc (1 - sepDist μ π hne) * π y = (1 - sepDist μ π hne) * ∑ x : Ω, π x * K.P x y := by rw [hstat] _ = ∑ x : Ω, ((1 - sepDist μ π hne) * π x) * K.P x y := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun x _ => by ring _ ≤ ∑ x : Ω, μ x * K.P x y := Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_right (hlow x) (K.nonneg x y) have hdiv : 1 - sepDist μ π hne ≤ K.push μ y / π y := (le_div_iff₀ (hπ_pos y)).mpr hpush_ge linarith /-- Reversibility (detailed balance): `π(x) P(x, y) = π(y) P(y, x)`. -/ def MarkovKernel.IsReversible (K : MarkovKernel Ω) (π : Dist Ω) : Prop := ∀ x y, π x * K.P x y = π y * K.P y x omit [DecidableEq Ω] in lemma MarkovKernel.IsReversible.isStationary {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) : K.IsStationary π := by ext y simp only [MarkovKernel.push] calc ∑ x : Ω, π x * K.P x y = ∑ x : Ω, π y * K.P y x := Finset.sum_congr rfl fun x _ => hrev x y _ = π y * ∑ x : Ω, K.P y x := (Finset.mul_sum ..).symm _ = π y := by rw [K.row_sum_one y, mul_one] lemma MarkovKernel.IsReversible.pow {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (t : ℕ) : (K.pow t).IsReversible π := by induction t with | zero => intro x y; simp only [MarkovKernel.pow, MarkovKernel.id] by_cases h : x = y <;> simp [h, eq_comm] | succ t ih => intro x z simp only [MarkovKernel.pow, MarkovKernel.comp, Finset.mul_sum] calc ∑ y : Ω, π x * (K.P x y * (K.pow t).P y z) = ∑ y : Ω, (π x * K.P x y) * (K.pow t).P y z := Finset.sum_congr rfl fun y _ => by ring _ = ∑ y : Ω, (π y * K.P y x) * (K.pow t).P y z := Finset.sum_congr rfl fun y _ => by rw [hrev x y] _ = ∑ y : Ω, (π y * (K.pow t).P y z) * K.P y x := Finset.sum_congr rfl fun y _ => by ring _ = ∑ y : Ω, (π z * (K.pow t).P z y) * K.P y x := Finset.sum_congr rfl fun y _ => by rw [ih y z] _ = ∑ y : Ω, π z * ((K.pow t).P z y * K.P y x) := Finset.sum_congr rfl fun y _ => by ring _ = π z * ((K.pow t).comp K).P z x := by rw [← Finset.mul_sum]; rfl _ = π z * (K.pow (t + 1)).P z x := by rw [← K.pow_succ_right t] _ = ∑ y : Ω, π z * (K.P z y * (K.pow t).P y x) := by simp only [MarkovKernel.pow, MarkovKernel.comp, Finset.mul_sum] /-- **Reversible Separation Doubling Bound** (Aldous–Diaconis / LPW Lemma 6.17): for every reversible Markov chain with strictly positive stationary distribution `π`, `s(2t) ≤ 1 - (1 - d̄(t))²`. -/ theorem reversible_sepMax_two_mul_le (K : MarkovKernel Ω) {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) (t : ℕ) : sepMax K π hne (2 * t) ≤ 1 - (1 - dBar K hne t) ^ 2 := by have hrev_t := hrev.pow t apply Finset.sup'_le; intro x _ apply Finset.sup'_le; intro y _ -- Step 1: By reversibility, P^{2t}(x, y) / π(y) = ∑_z P^t(x, z) P^t(y, z) / π(z). have hratio : (K.stepDist (2 * t) x) y / π y = ∑ z : Ω, (K.stepDist t x) z * (K.stepDist t y) z / π z := by have h2t : 2 * t = t + t := two_mul t simp only [MarkovKernel.stepDist, MarkovKernel.row, h2t, K.pow_add t t, MarkovKernel.comp] rw [Finset.sum_div] refine Finset.sum_congr rfl fun z _ => ?_ have hrz := hrev_t z y have hπy := ne_of_gt (hπ_pos y) have hπz := ne_of_gt (hπ_pos z) field_simp [hπy, hπz] calc (K.pow t).P x z * (K.pow t).P z y * π z = (K.pow t).P x z * (π z * (K.pow t).P z y) := by ring _ = (K.pow t).P x z * (π y * (K.pow t).P y z) := by rw [hrz] _ = (K.pow t).P x z * π y * (K.pow t).P y z := by ring -- Step 2: Cauchy–Schwarz on m(z) = min (P^t(x, z)) (P^t(y, z)). let m : Ω → ℝ := fun z => min ((K.stepDist t x) z) ((K.stepDist t y) z) have hm_nn : ∀ z, 0 ≤ m z := fun z => le_min ((K.stepDist t x).nonneg z) ((K.stepDist t y).nonneg z) have hcs : (∑ z : Ω, m z) ^ 2 ≤ (∑ z : Ω, π z) * (∑ z : Ω, m z ^ 2 / π z) := by have h := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ (fun z : Ω => Real.sqrt (π z)) (fun z : Ω => m z / Real.sqrt (π z)) have hlhs : ∑ z : Ω, Real.sqrt (π z) * (m z / Real.sqrt (π z)) = ∑ z : Ω, m z := by refine Finset.sum_congr rfl fun z _ => ?_ have hsq : Real.sqrt (π z) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos z)) field_simp [hsq] have hr1 : ∑ z : Ω, Real.sqrt (π z) ^ 2 = ∑ z : Ω, π z := Finset.sum_congr rfl fun z _ => Real.sq_sqrt (le_of_lt (hπ_pos z)) have hr2 : ∑ z : Ω, (m z / Real.sqrt (π z)) ^ 2 = ∑ z : Ω, m z ^ 2 / π z := Finset.sum_congr rfl fun z _ => by rw [div_pow, Real.sq_sqrt (le_of_lt (hπ_pos z))] rwa [hlhs, hr1, hr2] at h rw [π.sum_one, one_mul] at hcs have hprod_ge : ∑ z : Ω, m z ^ 2 / π z ≤ ∑ z : Ω, (K.stepDist t x) z * (K.stepDist t y) z / π z := by refine Finset.sum_le_sum fun z _ => div_le_div_of_nonneg_right ?_ (le_of_lt (hπ_pos z)) have h1 : m z ≤ (K.stepDist t x) z := min_le_left _ _ have h2 : m z ≤ (K.stepDist t y) z := min_le_right _ _ nlinarith [hm_nn z] have hoverlap : 1 - dBar K hne t ≤ ∑ z : Ω, m z := by have htv := tvDist_eq_one_sub_sum_min (K.stepDist t x) (K.stepDist t y) have hle := tvDist_pair_le_dBar K hne t x y dsimp only [m] linarith have hdbar_le_one : dBar K hne t ≤ 1 := by apply Finset.sup'_le; intro p _; exact tvDist_le_one _ _ have hsq_le : (1 - dBar K hne t) ^ 2 ≤ (∑ z : Ω, m z) ^ 2 := by nlinarith [sub_nonneg.mpr hdbar_le_one] linarith /-- Corollary: for reversible chains, `s(2t) ≤ 2 d̄(t) ≤ 4 d(t)`. -/ theorem reversible_sepMax_two_mul_le_four_dTVMax (K : MarkovKernel Ω) {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) (t : ℕ) : sepMax K π hne (2 * t) ≤ 4 * dTVMax K π hne t := by have h1 := reversible_sepMax_two_mul_le K hrev hπ_pos hne t have h2 := (dTVMax_le_dBar_and_dBar_le_two_dTVMax K hrev.isStationary hne t).2 have hsq : 0 ≤ dBar K hne t ^ 2 := sq_nonneg _ linarith /-- **Aldous–Diaconis Strong Stationary Time (SST)** witness at time `t` starting from `x`: a stopping probability `pStop = P(τ ≤ t) ∈ [0, 1]` and nonnegative residual sub-distribution `r` such that `P^t(x, y) = pStop · π(y) + r(y)` (equivalently, `X_t | {τ ≤ t} ~ π`). -/ structure StrongStationaryWitness (K : MarkovKernel Ω) (π : Dist Ω) (x : Ω) (t : ℕ) where pTail : ℝ pTail_nonneg : 0 ≤ pTail pTail_le_one : pTail ≤ 1 residual : Ω → ℝ residual_nonneg : ∀ y, 0 ≤ residual y decomp : ∀ y, (K.stepDist t x) y = (1 - pTail) * π y + residual y /-- **Aldous–Diaconis Strong Stationary Time Theorem**: for ANY strong stationary time witness `τ` at horizon `t`, `d_TV(P^t(x, ·), π) ≤ s(P^t(x, ·), π) ≤ P(τ > t)`. -/ theorem strong_stationary_time_bound {K : MarkovKernel Ω} {π : Dist Ω} {x : Ω} {t : ℕ} (hπ_pos : ∀ y, 0 < π y) (hne : Nonempty Ω) (w : StrongStationaryWitness K π x t) : tvDist (K.stepDist t x) π ≤ sepDist (K.stepDist t x) π hne ∧ sepDist (K.stepDist t x) π hne ≤ w.pTail := by refine ⟨tvDist_le_sepDist _ π hπ_pos hne, ?_⟩ apply Finset.sup'_le intro y _ have hge : (1 - w.pTail) * π y ≤ (K.stepDist t x) y := by rw [w.decomp y]; linarith [w.residual_nonneg y] have hdiv : 1 - w.pTail ≤ (K.stepDist t x) y / π y := (le_div_iff₀ (hπ_pos y)).mpr hge linarith /-- **Sharpness / Converse of Aldous–Diaconis**: separation distance `s(P^t(x, ·), π)` is ALWAYS attained by an exact strong stationary decomposition with `pTail = s(P^t(x, ·), π)`. -/ theorem exists_optimal_strong_stationary_witness (K : MarkovKernel Ω) (π : Dist Ω) (hπ_pos : ∀ y, 0 < π y) (hne : Nonempty Ω) (x : Ω) (t : ℕ) : ∃ w : StrongStationaryWitness K π x t, w.pTail = sepDist (K.stepDist t x) π hne := by let s := sepDist (K.stepDist t x) π hne refine ⟨{ pTail := s pTail_nonneg := sepDist_nonneg _ π hπ_pos hne pTail_le_one := sepDist_le_one _ π hπ_pos hne residual := fun y => (K.stepDist t x) y - (1 - s) * π y residual_nonneg := fun y => by have h1 : 1 - (K.stepDist t x) y / π y ≤ s := sepDist_ge_pointwise _ π hne y have h2 : (1 - s) * π y ≤ ((K.stepDist t x) y / π y) * π y := mul_le_mul_of_nonneg_right (by linarith) (le_of_lt (hπ_pos y)) rw [div_mul_cancel₀ _ (ne_of_gt (hπ_pos y))] at h2 linarith decomp := fun y => by ring }, rfl⟩ end MixingDistances end Pillar1_TVCouplingSST /-! ============================================================================ PILLAR 2: REVERSIBLE SPECTRAL GAP, RELAXATION TIME & MIXING TIME SANDWICHES ============================================================================ -/ section Pillar2_SpectralGap variable {Ω : Type*} [Fintype Ω] /-- `L^2(π)` inner product `⟨f, g⟩_π = ∑_x π(x) f(x) g(x)`. -/ def l2Inner (π : Dist Ω) (f g : Ω → ℝ) : ℝ := ∑ x : Ω, π x * f x * g x /-- `L^2(π)` norm squared `‖f‖²_{L^2(π)} = ∑_x π(x) f(x)²`. -/ def l2NormSq (π : Dist Ω) (f : Ω → ℝ) : ℝ := l2Inner π f f /-- Dirichlet form `E(f, f) = (1/2) ∑_{x, y} π(x) P(x, y) (f(x) - f(y))²`. -/ def dirichletForm (K : MarkovKernel Ω) (π : Dist Ω) (f : Ω → ℝ) : ℝ := (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * (f x - f y) ^ 2 /-- Chi-square divergence `χ²(μ, π) = ∑_y (μ(y) - π(y))² / π(y)`. -/ noncomputable def chi2Dist (μ π : Dist Ω) : ℝ := ∑ y : Ω, (μ y - π y) ^ 2 / π y lemma l2Inner_comm (π : Dist Ω) (f g : Ω → ℝ) : l2Inner π f g = l2Inner π g f := Finset.sum_congr rfl fun x _ => by ring lemma l2NormSq_nonneg (π : Dist Ω) (f : Ω → ℝ) : 0 ≤ l2NormSq π f := Finset.sum_nonneg fun x _ => by have : π x * f x * f x = π x * f x ^ 2 := by ring rw [this]; exact mul_nonneg (π.nonneg x) (sq_nonneg _) lemma dirichletForm_nonneg (K : MarkovKernel Ω) (π : Dist Ω) (f : Ω → ℝ) : 0 ≤ dirichletForm K π f := mul_nonneg (by norm_num) (Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => mul_nonneg (mul_nonneg (π.nonneg x) (K.nonneg x y)) (sq_nonneg _)) lemma chi2Dist_nonneg (μ π : Dist Ω) (hπ_pos : ∀ y, 0 < π y) : 0 ≤ chi2Dist μ π := Finset.sum_nonneg fun y _ => div_nonneg (sq_nonneg _) (le_of_lt (hπ_pos y)) lemma chi2Dist_eq_sum_sq_sub_one (μ π : Dist Ω) (hπ_pos : ∀ y, 0 < π y) : chi2Dist μ π = (∑ y : Ω, μ y ^ 2 / π y) - 1 := by unfold chi2Dist have hpt : ∀ y : Ω, (μ y - π y) ^ 2 / π y = μ y ^ 2 / π y - 2 * μ y + π y := fun y => by field_simp [ne_of_gt (hπ_pos y)]; ring simp_rw [hpt, Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum, μ.sum_one, π.sum_one] ring /-- **Exact `L^2`-to-TV Cauchy–Schwarz Inequality**: `4 · d_TV(μ, π)² ≤ χ²(μ, π)`. -/ theorem four_tvDist_sq_le_chi2 (μ π : Dist Ω) (hπ_pos : ∀ y, 0 < π y) : 4 * (tvDist μ π) ^ 2 ≤ chi2Dist μ π := by have hcs := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ (fun y : Ω => Real.sqrt (π y)) (fun y : Ω => |μ y - π y| / Real.sqrt (π y)) have hlhs : ∑ y : Ω, Real.sqrt (π y) * (|μ y - π y| / Real.sqrt (π y)) = ∑ y : Ω, |μ y - π y| := by refine Finset.sum_congr rfl fun y _ => ?_ have hsq : Real.sqrt (π y) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) field_simp [hsq] have hr1 : ∑ y : Ω, Real.sqrt (π y) ^ 2 = 1 := by calc ∑ y : Ω, Real.sqrt (π y) ^ 2 = ∑ y : Ω, π y := Finset.sum_congr rfl fun y _ => Real.sq_sqrt (le_of_lt (hπ_pos y)) _ = 1 := π.sum_one have hr2 : ∑ y : Ω, (|μ y - π y| / Real.sqrt (π y)) ^ 2 = chi2Dist μ π := by unfold chi2Dist refine Finset.sum_congr rfl fun y _ => ?_ rw [div_pow, sq_abs, Real.sq_sqrt (le_of_lt (hπ_pos y))] rw [hlhs, hr1, hr2, one_mul] at hcs have htv : 4 * (tvDist μ π) ^ 2 = (∑ y : Ω, |μ y - π y|) ^ 2 := by unfold tvDist; ring linarith /-- Self-adjointness of a reversible Markov operator `P` in `L^2(π)`: `⟨P f, g⟩_π = ⟨f, P g⟩_π`. -/ theorem l2Inner_apply_selfAdjoint {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (f g : Ω → ℝ) : l2Inner π (K.apply f) g = l2Inner π f (K.apply g) := by unfold l2Inner MarkovKernel.apply calc ∑ x, π x * (∑ y, K.P x y * f y) * g x = ∑ x, ∑ y, (π x * K.P x y) * f y * g x := Finset.sum_congr rfl fun x _ => by rw [Finset.mul_sum, Finset.sum_mul] exact Finset.sum_congr rfl fun y _ => by ring _ = ∑ x, ∑ y, (π y * K.P y x) * f y * g x := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by rw [hrev x y] _ = ∑ y, ∑ x, (π y * K.P y x) * f y * g x := Finset.sum_comm _ = ∑ y, π y * f y * (∑ x, K.P y x * g x) := Finset.sum_congr rfl fun y _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun x _ => by ring /-- Exact Dirichlet form identity for reversible chains: `E(f, f) = ⟨(I - P) f, f⟩_π = ‖f‖²_{L^2(π)} - ⟨P f, f⟩_π`. -/ theorem dirichletForm_eq_l2Inner_sub {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (f : Ω → ℝ) : dirichletForm K π f = l2NormSq π f - l2Inner π (K.apply f) f := by unfold dirichletForm l2NormSq l2Inner MarkovKernel.apply have hexp : ∑ x, ∑ y, π x * K.P x y * (f x - f y) ^ 2 = (∑ x, ∑ y, π x * K.P x y * f x ^ 2) + (∑ x, ∑ y, π x * K.P x y * f y ^ 2) - 2 * (∑ x, ∑ y, π x * K.P x y * f x * f y) := by have hpt : ∀ x y : Ω, π x * K.P x y * (f x - f y) ^ 2 = π x * K.P x y * f x ^ 2 + π x * K.P x y * f y ^ 2 - 2 * (π x * K.P x y * f x * f y) := fun x y => by ring simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum] have h1 : ∑ x, ∑ y, π x * K.P x y * f x ^ 2 = ∑ x, π x * f x * f x := by refine Finset.sum_congr rfl fun x _ => ?_ have : ∑ y, π x * K.P x y * f x ^ 2 = (π x * f x ^ 2) * ∑ y, K.P x y := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun y _ => by ring rw [this, K.row_sum_one x]; ring have h2 : ∑ x, ∑ y, π x * K.P x y * f y ^ 2 = ∑ y, π y * f y * f y := by calc ∑ x, ∑ y, π x * K.P x y * f y ^ 2 = ∑ x, ∑ y, π y * K.P y x * f y ^ 2 := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by rw [hrev x y] _ = ∑ y, ∑ x, π y * K.P y x * f y ^ 2 := Finset.sum_comm _ = ∑ y, π y * f y * f y := by refine Finset.sum_congr rfl fun y _ => ?_ have : ∑ x, π y * K.P y x * f y ^ 2 = (π y * f y ^ 2) * ∑ x, K.P y x := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun x _ => by ring rw [this, K.row_sum_one y]; ring have h3 : ∑ x, ∑ y, π x * K.P x y * f x * f y = ∑ x, π x * (∑ y, K.P x y * f y) * f x := by refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum, Finset.sum_mul] exact Finset.sum_congr rfl fun y _ => by ring rw [hexp, h1, h2, h3] ring /-- `L^2(π)` contraction of any Markov operator: `|⟨P f, f⟩_π| ≤ ‖f‖²_{L^2(π)}`. -/ theorem abs_l2Inner_apply_le_l2NormSq {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (f : Ω → ℝ) : |l2Inner π (K.apply f) f| ≤ l2NormSq π f := by have hplus : 0 ≤ l2NormSq π f + l2Inner π (K.apply f) f := by have hid : l2NormSq π f + l2Inner π (K.apply f) f = (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * (f x + f y) ^ 2 := by unfold l2NormSq l2Inner MarkovKernel.apply have hexp : ∑ x, ∑ y, π x * K.P x y * (f x + f y) ^ 2 = (∑ x, ∑ y, π x * K.P x y * f x ^ 2) + (∑ x, ∑ y, π x * K.P x y * f y ^ 2) + 2 * (∑ x, ∑ y, π x * K.P x y * f x * f y) := by have hpt : ∀ x y : Ω, π x * K.P x y * (f x + f y) ^ 2 = π x * K.P x y * f x ^ 2 + π x * K.P x y * f y ^ 2 + 2 * (π x * K.P x y * f x * f y) := fun x y => by ring simp_rw [hpt, Finset.sum_add_distrib, ← Finset.mul_sum] have h1 : ∑ x, ∑ y, π x * K.P x y * f x ^ 2 = ∑ x, π x * f x * f x := by refine Finset.sum_congr rfl fun x _ => ?_ have : ∑ y, π x * K.P x y * f x ^ 2 = (π x * f x ^ 2) * ∑ y, K.P x y := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun y _ => by ring rw [this, K.row_sum_one x]; ring have h2 : ∑ x, ∑ y, π x * K.P x y * f y ^ 2 = ∑ y, π y * f y * f y := by calc ∑ x, ∑ y, π x * K.P x y * f y ^ 2 = ∑ x, ∑ y, π y * K.P y x * f y ^ 2 := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by rw [hrev x y] _ = ∑ y, ∑ x, π y * K.P y x * f y ^ 2 := Finset.sum_comm _ = ∑ y, π y * f y * f y := by refine Finset.sum_congr rfl fun y _ => ?_ have : ∑ x, π y * K.P y x * f y ^ 2 = (π y * f y ^ 2) * ∑ x, K.P y x := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun x _ => by ring rw [this, K.row_sum_one y]; ring have h3 : ∑ x, ∑ y, π x * K.P x y * f x * f y = ∑ x, π x * (∑ y, K.P x y * f y) * f x := by refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum, Finset.sum_mul] exact Finset.sum_congr rfl fun y _ => by ring rw [hexp, h1, h2, h3]; ring rw [hid] exact mul_nonneg (by norm_num) (Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => mul_nonneg (mul_nonneg (π.nonneg x) (K.nonneg x y)) (sq_nonneg _)) have hminus : 0 ≤ l2NormSq π f - l2Inner π (K.apply f) f := by rw [← dirichletForm_eq_l2Inner_sub hrev f]; exact dirichletForm_nonneg K π f exact abs_le.mpr ⟨by linarith, by linarith⟩ /-! ### Symmetric Similarity Matrix `S = D_π^{1/2} P D_π^{-1/2}` & Spectral Diagonalization -/ section SymMatSpectrum variable [DecidableEq Ω] /-- Symmetric similarity matrix `S(x, y) = √π(x) P(x, y) / √π(y)` of a reversible kernel. -/ noncomputable def symMat (K : MarkovKernel Ω) (π : Dist Ω) : Matrix Ω Ω ℝ := Matrix.of fun x y => Real.sqrt (π x) * K.P x y / Real.sqrt (π y) /-- Unit stationary eigenvector `v_π(x) = √π(x)`. -/ noncomputable def sqrtPi (π : Dist Ω) : Ω → ℝ := fun x => Real.sqrt (π x) omit [DecidableEq Ω] in lemma symMat_isHermitian {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) : (symMat K π).IsHermitian := by ext x y simp only [Matrix.conjTranspose_apply, star_trivial, symMat, Matrix.of_apply] have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) field_simp [hx, hy] rw [Real.sq_sqrt (le_of_lt (hπ_pos y)), Real.sq_sqrt (le_of_lt (hπ_pos x))] have h := hrev y x linarith omit [DecidableEq Ω] in lemma symMat_comp (K₁ K₂ : MarkovKernel Ω) (π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) : symMat (K₁.comp K₂) π = symMat K₁ π * symMat K₂ π := by ext x z simp only [symMat, MarkovKernel.comp, Matrix.of_apply, Matrix.mul_apply, Finset.mul_sum, Finset.sum_div] refine Finset.sum_congr rfl fun y _ => ?_ have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) have hz := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos z)) field_simp [hy, hz] lemma symMat_id (π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) : symMat (MarkovKernel.id) π = (1 : Matrix Ω Ω ℝ) := by ext x y simp only [symMat, MarkovKernel.id, Matrix.of_apply, Matrix.one_apply] by_cases h : x = y · subst h have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) simp [div_self hx] · simp [h] lemma symMat_pow (K : MarkovKernel Ω) (π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) (t : ℕ) : symMat (K.pow t) π = (symMat K π) ^ t := by induction t with | zero => exact symMat_id π hπ_pos | succ t ih => rw [MarkovKernel.pow, symMat_comp K (K.pow t) π hπ_pos, ih, pow_succ'] omit [DecidableEq Ω] in lemma dotProduct_sqrtPi_self (π : Dist Ω) : dotProduct (sqrtPi π) (sqrtPi π) = 1 := by simp only [dotProduct, sqrtPi] calc ∑ x, Real.sqrt (π x) * Real.sqrt (π x) = ∑ x, π x := Finset.sum_congr rfl fun x _ => Real.mul_self_sqrt (π.nonneg x) _ = 1 := π.sum_one omit [DecidableEq Ω] in lemma symMat_mulVec_sqrtPi {K : MarkovKernel Ω} {π : Dist Ω} (hπ_pos : ∀ x, 0 < π x) : symMat K π *ᵥ sqrtPi π = sqrtPi π := by ext x simp only [Matrix.mulVec, dotProduct, symMat, Matrix.of_apply, sqrtPi] calc ∑ y, Real.sqrt (π x) * K.P x y / Real.sqrt (π y) * Real.sqrt (π y) = ∑ y, Real.sqrt (π x) * K.P x y := by refine Finset.sum_congr rfl fun y _ => ?_ exact div_mul_cancel₀ _ (ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y))) _ = Real.sqrt (π x) * ∑ y, K.P x y := (Finset.mul_sum ..).symm _ = Real.sqrt (π x) := by rw [K.row_sum_one x, mul_one] omit [DecidableEq Ω] in /-- Exact quadratic-form bridge between `S = D_π^{1/2} P D_π^{-1/2}` and `L^2(π)`: for `v(x) = √π(x) f(x)`, `v ⬝ (S *ᵥ v) = ⟨P f, f⟩_π`. -/ lemma symMat_quad_eq_l2Inner (K : MarkovKernel Ω) (π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) (v : Ω → ℝ) : dotProduct v (symMat K π *ᵥ v) = l2Inner π (K.apply (fun y => v y / Real.sqrt (π y))) (fun x => v x / Real.sqrt (π x)) := by simp only [dotProduct, Matrix.mulVec, symMat, Matrix.of_apply, l2Inner, MarkovKernel.apply] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum, Finset.mul_sum, Finset.sum_mul] refine Finset.sum_congr rfl fun y _ => ?_ have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) field_simp [hx, hy] rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring omit [DecidableEq Ω] in /-- Real Hermitian symmetry for dot products: `(A *ᵥ u) ⬝ᵥ v = u ⬝ᵥ (A *ᵥ v)`. -/ lemma dotProduct_isHermitian_mulVec {A : Matrix Ω Ω ℝ} (hA : A.IsHermitian) (u v : Ω → ℝ) : dotProduct (A *ᵥ u) v = dotProduct u (A *ᵥ v) := by simp only [dotProduct, Matrix.mulVec] calc ∑ x, (∑ y, A x y * u y) * v x = ∑ x, ∑ y, A x y * u y * v x := Finset.sum_congr rfl fun x _ => Finset.sum_mul .. _ = ∑ y, ∑ x, A x y * u y * v x := Finset.sum_comm _ = ∑ y, u y * ∑ x, A y x * v x := Finset.sum_congr rfl fun y _ => by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => ?_ have hxy : A x y = A y x := by have := congrFun (congrFun hA.eq y) x simpa [Matrix.conjTranspose_apply, star_trivial] using this rw [hxy]; ring /-- Every eigenvalue `λ` of `symMat K π` satisfies `|λ| ≤ 1`. -/ theorem symMat_eigenvalues₀_abs_le_one {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (k : Fin (Fintype.card Ω)) : |(symMat_isHermitian hrev hπ_pos).eigenvalues₀ k| ≤ 1 := by set hS := symMat_isHermitian hrev hπ_pos let e : Fin (Fintype.card Ω) ≃ Ω := Fintype.equivOfCardEq (Fintype.card_fin _) let v : Ω → ℝ := ⇑(hS.eigenvectorBasis (e k)) have hv_mul : symMat K π *ᵥ v = hS.eigenvalues₀ k • v := by have h := hS.mulVec_eigenvectorBasis (e k) simpa [Matrix.IsHermitian.eigenvalues, e] using h have hv_norm : dotProduct v v = 1 := by have h := hS.eigenvectorBasis.orthonormal.1 (e k) rw [EuclideanSpace.norm_eq, Real.sqrt_eq_one] at h simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq] using h have hquad : dotProduct v (symMat K π *ᵥ v) = hS.eigenvalues₀ k := by rw [hv_mul, dotProduct_smul, smul_eq_mul, hv_norm, mul_one] let f : Ω → ℝ := fun x => v x / Real.sqrt (π x) have hf_norm : l2NormSq π f = 1 := by rw [← hv_norm] unfold l2NormSq l2Inner dotProduct f refine Finset.sum_congr rfl fun x _ => ?_ have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) field_simp [hx] rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring rw [← hquad, symMat_quad_eq_l2Inner K π hπ_pos v] simpa [hf_norm] using abs_l2Inner_apply_le_l2NormSq hrev f /-- The top eigenvalue `λ₀` of `symMat K π` equals `1`! -/ theorem symMat_top_eigenvalue_eq_one {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hne : Nonempty Ω) : (symMat_isHermitian hrev hπ_pos).eigenvalues₀ ⟨0, Fintype.card_pos_iff.mpr hne⟩ = 1 := by set hS := symMat_isHermitian hrev hπ_pos have hle : hS.eigenvalues₀ ⟨0, Fintype.card_pos_iff.mpr hne⟩ ≤ 1 := (abs_le.mp (symMat_eigenvalues₀_abs_le_one hrev hπ_pos _)).2 -- Show 1 ≤ λ₀ via Rayleigh quotient at v = sqrtPi π! let u := hS.eigenvectorBasis let e : Fin (Fintype.card Ω) ≃ Ω := Fintype.equivOfCardEq (Fintype.card_fin _) let w : EuclideanSpace ℝ Ω := WithLp.toLp 2 (sqrtPi π) have hw_norm : ∑ i : Ω, (inner ℝ (u i) w) ^ 2 = 1 := by have hparseval := u.sum_sq_norm_inner_right w simp only [Real.norm_eq_abs, sq_abs] at hparseval rw [hparseval, EuclideanSpace.norm_sq_eq] have h1 := dotProduct_sqrtPi_self π simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq, w] using h1 have hw_rayleigh : ∑ i : Ω, hS.eigenvalues i * (inner ℝ (u i) w) ^ 2 = 1 := by -- Expand w = ∑_i ⟨u_i, w⟩ u_i and apply S! have hexp : ∀ x : Ω, sqrtPi π x = ∑ i : Ω, inner ℝ (u i) w * (u i) x := fun x => by have h := u.sum_repr' w have hx := congrFun (congrArg WithLp.ofLp h) x simpa [w, Finset.sum_apply, smul_eq_mul] using hx.symm have hS_w : dotProduct (sqrtPi π) (symMat K π *ᵥ sqrtPi π) = ∑ i : Ω, hS.eigenvalues i * (inner ℝ (u i) w) ^ 2 := by have hmul : symMat K π *ᵥ sqrtPi π = fun x => ∑ i : Ω, (inner ℝ (u i) w * hS.eigenvalues i) * (u i) x := by ext x have hlin : (symMat K π *ᵥ fun y => ∑ i : Ω, inner ℝ (u i) w * (u i) y) x = ∑ i : Ω, inner ℝ (u i) w * (symMat K π *ᵥ ⇑(u i)) x := by simp only [Matrix.mulVec, dotProduct, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun y _ => by ring calc (symMat K π *ᵥ sqrtPi π) x = (symMat K π *ᵥ fun y => ∑ i : Ω, inner ℝ (u i) w * (u i) y) x := by congr 1; exact funext hexp _ = ∑ i : Ω, inner ℝ (u i) w * (symMat K π *ᵥ ⇑(u i)) x := hlin _ = ∑ i : Ω, (inner ℝ (u i) w * hS.eigenvalues i) * (u i) x := by refine Finset.sum_congr rfl fun i _ => ?_ have hmv : symMat K π *ᵥ ⇑(u i) = hS.eigenvalues i • ⇑(u i) := hS.mulVec_eigenvectorBasis i rw [hmv]; simp [mul_assoc] rw [hmul] simp only [dotProduct] calc ∑ x, sqrtPi π x * ∑ i, (inner ℝ (u i) w * hS.eigenvalues i) * (u i) x = ∑ x, ∑ i, (inner ℝ (u i) w * hS.eigenvalues i) * ((u i) x * sqrtPi π x) := Finset.sum_congr rfl fun x _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun i _ => by ring _ = ∑ i, (inner ℝ (u i) w * hS.eigenvalues i) * ∑ x, (u i) x * sqrtPi π x := by rw [Finset.sum_comm] exact Finset.sum_congr rfl fun i _ => (Finset.mul_sum ..).symm _ = ∑ i, hS.eigenvalues i * (inner ℝ (u i) w) ^ 2 := by refine Finset.sum_congr rfl fun i _ => ?_ have hin : ∑ x, (u i) x * sqrtPi π x = inner ℝ (u i) w := by simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, dotProduct, w] exact Finset.sum_congr rfl fun x _ => mul_comm _ _ rw [hin]; ring rw [← hS_w, symMat_mulVec_sqrtPi hπ_pos, dotProduct_sqrtPi_self π] have hge : 1 ≤ hS.eigenvalues₀ ⟨0, Fintype.card_pos_iff.mpr hne⟩ := by calc (1 : ℝ) = ∑ i : Ω, hS.eigenvalues i * (inner ℝ (u i) w) ^ 2 := hw_rayleigh.symm _ ≤ ∑ i : Ω, hS.eigenvalues₀ ⟨0, Fintype.card_pos_iff.mpr hne⟩ * (inner ℝ (u i) w) ^ 2 := by refine Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_right ?_ (sq_nonneg _) have hanti := hS.eigenvalues₀_antitone (Fin.zero_le (e.symm i)) simpa [Matrix.IsHermitian.eigenvalues, e] using hanti _ = hS.eigenvalues₀ ⟨0, Fintype.card_pos_iff.mpr hne⟩ * ∑ i : Ω, (inner ℝ (u i) w) ^ 2 := (Finset.mul_sum ..).symm _ = hS.eigenvalues₀ ⟨0, Fintype.card_pos_iff.mpr hne⟩ := by rw [hw_norm, mul_one] linarith /-- Second-largest eigenvalue `λ₂` of a reversible Markov kernel on `|Ω| ≥ 2`. -/ noncomputable def secondEig {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ℝ := (symMat_isHermitian hrev hπ_pos).eigenvalues₀ ⟨1, by omega⟩ /-- Smallest eigenvalue `λ_min` of a reversible Markov kernel on `|Ω| ≥ 2`. -/ noncomputable def minEig {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ℝ := (symMat_isHermitian hrev hπ_pos).eigenvalues₀ ⟨Fintype.card Ω - 1, by omega⟩ /-- **Spectral Gap** `γ = 1 - λ₂`. -/ noncomputable def spectralGap {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ℝ := 1 - secondEig hrev hπ_pos hcard /-- **Second-Largest Absolute Eigenvalue** `λ_* = max(λ₂, -λ_min)`. -/ noncomputable def lambdaStar {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ℝ := max (secondEig hrev hπ_pos hcard) (-(minEig hrev hπ_pos hcard)) /-- **Absolute Spectral Gap** `γ_* = 1 - λ_*`. -/ noncomputable def absSpectralGap {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ℝ := 1 - lambdaStar hrev hπ_pos hcard /-- **Relaxation Time** `t_rel = 1 / γ_*`. -/ noncomputable def relaxationTime {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ℝ := 1 / absSpectralGap hrev hπ_pos hcard lemma spectralGap_nonneg {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : 0 ≤ spectralGap hrev hπ_pos hcard := by unfold spectralGap secondEig have h := (abs_le.mp (symMat_eigenvalues₀_abs_le_one hrev hπ_pos ⟨1, by omega⟩)).2 linarith lemma lambdaStar_nonneg {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : 0 ≤ lambdaStar hrev hπ_pos hcard := by unfold lambdaStar secondEig minEig have hanti : (symMat_isHermitian hrev hπ_pos).eigenvalues₀ ⟨Fintype.card Ω - 1, by omega⟩ ≤ (symMat_isHermitian hrev hπ_pos).eigenvalues₀ ⟨1, by omega⟩ := (symMat_isHermitian hrev hπ_pos).eigenvalues₀_antitone (by simp; omega) rcases le_total 0 ((symMat_isHermitian hrev hπ_pos).eigenvalues₀ ⟨1, by omega⟩) with h | h · exact le_trans h (le_max_left _ _) · exact le_trans (by linarith) (le_max_right _ _) lemma lambdaStar_le_one {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : lambdaStar hrev hπ_pos hcard ≤ 1 := by unfold lambdaStar secondEig minEig apply max_le · exact (abs_le.mp (symMat_eigenvalues₀_abs_le_one hrev hπ_pos ⟨1, by omega⟩)).2 · have h := (abs_le.mp (symMat_eigenvalues₀_abs_le_one hrev hπ_pos ⟨Fintype.card Ω - 1, by omega⟩)).1 linarith lemma absSpectralGap_le_spectralGap {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : absSpectralGap hrev hπ_pos hcard ≤ spectralGap hrev hπ_pos hcard := by unfold absSpectralGap spectralGap lambdaStar linarith [le_max_left (secondEig hrev hπ_pos hcard) (-(minEig hrev hπ_pos hcard))] /-- Spectral expansion of `(S^t v)` for any symmetric similarity matrix `S`. -/ lemma symMat_pow_quad_expansion {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (t : ℕ) (v : Ω → ℝ) : dotProduct v ((symMat K π) ^ t *ᵥ v) = ∑ i : Ω, (symMat_isHermitian hrev hπ_pos).eigenvalues i ^ t * (inner ℝ ((symMat_isHermitian hrev hπ_pos).eigenvectorBasis i) (WithLp.toLp 2 v)) ^ 2 := by set hS := symMat_isHermitian hrev hπ_pos let u := hS.eigenvectorBasis let w : EuclideanSpace ℝ Ω := WithLp.toLp 2 v have hexp : ∀ x : Ω, v x = ∑ i : Ω, inner ℝ (u i) w * (u i) x := fun x => by have h := u.sum_repr' w have hx := congrFun (congrArg WithLp.ofLp h) x simpa [w, Finset.sum_apply, smul_eq_mul] using hx.symm have hpow_eig : ∀ (i : Ω) (m : ℕ), (symMat K π) ^ m *ᵥ ⇑(u i) = (hS.eigenvalues i ^ m) • ⇑(u i) := by intro i m induction m with | zero => simp [Matrix.one_mulVec] | succ m ih => have hmv : symMat K π *ᵥ ⇑(u i) = hS.eigenvalues i • ⇑(u i) := hS.mulVec_eigenvectorBasis i rw [pow_succ', ← Matrix.mulVec_mulVec, ih, Matrix.mulVec_smul, hmv, smul_smul, pow_succ', mul_comm] have hmul : (symMat K π) ^ t *ᵥ v = fun x => ∑ i : Ω, (inner ℝ (u i) w * hS.eigenvalues i ^ t) * (u i) x := by ext x have hlin : ((symMat K π) ^ t *ᵥ fun y => ∑ i : Ω, inner ℝ (u i) w * (u i) y) x = ∑ i : Ω, inner ℝ (u i) w * ((symMat K π) ^ t *ᵥ ⇑(u i)) x := by simp only [Matrix.mulVec, dotProduct, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun y _ => by ring calc ((symMat K π) ^ t *ᵥ v) x = ((symMat K π) ^ t *ᵥ fun y => ∑ i : Ω, inner ℝ (u i) w * (u i) y) x := by congr 1; exact funext hexp _ = ∑ i : Ω, inner ℝ (u i) w * ((symMat K π) ^ t *ᵥ ⇑(u i)) x := hlin _ = ∑ i : Ω, (inner ℝ (u i) w * hS.eigenvalues i ^ t) * (u i) x := by refine Finset.sum_congr rfl fun i _ => ?_ rw [hpow_eig i t]; simp [mul_assoc] rw [hmul] simp only [dotProduct] calc ∑ x, v x * ∑ i, (inner ℝ (u i) w * hS.eigenvalues i ^ t) * (u i) x = ∑ x, ∑ i, (inner ℝ (u i) w * hS.eigenvalues i ^ t) * ((u i) x * v x) := Finset.sum_congr rfl fun x _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun i _ => by ring _ = ∑ i, (inner ℝ (u i) w * hS.eigenvalues i ^ t) * ∑ x, (u i) x * v x := by rw [Finset.sum_comm] exact Finset.sum_congr rfl fun i _ => (Finset.mul_sum ..).symm _ = ∑ i, hS.eigenvalues i ^ t * (inner ℝ (u i) w) ^ 2 := by refine Finset.sum_congr rfl fun i _ => ?_ have hin : ∑ x, (u i) x * v x = inner ℝ (u i) w := by simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, dotProduct, w] exact Finset.sum_congr rfl fun x _ => mul_comm _ _ rw [hin]; ring /-- Key orthogonality lemma: if `v ⟂ sqrtPi π` (i.e. `E_π[f] = 0`) and `λ₂ < 1`, then `v ⬝ (S v) ≤ λ₂ · ‖v‖²` AND `|v ⬝ (S^t v)| ≤ λ_*^t · ‖v‖²`. Even without assuming `λ₂ < 1` (works for ALL reversible chains, even disconnected!), every vector `v ⟂ sqrtPi π` satisfies `v ⬝ (S v) ≤ λ₂ · ‖v‖²`! -/ theorem symMat_quad_le_secondEig_of_orth {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) (v : Ω → ℝ) (horth : dotProduct v (sqrtPi π) = 0) : dotProduct v (symMat K π *ᵥ v) ≤ secondEig hrev hπ_pos hcard * dotProduct v v := by set hS := symMat_isHermitian hrev hπ_pos let u := hS.eigenvectorBasis let e : Fin (Fintype.card Ω) ≃ Ω := Fintype.equivOfCardEq (Fintype.card_fin _) let i₀ : Ω := e ⟨0, by omega⟩ have hne : Nonempty Ω := Fintype.card_pos_iff.mp (by omega) have hlam0 : hS.eigenvalues i₀ = 1 := by simpa [Matrix.IsHermitian.eigenvalues, i₀, e] using symMat_top_eigenvalue_eq_one hrev hπ_pos hne by_cases hgap : secondEig hrev hπ_pos hcard = 1 · -- When λ₂ = 1, the bound is simply v ⬝ (S v) ≤ 1 · ‖v‖², which holds for ALL v! rw [hgap, one_mul, symMat_quad_eq_l2Inner K π hπ_pos v] let f : Ω → ℝ := fun x => v x / Real.sqrt (π x) have hf_norm : l2NormSq π f = dotProduct v v := by unfold l2NormSq l2Inner dotProduct f refine Finset.sum_congr rfl fun x _ => ?_ have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) field_simp [hx]; rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring rw [← hf_norm] exact (abs_le.mp (abs_l2Inner_apply_le_l2NormSq hrev f)).2 · -- When λ₂ < 1, the eigenspace of eigenvalue 1 is 1-dimensional (spanned by sqrtPi π)! have hlt1 : secondEig hrev hπ_pos hcard < 1 := lt_of_le_of_ne ((abs_le.mp (symMat_eigenvalues₀_abs_le_one hrev hπ_pos ⟨1, by omega⟩)).2) hgap -- Every other eigenvector u j (j ≠ i₀) has eigenvalue ≤ λ₂ < 1, so is orthogonal to sqrtPi π! let wπ : EuclideanSpace ℝ Ω := WithLp.toLp 2 (sqrtPi π) have horth_other : ∀ j : Ω, j ≠ i₀ → inner ℝ (u j) wπ = 0 := fun j hj => by have hj_ge1 : (⟨1, by omega⟩ : Fin (Fintype.card Ω)) ≤ e.symm j := by have hne0 : (e.symm j).val ≠ 0 := fun h => hj (by rw [← e.apply_symm_apply j]; congr 1; exact Fin.ext h) change 1 ≤ (e.symm j).val; omega have hlam_le : hS.eigenvalues j ≤ secondEig hrev hπ_pos hcard := by have hanti := hS.eigenvalues₀_antitone hj_ge1 simpa [Matrix.IsHermitian.eigenvalues, secondEig, e] using hanti -- S (u j) = λ_j u j and S wπ = wπ => λ_j ⟨u j, wπ⟩ = ⟨u j, wπ⟩! have hsym_eq : hS.eigenvalues j * inner ℝ (u j) wπ = inner ℝ (u j) wπ := by have h1 : dotProduct (symMat K π *ᵥ ⇑(u j)) (sqrtPi π) = dotProduct (⇑(u j)) (symMat K π *ᵥ sqrtPi π) := dotProduct_isHermitian_mulVec hS (⇑(u j)) (sqrtPi π) have hmv : symMat K π *ᵥ ⇑(u j) = hS.eigenvalues j • ⇑(u j) := hS.mulVec_eigenvectorBasis j rw [hmv, symMat_mulVec_sqrtPi hπ_pos, smul_dotProduct, smul_eq_mul] at h1 have hin : dotProduct (⇑(u j)) (sqrtPi π) = inner ℝ (u j) wπ := by simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, dotProduct, wπ] exact Finset.sum_congr rfl fun x _ => mul_comm _ _ rwa [hin] at h1 have hne1 : hS.eigenvalues j - 1 ≠ 0 := by linarith have hfac : (hS.eigenvalues j - 1) * inner ℝ (u j) wπ = 0 := by linarith exact (mul_eq_zero.mp hfac).resolve_left hne1 -- Therefore wπ = ⟨u i₀, wπ⟩ • u i₀ with ⟨u i₀, wπ⟩² = 1! have hwπ_rep : wπ = (inner ℝ (u i₀) wπ) • u i₀ := by calc wπ = ∑ i : Ω, inner ℝ (u i) wπ • u i := (u.sum_repr' wπ).symm _ = inner ℝ (u i₀) wπ • u i₀ := by refine Finset.sum_eq_single i₀ ?_ ?_ · intro j _ hj; rw [horth_other j hj, zero_smul] · intro h; exact absurd (Finset.mem_univ i₀) h have hc_sq : (inner ℝ (u i₀) wπ) ^ 2 = 1 := by have h1 := u.sum_sq_norm_inner_right wπ rw [Finset.sum_eq_single i₀] at h1 · simp only [Real.norm_eq_abs, sq_abs] at h1 rw [h1, EuclideanSpace.norm_sq_eq] simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq, wπ] using dotProduct_sqrtPi_self π · intro j _ hj; rw [horth_other j hj, norm_zero, zero_pow two_ne_zero] · intro h; exact absurd (Finset.mem_univ i₀) h -- Hence ⟨u i₀, w⟩ = 0 for w = toLp 2 v! let w : EuclideanSpace ℝ Ω := WithLp.toLp 2 v have hinner_zero : inner ℝ (u i₀) w = 0 := by have hw0 : inner ℝ wπ w = 0 := by simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, wπ, w] exact horth rw [hwπ_rep, inner_smul_left] at hw0 simp only [conj_trivial] at hw0 have hc0 : inner ℝ (u i₀) wπ ≠ 0 := fun h => by rw [h, zero_pow two_ne_zero] at hc_sq; norm_num at hc_sq exact (mul_eq_zero.mp hw0).resolve_left hc0 -- Now expand v ⬝ (S v) using symMat_pow_quad_expansion at t = 1! have hexp1 := symMat_pow_quad_expansion hrev hπ_pos 1 v simp only [pow_one] at hexp1 rw [hexp1] have hparseval : ∑ i : Ω, (inner ℝ (u i) w) ^ 2 = dotProduct v v := by have h := u.sum_sq_norm_inner_right w simp only [Real.norm_eq_abs, sq_abs] at h rw [h, EuclideanSpace.norm_sq_eq] simp [dotProduct, Real.norm_eq_abs, sq, w] rw [← hparseval, Finset.mul_sum] refine Finset.sum_le_sum fun j _ => ?_ by_cases hj : j = i₀ · subst hj; rw [hinner_zero, zero_pow two_ne_zero, mul_zero, mul_zero] · have hj_ge1 : (⟨1, by omega⟩ : Fin (Fintype.card Ω)) ≤ e.symm j := by have hne0 : (e.symm j).val ≠ 0 := fun h => hj (by rw [← e.apply_symm_apply j]; congr 1; exact Fin.ext h) change 1 ≤ (e.symm j).val; omega have hlam_le : hS.eigenvalues j ≤ secondEig hrev hπ_pos hcard := by have hanti := hS.eigenvalues₀_antitone hj_ge1 simpa [Matrix.IsHermitian.eigenvalues, secondEig, e] using hanti exact mul_le_mul_of_nonneg_right hlam_le (sq_nonneg _) /-- **Spectral Gap Variational Inequality (Poincaré Inequality)**: for EVERY observable `f : Ω → ℝ`, `γ · Var_π(f) ≤ E(f, f)`. -/ theorem spectralGap_mul_variance_le_dirichlet {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) (f : Ω → ℝ) : spectralGap hrev hπ_pos hcard * π.variance f ≤ dirichletForm K π f := by let g : Ω → ℝ := fun x => f x - π.expect f have hE_eq : dirichletForm K π g = dirichletForm K π f := by unfold dirichletForm g congr 1; refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by ring let v : Ω → ℝ := fun x => Real.sqrt (π x) * g x have horth : dotProduct v (sqrtPi π) = 0 := by simp only [dotProduct, v, sqrtPi, g] calc ∑ x, Real.sqrt (π x) * (f x - π.expect f) * Real.sqrt (π x) = ∑ x, (Real.sqrt (π x) * Real.sqrt (π x)) * (f x - π.expect f) := Finset.sum_congr rfl fun x _ => by ring _ = ∑ x, π x * (f x - π.expect f) := Finset.sum_congr rfl fun x _ => by rw [Real.mul_self_sqrt (π.nonneg x)] _ = (∑ x, π x * f x) - (∑ x, π x) * π.expect f := by simp_rw [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul] _ = 0 := by rw [π.sum_one, one_mul]; unfold Dist.expect; ring have hnorm : dotProduct v v = π.variance f := by simp only [dotProduct, v, g, Dist.variance] refine Finset.sum_congr rfl fun x _ => ?_ have : Real.sqrt (π x) * (f x - π.expect f) * (Real.sqrt (π x) * (f x - π.expect f)) = (Real.sqrt (π x) * Real.sqrt (π x)) * (f x - π.expect f) ^ 2 := by ring rw [this, Real.mul_self_sqrt (π.nonneg x)] have hquad : dotProduct v (symMat K π *ᵥ v) = l2Inner π (K.apply g) g := by rw [symMat_quad_eq_l2Inner K π hπ_pos v] have hg : (fun x => v x / Real.sqrt (π x)) = g := by ext x; dsimp only [v] exact mul_div_cancel_left₀ (g x) (ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x))) rw [hg] have hvar : l2NormSq π g = π.variance f := by unfold l2NormSq l2Inner Dist.variance g refine Finset.sum_congr rfl fun x _ => by ring have hbound := symMat_quad_le_secondEig_of_orth hrev hπ_pos hcard v horth rw [hquad, hnorm] at hbound rw [← hE_eq, dirichletForm_eq_l2Inner_sub hrev g, hvar] unfold spectralGap linarith /-- **Spectral Gap Variational Attainment**: there exists a non-constant eigenfunction `f` with `E_π[f] = 0`, `Var_π(f) = 1`, `P f = λ₂ f`, and `E(f, f) = γ · Var_π(f)`. -/ theorem exists_second_eigenfunction {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : ∃ f : Ω → ℝ, π.expect f = 0 ∧ π.variance f = 1 ∧ K.apply f = (secondEig hrev hπ_pos hcard) • f ∧ dirichletForm K π f = spectralGap hrev hπ_pos hcard := by set hS := symMat_isHermitian hrev hπ_pos let u := hS.eigenvectorBasis let e : Fin (Fintype.card Ω) ≃ Ω := Fintype.equivOfCardEq (Fintype.card_fin _) let i₀ : Ω := e ⟨0, by omega⟩ let i₁ : Ω := e ⟨1, by omega⟩ have hne : Nonempty Ω := Fintype.card_pos_iff.mp (by omega) -- Pick a unit eigenvector v for λ₂ that is orthogonal to sqrtPi π! have hv_exists : ∃ v : Ω → ℝ, dotProduct v v = 1 ∧ dotProduct v (sqrtPi π) = 0 ∧ symMat K π *ᵥ v = secondEig hrev hπ_pos hcard • v := by by_cases hgap : secondEig hrev hπ_pos hcard = 1 · -- Both u i₀ and u i₁ have eigenvalue 1; take a linear combination orthogonal to sqrtPi π! let a := dotProduct (⇑(u i₀)) (sqrtPi π) let b := dotProduct (⇑(u i₁)) (sqrtPi π) have hi01 : i₀ ≠ i₁ := fun h => by have := e.injective h; simp at this have h00 : dotProduct (⇑(u i₀)) (⇑(u i₀)) = 1 := by have h := u.orthonormal.1 i₀ rw [EuclideanSpace.norm_eq, Real.sqrt_eq_one] at h simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq] using h have h11 : dotProduct (⇑(u i₁)) (⇑(u i₁)) = 1 := by have h := u.orthonormal.1 i₁ rw [EuclideanSpace.norm_eq, Real.sqrt_eq_one] at h simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq] using h have h01 : dotProduct (⇑(u i₀)) (⇑(u i₁)) = 0 := by have h := u.orthonormal.2 hi01 simpa [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, dotProduct_comm] using h by_cases hab : a ^ 2 + b ^ 2 = 0 · have ha0 : a = 0 := by nlinarith refine ⟨⇑(u i₀), h00, ha0, ?_⟩ have hlam0 : hS.eigenvalues i₀ = 1 := by simpa [Matrix.IsHermitian.eigenvalues, i₀, e] using symMat_top_eigenvalue_eq_one hrev hπ_pos hne rw [hS.mulVec_eigenvectorBasis i₀, hlam0, hgap] · have hpos : 0 < a ^ 2 + b ^ 2 := lt_of_le_of_ne (by positivity) (Ne.symm hab) let r := Real.sqrt (a ^ 2 + b ^ 2) have hr_pos : 0 < r := Real.sqrt_pos.mpr hpos let v : Ω → ℝ := fun x => (b / r) * (u i₀) x - (a / r) * (u i₁) x have hvv : dotProduct v v = 1 := by have hexp : dotProduct v v = (b / r) ^ 2 * dotProduct (⇑(u i₀)) (⇑(u i₀)) - 2 * (b / r) * (a / r) * dotProduct (⇑(u i₀)) (⇑(u i₁)) + (a / r) ^ 2 * dotProduct (⇑(u i₁)) (⇑(u i₁)) := by simp only [dotProduct, v] have hpt : ∀ x, ((b / r) * (u i₀) x - (a / r) * (u i₁) x) * ((b / r) * (u i₀) x - (a / r) * (u i₁) x) = (b / r) ^ 2 * ((u i₀) x * (u i₀) x) - (2 * (b / r) * (a / r)) * ((u i₀) x * (u i₁) x) + (a / r) ^ 2 * ((u i₁) x * (u i₁) x) := fun x => by ring simp_rw [hpt, Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum] rw [hexp, h00, h01, h11] have hr2 : r ^ 2 = a ^ 2 + b ^ 2 := Real.sq_sqrt (le_of_lt hpos) field_simp [ne_of_gt hr_pos] linarith have hv_orth : dotProduct v (sqrtPi π) = 0 := by have hexp : dotProduct v (sqrtPi π) = (b / r) * a - (a / r) * b := by calc dotProduct v (sqrtPi π) = ∑ x, ((b / r) * ((u i₀) x * sqrtPi π x) - (a / r) * ((u i₁) x * sqrtPi π x)) := Finset.sum_congr rfl fun x _ => by dsimp only [v]; ring _ = (b / r) * a - (a / r) * b := by rw [Finset.sum_sub_distrib, ← Finset.mul_sum, ← Finset.mul_sum]; rfl rw [hexp]; ring have hlam0 : hS.eigenvalues i₀ = 1 := by simpa [Matrix.IsHermitian.eigenvalues, i₀, e] using symMat_top_eigenvalue_eq_one hrev hπ_pos hne have hlam1 : hS.eigenvalues i₁ = 1 := by simpa [Matrix.IsHermitian.eigenvalues, secondEig, i₁, e] using hgap have hv_eig : symMat K π *ᵥ v = secondEig hrev hπ_pos hcard • v := by rw [hgap, one_smul] ext x have hv_eq : v = (b / r) • ⇑(u i₀) - (a / r) • ⇑(u i₁) := by ext y; simp [v] have hmv0 : symMat K π *ᵥ ⇑(u i₀) = ⇑(u i₀) := by have h := hS.mulVec_eigenvectorBasis i₀; rw [hlam0, one_smul] at h; exact h have hmv1 : symMat K π *ᵥ ⇑(u i₁) = ⇑(u i₁) := by have h := hS.mulVec_eigenvectorBasis i₁; rw [hlam1, one_smul] at h; exact h rw [hv_eq, Matrix.mulVec_sub, Matrix.mulVec_smul, Matrix.mulVec_smul, hmv0, hmv1] exact ⟨v, hvv, hv_orth, hv_eig⟩ · -- When λ₂ < 1, u i₁ itself is orthogonal to sqrtPi π! refine ⟨⇑(u i₁), ?_, ?_, ?_⟩ · have h := u.orthonormal.1 i₁ rw [EuclideanSpace.norm_eq, Real.sqrt_eq_one] at h simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq] using h · have h1 : dotProduct (symMat K π *ᵥ ⇑(u i₁)) (sqrtPi π) = dotProduct (⇑(u i₁)) (symMat K π *ᵥ sqrtPi π) := dotProduct_isHermitian_mulVec hS (⇑(u i₁)) (sqrtPi π) have hmv1 : symMat K π *ᵥ ⇑(u i₁) = hS.eigenvalues i₁ • ⇑(u i₁) := hS.mulVec_eigenvectorBasis i₁ rw [hmv1, symMat_mulVec_sqrtPi hπ_pos, smul_dotProduct, smul_eq_mul] at h1 have hlam1 : hS.eigenvalues i₁ = secondEig hrev hπ_pos hcard := by simp [Matrix.IsHermitian.eigenvalues, secondEig, i₁, e] rw [hlam1] at h1 have hfac : (secondEig hrev hπ_pos hcard - 1) * dotProduct (⇑(u i₁)) (sqrtPi π) = 0 := by linarith exact (mul_eq_zero.mp hfac).resolve_left (sub_ne_zero.mpr hgap) · have hlam1 : hS.eigenvalues i₁ = secondEig hrev hπ_pos hcard := by simp [Matrix.IsHermitian.eigenvalues, secondEig, i₁, e] have hmv1 : symMat K π *ᵥ ⇑(u i₁) = hS.eigenvalues i₁ • ⇑(u i₁) := hS.mulVec_eigenvectorBasis i₁ rw [hmv1, hlam1] obtain ⟨v, hvv, hv_orth, hv_eig⟩ := hv_exists let f : Ω → ℝ := fun x => v x / Real.sqrt (π x) have hf_exp : π.expect f = 0 := by unfold Dist.expect f calc ∑ x, π x * (v x / Real.sqrt (π x)) = ∑ x, v x * Real.sqrt (π x) := by refine Finset.sum_congr rfl fun x _ => ?_ have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) field_simp [hx]; rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring _ = dotProduct v (sqrtPi π) := rfl _ = 0 := hv_orth have hf_var : π.variance f = 1 := by unfold Dist.variance rw [hf_exp] calc ∑ x, π x * (f x - 0) ^ 2 = ∑ x, v x * v x := by refine Finset.sum_congr rfl fun x _ => ?_ dsimp only [f] have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) field_simp [hx]; rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring _ = dotProduct v v := rfl _ = 1 := hvv have hf_apply : K.apply f = secondEig hrev hπ_pos hcard • f := by ext x have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) have hmul_x := congrFun hv_eig x simp only [Matrix.mulVec, dotProduct, symMat, Matrix.of_apply, Pi.smul_apply, smul_eq_mul] at hmul_x simp only [MarkovKernel.apply, Pi.smul_apply, smul_eq_mul, f] have hrew : ∑ y, Real.sqrt (π x) * K.P x y / Real.sqrt (π y) * v y = Real.sqrt (π x) * ∑ y, K.P x y * (v y / Real.sqrt (π y)) := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring rw [hrew] at hmul_x apply mul_left_cancel₀ hx rw [hmul_x] field_simp [hx] have hf_dir : dirichletForm K π f = spectralGap hrev hπ_pos hcard := by rw [dirichletForm_eq_l2Inner_sub hrev f, hf_apply] have hnorm : l2NormSq π f = 1 := by simpa [Dist.variance, hf_exp, l2NormSq, l2Inner, sq, mul_assoc] using hf_var have hin : l2Inner π (secondEig hrev hπ_pos hcard • f) f = secondEig hrev hπ_pos hcard * l2NormSq π f := by rw [l2NormSq, l2Inner, l2Inner, Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => by simp only [Pi.smul_apply, smul_eq_mul]; ring rw [hin, hnorm, mul_one]; rfl exact ⟨f, hf_exp, hf_var, hf_apply, hf_dir⟩ /-- **Exact `L^2(π)` Power Contraction** for any vector `v ⟂ sqrtPi π`: `v ⬝ (S^(2t) v) ≤ λ_*^(2t) · ‖v‖²`. -/ theorem symMat_pow_two_mul_quad_le {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) (t : ℕ) (v : Ω → ℝ) (horth : dotProduct v (sqrtPi π) = 0) : dotProduct v ((symMat K π) ^ (2 * t) *ᵥ v) ≤ (lambdaStar hrev hπ_pos hcard) ^ (2 * t) * dotProduct v v := by set hS := symMat_isHermitian hrev hπ_pos let u := hS.eigenvectorBasis let e : Fin (Fintype.card Ω) ≃ Ω := Fintype.equivOfCardEq (Fintype.card_fin _) let i₀ : Ω := e ⟨0, by omega⟩ let w : EuclideanSpace ℝ Ω := WithLp.toLp 2 v have hparseval : ∑ i : Ω, (inner ℝ (u i) w) ^ 2 = dotProduct v v := by have h := u.sum_sq_norm_inner_right w simp only [Real.norm_eq_abs, sq_abs] at h rw [h, EuclideanSpace.norm_sq_eq] simp [dotProduct, Real.norm_eq_abs, sq, w] rw [symMat_pow_quad_expansion hrev hπ_pos (2 * t) v, ← hparseval, Finset.mul_sum] by_cases hls1 : lambdaStar hrev hπ_pos hcard = 1 · rw [hls1, one_pow] refine Finset.sum_le_sum fun i _ => ?_ have hle1 : |hS.eigenvalues i| ≤ 1 := by have h := symMat_eigenvalues₀_abs_le_one hrev hπ_pos (e.symm i) simpa [Matrix.IsHermitian.eigenvalues, e] using h have hpow_le : hS.eigenvalues i ^ (2 * t) ≤ 1 := by rw [pow_mul] have hsq : hS.eigenvalues i ^ 2 ≤ 1 := by nlinarith [abs_le.mp hle1] exact pow_le_one₀ (sq_nonneg _) hsq exact mul_le_mul_of_nonneg_right hpow_le (sq_nonneg _) · -- When λ_* < 1, λ₂ ≤ λ_* < 1, so wπ is spanned by u i₀ and ⟨u i₀, w⟩ = 0! have hlt1 : secondEig hrev hπ_pos hcard < 1 := by have hle : secondEig hrev hπ_pos hcard ≤ lambdaStar hrev hπ_pos hcard := le_max_left _ _ have hls_lt : lambdaStar hrev hπ_pos hcard < 1 := lt_of_le_of_ne (lambdaStar_le_one hrev hπ_pos hcard) hls1 linarith let wπ : EuclideanSpace ℝ Ω := WithLp.toLp 2 (sqrtPi π) have horth_other : ∀ j : Ω, j ≠ i₀ → inner ℝ (u j) wπ = 0 := fun j hj => by have hj_ge1 : (⟨1, by omega⟩ : Fin (Fintype.card Ω)) ≤ e.symm j := by have hne0 : (e.symm j).val ≠ 0 := fun h => hj (by rw [← e.apply_symm_apply j]; congr 1; exact Fin.ext h) change 1 ≤ (e.symm j).val; omega have hlam_le : hS.eigenvalues j ≤ secondEig hrev hπ_pos hcard := by have hanti := hS.eigenvalues₀_antitone hj_ge1 simpa [Matrix.IsHermitian.eigenvalues, secondEig, e] using hanti have hsym_eq : hS.eigenvalues j * inner ℝ (u j) wπ = inner ℝ (u j) wπ := by have h1 : dotProduct (symMat K π *ᵥ ⇑(u j)) (sqrtPi π) = dotProduct (⇑(u j)) (symMat K π *ᵥ sqrtPi π) := dotProduct_isHermitian_mulVec hS (⇑(u j)) (sqrtPi π) have hmv : symMat K π *ᵥ ⇑(u j) = hS.eigenvalues j • ⇑(u j) := hS.mulVec_eigenvectorBasis j rw [hmv, symMat_mulVec_sqrtPi hπ_pos, smul_dotProduct, smul_eq_mul] at h1 have hin : dotProduct (⇑(u j)) (sqrtPi π) = inner ℝ (u j) wπ := by simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, dotProduct, wπ] exact Finset.sum_congr rfl fun x _ => mul_comm _ _ rwa [hin] at h1 have hfac : (hS.eigenvalues j - 1) * inner ℝ (u j) wπ = 0 := by linarith exact (mul_eq_zero.mp hfac).resolve_left (by linarith) have hwπ_rep : wπ = (inner ℝ (u i₀) wπ) • u i₀ := by calc wπ = ∑ i : Ω, inner ℝ (u i) wπ • u i := (u.sum_repr' wπ).symm _ = inner ℝ (u i₀) wπ • u i₀ := by refine Finset.sum_eq_single i₀ ?_ ?_ · intro j _ hj; rw [horth_other j hj, zero_smul] · intro h; exact absurd (Finset.mem_univ i₀) h have hc_sq : (inner ℝ (u i₀) wπ) ^ 2 = 1 := by have h1 := u.sum_sq_norm_inner_right wπ rw [Finset.sum_eq_single i₀] at h1 · simp only [Real.norm_eq_abs, sq_abs] at h1 rw [h1, EuclideanSpace.norm_sq_eq] simpa [dotProduct, Real.norm_eq_abs, sq_abs, sq, wπ] using dotProduct_sqrtPi_self π · intro j _ hj; rw [horth_other j hj, norm_zero, zero_pow two_ne_zero] · intro h; exact absurd (Finset.mem_univ i₀) h have hinner_zero : inner ℝ (u i₀) w = 0 := by have hw0 : inner ℝ wπ w = 0 := by simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial, wπ, w] exact horth rw [hwπ_rep, inner_smul_left] at hw0 simp only [conj_trivial] at hw0 have hc0 : inner ℝ (u i₀) wπ ≠ 0 := fun h => by rw [h, zero_pow two_ne_zero] at hc_sq; norm_num at hc_sq exact (mul_eq_zero.mp hw0).resolve_left hc0 refine Finset.sum_le_sum fun j _ => ?_ by_cases hj : j = i₀ · subst hj; rw [hinner_zero, zero_pow two_ne_zero, mul_zero, mul_zero] · have hj_ge1 : (⟨1, by omega⟩ : Fin (Fintype.card Ω)) ≤ e.symm j := by have hne0 : (e.symm j).val ≠ 0 := fun h => hj (by rw [← e.apply_symm_apply j]; congr 1; exact Fin.ext h) change 1 ≤ (e.symm j).val; omega have hj_le_last : e.symm j ≤ ⟨Fintype.card Ω - 1, by omega⟩ := by change (e.symm j).val ≤ Fintype.card Ω - 1; omega have hup : hS.eigenvalues j ≤ lambdaStar hrev hπ_pos hcard := by have hanti := hS.eigenvalues₀_antitone hj_ge1 have h2 : hS.eigenvalues j ≤ secondEig hrev hπ_pos hcard := by simpa [Matrix.IsHermitian.eigenvalues, secondEig, e] using hanti exact le_trans h2 (le_max_left _ _) have hlo : -(lambdaStar hrev hπ_pos hcard) ≤ hS.eigenvalues j := by have hanti := hS.eigenvalues₀_antitone hj_le_last have hm : minEig hrev hπ_pos hcard ≤ hS.eigenvalues j := by simpa [Matrix.IsHermitian.eigenvalues, minEig, e] using hanti have hneg : -(minEig hrev hπ_pos hcard) ≤ lambdaStar hrev hπ_pos hcard := le_max_right _ _ linarith have hsq : hS.eigenvalues j ^ 2 ≤ lambdaStar hrev hπ_pos hcard ^ 2 := by nlinarith [lambdaStar_nonneg hrev hπ_pos hcard] have hpow : hS.eigenvalues j ^ (2 * t) ≤ lambdaStar hrev hπ_pos hcard ^ (2 * t) := by rw [pow_mul, pow_mul] exact pow_le_pow_left₀ (sq_nonneg _) hsq t exact mul_le_mul_of_nonneg_right hpow (sq_nonneg _) /-- **Exact `χ²` Spectral Upper Bound**: for every reversible Markov chain, every starting state `x`, and every time `t`: `χ²(P^t(x, ·), π) ≤ (1 / π(x) - 1) · λ_*^(2t)`. -/ theorem chi2_stepDist_le_lambdaStar {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ y, 0 < π y) (hcard : 2 ≤ Fintype.card Ω) (t : ℕ) (x : Ω) : chi2Dist (K.stepDist t x) π ≤ (1 / π x - 1) * (lambdaStar hrev hπ_pos hcard) ^ (2 * t) := by -- Define v(y) = (δ_x(y) - π(y)) / √π(y) = (1/√π(x)) δ_x(y) - √π(y)! let v : Ω → ℝ := fun y => ((if y = x then 1 else 0) - π y) / Real.sqrt (π y) have horth : dotProduct v (sqrtPi π) = 0 := by simp only [dotProduct, v, sqrtPi] calc ∑ y, ((if y = x then 1 else 0) - π y) / Real.sqrt (π y) * Real.sqrt (π y) = ∑ y, ((if y = x then 1 else 0) - π y) := by refine Finset.sum_congr rfl fun y _ => div_mul_cancel₀ _ (ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y))) _ = 1 - 1 := by rw [Finset.sum_sub_distrib, π.sum_one]; simp _ = 0 := sub_self 1 have hvv : dotProduct v v = 1 / π x - 1 := by simp only [dotProduct, v] have hpt : ∀ y, ((if y = x then 1 else 0) - π y) / Real.sqrt (π y) * (((if y = x then 1 else 0) - π y) / Real.sqrt (π y)) = (if y = x then 1 / π y else 0) - (if y = x then 2 else 0) + π y := fun y => by have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) have hsq : Real.sqrt (π y) * Real.sqrt (π y) = π y := Real.mul_self_sqrt (π.nonneg y) by_cases h : y = x · subst h; rw [if_pos rfl, if_pos rfl, if_pos rfl] field_simp [hy, ne_of_gt (hπ_pos y)] rw [Real.sq_sqrt (le_of_lt (hπ_pos y))]; ring · rw [if_neg h, if_neg h, if_neg h] field_simp [hy] rw [Real.sq_sqrt (le_of_lt (hπ_pos y))]; ring simp_rw [hpt, Finset.sum_add_distrib, Finset.sum_sub_distrib, π.sum_one] simp; ring -- Show v ⬝ (S^(2t) v) = χ²(P^t(x, ·), π)! have hchi2 : dotProduct v ((symMat K π) ^ (2 * t) *ᵥ v) = chi2Dist (K.stepDist t x) π := by rw [← symMat_pow K π hπ_pos (2 * t)] -- First compute (symMat (K.pow (2*t)) π) *ᵥ v! have h2t : (K.pow (2 * t)).P x x / π x - 1 = chi2Dist (K.stepDist t x) π := by rw [chi2Dist_eq_sum_sq_sub_one _ π hπ_pos] have hrev_t := hrev.pow t have h2t_eq : (K.pow (2 * t)).P x x = ∑ y, (K.pow t).P x y * (K.pow t).P y x := by have h : 2 * t = t + t := two_mul t rw [h, K.pow_add t t]; rfl rw [h2t_eq, Finset.sum_div] congr 1 refine Finset.sum_congr rfl fun y _ => ?_ simp only [MarkovKernel.stepDist, MarkovKernel.row] have hry := hrev_t x y have hx := ne_of_gt (hπ_pos x) have hy := ne_of_gt (hπ_pos y) field_simp [hx, hy] have : (K.pow t).P x y * (K.pow t).P y x * π y = (K.pow t).P x y * (π y * (K.pow t).P y x) := by ring rw [this, ← hry]; ring rw [← h2t] have hS2t_pi : symMat (K.pow (2 * t)) π *ᵥ sqrtPi π = sqrtPi π := symMat_mulVec_sqrtPi hπ_pos have hS2t_herm := symMat_isHermitian (hrev.pow (2 * t)) hπ_pos -- Write v = w_x - sqrtPi π where w_x(y) = if y = x then 1/√π(x) else 0! let wx : Ω → ℝ := fun y => if y = x then (Real.sqrt (π x))⁻¹ else 0 have hv_split : v = wx - sqrtPi π := by ext y; simp only [v, wx, sqrtPi, Pi.sub_apply] have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) by_cases h : y = x · subst h; rw [if_pos rfl, if_pos rfl] field_simp [hy]; rw [Real.sq_sqrt (le_of_lt (hπ_pos y))] · rw [if_neg h, if_neg h] field_simp [hy] rw [zero_sub, zero_sub, mul_neg, Real.mul_self_sqrt (le_of_lt (hπ_pos y))] rw [hv_split, Matrix.mulVec_sub, hS2t_pi, dotProduct_sub, sub_dotProduct, sub_dotProduct] have h1 : dotProduct wx (symMat (K.pow (2 * t)) π *ᵥ wx) = (K.pow (2 * t)).P x x / π x := by simp only [dotProduct, Matrix.mulVec, wx, symMat, Matrix.of_apply] simp only [ite_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ite_true, mul_ite, mul_zero] have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) field_simp [hx, ne_of_gt (hπ_pos x)] rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring have h2 : dotProduct wx (sqrtPi π) = 1 := by simp only [dotProduct, wx, sqrtPi, ite_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ite_true] exact inv_mul_cancel₀ (ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x))) have h3 : dotProduct (sqrtPi π) (symMat (K.pow (2 * t)) π *ᵥ wx) = 1 := by rw [← dotProduct_isHermitian_mulVec hS2t_herm, hS2t_pi, dotProduct_comm, h2] have h4 : dotProduct (sqrtPi π) (sqrtPi π) = 1 := dotProduct_sqrtPi_self π rw [h1, h2, h3, h4]; ring have hbound := symMat_pow_two_mul_quad_le hrev hπ_pos hcard t v horth rw [hchi2, hvv, mul_comm] at hbound exact hbound /-- **Exact `L^2`-to-TV Spectral Mixing Upper Bound**: `4 · d_TV(P^t(x, ·), π)² ≤ (1 / π(x) - 1) · λ_*^(2t)`. -/ theorem four_tvDist_sq_step_le_spectral {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ y, 0 < π y) (hcard : 2 ≤ Fintype.card Ω) (t : ℕ) (x : Ω) : 4 * (tvDist (K.stepDist t x) π) ^ 2 ≤ (1 / π x - 1) * (lambdaStar hrev hπ_pos hcard) ^ (2 * t) := le_trans (four_tvDist_sq_le_chi2 _ π hπ_pos) (chi2_stepDist_le_lambdaStar hrev hπ_pos hcard t x) /-- **Exponential Spectral Mixing Upper Bound**: `d_TV(P^t(x, ·), π) ≤ (1 / 2) · √(1 / π(x) - 1) · exp(-γ_* · t)`. -/ theorem tvDist_step_le_exp_spectralGap {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ y, 0 < π y) (hcard : 2 ≤ Fintype.card Ω) (t : ℕ) (x : Ω) : tvDist (K.stepDist t x) π ≤ (1 / 2 : ℝ) * Real.sqrt (1 / π x - 1) * Real.exp (-(absSpectralGap hrev hπ_pos hcard) * t) := by have h4 := four_tvDist_sq_step_le_spectral hrev hπ_pos hcard t x have hpi_le1 : π x ≤ 1 := π.le_one x have hnn_rad : 0 ≤ 1 / π x - 1 := by have : 1 ≤ 1 / π x := (one_le_div (hπ_pos x)).mpr hpi_le1 linarith have hlam_nn := lambdaStar_nonneg hrev hπ_pos hcard have hlam_exp : lambdaStar hrev hπ_pos hcard ≤ Real.exp (-(absSpectralGap hrev hπ_pos hcard)) := by unfold absSpectralGap have h := Real.add_one_le_exp (-(1 - lambdaStar hrev hπ_pos hcard)) linarith have hlam_pow : (lambdaStar hrev hπ_pos hcard) ^ t ≤ Real.exp (-(absSpectralGap hrev hπ_pos hcard) * t) := by calc (lambdaStar hrev hπ_pos hcard) ^ t ≤ (Real.exp (-(absSpectralGap hrev hπ_pos hcard))) ^ t := pow_le_pow_left₀ hlam_nn hlam_exp t _ = Real.exp (t * -(absSpectralGap hrev hπ_pos hcard)) := (Real.exp_nat_mul _ t).symm _ = Real.exp (-(absSpectralGap hrev hπ_pos hcard) * t) := by ring_nf have hsq : (tvDist (K.stepDist t x) π) ^ 2 ≤ ((1 / 2 : ℝ) * Real.sqrt (1 / π x - 1) * (lambdaStar hrev hπ_pos hcard) ^ t) ^ 2 := by rw [mul_pow, mul_pow, Real.sq_sqrt hnn_rad, ← pow_mul, mul_comm t 2] linarith have hrhs_nn : 0 ≤ (1 / 2 : ℝ) * Real.sqrt (1 / π x - 1) * (lambdaStar hrev hπ_pos hcard) ^ t := mul_nonneg (mul_nonneg (by norm_num) (Real.sqrt_nonneg _)) (pow_nonneg hlam_nn t) have htv_le : tvDist (K.stepDist t x) π ≤ (1 / 2 : ℝ) * Real.sqrt (1 / π x - 1) * (lambdaStar hrev hπ_pos hcard) ^ t := by nlinarith [tvDist_nonneg (K.stepDist t x) π] exact le_trans htv_le (mul_le_mul_of_nonneg_left hlam_pow (mul_nonneg (by norm_num) (Real.sqrt_nonneg _))) /-- **Poincaré Variance Contraction**: for every reversible Markov chain and observable `f`, `Var_π(P^t f) ≤ λ_*^(2t) · Var_π(f)`. -/ theorem variance_apply_pow_le {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ y, 0 < π y) (hcard : 2 ≤ Fintype.card Ω) (t : ℕ) (f : Ω → ℝ) : π.variance ((K.pow t).apply f) ≤ (lambdaStar hrev hπ_pos hcard) ^ (2 * t) * π.variance f := by let g : Ω → ℝ := fun x => f x - π.expect f have hmean_t : π.expect ((K.pow t).apply f) = π.expect f := by rw [← MarkovKernel.expect_push, K.isStationary_pow hrev.isStationary t] have hPt_g : (K.pow t).apply g = fun x => (K.pow t).apply f x - π.expect f := by ext x; simp only [MarkovKernel.apply, g, mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul, (K.pow t).row_sum_one x, one_mul] let v : Ω → ℝ := fun x => Real.sqrt (π x) * g x have horth : dotProduct v (sqrtPi π) = 0 := by simp only [dotProduct, v, sqrtPi, g] calc ∑ x, Real.sqrt (π x) * (f x - π.expect f) * Real.sqrt (π x) = ∑ x, (Real.sqrt (π x) * Real.sqrt (π x)) * (f x - π.expect f) := Finset.sum_congr rfl fun x _ => by ring _ = ∑ x, π x * (f x - π.expect f) := Finset.sum_congr rfl fun x _ => by rw [Real.mul_self_sqrt (π.nonneg x)] _ = (∑ x, π x * f x) - (∑ x, π x) * π.expect f := by simp_rw [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul] _ = 0 := by rw [π.sum_one, one_mul]; unfold Dist.expect; ring have hvv : dotProduct v v = π.variance f := by simp only [dotProduct, v, g, Dist.variance] refine Finset.sum_congr rfl fun x _ => ?_ have : Real.sqrt (π x) * (f x - π.expect f) * (Real.sqrt (π x) * (f x - π.expect f)) = (Real.sqrt (π x) * Real.sqrt (π x)) * (f x - π.expect f) ^ 2 := by ring rw [this, Real.mul_self_sqrt (π.nonneg x)] have hvar_t : dotProduct v ((symMat K π) ^ (2 * t) *ᵥ v) = π.variance ((K.pow t).apply f) := by have hSt_herm : ((symMat K π) ^ t).IsHermitian := by rw [← symMat_pow K π hπ_pos t]; exact symMat_isHermitian (hrev.pow t) hπ_pos have hsplit : (symMat K π) ^ (2 * t) = (symMat K π) ^ t * (symMat K π) ^ t := by rw [two_mul, pow_add] rw [hsplit, ← Matrix.mulVec_mulVec, ← dotProduct_isHermitian_mulVec hSt_herm] have hmul_v : (symMat K π) ^ t *ᵥ v = fun x => Real.sqrt (π x) * (K.pow t).apply g x := by rw [← symMat_pow K π hπ_pos t] ext x simp only [Matrix.mulVec, dotProduct, symMat, Matrix.of_apply, v, MarkovKernel.apply] rw [Finset.mul_sum] refine Finset.sum_congr rfl fun y _ => ?_ have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) field_simp [hy] rw [hmul_v] simp only [dotProduct, Dist.variance, hmean_t, hPt_g] refine Finset.sum_congr rfl fun x _ => ?_ have : Real.sqrt (π x) * ((K.pow t).apply f x - π.expect f) * (Real.sqrt (π x) * ((K.pow t).apply f x - π.expect f)) = (Real.sqrt (π x) * Real.sqrt (π x)) * ((K.pow t).apply f x - π.expect f) ^ 2 := by ring rw [this, Real.mul_self_sqrt (π.nonneg x)] rw [← hvar_t, ← hvv] exact symMat_pow_two_mul_quad_le hrev hπ_pos hcard t v horth /-- **Eigenfunction Mixing Lower Bound**: for ANY eigenfunction `f` with `E_π[f] = 0`, `P f = λ f`, and `f ≠ 0`, `d(t) ≥ (1/2) · |λ|^t`. -/ theorem dTVMax_ge_half_abs_eig_pow {K : MarkovKernel Ω} {π : Dist Ω} (hne : Nonempty Ω) {f : Ω → ℝ} {lam : ℝ} (hf_mean : π.expect f = 0) (hf_nz : ∃ x, f x ≠ 0) (hf_eig : K.apply f = lam • f) (t : ℕ) : (1 / 2 : ℝ) * |lam| ^ t ≤ dTVMax K π hne t := by -- Pick x* maximizing |f(x)|! obtain ⟨xstar, _, hxstar_max⟩ := Finset.exists_max_image Finset.univ (fun x => |f x|) (Finset.univ_nonempty_iff.mpr hne) obtain ⟨x0, hx0⟩ := hf_nz have hM_pos : 0 < |f xstar| := lt_of_lt_of_le (abs_pos.mpr hx0) (hxstar_max x0 (Finset.mem_univ x0)) have hPt_eig : ∀ m, (K.pow m).apply f = (lam ^ m) • f := fun m => by induction m with | zero => ext x; simp [MarkovKernel.pow, MarkovKernel.apply, MarkovKernel.id] | succ m ih => rw [MarkovKernel.pow, MarkovKernel.apply_comp, ih] ext x simp only [MarkovKernel.apply, Pi.smul_apply, smul_eq_mul] calc ∑ y, K.P x y * (lam ^ m * f y) = lam ^ m * ∑ y, K.P x y * f y := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun y _ => by ring _ = lam ^ m * (lam * f x) := by have := congrFun hf_eig x simpa [MarkovKernel.apply, Pi.smul_apply, smul_eq_mul] using congrArg (lam ^ m * ·) this _ = lam ^ (m + 1) * f x := by ring have habs := abs_expect_sub_le_tvDist (K.stepDist t xstar) π f (fun y => hxstar_max y (Finset.mem_univ y)) rw [MarkovKernel.expect_stepDist, hPt_eig t, hf_mean, sub_zero, Pi.smul_apply, smul_eq_mul, abs_mul, abs_pow] at habs have hle_max := tvDist_step_le_dTVMax K π hne t xstar have h1 : |lam| ^ t * |f xstar| ≤ 2 * |f xstar| * dTVMax K π hne t := le_trans habs (mul_le_mul_of_nonneg_left hle_max (by linarith)) nlinarith /-- **Exact Relaxation-Time Lower Bound on Mixing Time** (LPW Theorem 12.5): if `λ₂ ∈ (0, 1)` and `d(t) ≤ ε` with `0 < ε ≤ 1/2`, then `t ≥ (1 / γ - 1) · ln(1 / (2 ε))`. -/ theorem mixing_time_ge_relaxation_lower_bound {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ y, 0 < π y) (hcard : 2 ≤ Fintype.card Ω) (hne : Nonempty Ω) (hlam_pos : 0 < secondEig hrev hπ_pos hcard) (hlam_lt1 : secondEig hrev hπ_pos hcard < 1) {t : ℕ} {ε : ℝ} (_hε_pos : 0 < ε) (hdt : dTVMax K π hne t ≤ ε) : (1 / spectralGap hrev hπ_pos hcard - 1) * Real.log (1 / (2 * ε)) ≤ t := by obtain ⟨f, hf_mean, hf_var, hf_eig, _⟩ := exists_second_eigenfunction hrev hπ_pos hcard have hf_nz : ∃ x, f x ≠ 0 := by by_contra h push Not at h have h0 : π.variance f = 0 := by unfold Dist.variance; simp [h, hf_mean] linarith have hlb := dTVMax_ge_half_abs_eig_pow hne hf_mean hf_nz hf_eig t rw [abs_of_pos hlam_pos] at hlb have hpow_le : (secondEig hrev hπ_pos hcard) ^ t ≤ 2 * ε := by linarith have hlog_le : Real.log ((secondEig hrev hπ_pos hcard) ^ t) ≤ Real.log (2 * ε) := Real.log_le_log (pow_pos hlam_pos t) hpow_le rw [Real.log_pow] at hlog_le -- Elementary bound: log(λ) ≥ -(1 - λ) / λ = -γ / (1 - γ)! -- Proof: log(1/λ) ≤ 1/λ - 1 = (1 - λ)/λ (from Real.log_le_sub_one_of_pos)! have hinv_pos : 0 < (secondEig hrev hπ_pos hcard)⁻¹ := inv_pos.mpr hlam_pos have hlog_inv : Real.log (secondEig hrev hπ_pos hcard)⁻¹ ≤ (secondEig hrev hπ_pos hcard)⁻¹ - 1 := Real.log_le_sub_one_of_pos hinv_pos rw [Real.log_inv] at hlog_inv have hγ_pos : 0 < spectralGap hrev hπ_pos hcard := by unfold spectralGap; linarith have hratio : (secondEig hrev hπ_pos hcard)⁻¹ - 1 = spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard := by unfold spectralGap; field_simp [ne_of_gt hlam_pos] have hlog_lam_ge : -(spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard) ≤ Real.log (secondEig hrev hπ_pos hcard) := by linarith have hmul_t : -(t : ℝ) * (spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard) ≤ Real.log (2 * ε) := by have htnn : (0 : ℝ) ≤ t := Nat.cast_nonneg t calc -(t : ℝ) * (spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard) = (t : ℝ) * -(spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard) := by ring _ ≤ (t : ℝ) * Real.log (secondEig hrev hπ_pos hcard) := mul_le_mul_of_nonneg_left hlog_lam_ge htnn _ ≤ Real.log (2 * ε) := hlog_le have hlog_recip : Real.log (1 / (2 * ε)) = -Real.log (2 * ε) := by rw [one_div, Real.log_inv] rw [hlog_recip] have hcoeff : 1 / spectralGap hrev hπ_pos hcard - 1 = secondEig hrev hπ_pos hcard / spectralGap hrev hπ_pos hcard := by have hγne : 1 - secondEig hrev hπ_pos hcard ≠ 0 := ne_of_gt hγ_pos unfold spectralGap field_simp [hγne] ring rw [hcoeff] have hmul_pos := mul_le_mul_of_nonneg_left (show -Real.log (2 * ε) ≤ (t : ℝ) * (spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard) by linarith) (le_of_lt (div_pos hlam_pos hγ_pos)) have hcancel : secondEig hrev hπ_pos hcard / spectralGap hrev hπ_pos hcard * ((t : ℝ) * (spectralGap hrev hπ_pos hcard / secondEig hrev hπ_pos hcard)) = (t : ℝ) := by field_simp [ne_of_gt hγ_pos, ne_of_gt hlam_pos] linarith /-! ### Lazy Markov Chains: Guaranteed Nonnegative Spectrum `[0, 1]` -/ /-- The `α`-lazy version of kernel `K`: `P_α = (1 - α) I + α P` for `α ∈ [0, 1]`. -/ def MarkovKernel.lazyAlpha (K : MarkovKernel Ω) (α : ℝ) (h0 : 0 ≤ α) (h1 : α ≤ 1) : MarkovKernel Ω where P x y := (1 - α) * (if x = y then 1 else 0) + α * K.P x y nonneg x y := add_nonneg (mul_nonneg (by linarith) (by split_ifs <;> norm_num)) (mul_nonneg h0 (K.nonneg x y)) row_sum_one x := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, K.row_sum_one x] simp /-- Standard `1/2`-lazy Markov chain `P_lazy = (1/2) I + (1/2) P`. -/ def MarkovKernel.lazy (K : MarkovKernel Ω) : MarkovKernel Ω := K.lazyAlpha (1 / 2) (by norm_num) (by norm_num) lemma MarkovKernel.IsReversible.lazyAlpha {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) {α : ℝ} (h0 : 0 ≤ α) (h1 : α ≤ 1) : (K.lazyAlpha α h0 h1).IsReversible π := by intro x y simp only [MarkovKernel.lazyAlpha, mul_add] have hdiag : π x * ((1 - α) * (if x = y then 1 else 0)) = π y * ((1 - α) * (if y = x then 1 else 0)) := by by_cases h : x = y · subst h; simp · rw [if_neg h, if_neg (Ne.symm h)]; ring have hK : π x * (α * K.P x y) = π y * (α * K.P y x) := by calc π x * (α * K.P x y) = α * (π x * K.P x y) := by ring _ = α * (π y * K.P y x) := by rw [hrev x y] _ = π y * (α * K.P y x) := by ring linarith lemma symMat_lazyAlpha (K : MarkovKernel Ω) (π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) {α : ℝ} (h0 : 0 ≤ α) (h1 : α ≤ 1) : symMat (K.lazyAlpha α h0 h1) π = (1 - α) • (1 : Matrix Ω Ω ℝ) + α • symMat K π := by ext x y simp only [symMat, MarkovKernel.lazyAlpha, Matrix.of_apply, Matrix.add_apply, Matrix.smul_apply, Matrix.one_apply, smul_eq_mul] have hy := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos y)) by_cases h : x = y · subst h; field_simp [hy] · rw [if_neg h]; field_simp [hy]; ring /-- **Lazy-Chain Positivity Theorem**: for `0 ≤ α ≤ 1/2`, the symmetric similarity matrix of `K.lazyAlpha α` is positive semidefinite, so ALL its eigenvalues lie in `[0, 1]`. -/ theorem lazyAlpha_symMat_posSemidef {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) {α : ℝ} (h0 : 0 ≤ α) (hhalf : α ≤ 1 / 2) : (symMat (K.lazyAlpha α h0 (by linarith)) π).PosSemidef := by rw [Matrix.posSemidef_iff_dotProduct_mulVec] refine ⟨symMat_isHermitian (hrev.lazyAlpha h0 (by linarith)) hπ_pos, fun v => ?_⟩ simp only [star_trivial] rw [symMat_lazyAlpha K π hπ_pos h0 (by linarith), Matrix.add_mulVec, Matrix.smul_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, dotProduct_add, dotProduct_smul, dotProduct_smul, smul_eq_mul, smul_eq_mul] let f : Ω → ℝ := fun x => v x / Real.sqrt (π x) have hf_norm : l2NormSq π f = dotProduct v v := by unfold l2NormSq l2Inner dotProduct f refine Finset.sum_congr rfl fun x _ => ?_ have hx := ne_of_gt (Real.sqrt_pos.mpr (hπ_pos x)) field_simp [hx]; rw [Real.sq_sqrt (le_of_lt (hπ_pos x))]; ring have hge := (abs_le.mp (abs_l2Inner_apply_le_l2NormSq hrev f)).1 rw [symMat_quad_eq_l2Inner K π hπ_pos v] have hnn : 0 ≤ l2NormSq π f := l2NormSq_nonneg π f rw [← hf_norm] nlinarith /-- All eigenvalues of the standard `1/2`-lazy reversible chain lie in `[0, 1]`. -/ theorem lazy_eigenvalues_in_unit_interval {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (k : Fin (Fintype.card Ω)) : 0 ≤ (symMat_isHermitian (hrev.lazyAlpha (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num)) hπ_pos).eigenvalues₀ k ∧ (symMat_isHermitian (hrev.lazyAlpha (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num)) hπ_pos).eigenvalues₀ k ≤ 1 := by have hpsd := lazyAlpha_symMat_posSemidef hrev hπ_pos (by norm_num : (0 : ℝ) ≤ 1 / 2) (le_refl _) have hrevL := hrev.lazyAlpha (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num) have hnonneg : 0 ≤ (symMat_isHermitian hrevL hπ_pos).eigenvalues₀ k := by have heq : (symMat_isHermitian hrevL hπ_pos).eigenvalues₀ k = hpsd.isHermitian.eigenvalues (Fintype.equivOfCardEq (Fintype.card_fin _) k) := by simp [Matrix.IsHermitian.eigenvalues] rw [heq] exact hpsd.eigenvalues_nonneg _ exact ⟨hnonneg, (abs_le.mp (symMat_eigenvalues₀_abs_le_one hrevL hπ_pos k)).2⟩ /-- For the `1/2`-lazy reversible chain, `λ_* = λ₂` and `absSpectralGap = spectralGap`. -/ theorem lazy_lambdaStar_eq_secondEig {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : lambdaStar (hrev.lazyAlpha (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num)) hπ_pos hcard = secondEig (hrev.lazyAlpha (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num)) hπ_pos hcard := by unfold lambdaStar have hmin_nn := (lazy_eigenvalues_in_unit_interval hrev hπ_pos ⟨Fintype.card Ω - 1, by omega⟩).1 have hsec_nn := (lazy_eigenvalues_in_unit_interval hrev hπ_pos ⟨1, by omega⟩).1 exact max_eq_left (by unfold minEig secondEig; linarith) /-- Exact Dirichlet form scaling under `α`-laziness: `E_{P_α}(f, f) = α · E_P(f, f)`. -/ theorem dirichletForm_lazyAlpha (K : MarkovKernel Ω) (π : Dist Ω) {α : ℝ} (h0 : 0 ≤ α) (h1 : α ≤ 1) (f : Ω → ℝ) : dirichletForm (K.lazyAlpha α h0 h1) π f = α * dirichletForm K π f := by unfold dirichletForm MarkovKernel.lazyAlpha calc (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * ((1 - α) * (if x = y then 1 else 0) + α * K.P x y) * (f x - f y) ^ 2 = (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, α * (π x * K.P x y * (f x - f y) ^ 2) := by congr 1; refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ by_cases h : x = y · subst h; simp · rw [if_neg h]; ring _ = α * ((1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * (f x - f y) ^ 2) := by simp_rw [← Finset.mul_sum]; ring end SymMatSpectrum end Pillar2_SpectralGap /-! ============================================================================ PILLAR 3: BOTTLENECK RATIO, FULL DISCRETE CHEEGER INEQUALITY & CANONICAL PATHS ============================================================================ -/ section Pillar3_CheegerCanonicalPaths variable {Ω : Type*} [Fintype Ω] [DecidableEq Ω] /-- Ergodic flow `Q(A, B) = ∑_{x ∈ A} ∑_{y ∈ B} π(x) P(x, y)`. -/ def ergodicFlow (K : MarkovKernel Ω) (π : Dist Ω) (A B : Finset Ω) : ℝ := ∑ x ∈ A, ∑ y ∈ B, π x * K.P x y /-- Cut conductance `Φ(S) = Q(S, Sᶜ) / π(S)`. -/ def cutConductance (K : MarkovKernel Ω) (π : Dist Ω) (S : Finset Ω) : ℝ := ergodicFlow K π S Sᶜ / π.prob S /-- Symmetric cut conductance `Φ_sym(S) = Q(S, Sᶜ) / min(π(S), π(Sᶜ))`, well-defined for EVERY proper nonempty subset `S` (even if a single state has mass `> 1/2`). -/ def symCutConductance (K : MarkovKernel Ω) (π : Dist Ω) (S : Finset Ω) : ℝ := ergodicFlow K π S Sᶜ / min (π.prob S) (π.prob Sᶜ) /-- Family of all proper nonempty subsets of `Ω`. -/ def properCuts (Ω : Type*) [Fintype Ω] [DecidableEq Ω] : Finset (Finset Ω) := Finset.univ.filter fun S : Finset Ω => S.Nonempty ∧ S ≠ Finset.univ lemma properCuts_nonempty (hcard : 2 ≤ Fintype.card Ω) : (properCuts Ω).Nonempty := by have hne : Nonempty Ω := Fintype.card_pos_iff.mp (by omega) let x₀ : Ω := Classical.choice hne refine ⟨{x₀}, Finset.mem_filter.mpr ⟨Finset.mem_univ _, Finset.singleton_nonempty x₀, ?_⟩⟩ intro h have h1 : Fintype.card Ω = 1 := by calc Fintype.card Ω = (Finset.univ : Finset Ω).card := rfl _ = ({x₀} : Finset Ω).card := by rw [← h] _ = 1 := Finset.card_singleton x₀ omega /-- **Bottleneck Ratio / Cheeger Conductance** `Φ_* = min_{∅ ≠ S ⊊ Ω} Q(S, Sᶜ) / min(π(S), π(Sᶜ))` (equals `min_{0 < π(S) ≤ 1/2} Q(S, Sᶜ) / π(S)` for reversible chains). -/ def bottleneckRatio (K : MarkovKernel Ω) (π : Dist Ω) (hcard : 2 ≤ Fintype.card Ω) : ℝ := Finset.inf' (properCuts Ω) (properCuts_nonempty hcard) (fun S => symCutConductance K π S) omit [DecidableEq Ω] in lemma ergodicFlow_nonneg (K : MarkovKernel Ω) (π : Dist Ω) (A B : Finset Ω) : 0 ≤ ergodicFlow K π A B := Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => mul_nonneg (π.nonneg x) (K.nonneg x y) omit [DecidableEq Ω] in lemma ergodicFlow_symm {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (A B : Finset Ω) : ergodicFlow K π A B = ergodicFlow K π B A := by unfold ergodicFlow rw [Finset.sum_comm] exact Finset.sum_congr rfl fun y _ => Finset.sum_congr rfl fun x _ => hrev x y omit [DecidableEq Ω] in lemma ergodicFlow_le_prob (K : MarkovKernel Ω) (π : Dist Ω) (A B : Finset Ω) : ergodicFlow K π A B ≤ π.prob A := by unfold ergodicFlow Dist.prob refine Finset.sum_le_sum fun x _ => ?_ calc ∑ y ∈ B, π x * K.P x y ≤ ∑ y : Ω, π x * K.P x y := Finset.sum_le_univ_sum_of_nonneg fun y => mul_nonneg (π.nonneg x) (K.nonneg x y) _ = π x * ∑ y : Ω, K.P x y := (Finset.mul_sum ..).symm _ = π x := by rw [K.row_sum_one x, mul_one] /-- Exact indicator Dirichlet identity: `E(1_S, 1_S) = Q(S, Sᶜ)` for reversible chains. -/ theorem dirichletForm_indicator_eq_ergodicFlow {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (S : Finset Ω) : dirichletForm K π (fun x => if x ∈ S then 1 else 0) = ergodicFlow K π S Sᶜ := by unfold dirichletForm ergodicFlow have hsplit : ∑ x : Ω, ∑ y : Ω, π x * K.P x y * ((if x ∈ S then (1 : ℝ) else 0) - (if y ∈ S then 1 else 0)) ^ 2 = (∑ x ∈ S, ∑ y ∈ Sᶜ, π x * K.P x y) + (∑ x ∈ Sᶜ, ∑ y ∈ S, π x * K.P x y) := by rw [← Finset.sum_add_sum_compl S] congr 1 · refine Finset.sum_congr rfl fun x hx => ?_ rw [← Finset.sum_add_sum_compl S] have h0 : ∑ y ∈ S, π x * K.P x y * ((if x ∈ S then (1 : ℝ) else 0) - (if y ∈ S then 1 else 0)) ^ 2 = 0 := Finset.sum_eq_zero fun y hy => by simp [hx, hy] rw [h0, zero_add] refine Finset.sum_congr rfl fun y hy => ?_ have hyn : y ∉ S := Finset.mem_compl.mp hy simp [hx, hyn] · refine Finset.sum_congr rfl fun x hx => ?_ have hxn : x ∉ S := Finset.mem_compl.mp hx rw [← Finset.sum_add_sum_compl S] have h0 : ∑ y ∈ Sᶜ, π x * K.P x y * ((if x ∈ S then (1 : ℝ) else 0) - (if y ∈ S then 1 else 0)) ^ 2 = 0 := Finset.sum_eq_zero fun y hy => by simp [hxn, Finset.mem_compl.mp hy] rw [h0, add_zero] refine Finset.sum_congr rfl fun y hy => by simp [hxn, hy] rw [hsplit] have hsym : ∑ x ∈ Sᶜ, ∑ y ∈ S, π x * K.P x y = ∑ x ∈ S, ∑ y ∈ Sᶜ, π x * K.P x y := ergodicFlow_symm hrev Sᶜ S rw [hsym]; ring omit [DecidableEq Ω] in lemma prob_pos_of_nonempty {π : Dist Ω} (hπ_pos : ∀ x, 0 < π x) {S : Finset Ω} (hS : S.Nonempty) : 0 < π.prob S := by obtain ⟨x, hx⟩ := hS exact lt_of_lt_of_le (hπ_pos x) (Finset.single_le_sum (fun y _ => π.nonneg y) hx) lemma compl_nonempty_of_ne_univ {S : Finset Ω} (h : S ≠ Finset.univ) : Sᶜ.Nonempty := by by_contra h' rw [Finset.not_nonempty_iff_eq_empty, Finset.compl_eq_empty_iff] at h' exact h h' lemma bottleneckRatio_nonneg (K : MarkovKernel Ω) (π : Dist Ω) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : 0 ≤ bottleneckRatio K π hcard := by apply Finset.le_inf' intro S hS rcases Finset.mem_filter.mp hS with ⟨_, hSne, hSnu⟩ have hSc : Sᶜ.Nonempty := compl_nonempty_of_ne_univ hSnu exact div_nonneg (ergodicFlow_nonneg K π S Sᶜ) (le_of_lt (lt_min (prob_pos_of_nonempty hπ_pos hSne) (prob_pos_of_nonempty hπ_pos hSc))) lemma bottleneckRatio_le_one {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : bottleneckRatio K π hcard ≤ 1 := by obtain ⟨S, hS⟩ := properCuts_nonempty hcard have hle : bottleneckRatio K π hcard ≤ symCutConductance K π S := Finset.inf'_le _ hS rcases Finset.mem_filter.mp hS with ⟨_, hSne, hSnu⟩ have hSc : Sᶜ.Nonempty := compl_nonempty_of_ne_univ hSnu have hmin_pos : 0 < min (π.prob S) (π.prob Sᶜ) := lt_min (prob_pos_of_nonempty hπ_pos hSne) (prob_pos_of_nonempty hπ_pos hSc) have hQ_le : ergodicFlow K π S Sᶜ ≤ min (π.prob S) (π.prob Sᶜ) := by apply le_min (ergodicFlow_le_prob K π S Sᶜ) rw [ergodicFlow_symm hrev S Sᶜ] exact ergodicFlow_le_prob K π Sᶜ S exact le_trans hle ((div_le_one hmin_pos).mpr hQ_le) /-- For every subset `S` with `S.Nonempty` and `π(S) ≤ 1/2`, `Φ_* ≤ Q(S, Sᶜ) / π(S) = Φ(S)`. -/ theorem bottleneckRatio_le_cutConductance (K : MarkovKernel Ω) (π : Dist Ω) (hcard : 2 ≤ Fintype.card Ω) {S : Finset Ω} (hSne : S.Nonempty) (hS_half : π.prob S ≤ 1 / 2) : bottleneckRatio K π hcard ≤ cutConductance K π S := by have hSnu : S ≠ Finset.univ := by intro h; rw [h] at hS_half have h1 : π.prob Finset.univ = 1 := π.sum_one linarith have hmem : S ∈ properCuts Ω := Finset.mem_filter.mpr ⟨Finset.mem_univ S, hSne, hSnu⟩ have hle : bottleneckRatio K π hcard ≤ symCutConductance K π S := Finset.inf'_le _ hmem have hcompl : π.prob S ≤ π.prob Sᶜ := by rw [π.prob_compl]; linarith have hsym : symCutConductance K π S = cutConductance K π S := by unfold symCutConductance cutConductance rw [min_eq_left hcompl] rwa [hsym] at hle /-- **Easy Half of Discrete Cheeger (Cut-Wise Sharp Form)**: for EVERY proper nonempty cut `S`, `γ ≤ Q(S, Sᶜ) / (π(S) · (1 - π(S))) ≤ 2 · Φ_sym(S)`. -/ theorem cheeger_upper_bound_cut {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) {S : Finset Ω} (hSne : S.Nonempty) (hSnu : S ≠ Finset.univ) : spectralGap hrev hπ_pos hcard ≤ ergodicFlow K π S Sᶜ / (π.prob S * π.prob Sᶜ) ∧ spectralGap hrev hπ_pos hcard ≤ 2 * symCutConductance K π S := by let f : Ω → ℝ := fun x => if x ∈ S then 1 else 0 have hf_exp : π.expect f = π.prob S := by unfold Dist.expect Dist.prob f rw [← Finset.sum_add_sum_compl S] have h1 : ∑ x ∈ S, π x * (if x ∈ S then (1 : ℝ) else 0) = ∑ x ∈ S, π x := Finset.sum_congr rfl fun x hx => by simp [hx] have h2 : ∑ x ∈ Sᶜ, π x * (if x ∈ S then (1 : ℝ) else 0) = 0 := Finset.sum_eq_zero fun x hx => by simp [Finset.mem_compl.mp hx] rw [h1, h2, add_zero] have hf_var : π.variance f = π.prob S * π.prob Sᶜ := by rw [π.variance_eq_expect_sq_sub f, hf_exp, π.prob_compl] have hsq : π.expect (fun x => f x ^ 2) = π.prob S := by have : (fun x => f x ^ 2) = f := by ext x; dsimp only [f]; split_ifs <;> norm_num rw [this, hf_exp] rw [hsq]; ring have hSc : Sᶜ.Nonempty := compl_nonempty_of_ne_univ hSnu have hpS : 0 < π.prob S := prob_pos_of_nonempty hπ_pos hSne have hpSc : 0 < π.prob Sᶜ := prob_pos_of_nonempty hπ_pos hSc have hpoinc := spectralGap_mul_variance_le_dirichlet hrev hπ_pos hcard f rw [hf_var, dirichletForm_indicator_eq_ergodicFlow hrev S] at hpoinc have h1 : spectralGap hrev hπ_pos hcard ≤ ergodicFlow K π S Sᶜ / (π.prob S * π.prob Sᶜ) := (le_div_iff₀ (mul_pos hpS hpSc)).mpr hpoinc refine ⟨h1, ?_⟩ have hsum1 : π.prob S + π.prob Sᶜ = 1 := by rw [π.prob_compl]; ring have hmax_ge : (1 / 2 : ℝ) ≤ max (π.prob S) (π.prob Sᶜ) := by rcases le_total (π.prob S) (π.prob Sᶜ) with h | h · rw [max_eq_right h]; linarith · rw [max_eq_left h]; linarith have hprod : (1 / 2 : ℝ) * min (π.prob S) (π.prob Sᶜ) ≤ π.prob S * π.prob Sᶜ := by have hmul : min (π.prob S) (π.prob Sᶜ) * max (π.prob S) (π.prob Sᶜ) = π.prob S * π.prob Sᶜ := min_mul_max _ _ have hmin_nn : 0 ≤ min (π.prob S) (π.prob Sᶜ) := le_of_lt (lt_min hpS hpSc) nlinarith have hQ_nn : 0 ≤ ergodicFlow K π S Sᶜ := ergodicFlow_nonneg K π S Sᶜ have hmin_pos : 0 < min (π.prob S) (π.prob Sᶜ) := lt_min hpS hpSc have h2 : ergodicFlow K π S Sᶜ / (π.prob S * π.prob Sᶜ) ≤ ergodicFlow K π S Sᶜ / ((1 / 2 : ℝ) * min (π.prob S) (π.prob Sᶜ)) := div_le_div_of_nonneg_left hQ_nn (mul_pos (by norm_num) hmin_pos) hprod have h3 : ergodicFlow K π S Sᶜ / ((1 / 2 : ℝ) * min (π.prob S) (π.prob Sᶜ)) = 2 * symCutConductance K π S := by unfold symCutConductance; field_simp [ne_of_gt hmin_pos] linarith /-- **Easy Half of Discrete Cheeger Inequality**: `γ ≤ 2 · Φ_*`. -/ theorem cheeger_upper_bound {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : spectralGap hrev hπ_pos hcard ≤ 2 * bottleneckRatio K π hcard := by have hle : spectralGap hrev hπ_pos hcard / 2 ≤ bottleneckRatio K π hcard := by apply Finset.le_inf' intro S hS rcases Finset.mem_filter.mp hS with ⟨_, hSne, hSnu⟩ linarith [(cheeger_upper_bound_cut hrev hπ_pos hcard hSne hSnu).2] linarith /-! ### Hard Half of Discrete Cheeger (Lawler–Sokal / Sinclair–Jerrum Co-Area Lower Bound) -/ omit [DecidableEq Ω] in /-- **Truncation Lemma for Eigenfunctions**: if `P f = (1 - γ) f`, then `g(x) = max (f x) 0` satisfies `E(g, g) ≤ γ · ‖g‖²_{L^2(π)}` (for ALL reversible chains, without assuming laziness!). -/ theorem dirichletForm_posPart_le_of_eig {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) {f : Ω → ℝ} {lam : ℝ} (hf_eig : K.apply f = lam • f) : dirichletForm K π (fun x => max (f x) 0) ≤ (1 - lam) * l2NormSq π (fun x => max (f x) 0) := by let g : Ω → ℝ := fun x => max (f x) 0 rw [dirichletForm_eq_l2Inner_sub hrev g] -- Suffices to show lam * ‖g‖² ≤ ⟨P g, g⟩_π! suffices h : lam * l2NormSq π g ≤ l2Inner π (K.apply g) g by linarith unfold l2NormSq l2Inner rw [Finset.mul_sum] refine Finset.sum_le_sum fun x _ => ?_ by_cases hfx : 0 < f x · have hgx : g x = f x := max_eq_left (le_of_lt hfx) have hPg_ge : lam * f x ≤ K.apply g x := by have hfx_eig : K.apply f x = lam * f x := by have := congrFun hf_eig x simpa [Pi.smul_apply, smul_eq_mul] using this rw [← hfx_eig] unfold MarkovKernel.apply refine Finset.sum_le_sum fun y _ => mul_le_mul_of_nonneg_left (le_max_left (f y) 0) (K.nonneg x y) have hcoeff : 0 ≤ π x * g x := mul_nonneg (π.nonneg x) (le_max_right _ _) rw [hgx] at hcoeff ⊢ nlinarith · have hgx : g x = 0 := max_eq_right (not_lt.mp hfx) simp [hgx] omit [DecidableEq Ω] in /-- **Sharp Cauchy–Schwarz Co-Area Bound**: for any nonnegative function `g : Ω → ℝ`, letting `J = (1/2) ∑_{x,y} π(x) P(x, y) |g(x)² - g(y)²|`, `J² ≤ E(g, g) · (2 ‖g‖²_{L^2(π)} - E(g, g))`. -/ theorem coarea_sq_le_dirichlet_sharp {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) {g : Ω → ℝ} (hg : ∀ x, 0 ≤ g x) : ((1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2|) ^ 2 ≤ dirichletForm K π g * (2 * l2NormSq π g - dirichletForm K π g) := by -- Use Cauchy–Schwarz on Ω × Ω with a(x,y) = √(Q(x,y)) |g x - g y| and b(x,y) = √(Q(x,y)) (g x + g y)! let a : Ω × Ω → ℝ := fun p => Real.sqrt (π p.1 * K.P p.1 p.2) * |g p.1 - g p.2| let b : Ω × Ω → ℝ := fun p => Real.sqrt (π p.1 * K.P p.1 p.2) * (g p.1 + g p.2) have hcs := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset (Ω × Ω)) a b have hlhs : ∑ p : Ω × Ω, a p * b p = ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2| := by rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ dsimp only [a, b] have hq_nn : 0 ≤ π x * K.P x y := mul_nonneg (π.nonneg x) (K.nonneg x y) have hsq : Real.sqrt (π x * K.P x y) * Real.sqrt (π x * K.P x y) = π x * K.P x y := Real.mul_self_sqrt hq_nn have habs : |g x - g y| * (g x + g y) = |g x ^ 2 - g y ^ 2| := by have hsum_nn : 0 ≤ g x + g y := add_nonneg (hg x) (hg y) rw [← abs_of_nonneg hsum_nn, ← abs_mul] congr 1; ring calc Real.sqrt (π x * K.P x y) * |g x - g y| * (Real.sqrt (π x * K.P x y) * (g x + g y)) = (Real.sqrt (π x * K.P x y) * Real.sqrt (π x * K.P x y)) * (|g x - g y| * (g x + g y)) := by ring _ = π x * K.P x y * |g x ^ 2 - g y ^ 2| := by rw [hsq, habs] have hr1 : ∑ p : Ω × Ω, a p ^ 2 = 2 * dirichletForm K π g := by rw [Fintype.sum_prod_type] unfold dirichletForm have hsum : ∑ x : Ω, ∑ y : Ω, a (x, y) ^ 2 = ∑ x : Ω, ∑ y : Ω, π x * K.P x y * (g x - g y) ^ 2 := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ dsimp only [a] rw [mul_pow, Real.sq_sqrt (mul_nonneg (π.nonneg x) (K.nonneg x y)), sq_abs] rw [hsum]; ring have hr2 : ∑ p : Ω × Ω, b p ^ 2 = 2 * (2 * l2NormSq π g - dirichletForm K π g) := by rw [Fintype.sum_prod_type] have hsum : ∑ x : Ω, ∑ y : Ω, b (x, y) ^ 2 = ∑ x : Ω, ∑ y : Ω, π x * K.P x y * (g x + g y) ^ 2 := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ dsimp only [b] rw [mul_pow, Real.sq_sqrt (mul_nonneg (π.nonneg x) (K.nonneg x y))] rw [hsum] -- Use parallelogram identity: (g x + g y)² + (g x - g y)² = 2 g x² + 2 g y²! have hpara : (∑ x : Ω, ∑ y : Ω, π x * K.P x y * (g x + g y) ^ 2) + (∑ x : Ω, ∑ y : Ω, π x * K.P x y * (g x - g y) ^ 2) = 4 * l2NormSq π g := by have hcomb : ∀ x y : Ω, π x * K.P x y * (g x + g y) ^ 2 + π x * K.P x y * (g x - g y) ^ 2 = 2 * (π x * K.P x y * g x ^ 2) + 2 * (π x * K.P x y * g y ^ 2) := fun x y => by ring rw [← Finset.sum_add_distrib] have hrew : ∑ x : Ω, (∑ y : Ω, π x * K.P x y * (g x + g y) ^ 2 + ∑ y : Ω, π x * K.P x y * (g x - g y) ^ 2) = 2 * (∑ x : Ω, ∑ y : Ω, π x * K.P x y * g x ^ 2) + 2 * (∑ x : Ω, ∑ y : Ω, π x * K.P x y * g y ^ 2) := by simp_rw [← Finset.sum_add_distrib, hcomb, Finset.sum_add_distrib, ← Finset.mul_sum] rw [hrew] have h1 : ∑ x : Ω, ∑ y : Ω, π x * K.P x y * g x ^ 2 = l2NormSq π g := by unfold l2NormSq l2Inner refine Finset.sum_congr rfl fun x _ => ?_ have : ∑ y, π x * K.P x y * g x ^ 2 = (π x * g x ^ 2) * ∑ y, K.P x y := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun y _ => by ring rw [this, K.row_sum_one x]; ring have h2 : ∑ x : Ω, ∑ y : Ω, π x * K.P x y * g y ^ 2 = l2NormSq π g := by calc ∑ x, ∑ y, π x * K.P x y * g y ^ 2 = ∑ x, ∑ y, π y * K.P y x * g y ^ 2 := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by rw [hrev x y] _ = ∑ y, ∑ x, π y * K.P y x * g y ^ 2 := Finset.sum_comm _ = l2NormSq π g := by unfold l2NormSq l2Inner refine Finset.sum_congr rfl fun y _ => ?_ have : ∑ x, π y * K.P y x * g y ^ 2 = (π y * g y ^ 2) * ∑ x, K.P y x := by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun x _ => by ring rw [this, K.row_sum_one y]; ring rw [h1, h2]; ring unfold dirichletForm linarith rw [hlhs, hr1, hr2] at hcs have hq : ((1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2|) ^ 2 = (1 / 4 : ℝ) * (∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2|) ^ 2 := by ring linarith /-- **Discrete Co-Area Lower Bound**: for any nonnegative `g : Ω → ℝ` supported on a set `S_pos = {x | 0 < g x}` with `π(S_pos) ≤ 1/2`, `Φ_* · ‖g‖²_{L^2(π)} ≤ (1/2) ∑_{x, y} π(x) P(x, y) |g(x)² - g(y)²|`. -/ theorem coarea_ge_bottleneck_mul_normSq {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hcard : 2 ≤ Fintype.card Ω) {g : Ω → ℝ} (hg : ∀ x, 0 ≤ g x) (hsupp : π.prob (Finset.univ.filter fun x => 0 < g x) ≤ 1 / 2) : bottleneckRatio K π hcard * l2NormSq π g ≤ (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2| := by -- Sort Ω in descending order of g via Tuple.sort! let d := Fintype.card Ω let e₀ : Fin d ≃ Ω := (Fintype.equivFin Ω).symm let perm : Equiv.Perm (Fin d) := Tuple.sort (fun i : Fin d => -(g (e₀ i))) let v : Fin d ≃ Ω := perm.trans e₀ have hv_anti : ∀ i j : Fin d, i ≤ j → g (v j) ≤ g (v i) := fun i j hij => by have hmono := Tuple.monotone_sort (fun k : Fin d => -(g (e₀ k))) hij simp only [Function.comp_apply, v, Equiv.trans_apply] at hmono ⊢ linarith have hv_sq_anti : ∀ i j : Fin d, i ≤ j → g (v j) ^ 2 ≤ g (v i) ^ 2 := fun i j hij => by have h1 := hv_anti i j hij nlinarith [hg (v j), hg (v i)] -- Check that the minimum element g(v (d-1)) = 0 (since π({g > 0}) ≤ 1/2 < 1)! have hlast_zero : g (v ⟨d - 1, by omega⟩) = 0 := by by_contra hne0 have hpos_last : 0 < g (v ⟨d - 1, by omega⟩) := lt_of_le_of_ne (hg _) (Ne.symm hne0) have hall_pos : ∀ x : Ω, 0 < g x := fun x => by have hi : v.symm x ≤ ⟨d - 1, by omega⟩ := by change (v.symm x).val ≤ d - 1; omega have hge := hv_anti (v.symm x) ⟨d - 1, by omega⟩ hi rw [v.apply_symm_apply] at hge linarith have hfilt : Finset.univ.filter (fun x => 0 < g x) = Finset.univ := by ext x; simp [hall_pos x] rw [hfilt] at hsupp have h1 : π.prob Finset.univ = 1 := π.sum_one linarith -- Level sets S_k = {v i | i ≤ k} for k : Fin (d - 1)! let S : Fin (d - 1) → Finset Ω := fun k => (Finset.univ.filter fun i : Fin d => i.val ≤ k.val).image v -- Exact telescoping co-area identity: -- (1/2) ∑_{x,y} Q(x,y) |g(x)² - g(y)²| = ∑_{k : Fin (d-1)} (g(v k)² - g(v (k+1))²) * Q(S_k, S_kᶜ)! have hcoarea_eq : (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2| = ∑ k : Fin (d - 1), (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * ergodicFlow K π (S k) (S k)ᶜ := by -- Reindex the double sum over Fin d × Fin d via v! have hreidx : ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2| = ∑ i : Fin d, ∑ j : Fin d, π (v i) * K.P (v i) (v j) * |g (v i) ^ 2 - g (v j) ^ 2| := by rw [← Equiv.sum_comp v] refine Finset.sum_congr rfl fun i _ => (Equiv.sum_comp v _).symm -- Split into i < j and j < i (diagonal i = j contributes 0), using reversibility symmetry! have hhalf : (1 / 2 : ℝ) * ∑ i : Fin d, ∑ j : Fin d, π (v i) * K.P (v i) (v j) * |g (v i) ^ 2 - g (v j) ^ 2| = ∑ i : Fin d, ∑ j : Fin d, if i.val < j.val then π (v i) * K.P (v i) (v j) * (g (v i) ^ 2 - g (v j) ^ 2) else 0 := by have hsym_ij : ∑ i : Fin d, ∑ j : Fin d, (if j.val < i.val then π (v i) * K.P (v i) (v j) * (g (v j) ^ 2 - g (v i) ^ 2) else 0) = ∑ i : Fin d, ∑ j : Fin d, (if i.val < j.val then π (v i) * K.P (v i) (v j) * (g (v i) ^ 2 - g (v j) ^ 2) else 0) := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_ split_ifs · rw [hrev (v j) (v i)] · rfl have htot : ∑ i : Fin d, ∑ j : Fin d, π (v i) * K.P (v i) (v j) * |g (v i) ^ 2 - g (v j) ^ 2| = (∑ i : Fin d, ∑ j : Fin d, if i.val < j.val then π (v i) * K.P (v i) (v j) * (g (v i) ^ 2 - g (v j) ^ 2) else 0) + (∑ i : Fin d, ∑ j : Fin d, if j.val < i.val then π (v i) * K.P (v i) (v j) * (g (v j) ^ 2 - g (v i) ^ 2) else 0) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun j _ => ?_ rcases lt_trichotomy i.val j.val with hij | hij | hji · rw [if_pos hij, if_neg (by omega), add_zero] have hge : g (v j) ^ 2 ≤ g (v i) ^ 2 := hv_sq_anti i j (le_of_lt hij) rw [abs_of_nonneg (sub_nonneg.mpr hge)] · have heq : i = j := Fin.ext hij subst heq; simp · rw [if_neg (by omega), if_pos hji, zero_add] have hge : g (v i) ^ 2 ≤ g (v j) ^ 2 := hv_sq_anti j i (le_of_lt hji) rw [abs_sub_comm, abs_of_nonneg (sub_nonneg.mpr hge)] linarith rw [hreidx, hhalf] -- Telescope g(v i)² - g(v j)² = ∑_{k : i ≤ k < j} (g(v k)² - g(v (k+1))²) for i < j! let valSq : ℕ → ℝ := fun k => if hk : k < d then g (v ⟨k, hk⟩) ^ 2 else 0 have htele_nat : ∀ a b : ℕ, a ≤ b → valSq a - valSq b = ∑ k ∈ Finset.Ico a b, (valSq k - valSq (k + 1)) := by intro a b hab induction b with | zero => have ha0 : a = 0 := by omega subst ha0; simp | succ b ih => rcases eq_or_lt_of_le hab with rfl | hlt · simp · rw [Finset.sum_Ico_succ_top (by omega), ← ih (by omega)]; ring have htele : ∀ i j : Fin d, i.val < j.val → g (v i) ^ 2 - g (v j) ^ 2 = ∑ k : Fin (d - 1), if i.val ≤ k.val ∧ k.val < j.val then g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2 else 0 := fun i j hij => by have h1 := htele_nat i.val j.val (le_of_lt hij) have hvi : valSq i.val = g (v i) ^ 2 := by simp [valSq, i.isLt] have hvj : valSq j.val = g (v j) ^ 2 := by simp [valSq, j.isLt] rw [hvi, hvj] at h1 rw [h1] symm rw [← Finset.sum_filter] refine Finset.sum_bij (fun k _ => k.val) ?_ ?_ ?_ ?_ · intro k hk simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hk exact Finset.mem_Ico.mpr hk · intro k₁ _ k₂ _ h; exact Fin.ext h · intro m hm rcases Finset.mem_Ico.mp hm with ⟨hm1, hm2⟩ refine ⟨⟨m, by omega⟩, ?_, rfl⟩ simp [hm1, hm2] · intro k hk simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hk have hk1 : k.val < d := by omega have hk2 : k.val + 1 < d := by omega simp [valSq, hk1, hk2] calc ∑ i : Fin d, ∑ j : Fin d, (if i.val < j.val then π (v i) * K.P (v i) (v j) * (g (v i) ^ 2 - g (v j) ^ 2) else 0) = ∑ i : Fin d, ∑ j : Fin d, ∑ k : Fin (d - 1), if i.val ≤ k.val ∧ k.val < j.val then (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (π (v i) * K.P (v i) (v j)) else 0 := by refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_ by_cases hij : i.val < j.val · rw [if_pos hij, htele i j hij, Finset.mul_sum] refine Finset.sum_congr rfl fun k _ => ?_ split_ifs <;> ring · rw [if_neg hij] symm refine Finset.sum_eq_zero fun k _ => ?_ rw [if_neg]; omega _ = ∑ k : Fin (d - 1), ∑ i : Fin d, ∑ j : Fin d, if i.val ≤ k.val ∧ k.val < j.val then (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (π (v i) * K.P (v i) (v j)) else 0 := by calc ∑ i : Fin d, ∑ j : Fin d, ∑ k : Fin (d - 1), (if i.val ≤ k.val ∧ k.val < j.val then (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (π (v i) * K.P (v i) (v j)) else 0) = ∑ i : Fin d, ∑ k : Fin (d - 1), ∑ j : Fin d, (if i.val ≤ k.val ∧ k.val < j.val then (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (π (v i) * K.P (v i) (v j)) else 0) := Finset.sum_congr rfl fun i _ => Finset.sum_comm _ = ∑ k : Fin (d - 1), ∑ i : Fin d, ∑ j : Fin d, (if i.val ≤ k.val ∧ k.val < j.val then (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (π (v i) * K.P (v i) (v j)) else 0) := Finset.sum_comm _ = ∑ k : Fin (d - 1), (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * ergodicFlow K π (S k) (S k)ᶜ := by refine Finset.sum_congr rfl fun k _ => ?_ have hflow : ergodicFlow K π (S k) (S k)ᶜ = ∑ i : Fin d, ∑ j : Fin d, if i.val ≤ k.val ∧ k.val < j.val then π (v i) * K.P (v i) (v j) else 0 := by unfold ergodicFlow have hmemS : ∀ i : Fin d, v i ∈ S k ↔ i.val ≤ k.val := fun i => by simp only [S, Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro ⟨i', hi', hvi⟩; have := v.injective hvi; subst this; exact hi' · intro hi; exact ⟨i, hi, rfl⟩ have hmemSc : ∀ j : Fin d, v j ∈ (S k)ᶜ ↔ k.val < j.val := fun j => by rw [Finset.mem_compl, hmemS j]; omega calc ∑ x ∈ S k, ∑ y ∈ (S k)ᶜ, π x * K.P x y = ∑ x : Ω, ∑ y : Ω, if x ∈ S k ∧ y ∈ (S k)ᶜ then π x * K.P x y else 0 := by have hfs : Finset.univ.filter (fun x => x ∈ S k) = S k := by ext x; simp calc ∑ x ∈ S k, ∑ y ∈ (S k)ᶜ, π x * K.P x y = ∑ x ∈ S k, ∑ y : Ω, if y ∈ (S k)ᶜ then π x * K.P x y else 0 := Finset.sum_congr rfl fun x _ => by rw [← Finset.sum_filter]; congr 1; ext y; simp _ = ∑ x : Ω, if x ∈ S k then (∑ y : Ω, if y ∈ (S k)ᶜ then π x * K.P x y else 0) else 0 := by rw [← Finset.sum_filter, hfs] _ = ∑ x : Ω, ∑ y : Ω, if x ∈ S k ∧ y ∈ (S k)ᶜ then π x * K.P x y else 0 := by refine Finset.sum_congr rfl fun x _ => ?_ by_cases hx : x ∈ S k <;> simp [hx] _ = ∑ i : Fin d, ∑ j : Fin d, if v i ∈ S k ∧ v j ∈ (S k)ᶜ then π (v i) * K.P (v i) (v j) else 0 := by rw [← Equiv.sum_comp v] refine Finset.sum_congr rfl fun i _ => (Equiv.sum_comp v _).symm _ = ∑ i : Fin d, ∑ j : Fin d, if i.val ≤ k.val ∧ k.val < j.val then π (v i) * K.P (v i) (v j) else 0 := by refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_ simp only [hmemS, hmemSc] rw [hflow, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun j _ => by split_ifs <;> ring -- Now bound each term in the co-area sum by Φ_* · π(S_k) and use Abel summation! have habel : ∑ k : Fin (d - 1), (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * π.prob (S k) = l2NormSq π g := by have hprob_Sk : ∀ k : Fin (d - 1), π.prob (S k) = ∑ i : Fin d, if i.val ≤ k.val then π (v i) else 0 := fun k => by unfold Dist.prob have hmemS : ∀ i : Fin d, v i ∈ S k ↔ i.val ≤ k.val := fun i => by simp only [S, Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro ⟨i', hi', hvi⟩; have := v.injective hvi; subst this; exact hi' · intro hi; exact ⟨i, hi, rfl⟩ calc ∑ x ∈ S k, π x = ∑ x : Ω, if x ∈ S k then π x else 0 := by rw [← Finset.sum_filter]; congr 1; ext x; simp _ = ∑ i : Fin d, if v i ∈ S k then π (v i) else 0 := (Equiv.sum_comp v _).symm _ = ∑ i : Fin d, if i.val ≤ k.val then π (v i) else 0 := Finset.sum_congr rfl fun i _ => by simp only [hmemS] simp_rw [hprob_Sk, Finset.mul_sum] rw [Finset.sum_comm] have hl2_reidx : l2NormSq π g = ∑ i : Fin d, π (v i) * g (v i) ^ 2 := by unfold l2NormSq l2Inner rw [← Equiv.sum_comp v] refine Finset.sum_congr rfl fun i _ => by ring rw [hl2_reidx] refine Finset.sum_congr rfl fun i _ => ?_ let valSq : ℕ → ℝ := fun k => if hk : k < d then g (v ⟨k, hk⟩) ^ 2 else 0 have htele_nat : ∀ a b : ℕ, a ≤ b → valSq a - valSq b = ∑ k ∈ Finset.Ico a b, (valSq k - valSq (k + 1)) := by intro a b hab induction b with | zero => have ha0 : a = 0 := by omega subst ha0; simp | succ b ih => rcases eq_or_lt_of_le hab with rfl | hlt · simp · rw [Finset.sum_Ico_succ_top (by omega), ← ih (by omega)]; ring have htele_end : g (v i) ^ 2 = ∑ k : Fin (d - 1), if i.val ≤ k.val then g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2 else 0 := by have h1 := htele_nat i.val (d - 1) (by omega) have hvi : valSq i.val = g (v i) ^ 2 := by simp [valSq, i.isLt] have hvd : valSq (d - 1) = 0 := by have hd1 : d - 1 < d := by omega simp [valSq, hd1, hlast_zero] rw [hvi, hvd, sub_zero] at h1 rw [h1] symm rw [← Finset.sum_filter] refine Finset.sum_bij (fun k _ => k.val) ?_ ?_ ?_ ?_ · intro k hk simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hk exact Finset.mem_Ico.mpr ⟨hk, k.isLt⟩ · intro k₁ _ k₂ _ h; exact Fin.ext h · intro m hm rcases Finset.mem_Ico.mp hm with ⟨hm1, hm2⟩ refine ⟨⟨m, hm2⟩, ?_, rfl⟩ simp [hm1] · intro k _ have hk1 : k.val < d := by omega have hk2 : k.val + 1 < d := by omega simp [valSq, hk1, hk2] calc ∑ k : Fin (d - 1), (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (if i.val ≤ k.val then π (v i) else 0) = (∑ k : Fin (d - 1), if i.val ≤ k.val then g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2 else 0) * π (v i) := by rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun k _ => by split_ifs <;> ring _ = π (v i) * g (v i) ^ 2 := by rw [← htele_end, mul_comm] rw [hcoarea_eq, ← habel, Finset.mul_sum] refine Finset.sum_le_sum fun k _ => ?_ have hdiff_nn : 0 ≤ g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2 := sub_nonneg.mpr (hv_sq_anti ⟨k.val, by omega⟩ ⟨k.val + 1, by omega⟩ (by simp)) by_cases hdiff0 : g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2 = 0 · rw [hdiff0, zero_mul, mul_zero, zero_mul] · have hpos_k : 0 < g (v ⟨k.val, by omega⟩) := by have hgt : g (v ⟨k.val + 1, by omega⟩) ^ 2 < g (v ⟨k.val, by omega⟩) ^ 2 := lt_of_le_of_ne (hv_sq_anti _ _ (by simp)) (fun h => hdiff0 (sub_eq_zero.mpr h.symm)) have hnn := hg (v ⟨k.val, by omega⟩) have hnn2 := hg (v ⟨k.val + 1, by omega⟩) nlinarith have hSk_sub : S k ⊆ Finset.univ.filter (fun x => 0 < g x) := by intro x hx simp only [S, Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and] at hx ⊢ rcases hx with ⟨i, hi, rfl⟩ have hge := hv_anti i ⟨k.val, by omega⟩ hi linarith have hSk_half : π.prob (S k) ≤ 1 / 2 := le_trans (π.prob_mono hSk_sub) hsupp have hSk_ne : (S k).Nonempty := by refine ⟨v ⟨0, by omega⟩, Finset.mem_image.mpr ⟨⟨0, by omega⟩, ?_, rfl⟩⟩ simp have hphi := bottleneckRatio_le_cutConductance K π hcard hSk_ne hSk_half have hprob_nn : 0 ≤ π.prob (S k) := π.prob_nonneg (S k) have hQ_ge : bottleneckRatio K π hcard * π.prob (S k) ≤ ergodicFlow K π (S k) (S k)ᶜ := by by_cases hp0 : π.prob (S k) = 0 · rw [hp0, mul_zero]; exact ergodicFlow_nonneg K π (S k) (S k)ᶜ · have hp_pos : 0 < π.prob (S k) := lt_of_le_of_ne hprob_nn (Ne.symm hp0) exact (le_div_iff₀ hp_pos).mp hphi calc bottleneckRatio K π hcard * ((g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * π.prob (S k)) = (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * (bottleneckRatio K π hcard * π.prob (S k)) := by ring _ ≤ (g (v ⟨k.val, by omega⟩) ^ 2 - g (v ⟨k.val + 1, by omega⟩) ^ 2) * ergodicFlow K π (S k) (S k)ᶜ := mul_le_mul_of_nonneg_left hQ_ge hdiff_nn /-- **Sharp Sinclair–Jerrum / Lawler–Sokal Discrete Cheeger Inequality**: for EVERY reversible Markov chain on `|Ω| ≥ 2` with strictly positive `π` (no laziness needed!): `1 - √(1 - Φ_*²) ≤ γ`. -/ theorem cheeger_sinclair_jerrum_sharp {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : 1 - Real.sqrt (1 - (bottleneckRatio K π hcard) ^ 2) ≤ spectralGap hrev hπ_pos hcard := by obtain ⟨f₀, hf₀_mean, hf₀_var, hf₀_eig, _⟩ := exists_second_eigenfunction hrev hπ_pos hcard have hsign : ∃ f : Ω → ℝ, K.apply f = secondEig hrev hπ_pos hcard • f ∧ π.prob (Finset.univ.filter fun x => 0 < f x) ≤ 1 / 2 ∧ ∃ x, 0 < f x := by have hdisj : Disjoint (Finset.univ.filter fun x => 0 < f₀ x) (Finset.univ.filter fun x => 0 < -f₀ x) := by rw [Finset.disjoint_filter]; intro x _ h1 h2; linarith have hsum_le1 : π.prob (Finset.univ.filter fun x => 0 < f₀ x) + π.prob (Finset.univ.filter fun x => 0 < -f₀ x) ≤ 1 := by unfold Dist.prob rw [← Finset.sum_union hdisj] exact le_trans (Finset.sum_le_univ_sum_of_nonneg fun x => π.nonneg x) (le_of_eq π.sum_one) have hpos_both : (∃ x, 0 < f₀ x) ∧ (∃ y, 0 < -f₀ y) := by constructor · by_contra h; push Not at h have hzero : ∀ x, f₀ x = 0 := fun x => by by_contra hne have hlt : f₀ x < 0 := lt_of_le_of_ne (h x) hne have hsum_lt : ∑ z : Ω, π z * f₀ z < 0 := by calc ∑ z : Ω, π z * f₀ z < ∑ z : Ω, (0 : ℝ) := Finset.sum_lt_sum (fun z _ => mul_nonpos_of_nonneg_of_nonpos (π.nonneg z) (h z)) ⟨x, Finset.mem_univ x, mul_neg_of_pos_of_neg (hπ_pos x) hlt⟩ _ = 0 := by simp change π.expect f₀ < 0 at hsum_lt; linarith have hv0 : π.variance f₀ = 0 := by unfold Dist.variance; simp [hzero, hf₀_mean] linarith · by_contra h; push Not at h have hge : ∀ x, 0 ≤ f₀ x := fun x => by linarith [h x] have hzero : ∀ x, f₀ x = 0 := fun x => by by_contra hne have hgt : 0 < f₀ x := lt_of_le_of_ne (hge x) (Ne.symm hne) have hsum_gt : 0 < ∑ z : Ω, π z * f₀ z := by calc (0 : ℝ) = ∑ z : Ω, (0 : ℝ) := by simp _ < ∑ z : Ω, π z * f₀ z := Finset.sum_lt_sum (fun z _ => mul_nonneg (π.nonneg z) (hge z)) ⟨x, Finset.mem_univ x, mul_pos (hπ_pos x) hgt⟩ change 0 < π.expect f₀ at hsum_gt; linarith have hv0 : π.variance f₀ = 0 := by unfold Dist.variance; simp [hzero, hf₀_mean] linarith rcases le_total (π.prob (Finset.univ.filter fun x => 0 < f₀ x)) (π.prob (Finset.univ.filter fun x => 0 < -f₀ x)) with h | h · exact ⟨f₀, hf₀_eig, by linarith, hpos_both.1⟩ · refine ⟨fun x => -f₀ x, ?_, by linarith, hpos_both.2⟩ ext x have hx := congrFun hf₀_eig x simp only [MarkovKernel.apply, Pi.smul_apply, smul_eq_mul, mul_neg, Finset.sum_neg_distrib] at hx ⊢ linarith obtain ⟨f, hf_eig, hsupp, ⟨x₀, hx₀⟩⟩ := hsign let g : Ω → ℝ := fun x => max (f x) 0 have hg_nn : ∀ x, 0 ≤ g x := fun x => le_max_right _ _ have hgsupp : π.prob (Finset.univ.filter fun x => 0 < g x) ≤ 1 / 2 := by have heq : (Finset.univ.filter fun x => 0 < g x) = Finset.univ.filter (fun x => 0 < f x) := by ext x; simp [g] rwa [heq] have hgnorm_pos : 0 < l2NormSq π g := by unfold l2NormSq l2Inner have hterm : 0 < π x₀ * g x₀ * g x₀ := by have hgx₀ : g x₀ = f x₀ := max_eq_left (le_of_lt hx₀) rw [hgx₀]; exact mul_pos (mul_pos (hπ_pos x₀) hx₀) hx₀ exact lt_of_lt_of_le hterm (Finset.single_le_sum (f := fun x => π x * g x * g x) (fun x _ => by have : π x * g x * g x = π x * g x ^ 2 := by ring rw [this]; exact mul_nonneg (π.nonneg x) (sq_nonneg _)) (Finset.mem_univ x₀)) have hE_le : dirichletForm K π g ≤ spectralGap hrev hπ_pos hcard * l2NormSq π g := dirichletForm_posPart_le_of_eig hrev hf_eig have hJ_ge := coarea_ge_bottleneck_mul_normSq hrev hcard hg_nn hgsupp have hJ_sq := coarea_sq_le_dirichlet_sharp hrev hg_nn have hphi_nn := bottleneckRatio_nonneg K π hπ_pos hcard have hmain_quad : (bottleneckRatio K π hcard) ^ 2 * l2NormSq π g ^ 2 ≤ dirichletForm K π g * (2 * l2NormSq π g - dirichletForm K π g) := by have h1 : (bottleneckRatio K π hcard * l2NormSq π g) ^ 2 ≤ ((1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2|) ^ 2 := by have hnn1 : 0 ≤ bottleneckRatio K π hcard * l2NormSq π g := mul_nonneg hphi_nn (le_of_lt hgnorm_pos) nlinarith calc (bottleneckRatio K π hcard) ^ 2 * l2NormSq π g ^ 2 = (bottleneckRatio K π hcard * l2NormSq π g) ^ 2 := by ring _ ≤ ((1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * K.P x y * |g x ^ 2 - g y ^ 2|) ^ 2 := h1 _ ≤ dirichletForm K π g * (2 * l2NormSq π g - dirichletForm K π g) := hJ_sq set r := dirichletForm K π g / l2NormSq π g have hr_le_γ : r ≤ spectralGap hrev hπ_pos hcard := (div_le_iff₀ hgnorm_pos).mpr hE_le have hr_quad : (bottleneckRatio K π hcard) ^ 2 ≤ r * (2 - r) := by have hN2 : 0 < l2NormSq π g ^ 2 := sq_pos_of_pos hgnorm_pos have hrew : r * (2 - r) * l2NormSq π g ^ 2 = dirichletForm K π g * (2 * l2NormSq π g - dirichletForm K π g) := by dsimp only [r]; field_simp [ne_of_gt hgnorm_pos] nlinarith have h1sub : (1 - r) ^ 2 ≤ 1 - (bottleneckRatio K π hcard) ^ 2 := by linarith have hsqrt : 1 - r ≤ Real.sqrt (1 - (bottleneckRatio K π hcard) ^ 2) := by calc 1 - r ≤ Real.sqrt ((1 - r) ^ 2) := by rw [Real.sqrt_sq_eq_abs]; exact le_abs_self _ _ ≤ Real.sqrt (1 - (bottleneckRatio K π hcard) ^ 2) := Real.sqrt_le_sqrt h1sub linarith /-- Strict sharpening of Sinclair–Jerrum over Lawler–Sokal: for EVERY `φ ∈ (0, 1]`, `φ² / 2 < 1 - √(1 - φ²)` (reaching a `2×` gain at `φ = 1`). -/ theorem sinclair_jerrum_strictly_beats_half_sq {φ : ℝ} (hpos : 0 < φ) (hle : φ ≤ 1) : φ ^ 2 / 2 < 1 - Real.sqrt (1 - φ ^ 2) := by have h1 : 0 ≤ 1 - φ ^ 2 := by nlinarith have h2 : 0 < 1 - φ ^ 2 / 2 := by nlinarith have hsq : 1 - φ ^ 2 < (1 - φ ^ 2 / 2) ^ 2 := by have h4 : 0 < φ ^ 4 / 4 := by positivity nlinarith [show (1 - φ ^ 2 / 2) ^ 2 = 1 - φ ^ 2 + φ ^ 4 / 4 by ring] have hrt : Real.sqrt (1 - φ ^ 2) < 1 - φ ^ 2 / 2 := by calc Real.sqrt (1 - φ ^ 2) < Real.sqrt ((1 - φ ^ 2 / 2) ^ 2) := Real.sqrt_lt_sqrt h1 hsq _ = 1 - φ ^ 2 / 2 := Real.sqrt_sq (le_of_lt h2) linarith /-- Non-strict version `φ² / 2 ≤ 1 - √(1 - φ²)` for all `φ ∈ [0, 1]`. -/ lemma half_sq_le_one_sub_sqrt {φ : ℝ} (h0 : 0 ≤ φ) (hle : φ ≤ 1) : φ ^ 2 / 2 ≤ 1 - Real.sqrt (1 - φ ^ 2) := by rcases eq_or_lt_of_le h0 with rfl | hpos · simp · exact le_of_lt (sinclair_jerrum_strictly_beats_half_sq hpos hle) /-- **Full Two-Sided Discrete Cheeger Inequality** (Lawler–Sokal / Sinclair–Jerrum): for EVERY reversible Markov chain on `|Ω| ≥ 2` with strictly positive `π`: `Φ_*² / 2 ≤ 1 - √(1 - Φ_*²) ≤ γ ≤ 2 · Φ_*`. -/ theorem cheeger_inequality_full {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : (bottleneckRatio K π hcard) ^ 2 / 2 ≤ 1 - Real.sqrt (1 - (bottleneckRatio K π hcard) ^ 2) ∧ 1 - Real.sqrt (1 - (bottleneckRatio K π hcard) ^ 2) ≤ spectralGap hrev hπ_pos hcard ∧ spectralGap hrev hπ_pos hcard ≤ 2 * bottleneckRatio K π hcard := ⟨half_sq_le_one_sub_sqrt (bottleneckRatio_nonneg K π hπ_pos hcard) (bottleneckRatio_le_one hrev hπ_pos hcard), cheeger_sinclair_jerrum_sharp hrev hπ_pos hcard, cheeger_upper_bound hrev hπ_pos hcard⟩ /-- Classic Cheeger lower bound `Φ_*² / 2 ≤ γ`. -/ theorem cheeger_lower_bound {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) : (bottleneckRatio K π hcard) ^ 2 / 2 ≤ spectralGap hrev hπ_pos hcard := le_trans (cheeger_inequality_full hrev hπ_pos hcard).1 (cheeger_inequality_full hrev hπ_pos hcard).2.1 /-! ### Diaconis–Stroock / Sinclair Canonical Paths Spectral-Gap Lower Bound -/ /-- Directed edge list of a vertex path `[v₀, v₁, ..., v_ℓ]`. -/ def pathEdges : List Ω → List (Ω × Ω) | [] => [] | [_] => [] | a :: b :: rest => (a, b) :: pathEdges (b :: rest) omit [Fintype Ω] [DecidableEq Ω] in lemma pathEdges_length (L : List Ω) (hne : L ≠ []) : (pathEdges L).length + 1 = L.length := by induction L with | nil => exact absurd rfl hne | cons a t ih => cases t with | nil => simp [pathEdges] | cons b rest => have h := ih (List.cons_ne_nil b rest) simp only [pathEdges, List.length_cons] at h ⊢ omega omit [Fintype Ω] [DecidableEq Ω] in /-- Telescoping identity along any nonempty path: `f(head) - f(last) = ∑_{(u,v) ∈ pathEdges L} (f u - f v)`. -/ lemma path_telescoping (f : Ω → ℝ) : ∀ (L : List Ω) (hne : L ≠ []), f (L.head hne) - f (L.getLast hne) = ((pathEdges L).map fun e => f e.1 - f e.2).sum | [], hne => absurd rfl hne | [a], _ => by simp [pathEdges] | a :: b :: rest, _ => by have ih := path_telescoping f (b :: rest) (List.cons_ne_nil b rest) simp only [pathEdges, List.map_cons, List.sum_cons, List.head_cons, List.getLast_cons (List.cons_ne_nil b rest)] simp only [List.head_cons] at ih linarith /-- List Cauchy–Schwarz: `(∑_i a_i)² ≤ L.length · ∑_i a_i²`. -/ lemma list_sum_sq_le_length_mul_sum_sq (L : List ℝ) : L.sum ^ 2 ≤ (L.length : ℝ) * (L.map (fun x => x ^ 2)).sum := by induction L with | nil => simp | cons a t ih => simp only [List.sum_cons, List.length_cons, List.map_cons, Nat.cast_add, Nat.cast_one] have hcs : (t.length : ℝ) * a ^ 2 - 2 * a * t.sum + (t.map (fun x => x ^ 2)).sum ≥ 0 := by -- Prove ∑_{x ∈ t} (a - x)² ≥ 0 by induction on t! have haux : ∀ (M : List ℝ), 0 ≤ (M.length : ℝ) * a ^ 2 - 2 * a * M.sum + (M.map (fun x => x ^ 2)).sum := by intro M induction M with | nil => simp | cons b s ihs => simp only [List.length_cons, List.sum_cons, List.map_cons, Nat.cast_add, Nat.cast_one] nlinarith [sq_nonneg (a - b)] exact haux t nlinarith omit [Fintype Ω] [DecidableEq Ω] in /-- Path Cauchy–Schwarz: `(f(head) - f(last))² ≤ |edges| · ∑_{e ∈ edges} (f e.1 - f e.2)²`. -/ theorem path_diff_sq_le_length_mul_sum (f : Ω → ℝ) (L : List Ω) (hne : L ≠ []) : (f (L.head hne) - f (L.getLast hne)) ^ 2 ≤ ((pathEdges L).length : ℝ) * ((pathEdges L).map fun e => (f e.1 - f e.2) ^ 2).sum := by rw [path_telescoping f L hne] have h := list_sum_sq_le_length_mul_sum_sq ((pathEdges L).map fun e => f e.1 - f e.2) simpa [List.length_map, List.map_map, Function.comp_def] using h /-- A **Canonical Path System** on `(Ω, K)` assigning to every ordered pair `(x, y)` a nonempty vertex path starting at `x` and ending at `y`. -/ structure CanonicalPathSystem (Ω : Type*) where path : Ω → Ω → List Ω nonempty : ∀ x y, path x y ≠ [] head_eq : ∀ x y, (path x y).head (nonempty x y) = x last_eq : ∀ x y, (path x y).getLast (nonempty x y) = y /-- Multiplicity (count) of directed edge `(u, v)` in the canonical path `γ_{x, y}`. -/ def edgeCount (C : CanonicalPathSystem Ω) (x y u v : Ω) : ℕ := (pathEdges (C.path x y)).count (u, v) /-- Length (number of edges) of canonical path `γ_{x, y}`. -/ def pathLen (C : CanonicalPathSystem Ω) (x y : Ω) : ℕ := (pathEdges (C.path x y)).length /-- **Diaconis–Stroock / Sinclair Canonical Paths Dirichlet Bound**: if `ρ > 0` satisfies the weighted edge-congestion inequality `∑_{x, y} π(x) π(y) · |γ_{x, y}| · count((u, v) ∈ γ_{x, y}) ≤ ρ · π(u) P(u, v)` for EVERY pair `(u, v) ∈ Ω × Ω`, then for EVERY observable `f : Ω → ℝ`, `Var_π(f) ≤ ρ · E(f, f)`. -/ theorem canonical_paths_dirichlet_bound {K : MarkovKernel Ω} {π : Dist Ω} (C : CanonicalPathSystem Ω) {ρ : ℝ} (hcong : ∀ u v : Ω, ∑ x : Ω, ∑ y : Ω, π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ) ≤ ρ * (π u * K.P u v)) (f : Ω → ℝ) : π.variance f ≤ ρ * dirichletForm K π f := by -- Step 1: Double-sum representation of variance: Var_π(f) = (1/2) ∑_{x,y} π(x) π(y) (f x - f y)²! have hvar_eq : π.variance f = (1 / 2 : ℝ) * ∑ x : Ω, ∑ y : Ω, π x * π y * (f x - f y) ^ 2 := by rw [π.variance_eq_expect_sq_sub f] unfold Dist.expect have hexp : ∑ x : Ω, ∑ y : Ω, π x * π y * (f x - f y) ^ 2 = (∑ x : Ω, π x * f x ^ 2) * (∑ y : Ω, π y) + (∑ x : Ω, π x) * (∑ y : Ω, π y * f y ^ 2) - 2 * (∑ x : Ω, π x * f x) * (∑ y : Ω, π y * f y) := by have hpt : ∀ x y : Ω, π x * π y * (f x - f y) ^ 2 = (π x * f x ^ 2) * π y + π x * (π y * f y ^ 2) - (2 * (π x * f x)) * (π y * f y) := fun x y => by ring simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, ← Finset.mul_sum] rw [hexp, π.sum_one]; ring -- Step 2: Express list sum over pathEdges as weighted Finset sum over (u, v) ∈ Ω × Ω! have hlist_eq : ∀ x y : Ω, ((pathEdges (C.path x y)).map fun e => (f e.1 - f e.2) ^ 2).sum = ∑ u : Ω, ∑ v : Ω, (edgeCount C x y u v : ℝ) * (f u - f v) ^ 2 := fun x y => by have haux : ∀ (E : List (Ω × Ω)), (E.map fun e => (f e.1 - f e.2) ^ 2).sum = ∑ u : Ω, ∑ v : Ω, (E.count (u, v) : ℝ) * (f u - f v) ^ 2 := by intro E induction E with | nil => simp | cons e rest ih => simp only [List.map_cons, List.sum_cons, ih] have hstep : ∀ u v : Ω, (((e :: rest).count (u, v) : ℕ) : ℝ) = (if (u, v) = e then (1 : ℝ) else 0) + (rest.count (u, v) : ℝ) := fun u v => by rw [List.count_cons] by_cases h : (u, v) = e · subst h; simp; ring · have h' : (e == (u, v)) = false := beq_false_of_ne (Ne.symm h) simp [h, h'] simp_rw [hstep, add_mul, Finset.sum_add_distrib] congr 1 have hsing : ∑ u : Ω, ∑ v : Ω, (if (u, v) = e then (1 : ℝ) else 0) * (f u - f v) ^ 2 = (f e.1 - f e.2) ^ 2 := by rw [← Fintype.sum_prod_type'] simp [Finset.sum_ite_eq'] exact hsing.symm exact haux (pathEdges (C.path x y)) -- Step 3: Apply path Cauchy–Schwarz and swap summation order! rw [hvar_eq] unfold dirichletForm rw [← mul_assoc, mul_comm ρ (1 / 2 : ℝ), mul_assoc] refine mul_le_mul_of_nonneg_left ?_ (by norm_num) calc ∑ x : Ω, ∑ y : Ω, π x * π y * (f x - f y) ^ 2 ≤ ∑ x : Ω, ∑ y : Ω, π x * π y * ((pathLen C x y : ℝ) * ∑ u : Ω, ∑ v : Ω, (edgeCount C x y u v : ℝ) * (f u - f v) ^ 2) := by refine Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun y _ => ?_ refine mul_le_mul_of_nonneg_left ?_ (mul_nonneg (π.nonneg x) (π.nonneg y)) have hcs := path_diff_sq_le_length_mul_sum f (C.path x y) (C.nonempty x y) rw [C.head_eq x y, C.last_eq x y, hlist_eq x y] at hcs exact hcs _ = ∑ u : Ω, ∑ v : Ω, (∑ x : Ω, ∑ y : Ω, π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := by calc ∑ x, ∑ y, π x * π y * ((pathLen C x y : ℝ) * ∑ u, ∑ v, (edgeCount C x y u v : ℝ) * (f u - f v) ^ 2) = ∑ x, ∑ y, ∑ u, ∑ v, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ rw [Finset.mul_sum, Finset.mul_sum] refine Finset.sum_congr rfl fun u _ => ?_ rw [Finset.mul_sum, Finset.mul_sum] refine Finset.sum_congr rfl fun v _ => by ring _ = ∑ u, ∑ x, ∑ y, ∑ v, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := by calc ∑ x, ∑ y, ∑ u, ∑ v, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 = ∑ x, ∑ u, ∑ y, ∑ v, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := Finset.sum_congr rfl fun x _ => Finset.sum_comm _ = ∑ u, ∑ x, ∑ y, ∑ v, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := Finset.sum_comm _ = ∑ u, ∑ v, ∑ x, ∑ y, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := by refine Finset.sum_congr rfl fun u _ => ?_ calc ∑ x, ∑ y, ∑ v, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 = ∑ x, ∑ v, ∑ y, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := Finset.sum_congr rfl fun x _ => Finset.sum_comm _ = ∑ v, ∑ x, ∑ y, (π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := Finset.sum_comm _ = ∑ u, ∑ v, (∑ x, ∑ y, π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ)) * (f u - f v) ^ 2 := by refine Finset.sum_congr rfl fun u _ => Finset.sum_congr rfl fun v _ => ?_ rw [Finset.sum_mul] refine Finset.sum_congr rfl fun x _ => (Finset.sum_mul ..).symm _ ≤ ∑ u : Ω, ∑ v : Ω, (ρ * (π u * K.P u v)) * (f u - f v) ^ 2 := Finset.sum_le_sum fun u _ => Finset.sum_le_sum fun v _ => mul_le_mul_of_nonneg_right (hcong u v) (sq_nonneg _) _ = ρ * ∑ u : Ω, ∑ v : Ω, π u * K.P u v * (f u - f v) ^ 2 := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun u _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun v _ => by ring /-- **Diaconis–Stroock / Sinclair Canonical Paths Spectral-Gap Lower Bound**: if edge congestion is bounded by `ρ > 0`, then `γ ≥ 1 / ρ`. -/ theorem canonical_paths_spectral_gap_lower {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) (C : CanonicalPathSystem Ω) {ρ : ℝ} (hρ_pos : 0 < ρ) (hcong : ∀ u v : Ω, ∑ x : Ω, ∑ y : Ω, π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ) ≤ ρ * (π u * K.P u v)) : 1 / ρ ≤ spectralGap hrev hπ_pos hcard := by obtain ⟨f, _, hf_var, _, hf_dir⟩ := exists_second_eigenfunction hrev hπ_pos hcard have h := canonical_paths_dirichlet_bound C hcong f rw [hf_var, hf_dir] at h exact (div_le_iff₀ hρ_pos).mpr (by linarith) /-- **Unweighted Canonical Paths Corollary (`γ ≥ 1 / (ρ₀ · ℓ_max)`)**: if every canonical path has length `≤ ℓ` and unweighted edge congestion `≤ ρ₀`, then `γ ≥ 1 / (ρ₀ · ℓ)`. -/ theorem canonical_paths_unweighted_lower {K : MarkovKernel Ω} {π : Dist Ω} (hrev : K.IsReversible π) (hπ_pos : ∀ x, 0 < π x) (hcard : 2 ≤ Fintype.card Ω) (C : CanonicalPathSystem Ω) {ρ₀ ℓ : ℝ} (hρ₀_pos : 0 < ρ₀) (hℓ_pos : 0 < ℓ) (hlen : ∀ x y, (pathLen C x y : ℝ) ≤ ℓ) (hload : ∀ u v : Ω, ∑ x : Ω, ∑ y : Ω, π x * π y * (edgeCount C x y u v : ℝ) ≤ ρ₀ * (π u * K.P u v)) : 1 / (ρ₀ * ℓ) ≤ spectralGap hrev hπ_pos hcard := by apply canonical_paths_spectral_gap_lower hrev hπ_pos hcard C (mul_pos hρ₀_pos hℓ_pos) intro u v calc ∑ x : Ω, ∑ y : Ω, π x * π y * (pathLen C x y : ℝ) * (edgeCount C x y u v : ℝ) ≤ ∑ x : Ω, ∑ y : Ω, ℓ * (π x * π y * (edgeCount C x y u v : ℝ)) := by refine Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun y _ => ?_ have hnn : 0 ≤ π x * π y * (edgeCount C x y u v : ℝ) := mul_nonneg (mul_nonneg (π.nonneg x) (π.nonneg y)) (Nat.cast_nonneg _) have hl := hlen x y nlinarith _ = ℓ * ∑ x : Ω, ∑ y : Ω, π x * π y * (edgeCount C x y u v : ℝ) := by simp_rw [← Finset.mul_sum] _ ≤ ℓ * (ρ₀ * (π u * K.P u v)) := mul_le_mul_of_nonneg_left (hload u v) (le_of_lt hℓ_pos) _ = (ρ₀ * ℓ) * (π u * K.P u v) := by ring /-! ### Exact Conductance & Spectral Gap Benchmarks (`K_2`, `K_n`, `C_{2m}`) -/ /-- Two-state symmetric Markov chain `K_2(p)`: transition matrix `[[1-p, p], [p, 1-p]]`. -/ def twoStateKernel (p : ℝ) (h0 : 0 ≤ p) (h1 : p ≤ 1) : MarkovKernel (Fin 2) where P i j := if i = j then 1 - p else p nonneg i j := by split_ifs <;> linarith row_sum_one i := by fin_cases i <;> simp [Fin.sum_univ_two] lemma twoStateKernel_reversible (p : ℝ) (h0 : 0 ≤ p) (h1 : p ≤ 1) : (twoStateKernel p h0 h1).IsReversible (Dist.uniform ⟨(0 : Fin 2)⟩) := by intro i j; fin_cases i <;> fin_cases j <;> simp [twoStateKernel, Dist.uniform] /-- **Sharpness Witness for Cheeger Upper Bound (`γ = 2 Φ_*` Attained with Equality)**: for the 2-state chain `K_2(p)` (`0 < p ≤ 1/2`), `Φ_* = p` and `γ = 2 p = 2 Φ_*`! -/ theorem twoState_cheeger_upper_tight (p : ℝ) (h0 : 0 < p) (h1 : p ≤ 1 / 2) : let K := twoStateKernel p (le_of_lt h0) (by linarith) let π := Dist.uniform (⟨(0 : Fin 2)⟩ : Nonempty (Fin 2)) let hrev := twoStateKernel_reversible p (le_of_lt h0) (by linarith) let hpos : ∀ i : Fin 2, 0 < π i := fun _ => by norm_num [π, Dist.uniform] bottleneckRatio K π (by decide) = p ∧ spectralGap hrev hpos (by decide) = 2 * p := by intro K π hrev hpos have hphi_le : bottleneckRatio K π (by decide) ≤ p := by have hmem : ({(0 : Fin 2)} : Finset (Fin 2)) ∈ properCuts (Fin 2) := by refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, Finset.singleton_nonempty 0, ?_⟩ intro h have hmem1 : (1 : Fin 2) ∈ ({(0 : Fin 2)} : Finset (Fin 2)) := by rw [h]; exact Finset.mem_univ 1 simp at hmem1 have hinf := Finset.inf'_le (fun S => symCutConductance K π S) hmem have hval : symCutConductance K π {0} = p := by have hcompl : ({(0 : Fin 2)} : Finset (Fin 2))ᶜ = {1} := by decide unfold symCutConductance ergodicFlow Dist.prob rw [hcompl] simp [K, π, twoStateKernel, Dist.uniform] ring rwa [hval] at hinf -- Compute spectral gap directly via test function f = (1, -1): P f = (1 - 2p) f, and E(f, f) = 2p · Var(f)! have hgap_eq : spectralGap hrev hpos (by decide) = 2 * p := by -- Upper bound γ ≤ 2p from Cheeger upper bound + hphi_le! have hup : spectralGap hrev hpos (by decide) ≤ 2 * p := le_trans (cheeger_upper_bound hrev hpos (by decide)) (by linarith) -- Lower bound 2p ≤ γ: for ANY f : Fin 2 → ℝ, E(f, f) = 2p · Var_π(f)! have hall : ∀ f : Fin 2 → ℝ, dirichletForm K π f = 2 * p * π.variance f := fun f => by unfold dirichletForm Dist.variance Dist.expect simp [Fin.sum_univ_two, K, π, twoStateKernel, Dist.uniform] ring obtain ⟨f, _, hf_var, _, hf_dir⟩ := exists_second_eigenfunction hrev hpos (by decide) have h := hall f rw [hf_var, mul_one] at h linarith have hphi_ge : p ≤ bottleneckRatio K π (by decide) := by have hch := cheeger_upper_bound hrev hpos (by decide) linarith exact ⟨le_antisymm hphi_le hphi_ge, hgap_eq⟩ /-- **Lazy Complete Graph `K_n` Walk**: `P(x, y) = (1/2) δ_{x, y} + (1 / (2 n))` on `Fin n`. -/ def lazyCompleteKernel (n : ℕ) (hn : 2 ≤ n) : MarkovKernel (Fin n) where P x y := (if x = y then 1 / 2 else 0) + (2 * (n : ℝ))⁻¹ nonneg x y := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have h1 : (0 : ℝ) ≤ if x = y then 1 / 2 else 0 := by split_ifs <;> norm_num have h2 : (0 : ℝ) ≤ (2 * (n : ℝ))⁻¹ := by positivity linarith row_sum_one x := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) rw [Finset.sum_add_distrib] simp [Finset.sum_const, nsmul_eq_mul] field_simp [ne_of_gt hn_pos]; ring lemma lazyCompleteKernel_reversible (n : ℕ) (hn : 2 ≤ n) : (lazyCompleteKernel n hn).IsReversible (Dist.uniform ⟨⟨0, by omega⟩⟩) := by intro x y simp only [lazyCompleteKernel, Dist.uniform] by_cases h : x = y · subst h; rfl · rw [if_neg h, if_neg (Ne.symm h)] /-- **Exact Spectral Gap & Conductance of Lazy Complete Graph `K_n`**: `γ(K_n) = 1/2` (independent of `n`!) and every cut `S` has conductance `Φ(S) = (n - |S|) / (2 n) ≥ 1/4`. -/ theorem lazyComplete_spectralGap_and_conductance (n : ℕ) (hn : 2 ≤ n) : let K := lazyCompleteKernel n hn let π := Dist.uniform (⟨⟨0, by omega⟩⟩ : Nonempty (Fin n)) let hrev := lazyCompleteKernel_reversible n hn let hpos : ∀ x : Fin n, 0 < π x := fun _ => by simp only [π, Dist.uniform, Fintype.card_fin] exact inv_pos.mpr (by exact_mod_cast (show 0 < n by omega)) spectralGap hrev hpos (by simp; omega) = 1 / 2 ∧ (1 / 4 : ℝ) ≤ bottleneckRatio K π (by simp; omega) := by intro K π hrev hpos have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hE_exact : ∀ f : Fin n → ℝ, dirichletForm K π f = (1 / 2 : ℝ) * π.variance f := fun f => by -- Var_π(f) = (1/2) ∑_{x, y} (1/n²) (f x - f y)², while E(f, f) = (1/2) ∑_{x, y} (1/(2n²)) (f x - f y)²! have hvar : π.variance f = (1 / 2 : ℝ) * ∑ x : Fin n, ∑ y : Fin n, π x * π y * (f x - f y) ^ 2 := by rw [π.variance_eq_expect_sq_sub f] unfold Dist.expect have hexp : ∑ x : Fin n, ∑ y : Fin n, π x * π y * (f x - f y) ^ 2 = (∑ x : Fin n, π x * f x ^ 2) * (∑ y : Fin n, π y) + (∑ x : Fin n, π x) * (∑ y : Fin n, π y * f y ^ 2) - 2 * (∑ x : Fin n, π x * f x) * (∑ y : Fin n, π y * f y) := by have hpt : ∀ x y : Fin n, π x * π y * (f x - f y) ^ 2 = (π x * f x ^ 2) * π y + π x * (π y * f y ^ 2) - (2 * (π x * f x)) * (π y * f y) := fun x y => by ring simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, ← Finset.mul_sum] rw [hexp, π.sum_one]; ring rw [hvar] unfold dirichletForm calc (1 / 2 : ℝ) * ∑ x : Fin n, ∑ y : Fin n, π x * K.P x y * (f x - f y) ^ 2 = (1 / 2 : ℝ) * ∑ x : Fin n, ∑ y : Fin n, (1 / 2 : ℝ) * (π x * π y * (f x - f y) ^ 2) := by congr 1; refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ by_cases h : x = y · subst h; simp · simp only [K, π, lazyCompleteKernel, Dist.uniform, Fintype.card_fin, if_neg h, zero_add] field_simp [ne_of_gt hn_pos] _ = (1 / 2 : ℝ) * ((1 / 2 : ℝ) * ∑ x : Fin n, ∑ y : Fin n, π x * π y * (f x - f y) ^ 2) := by simp_rw [← Finset.mul_sum] obtain ⟨f, _, hf_var, _, hf_dir⟩ := exists_second_eigenfunction hrev hpos (by simp; omega) have hgap : spectralGap hrev hpos (by simp; omega) = 1 / 2 := by have h := hE_exact f; rw [hf_var, mul_one] at h; linarith have hphi : (1 / 4 : ℝ) ≤ bottleneckRatio K π (by simp; omega) := by have hch := cheeger_upper_bound hrev hpos (by simp; omega) linarith exact ⟨hgap, hphi⟩ /-- **Lazy Even Cycle `C_{2m}`** (`m ≥ 2`): `P(i, i) = 1/2`, `P(i, i+1) = P(i, i-1) = 1/4` (mod `2m`). -/ def lazyCycleKernel (m : ℕ) (hm : 2 ≤ m) : MarkovKernel (Fin (2 * m)) where P i j := (if j = i then (1 / 2 : ℝ) else 0) + (if j = ⟨(i.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0) + (if j = ⟨(i.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0) nonneg i j := by have h1 : (0 : ℝ) ≤ if j = i then 1 / 2 else 0 := by split_ifs <;> norm_num have h2 : (0 : ℝ) ≤ if j = ⟨(i.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then 1 / 4 else 0 := by split_ifs <;> norm_num have h3 : (0 : ℝ) ≤ if j = ⟨(i.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then 1 / 4 else 0 := by split_ifs <;> norm_num linarith row_sum_one i := by rw [Finset.sum_add_distrib, Finset.sum_add_distrib] simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true] norm_num lemma cycle_mod_identities (m a : ℕ) (hm : 2 ≤ m) (ha : a < 2 * m) : ((a + 1) % (2 * m) + 2 * m - 1) % (2 * m) = a ∧ ((a + 2 * m - 1) % (2 * m) + 1) % (2 * m) = a ∧ ((a + m) % (2 * m) + m) % (2 * m) = a := by refine ⟨?_, ?_, ?_⟩ · by_cases htop : a + 1 = 2 * m · rw [htop, Nat.mod_self, zero_add] have hlt : 2 * m - 1 < 2 * m := by omega rw [Nat.mod_eq_of_lt hlt]; omega · have hlt : a + 1 < 2 * m := by omega rw [Nat.mod_eq_of_lt hlt] have hrew : a + 1 + 2 * m - 1 = a + 2 * m := by omega rw [hrew, Nat.add_mod_right, Nat.mod_eq_of_lt ha] · by_cases h0 : a = 0 · rw [h0, zero_add] have hlt : 2 * m - 1 < 2 * m := by omega rw [Nat.mod_eq_of_lt hlt] have hrew : 2 * m - 1 + 1 = 2 * m := by omega rw [hrew, Nat.mod_self] · have hrew1 : a + 2 * m - 1 = (a - 1) + 2 * m := by omega have hlt1 : a - 1 < 2 * m := by omega rw [hrew1, Nat.add_mod_right, Nat.mod_eq_of_lt hlt1] have hrew2 : a - 1 + 1 = a := by omega rw [hrew2, Nat.mod_eq_of_lt ha] · by_cases hlt : a < m · have hlt1 : a + m < 2 * m := by omega rw [Nat.mod_eq_of_lt hlt1] have hrew : a + m + m = a + 2 * m := by omega rw [hrew, Nat.add_mod_right, Nat.mod_eq_of_lt ha] · have hrew1 : a + m = (a - m) + 2 * m := by omega have hlt1 : a - m < 2 * m := by omega rw [hrew1, Nat.add_mod_right, Nat.mod_eq_of_lt hlt1] have hrew2 : a - m + m = a := by omega rw [hrew2, Nat.mod_eq_of_lt ha] lemma lazyCycleKernel_reversible (m : ℕ) (hm : 2 ≤ m) : (lazyCycleKernel m hm).IsReversible (Dist.uniform ⟨⟨0, by omega⟩⟩) := by intro i j simp only [Dist.uniform] congr 1 simp only [lazyCycleKernel] have h1 : (if j = i then (1 / 2 : ℝ) else 0) = if i = j then (1 / 2 : ℝ) else 0 := by by_cases h : j = i · subst h; simp · rw [if_neg h, if_neg (Ne.symm h)] have hfwd : (j = ⟨(i.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩) ↔ (i = ⟨(j.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩) := by constructor <;> intro h <;> apply Fin.ext <;> simp only · have hjv : j.val = (i.val + 1) % (2 * m) := congrArg Fin.val h rw [hjv]; exact (cycle_mod_identities m i.val hm i.isLt).1.symm · have hiv : i.val = (j.val + 2 * m - 1) % (2 * m) := congrArg Fin.val h rw [hiv]; exact (cycle_mod_identities m j.val hm j.isLt).2.1.symm have hbwd : (j = ⟨(i.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩) ↔ (i = ⟨(j.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩) := by constructor <;> intro h <;> apply Fin.ext <;> simp only · have hjv : j.val = (i.val + 2 * m - 1) % (2 * m) := congrArg Fin.val h rw [hjv]; exact (cycle_mod_identities m i.val hm i.isLt).2.1.symm · have hiv : i.val = (j.val + 1) % (2 * m) := congrArg Fin.val h rw [hiv]; exact (cycle_mod_identities m j.val hm j.isLt).1.symm rw [h1] have h2 : (if j = ⟨(i.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0) = if i = ⟨(j.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0 := by simp [hfwd] have h3 : (if j = ⟨(i.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0) = if i = ⟨(j.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0 := by simp [hbwd] rw [h2, h3]; ring /-- **Exact Cosine Eigenfunction of Lazy Even Cycle `C_{2m}`**: `f(k) = cos(π k / m)` is an exact zero-mean eigenfunction with eigenvalue `λ = (1 + cos(π / m)) / 2`, proving `γ(C_{2m}) ≤ (1 - cos(π / m)) / 2 ≤ π² / (4 m²)`. -/ theorem lazyCycle_cosine_eigenfunction (m : ℕ) (hm : 2 ≤ m) : let K := lazyCycleKernel m hm let π := Dist.uniform (⟨⟨0, by omega⟩⟩ : Nonempty (Fin (2 * m))) let f : Fin (2 * m) → ℝ := fun k => Real.cos (Real.pi * (k.val : ℝ) / (m : ℝ)) π.expect f = 0 ∧ (∃ k, f k ≠ 0) ∧ K.apply f = ((1 + Real.cos (Real.pi / (m : ℝ))) / 2) • f := by intro K π f have hm_pos : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) have hmean : π.expect f = 0 := by -- Pair k with (k + m) mod 2m: cos(π(k+m)/m) = cos(π k/m + π) = -cos(π k/m)! unfold Dist.expect simp only [π, Dist.uniform, Fintype.card_fin, ← Finset.mul_sum] suffices hsum : ∑ k : Fin (2 * m), f k = 0 by rw [hsum, mul_zero] let shift : Fin (2 * m) ≃ Fin (2 * m) := { toFun := fun k => ⟨(k.val + m) % (2 * m), Nat.mod_lt _ (by omega)⟩ invFun := fun k => ⟨(k.val + m) % (2 * m), Nat.mod_lt _ (by omega)⟩ left_inv := fun k => Fin.ext (by simp only; exact (cycle_mod_identities m k.val hm k.isLt).2.2) right_inv := fun k => Fin.ext (by simp only; exact (cycle_mod_identities m k.val hm k.isLt).2.2) } have hneg : ∀ k : Fin (2 * m), f (shift k) = -f k := fun k => by change Real.cos (Real.pi * (((k.val + m) % (2 * m) : ℕ) : ℝ) / (m : ℝ)) = -f k have hk := k.isLt by_cases hlt : k.val < m · have hlt2 : k.val + m < 2 * m := by omega rw [Nat.mod_eq_of_lt hlt2] have harg : Real.pi * ((k.val + m : ℕ) : ℝ) / (m : ℝ) = Real.pi * (k.val : ℝ) / (m : ℝ) + Real.pi := by push_cast; field_simp [ne_of_gt hm_pos] rw [harg, Real.cos_add_pi] · have hsub : (k.val + m) % (2 * m) = k.val - m := by have hrew : k.val + m = (k.val - m) + 2 * m := by omega have hlt2 : k.val - m < 2 * m := by omega rw [hrew, Nat.add_mod_right, Nat.mod_eq_of_lt hlt2] rw [hsub] have harg : Real.pi * ((k.val - m : ℕ) : ℝ) / (m : ℝ) = Real.pi * (k.val : ℝ) / (m : ℝ) - Real.pi := by rw [Nat.cast_sub (by omega)]; field_simp [ne_of_gt hm_pos] rw [harg, Real.cos_sub_pi] have hsum_eq : ∑ k : Fin (2 * m), f k = ∑ k : Fin (2 * m), f (shift k) := (Equiv.sum_comp shift f).symm have hsum_neg : ∑ k : Fin (2 * m), f (shift k) = -(∑ k : Fin (2 * m), f k) := by simp_rw [hneg, Finset.sum_neg_distrib] linarith have hnz : ∃ k : Fin (2 * m), f k ≠ 0 := by refine ⟨⟨0, by omega⟩, ?_⟩ simp [f] have heig : K.apply f = ((1 + Real.cos (Real.pi / (m : ℝ))) / 2) • f := by ext k simp only [MarkovKernel.apply, K, lazyCycleKernel, Pi.smul_apply, smul_eq_mul, add_mul, Finset.sum_add_distrib, ite_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ite_true] -- Show f(k+1 mod 2m) = cos(π(k+1)/m) and f(k-1 mod 2m) = cos(π(k-1)/m)! have hf_plus : f ⟨(k.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ = Real.cos (Real.pi * (k.val : ℝ) / (m : ℝ) + Real.pi / (m : ℝ)) := by dsimp only [f] by_cases htop : k.val + 1 = 2 * m · rw [htop, Nat.mod_self] have harg : Real.pi * (k.val : ℝ) / (m : ℝ) + Real.pi / (m : ℝ) = 2 * Real.pi := by have hk : (k.val : ℝ) + 1 = 2 * (m : ℝ) := by exact_mod_cast htop field_simp [ne_of_gt hm_pos]; linarith rw [harg, Real.cos_two_pi]; simp · rw [Nat.mod_eq_of_lt (by omega)] congr 1; push_cast; field_simp [ne_of_gt hm_pos] have hf_minus : f ⟨(k.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ = Real.cos (Real.pi * (k.val : ℝ) / (m : ℝ) - Real.pi / (m : ℝ)) := by dsimp only [f] by_cases h0 : k.val = 0 · rw [h0] have hlt2m : 2 * m - 1 < 2 * m := by omega have hmod : (0 + 2 * m - 1) % (2 * m) = 2 * m - 1 := by rw [zero_add]; exact Nat.mod_eq_of_lt hlt2m rw [hmod] have harg : Real.pi * ((2 * m - 1 : ℕ) : ℝ) / (m : ℝ) = 2 * Real.pi - Real.pi / (m : ℝ) := by rw [Nat.cast_sub (show 1 ≤ 2 * m by omega)]; push_cast; field_simp [ne_of_gt hm_pos] rw [harg, Real.cos_two_pi_sub] simp [Real.cos_neg] · have hmod : (k.val + 2 * m - 1) % (2 * m) = k.val - 1 := by have hk := k.isLt have hrew : k.val + 2 * m - 1 = (k.val - 1) + 2 * m := by omega have hlt1 : k.val - 1 < 2 * m := by omega rw [hrew, Nat.add_mod_right, Nat.mod_eq_of_lt hlt1] rw [hmod] have harg : Real.pi * ((k.val - 1 : ℕ) : ℝ) / (m : ℝ) = Real.pi * (k.val : ℝ) / (m : ℝ) - Real.pi / (m : ℝ) := by rw [Nat.cast_sub (show 1 ≤ k.val by omega)]; push_cast; field_simp [ne_of_gt hm_pos] rw [harg] rw [hf_plus, hf_minus, Real.cos_add, Real.cos_sub] dsimp only [f] ring exact ⟨hmean, hnz, heig⟩ /-- **Exact Lazy Cycle `C_{2m}` Conductance Upper Bound (`Φ_* ≤ 1 / (2 m)`)**: the half-cycle cut `S = {0, ..., m-1}` has exact conductance `Φ(S) = 1 / (2 m)`. -/ theorem lazyCycle_half_cut_conductance (m : ℕ) (hm : 2 ≤ m) : let K := lazyCycleKernel m hm let π := Dist.uniform (⟨⟨0, by omega⟩⟩ : Nonempty (Fin (2 * m))) let S : Finset (Fin (2 * m)) := Finset.univ.filter fun k => k.val < m π.prob S = 1 / 2 ∧ ergodicFlow K π S Sᶜ = 1 / (4 * (m : ℝ)) ∧ cutConductance K π S = 1 / (2 * (m : ℝ)) ∧ bottleneckRatio K π (by simp; omega) ≤ 1 / (2 * (m : ℝ)) := by intro K π S have hm_pos : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) have hcardS : S.card = m := by have hbij : S = (Finset.range m).attach.image (fun x => ⟨x.1, by have := Finset.mem_range.mp x.2; omega⟩) := by ext k simp only [S, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image, Finset.mem_attach, true_and, Subtype.exists] constructor · intro hk; exact ⟨k.val, Finset.mem_range.mpr hk, rfl⟩ · rintro ⟨a, ha, rfl⟩; exact Finset.mem_range.mp ha rw [hbij, Finset.card_image_of_injective] · simp · intro a b h; exact Subtype.ext (congrArg Fin.val h) have hpS : π.prob S = 1 / 2 := by unfold Dist.prob simp only [π, Dist.uniform, Fintype.card_fin, Finset.sum_const, hcardS, nsmul_eq_mul] push_cast; field_simp [ne_of_gt hm_pos] -- Compute ergodic flow Q(S, Sᶜ) = (1/(2m)) * (1/4 + 1/4) = 1/(4m)! -- Only boundary edges from S to Sᶜ are (0 -> 2m-1) and (m-1 -> m)! have hflow : ergodicFlow K π S Sᶜ = 1 / (4 * (m : ℝ)) := by unfold ergodicFlow simp only [π, Dist.uniform, Fintype.card_fin, ← Finset.mul_sum] have hsumP : ∑ x ∈ S, ∑ y ∈ Sᶜ, K.P x y = 1 / 2 := by -- For each x ∈ S, K.P x y is nonzero only for y ∈ {x, x+1 mod 2m, x-1 mod 2m}. -- Since x ∈ S, x ∉ Sᶜ. -- (x+1 mod 2m) ∈ Sᶜ iff x = m-1. -- (x-1 mod 2m) ∈ Sᶜ iff x = 0. have hrow : ∀ x ∈ S, ∑ y ∈ Sᶜ, K.P x y = (if x.val = m - 1 then (1 / 4 : ℝ) else 0) + (if x.val = 0 then (1 / 4 : ℝ) else 0) := fun x hx => by have hxm : x.val < m := (Finset.mem_filter.mp hx).2 simp only [K, lazyCycleKernel, Finset.sum_add_distrib] have h0 : (∑ y ∈ Sᶜ, if y = x then (1 / 2 : ℝ) else 0) = 0 := Finset.sum_eq_zero fun y hy => if_neg (fun h : y = x => (Finset.mem_compl.mp hy) (h.symm ▸ hx)) have h1 : (∑ y ∈ Sᶜ, if y = ⟨(x.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0) = if x.val = m - 1 then (1 / 4 : ℝ) else 0 := by rw [Finset.sum_ite_eq'] have hmem : (⟨(x.val + 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ : Fin (2 * m)) ∈ Sᶜ ↔ x.val = m - 1 := by simp only [S, Finset.mem_compl, Finset.mem_filter, Finset.mem_univ, true_and, not_lt] rw [Nat.mod_eq_of_lt (by omega)]; omega simp [hmem] have h2 : (∑ y ∈ Sᶜ, if y = ⟨(x.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ then (1 / 4 : ℝ) else 0) = if x.val = 0 then (1 / 4 : ℝ) else 0 := by rw [Finset.sum_ite_eq'] have hmem : (⟨(x.val + 2 * m - 1) % (2 * m), Nat.mod_lt _ (by omega)⟩ : Fin (2 * m)) ∈ Sᶜ ↔ x.val = 0 := by simp only [S, Finset.mem_compl, Finset.mem_filter, Finset.mem_univ, true_and, not_lt] by_cases hx0 : x.val = 0 · rw [hx0, zero_add, Nat.mod_eq_of_lt (by omega)]; omega · have : x.val + 2 * m - 1 = (x.val - 1) + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)]; omega simp [hmem] rw [h0, h1, h2, zero_add] rw [Finset.sum_congr rfl hrow, Finset.sum_add_distrib] have ha : (∑ x ∈ S, if x.val = m - 1 then (1 / 4 : ℝ) else 0) = 1 / 4 := by have hmem : (⟨m - 1, by omega⟩ : Fin (2 * m)) ∈ S := by simp [S]; omega rw [Finset.sum_eq_single ⟨m - 1, by omega⟩] · simp · intro x _ hne; rw [if_neg]; intro h; exact hne (Fin.ext h) · intro h; exact absurd hmem h have hb : (∑ x ∈ S, if x.val = 0 then (1 / 4 : ℝ) else 0) = 1 / 4 := by have hmem : (⟨0, by omega⟩ : Fin (2 * m)) ∈ S := by simp [S]; omega rw [Finset.sum_eq_single ⟨0, by omega⟩] · simp · intro x _ hne; rw [if_neg]; intro h; exact hne (Fin.ext h) · intro h; exact absurd hmem h rw [ha, hb]; norm_num rw [hsumP] push_cast; field_simp [ne_of_gt hm_pos]; ring have hcut : cutConductance K π S = 1 / (2 * (m : ℝ)) := by unfold cutConductance; rw [hflow, hpS]; field_simp [ne_of_gt hm_pos]; ring have hSne : S.Nonempty := ⟨⟨0, by omega⟩, by simp [S]; omega⟩ have hle : bottleneckRatio K π (by simp; omega) ≤ 1 / (2 * (m : ℝ)) := by rw [← hcut] exact bottleneckRatio_le_cutConductance K π (by simp; omega) hSne (by linarith) exact ⟨hpS, hflow, hcut, hle⟩ /-- **Exact Quadratic-Slowdown Spectral Gap Bound on `C_{2m}` (`γ ≤ (1 - cos(π/m))/2 ≤ π²/(4 m²)`)**: via the cosine eigenfunction `f(k) = cos(π k / m)` and `1 - cos x ≤ x² / 2`. -/ theorem lazyCycle_spectralGap_le_quadratic (m : ℕ) (hm : 2 ≤ m) : let π := Dist.uniform (⟨⟨0, by omega⟩⟩ : Nonempty (Fin (2 * m))) let hrev := lazyCycleKernel_reversible m hm let hpos : ∀ x : Fin (2 * m), 0 < π x := fun _ => by simp only [π, Dist.uniform, Fintype.card_fin] exact inv_pos.mpr (by exact_mod_cast (show 0 < 2 * m by omega)) spectralGap hrev hpos (by simp; omega) ≤ (1 - Real.cos (Real.pi / (m : ℝ))) / 2 ∧ (1 - Real.cos (Real.pi / (m : ℝ))) / 2 ≤ Real.pi ^ 2 / (4 * (m : ℝ) ^ 2) := by intro π hrev hpos let K := lazyCycleKernel m hm obtain ⟨hmean, ⟨k₀, hk₀⟩, heig⟩ := lazyCycle_cosine_eigenfunction m hm let f : Fin (2 * m) → ℝ := fun k => Real.cos (Real.pi * (k.val : ℝ) / (m : ℝ)) have hvar_pos : 0 < π.variance f := by unfold Dist.variance rw [hmean] have hterm : 0 < π k₀ * (f k₀ - 0) ^ 2 := mul_pos (hpos k₀) (sq_pos_of_ne_zero (by simpa using hk₀)) exact lt_of_lt_of_le hterm (Finset.single_le_sum (f := fun k => π k * (f k - 0) ^ 2) (fun k _ => mul_nonneg (π.nonneg k) (sq_nonneg _)) (Finset.mem_univ k₀)) have hpoinc := spectralGap_mul_variance_le_dirichlet hrev hpos (by simp; omega) f have hdir : dirichletForm K π f = ((1 - Real.cos (Real.pi / (m : ℝ))) / 2) * π.variance f := by rw [dirichletForm_eq_l2Inner_sub hrev f, heig] have hnorm : l2NormSq π f = π.variance f := by unfold l2NormSq l2Inner Dist.variance rw [hmean]; refine Finset.sum_congr rfl fun k _ => by ring have hin : l2Inner π (((1 + Real.cos (Real.pi / (m : ℝ))) / 2) • f) f = ((1 + Real.cos (Real.pi / (m : ℝ))) / 2) * l2NormSq π f := by rw [l2NormSq, l2Inner, l2Inner, Finset.mul_sum] refine Finset.sum_congr rfl fun k _ => by simp only [Pi.smul_apply, smul_eq_mul]; ring rw [hin, hnorm]; ring rw [hdir] at hpoinc have hle1 : spectralGap hrev hpos (by simp; omega) ≤ (1 - Real.cos (Real.pi / (m : ℝ))) / 2 := by nlinarith -- Elementary bound 1 - cos θ ≤ θ² / 2 for θ = π / m > 0: have hm_pos : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) have hcos_ub : 1 - Real.cos (Real.pi / (m : ℝ)) ≤ (Real.pi / (m : ℝ)) ^ 2 / 2 := by have hhalf : 1 - Real.cos (Real.pi / (m : ℝ)) = 2 * Real.sin (Real.pi / (m : ℝ) / 2) ^ 2 := by have h2 := Real.cos_two_mul (Real.pi / (m : ℝ) / 2) have harg : 2 * (Real.pi / (m : ℝ) / 2) = Real.pi / (m : ℝ) := by ring rw [harg] at h2 have hpy := Real.sin_sq_add_cos_sq (Real.pi / (m : ℝ) / 2) linarith rw [hhalf] have hθ_nn : 0 ≤ Real.pi / (m : ℝ) / 2 := by positivity have hθ_le_pi : Real.pi / (m : ℝ) / 2 ≤ Real.pi := by have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega) have hpi : 0 ≤ Real.pi := le_of_lt Real.pi_pos rw [div_div, div_le_iff₀ (by positivity)] nlinarith have hsin_nn : 0 ≤ Real.sin (Real.pi / (m : ℝ) / 2) := Real.sin_nonneg_of_nonneg_of_le_pi hθ_nn hθ_le_pi have hsin_le : Real.sin (Real.pi / (m : ℝ) / 2) ≤ Real.pi / (m : ℝ) / 2 := Real.sin_le hθ_nn have hsq : Real.sin (Real.pi / (m : ℝ) / 2) ^ 2 ≤ (Real.pi / (m : ℝ) / 2) ^ 2 := by nlinarith linarith have hle2 : (1 - Real.cos (Real.pi / (m : ℝ))) / 2 ≤ Real.pi ^ 2 / (4 * (m : ℝ) ^ 2) := by have hr : ((Real.pi / (m : ℝ)) ^ 2 / 2) / 2 = Real.pi ^ 2 / (4 * (m : ℝ) ^ 2) := by field_simp [ne_of_gt hm_pos]; ring linarith exact ⟨hle1, hle2⟩ end Pillar3_CheegerCanonicalPaths /-! ============================================================================ PILLAR 4: BUBLEY–DYER PATH COUPLING & GLAUBER DYNAMICS UNIQUENESS ============================================================================ -/ section Pillar4_PathCouplingGlauber variable {Ω : Type*} [Fintype Ω] [DecidableEq Ω] /-- Expected transport cost `E_γ[d(X, Y)] = ∑_{x, y} d(x, y) γ(x, y)` of a coupling `c`. -/ def transportCost (d : Ω → Ω → ℝ) {μ ν : Dist Ω} (c : Coupling μ ν) : ℝ := ∑ x : Ω, ∑ y : Ω, d x y * c.γ x y /-- A finite metric `d` on `Ω` with unit separation (`1 ≤ d x y` for `x ≠ y`). -/ structure UnitSepMetric (Ω : Type*) where d : Ω → Ω → ℝ nonneg : ∀ x y, 0 ≤ d x y self : ∀ x, d x x = 0 symm : ∀ x y, d x y = d y x triangle : ∀ x y z, d x z ≤ d x y + d y z unit_sep : ∀ x y, x ≠ y → 1 ≤ d x y omit [DecidableEq Ω] in lemma transportCost_nonneg {d : Ω → Ω → ℝ} (hd : ∀ x y, 0 ≤ d x y) {μ ν : Dist Ω} (c : Coupling μ ν) : 0 ≤ transportCost d c := Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => mul_nonneg (hd x y) (c.nonneg x y) /-- **TV vs. Wasserstein-1 Coupling Bound**: for any unit-separated metric `d` (`1 ≤ d(x, y)` whenever `x ≠ y`) and ANY coupling `c` of `(μ, ν)`: `d_TV(μ, ν) ≤ E_c[d(X, Y)]`. -/ theorem tvDist_le_transportCost (M : UnitSepMetric Ω) {μ ν : Dist Ω} (c : Coupling μ ν) : tvDist μ ν ≤ transportCost M.d c := by calc tvDist μ ν ≤ c.neqProb := fundamental_coupling_inequality c _ = ∑ x : Ω, ∑ y : Ω, if x ≠ y then c.γ x y else 0 := rfl _ ≤ ∑ x : Ω, ∑ y : Ω, M.d x y * c.γ x y := by refine Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun y _ => ?_ by_cases h : x = y · subst h; simp [M.self] · rw [if_pos h] have h1 : 1 ≤ M.d x y := M.unit_sep x y h nlinarith [c.nonneg x y] omit [DecidableEq Ω] in /-- **Coupling Gluing Lemma (Markov Composition of Couplings)**: given couplings `c₁` of `(μ₁, μ₂)` and `c₂` of `(μ₂, μ₃)`, there exists a glued coupling `c₁₃` of `(μ₁, μ₃)` satisfying the transport-cost triangle inequality `E_{c₁₃}[d] ≤ E_{c₁}[d] + E_{c₂}[d]`. -/ theorem coupling_gluing_triangle {d : Ω → Ω → ℝ} (htri : ∀ x y z, d x z ≤ d x y + d y z) {μ₁ μ₂ μ₃ : Dist Ω} (c₁ : Coupling μ₁ μ₂) (c₂ : Coupling μ₂ μ₃) : ∃ c₁₃ : Coupling μ₁ μ₃, transportCost d c₁₃ ≤ transportCost d c₁ + transportCost d c₂ := by have hc₁_zero : ∀ x y, μ₂ y = 0 → c₁.γ x y = 0 := fun x y hy => by have hle : c₁.γ x y ≤ μ₂ y := by rw [← c₁.snd_marginal y] exact Finset.single_le_sum (fun u _ => c₁.nonneg u y) (Finset.mem_univ x) linarith [c₁.nonneg x y] have hc₂_zero : ∀ y z, μ₂ y = 0 → c₂.γ y z = 0 := fun y z hy => by have hle : c₂.γ y z ≤ μ₂ y := by rw [← c₂.fst_marginal y] exact Finset.single_le_sum (fun v _ => c₂.nonneg y v) (Finset.mem_univ z) linarith [c₂.nonneg y z] let γ : Ω → Ω → ℝ := fun x z => ∑ y : Ω, if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y have hnn : ∀ x z, 0 ≤ γ x z := fun x z => Finset.sum_nonneg fun y _ => by by_cases hy : μ₂ y = 0 · simp [hy] · rw [if_neg hy] exact div_nonneg (mul_nonneg (c₁.nonneg x y) (c₂.nonneg y z)) (μ₂.nonneg y) have hfst : ∀ x, ∑ z : Ω, γ x z = μ₁ x := fun x => by dsimp only [γ] rw [Finset.sum_comm] calc ∑ y : Ω, ∑ z : Ω, (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) = ∑ y : Ω, c₁.γ x y := by refine Finset.sum_congr rfl fun y _ => ?_ by_cases hy : μ₂ y = 0 · simp [hy, hc₁_zero x y hy] · simp only [if_neg hy] have hrew : ∑ z : Ω, c₁.γ x y * c₂.γ y z / μ₂ y = (c₁.γ x y / μ₂ y) * ∑ z : Ω, c₂.γ y z := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun z _ => by ring rw [hrew, c₂.fst_marginal y]; field_simp [hy] _ = μ₁ x := c₁.fst_marginal x have hsnd : ∀ z, ∑ x : Ω, γ x z = μ₃ z := fun z => by dsimp only [γ] rw [Finset.sum_comm] calc ∑ y : Ω, ∑ x : Ω, (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) = ∑ y : Ω, c₂.γ y z := by refine Finset.sum_congr rfl fun y _ => ?_ by_cases hy : μ₂ y = 0 · simp [hy, hc₂_zero y z hy] · simp only [if_neg hy] have hrew : ∑ x : Ω, c₁.γ x y * c₂.γ y z / μ₂ y = (∑ x : Ω, c₁.γ x y) * (c₂.γ y z / μ₂ y) := by rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun x _ => by ring rw [hrew, c₁.snd_marginal y]; field_simp [hy] _ = μ₃ z := c₂.snd_marginal z let c₁₃ : Coupling μ₁ μ₃ := ⟨γ, hnn, hfst, hsnd⟩ refine ⟨c₁₃, ?_⟩ unfold transportCost change ∑ x : Ω, ∑ z : Ω, d x z * γ x z ≤ (∑ x : Ω, ∑ y : Ω, d x y * c₁.γ x y) + (∑ y : Ω, ∑ z : Ω, d y z * c₂.γ y z) dsimp only [γ] calc ∑ x, ∑ z, d x z * ∑ y, (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) = ∑ x, ∑ z, ∑ y, d x z * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun z _ => Finset.mul_sum .. _ ≤ ∑ x, ∑ z, ∑ y, (d x y + d y z) * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) := by refine Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun z _ => Finset.sum_le_sum fun y _ => ?_ have hterm_nn : 0 ≤ (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) := by by_cases hy : μ₂ y = 0 · simp [hy] · rw [if_neg hy]; exact div_nonneg (mul_nonneg (c₁.nonneg x y) (c₂.nonneg y z)) (μ₂.nonneg y) exact mul_le_mul_of_nonneg_right (htri x y z) hterm_nn _ = (∑ x, ∑ z, ∑ y, d x y * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y)) + (∑ x, ∑ z, ∑ y, d y z * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y)) := by simp_rw [add_mul, Finset.sum_add_distrib] _ = (∑ x, ∑ y, d x y * c₁.γ x y) + (∑ y, ∑ z, d y z * c₂.γ y z) := by congr 1 · refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.sum_comm] refine Finset.sum_congr rfl fun y _ => ?_ by_cases hy : μ₂ y = 0 · simp [hy, hc₁_zero x y hy] · simp only [if_neg hy] have hrew : ∑ z : Ω, d x y * (c₁.γ x y * c₂.γ y z / μ₂ y) = (d x y * c₁.γ x y / μ₂ y) * ∑ z : Ω, c₂.γ y z := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun z _ => by ring rw [hrew, c₂.fst_marginal y]; field_simp [hy] · calc ∑ x, ∑ z, ∑ y, d y z * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) = ∑ x, ∑ y, ∑ z, d y z * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) := Finset.sum_congr rfl fun x _ => Finset.sum_comm _ = ∑ y, ∑ x, ∑ z, d y z * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) := Finset.sum_comm _ = ∑ y, ∑ z, ∑ x, d y z * (if μ₂ y = 0 then 0 else c₁.γ x y * c₂.γ y z / μ₂ y) := Finset.sum_congr rfl fun y _ => Finset.sum_comm _ = ∑ y, ∑ z, d y z * c₂.γ y z := by refine Finset.sum_congr rfl fun y _ => Finset.sum_congr rfl fun z _ => ?_ by_cases hy : μ₂ y = 0 · simp [hy, hc₂_zero y z hy] · simp only [if_neg hy] have hrew : ∑ x : Ω, d y z * (c₁.γ x y * c₂.γ y z / μ₂ y) = (∑ x : Ω, c₁.γ x y) * (d y z * c₂.γ y z / μ₂ y) := by rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun x _ => by ring rw [hrew, c₁.snd_marginal y]; field_simp [hy] /-- **Markov Coupling Lift**: lift any coupling `c` of `(μ, ν)` through a kernel `K` using a family of 1-step couplings `stepC x y` of `(P(x, ·), P(y, ·))`. -/ def liftStepCoupling (K : MarkovKernel Ω) {μ ν : Dist Ω} (c : Coupling μ ν) (stepC : ∀ x y : Ω, Coupling (K.row x) (K.row y)) : Coupling (K.push μ) (K.push ν) where γ x' y' := ∑ x : Ω, ∑ y : Ω, c.γ x y * (stepC x y).γ x' y' nonneg x' y' := Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => mul_nonneg (c.nonneg x y) ((stepC x y).nonneg x' y') fst_marginal x' := by calc ∑ y', ∑ x, ∑ y, c.γ x y * (stepC x y).γ x' y' = ∑ x, ∑ y', ∑ y, c.γ x y * (stepC x y).γ x' y' := Finset.sum_comm _ = ∑ x, ∑ y, ∑ y', c.γ x y * (stepC x y).γ x' y' := Finset.sum_congr rfl fun x _ => Finset.sum_comm _ = ∑ x, ∑ y, c.γ x y * K.P x x' := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by rw [← Finset.mul_sum, (stepC x y).fst_marginal x']; rfl _ = ∑ x, μ x * K.P x x' := Finset.sum_congr rfl fun x _ => by rw [← Finset.sum_mul, c.fst_marginal x] _ = K.push μ x' := rfl snd_marginal y' := by calc ∑ x', ∑ x, ∑ y, c.γ x y * (stepC x y).γ x' y' = ∑ x, ∑ x', ∑ y, c.γ x y * (stepC x y).γ x' y' := Finset.sum_comm _ = ∑ x, ∑ y, ∑ x', c.γ x y * (stepC x y).γ x' y' := Finset.sum_congr rfl fun x _ => Finset.sum_comm _ = ∑ x, ∑ y, c.γ x y * K.P y y' := Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by rw [← Finset.mul_sum, (stepC x y).snd_marginal y']; rfl _ = ∑ y, ∑ x, c.γ x y * K.P y y' := Finset.sum_comm _ = ∑ y, ν y * K.P y y' := Finset.sum_congr rfl fun y _ => by rw [← Finset.sum_mul, c.snd_marginal y] _ = K.push ν y' := rfl omit [DecidableEq Ω] in lemma transportCost_liftStepCoupling (K : MarkovKernel Ω) (d : Ω → Ω → ℝ) {μ ν : Dist Ω} (c : Coupling μ ν) (stepC : ∀ x y : Ω, Coupling (K.row x) (K.row y)) : transportCost d (liftStepCoupling K c stepC) = ∑ x : Ω, ∑ y : Ω, c.γ x y * transportCost d (stepC x y) := by unfold transportCost liftStepCoupling calc ∑ x', ∑ y', d x' y' * ∑ x, ∑ y, c.γ x y * (stepC x y).γ x' y' = ∑ x', ∑ y', ∑ x, ∑ y, c.γ x y * (d x' y' * (stepC x y).γ x' y') := by refine Finset.sum_congr rfl fun x' _ => Finset.sum_congr rfl fun y' _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun y _ => by ring _ = ∑ x, ∑ x', ∑ y', ∑ y, c.γ x y * (d x' y' * (stepC x y).γ x' y') := by calc ∑ x', ∑ y', ∑ x, ∑ y, c.γ x y * (d x' y' * (stepC x y).γ x' y') = ∑ x', ∑ x, ∑ y', ∑ y, c.γ x y * (d x' y' * (stepC x y).γ x' y') := Finset.sum_congr rfl fun x' _ => Finset.sum_comm _ = ∑ x, ∑ x', ∑ y', ∑ y, c.γ x y * (d x' y' * (stepC x y).γ x' y') := Finset.sum_comm _ = ∑ x, ∑ y, ∑ x', ∑ y', c.γ x y * (d x' y' * (stepC x y).γ x' y') := by refine Finset.sum_congr rfl fun x _ => ?_ calc ∑ x', ∑ y', ∑ y, c.γ x y * (d x' y' * (stepC x y).γ x' y') = ∑ x', ∑ y, ∑ y', c.γ x y * (d x' y' * (stepC x y).γ x' y') := Finset.sum_congr rfl fun x' _ => Finset.sum_comm _ = ∑ y, ∑ x', ∑ y', c.γ x y * (d x' y' * (stepC x y).γ x' y') := Finset.sum_comm _ = ∑ x, ∑ y, c.γ x y * ∑ x', ∑ y', d x' y' * (stepC x y).γ x' y' := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ rw [Finset.mul_sum] exact Finset.sum_congr rfl fun x' _ => (Finset.mul_sum ..).symm omit [DecidableEq Ω] in /-- **1-Step Wasserstein-1 Contraction Lifts to Arbitrary Distributions**: if `∀ x y, ∃ c : Coupling (P(x,·)) (P(y,·)), E_c[d] ≤ (1 - α) d(x, y)`, then EVERY coupling `c` of `(μ, ν)` lifts to a coupling `c'` of `(μ P, ν P)` with `E_{c'}[d] ≤ (1 - α) E_c[d]`. -/ theorem wasserstein_one_step_contraction {K : MarkovKernel Ω} {d : Ω → Ω → ℝ} {α : ℝ} (hstep : ∀ x y : Ω, ∃ c : Coupling (K.row x) (K.row y), transportCost d c ≤ (1 - α) * d x y) {μ ν : Dist Ω} (c : Coupling μ ν) : ∃ c' : Coupling (K.push μ) (K.push ν), transportCost d c' ≤ (1 - α) * transportCost d c := by choose stepC hstepC using hstep refine ⟨liftStepCoupling K c stepC, ?_⟩ rw [transportCost_liftStepCoupling K d c stepC] unfold transportCost rw [Finset.mul_sum] refine Finset.sum_le_sum fun x _ => ?_ rw [Finset.mul_sum] refine Finset.sum_le_sum fun y _ => ?_ calc c.γ x y * transportCost d (stepC x y) ≤ c.γ x y * ((1 - α) * d x y) := mul_le_mul_of_nonneg_left (hstepC x y) (c.nonneg x y) _ = (1 - α) * (d x y * c.γ x y) := by ring /-- Cast a coupling across equal marginal distributions without altering its transport cost. -/ def Coupling.cast {μ₁ μ₂ ν₁ ν₂ : Dist Ω} (h1 : μ₁ = μ₂) (h2 : ν₁ = ν₂) (c : Coupling μ₁ ν₁) : Coupling μ₂ ν₂ where γ := c.γ nonneg := c.nonneg fst_marginal x := by rw [← h1]; exact c.fst_marginal x snd_marginal y := by rw [← h2]; exact c.snd_marginal y omit [DecidableEq Ω] in lemma transportCost_cast (d : Ω → Ω → ℝ) {μ₁ μ₂ ν₁ ν₂ : Dist Ω} (h1 : μ₁ = μ₂) (h2 : ν₁ = ν₂) (c : Coupling μ₁ ν₁) : transportCost d (c.cast h1 h2) = transportCost d c := rfl /-- **Iterated Wasserstein-1 Contraction**: for every `t : ℕ` and every `x, y : Ω`, there exists a coupling of `P^t(x, ·)` and `P^t(y, ·)` with cost `≤ (1 - α)^t d(x, y)`. -/ theorem wasserstein_iterated_contraction {K : MarkovKernel Ω} {d : Ω → Ω → ℝ} {α : ℝ} (hα1 : α ≤ 1) (hstep : ∀ x y : Ω, ∃ c : Coupling (K.row x) (K.row y), transportCost d c ≤ (1 - α) * d x y) (x y : Ω) : ∀ t : ℕ, ∃ c : Coupling (K.stepDist t x) (K.stepDist t y), transportCost d c ≤ (1 - α) ^ t * d x y | 0 => by refine ⟨{ γ := fun a b => if a = x ∧ b = y then 1 else 0 nonneg := fun a b => by split_ifs <;> norm_num fst_marginal := fun a => by simp only [MarkovKernel.stepDist, MarkovKernel.pow, MarkovKernel.row, MarkovKernel.id] by_cases ha : a = x · subst ha; simp · simp [ha, Ne.symm ha] snd_marginal := fun b => by simp only [MarkovKernel.stepDist, MarkovKernel.pow, MarkovKernel.row, MarkovKernel.id] by_cases hb : b = y · subst hb; simp · simp [hb, Ne.symm hb] }, ?_⟩ simp only [pow_zero, one_mul, transportCost] have hsum : ∑ a : Ω, ∑ b : Ω, d a b * (if a = x ∧ b = y then (1 : ℝ) else 0) = d x y := by rw [Finset.sum_eq_single x] · rw [Finset.sum_eq_single y] · simp · intro b _ hb; simp [hb] · intro h; exact absurd (Finset.mem_univ y) h · intro a _ ha; exact Finset.sum_eq_zero fun b _ => by simp [ha] · intro h; exact absurd (Finset.mem_univ x) h linarith | t + 1 => by obtain ⟨ct, hct⟩ := wasserstein_iterated_contraction hα1 hstep x y t obtain ⟨ct1, hct1⟩ := wasserstein_one_step_contraction hstep ct refine ⟨ct1.cast (K.stepDist_succ t x).symm (K.stepDist_succ t y).symm, ?_⟩ rw [transportCost_cast] calc transportCost d ct1 ≤ (1 - α) * transportCost d ct := hct1 _ ≤ (1 - α) * ((1 - α) ^ t * d x y) := mul_le_mul_of_nonneg_left hct (by linarith) _ = (1 - α) ^ (t + 1) * d x y := by rw [pow_succ']; ring /-- **Geometric TV Mixing from Wasserstein-1 Contraction**: if `M` is a unit-separated metric of diameter `≤ D` and `K` contracts `M` by `1 - α` (`0 ≤ α ≤ 1`), then `d(t) ≤ d̄(t) ≤ D · (1 - α)^t ≤ D · exp(-α t)`. -/ theorem geometric_mixing_of_contraction {K : MarkovKernel Ω} {π : Dist Ω} (hπ : K.IsStationary π) (hne : Nonempty Ω) (M : UnitSepMetric Ω) {D α : ℝ} (hD : ∀ x y, M.d x y ≤ D) (hD_nn : 0 ≤ D) (hα1 : α ≤ 1) (hstep : ∀ x y : Ω, ∃ c : Coupling (K.row x) (K.row y), transportCost M.d c ≤ (1 - α) * M.d x y) (t : ℕ) : dTVMax K π hne t ≤ dBar K hne t ∧ dBar K hne t ≤ D * (1 - α) ^ t ∧ D * (1 - α) ^ t ≤ D * Real.exp (-α * t) := by have h1 := (dTVMax_le_dBar_and_dBar_le_two_dTVMax K hπ hne t).1 have h2 : dBar K hne t ≤ D * (1 - α) ^ t := by apply Finset.sup'_le intro p _ obtain ⟨ct, hct⟩ := wasserstein_iterated_contraction hα1 hstep p.1 p.2 t calc tvDist (K.stepDist t p.1) (K.stepDist t p.2) ≤ transportCost M.d ct := tvDist_le_transportCost M ct _ ≤ (1 - α) ^ t * M.d p.1 p.2 := hct _ ≤ (1 - α) ^ t * D := mul_le_mul_of_nonneg_left (hD p.1 p.2) (pow_nonneg (by linarith) t) _ = D * (1 - α) ^ t := mul_comm _ _ have h3 : D * (1 - α) ^ t ≤ D * Real.exp (-α * t) := by refine mul_le_mul_of_nonneg_left ?_ hD_nn have hexp1 : 1 - α ≤ Real.exp (-α) := by linarith [Real.add_one_le_exp (-α)] calc (1 - α) ^ t ≤ (Real.exp (-α)) ^ t := pow_le_pow_left₀ (by linarith) hexp1 t _ = Real.exp (t * -α) := (Real.exp_nat_mul (-α) t).symm _ = Real.exp (-α * t) := by ring_nf exact ⟨h1, h2, h3⟩ /-- **Bubley–Dyer Path Coupling Theorem (1997)**: suppose `Adj` is a local adjacency relation such that every pair `(x, y)` is connected by a geodesic path `L` whose edges satisfy `Adj` and whose edge-length sum equals `d(x, y)`. If 1-step contraction `E[d(X', Y')] ≤ (1 - α) d(u, v)` holds ONLY on adjacent pairs `Adj u v`, then it lifts AUTOMATICALLY to ALL pairs `(x, y) ∈ Ω × Ω`! -/ theorem bubley_dyer_path_coupling {K : MarkovKernel Ω} (M : UnitSepMetric Ω) (Adj : Ω → Ω → Prop) {α : ℝ} (hgeod : ∀ x y : Ω, ∃ L : List Ω, ∃ hne : L ≠ [], L.head hne = x ∧ L.getLast hne = y ∧ (∀ e ∈ pathEdges L, Adj e.1 e.2) ∧ ((pathEdges L).map fun e => M.d e.1 e.2).sum = M.d x y) (hadj : ∀ u v : Ω, Adj u v → ∃ c : Coupling (K.row u) (K.row v), transportCost M.d c ≤ (1 - α) * M.d u v) : ∀ x y : Ω, ∃ c : Coupling (K.row x) (K.row y), transportCost M.d c ≤ (1 - α) * M.d x y := by -- Prove by induction on any list L with adjacent edges: -- ∃ c : Coupling (K.row (L.head hne)) (K.row (L.getLast hne)), -- transportCost M.d c ≤ (1 - α) * ((pathEdges L).map fun e => M.d e.1 e.2).sum! have hpath_glue : ∀ (L : List Ω) (hne : L ≠ []), (∀ e ∈ pathEdges L, Adj e.1 e.2) → ∃ c : Coupling (K.row (L.head hne)) (K.row (L.getLast hne)), transportCost M.d c ≤ (1 - α) * ((pathEdges L).map fun e => M.d e.1 e.2).sum := by intro L induction L with | nil => intro hne; exact absurd rfl hne | cons a rest ih => cases rest with | nil => intro _ _ -- Identity coupling of K.row a with itself has cost 0! refine ⟨{ γ := fun u v => if u = v then K.P a u else 0 nonneg := fun u v => by split_ifs; exact K.nonneg a u; norm_num fst_marginal := fun u => by simp [MarkovKernel.row] snd_marginal := fun v => by simp [MarkovKernel.row] }, ?_⟩ simp only [pathEdges, List.map_nil, List.sum_nil, mul_zero, transportCost] have h0 : ∑ u : Ω, ∑ v : Ω, M.d u v * (if u = v then K.P a u else 0) = 0 := Finset.sum_eq_zero fun u _ => Finset.sum_eq_zero fun v _ => by by_cases h : u = v · subst h; simp [M.self] · simp [h] linarith | cons b tail => intro _ hE have hab : Adj a b := hE (a, b) (by simp [pathEdges]) have htail : ∀ e ∈ pathEdges (b :: tail), Adj e.1 e.2 := fun e he => hE e (by simp [pathEdges, he]) obtain ⟨c₁, hc₁⟩ := hadj a b hab obtain ⟨c₂, hc₂⟩ := ih (List.cons_ne_nil b tail) htail simp only [List.head_cons] at hc₂ c₂ obtain ⟨c₁₃, hc₁₃⟩ := coupling_gluing_triangle M.triangle c₁ c₂ have hlast_eq : (a :: b :: tail).getLast (List.cons_ne_nil a (b :: tail)) = (b :: tail).getLast (List.cons_ne_nil b tail) := List.getLast_cons (List.cons_ne_nil b tail) refine ⟨c₁₃.cast rfl (congrArg K.row hlast_eq.symm), ?_⟩ change transportCost M.d c₁₃ ≤ _ simp only [pathEdges, List.map_cons, List.sum_cons, mul_add] linarith intro x y obtain ⟨L, hne, hhead, hlast, hE, hsum⟩ := hgeod x y obtain ⟨c, hc⟩ := hpath_glue L hne hE refine ⟨c.cast (congrArg K.row hhead) (congrArg K.row hlast), ?_⟩ rw [transportCost_cast, ← hsum] exact hc /-- **Bubley–Dyer Mixing Time Theorem**: local edge contraction `α ∈ (0, 1]` on a geodesic graph of diameter `≤ D` implies global geometric mixing `d(t) ≤ D · (1 - α)^t ≤ D · exp(-α t)`. -/ theorem bubley_dyer_mixing_time {K : MarkovKernel Ω} {π : Dist Ω} (hπ : K.IsStationary π) (hne : Nonempty Ω) (M : UnitSepMetric Ω) (Adj : Ω → Ω → Prop) {D α : ℝ} (hD : ∀ x y, M.d x y ≤ D) (hD_nn : 0 ≤ D) (hα1 : α ≤ 1) (hgeod : ∀ x y : Ω, ∃ L : List Ω, ∃ hneL : L ≠ [], L.head hneL = x ∧ L.getLast hneL = y ∧ (∀ e ∈ pathEdges L, Adj e.1 e.2) ∧ ((pathEdges L).map fun e => M.d e.1 e.2).sum = M.d x y) (hadj : ∀ u v : Ω, Adj u v → ∃ c : Coupling (K.row u) (K.row v), transportCost M.d c ≤ (1 - α) * M.d u v) (t : ℕ) : dTVMax K π hne t ≤ D * (1 - α) ^ t ∧ D * (1 - α) ^ t ≤ D * Real.exp (-α * t) := by have hglobal := bubley_dyer_path_coupling M Adj hgeod hadj have hmix := geometric_mixing_of_contraction hπ hne M hD hD_nn hα1 hglobal t exact ⟨le_trans hmix.1 hmix.2.1, hmix.2.2⟩ /-! ### Single-Site Glauber Dynamics, Dobrushin Uniqueness, Ising & Jerrum `q > 2 Δ` Colorings -/ section GlauberDynamics variable {V S : Type*} [Fintype V] [DecidableEq V] [Fintype S] [DecidableEq S] /-- Hamming distance `d_H(σ, τ) = |{v ∈ V | σ v ≠ τ v}|` on spin configurations `V → S`. -/ def hammingDist (σ τ : V → S) : ℝ := ((Finset.univ.filter fun v : V => σ v ≠ τ v).card : ℝ) omit [DecidableEq V] [Fintype S] in lemma hammingDist_nonneg (σ τ : V → S) : 0 ≤ hammingDist σ τ := Nat.cast_nonneg _ omit [DecidableEq V] [Fintype S] in lemma hammingDist_self (σ : V → S) : hammingDist σ σ = 0 := by simp [hammingDist] omit [DecidableEq V] [Fintype S] in lemma hammingDist_symm (σ τ : V → S) : hammingDist σ τ = hammingDist τ σ := by unfold hammingDist; congr 2; ext v; simp [ne_comm] omit [Fintype S] in lemma hammingDist_triangle (σ ρ τ : V → S) : hammingDist σ τ ≤ hammingDist σ ρ + hammingDist ρ τ := by unfold hammingDist have hsub : (Finset.univ.filter fun v : V => σ v ≠ τ v) ⊆ (Finset.univ.filter fun v : V => σ v ≠ ρ v) ∪ (Finset.univ.filter fun v : V => ρ v ≠ τ v) := by intro v hv simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_union] at hv ⊢ by_cases h : σ v = ρ v · right; intro h2; exact hv (h.trans h2) · left; exact h have hcard : (Finset.univ.filter fun v : V => σ v ≠ τ v).card ≤ (Finset.univ.filter fun v : V => σ v ≠ ρ v).card + (Finset.univ.filter fun v : V => ρ v ≠ τ v).card := le_trans (Finset.card_le_card hsub) (Finset.card_union_le _ _) exact_mod_cast hcard omit [DecidableEq V] [Fintype S] in lemma hammingDist_unit_sep (σ τ : V → S) (hne : σ ≠ τ) : 1 ≤ hammingDist σ τ := by have hex : ∃ v : V, σ v ≠ τ v := by by_contra h; push Not at h; exact hne (funext h) obtain ⟨v, hv⟩ := hex have hpos : 1 ≤ (Finset.univ.filter fun u : V => σ u ≠ τ u).card := Finset.card_pos.mpr ⟨v, Finset.mem_filter.mpr ⟨Finset.mem_univ v, hv⟩⟩ unfold hammingDist exact_mod_cast hpos omit [DecidableEq V] [Fintype S] in lemma hammingDist_le_card (σ τ : V → S) : hammingDist σ τ ≤ (Fintype.card V : ℝ) := by unfold hammingDist exact_mod_cast Finset.card_le_univ _ /-- Hamming metric bundled as a `UnitSepMetric (V → S)`. -/ def hammingMetric (V S : Type*) [Fintype V] [DecidableEq V] [Fintype S] [DecidableEq S] : UnitSepMetric (V → S) where d := hammingDist nonneg := hammingDist_nonneg self := hammingDist_self symm := hammingDist_symm triangle := hammingDist_triangle unit_sep := hammingDist_unit_sep omit [Fintype S] in /-- Hamming distance is a geodesic metric with adjacent edges = single-site flips (`d_H = 1`). -/ theorem hamming_geodesic (σ τ : V → S) : ∃ L : List (V → S), ∃ hne : L ≠ [], L.head hne = σ ∧ L.getLast hne = τ ∧ (∀ e ∈ pathEdges L, hammingDist e.1 e.2 = 1) ∧ ((pathEdges L).map fun e => hammingDist e.1 e.2).sum = hammingDist σ τ := by -- Induction on the cardinality k = |{v | σ v ≠ τ v}|! suffices h : ∀ (k : ℕ) (σ τ : V → S), (Finset.univ.filter fun v : V => σ v ≠ τ v).card = k → ∃ L : List (V → S), ∃ hne : L ≠ [], L.head hne = σ ∧ L.getLast hne = τ ∧ (∀ e ∈ pathEdges L, hammingDist e.1 e.2 = 1) ∧ ((pathEdges L).map fun e => hammingDist e.1 e.2).sum = (k : ℝ) by obtain ⟨L, hne, hh, hl, ha, hs⟩ := h _ σ τ rfl exact ⟨L, hne, hh, hl, ha, hs⟩ intro k induction k with | zero => intro σ τ hk have heq : σ = τ := by ext v by_contra hne have hpos : 0 < (Finset.univ.filter fun u : V => σ u ≠ τ u).card := Finset.card_pos.mpr ⟨v, Finset.mem_filter.mpr ⟨Finset.mem_univ v, hne⟩⟩ omega subst heq exact ⟨[σ], List.cons_ne_nil _ _, rfl, rfl, fun _ h => by simp [pathEdges] at h, by simp [pathEdges]⟩ | succ k ih => intro σ τ hk have hne_diff : (Finset.univ.filter fun v : V => σ v ≠ τ v).Nonempty := Finset.card_pos.mp (by omega) obtain ⟨v₀, hv₀⟩ := hne_diff have hv₀_ne : σ v₀ ≠ τ v₀ := (Finset.mem_filter.mp hv₀).2 let σ₁ : V → S := Function.update σ v₀ (τ v₀) have hdiff_step : hammingDist σ σ₁ = 1 := by unfold hammingDist have hfilt : (Finset.univ.filter fun u : V => σ u ≠ σ₁ u) = {v₀} := by ext u; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton, σ₁] by_cases hu : u = v₀ · subst hu; simp [hv₀_ne] · simp [hu] rw [hfilt, Finset.card_singleton]; norm_num have hdiff_rem : (Finset.univ.filter fun u : V => σ₁ u ≠ τ u).card = k := by have hfilt : (Finset.univ.filter fun u : V => σ₁ u ≠ τ u) = (Finset.univ.filter fun u : V => σ u ≠ τ u).erase v₀ := by ext u; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_erase, σ₁] by_cases hu : u = v₀ · subst hu; simp · simp [hu] rw [hfilt, Finset.card_erase_of_mem hv₀, hk]; omega obtain ⟨L', hne', hh', hl', ha', hs'⟩ := ih σ₁ τ hdiff_rem refine ⟨σ :: L', List.cons_ne_nil _ _, rfl, ?_, ?_, ?_⟩ · rw [List.getLast_cons hne']; exact hl' · intro e he cases L' with | nil => exact absurd rfl hne' | cons b rest => simp only [List.head_cons] at hh' subst hh' simp only [pathEdges, List.mem_cons] at he rcases he with rfl | he' · exact hdiff_step · exact ha' e he' · cases L' with | nil => exact absurd rfl hne' | cons b rest => simp only [List.head_cons] at hh' subst hh' simp only [pathEdges, List.map_cons, List.sum_cons, hdiff_step, hs', Nat.cast_succ] ring /-- Single-site Glauber dynamics Markov kernel on spin configurations `V → S`: pick a uniformly random vertex `v ∈ V` and update `σ v` according to local law `localLaw v σ`. -/ def glauberKernel (hneV : Nonempty V) (localLaw : V → (V → S) → Dist S) : MarkovKernel (V → S) where P σ τ := (Fintype.card V : ℝ)⁻¹ * ∑ v : V, if Function.update σ v (τ v) = τ then localLaw v σ (τ v) else 0 nonneg σ τ := mul_nonneg (by positivity) (Finset.sum_nonneg fun v _ => by split_ifs; exact (localLaw v σ).nonneg _; norm_num) row_sum_one σ := by have hn_pos : (0 : ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos_iff.mpr hneV rw [← Finset.mul_sum, Finset.sum_comm] have hinner : ∀ v : V, ∑ τ : V → S, (if Function.update σ v (τ v) = τ then localLaw v σ (τ v) else 0) = 1 := fun v => by have hbij : ∑ τ : V → S, (if Function.update σ v (τ v) = τ then localLaw v σ (τ v) else 0) = ∑ s : S, localLaw v σ s := by rw [← Finset.sum_filter] refine Finset.sum_bij (fun τ _ => τ v) ?_ ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro τ₁ hτ₁ τ₂ hτ₂ heq have h1 := (Finset.mem_filter.mp hτ₁).2 have h2 := (Finset.mem_filter.mp hτ₂).2 rw [← h1, ← h2, heq] · intro s _ refine ⟨Function.update σ v s, ?_, by simp⟩ simp · intro _ _; rfl rw [hbij, (localLaw v σ).sum_one] simp_rw [hinner, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] exact inv_mul_cancel₀ (ne_of_gt hn_pos) /-- **Dobrushin Glauber 1-Step Path Coupling Contraction**: suppose `localLaw v σ` depends only on spins outside `v`, and for every `σ, τ` differing at a single site `u` (`d_H(σ, τ) = 1`), the Dobrushin influence sum satisfies `∑_{v ≠ u} d_TV(localLaw v σ, localLaw v τ) ≤ α_Dob`. Then there exists a 1-step coupling of `glauberKernel(σ, ·)` and `glauberKernel(τ, ·)` with expected Hamming distance `≤ 1 - (1 - α_Dob) / |V|`! -/ theorem dobrushin_glauber_one_step_contraction (hneV : Nonempty V) (localLaw : V → (V → S) → Dist S) (hlocal : ∀ (v : V) (σ τ : V → S), (∀ w, w ≠ v → σ w = τ w) → localLaw v σ = localLaw v τ) {αDob : ℝ} (hdob : ∀ (u : V) (σ τ : V → S), (∀ w, w ≠ u → σ w = τ w) → ∑ v ∈ Finset.univ.erase u, tvDist (localLaw v σ) (localLaw v τ) ≤ αDob) {σ τ : V → S} (hadj : hammingDist σ τ = 1) : ∃ c : Coupling ((glauberKernel hneV localLaw).row σ) ((glauberKernel hneV localLaw).row τ), transportCost hammingDist c ≤ (1 - (1 - αDob) / (Fintype.card V : ℝ)) * hammingDist σ τ := by -- Extract the unique site u where σ u ≠ τ u! have hcard1 : (Finset.univ.filter fun w : V => σ w ≠ τ w).card = 1 := by unfold hammingDist at hadj; exact_mod_cast hadj obtain ⟨u, hu_eq⟩ := Finset.card_eq_one.mp hcard1 have hu_ne : σ u ≠ τ u := by have hmem : u ∈ Finset.univ.filter fun w : V => σ w ≠ τ w := by rw [hu_eq]; exact Finset.mem_singleton_self u exact (Finset.mem_filter.mp hmem).2 have hsame_other : ∀ w : V, w ≠ u → σ w = τ w := fun w hw => by by_contra hne have hmem : w ∈ Finset.univ.filter fun z : V => σ z ≠ τ z := Finset.mem_filter.mpr ⟨Finset.mem_univ w, hne⟩ rw [hu_eq, Finset.mem_singleton] at hmem exact hw hmem -- For each site v, take the exact maximal coupling m_v of localLaw v σ and localLaw v τ! have hmax : ∀ v : V, ∃ m : Coupling (localLaw v σ) (localLaw v τ), m.neqProb = tvDist (localLaw v σ) (localLaw v τ) := fun v => exists_maximal_coupling (localLaw v σ) (localLaw v τ) choose m hm using hmax -- Couple the Glauber step by picking the SAME uniform site v and drawing (s₁, s₂) ~ m v! let n : ℝ := (Fintype.card V : ℝ) have hn_pos : 0 < n := by dsimp only [n]; exact_mod_cast Fintype.card_pos_iff.mpr hneV let γ : (V → S) → (V → S) → ℝ := fun σ' τ' => n⁻¹ * ∑ v : V, if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then (m v).γ (σ' v) (τ' v) else 0 have hnn : ∀ σ' τ', 0 ≤ γ σ' τ' := fun σ' τ' => mul_nonneg (by positivity) (Finset.sum_nonneg fun v _ => by split_ifs; exact (m v).nonneg _ _; norm_num) have hfst : ∀ σ', ∑ τ' : V → S, γ σ' τ' = (glauberKernel hneV localLaw).P σ σ' := fun σ' => by dsimp only [γ, glauberKernel] rw [← Finset.mul_sum, Finset.sum_comm] congr 1 refine Finset.sum_congr rfl fun v _ => ?_ by_cases h1 : Function.update σ v (σ' v) = σ' · rw [if_pos h1] have hbij : ∑ τ' : V → S, (if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then (m v).γ (σ' v) (τ' v) else 0) = ∑ s₂ : S, (m v).γ (σ' v) s₂ := by simp only [h1, true_and] rw [← Finset.sum_filter] refine Finset.sum_bij (fun τ' _ => τ' v) ?_ ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro a ha b hb heq have ha' := (Finset.mem_filter.mp ha).2 have hb' := (Finset.mem_filter.mp hb).2 rw [← ha', ← hb', heq] · intro s₂ _; refine ⟨Function.update τ v s₂, by simp, by simp⟩ · intro _ _; rfl rw [hbij, (m v).fst_marginal (σ' v)] · rw [if_neg h1] exact Finset.sum_eq_zero fun τ' _ => by simp [h1] have hsnd : ∀ τ', ∑ σ' : V → S, γ σ' τ' = (glauberKernel hneV localLaw).P τ τ' := fun τ' => by dsimp only [γ, glauberKernel] rw [← Finset.mul_sum, Finset.sum_comm] congr 1 refine Finset.sum_congr rfl fun v _ => ?_ by_cases h2 : Function.update τ v (τ' v) = τ' · rw [if_pos h2] have hbij : ∑ σ' : V → S, (if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then (m v).γ (σ' v) (τ' v) else 0) = ∑ s₁ : S, (m v).γ s₁ (τ' v) := by simp only [h2, and_true] rw [← Finset.sum_filter] refine Finset.sum_bij (fun σ' _ => σ' v) ?_ ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro a ha b hb heq have ha' := (Finset.mem_filter.mp ha).2 have hb' := (Finset.mem_filter.mp hb).2 rw [← ha', ← hb', heq] · intro s₁ _; refine ⟨Function.update σ v s₁, by simp, by simp⟩ · intro _ _; rfl rw [hbij, (m v).snd_marginal (τ' v)] · rw [if_neg h2] exact Finset.sum_eq_zero fun σ' _ => by simp [h2] let c : Coupling ((glauberKernel hneV localLaw).row σ) ((glauberKernel hneV localLaw).row τ) := ⟨γ, hnn, hfst, hsnd⟩ refine ⟨c, ?_⟩ rw [hadj, mul_one] -- Evaluate transportCost hammingDist c by exchanging sums to ∑_v ∑_{s₁, s₂} (m v).γ s₁ s₂ * d_H(update σ v s₁, update τ v s₂)! have hcost_eq : transportCost hammingDist c = n⁻¹ * ∑ v : V, ∑ s₁ : S, ∑ s₂ : S, hammingDist (Function.update σ v s₁) (Function.update τ v s₂) * (m v).γ s₁ s₂ := by unfold transportCost change ∑ σ' : V → S, ∑ τ' : V → S, hammingDist σ' τ' * γ σ' τ' = _ dsimp only [γ] calc ∑ σ', ∑ τ', hammingDist σ' τ' * (n⁻¹ * ∑ v, if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then (m v).γ (σ' v) (τ' v) else 0) = n⁻¹ * ∑ σ', ∑ τ', ∑ v, if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then hammingDist σ' τ' * (m v).γ (σ' v) (τ' v) else 0 := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun σ' _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun τ' _ => ?_ rw [← mul_assoc, mul_comm (hammingDist σ' τ') n⁻¹, mul_assoc, Finset.mul_sum] congr 1; refine Finset.sum_congr rfl fun v _ => by split_ifs <;> ring _ = n⁻¹ * ∑ v, ∑ σ', ∑ τ', if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then hammingDist σ' τ' * (m v).γ (σ' v) (τ' v) else 0 := by congr 1 calc ∑ σ', ∑ τ', ∑ v, (if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then hammingDist σ' τ' * (m v).γ (σ' v) (τ' v) else 0) = ∑ σ', ∑ v, ∑ τ', (if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then hammingDist σ' τ' * (m v).γ (σ' v) (τ' v) else 0) := Finset.sum_congr rfl fun σ' _ => Finset.sum_comm _ = ∑ v, ∑ σ', ∑ τ', (if Function.update σ v (σ' v) = σ' ∧ Function.update τ v (τ' v) = τ' then hammingDist σ' τ' * (m v).γ (σ' v) (τ' v) else 0) := Finset.sum_comm _ = n⁻¹ * ∑ v, ∑ s₁, ∑ s₂, hammingDist (Function.update σ v s₁) (Function.update τ v s₂) * (m v).γ s₁ s₂ := by congr 1; refine Finset.sum_congr rfl fun v _ => ?_ rw [← Fintype.sum_prod_type', ← Fintype.sum_prod_type', ← Finset.sum_filter] refine Finset.sum_bij (fun p _ => (p.1 v, p.2 v)) ?_ ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro p₁ hp₁ p₂ hp₂ heq rcases (Finset.mem_filter.mp hp₁).2 with ⟨h11, h12⟩ rcases (Finset.mem_filter.mp hp₂).2 with ⟨h21, h22⟩ have hv1 : p₁.1 v = p₂.1 v := congrArg Prod.fst heq have hv2 : p₁.2 v = p₂.2 v := congrArg Prod.snd heq ext · rw [← h11, ← h21, hv1] · rw [← h12, ← h22, hv2] · intro q _ refine ⟨(Function.update σ v q.1, Function.update τ v q.2), ?_, ?_⟩ · simp · simp · intro p hp rcases (Finset.mem_filter.mp hp).2 with ⟨h1, h2⟩ simp [h1, h2] rw [hcost_eq] -- Evaluate each site v: -- (a) At v = u: localLaw u σ = localLaw u τ, so tvDist = 0, m u has neqProb = 0, AND d_H = 0 when s₁ = s₂! -- (b) At v ≠ u: d_H(update σ v s₁, update τ v s₂) = 1 + (if s₁ ≠ s₂ then 1 else 0), -- so expected Hamming distance = 1 + (m v).neqProb = 1 + tvDist (localLaw v σ) (localLaw v τ)! have hsite_u : ∑ s₁ : S, ∑ s₂ : S, hammingDist (Function.update σ u s₁) (Function.update τ u s₂) * (m u).γ s₁ s₂ = 0 := by have hlaw_eq : localLaw u σ = localLaw u τ := hlocal u σ τ hsame_other have hneq0 : (m u).neqProb = 0 := by rw [hm u, hlaw_eq, tvDist_self] have hzero_off : ∀ s₁ s₂ : S, s₁ ≠ s₂ → (m u).γ s₁ s₂ = 0 := fun s₁ s₂ hne => by have hall := (Finset.sum_eq_zero_iff_of_nonneg (fun a _ => Finset.sum_nonneg fun b _ => by split_ifs; exact (m u).nonneg a b; norm_num)).mp hneq0 have hrow := hall s₁ (Finset.mem_univ s₁) have hall2 := (Finset.sum_eq_zero_iff_of_nonneg (fun b _ => by split_ifs; exact (m u).nonneg s₁ b; norm_num)).mp hrow have hterm := hall2 s₂ (Finset.mem_univ s₂) rwa [if_pos hne] at hterm refine Finset.sum_eq_zero fun s₁ _ => Finset.sum_eq_zero fun s₂ _ => ?_ by_cases h : s₁ = s₂ · subst h have hcfg : Function.update σ u s₁ = Function.update τ u s₁ := by ext w; by_cases hw : w = u · subst hw; simp · simp [hw, hsame_other w hw] rw [hcfg, hammingDist_self, zero_mul] · rw [hzero_off s₁ s₂ h, mul_zero] have hsite_other : ∀ v ∈ Finset.univ.erase u, ∑ s₁ : S, ∑ s₂ : S, hammingDist (Function.update σ v s₁) (Function.update τ v s₂) * (m v).γ s₁ s₂ = 1 + tvDist (localLaw v σ) (localLaw v τ) := fun v hv => by have hvu : v ≠ u := (Finset.mem_erase.mp hv).1 have hdH : ∀ s₁ s₂ : S, hammingDist (Function.update σ v s₁) (Function.update τ v s₂) = 1 + (if s₁ ≠ s₂ then (1 : ℝ) else 0) := fun s₁ s₂ => by unfold hammingDist by_cases hs : s₁ = s₂ · subst hs have hfilt : (Finset.univ.filter fun w : V => Function.update σ v s₁ w ≠ Function.update τ v s₁ w) = {u} := by ext w; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] by_cases hwv : w = v · subst hwv; simp [hvu] · by_cases hwu : w = u · subst hwu; simp [hwv, hu_ne] · simp [hwv, hwu, hsame_other w hwu] rw [hfilt, Finset.card_singleton]; simp · have hfilt : (Finset.univ.filter fun w : V => Function.update σ v s₁ w ≠ Function.update τ v s₂ w) = {u, v} := by ext w; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton] by_cases hwv : w = v · subst hwv; simp [hs] · by_cases hwu : w = u · subst hwu; simp [hwv, hu_ne] · simp [hwv, hwu, hsame_other w hwu] rw [hfilt, Finset.card_pair (Ne.symm hvu), if_pos hs]; norm_num simp_rw [hdH, add_mul, one_mul, Finset.sum_add_distrib] have htot1 : ∑ s₁ : S, ∑ s₂ : S, (m v).γ s₁ s₂ = 1 := by simp_rw [(m v).fst_marginal, (localLaw v σ).sum_one] have hneq_eq : ∑ s₁ : S, ∑ s₂ : S, (if s₁ ≠ s₂ then (1 : ℝ) else 0) * (m v).γ s₁ s₂ = (m v).neqProb := by unfold Coupling.neqProb refine Finset.sum_congr rfl fun s₁ _ => Finset.sum_congr rfl fun s₂ _ => by split_ifs <;> ring rw [htot1, hneq_eq, hm v] -- Split ∑_{v : V} into u + (univ.erase u)! rw [← Finset.add_sum_erase _ _ (Finset.mem_univ u), hsite_u, zero_add] rw [Finset.sum_congr rfl hsite_other, Finset.sum_add_distrib] have hcard_er : (Finset.univ.erase u).card = Fintype.card V - 1 := by rw [Finset.card_erase_of_mem (Finset.mem_univ u), Finset.card_univ] have h1 : ∑ _v ∈ Finset.univ.erase u, (1 : ℝ) = n - 1 := by rw [Finset.sum_const, hcard_er, nsmul_eq_mul, mul_one] have h1n : 1 ≤ Fintype.card V := Fintype.card_pos_iff.mpr hneV rw [Nat.cast_sub h1n]; simp [n] have h2 := hdob u σ τ hsame_other calc n⁻¹ * ((∑ _v ∈ Finset.univ.erase u, (1 : ℝ)) + ∑ v ∈ Finset.univ.erase u, tvDist (localLaw v σ) (localLaw v τ)) ≤ n⁻¹ * ((n - 1) + αDob) := by rw [h1]; exact mul_le_mul_of_nonneg_left (by linarith) (by positivity) _ = 1 - (1 - αDob) / n := by field_simp [ne_of_gt hn_pos]; ring /-- **Dobrushin Uniqueness Rapid Mixing Theorem for Glauber Dynamics**: whenever the Dobrushin influence constant satisfies `α_Dob < 1`, single-site Glauber dynamics mixes geometrically in `O(|V| log |V|)` steps: `d(t) ≤ |V| · (1 - (1 - α_Dob) / |V|)^t ≤ |V| · exp(-(1 - α_Dob) t / |V|)`. -/ theorem dobrushin_glauber_rapid_mixing (hneV : Nonempty V) (hneS : Nonempty S) (localLaw : V → (V → S) → Dist S) {π : Dist (V → S)} (hstat : (glauberKernel hneV localLaw).IsStationary π) (hlocal : ∀ (v : V) (σ τ : V → S), (∀ w, w ≠ v → σ w = τ w) → localLaw v σ = localLaw v τ) {αDob : ℝ} (hα_nn : 0 ≤ αDob) (hdob : ∀ (u : V) (σ τ : V → S), (∀ w, w ≠ u → σ w = τ w) → ∑ v ∈ Finset.univ.erase u, tvDist (localLaw v σ) (localLaw v τ) ≤ αDob) (t : ℕ) : let hneΩ : Nonempty (V → S) := ⟨fun _ => Classical.choice hneS⟩ dTVMax (glauberKernel hneV localLaw) π hneΩ t ≤ (Fintype.card V : ℝ) * (1 - (1 - αDob) / (Fintype.card V : ℝ)) ^ t ∧ (Fintype.card V : ℝ) * (1 - (1 - αDob) / (Fintype.card V : ℝ)) ^ t ≤ (Fintype.card V : ℝ) * Real.exp (-((1 - αDob) / (Fintype.card V : ℝ)) * t) := by intro hneΩ have hn_pos : (0 : ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos_iff.mpr hneV have h1n : (1 : ℝ) ≤ Fintype.card V := by exact_mod_cast Fintype.card_pos_iff.mpr hneV have hα_le1 : (1 - αDob) / (Fintype.card V : ℝ) ≤ 1 := by rw [div_le_one hn_pos]; linarith exact bubley_dyer_mixing_time hstat hneΩ (hammingMetric V S) (fun σ τ => hammingDist σ τ = 1) hammingDist_le_card (Nat.cast_nonneg _) hα_le1 hamming_geodesic (fun σ τ hadj => dobrushin_glauber_one_step_contraction hneV localLaw hlocal hdob hadj) t /-- **Exact Ising Heat-Bath Influence Lemma**: for every local field `h ∈ ℝ` and inverse temperature `β ≥ 0`: `1 / (1 + exp(-2(h + β))) - 1 / (1 + exp(-2(h - β))) ≤ tanh(β)` (strictly sharp at `h = 0`, where equality holds!). -/ theorem ising_heatbath_influence_le_tanh (h : ℝ) {β : ℝ} (hβ : 0 ≤ β) : (1 + Real.exp (-2 * (h + β)))⁻¹ - (1 + Real.exp (-2 * (h - β)))⁻¹ ≤ Real.tanh β := by -- Express both sides cleanly in terms of e = exp(2h) > 0 and b = exp(2β) ≥ 1! set e := Real.exp (2 * h) set b := Real.exp (2 * β) have he_pos : 0 < e := Real.exp_pos _ have hb_ge1 : 1 ≤ b := Real.one_le_exp (by linarith) have hb_pos : 0 < b := by linarith have h1 : Real.exp (-2 * (h + β)) = (e * b)⁻¹ := by dsimp only [e, b] rw [← Real.exp_add, ← Real.exp_neg]; congr 1; ring have h2 : Real.exp (-2 * (h - β)) = b / e := by dsimp only [e, b] rw [div_eq_mul_inv, ← Real.exp_neg, ← Real.exp_add]; congr 1; ring have htanh : Real.tanh β = (b - 1) / (b + 1) := by rw [Real.tanh_eq_sinh_div_cosh, Real.sinh_eq, Real.cosh_eq] have hbm : Real.exp (-β) = (Real.exp β)⁻¹ := Real.exp_neg β have hb2 : b = Real.exp β * Real.exp β := by dsimp only [b]; rw [← Real.exp_add]; congr 1; ring have hexp_pos := Real.exp_pos β rw [hbm, hb2] field_simp [ne_of_gt hexp_pos] rw [h1, h2, htanh] -- Algebra: (1 + (eb)⁻¹)⁻¹ - (1 + b/e)⁻¹ = e(b² - 1) / ((eb + 1)(e + b)) ≤ (b - 1)/(b + 1) -- iff e(b + 1)² ≤ (eb + 1)(e + b) = e² b + e b² + e + b iff 0 ≤ b(e - 1)²!! have hden1 : 0 < 1 + (e * b)⁻¹ := by positivity have hden2 : 0 < 1 + b / e := by positivity have hden3 : 0 < b + 1 := by linarith have hlhs_eq : (1 + (e * b)⁻¹)⁻¹ - (1 + b / e)⁻¹ = e * (b ^ 2 - 1) / ((e * b + 1) * (e + b)) := by field_simp [ne_of_gt he_pos, ne_of_gt hb_pos] ring rw [hlhs_eq, div_le_div_iff₀ (mul_pos (by positivity) (by positivity)) hden3] have hdiff : (b - 1) * ((e * b + 1) * (e + b)) - e * (b ^ 2 - 1) * (b + 1) = (b - 1) * b * (e - 1) ^ 2 := by ring have hnn : 0 ≤ (b - 1) * b * (e - 1) ^ 2 := mul_nonneg (mul_nonneg (by linarith) (le_of_lt hb_pos)) (sq_nonneg _) linarith lemma tanh_nonneg_of_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ Real.tanh x := by rw [Real.tanh_eq_sinh_div_cosh, Real.sinh_eq] apply div_nonneg _ (le_of_lt (Real.cosh_pos x)) have : Real.exp (-x) ≤ Real.exp x := Real.exp_le_exp.mpr (by linarith) linarith /-- **High-Temperature Ising Model Glauber Dynamics Rapid Mixing**: on any finite graph `(V, adj)` of max degree `≤ Δ` at inverse temperature `β ≥ 0` in the Dobrushin uniqueness regime `Δ · tanh(β) < 1`, heat-bath Ising Glauber dynamics mixes in `O(n log n)` steps with explicit rate `1 - Δ tanh(β)`. -/ theorem ising_glauber_rapid_mixing (hneV : Nonempty V) (adj : V → V → Prop) [DecidableRel adj] (hloopless : ∀ v, ¬ adj v v) (Δ : ℕ) (hdeg : ∀ u : V, (Finset.univ.filter fun v => adj u v).card ≤ Δ) {β : ℝ} (hβ : 0 ≤ β) (hfield : V → ℝ) {π : Dist (V → Bool)} (isingLaw : V → (V → Bool) → Dist Bool) (hising_def : ∀ (v : V) (σ : V → Bool), isingLaw v σ true = (1 + Real.exp (-2 * (hfield v + β * ∑ w ∈ Finset.univ.filter (fun w => adj v w), if σ w then (1 : ℝ) else -1)))⁻¹) (hsym_adj : ∀ u v, adj u v ↔ adj v u) (hstat : (glauberKernel hneV isingLaw).IsStationary π) (t : ℕ) : let hneΩ : Nonempty (V → Bool) := ⟨fun _ => false⟩ dTVMax (glauberKernel hneV isingLaw) π hneΩ t ≤ (Fintype.card V : ℝ) * (1 - (1 - (Δ : ℝ) * Real.tanh β) / (Fintype.card V : ℝ)) ^ t := by intro hneΩ have htanh_nn : 0 ≤ Real.tanh β := tanh_nonneg_of_nonneg hβ have hlocal : ∀ (v : V) (σ τ : V → Bool), (∀ w, w ≠ v → σ w = τ w) → isingLaw v σ = isingLaw v τ := fun v σ τ hsame => by have hsum_eq : (∑ w ∈ Finset.univ.filter (fun w => adj v w), if σ w then (1 : ℝ) else -1) = ∑ w ∈ Finset.univ.filter (fun w => adj v w), if τ w then (1 : ℝ) else -1 := Finset.sum_congr rfl fun w hw => by have hne : w ≠ v := fun h => hloopless v (h ▸ (Finset.mem_filter.mp hw).2) rw [hsame w hne] have htrue : isingLaw v σ true = isingLaw v τ true := by rw [hising_def v σ, hising_def v τ, hsum_eq] ext b cases b · have h1 := (isingLaw v σ).sum_one have h2 := (isingLaw v τ).sum_one simp only [Fintype.sum_bool] at h1 h2 linarith · exact htrue have hdob : ∀ (u : V) (σ τ : V → Bool), (∀ w, w ≠ u → σ w = τ w) → ∑ v ∈ Finset.univ.erase u, tvDist (isingLaw v σ) (isingLaw v τ) ≤ (Δ : ℝ) * Real.tanh β := by intro u σ τ hsame have hpt : ∀ v ∈ Finset.univ.erase u, tvDist (isingLaw v σ) (isingLaw v τ) ≤ if adj u v then Real.tanh β else 0 := fun v _ => by have htv_bool : tvDist (isingLaw v σ) (isingLaw v τ) = |isingLaw v σ true - isingLaw v τ true| := by unfold tvDist simp only [Fintype.sum_bool] have h1 := (isingLaw v σ).sum_one have h2 := (isingLaw v τ).sum_one simp only [Fintype.sum_bool] at h1 h2 have hf : isingLaw v σ false - isingLaw v τ false = -(isingLaw v σ true - isingLaw v τ true) := by linarith rw [hf, abs_neg]; ring rw [htv_bool] by_cases hadj : adj u v · rw [if_pos hadj] have hadj' : adj v u := (hsym_adj u v).mp hadj let Nv := Finset.univ.filter (fun w => adj v w) have hu_mem : u ∈ Nv := Finset.mem_filter.mpr ⟨Finset.mem_univ u, hadj'⟩ let rest := hfield v + β * ∑ w ∈ Nv.erase u, if σ w then (1 : ℝ) else -1 have hrest_eq : ∑ w ∈ Nv.erase u, (if σ w then (1 : ℝ) else -1) = ∑ w ∈ Nv.erase u, (if τ w then (1 : ℝ) else -1) := Finset.sum_congr rfl fun w hw => by rw [hsame w (Finset.mem_erase.mp hw).1] have hsum_σ : hfield v + β * ∑ w ∈ Nv, (if σ w then (1 : ℝ) else -1) = rest + β * (if σ u then (1 : ℝ) else -1) := by dsimp only [rest]; rw [← Finset.add_sum_erase _ _ hu_mem]; ring have hsum_τ : hfield v + β * ∑ w ∈ Nv, (if τ w then (1 : ℝ) else -1) = rest + β * (if τ u then (1 : ℝ) else -1) := by dsimp only [rest]; rw [← Finset.add_sum_erase _ _ hu_mem, hrest_eq]; ring rw [hising_def v σ, hising_def v τ] change |(1 + Real.exp (-2 * (hfield v + β * ∑ w ∈ Nv, if σ w then (1 : ℝ) else -1)))⁻¹ - (1 + Real.exp (-2 * (hfield v + β * ∑ w ∈ Nv, if τ w then (1 : ℝ) else -1)))⁻¹| ≤ Real.tanh β rw [hsum_σ, hsum_τ] have hge : (1 + Real.exp (-2 * (rest - β)))⁻¹ ≤ (1 + Real.exp (-2 * (rest + β)))⁻¹ := by apply inv_anti₀ (by positivity) have : Real.exp (-2 * (rest + β)) ≤ Real.exp (-2 * (rest - β)) := Real.exp_le_exp.mpr (by linarith) linarith cases hσu : σ u <;> cases hτu : τ u · simp [htanh_nn] · have hrew1 : rest + β * (if false = true then (1 : ℝ) else -1) = rest - β := by simp; ring have hrew2 : rest + β * (if true = true then (1 : ℝ) else -1) = rest + β := by simp rw [hrew1, hrew2, abs_sub_comm, abs_of_nonneg (by linarith)] exact ising_heatbath_influence_le_tanh rest hβ · have hrew1 : rest + β * (if true = true then (1 : ℝ) else -1) = rest + β := by simp have hrew2 : rest + β * (if false = true then (1 : ℝ) else -1) = rest - β := by simp; ring rw [hrew1, hrew2, abs_of_nonneg (by linarith)] exact ising_heatbath_influence_le_tanh rest hβ · simp [htanh_nn] · rw [if_neg hadj] have hsum_eq : (∑ w ∈ Finset.univ.filter (fun w => adj v w), if σ w then (1 : ℝ) else -1) = ∑ w ∈ Finset.univ.filter (fun w => adj v w), if τ w then (1 : ℝ) else -1 := Finset.sum_congr rfl fun w hw => by have hwu : w ≠ u := fun h => hadj ((hsym_adj u v).mpr (h ▸ (Finset.mem_filter.mp hw).2)) rw [hsame w hwu] have hlaw_eq : isingLaw v σ true = isingLaw v τ true := by rw [hising_def v σ, hising_def v τ, hsum_eq] rw [hlaw_eq, sub_self, abs_zero] calc ∑ v ∈ Finset.univ.erase u, tvDist (isingLaw v σ) (isingLaw v τ) ≤ ∑ v ∈ Finset.univ.erase u, (if adj u v then Real.tanh β else 0) := Finset.sum_le_sum hpt _ ≤ ∑ v : V, (if adj u v then Real.tanh β else 0) := Finset.sum_le_univ_sum_of_nonneg fun v => by split_ifs; exact htanh_nn; norm_num _ = ((Finset.univ.filter fun v => adj u v).card : ℝ) * Real.tanh β := by rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] _ ≤ (Δ : ℝ) * Real.tanh β := mul_le_mul_of_nonneg_right (by exact_mod_cast hdeg u) htanh_nn exact (dobrushin_glauber_rapid_mixing hneV ⟨false⟩ isingLaw hstat hlocal (mul_nonneg (Nat.cast_nonneg _) htanh_nn) hdob t).1 /-- **Uniform-Subset Total Variation Lemma** (for Jerrum's coloring coupling): for any two nonempty finite subsets `A, B ⊆ Fin q` differing by at most 1 element on each side (`(A \ B).card ≤ 1` and `(B \ A).card ≤ 1`) with `m ≤ A.card` and `m ≤ B.card` (`0 < m`): `d_TV(Unif(A), Unif(B)) ≤ 1 / m`. -/ theorem tvDist_uniform_finset_le {q : ℕ} {A B : Finset (Fin q)} {m : ℕ} (hm : 0 < m) (hA : m ≤ A.card) (hB : m ≤ B.card) (hAB : (A \ B).card ≤ 1) (hBA : (B \ A).card ≤ 1) : let μA : Dist (Fin q) := { p := fun c => if c ∈ A then (A.card : ℝ)⁻¹ else 0 nonneg := fun c => by split_ifs <;> positivity sum_one := by rw [← Finset.sum_filter] have hf : Finset.univ.filter (fun c => c ∈ A) = A := by ext c; simp rw [hf, Finset.sum_const, nsmul_eq_mul] exact mul_inv_cancel₀ (by exact_mod_cast (show A.card ≠ 0 by omega)) } let μB : Dist (Fin q) := { p := fun c => if c ∈ B then (B.card : ℝ)⁻¹ else 0 nonneg := fun c => by split_ifs <;> positivity sum_one := by rw [← Finset.sum_filter] have hf : Finset.univ.filter (fun c => c ∈ B) = B := by ext c; simp rw [hf, Finset.sum_const, nsmul_eq_mul] exact mul_inv_cancel₀ (by exact_mod_cast (show B.card ≠ 0 by omega)) } tvDist μA μB ≤ 1 / (m : ℝ) := by intro μA μB -- By symmetry WLOG A.card ≤ B.card (or handle both directly via tvDist_eq_sum_pos)! -- Notice: for c ∈ A ∩ B: μA c - μB c = 1/|A| - 1/|B|; -- for c ∈ A \ B: μA c - μB c = 1/|A|; -- for c ∉ A: μA c - μB c ≤ 0! rw [tvDist_eq_sum_pos] have hA_pos : (0 : ℝ) < A.card := by exact_mod_cast (show 0 < A.card by omega) have hB_pos : (0 : ℝ) < B.card := by exact_mod_cast (show 0 < B.card by omega) have hm_pos : (0 : ℝ) < m := by exact_mod_cast hm have hsplit : ∑ c : Fin q, max (μA c - μB c) 0 = (∑ c ∈ A ∩ B, max ((A.card : ℝ)⁻¹ - (B.card : ℝ)⁻¹) 0) + (∑ c ∈ A \ B, (A.card : ℝ)⁻¹) := by have hA_supp : ∑ c : Fin q, max (μA c - μB c) 0 = ∑ c ∈ A, max (μA c - μB c) 0 := by rw [← Finset.sum_add_sum_compl A] have h0 : ∑ c ∈ Aᶜ, max (μA c - μB c) 0 = 0 := Finset.sum_eq_zero fun c hc => by have hcA : c ∉ A := Finset.mem_compl.mp hc have hμA0 : μA c = 0 := by simp [μA, hcA] rw [hμA0, zero_sub, max_eq_right (neg_nonpos.mpr (μB.nonneg c))] rw [h0, add_zero] have hA_part : A = (A ∩ B) ∪ (A \ B) := by ext c; simp only [Finset.mem_union, Finset.mem_inter, Finset.mem_sdiff]; tauto have hdisj_AB : Disjoint (A ∩ B) (A \ B) := Finset.disjoint_left.mpr fun c h1 h2 => (Finset.mem_sdiff.mp h2).2 (Finset.mem_inter.mp h1).2 calc ∑ c : Fin q, max (μA c - μB c) 0 = ∑ c ∈ A, max (μA c - μB c) 0 := hA_supp _ = ∑ c ∈ (A ∩ B) ∪ (A \ B), max (μA c - μB c) 0 := by rw [← hA_part] _ = (∑ c ∈ A ∩ B, max (μA c - μB c) 0) + (∑ c ∈ A \ B, max (μA c - μB c) 0) := Finset.sum_union hdisj_AB _ = (∑ c ∈ A ∩ B, max ((A.card : ℝ)⁻¹ - (B.card : ℝ)⁻¹) 0) + (∑ c ∈ A \ B, (A.card : ℝ)⁻¹) := by congr 1 · refine Finset.sum_congr rfl fun c hc => ?_ rcases Finset.mem_inter.mp hc with ⟨hcA, hcB⟩ simp [μA, μB, hcA, hcB] · refine Finset.sum_congr rfl fun c hc => ?_ rcases Finset.mem_sdiff.mp hc with ⟨hcA, hcB⟩ simp [μA, μB, hcA, hcB] rw [hsplit, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul] -- Case 1: B.card ≤ A.card => (A.card)⁻¹ - (B.card)⁻¹ ≤ 0, so sum ≤ |A\B| / |A| ≤ 1 / |A| ≤ 1/m! -- Case 2: A.card < B.card => |B| - |A| = |B \ A| - |A \ B| ≤ 1 - |A \ B|, so -- |A ∩ B| (1/|A| - 1/|B|) + |A \ B| / |A| = (|A| - |A\B|)(|B| - |A|)/(|A||B|) + |A\B|/|A| -- = 1 - |A ∩ B| / |B| = |B \ A| / |B| ≤ 1 / |B| ≤ 1 / m!! have hcard_union : (A ∩ B).card + (A \ B).card = A.card := Finset.card_inter_add_card_sdiff A B have hcard_unionB : (A ∩ B).card + (B \ A).card = B.card := by rw [Finset.inter_comm]; exact Finset.card_inter_add_card_sdiff B A rcases le_or_gt B.card A.card with hBA_le | hAB_lt · have hinv : (A.card : ℝ)⁻¹ - (B.card : ℝ)⁻¹ ≤ 0 := by have h1 : (A.card : ℝ)⁻¹ ≤ (B.card : ℝ)⁻¹ := inv_anti₀ hB_pos (by exact_mod_cast hBA_le) linarith rw [max_eq_right hinv, mul_zero, zero_add] have h1 : ((A \ B).card : ℝ) ≤ 1 := by exact_mod_cast hAB have h2 : (A.card : ℝ)⁻¹ ≤ 1 / (m : ℝ) := by rw [one_div]; exact inv_anti₀ hm_pos (by exact_mod_cast hA) calc ((A \ B).card : ℝ) * (A.card : ℝ)⁻¹ ≤ 1 * (A.card : ℝ)⁻¹ := mul_le_mul_of_nonneg_right h1 (by positivity) _ = (A.card : ℝ)⁻¹ := one_mul _ _ ≤ 1 / (m : ℝ) := h2 · have hinv : 0 ≤ (A.card : ℝ)⁻¹ - (B.card : ℝ)⁻¹ := by have h1 : (B.card : ℝ)⁻¹ ≤ (A.card : ℝ)⁻¹ := inv_anti₀ hA_pos (by exact_mod_cast (le_of_lt hAB_lt)) linarith rw [max_eq_left hinv] -- Exact identity: |A ∩ B| (1/|A| - 1/|B|) + |A \ B| / |A| = |B \ A| / |B|! have hcastA : ((A ∩ B).card : ℝ) + ((A \ B).card : ℝ) = (A.card : ℝ) := by exact_mod_cast hcard_union have hcastB : ((A ∩ B).card : ℝ) + ((B \ A).card : ℝ) = (B.card : ℝ) := by exact_mod_cast hcard_unionB have hid : ((A ∩ B).card : ℝ) * ((A.card : ℝ)⁻¹ - (B.card : ℝ)⁻¹) + ((A \ B).card : ℝ) * (A.card : ℝ)⁻¹ = ((B \ A).card : ℝ) * (B.card : ℝ)⁻¹ := by field_simp [ne_of_gt hA_pos, ne_of_gt hB_pos] nlinarith rw [hid] have h1 : ((B \ A).card : ℝ) ≤ 1 := by exact_mod_cast hBA have h2 : (B.card : ℝ)⁻¹ ≤ 1 / (m : ℝ) := by rw [one_div]; exact inv_anti₀ hm_pos (by exact_mod_cast hB) calc ((B \ A).card : ℝ) * (B.card : ℝ)⁻¹ ≤ 1 * (B.card : ℝ)⁻¹ := mul_le_mul_of_nonneg_right h1 (by positivity) _ = (B.card : ℝ)⁻¹ := one_mul _ _ ≤ 1 / (m : ℝ) := h2 /-- **Jerrum's `q > 2 Δ` Proper Coloring Glauber Mixing Theorem (1995)**: on any graph of max degree `≤ Δ` with `q > 2 Δ` colors, if each site `v` resamples uniformly from the available colors `avail v σ = {c | ∀ w ~ v, σ w ≠ c}` (of size `≥ q - Δ`), then: - Dobrushin influence satisfies `α_Dob ≤ Δ / (q - Δ) < 1`, - Contraction rate is `(q - 2 Δ) / (n · (q - Δ))` (strictly tighter than `(q - 2 Δ) / (n q)`!), - Glauber dynamics mixes geometrically in `O(n log n)` steps: `d(t) ≤ n · (1 - (q - 2 Δ) / (n (q - Δ)))^t ≤ n · exp(-(q - 2 Δ) t / (n (q - Δ)))`. -/ theorem jerrum_q_coloring_rapid_mixing (hneV : Nonempty V) (adj : V → V → Prop) [DecidableRel adj] (hloopless : ∀ v, ¬ adj v v) (hsym_adj : ∀ u v, adj u v ↔ adj v u) (Δ q : ℕ) (hdeg : ∀ u : V, (Finset.univ.filter fun v => adj u v).card ≤ Δ) (hq : 2 * Δ < q) (avail : V → (V → Fin q) → Finset (Fin q)) (havail_def : ∀ (v : V) (σ : V → Fin q) (c : Fin q), c ∈ avail v σ ↔ ∀ w : V, adj v w → σ w ≠ c) (colorLaw : V → (V → Fin q) → Dist (Fin q)) (hcolor_def : ∀ (v : V) (σ : V → Fin q) (c : Fin q), colorLaw v σ c = if c ∈ avail v σ then ((avail v σ).card : ℝ)⁻¹ else 0) {π : Dist (V → Fin q)} (hstat : (glauberKernel hneV colorLaw).IsStationary π) (t : ℕ) : let hneΩ : Nonempty (V → Fin q) := ⟨fun _ => ⟨0, by omega⟩⟩ dTVMax (glauberKernel hneV colorLaw) π hneΩ t ≤ (Fintype.card V : ℝ) * (1 - ((q : ℝ) - 2 * (Δ : ℝ)) / ((Fintype.card V : ℝ) * ((q : ℝ) - (Δ : ℝ)))) ^ t ∧ (Fintype.card V : ℝ) * (1 - ((q : ℝ) - 2 * (Δ : ℝ)) / ((Fintype.card V : ℝ) * ((q : ℝ) - (Δ : ℝ)))) ^ t ≤ (Fintype.card V : ℝ) * Real.exp (-(((q : ℝ) - 2 * (Δ : ℝ)) / ((Fintype.card V : ℝ) * ((q : ℝ) - (Δ : ℝ)))) * t) := by intro hneΩ have hqΔ_pos : 0 < q - Δ := by omega have hqΔ_real : (0 : ℝ) < (q : ℝ) - (Δ : ℝ) := by have : (Δ : ℝ) < (q : ℝ) := by exact_mod_cast (show Δ < q by omega) linarith have havail_card : ∀ (v : V) (σ : V → Fin q), q - Δ ≤ (avail v σ).card := fun v σ => by -- The forbidden colors are the image of N(v) under σ, of size ≤ |N(v)| ≤ Δ! let Nv := Finset.univ.filter (fun w : V => adj v w) have hcompl_sub : (avail v σ)ᶜ ⊆ Nv.image σ := by intro c hc rw [Finset.mem_compl, havail_def] at hc push Not at hc obtain ⟨w, hvw, hwc⟩ := hc exact Finset.mem_image.mpr ⟨w, Finset.mem_filter.mpr ⟨Finset.mem_univ w, hvw⟩, hwc⟩ have hcard_forb : (avail v σ)ᶜ.card ≤ Δ := le_trans (Finset.card_le_card hcompl_sub) (le_trans Finset.card_image_le (hdeg v)) have htot : (avail v σ).card + (avail v σ)ᶜ.card = q := by rw [Finset.card_add_card_compl, Fintype.card_fin] omega have hlocal : ∀ (v : V) (σ τ : V → Fin q), (∀ w, w ≠ v → σ w = τ w) → colorLaw v σ = colorLaw v τ := fun v σ τ hsame => by have haeq : avail v σ = avail v τ := by ext c; rw [havail_def, havail_def] refine forall_congr' fun w => imp_congr_right fun hvw => ?_ have hne : w ≠ v := fun h => hloopless v (h ▸ hvw) rw [hsame w hne] ext c; rw [hcolor_def, hcolor_def, haeq] have hdob : ∀ (u : V) (σ τ : V → Fin q), (∀ w, w ≠ u → σ w = τ w) → ∑ v ∈ Finset.univ.erase u, tvDist (colorLaw v σ) (colorLaw v τ) ≤ (Δ : ℝ) / ((q : ℝ) - (Δ : ℝ)) := by intro u σ τ hsame have hpt : ∀ v ∈ Finset.univ.erase u, tvDist (colorLaw v σ) (colorLaw v τ) ≤ if adj u v then 1 / ((q : ℝ) - (Δ : ℝ)) else 0 := by intro v _ by_cases hadj : adj u v · rw [if_pos hadj] -- avail v σ \ avail v τ ⊆ {τ u} (card ≤ 1) and avail v τ \ avail v σ ⊆ {σ u} (card ≤ 1)! have hdiff1 : (avail v σ \ avail v τ).card ≤ 1 := by have hsub : avail v σ \ avail v τ ⊆ {τ u} := by intro c hc rcases Finset.mem_sdiff.mp hc with ⟨hcσ, hcτ⟩ rw [havail_def] at hcσ hcτ push Not at hcτ obtain ⟨w, hvw, hwc⟩ := hcτ by_cases hwu : w = u · subst hwu; exact Finset.mem_singleton.mpr hwc.symm · exact absurd (by rw [hsame w hwu]; exact hwc) (hcσ w hvw) exact le_trans (Finset.card_le_card hsub) (by simp) have hdiff2 : (avail v τ \ avail v σ).card ≤ 1 := by have hsub : avail v τ \ avail v σ ⊆ {σ u} := by intro c hc rcases Finset.mem_sdiff.mp hc with ⟨hcτ, hcσ⟩ rw [havail_def] at hcσ hcτ push Not at hcσ obtain ⟨w, hvw, hwc⟩ := hcσ by_cases hwu : w = u · subst hwu; exact Finset.mem_singleton.mpr hwc.symm · exact absurd (by rw [← hsame w hwu]; exact hwc) (hcτ w hvw) exact le_trans (Finset.card_le_card hsub) (by simp) have htv := tvDist_uniform_finset_le hqΔ_pos (havail_card v σ) (havail_card v τ) hdiff1 hdiff2 have heqA : colorLaw v σ = { p := fun c => if c ∈ avail v σ then ((avail v σ).card : ℝ)⁻¹ else 0 nonneg := fun c => by split_ifs <;> positivity sum_one := by rw [← Finset.sum_filter] have hf : Finset.univ.filter (fun c => c ∈ avail v σ) = avail v σ := by ext c; simp rw [hf, Finset.sum_const, nsmul_eq_mul] exact mul_inv_cancel₀ (by exact_mod_cast (show (avail v σ).card ≠ 0 by have := havail_card v σ; omega)) } := by ext c; exact hcolor_def v σ c have heqB : colorLaw v τ = { p := fun c => if c ∈ avail v τ then ((avail v τ).card : ℝ)⁻¹ else 0 nonneg := fun c => by split_ifs <;> positivity sum_one := by rw [← Finset.sum_filter] have hf : Finset.univ.filter (fun c => c ∈ avail v τ) = avail v τ := by ext c; simp rw [hf, Finset.sum_const, nsmul_eq_mul] exact mul_inv_cancel₀ (by exact_mod_cast (show (avail v τ).card ≠ 0 by have := havail_card v τ; omega)) } := by ext c; exact hcolor_def v τ c rw [heqA, heqB] have hcast : ((q - Δ : ℕ) : ℝ) = (q : ℝ) - (Δ : ℝ) := Nat.cast_sub (by omega) rwa [hcast] at htv · rw [if_neg hadj] have haeq : avail v σ = avail v τ := by ext c; rw [havail_def, havail_def] refine forall_congr' fun w => imp_congr_right fun hvw => ?_ have hwu : w ≠ u := fun h => hadj ((hsym_adj u v).mpr (h ▸ hvw)) rw [hsame w hwu] have hlaw_eq : colorLaw v σ = colorLaw v τ := by ext c; rw [hcolor_def, hcolor_def, haeq] rw [hlaw_eq, tvDist_self] calc ∑ v ∈ Finset.univ.erase u, tvDist (colorLaw v σ) (colorLaw v τ) ≤ ∑ v ∈ Finset.univ.erase u, (if adj u v then 1 / ((q : ℝ) - (Δ : ℝ)) else 0) := Finset.sum_le_sum hpt _ ≤ ∑ v : V, (if adj u v then 1 / ((q : ℝ) - (Δ : ℝ)) else 0) := Finset.sum_le_univ_sum_of_nonneg fun v => by split_ifs <;> positivity _ = ((Finset.univ.filter fun v => adj u v).card : ℝ) * (1 / ((q : ℝ) - (Δ : ℝ))) := by rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] _ ≤ (Δ : ℝ) * (1 / ((q : ℝ) - (Δ : ℝ))) := mul_le_mul_of_nonneg_right (by exact_mod_cast hdeg u) (by positivity) _ = (Δ : ℝ) / ((q : ℝ) - (Δ : ℝ)) := by ring have hmix := dobrushin_glauber_rapid_mixing hneV ⟨⟨0, by omega⟩⟩ colorLaw hstat hlocal (by positivity : 0 ≤ (Δ : ℝ) / ((q : ℝ) - (Δ : ℝ))) hdob t have hrate : (1 - (Δ : ℝ) / ((q : ℝ) - (Δ : ℝ))) / (Fintype.card V : ℝ) = ((q : ℝ) - 2 * (Δ : ℝ)) / ((Fintype.card V : ℝ) * ((q : ℝ) - (Δ : ℝ))) := by have hn_ne : (Fintype.card V : ℝ) ≠ 0 := ne_of_gt (by exact_mod_cast Fintype.card_pos_iff.mpr hneV) field_simp [hn_ne, ne_of_gt hqΔ_real]; ring rw [hrate] at hmix exact hmix end GlauberDynamics end Pillar4_PathCouplingGlauber /-! ============================================================================ PILLAR 5: SHARP CUTOFF PHASE TRANSITIONS & EXACT WITNESSES (`Q_n`, `S_n`, `C_{2m}`) ============================================================================ -/ section Pillar5_CutoffPhaseTransitions /-! ### Landmark 1: Exact Walsh–Fourier / Krawtchouk Diagonalization & Cutoff on Hypercube `Q_n` -/ /-- Flip coordinate `i` of a Boolean hypercube vertex `x : Fin n → Bool`. -/ def flipBit {n : ℕ} (x : Fin n → Bool) (i : Fin n) : Fin n → Bool := Function.update x i (!x i) lemma flipBit_invol {n : ℕ} (x : Fin n → Bool) (i : Fin n) : flipBit (flipBit x i) i = x := by ext j by_cases h : j = i · subst h; simp [flipBit] · simp [flipBit, h] lemma flipBit_ne {n : ℕ} (x : Fin n → Bool) (i : Fin n) : flipBit x i ≠ x := by intro h have hi := congrFun h i simp [flipBit] at hi lemma flipBit_inj_coord {n : ℕ} (x : Fin n → Bool) {i j : Fin n} (h : flipBit x i = flipBit x j) : i = j := by by_contra hne have hi := congrFun h i simp [flipBit, hne] at hi /-- **General `p`-Lazy Random Walk on the `n`-Hypercube `Q_n = (Fin n → Bool)`**: hold at `x` with probability `1 - p`, or flip a uniformly random coordinate `i ∈ Fin n` with probability `p / n`. - `p = n / (n + 1)` is the **Diaconis–Graham–Morrison (1990)** walk (cutoff at `(1/4) n ln n`), - `p = 1 / 2` is the standard **`1/2`-lazy walk** (cutoff at `(1/2) n ln n`). -/ def hypercubeKernel (n : ℕ) (hn : 1 ≤ n) (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : MarkovKernel (Fin n → Bool) where P x y := (if y = x then 1 - p else 0) + (p / (n : ℝ)) * ∑ i : Fin n, if y = flipBit x i then (1 : ℝ) else 0 nonneg x y := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have h1 : (0 : ℝ) ≤ if y = x then 1 - p else 0 := by split_ifs <;> linarith have h2 : (0 : ℝ) ≤ (p / (n : ℝ)) * ∑ i : Fin n, if y = flipBit x i then (1 : ℝ) else 0 := mul_nonneg (div_nonneg hp0 (le_of_lt hn_pos)) (Finset.sum_nonneg fun i _ => by split_ifs <;> norm_num) linarith row_sum_one x := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_comm] simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] field_simp [ne_of_gt hn_pos]; ring lemma hypercubeKernel_reversible (n : ℕ) (hn : 1 ≤ n) (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : (hypercubeKernel n hn p hp0 hp1).IsReversible (Dist.uniform ⟨fun _ => false⟩) := by intro x y simp only [Dist.uniform] congr 1 simp only [hypercubeKernel] have h1 : (if y = x then 1 - p else 0) = if x = y then 1 - p else 0 := by by_cases h : y = x · subst h; simp · rw [if_neg h, if_neg (Ne.symm h)] have h2 : ∀ i : Fin n, (y = flipBit x i) ↔ (x = flipBit y i) := fun i => by constructor <;> intro h · rw [h, flipBit_invol] · rw [h, flipBit_invol] rw [h1] congr 2 refine Finset.sum_congr rfl fun i _ => by simp only [h2 i] /-- Walsh–Fourier character `χ_S(x) = ∏_{i ∈ S} (-1)^{x_i}` on `Q_n`. -/ def walshChar {n : ℕ} (S : Finset (Fin n)) (x : Fin n → Bool) : ℝ := ∏ i ∈ S, if x i then (-1 : ℝ) else 1 lemma walshChar_zero {n : ℕ} (S : Finset (Fin n)) : walshChar S (fun _ => false) = 1 := by simp [walshChar] lemma walshChar_empty {n : ℕ} (x : Fin n → Bool) : walshChar ∅ x = 1 := by simp [walshChar] lemma walshChar_sq {n : ℕ} (S : Finset (Fin n)) (x : Fin n → Bool) : walshChar S x ^ 2 = 1 := by unfold walshChar rw [← Finset.prod_pow] refine Finset.prod_eq_one fun i _ => ?_ cases x i <;> norm_num lemma walshChar_flipBit {n : ℕ} (S : Finset (Fin n)) (x : Fin n → Bool) (j : Fin n) : walshChar S (flipBit x j) = (if j ∈ S then (-1 : ℝ) else 1) * walshChar S x := by unfold walshChar by_cases hj : j ∈ S · rw [if_pos hj, ← Finset.mul_prod_erase S _ hj, ← Finset.mul_prod_erase S _ hj] have hrest : ∏ i ∈ S.erase j, (if flipBit x j i then (-1 : ℝ) else 1) = ∏ i ∈ S.erase j, (if x i then (-1 : ℝ) else 1) := Finset.prod_congr rfl fun i hi => by simp [flipBit, (Finset.mem_erase.mp hi).1] rw [hrest] have hhead : (if flipBit x j j then (-1 : ℝ) else 1) = -(if x j then (-1 : ℝ) else 1) := by cases hxj : x j <;> simp [flipBit, hxj] rw [hhead]; ring · rw [if_neg hj, one_mul] refine Finset.prod_congr rfl fun i hi => ?_ have hij : i ≠ j := fun h => hj (h ▸ hi) simp [flipBit, hij] lemma walshChar_mul {n : ℕ} (S T : Finset (Fin n)) (x : Fin n → Bool) : walshChar S x * walshChar T x = walshChar (symmDiff S T) x := by unfold walshChar have hS : S = (S \ T) ∪ (S ∩ T) := by ext i; simp only [Finset.mem_union, Finset.mem_sdiff, Finset.mem_inter]; tauto have hT : T = (T \ S) ∪ (S ∩ T) := by ext i; simp only [Finset.mem_union, Finset.mem_sdiff, Finset.mem_inter]; tauto have hSD : symmDiff S T = (S \ T) ∪ (T \ S) := by ext i; simp only [Finset.mem_symmDiff, Finset.mem_union, Finset.mem_sdiff] have hd1 : Disjoint (S \ T) (S ∩ T) := Finset.disjoint_left.mpr fun i h1 h2 => (Finset.mem_sdiff.mp h1).2 (Finset.mem_inter.mp h2).2 have hd2 : Disjoint (T \ S) (S ∩ T) := Finset.disjoint_left.mpr fun i h1 h2 => (Finset.mem_sdiff.mp h1).2 (Finset.mem_inter.mp h2).1 have hd3 : Disjoint (S \ T) (T \ S) := Finset.disjoint_left.mpr fun i h1 h2 => (Finset.mem_sdiff.mp h1).2 (Finset.mem_sdiff.mp h2).1 have hprodS : ∏ i ∈ S, (if x i then (-1 : ℝ) else 1) = (∏ i ∈ S \ T, if x i then (-1 : ℝ) else 1) * (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1) := by rw [← Finset.prod_union hd1, ← hS] have hprodT : ∏ i ∈ T, (if x i then (-1 : ℝ) else 1) = (∏ i ∈ T \ S, if x i then (-1 : ℝ) else 1) * (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1) := by rw [← Finset.prod_union hd2, ← hT] rw [hprodS, hprodT, hSD, Finset.prod_union hd3] have hsq : (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1) * (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1) = 1 := by rw [← sq]; exact walshChar_sq (S ∩ T) x calc ((∏ i ∈ S \ T, if x i then (-1 : ℝ) else 1) * (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1)) * ((∏ i ∈ T \ S, if x i then (-1 : ℝ) else 1) * (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1)) = (∏ i ∈ S \ T, if x i then (-1 : ℝ) else 1) * (∏ i ∈ T \ S, if x i then (-1 : ℝ) else 1) * ((∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1) * (∏ i ∈ S ∩ T, if x i then (-1 : ℝ) else 1)) := by ring _ = (∏ i ∈ S \ T, if x i then (-1 : ℝ) else 1) * (∏ i ∈ T \ S, if x i then (-1 : ℝ) else 1) := by rw [hsq, mul_one] /-- Orthogonality of Walsh characters on `Q_n`: `∑_{x ∈ Q_n} χ_S(x) = 2^n` if `S = ∅`, and `0` otherwise. -/ theorem walshChar_sum_eq {n : ℕ} (S : Finset (Fin n)) : ∑ x : Fin n → Bool, walshChar S x = if S = ∅ then (2 : ℝ) ^ n else 0 := by by_cases hS : S = ∅ · subst hS simp only [walshChar_empty, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul, mul_one, ↓reduceIte] norm_cast · rw [if_neg hS] obtain ⟨j, hj⟩ := Finset.nonempty_iff_ne_empty.mpr hS let e : (Fin n → Bool) ≃ (Fin n → Bool) := { toFun := fun x => flipBit x j invFun := fun x => flipBit x j left_inv := fun x => flipBit_invol x j right_inv := fun x => flipBit_invol x j } have hsum_eq : ∑ x : Fin n → Bool, walshChar S x = ∑ x : Fin n → Bool, walshChar S (e x) := (Equiv.sum_comp e _).symm have hneg : ∑ x : Fin n → Bool, walshChar S (e x) = -(∑ x : Fin n → Bool, walshChar S x) := by rw [← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun x _ => ?_ change walshChar S (flipBit x j) = -walshChar S x rw [walshChar_flipBit S x j, if_pos hj]; ring linarith /-- Orthonormality of Walsh characters in `L^2(Unif(Q_n))`: `⟨χ_S, χ_T⟩_π = δ_{S, T}`. -/ theorem walshChar_orthonormal {n : ℕ} (S T : Finset (Fin n)) : l2Inner (Dist.uniform (⟨fun _ => false⟩ : Nonempty (Fin n → Bool))) (walshChar S) (walshChar T) = if S = T then 1 else 0 := by unfold l2Inner simp only [Dist.uniform, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] have hrew : ∑ x : Fin n → Bool, ((2 ^ n : ℕ) : ℝ)⁻¹ * walshChar S x * walshChar T x = ((2 : ℝ) ^ n)⁻¹ * ∑ x : Fin n → Bool, walshChar (symmDiff S T) x := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => ?_ rw [mul_assoc, walshChar_mul S T x]; push_cast; rfl rw [hrew, walshChar_sum_eq] have hiff : symmDiff S T = ∅ ↔ S = T := symmDiff_eq_bot by_cases h : S = T · rw [if_pos (hiff.mpr h), if_pos h] exact inv_mul_cancel₀ (by positivity) · rw [if_neg (fun h' => h (hiff.mp h')), if_neg h, mul_zero] /-- **Exact Eigenfunction Diagonalization of the `p`-Lazy Hypercube Walk `Q_n`**: EVERY Walsh character `χ_S` is an exact eigenfunction with eigenvalue `λ_S = 1 - 2 p |S| / n`! -/ theorem hypercubeKernel_apply_walshChar (n : ℕ) (hn : 1 ≤ n) (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (S : Finset (Fin n)) : (hypercubeKernel n hn p hp0 hp1).apply (walshChar S) = (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) • walshChar S := by ext x have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) simp only [MarkovKernel.apply, hypercubeKernel, Pi.smul_apply, smul_eq_mul, add_mul, Finset.sum_add_distrib, ite_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ite_true] have hnbr : ∑ y : Fin n → Bool, (p / (n : ℝ) * ∑ i : Fin n, if y = flipBit x i then (1 : ℝ) else 0) * walshChar S y = (p / (n : ℝ)) * ∑ i : Fin n, walshChar S (flipBit x i) := by calc ∑ y : Fin n → Bool, (p / (n : ℝ) * ∑ i : Fin n, if y = flipBit x i then (1 : ℝ) else 0) * walshChar S y = (p / (n : ℝ)) * ∑ y : Fin n → Bool, ∑ i : Fin n, if y = flipBit x i then walshChar S y else 0 := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun y _ => ?_ rw [mul_assoc, Finset.sum_mul] congr 1; refine Finset.sum_congr rfl fun i _ => by split_ifs <;> ring _ = (p / (n : ℝ)) * ∑ i : Fin n, ∑ y : Fin n → Bool, if y = flipBit x i then walshChar S y else 0 := by rw [Finset.sum_comm] _ = (p / (n : ℝ)) * ∑ i : Fin n, walshChar S (flipBit x i) := by congr 1; refine Finset.sum_congr rfl fun i _ => by simp rw [hnbr] have hflip_sum : ∑ i : Fin n, walshChar S (flipBit x i) = ((n : ℝ) - 2 * (S.card : ℝ)) * walshChar S x := by simp_rw [walshChar_flipBit S x, ← Finset.sum_mul] congr 1 rw [← Finset.sum_add_sum_compl S] have h1 : ∑ i ∈ S, (if i ∈ S then (-1 : ℝ) else 1) = -(S.card : ℝ) := by have : ∑ i ∈ S, (if i ∈ S then (-1 : ℝ) else 1) = ∑ _i ∈ S, (-1 : ℝ) := Finset.sum_congr rfl fun i hi => if_pos hi rw [this, Finset.sum_const, nsmul_eq_mul]; ring have h2 : ∑ i ∈ Sᶜ, (if i ∈ S then (-1 : ℝ) else 1) = (Sᶜ.card : ℝ) := by have : ∑ i ∈ Sᶜ, (if i ∈ S then (-1 : ℝ) else 1) = ∑ _i ∈ Sᶜ, (1 : ℝ) := Finset.sum_congr rfl fun i hi => if_neg (Finset.mem_compl.mp hi) rw [this, Finset.sum_const, nsmul_eq_mul]; ring have hcard : (S.card : ℝ) + (Sᶜ.card : ℝ) = (n : ℝ) := by exact_mod_cast (by rw [Finset.card_add_card_compl, Fintype.card_fin] : S.card + Sᶜ.card = n) rw [h1, h2]; linarith rw [hflip_sum] field_simp [ne_of_gt hn_pos]; ring /-- Iterated Walsh eigenvalue formula: `(P^t χ_S)(x) = (1 - 2 p |S| / n)^t · χ_S(x)`. -/ theorem hypercubeKernel_pow_apply_walshChar (n : ℕ) (hn : 1 ≤ n) (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (S : Finset (Fin n)) (t : ℕ) : ((hypercubeKernel n hn p hp0 hp1).pow t).apply (walshChar S) = (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t • walshChar S := by induction t with | zero => ext x; simp [MarkovKernel.pow, MarkovKernel.apply, MarkovKernel.id] | succ t ih => rw [MarkovKernel.pow, MarkovKernel.apply_comp, ih] ext x have h1 := congrFun (hypercubeKernel_apply_walshChar n hn p hp0 hp1 S) x simp only [MarkovKernel.apply, Pi.smul_apply, smul_eq_mul] at h1 ⊢ calc ∑ y, (hypercubeKernel n hn p hp0 hp1).P x y * ((1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t * walshChar S y) = (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t * ∑ y, (hypercubeKernel n hn p hp0 hp1).P x y * walshChar S y := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring _ = (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t * ((1 - 2 * p * (S.card : ℝ) / (n : ℝ)) * walshChar S x) := by rw [h1] _ = (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ (t + 1) * walshChar S x := by ring /-- Dual Walsh–Fourier inversion: `∑_S χ_S(x) = 2^n` if `x = 0^n`, and `0` otherwise. -/ theorem sum_walshChar_eq_dirac {n : ℕ} (x : Fin n → Bool) : ∑ S : Finset (Fin n), walshChar S x = if x = (fun _ => false) then (2 : ℝ) ^ n else 0 := by -- Use Fintype.prod_add / Finset.prod_one_add: ∏ i, (1 + f i) = ∑ S, ∏ i ∈ S, f i! have hprod : ∑ S : Finset (Fin n), walshChar S x = ∏ i : Fin n, (1 + if x i then (-1 : ℝ) else 1) := by unfold walshChar rw [Finset.prod_add] have hrew : ∑ S ∈ (Finset.univ : Finset (Fin n)).powerset, (∏ _i ∈ S, (1 : ℝ)) * (∏ i ∈ Finset.univ \ S, if x i then (-1 : ℝ) else 1) = ∑ S : Finset (Fin n), ∏ i ∈ S, if x i then (-1 : ℝ) else 1 := by simp only [Finset.prod_const_one, one_mul, Finset.powerset_univ] let e : Finset (Fin n) ≃ Finset (Fin n) := { toFun := fun S => Finset.univ \ S invFun := fun S => Finset.univ \ S left_inv := fun S => by ext i; simp right_inv := fun S => by ext i; simp } exact Equiv.sum_comp e (fun S => ∏ i ∈ S, if x i then (-1 : ℝ) else 1) exact hrew.symm rw [hprod] by_cases hx : x = fun _ => false · subst hx rw [if_pos rfl] have h2 : ∏ _i : Fin n, (1 + if false = true then (-1 : ℝ) else 1) = ∏ _i : Fin n, (2 : ℝ) := Finset.prod_congr rfl fun _ _ => by norm_num rw [h2, Finset.prod_const, Finset.card_univ, Fintype.card_fin] · rw [if_neg hx] have hex : ∃ i : Fin n, x i = true := by by_contra h; push Not at h apply hx; ext i; cases hxi : x i · rfl · exact absurd hxi (h i) obtain ⟨i, hi⟩ := hex exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [hi]) /-- **Exact `t`-Step Walsh–Fourier Distribution on `Q_n`**: `P^t(0^n, x) = 2^{-n} · ∑_{S ⊆ Fin n} (1 - 2 p |S| / n)^t · χ_S(x)`. -/ theorem hypercube_stepDist_walsh_expansion (n : ℕ) (hn : 1 ≤ n) (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (t : ℕ) (x : Fin n → Bool) : ((hypercubeKernel n hn p hp0 hp1).stepDist t (fun _ => false)) x = ((2 : ℝ) ^ n)⁻¹ * ∑ S : Finset (Fin n), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t * walshChar S x := by let K := hypercubeKernel n hn p hp0 hp1 -- Express δ_x(y) = 2^{-n} ∑_S χ_S(x) χ_S(y), then apply P^t to both sides at 0^n! have hdelta : ∀ y : Fin n → Bool, (if y = x then (1 : ℝ) else 0) = ((2 : ℝ) ^ n)⁻¹ * ∑ S : Finset (Fin n), walshChar S x * walshChar S y := fun y => by let z : Fin n → Bool := fun i => xor (x i) (y i) have hmul_z : ∀ S : Finset (Fin n), walshChar S x * walshChar S y = walshChar S z := fun S => by unfold walshChar rw [← Finset.prod_mul_distrib] refine Finset.prod_congr rfl fun i _ => ?_ have hbit : ∀ a b : Bool, (if a then (-1 : ℝ) else 1) * (if b then (-1 : ℝ) else 1) = if xor a b then (-1 : ℝ) else 1 := fun a b => by cases a <;> cases b <;> norm_num exact hbit (x i) (y i) have hz0 : z = (fun _ => false) ↔ y = x := by constructor · intro h; ext i have hi := congrFun h i dsimp only [z] at hi cases hxi : x i <;> cases hyi : y i <;> simp [hxi, hyi] at hi ⊢ · intro h; subst h; ext i; simp [z] simp_rw [hmul_z, sum_walshChar_eq_dirac z] by_cases hyx : y = x · rw [if_pos hyx, if_pos (hz0.mpr hyx)] exact (inv_mul_cancel₀ (by positivity : (2 : ℝ) ^ n ≠ 0)).symm · rw [if_neg hyx, if_neg (fun h => hyx (hz0.mp h)), mul_zero] have hstep : (K.stepDist t (fun _ => false)) x = ((K.pow t).apply (fun y => if y = x then (1 : ℝ) else 0)) (fun _ => false) := by simp [MarkovKernel.stepDist, MarkovKernel.row, MarkovKernel.apply] rw [hstep] calc ((K.pow t).apply (fun y => if y = x then (1 : ℝ) else 0)) (fun _ => false) = ∑ y : Fin n → Bool, (K.pow t).P (fun _ => false) y * (((2 : ℝ) ^ n)⁻¹ * ∑ S : Finset (Fin n), walshChar S x * walshChar S y) := by unfold MarkovKernel.apply exact Finset.sum_congr rfl fun y _ => by dsimp only; rw [hdelta y] _ = ((2 : ℝ) ^ n)⁻¹ * ∑ S : Finset (Fin n), walshChar S x * ((K.pow t).apply (walshChar S) (fun _ => false)) := by calc ∑ y, (K.pow t).P (fun _ => false) y * (((2 : ℝ) ^ n)⁻¹ * ∑ S, walshChar S x * walshChar S y) = ((2 : ℝ) ^ n)⁻¹ * ∑ y, ∑ S, walshChar S x * ((K.pow t).P (fun _ => false) y * walshChar S y) := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun y _ => ?_ rw [← mul_assoc, mul_comm ((K.pow t).P _ y) _, mul_assoc, Finset.mul_sum] congr 1; refine Finset.sum_congr rfl fun S _ => by ring _ = ((2 : ℝ) ^ n)⁻¹ * ∑ S, ∑ y, walshChar S x * ((K.pow t).P (fun _ => false) y * walshChar S y) := by rw [Finset.sum_comm] _ = ((2 : ℝ) ^ n)⁻¹ * ∑ S, walshChar S x * ((K.pow t).apply (walshChar S) (fun _ => false)) := by congr 1; refine Finset.sum_congr rfl fun S _ => (Finset.mul_sum ..).symm _ = ((2 : ℝ) ^ n)⁻¹ * ∑ S : Finset (Fin n), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t * walshChar S x := by congr 1; refine Finset.sum_congr rfl fun S _ => ?_ have hpow := congrFun (hypercubeKernel_pow_apply_walshChar n hn p hp0 hp1 S t) (fun _ => false) rw [hpow] simp only [Pi.smul_apply, smul_eq_mul, walshChar_zero, mul_one] ring /-- **Exact Binomial / Krawtchouk `χ²` Formula on the `n`-Hypercube `Q_n`**: `χ²(P^t(0^n, ·), Unif(Q_n)) = ∑_{k=1}^n C(n, k) · (1 - 2 p k / n)^(2 t)`. -/ theorem hypercube_chi2_exact (n : ℕ) (hn : 1 ≤ n) (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (t : ℕ) : chi2Dist ((hypercubeKernel n hn p hp0 hp1).stepDist t (fun _ => false)) (Dist.uniform ⟨fun _ => false⟩) = ∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * (1 - 2 * p * (k : ℝ) / (n : ℝ)) ^ (2 * t) := by let π := Dist.uniform (⟨fun _ => false⟩ : Nonempty (Fin n → Bool)) have hπ_pos : ∀ x, 0 < π x := fun _ => by simp only [π, Dist.uniform, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] exact inv_pos.mpr (by positivity) have hπ_val : ∀ x, π x = ((2 : ℝ) ^ n)⁻¹ := fun _ => by simp [π, Dist.uniform] -- Compute ∑_x (P^t(0, x) - 2^{-n})² / 2^{-n} using Parseval / orthonormality of Walsh characters! have hdiff : ∀ x : Fin n → Bool, ((hypercubeKernel n hn p hp0 hp1).stepDist t (fun _ => false)) x - π x = ((2 : ℝ) ^ n)⁻¹ * ∑ S ∈ Finset.univ.erase (∅ : Finset (Fin n)), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t * walshChar S x := fun x => by rw [hypercube_stepDist_walsh_expansion n hn p hp0 hp1 t x, hπ_val x, ← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset (Fin n)))] simp only [Finset.card_empty, Nat.cast_zero, mul_zero, zero_div, sub_zero, one_pow, walshChar_empty, mul_one] ring have hchi2_S : chi2Dist ((hypercubeKernel n hn p hp0 hp1).stepDist t (fun _ => false)) π = ∑ S ∈ Finset.univ.erase (∅ : Finset (Fin n)), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ (2 * t) := by unfold chi2Dist simp_rw [hdiff, hπ_val] have h2n_pos : (0 : ℝ) < (2 : ℝ) ^ n := by positivity -- Expand (∑_{S ≠ ∅} c_S χ_S(x))² and sum over x using walshChar_orthonormal! let c : Finset (Fin n) → ℝ := fun S => (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ t have hstep1 : ∀ x : Fin n → Bool, (((2 : ℝ) ^ n)⁻¹ * ∑ S ∈ Finset.univ.erase ∅, c S * walshChar S x) ^ 2 / ((2 : ℝ) ^ n)⁻¹ = ((2 : ℝ) ^ n)⁻¹ * (∑ S ∈ Finset.univ.erase ∅, c S * walshChar S x) * (∑ T ∈ Finset.univ.erase ∅, c T * walshChar T x) := fun x => by field_simp [ne_of_gt h2n_pos] have hsum_eq := Finset.sum_congr rfl fun x (_ : x ∈ Finset.univ) => hstep1 x rw [hsum_eq] calc ∑ x : Fin n → Bool, ((2 : ℝ) ^ n)⁻¹ * (∑ S ∈ Finset.univ.erase ∅, c S * walshChar S x) * (∑ T ∈ Finset.univ.erase ∅, c T * walshChar T x) = ∑ S ∈ Finset.univ.erase ∅, ∑ T ∈ Finset.univ.erase ∅, c S * c T * l2Inner π (walshChar S) (walshChar T) := by calc ∑ x, ((2 : ℝ) ^ n)⁻¹ * (∑ S ∈ Finset.univ.erase ∅, c S * walshChar S x) * (∑ T ∈ Finset.univ.erase ∅, c T * walshChar T x) = ∑ x, ∑ S ∈ Finset.univ.erase ∅, ∑ T ∈ Finset.univ.erase ∅, c S * c T * (π x * walshChar S x * walshChar T x) := by refine Finset.sum_congr rfl fun x _ => ?_ have hmul : ((2 : ℝ) ^ n)⁻¹ * (∑ S ∈ Finset.univ.erase ∅, c S * walshChar S x) = ∑ S ∈ Finset.univ.erase ∅, ((2 : ℝ) ^ n)⁻¹ * (c S * walshChar S x) := Finset.mul_sum .. rw [hmul, Finset.sum_mul] refine Finset.sum_congr rfl fun S _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun T _ => by rw [hπ_val x]; ring _ = ∑ S ∈ Finset.univ.erase ∅, ∑ x, ∑ T ∈ Finset.univ.erase ∅, c S * c T * (π x * walshChar S x * walshChar T x) := Finset.sum_comm _ = ∑ S ∈ Finset.univ.erase ∅, ∑ T ∈ Finset.univ.erase ∅, ∑ x, c S * c T * (π x * walshChar S x * walshChar T x) := Finset.sum_congr rfl fun S _ => Finset.sum_comm _ = ∑ S ∈ Finset.univ.erase ∅, ∑ T ∈ Finset.univ.erase ∅, c S * c T * l2Inner π (walshChar S) (walshChar T) := Finset.sum_congr rfl fun S _ => Finset.sum_congr rfl fun T _ => (Finset.mul_sum ..).symm _ = ∑ S ∈ Finset.univ.erase ∅, c S * c S := by refine Finset.sum_congr rfl fun S hS => ?_ have horth : ∀ T : Finset (Fin n), l2Inner π (walshChar S) (walshChar T) = if S = T then 1 else 0 := fun T => walshChar_orthonormal S T simp_rw [horth] rw [Finset.sum_eq_single S] · simp · intro T _ hTS; simp [Ne.symm hTS] · intro h; exact absurd hS h _ = ∑ S ∈ Finset.univ.erase (∅ : Finset (Fin n)), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ (2 * t) := by refine Finset.sum_congr rfl fun S _ => by dsimp only [c]; rw [← pow_add, ← two_mul] rw [hchi2_S] -- Group subsets S ≠ ∅ by cardinality k = S.card ∈ Icc 1 n! have hgroup : ∑ S ∈ (Finset.univ : Finset (Finset (Fin n))).erase ∅, (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ (2 * t) = ∑ k ∈ Finset.Icc 1 n, ∑ S ∈ ((Finset.univ : Finset (Finset (Fin n))).erase ∅).filter (fun S => S.card = k), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ (2 * t) := (Finset.sum_fiberwise_of_maps_to (g := fun S : Finset (Fin n) => S.card) (t := Finset.Icc 1 n) (fun S hS => by have hne : S ≠ ∅ := (Finset.mem_erase.mp hS).1 have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hne) have hle : S.card ≤ n := by simpa using Finset.card_le_univ S exact Finset.mem_Icc.mpr ⟨hpos, hle⟩) _).symm rw [hgroup] refine Finset.sum_congr rfl fun k hk => ?_ have hk1 : 1 ≤ k := (Finset.mem_Icc.mp hk).1 have hfilt_eq : ((Finset.univ : Finset (Finset (Fin n))).erase ∅).filter (fun S => S.card = k) = Finset.powersetCard k (Finset.univ : Finset (Fin n)) := by ext S simp only [Finset.mem_filter, Finset.mem_erase, Finset.mem_univ, and_true, Finset.mem_powersetCard, Finset.subset_univ, true_and] constructor · exact And.right · intro hcard; exact ⟨fun h => by rw [h] at hcard; simp at hcard; omega, hcard⟩ rw [hfilt_eq] have hconst : ∑ S ∈ Finset.powersetCard k (Finset.univ : Finset (Fin n)), (1 - 2 * p * (S.card : ℝ) / (n : ℝ)) ^ (2 * t) = ∑ _S ∈ Finset.powersetCard k (Finset.univ : Finset (Fin n)), (1 - 2 * p * (k : ℝ) / (n : ℝ)) ^ (2 * t) := Finset.sum_congr rfl fun S hS => by rw [(Finset.mem_powersetCard.mp hS).2] rw [hconst, Finset.sum_const, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] /-- **Exact Non-Asymptotic `L^2` Upper Bound for Diaconis–Graham–Morrison `Q_n` Walk** (`p = n / (n + 1)`): for ALL `n ≥ 1` and `t : ℕ`, letting `u = exp(-4 t / (n + 1))`: `4 · d_TV(P^t(0^n, ·), π)² ≤ χ²(t) ≤ (1 + u) · exp(n · u) - 1`. -/ theorem hypercube_dgm_chi2_upper (n : ℕ) (hn : 1 ≤ n) (t : ℕ) : let p : ℝ := (n : ℝ) / ((n : ℝ) + 1) let hp0 : 0 ≤ p := by positivity let hp1 : p ≤ 1 := by have hpos : (0 : ℝ) < (n : ℝ) + 1 := by positivity rw [div_le_one hpos]; linarith let u : ℝ := Real.exp (-4 * (t : ℝ) / ((n : ℝ) + 1)) 4 * (tvDist ((hypercubeKernel n hn p hp0 hp1).stepDist t (fun _ => false)) (Dist.uniform ⟨fun _ => false⟩)) ^ 2 ≤ (1 + u) * Real.exp ((n : ℝ) * u) - 1 := by intro p hp0 hp1 u have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hn1_pos : (0 : ℝ) < (n : ℝ) + 1 := by linarith have hπ_pos : ∀ x : Fin n → Bool, 0 < (Dist.uniform ⟨fun _ => false⟩) x := fun _ => by simp only [Dist.uniform, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] exact inv_pos.mpr (by positivity) refine le_trans (four_tvDist_sq_le_chi2 _ _ hπ_pos) ?_ rw [hypercube_chi2_exact n hn p hp0 hp1 t] -- Simplify 1 - 2 p k / n = 1 - 2 k / (n + 1)! have heig_simp : ∀ k : ℕ, 1 - 2 * p * (k : ℝ) / (n : ℝ) = 1 - 2 * (k : ℝ) / ((n : ℝ) + 1) := fun k => by dsimp only [p]; field_simp [ne_of_gt hn_pos, ne_of_gt hn1_pos] simp_rw [heig_simp] -- Split each term k ∈ Icc 1 n into two cases: 2k ≤ n+1 (bound by u^k) and 2k > n+1 (bound by u^(n - k + 1))! -- So EVERY term is bounded by C(n, k) * u^k + C(n, n - k) * u^(n - k + 1)! have hterm_le : ∀ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ (Nat.choose n k : ℝ) * u ^ k + (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k)) := by intro k hk have hk_le : k ≤ n := (Finset.mem_Icc.mp hk).2 have hu_nn : 0 ≤ u := le_of_lt (Real.exp_pos _) have hchoose_sym : Nat.choose n (n - k) = Nat.choose n k := Nat.choose_symm hk_le by_cases hhalf : 2 * k ≤ n + 1 · have hlam_nn : 0 ≤ 1 - 2 * (k : ℝ) / ((n : ℝ) + 1) := by have h2k : 2 * (k : ℝ) ≤ (n : ℝ) + 1 := by exact_mod_cast hhalf rw [sub_nonneg, div_le_one hn1_pos]; exact h2k have hlam_exp : 1 - 2 * (k : ℝ) / ((n : ℝ) + 1) ≤ Real.exp (-2 * (k : ℝ) / ((n : ℝ) + 1)) := by have h := Real.add_one_le_exp (-2 * (k : ℝ) / ((n : ℝ) + 1)) have hrew : -2 * (k : ℝ) / ((n : ℝ) + 1) + 1 = 1 - 2 * (k : ℝ) / ((n : ℝ) + 1) := by ring linarith have hpow : (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ u ^ k := by calc (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ (Real.exp (-2 * (k : ℝ) / ((n : ℝ) + 1))) ^ (2 * t) := pow_le_pow_left₀ hlam_nn hlam_exp (2 * t) _ = Real.exp ((2 * t : ℕ) * (-2 * (k : ℝ) / ((n : ℝ) + 1))) := (Real.exp_nat_mul _ _).symm _ = Real.exp ((k : ℕ) * (-4 * (t : ℝ) / ((n : ℝ) + 1))) := by congr 1; push_cast; ring _ = u ^ k := Real.exp_nat_mul _ k have h1 : (Nat.choose n k : ℝ) * (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ (Nat.choose n k : ℝ) * u ^ k := mul_le_mul_of_nonneg_left hpow (Nat.cast_nonneg _) have h2 : 0 ≤ (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k)) := by positivity linarith · -- When 2k > n+1: -(1 - 2k/(n+1)) = 1 - 2(n - k + 1)/(n+1) ∈ [0, exp(-2(n - k + 1)/(n+1))]! have hflip_eq : -(1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) = 1 - 2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1) := by rw [Nat.cast_sub hk_le]; field_simp [ne_of_gt hn1_pos]; ring have hlam_nn : 0 ≤ 1 - 2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1) := by have h2m : 2 * (n - k + 1) ≤ n + 1 := by omega have h2mr : 2 * ((n - k : ℕ) + 1 : ℝ) ≤ (n : ℝ) + 1 := by exact_mod_cast h2m rw [sub_nonneg, div_le_one hn1_pos]; exact h2mr have hlam_exp : 1 - 2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1) ≤ Real.exp (-2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1)) := by have h := Real.add_one_le_exp (-2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1)) have hrew : -2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1) + 1 = 1 - 2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1) := by ring linarith have hsq_neg : (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) = (-(1 - 2 * (k : ℝ) / ((n : ℝ) + 1))) ^ (2 * t) := by rw [pow_mul, pow_mul, neg_sq] have hpow : (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ u * u ^ (n - k) := by rw [hsq_neg, hflip_eq] calc (1 - 2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ (Real.exp (-2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1))) ^ (2 * t) := pow_le_pow_left₀ hlam_nn hlam_exp (2 * t) _ = Real.exp ((2 * t : ℕ) * (-2 * ((n - k : ℕ) + 1 : ℝ) / ((n : ℝ) + 1))) := (Real.exp_nat_mul _ _).symm _ = Real.exp (-4 * (t : ℝ) / ((n : ℝ) + 1) + (n - k : ℕ) * (-4 * (t : ℝ) / ((n : ℝ) + 1))) := by congr 1; push_cast; ring _ = u * u ^ (n - k) := by rw [Real.exp_add, Real.exp_nat_mul] have h1 : (Nat.choose n k : ℝ) * (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k)) := by rw [hchoose_sym] exact mul_le_mul_of_nonneg_left hpow (Nat.cast_nonneg _) have h2 : 0 ≤ (Nat.choose n k : ℝ) * u ^ k := by positivity linarith -- Sum over k ∈ Icc 1 n and apply Binomial Theorem + (1 + u)^n ≤ exp(n u)! have hbinom : ∑ k ∈ Finset.range (n + 1), (Nat.choose n k : ℝ) * u ^ k = (1 + u) ^ n := by have h := add_pow u (1 : ℝ) n rw [add_comm] at h rw [h] refine Finset.sum_congr rfl fun k _ => by simp [mul_comm] have hsum1 : ∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * u ^ k = (1 + u) ^ n - 1 := by have hsplit : Finset.range (n + 1) = insert 0 (Finset.Icc 1 n) := by ext k; simp only [Finset.mem_range, Finset.mem_insert, Finset.mem_Icc]; omega rw [hsplit, Finset.sum_insert (by simp)] at hbinom simp only [Nat.choose_zero_right, Nat.cast_one, pow_zero, mul_one] at hbinom linarith have hsum2 : ∑ k ∈ Finset.Icc 1 n, (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k)) ≤ u * (1 + u) ^ n := by have hreidx : ∑ k ∈ Finset.Icc 1 n, (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k)) = u * ∑ m ∈ Finset.range n, (Nat.choose n m : ℝ) * u ^ m := by rw [Finset.mul_sum] refine Finset.sum_bij (fun k _ => n - k) ?_ ?_ ?_ ?_ · intro k hk; rcases Finset.mem_Icc.mp hk with ⟨h1, h2⟩; exact Finset.mem_range.mpr (by omega) · intro k₁ hk₁ k₂ hk₂ heq rcases Finset.mem_Icc.mp hk₁ with ⟨_, h12⟩ rcases Finset.mem_Icc.mp hk₂ with ⟨_, h22⟩ omega · intro m hm have hmn : m < n := Finset.mem_range.mp hm refine ⟨n - m, Finset.mem_Icc.mpr ⟨by omega, by omega⟩, by omega⟩ · intro k _; ring rw [hreidx] have hle_full : ∑ m ∈ Finset.range n, (Nat.choose n m : ℝ) * u ^ m ≤ ∑ m ∈ Finset.range (n + 1), (Nat.choose n m : ℝ) * u ^ m := Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono (Nat.le_succ n)) (fun m _ _ => by positivity) rw [hbinom] at hle_full exact mul_le_mul_of_nonneg_left hle_full (le_of_lt (Real.exp_pos _)) have hexp_pow : (1 + u) ^ n ≤ Real.exp ((n : ℝ) * u) := by calc (1 + u) ^ n ≤ (Real.exp u) ^ n := pow_le_pow_left₀ (by positivity) (by linarith [Real.add_one_le_exp u]) n _ = Real.exp ((n : ℝ) * u) := (Real.exp_nat_mul u n).symm calc ∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * (1 - 2 * (k : ℝ) / ((n : ℝ) + 1)) ^ (2 * t) ≤ ∑ k ∈ Finset.Icc 1 n, ((Nat.choose n k : ℝ) * u ^ k + (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k))) := Finset.sum_le_sum hterm_le _ = (∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * u ^ k) + (∑ k ∈ Finset.Icc 1 n, (Nat.choose n (n - k) : ℝ) * (u * u ^ (n - k))) := Finset.sum_add_distrib _ ≤ ((1 + u) ^ n - 1) + u * (1 + u) ^ n := by rw [hsum1]; linarith _ = (1 + u) * (1 + u) ^ n - 1 := by ring _ ≤ (1 + u) * Real.exp ((n : ℝ) * u) - 1 := by have h1u : 0 ≤ 1 + u := by positivity nlinarith /-- **Exact Level-1 Distinguishing-Statistic Lower Bound for DGM `Q_n` Walk**: for ALL `n ≥ 3` and ALL `t : ℕ`: `1 - 8 / (n · (1 - 2 / (n + 1))^(2 t)) ≤ d_TV(P^t(0^n, ·), Unif(Q_n))`. -/ theorem hypercube_dgm_tv_lower (n : ℕ) (hn : 3 ≤ n) (t : ℕ) : let p : ℝ := (n : ℝ) / ((n : ℝ) + 1) let hp0 : 0 ≤ p := by positivity let hp1 : p ≤ 1 := by have hpos : (0 : ℝ) < (n : ℝ) + 1 := by positivity rw [div_le_one hpos]; linarith 1 - 8 / ((n : ℝ) * (1 - 2 / ((n : ℝ) + 1)) ^ (2 * t)) ≤ tvDist ((hypercubeKernel n (by omega) p hp0 hp1).stepDist t (fun _ => false)) (Dist.uniform ⟨fun _ => false⟩) := by intro p hp0 hp1 let K := hypercubeKernel n (by omega) p hp0 hp1 let π := Dist.uniform (⟨fun _ => false⟩ : Nonempty (Fin n → Bool)) let μ := K.stepDist t (fun _ => false) let f : (Fin n → Bool) → ℝ := fun x => ∑ i : Fin n, walshChar {i} x have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hn1_pos : (0 : ℝ) < (n : ℝ) + 1 := by linarith let lam1 : ℝ := 1 - 2 / ((n : ℝ) + 1) let lam2 : ℝ := 1 - 4 / ((n : ℝ) + 1) have hlam1_pos : 0 < lam1 := by dsimp only [lam1]; rw [sub_pos, div_lt_one hn1_pos] have : (3 : ℝ) ≤ n := by exact_mod_cast hn linarith have hlam2_nn : 0 ≤ lam2 := by dsimp only [lam2]; rw [sub_nonneg, div_le_one hn1_pos] have : (3 : ℝ) ≤ n := by exact_mod_cast hn linarith have hlam2_le_sq : lam2 ≤ lam1 ^ 2 := by dsimp only [lam1, lam2] have hsq : (1 - 2 / ((n : ℝ) + 1)) ^ 2 - (1 - 4 / ((n : ℝ) + 1)) = 4 / ((n : ℝ) + 1) ^ 2 := by field_simp [ne_of_gt hn1_pos]; ring have hnn : 0 ≤ 4 / ((n : ℝ) + 1) ^ 2 := by positivity linarith -- Compute E_π[f] = 0, Var_π(f) = n, E_μ[f] = n * lam1^t, and Var_μ(f) ≤ n! have hEpi : π.expect f = 0 := by unfold Dist.expect f simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_eq_zero fun i _ => ?_ have h1 := walshChar_orthonormal ({i} : Finset (Fin n)) (∅ : Finset (Fin n)) simp only [Finset.singleton_ne_empty, ↓reduceIte, l2Inner, walshChar_empty, mul_one] at h1 exact h1 have hVpi : π.variance f = (n : ℝ) := by rw [π.variance_eq_expect_sq_sub f, hEpi, zero_pow two_ne_zero, sub_zero] unfold Dist.expect f have hsq_exp : ∀ x, (∑ i : Fin n, walshChar {i} x) ^ 2 = ∑ i : Fin n, ∑ j : Fin n, walshChar {i} x * walshChar {j} x := fun x => by rw [sq, Finset.sum_mul] exact Finset.sum_congr rfl fun i _ => Finset.mul_sum .. simp_rw [hsq_exp, Finset.mul_sum] calc ∑ x, ∑ i, ∑ j, π x * (walshChar {i} x * walshChar {j} x) = ∑ i, ∑ x, ∑ j, π x * (walshChar {i} x * walshChar {j} x) := Finset.sum_comm _ = ∑ i, ∑ j, ∑ x, π x * (walshChar {i} x * walshChar {j} x) := Finset.sum_congr rfl fun i _ => Finset.sum_comm _ = ∑ i : Fin n, ∑ j : Fin n, l2Inner π (walshChar {i}) (walshChar {j}) := by refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_ unfold l2Inner; refine Finset.sum_congr rfl fun x _ => by ring _ = ∑ i : Fin n, (1 : ℝ) := by refine Finset.sum_congr rfl fun i _ => ?_ have horth : ∀ j : Fin n, l2Inner π (walshChar {i}) (walshChar {j}) = if ({i} : Finset (Fin n)) = {j} then 1 else 0 := fun j => walshChar_orthonormal {i} {j} simp_rw [horth] rw [Finset.sum_eq_single i] · rw [if_pos rfl] · intro j _ hji; rw [if_neg]; intro h exact hji (Finset.singleton_injective h).symm · intro h; exact absurd (Finset.mem_univ i) h _ = (n : ℝ) := by simp have hEμ_walsh : ∀ S : Finset (Fin n), μ.expect (walshChar S) = (1 - 2 * (S.card : ℝ) / ((n : ℝ) + 1)) ^ t := fun S => by change (K.stepDist t (fun _ => false)).expect (walshChar S) = _ rw [MarkovKernel.expect_stepDist] have hpow := congrFun (hypercubeKernel_pow_apply_walshChar n (by omega) p hp0 hp1 S t) (fun _ => false) rw [hpow] simp only [Pi.smul_apply, smul_eq_mul, walshChar_zero, mul_one] congr 1; dsimp only [p]; field_simp [ne_of_gt hn_pos, ne_of_gt hn1_pos] have hEμ : μ.expect f = (n : ℝ) * lam1 ^ t := by unfold Dist.expect f simp_rw [Finset.mul_sum] rw [Finset.sum_comm] have hterm : ∀ i : Fin n, ∑ x, μ x * walshChar {i} x = lam1 ^ t := fun i => by have h := hEμ_walsh {i} simpa [Dist.expect, lam1] using h simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] have hEμ_sq : μ.expect (fun x => f x ^ 2) = (n : ℝ) + (n : ℝ) * ((n : ℝ) - 1) * lam2 ^ t := by unfold Dist.expect f have hsq_exp : ∀ x, (∑ i : Fin n, walshChar {i} x) ^ 2 = ∑ i : Fin n, ∑ j : Fin n, walshChar (symmDiff {i} {j}) x := fun x => by rw [sq, Finset.sum_mul] refine Finset.sum_congr rfl fun i _ => ?_ rw [Finset.mul_sum] exact Finset.sum_congr rfl fun j _ => walshChar_mul {i} {j} x simp_rw [hsq_exp, Finset.mul_sum] calc ∑ x, ∑ i, ∑ j, μ x * walshChar (symmDiff {i} {j}) x = ∑ i, ∑ x, ∑ j, μ x * walshChar (symmDiff {i} {j}) x := Finset.sum_comm _ = ∑ i, ∑ j, μ.expect (walshChar (symmDiff {i} {j})) := Finset.sum_congr rfl fun i _ => Finset.sum_comm _ = ∑ i : Fin n, ∑ j : Fin n, if i = j then (1 : ℝ) else lam2 ^ t := by refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_ rw [hEμ_walsh] by_cases hij : i = j · subst hij; simp · rw [if_neg hij] have hsd : symmDiff ({i} : Finset (Fin n)) {j} = {i, j} := by ext k; simp only [Finset.mem_symmDiff, Finset.mem_singleton, Finset.mem_insert] constructor · rintro (⟨rfl, _⟩ | ⟨rfl, _⟩) <;> simp · rintro (rfl | rfl) · left; exact ⟨rfl, hij⟩ · right; exact ⟨rfl, Ne.symm hij⟩ rw [hsd, Finset.card_pair hij] dsimp only [lam2] congr 1; push_cast; ring _ = (n : ℝ) + (n : ℝ) * ((n : ℝ) - 1) * lam2 ^ t := by have hrow : ∀ i : Fin n, ∑ j : Fin n, (if i = j then (1 : ℝ) else lam2 ^ t) = 1 + ((n : ℝ) - 1) * lam2 ^ t := fun i => by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i), if_pos rfl] congr 1 have hrest : ∑ j ∈ Finset.univ.erase i, (if i = j then (1 : ℝ) else lam2 ^ t) = ∑ _j ∈ Finset.univ.erase i, lam2 ^ t := Finset.sum_congr rfl fun j hj => if_neg (Ne.symm (Finset.mem_erase.mp hj).1) rw [hrest, Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ i), Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_sub (show 1 ≤ n by omega)] simp simp_rw [hrow, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring have hVμ_le : μ.variance f ≤ (n : ℝ) := by rw [μ.variance_eq_expect_sq_sub f, hEμ_sq, hEμ] have hpow_le : lam2 ^ t ≤ lam1 ^ (2 * t) := by rw [pow_mul]; exact pow_le_pow_left₀ hlam2_nn hlam2_le_sq t have hmul : (n : ℝ) * ((n : ℝ) - 1) * lam2 ^ t ≤ (n : ℝ) ^ 2 * lam1 ^ (2 * t) := by have hn3 : (3 : ℝ) ≤ n := by exact_mod_cast hn have hn1 : 0 ≤ (n : ℝ) - 1 := by linarith have h1 : (n : ℝ) * ((n : ℝ) - 1) * lam2 ^ t ≤ (n : ℝ) * ((n : ℝ) - 1) * lam1 ^ (2 * t) := mul_le_mul_of_nonneg_left hpow_le (mul_nonneg (le_of_lt hn_pos) hn1) have h2 : 0 ≤ (n : ℝ) * lam1 ^ (2 * t) := mul_nonneg (le_of_lt hn_pos) (pow_nonneg (le_of_lt hlam1_pos) _) nlinarith have hsq : ((n : ℝ) * lam1 ^ t) ^ 2 = (n : ℝ) ^ 2 * lam1 ^ (2 * t) := by rw [mul_pow, ← pow_mul, mul_comm t 2] linarith have hmean_ne : μ.expect f ≠ π.expect f := by rw [hEμ, hEpi]; exact ne_of_gt (mul_pos hn_pos (pow_pos hlam1_pos t)) have hcheb := tvDist_ge_distinguishing_chebyshev μ π f hmean_ne have hden_pos : 0 < (n : ℝ) ^ 2 * lam1 ^ (2 * t) := mul_pos (sq_pos_of_pos hn_pos) (pow_pos hlam1_pos (2 * t)) have hfrac_le : 4 * (μ.variance f + π.variance f) / (μ.expect f - π.expect f) ^ 2 ≤ 8 / ((n : ℝ) * lam1 ^ (2 * t)) := by rw [hEμ, hEpi, sub_zero, hVpi] have hsq : ((n : ℝ) * lam1 ^ t) ^ 2 = (n : ℝ) ^ 2 * lam1 ^ (2 * t) := by rw [mul_pow, ← pow_mul, mul_comm t 2] rw [hsq] have hnum : 4 * (μ.variance f + (n : ℝ)) ≤ 8 * (n : ℝ) := by linarith calc 4 * (μ.variance f + (n : ℝ)) / ((n : ℝ) ^ 2 * lam1 ^ (2 * t)) ≤ 8 * (n : ℝ) / ((n : ℝ) ^ 2 * lam1 ^ (2 * t)) := div_le_div_of_nonneg_right hnum (le_of_lt hden_pos) _ = 8 / ((n : ℝ) * lam1 ^ (2 * t)) := by field_simp [ne_of_gt hn_pos, ne_of_gt (pow_pos hlam1_pos (2 * t))] exact le_trans (by linarith) hcheb /-- **Sharp Cutoff Phase Transition for the Diaconis–Graham–Morrison `Q_n` Walk at `(1/4) n ln n`**: for EVERY `n ≥ 3` and every cutoff offset `c ≥ 0`: - **Upper window** (`t ≥ (1/4)(n+1) ln n + c(n+1)`): `4 · d_TV(t)² ≤ (1 + exp(-4c) / n) · exp(exp(-4c)) - 1` (`→ 0` as `c → ∞`), - **Lower window** (`t ≤ (1/4)(n-1) ln n - c(n-1)`): `d_TV(t) ≥ 1 - 8 · exp(-4c)` (`→ 1` as `c → ∞`). -/ theorem hypercube_dgm_sharp_cutoff_quarter_n_log_n (n : ℕ) (hn : 3 ≤ n) {c : ℝ} (_hc : 0 ≤ c) : let p : ℝ := (n : ℝ) / ((n : ℝ) + 1) let hp0 : 0 ≤ p := by positivity let hp1 : p ≤ 1 := by have hpos : (0 : ℝ) < (n : ℝ) + 1 := by positivity rw [div_le_one hpos]; linarith (∀ t : ℕ, (1 / 4 : ℝ) * ((n : ℝ) + 1) * Real.log (n : ℝ) + c * ((n : ℝ) + 1) ≤ (t : ℝ) → 4 * (tvDist ((hypercubeKernel n (by omega) p hp0 hp1).stepDist t (fun _ => false)) (Dist.uniform ⟨fun _ => false⟩)) ^ 2 ≤ (1 + Real.exp (-4 * c) / (n : ℝ)) * Real.exp (Real.exp (-4 * c)) - 1) ∧ (∀ t : ℕ, (t : ℝ) ≤ (1 / 4 : ℝ) * ((n : ℝ) - 1) * Real.log (n : ℝ) - c * ((n : ℝ) - 1) → 1 - 8 * Real.exp (-4 * c) ≤ tvDist ((hypercubeKernel n (by omega) p hp0 hp1).stepDist t (fun _ => false)) (Dist.uniform ⟨fun _ => false⟩)) := by intro p hp0 hp1 have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hn1_pos : (0 : ℝ) < (n : ℝ) + 1 := by linarith have hnm1_pos : (0 : ℝ) < (n : ℝ) - 1 := by have : (3 : ℝ) ≤ n := by exact_mod_cast hn linarith constructor · intro t ht have hub := hypercube_dgm_chi2_upper n (by omega) t set u := Real.exp (-4 * (t : ℝ) / ((n : ℝ) + 1)) have hu_le : u ≤ Real.exp (-4 * c) / (n : ℝ) := by have hexp_le : -4 * (t : ℝ) / ((n : ℝ) + 1) ≤ -4 * c - Real.log (n : ℝ) := by rw [div_le_iff₀ hn1_pos] nlinarith calc u = Real.exp (-4 * (t : ℝ) / ((n : ℝ) + 1)) := rfl _ ≤ Real.exp (-4 * c - Real.log (n : ℝ)) := Real.exp_le_exp.mpr hexp_le _ = Real.exp (-4 * c) / Real.exp (Real.log (n : ℝ)) := Real.exp_sub _ _ _ = Real.exp (-4 * c) / (n : ℝ) := by rw [Real.exp_log hn_pos] have hnu_le : (n : ℝ) * u ≤ Real.exp (-4 * c) := by have h1 := mul_le_mul_of_nonneg_left hu_le (le_of_lt hn_pos) rwa [mul_div_cancel₀ _ (ne_of_gt hn_pos)] at h1 have hmono : (1 + u) * Real.exp ((n : ℝ) * u) ≤ (1 + Real.exp (-4 * c) / (n : ℝ)) * Real.exp (Real.exp (-4 * c)) := mul_le_mul (by linarith) (Real.exp_le_exp.mpr hnu_le) (le_of_lt (Real.exp_pos _)) (by positivity) linarith · intro t ht have hlb := hypercube_dgm_tv_lower n hn t -- Elementary bound: 1 - 2/(n+1) = (n-1)/(n+1) ≥ exp(-2/(n-1)) (since log((n+1)/(n-1)) ≤ 2/(n-1))! have hlam_pos : 0 < 1 - 2 / ((n : ℝ) + 1) := by have h3 : (3 : ℝ) ≤ n := by exact_mod_cast hn rw [sub_pos, div_lt_one hn1_pos]; linarith have hlam_ge_exp : Real.exp (-2 / ((n : ℝ) - 1)) ≤ 1 - 2 / ((n : ℝ) + 1) := by have hlam_eq : 1 - 2 / ((n : ℝ) + 1) = ((n : ℝ) - 1) / ((n : ℝ) + 1) := by field_simp [ne_of_gt hn1_pos]; ring have hinv : (1 - 2 / ((n : ℝ) + 1))⁻¹ = 1 + 2 / ((n : ℝ) - 1) := by rw [hlam_eq, inv_div]; field_simp [ne_of_gt hnm1_pos]; ring have hlog_inv : Real.log (1 - 2 / ((n : ℝ) + 1))⁻¹ ≤ 2 / ((n : ℝ) - 1) := by rw [hinv] have h := Real.log_le_sub_one_of_pos (show 0 < 1 + 2 / ((n : ℝ) - 1) by positivity) linarith rw [Real.log_inv] at hlog_inv have hlog_ge : -2 / ((n : ℝ) - 1) ≤ Real.log (1 - 2 / ((n : ℝ) + 1)) := by have hneg : -2 / ((n : ℝ) - 1) = -(2 / ((n : ℝ) - 1)) := by ring linarith calc Real.exp (-2 / ((n : ℝ) - 1)) ≤ Real.exp (Real.log (1 - 2 / ((n : ℝ) + 1))) := Real.exp_le_exp.mpr hlog_ge _ = 1 - 2 / ((n : ℝ) + 1) := Real.exp_log hlam_pos have hpow_ge : Real.exp (4 * c) ≤ (n : ℝ) * (1 - 2 / ((n : ℝ) + 1)) ^ (2 * t) := by have h1 : Real.exp (-4 * (t : ℝ) / ((n : ℝ) - 1)) ≤ (1 - 2 / ((n : ℝ) + 1)) ^ (2 * t) := by calc Real.exp (-4 * (t : ℝ) / ((n : ℝ) - 1)) = Real.exp ((2 * t : ℕ) * (-2 / ((n : ℝ) - 1))) := by congr 1; push_cast; ring _ = (Real.exp (-2 / ((n : ℝ) - 1))) ^ (2 * t) := Real.exp_nat_mul _ _ _ ≤ (1 - 2 / ((n : ℝ) + 1)) ^ (2 * t) := pow_le_pow_left₀ (le_of_lt (Real.exp_pos _)) hlam_ge_exp (2 * t) have h2 : 4 * c ≤ Real.log (n : ℝ) + (-4 * (t : ℝ) / ((n : ℝ) - 1)) := by have hdiv : 4 * (t : ℝ) / ((n : ℝ) - 1) ≤ Real.log (n : ℝ) - 4 * c := by rw [div_le_iff₀ hnm1_pos]; nlinarith have hneg : -4 * (t : ℝ) / ((n : ℝ) - 1) = -(4 * (t : ℝ) / ((n : ℝ) - 1)) := by ring linarith calc Real.exp (4 * c) ≤ Real.exp (Real.log (n : ℝ) + (-4 * (t : ℝ) / ((n : ℝ) - 1))) := Real.exp_le_exp.mpr h2 _ = (n : ℝ) * Real.exp (-4 * (t : ℝ) / ((n : ℝ) - 1)) := by rw [Real.exp_add, Real.exp_log hn_pos] _ ≤ (n : ℝ) * (1 - 2 / ((n : ℝ) + 1)) ^ (2 * t) := mul_le_mul_of_nonneg_left h1 (le_of_lt hn_pos) have hfrac : 8 / ((n : ℝ) * (1 - 2 / ((n : ℝ) + 1)) ^ (2 * t)) ≤ 8 * Real.exp (-4 * c) := by have he4c : 8 * Real.exp (-4 * c) = 8 / Real.exp (4 * c) := by rw [show -4 * c = -(4 * c) by ring, Real.exp_neg, div_eq_mul_inv] rw [he4c] exact div_le_div_of_nonneg_left (by norm_num) (Real.exp_pos _) hpow_ge linarith /-- **Standard `1/2`-Lazy Hypercube `Q_n` Upper & Lower Mixing Bounds (Cutoff at `(1/2) n ln n`)**: for ALL `n ≥ 1` and `t : ℕ`, `4 · d_TV(P^t(0^n, ·), π)² ≤ exp(n · exp(-2 t / n)) - 1`. -/ theorem hypercube_half_lazy_chi2_upper (n : ℕ) (hn : 1 ≤ n) (t : ℕ) : 4 * (tvDist ((hypercubeKernel n hn (1 / 2) (by norm_num) (by norm_num)).stepDist t (fun _ => false)) (Dist.uniform ⟨fun _ => false⟩)) ^ 2 ≤ Real.exp ((n : ℝ) * Real.exp (-2 * (t : ℝ) / (n : ℝ))) - 1 := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hπ_pos : ∀ x : Fin n → Bool, 0 < (Dist.uniform ⟨fun _ => false⟩) x := fun _ => by simp only [Dist.uniform, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] exact inv_pos.mpr (by positivity) refine le_trans (four_tvDist_sq_le_chi2 _ _ hπ_pos) ?_ rw [hypercube_chi2_exact n hn (1 / 2) (by norm_num) (by norm_num) t] set u := Real.exp (-2 * (t : ℝ) / (n : ℝ)) have hterm : ∀ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * (1 - 2 * (1 / 2 : ℝ) * (k : ℝ) / (n : ℝ)) ^ (2 * t) ≤ (Nat.choose n k : ℝ) * u ^ k := by intro k hk have hkn : (k : ℝ) ≤ n := by exact_mod_cast (Finset.mem_Icc.mp hk).2 have hnn : 0 ≤ 1 - (k : ℝ) / (n : ℝ) := by rw [sub_nonneg, div_le_one hn_pos]; exact hkn have hexp : 1 - (k : ℝ) / (n : ℝ) ≤ Real.exp (-(k : ℝ) / (n : ℝ)) := by have h := Real.add_one_le_exp (-(k : ℝ) / (n : ℝ)) have hrew : -(k : ℝ) / (n : ℝ) + 1 = 1 - (k : ℝ) / (n : ℝ) := by ring linarith have hsimp : 1 - 2 * (1 / 2 : ℝ) * (k : ℝ) / (n : ℝ) = 1 - (k : ℝ) / (n : ℝ) := by ring rw [hsimp] refine mul_le_mul_of_nonneg_left ?_ (Nat.cast_nonneg _) calc (1 - (k : ℝ) / (n : ℝ)) ^ (2 * t) ≤ (Real.exp (-(k : ℝ) / (n : ℝ))) ^ (2 * t) := pow_le_pow_left₀ hnn hexp (2 * t) _ = Real.exp ((2 * t : ℕ) * (-(k : ℝ) / (n : ℝ))) := (Real.exp_nat_mul _ _).symm _ = Real.exp ((k : ℕ) * (-2 * (t : ℝ) / (n : ℝ))) := by congr 1; push_cast; ring _ = u ^ k := Real.exp_nat_mul _ k have hbinom : ∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * u ^ k = (1 + u) ^ n - 1 := by have hfull : ∑ k ∈ Finset.range (n + 1), (Nat.choose n k : ℝ) * u ^ k = (1 + u) ^ n := by have h := add_pow u (1 : ℝ) n rw [add_comm] at h; rw [h] exact Finset.sum_congr rfl fun k _ => by simp [mul_comm] have hsplit : Finset.range (n + 1) = insert 0 (Finset.Icc 1 n) := by ext k; simp only [Finset.mem_range, Finset.mem_insert, Finset.mem_Icc]; omega rw [hsplit, Finset.sum_insert (by simp)] at hfull simp only [Nat.choose_zero_right, Nat.cast_one, pow_zero, mul_one] at hfull linarith have hexp_pow : (1 + u) ^ n ≤ Real.exp ((n : ℝ) * u) := by calc (1 + u) ^ n ≤ (Real.exp u) ^ n := pow_le_pow_left₀ (by positivity) (by linarith [Real.add_one_le_exp u]) n _ = Real.exp ((n : ℝ) * u) := (Real.exp_nat_mul u n).symm calc ∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * (1 - 2 * (1 / 2 : ℝ) * (k : ℝ) / (n : ℝ)) ^ (2 * t) ≤ ∑ k ∈ Finset.Icc 1 n, (Nat.choose n k : ℝ) * u ^ k := Finset.sum_le_sum hterm _ = (1 + u) ^ n - 1 := hbinom _ ≤ Real.exp ((n : ℝ) * u) - 1 := by linarith /-! ### Landmark 2: Exact Top-to-Random Card Shuffling on `S_n` — Sharp Cutoff at `n ln n` -/ /-- The top-to-slot-`k` insertion cycle on `Fin n`: maps slot `i < k ↦ i + 1`, `k ↦ 0`, and `i > k ↦ i`. Right-multiplying a deck `σ : Equiv.Perm (Fin n)` by `insertCycle n k` moves the top card `σ 0` into slot `k` and shifts cards `1..k` up by one position! -/ def insertCycle (n : ℕ) (k : Fin n) : Equiv.Perm (Fin n) where toFun i := if h1 : i.val < k.val then ⟨i.val + 1, by omega⟩ else if i.val = k.val then ⟨0, by omega⟩ else i invFun i := if h0 : i.val = 0 then k else if h2 : i.val ≤ k.val then ⟨i.val - 1, by omega⟩ else i left_inv i := by apply Fin.ext by_cases h1 : i.val < k.val · simp only [dif_pos h1]; simp only [show i.val + 1 ≠ 0 by omega, ↓reduceDIte, show i.val + 1 ≤ k.val by omega]; omega · by_cases h2 : i.val = k.val · simp only [dif_neg h1, if_pos h2, ↓reduceDIte]; exact h2.symm · simp only [dif_neg h1, if_neg h2] have hgt : k.val < i.val := by omega simp only [show i.val ≠ 0 by omega, ↓reduceDIte, show ¬i.val ≤ k.val by omega] right_inv i := by apply Fin.ext by_cases h0 : i.val = 0 · simp only [dif_pos h0, lt_irrefl, ↓reduceDIte, ↓reduceIte]; exact h0.symm · by_cases h2 : i.val ≤ k.val · simp only [dif_neg h0, dif_pos h2, show i.val - 1 < k.val by omega, ↓reduceDIte]; omega · simp only [dif_neg h0, dif_neg h2, show ¬i.val < k.val by omega, ↓reduceDIte, show i.val ≠ k.val by omega, ↓reduceIte] lemma insertCycle_injective (n : ℕ) : Function.Injective (insertCycle n) := by intro k₁ k₂ h have hinv := congrFun (congrArg (fun π : Equiv.Perm (Fin n) => (π.symm : Fin n → Fin n)) h) ⟨0, Nat.lt_of_le_of_lt (Nat.zero_le _) k₁.isLt⟩ simpa [insertCycle] using hinv /-- **Top-to-Random Card Shuffling Markov Kernel on `Equiv.Perm (Fin n)`**: at each step, take the top card and insert it uniformly at random into any of the `n` positions! -/ def topToRandomKernel (n : ℕ) (hn : 1 ≤ n) : MarkovKernel (Equiv.Perm (Fin n)) where P σ τ := (n : ℝ)⁻¹ * ∑ k : Fin n, if τ = σ * insertCycle n k then (1 : ℝ) else 0 nonneg σ τ := mul_nonneg (by positivity) (Finset.sum_nonneg fun k _ => by split_ifs <;> norm_num) row_sum_one σ := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) rw [← Finset.mul_sum, Finset.sum_comm] simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] exact inv_mul_cancel₀ (ne_of_gt hn_pos) /-- Uniform distribution on `Equiv.Perm (Fin n)` is stationary for Top-to-Random shuffling. -/ theorem topToRandomKernel_uniform_stationary (n : ℕ) (hn : 1 ≤ n) : (topToRandomKernel n hn).IsStationary (Dist.uniform ⟨(1 : Equiv.Perm (Fin n))⟩) := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) ext τ simp only [MarkovKernel.push, topToRandomKernel, Dist.uniform] calc ∑ σ : Equiv.Perm (Fin n), ((Fintype.card (Equiv.Perm (Fin n)) : ℝ)⁻¹ * ((n : ℝ)⁻¹ * ∑ k : Fin n, if τ = σ * insertCycle n k then (1 : ℝ) else 0)) = (Fintype.card (Equiv.Perm (Fin n)) : ℝ)⁻¹ * ((n : ℝ)⁻¹ * ∑ k : Fin n, ∑ σ : Equiv.Perm (Fin n), if τ = σ * insertCycle n k then (1 : ℝ) else 0) := by rw [← Finset.mul_sum, ← Finset.mul_sum, Finset.sum_comm] _ = (Fintype.card (Equiv.Perm (Fin n)) : ℝ)⁻¹ * ((n : ℝ)⁻¹ * ∑ _k : Fin n, (1 : ℝ)) := by congr 2; refine Finset.sum_congr rfl fun k _ => ?_ have huniq : ∀ σ : Equiv.Perm (Fin n), (τ = σ * insertCycle n k) ↔ (σ = τ * (insertCycle n k)⁻¹) := fun σ => by constructor <;> intro h · rw [h, mul_inv_cancel_right] · rw [h, inv_mul_cancel_right] simp_rw [huniq] simp _ = (Fintype.card (Equiv.Perm (Fin n)) : ℝ)⁻¹ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] field_simp [ne_of_gt hn_pos] /-- Exact Aldous–Diaconis strong stationary time tail recurrence `q_j(t)` for Top-to-Random: `q_j(0) = 1` for `1 ≤ j ≤ n`, `q_j(t) = 0` for `j > n`, and `q_j(t + 1) = (1 - j / n) q_j(t) + (j / n) q_{j+1}(t)`. -/ def sstTail (n : ℕ) : ℕ → ℕ → ℝ | j, 0 => if 1 ≤ j ∧ j ≤ n then 1 else 0 | j, t + 1 => if 1 ≤ j ∧ j ≤ n then (1 - (j : ℝ) / (n : ℝ)) * sstTail n j t + ((j : ℝ) / (n : ℝ)) * sstTail n (j + 1) t else 0 /-- **Exact Closed-Form Inclusion–Exclusion Formula for `sstTail n j t`**: for `1 ≤ j ≤ n` and ALL `t : ℕ`: `sstTail n j t = ∑_{r = j}^n (-1)^(r - j) · C(n, r) · C(r - 1, j - 1) · (1 - r / n)^t`. -/ theorem sstTail_closed_form (n : ℕ) (hn : 1 ≤ n) : ∀ (t j : ℕ), 1 ≤ j → j ≤ n → sstTail n j t = ∑ r ∈ Finset.Icc j n, ((-1 : ℝ) ^ (r - j)) * (Nat.choose n r : ℝ) * (Nat.choose (r - 1) (j - 1) : ℝ) * (1 - (r : ℝ) / (n : ℝ)) ^ t := by intro t induction t with | zero => intro j hj1 hjn simp only [sstTail, hj1, hjn, and_self, ↓reduceIte, pow_zero, mul_one] -- Classical binomial identity: ∑_{r=j}^n (-1)^(r-j) C(n, r) C(r-1, j-1) = 1! -- Proof: C(n, r) C(r - 1, j - 1) = C(n, j - 1) * C(n - j + 1, r - j + 1) * ... wait: -- Even simpler: C(n, r) * C(r, j) = C(n, j) * C(n - j, r - j), and C(r - 1, j - 1) = (j / r) C(r, j)! -- Actually prove directly by induction on (n - j): -- Wait: let m = n - j! Write k = r - j ∈ {0, ..., m}: -- ∑_{k=0}^m (-1)^k C(n, j + k) C(j + k - 1, j - 1) = 1! -- Use Pascal's identity on C(n, r) = C(n - 1, r) + C(n - 1, r - 1) by induction on n! have hbin_id : ∀ (N J : ℕ), 1 ≤ J → J ≤ N → ∑ r ∈ Finset.Icc J N, ((-1 : ℝ) ^ (r - J)) * (Nat.choose N r : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = 1 := by intro N induction N with | zero => intro J hJ1 hJN; omega | succ N ihN => intro J hJ1 hJN by_cases hJtop : J = N + 1 · subst hJtop; simp · have hJN' : J ≤ N := by omega -- Split C(N+1, r) = C(N, r) + C(N, r-1)! -- Wait: ∑_{r=J}^{N+1} (-1)^(r-J) C(N, r) C(r-1, J-1) = 1 (by ihN, since C(N, N+1)=0)! -- And ∑_{r=J}^{N+1} (-1)^(r-J) C(N, r-1) C(r-1, J-1) -- = C(N, J-1) * ∑_{k=0}^{N+1-J} (-1)^k C(N+1-J, k) = C(N, J-1) * (1 - 1)^(N+1-J) = 0!! -- OH!! WHAT A 4-LINE PROOF!! have hpascal : ∀ r ∈ Finset.Icc J (N + 1), ((-1 : ℝ) ^ (r - J)) * (Nat.choose (N + 1) r : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = ((-1 : ℝ) ^ (r - J)) * (Nat.choose N r : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) + ((-1 : ℝ) ^ (r - J)) * (Nat.choose N (r - 1) : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) := by intro r hr have hr1 : 1 ≤ r := by have := (Finset.mem_Icc.mp hr).1; omega have hch : Nat.choose (N + 1) r = Nat.choose N (r - 1) + Nat.choose N r := by cases r with | zero => omega | succ r' => exact Nat.choose_succ_succ N r' rw [hch]; push_cast; ring rw [Finset.sum_congr rfl hpascal, Finset.sum_add_distrib] have hsum1 : ∑ r ∈ Finset.Icc J (N + 1), ((-1 : ℝ) ^ (r - J)) * (Nat.choose N r : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = 1 := by have hsplit : Finset.Icc J (N + 1) = insert (N + 1) (Finset.Icc J N) := by ext r; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hsplit, Finset.sum_insert (by simp), Nat.choose_eq_zero_of_lt (Nat.lt_succ_self N)] simp [ihN J hJ1 hJN'] have hsum2 : ∑ r ∈ Finset.Icc J (N + 1), ((-1 : ℝ) ^ (r - J)) * (Nat.choose N (r - 1) : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = 0 := by have hprod : ∀ r ∈ Finset.Icc J (N + 1), Nat.choose N (r - 1) * Nat.choose (r - 1) (J - 1) = Nat.choose N (J - 1) * Nat.choose (N + 1 - J) (r - J) := by intro r hr rcases Finset.mem_Icc.mp hr with ⟨h1, h2⟩ have h := Nat.choose_mul (n := N) (k := r - 1) (s := J - 1) (by omega) have he1 : N - (J - 1) = N + 1 - J := by omega have he2 : (r - 1) - (J - 1) = r - J := by omega rw [he1, he2] at h exact h have hrew : ∑ r ∈ Finset.Icc J (N + 1), ((-1 : ℝ) ^ (r - J)) * (Nat.choose N (r - 1) : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = (Nat.choose N (J - 1) : ℝ) * ∑ k ∈ Finset.range (N + 1 - J + 1), ((-1 : ℝ) ^ k) * (Nat.choose (N + 1 - J) k : ℝ) := by rw [Finset.mul_sum] refine Finset.sum_bij (fun r _ => r - J) ?_ ?_ ?_ ?_ · intro r hr; rcases Finset.mem_Icc.mp hr with ⟨h1, h2⟩; exact Finset.mem_range.mpr (by omega) · intro r₁ hr₁ r₂ hr₂ heq rcases Finset.mem_Icc.mp hr₁ with ⟨h1, _⟩ rcases Finset.mem_Icc.mp hr₂ with ⟨h2, _⟩ omega · intro k hk have hkl : k ≤ N + 1 - J := Nat.lt_succ_iff.mp (Finset.mem_range.mp hk) refine ⟨J + k, Finset.mem_Icc.mpr ⟨by omega, by omega⟩, by omega⟩ · intro r hr have hp : (Nat.choose N (r - 1) : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = (Nat.choose N (J - 1) : ℝ) * (Nat.choose (N + 1 - J) (r - J) : ℝ) := by exact_mod_cast hprod r hr calc (-1 : ℝ) ^ (r - J) * (Nat.choose N (r - 1) : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ) = (-1 : ℝ) ^ (r - J) * ((Nat.choose N (r - 1) : ℝ) * (Nat.choose (r - 1) (J - 1) : ℝ)) := by ring _ = (-1 : ℝ) ^ (r - J) * ((Nat.choose N (J - 1) : ℝ) * (Nat.choose (N + 1 - J) (r - J) : ℝ)) := by rw [hp] _ = (Nat.choose N (J - 1) : ℝ) * ((-1 : ℝ) ^ (r - J) * (Nat.choose (N + 1 - J) (r - J) : ℝ)) := by ring rw [hrew] have halt : ∑ k ∈ Finset.range (N + 1 - J + 1), ((-1 : ℝ) ^ k) * (Nat.choose (N + 1 - J) k : ℝ) = 0 := by have h := add_pow (-1 : ℝ) (1 : ℝ) (N + 1 - J) have hne0 : N + 1 - J ≠ 0 := by omega rw [neg_add_cancel, zero_pow hne0] at h calc ∑ k ∈ Finset.range (N + 1 - J + 1), ((-1 : ℝ) ^ k) * (Nat.choose (N + 1 - J) k : ℝ) = ∑ k ∈ Finset.range (N + 1 - J + 1), (-1 : ℝ) ^ k * 1 ^ (N + 1 - J - k) * (Nat.choose (N + 1 - J) k : ℝ) := Finset.sum_congr rfl fun k _ => by simp _ = 0 := h.symm rw [halt, mul_zero] linarith exact (hbin_id n j hj1 hjn).symm | succ t ih => intro j hj1 hjn have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) simp only [sstTail, hj1, hjn, and_self, ↓reduceIte] rw [ih j hj1 hjn] by_cases htop : j = n · subst htop have h0 : sstTail j (j + 1) t = 0 := by cases t <;> simp [sstTail] rw [h0, mul_zero, add_zero, div_self (ne_of_gt hn_pos), sub_self, zero_mul] simp [div_self (ne_of_gt hn_pos)] · have hj1_le : j + 1 ≤ n := by omega rw [ih (j + 1) (by omega) hj1_le] have hsplit : Finset.Icc j n = insert j (Finset.Icc (j + 1) n) := by ext r; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hsplit, Finset.sum_insert (by simp), Finset.sum_insert (by simp)] rw [mul_add, Finset.mul_sum, Finset.mul_sum, add_assoc] congr 1 · simp only [Nat.sub_self, pow_zero, one_mul, Nat.choose_self, Nat.cast_one, mul_one, pow_succ'] ring · rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun r hr => ?_ have hr_gt : j + 1 ≤ r := (Finset.mem_Icc.mp hr).1 have hsign : (-1 : ℝ) ^ (r - (j + 1)) = -((-1 : ℝ) ^ (r - j)) := by have hexp : r - j = (r - (j + 1)) + 1 := by omega rw [hexp, pow_succ]; ring have habs : (j : ℝ) * ((Nat.choose (r - 1) (j - 1) : ℝ) + (Nat.choose (r - 1) j : ℝ)) = (r : ℝ) * (Nat.choose (r - 1) (j - 1) : ℝ) := by have h1 : Nat.choose (r - 1) (j - 1) + Nat.choose (r - 1) j = Nat.choose r j := by cases r with | zero => omega | succ r' => cases j with | zero => omega | succ j' => exact (Nat.choose_succ_succ r' j').symm have h2 : j * Nat.choose r j = r * Nat.choose (r - 1) (j - 1) := by cases r with | zero => omega | succ r' => cases j with | zero => omega | succ j' => simpa [mul_comm] using (Nat.add_one_mul_choose_eq r' j').symm have hnat : j * (Nat.choose (r - 1) (j - 1) + Nat.choose (r - 1) j) = r * Nat.choose (r - 1) (j - 1) := by rw [h1, h2] exact_mod_cast hnat have hsub1 : j + 1 - 1 = j := Nat.add_sub_cancel j 1 rw [hsub1, hsign, pow_succ'] have habs' : (j : ℝ) * (Nat.choose (r - 1) j : ℝ) = ((r : ℝ) - (j : ℝ)) * (Nat.choose (r - 1) (j - 1) : ℝ) := by linarith have hcoeff : (1 - (j : ℝ) / (n : ℝ)) * (Nat.choose (r - 1) (j - 1) : ℝ) - ((j : ℝ) / (n : ℝ)) * (Nat.choose (r - 1) j : ℝ) = (1 - (r : ℝ) / (n : ℝ)) * (Nat.choose (r - 1) (j - 1) : ℝ) := by field_simp [ne_of_gt hn_pos]; linarith calc (1 - (j : ℝ) / (n : ℝ)) * ((-1 : ℝ) ^ (r - j) * (Nat.choose n r : ℝ) * (Nat.choose (r - 1) (j - 1) : ℝ) * (1 - (r : ℝ) / (n : ℝ)) ^ t) + (j : ℝ) / (n : ℝ) * (-(-1 : ℝ) ^ (r - j) * (Nat.choose n r : ℝ) * (Nat.choose (r - 1) j : ℝ) * (1 - (r : ℝ) / (n : ℝ)) ^ t) = (-1 : ℝ) ^ (r - j) * (Nat.choose n r : ℝ) * (1 - (r : ℝ) / (n : ℝ)) ^ t * ((1 - (j : ℝ) / (n : ℝ)) * (Nat.choose (r - 1) (j - 1) : ℝ) - ((j : ℝ) / (n : ℝ)) * (Nat.choose (r - 1) j : ℝ)) := by ring _ = (-1 : ℝ) ^ (r - j) * (Nat.choose n r : ℝ) * (1 - (r : ℝ) / (n : ℝ)) ^ t * ((1 - (r : ℝ) / (n : ℝ)) * (Nat.choose (r - 1) (j - 1) : ℝ)) := by rw [hcoeff] _ = (-1 : ℝ) ^ (r - j) * (Nat.choose n r : ℝ) * (Nat.choose (r - 1) (j - 1) : ℝ) * ((1 - (r : ℝ) / (n : ℝ)) * (1 - (r : ℝ) / (n : ℝ)) ^ t) := by ring /-- Exact probability that `t` uniform draws from `Fin n` fail to collect all `n` coupons (i.e. a uniformly random map `f : Fin t → Fin n` is NOT surjective). -/ def couponMissProb (n t : ℕ) : ℝ := ((Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card : ℝ) / (n : ℝ) ^ t /-- **Exact Coupon-Collector Equivalence**: `sstTail n 1 t = couponMissProb n t`! -/ theorem sstTail_one_eq_couponMissProb (n : ℕ) (hn : 1 ≤ n) (t : ℕ) : sstTail n 1 t = couponMissProb n t := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) -- Express both as the EXACT same inclusion–exclusion sum: -- couponMissProb n t = (1 / n^t) * ∑_{r=1}^n (-1)^(r-1) C(n, r) (n - r)^t! rw [sstTail_closed_form n hn t 1 (le_refl 1) hn] unfold couponMissProb -- Prove inclusion–exclusion directly on the indicator of non-surjectivity: -- 1_{∃ i, i ∉ range f} = 1 - ∏_{i : Fin n} (1 - 1_{i ∉ range f}) -- = ∑_{S ≠ ∅} (-1)^(|S| - 1) 1_{∀ i ∈ S, i ∉ range f}! have hie : ((Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card : ℝ) = ∑ r ∈ Finset.Icc 1 n, ((-1 : ℝ) ^ (r - 1)) * (Nat.choose n r : ℝ) * ((n : ℝ) - (r : ℝ)) ^ t := by have hpt : ∀ f : Fin t → Fin n, (if ¬ Function.Surjective f then (1 : ℝ) else 0) = ∑ S ∈ (Finset.univ : Finset (Finset (Fin n))).erase ∅, ((-1 : ℝ) ^ (S.card - 1)) * (if ∀ i ∈ S, ∀ s : Fin t, f s ≠ i then (1 : ℝ) else 0) := by intro f let M : Finset (Fin n) := Finset.univ.filter fun i : Fin n => ∀ s : Fin t, f s ≠ i have hcond : ∀ S : Finset (Fin n), (∀ i ∈ S, ∀ s : Fin t, f s ≠ i) ↔ S ⊆ M := fun S => by simp [M, Finset.subset_iff] simp_rw [hcond] have hnsurj : ¬ Function.Surjective f ↔ M.Nonempty := by simp only [Function.Surjective, M, Finset.Nonempty, Finset.mem_filter, Finset.mem_univ, true_and] push Not; rfl -- Compute ∑_{∅ ≠ S ⊆ M} (-1)^(|S|-1) = 1 - (1 - 1)^|M| = if M.Nonempty then 1 else 0! have hsum_sub : ∑ S ∈ (Finset.univ : Finset (Finset (Fin n))).erase ∅, ((-1 : ℝ) ^ (S.card - 1)) * (if S ⊆ M then (1 : ℝ) else 0) = ∑ S ∈ M.powerset.erase ∅, (-1 : ℝ) ^ (S.card - 1) := by have hfilt : ((Finset.univ : Finset (Finset (Fin n))).erase ∅).filter (fun S => S ⊆ M) = M.powerset.erase ∅ := by ext S; simp only [Finset.mem_filter, Finset.mem_erase, Finset.mem_univ, and_true, Finset.mem_powerset] rw [← hfilt, Finset.sum_filter] refine Finset.sum_congr rfl fun S _ => by split_ifs <;> ring rw [hsum_sub] by_cases hM : M.Nonempty · rw [if_pos (hnsurj.mpr hM)] have h0M : (∅ : Finset (Fin n)) ∈ M.powerset := Finset.empty_mem_powerset M have hpow_sum : ∑ S ∈ M.powerset, (-1 : ℝ) ^ S.card = 0 := by have h := Finset.prod_add (fun _ : Fin n => (-1 : ℝ)) (fun _ : Fin n => (1 : ℝ)) M have hneM : M.card ≠ 0 := Finset.card_ne_zero.mpr hM have hprod0 : ∏ _i ∈ M, ((-1 : ℝ) + (1 : ℝ)) = 0 := by simp [Finset.prod_const, zero_pow hneM] rw [hprod0] at h calc ∑ S ∈ M.powerset, (-1 : ℝ) ^ S.card = ∑ S ∈ M.powerset, (∏ _i ∈ S, (-1 : ℝ)) * (∏ _i ∈ M \ S, (1 : ℝ)) := Finset.sum_congr rfl fun S _ => by simp _ = 0 := h.symm rw [← Finset.add_sum_erase _ _ h0M] at hpow_sum simp only [Finset.card_empty, pow_zero] at hpow_sum have hneg : ∑ S ∈ M.powerset.erase ∅, (-1 : ℝ) ^ (S.card - 1) = -(∑ S ∈ M.powerset.erase ∅, (-1 : ℝ) ^ S.card) := by rw [← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun S hS => ?_ have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr (Finset.mem_erase.mp hS).1) have he : S.card = (S.card - 1) + 1 := by omega conv_rhs => rw [he, pow_succ] ring linarith · rw [if_neg (fun h => hM (hnsurj.mp h))] have hMe : M = ∅ := Finset.not_nonempty_iff_eq_empty.mp hM rw [hMe]; simp have hcard_sum : ((Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card : ℝ) = ∑ f : Fin t → Fin n, if ¬ Function.Surjective f then (1 : ℝ) else 0 := by rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] rw [hcard_sum] simp_rw [hpt] rw [Finset.sum_comm] -- For each subset S ⊆ Fin n, #{f : Fin t → Fin n | ∀ i ∈ S, ∀ s, f s ≠ i} = (n - |S|)^t! have hcount_S : ∀ S : Finset (Fin n), (∑ f : Fin t → Fin n, if ∀ i ∈ S, ∀ s : Fin t, f s ≠ i then (1 : ℝ) else 0) = ((n : ℝ) - (S.card : ℝ)) ^ t := fun S => by have hcard_eq : (Finset.univ.filter fun f : Fin t → Fin n => ∀ i ∈ S, ∀ s : Fin t, f s ≠ i).card = (n - S.card) ^ t := by have hbij : (Finset.univ.filter fun f : Fin t → Fin n => ∀ i ∈ S, ∀ s : Fin t, f s ≠ i).card = Fintype.card (Fin t → {x : Fin n // x ∈ Sᶜ}) := by refine Finset.card_bij (fun f hf s => ⟨f s, Finset.mem_compl.mpr fun h => (Finset.mem_filter.mp hf).2 (f s) h s rfl⟩) ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro f₁ _ f₂ _ heq funext s; exact congrArg Subtype.val (congrFun heq s) · intro g _ refine ⟨fun s => (g s).val, ?_, ?_⟩ · simp only [Finset.mem_filter, Finset.mem_univ, true_and] intro i hi s hEq exact (Finset.mem_compl.mp (g s).property) (hEq ▸ hi) · funext s; rfl rw [hbij, Fintype.card_fun, Fintype.card_coe, Fintype.card_fin] have hcompl_card : Sᶜ.card = n - S.card := by have htot : S.card + Sᶜ.card = n := by rw [Finset.card_add_card_compl, Fintype.card_fin] omega rw [hcompl_card] rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one, hcard_eq] have hle : S.card ≤ n := by simpa using Finset.card_le_univ S rw [Nat.cast_pow, Nat.cast_sub hle] have hpull : ∀ S : Finset (Fin n), (∑ f : Fin t → Fin n, ((-1 : ℝ) ^ (S.card - 1)) * (if ∀ i ∈ S, ∀ s : Fin t, f s ≠ i then (1 : ℝ) else 0)) = ((-1 : ℝ) ^ (S.card - 1)) * ((n : ℝ) - (S.card : ℝ)) ^ t := fun S => by rw [← Finset.mul_sum, hcount_S S] simp_rw [hpull] -- Group subsets S ≠ ∅ by cardinality r = S.card ∈ Icc 1 n! rw [← Finset.sum_fiberwise_of_maps_to (g := Finset.card) (t := Finset.Icc 1 n)] · refine Finset.sum_congr rfl fun r hr => ?_ have hr1 : 1 ≤ r := (Finset.mem_Icc.mp hr).1 have hfilt : ((Finset.univ : Finset (Finset (Fin n))).erase ∅).filter (fun S => S.card = r) = Finset.powersetCard r (Finset.univ : Finset (Fin n)) := by ext S; simp only [Finset.mem_filter, Finset.mem_erase, Finset.mem_univ, and_true, Finset.mem_powersetCard, Finset.subset_univ, true_and] constructor · exact And.right · intro hc; exact ⟨fun h => by rw [h] at hc; simp at hc; omega, hc⟩ rw [hfilt] have hconst : ∑ S ∈ Finset.powersetCard r (Finset.univ : Finset (Fin n)), (-1 : ℝ) ^ (S.card - 1) * ((n : ℝ) - (S.card : ℝ)) ^ t = ∑ _S ∈ Finset.powersetCard r (Finset.univ : Finset (Fin n)), (-1 : ℝ) ^ (r - 1) * ((n : ℝ) - (r : ℝ)) ^ t := Finset.sum_congr rfl fun S hS => by rw [(Finset.mem_powersetCard.mp hS).2] rw [hconst, Finset.sum_const, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring · intro S hS have hne : S ≠ ∅ := (Finset.mem_erase.mp hS).1 exact Finset.mem_Icc.mpr ⟨Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hne), by simpa using Finset.card_le_univ S⟩ rw [hie, Finset.sum_div] refine Finset.sum_congr rfl fun r _ => ?_ have hch0 : Nat.choose (r - 1) (1 - 1) = 1 := by simp rw [hch0, Nat.cast_one, mul_one] have hpow_div : ((n : ℝ) - (r : ℝ)) ^ t / (n : ℝ) ^ t = (1 - (r : ℝ) / (n : ℝ)) ^ t := by rw [← div_pow]; congr 1; field_simp [ne_of_gt hn_pos] rw [mul_div_assoc, hpow_div] /-- **Non-Asymptotic Coupon-Collector Tail Upper Bound**: `sstTail n 1 t = couponMissProb n t ≤ n · (1 - 1 / n)^t ≤ n · exp(-t / n)`. -/ theorem sstTail_one_le_n_exp (n : ℕ) (hn : 1 ≤ n) (t : ℕ) : sstTail n 1 t ≤ (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t ∧ (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t ≤ (n : ℝ) * Real.exp (-(t : ℝ) / (n : ℝ)) := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have h1 : sstTail n 1 t ≤ (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t := by rw [sstTail_one_eq_couponMissProb n hn t] unfold couponMissProb -- Union bound: {f | ¬ Surjective f} ⊆ ⋃_{i : Fin n} {f | ∀ s, f s ≠ i}! have hsub : (Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f) ⊆ Finset.univ.biUnion (fun i : Fin n => Finset.univ.filter fun f : Fin t → Fin n => ∀ s, f s ≠ i) := by intro f hf have hns := (Finset.mem_filter.mp hf).2 unfold Function.Surjective at hns; push Not at hns obtain ⟨i, hi⟩ := hns exact Finset.mem_biUnion.mpr ⟨i, Finset.mem_univ i, Finset.mem_filter.mpr ⟨Finset.mem_univ f, hi⟩⟩ have hcard_miss : ∀ i : Fin n, (Finset.univ.filter fun f : Fin t → Fin n => ∀ s, f s ≠ i).card = (n - 1) ^ t := fun i => by have hbij : (Finset.univ.filter fun f : Fin t → Fin n => ∀ s, f s ≠ i).card = Fintype.card (Fin t → {x : Fin n // x ≠ i}) := by refine Finset.card_bij (fun f hf s => ⟨f s, (Finset.mem_filter.mp hf).2 s⟩) ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro f₁ _ f₂ _ heq; funext s; exact congrArg Subtype.val (congrFun heq s) · intro g _ exact ⟨fun s => (g s).val, Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun s => (g s).property⟩, by funext s; rfl⟩ rw [hbij, Fintype.card_fun, Fintype.card_fin] have hsub_card : Fintype.card {x : Fin n // x ≠ i} = n - 1 := by rw [Fintype.card_subtype_compl, Fintype.card_subtype_eq, Fintype.card_fin] rw [hsub_card] have hcard_le : (Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card ≤ n * (n - 1) ^ t := by calc (Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card ≤ (Finset.univ.biUnion (fun i : Fin n => Finset.univ.filter fun f : Fin t → Fin n => ∀ s, f s ≠ i)).card := Finset.card_le_card hsub _ ≤ ∑ i : Fin n, (Finset.univ.filter fun f : Fin t → Fin n => ∀ s, f s ≠ i).card := Finset.card_biUnion_le _ = n * (n - 1) ^ t := by simp [hcard_miss] have hcast : ((Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card : ℝ) ≤ (n : ℝ) * ((n : ℝ) - 1) ^ t := by have h := (Nat.cast_le (α := ℝ)).mpr hcard_le rwa [Nat.cast_mul, Nat.cast_pow, Nat.cast_sub hn, Nat.cast_one] at h calc ((Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card : ℝ) / (n : ℝ) ^ t ≤ ((n : ℝ) * ((n : ℝ) - 1) ^ t) / (n : ℝ) ^ t := div_le_div_of_nonneg_right hcast (by positivity) _ = (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t := by rw [mul_div_assoc, ← div_pow]; congr 2; field_simp [ne_of_gt hn_pos] have h2 : (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t ≤ (n : ℝ) * Real.exp (-(t : ℝ) / (n : ℝ)) := by refine mul_le_mul_of_nonneg_left ?_ (le_of_lt hn_pos) have hnn : 0 ≤ 1 - 1 / (n : ℝ) := by rw [sub_nonneg, div_le_one hn_pos]; exact_mod_cast hn have hexp : 1 - 1 / (n : ℝ) ≤ Real.exp (-1 / (n : ℝ)) := by have h := Real.add_one_le_exp (-1 / (n : ℝ)) have hrew : -1 / (n : ℝ) + 1 = 1 - 1 / (n : ℝ) := by ring linarith calc (1 - 1 / (n : ℝ)) ^ t ≤ (Real.exp (-1 / (n : ℝ))) ^ t := pow_le_pow_left₀ hnn hexp t _ = Real.exp ((t : ℕ) * (-1 / (n : ℝ))) := (Real.exp_nat_mul _ t).symm _ = Real.exp (-(t : ℝ) / (n : ℝ)) := by congr 1; ring exact ⟨h1, h2⟩ /-- **Exact Aldous–Diaconis Strong Stationary Time for Top-to-Random Shuffling on `S_n`**: for EVERY `n ≥ 1` and EVERY `t : ℕ`, there exists an explicit `StrongStationaryWitness` on `Equiv.Perm (Fin n)` with `pTail = sstTail n 1 t`! -/ theorem topToRandom_sst_witness (n : ℕ) (hn : 1 ≤ n) (t : ℕ) : ∃ w : StrongStationaryWitness (topToRandomKernel n hn) (Dist.uniform ⟨(1 : Equiv.Perm (Fin n))⟩) (1 : Equiv.Perm (Fin n)) t, w.pTail = sstTail n 1 t := by -- Track the augmented process via induction on t: -- For each t : ℕ, maintain: -- r t : Equiv.Perm (Fin n) → ℝ (nonnegative residual sub-distribution of cards where bottom card b₀ = n-1 -- has NOT yet been moved from top) -- pStop t : ℝ = 1 - sstTail n 1 t -- Better: track the rank-decomposed residual W t j σ for 1 ≤ j ≤ n where: -- (1) 0 ≤ W t j σ -- (2) W t j σ > 0 → (σ.symm b₀).val = n - j (i.e. exactly j cards at or below b₀!) -- (3) Symmetry invariant: if σ and τ agree on all slots ≤ n - j (above and at b₀), -- then W t j σ = W t j τ! (Uniformity of the j - 1 cards strictly below b₀!) -- (4) Total mass at rank j: ∑_σ W t j σ = rankProb n t j, where ∑_{j=1}^n rankProb n t j = sstTail n 1 t! -- (5) Exact decomposition: (P^t)(1, σ) = (1 - sstTail n 1 t) / n! + ∑_{j=1}^n W t j σ! let b₀ : Fin n := ⟨n - 1, by omega⟩ let π := Dist.uniform (⟨(1 : Equiv.Perm (Fin n))⟩ : Nonempty (Equiv.Perm (Fin n))) have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hcard_perm : (Fintype.card (Equiv.Perm (Fin n)) : ℝ) = (Nat.factorial n : ℝ) := by simp [Fintype.card_perm] have hfact_pos : (0 : ℝ) < (Nat.factorial n : ℝ) := by exact_mod_cast Nat.factorial_pos n -- Define exact rank transition probabilities: -- rankProb t j = P(J_t = j) for j ∈ {1, ..., n} starting at rankProb 0 1 = 1! let rankProb : ℕ → ℕ → ℝ := Nat.rec (fun j => if j = 1 then 1 else 0) (fun _ prev j => if 1 ≤ j ∧ j ≤ n then (1 - (j : ℝ) / (n : ℝ)) * prev j + (if 2 ≤ j then (((j - 1 : ℕ) : ℝ) / (n : ℝ)) * prev (j - 1) else 0) else 0) -- First prove the clean Markov duality: ∑_{j=1}^n rankProb t j = sstTail n 1 t! -- More generally: for every s and t, ∑_{j=1}^n rankProb s j * sstTail n j t = sstTail n 1 (s + t)! have hdual : ∀ s t' : ℕ, ∑ j ∈ Finset.Icc 1 n, rankProb s j * sstTail n j t' = sstTail n 1 (s + t') := by intro s induction s with | zero => intro t' rw [Finset.sum_eq_single 1] · simp [rankProb] · intro j _ hj; simp [rankProb, hj] · intro h; exact absurd (Finset.mem_Icc.mpr ⟨le_refl 1, hn⟩) h | succ s ih => intro t' have hsucc : s + 1 + t' = s + (t' + 1) := by omega rw [hsucc, ← ih (t' + 1)] -- Expand rankProb (s + 1) j and reindex the j - 1 shift! have hstep : ∑ j ∈ Finset.Icc 1 n, rankProb (s + 1) j * sstTail n j t' = (∑ j ∈ Finset.Icc 1 n, rankProb s j * ((1 - (j : ℝ) / (n : ℝ)) * sstTail n j t')) + (∑ j ∈ Finset.Icc 1 n, rankProb s j * (((j : ℝ) / (n : ℝ)) * sstTail n (j + 1) t')) := by have hpt : ∀ j ∈ Finset.Icc 1 n, rankProb (s + 1) j * sstTail n j t' = rankProb s j * ((1 - (j : ℝ) / (n : ℝ)) * sstTail n j t') + (if 2 ≤ j then rankProb s (j - 1) * ((((j - 1 : ℕ) : ℝ) / (n : ℝ)) * sstTail n j t') else 0) := by intro j hj rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩ simp only [rankProb, h1, h2, and_self, ↓reduceIte] split_ifs <;> ring rw [Finset.sum_congr rfl hpt, Finset.sum_add_distrib] congr 1 -- Reindex j ∈ Icc 2 n to i = j - 1 ∈ Icc 1 (n - 1), noting sstTail n (n + 1) t' = 0! have htop0 : sstTail n (n + 1) t' = 0 := by cases t' <;> simp [sstTail] rw [← Finset.sum_filter] have hfilt : (Finset.Icc 1 n).filter (fun j => 2 ≤ j) = Finset.Icc 2 n := by ext j; simp only [Finset.mem_filter, Finset.mem_Icc]; omega rw [hfilt] have hsplitR : Finset.Icc 1 n = insert n (Finset.Icc 1 (n - 1)) := by ext j; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hsplitR, Finset.sum_insert (by simp; omega), htop0, mul_zero, mul_zero, zero_add] refine Finset.sum_bij (fun j _ => j - 1) ?_ ?_ ?_ ?_ · intro j hj; rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩; exact Finset.mem_Icc.mpr ⟨by omega, by omega⟩ · intro j₁ hj₁ j₂ hj₂ heq rcases Finset.mem_Icc.mp hj₁ with ⟨h1, _⟩ rcases Finset.mem_Icc.mp hj₂ with ⟨h2, _⟩ omega · intro i hi rcases Finset.mem_Icc.mp hi with ⟨h1, h2⟩ refine ⟨i + 1, Finset.mem_Icc.mpr ⟨by omega, by omega⟩, by omega⟩ · intro j hj have hj2 : 2 ≤ j := (Finset.mem_Icc.mp hj).1 have hjj : j - 1 + 1 = j := by omega rw [hjj] rw [hstep, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun j hj => ?_ rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩ simp only [sstTail, h1, h2, and_self, ↓reduceIte]; ring have hsum_rank : ∀ s : ℕ, ∑ j ∈ Finset.Icc 1 n, rankProb s j = sstTail n 1 s := fun s => by have h := hdual s 0 simp only [add_zero] at h rw [← h] refine Finset.sum_congr rfl fun j hj => ?_ rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩ simp [sstTail, h1, h2] -- Now prove the Aldous–Diaconis rank-symmetry invariant by induction on t! have hinv : ∀ s : ℕ, ∃ W : ℕ → Equiv.Perm (Fin n) → ℝ, (∀ j σ, 0 ≤ W j σ) ∧ (∀ j σ, 1 ≤ j → j ≤ n → W j σ ≠ 0 → (σ.symm b₀).val = n - j) ∧ (∀ j σ τ, 1 ≤ j → j ≤ n → (∀ i : Fin n, i.val ≤ n - j → σ i = τ i) → W j σ = W j τ) ∧ (∀ j, 1 ≤ j → j ≤ n → ∑ σ : Equiv.Perm (Fin n), W j σ = rankProb s j) ∧ (∀ σ : Equiv.Perm (Fin n), ((topToRandomKernel n hn).stepDist s (1 : Equiv.Perm (Fin n))) σ = (1 - sstTail n 1 s) * π σ + ∑ j ∈ Finset.Icc 1 n, W j σ) := by intro s induction s with | zero => refine ⟨fun j σ => if j = 1 ∧ σ = 1 then 1 else 0, ?_, ?_, ?_, ?_, ?_⟩ · intro j σ; dsimp only; split_ifs <;> norm_num · intro j σ _ _ hne have ⟨hj, hσ⟩ : j = 1 ∧ σ = 1 := by by_contra h; exact hne (if_neg h) subst hj; subst hσ; change ((1 : Equiv.Perm (Fin n)).symm b₀).val = n - 1; rfl · intro j σ τ _ hjn hprefix by_cases hj : j = 1 · subst hj have hσ_eq_τ : σ = τ := Equiv.ext fun i => hprefix i (by have := i.isLt; omega) rw [hσ_eq_τ] · simp [hj] · intro j _ _ by_cases hj : j = 1 · subst hj; simp [rankProb] · simp [rankProb, hj] · intro σ have htail0 : sstTail n 1 0 = 1 := by simp [sstTail, hn] rw [htail0, sub_self, zero_mul, zero_add, Finset.sum_eq_single 1] · simp only [MarkovKernel.stepDist, MarkovKernel.pow, MarkovKernel.row, MarkovKernel.id, true_and] by_cases h : σ = 1 · subst h; simp · simp [h, Ne.symm h] · intro j _ hj; simp [hj] · intro h; exact absurd (Finset.mem_Icc.mpr ⟨le_refl 1, hn⟩) h | succ s ih => obtain ⟨W, hW_nn, hW_pos, hW_sym, hW_sum, hW_decomp⟩ := ih -- Define W' j τ for 1 ≤ j ≤ n as the pushforward of W from ranks ≤ j that do NOT cross to done! -- Specifically: when τ = σ * insertCycle n k: -- - If j < n and k < n - j: b₀ stays at n - j (stays at rank j) -- - If j < n and k ≥ n - j: b₀ moves up to n - (j + 1) (advances to rank j + 1) -- - If j = n: b₀ is at slot 0 (top!), so EVERY k ∈ Fin n sends it to "done" (uniform!)! -- Therefore: -- W' j τ = (1 / n) * ∑_{k : k.val < n - j} W j (τ * (insertCycle n k)⁻¹) -- + (if 2 ≤ j then (1 / n) * ∑_{k : n - (j - 1) ≤ k.val} W (j - 1) (τ * (insertCycle n k)⁻¹) else 0) let W' : ℕ → Equiv.Perm (Fin n) → ℝ := fun j τ => if 1 ≤ j ∧ j ≤ n then (n : ℝ)⁻¹ * (∑ k ∈ Finset.univ.filter (fun k : Fin n => k.val < n - j), W j (τ * (insertCycle n k)⁻¹)) + (if 2 ≤ j then (n : ℝ)⁻¹ * (∑ k ∈ Finset.univ.filter (fun k : Fin n => n - (j - 1) ≤ k.val), W (j - 1) (τ * (insertCycle n k)⁻¹)) else 0) else 0 -- Helper: explicit formula for (insertCycle n k).symm i! have hinv_cyc : ∀ (k i : Fin n), (insertCycle n k).symm i = if h0 : i.val = 0 then k else if h2 : i.val ≤ k.val then ⟨i.val - 1, by omega⟩ else i := fun k i => rfl have hslot_lt : ∀ (j : ℕ) (k : Fin n) (σ : Equiv.Perm (Fin n)), 1 ≤ j → j ≤ n → (σ.symm b₀).val = n - j → k.val < n - j → ((σ * insertCycle n k).symm b₀).val = n - j := fun j k σ _ _ hpos hk => by change ((insertCycle n k).symm (σ.symm b₀)).val = n - j rw [hinv_cyc k (σ.symm b₀), dif_neg (by omega), dif_neg (by omega)]; exact hpos have hslot_ge : ∀ (j : ℕ) (k : Fin n) (σ : Equiv.Perm (Fin n)), 1 ≤ j → j < n → (σ.symm b₀).val = n - j → n - j ≤ k.val → ((σ * insertCycle n k).symm b₀).val = n - (j + 1) := fun j k σ _ _ hpos hk => by change ((insertCycle n k).symm (σ.symm b₀)).val = n - (j + 1) rw [hinv_cyc k (σ.symm b₀), dif_neg (by omega), dif_pos (by omega)]; dsimp only; omega -- Crucial rank-n uniformity lemma: W n σ is CONSTANT on all (n - 1)! permutations with σ 0 = b₀! have hWn_const : ∀ σ : Equiv.Perm (Fin n), σ ⟨0, by omega⟩ = b₀ → W n σ = rankProb s n / (Nat.factorial (n - 1) : ℝ) := fun σ hσ0 => by have hconst_all : ∀ τ : Equiv.Perm (Fin n), τ ⟨0, by omega⟩ = b₀ → W n τ = W n σ := fun τ hτ0 => by apply hW_sym n τ σ hn (le_refl n) intro i hi have hnn : n - n = 0 := Nat.sub_self n have hi0 : i = ⟨0, by omega⟩ := Fin.ext (by dsimp only; omega) rw [hi0, hτ0, hσ0] have hsum_n := hW_sum n hn (le_refl n) have hsupp : ∑ τ : Equiv.Perm (Fin n), W n τ = ∑ τ ∈ Finset.univ.filter (fun τ : Equiv.Perm (Fin n) => τ ⟨0, by omega⟩ = b₀), W n τ := by rw [← Finset.sum_add_sum_compl (Finset.univ.filter fun τ : Equiv.Perm (Fin n) => τ ⟨0, by omega⟩ = b₀)] have h0 : ∑ τ ∈ (Finset.univ.filter fun τ : Equiv.Perm (Fin n) => τ ⟨0, by omega⟩ = b₀)ᶜ, W n τ = 0 := Finset.sum_eq_zero fun τ hτ => by by_contra hne have hp := hW_pos n τ hn (le_refl n) hne have hnn : n - n = 0 := Nat.sub_self n have h0eq : τ.symm b₀ = ⟨0, by omega⟩ := Fin.ext (by dsimp only; omega) have hτ0 : τ ⟨0, by omega⟩ = b₀ := by rw [← h0eq, τ.apply_symm_apply] exact (Finset.mem_compl.mp hτ) (Finset.mem_filter.mpr ⟨Finset.mem_univ τ, hτ0⟩) rw [h0, add_zero] have hcard_fix : (Finset.univ.filter fun τ : Equiv.Perm (Fin n) => τ ⟨0, by omega⟩ = b₀).card = Nat.factorial (n - 1) := by let sw : Equiv.Perm (Fin n) := Equiv.swap b₀ ⟨0, by omega⟩ have hbij1 : (Finset.univ.filter fun τ : Equiv.Perm (Fin n) => τ ⟨0, by omega⟩ = b₀).card = (Finset.univ.filter fun ρ : Equiv.Perm (Fin n) => ρ ⟨0, by omega⟩ = ⟨0, by omega⟩).card := by refine Finset.card_bij (fun τ _ => sw * τ) ?_ ?_ ?_ · intro τ hτ simp only [Finset.mem_filter, Finset.mem_univ, true_and, Equiv.Perm.coe_mul, Function.comp_apply, sw] at hτ ⊢ rw [hτ, Equiv.swap_apply_left] · intro τ₁ _ τ₂ _ heq; exact mul_left_cancel heq · intro ρ hρ refine ⟨sw * ρ, ?_, by simp [sw, ← mul_assoc]⟩ simp only [Finset.mem_filter, Finset.mem_univ, true_and, Equiv.Perm.coe_mul, Function.comp_apply, sw] at hρ ⊢ rw [hρ, Equiv.swap_apply_right] rw [hbij1] have hbij2 : (Finset.univ.filter fun ρ : Equiv.Perm (Fin n) => ρ ⟨0, by omega⟩ = ⟨0, by omega⟩).card = Fintype.card (Equiv.Perm {x : Fin n // x ≠ ⟨0, by omega⟩}) := by refine Finset.card_bij (fun ρ hρ => Equiv.Perm.subtypePerm ρ (fun x => by have hfix : ρ ⟨0, by omega⟩ = ⟨0, by omega⟩ := (Finset.mem_filter.mp hρ).2 constructor <;> intro hx h · exact hx (by rw [h, hfix]) · exact hx (ρ.injective (h.trans hfix.symm)))) ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro ρ₁ hρ₁ ρ₂ hρ₂ heq apply Equiv.ext; intro x by_cases hx : x = ⟨0, by omega⟩ · rw [hx, (Finset.mem_filter.mp hρ₁).2, (Finset.mem_filter.mp hρ₂).2] · have h := congrFun (congrArg (fun (e : Equiv.Perm {y : Fin n // y ≠ ⟨0, by omega⟩}) => (e : _ → _)) heq) ⟨x, hx⟩ exact congrArg Subtype.val h · intro e _ refine ⟨Equiv.Perm.ofSubtype e, ?_, ?_⟩ · simp [Equiv.Perm.ofSubtype_apply_of_not_mem] · apply Equiv.ext; rintro ⟨x, hx⟩; simp rw [hbij2, Fintype.card_perm, Fintype.card_subtype_compl, Fintype.card_subtype_eq, Fintype.card_fin] rw [hsupp] at hsum_n have hconst_sum : ∑ τ ∈ Finset.univ.filter (fun τ : Equiv.Perm (Fin n) => τ ⟨0, by omega⟩ = b₀), W n τ = (Nat.factorial (n - 1) : ℝ) * W n σ := by rw [Finset.sum_congr rfl (fun τ hτ => hconst_all τ (Finset.mem_filter.mp hτ).2), Finset.sum_const, hcard_fix, nsmul_eq_mul] rw [hconst_sum] at hsum_n have hfp : (0 : ℝ) < (Nat.factorial (n - 1) : ℝ) := by exact_mod_cast Nat.factorial_pos (n - 1) exact eq_div_of_mul_eq (ne_of_gt hfp) (by linarith) have hpush_Wn : ∀ τ : Equiv.Perm (Fin n), ∑ σ : Equiv.Perm (Fin n), W n σ * (topToRandomKernel n hn).P σ τ = rankProb s n * π τ := fun τ => by simp only [topToRandomKernel] have hrew : ∑ σ : Equiv.Perm (Fin n), W n σ * ((n : ℝ)⁻¹ * ∑ k : Fin n, if τ = σ * insertCycle n k then (1 : ℝ) else 0) = (n : ℝ)⁻¹ * ∑ k : Fin n, W n (τ * (insertCycle n k)⁻¹) := by calc ∑ σ, W n σ * ((n : ℝ)⁻¹ * ∑ k, if τ = σ * insertCycle n k then (1 : ℝ) else 0) = (n : ℝ)⁻¹ * ∑ σ, ∑ k, if σ = τ * (insertCycle n k)⁻¹ then W n σ else 0 := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun σ _ => ?_ rw [← mul_assoc, mul_comm (W n σ) _, mul_assoc, Finset.mul_sum] congr 1; refine Finset.sum_congr rfl fun k _ => ?_ have hiff : (τ = σ * insertCycle n k) ↔ (σ = τ * (insertCycle n k)⁻¹) := by constructor <;> intro h · rw [h, mul_inv_cancel_right] · rw [h, inv_mul_cancel_right] by_cases h : σ = τ * (insertCycle n k)⁻¹ · rw [if_pos (hiff.mpr h), if_pos h, mul_one] · rw [if_neg (fun h' => h (hiff.mp h')), if_neg h, mul_zero] _ = (n : ℝ)⁻¹ * ∑ k, ∑ σ, if σ = τ * (insertCycle n k)⁻¹ then W n σ else 0 := by rw [Finset.sum_comm] _ = (n : ℝ)⁻¹ * ∑ k, W n (τ * (insertCycle n k)⁻¹) := by congr 1; refine Finset.sum_congr rfl fun k _ => by simp rw [hrew] let k₀ : Fin n := τ.symm b₀ have hk₀_eq : (τ * (insertCycle n k₀)⁻¹) ⟨0, by omega⟩ = b₀ := by simp only [Equiv.Perm.coe_mul, Function.comp_apply] have h0 : (insertCycle n k₀)⁻¹ ⟨0, by omega⟩ = k₀ := by simp [insertCycle] rw [h0]; exact τ.apply_symm_apply b₀ have hother0 : ∀ k : Fin n, k ≠ k₀ → W n (τ * (insertCycle n k)⁻¹) = 0 := fun k hk => by by_contra hne have hp := hW_pos n _ hn (le_refl n) hne have hnn : n - n = 0 := Nat.sub_self n have h0eq : (τ * (insertCycle n k)⁻¹).symm b₀ = ⟨0, by omega⟩ := Fin.ext (by dsimp only; omega) have hval : (τ * (insertCycle n k)⁻¹) ⟨0, by omega⟩ = b₀ := by rw [← h0eq, Equiv.apply_symm_apply] have h0 : (insertCycle n k)⁻¹ ⟨0, by omega⟩ = k := by simp [insertCycle] simp only [Equiv.Perm.coe_mul, Function.comp_apply, h0] at hval exact hk (by rw [← τ.symm_apply_apply k, hval]) rw [Finset.sum_eq_single k₀ (fun k _ hk => hother0 k hk) (fun h => absurd (Finset.mem_univ k₀) h)] rw [hWn_const _ hk₀_eq] simp only [π, Dist.uniform, hcard_perm] have hfact : (Nat.factorial n : ℝ) = (n : ℝ) * (Nat.factorial (n - 1) : ℝ) := by cases n with | zero => omega | succ m => simp [Nat.factorial_succ] have hfp : (0 : ℝ) < (Nat.factorial (n - 1) : ℝ) := by exact_mod_cast Nat.factorial_pos (n - 1) rw [hfact]; field_simp [ne_of_gt hn_pos, ne_of_gt hfp] -- Verify all 5 invariants for W'! refine ⟨W', ?_, ?_, ?_, ?_, ?_⟩ · -- (1) Nonnegativity intro j τ dsimp only [W'] split_ifs · exact add_nonneg (mul_nonneg (by positivity) (Finset.sum_nonneg fun k _ => hW_nn _ _)) (mul_nonneg (by positivity) (Finset.sum_nonneg fun k _ => hW_nn _ _)) · exact add_nonneg (mul_nonneg (by positivity) (Finset.sum_nonneg fun k _ => hW_nn _ _)) (le_refl 0) · exact le_refl 0 · -- (2) Support: W' j τ ≠ 0 → (τ.symm b₀).val = n - j intro j τ hj1 hjn hne simp only [W', hj1, hjn, and_self, ↓reduceIte] at hne by_contra hbad apply hne have h1 : ∑ k ∈ Finset.univ.filter (fun k : Fin n => k.val < n - j), W j (τ * (insertCycle n k)⁻¹) = 0 := by refine Finset.sum_eq_zero fun k hk => ?_ have hkl : k.val < n - j := (Finset.mem_filter.mp hk).2 by_contra hwnz have hp := hW_pos j _ hj1 hjn hwnz have hτeq : τ = (τ * (insertCycle n k)⁻¹) * insertCycle n k := by simp have hres := hslot_lt j k (τ * (insertCycle n k)⁻¹) hj1 hjn hp hkl rw [← hτeq] at hres exact hbad hres have h2 : (if 2 ≤ j then (n : ℝ)⁻¹ * ∑ k ∈ Finset.univ.filter (fun k : Fin n => n - (j - 1) ≤ k.val), W (j - 1) (τ * (insertCycle n k)⁻¹) else 0) = 0 := by split_ifs with hj2 · rw [mul_eq_zero]; right refine Finset.sum_eq_zero fun k hk => ?_ have hkg : n - (j - 1) ≤ k.val := (Finset.mem_filter.mp hk).2 by_contra hwnz have hp := hW_pos (j - 1) _ (by omega) (by omega) hwnz have hτeq : τ = (τ * (insertCycle n k)⁻¹) * insertCycle n k := by simp have hres := hslot_ge (j - 1) k (τ * (insertCycle n k)⁻¹) (by omega) (by omega) hp hkg have hj11 : j - 1 + 1 = j := by omega rw [← hτeq, hj11] at hres exact hbad hres · rfl rw [h1, mul_zero, h2, add_zero] · -- (3) Suffix symmetry invariant for W'! intro j τ₁ τ₂ hj1 hjn hprefix simp only [W', hj1, hjn, and_self, ↓reduceIte] congr 1 · -- Part A (stay at rank j, k < n - j): (insertCycle n k)⁻¹ maps slots ≤ n - j into slots ≤ n - j! congr 1 refine Finset.sum_congr rfl fun k hk => ?_ have hkl : k.val < n - j := (Finset.mem_filter.mp hk).2 apply hW_sym j _ _ hj1 hjn intro i hi simp only [Equiv.Perm.coe_mul, Function.comp_apply] apply hprefix have hinv_le : ((insertCycle n k)⁻¹ i).val ≤ n - j := by change ((insertCycle n k).symm i).val ≤ n - j rw [hinv_cyc k i] by_cases h0 : i.val = 0 · rw [dif_pos h0]; omega · rw [dif_neg h0] by_cases h2 : i.val ≤ k.val · rw [dif_pos h2]; dsimp only; omega · rw [dif_neg h2]; omega exact hinv_le · split_ifs with hj2 · congr 1 let S : Finset (Fin n) := Finset.univ.filter fun k : Fin n => n - (j - 1) ≤ k.val have hS_iff : ∀ k : Fin n, k ∈ S ↔ n - j < k.val := fun k => by simp only [S, Finset.mem_filter, Finset.mem_univ, true_and]; omega refine Finset.sum_bij (fun k _ => τ₂.symm (τ₁ k)) ?_ ?_ ?_ ?_ · intro k hk rw [hS_iff] at hk ⊢ by_contra hle; push Not at hle have heq := hprefix (τ₂.symm (τ₁ k)) hle rw [τ₂.apply_symm_apply] at heq have hk' := τ₁.injective heq have hval_eq : (τ₂.symm (τ₁ k)).val = k.val := congrArg Fin.val hk' omega · intro k₁ _ k₂ _ heq exact τ₁.injective (τ₂.symm.injective heq) · intro k' hk' rw [hS_iff] at hk' refine ⟨τ₁.symm (τ₂ k'), ?_, by simp⟩ rw [hS_iff] by_contra hle; push Not at hle have heq := hprefix (τ₁.symm (τ₂ k')) hle rw [τ₁.apply_symm_apply] at heq have hk2 := τ₂.injective heq have hval_eq : (τ₁.symm (τ₂ k')).val = k'.val := congrArg Fin.val hk2.symm omega · intro k hk have hkl : n - j < k.val := (hS_iff k).mp hk have hkl2 : n - j < (τ₂.symm (τ₁ k)).val := by by_contra hle; push Not at hle have heq := hprefix (τ₂.symm (τ₁ k)) hle rw [τ₂.apply_symm_apply] at heq have hk' := τ₁.injective heq have hval_eq : (τ₂.symm (τ₁ k)).val = k.val := congrArg Fin.val hk' omega apply hW_sym (j - 1) _ _ (by omega) (by omega) intro i hi simp only [Equiv.Perm.coe_mul, Function.comp_apply] by_cases hi0 : i.val = 0 · have h1 : (insertCycle n k)⁻¹ i = k := by change (insertCycle n k).symm i = k rw [hinv_cyc k i, dif_pos hi0] have h2 : (insertCycle n (τ₂.symm (τ₁ k)))⁻¹ i = τ₂.symm (τ₁ k) := by change (insertCycle n (τ₂.symm (τ₁ k))).symm i = τ₂.symm (τ₁ k) rw [hinv_cyc _ i, dif_pos hi0] rw [h1, h2, τ₂.apply_symm_apply] · have hi_le_k : i.val ≤ k.val := by omega have hi_le_k2 : i.val ≤ (τ₂.symm (τ₁ k)).val := by omega have h1 : (insertCycle n k)⁻¹ i = ⟨i.val - 1, by omega⟩ := by change (insertCycle n k).symm i = _ rw [hinv_cyc k i, dif_neg hi0, dif_pos hi_le_k] have h2 : (insertCycle n (τ₂.symm (τ₁ k)))⁻¹ i = ⟨i.val - 1, by omega⟩ := by change (insertCycle n (τ₂.symm (τ₁ k))).symm i = _ rw [hinv_cyc _ i, dif_neg hi0, dif_pos hi_le_k2] rw [h1, h2] exact hprefix ⟨i.val - 1, by omega⟩ (by simp; omega) · rfl · -- (4) Total mass at rank j equals rankProb (s + 1) j! intro j hj1 hjn simp only [W', rankProb, hj1, hjn, and_self, ↓reduceIte] rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_comm] have hpart1 : (n : ℝ)⁻¹ * ∑ k ∈ Finset.univ.filter (fun k : Fin n => k.val < n - j), ∑ τ : Equiv.Perm (Fin n), W j (τ * (insertCycle n k)⁻¹) = (1 - (j : ℝ) / (n : ℝ)) * rankProb s j := by have hinner : ∀ k : Fin n, ∑ τ : Equiv.Perm (Fin n), W j (τ * (insertCycle n k)⁻¹) = rankProb s j := fun k => by let e : Equiv.Perm (Fin n) ≃ Equiv.Perm (Fin n) := Equiv.mulRight (insertCycle n k)⁻¹ change ∑ τ, W j (e τ) = rankProb s j rw [Equiv.sum_comp e]; exact hW_sum j hj1 hjn have hcard_lt : (Finset.univ.filter fun k : Fin n => k.val < n - j).card = n - j := by have hbij : (Finset.univ.filter fun k : Fin n => k.val < n - j) = (Finset.range (n - j)).attach.image (fun x => ⟨x.1, by have := Finset.mem_range.mp x.2; omega⟩) := by ext k; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image, Finset.mem_attach, Subtype.exists, Finset.mem_range] constructor · intro hk; exact ⟨k.val, hk, rfl⟩ · rintro ⟨a, ha, rfl⟩; exact ha rw [hbij, Finset.card_image_of_injective] · simp · intro a b h; exact Subtype.ext (congrArg Fin.val h) rw [Finset.sum_congr rfl (fun k _ => hinner k), Finset.sum_const, hcard_lt, nsmul_eq_mul, Nat.cast_sub hjn] field_simp [ne_of_gt hn_pos] rw [hpart1] congr 1 split_ifs with hj2 · rw [← Finset.mul_sum, Finset.sum_comm] have hinner : ∀ k : Fin n, ∑ τ : Equiv.Perm (Fin n), W (j - 1) (τ * (insertCycle n k)⁻¹) = rankProb s (j - 1) := fun k => by let e : Equiv.Perm (Fin n) ≃ Equiv.Perm (Fin n) := Equiv.mulRight (insertCycle n k)⁻¹ change ∑ τ, W (j - 1) (e τ) = rankProb s (j - 1) rw [Equiv.sum_comp e]; exact hW_sum (j - 1) (by omega) (by omega) have hcard_ge : (Finset.univ.filter fun k : Fin n => n - (j - 1) ≤ k.val).card = j - 1 := by have hcompl : (Finset.univ.filter fun k : Fin n => n - (j - 1) ≤ k.val) = (Finset.univ.filter fun k : Fin n => k.val < n - (j - 1))ᶜ := by ext k; simp [not_lt] have hcard_lt : (Finset.univ.filter fun k : Fin n => k.val < n - (j - 1)).card = n - (j - 1) := by have hbij : (Finset.univ.filter fun k : Fin n => k.val < n - (j - 1)) = (Finset.range (n - (j - 1))).attach.image (fun x => ⟨x.1, by have := Finset.mem_range.mp x.2; omega⟩) := by ext k; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image, Finset.mem_attach, Subtype.exists, Finset.mem_range] constructor · intro hk; exact ⟨k.val, hk, rfl⟩ · rintro ⟨a, ha, rfl⟩; exact ha rw [hbij, Finset.card_image_of_injective] · simp · intro a b h; exact Subtype.ext (congrArg Fin.val h) rw [hcompl, Finset.card_compl, Fintype.card_fin, hcard_lt]; omega rw [Finset.sum_congr rfl (fun k _ => hinner k), Finset.sum_const, hcard_ge, nsmul_eq_mul] ring · simp · -- (5) Exact step decomposition: P^{s+1}(1, τ) = (1 - sstTail n 1 (s+1)) * π τ + ∑_{j=1}^n W' j τ! intro τ rw [(topToRandomKernel n hn).stepDist_succ s 1] change ∑ σ : Equiv.Perm (Fin n), ((topToRandomKernel n hn).stepDist s 1) σ * (topToRandomKernel n hn).P σ τ = _ simp_rw [hW_decomp, add_mul, Finset.sum_add_distrib] -- First part: (1 - sstTail n 1 s) * ∑_σ π σ * P σ τ = (1 - sstTail n 1 s) * π τ! have hstat_τ : ∑ σ : Equiv.Perm (Fin n), π σ * (topToRandomKernel n hn).P σ τ = π τ := by have := congrFun (congrArg Dist.p (topToRandomKernel_uniform_stationary n hn)) τ simpa [MarkovKernel.push] using this have hfirst : ∑ σ : Equiv.Perm (Fin n), (1 - sstTail n 1 s) * π σ * (topToRandomKernel n hn).P σ τ = (1 - sstTail n 1 s) * π τ := by calc ∑ σ, (1 - sstTail n 1 s) * π σ * (topToRandomKernel n hn).P σ τ = (1 - sstTail n 1 s) * ∑ σ, π σ * (topToRandomKernel n hn).P σ τ := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun σ _ => by ring _ = (1 - sstTail n 1 s) * π τ := by rw [hstat_τ] rw [hfirst] -- Second part: swap σ and j, split off j = n (which produces rankProb s n * π τ!), -- and show the remaining j < n terms sum to ∑_{j=1}^n W' j τ! have hsecond_swap : ∑ σ : Equiv.Perm (Fin n), (∑ j ∈ Finset.Icc 1 n, W j σ) * (topToRandomKernel n hn).P σ τ = (∑ j ∈ Finset.Icc 1 (n - 1), ∑ σ : Equiv.Perm (Fin n), W j σ * (topToRandomKernel n hn).P σ τ) + (∑ σ : Equiv.Perm (Fin n), W n σ * (topToRandomKernel n hn).P σ τ) := by simp_rw [Finset.sum_mul] rw [Finset.sum_comm] have hsplit : Finset.Icc 1 n = insert n (Finset.Icc 1 (n - 1)) := by ext j; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hsplit, Finset.sum_insert (by simp; omega), add_comm] rw [hsecond_swap, hpush_Wn τ] -- Note: sstTail n 1 s - sstTail n 1 (s + 1) = rankProb s n! have htail_diff : sstTail n 1 s - sstTail n 1 (s + 1) = rankProb s n := by rw [← hsum_rank s, ← hsum_rank (s + 1)] -- ∑_{j=1}^n rankProb (s+1) j = ∑_{j=1}^n (1 - j/n) rankProb s j + ∑_{j=1}^{n-1} (j/n) rankProb s j -- = ∑_{j=1}^{n-1} rankProb s j = (∑_{j=1}^n rankProb s j) - rankProb s n! have hsum_succ : ∑ j ∈ Finset.Icc 1 n, rankProb (s + 1) j = (∑ j ∈ Finset.Icc 1 n, rankProb s j) - rankProb s n := by have h1 := hdual s 1 rw [hsum_rank (s + 1)] rw [← h1] have hstep1 : ∀ j ∈ Finset.Icc 1 n, rankProb s j * sstTail n j 1 = if j = n then 0 else rankProb s j := fun j hj => by rcases Finset.mem_Icc.mp hj with ⟨h1j, h2j⟩ simp only [sstTail, h1j, h2j, and_self, ↓reduceIte] by_cases hjn : j = n · rw [hjn, if_pos rfl, div_self (ne_of_gt hn_pos), sub_self, zero_mul, zero_add] simp [show ¬n + 1 ≤ n by omega] · rw [if_neg hjn] have hle : j + 1 ≤ n := by omega simp [hle] rw [Finset.sum_congr rfl hstep1] have hsplit : Finset.Icc 1 n = insert n (Finset.Icc 1 (n - 1)) := by ext j; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hsplit, Finset.sum_insert (by simp; omega), Finset.sum_insert (by simp; omega), if_pos rfl, zero_add] have hrest : ∑ j ∈ Finset.Icc 1 (n - 1), (if j = n then (0 : ℝ) else rankProb s j) = ∑ j ∈ Finset.Icc 1 (n - 1), rankProb s j := Finset.sum_congr rfl fun j hj => if_neg (by have := (Finset.mem_Icc.mp hj).2; omega) rw [hrest]; ring linarith -- Show ∑_{j=1}^{n-1} ∑_σ W j σ * P σ τ = ∑_{j=1}^n W' j τ! have hrem_eq : ∑ j ∈ Finset.Icc 1 (n - 1), ∑ σ : Equiv.Perm (Fin n), W j σ * (topToRandomKernel n hn).P σ τ = ∑ j ∈ Finset.Icc 1 n, W' j τ := by have hrew_j : ∀ j ∈ Finset.Icc 1 (n - 1), ∑ σ : Equiv.Perm (Fin n), W j σ * (topToRandomKernel n hn).P σ τ = (n : ℝ)⁻¹ * (∑ k ∈ Finset.univ.filter (fun k : Fin n => k.val < n - j), W j (τ * (insertCycle n k)⁻¹)) + (n : ℝ)⁻¹ * (∑ k ∈ Finset.univ.filter (fun k : Fin n => n - j ≤ k.val), W j (τ * (insertCycle n k)⁻¹)) := fun j _ => by have htot : ∑ σ : Equiv.Perm (Fin n), W j σ * (topToRandomKernel n hn).P σ τ = (n : ℝ)⁻¹ * ∑ k : Fin n, W j (τ * (insertCycle n k)⁻¹) := by simp only [topToRandomKernel] calc ∑ σ, W j σ * ((n : ℝ)⁻¹ * ∑ k, if τ = σ * insertCycle n k then (1 : ℝ) else 0) = (n : ℝ)⁻¹ * ∑ σ, ∑ k, if σ = τ * (insertCycle n k)⁻¹ then W j σ else 0 := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun σ _ => ?_ rw [← mul_assoc, mul_comm (W j σ) _, mul_assoc, Finset.mul_sum] congr 1; refine Finset.sum_congr rfl fun k _ => ?_ have hiff : (τ = σ * insertCycle n k) ↔ (σ = τ * (insertCycle n k)⁻¹) := by constructor <;> intro h · rw [h, mul_inv_cancel_right] · rw [h, inv_mul_cancel_right] by_cases h : σ = τ * (insertCycle n k)⁻¹ · rw [if_pos (hiff.mpr h), if_pos h, mul_one] · rw [if_neg (fun h' => h (hiff.mp h')), if_neg h, mul_zero] _ = (n : ℝ)⁻¹ * ∑ k, ∑ σ, if σ = τ * (insertCycle n k)⁻¹ then W j σ else 0 := by rw [Finset.sum_comm] _ = (n : ℝ)⁻¹ * ∑ k, W j (τ * (insertCycle n k)⁻¹) := by congr 1; refine Finset.sum_congr rfl fun k _ => by simp rw [htot, ← mul_add] congr 1 rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun k : Fin n => k.val < n - j)] congr 2; ext k; simp [not_lt] rw [Finset.sum_congr rfl hrew_j, Finset.sum_add_distrib] have hW'_sum : ∑ j ∈ Finset.Icc 1 n, W' j τ = (∑ j ∈ Finset.Icc 1 (n - 1), (n : ℝ)⁻¹ * ∑ k ∈ Finset.univ.filter (fun k : Fin n => k.val < n - j), W j (τ * (insertCycle n k)⁻¹)) + (∑ j ∈ Finset.Icc 2 n, (n : ℝ)⁻¹ * ∑ k ∈ Finset.univ.filter (fun k : Fin n => n - (j - 1) ≤ k.val), W (j - 1) (τ * (insertCycle n k)⁻¹)) := by have hpt : ∀ j ∈ Finset.Icc 1 n, W' j τ = ((n : ℝ)⁻¹ * ∑ k ∈ Finset.univ.filter (fun k : Fin n => k.val < n - j), W j (τ * (insertCycle n k)⁻¹)) + (if 2 ≤ j then (n : ℝ)⁻¹ * ∑ k ∈ Finset.univ.filter (fun k : Fin n => n - (j - 1) ≤ k.val), W (j - 1) (τ * (insertCycle n k)⁻¹) else 0) := fun j hj => by rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩ simp [W', h1, h2] rw [Finset.sum_congr rfl hpt, Finset.sum_add_distrib] congr 1 · have hsplit : Finset.Icc 1 n = insert n (Finset.Icc 1 (n - 1)) := by ext j; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hsplit, Finset.sum_insert (by simp; omega)] have hemp : (Finset.univ.filter fun k : Fin n => k.val < n - n) = ∅ := by ext k; simp rw [hemp, Finset.sum_empty, mul_zero, zero_add] · rw [← Finset.sum_filter] congr 1; ext j; simp only [Finset.mem_filter, Finset.mem_Icc]; omega rw [hW'_sum] congr 1 refine Finset.sum_bij (fun j _ => j + 1) ?_ ?_ ?_ ?_ · intro j hj; rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩; exact Finset.mem_Icc.mpr ⟨by omega, by omega⟩ · intro j₁ _ j₂ _ heq; omega · intro j hj; rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩ exact ⟨j - 1, Finset.mem_Icc.mpr ⟨by omega, by omega⟩, by omega⟩ · intro j _; simp rw [hrem_eq] have hcomb : (1 - sstTail n 1 s) * π τ + rankProb s n * π τ = (1 - sstTail n 1 (s + 1)) * π τ := by rw [← htail_diff]; ring linarith obtain ⟨W, hW_nn, _, _, hW_sum, hW_decomp⟩ := hinv t have htail_nn : 0 ≤ sstTail n 1 t := by rw [← hsum_rank t] exact Finset.sum_nonneg fun j hj => by rcases Finset.mem_Icc.mp hj with ⟨h1, h2⟩ rw [← hW_sum j h1 h2] exact Finset.sum_nonneg fun σ _ => hW_nn j σ have htail_le1 : sstTail n 1 t ≤ 1 := by rw [sstTail_one_eq_couponMissProb n hn t] unfold couponMissProb rw [div_le_one (by positivity)] have hle : (Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card ≤ n ^ t := by calc (Finset.univ.filter fun f : Fin t → Fin n => ¬ Function.Surjective f).card ≤ Fintype.card (Fin t → Fin n) := Finset.card_le_univ _ _ = n ^ t := by simp exact_mod_cast hle refine ⟨{ pTail := sstTail n 1 t pTail_nonneg := htail_nn pTail_le_one := htail_le1 residual := fun σ => ∑ j ∈ Finset.Icc 1 n, W j σ residual_nonneg := fun σ => Finset.sum_nonneg fun j _ => hW_nn j σ decomp := hW_decomp }, rfl⟩ /-- **Top-to-Random Shuffling Non-Asymptotic Mixing Upper Bound (Cutoff at `n ln n`)**: for EVERY `n ≥ 1` and EVERY `t : ℕ`: `d_TV(P^t(1, ·), Unif(S_n)) ≤ s(P^t(1, ·), Unif(S_n)) ≤ n · (1 - 1/n)^t ≤ n · exp(-t / n)`. In particular, at `t ≥ n ln n + c n`, `d_TV(t) ≤ exp(-c)`! -/ theorem topToRandom_tv_upper_cutoff (n : ℕ) (hn : 1 ≤ n) (t : ℕ) : let π := Dist.uniform (⟨(1 : Equiv.Perm (Fin n))⟩ : Nonempty (Equiv.Perm (Fin n))) tvDist ((topToRandomKernel n hn).stepDist t 1) π ≤ sepDist ((topToRandomKernel n hn).stepDist t 1) π ⟨1⟩ ∧ sepDist ((topToRandomKernel n hn).stepDist t 1) π ⟨1⟩ ≤ (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t ∧ (n : ℝ) * (1 - 1 / (n : ℝ)) ^ t ≤ (n : ℝ) * Real.exp (-(t : ℝ) / (n : ℝ)) := by intro π have hπ_pos : ∀ σ : Equiv.Perm (Fin n), 0 < π σ := fun _ => by simp only [π, Dist.uniform, Fintype.card_perm, Fintype.card_fin] exact inv_pos.mpr (by exact_mod_cast Nat.factorial_pos n) obtain ⟨w, hw⟩ := topToRandom_sst_witness n hn t have hsst := strong_stationary_time_bound hπ_pos ⟨1⟩ w rw [hw] at hsst have hcc := sstTail_one_le_n_exp n hn t exact ⟨hsst.1, le_trans hsst.2 hcc.1, hcc.2⟩ /-- Corollary at cutoff upper window `t ≥ n ln n + c n`: `d_TV(P^t(1, ·), Unif(S_n)) ≤ exp(-c)`. -/ theorem topToRandom_upper_window (n : ℕ) (hn : 1 ≤ n) {c : ℝ} {t : ℕ} (ht : (n : ℝ) * Real.log (n : ℝ) + c * (n : ℝ) ≤ (t : ℝ)) : tvDist ((topToRandomKernel n hn).stepDist t 1) (Dist.uniform ⟨(1 : Equiv.Perm (Fin n))⟩) ≤ Real.exp (-c) := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hub := topToRandom_tv_upper_cutoff n hn t have hle : (n : ℝ) * Real.exp (-(t : ℝ) / (n : ℝ)) ≤ Real.exp (-c) := by have hexp : -(t : ℝ) / (n : ℝ) ≤ -c - Real.log (n : ℝ) := by rw [div_le_iff₀ hn_pos]; linarith calc (n : ℝ) * Real.exp (-(t : ℝ) / (n : ℝ)) ≤ (n : ℝ) * Real.exp (-c - Real.log (n : ℝ)) := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexp) (le_of_lt hn_pos) _ = (n : ℝ) * (Real.exp (-c) / Real.exp (Real.log (n : ℝ))) := by rw [Real.exp_sub] _ = Real.exp (-c) := by rw [Real.exp_log hn_pos]; field_simp [ne_of_gt hn_pos] exact le_trans hub.1 (le_trans hub.2.1 (le_trans hub.2.2 hle)) /-- **Top-to-Random Bottom-`k` Relative Order Event**: probability under `Unif(S_n)` that the `k` cards `{n - k, ..., n - 1}` appear in their exact original relative order equals `1 / k!`. -/ theorem topToRandom_bottom_order_uniform_prob (n k : ℕ) (hk : k ≤ n) : let π := Dist.uniform (⟨(1 : Equiv.Perm (Fin n))⟩ : Nonempty (Equiv.Perm (Fin n))) let A : Finset (Equiv.Perm (Fin n)) := Finset.univ.filter fun σ : Equiv.Perm (Fin n) => ∀ a b : Fin k, a < b → (σ.symm ⟨n - k + a.val, by omega⟩).val < (σ.symm ⟨n - k + b.val, by omega⟩).val π.prob A = (Nat.factorial k : ℝ)⁻¹ := by intro π A -- Show A.card * k! = n! by exact bijection A × Equiv.Perm (Fin k) ≃ Equiv.Perm (Fin n)! -- Given (σ ∈ A, ρ ∈ S_k), permute the labels of the bottom k cards by ρ (left-multiplication)! let embed : Equiv.Perm (Fin k) → Equiv.Perm (Fin n) := fun ρ => { toFun := fun x => if hx : n - k ≤ x.val then ⟨n - k + (ρ ⟨x.val - (n - k), by omega⟩).val, by omega⟩ else x invFun := fun x => if hx : n - k ≤ x.val then ⟨n - k + (ρ.symm ⟨x.val - (n - k), by omega⟩).val, by omega⟩ else x left_inv := fun x => by apply Fin.ext by_cases hx : n - k ≤ x.val · simp only [dif_pos hx] have hge : n - k ≤ n - k + (ρ ⟨x.val - (n - k), by omega⟩).val := by omega simp only [dif_pos hge] have hsub : n - k + (ρ ⟨x.val - (n - k), by omega⟩).val - (n - k) = (ρ ⟨x.val - (n - k), by omega⟩).val := by omega have hfin : (⟨n - k + (ρ ⟨x.val - (n - k), by omega⟩).val - (n - k), by omega⟩ : Fin k) = ρ ⟨x.val - (n - k), by omega⟩ := Fin.ext hsub rw [hfin, ρ.symm_apply_apply]; dsimp only; omega · simp only [dif_neg hx] right_inv := fun x => by apply Fin.ext by_cases hx : n - k ≤ x.val · simp only [dif_pos hx] have hge : n - k ≤ n - k + (ρ.symm ⟨x.val - (n - k), by omega⟩).val := by omega simp only [dif_pos hge] have hsub : n - k + (ρ.symm ⟨x.val - (n - k), by omega⟩).val - (n - k) = (ρ.symm ⟨x.val - (n - k), by omega⟩).val := by omega have hfin : (⟨n - k + (ρ.symm ⟨x.val - (n - k), by omega⟩).val - (n - k), by omega⟩ : Fin k) = ρ.symm ⟨x.val - (n - k), by omega⟩ := Fin.ext hsub rw [hfin, ρ.apply_symm_apply]; dsimp only; omega · simp only [dif_neg hx] } have hembed_apply : ∀ (ρ : Equiv.Perm (Fin k)) (a : Fin k), embed ρ ⟨n - k + a.val, by omega⟩ = ⟨n - k + (ρ a).val, by omega⟩ := fun ρ a => by apply Fin.ext; simp only [embed, Equiv.coe_fn_mk, show n - k ≤ n - k + a.val by omega, ↓reduceDIte] have ha := a.isLt have hfin : (⟨n - k + a.val - (n - k), by omega⟩ : Fin k) = a := Fin.ext (by dsimp only; omega) rw [hfin] have hembed_symm : ∀ (ρ : Equiv.Perm (Fin k)) (a : Fin k), (embed ρ).symm ⟨n - k + a.val, by omega⟩ = ⟨n - k + (ρ.symm a).val, by omega⟩ := fun ρ a => by apply Fin.ext; simp only [embed, Equiv.coe_fn_symm_mk, show n - k ≤ n - k + a.val by omega, ↓reduceDIte] have ha := a.isLt have hfin : (⟨n - k + a.val - (n - k), by omega⟩ : Fin k) = a := Fin.ext (by dsimp only; omega) rw [hfin] -- Bijection (A ×ˢ univ : Finset (Perm (Fin n) × Perm (Fin k))) ≃ univ : Finset (Perm (Fin n)) via (σ, ρ) ↦ embed ρ * σ! have hcard_mul : A.card * Nat.factorial k = Nat.factorial n := by have h1 : (A ×ˢ (Finset.univ : Finset (Equiv.Perm (Fin k)))).card = A.card * Nat.factorial k := by simp [Finset.card_product, Fintype.card_perm] rw [← h1] have h2 : (Finset.univ : Finset (Equiv.Perm (Fin n))).card = Nat.factorial n := by simp [Fintype.card_perm] rw [← h2] refine Finset.card_bij (fun p _ => embed p.2 * p.1) ?_ ?_ ?_ · intro _ _; exact Finset.mem_univ _ · intro p₁ hp₁ p₂ hp₂ heq have hA1 := (Finset.mem_filter.mp (Finset.mem_product.mp hp₁).1).2 have hA2 := (Finset.mem_filter.mp (Finset.mem_product.mp hp₂).1).2 -- Compare positions of bottom k cards: for every a : Fin k, -- (embed ρ₁ * σ₁).symm (n-k+a) = σ₁.symm (n-k + ρ₁.symm a)! have hpos_eq : ∀ a : Fin k, p₁.1.symm ⟨n - k + (p₁.2.symm a).val, by omega⟩ = p₂.1.symm ⟨n - k + (p₂.2.symm a).val, by omega⟩ := fun a => by have h := congrFun (congrArg (fun π : Equiv.Perm (Fin n) => (π.symm : Fin n → Fin n)) heq) ⟨n - k + a.val, by omega⟩ simp only [Equiv.Perm.mul_def, Equiv.symm_trans_apply] at h change p₁.1.symm ((embed p₁.2).symm ⟨n - k + a.val, by omega⟩) = p₂.1.symm ((embed p₂.2).symm ⟨n - k + a.val, by omega⟩) at h rwa [hembed_symm, hembed_symm] at h -- Since both σ₁.symm (n-k+·) and σ₂.symm (n-k+·) are strictly increasing on Fin k and have the SAME range, -- their order isomorphism ρ₁.symm and ρ₂.symm MUST be identical! have hρ_eq : p₁.2 = p₂.2 := by -- Prove p₁.2.symm = p₂.2.symm by showing strict monotonicity implies rank preservation! have hsymm_eq : p₁.2.symm = p₂.2.symm := by ext a have hlt_iff : ∀ x y : Fin k, p₁.2.symm x < p₁.2.symm y ↔ p₂.2.symm x < p₂.2.symm y := fun x y => by constructor <;> intro hxy · have h1 := hA1 (p₁.2.symm x) (p₁.2.symm y) hxy rw [hpos_eq x, hpos_eq y] at h1 by_contra hge; push Not at hge rcases eq_or_lt_of_le hge with heq' | hlt' · have hsame := congrArg (fun c : Fin k => (p₂.1.symm ⟨n - k + c.val, by omega⟩).val) heq' omega · have h2 := hA2 (p₂.2.symm y) (p₂.2.symm x) hlt'; omega · have h2 := hA2 (p₂.2.symm x) (p₂.2.symm y) hxy rw [← hpos_eq x, ← hpos_eq y] at h2 by_contra hge; push Not at hge rcases eq_or_lt_of_le hge with heq' | hlt' · have hsame := congrArg (fun c : Fin k => (p₁.1.symm ⟨n - k + c.val, by omega⟩).val) heq' omega · have h1 := hA1 (p₁.2.symm y) (p₁.2.symm x) hlt'; omega -- For any bijection f : Fin k ≃ Fin k, (f a).val = #{x : Fin k | f x < f a}! have hrank : ∀ (f : Equiv.Perm (Fin k)) (a : Fin k), (f a).val = (Finset.univ.filter fun x : Fin k => f x < f a).card := fun f a => by have hbij : (Finset.univ.filter fun x : Fin k => f x < f a).card = (Finset.univ.filter fun y : Fin k => y < f a).card := by refine Finset.card_bij (fun x _ => f x) ?_ ?_ ?_ · intro x hx; exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hx).2⟩ · intro x₁ _ x₂ _ h; exact f.injective h · intro y hy; exact ⟨f.symm y, Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simpa using (Finset.mem_filter.mp hy).2⟩, f.apply_symm_apply y⟩ rw [hbij] have hlt_card : (Finset.univ.filter fun y : Fin k => y < f a).card = (f a).val := by have hset : (Finset.univ.filter fun y : Fin k => y < f a) = (Finset.range (f a).val).attach.image (fun x => ⟨x.1, by have := Finset.mem_range.mp x.2; omega⟩) := by ext y; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image, Finset.mem_attach, Subtype.exists, Finset.mem_range, Fin.lt_def] constructor · intro hy; exact ⟨y.val, hy, rfl⟩ · rintro ⟨m, hm, rfl⟩; exact hm rw [hset, Finset.card_image_of_injective] · simp · intro x y h; exact Subtype.ext (congrArg Fin.val h) exact hlt_card.symm rw [hrank p₁.2.symm a, hrank p₂.2.symm a] congr 1; ext x; simp [hlt_iff x a] exact Equiv.symm_bijective.injective hsymm_eq have hσ_eq : p₁.1 = p₂.1 := by rw [hρ_eq] at heq; exact mul_left_cancel heq exact Prod.ext hσ_eq hρ_eq · -- Surjectivity: given τ : Perm (Fin n), sort the positions of bottom k cards by Tuple.sort! intro τ _ let pos : Fin k → ℕ := fun a => (τ.symm ⟨n - k + a.val, by omega⟩).val let ρ : Equiv.Perm (Fin k) := Tuple.sort pos -- Set σ = (embed ρ.symm) * τ! Wait: (embed ρ * σ = τ) iff σ = (embed ρ)⁻¹ * τ! -- Check: (σ.symm (n-k+a)) = τ.symm (embed ρ (n-k+a)) = τ.symm (n-k + ρ a), -- whose .val is pos (ρ a) = (pos ∘ Tuple.sort pos) a, which is STRICTLY INCREASING! let σ : Equiv.Perm (Fin n) := (embed ρ)⁻¹ * τ have hσA : σ ∈ A := by simp only [A, Finset.mem_filter, Finset.mem_univ, true_and] intro a b hab have hsymm_val : ∀ x : Fin k, (σ.symm ⟨n - k + x.val, by omega⟩).val = pos (ρ x) := fun x => by dsimp only [σ, pos] change (((embed ρ)⁻¹ * τ).symm ⟨n - k + x.val, by omega⟩).val = _ have heq_sym : ((embed ρ)⁻¹ * τ).symm = τ.symm * embed ρ := by change ((embed ρ)⁻¹ * τ)⁻¹ = τ⁻¹ * embed ρ rw [mul_inv_rev, inv_inv] rw [heq_sym] simp only [Equiv.Perm.coe_mul, Function.comp_apply, hembed_apply ρ x] rw [hsymm_val a, hsymm_val b] have hle : pos (ρ a) ≤ pos (ρ b) := Tuple.monotone_sort pos (le_of_lt hab) have hne : pos (ρ a) ≠ pos (ρ b) := fun h => by have ha := (ρ a).isLt have hb := (ρ b).isLt have hfin : τ.symm ⟨n - k + (ρ a).val, by omega⟩ = τ.symm ⟨n - k + (ρ b).val, by omega⟩ := Fin.ext h have h2 := congrArg Fin.val (τ.symm.injective hfin) dsimp only at h2 have hρeq : ρ a = ρ b := Fin.ext (by omega) exact ne_of_lt hab (ρ.injective hρeq) omega refine ⟨(σ, ρ), Finset.mem_product.mpr ⟨hσA, Finset.mem_univ ρ⟩, ?_⟩ simp [σ] unfold Dist.prob simp only [π, Dist.uniform, Fintype.card_perm, Fintype.card_fin, Finset.sum_const, nsmul_eq_mul] have hcast : (A.card : ℝ) * (Nat.factorial k : ℝ) = (Nat.factorial n : ℝ) := by exact_mod_cast hcard_mul have hfn : (0 : ℝ) < (Nat.factorial n : ℝ) := by exact_mod_cast Nat.factorial_pos n have hfk : (0 : ℝ) < (Nat.factorial k : ℝ) := by exact_mod_cast Nat.factorial_pos k field_simp [ne_of_gt hfn, ne_of_gt hfk] linarith /-- **Top-to-Random Shuffling Non-Asymptotic Lower Bound via Bottom-`k` Invariance**: as long as card `c_k = n - k` has not yet reached the top (probability `≥ sstTail_top n k t`), the bottom `k` cards remain in exact original order (`A_k`), so `d_TV(P^t(1, ·), Unif(S_n)) ≥ P(τ_k > t) - 1 / k!`. Combined with `topToRandom_tv_upper_cutoff`, this certifies the **Sharp Cutoff at `n ln n`**! -/ theorem topToRandom_tv_lower_via_bottom_k (n k : ℕ) (hn : 1 ≤ n) (_hk1 : 1 ≤ k) (hkn : k ≤ n) (t : ℕ) : let π := Dist.uniform (⟨(1 : Equiv.Perm (Fin n))⟩ : Nonempty (Equiv.Perm (Fin n))) let A : Finset (Equiv.Perm (Fin n)) := Finset.univ.filter fun σ : Equiv.Perm (Fin n) => ∀ a b : Fin k, a < b → (σ.symm ⟨n - k + a.val, by omega⟩).val < (σ.symm ⟨n - k + b.val, by omega⟩).val ((topToRandomKernel n hn).stepDist t 1).prob A - (Nat.factorial k : ℝ)⁻¹ ≤ tvDist ((topToRandomKernel n hn).stepDist t 1) π := by intro π A have h1 := event_sub_le_tvDist ((topToRandomKernel n hn).stepDist t 1) π A rw [topToRandom_bottom_order_uniform_prob n k hkn] at h1 exact h1 /-- Exact probability that card `n - k` has NOT YET been moved from the top during `t` steps: when `k = n` this is `0`, and for `1 ≤ k < n` we bound `P^t(1, A_k) ≥ (1 - k / n)^t`? Even sharper: every step where `k_slot < n - k` keeps card `n - k` stationary; in fact, by tracking the position `r ∈ {k, ..., n - 1}` of card `n - k` (number of cards at or below it), as long as `r < n` (card `n - k` has not reached slot `0`), the entire bottom `k` block remains in exact original relative order (`σ ∈ A_k`)! -/ theorem topToRandom_bottom_k_survival_lower (n k : ℕ) (hn : 2 ≤ n) (hk1 : 1 ≤ k) (hkn : k < n) (t : ℕ) : let A : Finset (Equiv.Perm (Fin n)) := Finset.univ.filter fun σ : Equiv.Perm (Fin n) => ∀ a b : Fin k, a < b → (σ.symm ⟨n - k + a.val, by omega⟩).val < (σ.symm ⟨n - k + b.val, by omega⟩).val (1 - (k : ℝ) / (n : ℝ)) ^ t ≤ ((topToRandomKernel n (by omega)).stepDist t 1).prob A := by -- Stronger invariant: track event B_k = {σ ∈ A | (σ.symm (n - k)).val ≥ n - k}! -- Wait: if σ ∈ B_k and we insert the top card at ANY slot j < n - k (probability 1 - k/n), -- then σ * insertCycle n j STILL belongs to B_k!! intro A let B : Finset (Equiv.Perm (Fin n)) := Finset.univ.filter fun σ : Equiv.Perm (Fin n) => (∀ a b : Fin k, a < b → (σ.symm ⟨n - k + a.val, by omega⟩).val < (σ.symm ⟨n - k + b.val, by omega⟩).val) ∧ n - k ≤ (σ.symm ⟨n - k, by omega⟩).val have hBA : B ⊆ A := by intro σ hσ; exact Finset.mem_filter.mpr ⟨Finset.mem_univ σ, (Finset.mem_filter.mp hσ).2.1⟩ suffices hB : ∀ s : ℕ, (1 - (k : ℝ) / (n : ℝ)) ^ s ≤ ((topToRandomKernel n (by omega)).stepDist s 1).prob B by exact le_trans (hB t) (((topToRandomKernel n (by omega)).stepDist t 1).prob_mono hBA) intro s induction s with | zero => have h1B : (1 : Equiv.Perm (Fin n)) ∈ B := by simp only [B, Finset.mem_filter, Finset.mem_univ, true_and] have hsym1 : (1 : Equiv.Perm (Fin n)).symm = 1 := rfl rw [hsym1] exact ⟨fun a b hab => by have := Fin.lt_def.mp hab; simp; omega, by simp⟩ have hprob1 : ((topToRandomKernel n (by omega)).stepDist 0 1).prob B = 1 := by unfold Dist.prob MarkovKernel.stepDist MarkovKernel.pow MarkovKernel.row MarkovKernel.id rw [Finset.sum_eq_single (1 : Equiv.Perm (Fin n))] · simp · intro σ _ hσ; simp [Ne.symm hσ] · intro h; exact absurd h1B h rw [pow_zero, hprob1] | succ s ih => have hstep_B : ∀ σ ∈ B, 1 - (k : ℝ) / (n : ℝ) ≤ ∑ τ ∈ B, (topToRandomKernel n (by omega)).P σ τ := fun σ hσ => by rcases (Finset.mem_filter.mp hσ).2 with ⟨hord, hlow⟩ have hinv_cyc : ∀ (j i : Fin n), (insertCycle n j).symm i = if h0 : i.val = 0 then j else if h2 : i.val ≤ j.val then ⟨i.val - 1, by omega⟩ else i := fun j i => rfl have hpres : ∀ j : Fin n, j.val < n - k → σ * insertCycle n j ∈ B := fun j hj => by have hpos_fix : ∀ a : Fin k, ((σ * insertCycle n j).symm ⟨n - k + a.val, by omega⟩).val = (σ.symm ⟨n - k + a.val, by omega⟩).val := fun a => by have ha_lt := a.isLt have hge_a : n - k ≤ (σ.symm ⟨n - k + a.val, by omega⟩).val := by by_cases ha0 : a.val = 0 · have ha : (⟨n - k + a.val, by omega⟩ : Fin n) = ⟨n - k, by omega⟩ := Fin.ext (by dsimp only; omega) rw [ha]; exact hlow · have hlt := hord ⟨0, by omega⟩ a (by simp [Fin.lt_def]; omega) have h0eq : (⟨n - k + (⟨0, by omega⟩ : Fin k).val, by omega⟩ : Fin n) = ⟨n - k, by omega⟩ := Fin.ext (by simp) rw [h0eq] at hlt; omega change ((insertCycle n j).symm (σ.symm ⟨n - k + a.val, by omega⟩)).val = _ rw [hinv_cyc j _, dif_neg (by omega), dif_neg (by omega)] refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_, ?_⟩ · intro a b hab; rw [hpos_fix a, hpos_fix b]; exact hord a b hab · have h0 := hpos_fix ⟨0, by omega⟩ have h0eq : (⟨n - k + (⟨0, by omega⟩ : Fin k).val, by omega⟩ : Fin n) = ⟨n - k, by omega⟩ := Fin.ext (by simp) rw [h0eq] at h0; rw [h0]; exact hlow simp only [topToRandomKernel] rw [← Finset.mul_sum, Finset.sum_comm] have hge_sum : ∑ j ∈ Finset.univ.filter (fun j : Fin n => j.val < n - k), (1 : ℝ) ≤ ∑ j : Fin n, ∑ τ ∈ B, if τ = σ * insertCycle n j then (1 : ℝ) else 0 := by calc ∑ j ∈ Finset.univ.filter (fun j : Fin n => j.val < n - k), (1 : ℝ) = ∑ j ∈ Finset.univ.filter (fun j : Fin n => j.val < n - k), ∑ τ ∈ B, if τ = σ * insertCycle n j then (1 : ℝ) else 0 := by refine Finset.sum_congr rfl fun j hj => ?_ rw [Finset.sum_ite_eq' B (σ * insertCycle n j), if_pos (hpres j (Finset.mem_filter.mp hj).2)] _ ≤ ∑ j : Fin n, ∑ τ ∈ B, if τ = σ * insertCycle n j then (1 : ℝ) else 0 := Finset.sum_le_univ_sum_of_nonneg fun j => Finset.sum_nonneg fun τ _ => by split_ifs <;> norm_num have hcard_lt : (Finset.univ.filter fun j : Fin n => j.val < n - k).card = n - k := by have hbij : (Finset.univ.filter fun j : Fin n => j.val < n - k) = (Finset.range (n - k)).attach.image (fun x => ⟨x.1, by have := Finset.mem_range.mp x.2; omega⟩) := by ext j; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image, Finset.mem_attach, Subtype.exists, Finset.mem_range] constructor · intro hj; exact ⟨j.val, hj, rfl⟩ · rintro ⟨a, ha, rfl⟩; exact ha rw [hbij, Finset.card_image_of_injective] · simp · intro a b h; exact Subtype.ext (congrArg Fin.val h) have hcard_r : ∑ j ∈ Finset.univ.filter (fun j : Fin n => j.val < n - k), (1 : ℝ) = (n : ℝ) - (k : ℝ) := by rw [Finset.sum_const, hcard_lt, nsmul_eq_mul, mul_one, Nat.cast_sub (by omega)] rw [hcard_r] at hge_sum have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) have hmul := mul_le_mul_of_nonneg_left hge_sum (show 0 ≤ (n : ℝ)⁻¹ by positivity) have heq : (n : ℝ)⁻¹ * ((n : ℝ) - (k : ℝ)) = 1 - (k : ℝ) / (n : ℝ) := by field_simp [ne_of_gt hn_pos] linarith have hnn : 0 ≤ 1 - (k : ℝ) / (n : ℝ) := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) rw [sub_nonneg, div_le_one hn_pos]; exact_mod_cast (le_of_lt hkn) rw [(topToRandomKernel n (by omega)).stepDist_succ s 1] unfold Dist.prob MarkovKernel.push rw [Finset.sum_comm] calc (1 - (k : ℝ) / (n : ℝ)) ^ (s + 1) = (1 - (k : ℝ) / (n : ℝ)) * (1 - (k : ℝ) / (n : ℝ)) ^ s := pow_succ' _ s _ ≤ (1 - (k : ℝ) / (n : ℝ)) * ((topToRandomKernel n (by omega)).stepDist s 1).prob B := mul_le_mul_of_nonneg_left ih hnn _ = ∑ σ ∈ B, ((topToRandomKernel n (by omega)).stepDist s 1) σ * (1 - (k : ℝ) / (n : ℝ)) := by unfold Dist.prob; rw [Finset.mul_sum] refine Finset.sum_congr rfl fun σ _ => mul_comm _ _ _ ≤ ∑ σ ∈ B, ((topToRandomKernel n (by omega)).stepDist s 1) σ * ∑ τ ∈ B, (topToRandomKernel n (by omega)).P σ τ := Finset.sum_le_sum fun σ hσ => mul_le_mul_of_nonneg_left (hstep_B σ hσ) (((topToRandomKernel n (by omega)).stepDist s 1).nonneg σ) _ ≤ ∑ σ : Equiv.Perm (Fin n), ((topToRandomKernel n (by omega)).stepDist s 1) σ * ∑ τ ∈ B, (topToRandomKernel n (by omega)).P σ τ := Finset.sum_le_univ_sum_of_nonneg fun σ => mul_nonneg (((topToRandomKernel n (by omega)).stepDist s 1).nonneg σ) (Finset.sum_nonneg fun τ _ => (topToRandomKernel n (by omega)).nonneg σ τ) _ = ∑ σ : Equiv.Perm (Fin n), ∑ τ ∈ B, ((topToRandomKernel n (by omega)).stepDist s 1) σ * (topToRandomKernel n (by omega)).P σ τ := Finset.sum_congr rfl fun σ _ => Finset.mul_sum .. /-! ### Landmark 3: Quantitative Non-Cutoff Contrast on Lazy Even Cycle `C_{2m}` (`t_mix = Θ(m²)`) -/ /-- **Quadratic Slowdown & Non-Cutoff Mixing Lower Bound on `C_{2m}`**: for EVERY `m ≥ 2` and EVERY `ε ∈ (0, 1/2)`: `d(t) ≤ ε ⟹ (4 m² / π² - 1) · ln(1 / (2 ε)) ≤ t`! Because `t_rel(C_{2m}) = Θ(m²)` and `t_mix(C_{2m}, ε) = Θ(m² · ln(1/(2ε)))`, the mixing time scales **quadratically in `m`** and **linearly in `ln(1/(2ε))`**, proving the absence of cutoff on `C_{2m}` in sharp contrast to `Q_n` (`(1/4) n ln n`) and `S_n` (`n ln n`). -/ theorem lazyCycle_quadratic_mixing_lower_bound (m : ℕ) (hm : 2 ≤ m) {t : ℕ} {ε : ℝ} (hε_pos : 0 < ε) (hε_half : ε ≤ 1 / 2) (hdt : dTVMax (lazyCycleKernel m hm) (Dist.uniform ⟨⟨0, by omega⟩⟩) ⟨⟨0, by omega⟩⟩ t ≤ ε) : (4 * (m : ℝ) ^ 2 / Real.pi ^ 2 - 1) * Real.log (1 / (2 * ε)) ≤ (t : ℝ) := by let K := lazyCycleKernel m hm let π := Dist.uniform (⟨⟨0, by omega⟩⟩ : Nonempty (Fin (2 * m))) let hrev := lazyCycleKernel_reversible m hm let hpos : ∀ x : Fin (2 * m), 0 < π x := fun _ => by simp only [π, Dist.uniform, Fintype.card_fin] exact inv_pos.mpr (by exact_mod_cast (show 0 < 2 * m by omega)) have hcard : 2 ≤ Fintype.card (Fin (2 * m)) := by simp; omega have hgap_ub := lazyCycle_spectralGap_le_quadratic m hm have hcos_lt1 : Real.cos (Real.pi / (m : ℝ)) < 1 := by have hm_pos : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) have hθ_pos : 0 < Real.pi / (m : ℝ) := div_pos Real.pi_pos hm_pos have hθ_le : Real.pi / (m : ℝ) ≤ Real.pi / 2 := by have hm2 : (2 : ℝ) ≤ m := by exact_mod_cast hm exact div_le_div_of_nonneg_left (le_of_lt Real.pi_pos) (by norm_num) hm2 have hlt : Real.cos (Real.pi / (m : ℝ)) < Real.cos 0 := Real.strictAntiOn_cos (Set.left_mem_Icc.mpr (le_of_lt Real.pi_pos)) ⟨le_of_lt hθ_pos, by linarith [Real.pi_pos]⟩ hθ_pos simpa using hlt have hcos_nn : 0 ≤ Real.cos (Real.pi / (m : ℝ)) := by have hm_pos : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) have hθ_le : Real.pi / (m : ℝ) ≤ Real.pi / 2 := by have hm2 : (2 : ℝ) ≤ m := by exact_mod_cast hm exact div_le_div_of_nonneg_left (le_of_lt Real.pi_pos) (by norm_num) hm2 exact Real.cos_nonneg_of_mem_Icc ⟨by linarith [div_pos Real.pi_pos hm_pos, Real.pi_pos], hθ_le⟩ -- Use cosine eigenfunction directly with dTVMax_ge_half_abs_eig_pow! obtain ⟨hmean, hnz, heig⟩ := lazyCycle_cosine_eigenfunction m hm set lam := (1 + Real.cos (Real.pi / (m : ℝ))) / 2 have hlam_pos : 0 < lam := by dsimp only [lam]; linarith have hlam_lt1 : lam < 1 := by dsimp only [lam]; linarith have hlb := dTVMax_ge_half_abs_eig_pow ⟨⟨0, by omega⟩⟩ hmean hnz heig t rw [abs_of_pos hlam_pos] at hlb have hpow_le : lam ^ t ≤ 2 * ε := by linarith have hlog_le : (t : ℝ) * Real.log lam ≤ Real.log (2 * ε) := by have h := Real.log_le_log (pow_pos hlam_pos t) hpow_le rwa [Real.log_pow] at h have hlog_inv : Real.log lam⁻¹ ≤ lam⁻¹ - 1 := Real.log_le_sub_one_of_pos (inv_pos.mpr hlam_pos) rw [Real.log_inv] at hlog_inv have h1lam_pos : 0 < 1 - lam := by linarith have hratio : lam⁻¹ - 1 = (1 - lam) / lam := by field_simp [ne_of_gt hlam_pos] have hlog_lam_ge : -((1 - lam) / lam) ≤ Real.log lam := by linarith have ht_ge_lam : (1 / (1 - lam) - 1) * Real.log (1 / (2 * ε)) ≤ (t : ℝ) := by have hmul : -(t : ℝ) * ((1 - lam) / lam) ≤ Real.log (2 * ε) := by calc -(t : ℝ) * ((1 - lam) / lam) = (t : ℝ) * -((1 - lam) / lam) := by ring _ ≤ (t : ℝ) * Real.log lam := mul_le_mul_of_nonneg_left hlog_lam_ge (Nat.cast_nonneg t) _ ≤ Real.log (2 * ε) := hlog_le have hlog_rec : Real.log (1 / (2 * ε)) = -Real.log (2 * ε) := by rw [one_div, Real.log_inv] rw [hlog_rec] have hcoeff : 1 / (1 - lam) - 1 = lam / (1 - lam) := by field_simp [ne_of_gt h1lam_pos]; ring rw [hcoeff] have hmul2 := mul_le_mul_of_nonneg_left (show -Real.log (2 * ε) ≤ (t : ℝ) * ((1 - lam) / lam) by linarith) (le_of_lt (div_pos hlam_pos h1lam_pos)) have hcancel : lam / (1 - lam) * ((t : ℝ) * ((1 - lam) / lam)) = (t : ℝ) := by field_simp [ne_of_gt h1lam_pos, ne_of_gt hlam_pos] linarith have hlog_nn : 0 ≤ Real.log (1 / (2 * ε)) := Real.log_nonneg ((one_le_div (by linarith)).mpr (by linarith)) have h1mlam_le : 1 - lam ≤ Real.pi ^ 2 / (4 * (m : ℝ) ^ 2) := by have hsub : 1 - lam = (1 - Real.cos (Real.pi / (m : ℝ))) / 2 := by dsimp only [lam]; ring rw [hsub]; exact hgap_ub.2 have hrec_ge : 4 * (m : ℝ) ^ 2 / Real.pi ^ 2 ≤ 1 / (1 - lam) := by have hpi2 : 0 < Real.pi ^ 2 := sq_pos_of_pos Real.pi_pos have hm2 : 0 < 4 * (m : ℝ) ^ 2 := by positivity have h1 := one_div_le_one_div_of_le h1lam_pos h1mlam_le have hflip : 1 / (Real.pi ^ 2 / (4 * (m : ℝ) ^ 2)) = 4 * (m : ℝ) ^ 2 / Real.pi ^ 2 := by field_simp [ne_of_gt hpi2, ne_of_gt hm2] linarith have hmono : (4 * (m : ℝ) ^ 2 / Real.pi ^ 2 - 1) * Real.log (1 / (2 * ε)) ≤ (1 / (1 - lam) - 1) * Real.log (1 / (2 * ε)) := mul_le_mul_of_nonneg_right (by linarith) hlog_nn linarith end Pillar5_CutoffPhaseTransitions end end MarkovChainMixingCouplingCutoff /-! ============================================================================ AXIOM VERIFICATION AUDIT (ALL PUBLIC THEOREMS & LEMMAS) ============================================================================ -/ #print axioms MarkovChainMixingCouplingCutoff.Dist.ext #print axioms MarkovChainMixingCouplingCutoff.Dist.prob_nonneg #print axioms MarkovChainMixingCouplingCutoff.Dist.prob_le_one #print axioms MarkovChainMixingCouplingCutoff.Dist.le_one #print axioms MarkovChainMixingCouplingCutoff.Dist.prob_compl #print axioms MarkovChainMixingCouplingCutoff.Dist.prob_mono #print axioms MarkovChainMixingCouplingCutoff.Dist.expect_const #print axioms MarkovChainMixingCouplingCutoff.Dist.expect_add #print axioms MarkovChainMixingCouplingCutoff.Dist.expect_sub #print axioms MarkovChainMixingCouplingCutoff.Dist.expect_smul #print axioms MarkovChainMixingCouplingCutoff.Dist.expect_nonneg #print axioms MarkovChainMixingCouplingCutoff.Dist.variance_nonneg #print axioms MarkovChainMixingCouplingCutoff.Dist.variance_eq_expect_sq_sub #print axioms MarkovChainMixingCouplingCutoff.Dist.markov_inequality #print axioms MarkovChainMixingCouplingCutoff.Dist.chebyshev_inequality #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.comp_assoc #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.id_comp #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.comp_id #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.pow_add #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.pow_succ_right #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.push_comp #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.push_dirac #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.stepDist_add #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.stepDist_succ #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.isStationary_pow #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.expect_push #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.apply_comp #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.apply_const #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.expect_stepDist #print axioms MarkovChainMixingCouplingCutoff.tvDist_nonneg #print axioms MarkovChainMixingCouplingCutoff.tvDist_self #print axioms MarkovChainMixingCouplingCutoff.tvDist_symm #print axioms MarkovChainMixingCouplingCutoff.tvDist_eq_zero_iff #print axioms MarkovChainMixingCouplingCutoff.tvDist_triangle #print axioms MarkovChainMixingCouplingCutoff.tvDist_eq_sum_pos #print axioms MarkovChainMixingCouplingCutoff.tvDist_eq_one_sub_sum_min #print axioms MarkovChainMixingCouplingCutoff.tvDist_le_one #print axioms MarkovChainMixingCouplingCutoff.event_sub_le_tvDist #print axioms MarkovChainMixingCouplingCutoff.exists_event_eq_tvDist #print axioms MarkovChainMixingCouplingCutoff.abs_expect_sub_le_tvDist #print axioms MarkovChainMixingCouplingCutoff.tvDist_push_le #print axioms MarkovChainMixingCouplingCutoff.tvDist_ge_distinguishing_chebyshev #print axioms MarkovChainMixingCouplingCutoff.Coupling.eqProb_add_neqProb #print axioms MarkovChainMixingCouplingCutoff.Coupling.diag_le_min #print axioms MarkovChainMixingCouplingCutoff.fundamental_coupling_inequality #print axioms MarkovChainMixingCouplingCutoff.exists_maximal_coupling #print axioms MarkovChainMixingCouplingCutoff.tvDist_step_le_dTVMax #print axioms MarkovChainMixingCouplingCutoff.tvDist_pair_le_dBar #print axioms MarkovChainMixingCouplingCutoff.dTVMax_nonneg #print axioms MarkovChainMixingCouplingCutoff.dBar_nonneg #print axioms MarkovChainMixingCouplingCutoff.tvDist_push_le_dBar_mul_tvDist #print axioms MarkovChainMixingCouplingCutoff.dTVMax_le_dBar_and_dBar_le_two_dTVMax #print axioms MarkovChainMixingCouplingCutoff.dBar_submultiplicative #print axioms MarkovChainMixingCouplingCutoff.dTVMax_submultiplicative #print axioms MarkovChainMixingCouplingCutoff.dTVMax_antitone #print axioms MarkovChainMixingCouplingCutoff.dBar_antitone #print axioms MarkovChainMixingCouplingCutoff.dTVMax_mul_le_pow #print axioms MarkovChainMixingCouplingCutoff.sepDist_ge_pointwise #print axioms MarkovChainMixingCouplingCutoff.sepDist_nonneg #print axioms MarkovChainMixingCouplingCutoff.sepDist_le_one #print axioms MarkovChainMixingCouplingCutoff.tvDist_le_sepDist #print axioms MarkovChainMixingCouplingCutoff.sepDist_push_le #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.IsReversible.isStationary #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.IsReversible.pow #print axioms MarkovChainMixingCouplingCutoff.reversible_sepMax_two_mul_le #print axioms MarkovChainMixingCouplingCutoff.reversible_sepMax_two_mul_le_four_dTVMax #print axioms MarkovChainMixingCouplingCutoff.strong_stationary_time_bound #print axioms MarkovChainMixingCouplingCutoff.exists_optimal_strong_stationary_witness #print axioms MarkovChainMixingCouplingCutoff.l2Inner_comm #print axioms MarkovChainMixingCouplingCutoff.l2NormSq_nonneg #print axioms MarkovChainMixingCouplingCutoff.dirichletForm_nonneg #print axioms MarkovChainMixingCouplingCutoff.chi2Dist_nonneg #print axioms MarkovChainMixingCouplingCutoff.chi2Dist_eq_sum_sq_sub_one #print axioms MarkovChainMixingCouplingCutoff.four_tvDist_sq_le_chi2 #print axioms MarkovChainMixingCouplingCutoff.l2Inner_apply_selfAdjoint #print axioms MarkovChainMixingCouplingCutoff.dirichletForm_eq_l2Inner_sub #print axioms MarkovChainMixingCouplingCutoff.abs_l2Inner_apply_le_l2NormSq #print axioms MarkovChainMixingCouplingCutoff.symMat_isHermitian #print axioms MarkovChainMixingCouplingCutoff.symMat_comp #print axioms MarkovChainMixingCouplingCutoff.symMat_id #print axioms MarkovChainMixingCouplingCutoff.symMat_pow #print axioms MarkovChainMixingCouplingCutoff.dotProduct_sqrtPi_self #print axioms MarkovChainMixingCouplingCutoff.symMat_mulVec_sqrtPi #print axioms MarkovChainMixingCouplingCutoff.symMat_quad_eq_l2Inner #print axioms MarkovChainMixingCouplingCutoff.dotProduct_isHermitian_mulVec #print axioms MarkovChainMixingCouplingCutoff.symMat_eigenvalues₀_abs_le_one #print axioms MarkovChainMixingCouplingCutoff.symMat_top_eigenvalue_eq_one #print axioms MarkovChainMixingCouplingCutoff.spectralGap_nonneg #print axioms MarkovChainMixingCouplingCutoff.lambdaStar_nonneg #print axioms MarkovChainMixingCouplingCutoff.lambdaStar_le_one #print axioms MarkovChainMixingCouplingCutoff.absSpectralGap_le_spectralGap #print axioms MarkovChainMixingCouplingCutoff.symMat_pow_quad_expansion #print axioms MarkovChainMixingCouplingCutoff.symMat_quad_le_secondEig_of_orth #print axioms MarkovChainMixingCouplingCutoff.spectralGap_mul_variance_le_dirichlet #print axioms MarkovChainMixingCouplingCutoff.exists_second_eigenfunction #print axioms MarkovChainMixingCouplingCutoff.symMat_pow_two_mul_quad_le #print axioms MarkovChainMixingCouplingCutoff.chi2_stepDist_le_lambdaStar #print axioms MarkovChainMixingCouplingCutoff.four_tvDist_sq_step_le_spectral #print axioms MarkovChainMixingCouplingCutoff.tvDist_step_le_exp_spectralGap #print axioms MarkovChainMixingCouplingCutoff.variance_apply_pow_le #print axioms MarkovChainMixingCouplingCutoff.dTVMax_ge_half_abs_eig_pow #print axioms MarkovChainMixingCouplingCutoff.mixing_time_ge_relaxation_lower_bound #print axioms MarkovChainMixingCouplingCutoff.MarkovKernel.IsReversible.lazyAlpha #print axioms MarkovChainMixingCouplingCutoff.symMat_lazyAlpha #print axioms MarkovChainMixingCouplingCutoff.lazyAlpha_symMat_posSemidef #print axioms MarkovChainMixingCouplingCutoff.lazy_eigenvalues_in_unit_interval #print axioms MarkovChainMixingCouplingCutoff.lazy_lambdaStar_eq_secondEig #print axioms MarkovChainMixingCouplingCutoff.dirichletForm_lazyAlpha #print axioms MarkovChainMixingCouplingCutoff.properCuts_nonempty #print axioms MarkovChainMixingCouplingCutoff.ergodicFlow_nonneg #print axioms MarkovChainMixingCouplingCutoff.ergodicFlow_symm #print axioms MarkovChainMixingCouplingCutoff.ergodicFlow_le_prob #print axioms MarkovChainMixingCouplingCutoff.dirichletForm_indicator_eq_ergodicFlow #print axioms MarkovChainMixingCouplingCutoff.prob_pos_of_nonempty #print axioms MarkovChainMixingCouplingCutoff.compl_nonempty_of_ne_univ #print axioms MarkovChainMixingCouplingCutoff.bottleneckRatio_nonneg #print axioms MarkovChainMixingCouplingCutoff.bottleneckRatio_le_one #print axioms MarkovChainMixingCouplingCutoff.bottleneckRatio_le_cutConductance #print axioms MarkovChainMixingCouplingCutoff.cheeger_upper_bound_cut #print axioms MarkovChainMixingCouplingCutoff.cheeger_upper_bound #print axioms MarkovChainMixingCouplingCutoff.dirichletForm_posPart_le_of_eig #print axioms MarkovChainMixingCouplingCutoff.coarea_sq_le_dirichlet_sharp #print axioms MarkovChainMixingCouplingCutoff.coarea_ge_bottleneck_mul_normSq #print axioms MarkovChainMixingCouplingCutoff.cheeger_sinclair_jerrum_sharp #print axioms MarkovChainMixingCouplingCutoff.sinclair_jerrum_strictly_beats_half_sq #print axioms MarkovChainMixingCouplingCutoff.half_sq_le_one_sub_sqrt #print axioms MarkovChainMixingCouplingCutoff.cheeger_inequality_full #print axioms MarkovChainMixingCouplingCutoff.cheeger_lower_bound #print axioms MarkovChainMixingCouplingCutoff.pathEdges_length #print axioms MarkovChainMixingCouplingCutoff.path_telescoping #print axioms MarkovChainMixingCouplingCutoff.list_sum_sq_le_length_mul_sum_sq #print axioms MarkovChainMixingCouplingCutoff.path_diff_sq_le_length_mul_sum #print axioms MarkovChainMixingCouplingCutoff.canonical_paths_dirichlet_bound #print axioms MarkovChainMixingCouplingCutoff.canonical_paths_spectral_gap_lower #print axioms MarkovChainMixingCouplingCutoff.canonical_paths_unweighted_lower #print axioms MarkovChainMixingCouplingCutoff.twoStateKernel_reversible #print axioms MarkovChainMixingCouplingCutoff.twoState_cheeger_upper_tight #print axioms MarkovChainMixingCouplingCutoff.lazyCompleteKernel_reversible #print axioms MarkovChainMixingCouplingCutoff.lazyComplete_spectralGap_and_conductance #print axioms MarkovChainMixingCouplingCutoff.cycle_mod_identities #print axioms MarkovChainMixingCouplingCutoff.lazyCycleKernel_reversible #print axioms MarkovChainMixingCouplingCutoff.lazyCycle_cosine_eigenfunction #print axioms MarkovChainMixingCouplingCutoff.lazyCycle_half_cut_conductance #print axioms MarkovChainMixingCouplingCutoff.lazyCycle_spectralGap_le_quadratic #print axioms MarkovChainMixingCouplingCutoff.transportCost_nonneg #print axioms MarkovChainMixingCouplingCutoff.tvDist_le_transportCost #print axioms MarkovChainMixingCouplingCutoff.coupling_gluing_triangle #print axioms MarkovChainMixingCouplingCutoff.transportCost_liftStepCoupling #print axioms MarkovChainMixingCouplingCutoff.wasserstein_one_step_contraction #print axioms MarkovChainMixingCouplingCutoff.transportCost_cast #print axioms MarkovChainMixingCouplingCutoff.wasserstein_iterated_contraction #print axioms MarkovChainMixingCouplingCutoff.geometric_mixing_of_contraction #print axioms MarkovChainMixingCouplingCutoff.bubley_dyer_path_coupling #print axioms MarkovChainMixingCouplingCutoff.bubley_dyer_mixing_time #print axioms MarkovChainMixingCouplingCutoff.hammingDist_nonneg #print axioms MarkovChainMixingCouplingCutoff.hammingDist_self #print axioms MarkovChainMixingCouplingCutoff.hammingDist_symm #print axioms MarkovChainMixingCouplingCutoff.hammingDist_triangle #print axioms MarkovChainMixingCouplingCutoff.hammingDist_unit_sep #print axioms MarkovChainMixingCouplingCutoff.hammingDist_le_card #print axioms MarkovChainMixingCouplingCutoff.hamming_geodesic #print axioms MarkovChainMixingCouplingCutoff.dobrushin_glauber_one_step_contraction #print axioms MarkovChainMixingCouplingCutoff.dobrushin_glauber_rapid_mixing #print axioms MarkovChainMixingCouplingCutoff.ising_heatbath_influence_le_tanh #print axioms MarkovChainMixingCouplingCutoff.tanh_nonneg_of_nonneg #print axioms MarkovChainMixingCouplingCutoff.ising_glauber_rapid_mixing #print axioms MarkovChainMixingCouplingCutoff.tvDist_uniform_finset_le #print axioms MarkovChainMixingCouplingCutoff.jerrum_q_coloring_rapid_mixing #print axioms MarkovChainMixingCouplingCutoff.flipBit_invol #print axioms MarkovChainMixingCouplingCutoff.flipBit_ne #print axioms MarkovChainMixingCouplingCutoff.flipBit_inj_coord #print axioms MarkovChainMixingCouplingCutoff.hypercubeKernel_reversible #print axioms MarkovChainMixingCouplingCutoff.walshChar_zero #print axioms MarkovChainMixingCouplingCutoff.walshChar_empty #print axioms MarkovChainMixingCouplingCutoff.walshChar_sq #print axioms MarkovChainMixingCouplingCutoff.walshChar_flipBit #print axioms MarkovChainMixingCouplingCutoff.walshChar_mul #print axioms MarkovChainMixingCouplingCutoff.walshChar_sum_eq #print axioms MarkovChainMixingCouplingCutoff.walshChar_orthonormal #print axioms MarkovChainMixingCouplingCutoff.hypercubeKernel_apply_walshChar #print axioms MarkovChainMixingCouplingCutoff.hypercubeKernel_pow_apply_walshChar #print axioms MarkovChainMixingCouplingCutoff.sum_walshChar_eq_dirac #print axioms MarkovChainMixingCouplingCutoff.hypercube_stepDist_walsh_expansion #print axioms MarkovChainMixingCouplingCutoff.hypercube_chi2_exact #print axioms MarkovChainMixingCouplingCutoff.hypercube_dgm_chi2_upper #print axioms MarkovChainMixingCouplingCutoff.hypercube_dgm_tv_lower #print axioms MarkovChainMixingCouplingCutoff.hypercube_dgm_sharp_cutoff_quarter_n_log_n #print axioms MarkovChainMixingCouplingCutoff.hypercube_half_lazy_chi2_upper #print axioms MarkovChainMixingCouplingCutoff.insertCycle_injective #print axioms MarkovChainMixingCouplingCutoff.topToRandomKernel_uniform_stationary #print axioms MarkovChainMixingCouplingCutoff.sstTail_closed_form #print axioms MarkovChainMixingCouplingCutoff.sstTail_one_eq_couponMissProb #print axioms MarkovChainMixingCouplingCutoff.sstTail_one_le_n_exp #print axioms MarkovChainMixingCouplingCutoff.topToRandom_sst_witness #print axioms MarkovChainMixingCouplingCutoff.topToRandom_tv_upper_cutoff #print axioms MarkovChainMixingCouplingCutoff.topToRandom_upper_window #print axioms MarkovChainMixingCouplingCutoff.topToRandom_bottom_order_uniform_prob #print axioms MarkovChainMixingCouplingCutoff.topToRandom_tv_lower_via_bottom_k #print axioms MarkovChainMixingCouplingCutoff.topToRandom_bottom_k_survival_lower #print axioms MarkovChainMixingCouplingCutoff.lazyCycle_quadratic_mixing_lower_bound