import Mathlib /-! # Exact Finite-N Kuramoto Dynamics, Gradient Potential, Tree Critical Coupling & Cycle Holonomy This file provides a 100% self-contained Lean 4 / Mathlib formalization of the finite-$N$ Kuramoto coupled-oscillator dynamical system on weighted undirected graphs $G = (V, A)$, establishing: 1. **Exact Order-Parameter & Mean-Field Identities** (`orderParamSq_eq_double_sum`, `orderParamSq_bounds_and_sync_iff`, `completeGraph_meanField_reformulation`). 2. **Exact Gradient Flow, Mean-Frequency Invariance & Lyapunov Dissipation** (`kuramoto_mean_frequency_invariance`, `kuramoto_potential_partial_deriv`, `kuramoto_lyapunov_dissipation`, `kuramoto_cut_lower_bound`). 3. **Necessary & Sufficient Exact Critical Coupling on Trees (Dekker–Taylor / Dörfler–Bullo)** (`tree_kuramoto_exact_critical_coupling`, `tree_kuramoto_strict_stability_above_Kc`, with exact specializations to paths $P_n$ and stars $S_n$). 4. **Exact Complete-Graph $K_{2m}$ Two-Cluster Critical Coupling & General Spectral/$\ell_\infty$ Bounds** (`completeGraph_twoCluster_exact_Kc`, `completeGraph_arbitrary_omega_bounds`, `general_graph_spectral_freq_bound`). 5. **Exact Cycle $C_n$ Circulation Barrier, Two-Cluster Threshold & Strict $C_3$ Holonomy Gap** (`cycle_kuramoto_circulation_lower_bound`, `cycle_twoCluster_exact_Kc`, `cycle3_topological_holonomy_gap`). -/ open scoped BigOperators open Finset Real namespace KuramotoCore /-! ## Section 1: Weighted Undirected Graphs, Kuramoto RHS, Potential & Order Parameter -/ /-- A finite weighted undirected graph on `Fin n` with nonnegative symmetric weights and zero self-loops. -/ structure WeightedGraph (n : ℕ) where weight : Fin n → Fin n → ℝ symm : ∀ i j, weight i j = weight j i nonneg : ∀ i j, 0 ≤ weight i j diag_zero : ∀ i, weight i i = 0 /-- The finite-$N$ Kuramoto vector field $F_i(\theta) = \omega_i + \sum_j a_{ij} \sin(\theta_j - \theta_i)$. -/ noncomputable def kuramotoRHS {n : ℕ} (G : WeightedGraph n) (ω θ : Fin n → ℝ) (i : Fin n) : ℝ := ω i + ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i) /-- A phase configuration $\theta$ is a frequency-locked equilibrium if $F_i(\theta) = 0$ for all $i$. -/ def IsKuramotoEquilibrium {n : ℕ} (G : WeightedGraph n) (ω θ : Fin n → ℝ) : Prop := ∀ i : Fin n, kuramotoRHS G ω θ i = 0 /-- The Kuramoto Lyapunov / energy potential $V(\theta) = -\sum_i \omega_i \theta_i - \frac{1}{2}\sum_{i,j} a_{ij} \cos(\theta_j - \theta_i)$. -/ noncomputable def kuramotoPotential {n : ℕ} (G : WeightedGraph n) (ω θ : Fin n → ℝ) : ℝ := -(∑ i : Fin n, ω i * θ i) - (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.cos (θ j - θ i) /-- Quadratic form of the Hessian $\nabla^2 V(\theta) = -J(\theta)$: $v^\top \nabla^2 V(\theta) v = \frac{1}{2} \sum_{i,j} a_{ij} \cos(\theta_j - \theta_i) (v_j - v_i)^2$. -/ noncomputable def kuramotoHessianQuad {n : ℕ} (G : WeightedGraph n) (θ v : Fin n → ℝ) : ℝ := (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.cos (θ j - θ i) * (v j - v i) ^ 2 /-- Real part of the complex order parameter $C(\theta) = \frac{1}{n}\sum_j \cos \theta_j$. -/ noncomputable def orderCos {n : ℕ} (θ : Fin n → ℝ) : ℝ := (∑ j : Fin n, Real.cos (θ j)) / (n : ℝ) /-- Imaginary part of the complex order parameter $S(\theta) = \frac{1}{n}\sum_j \sin \theta_j$. -/ noncomputable def orderSin {n : ℕ} (θ : Fin n → ℝ) : ℝ := (∑ j : Fin n, Real.sin (θ j)) / (n : ℝ) /-- Squared modulus of the Kuramoto order parameter $R(\theta)^2 = C(\theta)^2 + S(\theta)^2$. -/ noncomputable def orderParamSq {n : ℕ} (θ : Fin n → ℝ) : ℝ := (orderCos θ) ^ 2 + (orderSin θ) ^ 2 /-- Kuramoto order parameter $R(\theta) = \sqrt{C(\theta)^2 + S(\theta)^2}$. -/ noncomputable def orderParam {n : ℕ} (θ : Fin n → ℝ) : ℝ := Real.sqrt (orderParamSq θ) /-- Complete graph $K_n$ with uniform edge coupling $K \ge 0$. -/ def completeGraph (n : ℕ) (K : ℝ) (hK : 0 ≤ K) : WeightedGraph n where weight i j := if i = j then 0 else K symm i j := by by_cases h : i = j · subst h; simp · have h' : j ≠ i := Ne.symm h simp [h, h'] nonneg i j := by split_ifs <;> linarith diag_zero i := by simp /-! ## Section 2: Order-Parameter Identities & Complete-Graph Mean-Field Reduction -/ /-- Exact double-sum formula for the squared order parameter: $R(\theta)^2 = \frac{1}{n^2}\sum_{i,j} \cos(\theta_j - \theta_i) = 1 - \frac{1}{n^2}\sum_{i,j}(1 - \cos(\theta_j - \theta_i))$. -/ theorem orderParamSq_eq_double_sum {n : ℕ} (hn : 0 < n) (θ : Fin n → ℝ) : orderParamSq θ = (∑ i : Fin n, ∑ j : Fin n, Real.cos (θ j - θ i)) / (n : ℝ) ^ 2 ∧ orderParamSq θ = 1 - (∑ i : Fin n, ∑ j : Fin n, (1 - Real.cos (θ j - θ i))) / (n : ℝ) ^ 2 := by have hnR : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hn) have hsum : (∑ i : Fin n, Real.cos (θ i)) ^ 2 + (∑ i : Fin n, Real.sin (θ i)) ^ 2 = ∑ i : Fin n, ∑ j : Fin n, Real.cos (θ j - θ i) := by rw [sq, sq, Finset.sum_mul_sum, Finset.sum_mul_sum, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun j _ => ?_ rw [Real.cos_sub] ring have h1 : orderParamSq θ = (∑ i : Fin n, ∑ j : Fin n, Real.cos (θ j - θ i)) / (n : ℝ) ^ 2 := by unfold orderParamSq orderCos orderSin rw [div_pow, div_pow, ← add_div, hsum] have h2 : ∑ i : Fin n, ∑ j : Fin n, (1 - Real.cos (θ j - θ i)) = (n : ℝ) ^ 2 - ∑ i : Fin n, ∑ j : Fin n, Real.cos (θ j - θ i) := by simp_rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] ring refine ⟨h1, ?_⟩ rw [h1, h2, sub_div, div_self (pow_ne_zero 2 hnR)] ring /-- Universal bounds $0 \le R(\theta)^2 \le 1$, and exact characterization of full synchronization: $R(\theta)^2 = 1 \iff \forall i\, j,\; \cos(\theta_j - \theta_i) = 1$. -/ theorem orderParamSq_bounds_and_sync_iff {n : ℕ} (hn : 0 < n) (θ : Fin n → ℝ) : 0 ≤ orderParamSq θ ∧ orderParamSq θ ≤ 1 ∧ (orderParamSq θ = 1 ↔ ∀ i j : Fin n, Real.cos (θ j - θ i) = 1) := by have hnR : (0 : ℝ) < (n : ℝ) ^ 2 := by positivity have hnonneg : 0 ≤ orderParamSq θ := by unfold orderParamSq; positivity have hdiff_nonneg : ∀ i j : Fin n, 0 ≤ 1 - Real.cos (θ j - θ i) := fun i j => by linarith [Real.cos_le_one (θ j - θ i)] have hsum_nonneg : 0 ≤ ∑ i : Fin n, ∑ j : Fin n, (1 - Real.cos (θ j - θ i)) := Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => hdiff_nonneg i j have hform := (orderParamSq_eq_double_sum hn θ).2 have hle1 : orderParamSq θ ≤ 1 := by rw [hform] have hq : 0 ≤ (∑ i : Fin n, ∑ j : Fin n, (1 - Real.cos (θ j - θ i))) / (n : ℝ) ^ 2 := div_nonneg hsum_nonneg hnR.le linarith refine ⟨hnonneg, hle1, ?_⟩ constructor · intro h1 i j have hdiv : (∑ a : Fin n, ∑ b : Fin n, (1 - Real.cos (θ b - θ a))) / (n : ℝ) ^ 2 = 0 := by linarith have hzero : ∑ a : Fin n, ∑ b : Fin n, (1 - Real.cos (θ b - θ a)) = 0 := by exact (div_eq_zero_iff.mp hdiv).resolve_right (ne_of_gt hnR) have hi : ∑ b : Fin n, (1 - Real.cos (θ b - θ i)) = 0 := by exact (Finset.sum_eq_zero_iff_of_nonneg fun a _ => Finset.sum_nonneg fun b _ => hdiff_nonneg a b).mp hzero i (Finset.mem_univ i) have hij : 1 - Real.cos (θ j - θ i) = 0 := by exact (Finset.sum_eq_zero_iff_of_nonneg fun b _ => hdiff_nonneg i b).mp hi j (Finset.mem_univ j) linarith · intro hall rw [hform] have hzero : ∑ a : Fin n, ∑ b : Fin n, (1 - Real.cos (θ b - θ a)) = 0 := by refine Finset.sum_eq_zero fun a _ => Finset.sum_eq_zero fun b _ => ?_ rw [hall a b, sub_self] rw [hzero, zero_div, sub_zero] /-- Exact mean-field reformulation of the Kuramoto coupling on $K_n$ with coupling $K/n$: $\sum_{j \ne i} \frac{K}{n}\sin(\theta_j - \theta_i) = K(S(\theta)\cos\theta_i - C(\theta)\sin\theta_i)$. -/ theorem completeGraph_meanField_reformulation {n : ℕ} (hn : 0 < n) (K : ℝ) (hK : 0 ≤ K) (ω θ : Fin n → ℝ) (i : Fin n) : kuramotoRHS (completeGraph n (K / (n : ℝ)) (div_nonneg hK (Nat.cast_nonneg n))) ω θ i = ω i + K * (orderSin θ * Real.cos (θ i) - orderCos θ * Real.sin (θ i)) := by have hnR : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hn) unfold kuramotoRHS completeGraph orderSin orderCos dsimp only congr 1 have h1 : ∑ j : Fin n, (if i = j then (0 : ℝ) else K / (n : ℝ)) * Real.sin (θ j - θ i) = ∑ j : Fin n, (K / (n : ℝ)) * Real.sin (θ j - θ i) := by refine Finset.sum_congr rfl fun j _ => ?_ by_cases h : i = j · subst h; simp · simp [h] rw [h1, ← Finset.mul_sum] have h2 : ∑ j : Fin n, Real.sin (θ j - θ i) = (∑ j : Fin n, Real.sin (θ j)) * Real.cos (θ i) - (∑ j : Fin n, Real.cos (θ j)) * Real.sin (θ i) := by simp_rw [Real.sin_sub, Finset.sum_sub_distrib, Finset.sum_mul] rw [h2] field_simp [hnR] /-! ## Section 3: Mean-Frequency Invariance, Gradient Flow & Universal Cut Lower Bound -/ /-- Exact skew-symmetry cancellation: for any symmetric weight matrix $a_{ij} = a_{ji}$, $\sum_{i,j} a_{ij} \sin(\theta_j - \theta_i) = 0$. -/ lemma sum_symm_weight_sin_eq_zero {n : ℕ} (G : WeightedGraph n) (θ : Fin n → ℝ) : ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i) = 0 := by set S := ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i) have hswap : S = -S := by calc S = ∑ j : Fin n, ∑ i : Fin n, G.weight i j * Real.sin (θ j - θ i) := Finset.sum_comm _ = ∑ j : Fin n, ∑ i : Fin n, -(G.weight j i * Real.sin (θ i - θ j)) := by refine Finset.sum_congr rfl fun j _ => Finset.sum_congr rfl fun i _ => ?_ rw [G.symm i j, ← neg_sub (θ i) (θ j), Real.sin_neg] ring _ = -S := by simp_rw [Finset.sum_neg_distrib] rfl linarith /-- **Exact Mean-Frequency Invariance:** On any undirected weighted graph $G$, $\sum_i F_i(\theta) = \sum_i \omega_i$ identically for all $\theta$. In particular, any frequency-locked equilibrium requires $\sum_i \omega_i = 0$. -/ theorem kuramoto_mean_frequency_invariance {n : ℕ} (G : WeightedGraph n) (ω θ : Fin n → ℝ) : ∑ i : Fin n, kuramotoRHS G ω θ i = ∑ i : Fin n, ω i := by unfold kuramotoRHS rw [Finset.sum_add_distrib, sum_symm_weight_sin_eq_zero G θ, add_zero] /-- Corollary: zero-sum frequency condition is necessary for equilibrium on any undirected graph. -/ lemma sum_omega_eq_zero_of_equilibrium {n : ℕ} {G : WeightedGraph n} {ω θ : Fin n → ℝ} (heq : IsKuramotoEquilibrium G ω θ) : ∑ i : Fin n, ω i = 0 := by rw [← kuramoto_mean_frequency_invariance G ω θ] exact Finset.sum_eq_zero fun i _ => heq i /-- **Exact Partial Derivative of the Kuramoto Potential:** $\frac{\partial V}{\partial \theta_i}(\theta) = -F_i(\theta)$, proving $\dot{\theta} = -\nabla V(\theta)$. -/ theorem kuramoto_potential_partial_deriv {n : ℕ} (G : WeightedGraph n) (ω θ : Fin n → ℝ) (i : Fin n) : HasDerivAt (fun x : ℝ => kuramotoPotential G ω (Function.update θ i x)) (-kuramotoRHS G ω θ i) (θ i) := by -- Express V(update θ i x) cleanly as a function of x alone plus a constant have hV : ∀ x : ℝ, kuramotoPotential G ω (Function.update θ i x) = -(ω i * x) - (∑ j : Fin n, G.weight i j * Real.cos (θ j - x)) + (-(∑ k ∈ Finset.univ.erase i, ω k * θ k) - (1 / 2 : ℝ) * ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase i, G.weight k l * Real.cos (θ l - θ k)) := by intro x unfold kuramotoPotential have hlin : ∑ k : Fin n, ω k * Function.update θ i x k = ω i * x + ∑ k ∈ Finset.univ.erase i, ω k * θ k := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i)] simp only [Function.update_self] congr 1 refine Finset.sum_congr rfl fun k hk => ?_ rw [Function.update_of_ne (Finset.ne_of_mem_erase hk)] have hquad : ∑ k : Fin n, ∑ l : Fin n, G.weight k l * Real.cos (Function.update θ i x l - Function.update θ i x k) = 2 * (∑ j : Fin n, G.weight i j * Real.cos (θ j - x)) + ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase i, G.weight k l * Real.cos (θ l - θ k) := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i)] -- First term: k = i have hk_i : ∑ l : Fin n, G.weight i l * Real.cos (Function.update θ i x l - Function.update θ i x i) = ∑ j : Fin n, G.weight i j * Real.cos (θ j - x) := by refine Finset.sum_congr rfl fun l _ => ?_ by_cases hl : l = i · subst hl; simp [G.diag_zero] · simp [Function.update_of_ne hl] -- Second term: k ≠ i, split l = i vs l ≠ i have hk_ne : ∑ k ∈ Finset.univ.erase i, ∑ l : Fin n, G.weight k l * Real.cos (Function.update θ i x l - Function.update θ i x k) = (∑ j : Fin n, G.weight i j * Real.cos (θ j - x)) + ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase i, G.weight k l * Real.cos (θ l - θ k) := by have hstep : ∀ k ∈ Finset.univ.erase i, ∑ l : Fin n, G.weight k l * Real.cos (Function.update θ i x l - Function.update θ i x k) = G.weight i k * Real.cos (θ k - x) + ∑ l ∈ Finset.univ.erase i, G.weight k l * Real.cos (θ l - θ k) := by intro k hk have hki : k ≠ i := Finset.ne_of_mem_erase hk rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i)] simp only [Function.update_self, Function.update_of_ne hki] congr 1 · rw [G.symm k i, ← neg_sub (θ k) x, Real.cos_neg] · refine Finset.sum_congr rfl fun l hl => ?_ rw [Function.update_of_ne (Finset.ne_of_mem_erase hl)] rw [Finset.sum_congr rfl hstep, Finset.sum_add_distrib] congr 1 rw [← Finset.add_sum_erase (s := Finset.univ) (f := fun j => G.weight i j * Real.cos (θ j - x)) (Finset.mem_univ i)] simp [G.diag_zero] rw [hk_i, hk_ne]; ring rw [hlin, hquad]; ring rw [show (fun x => kuramotoPotential G ω (Function.update θ i x)) = fun x => -(ω i * x) - (∑ j : Fin n, G.weight i j * Real.cos (θ j - x)) + (-(∑ k ∈ Finset.univ.erase i, ω k * θ k) - (1 / 2 : ℝ) * ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase i, G.weight k l * Real.cos (θ l - θ k)) from funext hV] have hd1 : HasDerivAt (fun x : ℝ => -(ω i * x)) (-ω i) (θ i) := by have h : HasDerivAt (fun x : ℝ => ω i * x) (ω i) (θ i) := by simpa using (hasDerivAt_id (θ i)).const_mul (ω i) exact h.fun_neg have hd2 : HasDerivAt (fun x : ℝ => ∑ j : Fin n, G.weight i j * Real.cos (θ j - x)) (∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i)) (θ i) := by have hterm : ∀ j ∈ (Finset.univ : Finset (Fin n)), HasDerivAt (fun x : ℝ => G.weight i j * Real.cos (θ j - x)) (G.weight i j * Real.sin (θ j - θ i)) (θ i) := by intro j _ have hsub : HasDerivAt (fun x : ℝ => θ j - x) (-1) (θ i) := by simpa using (hasDerivAt_const (θ i) (θ j)).fun_sub (hasDerivAt_id (θ i)) have hcos : HasDerivAt (fun x : ℝ => Real.cos (θ j - x)) (-Real.sin (θ j - θ i) * (-1)) (θ i) := hsub.cos have hmul : HasDerivAt (fun x : ℝ => G.weight i j * Real.cos (θ j - x)) (G.weight i j * (-Real.sin (θ j - θ i) * (-1))) (θ i) := hcos.const_mul (G.weight i j) have hval : G.weight i j * (-Real.sin (θ j - θ i) * (-1)) = G.weight i j * Real.sin (θ j - θ i) := by ring rwa [hval] at hmul exact HasDerivAt.fun_sum hterm have hd3 := (hd1.fun_sub hd2).add_const (-(∑ k ∈ Finset.univ.erase i, ω k * θ k) - (1 / 2 : ℝ) * ∑ k ∈ Finset.univ.erase i, ∑ l ∈ Finset.univ.erase i, G.weight k l * Real.cos (θ l - θ k)) have hval : -ω i - ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i) = -kuramotoRHS G ω θ i := by unfold kuramotoRHS; ring rwa [hval] at hd3 /-- **Exact Lyapunov Energy Dissipation along Kuramoto Trajectories:** For any differentiable trajectory $\theta(t)$ solving $\dot{\theta}_i(t) = F_i(\theta(t))$ at time $t$, $\frac{d}{dt} V(\theta(t)) = -\sum_i F_i(\theta(t))^2 \le 0$. -/ theorem kuramoto_lyapunov_dissipation {n : ℕ} (G : WeightedGraph n) (ω : Fin n → ℝ) (θ : ℝ → Fin n → ℝ) (t : ℝ) (hode : ∀ i : Fin n, HasDerivAt (fun s => θ s i) (kuramotoRHS G ω (θ t) i) t) : HasDerivAt (fun s => kuramotoPotential G ω (θ s)) (-(∑ i : Fin n, (kuramotoRHS G ω (θ t) i) ^ 2)) t ∧ -(∑ i : Fin n, (kuramotoRHS G ω (θ t) i) ^ 2) ≤ 0 := by have h1 : HasDerivAt (fun s => -(∑ i : Fin n, ω i * θ s i)) (-(∑ i : Fin n, ω i * kuramotoRHS G ω (θ t) i)) t := by have hsum : HasDerivAt (fun s => ∑ i : Fin n, ω i * θ s i) (∑ i : Fin n, ω i * kuramotoRHS G ω (θ t) i) t := HasDerivAt.fun_sum fun i _ => (hode i).const_mul (ω i) exact hsum.neg have h2 : HasDerivAt (fun s => (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.cos (θ s j - θ s i)) ((1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (-Real.sin (θ t j - θ t i) * (kuramotoRHS G ω (θ t) j - kuramotoRHS G ω (θ t) i))) t := by refine HasDerivAt.const_mul (1 / 2 : ℝ) ?_ refine HasDerivAt.fun_sum fun i _ => HasDerivAt.fun_sum fun j _ => ?_ exact ((hode j).sub (hode i)).cos.const_mul (G.weight i j) have hsub := h1.sub h2 -- Simplify the derivative using symmetry of G.weight and skew-symmetry of sin have hsimp : -(∑ i : Fin n, ω i * kuramotoRHS G ω (θ t) i) - (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (-Real.sin (θ t j - θ t i) * (kuramotoRHS G ω (θ t) j - kuramotoRHS G ω (θ t) i)) = -(∑ i : Fin n, (kuramotoRHS G ω (θ t) i) ^ 2) := by set F := fun i => kuramotoRHS G ω (θ t) i have hdouble : (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (-Real.sin (θ t j - θ t i) * (F j - F i)) = ∑ i : Fin n, F i * (∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i)) := by have hsplit : ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (-Real.sin (θ t j - θ t i) * (F j - F i)) = (∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F i) - (∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F j) := by rw [← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun i _ => ?_ rw [← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun j _ => ?_ ring have hswap : ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F j = -(∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F i) := by calc ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F j = ∑ j : Fin n, ∑ i : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F j := Finset.sum_comm _ = ∑ j : Fin n, ∑ i : Fin n, -(G.weight j i * Real.sin (θ t i - θ t j) * F j) := by refine Finset.sum_congr rfl fun j _ => Finset.sum_congr rfl fun i _ => ?_ rw [G.symm i j, ← neg_sub (θ t i) (θ t j), Real.sin_neg]; ring _ = -(∑ j : Fin n, ∑ i : Fin n, G.weight j i * Real.sin (θ t i - θ t j) * F j) := by simp_rw [Finset.sum_neg_distrib] rw [hsplit, hswap] have hfactor : ∑ i : Fin n, ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) * F i = ∑ i : Fin n, F i * (∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i)) := by refine Finset.sum_congr rfl fun i _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun j _ => ?_ ring rw [hfactor]; ring rw [hdouble] have hrhs : ∑ i : Fin n, (F i) ^ 2 = ∑ i : Fin n, ω i * F i + ∑ i : Fin n, F i * (∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i)) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ have hFi : F i = ω i + ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i) := rfl calc (F i) ^ 2 = F i * F i := sq (F i) _ = F i * (ω i + ∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i)) := by rw [← hFi] _ = ω i * F i + F i * (∑ j : Fin n, G.weight i j * Real.sin (θ t j - θ t i)) := by ring linarith refine ⟨?_, ?_⟩ · unfold kuramotoPotential rw [← hsimp] exact hsub · exact neg_nonpos.mpr (Finset.sum_nonneg fun i _ => sq_nonneg _) /-- **Universal Cut Lower Bound:** For any weighted undirected graph $G$, any frequency-locked equilibrium $\theta$, and any vertex cut $S \subseteq V$, $\left|\sum_{i \in S} \omega_i\right| \le \sum_{i \in S}\sum_{j \notin S} a_{ij}$. -/ theorem kuramoto_cut_lower_bound {n : ℕ} (G : WeightedGraph n) (ω θ : Fin n → ℝ) (heq : IsKuramotoEquilibrium G ω θ) (S : Finset (Fin n)) : |∑ i ∈ S, ω i| ≤ ∑ i ∈ S, ∑ j ∈ Sᶜ, G.weight i j := by -- Internal coupling within S cancels by skew-symmetry have hinternal : ∑ i ∈ S, ∑ j ∈ S, G.weight i j * Real.sin (θ j - θ i) = 0 := by set I := ∑ i ∈ S, ∑ j ∈ S, G.weight i j * Real.sin (θ j - θ i) have hswap : I = -I := by calc I = ∑ j ∈ S, ∑ i ∈ S, G.weight i j * Real.sin (θ j - θ i) := Finset.sum_comm _ = ∑ j ∈ S, ∑ i ∈ S, -(G.weight j i * Real.sin (θ i - θ j)) := by refine Finset.sum_congr rfl fun j _ => Finset.sum_congr rfl fun i _ => ?_ rw [G.symm i j, ← neg_sub (θ i) (θ j), Real.sin_neg]; ring _ = -I := by simp_rw [Finset.sum_neg_distrib]; rfl linarith have hbal : ∑ i ∈ S, ω i = -(∑ i ∈ S, ∑ j ∈ Sᶜ, G.weight i j * Real.sin (θ j - θ i)) := by have h0 : ∑ i ∈ S, kuramotoRHS G ω θ i = 0 := Finset.sum_eq_zero fun i _ => heq i unfold kuramotoRHS at h0 rw [Finset.sum_add_distrib] at h0 have hsplit : ∑ i ∈ S, ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i) = (∑ i ∈ S, ∑ j ∈ S, G.weight i j * Real.sin (θ j - θ i)) + (∑ i ∈ S, ∑ j ∈ Sᶜ, G.weight i j * Real.sin (θ j - θ i)) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ exact (Finset.sum_add_sum_compl S (fun j => G.weight i j * Real.sin (θ j - θ i))).symm rw [hsplit, hinternal, zero_add] at h0 linarith rw [hbal, abs_neg] calc |∑ i ∈ S, ∑ j ∈ Sᶜ, G.weight i j * Real.sin (θ j - θ i)| ≤ ∑ i ∈ S, |∑ j ∈ Sᶜ, G.weight i j * Real.sin (θ j - θ i)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ i ∈ S, ∑ j ∈ Sᶜ, |G.weight i j * Real.sin (θ j - θ i)| := Finset.sum_le_sum fun i _ => Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ i ∈ S, ∑ j ∈ Sᶜ, G.weight i j := by refine Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => ?_ rw [abs_mul, abs_of_nonneg (G.nonneg i j)] exact mul_le_of_le_one_right (G.nonneg i j) (Real.abs_sin_le_one _) /-! ## Section 4: Necessary & Sufficient Exact Critical Coupling on Trees (Dekker–Taylor / Dörfler–Bullo) -/ /-- A topologically ordered rooted tree on `Fin n` ($n \ge 1$) with root `0`: every non-root vertex $u > 0$ has a unique parent `parent u < u`. Every finite tree admits such a topological ordering (e.g. BFS/DFS numbering from any root). -/ structure RootedTree (n : ℕ) where hn : 0 < n parent : Fin n → Fin n parent_root : parent ⟨0, hn⟩ = ⟨0, hn⟩ parent_lt : ∀ u : Fin n, u.val ≠ 0 → (parent u).val < u.val namespace RootedTree /-- The set of children of vertex $u$ in a rooted tree. -/ def children {n : ℕ} (T : RootedTree n) (u : Fin n) : Finset (Fin n) := Finset.univ.filter fun c => c.val ≠ 0 ∧ T.parent c = u /-- Every child of $u$ has strictly larger index than $u$. -/ lemma lt_of_mem_children {n : ℕ} (T : RootedTree n) {u c : Fin n} (hc : c ∈ T.children u) : u.val < c.val := by simp only [children, Finset.mem_filter, Finset.mem_univ, true_and] at hc rw [← hc.2] exact T.parent_lt c hc.1 /-- Weighted graph of a rooted tree with uniform edge coupling $K \ge 0$. -/ def graph {n : ℕ} (T : RootedTree n) (K : ℝ) (hK : 0 ≤ K) : WeightedGraph n where weight i j := if (i.val ≠ 0 ∧ T.parent i = j) ∨ (j.val ≠ 0 ∧ T.parent j = i) then K else 0 symm i j := by by_cases h : (i.val ≠ 0 ∧ T.parent i = j) ∨ (j.val ≠ 0 ∧ T.parent j = i) · have h' : (j.val ≠ 0 ∧ T.parent j = i) ∨ (i.val ≠ 0 ∧ T.parent i = j) := h.symm simp [h, h'] · have h' : ¬((j.val ≠ 0 ∧ T.parent j = i) ∨ (i.val ≠ 0 ∧ T.parent i = j)) := fun x => h x.symm simp [h, h'] nonneg i j := by split_ifs <;> linarith diag_zero i := by have h : ¬(i.val ≠ 0 ∧ T.parent i = i) := by rintro ⟨hi, heq⟩ exact (ne_of_lt (T.parent_lt i hi)) (congrArg Fin.val heq) simp [h] /-- Exact neighbor decomposition of the Kuramoto RHS on a rooted tree. -/ lemma rhs_eq {n : ℕ} (T : RootedTree n) (K : ℝ) (hK : 0 ≤ K) (ω θ : Fin n → ℝ) (u : Fin n) : kuramotoRHS (T.graph K hK) ω θ u = ω u + (if u.val ≠ 0 then K * Real.sin (θ (T.parent u) - θ u) else 0) + ∑ c ∈ T.children u, K * Real.sin (θ c - θ u) := by unfold kuramotoRHS graph dsimp only -- Split the sum over j into parent (if u ≠ 0) and children of u have hdisj : ∀ j : Fin n, (if (u.val ≠ 0 ∧ T.parent u = j) ∨ (j.val ≠ 0 ∧ T.parent j = u) then K else 0) * Real.sin (θ j - θ u) = (if u.val ≠ 0 ∧ T.parent u = j then K * Real.sin (θ j - θ u) else 0) + (if j.val ≠ 0 ∧ T.parent j = u then K * Real.sin (θ j - θ u) else 0) := by intro j by_cases h1 : u.val ≠ 0 ∧ T.parent u = j · have h2 : ¬(j.val ≠ 0 ∧ T.parent j = u) := by rintro ⟨hj, hp⟩ have lt1 := T.parent_lt u h1.1 have lt2 := T.parent_lt j hj rw [h1.2] at lt1; rw [hp] at lt2; omega rw [if_pos (Or.inl h1), if_pos h1, if_neg h2, add_zero] · by_cases h2 : j.val ≠ 0 ∧ T.parent j = u · rw [if_pos (Or.inr h2), if_neg h1, if_pos h2, zero_add] · have hnot : ¬((u.val ≠ 0 ∧ T.parent u = j) ∨ (j.val ≠ 0 ∧ T.parent j = u)) := not_or.mpr ⟨h1, h2⟩ rw [if_neg hnot, if_neg h1, if_neg h2]; ring simp_rw [hdisj, Finset.sum_add_distrib] have hpar : ∑ j : Fin n, (if u.val ≠ 0 ∧ T.parent u = j then K * Real.sin (θ j - θ u) else 0) = if u.val ≠ 0 then K * Real.sin (θ (T.parent u) - θ u) else 0 := by by_cases hu : u.val ≠ 0 · rw [if_pos hu, Finset.sum_eq_single (T.parent u)] · rw [if_pos ⟨hu, rfl⟩] · intro j _ hne; exact if_neg (fun h => hne h.2.symm) · intro h; exact absurd (Finset.mem_univ _) h · rw [if_neg hu] refine Finset.sum_eq_zero fun j _ => if_neg (fun h => hu h.1) have hch : ∑ j : Fin n, (if j.val ≠ 0 ∧ T.parent j = u then K * Real.sin (θ j - θ u) else 0) = ∑ c ∈ T.children u, K * Real.sin (θ c - θ u) := by unfold children rw [Finset.sum_filter] rw [hpar, hch]; ring /-- The unique tree edge flow $f_u(\omega) = (B^\dagger \omega)_{(u, p(u))} = \sum_{v \in S_u} \omega_v$, computed bottom-up in reverse topological order. -/ noncomputable def edgeFlow {n : ℕ} (T : RootedTree n) (ω : Fin n → ℝ) (u : Fin n) : ℝ := ω u + ∑ c ∈ (T.children u).attach, edgeFlow T ω c.1 termination_by n - 1 - u.val decreasing_by have hlt := T.lt_of_mem_children c.2 have _hc_lt := c.1.isLt omega /-- Exact bottom-up recurrence for the tree edge flow: $f_u(\omega) = \omega_u + \sum_{c \in \mathrm{children}(u)} f_c(\omega)$. -/ lemma edgeFlow_eq {n : ℕ} (T : RootedTree n) (ω : Fin n → ℝ) (u : Fin n) : T.edgeFlow ω u = ω u + ∑ c ∈ T.children u, T.edgeFlow ω c := by rw [edgeFlow] congr 1 exact Finset.sum_attach (T.children u) (fun c => T.edgeFlow ω c) /-- Conservation of total frequency at the root: $f_0(\omega) = \sum_{v \in V} \omega_v$. -/ lemma edgeFlow_root_eq_sum {n : ℕ} (T : RootedTree n) (ω : Fin n → ℝ) : T.edgeFlow ω ⟨0, T.hn⟩ = ∑ v : Fin n, ω v := by -- Sum edgeFlow_eq over all u : Fin n; every non-root vertex appears once as a child have hsum : ∑ u : Fin n, T.edgeFlow ω u = (∑ u : Fin n, ω u) + ∑ u : Fin n, ∑ c ∈ T.children u, T.edgeFlow ω c := by rw [← Finset.sum_add_distrib] exact Finset.sum_congr rfl fun u _ => T.edgeFlow_eq ω u have hch_all : ∑ u : Fin n, ∑ c ∈ T.children u, T.edgeFlow ω c = ∑ c ∈ Finset.univ.erase ⟨0, T.hn⟩, T.edgeFlow ω c := by have h1 : ∀ u : Fin n, ∑ c ∈ T.children u, T.edgeFlow ω c = ∑ c ∈ Finset.univ.erase ⟨0, T.hn⟩, if T.parent c = u then T.edgeFlow ω c else 0 := by intro u unfold children rw [← Finset.sum_filter] refine Finset.sum_congr ?_ fun _ _ => rfl ext c simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_erase, ne_eq, Fin.ext_iff] simp simp_rw [h1] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun c _ => ?_ rw [Finset.sum_eq_single (T.parent c)] · simp · intro u _ hne; simp [Ne.symm hne] · intro h; exact absurd (Finset.mem_univ _) h rw [hch_all] at hsum have hsplit := Finset.add_sum_erase Finset.univ (fun u => T.edgeFlow ω u) (Finset.mem_univ ⟨0, T.hn⟩) linarith /-- **Unique Edge-Flow Theorem on Trees:** At ANY frequency-locked equilibrium $\theta$ on a tree $T$ with coupling $K \ge 0$, every non-root edge $(u, p(u))$ carries the unique sine flow $K \sin(\theta_u - \theta_{p(u)}) = f_u(\omega) = (B^\dagger \omega)_u$. -/ theorem equilibrium_edge_flow_exact {n : ℕ} (T : RootedTree n) (K : ℝ) (hK : 0 ≤ K) (ω θ : Fin n → ℝ) (heq : IsKuramotoEquilibrium (T.graph K hK) ω θ) : ∀ u : Fin n, u.val ≠ 0 → K * Real.sin (θ u - θ (T.parent u)) = T.edgeFlow ω u := by -- Strong downward induction on d = n - 1 - u.val suffices h : ∀ d : ℕ, ∀ u : Fin n, n - 1 - u.val = d → u.val ≠ 0 → K * Real.sin (θ u - θ (T.parent u)) = T.edgeFlow ω u by intro u hu; exact h (n - 1 - u.val) u rfl hu intro d induction d using Nat.strong_induction_on with | h d ih => intro u hd hu have hrhs := heq u rw [T.rhs_eq K hK ω θ u, if_pos hu] at hrhs have hch : ∑ c ∈ T.children u, K * Real.sin (θ c - θ u) = ∑ c ∈ T.children u, T.edgeFlow ω c := by refine Finset.sum_congr rfl fun c hc => ?_ have hc_spec : c.val ≠ 0 ∧ T.parent c = u := by simpa [children] using hc have hlt : u.val < c.val := T.lt_of_mem_children hc have _hc_lt : c.val < n := c.isLt have hd' : n - 1 - c.val < d := by omega rw [← hc_spec.2] exact ih (n - 1 - c.val) hd' c rfl hc_spec.1 rw [hch] at hrhs rw [T.edgeFlow_eq ω u] have hsin : Real.sin (θ (T.parent u) - θ u) = -Real.sin (θ u - θ (T.parent u)) := by rw [← neg_sub (θ u) (θ (T.parent u)), Real.sin_neg] rw [hsin] at hrhs linarith /-- Explicit top-down construction of the principal-branch equilibrium phase vector on a tree $T$ for any $K > 0$ satisfying $\max_{u \ne 0} |f_u(\omega)| \le K$. -/ noncomputable def principalPhase {n : ℕ} (T : RootedTree n) (K : ℝ) (ω : Fin n → ℝ) (u : Fin n) : ℝ := if u.val = 0 then 0 else principalPhase T K ω (T.parent u) + Real.arcsin (T.edgeFlow ω u / K) termination_by u.val decreasing_by exact T.parent_lt u (by assumption) lemma principalPhase_step {n : ℕ} (T : RootedTree n) (K : ℝ) (ω : Fin n → ℝ) (u : Fin n) (hu : u.val ≠ 0) : T.principalPhase K ω u = T.principalPhase K ω (T.parent u) + Real.arcsin (T.edgeFlow ω u / K) := by rw [principalPhase, if_neg hu] /-- **Necessary & Sufficient Exact Critical Coupling on Trees (Dekker–Taylor / Dörfler–Bullo):** For any rooted tree $T$, zero-mean frequency vector $\omega$ ($\sum_v \omega_v = 0$), and $K > 0$: a frequency-locked Kuramoto equilibrium exists **if and only if** $$K \;\ge\; K_c(T, \omega) := \max_{u \ne 0} |f_u(\omega)| = \|B^\dagger \omega\|_\infty.$$ -/ theorem tree_kuramoto_exact_critical_coupling {n : ℕ} (T : RootedTree n) (ω : Fin n → ℝ) (hzero : ∑ v : Fin n, ω v = 0) (K : ℝ) (hK : 0 < K) : (∃ θ : Fin n → ℝ, IsKuramotoEquilibrium (T.graph K hK.le) ω θ) ↔ ∀ u : Fin n, u.val ≠ 0 → |T.edgeFlow ω u| ≤ K := by constructor · rintro ⟨θ, heq⟩ u hu have hfl := T.equilibrium_edge_flow_exact K hK.le ω θ heq u hu rw [← hfl, abs_mul, abs_of_pos hK] exact mul_le_of_le_one_right hK.le (Real.abs_sin_le_one _) · intro hbound refine ⟨T.principalPhase K ω, ?_⟩ intro u rw [T.rhs_eq K hK.le ω (T.principalPhase K ω) u] have hch : ∑ c ∈ T.children u, K * Real.sin (T.principalPhase K ω c - T.principalPhase K ω u) = ∑ c ∈ T.children u, T.edgeFlow ω c := by refine Finset.sum_congr rfl fun c hc => ?_ have hc_spec : c.val ≠ 0 ∧ T.parent c = u := by simpa [children] using hc rw [T.principalPhase_step K ω c hc_spec.1, hc_spec.2, add_sub_cancel_left] have hbd := abs_le.mp (hbound c hc_spec.1) have hdiv1 : -1 ≤ T.edgeFlow ω c / K := by rw [le_div_iff₀ hK]; linarith have hdiv2 : T.edgeFlow ω c / K ≤ 1 := by rw [div_le_iff₀ hK]; linarith rw [Real.sin_arcsin hdiv1 hdiv2, mul_div_cancel₀ _ (ne_of_gt hK)] rw [hch] by_cases hu : u.val ≠ 0 · rw [if_pos hu, T.principalPhase_step K ω u hu] have hsub : T.principalPhase K ω (T.parent u) - (T.principalPhase K ω (T.parent u) + Real.arcsin (T.edgeFlow ω u / K)) = -Real.arcsin (T.edgeFlow ω u / K) := by ring rw [hsub, Real.sin_neg] have hbd := abs_le.mp (hbound u hu) have hdiv1 : -1 ≤ T.edgeFlow ω u / K := by rw [le_div_iff₀ hK]; linarith have hdiv2 : T.edgeFlow ω u / K ≤ 1 := by rw [div_le_iff₀ hK]; linarith rw [Real.sin_arcsin hdiv1 hdiv2] have hcancel : K * -(T.edgeFlow ω u / K) = -T.edgeFlow ω u := by field_simp [ne_of_gt hK] rw [hcancel, T.edgeFlow_eq ω u] ring · rw [if_neg hu] have hu_val : u.val = 0 := not_ne_iff.mp hu have hu0 : u = ⟨0, T.hn⟩ := Fin.ext hu_val subst hu0 have hroot : T.edgeFlow ω ⟨0, T.hn⟩ = 0 := by rw [T.edgeFlow_root_eq_sum, hzero] have hrec := T.edgeFlow_eq ω ⟨0, T.hn⟩ linarith /-- **Strict Linear Stability Above $K_c$ on Trees:** Whenever $K > \max_{u \ne 0} |f_u(\omega)|$, the principal equilibrium $\theta^*$ has $\cos(\theta^*_u - \theta^*_{p(u)}) > 0$ on every edge, so the Hessian $\nabla^2 V(\theta^*)$ is strictly positive definite on all non-constant perturbations $v \notin \mathrm{span}(\mathbf{1})$. -/ theorem tree_kuramoto_strict_stability_above_Kc {n : ℕ} (T : RootedTree n) (ω : Fin n → ℝ) (K : ℝ) (hK : 0 < K) (hstrict : ∀ u : Fin n, u.val ≠ 0 → |T.edgeFlow ω u| < K) (v : Fin n → ℝ) (hnonconst : ∃ a b : Fin n, v a ≠ v b) : 0 < kuramotoHessianQuad (T.graph K hK.le) (T.principalPhase K ω) v := by -- Every directed edge has strictly positive weight * cos have hcos_pos : ∀ u : Fin n, u.val ≠ 0 → 0 < Real.cos (T.principalPhase K ω u - T.principalPhase K ω (T.parent u)) := by intro u hu rw [T.principalPhase_step K ω u hu, add_sub_cancel_left, Real.cos_arcsin] refine Real.sqrt_pos.mpr ?_ have habs : |T.edgeFlow ω u / K| < 1 := by rw [abs_div, abs_of_pos hK, div_lt_one hK]; exact hstrict u hu have hsq : (T.edgeFlow ω u / K) ^ 2 < 1 := by nlinarith [sq_abs (T.edgeFlow ω u / K), abs_nonneg (T.edgeFlow ω u / K)] linarith have hterm_nonneg : ∀ i j : Fin n, 0 ≤ (T.graph K hK.le).weight i j * Real.cos (T.principalPhase K ω j - T.principalPhase K ω i) * (v j - v i) ^ 2 := by intro i j unfold graph; dsimp only by_cases h : (i.val ≠ 0 ∧ T.parent i = j) ∨ (j.val ≠ 0 ∧ T.parent j = i) · rw [if_pos h] have hcp : 0 < Real.cos (T.principalPhase K ω j - T.principalPhase K ω i) := by rcases h with ⟨hi, hij⟩ | ⟨hj, hji⟩ · rw [← hij, ← neg_sub (T.principalPhase K ω i) (T.principalPhase K ω (T.parent i)), Real.cos_neg] exact hcos_pos i hi · rw [← hji]; exact hcos_pos j hj positivity · rw [if_neg h]; simp -- Find a non-root vertex u where v u ≠ v (parent u) have hex_edge : ∃ u : Fin n, u.val ≠ 0 ∧ v u ≠ v (T.parent u) := by by_contra hall push Not at hall -- Induction shows v u = v 0 for all u have hconst : ∀ u : Fin n, v u = v ⟨0, T.hn⟩ := by intro u suffices ∀ k : ℕ, ∀ x : Fin n, x.val = k → v x = v ⟨0, T.hn⟩ from this u.val u rfl intro k induction k using Nat.strong_induction_on with | h k ih => intro x hx by_cases hx0 : x.val = 0 · congr 1; exact Fin.ext hx0 · rw [hall x hx0] exact ih (T.parent x).val (hx ▸ T.parent_lt x hx0) (T.parent x) rfl rcases hnonconst with ⟨a, b, hab⟩ exact hab (by rw [hconst a, hconst b]) rcases hex_edge with ⟨u, hu, hvu⟩ unfold kuramotoHessianQuad refine mul_pos (by norm_num) ?_ have hpos_term : 0 < (T.graph K hK.le).weight (T.parent u) u * Real.cos (T.principalPhase K ω u - T.principalPhase K ω (T.parent u)) * (v u - v (T.parent u)) ^ 2 := by have hw : (T.graph K hK.le).weight (T.parent u) u = K := by unfold graph; dsimp only; rw [if_pos (Or.inr ⟨hu, rfl⟩)] rw [hw] have hsq : 0 < (v u - v (T.parent u)) ^ 2 := sq_pos_of_ne_zero (sub_ne_zero.mpr hvu) exact mul_pos (mul_pos hK (hcos_pos u hu)) hsq calc 0 < (T.graph K hK.le).weight (T.parent u) u * Real.cos (T.principalPhase K ω u - T.principalPhase K ω (T.parent u)) * (v u - v (T.parent u)) ^ 2 := hpos_term _ ≤ ∑ j : Fin n, (T.graph K hK.le).weight (T.parent u) j * Real.cos (T.principalPhase K ω j - T.principalPhase K ω (T.parent u)) * (v j - v (T.parent u)) ^ 2 := Finset.single_le_sum (fun j _ => hterm_nonneg (T.parent u) j) (Finset.mem_univ u) _ ≤ ∑ i : Fin n, ∑ j : Fin n, (T.graph K hK.le).weight i j * Real.cos (T.principalPhase K ω j - T.principalPhase K ω i) * (v j - v i) ^ 2 := Finset.single_le_sum (fun i _ => Finset.sum_nonneg fun j _ => hterm_nonneg i j) (Finset.mem_univ (T.parent u)) /-- Path tree $P_n$ ($n \ge 1$) with parent of $u > 0$ equal to $u - 1$. -/ def pathTree (n : ℕ) (hn : 0 < n) : RootedTree n where hn := hn parent u := if hu : u.val = 0 then ⟨0, hn⟩ else ⟨u.val - 1, by omega⟩ parent_root := by simp parent_lt u hu := by simp [hu]; omega /-- Exact edge-flow formula on the path $P_n$: $f_u(\omega) = \sum_{j \ge u} \omega_j$. -/ theorem pathTree_edgeFlow_eq {n : ℕ} (hn : 0 < n) (ω : Fin n → ℝ) (u : Fin n) : (pathTree n hn).edgeFlow ω u = ∑ j ∈ Finset.univ.filter (fun j : Fin n => u.val ≤ j.val), ω j := by suffices h : ∀ d : ℕ, ∀ x : Fin n, n - 1 - x.val = d → (pathTree n hn).edgeFlow ω x = ∑ j ∈ Finset.univ.filter (fun j : Fin n => x.val ≤ j.val), ω j from h (n - 1 - u.val) u rfl intro d induction d using Nat.strong_induction_on with | h d ih => intro x hx rw [(pathTree n hn).edgeFlow_eq ω x] by_cases hlast : x.val + 1 < n · let next : Fin n := ⟨x.val + 1, hlast⟩ have hch : (pathTree n hn).children x = {next} := by ext c simp only [children, pathTree, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton, Fin.ext_iff, next] constructor · rintro ⟨hc0, hpar⟩ simp only [hc0, ↓reduceDIte] at hpar omega · intro hc have hc0 : c.val ≠ 0 := by omega refine ⟨hc0, ?_⟩ simp only [hc0, ↓reduceDIte] omega rw [hch, Finset.sum_singleton] have hd' : n - 1 - next.val < d := by dsimp [next]; omega rw [ih (n - 1 - next.val) hd' next rfl] have hset : Finset.univ.filter (fun j : Fin n => x.val ≤ j.val) = insert x (Finset.univ.filter (fun j : Fin n => next.val ≤ j.val)) := by ext j simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Fin.ext_iff, next] omega have hxnot : x ∉ Finset.univ.filter (fun j : Fin n => next.val ≤ j.val) := by simp [next] rw [hset, Finset.sum_insert hxnot] · have hch : (pathTree n hn).children x = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro c hc unfold children at hc rw [Finset.mem_filter] at hc rcases hc.2 with ⟨hc0, hpar⟩ dsimp only [pathTree] at hpar simp only [hc0, ↓reduceDIte, Fin.ext_iff] at hpar have := c.isLt omega rw [hch, Finset.sum_empty, add_zero] have hset : Finset.univ.filter (fun j : Fin n => x.val ≤ j.val) = {x} := by ext j simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton, Fin.ext_iff] have := j.isLt omega rw [hset, Finset.sum_singleton] /-- Exact critical coupling on the path $P_n$: $(\exists \theta,\; \mathrm{Eq}(P_n, K, \omega, \theta)) \iff \forall u > 0,\; \left|\sum_{j \ge u} \omega_j\right| \le K$. -/ theorem path_kuramoto_exact_Kc {n : ℕ} (hn : 0 < n) (ω : Fin n → ℝ) (hzero : ∑ v : Fin n, ω v = 0) (K : ℝ) (hK : 0 < K) : (∃ θ : Fin n → ℝ, IsKuramotoEquilibrium ((pathTree n hn).graph K hK.le) ω θ) ↔ ∀ u : Fin n, u.val ≠ 0 → |∑ j ∈ Finset.univ.filter (fun j : Fin n => u.val ≤ j.val), ω j| ≤ K := by rw [(pathTree n hn).tree_kuramoto_exact_critical_coupling ω hzero K hK] simp_rw [pathTree_edgeFlow_eq] /-- Star tree $S_n$ ($n \ge 1$) with center `0` and leaves `1, ..., n-1`. -/ def starTree (n : ℕ) (hn : 0 < n) : RootedTree n where hn := hn parent _ := ⟨0, hn⟩ parent_root := rfl parent_lt _ hu := Nat.pos_of_ne_zero hu /-- Exact critical coupling on the star $S_n$: $(\exists \theta,\; \mathrm{Eq}(S_n, K, \omega, \theta)) \iff \forall u > 0,\; |\omega_u| \le K$. -/ theorem star_kuramoto_exact_Kc {n : ℕ} (hn : 0 < n) (ω : Fin n → ℝ) (hzero : ∑ v : Fin n, ω v = 0) (K : ℝ) (hK : 0 < K) : (∃ θ : Fin n → ℝ, IsKuramotoEquilibrium ((starTree n hn).graph K hK.le) ω θ) ↔ ∀ u : Fin n, u.val ≠ 0 → |ω u| ≤ K := by rw [(starTree n hn).tree_kuramoto_exact_critical_coupling ω hzero K hK] have hleaf : ∀ u : Fin n, u.val ≠ 0 → (starTree n hn).edgeFlow ω u = ω u := by intro u hu rw [(starTree n hn).edgeFlow_eq ω u] have hch : (starTree n hn).children u = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro c hc unfold children at hc rw [Finset.mem_filter] at hc dsimp only [starTree] at hc exact hu (congrArg Fin.val hc.2.2.symm) rw [hch, Finset.sum_empty, add_zero] exact ⟨fun h u hu => hleaf u hu ▸ h u hu, fun h u hu => by rw [hleaf u hu]; exact h u hu⟩ end RootedTree /-! ## Section 5: Complete Graph $K_N$ Critical Coupling & General Spectral/$\ell_\infty$ Bounds -/ /-- Balanced two-cluster frequency vector on $N = 2m$ oscillators: $\omega_i = +\Delta$ for $i < m$ and $\omega_i = -\Delta$ for $i \ge m$. -/ def twoClusterOmega (m : ℕ) (Δ : ℝ) (i : Fin (2 * m)) : ℝ := if i.val < m then Δ else -Δ lemma sum_twoClusterOmega (m : ℕ) (Δ : ℝ) : ∑ i : Fin (2 * m), twoClusterOmega m Δ i = 0 := by set S := Finset.univ.filter (fun i : Fin (2 * m) => i.val < m) rw [← Finset.sum_add_sum_compl S] have hS_card : S.card = m := by have hbij : S.card = (Finset.range m).card := by refine Finset.card_bij (fun i _ => i.val) ?_ ?_ ?_ · intro i hi; simp [S] at hi; simp [hi] · intro a _ b _ h; exact Fin.ext h · intro k hk; simp at hk; exact ⟨⟨k, by omega⟩, by simp [S, hk], rfl⟩ rw [hbij, Finset.card_range] have hSc_card : Sᶜ.card = m := by have h := Finset.card_compl S simp only [Fintype.card_fin, hS_card] at h omega have h1 : ∑ i ∈ S, twoClusterOmega m Δ i = (m : ℝ) * Δ := by have : ∀ i ∈ S, twoClusterOmega m Δ i = Δ := fun i hi => by unfold twoClusterOmega; exact if_pos (Finset.mem_filter.mp hi).2 rw [Finset.sum_congr rfl this, Finset.sum_const, hS_card, nsmul_eq_mul] have h2 : ∑ i ∈ Sᶜ, twoClusterOmega m Δ i = (m : ℝ) * (-Δ) := by have : ∀ i ∈ Sᶜ, twoClusterOmega m Δ i = -Δ := fun i hi => by unfold twoClusterOmega have hnot : ¬(i.val < m) := by simpa [S] using hi exact if_neg hnot rw [Finset.sum_congr rfl this, Finset.sum_const, hSc_card, nsmul_eq_mul] rw [h1, h2]; ring /-- **Exact Complete Graph $K_{2m}$ Critical Coupling for Balanced Two-Cluster Frequencies:** With zero symmetry ansatz on $\theta$, a frequency-locked equilibrium on $K_{2m}$ with uniform edge weight $K > 0$ exists **if and only if** $K \ge \frac{2\Delta}{2m} = \frac{\Delta}{m}$. -/ theorem completeGraph_twoCluster_exact_Kc {m : ℕ} (hm : 0 < m) {Δ : ℝ} (hΔ : 0 < Δ) {K : ℝ} (hK : 0 < K) : (∃ θ : Fin (2 * m) → ℝ, IsKuramotoEquilibrium (completeGraph (2 * m) K hK.le) (twoClusterOmega m Δ) θ) ↔ (2 * Δ) / (2 * m : ℝ) ≤ K := by have hmR : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr hm set S := Finset.univ.filter (fun i : Fin (2 * m) => i.val < m) have hS_card : S.card = m := by have hbij : S.card = (Finset.range m).card := by refine Finset.card_bij (fun i _ => i.val) ?_ ?_ ?_ · intro i hi; simp [S] at hi; simp [hi] · intro a _ b _ h; exact Fin.ext h · intro k hk; simp at hk; exact ⟨⟨k, by omega⟩, by simp [S, hk], rfl⟩ rw [hbij, Finset.card_range] have hSc_card : Sᶜ.card = m := by have h := Finset.card_compl S simp only [Fintype.card_fin, hS_card] at h omega constructor · rintro ⟨θ, heq⟩ have hcut := kuramoto_cut_lower_bound (completeGraph (2 * m) K hK.le) (twoClusterOmega m Δ) θ heq S have hL : ∑ i ∈ S, twoClusterOmega m Δ i = (m : ℝ) * Δ := by have : ∀ i ∈ S, twoClusterOmega m Δ i = Δ := fun i hi => by unfold twoClusterOmega; exact if_pos (Finset.mem_filter.mp hi).2 rw [Finset.sum_congr rfl this, Finset.sum_const, hS_card, nsmul_eq_mul] have hR : ∑ i ∈ S, ∑ j ∈ Sᶜ, (completeGraph (2 * m) K hK.le).weight i j = (m : ℝ) * (m : ℝ) * K := by have hne : ∀ i ∈ S, ∀ j ∈ Sᶜ, (completeGraph (2 * m) K hK.le).weight i j = K := by intro i hi j hj have : i ≠ j := fun h => by subst h; exact Finset.mem_compl.mp hj hi simp [completeGraph, this] have hinner : ∀ i ∈ S, ∑ j ∈ Sᶜ, (completeGraph (2 * m) K hK.le).weight i j = (m : ℝ) * K := by intro i hi rw [Finset.sum_congr rfl (hne i hi), Finset.sum_const, hSc_card, nsmul_eq_mul] rw [Finset.sum_congr rfl hinner, Finset.sum_const, hS_card, nsmul_eq_mul] ring rw [hL, hR, abs_of_pos (mul_pos hmR hΔ)] at hcut rw [div_le_iff₀ (by positivity : (0 : ℝ) < 2 * m)] nlinarith · intro hKge have hdiv_le : Δ / ((m : ℝ) * K) ≤ 1 := by rw [div_le_one (mul_pos hmR hK)] rw [div_le_iff₀ (by positivity : (0 : ℝ) < 2 * m)] at hKge linarith have hdiv_ge : -1 ≤ Δ / ((m : ℝ) * K) := by have : 0 ≤ Δ / ((m : ℝ) * K) := div_nonneg hΔ.le (mul_pos hmR hK).le linarith set δ := Real.arcsin (Δ / ((m : ℝ) * K)) have hsinδ : Real.sin δ = Δ / ((m : ℝ) * K) := Real.sin_arcsin hdiv_ge hdiv_le -- Place cluster S at phase +δ/2 and cluster Sᶜ at phase -δ/2 refine ⟨fun i => if i.val < m then δ / 2 else -(δ / 2), ?_⟩ intro i unfold kuramotoRHS completeGraph twoClusterOmega dsimp only rw [← Finset.sum_add_sum_compl S] by_cases hi : i.val < m · simp only [hi, ↓reduceIte] have h1 : ∑ j ∈ S, (if i = j then (0 : ℝ) else K) * Real.sin ((if j.val < m then δ / 2 else -(δ / 2)) - δ / 2) = 0 := by refine Finset.sum_eq_zero fun j hj => ?_ have hjlt : j.val < m := (Finset.mem_filter.mp hj).2 simp [hjlt] have h2 : ∑ j ∈ Sᶜ, (if i = j then (0 : ℝ) else K) * Real.sin ((if j.val < m then δ / 2 else -(δ / 2)) - δ / 2) = -(m : ℝ) * K * Real.sin δ := by have hterm : ∀ j ∈ Sᶜ, (if i = j then (0 : ℝ) else K) * Real.sin ((if j.val < m then δ / 2 else -(δ / 2)) - δ / 2) = -(K * Real.sin δ) := by intro j hj have hjge : ¬(j.val < m) := by simpa [S] using hj have hne : i ≠ j := fun h => hjge (h ▸ hi) rw [if_neg hne, if_neg hjge] have harg : -(δ / 2) - δ / 2 = -δ := by ring rw [harg, Real.sin_neg]; ring rw [Finset.sum_congr rfl hterm, Finset.sum_const, hSc_card, nsmul_eq_mul]; ring rw [h1, h2, zero_add, hsinδ] field_simp [ne_of_gt hmR, ne_of_gt hK]; ring · simp only [hi, ↓reduceIte] have h1 : ∑ j ∈ S, (if i = j then (0 : ℝ) else K) * Real.sin ((if j.val < m then δ / 2 else -(δ / 2)) - -(δ / 2)) = (m : ℝ) * K * Real.sin δ := by have hterm : ∀ j ∈ S, (if i = j then (0 : ℝ) else K) * Real.sin ((if j.val < m then δ / 2 else -(δ / 2)) - -(δ / 2)) = K * Real.sin δ := by intro j hj have hjlt : j.val < m := (Finset.mem_filter.mp hj).2 have hne : i ≠ j := fun h => hi (h ▸ hjlt) rw [if_neg hne, if_pos hjlt] have harg : δ / 2 - -(δ / 2) = δ := by ring rw [harg] rw [Finset.sum_congr rfl hterm, Finset.sum_const, hS_card, nsmul_eq_mul]; ring have h2 : ∑ j ∈ Sᶜ, (if i = j then (0 : ℝ) else K) * Real.sin ((if j.val < m then δ / 2 else -(δ / 2)) - -(δ / 2)) = 0 := by refine Finset.sum_eq_zero fun j hj => ?_ have hjge : ¬(j.val < m) := by simpa [S] using hj simp [hjge] rw [h1, h2, add_zero, hsinδ] field_simp [ne_of_gt hmR, ne_of_gt hK]; ring /-- **Sharp $\ell_\infty$ & Spread Lower Bounds on $K_n$ for Arbitrary Frequencies:** At any equilibrium $\theta$ on $K_n$ with normalized mean-field coupling $K/n$ ($K > 0$): 1. $|\omega_i| \le K R(\theta) \le K$ for every $i$, 2. $|\omega_i - \omega_j| \le 2 K R(\theta) \le 2 K$ for all $i, j$, 3. In unnormalized edge coupling $a_{ij} = K_{\mathrm{edge}}$: $|\omega_i| \le (n - 1) K_{\mathrm{edge}}$. -/ theorem completeGraph_arbitrary_omega_bounds {n : ℕ} (hn : 0 < n) (K : ℝ) (hK : 0 ≤ K) (ω θ : Fin n → ℝ) (heq : IsKuramotoEquilibrium (completeGraph n (K / (n : ℝ)) (div_nonneg hK (Nat.cast_nonneg n))) ω θ) : (∀ i : Fin n, |ω i| ≤ K * orderParam θ ∧ |ω i| ≤ K) ∧ (∀ i j : Fin n, |ω i - ω j| ≤ 2 * K * orderParam θ) := by have hbound_i : ∀ i : Fin n, |ω i| ≤ K * orderParam θ := by intro i have hi := heq i rw [completeGraph_meanField_reformulation hn K hK ω θ i] at hi have hwi : ω i = -K * (orderSin θ * Real.cos (θ i) - orderCos θ * Real.sin (θ i)) := by linarith rw [hwi, abs_mul, abs_neg, abs_of_nonneg hK] -- Cauchy-Schwarz in R^2: (S cos - C sin)^2 <= (C^2 + S^2)(cos^2 + sin^2) = R^2 have hcs : (orderSin θ * Real.cos (θ i) - orderCos θ * Real.sin (θ i)) ^ 2 ≤ orderParamSq θ := by unfold orderParamSq have hid : (orderSin θ * Real.cos (θ i) - orderCos θ * Real.sin (θ i)) ^ 2 + (orderCos θ * Real.cos (θ i) + orderSin θ * Real.sin (θ i)) ^ 2 = ((orderCos θ) ^ 2 + (orderSin θ) ^ 2) * ((Real.cos (θ i)) ^ 2 + (Real.sin (θ i)) ^ 2) := by ring rw [Real.cos_sq_add_sin_sq, mul_one] at hid nlinarith [sq_nonneg (orderCos θ * Real.cos (θ i) + orderSin θ * Real.sin (θ i))] have habs : |orderSin θ * Real.cos (θ i) - orderCos θ * Real.sin (θ i)| ≤ orderParam θ := by unfold orderParam rw [← Real.sqrt_sq_eq_abs] exact Real.sqrt_le_sqrt hcs exact mul_le_mul_of_nonneg_left habs hK have hR_le : orderParam θ ≤ 1 := by unfold orderParam rw [← Real.sqrt_one] exact Real.sqrt_le_sqrt (orderParamSq_bounds_and_sync_iff hn θ).2.1 refine ⟨fun i => ⟨hbound_i i, (hbound_i i).trans (mul_le_of_le_one_right hK hR_le)⟩, fun i j => ?_⟩ calc |ω i - ω j| = |ω i + (-ω j)| := by ring_nf _ ≤ |ω i| + |-ω j| := abs_add_le _ _ _ = |ω i| + |ω j| := by rw [abs_neg] _ ≤ K * orderParam θ + K * orderParam θ := add_le_add (hbound_i i) (hbound_i j) _ = 2 * K * orderParam θ := by ring /-- Graph Laplacian quadratic form $v^\top L_G v = \frac{1}{2}\sum_{i,j} a_{ij}(v_j - v_i)^2$. -/ noncomputable def laplacianQuad {n : ℕ} (G : WeightedGraph n) (v : Fin n → ℝ) : ℝ := (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (v j - v i) ^ 2 /-- **Concavity lower bound on sine:** for $0 \le x \le \gamma \le \pi$ with $\gamma > 0$, $\frac{\sin\gamma}{\gamma} x \le \sin x$. -/ lemma sin_ge_secant_on_arc {γ x : ℝ} (hγ0 : 0 < γ) (hγpi : γ ≤ Real.pi) (hx0 : 0 ≤ x) (hxγ : x ≤ γ) : (Real.sin γ / γ) * x ≤ Real.sin x := by rcases eq_or_lt_of_le hx0 with rfl | hx_pos · simp · -- g(t) = sin t - t cos t >= 0 on [0, π] since g(0)=0 and g'(t) = t sin t >= 0 have hgx : ∀ t ∈ Set.Icc 0 Real.pi, 0 ≤ Real.sin t - t * Real.cos t := by have hmono : MonotoneOn (fun t : ℝ => Real.sin t - t * Real.cos t) (Set.Icc 0 Real.pi) := by refine monotoneOn_of_deriv_nonneg (convex_Icc 0 Real.pi) ?_ ?_ ?_ · exact (Real.continuous_sin.sub (continuous_id.mul Real.continuous_cos)).continuousOn · exact (Real.differentiable_sin.sub (differentiable_id.mul Real.differentiable_cos)).differentiableOn · intro t ht rw [interior_Icc] at ht have hd : HasDerivAt (fun s : ℝ => Real.sin s - s * Real.cos s) (t * Real.sin t) t := by have hid : HasDerivAt (fun s : ℝ => s) 1 t := hasDerivAt_id t have h1 := (Real.hasDerivAt_sin t).fun_sub (hid.fun_mul (Real.hasDerivAt_cos t)) have hv : Real.cos t - (1 * Real.cos t + t * -Real.sin t) = t * Real.sin t := by ring rwa [hv] at h1 rw [hd.deriv] exact mul_nonneg ht.1.le (Real.sin_nonneg_of_nonneg_of_le_pi ht.1.le ht.2.le) intro t ht have h0 := hmono ⟨le_refl 0, Real.pi_pos.le⟩ ht ht.1 simpa using h0 -- Therefore sin t / t is antitone on (0, π] have hanti : AntitoneOn (fun t : ℝ => Real.sin t / t) (Set.Ioc 0 Real.pi) := by refine antitoneOn_of_deriv_nonpos (convex_Ioc 0 Real.pi) ?_ ?_ ?_ · exact Real.continuous_sin.continuousOn.div continuousOn_id fun t ht => ne_of_gt ht.1 · exact Real.differentiable_sin.differentiableOn.div differentiableOn_id fun t ht => ne_of_gt (interior_subset ht).1 · intro t ht rw [interior_Ioc] at ht have hd : HasDerivAt (fun s : ℝ => Real.sin s / s) ((Real.cos t * t - Real.sin t * 1) / t ^ 2) t := (Real.hasDerivAt_sin t).fun_div (hasDerivAt_id t) (ne_of_gt ht.1) rw [hd.deriv] have hle := hgx t ⟨ht.1.le, ht.2.le⟩ exact div_nonpos_of_nonpos_of_nonneg (by linarith) (sq_nonneg t) have hle := hanti ⟨hx_pos, hxγ.trans hγpi⟩ ⟨hγ0, hγpi⟩ hxγ exact (le_div_iff₀ hx_pos).mp hle /-- **General Graph Spectral-Frequency Equilibrium Bound:** If $\theta$ is an equilibrium on $G$ with all pairwise phase differences $|\theta_j - \theta_i| \le \gamma$ ($0 < \gamma \le \pi$) and algebraic connectivity $\lambda_2$ (i.e. $v^\top L_G v \ge \lambda_2 \|v\|_2^2$ for all $v \perp \mathbf{1}$), then $$\lambda_2 \frac{\sin\gamma}{\gamma} \sum_i (\theta_i - \bar\theta)^2 \;\le\; \sqrt{\sum_i \omega_i^2}\,\sqrt{\sum_i (\theta_i - \bar\theta)^2},$$ hence $\lambda_2 \frac{\sin\gamma}{\gamma} \|\theta - \bar\theta\mathbf{1}\|_2 \le \|\omega\|_2$. -/ theorem general_graph_spectral_freq_bound {n : ℕ} (hn : 0 < n) (G : WeightedGraph n) (ω θ : Fin n → ℝ) (heq : IsKuramotoEquilibrium G ω θ) {γ lam2 : ℝ} (hγ0 : 0 < γ) (hγpi : γ ≤ Real.pi) (harc : ∀ i j : Fin n, |θ j - θ i| ≤ γ) (hlam2 : ∀ v : Fin n → ℝ, (∑ i : Fin n, v i) = 0 → lam2 * (∑ i : Fin n, (v i) ^ 2) ≤ laplacianQuad G v) : lam2 * (Real.sin γ / γ) * Real.sqrt (∑ i : Fin n, (θ i - (∑ k, θ k) / (n : ℝ)) ^ 2) ≤ Real.sqrt (∑ i : Fin n, (ω i) ^ 2) := by have hnR : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hn) set θbar := (∑ k : Fin n, θ k) / (n : ℝ) set u : Fin n → ℝ := fun i => θ i - θbar have husum : ∑ i : Fin n, u i = 0 := by simp only [u, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, θbar] field_simp [hnR]; ring -- Inner product <ω, u> = (1/2) sum a_{ij} (θ_j - θ_i) sin(θ_j - θ_i) have hinner : ∑ i : Fin n, ω i * u i = (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (θ j - θ i) * Real.sin (θ j - θ i) := by have hstep : ∀ i : Fin n, ω i * u i = -(u i * ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i)) := by intro i have hi := heq i unfold kuramotoRHS at hi have hwi : ω i = -(∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i)) := by linarith rw [hwi]; ring rw [Finset.sum_congr rfl fun i _ => hstep i, Finset.sum_neg_distrib] have hmul : ∑ i : Fin n, u i * ∑ j : Fin n, G.weight i j * Real.sin (θ j - θ i) = ∑ i : Fin n, ∑ j : Fin n, G.weight i j * u i * Real.sin (θ j - θ i) := by refine Finset.sum_congr rfl fun i _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun j _ => ?_; ring rw [hmul] set T := ∑ i : Fin n, ∑ j : Fin n, G.weight i j * u i * Real.sin (θ j - θ i) have hswap : T = -(∑ i : Fin n, ∑ j : Fin n, G.weight i j * u j * Real.sin (θ j - θ i)) := by calc T = ∑ j : Fin n, ∑ i : Fin n, G.weight i j * u i * Real.sin (θ j - θ i) := Finset.sum_comm _ = ∑ j : Fin n, ∑ i : Fin n, -(G.weight j i * u i * Real.sin (θ i - θ j)) := by refine Finset.sum_congr rfl fun j _ => Finset.sum_congr rfl fun i _ => ?_ rw [G.symm i j, ← neg_sub (θ i) (θ j), Real.sin_neg]; ring _ = -(∑ j : Fin n, ∑ i : Fin n, G.weight j i * u i * Real.sin (θ i - θ j)) := by simp_rw [Finset.sum_neg_distrib] have hdiff : ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (θ j - θ i) * Real.sin (θ j - θ i) = (∑ i : Fin n, ∑ j : Fin n, G.weight i j * u j * Real.sin (θ j - θ i)) - T := by rw [← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun i _ => ?_ rw [← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun j _ => ?_ dsimp [u]; ring linarith -- Pointwise lower bound: (θ_j - θ_i) sin(θ_j - θ_i) >= (sin γ / γ) (θ_j - θ_i)^2 have hpoint : ∀ i j : Fin n, (Real.sin γ / γ) * (u j - u i) ^ 2 ≤ (θ j - θ i) * Real.sin (θ j - θ i) := by intro i j have hudiff : u j - u i = θ j - θ i := by dsimp [u]; ring rw [hudiff] by_cases hpos : 0 ≤ θ j - θ i · have hle : θ j - θ i ≤ γ := (abs_le.mp (harc i j)).2 have hsec := sin_ge_secant_on_arc hγ0 hγpi hpos hle nlinarith · push Not at hpos have hpos' : 0 ≤ -(θ j - θ i) := by linarith have hle' : -(θ j - θ i) ≤ γ := by linarith [(abs_le.mp (harc i j)).1] have hsec := sin_ge_secant_on_arc hγ0 hγpi hpos' hle' rw [Real.sin_neg] at hsec nlinarith have hquad_le : (Real.sin γ / γ) * laplacianQuad G u ≤ ∑ i : Fin n, ω i * u i := by rw [hinner] unfold laplacianQuad have hrw : (Real.sin γ / γ) * ((1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * (u j - u i) ^ 2) = (1 / 2 : ℝ) * ∑ i : Fin n, ∑ j : Fin n, G.weight i j * ((Real.sin γ / γ) * (u j - u i) ^ 2) := by rw [← mul_assoc, mul_comm (Real.sin γ / γ) (1 / 2 : ℝ), mul_assoc, Finset.mul_sum] congr 1; refine Finset.sum_congr rfl fun i _ => ?_ rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun j _ => ?_; ring rw [hrw] refine mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => ?_) (by norm_num) calc G.weight i j * ((Real.sin γ / γ) * (u j - u i) ^ 2) ≤ G.weight i j * ((θ j - θ i) * Real.sin (θ j - θ i)) := mul_le_mul_of_nonneg_left (hpoint i j) (G.nonneg i j) _ = G.weight i j * (θ j - θ i) * Real.sin (θ j - θ i) := by ring have hsin_nonneg : 0 ≤ Real.sin γ / γ := div_nonneg (Real.sin_nonneg_of_nonneg_of_le_pi hγ0.le hγpi) hγ0.le have hspec := mul_le_mul_of_nonneg_left (hlam2 u husum) hsin_nonneg -- Cauchy-Schwarz: sum ω_i u_i <= sqrt(sum ω_i^2) * sqrt(sum u_i^2) have hcs : ∑ i : Fin n, ω i * u i ≤ Real.sqrt (∑ i : Fin n, (ω i) ^ 2) * Real.sqrt (∑ i : Fin n, (u i) ^ 2) := by have hsq := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ ω u have h1 := Real.sqrt_le_sqrt hsq rw [Real.sqrt_mul (Finset.sum_nonneg fun i _ => sq_nonneg (ω i))] at h1 exact (le_abs_self _).trans (by rwa [← Real.sqrt_sq_eq_abs]) have hcomb : lam2 * (Real.sin γ / γ) * (∑ i : Fin n, (u i) ^ 2) ≤ Real.sqrt (∑ i : Fin n, (ω i) ^ 2) * Real.sqrt (∑ i : Fin n, (u i) ^ 2) := by have htmp : lam2 * (Real.sin γ / γ) * (∑ i : Fin n, (u i) ^ 2) = (Real.sin γ / γ) * (lam2 * ∑ i : Fin n, (u i) ^ 2) := by ring linarith set S := Real.sqrt (∑ i : Fin n, (u i) ^ 2) have hSsq : S * S = ∑ i : Fin n, (u i) ^ 2 := Real.mul_self_sqrt (Finset.sum_nonneg fun i _ => sq_nonneg (u i)) by_cases hS0 : S = 0 · rw [hS0, mul_zero]; exact Real.sqrt_nonneg _ · have hSpos : 0 < S := lt_of_le_of_ne (Real.sqrt_nonneg _) (Ne.symm hS0) have hcomb' : (lam2 * (Real.sin γ / γ) * S) * S ≤ Real.sqrt (∑ i : Fin n, (ω i) ^ 2) * S := by calc (lam2 * (Real.sin γ / γ) * S) * S = lam2 * (Real.sin γ / γ) * (S * S) := by ring _ = lam2 * (Real.sin γ / γ) * (∑ i : Fin n, (u i) ^ 2) := by rw [hSsq] _ ≤ Real.sqrt (∑ i : Fin n, (ω i) ^ 2) * S := hcomb exact le_of_mul_le_mul_right hcomb' hSpos /-! ## Section 6: Exact Cycle $C_n$ Circulation Barrier, Two-Cluster Threshold & Strict $C_3$ Holonomy Gap -/ /-- Next vertex on the cycle $C_n$. -/ def cycNext {n : ℕ} (i : Fin n) : Fin n := ⟨(i.val + 1) % n, Nat.mod_lt _ (Nat.pos_of_ne_zero (by intro h; subst h; exact Fin.elim0 i))⟩ /-- Previous vertex on the cycle $C_n$. -/ def cycPrev {n : ℕ} (i : Fin n) : Fin n := ⟨(i.val + n - 1) % n, Nat.mod_lt _ (Nat.pos_of_ne_zero (by intro h; subst h; exact Fin.elim0 i))⟩ lemma cycPrev_cycNext {n : ℕ} (i : Fin n) : cycPrev (cycNext i) = i := by ext simp only [cycPrev, cycNext] have hi := i.isLt by_cases h : i.val + 1 < n · rw [Nat.mod_eq_of_lt h] have h1 : i.val + 1 + n - 1 = i.val + n := by omega rw [h1, Nat.add_mod_right, Nat.mod_eq_of_lt hi] · have h1 : i.val + 1 = n := by omega rw [h1, Nat.mod_self, zero_add, Nat.mod_eq_of_lt (by omega)] omega lemma cycNext_cycPrev {n : ℕ} (i : Fin n) : cycNext (cycPrev i) = i := by ext simp only [cycPrev, cycNext] have hi := i.isLt by_cases h : i.val = 0 · rw [h, zero_add] have hmod : (n - 1) % n = n - 1 := Nat.mod_eq_of_lt (by omega) rw [hmod, show n - 1 + 1 = n by omega, Nat.mod_self] · have h1 : (i.val + n - 1) % n = i.val - 1 := by have : i.val + n - 1 = (i.val - 1) + n := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [h1] have h2 : i.val - 1 + 1 = i.val := by omega rw [h2, Nat.mod_eq_of_lt hi] lemma cycNext_ne_self {n : ℕ} (hn : 3 ≤ n) (i : Fin n) : cycNext i ≠ i := by intro h have hval := congrArg Fin.val h simp only [cycNext] at hval have hi := i.isLt by_cases hlt : i.val + 1 < n · rw [Nat.mod_eq_of_lt hlt] at hval; omega · have h1 : i.val + 1 = n := by omega rw [h1, Nat.mod_self] at hval; omega lemma cycNext_ne_cycPrev {n : ℕ} (hn : 3 ≤ n) (i : Fin n) : cycNext i ≠ cycPrev i := by intro h have hval := congrArg Fin.val h simp only [cycNext, cycPrev] at hval have hi := i.isLt by_cases h0 : i.val = 0 · rw [h0] at hval simp only [zero_add, Nat.mod_eq_of_lt (by omega : 1 < n), Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hval omega · by_cases hlt : i.val + 1 < n · rw [Nat.mod_eq_of_lt hlt] at hval have h1 : (i.val + n - 1) % n = i.val - 1 := by have : i.val + n - 1 = (i.val - 1) + n := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [h1] at hval; omega · have h1 : i.val + 1 = n := by omega rw [h1, Nat.mod_self] at hval have h2 : (i.val + n - 1) % n = i.val - 1 := by have : i.val + n - 1 = (i.val - 1) + n := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [h2] at hval; omega /-- The undirected cycle graph $C_n$ ($n \ge 3$) with uniform edge weight $K \ge 0$. -/ def cycleGraph (n : ℕ) (hn : 3 ≤ n) (K : ℝ) (hK : 0 ≤ K) : WeightedGraph n where weight i j := if j = cycNext i ∨ j = cycPrev i then K else 0 symm i j := by have hiff : (j = cycNext i ∨ j = cycPrev i) ↔ (i = cycNext j ∨ i = cycPrev j) := by constructor · rintro (rfl | rfl) · exact Or.inr (cycPrev_cycNext i).symm · exact Or.inl (cycNext_cycPrev i).symm · rintro (rfl | rfl) · exact Or.inr (cycPrev_cycNext j).symm · exact Or.inl (cycNext_cycPrev j).symm simp [hiff] nonneg i j := by split_ifs <;> linarith diag_zero i := by have h1 : i ≠ cycNext i := Ne.symm (cycNext_ne_self hn i) have h2 : i ≠ cycPrev i := fun h => h1 (by have h' := congrArg cycNext h rw [cycNext_cycPrev] at h' exact h'.symm) simp [h1, h2] /-- Exact 2-neighbor formula for the Kuramoto RHS on $C_n$ ($n \ge 3$). -/ lemma cycleGraph_rhs {n : ℕ} (hn : 3 ≤ n) (K : ℝ) (hK : 0 ≤ K) (ω θ : Fin n → ℝ) (i : Fin n) : kuramotoRHS (cycleGraph n hn K hK) ω θ i = ω i + K * Real.sin (θ (cycNext i) - θ i) + K * Real.sin (θ (cycPrev i) - θ i) := by unfold kuramotoRHS cycleGraph dsimp only have hne := cycNext_ne_cycPrev hn i have hpair : ∑ j : Fin n, (if j = cycNext i ∨ j = cycPrev i then K else 0) * Real.sin (θ j - θ i) = K * Real.sin (θ (cycNext i) - θ i) + K * Real.sin (θ (cycPrev i) - θ i) := by have hsub : ({cycNext i, cycPrev i} : Finset (Fin n)) ⊆ Finset.univ := Finset.subset_univ _ rw [← Finset.sum_subset hsub] · rw [Finset.sum_pair hne]; simp · intro j _ hj simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hj simp [hj.1, hj.2] rw [hpair]; ring /-- Cumulative frequency partial sum $P_k = \sum_{j \le k} \omega_j$. -/ def partialSum {n : ℕ} (ω : Fin n → ℝ) (k : Fin n) : ℝ := ∑ j ∈ Finset.univ.filter (fun j : Fin n => j.val ≤ k.val), ω j /-- **Exact Cycle Circulation Lower Bound:** For ANY frequency-locked equilibrium $\theta$ on $C_n$ ($n \ge 3$) with coupling $K > 0$: 1. There exists a single scalar circulation $c = K \sin(\theta_0 - \theta_{n-1}) \in \mathbb{R}$ such that $K \sin(\theta_{k+1} - \theta_k) = c - P_k$ for all $k \in \mathrm{Fin}\, n$; 2. Consequently, for EVERY pair $a, b \in \mathrm{Fin}\, n$, $$\frac{1}{2}|P_a - P_b| \;\le\; K,$$ i.e., $K \ge \frac{1}{2}(\max_k P_k - \min_k P_k) = \frac{1}{2}\max_{\text{arc } S}\left|\sum_{i \in S} \omega_i\right|$. -/ theorem cycle_kuramoto_circulation_lower_bound {n : ℕ} (hn : 3 ≤ n) (K : ℝ) (hK : 0 < K) (ω θ : Fin n → ℝ) (heq : IsKuramotoEquilibrium (cycleGraph n hn K hK.le) ω θ) : let c := K * Real.sin (θ ⟨0, by omega⟩ - θ ⟨n - 1, by omega⟩) (∀ k : Fin n, K * Real.sin (θ (cycNext k) - θ k) = c - partialSum ω k) ∧ (∀ a b : Fin n, (1 / 2 : ℝ) * |partialSum ω a - partialSum ω b| ≤ K) := by intro c have hflow : ∀ k : Fin n, K * Real.sin (θ (cycNext k) - θ k) = c - partialSum ω k := by suffices h : ∀ m : ℕ, ∀ k : Fin n, k.val = m → K * Real.sin (θ (cycNext k) - θ k) = c - partialSum ω k from fun k => h k.val k rfl intro m induction m with | zero => intro k hk have hn0 : 0 < n := by omega have hk0 : k = ⟨0, hn0⟩ := Fin.ext hk rw [hk0] have h0 := heq ⟨0, hn0⟩ rw [cycleGraph_rhs hn K hK.le ω θ ⟨0, hn0⟩] at h0 have hprev : cycPrev ⟨0, hn0⟩ = ⟨n - 1, by omega⟩ := by ext; simp [cycPrev, Nat.mod_eq_of_lt (by omega : n - 1 < n)] rw [hprev] at h0 have hP0 : partialSum ω ⟨0, hn0⟩ = ω ⟨0, hn0⟩ := by unfold partialSum have hset : Finset.univ.filter (fun j : Fin n => j.val ≤ 0) = {⟨0, hn0⟩} := by ext j; simp [Fin.ext_iff] rw [hset, Finset.sum_singleton] have hsin : Real.sin (θ ⟨n - 1, by omega⟩ - θ ⟨0, hn0⟩) = -Real.sin (θ ⟨0, hn0⟩ - θ ⟨n - 1, by omega⟩) := by rw [← neg_sub (θ ⟨0, hn0⟩), Real.sin_neg] rw [hsin] at h0 rw [hP0]; dsimp [c]; linarith | succ m ih => intro k hk have hm_lt : m < n := by have := k.isLt; omega let prev : Fin n := ⟨m, hm_lt⟩ have hnext_prev : cycNext prev = k := by ext; simp only [cycNext, prev, hk, Nat.mod_eq_of_lt (by omega : m + 1 < n)] have hprev_k : cycPrev k = prev := by rw [← hnext_prev, cycPrev_cycNext] have hk_eq := heq k rw [cycleGraph_rhs hn K hK.le ω θ k, hprev_k] at hk_eq have hih := ih prev rfl rw [hnext_prev] at hih have hsin : Real.sin (θ prev - θ k) = -Real.sin (θ k - θ prev) := by rw [← neg_sub (θ k), Real.sin_neg] rw [hsin] at hk_eq have hPk : partialSum ω k = partialSum ω prev + ω k := by unfold partialSum have hset : Finset.univ.filter (fun j : Fin n => j.val ≤ k.val) = insert k (Finset.univ.filter (fun j : Fin n => j.val ≤ prev.val)) := by ext j simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Fin.ext_iff, prev, hk] omega have hknotin : k ∉ Finset.univ.filter (fun j : Fin n => j.val ≤ prev.val) := by simp [prev, hk] rw [hset, Finset.sum_insert hknotin, add_comm] rw [hPk]; linarith refine ⟨hflow, fun a b => ?_⟩ have ha : |c - partialSum ω a| ≤ K := by rw [← hflow a, abs_mul, abs_of_pos hK] exact mul_le_of_le_one_right hK.le (Real.abs_sin_le_one _) have hb : |c - partialSum ω b| ≤ K := by rw [← hflow b, abs_mul, abs_of_pos hK] exact mul_le_of_le_one_right hK.le (Real.abs_sin_le_one _) have hdiff : |partialSum ω a - partialSum ω b| ≤ 2 * K := by calc |partialSum ω a - partialSum ω b| = |(c - partialSum ω b) - (c - partialSum ω a)| := by ring_nf _ ≤ |c - partialSum ω b| + |c - partialSum ω a| := abs_sub _ _ _ ≤ K + K := add_le_add hb ha _ = 2 * K := by ring linarith /-- **Exact Cycle $C_{2m}$ Critical Coupling for Balanced Two-Cluster Frequencies:** For $m \ge 2$, $\Delta > 0$, and $K > 0$: $(\exists \theta,\; \mathrm{Eq}(C_{2m}, K, \omega_{\mathrm{2cl}}, \theta)) \iff K \ge \frac{m \Delta}{2}$ (exactly half the path threshold $m\Delta$!). -/ theorem cycle_twoCluster_exact_Kc {m : ℕ} (hm : 2 ≤ m) {Δ : ℝ} (hΔ : 0 < Δ) {K : ℝ} (hK : 0 < K) : (∃ θ : Fin (2 * m) → ℝ, IsKuramotoEquilibrium (cycleGraph (2 * m) (by omega) K hK.le) (twoClusterOmega m Δ) θ) ↔ ((m : ℝ) * Δ) / 2 ≤ K := by have hmR : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr (by omega) constructor · rintro ⟨θ, heq⟩ have hcirc := (cycle_kuramoto_circulation_lower_bound (by omega) K hK (twoClusterOmega m Δ) θ heq).2 let a : Fin (2 * m) := ⟨m - 1, by omega⟩ let b : Fin (2 * m) := ⟨2 * m - 1, by omega⟩ have hPa : partialSum (twoClusterOmega m Δ) a = (m : ℝ) * Δ := by unfold partialSum have hset : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ a.val) = Finset.univ.filter (fun j : Fin (2 * m) => j.val < m) := by ext j; simp [a]; omega rw [hset] have hval : ∀ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < m), twoClusterOmega m Δ j = Δ := fun j hj => by unfold twoClusterOmega; exact if_pos (Finset.mem_filter.mp hj).2 rw [Finset.sum_congr rfl hval, Finset.sum_const, nsmul_eq_mul] have hcard : (Finset.univ.filter (fun j : Fin (2 * m) => j.val < m)).card = m := by have hbij : (Finset.univ.filter (fun j : Fin (2 * m) => j.val < m)).card = (Finset.range m).card := by refine Finset.card_bij (fun i _ => i.val) ?_ ?_ ?_ · intro i hi; simp at hi ⊢; exact hi · intro x _ y _ h; exact Fin.ext h · intro k hk; simp at hk; exact ⟨⟨k, by omega⟩, by simp [hk], rfl⟩ rw [hbij, Finset.card_range] rw [hcard] have hPb : partialSum (twoClusterOmega m Δ) b = 0 := by unfold partialSum have hset : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ b.val) = Finset.univ := by ext j; simp [b]; omega rw [hset, sum_twoClusterOmega] have hab := hcirc a b rw [hPa, hPb, sub_zero, abs_of_pos (mul_pos hmR hΔ)] at hab linarith · intro hKge -- Explicit symmetric flow s_k = P_k - (m*Δ)/2 has exact zero holonomy sum(arcsin(-s_k/K)) = 0! set s : Fin (2 * m) → ℝ := fun k => (m : ℝ) * Δ / 2 - partialSum (twoClusterOmega m Δ) k have hP_eval : ∀ k : Fin (2 * m), partialSum (twoClusterOmega m Δ) k = if k.val < m then ((k.val + 1 : ℕ) : ℝ) * Δ else ((2 * m - 1 - k.val : ℕ) : ℝ) * Δ := by intro k suffices h : ∀ r : ℕ, ∀ x : Fin (2 * m), x.val = r → partialSum (twoClusterOmega m Δ) x = if x.val < m then ((x.val + 1 : ℕ) : ℝ) * Δ else ((2 * m - 1 - x.val : ℕ) : ℝ) * Δ from h k.val k rfl intro r induction r with | zero => intro x hx have h2m0 : 0 < 2 * m := by omega have hx0 : x = ⟨0, h2m0⟩ := Fin.ext hx rw [hx0] unfold partialSum have hset : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ 0) = {⟨0, h2m0⟩} := by ext j; simp [Fin.ext_iff] rw [hset, Finset.sum_singleton] simp [twoClusterOmega, show (0 : ℕ) < m by omega] | succ r ih => intro x hx let prev : Fin (2 * m) := ⟨r, by have := x.isLt; omega⟩ have hstep : partialSum (twoClusterOmega m Δ) x = partialSum (twoClusterOmega m Δ) prev + twoClusterOmega m Δ x := by unfold partialSum have hset : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ x.val) = insert x (Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ prev.val)) := by ext j; simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Fin.ext_iff, prev, hx]; omega have hnot : x ∉ Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ prev.val) := by simp [prev, hx] rw [hset, Finset.sum_insert hnot, add_comm] rw [hstep, ih prev rfl] by_cases hlt : x.val < m · have hprev_lt : prev.val < m := by dsimp [prev]; omega rw [if_pos hlt, if_pos hprev_lt] unfold twoClusterOmega rw [if_pos hlt] dsimp [prev]; rw [hx]; push_cast; ring · rw [if_neg hlt]; unfold twoClusterOmega; rw [if_neg hlt] by_cases hprev_lt : prev.val < m · rw [if_pos hprev_lt] have hr : r + 1 = m := by dsimp [prev] at hprev_lt; omega have h2m : 2 * m - 1 - x.val = m - 1 := by omega rw [h2m] have hm1 : ((m - 1 : ℕ) : ℝ) = (m : ℝ) - 1 := by rw [Nat.cast_sub (show 1 ≤ m by omega)]; norm_num have hr' : ((prev.val + 1 : ℕ) : ℝ) = (m : ℝ) := by dsimp [prev]; exact_mod_cast hr rw [hm1, hr']; ring · rw [if_neg hprev_lt] have hsub : 2 * m - 1 - prev.val = (2 * m - 1 - x.val) + 1 := by dsimp [prev]; have := x.isLt; omega rw [hsub]; push_cast; ring have hs_bound : ∀ k : Fin (2 * m), |s k| ≤ K := by intro k have hPk := hP_eval k have h0le : 0 ≤ partialSum (twoClusterOmega m Δ) k := by rw [hPk]; split_ifs <;> positivity have hlem : partialSum (twoClusterOmega m Δ) k ≤ (m : ℝ) * Δ := by rw [hPk] split_ifs with hlt · have : ((k.val + 1 : ℕ) : ℝ) ≤ (m : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hlt nlinarith · have : ((2 * m - 1 - k.val : ℕ) : ℝ) ≤ (m : ℝ) := by exact_mod_cast (by omega : 2 * m - 1 - k.val ≤ m) nlinarith dsimp [s] rw [abs_le] constructor <;> linarith -- Exact anti-symmetry pairing: s(k) = -s((k + m) mod 2m) have hs_anti : ∀ k : Fin (2 * m), s ⟨(k.val + m) % (2 * m), Nat.mod_lt _ (by omega)⟩ = -s k := by intro k dsimp [s] rw [hP_eval k, hP_eval ⟨(k.val + m) % (2 * m), Nat.mod_lt _ (by omega)⟩] by_cases hlt : k.val < m · have hmod : (k.val + m) % (2 * m) = k.val + m := Nat.mod_eq_of_lt (by omega) simp only [hlt, ↓reduceIte, hmod, show ¬(k.val + m < m) by omega] have hsub : 2 * m - 1 - (k.val + m) = m - 1 - k.val := by omega rw [hsub] have hcast : ((m - 1 - k.val : ℕ) : ℝ) + ((k.val + 1 : ℕ) : ℝ) = (m : ℝ) := by exact_mod_cast (by omega : (m - 1 - k.val) + (k.val + 1) = m) nlinarith · have hmod : (k.val + m) % (2 * m) = k.val - m := by have hk := k.isLt have : k.val + m = (k.val - m) + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] simp only [hlt, ↓reduceIte, hmod, show k.val - m < m by have := k.isLt; omega] have hcast : ((k.val - m + 1 : ℕ) : ℝ) + ((2 * m - 1 - k.val : ℕ) : ℝ) = (m : ℝ) := by have := k.isLt exact_mod_cast (by omega : (k.val - m + 1) + (2 * m - 1 - k.val) = m) nlinarith -- Define δ_k = arcsin(s_k / K) and prove sum_{k} δ_k = 0 by involution k ↦ (k + m) mod 2m set δ : Fin (2 * m) → ℝ := fun k => Real.arcsin (s k / K) have hδ_sum : ∑ k : Fin (2 * m), δ k = 0 := by set σ : 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 => by ext; dsimp have hk := k.isLt by_cases h : k.val < m · rw [Nat.mod_eq_of_lt (by omega : k.val + m < 2 * m)] have : k.val + m + m = k.val + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt hk] · have h1 : (k.val + m) % (2 * m) = k.val - m := by have : k.val + m = (k.val - m) + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [h1] have h2 : k.val - m + m = k.val := by omega rw [h2, Nat.mod_eq_of_lt hk] right_inv := fun k => by ext; dsimp have hk := k.isLt by_cases h : k.val < m · rw [Nat.mod_eq_of_lt (by omega : k.val + m < 2 * m)] have : k.val + m + m = k.val + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt hk] · have h1 : (k.val + m) % (2 * m) = k.val - m := by have : k.val + m = (k.val - m) + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] rw [h1] have h2 : k.val - m + m = k.val := by omega rw [h2, Nat.mod_eq_of_lt hk] } have hswap : ∑ k : Fin (2 * m), δ k = -(∑ k : Fin (2 * m), δ k) := by calc ∑ k : Fin (2 * m), δ k = ∑ k : Fin (2 * m), δ (σ k) := (Equiv.sum_comp σ δ).symm _ = ∑ k : Fin (2 * m), -δ k := by refine Finset.sum_congr rfl fun k _ => ?_ dsimp [δ, σ] rw [hs_anti k, neg_div, Real.arcsin_neg] _ = -(∑ k : Fin (2 * m), δ k) := by rw [Finset.sum_neg_distrib] linarith -- Define θ_i = sum_{j < i} δ_j so θ_{cycNext k} - θ_k = δ_k for ALL k (including wraparound!) refine ⟨fun i => ∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < i.val), δ j, ?_⟩ have hstep : ∀ k : Fin (2 * m), (∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < (cycNext k).val), δ j) - (∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < k.val), δ j) = δ k := by intro k by_cases hlt : k.val + 1 < 2 * m · have hnext : (cycNext k).val = k.val + 1 := Nat.mod_eq_of_lt hlt rw [hnext] have hset : Finset.univ.filter (fun j : Fin (2 * m) => j.val < k.val + 1) = insert k (Finset.univ.filter (fun j : Fin (2 * m) => j.val < k.val)) := by ext j; simp [Fin.ext_iff]; omega have hnot : k ∉ Finset.univ.filter (fun j : Fin (2 * m) => j.val < k.val) := by simp rw [hset, Finset.sum_insert hnot]; ring · have hlast : k.val = 2 * m - 1 := by have := k.isLt; omega have hnext : (cycNext k).val = 0 := by simp [cycNext, show k.val + 1 = 2 * m by omega] rw [hnext] have hempty : Finset.univ.filter (fun j : Fin (2 * m) => j.val < 0) = ∅ := by ext j; simp have herase : Finset.univ.filter (fun j : Fin (2 * m) => j.val < k.val) = Finset.univ.erase k := by ext j; simp [Fin.ext_iff, hlast]; omega rw [hempty, Finset.sum_empty, herase] have htot := Finset.add_sum_erase Finset.univ δ (Finset.mem_univ k) linarith have hsin_k : ∀ k : Fin (2 * m), K * Real.sin ((∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < (cycNext k).val), δ j) - (∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < k.val), δ j)) = s k := by intro k rw [hstep k] have hb := abs_le.mp (hs_bound k) have h1 : -1 ≤ s k / K := by rw [le_div_iff₀ hK]; linarith have h2 : s k / K ≤ 1 := by rw [div_le_iff₀ hK]; linarith dsimp [δ] rw [Real.sin_arcsin h1 h2, mul_div_cancel₀ _ (ne_of_gt hK)] intro i rw [cycleGraph_rhs (by omega) K hK.le] have hprev_sin : K * Real.sin ((∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < (cycPrev i).val), δ j) - (∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < i.val), δ j)) = -s (cycPrev i) := by have hneg := hsin_k (cycPrev i) rw [cycNext_cycPrev] at hneg have hflip : Real.sin ((∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < (cycPrev i).val), δ j) - (∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < i.val), δ j)) = -Real.sin ((∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < i.val), δ j) - (∑ j ∈ Finset.univ.filter (fun j : Fin (2 * m) => j.val < (cycPrev i).val), δ j)) := by rw [← neg_sub, Real.sin_neg] rw [hflip]; linarith rw [hsin_k i, hprev_sin] dsimp [s] by_cases hi0 : i.val = 0 · have h2m0 : 0 < 2 * m := by omega have hi : i = ⟨0, h2m0⟩ := Fin.ext hi0 rw [hi] have hprev : cycPrev ⟨0, h2m0⟩ = ⟨2 * m - 1, by omega⟩ := by ext; simp [cycPrev, Nat.mod_eq_of_lt (by omega : 2 * m - 1 < 2 * m)] rw [hprev] have hP0 : partialSum (twoClusterOmega m Δ) ⟨0, h2m0⟩ = twoClusterOmega m Δ ⟨0, h2m0⟩ := by unfold partialSum have : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ 0) = {⟨0, h2m0⟩} := by ext j; simp [Fin.ext_iff] rw [this, Finset.sum_singleton] have hPlast : partialSum (twoClusterOmega m Δ) ⟨2 * m - 1, by omega⟩ = 0 := by unfold partialSum have : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ 2 * m - 1) = Finset.univ := by ext j; simp; omega rw [this, sum_twoClusterOmega] rw [hP0, hPlast]; ring · have hprev_val : (cycPrev i).val = i.val - 1 := by simp only [cycPrev] have hi := i.isLt have : i.val + 2 * m - 1 = (i.val - 1) + 2 * m := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt (by omega)] have hPi : partialSum (twoClusterOmega m Δ) i = partialSum (twoClusterOmega m Δ) (cycPrev i) + twoClusterOmega m Δ i := by unfold partialSum have hset : Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ i.val) = insert i (Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ (cycPrev i).val)) := by ext j; simp [Fin.ext_iff, hprev_val]; omega have hnot : i ∉ Finset.univ.filter (fun j : Fin (2 * m) => j.val ≤ (cycPrev i).val) := by simp [hprev_val]; omega rw [hset, Finset.sum_insert hnot, add_comm] rw [hPi]; ring /-- Frequency vector $(3, -2, -1)$ on $C_3$ demonstrating the strict topological holonomy gap. -/ def omegaHolonomyC3 : Fin 3 → ℝ := ![3, -2, -1] /-- **Strict Topological Holonomy Obstruction on $C_3$:** For $\omega = (3, -2, -1)$ on $C_3$, the exact cycle circulation lower bound is $\frac{1}{2}(\max_k P_k - \min_k P_k) = \frac{3}{2}$, YET at $K = \frac{3}{2}$ **no equilibrium exists** (unlike trees, where the edge-flow bound $\|B^\dagger \omega\|_\infty$ is always sufficient!). The holonomy angle sum $\delta_0 + \delta_1 + \delta_2 = 0$ forces $\sin(\delta_1) = 0$, contradicting $\sin(\delta_1) = -1/3$. -/ theorem cycle3_topological_holonomy_gap : (1 / 2 : ℝ) * |partialSum omegaHolonomyC3 0 - partialSum omegaHolonomyC3 2| = 3 / 2 ∧ ¬ ∃ θ : Fin 3 → ℝ, IsKuramotoEquilibrium (cycleGraph 3 (le_refl 3) (3 / 2) (by norm_num)) omegaHolonomyC3 θ := by have hP0 : partialSum omegaHolonomyC3 0 = 3 := by unfold partialSum omegaHolonomyC3 have : Finset.univ.filter (fun j : Fin 3 => j.val ≤ (0 : Fin 3).val) = {0} := by decide rw [this, Finset.sum_singleton]; norm_num have hP1 : partialSum omegaHolonomyC3 1 = 1 := by unfold partialSum omegaHolonomyC3 have : Finset.univ.filter (fun j : Fin 3 => j.val ≤ (1 : Fin 3).val) = {0, 1} := by decide rw [this, Finset.sum_pair (by decide)]; norm_num have hP2 : partialSum omegaHolonomyC3 2 = 0 := by unfold partialSum omegaHolonomyC3 have : Finset.univ.filter (fun j : Fin 3 => j.val ≤ (2 : Fin 3).val) = Finset.univ := by decide rw [this, Fin.sum_univ_three] simp only [Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val] norm_num refine ⟨by rw [hP0, hP2]; norm_num, ?_⟩ rintro ⟨θ, heq⟩ have hflow := (cycle_kuramoto_circulation_lower_bound (le_refl 3) (3 / 2) (by norm_num) omegaHolonomyC3 θ heq).1 set c := (3 / 2 : ℝ) * Real.sin (θ 0 - θ 2) have hf0 : (3 / 2 : ℝ) * Real.sin (θ 1 - θ 0) = c - 3 := by simpa [cycNext, hP0] using hflow 0 have hf1 : (3 / 2 : ℝ) * Real.sin (θ 2 - θ 1) = c - 1 := by simpa [cycNext, hP1] using hflow 1 have hf2 : (3 / 2 : ℝ) * Real.sin (θ 0 - θ 2) = c := rfl -- From |sin| <= 1, we get c - 3 >= -3/2 and c <= 3/2, forcing c = 3/2 uniquely! have hle1 : c - 3 ≥ -(3 / 2 : ℝ) := by have := Real.neg_one_le_sin (θ 1 - θ 0); linarith have hle2 : c ≤ (3 / 2 : ℝ) := by have := Real.sin_le_one (θ 0 - θ 2); linarith have hc : c = 3 / 2 := by linarith have hsin0 : Real.sin (θ 1 - θ 0) = -1 := by linarith have hsin1 : Real.sin (θ 2 - θ 1) = 1 / 3 := by linarith have hsin2 : Real.sin (θ 0 - θ 2) = 1 := by linarith -- Since sin(θ_1 - θ_0) = -1 and sin(θ_0 - θ_2) = 1, cos(θ_1 - θ_0) = 0 and cos(θ_0 - θ_2) = 0 have hcos0 : Real.cos (θ 1 - θ 0) = 0 := by have := Real.sin_sq_add_cos_sq (θ 1 - θ 0) rw [hsin0] at this; nlinarith have hcos2 : Real.cos (θ 0 - θ 2) = 0 := by have := Real.sin_sq_add_cos_sq (θ 0 - θ 2) rw [hsin2] at this; nlinarith -- Holonomy identity: θ_2 - θ_1 = -((θ_1 - θ_0) + (θ_0 - θ_2)) have hhol : θ 2 - θ 1 = -((θ 1 - θ 0) + (θ 0 - θ 2)) := by ring have hsin1_zero : Real.sin (θ 2 - θ 1) = 0 := by rw [hhol, Real.sin_neg, Real.sin_add, hcos0, hcos2] ring linarith /-! ## Axiom Audits for Headline Theorems -/ #print axioms orderParamSq_eq_double_sum #print axioms orderParamSq_bounds_and_sync_iff #print axioms completeGraph_meanField_reformulation #print axioms kuramoto_mean_frequency_invariance #print axioms kuramoto_potential_partial_deriv #print axioms kuramoto_lyapunov_dissipation #print axioms kuramoto_cut_lower_bound #print axioms RootedTree.equilibrium_edge_flow_exact #print axioms RootedTree.tree_kuramoto_exact_critical_coupling #print axioms RootedTree.tree_kuramoto_strict_stability_above_Kc #print axioms RootedTree.pathTree_edgeFlow_eq #print axioms RootedTree.path_kuramoto_exact_Kc #print axioms RootedTree.star_kuramoto_exact_Kc #print axioms completeGraph_twoCluster_exact_Kc #print axioms completeGraph_arbitrary_omega_bounds #print axioms general_graph_spectral_freq_bound #print axioms cycle_kuramoto_circulation_lower_bound #print axioms cycle_twoCluster_exact_Kc #print axioms cycle3_topological_holonomy_gap end KuramotoCore