import Mathlib /-! # Mathematical Foundations of Active Inference, Variational Free Energy, and Predictive Processing A self-contained, zero-`sorry`, zero-axiom Lean 4 formalization establishing sharp, non-asymptotic theorems across four interlocking pillars of Active Inference, Variational Bayes, and Predictive Processing: ## Pillar 1 — Variational Free Energy (VFE), Exact Four-Way Decomposition & Curvature Sandwich For any discrete generative model $P(s, o) = p(s) L(o \mid s) > 0$ with marginal evidence $Z(o) = \sum_s P(s,o)$, surprise $S(o) = -\log Z(o)$, and exact Bayesian posterior $p^*(s) = P(s,o)/Z(o)$: - **Exact Four-Way VFE Decomposition**: $$F(q) = D_{\mathrm{KL}}(q \parallel p^*) + S(o) = D_{\mathrm{KL}}(q \parallel p) - \mathbb{E}_q[\log L(o \mid s)] = U(q) - H(q) = F(p^*) + D_{\mathrm{KL}}(q \parallel p^*).$$ - **Exact Variational Bayes Optimality & Uniqueness**: $F(q) \ge S(o)$ with equality iff $q = p^*$. - **Exact Pinsker–Hellinger–$\chi^2$ Curvature Sandwich**: $$\max\!\left(\frac{1}{2}\|q - p^*\|_1^2,\; 2 H^2(q, p^*)\right) \;\le\; F(q) - S(o) \;\le\; \log\bigl(1 + \chi^2(q \parallel p^*)\bigr) \;\le\; \chi^2(q \parallel p^*).$$ - **Precision-Tempered VFE Gibbs Optimality** and **Sequential Bayesian Evidence-Gain Telescoping**. ## Pillar 2 — Entropic Mirror Descent / Natural-Gradient VI & Predictive Coding Contraction Theory For entropic mirror descent (natural-gradient VI) on the probability simplex, $q_{t+1}(s) \propto q_t(s)^{1-\eta} p^*(s)^\eta$ ($\eta \in (0, 1]$), with Chernoff divergence $\Lambda_\eta(q, p) := -\log \sum_s q(s)^{1-\eta} p(s)^\eta \ge 0$: - **Exact Bregman Pythagorean Identity** (for every reference $r \in \Delta_\iota^\circ$): $$\eta\, D_{\mathrm{KL}}(r \parallel p^*) + (1-\eta) D_{\mathrm{KL}}(r \parallel q_t) = D_{\mathrm{KL}}(r \parallel q_{t+1}) + \Lambda_\eta(q_t, p^*).$$ - **Exact Two-Sided VFE Descent Law**: $$F(q_t) - F(q_{t+1}) = \frac{1}{\eta} D_{\mathrm{KL}}(q_t \parallel q_{t+1}) + \frac{1-\eta}{\eta} D_{\mathrm{KL}}(q_{t+1} \parallel q_t) \ge 0.$$ - **Exact Forward-KL & Symmetrized Jeffreys Contraction Identities**: $$D_{\mathrm{KL}}(p^* \parallel q_{t+1}) = (1-\eta) D_{\mathrm{KL}}(p^* \parallel q_t) - \Lambda_\eta(q_t, p^*),$$ $$J(q_{t+1}, p^*) = (1-\eta) J(q_t, p^*) - \frac{1-\eta}{\eta} J(q_t, q_{t+1}).$$ - **Exact $T$-Step Non-Asymptotic VFE Convergence Bounds** (with 1-step exact Bayes at $\eta = 1$): $$F(q_T) - S(o) \;\le\; \min\!\left((1-\eta)^T J(q_0, p^*),\; \frac{(1-\eta)^T}{1 - (1-\eta)^T} D_{\mathrm{KL}}(p^* \parallel q_0)\right).$$ - **Overconfidence-Trap Non-Contraction Paradox**: For EVERY $\eta \in (0, 1)$ and EVERY $\rho < 1$, there exist $q_0, p^* \in \Delta_2^\circ$ with $F(q_1) - S(o) > \rho(F(q_0) - S(o))$ (no uniform one-step VFE contraction exists!), accompanied by an explicit rational witness ($k = 99, \eta = 1/2$, ratio $> 9/10 > 1/2$). - **Linear-Gaussian Predictive Coding Precision-Stiffness Theorem**: Exact contraction comparison between Euclidean predictive coding (diverges for $\eta > 2/(\pi_p + g^2 \pi_o)$) and precision-normalized natural-gradient predictive coding (precision-invariant rate $(1-\eta)^2$). ## Pillar 3 — Exact Expected Free Energy (EFE) & Epistemic-vs-Pragmatic Phase Transitions - **Exact Four-Way EFE Identity** (`Risk + Ambiguity = Pragmatic Cost - Expected Information Gain = Pragmatic Cost - Mutual Information`) with zero approximation, and exact risk-free lower bound. - **Exact Universal Preference-Precision Phase Transition** at $\beta_c = \Delta I / \Delta R$ under Boltzmann preference $C_\beta(o) \propto e^{\beta r(o)}$, plus softmax policy susceptibility $-\gamma \Delta R / 4$ at $\beta_c$. - **Sharp Binary Entropy Sandwich**: $4 p(1-p)\log 2 \le h_2(p) \le \log 2 - 2(p - 1/2)^2$. - **Exact Nonlinear Noisy-Sensor T-Maze Phase Transition**: Exploration Extinction Wall ($c \ge \log 2 - h_2(\alpha)$), unique critical belief confidence window $(1 - p_c, p_c)$, closed-form non-asymptotic sandwich on $p_c(\alpha, c)$, and concrete witnesses in both phases. ## Pillar 4 — Sharp Mean-Field vs. Exact Bayes Variational Gap Bounds in Coupled Generative Models - **General Structural Laws**: Forward-KL exact minimization equals $I_p(S_1; S_2)$; Reverse-KL zero-gap iff exact independence; Lautum upper bound $\Delta_{\mathrm{MF}}(p) \le D_{\mathrm{KL}}(p_1 \otimes p_2 \parallel p)$. - **Exact $d$-Cause Explaining-Away Gaussian Mean-Field Gap & Total-Correlation Inversion**: $$\Delta_{\mathrm{MF}}^{\mathrm{EA}}(d, \lambda) = \frac{1}{2}\bigl(d\log(1+\lambda) - \log(1+d\lambda)\bigr),$$ exact variance overconfidence collapse $\frac{v_i^*}{\Sigma_{ii}} = \frac{1+d\lambda}{(1+\lambda)(1+(d-1)\lambda)} < 1$, equality with total correlation $I_{\mathrm{TC}}^{\mathrm{EA}}$ at $d = 2$, and **strict inversion** $\Delta_{\mathrm{MF}}^{\mathrm{EA}}(d, \lambda) > I_{\mathrm{TC}}^{\mathrm{EA}}(d, \lambda)$ for all $d \ge 3, \lambda > 0$. - **Exact 2-Spin Ising Mean-Field Gap, $J_c = 1$ Symmetry-Breaking Phase Transition & Universal Mutual-Information Dominance**: Exact subcritical gap $\log(\cosh J)$ ($0 < J \le 1$), exact supercritical symmetry-breaking gap $\log(\cosh J) + J(m^*)^2 - 2\log\cosh(J m^*)$ ($J > 1$, $m^* = \tanh(J m^*)$), exact symmetry-breaking gain $u(J m^*) > 0$ via $u(x) := 2\log\cosh x - x\tanh x$, universal 1-bit ceiling $\Delta_{\mathrm{MF}}^{\mathrm{Ising}}(J) < \log 2$, and universal strict dominance $\Delta_{\mathrm{MF}}^{\mathrm{Ising}}(J) > I_{p_J}(S_1; S_2)$ for ALL $J > 0$. -/ open scoped BigOperators open Finset Real namespace ActiveInference /-! ## Section 0: Core Probability Simplex & Information-Theoretic Foundations -/ section CoreInfoTheory /-- Strictly positive probability mass function on a finite type `ι`. -/ def IsPosProb {ι : Type*} [Fintype ι] (p : ι → ℝ) : Prop := (∀ i, 0 < p i) ∧ ∑ i, p i = 1 /-- Kullback–Leibler divergence `D_KL(q ‖ p)` in nats. -/ noncomputable def klDiv {ι : Type*} [Fintype ι] (q p : ι → ℝ) : ℝ := ∑ i, q i * Real.log (q i / p i) /-- Shannon entropy `H(p)` in nats. -/ noncomputable def shannonEntropy {ι : Type*} [Fintype ι] (p : ι → ℝ) : ℝ := - ∑ i, p i * Real.log (p i) /-- Symmetrized Jeffreys divergence `J(q, p) = D_KL(q ‖ p) + D_KL(p ‖ q)`. -/ noncomputable def jeffreysDiv {ι : Type*} [Fintype ι] (q p : ι → ℝ) : ℝ := klDiv q p + klDiv p q /-- Squared Hellinger distance `H²(q, p) = 1 - ∑ √(q_i p_i)`. -/ noncomputable def hellingerSq {ι : Type*} [Fintype ι] (q p : ι → ℝ) : ℝ := 1 - ∑ i, Real.sqrt (q i * p i) /-- Pearson `χ²`-divergence `χ²(q ‖ p) = ∑ (q_i - p_i)² / p_i`. -/ noncomputable def chiSqDiv {ι : Type*} [Fintype ι] (q p : ι → ℝ) : ℝ := ∑ i, (q i - p i) ^ 2 / p i /-- Total variation `L¹` distance `‖q - p‖₁ = ∑ |q_i - p_i|`. -/ noncomputable def l1Dist {ι : Type*} [Fintype ι] (q p : ι → ℝ) : ℝ := ∑ i, |q i - p i| /-- Binary Shannon entropy `h₂(p) = -p log p - (1-p) log (1-p)` in nats. -/ noncomputable def binaryEntropy (p : ℝ) : ℝ := -(p * Real.log p + (1 - p) * Real.log (1 - p)) /-- Elementary strict Gibbs log inequality: `log x ≤ x - 1` for `x > 0`, with equality iff `x = 1`. -/ lemma log_le_sub_one_of_pos {x : ℝ} (hx : 0 < x) : Real.log x ≤ x - 1 := Real.log_le_sub_one_of_pos hx lemma log_lt_sub_one_of_ne_one {x : ℝ} (hx : 0 < x) (hne : x ≠ 1) : Real.log x < x - 1 := by have hlog_ne : Real.log x ≠ 0 := by intro h0 have hexp := Real.exp_log hx rw [h0, Real.exp_zero] at hexp exact hne hexp.symm have h1 := Real.add_one_lt_exp hlog_ne rw [Real.exp_log hx] at h1 linarith /-- Non-negativity of KL divergence (`Gibbs' inequality`). -/ theorem klDiv_nonneg {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : 0 ≤ klDiv q p := by unfold klDiv have hsum : ∑ i, (q i - p i) = 0 := by rw [Finset.sum_sub_distrib, hq.2, hp.2, sub_self] have hle : ∑ i, (q i - p i) ≤ ∑ i, q i * Real.log (q i / p i) := by apply Finset.sum_le_sum intro i _ have hqi := hq.1 i have hpi := hp.1 i have hlog := Real.log_le_sub_one_of_pos (div_pos hpi hqi) have hneg : Real.log (p i / q i) = -Real.log (q i / p i) := by rw [Real.log_div hpi.ne' hqi.ne', Real.log_div hqi.ne' hpi.ne'] ring have hmul : q i * Real.log (p i / q i) ≤ q i * (p i / q i - 1) := mul_le_mul_of_nonneg_left hlog hqi.le rw [hneg] at hmul have hsimp : q i * (p i / q i - 1) = p i - q i := by field_simp linarith linarith /-- Strict positivity / zero characterization of KL divergence: `D_KL(q ‖ p) = 0 ↔ q = p`. -/ theorem klDiv_eq_zero_iff {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : klDiv q p = 0 ↔ q = p := by constructor · intro hzero funext i by_contra hne have hterm_le : ∀ j ∈ (Finset.univ : Finset ι), q j - p j ≤ q j * Real.log (q j / p j) := by intro j _ have hqj := hq.1 j; have hpj := hp.1 j have hlog := Real.log_le_sub_one_of_pos (div_pos hpj hqj) have hneg : Real.log (p j / q j) = -Real.log (q j / p j) := by rw [Real.log_div hpj.ne' hqj.ne', Real.log_div hqj.ne' hpj.ne']; ring have hmul := mul_le_mul_of_nonneg_left hlog hqj.le rw [hneg] at hmul have hsimp : q j * (p j / q j - 1) = p j - q j := by field_simp linarith have hterm_lt : q i - p i < q i * Real.log (q i / p i) := by have hqi := hq.1 i; have hpi := hp.1 i have hdiv_ne : p i / q i ≠ 1 := by intro h1 rw [div_eq_one_iff_eq hqi.ne'] at h1 exact hne h1.symm have hlog := log_lt_sub_one_of_ne_one (div_pos hpi hqi) hdiv_ne have hneg : Real.log (p i / q i) = -Real.log (q i / p i) := by rw [Real.log_div hpi.ne' hqi.ne', Real.log_div hqi.ne' hpi.ne']; ring have hmul := mul_lt_mul_of_pos_left hlog hqi rw [hneg] at hmul have hsimp : q i * (p i / q i - 1) = p i - q i := by field_simp linarith have hstrict : ∑ j, (q j - p j) < ∑ j, q j * Real.log (q j / p j) := Finset.sum_lt_sum hterm_le ⟨i, Finset.mem_univ i, hterm_lt⟩ have hsum0 : ∑ j, (q j - p j) = 0 := by rw [Finset.sum_sub_distrib, hq.2, hp.2, sub_self] unfold klDiv at hzero linarith · intro heq subst heq unfold klDiv apply Finset.sum_eq_zero intro i _ rw [div_self (hq.1 i).ne', Real.log_one, mul_zero] /-- Shannon entropy is non-negative for any positive probability distribution. -/ lemma shannonEntropy_nonneg {ι : Type*} [Fintype ι] {p : ι → ℝ} (hp : IsPosProb p) : 0 ≤ shannonEntropy p := by unfold shannonEntropy have hle : ∀ i, p i * Real.log (p i) ≤ 0 := by intro i have hpi := hp.1 i have hle1 : p i ≤ 1 := by rw [← hp.2] exact Finset.single_le_sum (fun j _ => (hp.1 j).le) (Finset.mem_univ i) exact mul_nonpos_of_nonneg_of_nonpos hpi.le (Real.log_nonpos hpi.le hle1) have hsum : ∑ i, p i * Real.log (p i) ≤ 0 := Finset.sum_nonpos (fun i _ => hle i) linarith /-- Non-negativity of Jeffreys divergence. -/ lemma jeffreysDiv_nonneg {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : 0 ≤ jeffreysDiv q p := add_nonneg (klDiv_nonneg hq hp) (klDiv_nonneg hp hq) /-- Hellinger lower bound on KL divergence: `2 H²(q, p) ≤ D_KL(q ‖ p)`. -/ theorem two_mul_hellingerSq_le_klDiv {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : 2 * hellingerSq q p ≤ klDiv q p := by unfold hellingerSq klDiv have hsum : 2 * (1 - ∑ i, Real.sqrt (q i * p i)) = ∑ i, 2 * (q i - Real.sqrt (q i * p i)) := by rw [← hq.2, ← Finset.sum_sub_distrib, Finset.mul_sum] rw [hsum] apply Finset.sum_le_sum intro i _ have hqi := hq.1 i; have hpi := hp.1 i have hsqrt_pos : 0 < Real.sqrt (p i / q i) := Real.sqrt_pos.mpr (div_pos hpi hqi) have hlog := Real.log_le_sub_one_of_pos hsqrt_pos have hlog_eq : Real.log (q i / p i) = -2 * Real.log (Real.sqrt (p i / q i)) := by rw [Real.log_sqrt (div_pos hpi hqi).le, Real.log_div hpi.ne' hqi.ne', Real.log_div hqi.ne' hpi.ne'] ring have hmul : q i * Real.sqrt (p i / q i) = Real.sqrt (q i * p i) := by rw [Real.sqrt_div hpi.le] have hqeq : q i = Real.sqrt (q i) * Real.sqrt (q i) := (Real.mul_self_sqrt hqi.le).symm rw [Real.sqrt_mul hqi.le] have hsqne : Real.sqrt (q i) ≠ 0 := (Real.sqrt_pos.mpr hqi).ne' calc q i * (Real.sqrt (p i) / Real.sqrt (q i)) = (Real.sqrt (q i) * Real.sqrt (q i)) * (Real.sqrt (p i) / Real.sqrt (q i)) := by rw [← hqeq] _ = Real.sqrt (q i) * Real.sqrt (p i) := by field_simp have h1 : q i * Real.log (Real.sqrt (p i / q i)) ≤ q i * (Real.sqrt (p i / q i) - 1) := mul_le_mul_of_nonneg_left hlog hqi.le rw [hlog_eq] linarith [hmul] /-- Pointwise Topsøe–Csiszár inequality for exact Pinsker: `x log x - (x - 1) ≥ 3 (x - 1)² / (2 (x + 2))` for all `x > 0`. -/ lemma topsoe_pointwise_ineq {x : ℝ} (hx : 0 < x) : 3 * (x - 1) ^ 2 / (2 * (x + 2)) ≤ x * Real.log x - (x - 1) := by let f : ℝ → ℝ := fun t => t * Real.log t - (t - 1) - 3 * (t - 1) ^ 2 / (2 * (t + 2)) let f' : ℝ → ℝ := fun t => Real.log t - (3 / 2) * (1 - 9 / (t + 2) ^ 2) have hf_deriv : ∀ t ∈ Set.Ioi (0 : ℝ), HasDerivAt f (f' t) t := by intro t ht have htpos : 0 < t := ht have ht0 : t ≠ 0 := htpos.ne' have ht2 : t + 2 ≠ 0 := by linarith have hrewrite : ∀ s : ℝ, 0 < s → 3 * (s - 1) ^ 2 / (2 * (s + 2)) = (3 / 2) * (s - 4 + 9 / (s + 2)) := by intro s hs have hs2 : s + 2 ≠ 0 := by linarith field_simp [hs2] ring have h1 : HasDerivAt (fun s => s * Real.log s - (s - 1)) (Real.log t) t := by have ha := (hasDerivAt_id t).mul (Real.hasDerivAt_log ht0) have hb := (hasDerivAt_id t).sub_const (1 : ℝ) exact (ha.sub hb).congr_deriv (by simp only [id_eq]; field_simp [ht0]; ring) have h2 : HasDerivAt (fun s => (3 / 2) * (s - 4 + 9 / (s + 2))) ((3 / 2) * (1 - 9 / (t + 2) ^ 2)) t := by have ha := (hasDerivAt_id t).sub_const (4 : ℝ) have hb := (hasDerivAt_const t (9 : ℝ)).div ((hasDerivAt_id t).add_const (2 : ℝ)) ht2 exact ((ha.add hb).const_mul (3 / 2 : ℝ)).congr_deriv (by simp only [id_eq]; field_simp [ht2]; ring) have h2' : HasDerivAt (fun s => 3 * (s - 1) ^ 2 / (2 * (s + 2))) ((3 / 2) * (1 - 9 / (t + 2) ^ 2)) t := by refine h2.congr_of_eventuallyEq ?_ filter_upwards [eventually_gt_nhds htpos] with s hs exact hrewrite s hs exact h1.sub h2' have hf'_deriv : ∀ t ∈ Set.Ioi (0 : ℝ), HasDerivAt f' (1 / t - 27 / (t + 2) ^ 3) t := by intro t ht have htpos : 0 < t := ht have ht0 : t ≠ 0 := htpos.ne' have ht2 : t + 2 ≠ 0 := by linarith have h1 := Real.hasDerivAt_log ht0 have hpow : HasDerivAt (fun s => (s + 2) ^ 2) (2 * (t + 2)) t := (((hasDerivAt_id t).add_const (2 : ℝ)).pow 2).congr_deriv (by simp only [id_eq]; ring) have hdiv : HasDerivAt (fun s => 9 / (s + 2) ^ 2) (-(9 * (2 * (t + 2))) / ((t + 2) ^ 2) ^ 2) t := ((hasDerivAt_const t (9 : ℝ)).div hpow (pow_ne_zero 2 ht2)).congr_deriv (by ring) have h2 := ((hasDerivAt_const t (1 : ℝ)).sub hdiv).const_mul (3 / 2 : ℝ) exact (h1.sub h2).congr_deriv (by field_simp [ht0, ht2]; ring) have hf'_nonneg_deriv : ∀ t ∈ Set.Ioi (0 : ℝ), 0 ≤ 1 / t - 27 / (t + 2) ^ 3 := by intro t ht have htpos : 0 < t := ht have ht2pos : 0 < t + 2 := by linarith rw [sub_nonneg, div_le_div_iff₀ (pow_pos ht2pos 3) htpos] nlinarith [sq_nonneg (t - 1)] have hf'_mono : MonotoneOn f' (Set.Ioi 0) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ioi 0) (fun t ht => (hf'_deriv t ht).continuousAt.continuousWithinAt) (fun t ht => (hf'_deriv t (interior_subset ht)).hasDerivWithinAt) (fun t ht => hf'_nonneg_deriv t (interior_subset ht)) have hf'1 : f' 1 = 0 := by simp [f']; norm_num have hf1 : f 1 = 0 := by simp [f] suffices h : 0 ≤ f x by dsimp [f] at h; linarith rcases le_or_gt 1 x with hx1 | hx1 · have hmono : MonotoneOn f (Set.Ici 1) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ici 1) (fun t ht => (hf_deriv t (Set.mem_Ioi.mpr (lt_of_lt_of_le zero_lt_one ht))).continuousAt.continuousWithinAt) (fun t ht => (hf_deriv t (Set.mem_Ioi.mpr (lt_of_lt_of_le zero_lt_one (interior_subset ht)))).hasDerivWithinAt) (fun t ht => by rw [← hf'1] exact hf'_mono (Set.mem_Ioi.mpr zero_lt_one) (Set.mem_Ioi.mpr (lt_of_lt_of_le zero_lt_one (interior_subset ht))) (interior_subset ht)) rw [← hf1] exact hmono (Set.mem_Ici.mpr le_rfl) hx1 hx1 · have hanti : AntitoneOn f (Set.Ioc 0 1) := antitoneOn_of_hasDerivWithinAt_nonpos (convex_Ioc 0 1) (fun t ht => (hf_deriv t ht.1).continuousAt.continuousWithinAt) (fun t ht => (hf_deriv t (interior_subset ht).1).hasDerivWithinAt) (fun t ht => by rw [← hf'1] exact hf'_mono (interior_subset ht).1 (by norm_num : (1 : ℝ) ∈ Set.Ioi 0) (interior_subset ht).2) rw [← hf1] exact hanti ⟨hx, hx1.le⟩ ⟨by norm_num, le_rfl⟩ hx1.le /-- **Exact Pinsker's Inequality**: `(1/2) ‖q - p‖₁² ≤ D_KL(q ‖ p)` for all positive distributions. -/ theorem pinsker_ineq {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : (1 / 2 : ℝ) * (l1Dist q p) ^ 2 ≤ klDiv q p := by have htop : ∑ i, 3 * (q i - p i) ^ 2 / (2 * q i + 4 * p i) ≤ klDiv q p := by have hsum0 : ∑ i, (q i - p i) = 0 := by rw [Finset.sum_sub_distrib, hq.2, hp.2, sub_self] have hkl : klDiv q p = ∑ i, p i * ((q i / p i) * Real.log (q i / p i) - (q i / p i - 1)) := by unfold klDiv calc ∑ i, q i * Real.log (q i / p i) = ∑ i, q i * Real.log (q i / p i) - ∑ i, (q i - p i) := by rw [hsum0, sub_zero] _ = ∑ i, (q i * Real.log (q i / p i) - (q i - p i)) := by rw [← Finset.sum_sub_distrib] _ = ∑ i, p i * ((q i / p i) * Real.log (q i / p i) - (q i / p i - 1)) := by apply Finset.sum_congr rfl; intro i _ have hpi := (hp.1 i).ne' field_simp [hpi] rw [hkl] apply Finset.sum_le_sum intro i _ have hqi := hq.1 i; have hpi := hp.1 i have hpt := topsoe_pointwise_ineq (div_pos hqi hpi) have hmul := mul_le_mul_of_nonneg_left hpt hpi.le convert hmul using 1 have hdenom : 2 * q i + 4 * p i ≠ 0 := by linarith have hdenom2 : q i / p i + 2 ≠ 0 := by positivity field_simp [hpi.ne', hdenom, hdenom2] ring -- Cauchy-Schwarz: (∑ |q_i - p_i|)² ≤ (∑ (q_i - p_i)² / (2q_i + 4p_i)) * (∑ (2q_i + 4p_i)) have hcs : (l1Dist q p) ^ 2 ≤ (∑ i, (q i - p i) ^ 2 / (2 * q i + 4 * p i)) * ∑ i, (2 * q i + 4 * p i) := by have h := Finset.sum_mul_sq_le_sq_mul_sq (s := (Finset.univ : Finset ι)) (f := fun i => |q i - p i| / Real.sqrt (2 * q i + 4 * p i)) (g := fun i => Real.sqrt (2 * q i + 4 * p i)) have hlhs : ∑ i, |q i - p i| / Real.sqrt (2 * q i + 4 * p i) * Real.sqrt (2 * q i + 4 * p i) = l1Dist q p := by unfold l1Dist apply Finset.sum_congr rfl; intro i _ have hpos : 0 < 2 * q i + 4 * p i := by linarith [hq.1 i, hp.1 i] rw [div_mul_cancel₀ _ (Real.sqrt_pos.mpr hpos).ne'] have hr1 : ∑ i, (|q i - p i| / Real.sqrt (2 * q i + 4 * p i)) ^ 2 = ∑ i, (q i - p i) ^ 2 / (2 * q i + 4 * p i) := by apply Finset.sum_congr rfl; intro i _ have hpos : 0 < 2 * q i + 4 * p i := by linarith [hq.1 i, hp.1 i] rw [div_pow, sq_abs, Real.sq_sqrt hpos.le] have hr2 : ∑ i, (Real.sqrt (2 * q i + 4 * p i)) ^ 2 = ∑ i, (2 * q i + 4 * p i) := by apply Finset.sum_congr rfl; intro i _ have hpos : 0 < 2 * q i + 4 * p i := by linarith [hq.1 i, hp.1 i] exact Real.sq_sqrt hpos.le rw [hlhs, hr1, hr2] at h exact h have hsum6 : ∑ i, (2 * q i + 4 * p i) = 6 := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, hq.2, hp.2] norm_num have htop3 : ∑ i, 3 * (q i - p i) ^ 2 / (2 * q i + 4 * p i) = 3 * ∑ i, (q i - p i) ^ 2 / (2 * q i + 4 * p i) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro i _; ring rw [hsum6] at hcs rw [htop3] at htop linarith /-- Exact `χ²` identity: `1 + χ²(q ‖ p) = ∑ q_i² / p_i`. -/ lemma one_add_chiSqDiv_eq {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : 1 + chiSqDiv q p = ∑ i, q i ^ 2 / p i := by unfold chiSqDiv have h : ∑ i, (q i - p i) ^ 2 / p i = ∑ i, (q i ^ 2 / p i - 2 * q i + p i) := by apply Finset.sum_congr rfl; intro i _ have hpi := (hp.1 i).ne' field_simp [hpi]; ring rw [h, Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum, hq.2, hp.2] ring /-- Non-negativity of `χ²` divergence. -/ lemma chiSqDiv_nonneg {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hp : IsPosProb p) : 0 ≤ chiSqDiv q p := by unfold chiSqDiv exact Finset.sum_nonneg (fun i _ => div_nonneg (sq_nonneg _) (hp.1 i).le) /-- Sharp `log(1 + χ²)` upper bound on KL divergence: `D_KL(q ‖ p) ≤ log(1 + χ²(q ‖ p)) ≤ χ²(q ‖ p)`. -/ theorem klDiv_le_log_one_add_chiSqDiv {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) : klDiv q p ≤ Real.log (1 + chiSqDiv q p) := by set A := 1 + chiSqDiv q p with hA_def have hA_pos : 0 < A := by linarith [chiSqDiv_nonneg (q := q) hp] have hA_eq : A = ∑ i, q i ^ 2 / p i := one_add_chiSqDiv_eq hq hp have hkl : klDiv q p = Real.log A + ∑ i, q i * Real.log ((q i / p i) / A) := by unfold klDiv calc ∑ i, q i * Real.log (q i / p i) = ∑ i, q i * (Real.log A + Real.log ((q i / p i) / A)) := by apply Finset.sum_congr rfl; intro i _ have hdiv : 0 < q i / p i := div_pos (hq.1 i) (hp.1 i) rw [Real.log_div hdiv.ne' hA_pos.ne']; ring _ = ∑ i, (q i * Real.log A + q i * Real.log ((q i / p i) / A)) := by apply Finset.sum_congr rfl; intro i _; ring _ = (∑ i, q i) * Real.log A + ∑ i, q i * Real.log ((q i / p i) / A) := by rw [Finset.sum_add_distrib, Finset.sum_mul] _ = Real.log A + ∑ i, q i * Real.log ((q i / p i) / A) := by rw [hq.2, one_mul] rw [hkl] have hrem : ∑ i, q i * Real.log ((q i / p i) / A) ≤ 0 := by calc ∑ i, q i * Real.log ((q i / p i) / A) ≤ ∑ i, q i * ((q i / p i) / A - 1) := by apply Finset.sum_le_sum; intro i _ have hqi := hq.1 i; have hpi := hp.1 i exact mul_le_mul_of_nonneg_left (Real.log_le_sub_one_of_pos (div_pos (div_pos hqi hpi) hA_pos)) hqi.le _ = (∑ i, q i ^ 2 / p i) / A - ∑ i, q i := by rw [Finset.sum_div, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro i _ have hpi := (hp.1 i).ne' field_simp [hpi, hA_pos.ne'] _ = A / A - 1 := by rw [← hA_eq, hq.2] _ = 0 := by rw [div_self hA_pos.ne', sub_self] linarith theorem log_one_add_chiSqDiv_le_chiSqDiv {ι : Type*} [Fintype ι] {q p : ι → ℝ} (hp : IsPosProb p) : Real.log (1 + chiSqDiv q p) ≤ chiSqDiv q p := by have hpos : 0 < 1 + chiSqDiv q p := by linarith [chiSqDiv_nonneg (q := q) hp] linarith [Real.log_le_sub_one_of_pos hpos] end CoreInfoTheory /-! ## Section 1 (Pillar 1): Variational Free Energy, Exact Four-Way Decomposition & Curvature Sandwich -/ section Pillar1VFE /-- Discrete generative model slice at a fixed observation `o`: positive prior `p(s)` and positive observation likelihood `L(o | s)`. -/ structure DiscreteGenModel (ι : Type*) [Fintype ι] where prior : ι → ℝ likelihood : ι → ℝ prior_pos : ∀ s, 0 < prior s prior_sum : ∑ s, prior s = 1 lik_pos : ∀ s, 0 < likelihood s namespace DiscreteGenModel variable {ι : Type*} [Fintype ι] (M : DiscreteGenModel ι) lemma prior_isPosProb : IsPosProb M.prior := ⟨M.prior_pos, M.prior_sum⟩ /-- Joint density slice `P(s, o) = p(s) L(o | s)`. -/ def joint (s : ι) : ℝ := M.prior s * M.likelihood s lemma joint_pos (s : ι) : 0 < M.joint s := mul_pos (M.prior_pos s) (M.lik_pos s) /-- Marginal model evidence `Z(o) = ∑_s P(s, o)`. -/ def evidence : ℝ := ∑ s, M.joint s lemma evidence_pos [Nonempty ι] : 0 < M.evidence := Finset.sum_pos (fun s _ => M.joint_pos s) Finset.univ_nonempty /-- Exact Bayesian posterior `p*(s | o) = P(s, o) / Z(o)`. -/ noncomputable def exactPosterior (s : ι) : ℝ := M.joint s / M.evidence lemma exactPosterior_isPosProb [Nonempty ι] : IsPosProb M.exactPosterior := by refine ⟨fun s => div_pos (M.joint_pos s) M.evidence_pos, ?_⟩ unfold exactPosterior rw [← Finset.sum_div] exact div_self M.evidence_pos.ne' /-- Surprisal (negative log model evidence) `S(o) = -log Z(o)`. -/ noncomputable def surprise : ℝ := -Real.log M.evidence /-- Variational Free Energy `F(q) = ∑_s q(s) log(q(s) / P(s, o))`. -/ noncomputable def vfe (q : ι → ℝ) : ℝ := ∑ s, q s * Real.log (q s / M.joint s) /-- Expected generative energy `U(q) = ∑_s q(s) (-log P(s, o))`. -/ noncomputable def expectedEnergy (q : ι → ℝ) : ℝ := ∑ s, q s * (-Real.log (M.joint s)) /-- Expected log-likelihood (accuracy) `Acc(q) = ∑_s q(s) log L(o | s)`. -/ noncomputable def accuracy (q : ι → ℝ) : ℝ := ∑ s, q s * Real.log (M.likelihood s) /-- Complexity `Comp(q) = D_KL(q ‖ p)`. -/ noncomputable def complexity (q : ι → ℝ) : ℝ := klDiv q M.prior /-- **Pillar 1A**: Exact Divergence + Surprise decomposition `F(q) = D_KL(q ‖ p*) + S(o)`. -/ theorem vfe_eq_kl_add_surprise [Nonempty ι] {q : ι → ℝ} (hq : IsPosProb q) : M.vfe q = klDiv q M.exactPosterior + M.surprise := by unfold vfe klDiv exactPosterior surprise have hZ := M.evidence_pos calc ∑ s, q s * Real.log (q s / M.joint s) = ∑ s, (q s * Real.log (q s / (M.joint s / M.evidence)) + q s * (-Real.log M.evidence)) := by apply Finset.sum_congr rfl; intro s _ have hqs := hq.1 s; have hjs := M.joint_pos s rw [Real.log_div hqs.ne' hjs.ne', Real.log_div hqs.ne' (div_pos hjs hZ).ne', Real.log_div hjs.ne' hZ.ne'] ring _ = (∑ s, q s * Real.log (q s / (M.joint s / M.evidence))) + (∑ s, q s) * (-Real.log M.evidence) := by rw [Finset.sum_add_distrib, Finset.sum_mul] _ = (∑ s, q s * Real.log (q s / (M.joint s / M.evidence))) + (-Real.log M.evidence) := by rw [hq.2, one_mul] /-- **Pillar 1B**: Exact Complexity - Accuracy decomposition `F(q) = D_KL(q ‖ p) - E_q[log L]`. -/ theorem vfe_eq_complexity_sub_accuracy {q : ι → ℝ} (hq : IsPosProb q) : M.vfe q = M.complexity q - M.accuracy q := by unfold vfe complexity klDiv accuracy joint rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro s _ have hqs := hq.1 s; have hps := M.prior_pos s; have hls := M.lik_pos s rw [Real.log_div hqs.ne' (mul_pos hps hls).ne', Real.log_mul hps.ne' hls.ne', Real.log_div hqs.ne' hps.ne'] ring /-- **Pillar 1C**: Exact Energy - Entropy decomposition `F(q) = U(q) - H(q)`. -/ theorem vfe_eq_energy_sub_entropy {q : ι → ℝ} (hq : IsPosProb q) : M.vfe q = M.expectedEnergy q - shannonEntropy q := by unfold vfe expectedEnergy shannonEntropy rw [sub_neg_eq_add, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro s _ have hqs := hq.1 s; have hjs := M.joint_pos s rw [Real.log_div hqs.ne' hjs.ne'] ring /-- **Pillar 1D**: Exact Variational Bayes optimality and uniqueness (`F(q) ≥ S(o)`, eq iff `q = p*`). -/ theorem vfe_ge_surprise [Nonempty ι] {q : ι → ℝ} (hq : IsPosProb q) : M.surprise ≤ M.vfe q := by rw [M.vfe_eq_kl_add_surprise hq] linarith [klDiv_nonneg hq M.exactPosterior_isPosProb] theorem vfe_eq_surprise_iff [Nonempty ι] {q : ι → ℝ} (hq : IsPosProb q) : M.vfe q = M.surprise ↔ q = M.exactPosterior := by rw [M.vfe_eq_kl_add_surprise hq, add_eq_right] exact klDiv_eq_zero_iff hq M.exactPosterior_isPosProb theorem vfe_at_exactPosterior [Nonempty ι] : M.vfe M.exactPosterior = M.surprise := (M.vfe_eq_surprise_iff M.exactPosterior_isPosProb).mpr rfl /-- **Pillar 1E (Headline)**: Exact non-asymptotic Pinsker–Hellinger–`χ²` curvature sandwich around the exact Bayesian posterior. -/ theorem vfe_curvature_sandwich [Nonempty ι] {q : ι → ℝ} (hq : IsPosProb q) : max ((1 / 2 : ℝ) * (l1Dist q M.exactPosterior) ^ 2) (2 * hellingerSq q M.exactPosterior) ≤ M.vfe q - M.surprise ∧ M.vfe q - M.surprise ≤ Real.log (1 + chiSqDiv q M.exactPosterior) ∧ Real.log (1 + chiSqDiv q M.exactPosterior) ≤ chiSqDiv q M.exactPosterior := by have hdiff : M.vfe q - M.surprise = klDiv q M.exactPosterior := by linarith [M.vfe_eq_kl_add_surprise hq] rw [hdiff] refine ⟨max_le (pinsker_ineq hq M.exactPosterior_isPosProb) (two_mul_hellingerSq_le_klDiv hq M.exactPosterior_isPosProb), klDiv_le_log_one_add_chiSqDiv hq M.exactPosterior_isPosProb, log_one_add_chiSqDiv_le_chiSqDiv M.exactPosterior_isPosProb⟩ end DiscreteGenModel /-- **Pillar 1F**: Precision-tempered VFE `F_β(q) = E_q[E] - (1/β) H(q)` equals `(1/β) D_KL(q ‖ p_β) - (1/β) log Z(β)`, uniquely minimized at the Gibbs posterior `p_β ∝ e^{-βE}`. -/ noncomputable def temperedVFE {ι : Type*} [Fintype ι] (β : ℝ) (E q : ι → ℝ) : ℝ := (∑ s, q s * E s) - (1 / β) * shannonEntropy q noncomputable def gibbsPartition {ι : Type*} [Fintype ι] (β : ℝ) (E : ι → ℝ) : ℝ := ∑ s, Real.exp (-β * E s) noncomputable def gibbsPosterior {ι : Type*} [Fintype ι] (β : ℝ) (E : ι → ℝ) (s : ι) : ℝ := Real.exp (-β * E s) / gibbsPartition β E lemma gibbsPartition_pos {ι : Type*} [Fintype ι] [Nonempty ι] (β : ℝ) (E : ι → ℝ) : 0 < gibbsPartition β E := Finset.sum_pos (fun _ _ => Real.exp_pos _) Finset.univ_nonempty lemma gibbsPosterior_isPosProb {ι : Type*} [Fintype ι] [Nonempty ι] (β : ℝ) (E : ι → ℝ) : IsPosProb (gibbsPosterior β E) := by refine ⟨fun s => div_pos (Real.exp_pos _) (gibbsPartition_pos β E), ?_⟩ unfold gibbsPosterior rw [← Finset.sum_div] exact div_self (gibbsPartition_pos β E).ne' theorem temperedVFE_exact_gibbs_identity {ι : Type*} [Fintype ι] [Nonempty ι] {β : ℝ} (hβ : 0 < β) (E : ι → ℝ) {q : ι → ℝ} (hq : IsPosProb q) : temperedVFE β E q = (1 / β) * klDiv q (gibbsPosterior β E) - (1 / β) * Real.log (gibbsPartition β E) := by unfold temperedVFE shannonEntropy klDiv gibbsPosterior have hZ := gibbsPartition_pos β E have hterm : ∑ s, q s * Real.log (q s / (Real.exp (-β * E s) / gibbsPartition β E)) = ∑ s, (q s * Real.log (q s) + β * (q s * E s) + q s * Real.log (gibbsPartition β E)) := by apply Finset.sum_congr rfl; intro s _ have hqs := hq.1 s rw [Real.log_div hqs.ne' (div_pos (Real.exp_pos _) hZ).ne', Real.log_div (Real.exp_pos _).ne' hZ.ne', Real.log_exp] ring rw [hterm, Finset.sum_add_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, hq.2, one_mul] field_simp [hβ.ne'] ring theorem temperedVFE_min_iff {ι : Type*} [Fintype ι] [Nonempty ι] {β : ℝ} (hβ : 0 < β) (E : ι → ℝ) {q : ι → ℝ} (hq : IsPosProb q) : -(1 / β) * Real.log (gibbsPartition β E) ≤ temperedVFE β E q ∧ (temperedVFE β E q = -(1 / β) * Real.log (gibbsPartition β E) ↔ q = gibbsPosterior β E) := by rw [temperedVFE_exact_gibbs_identity hβ E hq] have hkl := klDiv_nonneg hq (gibbsPosterior_isPosProb β E) have hpos : 0 < 1 / β := one_div_pos.mpr hβ constructor · nlinarith · constructor · intro heq have h0 : (1 / β) * klDiv q (gibbsPosterior β E) = 0 := by linarith rcases mul_eq_zero.mp h0 with h1 | h2 · linarith · exact (klDiv_eq_zero_iff hq (gibbsPosterior_isPosProb β E)).mp h2 · intro heq rw [(klDiv_eq_zero_iff hq (gibbsPosterior_isPosProb β E)).mpr heq] ring /-- **Pillar 1G**: Sequential Bayesian surprise telescoping under conditionally independent observations `L₁, L₂`: `S(o₁, o₂) = S(o₁) + S(o₂ | o₁)`. -/ theorem sequential_bayes_surprise_telescoping {ι : Type*} [Fintype ι] [Nonempty ι] (M₁ : DiscreteGenModel ι) (L₂ : ι → ℝ) (hL₂ : ∀ s, 0 < L₂ s) : let M₁₂ : DiscreteGenModel ι := { prior := M₁.prior likelihood := fun s => M₁.likelihood s * L₂ s prior_pos := M₁.prior_pos prior_sum := M₁.prior_sum lik_pos := fun s => mul_pos (M₁.lik_pos s) (hL₂ s) } let M₂_given_1 : DiscreteGenModel ι := { prior := M₁.exactPosterior likelihood := L₂ prior_pos := M₁.exactPosterior_isPosProb.1 prior_sum := M₁.exactPosterior_isPosProb.2 lik_pos := hL₂ } M₁₂.surprise = M₁.surprise + M₂_given_1.surprise := by intro M₁₂ M₂_given_1 have hZ₁ := M₁.evidence_pos have hZ₂ := M₂_given_1.evidence_pos have hmul : M₁₂.evidence = M₁.evidence * M₂_given_1.evidence := by change ∑ s, M₁.prior s * (M₁.likelihood s * L₂ s) = M₁.evidence * ∑ s, (M₁.prior s * M₁.likelihood s / M₁.evidence) * L₂ s rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro s _ field_simp [hZ₁.ne'] unfold DiscreteGenModel.surprise rw [hmul, Real.log_mul hZ₁.ne' hZ₂.ne'] ring end Pillar1VFE /-! ## Section 2 (Pillar 2): Entropic Mirror Descent / NGVI & Predictive Coding Contraction Theory -/ section Pillar2MirrorDescent /-- Normalization constant `Z_η(q, p) = ∑_s q(s)^{1-η} p(s)^η` for an entropic mirror-descent step. -/ noncomputable def mirrorNorm {ι : Type*} [Fintype ι] (q p : ι → ℝ) (η : ℝ) : ℝ := ∑ s, q s ^ (1 - η) * p s ^ η /-- Chernoff `η`-divergence `Λ_η(q, p) = -log Z_η(q, p)`. -/ noncomputable def chernoffDiv {ι : Type*} [Fintype ι] (q p : ι → ℝ) (η : ℝ) : ℝ := -Real.log (mirrorNorm q p η) /-- Single entropic mirror-descent / natural-gradient VI step: `q₁(s) = q(s)^{1-η} p*(s)^η / Z_η(q, p*)`. -/ noncomputable def mirrorStep {ι : Type*} [Fintype ι] (q p : ι → ℝ) (η : ℝ) (s : ι) : ℝ := q s ^ (1 - η) * p s ^ η / mirrorNorm q p η /-- `T`-step iterate of entropic mirror descent starting from `q₀`. -/ noncomputable def mirrorIter {ι : Type*} [Fintype ι] (q₀ p : ι → ℝ) (η : ℝ) : ℕ → ι → ℝ | 0 => q₀ | t + 1 => mirrorStep (mirrorIter q₀ p η t) p η lemma mirrorNorm_pos {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) (η : ℝ) : 0 < mirrorNorm q p η := Finset.sum_pos (fun s _ => mul_pos (Real.rpow_pos_of_pos (hq.1 s) _) (Real.rpow_pos_of_pos (hp.1 s) _)) Finset.univ_nonempty lemma mirrorStep_isPosProb {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) (η : ℝ) : IsPosProb (mirrorStep q p η) := by refine ⟨fun s => div_pos (mul_pos (Real.rpow_pos_of_pos (hq.1 s) _) (Real.rpow_pos_of_pos (hp.1 s) _)) (mirrorNorm_pos hq hp η), ?_⟩ unfold mirrorStep rw [← Finset.sum_div] exact div_self (mirrorNorm_pos hq hp η).ne' lemma mirrorIter_isPosProb {ι : Type*} [Fintype ι] [Nonempty ι] {q₀ p : ι → ℝ} (hq₀ : IsPosProb q₀) (hp : IsPosProb p) (η : ℝ) : ∀ t, IsPosProb (mirrorIter q₀ p η t) | 0 => hq₀ | t + 1 => mirrorStep_isPosProb (mirrorIter_isPosProb hq₀ hp η t) hp η /-- Chernoff `η`-divergence is non-negative for all `η ∈ [0, 1]` via weighted AM–GM. -/ theorem chernoffDiv_nonneg {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) {η : ℝ} (hη0 : 0 ≤ η) (hη1 : η ≤ 1) : 0 ≤ chernoffDiv q p η := by unfold chernoffDiv have hZle1 : mirrorNorm q p η ≤ 1 := by unfold mirrorNorm calc ∑ s, q s ^ (1 - η) * p s ^ η ≤ ∑ s, ((1 - η) * q s + η * p s) := by apply Finset.sum_le_sum; intro s _ exact Real.geom_mean_le_arith_mean2_weighted (by linarith) hη0 (hq.1 s).le (hp.1 s).le (by ring) _ = (1 - η) * ∑ s, q s + η * ∑ s, p s := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] _ = 1 := by rw [hq.2, hp.2]; ring have hlog : Real.log (mirrorNorm q p η) ≤ 0 := Real.log_nonpos (mirrorNorm_pos hq hp η).le hZle1 linarith /-- **Pillar 2A (Exact Bregman Pythagorean Identity)**: For EVERY reference distribution `r ∈ Δ_ι°` and every step size `η ∈ ℝ`, `η D_KL(r ‖ p*) + (1 - η) D_KL(r ‖ q) = D_KL(r ‖ q₁) + Λ_η(q, p*)`. -/ theorem mirrorStep_pythagorean_identity {ι : Type*} [Fintype ι] [Nonempty ι] {r q p : ι → ℝ} (hr : IsPosProb r) (hq : IsPosProb q) (hp : IsPosProb p) (η : ℝ) : η * klDiv r p + (1 - η) * klDiv r q = klDiv r (mirrorStep q p η) + chernoffDiv q p η := by unfold klDiv mirrorStep chernoffDiv have hZ := mirrorNorm_pos hq hp η rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib] have hright : ∑ s, r s * Real.log (r s / (q s ^ (1 - η) * p s ^ η / mirrorNorm q p η)) + (-Real.log (mirrorNorm q p η)) = ∑ s, (r s * Real.log (r s / (q s ^ (1 - η) * p s ^ η / mirrorNorm q p η)) + r s * (-Real.log (mirrorNorm q p η))) := by rw [Finset.sum_add_distrib, ← Finset.sum_mul, hr.2, one_mul] rw [hright] apply Finset.sum_congr rfl; intro s _ have hrs := hr.1 s; have hqs := hq.1 s; have hps := hp.1 s have hpow1 := Real.rpow_pos_of_pos hqs (1 - η) have hpow2 := Real.rpow_pos_of_pos hps η rw [Real.log_div hrs.ne' hps.ne', Real.log_div hrs.ne' hqs.ne', Real.log_div hrs.ne' (div_pos (mul_pos hpow1 hpow2) hZ).ne', Real.log_div (mul_pos hpow1 hpow2).ne' hZ.ne', Real.log_mul hpow1.ne' hpow2.ne', Real.log_rpow hqs, Real.log_rpow hps] ring /-- **Pillar 2B (Exact Two-Sided VFE Descent Identity)**: `D_KL(q ‖ p*) - D_KL(q₁ ‖ p*) = (1/η) D_KL(q ‖ q₁) + ((1-η)/η) D_KL(q₁ ‖ q)`. -/ theorem mirrorStep_exact_kl_descent {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) {η : ℝ} (hη : η ≠ 0) : klDiv q p - klDiv (mirrorStep q p η) p = (1 / η) * klDiv q (mirrorStep q p η) + ((1 - η) / η) * klDiv (mirrorStep q p η) q := by have hq1 := mirrorStep_isPosProb hq hp η have h1 := mirrorStep_pythagorean_identity hq1 hq hp η have h2 := mirrorStep_pythagorean_identity hq hq hp η have hzero1 : klDiv (mirrorStep q p η) (mirrorStep q p η) = 0 := (klDiv_eq_zero_iff hq1 hq1).mpr rfl have hzero2 : klDiv q q = 0 := (klDiv_eq_zero_iff hq hq).mpr rfl rw [hzero1, zero_add] at h1 rw [hzero2, mul_zero, add_zero] at h2 -- h1: η * kl(q₁, p) + (1 - η) * kl(q₁, q) = Λ -- h2: η * kl(q, p) = kl(q, q₁) + Λ have hsub : η * (klDiv q p - klDiv (mirrorStep q p η) p) = klDiv q (mirrorStep q p η) + (1 - η) * klDiv (mirrorStep q p η) q := by linarith field_simp [hη] linarith /-- VFE strictly decreases on every step `η ∈ (0, 1]` unless already at exact Bayes `q = p*`. -/ theorem mirrorStep_vfe_monotone_descent {ι : Type*} [Fintype ι] [Nonempty ι] (M : DiscreteGenModel ι) {q : ι → ℝ} (hq : IsPosProb q) {η : ℝ} (hη0 : 0 < η) (hη1 : η ≤ 1) : M.vfe (mirrorStep q M.exactPosterior η) ≤ M.vfe q := by have hq1 := mirrorStep_isPosProb hq M.exactPosterior_isPosProb η rw [M.vfe_eq_kl_add_surprise hq1, M.vfe_eq_kl_add_surprise hq] have hdesc := mirrorStep_exact_kl_descent hq M.exactPosterior_isPosProb hη0.ne' have hd1 := klDiv_nonneg hq hq1 have hd2 := klDiv_nonneg hq1 hq have h1 : 0 ≤ (1 / η) * klDiv q (mirrorStep q M.exactPosterior η) := mul_nonneg (one_div_nonneg.mpr hη0.le) hd1 have h2 : 0 ≤ ((1 - η) / η) * klDiv (mirrorStep q M.exactPosterior η) q := mul_nonneg (div_nonneg (by linarith) hη0.le) hd2 linarith /-- **Pillar 2C (Exact Forward-KL Contraction Identity)**: `D_KL(p* ‖ q₁) = (1 - η) D_KL(p* ‖ q) - Λ_η(q, p*) ≤ (1 - η) D_KL(p* ‖ q)`. -/ theorem mirrorStep_forward_kl_exact_contraction {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) (η : ℝ) : klDiv p (mirrorStep q p η) = (1 - η) * klDiv p q - chernoffDiv q p η := by have h := mirrorStep_pythagorean_identity hp hq hp η have hzero : klDiv p p = 0 := (klDiv_eq_zero_iff hp hp).mpr rfl rw [hzero, mul_zero, zero_add] at h linarith theorem mirrorStep_forward_kl_contraction_le {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) {η : ℝ} (hη0 : 0 ≤ η) (hη1 : η ≤ 1) : klDiv p (mirrorStep q p η) ≤ (1 - η) * klDiv p q := by rw [mirrorStep_forward_kl_exact_contraction hq hp η] linarith [chernoffDiv_nonneg hq hp hη0 hη1] /-- **Pillar 2D (Exact Symmetrized Jeffreys Contraction Identity)**: `J(q₁, p*) = (1 - η) J(q, p*) - ((1 - η) / η) J(q, q₁) ≤ (1 - η) J(q, p*)`. Remarkably, the Chernoff divergence `Λ_η` cancels identically! -/ theorem mirrorStep_jeffreys_exact_contraction {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) {η : ℝ} (hη : η ≠ 0) : jeffreysDiv (mirrorStep q p η) p = (1 - η) * jeffreysDiv q p - ((1 - η) / η) * jeffreysDiv q (mirrorStep q p η) := by unfold jeffreysDiv have hq1 := mirrorStep_isPosProb hq hp η have hp1 := mirrorStep_pythagorean_identity hq1 hq hp η have hp2 := mirrorStep_pythagorean_identity hq hq hp η have hp3 := mirrorStep_pythagorean_identity hp hq hp η rw [(klDiv_eq_zero_iff hq1 hq1).mpr rfl, zero_add] at hp1 rw [(klDiv_eq_zero_iff hq hq).mpr rfl, mul_zero, add_zero] at hp2 rw [(klDiv_eq_zero_iff hp hp).mpr rfl, mul_zero, zero_add] at hp3 -- hp1: η * kl(q₁, p) + (1-η) * kl(q₁, q) = Λ -- hp2: η * kl(q, p) = kl(q, q₁) + Λ -- hp3: (1-η) * kl(p, q) = kl(p, q₁) + Λ have hmul2 : (1 - η) * (η * klDiv q p) = (1 - η) * (klDiv q (mirrorStep q p η) + chernoffDiv q p η) := congrArg ((1 - η) * ·) hp2 have hmul3 : η * ((1 - η) * klDiv p q) = η * (klDiv p (mirrorStep q p η) + chernoffDiv q p η) := congrArg (η * ·) hp3 have hmul : η * (klDiv (mirrorStep q p η) p + klDiv p (mirrorStep q p η)) = η * ((1 - η) * (klDiv q p + klDiv p q)) - (1 - η) * (klDiv q (mirrorStep q p η) + klDiv (mirrorStep q p η) q) := by linarith [hp1, hmul2, hmul3] field_simp [hη] linarith theorem mirrorStep_jeffreys_contraction_le {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (hq : IsPosProb q) (hp : IsPosProb p) {η : ℝ} (hη0 : 0 < η) (hη1 : η ≤ 1) : jeffreysDiv (mirrorStep q p η) p ≤ (1 - η) * jeffreysDiv q p := by rw [mirrorStep_jeffreys_exact_contraction hq hp hη0.ne'] have hq1 := mirrorStep_isPosProb hq hp η have hJ := jeffreysDiv_nonneg hq hq1 have hcoef : 0 ≤ (1 - η) / η := div_nonneg (by linarith) hη0.le nlinarith /-- One-step exact Bayes attainment at `η = 1`: `mirrorStep q p 1 = p`. -/ theorem mirrorStep_one_eq_exact {ι : Type*} [Fintype ι] [Nonempty ι] {q p : ι → ℝ} (_hq : IsPosProb q) (hp : IsPosProb p) : mirrorStep q p 1 = p := by funext s unfold mirrorStep mirrorNorm have hnorm : ∑ i, q i ^ (1 - (1 : ℝ)) * p i ^ (1 : ℝ) = 1 := by have : ∑ i, q i ^ (1 - (1 : ℝ)) * p i ^ (1 : ℝ) = ∑ i, p i := by apply Finset.sum_congr rfl; intro i _ simp [sub_self, Real.rpow_zero, Real.rpow_one] rw [this, hp.2] rw [hnorm, div_one, sub_self, Real.rpow_zero, Real.rpow_one, one_mul] /-- Closed-form exponential geodesic law: `T` steps of mirror descent with step `η` equal one direct geodesic step of weight `1 - (1 - η)^T`. -/ theorem mirrorIter_closed_form {ι : Type*} [Fintype ι] [Nonempty ι] {q₀ p : ι → ℝ} (hq₀ : IsPosProb q₀) (hp : IsPosProb p) (η : ℝ) : ∀ t : ℕ, mirrorIter q₀ p η t = mirrorStep q₀ p (1 - (1 - η) ^ t) := by intro t induction t with | zero => funext s simp only [mirrorIter, pow_zero, sub_self, mirrorStep, mirrorNorm, sub_zero, Real.rpow_one, Real.rpow_zero, mul_one, hq₀.2, div_one] | succ t ih => funext s simp only [mirrorIter, ih] set α : ℝ := (1 - η) ^ t set Z₁ : ℝ := mirrorNorm q₀ p (1 - α) have hZ₁ : 0 < Z₁ := mirrorNorm_pos hq₀ hp (1 - α) have hpow_step : ∀ i, (mirrorStep q₀ p (1 - α) i) ^ (1 - η) * p i ^ η = (Z₁ ^ (1 - η))⁻¹ * (q₀ i ^ (1 - (1 - (1 - η) ^ (t + 1))) * p i ^ (1 - (1 - η) ^ (t + 1))) := by intro i have hqi := hq₀.1 i; have hpi := hp.1 i have hqpow := Real.rpow_pos_of_pos hqi (1 - (1 - α)) have hppow := Real.rpow_pos_of_pos hpi (1 - α) have hexp1 : (1 - (1 - α)) * (1 - η) = 1 - (1 - (1 - η) ^ (t + 1)) := by dsimp [α]; rw [pow_succ]; ring have hexp2 : (1 - α) * (1 - η) + η = 1 - (1 - η) ^ (t + 1) := by dsimp [α]; rw [pow_succ]; ring have hp_comb : p i ^ ((1 - α) * (1 - η)) * p i ^ η = p i ^ (1 - (1 - η) ^ (t + 1)) := by rw [← Real.rpow_add hpi, hexp2] calc (mirrorStep q₀ p (1 - α) i) ^ (1 - η) * p i ^ η = (q₀ i ^ (1 - (1 - α)) * p i ^ (1 - α) / Z₁) ^ (1 - η) * p i ^ η := rfl _ = (q₀ i ^ (1 - (1 - α)) * p i ^ (1 - α)) ^ (1 - η) / Z₁ ^ (1 - η) * p i ^ η := by rw [Real.div_rpow (mul_pos hqpow hppow).le hZ₁.le] _ = q₀ i ^ ((1 - (1 - α)) * (1 - η)) * p i ^ ((1 - α) * (1 - η)) * (Z₁ ^ (1 - η))⁻¹ * p i ^ η := by rw [Real.mul_rpow hqpow.le hppow.le, ← Real.rpow_mul hqi.le, ← Real.rpow_mul hpi.le, div_eq_mul_inv] _ = (Z₁ ^ (1 - η))⁻¹ * (q₀ i ^ (1 - (1 - (1 - η) ^ (t + 1))) * (p i ^ ((1 - α) * (1 - η)) * p i ^ η)) := by rw [hexp1]; ring _ = (Z₁ ^ (1 - η))⁻¹ * (q₀ i ^ (1 - (1 - (1 - η) ^ (t + 1))) * p i ^ (1 - (1 - η) ^ (t + 1))) := by rw [hp_comb] have hsum_eq : ∑ i, (mirrorStep q₀ p (1 - α) i) ^ (1 - η) * p i ^ η = (Z₁ ^ (1 - η))⁻¹ * ∑ i, q₀ i ^ (1 - (1 - (1 - η) ^ (t + 1))) * p i ^ (1 - (1 - η) ^ (t + 1)) := by rw [Finset.mul_sum] exact Finset.sum_congr rfl (fun i _ => hpow_step i) change (mirrorStep q₀ p (1 - α) s) ^ (1 - η) * p s ^ η / (∑ i, (mirrorStep q₀ p (1 - α) i) ^ (1 - η) * p i ^ η) = q₀ s ^ (1 - (1 - (1 - η) ^ (t + 1))) * p s ^ (1 - (1 - η) ^ (t + 1)) / (∑ i, q₀ i ^ (1 - (1 - (1 - η) ^ (t + 1))) * p i ^ (1 - (1 - η) ^ (t + 1))) rw [hpow_step s, hsum_eq] have hinv_ne : (Z₁ ^ (1 - η))⁻¹ ≠ 0 := inv_ne_zero (Real.rpow_pos_of_pos hZ₁ _).ne' rw [mul_div_mul_left _ _ hinv_ne] /-- **Pillar 2E (Headline)**: Exact non-asymptotic `T`-step contraction bounds for Forward KL, Jeffreys divergence, and Variational Free Energy under Entropic Mirror Descent. -/ theorem mirrorIter_T_step_contraction {ι : Type*} [Fintype ι] [Nonempty ι] (M : DiscreteGenModel ι) {q₀ : ι → ℝ} (hq₀ : IsPosProb q₀) {η : ℝ} (hη0 : 0 < η) (hη1 : η < 1) (T : ℕ) : let qT := mirrorIter q₀ M.exactPosterior η T klDiv M.exactPosterior qT ≤ (1 - η) ^ T * klDiv M.exactPosterior q₀ ∧ jeffreysDiv qT M.exactPosterior ≤ (1 - η) ^ T * jeffreysDiv q₀ M.exactPosterior ∧ M.vfe qT - M.surprise ≤ (1 - η) ^ T * jeffreysDiv q₀ M.exactPosterior := by intro qT have hp := M.exactPosterior_isPosProb have hqT := mirrorIter_isPosProb hq₀ hp η T have hfkl : ∀ t, klDiv M.exactPosterior (mirrorIter q₀ M.exactPosterior η t) ≤ (1 - η) ^ t * klDiv M.exactPosterior q₀ := by intro t; induction t with | zero => simp [mirrorIter] | succ t ih => have hqt := mirrorIter_isPosProb hq₀ hp η t calc klDiv M.exactPosterior (mirrorIter q₀ M.exactPosterior η (t + 1)) ≤ (1 - η) * klDiv M.exactPosterior (mirrorIter q₀ M.exactPosterior η t) := mirrorStep_forward_kl_contraction_le hqt hp hη0.le hη1.le _ ≤ (1 - η) * ((1 - η) ^ t * klDiv M.exactPosterior q₀) := mul_le_mul_of_nonneg_left ih (by linarith) _ = (1 - η) ^ (t + 1) * klDiv M.exactPosterior q₀ := by rw [pow_succ']; ring have hjeff : ∀ t, jeffreysDiv (mirrorIter q₀ M.exactPosterior η t) M.exactPosterior ≤ (1 - η) ^ t * jeffreysDiv q₀ M.exactPosterior := by intro t; induction t with | zero => simp [mirrorIter] | succ t ih => have hqt := mirrorIter_isPosProb hq₀ hp η t calc jeffreysDiv (mirrorIter q₀ M.exactPosterior η (t + 1)) M.exactPosterior ≤ (1 - η) * jeffreysDiv (mirrorIter q₀ M.exactPosterior η t) M.exactPosterior := mirrorStep_jeffreys_contraction_le hqt hp hη0 hη1.le _ ≤ (1 - η) * ((1 - η) ^ t * jeffreysDiv q₀ M.exactPosterior) := mul_le_mul_of_nonneg_left ih (by linarith) _ = (1 - η) ^ (t + 1) * jeffreysDiv q₀ M.exactPosterior := by rw [pow_succ']; ring have hvfe : M.vfe qT - M.surprise ≤ (1 - η) ^ T * jeffreysDiv q₀ M.exactPosterior := by have hdiff : M.vfe qT - M.surprise = klDiv qT M.exactPosterior := by linarith [M.vfe_eq_kl_add_surprise hqT] rw [hdiff] have h1 : klDiv qT M.exactPosterior + klDiv M.exactPosterior qT ≤ (1 - η) ^ T * jeffreysDiv q₀ M.exactPosterior := hjeff T have h2 := klDiv_nonneg hp hqT linarith exact ⟨hfkl T, hjeff T, hvfe⟩ /-- Sharp `T`-step VFE bound purely in terms of the initial Forward KL `D_KL(p* ‖ q₀)`: `F(q_T) - S(o) ≤ ((1 - η)^T / (1 - (1 - η)^T)) * D_KL(p* ‖ q₀)` for every `T ≥ 1`. -/ theorem mirrorIter_T_step_vfe_le_forward_kl {ι : Type*} [Fintype ι] [Nonempty ι] (M : DiscreteGenModel ι) {q₀ : ι → ℝ} (hq₀ : IsPosProb q₀) {η : ℝ} (hη0 : 0 < η) (hη1 : η < 1) {T : ℕ} (hT : 1 ≤ T) : M.vfe (mirrorIter q₀ M.exactPosterior η T) - M.surprise ≤ ((1 - η) ^ T / (1 - (1 - η) ^ T)) * klDiv M.exactPosterior q₀ := by have hp := M.exactPosterior_isPosProb set α : ℝ := (1 - η) ^ T have hα_pos : 0 < α := pow_pos (by linarith) T have hα_lt1 : α < 1 := pow_lt_one₀ (by linarith) (by linarith) (by omega) have h1mα : 0 < 1 - α := by linarith have hqT_eq : mirrorIter q₀ M.exactPosterior η T = mirrorStep q₀ M.exactPosterior (1 - α) := mirrorIter_closed_form hq₀ hp η T have hqT := mirrorIter_isPosProb hq₀ hp η T have hdiff : M.vfe (mirrorIter q₀ M.exactPosterior η T) - M.surprise = klDiv (mirrorStep q₀ M.exactPosterior (1 - α)) M.exactPosterior := by rw [hqT_eq] at hqT ⊢ linarith [M.vfe_eq_kl_add_surprise hqT] rw [hdiff] -- Pythagorean at r = qT: (1 - α) kl(qT, p*) + α kl(qT, q₀) = Λ_{1-α}(q₀, p*) have hpy1 := mirrorStep_pythagorean_identity (mirrorStep_isPosProb hq₀ hp (1 - α)) hq₀ hp (1 - α) rw [(klDiv_eq_zero_iff (mirrorStep_isPosProb hq₀ hp (1 - α)) (mirrorStep_isPosProb hq₀ hp (1 - α))).mpr rfl, zero_add] at hpy1 -- Pythagorean at r = p*: α kl(p*, q₀) = kl(p*, qT) + Λ_{1-α}(q₀, p*) have hpy2 := mirrorStep_pythagorean_identity hp hq₀ hp (1 - α) rw [(klDiv_eq_zero_iff hp hp).mpr rfl, mul_zero, zero_add] at hpy2 have hnonneg1 := klDiv_nonneg (mirrorStep_isPosProb hq₀ hp (1 - α)) hq₀ have hnonneg2 := klDiv_nonneg hp (mirrorStep_isPosProb hq₀ hp (1 - α)) have hmain : (1 - α) * klDiv (mirrorStep q₀ M.exactPosterior (1 - α)) M.exactPosterior ≤ α * klDiv M.exactPosterior q₀ := by nlinarith rw [div_mul_eq_mul_div, le_div_iff₀ h1mα] linarith /-- Elementary upper bound on binary entropy: `h₂(x) ≤ 2 √x` for all `x ∈ (0, 1)`. -/ lemma binaryEntropy_le_two_sqrt {x : ℝ} (hx0 : 0 < x) (hx1 : x < 1) : binaryEntropy x ≤ 2 * Real.sqrt x := by unfold binaryEntropy have h1mx : 0 < 1 - x := by linarith have hsqx : 0 < Real.sqrt x := Real.sqrt_pos.mpr hx0 have hlog1 : Real.log ((Real.sqrt x)⁻¹) ≤ (Real.sqrt x)⁻¹ - 1 := Real.log_le_sub_one_of_pos (inv_pos.mpr hsqx) have hterm1 : -x * Real.log x ≤ 2 * Real.sqrt x - 2 * x := by have hlogx : -Real.log x = 2 * Real.log ((Real.sqrt x)⁻¹) := by rw [Real.log_inv, Real.log_sqrt hx0.le]; ring have hmul : x * (2 * Real.log ((Real.sqrt x)⁻¹)) ≤ x * (2 * ((Real.sqrt x)⁻¹ - 1)) := mul_le_mul_of_nonneg_left (by linarith) hx0.le have hsimp : x * (2 * ((Real.sqrt x)⁻¹ - 1)) = 2 * Real.sqrt x - 2 * x := by have hxsq : Real.sqrt x * Real.sqrt x = x := Real.mul_self_sqrt hx0.le calc x * (2 * ((Real.sqrt x)⁻¹ - 1)) = 2 * ((Real.sqrt x * Real.sqrt x) * (Real.sqrt x)⁻¹) - 2 * x := by rw [hxsq]; ring _ = 2 * Real.sqrt x - 2 * x := by rw [mul_assoc, mul_inv_cancel₀ hsqx.ne', mul_one] calc -x * Real.log x = x * (-Real.log x) := by ring _ = x * (2 * Real.log ((Real.sqrt x)⁻¹)) := by rw [hlogx] _ ≤ x * (2 * ((Real.sqrt x)⁻¹ - 1)) := hmul _ = 2 * Real.sqrt x - 2 * x := hsimp have hlog2 : Real.log ((1 - x)⁻¹) ≤ (1 - x)⁻¹ - 1 := Real.log_le_sub_one_of_pos (inv_pos.mpr h1mx) have hterm2 : -(1 - x) * Real.log (1 - x) ≤ x := by have hmul : (1 - x) * Real.log ((1 - x)⁻¹) ≤ (1 - x) * ((1 - x)⁻¹ - 1) := mul_le_mul_of_nonneg_left hlog2 h1mx.le rw [Real.log_inv] at hmul have hsimp : (1 - x) * ((1 - x)⁻¹ - 1) = x := by field_simp [h1mx.ne']; ring linarith linarith /-- Binary distribution `(1 - ε, ε)` on `Bool`. -/ def bernDist (ε : ℝ) : Bool → ℝ | true => 1 - ε | false => ε lemma bernDist_isPosProb {ε : ℝ} (h0 : 0 < ε) (h1 : ε < 1) : IsPosProb (bernDist ε) := by refine ⟨fun b => by cases b <;> simp [bernDist] <;> linarith, ?_⟩ simp [bernDist] lemma klDiv_bern_unif {ε : ℝ} (h0 : 0 < ε) (h1 : ε < 1) : klDiv (bernDist ε) (bernDist (1 / 2)) = Real.log 2 - binaryEntropy ε := by unfold klDiv binaryEntropy simp only [Fintype.sum_bool, bernDist] have h1m : 0 < 1 - ε := by linarith have hhalf : (1 : ℝ) - 1 / 2 = 1 / 2 := by norm_num rw [hhalf, Real.log_div h1m.ne' (by norm_num), Real.log_div h0.ne' (by norm_num)] have hloghalf : Real.log (1 / 2 : ℝ) = -Real.log 2 := by rw [one_div, Real.log_inv] rw [hloghalf] ring /-- **Pillar 2F (NEW PARADOX — Overconfidence-Trap Non-Contraction Theorem)**: For EVERY step size `η ∈ (0, 1)` and EVERY candidate contraction factor `ρ < 1`, there exist a generative model on `Bool` (uniform posterior) and an initial belief `q₀ ∈ Δ₂°` such that `F(q₁) - S(o) > ρ · (F(q₀) - S(o))`. Thus NO uniform one-step contraction factor `ρ < 1` exists for Variational Free Energy under entropic mirror descent — in sharp contrast to Forward KL and Jeffreys divergence! -/ theorem mirrorStep_no_uniform_vfe_contraction {η ρ : ℝ} (hη0 : 0 < η) (hη1 : η < 1) (hρ : ρ < 1) : ∃ (q₀ p : Bool → ℝ), IsPosProb q₀ ∧ IsPosProb p ∧ ρ * klDiv q₀ p < klDiv (mirrorStep q₀ p η) p := by have h1mη : 0 < 1 - η := by linarith have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) -- Pick c small enough that 2 √c < min(log 2, (1 - ρ) log 2) and c < 1/2 set c := min ((Real.log 2 / 4) ^ 2) (((1 - ρ) * Real.log 2 / 4) ^ 2) have hc_pos : 0 < c := by apply lt_min · exact sq_pos_of_pos (div_pos hlog2 (by norm_num)) · exact sq_pos_of_pos (div_pos (mul_pos (by linarith) hlog2) (by norm_num)) have hc_lt_half : c < 1 / 2 := by have h1 : c ≤ (Real.log 2 / 4) ^ 2 := min_le_left _ _ have hlog2_lt : Real.log 2 < 1 := by linarith [Real.log_two_lt_d9] nlinarith -- Pick ε = (c / 2) ^ (1 / (1 - η)), so ε^(1 - η) = c / 2 set ε := (c / 2) ^ (1 / (1 - η)) have hc2_pos : 0 < c / 2 := by linarith have hc2_lt1 : c / 2 < 1 / 2 := by linarith have hε_pos : 0 < ε := Real.rpow_pos_of_pos hc2_pos _ have hε_lt_half : ε < 1 / 2 := by have hpow_ge1 : (1 : ℝ) ≤ 1 / (1 - η) := (one_le_div h1mη).mpr (by linarith) calc ε = (c / 2) ^ (1 / (1 - η)) := rfl _ ≤ (c / 2) ^ (1 : ℝ) := Real.rpow_le_rpow_of_exponent_ge hc2_pos (by linarith) hpow_ge1 _ = c / 2 := Real.rpow_one _ _ < 1 / 2 := hc2_lt1 have hε_lt1 : ε < 1 := by linarith refine ⟨bernDist ε, bernDist (1 / 2), bernDist_isPosProb hε_pos hε_lt1, bernDist_isPosProb (by norm_num) (by norm_num), ?_⟩ -- Compute mirrorStep (bernDist ε) (bernDist (1/2)) η = bernDist δ set δ := ε ^ (1 - η) / ((1 - ε) ^ (1 - η) + ε ^ (1 - η)) have h1mε_pos : 0 < 1 - ε := by linarith have hpow1_pos : 0 < (1 - ε) ^ (1 - η) := Real.rpow_pos_of_pos h1mε_pos _ have hpow2_pos : 0 < ε ^ (1 - η) := Real.rpow_pos_of_pos hε_pos _ have hδ_pos : 0 < δ := div_pos hpow2_pos (add_pos hpow1_pos hpow2_pos) have hδ_lt1 : δ < 1 := (div_lt_one (add_pos hpow1_pos hpow2_pos)).mpr (by linarith) have hstep_eq : mirrorStep (bernDist ε) (bernDist (1 / 2)) η = bernDist δ := by funext b unfold mirrorStep mirrorNorm simp only [Fintype.sum_bool, bernDist] have hhalf : (1 : ℝ) - 1 / 2 = 1 / 2 := by norm_num have hpη_pos : 0 < (1 / 2 : ℝ) ^ η := Real.rpow_pos_of_pos (by norm_num) η rw [hhalf, ← add_mul] cases b · -- false rw [mul_div_mul_right _ _ hpη_pos.ne'] · -- true rw [mul_div_mul_right _ _ hpη_pos.ne'] have h1mδ : 1 - δ = (1 - ε) ^ (1 - η) / ((1 - ε) ^ (1 - η) + ε ^ (1 - η)) := by dsimp [δ] field_simp [(add_pos hpow1_pos hpow2_pos).ne'] ring exact h1mδ.symm rw [hstep_eq, klDiv_bern_unif hε_pos hε_lt1, klDiv_bern_unif hδ_pos hδ_lt1] -- Bound δ ≤ c: since 1 - ε > 1/2, (1-ε)^(1-η) > 1/2, and ε^(1-η) = c/2 have hε_pow : ε ^ (1 - η) = c / 2 := by dsimp [ε] rw [← Real.rpow_mul hc2_pos.le, one_div_mul_cancel h1mη.ne', Real.rpow_one] have h1mε_pow : (1 / 2 : ℝ) < (1 - ε) ^ (1 - η) := by have hgt : (1 / 2 : ℝ) < 1 - ε := by linarith calc (1 / 2 : ℝ) = (1 / 2 : ℝ) ^ (1 : ℝ) := (Real.rpow_one _).symm _ ≤ (1 / 2 : ℝ) ^ (1 - η) := Real.rpow_le_rpow_of_exponent_ge (by norm_num) (by norm_num) (by linarith) _ < (1 - ε) ^ (1 - η) := Real.rpow_lt_rpow (by norm_num) hgt h1mη have hδ_le_c : δ ≤ c := by dsimp [δ] rw [hε_pow, div_le_iff₀ (add_pos hpow1_pos (by linarith : 0 < c / 2))] nlinarith have h2sqrt_lt : 2 * Real.sqrt δ < (1 - ρ) * Real.log 2 := by have hsq1 : Real.sqrt δ ≤ Real.sqrt c := Real.sqrt_le_sqrt hδ_le_c have hsq2 : Real.sqrt c ≤ (1 - ρ) * Real.log 2 / 4 := by have hcle : c ≤ ((1 - ρ) * Real.log 2 / 4) ^ 2 := min_le_right _ _ calc Real.sqrt c ≤ Real.sqrt (((1 - ρ) * Real.log 2 / 4) ^ 2) := Real.sqrt_le_sqrt hcle _ = (1 - ρ) * Real.log 2 / 4 := Real.sqrt_sq (div_nonneg (mul_nonneg (by linarith) hlog2.le) (by norm_num)) have hpos_rhs : 0 < (1 - ρ) * Real.log 2 := mul_pos (by linarith) hlog2 linarith have hbin_δ : binaryEntropy δ ≤ 2 * Real.sqrt δ := binaryEntropy_le_two_sqrt hδ_pos hδ_lt1 have hbin_ε : 0 ≤ binaryEntropy ε := by have h := shannonEntropy_nonneg (bernDist_isPosProb hε_pos hε_lt1) unfold shannonEntropy at h simp only [Fintype.sum_bool, bernDist] at h unfold binaryEntropy linarith -- If ρ ≤ 0, LHS ≤ 0 < RHS; if ρ > 0, ρ (log 2 - h₂(ε)) ≤ ρ log 2 < log 2 - h₂(δ) have hkl0_nonneg : 0 ≤ Real.log 2 - binaryEntropy ε := by rw [← klDiv_bern_unif hε_pos hε_lt1] exact klDiv_nonneg (bernDist_isPosProb hε_pos hε_lt1) (bernDist_isPosProb (by norm_num) (by norm_num)) have h2sqrt_lt_log2 : 2 * Real.sqrt δ < Real.log 2 := by have hsq1 : Real.sqrt δ ≤ Real.sqrt c := Real.sqrt_le_sqrt hδ_le_c have hsq2 : Real.sqrt c ≤ Real.log 2 / 4 := by calc Real.sqrt c ≤ Real.sqrt ((Real.log 2 / 4) ^ 2) := Real.sqrt_le_sqrt (min_le_left _ _) _ = Real.log 2 / 4 := Real.sqrt_sq (div_nonneg hlog2.le (by norm_num)) linarith rcases le_or_gt ρ 0 with hρ0 | hρ0 · have hlhs : ρ * (Real.log 2 - binaryEntropy ε) ≤ 0 := mul_nonpos_of_nonpos_of_nonneg hρ0 hkl0_nonneg have hrhs : 0 < Real.log 2 - binaryEntropy δ := by linarith linarith · nlinarith /-- **Explicit Rational Overconfidence-Trap Witness** (`k = 99, η = 1/2`): `q₀ = (9801/9802, 1/9802)`, `p* = (1/2, 1/2)` gives exact rational next iterate `q₁ = (99/100, 1/100)` with `D_KL(q₁ ‖ p*) > (4/5) D_KL(q₀ ‖ p*) > (1 - η) D_KL(q₀ ‖ p*)`. -/ theorem mirrorStep_rational_overconfidence_witness : let q₀ := bernDist (1 / 9802 : ℝ) let p := bernDist (1 / 2 : ℝ) mirrorStep q₀ p (1 / 2) = bernDist (1 / 100 : ℝ) ∧ (1 / 2 : ℝ) * klDiv q₀ p < klDiv (mirrorStep q₀ p (1 / 2)) p := by intro q₀ p have hstep : mirrorStep q₀ p (1 / 2) = bernDist (1 / 100 : ℝ) := by funext b unfold mirrorStep mirrorNorm q₀ p simp only [Fintype.sum_bool, bernDist] have h1 : (1 : ℝ) - 1 / 2 = 1 / 2 := by norm_num have h2 : (1 : ℝ) - 1 / 9802 = 9801 / 9802 := by norm_num have h3 : (1 : ℝ) - 1 / 100 = 99 / 100 := by norm_num have hpow_half : 0 < (1 / 2 : ℝ) ^ (1 / 2 : ℝ) := Real.rpow_pos_of_pos (by norm_num) _ rw [h1, h2, ← add_mul] have hsq1 : (9801 / 9802 : ℝ) ^ (1 / 2 : ℝ) = 99 / Real.sqrt 9802 := by rw [← Real.sqrt_eq_rpow, Real.sqrt_div (by norm_num), show (9801 : ℝ) = 99 ^ 2 by norm_num, Real.sqrt_sq (by norm_num)] have hsq2 : (1 / 9802 : ℝ) ^ (1 / 2 : ℝ) = 1 / Real.sqrt 9802 := by rw [← Real.sqrt_eq_rpow, Real.sqrt_div (by norm_num), Real.sqrt_one] have hsq9802 : Real.sqrt 9802 ≠ 0 := (Real.sqrt_pos.mpr (by norm_num)).ne' cases b · rw [mul_div_mul_right _ _ hpow_half.ne', hsq1, hsq2] field_simp [hsq9802]; norm_num · rw [mul_div_mul_right _ _ hpow_half.ne', hsq1, hsq2, h3] field_simp [hsq9802]; norm_num refine ⟨hstep, ?_⟩ rw [hstep, klDiv_bern_unif (by norm_num) (by norm_num), klDiv_bern_unif (by norm_num) (by norm_num)] have hbin100 : binaryEntropy (1 / 100 : ℝ) ≤ 1 / 5 := by have h := binaryEntropy_le_two_sqrt (x := (1 / 100 : ℝ)) (by norm_num) (by norm_num) have hsq : Real.sqrt (1 / 100 : ℝ) = 1 / 10 := by rw [show (1 / 100 : ℝ) = (1 / 10) ^ 2 by norm_num, Real.sqrt_sq (by norm_num)] rw [hsq] at h; linarith have hbin_nonneg : 0 ≤ binaryEntropy (1 / 9802 : ℝ) := by have h := shannonEntropy_nonneg (bernDist_isPosProb (ε := 1 / 9802) (by norm_num) (by norm_num)) unfold shannonEntropy at h; simp only [Fintype.sum_bool, bernDist] at h unfold binaryEntropy; linarith have hlog2 : (69 / 100 : ℝ) < Real.log 2 := by have := Real.log_two_gt_d9 linarith linarith /-! ### Linear-Gaussian Predictive Coding: Precision Stiffness vs. Precision-Invariant Natural Gradient -/ /-- Linear-Gaussian predictive coding Variational Free Energy (up to state-independent constant): `F(μ) = (1/2) π_p (μ - μ_p)² + (1/2) π_o (o - g μ)²`. -/ noncomputable def pcVFE (π_p π_o g μ_p o μ : ℝ) : ℝ := (1 / 2) * π_p * (μ - μ_p) ^ 2 + (1 / 2) * π_o * (o - g * μ) ^ 2 /-- Posterior precision `Π* = π_p + g² π_o`. -/ def pcPostPrec (π_p π_o g : ℝ) : ℝ := π_p + g ^ 2 * π_o /-- Exact linear-Gaussian Bayesian posterior mean `μ* = (π_p μ_p + g π_o o) / Π*`. -/ noncomputable def pcPostMean (π_p π_o g μ_p o : ℝ) : ℝ := (π_p * μ_p + g * π_o * o) / pcPostPrec π_p π_o g /-- Euclidean predictive-coding gradient step: `μ_{t+1} = μ_t - η (π_p (μ_t - μ_p) - g π_o (o - g μ_t))`. -/ def pcEuclidStep (π_p π_o g μ_p o η μ : ℝ) : ℝ := μ - η * (π_p * (μ - μ_p) - g * π_o * (o - g * μ)) /-- Precision-normalized (natural-gradient) predictive-coding step: `μ_{t+1} = μ_t - (η / Π*) (π_p (μ_t - μ_p) - g π_o (o - g μ_t))`. -/ noncomputable def pcNatGradStep (π_p π_o g μ_p o η μ : ℝ) : ℝ := μ - (η / pcPostPrec π_p π_o g) * (π_p * (μ - μ_p) - g * π_o * (o - g * μ)) /-- Exact quadratic VFE excess identity around the Bayesian posterior mean `μ*`. -/ theorem pcVFE_exact_excess {π_p π_o g μ_p o μ : ℝ} (hprec : pcPostPrec π_p π_o g ≠ 0) : pcVFE π_p π_o g μ_p o μ - pcVFE π_p π_o g μ_p o (pcPostMean π_p π_o g μ_p o) = (1 / 2) * pcPostPrec π_p π_o g * (μ - pcPostMean π_p π_o g μ_p o) ^ 2 := by unfold pcVFE pcPostMean pcPostPrec at * set P := π_p + g ^ 2 * π_o have hP : P ≠ 0 := hprec have h1 : (π_p * μ_p + g * π_o * o) / P * P = π_p * μ_p + g * π_o * o := div_mul_cancel₀ _ hP apply mul_right_cancel₀ (pow_ne_zero 2 hP) have hmul : ((1 / 2) * π_p * (μ - μ_p) ^ 2 + (1 / 2) * π_o * (o - g * μ) ^ 2 - ((1 / 2) * π_p * ((π_p * μ_p + g * π_o * o) / P - μ_p) ^ 2 + (1 / 2) * π_o * (o - g * ((π_p * μ_p + g * π_o * o) / P)) ^ 2)) * P ^ 2 = (1 / 2) * π_p * (μ - μ_p) ^ 2 * P ^ 2 + (1 / 2) * π_o * (o - g * μ) ^ 2 * P ^ 2 - ((1 / 2) * π_p * ((π_p * μ_p + g * π_o * o) - μ_p * P) ^ 2 + (1 / 2) * π_o * (o * P - g * (π_p * μ_p + g * π_o * o)) ^ 2) := by have hsq1 : ((π_p * μ_p + g * π_o * o) / P - μ_p) ^ 2 * P ^ 2 = ((π_p * μ_p + g * π_o * o) - μ_p * P) ^ 2 := by rw [← mul_pow]; congr 1; rw [sub_mul, h1] have hsq2 : (o - g * ((π_p * μ_p + g * π_o * o) / P)) ^ 2 * P ^ 2 = (o * P - g * (π_p * μ_p + g * π_o * o)) ^ 2 := by rw [← mul_pow]; congr 1; rw [sub_mul, mul_assoc, h1] rw [sub_mul, add_mul, add_mul] congr 1 congr 1 · rw [mul_assoc, hsq1] · rw [mul_assoc, hsq2] have hrhs : (1 / 2) * P * (μ - (π_p * μ_p + g * π_o * o) / P) ^ 2 * P ^ 2 = (1 / 2) * P * (μ * P - (π_p * μ_p + g * π_o * o)) ^ 2 := by have hsq : (μ - (π_p * μ_p + g * π_o * o) / P) ^ 2 * P ^ 2 = (μ * P - (π_p * μ_p + g * π_o * o)) ^ 2 := by rw [← mul_pow]; congr 1; rw [sub_mul, h1] rw [mul_assoc ((1 / 2) * P), hsq] rw [hmul, hrhs] dsimp [P] ring /-- **Pillar 2G (Predictive Coding Precision-Stiffness Theorem)**: - Euclidean predictive coding contracts VFE by `(1 - η Π*)²` per step — which **diverges** (`(1 - η Π*)² > 1`) whenever sensory precision `π_o` is large enough that `η Π* > 2`. - Natural-gradient (precision-normalized) predictive coding contracts VFE at the **precision-invariant** exact rate `(1 - η)²` for ALL `π_p, π_o > 0`, achieving exact Bayes in 1 step at `η = 1`. -/ theorem pc_euclid_vs_natgrad_exact {π_p π_o g μ_p o η μ : ℝ} (hprec : pcPostPrec π_p π_o g ≠ 0) : let μstar := pcPostMean π_p π_o g μ_p o let Pstar := pcPostPrec π_p π_o g (pcVFE π_p π_o g μ_p o (pcEuclidStep π_p π_o g μ_p o η μ) - pcVFE π_p π_o g μ_p o μstar = (1 - η * Pstar) ^ 2 * (pcVFE π_p π_o g μ_p o μ - pcVFE π_p π_o g μ_p o μstar)) ∧ (pcVFE π_p π_o g μ_p o (pcNatGradStep π_p π_o g μ_p o η μ) - pcVFE π_p π_o g μ_p o μstar = (1 - η) ^ 2 * (pcVFE π_p π_o g μ_p o μ - pcVFE π_p π_o g μ_p o μstar)) := by intro μstar Pstar rw [pcVFE_exact_excess hprec, pcVFE_exact_excess hprec, pcVFE_exact_excess hprec] constructor · have hstep : pcEuclidStep π_p π_o g μ_p o η μ - μstar = (1 - η * Pstar) * (μ - μstar) := by dsimp [pcEuclidStep, μstar, Pstar, pcPostMean, pcPostPrec] at * field_simp [hprec]; ring rw [hstep]; ring · have hstep : pcNatGradStep π_p π_o g μ_p o η μ - μstar = (1 - η) * (μ - μstar) := by dsimp [pcNatGradStep, μstar, Pstar, pcPostMean, pcPostPrec] at * field_simp [hprec]; ring rw [hstep]; ring end Pillar2MirrorDescent /-! ## Section 3 (Pillar 3): Exact Expected Free Energy & Epistemic-vs-Pragmatic Phase Transitions -/ section Pillar3EFE /-- A discrete active-inference policy specification: state belief `q(s)` and observation likelihood channel `A(o | s)`, both strictly positive. -/ structure PolicyModel (σ ω : Type*) [Fintype σ] [Fintype ω] where q : σ → ℝ A : σ → ω → ℝ q_pos : ∀ s, 0 < q s q_sum : ∑ s, q s = 1 A_pos : ∀ s o, 0 < A s o A_sum : ∀ s, ∑ o, A s o = 1 namespace PolicyModel variable {σ ω : Type*} [Fintype σ] [Fintype ω] (P : PolicyModel σ ω) lemma q_isPosProb : IsPosProb P.q := ⟨P.q_pos, P.q_sum⟩ lemma A_isPosProb (s : σ) : IsPosProb (P.A s) := ⟨P.A_pos s, P.A_sum s⟩ /-- Predictive joint distribution `Q(s, o) = q(s) A(o | s)`. -/ def predJoint (s : σ) (o : ω) : ℝ := P.q s * P.A s o lemma predJoint_pos (s : σ) (o : ω) : 0 < P.predJoint s o := mul_pos (P.q_pos s) (P.A_pos s o) /-- Predictive outcome marginal `Q(o) = ∑_s q(s) A(o | s)`. -/ def predOut (o : ω) : ℝ := ∑ s, P.predJoint s o lemma predOut_isPosProb [Nonempty σ] : IsPosProb P.predOut := by refine ⟨fun o => Finset.sum_pos (fun s _ => P.predJoint_pos s o) Finset.univ_nonempty, ?_⟩ unfold predOut predJoint rw [Finset.sum_comm] calc ∑ s, ∑ o, P.q s * P.A s o = ∑ s, P.q s * ∑ o, P.A s o := by apply Finset.sum_congr rfl; intro s _; rw [← Finset.mul_sum] _ = ∑ s, P.q s := by apply Finset.sum_congr rfl; intro s _; rw [P.A_sum s, mul_one] _ = 1 := P.q_sum /-- Predictive posterior over hidden states given hypothetical outcome `o`: `Q(s | o) = Q(s,o)/Q(o)`. -/ noncomputable def predPost (o : ω) (s : σ) : ℝ := P.predJoint s o / P.predOut o lemma predPost_isPosProb [Nonempty σ] (o : ω) : IsPosProb (P.predPost o) := by have hQo := P.predOut_isPosProb.1 o refine ⟨fun s => div_pos (P.predJoint_pos s o) hQo, ?_⟩ unfold predPost rw [← Finset.sum_div] exact div_self hQo.ne' /-- **Expected Free Energy (EFE)**: `G(π) = ∑_{s, o} Q(s, o) log(q(s) / (Q(s | o) C(o)))`. -/ noncomputable def efe (C : ω → ℝ) : ℝ := ∑ s, ∑ o, P.predJoint s o * Real.log (P.q s / (P.predPost o s * C o)) /-- Risk `D_KL(Q(O) ‖ C)`. -/ noncomputable def risk (C : ω → ℝ) : ℝ := klDiv P.predOut C /-- Ambiguity `H(O | S) = ∑_s q(s) H(A(· | s))`. -/ noncomputable def ambiguity : ℝ := ∑ s, P.q s * shannonEntropy (P.A s) /-- Expected Pragmatic Cost (Negative Extrinsic Value) `E_Q[-log C(O)]`. -/ noncomputable def pragmaticCost (C : ω → ℝ) : ℝ := ∑ o, P.predOut o * (-Real.log (C o)) /-- Epistemic Value / Expected Information Gain (Bayesian Surprise) `E_{Q(O)}[D_KL(Q(S|O) ‖ q(S))]`. -/ noncomputable def epistemicValue [Nonempty σ] : ℝ := ∑ o, P.predOut o * klDiv (P.predPost o) P.q /-- Mutual information `I_Q(S; O)` between hidden states and observations under policy `P`. -/ noncomputable def mutualInfo : ℝ := ∑ s, ∑ o, P.predJoint s o * Real.log (P.predJoint s o / (P.q s * P.predOut o)) /-- **Pillar 3A**: Exact Epistemic Value = Mutual Information identity (`EIG = I_Q(S; O) ≥ 0`). -/ theorem epistemicValue_eq_mutualInfo [Nonempty σ] : P.epistemicValue = P.mutualInfo := by unfold epistemicValue mutualInfo klDiv predPost have h1 : ∑ o, P.predOut o * ∑ s, P.predJoint s o / P.predOut o * Real.log (P.predJoint s o / P.predOut o / P.q s) = ∑ o, ∑ s, P.predJoint s o * Real.log (P.predJoint s o / (P.q s * P.predOut o)) := by apply Finset.sum_congr rfl; intro o _ rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro s _ have hQo := (P.predOut_isPosProb.1 o).ne' rw [div_div, mul_comm (P.predOut o) (P.q s)] field_simp [hQo] rw [h1, Finset.sum_comm] theorem epistemicValue_nonneg [Nonempty σ] : 0 ≤ P.epistemicValue := by unfold epistemicValue exact Finset.sum_nonneg (fun o _ => mul_nonneg (P.predOut_isPosProb.1 o).le (klDiv_nonneg (P.predPost_isPosProb o) P.q_isPosProb)) /-- **Pillar 3B**: Exact Risk + Ambiguity decomposition of Expected Free Energy: `G(π) = D_KL(Q(O) ‖ C) + H(O | S)`. -/ theorem efe_eq_risk_add_ambiguity [Nonempty σ] {C : ω → ℝ} (hC : IsPosProb C) : P.efe C = P.risk C + P.ambiguity := by unfold efe risk ambiguity klDiv shannonEntropy predPost have hinner : ∑ s, ∑ o, P.predJoint s o * Real.log (P.q s / (P.predJoint s o / P.predOut o * C o)) = (∑ s, ∑ o, P.predJoint s o * Real.log (P.predOut o / C o)) + (∑ s, ∑ o, -(P.predJoint s o * Real.log (P.A s o))) := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro s _ rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro o _ have hqs := P.q_pos s have hAs := P.A_pos s o have hQo := P.predOut_isPosProb.1 o have hCo := hC.1 o have hjs : P.predJoint s o = P.q s * P.A s o := rfl have harg : P.q s / (P.predJoint s o / P.predOut o * C o) = (P.predOut o / C o) / P.A s o := by rw [hjs]; field_simp [hqs.ne', hAs.ne', hQo.ne', hCo.ne'] rw [harg, Real.log_div (div_pos hQo hCo).ne' hAs.ne'] ring rw [hinner] have hrisk : ∑ s, ∑ o, P.predJoint s o * Real.log (P.predOut o / C o) = ∑ o, P.predOut o * Real.log (P.predOut o / C o) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro o _ rw [← Finset.sum_mul] rfl have hamb : ∑ s, ∑ o, -(P.predJoint s o * Real.log (P.A s o)) = ∑ s, P.q s * -∑ o, P.A s o * Real.log (P.A s o) := by apply Finset.sum_congr rfl; intro s _ rw [mul_neg, Finset.mul_sum, ← Finset.sum_neg_distrib] apply Finset.sum_congr rfl; intro o _ unfold predJoint; ring rw [hrisk, hamb] /-- **Pillar 3C**: Exact Pragmatic Cost - Epistemic Value decomposition of Expected Free Energy: `G(π) = E_Q[-log C(O)] - I_Q(S; O)`. -/ theorem efe_eq_pragmatic_sub_epistemic [Nonempty σ] {C : ω → ℝ} (hC : IsPosProb C) : P.efe C = P.pragmaticCost C - P.epistemicValue := by rw [P.epistemicValue_eq_mutualInfo] unfold efe pragmaticCost mutualInfo predPost have hprag : ∑ o, P.predOut o * (-Real.log (C o)) = ∑ s, ∑ o, P.predJoint s o * (-Real.log (C o)) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro o _ rw [← Finset.sum_mul]; rfl rw [hprag, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro s _ rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro o _ have hqs := P.q_pos s have hjs := P.predJoint_pos s o have hQo := P.predOut_isPosProb.1 o have hCo := hC.1 o rw [Real.log_div hqs.ne' (mul_pos (div_pos hjs hQo) hCo).ne', Real.log_mul (div_pos hjs hQo).ne' hCo.ne', Real.log_div hjs.ne' hQo.ne', Real.log_div hjs.ne' (mul_pos hqs hQo).ne', Real.log_mul hqs.ne' hQo.ne'] ring /-- **Pillar 3D**: Exact EFE lower bound (`G(π) ≥ Ambiguity(π) ≥ 0`) with equality iff exact preference matching (`Q(O) = C`). -/ theorem efe_ge_ambiguity_and_iff [Nonempty σ] {C : ω → ℝ} (hC : IsPosProb C) : P.ambiguity ≤ P.efe C ∧ (P.efe C = P.ambiguity ↔ P.predOut = C) := by rw [P.efe_eq_risk_add_ambiguity hC] have hr : 0 ≤ P.risk C := klDiv_nonneg P.predOut_isPosProb hC refine ⟨by linarith, ?_⟩ rw [add_eq_right] exact klDiv_eq_zero_iff P.predOut_isPosProb hC lemma ambiguity_nonneg : 0 ≤ P.ambiguity := Finset.sum_nonneg (fun s _ => mul_nonneg (P.q_pos s).le (shannonEntropy_nonneg (P.A_isPosProb s))) end PolicyModel /-- Boltzmann preference distribution `C_β(o) = exp(β r(o)) / ∑_{o'} exp(β r(o'))` with preference precision (inverse temperature) `β` and pragmatic utility `r(o)`. -/ noncomputable def boltzmannPref {ω : Type*} [Fintype ω] (r : ω → ℝ) (β : ℝ) (o : ω) : ℝ := Real.exp (β * r o) / ∑ o', Real.exp (β * r o') lemma boltzmannPref_isPosProb {ω : Type*} [Fintype ω] [Nonempty ω] (r : ω → ℝ) (β : ℝ) : IsPosProb (boltzmannPref r β) := by have hZ : 0 < ∑ o', Real.exp (β * r o') := Finset.sum_pos (fun o' _ => Real.exp_pos _) Finset.univ_nonempty refine ⟨fun o => div_pos (Real.exp_pos _) hZ, ?_⟩ unfold boltzmannPref rw [← Finset.sum_div, div_self hZ.ne'] /-- Expected pragmatic reward under policy `P`: `R(P) = ∑_o Q_P(o) r(o)`. -/ def expectedReward {σ ω : Type*} [Fintype σ] [Fintype ω] (P : PolicyModel σ ω) (r : ω → ℝ) : ℝ := ∑ o, P.predOut o * r o lemma pragmaticCost_boltzmannPref {σ ω : Type*} [Fintype σ] [Fintype ω] [Nonempty σ] [Nonempty ω] (P : PolicyModel σ ω) (r : ω → ℝ) (β : ℝ) : P.pragmaticCost (boltzmannPref r β) = Real.log (∑ o', Real.exp (β * r o')) - β * expectedReward P r := by have hZ : 0 < ∑ o', Real.exp (β * r o') := Finset.sum_pos (fun _ _ => Real.exp_pos _) Finset.univ_nonempty unfold PolicyModel.pragmaticCost boltzmannPref expectedReward calc ∑ o, P.predOut o * -Real.log (Real.exp (β * r o) / ∑ o', Real.exp (β * r o')) = ∑ o, (P.predOut o * Real.log (∑ o', Real.exp (β * r o')) - β * (P.predOut o * r o)) := by apply Finset.sum_congr rfl; intro o _ rw [Real.log_div (Real.exp_pos _).ne' hZ.ne', Real.log_exp]; ring _ = (∑ o, P.predOut o) * Real.log (∑ o', Real.exp (β * r o')) - β * ∑ o, P.predOut o * r o := by rw [Finset.sum_sub_distrib, ← Finset.sum_mul, ← Finset.mul_sum] _ = Real.log (∑ o', Real.exp (β * r o')) - β * ∑ o, P.predOut o * r o := by rw [P.predOut_isPosProb.2, one_mul] /-- **Pillar 3E (Universal EFE Difference Formula under Boltzmann Preferences)**: The preference log-partition cancels identically between policies: `G_β(π_ep) - G_β(π_pr) = β · (R(π_pr) - R(π_ep)) - (I(π_ep) - I(π_pr))`. -/ theorem efe_boltzmann_diff_exact {σ₁ σ₂ ω : Type*} [Fintype σ₁] [Fintype σ₂] [Fintype ω] [Nonempty σ₁] [Nonempty σ₂] [Nonempty ω] (P_ep : PolicyModel σ₁ ω) (P_pr : PolicyModel σ₂ ω) (r : ω → ℝ) (β : ℝ) : P_ep.efe (boltzmannPref r β) - P_pr.efe (boltzmannPref r β) = β * (expectedReward P_pr r - expectedReward P_ep r) - (P_ep.epistemicValue - P_pr.epistemicValue) := by have hC := boltzmannPref_isPosProb r β rw [P_ep.efe_eq_pragmatic_sub_epistemic hC, P_pr.efe_eq_pragmatic_sub_epistemic hC, pragmaticCost_boltzmannPref P_ep r β, pragmaticCost_boltzmannPref P_pr r β] ring /-- **Pillar 3F (Headline — Exact Epistemic-vs-Pragmatic Phase Transition in Preference Precision)**: Whenever policy `π_ep` has strictly higher epistemic value (`ΔI > 0`) and policy `π_pr` has strictly higher expected reward (`ΔR > 0`), there is a UNIQUE critical preference precision `β_c = ΔI / ΔR > 0` separating the epistemic-exploration phase (`β < β_c`) from the pragmatic-exploitation phase (`β > β_c`). -/ theorem efe_preference_precision_phase_transition {σ₁ σ₂ ω : Type*} [Fintype σ₁] [Fintype σ₂] [Fintype ω] [Nonempty σ₁] [Nonempty σ₂] [Nonempty ω] (P_ep : PolicyModel σ₁ ω) (P_pr : PolicyModel σ₂ ω) (r : ω → ℝ) (hΔR : 0 < expectedReward P_pr r - expectedReward P_ep r) (hΔI : 0 < P_ep.epistemicValue - P_pr.epistemicValue) : let β_c := (P_ep.epistemicValue - P_pr.epistemicValue) / (expectedReward P_pr r - expectedReward P_ep r) 0 < β_c ∧ (∀ β, β < β_c ↔ P_ep.efe (boltzmannPref r β) < P_pr.efe (boltzmannPref r β)) ∧ (∀ β, β = β_c ↔ P_ep.efe (boltzmannPref r β) = P_pr.efe (boltzmannPref r β)) ∧ (∀ β, β_c < β ↔ P_pr.efe (boltzmannPref r β) < P_ep.efe (boltzmannPref r β)) := by intro β_c refine ⟨div_pos hΔI hΔR, ?_, ?_, ?_⟩ · intro β have hdiff := efe_boltzmann_diff_exact P_ep P_pr r β constructor · intro hlt have h1 := (lt_div_iff₀ hΔR).mp hlt linarith · intro hlt exact (lt_div_iff₀ hΔR).mpr (by linarith) · intro β have hdiff := efe_boltzmann_diff_exact P_ep P_pr r β constructor · intro heq have h1 : β * (expectedReward P_pr r - expectedReward P_ep r) = P_ep.epistemicValue - P_pr.epistemicValue := by rw [heq]; dsimp [β_c]; field_simp [hΔR.ne'] linarith · intro heq dsimp [β_c] exact (eq_div_iff hΔR.ne').mpr (by linarith) · intro β have hdiff := efe_boltzmann_diff_exact P_ep P_pr r β constructor · intro hgt have h1 := (div_lt_iff₀ hΔR).mp hgt linarith · intro hgt exact (div_lt_iff₀ hΔR).mpr (by linarith) /-- Boltzmann softmax exploration probability under policy precision `γ > 0`: `P_γ(π_ep | β) = 1 / (1 + exp(γ (β ΔR - ΔI)))`. -/ noncomputable def softmaxExploreProb (γ ΔR ΔI β : ℝ) : ℝ := 1 / (1 + Real.exp (γ * (β * ΔR - ΔI))) /-- Exact softmax phase-transition behavior and critical susceptibility `-γ ΔR / 4` at `β_c`. -/ theorem softmax_policy_phase_transition {γ ΔR ΔI : ℝ} (hγ : 0 < γ) (hΔR : 0 < ΔR) : let β_c := ΔI / ΔR softmaxExploreProb γ ΔR ΔI β_c = 1 / 2 ∧ (∀ β, β < β_c → 1 / 2 < softmaxExploreProb γ ΔR ΔI β) ∧ (∀ β, β_c < β → softmaxExploreProb γ ΔR ΔI β < 1 / 2) ∧ HasDerivAt (softmaxExploreProb γ ΔR ΔI) (-(γ * ΔR) / 4) β_c := by intro β_c have hcrit : β_c * ΔR - ΔI = 0 := by dsimp [β_c]; field_simp [hΔR.ne']; ring refine ⟨?_, ?_, ?_, ?_⟩ · unfold softmaxExploreProb; rw [hcrit, mul_zero, Real.exp_zero]; norm_num · intro β hlt unfold softmaxExploreProb have hneg : γ * (β * ΔR - ΔI) < 0 := by have : β * ΔR < ΔI := (lt_div_iff₀ hΔR).mp hlt nlinarith have hexp : Real.exp (γ * (β * ΔR - ΔI)) < 1 := Real.exp_lt_one_iff.mpr hneg rw [div_lt_div_iff₀ (by norm_num) (by positivity)] linarith · intro β hgt unfold softmaxExploreProb have hpos : 0 < γ * (β * ΔR - ΔI) := by have : ΔI < β * ΔR := (div_lt_iff₀ hΔR).mp hgt nlinarith have hexp : 1 < Real.exp (γ * (β * ΔR - ΔI)) := Real.one_lt_exp_iff.mpr hpos rw [div_lt_div_iff₀ (by positivity) (by norm_num)] linarith · unfold softmaxExploreProb have hlin : HasDerivAt (fun β => γ * (β * ΔR - ΔI)) (γ * ΔR) β_c := ((((hasDerivAt_id β_c).mul_const ΔR).sub_const ΔI).const_mul γ).congr_deriv (by ring) have hexp : HasDerivAt (fun β => 1 + Real.exp (γ * (β * ΔR - ΔI))) (Real.exp (γ * (β_c * ΔR - ΔI)) * (γ * ΔR)) β_c := ((Real.hasDerivAt_exp _).comp β_c hlin).const_add 1 have hdiv := (hasDerivAt_const β_c (1 : ℝ)).div hexp (by positivity) exact hdiv.congr_deriv (by rw [hcrit, mul_zero, Real.exp_zero]; ring) /-! ### Sharp Binary Entropy Sandwich & Exact Nonlinear T-Maze Epistemic Phase Transition -/ lemma binaryEntropy_symm (p : ℝ) : binaryEntropy (1 - p) = binaryEntropy p := by unfold binaryEntropy ring_nf lemma binaryEntropy_half : binaryEntropy (1 / 2) = Real.log 2 := by unfold binaryEntropy have h1 : (1 : ℝ) - 1 / 2 = 1 / 2 := by norm_num have hlog : Real.log (1 / 2 : ℝ) = -Real.log 2 := by rw [one_div, Real.log_inv] rw [h1, hlog]; ring lemma hasDerivAt_binaryEntropy {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) : HasDerivAt binaryEntropy (Real.log ((1 - p) / p)) p := by unfold binaryEntropy have h1mp : 0 < 1 - p := by linarith have h1 : HasDerivAt (fun x => x * Real.log x) (Real.log p + 1) p := ((hasDerivAt_id p).mul (Real.hasDerivAt_log hp0.ne')).congr_deriv (by simp only [id_eq]; field_simp [hp0.ne']) have h2 : HasDerivAt (fun x => (1 - x) * Real.log (1 - x)) (-(Real.log (1 - p) + 1)) p := by have hsub : HasDerivAt (fun x : ℝ => 1 - x) (-1) p := (hasDerivAt_const p (1 : ℝ)).sub (hasDerivAt_id p) |>.congr_deriv (by ring) have hlog := (Real.hasDerivAt_log h1mp.ne').comp p hsub exact (hsub.mul hlog).congr_deriv (by simp only [Function.comp_apply]; field_simp [h1mp.ne']; ring) exact (h1.add h2).neg.congr_deriv (by rw [Real.log_div h1mp.ne' hp0.ne']; ring) /-- **Sharp Upper Quadratic Bound on Binary Entropy**: `h₂(p) ≤ log 2 - 2 (p - 1/2)²` for all `p ∈ (0, 1)`. -/ theorem binaryEntropy_le_log_two_sub_sq {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) : binaryEntropy p ≤ Real.log 2 - 2 * (p - 1 / 2) ^ 2 := by let k : ℝ → ℝ := fun x => Real.log 2 - 2 * (x - 1 / 2) ^ 2 - binaryEntropy x let k' : ℝ → ℝ := fun x => -4 * (x - 1 / 2) - Real.log ((1 - x) / x) have hk_deriv : ∀ x ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt k (k' x) x := by intro x hx have hpoly : HasDerivAt (fun t => Real.log 2 - 2 * (t - 1 / 2) ^ 2) (-4 * (x - 1 / 2)) x := ((hasDerivAt_const x (Real.log 2)).sub ((((hasDerivAt_id x).sub_const (1 / 2 : ℝ)).pow 2).const_mul (2 : ℝ))).congr_deriv (by simp only [id_eq]; ring) exact hpoly.sub (hasDerivAt_binaryEntropy hx.1 hx.2) have hk'_deriv : ∀ x ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt k' (1 / (x * (1 - x)) - 4) x := by intro x hx have hx0 : x ≠ 0 := hx.1.ne' have h1mx : 1 - x ≠ 0 := (sub_pos.mpr hx.2).ne' have h1 : HasDerivAt (fun t => -4 * (t - 1 / 2)) (-4) x := (((hasDerivAt_id x).sub_const (1 / 2 : ℝ)).const_mul (-4 : ℝ)).congr_deriv (by ring) have hlog_d : HasDerivAt (fun t => Real.log (1 - t) - Real.log t) (-1 / (1 - x) - 1 / x) x := by have ha : HasDerivAt (fun t => Real.log (1 - t)) (-1 / (1 - x)) x := by have hsub : HasDerivAt (fun t : ℝ => 1 - t) (-1) x := ((hasDerivAt_const x (1 : ℝ)).sub (hasDerivAt_id x)).congr_deriv (by ring) exact ((Real.hasDerivAt_log h1mx).comp x hsub).congr_deriv (by ring) exact (ha.sub (Real.hasDerivAt_log hx0)).congr_deriv (by simp [one_div]) have hlog_d' : HasDerivAt (fun t => Real.log ((1 - t) / t)) (-1 / (1 - x) - 1 / x) x := by refine hlog_d.congr_of_eventuallyEq ?_ filter_upwards [Ioo_mem_nhds hx.1 hx.2] with t ht exact Real.log_div (sub_pos.mpr ht.2).ne' ht.1.ne' exact (h1.sub hlog_d').congr_deriv (by field_simp [hx0, h1mx]; ring) have hk'_nonneg : ∀ x ∈ Set.Ioo (0 : ℝ) 1, 0 ≤ 1 / (x * (1 - x)) - 4 := by intro x hx have hprod : 0 < x * (1 - x) := mul_pos hx.1 (sub_pos.mpr hx.2) rw [sub_nonneg, le_div_iff₀ hprod] nlinarith [sq_nonneg (2 * x - 1)] have hk'_mono : MonotoneOn k' (Set.Ioo 0 1) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ioo 0 1) (fun x hx => (hk'_deriv x hx).continuousAt.continuousWithinAt) (fun x hx => (hk'_deriv x (interior_subset hx)).hasDerivWithinAt) (fun x hx => hk'_nonneg x (interior_subset hx)) have hk'half : k' (1 / 2) = 0 := by dsimp [k']; norm_num have hkhalf : k (1 / 2) = 0 := by dsimp [k]; rw [binaryEntropy_half]; ring suffices h : 0 ≤ k p by dsimp [k] at h; linarith rcases le_or_gt (1 / 2 : ℝ) p with hp | hp · have hmono : MonotoneOn k (Set.Ico (1 / 2) 1) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ico (1 / 2) 1) (fun x hx => (hk_deriv x ⟨by linarith [hx.1], hx.2⟩).continuousAt.continuousWithinAt) (fun x hx => (hk_deriv x ⟨by linarith [(interior_subset hx).1], (interior_subset hx).2⟩).hasDerivWithinAt) (fun x hx => by rw [← hk'half] exact hk'_mono ⟨by norm_num, by norm_num⟩ ⟨by linarith [(interior_subset hx).1], (interior_subset hx).2⟩ (interior_subset hx).1) rw [← hkhalf] exact hmono ⟨le_rfl, by norm_num⟩ ⟨hp, hp1⟩ hp · have hanti : AntitoneOn k (Set.Ioc 0 (1 / 2)) := antitoneOn_of_hasDerivWithinAt_nonpos (convex_Ioc 0 (1 / 2)) (fun x hx => (hk_deriv x ⟨hx.1, by linarith [hx.2]⟩).continuousAt.continuousWithinAt) (fun x hx => (hk_deriv x ⟨(interior_subset hx).1, by linarith [(interior_subset hx).2]⟩).hasDerivWithinAt) (fun x hx => by rw [← hk'half] exact hk'_mono ⟨(interior_subset hx).1, by linarith [(interior_subset hx).2]⟩ ⟨by norm_num, by norm_num⟩ (interior_subset hx).2) rw [← hkhalf] exact hanti ⟨hp0, hp.le⟩ ⟨by norm_num, le_rfl⟩ hp.le /-- **Sharp Lower Parabolic Bound on Binary Entropy**: `4 p (1 - p) log 2 ≤ h₂(p)` for all `p ∈ (0, 1)`. -/ theorem four_mul_log_two_le_binaryEntropy {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) : 4 * p * (1 - p) * Real.log 2 ≤ binaryEntropy p := by let g : ℝ → ℝ := fun x => binaryEntropy x - 4 * x * (1 - x) * Real.log 2 let g' : ℝ → ℝ := fun x => Real.log ((1 - x) / x) - 4 * (1 - 2 * x) * Real.log 2 suffices hhalf : ∀ x ∈ Set.Ioc (0 : ℝ) (1 / 2), 0 ≤ g x by rcases le_or_gt p (1 / 2) with hle | hgt · have := hhalf p ⟨hp0, hle⟩; dsimp [g] at this; linarith · have h1m := hhalf (1 - p) ⟨by linarith, by linarith⟩ dsimp [g] at h1m rw [binaryEntropy_symm] at h1m nlinarith have hlog2_gt : (1 / 2 : ℝ) < Real.log 2 := by linarith [Real.log_two_gt_d9] have hlog2_pos : 0 < Real.log 2 := by linarith have hg_deriv : ∀ x ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt g (g' x) x := by intro x hx have hpoly : HasDerivAt (fun t => 4 * t * (1 - t) * Real.log 2) (4 * (1 - 2 * x) * Real.log 2) x := by have ha : HasDerivAt (fun t : ℝ => t * (1 - t)) (1 - 2 * x) x := ((hasDerivAt_id x).mul ((hasDerivAt_const x (1 : ℝ)).sub (hasDerivAt_id x))).congr_deriv (by simp only [Pi.sub_apply, id_eq]; ring) have hrew : (fun t : ℝ => 4 * t * (1 - t) * Real.log 2) = (fun t : ℝ => (4 * (t * (1 - t))) * Real.log 2) := by funext t; ring rw [hrew] exact ((ha.const_mul (4 : ℝ)).mul_const (Real.log 2)).congr_deriv (by ring) exact (hasDerivAt_binaryEntropy hx.1 hx.2).sub hpoly have hg'_deriv : ∀ x ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt g' (8 * Real.log 2 - 1 / (x * (1 - x))) x := by intro x hx have hx0 : x ≠ 0 := hx.1.ne' have h1mx : 1 - x ≠ 0 := (sub_pos.mpr hx.2).ne' have hlog_d : HasDerivAt (fun t => Real.log (1 - t) - Real.log t) (-1 / (1 - x) - 1 / x) x := by have ha : HasDerivAt (fun t => Real.log (1 - t)) (-1 / (1 - x)) x := by have hsub : HasDerivAt (fun t : ℝ => 1 - t) (-1) x := ((hasDerivAt_const x (1 : ℝ)).sub (hasDerivAt_id x)).congr_deriv (by ring) exact ((Real.hasDerivAt_log h1mx).comp x hsub).congr_deriv (by ring) exact (ha.sub (Real.hasDerivAt_log hx0)).congr_deriv (by simp [one_div]) have hlog_d' : HasDerivAt (fun t => Real.log ((1 - t) / t)) (-1 / (1 - x) - 1 / x) x := by refine hlog_d.congr_of_eventuallyEq ?_ filter_upwards [Ioo_mem_nhds hx.1 hx.2] with t ht exact Real.log_div (sub_pos.mpr ht.2).ne' ht.1.ne' have hlin : HasDerivAt (fun t => 4 * (1 - 2 * t) * Real.log 2) (-8 * Real.log 2) x := ((((hasDerivAt_const x (1 : ℝ)).sub ((hasDerivAt_id x).const_mul 2)).const_mul 4).mul_const (Real.log 2)).congr_deriv (by ring) exact (hlog_d'.sub hlin).congr_deriv (by field_simp [hx0, h1mx]; ring) -- Inflection point p₀ = (1 - √(1 - 1/(2 log 2))) / 2 ∈ (0, 1/2) with p₀(1 - p₀) = 1/(8 log 2) have hdisc_pos : 0 < 1 - 1 / (2 * Real.log 2) := by rw [sub_pos, div_lt_one (by linarith)]; linarith have hdisc_lt1 : 1 - 1 / (2 * Real.log 2) < 1 := by have : 0 < 1 / (2 * Real.log 2) := div_pos one_pos (by linarith) linarith set s := Real.sqrt (1 - 1 / (2 * Real.log 2)) have hs_pos : 0 < s := Real.sqrt_pos.mpr hdisc_pos have hs_lt1 : s < 1 := by calc s = Real.sqrt (1 - 1 / (2 * Real.log 2)) := rfl _ < Real.sqrt 1 := Real.sqrt_lt_sqrt hdisc_pos.le hdisc_lt1 _ = 1 := Real.sqrt_one set p₀ := (1 - s) / 2 have hp₀_pos : 0 < p₀ := by dsimp [p₀]; linarith have hp₀_lt_half : p₀ < 1 / 2 := by dsimp [p₀]; linarith have hp₀_prod : p₀ * (1 - p₀) = 1 / (8 * Real.log 2) := by have hsq : s ^ 2 = 1 - 1 / (2 * Real.log 2) := Real.sq_sqrt hdisc_pos.le have h1 : p₀ * (1 - p₀) = (1 - s ^ 2) / 4 := by dsimp [p₀]; ring rw [h1, hsq]; field_simp [hlog2_pos.ne']; ring -- Part 1: On [p₀, 1/2], g'' ≥ 0 ⇒ g' ≤ g'(1/2) = 0 ⇒ g antitone ⇒ g(x) ≥ g(1/2) = 0 have hg'_mono_right : MonotoneOn g' (Set.Icc p₀ (1 / 2)) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc p₀ (1 / 2)) (fun x hx => (hg'_deriv x ⟨by linarith [hx.1], by linarith [hx.2]⟩).continuousAt.continuousWithinAt) (fun x hx => (hg'_deriv x ⟨by linarith [(interior_subset hx).1], by linarith [(interior_subset hx).2]⟩).hasDerivWithinAt) (fun x hx => by have hx1 := (interior_subset hx).1 have hx2 := (interior_subset hx).2 have hprod_ge : 1 / (8 * Real.log 2) ≤ x * (1 - x) := by rw [← hp₀_prod]; nlinarith have hprod_pos : 0 < x * (1 - x) := by have : 0 < 1 / (8 * Real.log 2) := div_pos one_pos (by linarith) linarith rw [sub_nonneg, div_le_iff₀ hprod_pos] have h2 := (div_le_iff₀ (show (0 : ℝ) < 8 * Real.log 2 by linarith)).mp hprod_ge linarith) have hg'half : g' (1 / 2) = 0 := by dsimp [g']; norm_num have hghalf : g (1 / 2) = 0 := by dsimp [g]; rw [binaryEntropy_half]; ring have hg_anti_right : AntitoneOn g (Set.Icc p₀ (1 / 2)) := antitoneOn_of_hasDerivWithinAt_nonpos (convex_Icc p₀ (1 / 2)) (fun x hx => (hg_deriv x ⟨by linarith [hx.1], by linarith [hx.2]⟩).continuousAt.continuousWithinAt) (fun x hx => (hg_deriv x ⟨by linarith [(interior_subset hx).1], by linarith [(interior_subset hx).2]⟩).hasDerivWithinAt) (fun x hx => by rw [← hg'half] exact hg'_mono_right (interior_subset hx) ⟨hp₀_lt_half.le, le_rfl⟩ (interior_subset hx).2) have hg_right_nonneg : ∀ x ∈ Set.Icc p₀ (1 / 2), 0 ≤ g x := by intro x hx rw [← hghalf] exact hg_anti_right hx ⟨hp₀_lt_half.le, le_rfl⟩ hx.2 have hgp₀ : 0 ≤ g p₀ := hg_right_nonneg p₀ ⟨le_rfl, hp₀_lt_half.le⟩ -- Part 2: On (0, p₀], g'' ≤ 0 ⇒ g' antitone ⇒ g(x) ≥ 0 (using h₂(a) ≥ 0 so g(a) ≥ -4a log 2) have hg'_anti_left : AntitoneOn g' (Set.Ioc 0 p₀) := antitoneOn_of_hasDerivWithinAt_nonpos (convex_Ioc 0 p₀) (fun x hx => (hg'_deriv x ⟨hx.1, by linarith [hx.2]⟩).continuousAt.continuousWithinAt) (fun x hx => (hg'_deriv x ⟨(interior_subset hx).1, by linarith [(interior_subset hx).2]⟩).hasDerivWithinAt) (fun x hx => by have hx1 := (interior_subset hx).1 have hx2 := (interior_subset hx).2 have hprod_le : x * (1 - x) ≤ 1 / (8 * Real.log 2) := by rw [← hp₀_prod]; nlinarith have hprod_pos : 0 < x * (1 - x) := mul_pos hx1 (by linarith) rw [sub_nonpos, le_div_iff₀ hprod_pos] have h2 := (le_div_iff₀ (show (0 : ℝ) < 8 * Real.log 2 by linarith)).mp hprod_le linarith) intro x hx rcases le_or_gt p₀ x with hxge | hxlt · exact hg_right_nonneg x ⟨hxge, hx.2⟩ · by_contra hneg push Not at hneg -- Choose a ∈ (0, x) small enough that a * (4 * p₀ * log 2 - g x) < -p₀ * g x have hD_pos : 0 < 4 * p₀ * Real.log 2 - g x := by have : 0 < 4 * p₀ * Real.log 2 := by positivity linarith set a := min (x / 2) ((-p₀ * g x) / (2 * (4 * p₀ * Real.log 2 - g x))) have ha_pos : 0 < a := lt_min (by linarith [hx.1]) (div_pos (by nlinarith) (by linarith)) have ha_lt_x : a < x := lt_of_le_of_lt (min_le_left _ _) (by linarith [hx.1]) have ha_bound : a * (4 * p₀ * Real.log 2 - g x) < -p₀ * g x := by have h1 : a ≤ (-p₀ * g x) / (2 * (4 * p₀ * Real.log 2 - g x)) := min_le_right _ _ have h2 := (le_div_iff₀ (show (0 : ℝ) < 2 * (4 * p₀ * Real.log 2 - g x) by linarith)).mp h1 have h3 : 0 < -p₀ * g x := by nlinarith linarith -- MVT on [a, x] and [x, p₀] have hcont1 : ContinuousOn g (Set.Icc a x) := fun t ht => (hg_deriv t ⟨by linarith [ht.1], by linarith [ht.2]⟩).continuousAt.continuousWithinAt have hdiff1 : ∀ t ∈ Set.Ioo a x, HasDerivAt g (g' t) t := fun t ht => hg_deriv t ⟨by linarith [ht.1], by linarith [ht.2]⟩ obtain ⟨c₁, hc₁, hslope1⟩ := exists_hasDerivAt_eq_slope g g' ha_lt_x hcont1 hdiff1 have hcont2 : ContinuousOn g (Set.Icc x p₀) := fun t ht => (hg_deriv t ⟨by linarith [ht.1, hx.1], by linarith [ht.2]⟩).continuousAt.continuousWithinAt have hdiff2 : ∀ t ∈ Set.Ioo x p₀, HasDerivAt g (g' t) t := fun t ht => hg_deriv t ⟨by linarith [ht.1, hx.1], by linarith [ht.2]⟩ obtain ⟨c₂, hc₂, hslope2⟩ := exists_hasDerivAt_eq_slope g g' hxlt hcont2 hdiff2 have hge : g' c₂ ≤ g' c₁ := hg'_anti_left ⟨by linarith [hc₁.1], by linarith [hc₁.2]⟩ ⟨by linarith [hc₂.1, hx.1], hc₂.2.le⟩ (by linarith [hc₁.2, hc₂.1]) rw [hslope1, hslope2] at hge have hcross : (g p₀ - g x) * (x - a) ≤ (g x - g a) * (p₀ - x) := by have h1 := (div_le_div_iff₀ (sub_pos.mpr hxlt) (sub_pos.mpr ha_lt_x)).mp hge linarith -- Since h₂(a) ≥ 0, g(a) ≥ -4a(1-a) log 2 ≥ -4a log 2 have hbin_a : 0 ≤ binaryEntropy a := by have h := shannonEntropy_nonneg (bernDist_isPosProb ha_pos (by linarith)) unfold shannonEntropy at h; simp only [Fintype.sum_bool, bernDist] at h unfold binaryEntropy; linarith have hga : -4 * a * Real.log 2 ≤ g a := by dsimp [g] have h1ma : 4 * a * (1 - a) * Real.log 2 ≤ 4 * a * Real.log 2 := by have hsq : 0 ≤ 4 * a ^ 2 * Real.log 2 := by positivity linarith linarith -- Exact algebraic rearrangement: (p₀ - a) * g x ≥ (p₀ - x) * g a + (x - a) * g p₀ have hrearr : (p₀ - x) * g a + (x - a) * g p₀ ≤ (p₀ - a) * g x := by have hid : (p₀ - a) * g x - ((p₀ - x) * g a + (x - a) * g p₀) = (g x - g a) * (p₀ - x) - (g p₀ - g x) * (x - a) := by ring linarith have hga_term : -(4 * a * p₀ * Real.log 2) ≤ (p₀ - x) * g a := by have h1 : (p₀ - x) * (-4 * a * Real.log 2) ≤ (p₀ - x) * g a := mul_le_mul_of_nonneg_left hga (by linarith) have h2 : 0 ≤ x * (4 * a * Real.log 2) := mul_nonneg hx.1.le (by positivity) linarith have hgp₀_term : 0 ≤ (x - a) * g p₀ := mul_nonneg (by linarith) hgp₀ have hcomb : -(4 * a * p₀ * Real.log 2) ≤ p₀ * g x - a * g x := by linarith have hcomb2 : -p₀ * g x ≤ a * (4 * p₀ * Real.log 2 - g x) := by linarith linarith /-- Binary symmetric channel (BSC) observation policy for the T-Maze active-inference task: prior belief `q(true) = p`, `q(false) = 1 - p`, sensor accuracy `α ∈ (1/2, 1)`. -/ def tmazeBSCPolicy {p α : ℝ} (hp0 : 0 < p) (hp1 : p < 1) (hα0 : 0 < α) (hα1 : α < 1) : PolicyModel Bool Bool where q := fun s => if s then p else 1 - p A := fun s o => if s = o then α else 1 - α q_pos := fun s => by cases s <;> simp <;> linarith q_sum := by simp A_pos := fun s o => by cases s <;> cases o <;> simp <;> linarith A_sum := fun s => by cases s <;> simp /-- Mutual information / Epistemic Value of the noisy T-Maze BSC sensor: `I(p; α) = h₂(p α + (1 - p)(1 - α)) - h₂(α)`. -/ noncomputable def tmazeEIG (p α : ℝ) : ℝ := binaryEntropy (p * α + (1 - p) * (1 - α)) - binaryEntropy α /-- Exact realization: `epistemicValue` of `tmazeBSCPolicy` equals `tmazeEIG p α`. -/ theorem tmazeBSCPolicy_epistemicValue_eq {p α : ℝ} (hp0 : 0 < p) (hp1 : p < 1) (hα0 : 0 < α) (hα1 : α < 1) : (tmazeBSCPolicy hp0 hp1 hα0 hα1).epistemicValue = tmazeEIG p α := by rw [PolicyModel.epistemicValue_eq_mutualInfo] simp only [PolicyModel.mutualInfo, PolicyModel.predJoint, PolicyModel.predOut, tmazeBSCPolicy, tmazeEIG, binaryEntropy, Fintype.sum_bool, ↓reduceIte, Bool.true_eq_false, Bool.false_eq_true] set r := p * α + (1 - p) * (1 - α) have hr1 : 1 - r = p * (1 - α) + (1 - p) * α := by dsimp [r]; ring have hr_pos : 0 < r := by dsimp [r]; nlinarith have h1mr_pos : 0 < 1 - r := by rw [hr1]; nlinarith have h1mp : 0 < 1 - p := by linarith have h1mα : 0 < 1 - α := by linarith have hq_f : p * (1 - α) + (1 - p) * α = 1 - r := hr1.symm rw [hq_f] rw [Real.log_div (mul_pos hp0 hα0).ne' (mul_pos hp0 hr_pos).ne', Real.log_div (mul_pos hp0 h1mα).ne' (mul_pos hp0 h1mr_pos).ne', Real.log_div (mul_pos h1mp h1mα).ne' (mul_pos h1mp hr_pos).ne', Real.log_div (mul_pos h1mp hα0).ne' (mul_pos h1mp h1mr_pos).ne', Real.log_mul hp0.ne' hα0.ne', Real.log_mul hp0.ne' hr_pos.ne', Real.log_mul hp0.ne' h1mα.ne', Real.log_mul hp0.ne' h1mr_pos.ne', Real.log_mul h1mp.ne' h1mα.ne', Real.log_mul h1mp.ne' hr_pos.ne', Real.log_mul h1mp.ne' hα0.ne', Real.log_mul h1mp.ne' h1mr_pos.ne'] ring /-- **Pillar 3G (Exploration Extinction Wall in the Noisy T-Maze)**: The sensor information capacity is `cap(α) = log 2 - h₂(α)`. For EVERY prior belief `p ∈ (0, 1)`, `tmazeEIG p α ≤ log 2 - h₂(α)`. Consequently, whenever the pragmatic incentive `c = β ΔR` satisfies `c ≥ log 2 - h₂(α)`, pragmatic exploitation dominates across ALL prior beliefs! -/ theorem tmaze_exploration_extinction_wall {p α c : ℝ} (hp0 : 0 < p) (hp1 : p < 1) (hα0 : 0 < α) (hα1 : α < 1) (hc : Real.log 2 - binaryEntropy α ≤ c) : tmazeEIG p α ≤ c := by unfold tmazeEIG set r := p * α + (1 - p) * (1 - α) have hr0 : 0 < r := by dsimp [r]; nlinarith have hr1 : r < 1 := by dsimp [r]; nlinarith have hup := binaryEntropy_le_log_two_sub_sq hr0 hr1 nlinarith [sq_nonneg (r - 1 / 2)] /-- Strict antitone property of `binaryEntropy` on `[1/2, 1)`. -/ lemma binaryEntropy_strictAntiOn_half_one : StrictAntiOn binaryEntropy (Set.Ico (1 / 2) 1) := by apply strictAntiOn_of_deriv_neg (convex_Ico (1 / 2) 1) · intro x hx exact (hasDerivAt_binaryEntropy (by linarith [hx.1]) hx.2).continuousAt.continuousWithinAt · intro x hx rw [interior_Ico] at hx rw [(hasDerivAt_binaryEntropy (by linarith [hx.1]) hx.2).deriv] exact Real.log_neg (div_pos (sub_pos.mpr hx.2) (by linarith [hx.1])) ((div_lt_one (by linarith [hx.1])).mpr (by linarith [hx.1])) /-- **Pillar 3H (Headline — Exact Nonlinear Belief-Uncertainty Phase Transition & Closed-Form Critical Threshold Sandwich in the Noisy T-Maze)**: For sensor accuracy `α ∈ (1/2, 1)` and sub-capacity pragmatic incentive `0 < c < log 2 - h₂(α)`: 1. There exists a **unique** critical belief confidence `p_c ∈ (1/2, 1)` with `tmazeEIG p_c α = c`. 2. **Exact Phase Dichotomy** for all `p ∈ (0, 1)`: - Epistemic exploration strictly dominates (`tmazeEIG p α > c`) iff `p ∈ (1 - p_c, p_c)`. - Pragmatic exploitation strictly dominates (`tmazeEIG p α < c`) iff `p < 1 - p_c ∨ p_c < p`. 3. **Closed-Form Non-Asymptotic Sandwich on `p_c`**: `1/2 + √((cap(α) - c) / log 2) / (2 (2α - 1)) ≤ p_c ≤ 1/2 + √(2 (cap(α) - c)) / (2 (2α - 1))`. -/ theorem tmaze_belief_phase_transition_and_sandwich {α c : ℝ} (hα_half : 1 / 2 < α) (hα1 : α < 1) (hc0 : 0 < c) (hc_cap : c < Real.log 2 - binaryEntropy α) : ∃! p_c : ℝ, p_c ∈ Set.Ioo (1 / 2 : ℝ) 1 ∧ tmazeEIG p_c α = c ∧ (∀ p, 0 < p → p < 1 → (c < tmazeEIG p α ↔ 1 - p_c < p ∧ p < p_c)) ∧ (∀ p, 0 < p → p < 1 → (tmazeEIG p α < c ↔ p < 1 - p_c ∨ p_c < p)) ∧ 1 / 2 + Real.sqrt ((Real.log 2 - binaryEntropy α - c) / Real.log 2) / (2 * (2 * α - 1)) ≤ p_c ∧ p_c ≤ 1 / 2 + Real.sqrt (2 * (Real.log 2 - binaryEntropy α - c)) / (2 * (2 * α - 1)) := by have hα0 : 0 < α := by linarith have h2α : 0 < 2 * α - 1 := by linarith have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) -- Helper: mapping r(p) = p α + (1-p)(1-α) = 1/2 + (p - 1/2)(2α - 1) have hr_eq : ∀ p : ℝ, p * α + (1 - p) * (1 - α) = 1 / 2 + (p - 1 / 2) * (2 * α - 1) := by intro p; ring have hsymm : ∀ p : ℝ, tmazeEIG (1 - p) α = tmazeEIG p α := by intro p; unfold tmazeEIG have : (1 - p) * α + (1 - (1 - p)) * (1 - α) = 1 - (p * α + (1 - p) * (1 - α)) := by ring rw [this, binaryEntropy_symm] -- Existence of p_c ∈ (1/2, 1) via IVT on [1/2, 1] have hf_cont : ContinuousOn (fun p => tmazeEIG p α) (Set.Icc (1 / 2) 1) := by intro p hp unfold tmazeEIG have hr0 : 0 < p * α + (1 - p) * (1 - α) := by rw [hr_eq]; nlinarith [hp.1, hp.2] have hr1 : p * α + (1 - p) * (1 - α) < 1 := by rw [hr_eq]; nlinarith [hp.1, hp.2] have hcomp : ContinuousAt (fun x => binaryEntropy (x * α + (1 - x) * (1 - α))) p := by let lin : ℝ → ℝ := fun x => x * α + (1 - x) * (1 - α) have hlin : ContinuousAt lin p := by dsimp [lin]; fun_prop have hbe : ContinuousAt binaryEntropy (lin p) := (hasDerivAt_binaryEntropy hr0 hr1).continuousAt exact hbe.comp hlin exact (hcomp.sub continuousAt_const).continuousWithinAt have hf_half : tmazeEIG (1 / 2) α = Real.log 2 - binaryEntropy α := by unfold tmazeEIG have : (1 / 2 : ℝ) * α + (1 - 1 / 2) * (1 - α) = 1 / 2 := by ring rw [this, binaryEntropy_half] have hf_one : tmazeEIG 1 α = 0 := by unfold tmazeEIG; simp have hmem : c ∈ Set.Icc (tmazeEIG 1 α) (tmazeEIG (1 / 2) α) := by rw [hf_one, hf_half]; exact ⟨hc0.le, hc_cap.le⟩ obtain ⟨p_c, hp_c_mem, hp_c_eq⟩ := intermediate_value_Icc' (by norm_num : (1 / 2 : ℝ) ≤ 1) hf_cont hmem have hp_c_gt : 1 / 2 < p_c := by rcases lt_or_eq_of_le hp_c_mem.1 with h | h · exact h · exfalso; rw [← h] at hp_c_eq; linarith [hf_half] have hp_c_lt : p_c < 1 := by rcases lt_or_eq_of_le hp_c_mem.2 with h | h · exact h · exfalso; rw [h] at hp_c_eq; linarith [hf_one] -- Strict antitone of tmazeEIG on [1/2, 1] have hf_anti : StrictAntiOn (fun p => tmazeEIG p α) (Set.Icc (1 / 2) 1) := by intro x hx y hy hxy unfold tmazeEIG have hrx : x * α + (1 - x) * (1 - α) ∈ Set.Ico (1 / 2 : ℝ) 1 := by rw [hr_eq]; exact ⟨by nlinarith [hx.1], by nlinarith [hx.2]⟩ have hry : y * α + (1 - y) * (1 - α) ∈ Set.Ico (1 / 2 : ℝ) 1 := by rw [hr_eq]; exact ⟨by nlinarith [hy.1], by nlinarith [hy.2]⟩ have hrlt : x * α + (1 - x) * (1 - α) < y * α + (1 - y) * (1 - α) := by rw [hr_eq, hr_eq]; nlinarith linarith [binaryEntropy_strictAntiOn_half_one hrx hry hrlt] -- Analytic sandwich on p_c from sharp binary entropy bounds at r_c = 1/2 + (p_c - 1/2)(2α - 1) set r_c := p_c * α + (1 - p_c) * (1 - α) have hrc_eq : r_c - 1 / 2 = (p_c - 1 / 2) * (2 * α - 1) := by dsimp [r_c]; ring have hrc0 : 0 < r_c := by dsimp [r_c]; rw [hr_eq]; nlinarith have hrc1 : r_c < 1 := by dsimp [r_c]; rw [hr_eq]; nlinarith have hup_c := binaryEntropy_le_log_two_sub_sq hrc0 hrc1 have hlo_c := four_mul_log_two_le_binaryEntropy hrc0 hrc1 have hbe_eq : binaryEntropy r_c = c + binaryEntropy α := by unfold tmazeEIG at hp_c_eq; linarith have hpc_upper : p_c ≤ 1 / 2 + Real.sqrt (2 * (Real.log 2 - binaryEntropy α - c)) / (2 * (2 * α - 1)) := by have hsq : (2 * (r_c - 1 / 2)) ^ 2 ≤ 2 * (Real.log 2 - binaryEntropy α - c) := by rw [hbe_eq] at hup_c; nlinarith have hsqrt : 2 * (r_c - 1 / 2) ≤ Real.sqrt (2 * (Real.log 2 - binaryEntropy α - c)) := by have hnonneg : 0 ≤ 2 * (r_c - 1 / 2) := by rw [hrc_eq]; nlinarith calc 2 * (r_c - 1 / 2) = Real.sqrt ((2 * (r_c - 1 / 2)) ^ 2) := (Real.sqrt_sq hnonneg).symm _ ≤ Real.sqrt (2 * (Real.log 2 - binaryEntropy α - c)) := Real.sqrt_le_sqrt hsq rw [hrc_eq] at hsqrt have hdiv : p_c - 1 / 2 ≤ Real.sqrt (2 * (Real.log 2 - binaryEntropy α - c)) / (2 * (2 * α - 1)) := by rw [le_div_iff₀ (by linarith)]; linarith linarith have hpc_lower : 1 / 2 + Real.sqrt ((Real.log 2 - binaryEntropy α - c) / Real.log 2) / (2 * (2 * α - 1)) ≤ p_c := by have h4r : 4 * r_c * (1 - r_c) = 1 - (2 * (r_c - 1 / 2)) ^ 2 := by ring rw [h4r, hbe_eq] at hlo_c have hsq : (Real.log 2 - binaryEntropy α - c) / Real.log 2 ≤ (2 * (r_c - 1 / 2)) ^ 2 := by rw [div_le_iff₀ hlog2]; nlinarith have hsqrt : Real.sqrt ((Real.log 2 - binaryEntropy α - c) / Real.log 2) ≤ 2 * (r_c - 1 / 2) := by have hnonneg : 0 ≤ 2 * (r_c - 1 / 2) := by rw [hrc_eq]; nlinarith calc Real.sqrt ((Real.log 2 - binaryEntropy α - c) / Real.log 2) ≤ Real.sqrt ((2 * (r_c - 1 / 2)) ^ 2) := Real.sqrt_le_sqrt hsq _ = 2 * (r_c - 1 / 2) := Real.sqrt_sq hnonneg rw [hrc_eq] at hsqrt have hdiv : Real.sqrt ((Real.log 2 - binaryEntropy α - c) / Real.log 2) / (2 * (2 * α - 1)) ≤ p_c - 1 / 2 := by rw [div_le_iff₀ (by linarith)]; linarith linarith refine ⟨p_c, ⟨⟨hp_c_gt, hp_c_lt⟩, hp_c_eq, ?_, ?_, hpc_lower, hpc_upper⟩, ?_⟩ · -- c < tmazeEIG p α ↔ 1 - p_c < p ∧ p < p_c intro p hp0 hp1 rcases le_or_gt (1 / 2 : ℝ) p with hge | hlt · have hiff : c < tmazeEIG p α ↔ p < p_c := by rw [← hp_c_eq] constructor · intro h; by_contra hge'; push Not at hge' rcases eq_or_lt_of_le hge' with rfl | hgt' · exact lt_irrefl _ h · exact lt_asymm h (hf_anti ⟨hp_c_gt.le, hp_c_lt.le⟩ ⟨hge, hp1.le⟩ hgt') · intro hlt'; exact hf_anti ⟨hge, hp1.le⟩ ⟨hp_c_gt.le, hp_c_lt.le⟩ hlt' rw [hiff] constructor · intro h; exact ⟨by linarith, h⟩ · intro h; exact h.2 · rw [← hsymm p] have hiff : c < tmazeEIG (1 - p) α ↔ 1 - p < p_c := by rw [← hp_c_eq] constructor · intro h; by_contra hge'; push Not at hge' rcases eq_or_lt_of_le hge' with heq | hgt' · rw [heq] at h; exact lt_irrefl _ h · exact lt_asymm h (hf_anti ⟨hp_c_gt.le, hp_c_lt.le⟩ ⟨by linarith, by linarith⟩ hgt') · intro hlt'; exact hf_anti ⟨by linarith, by linarith⟩ ⟨hp_c_gt.le, hp_c_lt.le⟩ hlt' rw [hiff] constructor · intro h; exact ⟨by linarith, by linarith⟩ · intro h; linarith · -- tmazeEIG p α < c ↔ p < 1 - p_c ∨ p_c < p intro p hp0 hp1 rcases le_or_gt (1 / 2 : ℝ) p with hge | hlt · have hiff : tmazeEIG p α < c ↔ p_c < p := by rw [← hp_c_eq] constructor · intro h; by_contra hle'; push Not at hle' rcases eq_or_lt_of_le hle' with rfl | hlt' · exact lt_irrefl _ h · exact lt_asymm h (hf_anti ⟨hge, hp1.le⟩ ⟨hp_c_gt.le, hp_c_lt.le⟩ hlt') · intro hgt'; exact hf_anti ⟨hp_c_gt.le, hp_c_lt.le⟩ ⟨hge, hp1.le⟩ hgt' rw [hiff] constructor · intro h; exact Or.inr h · rintro (h | h) · linarith · exact h · rw [← hsymm p] have hiff : tmazeEIG (1 - p) α < c ↔ p_c < 1 - p := by rw [← hp_c_eq] constructor · intro h; by_contra hle'; push Not at hle' rcases eq_or_lt_of_le hle' with heq | hlt' · rw [heq] at h; exact lt_irrefl _ h · exact lt_asymm h (hf_anti ⟨by linarith, by linarith⟩ ⟨hp_c_gt.le, hp_c_lt.le⟩ hlt') · intro hgt'; exact hf_anti ⟨hp_c_gt.le, hp_c_lt.le⟩ ⟨by linarith, by linarith⟩ hgt' rw [hiff] constructor · intro h; exact Or.inl (by linarith) · rintro (h | h) · linarith · linarith · -- Uniqueness intro p' ⟨hp'_mem, hp'_eq, _⟩ by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · have := hf_anti ⟨hp'_mem.1.le, hp'_mem.2.le⟩ ⟨hp_c_gt.le, hp_c_lt.le⟩ hlt linarith · have := hf_anti ⟨hp_c_gt.le, hp_c_lt.le⟩ ⟨hp'_mem.1.le, hp'_mem.2.le⟩ hgt linarith /-- **Explicit Concrete Phase Witnesses for the Noisy T-Maze** (`α = 9/10, c = 1/4`): - At `p = 1/2` (uncertain belief), epistemic exploration STRICTLY dominates (`tmazeEIG (1/2) (9/10) > 1/4`). - At `p = 9/10` (confident belief), pragmatic exploitation STRICTLY dominates (`tmazeEIG (9/10) (9/10) < 1/4`). -/ theorem tmaze_explicit_phase_witnesses : (1 / 4 : ℝ) < tmazeEIG (1 / 2) (9 / 10) ∧ tmazeEIG (9 / 10) (9 / 10) < (1 / 4 : ℝ) := by have hlog2_gt : (69 / 100 : ℝ) < Real.log 2 := by linarith [Real.log_two_gt_d9] -- Bound h₂(9/10) = h₂(1/10): since h₂(1/10) = -(1/10)log(1/10) - (9/10)log(9/10) -- Use elementary log bounds: log(10) < 2.31, log(10/9) < 1/9 (via log u ≤ u - 1) have hbe_9_10_upper : binaryEntropy (9 / 10 : ℝ) < 35 / 100 := by rw [← binaryEntropy_symm] have h1 : (1 : ℝ) - 9 / 10 = 1 / 10 := by norm_num rw [h1] unfold binaryEntropy have h1m : (1 : ℝ) - 1 / 10 = 9 / 10 := by norm_num rw [h1m] -- -log(1/10) = log 10 = log(10/8) + 3 log 2 ≤ 1/4 + 3 log 2 have hlog10 : Real.log 10 ≤ 1 / 4 + 3 * Real.log 2 := by have h10 : (10 : ℝ) = (10 / 8) * 2 ^ 3 := by norm_num rw [h10, Real.log_mul (by norm_num) (by norm_num), Real.log_pow] have hle := Real.log_le_sub_one_of_pos (x := (10 / 8 : ℝ)) (by norm_num) push_cast; linarith have hlog2_lt : Real.log 2 < 7 / 10 := by linarith [Real.log_two_lt_d9] have hlog9_10 : -(Real.log (9 / 10 : ℝ)) ≤ 1 / 9 := by have h := Real.log_le_sub_one_of_pos (x := (10 / 9 : ℝ)) (by norm_num) have hinv : Real.log (10 / 9 : ℝ) = -Real.log (9 / 10 : ℝ) := by rw [← Real.log_inv]; norm_num linarith have hlog1_10 : -Real.log (1 / 10 : ℝ) = Real.log 10 := by rw [one_div, Real.log_inv]; ring linarith constructor · unfold tmazeEIG have hmid : (1 / 2 : ℝ) * (9 / 10) + (1 - 1 / 2) * (1 - 9 / 10) = 1 / 2 := by norm_num rw [hmid, binaryEntropy_half] linarith · -- At p = 9/10, α = 9/10: r = 82/100 = 41/50, and h₂(41/50) - h₂(9/10) ≤ (log 2 - 2*(16/50)^2) - 4*(9/10)*(1/10)*log 2 unfold tmazeEIG have hr : (9 / 10 : ℝ) * (9 / 10) + (1 - 9 / 10) * (1 - 9 / 10) = 41 / 50 := by norm_num rw [hr] have hup := binaryEntropy_le_log_two_sub_sq (p := (41 / 50 : ℝ)) (by norm_num) (by norm_num) have hlo := four_mul_log_two_le_binaryEntropy (p := (9 / 10 : ℝ)) (by norm_num) (by norm_num) have hlog2_lt : Real.log 2 < 7 / 10 := by linarith [Real.log_two_lt_d9] linarith end Pillar3EFE /-! ## Section 4 (Pillar 4): Sharp Mean-Field vs. Exact Bayes Variational Gap Bounds -/ section Pillar4MeanField /-! ### 4A. General Structural Mean-Field Laws on Product Spaces -/ /-- Product distribution `(q₁ ⊗ q₂)(s₁, s₂) = q₁(s₁) q₂(s₂)`. -/ def prodDist {ι₁ ι₂ : Type*} (q₁ : ι₁ → ℝ) (q₂ : ι₂ → ℝ) (s : ι₁ × ι₂) : ℝ := q₁ s.1 * q₂ s.2 /-- First marginal `p₁(s₁) = ∑_{s₂} p(s₁, s₂)`. -/ def marg₁ {ι₁ ι₂ : Type*} [Fintype ι₂] (p : ι₁ × ι₂ → ℝ) (s₁ : ι₁) : ℝ := ∑ s₂, p (s₁, s₂) /-- Second marginal `p₂(s₂) = ∑_{s₁} p(s₁, s₂)`. -/ def marg₂ {ι₁ ι₂ : Type*} [Fintype ι₁] (p : ι₁ × ι₂ → ℝ) (s₂ : ι₂) : ℝ := ∑ s₁, p (s₁, s₂) /-- Mutual information of a joint distribution `p` on `ι₁ × ι₂`: `I_p(S₁; S₂) = D_KL(p ‖ p₁ ⊗ p₂)`. -/ noncomputable def jointMI {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] (p : ι₁ × ι₂ → ℝ) : ℝ := klDiv p (prodDist (marg₁ p) (marg₂ p)) /-- Lautum information `L_p(S₁; S₂) = D_KL(p₁ ⊗ p₂ ‖ p)` (Palomar–Verdú 2008). -/ noncomputable def lautumInfo {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] (p : ι₁ × ι₂ → ℝ) : ℝ := klDiv (prodDist (marg₁ p) (marg₂ p)) p lemma prodDist_isPosProb {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] {q₁ : ι₁ → ℝ} {q₂ : ι₂ → ℝ} (hq₁ : IsPosProb q₁) (hq₂ : IsPosProb q₂) : IsPosProb (prodDist q₁ q₂) := by refine ⟨fun s => mul_pos (hq₁.1 s.1) (hq₂.1 s.2), ?_⟩ unfold prodDist rw [Fintype.sum_prod_type] calc ∑ s₁, ∑ s₂, q₁ s₁ * q₂ s₂ = ∑ s₁, q₁ s₁ * ∑ s₂, q₂ s₂ := by apply Finset.sum_congr rfl; intro s₁ _; rw [← Finset.mul_sum] _ = ∑ s₁, q₁ s₁ := by apply Finset.sum_congr rfl; intro s₁ _; rw [hq₂.2, mul_one] _ = 1 := hq₁.2 lemma marg₁_isPosProb {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] [Nonempty ι₂] {p : ι₁ × ι₂ → ℝ} (hp : IsPosProb p) : IsPosProb (marg₁ p) := by refine ⟨fun s₁ => Finset.sum_pos (fun s₂ _ => hp.1 (s₁, s₂)) Finset.univ_nonempty, ?_⟩ unfold marg₁ rw [← Fintype.sum_prod_type, hp.2] lemma marg₂_isPosProb {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] [Nonempty ι₁] {p : ι₁ × ι₂ → ℝ} (hp : IsPosProb p) : IsPosProb (marg₂ p) := by refine ⟨fun s₂ => Finset.sum_pos (fun s₁ _ => hp.1 (s₁, s₂)) Finset.univ_nonempty, ?_⟩ unfold marg₂ rw [Finset.sum_comm, ← Fintype.sum_prod_type, hp.2] /-- **Pillar 4A-1 (Exact Forward-KL Mean-Field Decomposition)**: `D_KL(p ‖ q₁ ⊗ q₂) = I_p(S₁; S₂) + D_KL(p₁ ‖ q₁) + D_KL(p₂ ‖ q₂)`, uniquely minimized at the exact marginals `(p₁, p₂)` with minimum equal to `I_p(S₁; S₂)`. -/ theorem forward_kl_meanField_exact {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] [Nonempty ι₁] [Nonempty ι₂] {p : ι₁ × ι₂ → ℝ} {q₁ : ι₁ → ℝ} {q₂ : ι₂ → ℝ} (hp : IsPosProb p) (hq₁ : IsPosProb q₁) (hq₂ : IsPosProb q₂) : klDiv p (prodDist q₁ q₂) = jointMI p + klDiv (marg₁ p) q₁ + klDiv (marg₂ p) q₂ := by have hm₁ := marg₁_isPosProb hp have hm₂ := marg₂_isPosProb hp unfold jointMI klDiv prodDist rw [Fintype.sum_prod_type] have hmi_eq : ∑ x : ι₁ × ι₂, p x * Real.log (p x / (marg₁ p x.1 * marg₂ p x.2)) = ∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (p (s₁, s₂) / (marg₁ p s₁ * marg₂ p s₂)) := Fintype.sum_prod_type _ rw [hmi_eq] have hsplit : ∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (p (s₁, s₂) / (q₁ s₁ * q₂ s₂)) = (∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (p (s₁, s₂) / (marg₁ p s₁ * marg₂ p s₂))) + (∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (marg₁ p s₁ / q₁ s₁)) + (∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (marg₂ p s₂ / q₂ s₂)) := by rw [← Finset.sum_add_distrib, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro s₁ _ rw [← Finset.sum_add_distrib, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro s₂ _ have hps := hp.1 (s₁, s₂) have hp1 := hm₁.1 s₁; have hp2 := hm₂.1 s₂ have hq1 := hq₁.1 s₁; have hq2 := hq₂.1 s₂ rw [Real.log_div hps.ne' (mul_pos hq1 hq2).ne', Real.log_mul hq1.ne' hq2.ne', Real.log_div hps.ne' (mul_pos hp1 hp2).ne', Real.log_mul hp1.ne' hp2.ne', Real.log_div hp1.ne' hq1.ne', Real.log_div hp2.ne' hq2.ne'] ring rw [hsplit] have ht1 : ∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (marg₁ p s₁ / q₁ s₁) = ∑ s₁, marg₁ p s₁ * Real.log (marg₁ p s₁ / q₁ s₁) := by apply Finset.sum_congr rfl; intro s₁ _; rw [← Finset.sum_mul]; rfl have ht2 : ∑ s₁, ∑ s₂, p (s₁, s₂) * Real.log (marg₂ p s₂ / q₂ s₂) = ∑ s₂, marg₂ p s₂ * Real.log (marg₂ p s₂ / q₂ s₂) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro s₂ _; rw [← Finset.sum_mul]; rfl rw [ht1, ht2] /-- **Pillar 4A-2 (Reverse-KL Mean-Field Zero-Gap Characterization)**: A zero mean-field variational gap exists if and only if the exact posterior factorizes (`p = p₁ ⊗ p₂`). -/ theorem reverse_kl_meanField_zero_iff_indep {ι₁ ι₂ : Type*} [Fintype ι₁] [Fintype ι₂] [Nonempty ι₁] [Nonempty ι₂] {p : ι₁ × ι₂ → ℝ} (hp : IsPosProb p) : (∃ (q₁ : ι₁ → ℝ) (q₂ : ι₂ → ℝ), IsPosProb q₁ ∧ IsPosProb q₂ ∧ klDiv (prodDist q₁ q₂) p = 0) ↔ p = prodDist (marg₁ p) (marg₂ p) := by constructor · rintro ⟨q₁, q₂, hq₁, hq₂, hzero⟩ have heq : prodDist q₁ q₂ = p := (klDiv_eq_zero_iff (prodDist_isPosProb hq₁ hq₂) hp).mp hzero have hm1 : marg₁ p = q₁ := by funext s₁; unfold marg₁; rw [← heq]; unfold prodDist simp only rw [← Finset.mul_sum, hq₂.2, mul_one] have hm2 : marg₂ p = q₂ := by funext s₂; unfold marg₂; rw [← heq]; unfold prodDist simp only rw [← Finset.sum_mul, hq₁.2, one_mul] rw [hm1, hm2, heq] · intro hindep refine ⟨marg₁ p, marg₂ p, marg₁_isPosProb hp, marg₂_isPosProb hp, ?_⟩ rw [← hindep] exact (klDiv_eq_zero_iff hp hp).mpr rfl /-! ### 4B. Exact `d`-Cause Explaining-Away Gaussian Mean-Field Gap & Total-Correlation Inversion -/ /-- Exact analytical KL divergence `D_KL(N(m, diag(v)) ‖ N(μ*, Π⁻¹))` for the `d`-cause explaining-away Gaussian generative model with posterior precision matrix `Π = π_p I_d + π_o 1 1ᵀ` (`λ = π_o / π_p > 0`). -/ noncomputable def explainingAwayGaussianKL {d : ℕ} (π_p π_o : ℝ) (μstar m v : Fin d → ℝ) : ℝ := (1 / 2) * ( (π_p + π_o) * (∑ i, v i) + π_p * (∑ i, (m i - μstar i) ^ 2) + π_o * (∑ i, (m i - μstar i)) ^ 2 - (d : ℝ) - Real.log (1 + (d : ℝ) * (π_o / π_p)) - (d : ℝ) * Real.log π_p - ∑ i, Real.log (v i) ) /-- Exact closed-form `d`-cause Explaining-Away Mean-Field Variational Gap: `Δ_MF^EA(d, λ) = (1/2) (d log(1 + λ) - log(1 + d λ))`. -/ noncomputable def explainingAwayMFGap (d : ℕ) (lam : ℝ) : ℝ := (1 / 2) * ((d : ℝ) * Real.log (1 + lam) - Real.log (1 + (d : ℝ) * lam)) /-- Exact `d`-cause Explaining-Away Total Correlation (Forward-KL optimal factorized gap): `I_TC^EA(d, λ) = (1/2) (d log(1 + (d - 1) λ) - (d - 1) log(1 + d λ))`. -/ noncomputable def explainingAwayTotalCorr (d : ℕ) (lam : ℝ) : ℝ := (1 / 2) * ((d : ℝ) * Real.log (1 + ((d : ℝ) - 1) * lam) - ((d : ℝ) - 1) * Real.log (1 + (d : ℝ) * lam)) /-- **Pillar 4B-1 (Headline — Exact Global Optimality & Closed-Form Explaining-Away MF Gap)**: Over ALL diagonal Gaussian approximations `N(m, diag(v))` (`v_i > 0`), `D_KL^EA(m, v) ≥ (1/2)(d log(1 + λ) - log(1 + d λ))`, with equality if and only if `m = μ*` and `v_i = 1 / (π_p + π_o)` for all `i`. -/ theorem explainingAway_mf_gap_exact_min {d : ℕ} {π_p π_o : ℝ} (hπ_p : 0 < π_p) (hπ_o : 0 < π_o) (μstar m v : Fin d → ℝ) (hv : ∀ i, 0 < v i) : let lam := π_o / π_p explainingAwayMFGap d lam ≤ explainingAwayGaussianKL π_p π_o μstar m v ∧ (explainingAwayGaussianKL π_p π_o μstar m v = explainingAwayMFGap d lam ↔ m = μstar ∧ ∀ i, v i = 1 / (π_p + π_o)) := by intro lam have hsum_pos : 0 < π_p + π_o := by linarith have h1lam : 0 < 1 + lam := by dsimp [lam]; positivity -- Rewrite KL - gap as (1/2)[ ∑ ((π_p+π_o) v_i - 1 - log((π_p+π_o) v_i)) + quad ] have hdiff : explainingAwayGaussianKL π_p π_o μstar m v - explainingAwayMFGap d lam = (1 / 2) * ( (∑ i, ((π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i))) + π_p * (∑ i, (m i - μstar i) ^ 2) + π_o * (∑ i, (m i - μstar i)) ^ 2 ) := by unfold explainingAwayGaussianKL explainingAwayMFGap have hlog_sum : ∑ i : Fin d, Real.log ((π_p + π_o) * v i) = (d : ℝ) * Real.log π_p + (d : ℝ) * Real.log (1 + lam) + ∑ i, Real.log (v i) := by have hfac : π_p + π_o = π_p * (1 + lam) := by dsimp [lam]; field_simp [hπ_p.ne'] calc ∑ i : Fin d, Real.log ((π_p + π_o) * v i) = ∑ i : Fin d, (Real.log π_p + Real.log (1 + lam) + Real.log (v i)) := by apply Finset.sum_congr rfl; intro i _ rw [hfac, Real.log_mul (mul_pos hπ_p h1lam).ne' (hv i).ne', Real.log_mul hπ_p.ne' h1lam.ne'] _ = (∑ _i : Fin d, Real.log π_p) + (∑ _i : Fin d, Real.log (1 + lam)) + ∑ i, Real.log (v i) := by rw [Finset.sum_add_distrib, Finset.sum_add_distrib] _ = (d : ℝ) * Real.log π_p + (d : ℝ) * Real.log (1 + lam) + ∑ i, Real.log (v i) := by simp have h1 : ∑ i : Fin d, ((π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i)) = (π_p + π_o) * (∑ i, v i) - (d : ℝ) - ∑ i, Real.log ((π_p + π_o) * v i) := by rw [Finset.sum_sub_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum] simp rw [h1, hlog_sum] ring have hterm_nonneg : ∀ i, 0 ≤ (π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i) := by intro i linarith [Real.log_le_sub_one_of_pos (mul_pos hsum_pos (hv i))] have hsum_v : 0 ≤ ∑ i, ((π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i)) := Finset.sum_nonneg (fun i _ => hterm_nonneg i) have hquad1 : 0 ≤ π_p * ∑ i, (m i - μstar i) ^ 2 := mul_nonneg hπ_p.le (Finset.sum_nonneg (fun i _ => sq_nonneg _)) have hquad2 : 0 ≤ π_o * (∑ i, (m i - μstar i)) ^ 2 := mul_nonneg hπ_o.le (sq_nonneg _) constructor · linarith · constructor · intro heq have h0 : (∑ i, ((π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i))) + π_p * (∑ i, (m i - μstar i) ^ 2) + π_o * (∑ i, (m i - μstar i)) ^ 2 = 0 := by linarith have hq1_zero : ∑ i, (m i - μstar i) ^ 2 = 0 := by nlinarith have hv_zero : ∑ i, ((π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i)) = 0 := by nlinarith constructor · funext i have hi := (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => sq_nonneg (m j - μstar j))).mp hq1_zero i (Finset.mem_univ i) have := sq_eq_zero_iff.mp hi linarith · intro i have hi := (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => hterm_nonneg j)).mp hv_zero i (Finset.mem_univ i) by_contra hne have hmul_ne : (π_p + π_o) * v i ≠ 1 := by intro h1; exact hne (eq_one_div_of_mul_eq_one_right h1) have hlt := log_lt_sub_one_of_ne_one (mul_pos hsum_pos (hv i)) hmul_ne linarith · rintro ⟨hm, hv_eq⟩ suffices h : explainingAwayGaussianKL π_p π_o μstar m v - explainingAwayMFGap d lam = 0 by linarith rw [hdiff, hm] have h1 : ∑ i, ((π_p + π_o) * v i - 1 - Real.log ((π_p + π_o) * v i)) = 0 := by apply Finset.sum_eq_zero; intro i _ rw [hv_eq i, mul_one_div_cancel hsum_pos.ne', Real.log_one]; ring simp [h1] /-- **Pillar 4B-2 (Exact Variance Overconfidence Collapse Ratio)**: In `d`-cause explaining-away predictive coding (`d ≥ 2`), the optimal mean-field variance `v* = 1 / (π_p (1 + λ))` underestimates the exact marginal posterior variance `Σ_ii = (1 + (d - 1) λ) / (π_p (1 + d λ))` by the exact ratio `v* / Σ_ii = (1 + d λ) / ((1 + λ)(1 + (d - 1) λ)) < 1`. -/ theorem explainingAway_overconfidence_collapse {d : ℕ} (hd : 2 ≤ d) {π_p lam : ℝ} (hπ_p : 0 < π_p) (hlam : 0 < lam) : let v_mf := 1 / (π_p * (1 + lam)) let v_true := (1 + ((d : ℝ) - 1) * lam) / (π_p * (1 + (d : ℝ) * lam)) v_mf / v_true = (1 + (d : ℝ) * lam) / ((1 + lam) * (1 + ((d : ℝ) - 1) * lam)) ∧ v_mf / v_true < 1 := by intro v_mf v_true have hd_real : (2 : ℝ) ≤ (d : ℝ) := by exact_mod_cast hd have h1lam : 0 < 1 + lam := by linarith have h1d : 0 < 1 + (d : ℝ) * lam := by nlinarith have h1dm1 : 0 < 1 + ((d : ℝ) - 1) * lam := by nlinarith have hratio : v_mf / v_true = (1 + (d : ℝ) * lam) / ((1 + lam) * (1 + ((d : ℝ) - 1) * lam)) := by dsimp [v_mf, v_true] field_simp [hπ_p.ne', h1lam.ne', h1d.ne', h1dm1.ne'] refine ⟨hratio, ?_⟩ rw [hratio, div_lt_one (mul_pos h1lam h1dm1)] have hdiff : (1 + lam) * (1 + ((d : ℝ) - 1) * lam) - (1 + (d : ℝ) * lam) = ((d : ℝ) - 1) * lam ^ 2 := by ring have hpos : 0 < ((d : ℝ) - 1) * lam ^ 2 := mul_pos (by linarith) (sq_pos_of_pos hlam) linarith /-- **Pillar 4B-3 (Headline — Exact Total-Correlation Inversion Theorem)**: - At `d = 2`: `Δ_MF^EA(2, λ) = I_TC^EA(2, λ)` identically. - For EVERY `d ≥ 3` and EVERY `λ > 0`: `Δ_MF^EA(d, λ) > I_TC^EA(d, λ)` strictly! (Proved via the exact monomial derivative `d/dλ [2(Δ_MF - I_TC)] = d(d-1)(d-2)λ² / ((1+λ)(1+(d-1)λ)(1+dλ)) > 0`.) -/ theorem explainingAway_mf_eq_tc_dim2 (lam : ℝ) : explainingAwayMFGap 2 lam = explainingAwayTotalCorr 2 lam := by unfold explainingAwayMFGap explainingAwayTotalCorr norm_num theorem explainingAway_mf_strictly_exceeds_tc {d : ℕ} (hd : 3 ≤ d) {lam : ℝ} (hlam : 0 < lam) : explainingAwayTotalCorr d lam < explainingAwayMFGap d lam := by have hd_real : (3 : ℝ) ≤ (d : ℝ) := by exact_mod_cast hd let g : ℝ → ℝ := fun t => (d : ℝ) * Real.log (1 + t) + ((d : ℝ) - 2) * Real.log (1 + (d : ℝ) * t) - (d : ℝ) * Real.log (1 + ((d : ℝ) - 1) * t) have hg_diff : 2 * (explainingAwayMFGap d lam - explainingAwayTotalCorr d lam) = g lam := by unfold explainingAwayMFGap explainingAwayTotalCorr; dsimp [g]; ring suffices hpos : 0 < g lam by linarith have hg0 : g 0 = 0 := by simp [g] have hg_deriv : ∀ t ∈ Set.Ici (0 : ℝ), HasDerivAt g ((d : ℝ) * ((d : ℝ) - 1) * ((d : ℝ) - 2) * t ^ 2 / ((1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t))) t := by intro t ht have ht0 : 0 ≤ t := ht have h1 : 0 < 1 + t := by linarith have h2 : 0 < 1 + (d : ℝ) * t := by nlinarith have h3 : 0 < 1 + ((d : ℝ) - 1) * t := by nlinarith have hd1 : HasDerivAt (fun x => (d : ℝ) * Real.log (1 + x)) ((d : ℝ) / (1 + t)) t := by have ha : HasDerivAt (fun x => 1 + x) 1 t := (hasDerivAt_id t).const_add (1 : ℝ) exact (((Real.hasDerivAt_log h1.ne').comp t ha).const_mul (d : ℝ)).congr_deriv (by field_simp [h1.ne']) have hd2 : HasDerivAt (fun x => ((d : ℝ) - 2) * Real.log (1 + (d : ℝ) * x)) (((d : ℝ) - 2) * (d : ℝ) / (1 + (d : ℝ) * t)) t := by have ha : HasDerivAt (fun x => 1 + (d : ℝ) * x) (d : ℝ) t := (((hasDerivAt_id t).const_mul (d : ℝ)).const_add (1 : ℝ)).congr_deriv (by ring) exact (((Real.hasDerivAt_log h2.ne').comp t ha).const_mul ((d : ℝ) - 2)).congr_deriv (by field_simp [h2.ne']) have hd3 : HasDerivAt (fun x => (d : ℝ) * Real.log (1 + ((d : ℝ) - 1) * x)) ((d : ℝ) * ((d : ℝ) - 1) / (1 + ((d : ℝ) - 1) * t)) t := by have ha : HasDerivAt (fun x => 1 + ((d : ℝ) - 1) * x) ((d : ℝ) - 1) t := (((hasDerivAt_id t).const_mul ((d : ℝ) - 1)).const_add (1 : ℝ)).congr_deriv (by ring) exact ((ha.log h3.ne').const_mul (d : ℝ)).congr_deriv (by ring) have hsub_d := (hd1.add hd2).sub hd3 have hd_rew : ((d : ℝ) / (1 + t) + ((d : ℝ) - 2) * (d : ℝ) / (1 + (d : ℝ) * t) - (d : ℝ) * ((d : ℝ) - 1) / (1 + ((d : ℝ) - 1) * t)) = (d : ℝ) * ((d : ℝ) - 1) * ((d : ℝ) - 2) * t ^ 2 / ((1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t)) := by have hden_ne : (1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t) ≠ 0 := mul_ne_zero (mul_ne_zero h1.ne' h3.ne') h2.ne' rw [eq_div_iff hden_ne] have ha1 : (d : ℝ) / (1 + t) * ((1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t)) = (d : ℝ) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t) := by field_simp [h1.ne'] have ha2 : ((d : ℝ) - 2) * (d : ℝ) / (1 + (d : ℝ) * t) * ((1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t)) = ((d : ℝ) - 2) * (d : ℝ) * (1 + t) * (1 + ((d : ℝ) - 1) * t) := by field_simp [h2.ne'] have ha3 : (d : ℝ) * ((d : ℝ) - 1) / (1 + ((d : ℝ) - 1) * t) * ((1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t)) = (d : ℝ) * ((d : ℝ) - 1) * (1 + t) * (1 + (d : ℝ) * t) := by field_simp [h3.ne'] rw [sub_mul, add_mul, ha1, ha2, ha3] ring exact hsub_d.congr_deriv hd_rew have hstrict : StrictMonoOn g (Set.Ici 0) := by apply strictMonoOn_of_deriv_pos (convex_Ici 0) · intro t ht; exact (hg_deriv t ht).continuousAt.continuousWithinAt · intro t ht rw [interior_Ici] at ht have htpos : 0 < t := ht rw [(hg_deriv t htpos.le).deriv] have hnum : 0 < (d : ℝ) * ((d : ℝ) - 1) * ((d : ℝ) - 2) * t ^ 2 := by have h1 : 0 < (d : ℝ) := by linarith have h2 : 0 < (d : ℝ) - 1 := by linarith have h3 : 0 < (d : ℝ) - 2 := by linarith have h4 : 0 < t ^ 2 := sq_pos_of_pos htpos positivity have hden : 0 < (1 + t) * (1 + ((d : ℝ) - 1) * t) * (1 + (d : ℝ) * t) := by have h1 : 0 < 1 + t := by linarith have h2 : 0 < 1 + ((d : ℝ) - 1) * t := by nlinarith have h3 : 0 < 1 + (d : ℝ) * t := by nlinarith positivity exact div_pos hnum hden rw [← hg0] exact hstrict (Set.mem_Ici.mpr le_rfl) (Set.mem_Ici.mpr hlam.le) hlam /-! ### 4C. Exact 2-Spin Ising Mean-Field Variational Gap, `J_c = 1` Symmetry-Breaking Phase Transition & Universal Mutual-Information Dominance -/ /-- Spin value `σ(true) = +1`, `σ(false) = -1`. -/ def spinVal : Bool → ℝ | true => 1 | false => -1 /-- Coupled 2-spin Ising posterior on `Bool × Bool`: `p_J(s₁, s₂) = exp(J σ(s₁) σ(s₂)) / (4 cosh J)`. -/ noncomputable def isingDist (J : ℝ) (s : Bool × Bool) : ℝ := Real.exp (J * spinVal s.1 * spinVal s.2) / (4 * Real.cosh J) /-- Magnetization-parameterized binary factor `q_m(true) = (1 + m)/2`, `q_m(false) = (1 - m)/2`. -/ noncomputable def magDist (m : ℝ) : Bool → ℝ | true => (1 + m) / 2 | false => (1 - m) / 2 /-- 1D Landau–Ginzburg mean-field potential `Φ_J(m) = (1+m)log(1+m) + (1-m)log(1-m) - J m²`. -/ noncomputable def isingPhi (J m : ℝ) : ℝ := (1 + m) * Real.log (1 + m) + (1 - m) * Real.log (1 - m) - J * m ^ 2 /-- Master monotone defect function `u(x) = 2 log(cosh x) - x tanh x`. -/ noncomputable def isingDefectU (x : ℝ) : ℝ := 2 * Real.log (Real.cosh x) - x * Real.tanh x lemma magDist_isPosProb {m : ℝ} (hm1 : -1 < m) (hm2 : m < 1) : IsPosProb (magDist m) := by refine ⟨fun b => by cases b <;> simp [magDist] <;> linarith, ?_⟩ simp [magDist]; ring lemma isingDist_isPosProb (J : ℝ) : IsPosProb (isingDist J) := by have hc : 0 < Real.cosh J := Real.cosh_pos J refine ⟨fun s => div_pos (Real.exp_pos _) (by positivity), ?_⟩ unfold isingDist rw [Fintype.sum_prod_type] simp only [Fintype.sum_bool, spinVal] have hcosh : Real.cosh J = (Real.exp J + Real.exp (-J)) / 2 := Real.cosh_eq J have hnum : Real.exp (J * 1 * 1) + Real.exp (J * 1 * -1) + (Real.exp (J * -1 * 1) + Real.exp (J * -1 * -1)) = 4 * Real.cosh J := by rw [hcosh]; ring_nf field_simp [hc.ne'] linarith lemma isingDist_margs (J : ℝ) : marg₁ (isingDist J) = magDist 0 ∧ marg₂ (isingDist J) = magDist 0 := by have hc : 0 < Real.cosh J := Real.cosh_pos J have hcosh : Real.cosh J = (Real.exp J + Real.exp (-J)) / 2 := Real.cosh_eq J constructor · funext s₁; unfold marg₁ isingDist magDist cases s₁ <;> simp only [Fintype.sum_bool, spinVal] <;> (rw [hcosh]; field_simp [hc.ne']; ring_nf) · funext s₂; unfold marg₂ isingDist magDist cases s₂ <;> simp only [Fintype.sum_bool, spinVal] <;> (rw [hcosh]; field_simp [hc.ne']; ring_nf) /-- Exact mutual information of the 2-spin Ising posterior: `I(S₁; S₂) = J tanh J - log(cosh J)`. -/ theorem ising_mi_exact (J : ℝ) : jointMI (isingDist J) = J * Real.tanh J - Real.log (Real.cosh J) := by unfold jointMI klDiv prodDist rw [(isingDist_margs J).1, (isingDist_margs J).2, Fintype.sum_prod_type] simp only [Fintype.sum_bool, isingDist, magDist, spinVal] have hc : 0 < Real.cosh J := Real.cosh_pos J have h1 : (1 + (0 : ℝ)) / 2 * ((1 + 0) / 2) = 1 / 4 := by norm_num have h2 : (1 + (0 : ℝ)) / 2 * ((1 - 0) / 2) = 1 / 4 := by norm_num have h3 : (1 - (0 : ℝ)) / 2 * ((1 + 0) / 2) = 1 / 4 := by norm_num have h4 : (1 - (0 : ℝ)) / 2 * ((1 - 0) / 2) = 1 / 4 := by norm_num rw [h1, h2, h3, h4] have hsimp : ∀ x : ℝ, (Real.exp x / (4 * Real.cosh J)) / (1 / 4 : ℝ) = Real.exp x / Real.cosh J := by intro x; field_simp [hc.ne'] rw [hsimp, hsimp, hsimp, hsimp, Real.log_div (Real.exp_pos _).ne' hc.ne', Real.log_div (Real.exp_pos _).ne' hc.ne', Real.log_div (Real.exp_pos _).ne' hc.ne', Real.log_div (Real.exp_pos _).ne' hc.ne', Real.log_exp, Real.log_exp, Real.log_exp, Real.log_exp] rw [Real.tanh_eq_sinh_div_cosh, Real.sinh_eq, Real.cosh_eq] have hsum : Real.exp J + Real.exp (-J) ≠ 0 := (add_pos (Real.exp_pos J) (Real.exp_pos (-J))).ne' field_simp [hc.ne', hsum] ring_nf /-- **Pillar 4C-1 (Exact Landau–Ginzburg Reduction of 2-Spin Ising Mean-Field KL)**: For ANY product distribution `magDist m₁ ⊗ magDist m₂` (`m₁, m₂ ∈ (-1, 1)`), `D_KL(q_{m₁} ⊗ q_{m₂} ‖ p_J) = log(cosh J) + (1/2)(Φ_J(m₁) + Φ_J(m₂)) + (J/2)(m₁ - m₂)²`. -/ theorem ising_mf_kl_exact (J : ℝ) {m₁ m₂ : ℝ} (hm₁1 : -1 < m₁) (hm₁2 : m₁ < 1) (hm₂1 : -1 < m₂) (hm₂2 : m₂ < 1) : klDiv (prodDist (magDist m₁) (magDist m₂)) (isingDist J) = Real.log (Real.cosh J) + (1 / 2) * (isingPhi J m₁ + isingPhi J m₂) + (J / 2) * (m₁ - m₂) ^ 2 := by unfold klDiv prodDist magDist isingDist isingPhi rw [Fintype.sum_prod_type] simp only [Fintype.sum_bool, spinVal] have hc : 0 < Real.cosh J := Real.cosh_pos J have ha1 : 0 < 1 + m₁ := by linarith have hb1 : 0 < 1 - m₁ := by linarith have ha2 : 0 < 1 + m₂ := by linarith have hb2 : 0 < 1 - m₂ := by linarith have hlog_cell : ∀ (u v x : ℝ), 0 < u → 0 < v → Real.log ((u / 2 * (v / 2)) / (Real.exp x / (4 * Real.cosh J))) = Real.log u + Real.log v + Real.log (Real.cosh J) - x := by intro u v x hu hv have hrew : (u / 2 * (v / 2)) / (Real.exp x / (4 * Real.cosh J)) = (u * v * Real.cosh J) / Real.exp x := by field_simp [hc.ne', (Real.exp_pos x).ne']; ring rw [hrew, Real.log_div (mul_pos (mul_pos hu hv) hc).ne' (Real.exp_pos x).ne', Real.log_mul (mul_pos hu hv).ne' hc.ne', Real.log_mul hu.ne' hv.ne', Real.log_exp] rw [hlog_cell _ _ _ ha1 ha2, hlog_cell _ _ _ ha1 hb2, hlog_cell _ _ _ hb1 ha2, hlog_cell _ _ _ hb1 hb2] ring lemma hasDerivAt_isingPhi (J : ℝ) {m : ℝ} (hm1 : -1 < m) (hm2 : m < 1) : HasDerivAt (isingPhi J) (Real.log ((1 + m) / (1 - m)) - 2 * J * m) m := by unfold isingPhi have ha : 0 < 1 + m := by linarith have hb : 0 < 1 - m := by linarith have h1 : HasDerivAt (fun x => (1 + x) * Real.log (1 + x)) (Real.log (1 + m) + 1) m := by have hadd : HasDerivAt (fun x : ℝ => 1 + x) 1 m := (hasDerivAt_id m).const_add (1 : ℝ) have hlog := (Real.hasDerivAt_log ha.ne').comp m hadd exact (hadd.mul hlog).congr_deriv (by simp only [Function.comp_apply]; field_simp [ha.ne']) have h2 : HasDerivAt (fun x => (1 - x) * Real.log (1 - x)) (-(Real.log (1 - m) + 1)) m := by have hsub : HasDerivAt (fun x : ℝ => 1 - x) (-1) m := ((hasDerivAt_const m (1 : ℝ)).sub (hasDerivAt_id m)).congr_deriv (by ring) have hlog := (Real.hasDerivAt_log hb.ne').comp m hsub exact (hsub.mul hlog).congr_deriv (by simp only [Function.comp_apply]; field_simp [hb.ne']; ring) have h3 : HasDerivAt (fun x => J * x ^ 2) (2 * J * m) m := (((hasDerivAt_id m).pow 2).const_mul J).congr_deriv (by simp only [id_eq]; ring) exact ((h1.add h2).sub h3).congr_deriv (by rw [Real.log_div ha.ne' hb.ne']; ring) lemma hasDerivAt_isingPhi' (J : ℝ) {m : ℝ} (hm1 : -1 < m) (hm2 : m < 1) : HasDerivAt (fun x => Real.log ((1 + x) / (1 - x)) - 2 * J * x) (2 / (1 - m ^ 2) - 2 * J) m := by have ha : 0 < 1 + m := by linarith have hb : 0 < 1 - m := by linarith have hlog_d : HasDerivAt (fun x => Real.log (1 + x) - Real.log (1 - x)) (1 / (1 + m) + 1 / (1 - m)) m := by have h1 : HasDerivAt (fun x => Real.log (1 + x)) (1 / (1 + m)) m := by have hadd : HasDerivAt (fun x : ℝ => 1 + x) 1 m := (hasDerivAt_id m).const_add (1 : ℝ) exact ((Real.hasDerivAt_log ha.ne').comp m hadd).congr_deriv (by ring) have h2 : HasDerivAt (fun x => Real.log (1 - x)) (-1 / (1 - m)) m := by have hsub : HasDerivAt (fun x : ℝ => 1 - x) (-1) m := ((hasDerivAt_const m (1 : ℝ)).sub (hasDerivAt_id m)).congr_deriv (by ring) exact ((Real.hasDerivAt_log hb.ne').comp m hsub).congr_deriv (by ring) exact (h1.sub h2).congr_deriv (by ring) have hlog_d' : HasDerivAt (fun x => Real.log ((1 + x) / (1 - x))) (1 / (1 + m) + 1 / (1 - m)) m := by refine hlog_d.congr_of_eventuallyEq ?_ filter_upwards [Ioo_mem_nhds hm1 hm2] with t ht exact Real.log_div (by linarith [ht.1]) (by linarith [ht.2]) have hlin : HasDerivAt (fun x => 2 * J * x) (2 * J) m := ((hasDerivAt_id m).const_mul (2 * J)).congr_deriv (by ring) exact (hlog_d'.sub hlin).congr_deriv (by have hsq : 1 - m ^ 2 = (1 + m) * (1 - m) := by ring rw [hsq]; field_simp [ha.ne', hb.ne']; ring) lemma isingPhi_even (J m : ℝ) : isingPhi J (-m) = isingPhi J m := by unfold isingPhi; ring_nf lemma isingPhi_at_tanh (J x : ℝ) : isingPhi J (Real.tanh x) = 2 * x * Real.tanh x - 2 * Real.log (Real.cosh x) - J * (Real.tanh x) ^ 2 := by unfold isingPhi have hc : 0 < Real.cosh x := Real.cosh_pos x have h1p : 1 + Real.tanh x = Real.exp x / Real.cosh x := by rw [Real.tanh_eq_sinh_div_cosh, Real.sinh_eq, Real.cosh_eq] have hsum : Real.exp x + Real.exp (-x) ≠ 0 := (add_pos (Real.exp_pos x) (Real.exp_pos (-x))).ne' field_simp [hc.ne', hsum]; ring have h1m : 1 - Real.tanh x = Real.exp (-x) / Real.cosh x := by rw [Real.tanh_eq_sinh_div_cosh, Real.sinh_eq, Real.cosh_eq] have hsum : Real.exp x + Real.exp (-x) ≠ 0 := (add_pos (Real.exp_pos x) (Real.exp_pos (-x))).ne' field_simp [hc.ne', hsum]; ring rw [h1p, h1m, Real.log_div (Real.exp_pos x).ne' hc.ne', Real.log_div (Real.exp_pos (-x)).ne' hc.ne', Real.log_exp, Real.log_exp] rw [← h1p, ← h1m] ring /-- **Pillar 4C-2 (Subcritical Phase `0 < J ≤ 1`)**: The unique global mean-field minimizer is the symmetric marginal product `m₁ = m₂ = 0`, with exact variational gap `Δ_MF^Ising(J) = log(cosh J)`. -/ theorem ising_mf_subcritical_exact {J : ℝ} (hJ0 : 0 < J) (hJ1 : J ≤ 1) {m₁ m₂ : ℝ} (hm₁1 : -1 < m₁) (hm₁2 : m₁ < 1) (hm₂1 : -1 < m₂) (hm₂2 : m₂ < 1) : Real.log (Real.cosh J) ≤ klDiv (prodDist (magDist m₁) (magDist m₂)) (isingDist J) ∧ (klDiv (prodDist (magDist m₁) (magDist m₂)) (isingDist J) = Real.log (Real.cosh J) ↔ m₁ = 0 ∧ m₂ = 0) := by rw [ising_mf_kl_exact J hm₁1 hm₁2 hm₂1 hm₂2] have hphi'_strict : StrictMonoOn (fun x => Real.log ((1 + x) / (1 - x)) - 2 * J * x) (Set.Ioo (-1) 1) := by -- Strict monotonicity via nonneg derivative that is > 0 away from 0: split (-1, 0] and [0, 1) have hpos : ∀ x ∈ Set.Ioo (-1 : ℝ) 1, 0 ≤ 2 / (1 - x ^ 2) - 2 * J := by intro x hx have h1mx2 : 0 < 1 - x ^ 2 := by nlinarith [hx.1, hx.2] have h1mx2_le : 1 - x ^ 2 ≤ 1 := by nlinarith [sq_nonneg x] rw [sub_nonneg, le_div_iff₀ h1mx2]; nlinarith have hmono : MonotoneOn (fun x => Real.log ((1 + x) / (1 - x)) - 2 * J * x) (Set.Ioo (-1) 1) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ioo (-1) 1) (fun x hx => (hasDerivAt_isingPhi' J hx.1 hx.2).continuousAt.continuousWithinAt) (fun x hx => (hasDerivAt_isingPhi' J (interior_subset hx).1 (interior_subset hx).2).hasDerivWithinAt) (fun x hx => hpos x (interior_subset hx)) -- On (0, 1), derivative is strictly positive; on (-1, 0), strictly positive intro a ha b hb hab have h0 : a < 0 ∧ 0 < b ∨ (0 ≤ a ∧ a < b) ∨ (a < b ∧ b ≤ 0) := by rcases lt_or_ge a 0 with ha0 | ha0 · rcases lt_or_ge 0 b with hb0 | hb0 · left; exact ⟨ha0, hb0⟩ · right; right; exact ⟨hab, hb0⟩ · right; left; exact ⟨ha0, hab⟩ have hpos_strict : ∀ x ∈ Set.Ioo (0 : ℝ) 1, 0 < 2 / (1 - x ^ 2) - 2 * J := by intro x hx have h1mx2 : 0 < 1 - x ^ 2 := by nlinarith [hx.1, hx.2] rw [sub_pos, lt_div_iff₀ h1mx2]; nlinarith [sq_pos_of_pos hx.1] have hneg_strict : ∀ x ∈ Set.Ioo (-1 : ℝ) 0, 0 < 2 / (1 - x ^ 2) - 2 * J := by intro x hx have h1mx2 : 0 < 1 - x ^ 2 := by nlinarith [hx.1, hx.2] rw [sub_pos, lt_div_iff₀ h1mx2]; nlinarith [sq_pos_of_neg hx.2] have hsm_pos : StrictMonoOn (fun x => Real.log ((1 + x) / (1 - x)) - 2 * J * x) (Set.Ico 0 1) := strictMonoOn_of_deriv_pos (convex_Ico 0 1) (fun x hx => (hasDerivAt_isingPhi' J (by linarith [hx.1]) hx.2).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Ico] at hx rw [(hasDerivAt_isingPhi' J (by linarith [hx.1]) hx.2).deriv] exact hpos_strict x hx) have hsm_neg : StrictMonoOn (fun x => Real.log ((1 + x) / (1 - x)) - 2 * J * x) (Set.Ioc (-1) 0) := strictMonoOn_of_deriv_pos (convex_Ioc (-1) 0) (fun x hx => (hasDerivAt_isingPhi' J hx.1 (by linarith [hx.2])).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Ioc] at hx rw [(hasDerivAt_isingPhi' J hx.1 (by linarith [hx.2])).deriv] exact hneg_strict x hx) rcases h0 with ⟨ha0, hb0⟩ | ⟨ha0, _⟩ | ⟨_, hb0⟩ · exact lt_trans (hsm_neg ⟨ha.1, ha0.le⟩ ⟨by norm_num, le_rfl⟩ ha0) (hsm_pos ⟨le_rfl, by norm_num⟩ ⟨hb0.le, hb.2⟩ hb0) · exact hsm_pos ⟨ha0, ha.2⟩ ⟨by linarith, hb.2⟩ hab · exact hsm_neg ⟨ha.1, by linarith⟩ ⟨hb.1, hb0⟩ hab have hphi_ge : ∀ m, -1 < m → m < 1 → 0 ≤ isingPhi J m ∧ (isingPhi J m = 0 ↔ m = 0) := by intro m hm1 hm2 have hphi0 : isingPhi J 0 = 0 := by simp [isingPhi] have hphi'0 : Real.log ((1 + (0 : ℝ)) / (1 - 0)) - 2 * J * 0 = 0 := by simp have hsm_pos : StrictMonoOn (isingPhi J) (Set.Ico 0 1) := strictMonoOn_of_deriv_pos (convex_Ico 0 1) (fun x hx => (hasDerivAt_isingPhi J (by linarith [hx.1]) hx.2).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Ico] at hx rw [(hasDerivAt_isingPhi J (by linarith [hx.1]) hx.2).deriv, ← hphi'0] exact hphi'_strict ⟨by norm_num, by norm_num⟩ ⟨by linarith [hx.1], hx.2⟩ hx.1) rcases lt_trichotomy m 0 with hm | rfl | hm · have hgt : 0 < isingPhi J (-m) := by rw [← hphi0] exact hsm_pos ⟨le_rfl, by norm_num⟩ ⟨by linarith, by linarith⟩ (by linarith) rw [isingPhi_even] at hgt exact ⟨hgt.le, ⟨fun h => absurd h hgt.ne', fun h => absurd h hm.ne⟩⟩ · exact ⟨by rw [hphi0], ⟨fun _ => rfl, fun _ => hphi0⟩⟩ · have hgt : 0 < isingPhi J m := by rw [← hphi0] exact hsm_pos ⟨le_rfl, by norm_num⟩ ⟨hm.le, hm2⟩ hm exact ⟨hgt.le, ⟨fun h => absurd h hgt.ne', fun h => absurd h hm.ne'⟩⟩ have h1 := hphi_ge m₁ hm₁1 hm₁2 have h2 := hphi_ge m₂ hm₂1 hm₂2 have hsq : 0 ≤ (J / 2) * (m₁ - m₂) ^ 2 := mul_nonneg (by linarith) (sq_nonneg _) constructor · linarith [h1.1, h2.1] · constructor · intro heq have hp1 : isingPhi J m₁ = 0 := by linarith [h1.1, h2.1, hsq] have hp2 : isingPhi J m₂ = 0 := by linarith [h1.1, h2.1, hsq] exact ⟨h1.2.mp hp1, h2.2.mp hp2⟩ · rintro ⟨rfl, rfl⟩ simp [isingPhi] /-- **Pillar 4C-3 (Supercritical Symmetry-Breaking Phase `J > 1`)**: For every `J > 1`: 1. There exists a **unique** positive spontaneous magnetization `m* ∈ (0, 1)` solving `m* = tanh(J m*)`. 2. Every product distribution `q_{m₁} ⊗ q_{m₂}` obeys `D_KL(q_{m₁} ⊗ q_{m₂} ‖ p_J) ≥ log(cosh J) + J (m*)² - 2 log(cosh(J m*))`, attained at the two symmetry-broken modes `m₁ = m₂ = ±m*`. 3. The symmetric marginal product `m₁ = m₂ = 0` is **strictly suboptimal**. -/ theorem ising_mf_supercritical_symmetry_breaking {J : ℝ} (hJ : 1 < J) : ∃! mstar : ℝ, mstar ∈ Set.Ioo (0 : ℝ) 1 ∧ mstar = Real.tanh (J * mstar) ∧ (∀ m₁ m₂, -1 < m₁ → m₁ < 1 → -1 < m₂ → m₂ < 1 → Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar)) ≤ klDiv (prodDist (magDist m₁) (magDist m₂)) (isingDist J)) ∧ klDiv (prodDist (magDist mstar) (magDist mstar)) (isingDist J) = Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar)) ∧ klDiv (prodDist (magDist (-mstar)) (magDist (-mstar))) (isingDist J) = Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar)) ∧ Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar)) < Real.log (Real.cosh J) := by let f' : ℝ → ℝ := fun x => Real.log ((1 + x) / (1 - x)) - 2 * J * x -- Inflection point m₀ = √(1 - 1/J) ∈ (0, 1) where 1 - m₀² = 1/J have h1mJ : 0 < 1 - 1 / J := by rw [sub_pos, div_lt_one (by linarith)]; exact hJ have h1mJ_lt1 : 1 - 1 / J < 1 := by have : 0 < 1 / J := div_pos one_pos (by linarith); linarith set m₀ := Real.sqrt (1 - 1 / J) have hm₀_pos : 0 < m₀ := Real.sqrt_pos.mpr h1mJ have hm₀_lt1 : m₀ < 1 := by calc m₀ = Real.sqrt (1 - 1 / J) := rfl _ < Real.sqrt 1 := Real.sqrt_lt_sqrt h1mJ.le h1mJ_lt1 _ = 1 := Real.sqrt_one have hm₀_sq : m₀ ^ 2 = 1 - 1 / J := Real.sq_sqrt h1mJ.le -- On [0, m₀], f'' < 0 on (0, m₀), so f' is strictly decreasing from f'(0) = 0 to f'(m₀) < 0 have hf'_anti : StrictAntiOn f' (Set.Icc 0 m₀) := by apply strictAntiOn_of_deriv_neg (convex_Icc 0 m₀) · intro x hx exact (hasDerivAt_isingPhi' J (by linarith [hx.1]) (by linarith [hx.2])).continuousAt.continuousWithinAt · intro x hx rw [interior_Icc] at hx rw [(hasDerivAt_isingPhi' J (by linarith [hx.1]) (by linarith [hx.2])).deriv] have h1mx2 : 0 < 1 - x ^ 2 := by nlinarith [hx.1, hx.2] have hlt : 1 / J < 1 - x ^ 2 := by have hx2 : x ^ 2 < m₀ ^ 2 := sq_lt_sq' (by linarith [hx.1]) hx.2 linarith [hm₀_sq] rw [sub_neg, div_lt_iff₀ h1mx2] have := (div_lt_iff₀ (show (0 : ℝ) < J by linarith)).mp hlt linarith have hf'0 : f' 0 = 0 := by simp [f'] have hf'_m₀_neg : f' m₀ < 0 := by rw [← hf'0]; exact hf'_anti ⟨le_rfl, hm₀_pos.le⟩ ⟨hm₀_pos.le, le_rfl⟩ hm₀_pos -- On [m₀, 1), f'' > 0 on (m₀, 1), so f' is strictly increasing have hf'_mono : StrictMonoOn f' (Set.Ico m₀ 1) := by apply strictMonoOn_of_deriv_pos (convex_Ico m₀ 1) · intro x hx exact (hasDerivAt_isingPhi' J (by linarith [hx.1]) hx.2).continuousAt.continuousWithinAt · intro x hx rw [interior_Ico] at hx rw [(hasDerivAt_isingPhi' J (by linarith [hx.1]) hx.2).deriv] have h1mx2 : 0 < 1 - x ^ 2 := by nlinarith [hx.1, hx.2] have hgt : 1 - x ^ 2 < 1 / J := by have hx2 : m₀ ^ 2 < x ^ 2 := sq_lt_sq' (by linarith [hx.1]) hx.1 linarith [hm₀_sq] rw [sub_pos, lt_div_iff₀ h1mx2] have := (lt_div_iff₀ (show (0 : ℝ) < J by linarith)).mp hgt linarith -- Construct m₁ ∈ (m₀, 1) with f'(m₁) > 0: take m₁ = max m₀ (1 - exp(-(2J + 1))) / ... wait: set m₁ := max ((m₀ + 1) / 2) (1 - Real.exp (-(2 * J + 1))) have hm₁_gt : m₀ < m₁ := lt_of_lt_of_le (by linarith) (le_max_left _ _) have hm₁_lt1 : m₁ < 1 := max_lt (by linarith) (by linarith [Real.exp_pos (-(2 * J + 1))]) have hf'_m₁_pos : 0 < f' m₁ := by have h1mm₁ : 1 - m₁ ≤ Real.exp (-(2 * J + 1)) := by have : 1 - Real.exp (-(2 * J + 1)) ≤ m₁ := le_max_right _ _ linarith have hdiv_gt : Real.exp (2 * J + 1) < (1 + m₁) / (1 - m₁) := by have hpos : 0 < 1 - m₁ := by linarith rw [lt_div_iff₀ hpos] have h1 : Real.exp (2 * J + 1) * (1 - m₁) ≤ Real.exp (2 * J + 1) * Real.exp (-(2 * J + 1)) := mul_le_mul_of_nonneg_left h1mm₁ (Real.exp_pos _).le rw [← Real.exp_add, add_neg_cancel, Real.exp_zero] at h1 linarith have hlog_gt : 2 * J + 1 < Real.log ((1 + m₁) / (1 - m₁)) := by rw [← Real.log_exp (2 * J + 1)] exact Real.log_lt_log (Real.exp_pos _) hdiv_gt dsimp [f']; nlinarith -- IVT on [m₀, m₁] gives root m* ∈ (m₀, m₁) have hf'_cont : ContinuousOn f' (Set.Icc m₀ m₁) := fun x hx => (hasDerivAt_isingPhi' J (by linarith [hx.1]) (by linarith [hx.2])).continuousAt.continuousWithinAt obtain ⟨mstar, hmstar_mem, hmstar_zero⟩ := intermediate_value_Icc hm₁_gt.le hf'_cont ⟨hf'_m₀_neg.le, hf'_m₁_pos.le⟩ have hmstar_gt_m₀ : m₀ < mstar := by rcases lt_or_eq_of_le hmstar_mem.1 with h | h · exact h · rw [← h] at hmstar_zero; linarith have hmstar_pos : 0 < mstar := lt_trans hm₀_pos hmstar_gt_m₀ have hmstar_lt1 : mstar < 1 := lt_of_le_of_lt hmstar_mem.2 hm₁_lt1 -- Equivalence: f'(m) = 0 ↔ m = tanh(J m) for m ∈ (-1, 1) have hroot_iff_tanh : ∀ m ∈ Set.Ioo (-1 : ℝ) 1, f' m = 0 ↔ m = Real.tanh (J * m) := by intro m hm have ha : 0 < 1 + m := by linarith [hm.1] have hb : 0 < 1 - m := by linarith [hm.2] dsimp [f'] rw [sub_eq_zero, Real.tanh_eq_sinh_div_cosh, Real.sinh_eq, Real.cosh_eq] have hsum_pos : 0 < Real.exp (J * m) + Real.exp (-(J * m)) := add_pos (Real.exp_pos _) (Real.exp_pos _) constructor · intro hlog have hexp : (1 + m) / (1 - m) = Real.exp (2 * J * m) := by rw [← Real.exp_log (div_pos ha hb), hlog] have hmul : (1 + m) * Real.exp (-(J * m)) = (1 - m) * Real.exp (J * m) := by have h1 := (div_eq_iff hb.ne').mp hexp have h2 : Real.exp (2 * J * m) = Real.exp (J * m) * Real.exp (J * m) := by rw [← Real.exp_add]; ring_nf have h3 : (1 + m) * Real.exp (-(J * m)) = (Real.exp (2 * J * m) * (1 - m)) * Real.exp (-(J * m)) := by rw [h1] have hcancel : Real.exp (J * m) * Real.exp (-(J * m)) = 1 := by rw [← Real.exp_add, add_neg_cancel, Real.exp_zero] calc (1 + m) * Real.exp (-(J * m)) = (Real.exp (J * m) * Real.exp (J * m) * (1 - m)) * Real.exp (-(J * m)) := by rw [h3, h2] _ = (1 - m) * Real.exp (J * m) * (Real.exp (J * m) * Real.exp (-(J * m))) := by ring _ = (1 - m) * Real.exp (J * m) := by rw [hcancel, mul_one] rw [div_div_div_cancel_right₀ (by norm_num : (2 : ℝ) ≠ 0)] exact (eq_div_iff hsum_pos.ne').mpr (by linarith) · intro htanh rw [div_div_div_cancel_right₀ (by norm_num : (2 : ℝ) ≠ 0)] at htanh have hcross : m * (Real.exp (J * m) + Real.exp (-(J * m))) = Real.exp (J * m) - Real.exp (-(J * m)) := (eq_div_iff hsum_pos.ne').mp htanh have hratio : (1 + m) / (1 - m) = Real.exp (2 * J * m) := by rw [div_eq_iff hb.ne'] have h2 : Real.exp (2 * J * m) * Real.exp (-(J * m)) = Real.exp (J * m) := by rw [← Real.exp_add]; ring_nf have hne : Real.exp (-(J * m)) ≠ 0 := (Real.exp_pos _).ne' apply mul_right_cancel₀ hne calc (1 + m) * Real.exp (-(J * m)) = (1 - m) * Real.exp (J * m) := by linarith _ = (1 - m) * (Real.exp (2 * J * m) * Real.exp (-(J * m))) := by rw [h2] _ = Real.exp (2 * J * m) * (1 - m) * Real.exp (-(J * m)) := by ring rw [hratio, Real.log_exp] have hmstar_tanh : mstar = Real.tanh (J * mstar) := (hroot_iff_tanh mstar ⟨by linarith, hmstar_lt1⟩).mp hmstar_zero -- Value of Φ_J(m*) = J (m*)² - 2 log cosh(J m*) have hphi_mstar : isingPhi J mstar = J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar)) := by conv_lhs => rw [hmstar_tanh] rw [isingPhi_at_tanh, ← hmstar_tanh] ring -- Global minimality of m* on [0, 1): f' < 0 on (0, m*) and f' > 0 on (m*, 1) have hf'_neg_below : ∀ x ∈ Set.Ioo (0 : ℝ) mstar, f' x < 0 := by intro x hx rcases le_or_gt x m₀ with hle | hgt · rw [← hf'0]; exact hf'_anti ⟨le_rfl, hm₀_pos.le⟩ ⟨hx.1.le, hle⟩ hx.1 · rw [← hmstar_zero]; exact hf'_mono ⟨hgt.le, by linarith [hx.2]⟩ ⟨hmstar_gt_m₀.le, hmstar_lt1⟩ hx.2 have hf'_pos_above : ∀ x ∈ Set.Ioo mstar 1, 0 < f' x := by intro x hx rw [← hmstar_zero] exact hf'_mono ⟨hmstar_gt_m₀.le, hmstar_lt1⟩ ⟨by linarith [hx.1], hx.2⟩ hx.1 have hphi_anti : StrictAntiOn (isingPhi J) (Set.Icc 0 mstar) := strictAntiOn_of_deriv_neg (convex_Icc 0 mstar) (fun x hx => (hasDerivAt_isingPhi J (by linarith [hx.1]) (by linarith [hx.2])).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Icc] at hx rw [(hasDerivAt_isingPhi J (by linarith [hx.1]) (by linarith [hx.2])).deriv] exact hf'_neg_below x hx) have hphi_mono : StrictMonoOn (isingPhi J) (Set.Ico mstar 1) := strictMonoOn_of_deriv_pos (convex_Ico mstar 1) (fun x hx => (hasDerivAt_isingPhi J (by linarith [hx.1]) hx.2).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Ico] at hx rw [(hasDerivAt_isingPhi J (by linarith [hx.1]) hx.2).deriv] exact hf'_pos_above x hx) have hphi_min_all : ∀ m, -1 < m → m < 1 → isingPhi J mstar ≤ isingPhi J m := by intro m hm1 hm2 have hnonneg : ∀ x, 0 ≤ x → x < 1 → isingPhi J mstar ≤ isingPhi J x := by intro x hx0 hx1 rcases le_or_gt x mstar with hle | hgt · rcases eq_or_lt_of_le hle with rfl | hlt · exact le_rfl · exact (hphi_anti ⟨hx0, hlt.le⟩ ⟨hmstar_pos.le, le_rfl⟩ hlt).le · exact (hphi_mono ⟨le_rfl, hmstar_lt1⟩ ⟨hgt.le, hx1⟩ hgt).le rcases le_or_gt 0 m with hm0 | hm0 · exact hnonneg m hm0 hm2 · rw [← isingPhi_even J m]; exact hnonneg (-m) (by linarith) (by linarith) have hphi_lt_zero : isingPhi J mstar < 0 := by have h0 : isingPhi J 0 = 0 := by simp [isingPhi] rw [← h0] exact hphi_anti ⟨le_rfl, hmstar_pos.le⟩ ⟨hmstar_pos.le, le_rfl⟩ hmstar_pos refine ⟨mstar, ⟨⟨hmstar_pos, hmstar_lt1⟩, hmstar_tanh, ?_, ?_, ?_, ?_⟩, ?_⟩ · intro m₁ m₂ hm₁1 hm₁2 hm₂1 hm₂2 rw [ising_mf_kl_exact J hm₁1 hm₁2 hm₂1 hm₂2] have h1 := hphi_min_all m₁ hm₁1 hm₁2 have h2 := hphi_min_all m₂ hm₂1 hm₂2 have hsq : 0 ≤ (J / 2) * (m₁ - m₂) ^ 2 := mul_nonneg (by linarith) (sq_nonneg _) linarith [hphi_mstar] · rw [ising_mf_kl_exact J (by linarith) hmstar_lt1 (by linarith) hmstar_lt1, hphi_mstar]; ring · rw [ising_mf_kl_exact J (by linarith) (by linarith) (by linarith) (by linarith), isingPhi_even, hphi_mstar]; ring · linarith [hphi_mstar, hphi_lt_zero] · -- Uniqueness of positive root m' ∈ (0, 1) with m' = tanh(J m') intro m' ⟨hm'_mem, hm'_tanh, _⟩ have hf'm' : f' m' = 0 := (hroot_iff_tanh m' ⟨by linarith [hm'_mem.1], hm'_mem.2⟩).mpr hm'_tanh by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · exact (hf'_neg_below m' ⟨hm'_mem.1, hlt⟩).ne hf'm' · exact (hf'_pos_above m' ⟨hgt, hm'_mem.2⟩).ne' hf'm' /-- **Master Monotonicity Lemma for `u(x) = 2 log(cosh x) - x tanh x`**: `u(0) = 0` and `u'(x) = (sinh(2x) - 2x) / (2 cosh² x) > 0` for all `x > 0`, hence `u` is strictly increasing on `[0, ∞)`. -/ theorem isingDefectU_strictMono : StrictMonoOn isingDefectU (Set.Ici 0) := by have hderiv : ∀ x : ℝ, HasDerivAt isingDefectU (Real.tanh x - x / (Real.cosh x) ^ 2) x := by intro x have hc : Real.cosh x ≠ 0 := (Real.cosh_pos x).ne' have h1 : HasDerivAt (fun t => 2 * Real.log (Real.cosh t)) (2 * Real.tanh x) x := (((Real.hasDerivAt_log hc).comp x (Real.hasDerivAt_cosh x)).const_mul 2).congr_deriv (by rw [Real.tanh_eq_sinh_div_cosh]; field_simp [hc]) have htanh_d : HasDerivAt Real.tanh (1 / (Real.cosh x) ^ 2) x := by have hrew : Real.tanh = fun t => Real.sinh t / Real.cosh t := funext Real.tanh_eq_sinh_div_cosh rw [hrew] exact ((Real.hasDerivAt_sinh x).div (Real.hasDerivAt_cosh x) hc).congr_deriv (by have hsq : Real.cosh x ^ 2 - Real.sinh x ^ 2 = 1 := Real.cosh_sq_sub_sinh_sq x field_simp [hc]; linarith) have h2 : HasDerivAt (fun t => t * Real.tanh t) (Real.tanh x + x / (Real.cosh x) ^ 2) x := ((hasDerivAt_id x).mul htanh_d).congr_deriv (by simp only [id_eq]; ring) exact (h1.sub h2).congr_deriv (by ring) apply strictMonoOn_of_deriv_pos (convex_Ici 0) · intro x _; exact (hderiv x).continuousAt.continuousWithinAt · intro x hx rw [interior_Ici] at hx have hx0 : 0 < x := hx rw [(hderiv x).deriv] have hc : 0 < Real.cosh x := Real.cosh_pos x rw [Real.tanh_eq_sinh_div_cosh, sub_pos, div_lt_div_iff₀ (sq_pos_of_pos hc) hc] -- Need x * cosh x < sinh x * cosh² x ↔ 2x < sinh(2x) have hsinh_gt : ∀ y : ℝ, 0 < y → y < Real.sinh y := by intro y hy have hsm : StrictMonoOn (fun t => Real.sinh t - t) (Set.Ici 0) := by apply strictMonoOn_of_deriv_pos (convex_Ici 0) · intro t _; exact ((Real.hasDerivAt_sinh t).sub (hasDerivAt_id t)).continuousAt.continuousWithinAt · intro t ht rw [interior_Ici] at ht have htpos : 0 < t := ht have hd : HasDerivAt (fun s => Real.sinh s - s) (Real.cosh t - 1) t := (Real.hasDerivAt_sinh t).sub (hasDerivAt_id t) rw [hd.deriv] rw [sub_pos, Real.cosh_eq] have hexp_gt1 : 1 < Real.exp t := Real.one_lt_exp_iff.mpr htpos have hexp_inv : Real.exp (-t) = (Real.exp t)⁻¹ := Real.exp_neg t have hpos_e : 0 < Real.exp t := Real.exp_pos t rw [hexp_inv] have hsq : 0 < (Real.exp t - 1) ^ 2 := sq_pos_of_pos (by linarith) have hdiv : 2 < Real.exp t + (Real.exp t)⁻¹ := by have h1 : (Real.exp t + (Real.exp t)⁻¹ - 2) * Real.exp t = (Real.exp t - 1) ^ 2 := by field_simp [hpos_e.ne']; ring nlinarith linarith have h0 : Real.sinh 0 - 0 = 0 := by simp have hgt := hsm (Set.mem_Ici.mpr le_rfl) (Set.mem_Ici.mpr hy.le) hy linarith have hsinh2 : 2 * x < Real.sinh (2 * x) := hsinh_gt (2 * x) (by linarith) have hdouble : Real.sinh (2 * x) = 2 * Real.sinh x * Real.cosh x := Real.sinh_two_mul x nlinarith lemma isingDefectU_zero : isingDefectU 0 = 0 := by simp [isingDefectU] /-- **Pillar 4C-4 (Headline — Universal 1-Bit Ceiling & Strict Mutual-Information Dominance Across the Entire Ising Phase Diagram)**: 1. **Universal 1-Bit Mean-Field Ceiling**: For EVERY `J > 0`, there exists a product distribution (explicitly `m₁ = m₂ = tanh J`) with KL strictly below `log 2` — hence the optimal mean-field gap obeys `Δ_MF^Ising(J) < log 2` for ALL `J > 0` (while naive marginal-product KL `log(cosh J) → ∞`)! 2. **Exact Subcritical Dominance (`0 < J ≤ 1`)**: `Δ_MF^Ising(J) - I(J) = u(J) > 0`. 3. **Exact Supercritical Dominance & Symmetry-Breaking Gain (`J > 1`, `m* = tanh(J m*) ∈ (0, 1)`)**: - Exact Symmetry-Breaking Gain over symmetric marginal product: `log(cosh J) - Δ_MF^Ising(J) = u(J m*) > 0`. - Exact Dominance over Mutual Information: `Δ_MF^Ising(J) - I(J) = u(J) - u(J m*) > 0`! Thus `I(S₁; S₂) < Δ_MF^Ising(J) < min(log 2, log(cosh J))` for EVERY `J > 1`! -/ theorem ising_mf_universal_ceiling_and_mi_dominance {J : ℝ} (hJ : 0 < J) : -- (1) Explicit product witness (m = tanh J) strictly beats log 2 for ALL J > 0 klDiv (prodDist (magDist (Real.tanh J)) (magDist (Real.tanh J))) (isingDist J) < Real.log 2 -- (2) Subcritical dominance identity ∧ Real.log (Real.cosh J) - jointMI (isingDist J) = isingDefectU J ∧ 0 < isingDefectU J -- (3) Supercritical exact identities & strict sandwich for any m* ∈ (0, 1) with m* = tanh(J m*) ∧ (∀ mstar, 0 < mstar → mstar < 1 → mstar = Real.tanh (J * mstar) → let mf := Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar)) Real.log (Real.cosh J) - mf = isingDefectU (J * mstar) ∧ mf - jointMI (isingDist J) = isingDefectU J - isingDefectU (J * mstar) ∧ jointMI (isingDist J) < mf ∧ mf < Real.log (Real.cosh J)) := by have htanh_pos : 0 < Real.tanh J := by rw [Real.tanh_eq_sinh_div_cosh] exact div_pos (Real.sinh_pos_iff.mpr hJ) (Real.cosh_pos J) have htanh_lt1 : Real.tanh J < 1 := by rw [Real.tanh_eq_sinh_div_cosh, div_lt_one (Real.cosh_pos J), Real.sinh_eq, Real.cosh_eq] linarith [Real.exp_pos (-J)] have hceil : klDiv (prodDist (magDist (Real.tanh J)) (magDist (Real.tanh J))) (isingDist J) < Real.log 2 := by rw [ising_mf_kl_exact J (by linarith) htanh_lt1 (by linarith) htanh_lt1, isingPhi_at_tanh] have hlog2cosh : J < Real.log (2 * Real.cosh J) := by have hgt : Real.exp J < 2 * Real.cosh J := by rw [Real.cosh_eq]; linarith [Real.exp_pos (-J)] calc J = Real.log (Real.exp J) := (Real.log_exp J).symm _ < Real.log (2 * Real.cosh J) := Real.log_lt_log (Real.exp_pos J) hgt rw [Real.log_mul (by norm_num) (Real.cosh_pos J).ne'] at hlog2cosh have hquad : J * Real.tanh J * (2 - Real.tanh J) < J := by have hsq : 0 < (1 - Real.tanh J) ^ 2 := sq_pos_of_pos (by linarith) nlinarith linarith have hsub_id : Real.log (Real.cosh J) - jointMI (isingDist J) = isingDefectU J := by rw [ising_mi_exact]; unfold isingDefectU; ring have huJ_pos : 0 < isingDefectU J := by rw [← isingDefectU_zero] exact isingDefectU_strictMono (Set.mem_Ici.mpr le_rfl) (Set.mem_Ici.mpr hJ.le) hJ refine ⟨hceil, hsub_id, huJ_pos, ?_⟩ intro mstar hm0 hm1 hmtanh dsimp only have hJm_pos : 0 < J * mstar := mul_pos hJ hm0 have hJm_lt : J * mstar < J := by nlinarith have hgain : Real.log (Real.cosh J) - (Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar))) = isingDefectU (J * mstar) := by unfold isingDefectU rw [← hmtanh]; ring have hdom : (Real.log (Real.cosh J) + J * mstar ^ 2 - 2 * Real.log (Real.cosh (J * mstar))) - jointMI (isingDist J) = isingDefectU J - isingDefectU (J * mstar) := by rw [ising_mi_exact]; unfold isingDefectU rw [← hmtanh]; ring have hu_lt : isingDefectU (J * mstar) < isingDefectU J := isingDefectU_strictMono (Set.mem_Ici.mpr hJm_pos.le) (Set.mem_Ici.mpr hJ.le) hJm_lt have huJm_pos : 0 < isingDefectU (J * mstar) := by rw [← isingDefectU_zero] exact isingDefectU_strictMono (Set.mem_Ici.mpr le_rfl) (Set.mem_Ici.mpr hJm_pos.le) hJm_pos exact ⟨hgain, hdom, by linarith, by linarith⟩ end Pillar4MeanField end ActiveInference /-! ## Axiom Verification on All Headline Theorems -/ -- Core Information Theory & Pillar 1 (Variational Free Energy) #print axioms ActiveInference.pinsker_ineq #print axioms ActiveInference.two_mul_hellingerSq_le_klDiv #print axioms ActiveInference.klDiv_le_log_one_add_chiSqDiv #print axioms ActiveInference.DiscreteGenModel.vfe_eq_kl_add_surprise #print axioms ActiveInference.DiscreteGenModel.vfe_eq_complexity_sub_accuracy #print axioms ActiveInference.DiscreteGenModel.vfe_eq_energy_sub_entropy #print axioms ActiveInference.DiscreteGenModel.vfe_eq_surprise_iff #print axioms ActiveInference.DiscreteGenModel.vfe_curvature_sandwich #print axioms ActiveInference.temperedVFE_exact_gibbs_identity #print axioms ActiveInference.temperedVFE_min_iff #print axioms ActiveInference.sequential_bayes_surprise_telescoping -- Pillar 2 (Entropic Mirror Descent, Overconfidence Paradox & Predictive Coding) #print axioms ActiveInference.mirrorStep_pythagorean_identity #print axioms ActiveInference.mirrorStep_exact_kl_descent #print axioms ActiveInference.mirrorStep_vfe_monotone_descent #print axioms ActiveInference.mirrorStep_forward_kl_exact_contraction #print axioms ActiveInference.mirrorStep_jeffreys_exact_contraction #print axioms ActiveInference.mirrorStep_one_eq_exact #print axioms ActiveInference.mirrorIter_closed_form #print axioms ActiveInference.mirrorIter_T_step_contraction #print axioms ActiveInference.mirrorIter_T_step_vfe_le_forward_kl #print axioms ActiveInference.mirrorStep_no_uniform_vfe_contraction #print axioms ActiveInference.mirrorStep_rational_overconfidence_witness #print axioms ActiveInference.pcVFE_exact_excess #print axioms ActiveInference.pc_euclid_vs_natgrad_exact -- Pillar 3 (Expected Free Energy & Epistemic-vs-Pragmatic Phase Transitions) #print axioms ActiveInference.PolicyModel.epistemicValue_eq_mutualInfo #print axioms ActiveInference.PolicyModel.efe_eq_risk_add_ambiguity #print axioms ActiveInference.PolicyModel.efe_eq_pragmatic_sub_epistemic #print axioms ActiveInference.PolicyModel.efe_ge_ambiguity_and_iff #print axioms ActiveInference.efe_boltzmann_diff_exact #print axioms ActiveInference.efe_preference_precision_phase_transition #print axioms ActiveInference.softmax_policy_phase_transition #print axioms ActiveInference.binaryEntropy_le_log_two_sub_sq #print axioms ActiveInference.four_mul_log_two_le_binaryEntropy #print axioms ActiveInference.tmazeBSCPolicy_epistemicValue_eq #print axioms ActiveInference.tmaze_exploration_extinction_wall #print axioms ActiveInference.tmaze_belief_phase_transition_and_sandwich #print axioms ActiveInference.tmaze_explicit_phase_witnesses -- Pillar 4 (Mean-Field vs. Exact Bayes Variational Gap Bounds) #print axioms ActiveInference.forward_kl_meanField_exact #print axioms ActiveInference.reverse_kl_meanField_zero_iff_indep #print axioms ActiveInference.explainingAway_mf_gap_exact_min #print axioms ActiveInference.explainingAway_overconfidence_collapse #print axioms ActiveInference.explainingAway_mf_eq_tc_dim2 #print axioms ActiveInference.explainingAway_mf_strictly_exceeds_tc #print axioms ActiveInference.ising_mi_exact #print axioms ActiveInference.ising_mf_kl_exact #print axioms ActiveInference.ising_mf_subcritical_exact #print axioms ActiveInference.ising_mf_supercritical_symmetry_breaking #print axioms ActiveInference.isingDefectU_strictMono #print axioms ActiveInference.ising_mf_universal_ceiling_and_mi_dominance