import Mathlib /-! # Exact Minimax Theory of Multiclass Online Probability Forecasting Under Proper Scoring Rules This file formalizes the complete, non-asymptotic, arbitrary-label-space minimax theory of realizable multiclass online probability forecasting under the canonical families of strictly proper scoring rules: 1. **Multiclass Brier (Quadratic) Score** `L_Brier(p, y) = (1/2) * ‖p - e_y‖₂²`, 2. **Multiclass Spherical Score** `L_Sph(p, y) = 1 - p_y / ‖p‖₂`, 3. **Good's (1971) / Gneiting–Raftery (2007) Pseudospherical Family** (`q ≥ 1`, conjugate order `γ = q / (q - 1)`), continuously interpolating randomized 0–1 classification (`q = 1`, `RLdim`) and Spherical score (`q = 2`, `SphOpt`) through all `q ∈ [1, ∞)`. ## Headline Verified Discoveries 1. **Exact Multiclass Water-Filling & Self-Dual Brier Duality (`brierVal_le_iff`, `brierVal_primal_upper`, `brierVal_dual_lower`, `brierVal_eq_active_variance`, `online_brier_minimax_exact`)**: By the exact Bregman strict-propriety identity, the optimal Brier forecast `p*` is ITSELF the exact minimax dual adversary (`ν* = p*`), achieving the exact active-set variance formula `brierVal S v = mean_A(v) + (1/2)*(1 - 1/|A|) + (1/2)*∑_{y ∈ A} (v y - mean_A(v))²`. 2. **Exact Multiclass Pseudospherical / Spherical Duality (`psphVal_le_iff`, `psphVal_primal_upper`, `psphVal_dual_lower`, `online_psph_minimax_exact`)**: Exact primal-dual saddle point via Hölder's inequality for every `q ≥ 1` and arbitrary `β`. 3. **Non-Pointwise Universal Minimax Hierarchy (`BrierOpt_le_SphOpt`, `brier_not_pointwise_le_sph`, `BrierOpt_ge_half_RLdim`, `PsphOpt_ge_alpha_mul_RLdim`)**: Even though pointwise `L_Brier(p, y) > L_Sph(p, y)` occurs (e.g. `p = (3/4, 1/4)`), Cauchy–Schwarz + AM-GM yields the universal multiclass minimax chain for EVERY finite concept class `V` over ANY `β`: `(1/2) * RLdim V ≤ BrierOpt V ≤ SphOpt V ≤ RLdim V`, `(1/2) * SphOpt V ≤ BrierOpt V`, and `2 * (1 - 2^(-1/q)) * RLdim V ≤ PsphOpt q V ≤ RLdim V` (at `q = 2`: `(2 - √2) * RLdim V ≤ SphOpt V`). 4. **Universal Multiclass Brier Halving Theorem (`multiclass_brier_simplex_ineq`, `BrierOpt_le_quarter_log2_card`, `BrierOpt_beats_vovk_by_27pct`)**: Via the elementary subadditivity merging law `16^a + 16^b ≥ 16^(a + b - a*b)` (`a + b ≤ 1`) yielding `4^(1 + ∑ p²) ≤ ∑ 16^p` on every probability simplex `Δ(S)`, EVERY multiclass `V` satisfies `BrierOpt V ≤ (1 / (4 * log 2)) * log |V|` — beating Vovk's classical `(1/2) * log |V|` multiclass Brier aggregating bound by **> 27.8%** with zero dependence on `|β|`! 5. **Universal Multiclass Pseudospherical & Spherical Halving Theorem (`PsphOpt_le_log_card`, `SphOpt_le_log_card`, `SphOpt_beats_vovk_by_15pct`)**: Via strict concavity of `K(t) = (1 - t) t^(1/q) + t (1 - t)^(1/q)` and subadditivity `φ_q(a) + φ_q(b) ≥ φ_q(a + b)`, EVERY multiclass `V` and EVERY `q ≥ 1` satisfy `PsphOpt q V ≤ ((1 - 2^(-1/q)) / log 2) * log |V|`, specializing at `q = 2` to `SphOpt V ≤ ((1 - 1/√2) / log 2) * log |V|` — beating Vovk's classical `(1/2) * log |V|` spherical mixability bound by **> 15.4%** with zero dependence on `|β|`! 6. **Product Additivity, `r`-ary Cube Sharpness, & Binary Singletons Separation**: Exact product additivity, exact closed forms on `cubeClass r d` proving sharpness of every constant, and an exponential-vs-polynomial gap-to-1 separation on `binSingletonSub I`: `1 - RLdim = 2^(-n)` vs. `2 / (n + 2) ≤ 1 - SphOpt ≤ 1 - BrierOpt ≤ 4 / (n + 4)`. -/ noncomputable section open scoped BigOperators open Finset namespace ProperScoringMinimax /-! ## Part 1: Exact Multiclass Brier Score Minimax Duality (Water-Filling & Self-Dual Adversary) -/ /-- Normalized multiclass Brier (quadratic) proper scoring rule on `S`: `brierLoss S p y = (1/2) * ‖p - e_y‖₂² = (1 - 2 * p y + ∑ z ∈ S, (p z)²) / 2`. -/ def brierLoss {β : Type*} (S : Finset β) (p : β → ℝ) (y : β) : ℝ := (1 - 2 * p y + ∑ z ∈ S, p z ^ 2) / 2 /-- **Exact Bregman Strict-Propriety Identity for Multiclass Brier Score**: for ANY probability distribution `q` on `S` (`∑ y ∈ S, q y = 1`) and ANY `p : β → ℝ`, `∑ y ∈ S, q y * brierLoss S p y = ∑ y ∈ S, q y * brierLoss S q y + (1/2) * ∑ y ∈ S, (p y - q y)²`. -/ theorem brier_proper_identity {β : Type*} (S : Finset β) (p q : β → ℝ) (hq_sum : ∑ y ∈ S, q y = 1) : ∑ y ∈ S, q y * brierLoss S p y = ∑ y ∈ S, q y * brierLoss S q y + (∑ y ∈ S, (p y - q y) ^ 2) / 2 := by have h1 : ∀ f : β → ℝ, ∑ y ∈ S, q y * brierLoss S f y = (1 - 2 * (∑ y ∈ S, q y * f y) + ∑ z ∈ S, f z ^ 2) / 2 := by intro f have heq : ∑ y ∈ S, q y * brierLoss S f y = (∑ y ∈ S, (q y * (1 + ∑ z ∈ S, f z ^ 2) - 2 * (q y * f y))) / 2 := by rw [Finset.sum_div] refine Finset.sum_congr rfl fun y _ => ?_ dsimp only [brierLoss]; ring rw [heq, Finset.sum_sub_distrib, ← Finset.sum_mul, hq_sum, one_mul, ← Finset.mul_sum] ring rw [h1 p, h1 q] have hexp : ∑ y ∈ S, (p y - q y) ^ 2 = (∑ y ∈ S, p y ^ 2) - 2 * (∑ y ∈ S, q y * p y) + ∑ y ∈ S, q y ^ 2 := by calc ∑ y ∈ S, (p y - q y) ^ 2 = ∑ y ∈ S, (p y ^ 2 - 2 * (q y * p y) + q y ^ 2) := Finset.sum_congr rfl fun y _ => by ring _ = (∑ y ∈ S, (p y ^ 2 - 2 * (q y * p y))) + ∑ y ∈ S, q y ^ 2 := Finset.sum_add_distrib _ = (∑ y ∈ S, p y ^ 2) - (∑ y ∈ S, 2 * (q y * p y)) + ∑ y ∈ S, q y ^ 2 := by rw [Finset.sum_sub_distrib] _ = (∑ y ∈ S, p y ^ 2) - 2 * (∑ y ∈ S, q y * p y) + ∑ y ∈ S, q y ^ 2 := by rw [← Finset.mul_sum] have hq_sq : ∑ y ∈ S, q y * q y = ∑ y ∈ S, q y ^ 2 := Finset.sum_congr rfl fun y _ => by ring rw [hexp, hq_sq]; ring lemma brierLoss_nonneg {β : Type*} [DecidableEq β] {S : Finset β} {p : β → ℝ} {y : β} (hy : y ∈ S) : 0 ≤ brierLoss S p y := by dsimp only [brierLoss] have h1 : p y ^ 2 ≤ ∑ z ∈ S, p z ^ 2 := Finset.single_le_sum (fun z _ => sq_nonneg (p z)) hy have hsq : 0 ≤ (1 - p y) ^ 2 := sq_nonneg _ linarith lemma brierLoss_le_one_sub {β : Type*} [DecidableEq β] {S : Finset β} {p : β → ℝ} (hp0 : ∀ z ∈ S, 0 ≤ p z) (hp_sum : ∑ z ∈ S, p z = 1) {y : β} (_hy : y ∈ S) : brierLoss S p y ≤ 1 - p y := by dsimp only [brierLoss] have hle1 : ∀ z ∈ S, p z ≤ 1 := fun z hz => by calc p z ≤ ∑ w ∈ S, p w := Finset.single_le_sum hp0 hz _ = 1 := hp_sum have hsq_le : ∑ z ∈ S, p z ^ 2 ≤ 1 := by calc ∑ z ∈ S, p z ^ 2 ≤ ∑ z ∈ S, p z := Finset.sum_le_sum fun z hz => by nlinarith [hp0 z hz, hle1 z hz] _ = 1 := hp_sum linarith /-- The water-filling threshold `λ*(S, v) = inf { λ | ∑_{y ∈ S} max(0, v y - λ) ≤ 1 }`. -/ def wfThreshold {β : Type*} (S : Finset β) (v : β → ℝ) : ℝ := sInf { lam : ℝ | ∑ y ∈ S, max 0 (v y - lam) ≤ 1 } lemma wfThreshold_set_nonempty {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ({ lam : ℝ | ∑ y ∈ S, max 0 (v y - lam) ≤ 1 }).Nonempty := by refine ⟨S.sup' hS v, ?_⟩ change ∑ y ∈ S, max 0 (v y - S.sup' hS v) ≤ 1 have hzero : ∀ y ∈ S, max 0 (v y - S.sup' hS v) = 0 := fun y hy => max_eq_left (sub_nonpos.mpr (Finset.le_sup' v hy)) rw [Finset.sum_eq_zero hzero]; norm_num lemma wfThreshold_set_bddBelow {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : BddBelow { lam : ℝ | ∑ y ∈ S, max 0 (v y - lam) ≤ 1 } := by refine ⟨S.sup' hS v - 1, fun lam hlam => ?_⟩ change ∑ y ∈ S, max 0 (v y - lam) ≤ 1 at hlam obtain ⟨y0, hy0, hy0_eq⟩ := Finset.exists_mem_eq_sup' hS v have h1 : v y0 - lam ≤ ∑ y ∈ S, max 0 (v y - lam) := le_trans (le_max_right 0 (v y0 - lam)) (Finset.single_le_sum (fun y _ => le_max_left 0 (v y - lam)) hy0) linarith lemma wfThreshold_set_isClosed {β : Type*} (S : Finset β) (v : β → ℝ) : IsClosed { lam : ℝ | ∑ y ∈ S, max 0 (v y - lam) ≤ 1 } := by have hcont : Continuous (fun lam : ℝ => ∑ y ∈ S, max 0 (v y - lam)) := continuous_finsetSum S fun y _ => continuous_const.max (continuous_const.sub continuous_id) exact isClosed_le hcont continuous_const /-- **Exact Water-Filling Normalization**: at `λ* = wfThreshold S v`, `∑ y ∈ S, max 0 (v y - λ*) = 1`! -/ theorem wfThreshold_sum_eq_one {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∑ y ∈ S, max 0 (v y - wfThreshold S v) = 1 := by set lam := wfThreshold S v have hmem : ∑ y ∈ S, max 0 (v y - lam) ≤ 1 := (wfThreshold_set_isClosed S v).csInf_mem (wfThreshold_set_nonempty hS v) (wfThreshold_set_bddBelow hS v) apply le_antisymm hmem by_contra hlt push Not at hlt have hcont : ContinuousAt (fun l : ℝ => ∑ y ∈ S, max 0 (v y - l)) lam := (continuous_finsetSum S fun y _ => continuous_const.max (continuous_const.sub continuous_id)).continuousAt have hev := hcont.eventually (gt_mem_nhds hlt) rcases Metric.eventually_nhds_iff.mp hev with ⟨δ, hδ_pos, hδ⟩ set l' := lam - δ / 2 have hdist : dist l' lam < δ := by rw [Real.dist_eq]; dsimp only [l'] rw [show lam - δ / 2 - lam = -(δ / 2) by ring, abs_neg, abs_of_pos (by linarith)] linarith have hl' : ∑ y ∈ S, max 0 (v y - l') ≤ 1 := le_of_lt (hδ hdist) have hle : lam ≤ l' := csInf_le (wfThreshold_set_bddBelow hS v) hl' dsimp only [l'] at hle; linarith /-- Optimal water-filling forecast `p*(y) = max 0 (v y - wfThreshold S v)`. -/ def wfForecast {β : Type*} (S : Finset β) (v : β → ℝ) : β → ℝ := fun y => max 0 (v y - wfThreshold S v) lemma wfForecast_nonneg {β : Type*} (S : Finset β) (v : β → ℝ) (y : β) : 0 ≤ wfForecast S v y := le_max_left 0 _ lemma wfForecast_sum_eq_one {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∑ y ∈ S, wfForecast S v y = 1 := wfThreshold_sum_eq_one hS v /-- **Exact 1-Round Multiclass Brier Minimax Operator**: `brierVal S v = wfThreshold S v + 1/2 + (1/2) * ∑ y ∈ S, (wfForecast S v y)²` (for `S.Nonempty`). -/ def brierVal {β : Type*} (S : Finset β) (v : β → ℝ) : ℝ := if S.Nonempty then wfThreshold S v + (1 + ∑ y ∈ S, wfForecast S v y ^ 2) / 2 else 0 /-- **1-Round Primal Achievability for Multiclass Brier Score**: the water-filling forecast `p* = wfForecast S v` achieves `v y + brierLoss S p* y ≤ brierVal S v` for every `y ∈ S`, with EXACT equality on `{y ∈ S | 0 < p* y}`! -/ theorem brierVal_primal_upper {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : (∀ y ∈ S, v y + brierLoss S (wfForecast S v) y ≤ brierVal S v) ∧ (∀ y ∈ S, 0 < wfForecast S v y → v y + brierLoss S (wfForecast S v) y = brierVal S v) := by rw [brierVal, if_pos hS] constructor · intro y _ dsimp only [brierLoss] have hge : v y - wfThreshold S v ≤ wfForecast S v y := le_max_right 0 _ linarith · intro y _ hpos dsimp only [brierLoss, wfForecast] at hpos ⊢ have heq : max 0 (v y - wfThreshold S v) = v y - wfThreshold S v := by rcases le_total 0 (v y - wfThreshold S v) with h | h · exact max_eq_right h · rw [max_eq_left h] at hpos; linarith rw [heq]; ring /-- **1-Round Self-Dual Adversary Lower Bound for Multiclass Brier Score**: the optimal forecast `p* = wfForecast S v` IS ITSELF the exact minimax dual adversary: for EVERY `p : β → ℝ` (not even constrained to `Δ(S)`!), `brierVal S v + (1/2) * ∑ y ∈ S, (p y - p* y)² = ∑ y ∈ S, p* y * (v y + brierLoss S p y)`! -/ theorem brierVal_dual_lower {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (p : β → ℝ) : brierVal S v ≤ ∑ y ∈ S, wfForecast S v y * (v y + brierLoss S p y) := by have hsum1 := wfForecast_sum_eq_one hS v have hprop := brier_proper_identity S p (wfForecast S v) hsum1 have hsplit : ∑ y ∈ S, wfForecast S v y * (v y + brierLoss S p y) = (∑ y ∈ S, wfForecast S v y * v y) + ∑ y ∈ S, wfForecast S v y * brierLoss S p y := by rw [← Finset.sum_add_distrib] exact Finset.sum_congr rfl fun y _ => by ring have hsplit_star : ∑ y ∈ S, wfForecast S v y * (v y + brierLoss S (wfForecast S v) y) = (∑ y ∈ S, wfForecast S v y * v y) + ∑ y ∈ S, wfForecast S v y * brierLoss S (wfForecast S v) y := by rw [← Finset.sum_add_distrib] exact Finset.sum_congr rfl fun y _ => by ring have hconst : ∑ y ∈ S, wfForecast S v y * (v y + brierLoss S (wfForecast S v) y) = brierVal S v := by calc ∑ y ∈ S, wfForecast S v y * (v y + brierLoss S (wfForecast S v) y) = ∑ y ∈ S, wfForecast S v y * brierVal S v := by refine Finset.sum_congr rfl fun y hy => ?_ by_cases hpos : 0 < wfForecast S v y · rw [(brierVal_primal_upper hS v).2 y hy hpos] · have hzero : wfForecast S v y = 0 := le_antisymm (not_lt.mp hpos) (wfForecast_nonneg S v y) rw [hzero, zero_mul, zero_mul] _ = (∑ y ∈ S, wfForecast S v y) * brierVal S v := (Finset.sum_mul _ _ _).symm _ = brierVal S v := by rw [hsum1, one_mul] have hsq_nn : 0 ≤ (∑ y ∈ S, (p y - wfForecast S v y) ^ 2) / 2 := div_nonneg (Finset.sum_nonneg fun y _ => sq_nonneg _) (by norm_num) linarith /-- **Exact Primal-Dual Feasibility Equivalence for Multiclass Brier Score**: `brierVal S v ≤ t ↔ ∃ p ∈ Δ(S), ∀ y ∈ S, v y + brierLoss S p y ≤ t`. -/ theorem brierVal_le_iff {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (t : ℝ) : brierVal S v ≤ t ↔ ∃ p : β → ℝ, (∀ y ∈ S, 0 ≤ p y) ∧ (∑ y ∈ S, p y = 1) ∧ ∀ y ∈ S, v y + brierLoss S p y ≤ t := by constructor · intro hle exact ⟨wfForecast S v, fun y _ => wfForecast_nonneg S v y, wfForecast_sum_eq_one hS v, fun y hy => le_trans ((brierVal_primal_upper hS v).1 y hy) hle⟩ · rintro ⟨p, _, _, hp⟩ calc brierVal S v ≤ ∑ y ∈ S, wfForecast S v y * (v y + brierLoss S p y) := brierVal_dual_lower hS v p _ ≤ ∑ y ∈ S, wfForecast S v y * t := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left (hp y hy) (wfForecast_nonneg S v y) _ = (∑ y ∈ S, wfForecast S v y) * t := (Finset.sum_mul _ _ _).symm _ = t := by rw [wfForecast_sum_eq_one hS v, one_mul] /-- **Exact Active-Set Variance Formula for Multiclass Brier Score**: on the active support `A = {y ∈ S | wfThreshold S v < v y}` (`A.Nonempty`), `brierVal S v = mean_A(v) + (1/2) * (1 - 1/|A|) + (1/2) * ∑_{y ∈ A} (v y - mean_A(v))²`! -/ theorem brierVal_eq_active_variance {β : Type*} [DecidableEq β] {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : let A := S.filter fun y => wfThreshold S v < v y let mean := (∑ y ∈ A, v y) / (A.card : ℝ) A.Nonempty ∧ brierVal S v = mean + (1 - 1 / (A.card : ℝ)) / 2 + (∑ y ∈ A, (v y - mean) ^ 2) / 2 := by set lam := wfThreshold S v set A := S.filter fun y => lam < v y have hwf_eq : ∀ y ∈ A, wfForecast S v y = v y - lam := by intro y hy have hlt := (Finset.mem_filter.mp hy).2 exact max_eq_right (sub_nonneg.mpr (le_of_lt hlt)) have hwf_zero : ∀ y ∈ S, y ∉ A → wfForecast S v y = 0 := by intro y hy hnot have hle : v y ≤ lam := by by_contra hlt; push Not at hlt exact hnot (Finset.mem_filter.mpr ⟨hy, hlt⟩) exact max_eq_left (sub_nonpos.mpr hle) have hsumA : ∑ y ∈ A, (v y - lam) = 1 := by calc ∑ y ∈ A, (v y - lam) = ∑ y ∈ A, wfForecast S v y := Finset.sum_congr rfl fun y hy => (hwf_eq y hy).symm _ = ∑ y ∈ S, wfForecast S v y := Finset.sum_subset (Finset.filter_subset _ S) fun y hy hnot => hwf_zero y hy hnot _ = 1 := wfForecast_sum_eq_one hS v have hA_ne : A.Nonempty := by by_contra hemp rw [Finset.not_nonempty_iff_eq_empty] at hemp rw [hemp, Finset.sum_empty] at hsumA; norm_num at hsumA have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA_ne.card_pos have hcard_ne : (A.card : ℝ) ≠ 0 := ne_of_gt hcard_pos set mean := (∑ y ∈ A, v y) / (A.card : ℝ) have hlam_eq : lam = mean - 1 / (A.card : ℝ) := by have hs : ∑ y ∈ A, v y - (A.card : ℝ) * lam = 1 := by have := hsumA rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] at this exact this dsimp only [mean] apply mul_left_cancel₀ hcard_ne rw [mul_sub, mul_div_cancel₀ _ hcard_ne, mul_one_div_cancel hcard_ne] linarith have hsq_eq : ∑ y ∈ S, wfForecast S v y ^ 2 = (∑ y ∈ A, (v y - mean) ^ 2) + 1 / (A.card : ℝ) := by have h1 : ∑ y ∈ S, wfForecast S v y ^ 2 = ∑ y ∈ A, (v y - lam) ^ 2 := by rw [← Finset.sum_subset (Finset.filter_subset _ S) (fun y hy hnot => by rw [hwf_zero y hy hnot]; norm_num)] exact Finset.sum_congr rfl fun y hy => by rw [hwf_eq y hy] rw [h1] have hcent : ∑ y ∈ A, (v y - mean) = 0 := by rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] dsimp only [mean]; rw [mul_div_cancel₀ _ hcard_ne, sub_self] calc ∑ y ∈ A, (v y - lam) ^ 2 = ∑ y ∈ A, ((v y - mean) + 1 / (A.card : ℝ)) ^ 2 := Finset.sum_congr rfl fun y _ => by rw [hlam_eq]; ring _ = ∑ y ∈ A, ((v y - mean) ^ 2 + (2 / (A.card : ℝ)) * (v y - mean) + (1 / (A.card : ℝ)) ^ 2) := Finset.sum_congr rfl fun y _ => by ring _ = (∑ y ∈ A, (v y - mean) ^ 2) + (2 / (A.card : ℝ)) * (∑ y ∈ A, (v y - mean)) + ∑ _y ∈ A, (1 / (A.card : ℝ)) ^ 2 := by rw [Finset.sum_add_distrib, Finset.sum_add_distrib, ← Finset.mul_sum] _ = (∑ y ∈ A, (v y - mean) ^ 2) + 1 / (A.card : ℝ) := by rw [hcent, mul_zero, add_zero, Finset.sum_const, nsmul_eq_mul] congr 1; field_simp refine ⟨hA_ne, ?_⟩ rw [brierVal, if_pos hS, hsq_eq] change lam + (1 + ((∑ y ∈ A, (v y - mean) ^ 2) + 1 / (A.card : ℝ))) / 2 = mean + (1 - 1 / (A.card : ℝ)) / 2 + (∑ y ∈ A, (v y - mean) ^ 2) / 2 rw [hlam_eq] ring lemma brierVal_mono_v {β : Type*} {S : Finset β} {v w : β → ℝ} (hvw : ∀ y ∈ S, v y ≤ w y) : brierVal S v ≤ brierVal S w := by by_cases hS : S.Nonempty · rw [brierVal_le_iff hS] exact ⟨wfForecast S w, fun y _ => wfForecast_nonneg S w y, wfForecast_sum_eq_one hS w, fun y hy => by linarith [hvw y hy, (brierVal_primal_upper hS w).1 y hy]⟩ · simp [brierVal, hS] lemma brierVal_congr {β : Type*} {S : Finset β} {v w : β → ℝ} (hvw : ∀ y ∈ S, v y = w y) : brierVal S v = brierVal S w := le_antisymm (brierVal_mono_v fun y hy => le_of_eq (hvw y hy)) (brierVal_mono_v fun y hy => le_of_eq (hvw y hy).symm) lemma le_brierVal_of_mem {β : Type*} [DecidableEq β] {S : Finset β} {y : β} (hy : y ∈ S) (v : β → ℝ) : v y ≤ brierVal S v := by have hS : S.Nonempty := ⟨y, hy⟩ linarith [(brierVal_primal_upper hS v).1 y hy, brierLoss_nonneg (p := wfForecast S v) hy] lemma brierVal_add_const {β : Type*} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (c : ℝ) : brierVal S (fun y => v y + c) = brierVal S v + c := by apply le_antisymm · rw [brierVal_le_iff hS] exact ⟨wfForecast S v, fun y _ => wfForecast_nonneg S v y, wfForecast_sum_eq_one hS v, fun y hy => by linarith [(brierVal_primal_upper hS v).1 y hy]⟩ · have hle : brierVal S v ≤ brierVal S (fun y => v y + c) - c := by rw [brierVal_le_iff hS] exact ⟨wfForecast S (fun y => v y + c), fun y _ => wfForecast_nonneg S _ y, wfForecast_sum_eq_one hS _, fun y hy => by linarith [(brierVal_primal_upper hS (fun y => v y + c)).1 y hy]⟩ linarith lemma brierVal_const {β : Type*} [DecidableEq β] {S : Finset β} (hS : S.Nonempty) (c : ℝ) : brierVal S (fun _ => c) = c + (1 - 1 / (S.card : ℝ)) / 2 := by have hcard_pos : (0 : ℝ) < (S.card : ℝ) := Nat.cast_pos.mpr hS.card_pos have hcard_ne : (S.card : ℝ) ≠ 0 := ne_of_gt hcard_pos apply le_antisymm · rw [brierVal_le_iff hS] refine ⟨fun _ => 1 / (S.card : ℝ), fun _ _ => by positivity, by rw [Finset.sum_const, nsmul_eq_mul, mul_one_div_cancel hcard_ne], fun y _ => ?_⟩ dsimp only [brierLoss] rw [Finset.sum_const, nsmul_eq_mul] have hsq : (S.card : ℝ) * (1 / (S.card : ℝ)) ^ 2 = 1 / (S.card : ℝ) := by field_simp rw [hsq]; ring_nf; exact le_rfl · rcases brierVal_eq_active_variance hS (fun _ => c) with ⟨hA_ne, hval⟩ set A := S.filter fun y => wfThreshold S (fun _ => c) < c have hA_card_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA_ne.card_pos have hA_card_ne : (A.card : ℝ) ≠ 0 := ne_of_gt hA_card_pos have hmean : (∑ _y ∈ A, c) / (A.card : ℝ) = c := by rw [Finset.sum_const, nsmul_eq_mul, mul_div_cancel_left₀ c hA_card_ne] -- In fact A = S since wfThreshold < c (otherwise sum would be 0 ≠ 1)! have hlt_c : wfThreshold S (fun _ => c) < c := by rcases hA_ne with ⟨y, hy⟩; exact (Finset.mem_filter.mp hy).2 have hA_eq_S : A = S := Finset.filter_true_of_mem fun _ _ => hlt_c rw [hval, hmean, hA_eq_S] simp /-- Exact binary closed form of `brierVal` for `y₁ ≠ y₂`: equals `max v₁ v₂` when `|v₁ - v₂| ≥ 1`, else `(v₁ + v₂)/2 + 1/4 + (v₁ - v₂)² / 4`. -/ theorem brierVal_binary {β : Type*} [DecidableEq β] {y₁ y₂ : β} (hne : y₁ ≠ y₂) (v : β → ℝ) : brierVal ({y₁, y₂} : Finset β) v = if 1 ≤ |v y₁ - v y₂| then max (v y₁) (v y₂) else (v y₁ + v y₂) / 2 + 1 / 4 + (v y₁ - v y₂) ^ 2 / 4 := by have hS : ({y₁, y₂} : Finset β).Nonempty := ⟨y₁, by simp⟩ split_ifs with hdom · apply le_antisymm · rw [brierVal_le_iff hS] rcases le_total (v y₁) (v y₂) with h12 | h21 · have hd : 1 ≤ v y₂ - v y₁ := by rw [abs_of_nonpos (sub_nonpos.mpr h12)] at hdom; linarith refine ⟨fun y => if y = y₂ then 1 else 0, fun y _ => by dsimp only; split_ifs <;> norm_num, by rw [Finset.sum_pair hne]; simp [hne], fun y hy => ?_⟩ dsimp only [brierLoss] rw [Finset.sum_pair hne, max_eq_right h12] simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl <;> simp [hne] <;> linarith · have hd : 1 ≤ v y₁ - v y₂ := by rw [abs_of_nonneg (sub_nonneg.mpr h21)] at hdom; linarith refine ⟨fun y => if y = y₁ then 1 else 0, fun y _ => by dsimp only; split_ifs <;> norm_num, by rw [Finset.sum_pair hne]; simp [hne.symm], fun y hy => ?_⟩ dsimp only [brierLoss] rw [Finset.sum_pair hne, max_eq_left h21] simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl <;> simp [hne.symm] <;> linarith · exact max_le (le_brierVal_of_mem (by simp) v) (le_brierVal_of_mem (by simp) v) · push Not at hdom set p₁ := (1 + v y₁ - v y₂) / 2 set p₂ := (1 + v y₂ - v y₁) / 2 have hp₁_nn : 0 ≤ p₁ := by have := (abs_lt.mp hdom).1; dsimp only [p₁]; linarith have hp₂_nn : 0 ≤ p₂ := by have := (abs_lt.mp hdom).2; dsimp only [p₂]; linarith have hp_sum : p₁ + p₂ = 1 := by dsimp only [p₁, p₂]; ring set p : β → ℝ := fun y => if y = y₁ then p₁ else p₂ have hloss1 : v y₁ + brierLoss ({y₁, y₂} : Finset β) p y₁ = (v y₁ + v y₂) / 2 + 1 / 4 + (v y₁ - v y₂) ^ 2 / 4 := by dsimp only [brierLoss, p] rw [Finset.sum_pair hne]; simp only [↓reduceIte, hne.symm] dsimp only [p₁, p₂]; ring have hloss2 : v y₂ + brierLoss ({y₁, y₂} : Finset β) p y₂ = (v y₁ + v y₂) / 2 + 1 / 4 + (v y₁ - v y₂) ^ 2 / 4 := by dsimp only [brierLoss, p] rw [Finset.sum_pair hne]; simp only [↓reduceIte, hne.symm] dsimp only [p₁, p₂]; ring apply le_antisymm · rw [brierVal_le_iff hS] refine ⟨p, fun y hy => by simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl <;> simp [p, hne.symm, hp₁_nn, hp₂_nn], by rw [Finset.sum_pair hne]; simp [p, hne.symm, hp_sum], fun y hy => by simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl · exact le_of_eq hloss1 · exact le_of_eq hloss2⟩ · -- Lower bound: evaluate dual on q = p! have hp_eq : ∑ y ∈ ({y₁, y₂} : Finset β), p y = 1 := by rw [Finset.sum_pair hne]; simp [p, hne.symm, hp_sum] have hprop := brier_proper_identity ({y₁, y₂} : Finset β) (wfForecast ({y₁, y₂} : Finset β) v) p hp_eq have hsq_nn : 0 ≤ (∑ y ∈ ({y₁, y₂} : Finset β), (wfForecast ({y₁, y₂} : Finset β) v y - p y) ^ 2) / 2 := div_nonneg (Finset.sum_nonneg fun y _ => sq_nonneg _) (by norm_num) have hdual : ∑ y ∈ ({y₁, y₂} : Finset β), p y * (v y + brierLoss ({y₁, y₂} : Finset β) p y) ≤ ∑ y ∈ ({y₁, y₂} : Finset β), p y * (v y + brierLoss ({y₁, y₂} : Finset β) (wfForecast ({y₁, y₂} : Finset β) v) y) := by have h1 : ∀ f : β → ℝ, ∑ y ∈ ({y₁, y₂} : Finset β), p y * (v y + brierLoss ({y₁, y₂} : Finset β) f y) = (∑ y ∈ ({y₁, y₂} : Finset β), p y * v y) + ∑ y ∈ ({y₁, y₂} : Finset β), p y * brierLoss ({y₁, y₂} : Finset β) f y := by intro f; rw [← Finset.sum_add_distrib]; exact Finset.sum_congr rfl fun y _ => by ring rw [h1 p, h1 _]; linarith have hlhs : ∑ y ∈ ({y₁, y₂} : Finset β), p y * (v y + brierLoss ({y₁, y₂} : Finset β) p y) = (v y₁ + v y₂) / 2 + 1 / 4 + (v y₁ - v y₂) ^ 2 / 4 := by rw [Finset.sum_pair hne, hloss1, hloss2]; simp only [p, ↓reduceIte, hne.symm] rw [← add_mul, hp_sum, one_mul] have hrhs : ∑ y ∈ ({y₁, y₂} : Finset β), p y * (v y + brierLoss ({y₁, y₂} : Finset β) (wfForecast ({y₁, y₂} : Finset β) v) y) ≤ brierVal ({y₁, y₂} : Finset β) v := by calc _ ≤ ∑ y ∈ ({y₁, y₂} : Finset β), p y * brierVal ({y₁, y₂} : Finset β) v := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left ((brierVal_primal_upper hS v).1 y hy) (by simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl <;> simp [p, hne.symm, hp₁_nn, hp₂_nn]) _ = (∑ y ∈ ({y₁, y₂} : Finset β), p y) * brierVal ({y₁, y₂} : Finset β) v := (Finset.sum_mul _ _ _).symm _ = brierVal ({y₁, y₂} : Finset β) v := by rw [hp_eq, one_mul] linarith /-! ## Part 2: Exact Multiclass Pseudospherical & Spherical Proper Scoring Rule Duality (`q ≥ 1`) -/ /-- Feasibility predicate for the 1-round pseudospherical minimax operator of order `q ≥ 1`: `psphFeas q S v t ↔ (∀ y ∈ S, v y ≤ t) ∧ ∑ y ∈ S, (max 0 (v y + 1 - t))^q ≤ 1`. - `q = 1`: randomized 0–1 classification (`RLdim`)! - `q = 2`: multiclass Spherical proper scoring rule `L_Sph(p, y) = 1 - p_y / ‖p‖₂`! - General `q ≥ 1`: Good's (1971) pseudospherical proper scoring rule of order `γ = q / (q - 1)`! -/ def psphFeas {β : Type*} (q : ℝ) (S : Finset β) (v : β → ℝ) (t : ℝ) : Prop := (∀ y ∈ S, v y ≤ t) ∧ ∑ y ∈ S, (max 0 (v y + 1 - t)) ^ q ≤ 1 /-- Exact 1-round multiclass pseudospherical minimax operator (`q ≥ 1`). -/ def psphVal {β : Type*} (q : ℝ) (S : Finset β) (v : β → ℝ) : ℝ := if S.Nonempty then sInf { t : ℝ | psphFeas q S v t } else 0 lemma psphFeas_mono {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} {v : β → ℝ} {t₁ t₂ : ℝ} (h1 : psphFeas q S v t₁) (hle : t₁ ≤ t₂) : psphFeas q S v t₂ := by refine ⟨fun y hy => le_trans (h1.1 y hy) hle, le_trans ?_ h1.2⟩ refine Finset.sum_le_sum fun y _ => ?_ exact Real.rpow_le_rpow (le_max_left 0 _) (max_le_max_left 0 (by linarith)) (le_of_lt hq) lemma psphFeas_nonempty {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ({ t : ℝ | psphFeas q S v t }).Nonempty := by refine ⟨S.sup' hS v + 1, fun y hy => by linarith [Finset.le_sup' v hy], ?_⟩ have hzero : ∀ y ∈ S, (max 0 (v y + 1 - (S.sup' hS v + 1))) ^ q = 0 := fun y hy => by rw [max_eq_left (by linarith [Finset.le_sup' v hy]), Real.zero_rpow (ne_of_gt hq)] rw [Finset.sum_eq_zero hzero]; norm_num lemma psphFeas_bddBelow {β : Type*} {q : ℝ} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : BddBelow { t : ℝ | psphFeas q S v t } := by rcases hS with ⟨y0, hy0⟩ exact ⟨v y0, fun t ht => ht.1 y0 hy0⟩ lemma psphFeas_isClosed {β : Type*} {q : ℝ} (hq : 0 < q) (S : Finset β) (v : β → ℝ) : IsClosed { t : ℝ | psphFeas q S v t } := by have h1 : IsClosed { t : ℝ | ∀ y ∈ S, v y ≤ t } := by have heq : { t : ℝ | ∀ y ∈ S, v y ≤ t } = ⋂ y ∈ S, { t : ℝ | v y ≤ t } := by ext t; simp rw [heq] exact isClosed_biInter fun y _ => isClosed_Ici have hcont : Continuous (fun t : ℝ => ∑ y ∈ S, (max 0 (v y + 1 - t)) ^ q) := continuous_finsetSum S fun y _ => (continuous_const.max (continuous_const.sub continuous_id)).rpow_const fun _ => Or.inr (le_of_lt hq) exact h1.inter (isClosed_le hcont continuous_const) lemma psphVal_mem_feas {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : psphFeas q S v (psphVal q S v) := by rw [psphVal, if_pos hS] exact (psphFeas_isClosed hq S v).csInf_mem (psphFeas_nonempty hq hS v) (psphFeas_bddBelow hS v) /-- **Exact 1-Round Feasibility Equivalence for Multiclass Pseudospherical Scores (`q > 0`)**: `psphVal q S v ≤ t ↔ (∀ y ∈ S, v y ≤ t) ∧ ∑ y ∈ S, (max 0 (v y + 1 - t))^q ≤ 1`. -/ theorem psphVal_le_iff {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (t : ℝ) : psphVal q S v ≤ t ↔ psphFeas q S v t := ⟨fun hle => psphFeas_mono hq (psphVal_mem_feas hq hS v) hle, fun ht => by rw [psphVal, if_pos hS]; exact csInf_le (psphFeas_bddBelow hS v) ht⟩ /-- **1-Round Primal Achievability for Multiclass Pseudospherical Scores (`q > 0`)**: there exists `u : β → ℝ` with `u ≥ 0`, `∑ y ∈ S, u y ^ q ≤ 1`, and `v y + (1 - u y) ≤ psphVal q S v`! -/ theorem psphVal_primal_upper {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ u : β → ℝ, (∀ y ∈ S, 0 ≤ u y) ∧ (∑ y ∈ S, u y ^ q ≤ 1) ∧ ∀ y ∈ S, v y + (1 - u y) ≤ psphVal q S v := by rcases psphVal_mem_feas hq hS v with ⟨_, hsum⟩ refine ⟨fun y => max 0 (v y + 1 - psphVal q S v), fun _ _ => le_max_left 0 _, hsum, fun y _ => ?_⟩ linarith [le_max_right 0 (v y + 1 - psphVal q S v)] /-- **1-Round Exact Hölder-Conjugate Dual Adversary Lower Bound (`q ≥ 1`)**: for EVERY `q ≥ 1`, finite nonempty `S`, and `v : β → ℝ`, there exists a probability distribution `ν` on `S` such that for EVERY feasible `ℓ_q`-sphere forecast `u ≥ 0` (`∑ u^q ≤ 1`), `psphVal q S v ≤ ∑ y ∈ S, ν y * (v y + (1 - u y))`! -/ theorem psphVal_dual_lower {β : Type*} [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ ν : β → ℝ, (∀ y ∈ S, 0 ≤ ν y) ∧ (∑ y ∈ S, ν y = 1) ∧ ∀ u : β → ℝ, (∀ y ∈ S, 0 ≤ u y) → (∑ y ∈ S, u y ^ q ≤ 1) → psphVal q S v ≤ ∑ y ∈ S, ν y * (v y + (1 - u y)) := by have hq0 : 0 < q := by linarith set T := psphVal q S v -- Case 1: T = v y0 for some y0 ∈ S (point mass dual adversary!) by_cases hhit : ∃ y0 ∈ S, T ≤ v y0 · rcases hhit with ⟨y0, hy0, hT0⟩ refine ⟨fun y => if y = y0 then 1 else 0, fun y _ => by dsimp only; split_ifs <;> norm_num, by rw [Finset.sum_ite_eq' S y0, if_pos hy0], fun u hu0 husum => ?_⟩ rw [Finset.sum_eq_single y0 (fun y _ hne => by simp [hne]) (fun h => absurd hy0 h)] simp only [↓reduceIte, one_mul] have hu_le1 : u y0 ≤ 1 := by have h1 : u y0 ^ q ≤ 1 := le_trans (Finset.single_le_sum (fun z hz => Real.rpow_nonneg (hu0 z hz) q) hy0) husum by_contra hgt; push Not at hgt have hpow : (1 : ℝ) ^ q < u y0 ^ q := Real.rpow_lt_rpow zero_le_one hgt hq0 rw [Real.one_rpow] at hpow; linarith linarith -- Case 2: ∀ y ∈ S, v y < T (strict interior => ∑ (v y + 1 - T)_+^q = 1!) push Not at hhit set ustar : β → ℝ := fun y => max 0 (v y + 1 - T) have hustar_sum : ∑ y ∈ S, ustar y ^ q = 1 := by apply le_antisymm (psphVal_mem_feas hq0 hS v).2 by_contra hlt; push Not at hlt have hcont : ContinuousAt (fun t : ℝ => ∑ y ∈ S, (max 0 (v y + 1 - t)) ^ q) T := (continuous_finsetSum S fun y _ => (continuous_const.max (continuous_const.sub continuous_id)).rpow_const fun _ => Or.inr (le_of_lt hq0)).continuousAt have hM_lt : S.sup' hS v < T := (Finset.sup'_lt_iff hS).mpr hhit have hev := (hcont.eventually (gt_mem_nhds hlt)).and (Ioo_mem_nhds hM_lt (lt_add_one T)) rcases Metric.eventually_nhds_iff.mp hev with ⟨δ, hδ_pos, hδ⟩ set t' := T - δ / 2 have hdist : dist t' T < δ := by rw [Real.dist_eq]; dsimp only [t'] rw [show T - δ / 2 - T = -(δ / 2) by ring, abs_neg, abs_of_pos (by linarith)] linarith have ht' := hδ hdist have hfeas : psphFeas q S v t' := ⟨fun y hy => le_of_lt (lt_of_le_of_lt (Finset.le_sup' v hy) ht'.2.1), le_of_lt ht'.1⟩ have hle : T ≤ t' := (psphVal_le_iff hq0 hS v t').mpr hfeas dsimp only [t'] at hle; linarith -- Define active set A = {y ∈ S | 0 < ustar y} and dual weights w y = ustar y ^ (q - 1) on A! set A := S.filter fun y => 0 < ustar y have hA_ne : A.Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp have h0 : ∑ y ∈ S, ustar y ^ q = 0 := by refine Finset.sum_eq_zero fun y hy => ?_ have hle : ustar y ≤ 0 := by by_contra hpos; push Not at hpos have : y ∈ A := Finset.mem_filter.mpr ⟨hy, hpos⟩ rw [hemp] at this; exact Finset.notMem_empty y this rw [le_antisymm hle (le_max_left 0 _), Real.zero_rpow (ne_of_gt hq0)] linarith set w : β → ℝ := fun y => if y ∈ A then ustar y ^ (q - 1) else 0 have hw_nn : ∀ y ∈ S, 0 ≤ w y := fun y _ => by dsimp only [w]; split_ifs with h · exact Real.rpow_nonneg (le_of_lt (Finset.mem_filter.mp h).2) _ · exact le_rfl have hW_pos : 0 < ∑ y ∈ S, w y := by rcases hA_ne with ⟨y0, hy0⟩ have hy0S : y0 ∈ S := (Finset.mem_filter.mp hy0).1 have hpos0 : 0 < w y0 := by dsimp only [w]; rw [if_pos hy0] exact Real.rpow_pos_of_pos (Finset.mem_filter.mp hy0).2 _ exact lt_of_lt_of_le hpos0 (Finset.single_le_sum hw_nn hy0S) set W := ∑ y ∈ S, w y refine ⟨fun y => w y / W, fun y hy => div_nonneg (hw_nn y hy) (le_of_lt hW_pos), by rw [← Finset.sum_div, div_self (ne_of_gt hW_pos)], fun u hu0 husum => ?_⟩ -- Key identity on A: v y + (1 - ustar y) = T, and w y * ustar y = ustar y ^ q! have hwu_star : ∑ y ∈ S, w y * ustar y = 1 := by calc ∑ y ∈ S, w y * ustar y = ∑ y ∈ S, ustar y ^ q := by refine Finset.sum_congr rfl fun y hy => ?_ dsimp only [w] split_ifs with hA · have hpos := (Finset.mem_filter.mp hA).2 rw [← Real.rpow_add_one (ne_of_gt hpos)]; ring_nf · have hzero : ustar y = 0 := by by_contra hne have hpos : 0 < ustar y := lt_of_le_of_ne (le_max_left 0 _) (Ne.symm hne) exact hA (Finset.mem_filter.mpr ⟨hy, hpos⟩) rw [hzero, zero_mul, Real.zero_rpow (ne_of_gt hq0)] _ = 1 := hustar_sum -- Key Hölder inequality: ∑ y ∈ S, w y * u y ≤ 1! have hholder : ∑ y ∈ S, w y * u y ≤ 1 := by by_cases hq1 : q = 1 · subst hq1 calc ∑ y ∈ S, w y * u y ≤ ∑ y ∈ S, 1 * u y := by refine Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_right ?_ (hu0 y hy) dsimp only [w]; split_ifs · simp · norm_num _ = ∑ y ∈ S, u y ^ (1 : ℝ) := Finset.sum_congr rfl fun y _ => by simp _ ≤ 1 := husum · have hq_gt1 : 1 < q := lt_of_le_of_ne hq (Ne.symm hq1) -- Elementary Young's inequality: for a, b ≥ 0, a * b ≤ (1/q) * b^q + ((q-1)/q) * a^(q/(q-1))! -- Apply with a = w y, b = u y! have hconj : Real.HolderConjugate q (q / (q - 1)) := by rw [Real.holderConjugate_iff] refine ⟨hq_gt1, ?_⟩ have hq1_ne : q - 1 ≠ 0 := ne_of_gt (sub_pos.mpr hq_gt1) have hq_ne : q ≠ 0 := ne_of_gt hq0 field_simp; ring have hsum_young : ∑ y ∈ S, w y * u y ≤ (∑ y ∈ S, u y ^ q) / q + (∑ y ∈ S, w y ^ (q / (q - 1))) / (q / (q - 1)) := by have hterm : ∀ y ∈ S, w y * u y ≤ u y ^ q / q + w y ^ (q / (q - 1)) / (q / (q - 1)) := by intro y hy rw [mul_comm] exact Real.young_inequality_of_nonneg (hu0 y hy) (hw_nn y hy) hconj calc ∑ y ∈ S, w y * u y ≤ ∑ y ∈ S, (u y ^ q / q + w y ^ (q / (q - 1)) / (q / (q - 1))) := Finset.sum_le_sum hterm _ = (∑ y ∈ S, u y ^ q / q) + ∑ y ∈ S, w y ^ (q / (q - 1)) / (q / (q - 1)) := Finset.sum_add_distrib _ = (∑ y ∈ S, u y ^ q) / q + (∑ y ∈ S, w y ^ (q / (q - 1))) / (q / (q - 1)) := by rw [Finset.sum_div, Finset.sum_div] have hw_qstar : ∑ y ∈ S, w y ^ (q / (q - 1)) = 1 := by calc ∑ y ∈ S, w y ^ (q / (q - 1)) = ∑ y ∈ S, ustar y ^ q := by refine Finset.sum_congr rfl fun y hy => ?_ dsimp only [w]; split_ifs with hA · have hpos := (Finset.mem_filter.mp hA).2 rw [← Real.rpow_mul (le_of_lt hpos), mul_div_cancel₀ _ (ne_of_gt (sub_pos.mpr hq_gt1))] · have hzero : ustar y = 0 := by by_contra hne exact hA (Finset.mem_filter.mpr ⟨hy, lt_of_le_of_ne (le_max_left 0 _) (Ne.symm hne)⟩) have hqstar_pos : 0 < q / (q - 1) := div_pos hq0 (sub_pos.mpr hq_gt1) rw [hzero, Real.zero_rpow (ne_of_gt hqstar_pos), Real.zero_rpow (ne_of_gt hq0)] _ = 1 := hustar_sum rw [hw_qstar] at hsum_young have hdiv_le : (∑ y ∈ S, u y ^ q) / q ≤ 1 / q := div_le_div_of_nonneg_right husum (le_of_lt hq0) have hconj_sum : 1 / q + 1 / (q / (q - 1)) = 1 := by have hq1_ne : q - 1 ≠ 0 := ne_of_gt (sub_pos.mpr hq_gt1) have hq_ne : q ≠ 0 := ne_of_gt hq0 field_simp; ring linarith -- Combine: ∑ (w y / W) * (v y + 1 - u y) ≥ ∑ (w y / W) * (v y + 1 - ustar y) = T! have hwt : ∑ y ∈ S, w y * (v y + (1 - ustar y)) = W * T := by calc ∑ y ∈ S, w y * (v y + (1 - ustar y)) = ∑ y ∈ S, w y * T := by refine Finset.sum_congr rfl fun y _ => ?_ dsimp only [w]; split_ifs with hA · have hpos := (Finset.mem_filter.mp hA).2 have heq : ustar y = v y + 1 - T := by dsimp only [ustar] at hpos ⊢ rcases le_total 0 (v y + 1 - T) with h | h · exact max_eq_right h · rw [max_eq_left h] at hpos; linarith rw [heq]; ring · simp _ = (∑ y ∈ S, w y) * T := (Finset.sum_mul _ _ _).symm _ = W * T := rfl have hdiff : ∑ y ∈ S, w y * (v y + (1 - ustar y)) ≤ ∑ y ∈ S, w y * (v y + (1 - u y)) := by have hrew : ∀ f : β → ℝ, ∑ y ∈ S, w y * (v y + (1 - f y)) = (∑ y ∈ S, w y * (v y + 1)) - ∑ y ∈ S, w y * f y := by intro f; rw [← Finset.sum_sub_distrib]; exact Finset.sum_congr rfl fun y _ => by ring rw [hrew ustar, hrew u]; linarith have hsum_div : ∑ y ∈ S, (w y / W) * (v y + (1 - u y)) = (∑ y ∈ S, w y * (v y + (1 - u y))) / W := by rw [Finset.sum_div]; exact Finset.sum_congr rfl fun y _ => by ring rw [hsum_div, le_div_iff₀ hW_pos] linarith lemma psphVal_mono_v {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} {v w : β → ℝ} (hvw : ∀ y ∈ S, v y ≤ w y) : psphVal q S v ≤ psphVal q S w := by by_cases hS : S.Nonempty · rw [psphVal_le_iff hq hS] rcases psphVal_mem_feas hq hS w with ⟨h1, h2⟩ refine ⟨fun y hy => le_trans (hvw y hy) (h1 y hy), le_trans ?_ h2⟩ exact Finset.sum_le_sum fun y hy => Real.rpow_le_rpow (le_max_left 0 _) (max_le_max_left 0 (by linarith [hvw y hy])) (le_of_lt hq) · simp [psphVal, hS] lemma psphVal_congr {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} {v w : β → ℝ} (hvw : ∀ y ∈ S, v y = w y) : psphVal q S v = psphVal q S w := le_antisymm (psphVal_mono_v hq fun y hy => le_of_eq (hvw y hy)) (psphVal_mono_v hq fun y hy => le_of_eq (hvw y hy).symm) lemma le_psphVal_of_mem {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} {y : β} (hy : y ∈ S) (v : β → ℝ) : v y ≤ psphVal q S v := (psphVal_mem_feas hq ⟨y, hy⟩ v).1 y hy lemma psphVal_add_const {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (c : ℝ) : psphVal q S (fun y => v y + c) = psphVal q S v + c := by apply le_antisymm · rw [psphVal_le_iff hq hS] rcases psphVal_mem_feas hq hS v with ⟨h1, h2⟩ refine ⟨fun y hy => by linarith [h1 y hy], ?_⟩ simpa [show ∀ y, v y + c + 1 - (psphVal q S v + c) = v y + 1 - psphVal q S v by intro y; ring] using h2 · have hle : psphVal q S v ≤ psphVal q S (fun y => v y + c) - c := by rw [psphVal_le_iff hq hS] rcases psphVal_mem_feas hq hS (fun y => v y + c) with ⟨h1, h2⟩ refine ⟨fun y hy => by linarith [h1 y hy], ?_⟩ simpa [show ∀ y, v y + 1 - (psphVal q S (fun y => v y + c) - c) = v y + c + 1 - psphVal q S (fun y => v y + c) by intro y; ring] using h2 linarith lemma psphVal_anti_q {β : Type*} {p q : ℝ} (hp : 0 < p) (hpq : p ≤ q) (S : Finset β) (v : β → ℝ) : psphVal q S v ≤ psphVal p S v := by have hq : 0 < q := lt_of_lt_of_le hp hpq by_cases hS : S.Nonempty · rw [psphVal_le_iff hq hS] rcases psphVal_mem_feas hp hS v with ⟨h1, h2⟩ refine ⟨h1, le_trans ?_ h2⟩ refine Finset.sum_le_sum fun y hy => ?_ have hle1 : max 0 (v y + 1 - psphVal p S v) ≤ 1 := max_le (by norm_num) (by linarith [h1 y hy]) exact Real.rpow_le_rpow_of_exponent_ge' (le_max_left 0 _) hle1 (le_of_lt hp) hpq · simp [psphVal, hS] /-- Exact value of `psphVal q` on a constant continuation `v ≡ c`: `psphVal q S (fun _ => c) = c + 1 - (S.card : ℝ) ^ (-1 / q)`! -/ theorem psphVal_const {β : Type*} {q : ℝ} (hq : 0 < q) {S : Finset β} (hS : S.Nonempty) (c : ℝ) : psphVal q S (fun _ => c) = c + 1 - (S.card : ℝ) ^ (-(1 / q)) := by have hcard_pos : (0 : ℝ) < (S.card : ℝ) := Nat.cast_pos.mpr hS.card_pos have hcard_ge1 : (1 : ℝ) ≤ (S.card : ℝ) := by exact_mod_cast hS.card_pos have hr_le1 : (S.card : ℝ) ^ (-(1 / q)) ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hcard_ge1 (by rw [neg_nonpos]; positivity) have hr_pos : 0 < (S.card : ℝ) ^ (-(1 / q)) := Real.rpow_pos_of_pos hcard_pos _ have hr_pow : ((S.card : ℝ) ^ (-(1 / q))) ^ q = (S.card : ℝ)⁻¹ := by rw [← Real.rpow_mul (le_of_lt hcard_pos), neg_mul, one_div_mul_cancel (ne_of_gt hq), Real.rpow_neg_one] apply le_antisymm · rw [psphVal_le_iff hq hS] refine ⟨fun _ _ => by linarith, ?_⟩ simp only [show c + 1 - (c + 1 - (S.card : ℝ) ^ (-(1 / q))) = (S.card : ℝ) ^ (-(1 / q)) by ring, max_eq_right (le_of_lt hr_pos), hr_pow, Finset.sum_const, nsmul_eq_mul, mul_inv_cancel₀ (ne_of_gt hcard_pos), le_refl] · rcases psphVal_mem_feas hq hS (fun _ => c) with ⟨h1, h2⟩ set T := psphVal q S (fun _ => c) rw [Finset.sum_const, nsmul_eq_mul] at h2 have hpow_le : (max 0 (c + 1 - T)) ^ q ≤ (S.card : ℝ)⁻¹ := by have := (le_div_iff₀ hcard_pos).mpr (by linarith : (max 0 (c + 1 - T)) ^ q * (S.card : ℝ) ≤ 1) rwa [one_div] at this rw [← hr_pow] at hpow_le have hbase_le : max 0 (c + 1 - T) ≤ (S.card : ℝ) ^ (-(1 / q)) := by by_contra hgt; push Not at hgt have := Real.rpow_lt_rpow (le_of_lt hr_pos) hgt hq linarith have := le_trans (le_max_right 0 (c + 1 - T)) hbase_le linarith /-- Exact `q = 1` subset-average characterization of `psphVal 1` (recovering `RLdim` step!): `psphVal 1 S v ≤ t ↔ ∀ A ⊆ S, A.Nonempty → (∑ y ∈ A, v y + (A.card - 1)) / A.card ≤ t`. -/ theorem psphVal_one_le_iff_subsets {β : Type*} [DecidableEq β] {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (t : ℝ) : psphVal 1 S v ≤ t ↔ ∀ A : Finset β, A ⊆ S → A.Nonempty → ((∑ y ∈ A, v y) + ((A.card : ℝ) - 1)) / (A.card : ℝ) ≤ t := by rw [psphVal_le_iff (by norm_num : (0 : ℝ) < 1) hS] simp only [psphFeas, Real.rpow_one] constructor · rintro ⟨h1, h2⟩ A hAS hAne have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos rw [div_le_iff₀ hcard_pos] have hsumA : ∑ y ∈ A, (v y + 1 - t) ≤ 1 := by calc ∑ y ∈ A, (v y + 1 - t) ≤ ∑ y ∈ A, max 0 (v y + 1 - t) := Finset.sum_le_sum fun y _ => le_max_right 0 _ _ ≤ ∑ y ∈ S, max 0 (v y + 1 - t) := Finset.sum_le_sum_of_subset_of_nonneg hAS fun y _ _ => le_max_left 0 _ _ ≤ 1 := h2 have hrew : ∑ y ∈ A, (v y + 1 - t) = (∑ y ∈ A, v y) + (A.card : ℝ) - (A.card : ℝ) * t := by rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_one] linarith · intro hall constructor · intro y hy have h := hall {y} (Finset.singleton_subset_iff.mpr hy) (Finset.singleton_nonempty y) simp at h; exact h · set A := S.filter fun y => 0 < v y + 1 - t have hsplit : ∑ y ∈ S, max 0 (v y + 1 - t) = ∑ y ∈ A, (v y + 1 - t) := by rw [← Finset.sum_subset (Finset.filter_subset _ S) (fun y hy hnot => by have hle : v y + 1 - t ≤ 0 := by by_contra hpos; push Not at hpos; exact hnot (Finset.mem_filter.mpr ⟨hy, hpos⟩) exact max_eq_left hle)] exact Finset.sum_congr rfl fun y hy => max_eq_right (le_of_lt (Finset.mem_filter.mp hy).2) rw [hsplit] by_cases hAne : A.Nonempty · have h := hall A (Finset.filter_subset _ S) hAne have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos rw [div_le_iff₀ hcard_pos] at h have hrew : ∑ y ∈ A, (v y + 1 - t) = (∑ y ∈ A, v y) + (A.card : ℝ) - (A.card : ℝ) * t := by rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_one] linarith · rw [Finset.not_nonempty_iff_eq_empty] at hAne rw [hAne, Finset.sum_empty]; norm_num /-- Exact binary closed form for Spherical score (`q = 2`) when `y₁ ≠ y₂` and `|v y₁ - v y₂| < 1`: `psphVal 2 {y₁, y₂} v = 1 + (v y₁ + v y₂ - √(2 - (v y₁ - v y₂)²)) / 2`! -/ theorem sphVal_binary {β : Type*} [DecidableEq β] {y₁ y₂ : β} (hne : y₁ ≠ y₂) (v : β → ℝ) (hdom : |v y₁ - v y₂| < 1) : psphVal 2 ({y₁, y₂} : Finset β) v = 1 + (v y₁ + v y₂ - Real.sqrt (2 - (v y₁ - v y₂) ^ 2)) / 2 := by have hS : ({y₁, y₂} : Finset β).Nonempty := ⟨y₁, by simp⟩ set d := v y₁ - v y₂ have hd_bounds := abs_lt.mp hdom have hd_sq : d ^ 2 < 1 := by nlinarith have hrad_pos : 0 < 2 - d ^ 2 := by linarith have hsqrt_gt1 : 1 < Real.sqrt (2 - d ^ 2) := by rw [Real.lt_sqrt zero_le_one]; linarith set T := 1 + (v y₁ + v y₂ - Real.sqrt (2 - d ^ 2)) / 2 have hu1 : v y₁ + 1 - T = (Real.sqrt (2 - d ^ 2) + d) / 2 := by dsimp only [T, d]; ring have hu2 : v y₂ + 1 - T = (Real.sqrt (2 - d ^ 2) - d) / 2 := by dsimp only [T, d]; ring have hu1_pos : 0 < v y₁ + 1 - T := by rw [hu1]; linarith have hu2_pos : 0 < v y₂ + 1 - T := by rw [hu2]; linarith have hT_ge1 : v y₁ < T := by have hsqrt_le : Real.sqrt (2 - d ^ 2) < 2 - d := by rw [Real.sqrt_lt' (by linarith)] have hpos : 0 < (d - 1) ^ 2 := sq_pos_of_ne_zero (by intro h; linarith) nlinarith dsimp only [T, d] at *; linarith have hT_ge2 : v y₂ < T := by have hsqrt_le : Real.sqrt (2 - d ^ 2) < 2 + d := by rw [Real.sqrt_lt' (by linarith)] have hpos : 0 < (d + 1) ^ 2 := sq_pos_of_ne_zero (by intro h; linarith) nlinarith dsimp only [T, d] at *; linarith have hsum_eq1 : (v y₁ + 1 - T) ^ 2 + (v y₂ + 1 - T) ^ 2 = 1 := by rw [hu1, hu2] have hsq : Real.sqrt (2 - d ^ 2) ^ 2 = 2 - d ^ 2 := Real.sq_sqrt (le_of_lt hrad_pos) calc ((Real.sqrt (2 - d ^ 2) + d) / 2) ^ 2 + ((Real.sqrt (2 - d ^ 2) - d) / 2) ^ 2 = (Real.sqrt (2 - d ^ 2) ^ 2 + d ^ 2) / 2 := by ring _ = ((2 - d ^ 2) + d ^ 2) / 2 := by rw [hsq] _ = 1 := by ring apply le_antisymm · rw [psphVal_le_iff (by norm_num : (0 : ℝ) < 2) hS] refine ⟨fun y hy => by simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl <;> linarith, ?_⟩ rw [Finset.sum_pair hne, max_eq_right (le_of_lt hu1_pos), max_eq_right (le_of_lt hu2_pos), Real.rpow_two, Real.rpow_two, hsum_eq1] · by_contra hlt; push Not at hlt rcases psphVal_mem_feas (by norm_num : (0 : ℝ) < 2) hS v with ⟨_, hsum⟩ set s := psphVal 2 ({y₁, y₂} : Finset β) v rw [Finset.sum_pair hne, Real.rpow_two, Real.rpow_two] at hsum have h1 : v y₁ + 1 - T < v y₁ + 1 - s := by linarith have h2 : v y₂ + 1 - T < v y₂ + 1 - s := by linarith have hm1 : max 0 (v y₁ + 1 - s) = v y₁ + 1 - s := max_eq_right (by linarith) have hm2 : max 0 (v y₂ + 1 - s) = v y₂ + 1 - s := max_eq_right (by linarith) rw [hm1, hm2] at hsum nlinarith /-! ## Part 3: Multi-Round Minimax Values (`BrierOpt`, `PsphOpt`, `SphOpt`, `RLdim`) & Game Equivalence -/ /-- The set of realizable labels at query point `x` in version space `V`. -/ def labels {α β : Type*} [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) (x : α) : Finset β := V.image fun h => h x /-- The restricted version space after observing `(x, y)`. -/ def restrict {α β : Type*} [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : Finset (α → β) := V.filter fun h => h x = y lemma restrict_subset {α β : Type*} [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : restrict V x y ⊆ V := Finset.filter_subset _ _ lemma restrict_nonempty_iff {α β : Type*} [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : (restrict V x y).Nonempty ↔ y ∈ labels V x := by simp [restrict, labels, Finset.Nonempty] lemma card_restrict_lt_of_two_labels {α β : Type*} [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} {x : α} (hsplit : 2 ≤ (labels V x).card) (y : β) : (restrict V x y).card < V.card := by have hex : ∃ y' ∈ labels V x, y' ≠ y := by by_contra hall; push Not at hall have hsub : labels V x ⊆ {y} := fun z hz => Finset.mem_singleton.mpr (hall z hz) have := Finset.card_le_card hsub; simp at this; omega rcases hex with ⟨y', hy', hne⟩ rw [labels, Finset.mem_image] at hy' rcases hy' with ⟨h, hhV, hhx⟩ exact Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨restrict_subset V x y, fun heq => by have : h ∈ restrict V x y := heq.symm ▸ hhV rw [restrict, Finset.mem_filter] at this exact hne (hhx.symm.trans this.2)⟩) lemma sum_card_restrict {α β : Type*} [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) (x : α) : ∑ y ∈ labels V x, (restrict V x y).card = V.card := by unfold labels restrict exact (Finset.card_eq_sum_card_fiberwise (f := fun h : α → β => h x) (s := V) (t := V.image fun h => h x) (fun h hh => Finset.mem_image_of_mem _ hh)).symm /-- **Exact Minimax Cumulative Multiclass Brier Score `BrierOpt V`**. -/ def BrierOpt {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then splits.attach.sup' hs.attach fun ⟨x, hx⟩ => have _hlt : ∀ y, (restrict V x y).card < V.card := fun y => card_restrict_lt_of_two_labels (Finset.mem_filter.mp hx).2 y brierVal (labels V x) fun y => BrierOpt (restrict V x y) else 0 termination_by V.card decreasing_by exact _hlt y /-- **Exact Minimax Cumulative Multiclass Pseudospherical Score `PsphOpt q V`** (`q ≥ 1`). -/ def PsphOpt {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (q : ℝ) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then splits.attach.sup' hs.attach fun ⟨x, hx⟩ => have _hlt : ∀ y, (restrict V x y).card < V.card := fun y => card_restrict_lt_of_two_labels (Finset.mem_filter.mp hx).2 y psphVal q (labels V x) fun y => PsphOpt q (restrict V x y) else 0 termination_by V.card decreasing_by exact _hlt y /-- **Exact Minimax Cumulative Multiclass Spherical Score `SphOpt V := PsphOpt 2 V`**. -/ abbrev SphOpt {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : ℝ := PsphOpt 2 V /-- **Exact Multiclass Randomized Littlestone Dimension `RLdim V := PsphOpt 1 V`**. -/ abbrev RLdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : ℝ := PsphOpt 1 V lemma BrierOpt_eq_zero_of_card_le_one {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.card ≤ 1) : BrierOpt V = 0 := by rw [BrierOpt, if_pos hV] lemma PsphOpt_eq_zero_of_card_le_one {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (q : ℝ) {V : Finset (α → β)} (hV : V.card ≤ 1) : PsphOpt q V = 0 := by rw [PsphOpt, if_pos hV] lemma BrierOpt_unfold {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : 1 < V.card) : BrierOpt V = let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then splits.sup' hs fun x => brierVal (labels V x) fun y => BrierOpt (restrict V x y) else 0 := by conv_lhs => rw [BrierOpt, if_neg (by omega)] dsimp only split_ifs with hs · apply le_antisymm · refine Finset.sup'_le _ _ fun ⟨x, hx⟩ _ => Finset.le_sup' (f := fun x => brierVal (labels V x) fun y => BrierOpt (restrict V x y)) hx · refine Finset.sup'_le _ _ fun x hx => Finset.le_sup' (f := fun z : {x // x ∈ _} => brierVal (labels V z.1) fun y => BrierOpt (restrict V z.1 y)) (Finset.mem_attach _ ⟨x, hx⟩) · rfl lemma PsphOpt_unfold {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (q : ℝ) {V : Finset (α → β)} (hV : 1 < V.card) : PsphOpt q V = let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then splits.sup' hs fun x => psphVal q (labels V x) fun y => PsphOpt q (restrict V x y) else 0 := by conv_lhs => rw [PsphOpt, if_neg (by omega)] dsimp only split_ifs with hs · apply le_antisymm · refine Finset.sup'_le _ _ fun ⟨x, hx⟩ _ => Finset.le_sup' (f := fun x => psphVal q (labels V x) fun y => PsphOpt q (restrict V x y)) hx · refine Finset.sup'_le _ _ fun x hx => Finset.le_sup' (f := fun z : {x // x ∈ _} => psphVal q (labels V z.1) fun y => PsphOpt q (restrict V z.1 y)) (Finset.mem_attach _ ⟨x, hx⟩) · rfl lemma BrierOpt_nonneg {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] : ∀ V : Finset (α → β), 0 ≤ BrierOpt V := by intro V induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn by_cases hV : V.card ≤ 1 · rw [BrierOpt_eq_zero_of_card_le_one hV] · rw [BrierOpt_unfold (by omega)] dsimp only split_ifs with hs · rcases hs with ⟨x, hx⟩ have hsp := (Finset.mem_filter.mp hx).2 rcases Finset.card_pos.mp (by omega : 0 < (labels V x).card) with ⟨y, hy⟩ calc (0 : ℝ) ≤ BrierOpt (restrict V x y) := ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl _ ≤ brierVal (labels V x) (fun z => BrierOpt (restrict V x z)) := le_brierVal_of_mem hy (fun z => BrierOpt (restrict V x z)) _ ≤ _ := Finset.le_sup' (f := fun x => brierVal (labels V x) fun z => BrierOpt (restrict V x z)) hx · exact le_rfl lemma PsphOpt_nonneg {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℝ} (hq : 0 < q) : ∀ V : Finset (α → β), 0 ≤ PsphOpt q V := by intro V induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn by_cases hV : V.card ≤ 1 · rw [PsphOpt_eq_zero_of_card_le_one q hV] · rw [PsphOpt_unfold q (by omega)] dsimp only split_ifs with hs · rcases hs with ⟨x, hx⟩ have hsp := (Finset.mem_filter.mp hx).2 rcases Finset.card_pos.mp (by omega : 0 < (labels V x).card) with ⟨y, hy⟩ calc (0 : ℝ) ≤ PsphOpt q (restrict V x y) := ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl _ ≤ psphVal q (labels V x) (fun z => PsphOpt q (restrict V x z)) := le_psphVal_of_mem hq hy (fun z => PsphOpt q (restrict V x z)) _ ≤ _ := Finset.le_sup' (f := fun x => psphVal q (labels V x) fun z => PsphOpt q (restrict V x z)) hx · exact le_rfl lemma BrierOpt_le_of_forall_x {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) {t : ℝ} (ht0 : 0 ≤ t) (h : ∀ x : α, 2 ≤ (labels V x).card → brierVal (labels V x) (fun y => BrierOpt (restrict V x y)) ≤ t) : BrierOpt V ≤ t := by by_cases hV : V.card ≤ 1 · rw [BrierOpt_eq_zero_of_card_le_one hV]; exact ht0 · rw [BrierOpt_unfold (by omega)]; dsimp only split_ifs with hs · exact Finset.sup'_le hs _ fun x hx => h x (Finset.mem_filter.mp hx).2 · exact ht0 lemma PsphOpt_le_of_forall_x {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (q : ℝ) (V : Finset (α → β)) {t : ℝ} (ht0 : 0 ≤ t) (h : ∀ x : α, 2 ≤ (labels V x).card → psphVal q (labels V x) (fun y => PsphOpt q (restrict V x y)) ≤ t) : PsphOpt q V ≤ t := by by_cases hV : V.card ≤ 1 · rw [PsphOpt_eq_zero_of_card_le_one q hV]; exact ht0 · rw [PsphOpt_unfold q (by omega)]; dsimp only split_ifs with hs · exact Finset.sup'_le hs _ fun x hx => h x (Finset.mem_filter.mp hx).2 · exact ht0 lemma BrierOpt_ge_brierVal {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) (x : α) (hsplit : 2 ≤ (labels V x).card) : brierVal (labels V x) (fun y => BrierOpt (restrict V x y)) ≤ BrierOpt V := by have hV : 1 < V.card := by have hle : (labels V x).card ≤ V.card := Finset.card_image_le omega rw [BrierOpt_unfold hV]; dsimp only have hx : x ∈ Finset.univ.filter (fun z : α => 2 ≤ (labels V z).card) := by simp [hsplit] rw [dif_pos ⟨x, hx⟩] exact Finset.le_sup' (f := fun z => brierVal (labels V z) fun y => BrierOpt (restrict V z y)) hx lemma PsphOpt_ge_psphVal {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (q : ℝ) (V : Finset (α → β)) (x : α) (hsplit : 2 ≤ (labels V x).card) : psphVal q (labels V x) (fun y => PsphOpt q (restrict V x y)) ≤ PsphOpt q V := by have hV : 1 < V.card := by have hle : (labels V x).card ≤ V.card := Finset.card_image_le omega rw [PsphOpt_unfold q hV]; dsimp only have hx : x ∈ Finset.univ.filter (fun z : α => 2 ≤ (labels V z).card) := by simp [hsplit] rw [dif_pos ⟨x, hx⟩] exact Finset.le_sup' (f := fun z => psphVal q (labels V z) fun y => PsphOpt q (restrict V z y)) hx /-! ### Full Multi-Round Adaptive Proper-Scoring Forecasting Games -/ /-- A randomized adaptive adversary for multiclass online probability forecasting. -/ structure ForecastAdversary (α β : Type*) [DecidableEq α] [DecidableEq β] where query : Finset (α → β) → Option (α × (β → ℝ)) valid : ∀ V x ν, query V = some (x, ν) → 2 ≤ (labels V x).card ∧ (∀ y ∈ labels V x, 0 ≤ ν y) ∧ (∑ y ∈ labels V x, ν y = 1) /-- A multiclass probability forecaster outputs a forecast vector `p : β → ℝ` for `(V, x)`. -/ structure ProbForecaster (α β : Type*) [DecidableEq α] [DecidableEq β] where pred : Finset (α → β) → α → β → ℝ valid : ∀ V x, (labels V x).Nonempty → (∀ y ∈ labels V x, 0 ≤ pred V x y) ∧ (∑ y ∈ labels V x, pred V x y = 1) /-- Expected cumulative multiclass Brier score of forecaster `F` against adversary `A`. -/ def expectedBrierLoss {α β : Type*} [DecidableEq α] [DecidableEq β] (F : ProbForecaster α β) (A : ForecastAdversary α β) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else match hq : A.query V with | none => 0 | some (x, ν) => ∑ y ∈ labels V x, have _hlt : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels (A.valid V x ν hq).1 y ν y * (brierLoss (labels V x) (F.pred V x) y + expectedBrierLoss F A (restrict V x y)) termination_by V.card decreasing_by exact _hlt lemma expectedBrierLoss_of_card_le_one {α β : Type*} [DecidableEq α] [DecidableEq β] (F : ProbForecaster α β) (A : ForecastAdversary α β) {V : Finset (α → β)} (hV : V.card ≤ 1) : expectedBrierLoss F A V = 0 := by rw [expectedBrierLoss, if_pos hV] lemma expectedBrierLoss_of_none {α β : Type*} [DecidableEq α] [DecidableEq β] (F : ProbForecaster α β) (A : ForecastAdversary α β) {V : Finset (α → β)} (hq : A.query V = none) : expectedBrierLoss F A V = 0 := by conv_lhs => rw [expectedBrierLoss] split_ifs · rfl · split · rfl · rename_i x ν heq; rw [hq] at heq; cases heq lemma expectedBrierLoss_of_some {α β : Type*} [DecidableEq α] [DecidableEq β] (F : ProbForecaster α β) (A : ForecastAdversary α β) {V : Finset (α → β)} (hV : 1 < V.card) {x : α} {ν : β → ℝ} (hq : A.query V = some (x, ν)) : expectedBrierLoss F A V = ∑ y ∈ labels V x, ν y * (brierLoss (labels V x) (F.pred V x) y + expectedBrierLoss F A (restrict V x y)) := by conv_lhs => rw [expectedBrierLoss, if_neg (by omega)] split · rename_i heq; rw [hq] at heq; cases heq · rename_i x' ν' heq rw [hq] at heq; injection heq with hpair; rcases Prod.mk.inj hpair with ⟨rfl, rfl⟩; rfl /-- Optimal water-filling multiclass Brier forecaster. -/ def optBrierForecaster {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] : ProbForecaster α β where pred := fun V x => wfForecast (labels V x) fun y => BrierOpt (restrict V x y) valid := fun _V _x hS => ⟨fun y _ => wfForecast_nonneg _ _ y, wfForecast_sum_eq_one hS _⟩ /-- Optimal self-dual multiclass Brier adversary (`ν* = p*`). -/ def optBrierAdversary {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] : ForecastAdversary α β where query := fun V => let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then let x := Classical.choose (Finset.exists_mem_eq_sup' hs fun z => brierVal (labels V z) fun y => BrierOpt (restrict V z y)) some (x, wfForecast (labels V x) fun y => BrierOpt (restrict V x y)) else none valid := by intro V x ν hq dsimp only at hq split_ifs at hq with hs · set x0 := Classical.choose (Finset.exists_mem_eq_sup' hs fun z => brierVal (labels V z) fun y => BrierOpt (restrict V z y)) have hx := (Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => brierVal (labels V z) fun y => BrierOpt (restrict V z y))).1 have hsp : 2 ≤ (labels V x0).card := (Finset.mem_filter.mp hx).2 have hS : (labels V x0).Nonempty := Finset.card_pos.mp (by omega) injection hq with hpair rcases Prod.mk.inj hpair with ⟨hx_eq, hν_eq⟩ rw [← hx_eq, ← hν_eq] exact ⟨hsp, fun y _ => wfForecast_nonneg _ _ y, wfForecast_sum_eq_one hS _⟩ theorem optBrierForecaster_expectedLoss_le {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (A : ForecastAdversary α β) (V : Finset (α → β)) : expectedBrierLoss optBrierForecaster A V ≤ BrierOpt V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn by_cases hV : V.card ≤ 1 · rw [expectedBrierLoss_of_card_le_one _ A hV, BrierOpt_eq_zero_of_card_le_one hV] · cases hq : A.query V with | none => rw [expectedBrierLoss_of_none _ A hq]; exact BrierOpt_nonneg V | some xν => rcases xν with ⟨x, ν⟩ rw [expectedBrierLoss_of_some _ A (by omega) hq] rcases A.valid V x ν hq with ⟨hsp, hν_nn, hν_sum⟩ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hstep : ∀ y ∈ labels V x, brierLoss (labels V x) (optBrierForecaster.pred V x) y + expectedBrierLoss optBrierForecaster A (restrict V x y) ≤ BrierOpt V := by intro y hy have h1 := (brierVal_primal_upper hS (fun z => BrierOpt (restrict V x z))).1 y hy have h2 := ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl have h3 := BrierOpt_ge_brierVal V x hsp have hpred : optBrierForecaster.pred V x = wfForecast (labels V x) fun z => BrierOpt (restrict V x z) := rfl rw [hpred]; linarith calc ∑ y ∈ labels V x, ν y * (brierLoss (labels V x) (optBrierForecaster.pred V x) y + expectedBrierLoss optBrierForecaster A (restrict V x y)) ≤ ∑ y ∈ labels V x, ν y * BrierOpt V := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left (hstep y hy) (hν_nn y hy) _ = (∑ y ∈ labels V x, ν y) * BrierOpt V := (Finset.sum_mul _ _ _).symm _ = BrierOpt V := by rw [hν_sum, one_mul] theorem optBrierAdversary_expectedLoss_ge {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (F : ProbForecaster α β) (V : Finset (α → β)) : BrierOpt V ≤ expectedBrierLoss F optBrierAdversary V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn by_cases hV : V.card ≤ 1 · rw [BrierOpt_eq_zero_of_card_le_one hV, expectedBrierLoss_of_card_le_one F _ hV] · rw [BrierOpt_unfold (by omega)] set splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card by_cases hs : splits.Nonempty · set x := Classical.choose (Finset.exists_mem_eq_sup' hs fun z => brierVal (labels V z) fun y => BrierOpt (restrict V z y)) have hx_spec := Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => brierVal (labels V z) fun y => BrierOpt (restrict V z y)) have hsp : 2 ≤ (labels V x).card := (Finset.mem_filter.mp hx_spec.1).2 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) set ν := wfForecast (labels V x) fun y => BrierOpt (restrict V x y) have hq : optBrierAdversary.query V = some (x, ν) := by dsimp only [optBrierAdversary]; rw [dif_pos hs] rw [dif_pos hs, hx_spec.2, expectedBrierLoss_of_some F _ (by omega) hq] calc brierVal (labels V x) (fun y => BrierOpt (restrict V x y)) ≤ ∑ y ∈ labels V x, ν y * (BrierOpt (restrict V x y) + brierLoss (labels V x) (F.pred V x) y) := brierVal_dual_lower hS _ (F.pred V x) _ ≤ ∑ y ∈ labels V x, ν y * (brierLoss (labels V x) (F.pred V x) y + expectedBrierLoss F optBrierAdversary (restrict V x y)) := by refine Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left ?_ (wfForecast_nonneg _ _ y) linarith [ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl] · have hq : optBrierAdversary.query V = none := by dsimp only [optBrierAdversary]; rw [dif_neg hs] rw [dif_neg hs, expectedBrierLoss_of_none F _ hq] /-- **Full Multi-Round Multiclass Brier Minimax Saddle-Point Theorem**: `optBrierForecaster` and the self-dual `optBrierAdversary` achieve exact minimax value `BrierOpt V`. -/ theorem online_brier_minimax_exact {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : (∀ A : ForecastAdversary α β, expectedBrierLoss optBrierForecaster A V ≤ BrierOpt V) ∧ (∀ F : ProbForecaster α β, BrierOpt V ≤ expectedBrierLoss F optBrierAdversary V) ∧ expectedBrierLoss optBrierForecaster optBrierAdversary V = BrierOpt V := ⟨fun A => optBrierForecaster_expectedLoss_le A V, fun F => optBrierAdversary_expectedLoss_ge F V, le_antisymm (optBrierForecaster_expectedLoss_le _ V) (optBrierAdversary_expectedLoss_ge _ V)⟩ /-- An `ℓ_q`-sphere forecaster (`q ≥ 1`) for Good's pseudospherical proper scoring rule. -/ structure PsphForecaster (α β : Type*) [DecidableEq α] [DecidableEq β] (q : ℝ) where pred : Finset (α → β) → α → β → ℝ valid : ∀ V x, (labels V x).Nonempty → (∀ y ∈ labels V x, 0 ≤ pred V x y) ∧ (∑ y ∈ labels V x, pred V x y ^ q ≤ 1) /-- Expected cumulative multiclass pseudospherical score (`q ≥ 1`). -/ def expectedPsphLoss {α β : Type*} [DecidableEq α] [DecidableEq β] {q : ℝ} (F : PsphForecaster α β q) (A : ForecastAdversary α β) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else match hq : A.query V with | none => 0 | some (x, ν) => ∑ y ∈ labels V x, have _hlt : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels (A.valid V x ν hq).1 y ν y * ((1 - F.pred V x y) + expectedPsphLoss F A (restrict V x y)) termination_by V.card decreasing_by exact _hlt lemma expectedPsphLoss_of_card_le_one {α β : Type*} [DecidableEq α] [DecidableEq β] {q : ℝ} (F : PsphForecaster α β q) (A : ForecastAdversary α β) {V : Finset (α → β)} (hV : V.card ≤ 1) : expectedPsphLoss F A V = 0 := by rw [expectedPsphLoss, if_pos hV] lemma expectedPsphLoss_of_none {α β : Type*} [DecidableEq α] [DecidableEq β] {q : ℝ} (F : PsphForecaster α β q) (A : ForecastAdversary α β) {V : Finset (α → β)} (hq : A.query V = none) : expectedPsphLoss F A V = 0 := by conv_lhs => rw [expectedPsphLoss] split_ifs · rfl · split · rfl · rename_i x ν heq; rw [hq] at heq; cases heq lemma expectedPsphLoss_of_some {α β : Type*} [DecidableEq α] [DecidableEq β] {q : ℝ} (F : PsphForecaster α β q) (A : ForecastAdversary α β) {V : Finset (α → β)} (hV : 1 < V.card) {x : α} {ν : β → ℝ} (hq : A.query V = some (x, ν)) : expectedPsphLoss F A V = ∑ y ∈ labels V x, ν y * ((1 - F.pred V x y) + expectedPsphLoss F A (restrict V x y)) := by conv_lhs => rw [expectedPsphLoss, if_neg (by omega)] split · rename_i heq; rw [hq] at heq; cases heq · rename_i x' ν' heq rw [hq] at heq; injection heq with hpair; rcases Prod.mk.inj hpair with ⟨rfl, rfl⟩; rfl def optPsphForecaster {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℝ} (hq : 0 < q) : PsphForecaster α β q where pred := fun V x => if hS : (labels V x).Nonempty then Classical.choose (psphVal_primal_upper hq hS fun y => PsphOpt q (restrict V x y)) else fun _ => 0 valid := fun V x hS => by simp only [dif_pos hS] have hspec := Classical.choose_spec (psphVal_primal_upper hq hS fun y => PsphOpt q (restrict V x y)) exact ⟨hspec.1, hspec.2.1⟩ def optPsphAdversary {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) : ForecastAdversary α β where query := fun V => let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then let x := Classical.choose (Finset.exists_mem_eq_sup' hs fun z => psphVal q (labels V z) fun y => PsphOpt q (restrict V z y)) have hx : x ∈ splits := (Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => psphVal q (labels V z) fun y => PsphOpt q (restrict V z y))).1 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by have := (Finset.mem_filter.mp hx).2; omega) some (x, Classical.choose (psphVal_dual_lower hq hS fun y => PsphOpt q (restrict V x y))) else none valid := by intro V x ν hq_eq dsimp only at hq_eq split_ifs at hq_eq with hs · set x0 := Classical.choose (Finset.exists_mem_eq_sup' hs fun z => psphVal q (labels V z) fun y => PsphOpt q (restrict V z y)) have hx := (Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => psphVal q (labels V z) fun y => PsphOpt q (restrict V z y))).1 have hsp : 2 ≤ (labels V x0).card := (Finset.mem_filter.mp hx).2 have hS : (labels V x0).Nonempty := Finset.card_pos.mp (by omega) have hν := Classical.choose_spec (psphVal_dual_lower hq hS fun y => PsphOpt q (restrict V x0 y)) injection hq_eq with hpair rcases Prod.mk.inj hpair with ⟨hx_eq, hν_eq⟩ rw [← hx_eq, ← hν_eq] exact ⟨hsp, hν.1, hν.2.1⟩ /-- **Full Multi-Round Multiclass Pseudospherical Minimax Saddle-Point Theorem (`q ≥ 1`)**. -/ theorem online_psph_minimax_exact {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) (V : Finset (α → β)) : (∀ A : ForecastAdversary α β, expectedPsphLoss (optPsphForecaster (by linarith)) A V ≤ PsphOpt q V) ∧ (∀ F : PsphForecaster α β q, PsphOpt q V ≤ expectedPsphLoss F (optPsphAdversary hq) V) ∧ expectedPsphLoss (optPsphForecaster (by linarith)) (optPsphAdversary hq) V = PsphOpt q V := by have hq0 : 0 < q := by linarith have hupper : ∀ A : ForecastAdversary α β, ∀ W : Finset (α → β), expectedPsphLoss (optPsphForecaster hq0) A W ≤ PsphOpt q W := by intro A W induction hn : W.card using Nat.strong_induction_on generalizing W with | h n ih => subst hn by_cases hW : W.card ≤ 1 · rw [expectedPsphLoss_of_card_le_one _ A hW, PsphOpt_eq_zero_of_card_le_one q hW] · cases hq_eq : A.query W with | none => rw [expectedPsphLoss_of_none _ A hq_eq]; exact PsphOpt_nonneg hq0 W | some xν => rcases xν with ⟨x, ν⟩ rw [expectedPsphLoss_of_some _ A (by omega) hq_eq] rcases A.valid W x ν hq_eq with ⟨hsp, hν_nn, hν_sum⟩ have hS : (labels W x).Nonempty := Finset.card_pos.mp (by omega) have hspec := Classical.choose_spec (psphVal_primal_upper hq0 hS fun y => PsphOpt q (restrict W x y)) have hstep : ∀ y ∈ labels W x, (1 - (optPsphForecaster hq0).pred W x y) + expectedPsphLoss (optPsphForecaster hq0) A (restrict W x y) ≤ PsphOpt q W := by intro y hy have h1 := hspec.2.2 y hy have h2 := ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl have h3 := PsphOpt_ge_psphVal q W x hsp have hpred : (optPsphForecaster hq0).pred W x = Classical.choose (psphVal_primal_upper hq0 hS fun z => PsphOpt q (restrict W x z)) := by simp [optPsphForecaster, hS] rw [hpred]; linarith calc ∑ y ∈ labels W x, ν y * ((1 - (optPsphForecaster hq0).pred W x y) + expectedPsphLoss (optPsphForecaster hq0) A (restrict W x y)) ≤ ∑ y ∈ labels W x, ν y * PsphOpt q W := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left (hstep y hy) (hν_nn y hy) _ = (∑ y ∈ labels W x, ν y) * PsphOpt q W := (Finset.sum_mul _ _ _).symm _ = PsphOpt q W := by rw [hν_sum, one_mul] have hlower : ∀ F : PsphForecaster α β q, ∀ W : Finset (α → β), PsphOpt q W ≤ expectedPsphLoss F (optPsphAdversary hq) W := by intro F W induction hn : W.card using Nat.strong_induction_on generalizing W with | h n ih => subst hn by_cases hW : W.card ≤ 1 · rw [PsphOpt_eq_zero_of_card_le_one q hW, expectedPsphLoss_of_card_le_one F _ hW] · rw [PsphOpt_unfold q (by omega)] set splits := Finset.univ.filter fun x : α => 2 ≤ (labels W x).card by_cases hs : splits.Nonempty · set x := Classical.choose (Finset.exists_mem_eq_sup' hs fun z => psphVal q (labels W z) fun y => PsphOpt q (restrict W z y)) have hx_spec := Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => psphVal q (labels W z) fun y => PsphOpt q (restrict W z y)) have hsp : 2 ≤ (labels W x).card := (Finset.mem_filter.mp hx_spec.1).2 have hS : (labels W x).Nonempty := Finset.card_pos.mp (by omega) set ν := Classical.choose (psphVal_dual_lower hq hS fun y => PsphOpt q (restrict W x y)) have hν_spec := Classical.choose_spec (psphVal_dual_lower hq hS fun y => PsphOpt q (restrict W x y)) have hq_eq : (optPsphAdversary hq).query W = some (x, ν) := by dsimp only [optPsphAdversary]; rw [dif_pos hs] rw [dif_pos hs, hx_spec.2, expectedPsphLoss_of_some F _ (by omega) hq_eq] have hF := F.valid W x hS calc psphVal q (labels W x) (fun y => PsphOpt q (restrict W x y)) ≤ ∑ y ∈ labels W x, ν y * (PsphOpt q (restrict W x y) + (1 - F.pred W x y)) := hν_spec.2.2 (F.pred W x) hF.1 hF.2 _ ≤ ∑ y ∈ labels W x, ν y * ((1 - F.pred W x y) + expectedPsphLoss F (optPsphAdversary hq) (restrict W x y)) := by refine Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left ?_ (hν_spec.1 y hy) linarith [ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl] · have hq_eq : (optPsphAdversary hq).query W = none := by dsimp only [optPsphAdversary]; rw [dif_neg hs] rw [dif_neg hs, expectedPsphLoss_of_none F _ hq_eq] exact ⟨fun A => hupper A V, fun F => hlower F V, le_antisymm (hupper _ V) (hlower _ V)⟩ /-! ## Part 4: Non-Pointwise Minimax Hierarchy & Universal Multiclass Comparison Sandwiches -/ /-- **2-Line Cauchy–Schwarz + AM-GM Minimax Dominance (`brierVal S v ≤ psphVal 2 S v`)**: Even though pointwise `L_Brier(p, y) > L_Sph(p, y)` can hold, minimax-wise Brier NEVER exceeds Spherical for ANY finite `S` and ANY continuation vector `v`! -/ theorem brierVal_le_sphVal {β : Type*} (S : Finset β) (v : β → ℝ) : brierVal S v ≤ psphVal 2 S v := by by_cases hS : S.Nonempty · set T := psphVal 2 S v rcases psphVal_mem_feas (by norm_num : (0 : ℝ) < 2) hS v with ⟨hvT, hu2⟩ set q := wfForecast S v have hq_nn : ∀ y ∈ S, 0 ≤ q y := fun y _ => wfForecast_nonneg S v y have hq_sum : ∑ y ∈ S, q y = 1 := wfForecast_sum_eq_one hS v set u : β → ℝ := fun y => max 0 (v y + 1 - T) have hu_sq : ∑ y ∈ S, u y ^ 2 ≤ 1 := by simpa only [Real.rpow_two] using hu2 -- Cauchy-Schwarz + AM-GM: ∑ q y * u y ≤ (∑ q y^2 + ∑ u y^2) / 2 ≤ (∑ q y^2 + 1) / 2! have hcs_amgm : ∑ y ∈ S, q y * u y ≤ (∑ y ∈ S, q y ^ 2 + 1) / 2 := by have hpoint : ∑ y ∈ S, q y * u y ≤ ∑ y ∈ S, (q y ^ 2 + u y ^ 2) / 2 := Finset.sum_le_sum fun y _ => by nlinarith [sq_nonneg (q y - u y)] rw [← Finset.sum_div, Finset.sum_add_distrib] at hpoint linarith have h1 : ∑ y ∈ S, q y * (v y + 1 - T) ≤ (∑ y ∈ S, q y ^ 2 + 1) / 2 := le_trans (Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left (le_max_right 0 _) (hq_nn y hy)) hcs_amgm -- Compare with brierVal S v = ∑ q y * (v y + brierLoss S q y) = ∑ q y * v y + (1 - ∑ q y^2)/2! have hdual : brierVal S v = ∑ y ∈ S, q y * (v y + brierLoss S q y) := by apply le_antisymm (brierVal_dual_lower hS v q) calc ∑ y ∈ S, q y * (v y + brierLoss S q y) ≤ ∑ y ∈ S, q y * brierVal S v := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left ((brierVal_primal_upper hS v).1 y hy) (hq_nn y hy) _ = (∑ y ∈ S, q y) * brierVal S v := (Finset.sum_mul _ _ _).symm _ = brierVal S v := by rw [hq_sum, one_mul] have hrew_brier : ∑ y ∈ S, q y * (v y + brierLoss S q y) = (∑ y ∈ S, q y * v y) + (1 - ∑ y ∈ S, q y ^ 2) / 2 := by have hsum_bl : ∑ y ∈ S, q y * brierLoss S q y = (1 - ∑ y ∈ S, q y ^ 2) / 2 := by have h := Finset.sum_congr rfl fun y (_ : y ∈ S) => show q y * brierLoss S q y = (q y * (1 + ∑ z ∈ S, q z ^ 2) - 2 * q y ^ 2) / 2 by dsimp only [brierLoss]; ring rw [h, ← Finset.sum_div, Finset.sum_sub_distrib, ← Finset.sum_mul, hq_sum, one_mul, ← Finset.mul_sum]; ring rw [← hsum_bl, ← Finset.sum_add_distrib] exact Finset.sum_congr rfl fun y _ => by ring have hrew_T : ∑ y ∈ S, q y * (v y + 1 - T) = (∑ y ∈ S, q y * v y) + 1 - T := by calc ∑ y ∈ S, q y * (v y + 1 - T) = ∑ y ∈ S, (q y * v y + q y * (1 - T)) := Finset.sum_congr rfl fun y _ => by ring _ = (∑ y ∈ S, q y * v y) + (∑ y ∈ S, q y) * (1 - T) := by rw [Finset.sum_add_distrib, ← Finset.sum_mul] _ = (∑ y ∈ S, q y * v y) + 1 - T := by rw [hq_sum, one_mul]; ring linarith · simp [brierVal, psphVal, hS] /-- **Universal Multiclass Minimax Dominance (`BrierOpt V ≤ SphOpt V`)**: For EVERY finite concept class `V` over ANY label space `β`, `BrierOpt V ≤ SphOpt V`! -/ theorem BrierOpt_le_SphOpt {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : BrierOpt V ≤ SphOpt V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn refine BrierOpt_le_of_forall_x V (PsphOpt_nonneg (by norm_num) V) fun x hsp => ?_ calc brierVal (labels V x) (fun y => BrierOpt (restrict V x y)) ≤ brierVal (labels V x) (fun y => SphOpt (restrict V x y)) := brierVal_mono_v fun y _ => ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl _ ≤ psphVal 2 (labels V x) (fun y => SphOpt (restrict V x y)) := brierVal_le_sphVal _ _ _ ≤ SphOpt V := PsphOpt_ge_psphVal 2 V x hsp /-- **Pointwise-vs-Minimax Separation Witness**: At `p = (3/4, 1/4)` on `{false, true}`, Brier loss on `false` (`1/16 = 0.0625`) is STRICTLY GREATER than Spherical loss (`1 - 3/√10 ≈ 0.0513`), proving that `BrierOpt V ≤ SphOpt V` is a genuine minimax phenomenon (NOT pointwise dominance)! -/ theorem brier_not_pointwise_le_sph : let p : Bool → ℝ := fun b => if b then 1 / 4 else 3 / 4 let S : Finset Bool := {false, true} 1 - p false / Real.sqrt (∑ z ∈ S, p z ^ 2) < brierLoss S p false := by dsimp only have hsum : ∑ z ∈ ({false, true} : Finset Bool), (if z then (1 / 4 : ℝ) else 3 / 4) ^ 2 = 5 / 8 := by rw [Finset.sum_pair (by decide : (false : Bool) ≠ true)]; norm_num rw [brierLoss, hsum] simp only [Bool.false_eq_true, ↓reduceIte] have hval : (1 - 2 * (3 / 4 : ℝ) + 5 / 8) / 2 = 1 / 16 := by norm_num rw [hval] -- Need 1 - (3/4) / √(5/8) < 1/16 <=> 15/16 < (3/4) / √(5/8) <=> 5/4 < 1 / √(5/8) <=> 25/16 < 8/5 (125 < 128)! have hsqrt_pos : 0 < Real.sqrt (5 / 8 : ℝ) := Real.sqrt_pos.mpr (by norm_num) have hlt : (15 / 16 : ℝ) < (3 / 4 : ℝ) / Real.sqrt (5 / 8 : ℝ) := by rw [lt_div_iff₀ hsqrt_pos] have hsq : ((15 / 16 : ℝ) * Real.sqrt (5 / 8 : ℝ)) ^ 2 < (3 / 4 : ℝ) ^ 2 := by rw [mul_pow, Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 5 / 8)]; norm_num have hnn : 0 ≤ (15 / 16 : ℝ) * Real.sqrt (5 / 8 : ℝ) := by positivity nlinarith linarith /-- **1-Step Multiclass Brier vs. `RLdim` Lower Bound**: `(1/2) * psphVal 1 S v ≤ brierVal S ((1/2) * v)`. -/ lemma half_rlVal_le_brierVal_half {β : Type*} [DecidableEq β] (S : Finset β) (v : β → ℝ) : (1 / 2 : ℝ) * psphVal 1 S v ≤ brierVal S (fun y => (1 / 2 : ℝ) * v y) := by by_cases hS : S.Nonempty · set B := brierVal S (fun y => (1 / 2 : ℝ) * v y) have hle : psphVal 1 S v ≤ 2 * B := by rw [psphVal_one_le_iff_subsets hS] intro A hAS hAne have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos have hcard_ne : (A.card : ℝ) ≠ 0 := ne_of_gt hcard_pos set p := wfForecast S (fun y => (1 / 2 : ℝ) * v y) -- Average the primal bound (1/2) * v y + brierLoss S p y ≤ B over y ∈ A! have havg : ∑ y ∈ A, ((1 / 2 : ℝ) * v y + brierLoss S p y) ≤ (A.card : ℝ) * B := by calc ∑ y ∈ A, ((1 / 2 : ℝ) * v y + brierLoss S p y) ≤ ∑ _y ∈ A, B := Finset.sum_le_sum fun y hy => (brierVal_primal_upper hS (fun z => (1 / 2 : ℝ) * v z)).1 y (hAS hy) _ = (A.card : ℝ) * B := by rw [Finset.sum_const, nsmul_eq_mul] -- Lower bound ∑_{y ∈ A} brierLoss S p y ≥ ((A.card : ℝ) - 1) / 2 via Cauchy-Schwarz! have hbrier_sum : ((A.card : ℝ) - 1) / 2 ≤ ∑ y ∈ A, brierLoss S p y := by set sA := ∑ y ∈ A, p y have hcs : sA ^ 2 ≤ (A.card : ℝ) * ∑ y ∈ A, p y ^ 2 := by have h := Finset.sum_mul_sq_le_sq_mul_sq A (fun _ => (1 : ℝ)) p simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one] at h exact h have hsub_sq : ∑ y ∈ A, p y ^ 2 ≤ ∑ z ∈ S, p z ^ 2 := Finset.sum_le_sum_of_subset_of_nonneg hAS fun z _ _ => sq_nonneg (p z) have hrew : ∑ y ∈ A, brierLoss S p y = ((A.card : ℝ) - 2 * sA + (A.card : ℝ) * ∑ z ∈ S, p z ^ 2) / 2 := by have : ∑ y ∈ A, brierLoss S p y = (∑ y ∈ A, ((1 + ∑ z ∈ S, p z ^ 2) - 2 * p y)) / 2 := by rw [Finset.sum_div]; exact Finset.sum_congr rfl fun y _ => by dsimp only [brierLoss]; ring rw [this, Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, ← Finset.mul_sum] dsimp only [sA]; ring rw [hrew] have hsq : 0 ≤ (sA - 1) ^ 2 := sq_nonneg _ nlinarith rw [Finset.sum_add_distrib, ← Finset.mul_sum] at havg rw [div_le_iff₀ hcard_pos] linarith linarith · simp [psphVal, brierVal, hS] /-- **Universal Multiclass Brier–Spherical–RLdim Sandwich Theorem**: For EVERY finite concept class `V` over ANY label space `β`: `(1/2) * RLdim V ≤ BrierOpt V ≤ SphOpt V ≤ RLdim V` and in particular `(1/2) * SphOpt V ≤ BrierOpt V ≤ SphOpt V`! -/ theorem BrierOpt_ge_half_RLdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : (1 / 2 : ℝ) * RLdim V ≤ BrierOpt V ∧ BrierOpt V ≤ SphOpt V ∧ SphOpt V ≤ RLdim V := by have hSph_le_RL : ∀ W : Finset (α → β), SphOpt W ≤ RLdim W := by intro W induction hn : W.card using Nat.strong_induction_on generalizing W with | h n ih => subst hn refine PsphOpt_le_of_forall_x 2 W (PsphOpt_nonneg (by norm_num) W) fun x hsp => ?_ calc psphVal 2 (labels W x) (fun y => SphOpt (restrict W x y)) ≤ psphVal 2 (labels W x) (fun y => RLdim (restrict W x y)) := psphVal_mono_v (by norm_num) fun y _ => ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl _ ≤ psphVal 1 (labels W x) (fun y => RLdim (restrict W x y)) := psphVal_anti_q (by norm_num) (by norm_num) _ _ _ ≤ RLdim W := PsphOpt_ge_psphVal 1 W x hsp refine ⟨?_, BrierOpt_le_SphOpt V, hSph_le_RL V⟩ induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hle : RLdim V ≤ 2 * BrierOpt V := by refine PsphOpt_le_of_forall_x 1 V (by linarith [BrierOpt_nonneg V]) fun x hsp => ?_ have h1 := half_rlVal_le_brierVal_half (labels V x) (fun y => RLdim (restrict V x y)) have h2 : brierVal (labels V x) (fun y => (1 / 2 : ℝ) * RLdim (restrict V x y)) ≤ brierVal (labels V x) (fun y => BrierOpt (restrict V x y)) := brierVal_mono_v fun y _ => ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl have h3 := BrierOpt_ge_brierVal V x hsp linarith linarith /-- **Universal Multiclass Exponent Antitonicity (`PsphOpt q V ≤ PsphOpt p V`)** for `0 < p ≤ q`. -/ theorem PsphOpt_anti_q {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {p q : ℝ} (hp : 0 < p) (hpq : p ≤ q) (V : Finset (α → β)) : PsphOpt q V ≤ PsphOpt p V := by have hq : 0 < q := lt_of_lt_of_le hp hpq induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn refine PsphOpt_le_of_forall_x q V (PsphOpt_nonneg hp V) fun x hsp => ?_ calc psphVal q (labels V x) (fun y => PsphOpt q (restrict V x y)) ≤ psphVal q (labels V x) (fun y => PsphOpt p (restrict V x y)) := psphVal_mono_v hq fun y _ => ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl _ ≤ psphVal p (labels V x) (fun y => PsphOpt p (restrict V x y)) := psphVal_anti_q hp hpq _ _ _ ≤ PsphOpt p V := PsphOpt_ge_psphVal p V x hsp /-- Elementary concavity lemma: for `q ≥ 1` and every real `k ≥ 2`, `2 * (1 - 2^(-1/q)) * (k - 1) ≤ k - k^(1 - 1/q)`! -/ lemma psph_ratio_concavity_bound {q k : ℝ} (hq : 1 ≤ q) (hk : 2 ≤ k) : 2 * (1 - (2 : ℝ) ^ (-(1 / q))) * (k - 1) ≤ k - k ^ (1 - 1 / q) := by have hq0 : 0 < q := by linarith set r := 1 - 1 / q have hr0 : 0 ≤ r := sub_nonneg.mpr ((div_le_one hq0).mpr hq) have h1q_pos : 0 < 1 / q := by positivity have hr1 : r ≤ 1 := by dsimp only [r]; linarith -- Elementary MVT proof: f(x) = x^r has antitone derivative r * x^(r - 1) on (0, ∞), -- so for k ≥ 2, (k^r - 2^r)/(k - 2) ≤ (2^r - 1)/(2 - 1) = 2^r - 1, giving k^r - 1 ≤ (k - 1)*(2^r - 1)! have hkr_le : k ^ r - 1 ≤ (k - 1) * ((2 : ℝ) ^ r - 1) := by by_cases hk2 : k = 2 · rw [hk2]; ring_nf; exact le_rfl · have hk_gt2 : 2 < k := lt_of_le_of_ne hk (Ne.symm hk2) have hderiv : ∀ x : ℝ, 0 < x → HasDerivAt (fun z : ℝ => z ^ r) (r * x ^ (r - 1)) x := fun x hx => Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt hx)) have hmvt1 : ∃ c₁ ∈ Set.Ioo (1 : ℝ) 2, r * c₁ ^ (r - 1) = ((2 : ℝ) ^ r - (1 : ℝ) ^ r) / (2 - 1) := exists_hasDerivAt_eq_slope (fun z : ℝ => z ^ r) (fun z => r * z ^ (r - 1)) (by norm_num) (fun z hz => (hderiv z (by linarith [hz.1])).continuousAt.continuousWithinAt) (fun z hz => hderiv z (by linarith [hz.1])) have hmvt2 : ∃ c₂ ∈ Set.Ioo (2 : ℝ) k, r * c₂ ^ (r - 1) = (k ^ r - (2 : ℝ) ^ r) / (k - 2) := exists_hasDerivAt_eq_slope (fun z : ℝ => z ^ r) (fun z => r * z ^ (r - 1)) hk_gt2 (fun z hz => (hderiv z (by linarith [hz.1])).continuousAt.continuousWithinAt) (fun z hz => hderiv z (by linarith [hz.1])) rcases hmvt1 with ⟨c₁, ⟨hc₁_lo, hc₁_hi⟩, heq1⟩ rcases hmvt2 with ⟨c₂, ⟨hc₂_lo, _⟩, heq2⟩ have hc12 : c₁ ≤ c₂ := le_of_lt (lt_trans hc₁_hi hc₂_lo) have hpow_anti : c₂ ^ (r - 1) ≤ c₁ ^ (r - 1) := Real.rpow_le_rpow_of_nonpos (by linarith) hc12 (by linarith) have hslope_le : (k ^ r - (2 : ℝ) ^ r) / (k - 2) ≤ (2 : ℝ) ^ r - 1 := by rw [Real.one_rpow, show (2 : ℝ) - 1 = 1 by norm_num, div_one] at heq1 rw [← heq2, ← heq1] exact mul_le_mul_of_nonneg_left hpow_anti hr0 have hmul := (div_le_iff₀ (by linarith : 0 < k - 2)).mp hslope_le linarith have h2r : (2 : ℝ) ^ r = 2 * (2 : ℝ) ^ (-(1 / q)) := by dsimp only [r] rw [sub_eq_add_neg, Real.rpow_add (by norm_num : (0 : ℝ) < 2), Real.rpow_one] rw [h2r] at hkr_le linarith /-- **Exact Universal Multiclass Pseudospherical vs. `RLdim` Sandwich Theorem (`q ≥ 1`)**: For EVERY `q ≥ 1` and EVERY finite multiclass concept class `V` (arbitrary `β`!): `2 * (1 - 2^(-1/q)) * RLdim V ≤ PsphOpt q V ≤ RLdim V`! Specializes at `q = 2` (Spherical score) to `(2 - √2) * RLdim V ≤ SphOpt V ≤ RLdim V`! -/ theorem PsphOpt_ge_alpha_mul_RLdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) (V : Finset (α → β)) : 2 * (1 - (2 : ℝ) ^ (-(1 / q))) * RLdim V ≤ PsphOpt q V ∧ PsphOpt q V ≤ RLdim V := by have hq0 : 0 < q := by linarith refine ⟨?_, PsphOpt_anti_q (by norm_num) hq V⟩ set c := 2 * (1 - (2 : ℝ) ^ (-(1 / q))) have hc_pos : 0 < c := by have hlt : (2 : ℝ) ^ (-(1 / q)) < (2 : ℝ) ^ (0 : ℝ) := Real.rpow_lt_rpow_of_exponent_lt (by norm_num) (by rw [neg_lt_zero]; positivity) rw [Real.rpow_zero] at hlt dsimp only [c]; linarith induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hle : RLdim V ≤ PsphOpt q V / c := by refine PsphOpt_le_of_forall_x 1 V (div_nonneg (PsphOpt_nonneg hq0 V) (le_of_lt hc_pos)) fun x hsp => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [psphVal_one_le_iff_subsets hS] intro A hAS hAne have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos set T := PsphOpt q V have hT_ge : psphVal q (labels V x) (fun y => c * RLdim (restrict V x y)) ≤ T := le_trans (psphVal_mono_v hq0 fun y _ => ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl) (PsphOpt_ge_psphVal q V x hsp) rcases (psphVal_le_iff hq0 hS _ T).mp hT_ge with ⟨hvT, huq⟩ by_cases hA1 : A.card = 1 · rcases Finset.card_eq_one.mp hA1 with ⟨y0, rfl⟩ have hy0 : y0 ∈ labels V x := hAS (by simp) have h1 := hvT y0 hy0 simp only [Finset.sum_singleton, Finset.card_singleton, Nat.cast_one, sub_self, add_zero, div_one] exact (le_div_iff₀ hc_pos).mpr (by linarith) · have hA2 : (2 : ℝ) ≤ (A.card : ℝ) := by have : 2 ≤ A.card := by have := hAne.card_pos; omega exact_mod_cast this -- Power-mean / Jensen on A: (∑_{y ∈ A} u y) / |A| ≤ ((∑_{y ∈ A} u y ^ q) / |A|)^(1/q) ≤ |A|^(-1/q)! set u : β → ℝ := fun y => max 0 (c * RLdim (restrict V x y) + 1 - T) have hu_sum_q : ∑ y ∈ A, u y ^ q ≤ 1 := le_trans (Finset.sum_le_sum_of_subset_of_nonneg hAS fun y _ _ => Real.rpow_nonneg (le_max_left 0 _) q) huq have hconv : ConvexOn ℝ (Set.Ici (0 : ℝ)) (fun z : ℝ => z ^ q) := convexOn_rpow hq have hj := hconv.map_sum_le (t := A) (w := fun _ => 1 / (A.card : ℝ)) (p := u) (fun _ _ => by positivity) (by rw [Finset.sum_const, nsmul_eq_mul, mul_one_div_cancel (ne_of_gt hcard_pos)]) (fun y _ => Set.mem_Ici.mpr (le_max_left 0 _)) simp only [smul_eq_mul, ← Finset.mul_sum] at hj have havg_pow : ((1 / (A.card : ℝ)) * ∑ y ∈ A, u y) ^ q ≤ (A.card : ℝ)⁻¹ := by have h1 : (1 / (A.card : ℝ)) * ∑ y ∈ A, u y ^ q ≤ (A.card : ℝ)⁻¹ := by have := mul_le_mul_of_nonneg_left hu_sum_q (by positivity : (0 : ℝ) ≤ 1 / (A.card : ℝ)) rw [mul_one, one_div] at this simpa [one_div] using this exact le_trans hj h1 have havg_le : (1 / (A.card : ℝ)) * ∑ y ∈ A, u y ≤ (A.card : ℝ) ^ (-(1 / q)) := by have hr_pow : ((A.card : ℝ) ^ (-(1 / q))) ^ q = (A.card : ℝ)⁻¹ := by rw [← Real.rpow_mul (le_of_lt hcard_pos), neg_mul, one_div_mul_cancel (ne_of_gt hq0), Real.rpow_neg_one] rw [← hr_pow] at havg_pow by_contra hgt; push Not at hgt have := Real.rpow_lt_rpow (Real.rpow_nonneg (le_of_lt hcard_pos) _) hgt hq0 linarith have hsum_u_le : ∑ y ∈ A, u y ≤ (A.card : ℝ) ^ (1 - 1 / q) := by have hmul := mul_le_mul_of_nonneg_left havg_le (le_of_lt hcard_pos) rw [← mul_assoc, mul_one_div_cancel (ne_of_gt hcard_pos), one_mul] at hmul have hrew : (A.card : ℝ) * (A.card : ℝ) ^ (-(1 / q)) = (A.card : ℝ) ^ (1 - 1 / q) := by rw [sub_eq_add_neg, Real.rpow_add hcard_pos, Real.rpow_one] rwa [hrew] at hmul have hsum_lin : ∑ y ∈ A, (c * RLdim (restrict V x y) + 1 - T) ≤ (A.card : ℝ) ^ (1 - 1 / q) := le_trans (Finset.sum_le_sum fun y _ => le_max_right 0 _) hsum_u_le have hrew_lin : ∑ y ∈ A, (c * RLdim (restrict V x y) + 1 - T) = c * (∑ y ∈ A, RLdim (restrict V x y)) + (A.card : ℝ) - (A.card : ℝ) * T := by rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_one] rw [hrew_lin] at hsum_lin have hconc := psph_ratio_concavity_bound hq hA2 rw [div_le_div_iff₀ hcard_pos hc_pos] dsimp only [c] at hsum_lin ⊢ linarith exact (le_div_iff₀ hc_pos).mp hle |> fun h => by linarith /-- **Exact Spherical vs. `RLdim` Universal Multiclass Sandwich (`2 - √2 ≈ 0.5858`)**: `(2 - Real.sqrt 2) * RLdim V ≤ SphOpt V ≤ RLdim V` for EVERY multiclass `V`! -/ theorem SphOpt_ge_two_sub_sqrt2_RLdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : (2 - Real.sqrt 2) * RLdim V ≤ SphOpt V ∧ SphOpt V ≤ RLdim V := by have h := PsphOpt_ge_alpha_mul_RLdim (q := 2) (by norm_num) V have hcoef : 2 * (1 - (2 : ℝ) ^ (-(1 / (2 : ℝ)))) = 2 - Real.sqrt 2 := by rw [Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2), ← Real.sqrt_eq_rpow] have hsq : Real.sqrt 2 * Real.sqrt 2 = 2 := Real.mul_self_sqrt (by norm_num) have hne : Real.sqrt 2 ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (by norm_num)) calc 2 * (1 - (Real.sqrt 2)⁻¹) = 2 - 2 * (Real.sqrt 2)⁻¹ := by ring _ = 2 - (Real.sqrt 2 * Real.sqrt 2) * (Real.sqrt 2)⁻¹ := by rw [hsq] _ = 2 - Real.sqrt 2 := by rw [mul_assoc, mul_inv_cancel₀ hne, mul_one] rwa [hcoef] at h /-! ## Part 5: Universal Multiclass Brier Halving Theorem (`BrierOpt V ≤ (1 / (4 ln 2)) * ln |V|`) -/ /-- Elementary Taylor lower bound `1 - x + x²/2 - x³/6 ≤ exp (-x)` for all `x ≥ 0`. -/ lemma exp_neg_ge_cubic {x : ℝ} (hx : 0 ≤ x) : 1 - x + x ^ 2 / 2 - x ^ 3 / 6 ≤ Real.exp (-x) := by set g : ℝ → ℝ := fun z => Real.exp z * (1 - z + z ^ 2 / 2 - z ^ 3 / 6) have hderiv : ∀ z : ℝ, HasDerivAt g (-(z ^ 3 / 6) * Real.exp z) z := by intro z have hp : HasDerivAt (fun u : ℝ => 1 - u + u ^ 2 / 2 - u ^ 3 / 6) (0 - 1 + 2 * z / 2 - 3 * z ^ 2 / 6) z := by have h1 : HasDerivAt (fun u : ℝ => (1 : ℝ) - u) (0 - 1) z := (hasDerivAt_const z 1).sub (hasDerivAt_id z) have h2 : HasDerivAt (fun u : ℝ => u ^ 2 / 2) (2 * z ^ (2 - 1) / 2) z := (hasDerivAt_pow 2 z).div_const 2 have h3 : HasDerivAt (fun u : ℝ => u ^ 3 / 6) (3 * z ^ (3 - 1) / 6) z := (hasDerivAt_pow 3 z).div_const 6 exact ((h1.fun_add h2).fun_sub h3).congr_deriv (by norm_num) exact ((Real.hasDerivAt_exp z).mul hp).congr_deriv (by ring) have hanti : g x ≤ g 0 := antitoneOn_of_deriv_nonpos (convex_Icc 0 x) (fun z _ => (hderiv z).continuousAt.continuousWithinAt) (fun z _ => (hderiv z).differentiableAt.differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz rw [(hderiv z).deriv] have hz0 : 0 ≤ z := le_of_lt hz.1 have : 0 ≤ z ^ 3 / 6 * Real.exp z := by positivity linarith) (Set.left_mem_Icc.mpr hx) (Set.right_mem_Icc.mpr hx) hx have hg0 : g 0 = 1 := by simp [g] rw [hg0] at hanti rw [Real.exp_neg, ← one_div, le_div_iff₀ (Real.exp_pos x)] dsimp only [g] at hanti; linarith /-- Elementary Taylor upper bound `exp y ≤ 1 + y + y²/2 + y³/6 + y⁴/12` for all `y ∈ [0, 2]`. -/ lemma exp_le_quartic {y : ℝ} (hy0 : 0 ≤ y) (hy2 : y ≤ 2) : Real.exp y ≤ 1 + y + y ^ 2 / 2 + y ^ 3 / 6 + y ^ 4 / 12 := by set h : ℝ → ℝ := fun z => Real.exp (-z) * (1 + z + z ^ 2 / 2 + z ^ 3 / 6 + z ^ 4 / 12) have hderiv : ∀ z : ℝ, HasDerivAt h (z ^ 3 * (2 - z) / 12 * Real.exp (-z)) z := by intro z have he : HasDerivAt (fun u : ℝ => Real.exp (-u)) (Real.exp (-z) * (-1)) z := ((hasDerivAt_id z).neg).exp have hp : HasDerivAt (fun u : ℝ => 1 + u + u ^ 2 / 2 + u ^ 3 / 6 + u ^ 4 / 12) (0 + 1 + 2 * z / 2 + 3 * z ^ 2 / 6 + 4 * z ^ 3 / 12) z := by have h1 : HasDerivAt (fun u : ℝ => (1 : ℝ) + u) (0 + 1) z := (hasDerivAt_const z 1).add (hasDerivAt_id z) have h2 : HasDerivAt (fun u : ℝ => u ^ 2 / 2) (2 * z ^ (2 - 1) / 2) z := (hasDerivAt_pow 2 z).div_const 2 have h3 : HasDerivAt (fun u : ℝ => u ^ 3 / 6) (3 * z ^ (3 - 1) / 6) z := (hasDerivAt_pow 3 z).div_const 6 have h4 : HasDerivAt (fun u : ℝ => u ^ 4 / 12) (4 * z ^ (4 - 1) / 12) z := (hasDerivAt_pow 4 z).div_const 12 exact (((h1.fun_add h2).fun_add h3).fun_add h4).congr_deriv (by norm_num) exact (he.mul hp).congr_deriv (by ring) have hmono : h 0 ≤ h y := monotoneOn_of_deriv_nonneg (convex_Icc 0 y) (fun z _ => (hderiv z).continuousAt.continuousWithinAt) (fun z _ => (hderiv z).differentiableAt.differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz rw [(hderiv z).deriv] have hz2 : 0 ≤ 2 - z := by linarith [hz.2] have hz3 : 0 ≤ z ^ 3 := pow_nonneg (le_of_lt hz.1) 3 positivity) (Set.left_mem_Icc.mpr hy0) (Set.right_mem_Icc.mpr hy0) hy0 have hh0 : h 0 = 1 := by simp [h] rw [hh0] at hmono dsimp only [h] at hmono rw [Real.exp_neg, inv_mul_eq_div, one_le_div (Real.exp_pos y)] at hmono exact hmono /-- Hyperbolic cosine domination on `[0, 1]`: `2 * exp (log 2 * t²) ≤ exp (2 * log 2 * t) + exp (-2 * log 2 * t)`. -/ lemma cosh_two_log2_ge_two_pow_sq {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : 2 * Real.exp (Real.log 2 * t ^ 2) ≤ Real.exp (2 * Real.log 2 * t) + Real.exp (-(2 * Real.log 2 * t)) := by set c := Real.log 2 have hc_lo : (693 / 1000 : ℝ) < c := by have := Real.log_two_gt_d9; linarith have hc_hi : c < (694 / 1000 : ℝ) := by have := Real.log_two_lt_d9; linarith have hx_nn : 0 ≤ 2 * c * t := by nlinarith have hy_nn : 0 ≤ c * t ^ 2 := by positivity have hy_le2 : c * t ^ 2 ≤ 2 := by nlinarith have hlow_pos : 1 + 2 * c * t + (2 * c * t) ^ 2 / 2 + (2 * c * t) ^ 3 / 6 + (2 * c * t) ^ 4 / 24 ≤ Real.exp (2 * c * t) := by have h := Real.sum_le_exp_of_nonneg hx_nn 5 simp [Finset.sum_range_succ, Nat.factorial] at h linarith have hlow_neg : 1 - 2 * c * t + (2 * c * t) ^ 2 / 2 - (2 * c * t) ^ 3 / 6 ≤ Real.exp (-(2 * c * t)) := exp_neg_ge_cubic hx_nn have hup := exp_le_quartic hy_nn hy_le2 have ht2_le1 : t ^ 2 ≤ 1 := by nlinarith have ht4_le1 : t ^ 4 ≤ 1 := by nlinarith have ht6_le1 : t ^ 6 ≤ 1 := by nlinarith have hc2_lo : (480249 / 1000000 : ℝ) < c ^ 2 := by nlinarith have hc2_hi : c ^ 2 < (481636 / 1000000 : ℝ) := by nlinarith have hc3_hi : c ^ 3 < (335 / 1000 : ℝ) := by nlinarith have hc4_lo : (230 / 1000 : ℝ) < c ^ 4 := by nlinarith have hc4_hi : c ^ 4 < (233 / 1000 : ℝ) := by nlinarith have hpoly : 0 ≤ (4 * c ^ 2 - 2 * c) + ((2 / 3 : ℝ) * c ^ 4 - c ^ 2) * t ^ 2 - (c ^ 3 / 3) * t ^ 4 - (c ^ 4 / 6) * t ^ 6 := by have h1 : (2 / 3 : ℝ) * c ^ 4 - c ^ 2 ≤ 0 := by linarith have h2 : ((2 / 3 : ℝ) * c ^ 4 - c ^ 2) * 1 ≤ ((2 / 3 : ℝ) * c ^ 4 - c ^ 2) * t ^ 2 := mul_le_mul_of_nonpos_left ht2_le1 h1 have h3 : (c ^ 3 / 3) * t ^ 4 ≤ c ^ 3 / 3 := by nlinarith have h4 : (c ^ 4 / 6) * t ^ 6 ≤ c ^ 4 / 6 := by nlinarith linarith have hmul_t2 : 0 ≤ t ^ 2 * ((4 * c ^ 2 - 2 * c) + ((2 / 3 : ℝ) * c ^ 4 - c ^ 2) * t ^ 2 - (c ^ 3 / 3) * t ^ 4 - (c ^ 4 / 6) * t ^ 6) := mul_nonneg (sq_nonneg t) hpoly have hident : 2 + 4 * c ^ 2 * t ^ 2 + (2 / 3 : ℝ) * c ^ 4 * t ^ 4 - 2 * (1 + c * t ^ 2 + (c * t ^ 2) ^ 2 / 2 + (c * t ^ 2) ^ 3 / 6 + (c * t ^ 2) ^ 4 / 12) = t ^ 2 * ((4 * c ^ 2 - 2 * c) + ((2 / 3 : ℝ) * c ^ 4 - c ^ 2) * t ^ 2 - (c ^ 3 / 3) * t ^ 4 - (c ^ 4 / 6) * t ^ 6) := by ring linarith /-- **Brier Subadditivity Merging Law**: for ALL `a, b ≥ 0` with `a + b ≤ 1`, `exp (4 * log 2 * (a + b - a * b)) ≤ exp (4 * log 2 * a) + exp (4 * log 2 * b)` (equivalently `16^(a + b - a*b) ≤ 16^a + 16^b`, equality at `(1/2, 1/2)`)! -/ theorem brier_merge_ineq {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b ≤ 1) : Real.exp (4 * Real.log 2 * (a + b - a * b)) ≤ Real.exp (4 * Real.log 2 * a) + Real.exp (4 * Real.log 2 * b) := by set c := Real.log 2 have hc_pos : 0 < c := Real.log_pos (by norm_num) set s := a + b set t := |a - b| have ht0 : 0 ≤ t := abs_nonneg _ have ht1 : t ≤ 1 := by dsimp only [t]; rw [abs_le]; exact ⟨by linarith, by linarith⟩ have hs_bound : s / 2 - s ^ 2 / 4 ≤ 1 / 4 := by nlinarith [sq_nonneg (s - 1)] have hcosh := cosh_two_log2_ge_two_pow_sq ht0 ht1 have hpow_le : Real.exp (4 * c * (s / 2 - s ^ 2 / 4 + t ^ 2 / 4)) ≤ 2 * Real.exp (c * t ^ 2) := by have h1 : 4 * c * (s / 2 - s ^ 2 / 4 + t ^ 2 / 4) ≤ c + c * t ^ 2 := by nlinarith calc Real.exp (4 * c * (s / 2 - s ^ 2 / 4 + t ^ 2 / 4)) ≤ Real.exp (c + c * t ^ 2) := Real.exp_le_exp.mpr h1 _ = Real.exp c * Real.exp (c * t ^ 2) := Real.exp_add _ _ _ = 2 * Real.exp (c * t ^ 2) := by dsimp only [c]; rw [Real.exp_log (by norm_num : (0 : ℝ) < 2)] have hsum_eq : Real.exp (2 * c * t) + Real.exp (-(2 * c * t)) = Real.exp (2 * c * (a - b)) + Real.exp (2 * c * (b - a)) := by rcases le_total b a with h | h · have ht_eq : t = a - b := abs_of_nonneg (sub_nonneg.mpr h) rw [ht_eq]; congr 2; ring · have ht_eq : t = b - a := by dsimp only [t]; rw [abs_of_nonpos (sub_nonpos.mpr h)]; ring rw [ht_eq, add_comm]; congr 2; ring have hmid : Real.exp (4 * c * (s / 2 - s ^ 2 / 4 + t ^ 2 / 4)) ≤ Real.exp (2 * c * (a - b)) + Real.exp (2 * c * (b - a)) := by rw [← hsum_eq]; exact le_trans hpow_le hcosh have hmul := mul_le_mul_of_nonneg_left hmid (le_of_lt (Real.exp_pos (2 * c * s))) have hlhs : Real.exp (2 * c * s) * Real.exp (4 * c * (s / 2 - s ^ 2 / 4 + t ^ 2 / 4)) = Real.exp (4 * c * (a + b - a * b)) := by rw [← Real.exp_add] congr 1 have ht_sq : t ^ 2 = (a - b) ^ 2 := sq_abs (a - b) rw [ht_sq]; dsimp only [s]; ring have hrhs : Real.exp (2 * c * s) * (Real.exp (2 * c * (a - b)) + Real.exp (2 * c * (b - a))) = Real.exp (4 * c * a) + Real.exp (4 * c * b) := by rw [mul_add, ← Real.exp_add, ← Real.exp_add] dsimp only [s]; congr 1 <;> congr 1 <;> ring linarith /-- **Multiclass Brier Simplex Inequality (Arbitrary Cardinality `|S| ≥ 1`)**: For EVERY finite nonempty `S` and EVERY probability distribution `p` on `S`: `exp (2 * log 2 * (1 + ∑ y ∈ S, (p y)²)) ≤ ∑ y ∈ S, exp (4 * log 2 * p y)` (equivalently `4^(1 + ‖p‖₂²) ≤ ∑ 16^{p_y}`, i.e. `∑ y ∈ S, exp (-2 * log 2 * ‖p - e_y‖₂²) ≥ 1`)! -/ theorem multiclass_brier_simplex_ineq {β : Type*} [DecidableEq β] : ∀ (S : Finset β), S.Nonempty → ∀ (p : β → ℝ), (∀ y ∈ S, 0 ≤ p y) → (∑ y ∈ S, p y = 1) → Real.exp (2 * Real.log 2 * (1 + ∑ y ∈ S, p y ^ 2)) ≤ ∑ y ∈ S, Real.exp (4 * Real.log 2 * p y) := by intro S induction hn : S.card using Nat.strong_induction_on generalizing S with | h n ih => subst hn intro hS p hp0 hpsum by_cases h1 : S.card = 1 · rcases Finset.card_eq_one.mp h1 with ⟨y0, rfl⟩ simp only [Finset.sum_singleton] at hpsum ⊢ rw [hpsum]; exact le_of_eq (by congr 1; ring) · have h2 : 2 ≤ S.card := by have := hS.card_pos; omega obtain ⟨y₁, hy₁, y₂, hy₂, hne⟩ := Finset.one_lt_card.mp (by omega : 1 < S.card) -- Merge y₁ and y₂ into y₁ on S' = S.erase y₂! set S' := S.erase y₂ have hy₁' : y₁ ∈ S' := Finset.mem_erase.mpr ⟨hne, hy₁⟩ have hS'_ne : S'.Nonempty := ⟨y₁, hy₁'⟩ have hS'_card : S'.card < S.card := Finset.card_erase_lt_of_mem hy₂ set a := p y₁ set b := p y₂ have ha : 0 ≤ a := hp0 y₁ hy₁ have hb : 0 ≤ b := hp0 y₂ hy₂ have hab : a + b ≤ 1 := by rw [← hpsum] have hsub : ({y₁, y₂} : Finset β) ⊆ S := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl; exact hy₁; exact hy₂ calc a + b = ∑ z ∈ ({y₁, y₂} : Finset β), p z := (Finset.sum_pair hne).symm _ ≤ ∑ z ∈ S, p z := Finset.sum_le_sum_of_subset_of_nonneg hsub fun z hz _ => hp0 z hz set p' : β → ℝ := fun z => if z = y₁ then a + b else p z have hp'0 : ∀ z ∈ S', 0 ≤ p' z := fun z hz => by dsimp only [p']; split_ifs · linarith · exact hp0 z (Finset.mem_of_mem_erase hz) have hS'_split : S' = insert y₁ (S'.erase y₁) := (Finset.insert_erase hy₁').symm have hS_split : S = insert y₂ S' := (Finset.insert_erase hy₂).symm have hy₁_nmem : y₁ ∉ S'.erase y₁ := Finset.notMem_erase y₁ S' have hy₂_nmem : y₂ ∉ S' := Finset.notMem_erase y₂ S have hsum_rest : ∀ (f : β → ℝ), (∀ z ∈ S'.erase y₁, f z = f z) → ∑ z ∈ S, f z = f y₁ + f y₂ + ∑ z ∈ S'.erase y₁, f z := by intro f _ conv_lhs => rw [hS_split, Finset.sum_insert hy₂_nmem, hS'_split, Finset.sum_insert hy₁_nmem] ring have hp'sum : ∑ z ∈ S', p' z = 1 := by rw [hS'_split, Finset.sum_insert hy₁_nmem] have hrest : ∑ z ∈ S'.erase y₁, p' z = ∑ z ∈ S'.erase y₁, p z := Finset.sum_congr rfl fun z hz => by dsimp only [p']; rw [if_neg (Finset.ne_of_mem_erase hz)] rw [hrest]; simp only [p', ↓reduceIte] have hSsum := hsum_rest p (fun _ _ => rfl) dsimp only [a, b]; linarith have hih := ih S'.card hS'_card S' rfl hS'_ne p' hp'0 hp'sum -- Compare ∑_{S'} p'^2 = ∑_S p^2 + 2*a*b! have hsq_rel : ∑ z ∈ S', p' z ^ 2 = (∑ z ∈ S, p z ^ 2) + 2 * a * b := by rw [hS'_split, Finset.sum_insert hy₁_nmem] have hrest : ∑ z ∈ S'.erase y₁, p' z ^ 2 = ∑ z ∈ S'.erase y₁, p z ^ 2 := Finset.sum_congr rfl fun z hz => by dsimp only [p']; rw [if_neg (Finset.ne_of_mem_erase hz)] rw [hrest]; simp only [p', ↓reduceIte] have hSsq := hsum_rest (fun z => p z ^ 2) (fun _ _ => rfl) dsimp only [a, b] at *; linarith -- Factor out exp(4 * log 2 * (a * b)) ≥ 1! have hfac_lhs : Real.exp (2 * Real.log 2 * (1 + ∑ z ∈ S', p' z ^ 2)) = Real.exp (4 * Real.log 2 * (a * b)) * Real.exp (2 * Real.log 2 * (1 + ∑ z ∈ S, p z ^ 2)) := by rw [hsq_rel, ← Real.exp_add]; congr 1; ring have hmerge := brier_merge_ineq ha hb hab have hmerge_mul : Real.exp (4 * Real.log 2 * (a + b)) ≤ Real.exp (4 * Real.log 2 * (a * b)) * (Real.exp (4 * Real.log 2 * a) + Real.exp (4 * Real.log 2 * b)) := by have hmul := mul_le_mul_of_nonneg_left hmerge (le_of_lt (Real.exp_pos (4 * Real.log 2 * (a * b)))) rw [← Real.exp_add] at hmul have heq : 4 * Real.log 2 * (a * b) + 4 * Real.log 2 * (a + b - a * b) = 4 * Real.log 2 * (a + b) := by ring rwa [heq] at hmul have hfac_ge1 : 1 ≤ Real.exp (4 * Real.log 2 * (a * b)) := Real.one_le_exp (by have := Real.log_pos (by norm_num : (1 : ℝ) < 2); positivity) have hrhs_le : ∑ z ∈ S', Real.exp (4 * Real.log 2 * p' z) ≤ Real.exp (4 * Real.log 2 * (a * b)) * ∑ z ∈ S, Real.exp (4 * Real.log 2 * p z) := by rw [hS'_split, Finset.sum_insert hy₁_nmem] have hrest : ∑ z ∈ S'.erase y₁, Real.exp (4 * Real.log 2 * p' z) = ∑ z ∈ S'.erase y₁, Real.exp (4 * Real.log 2 * p z) := Finset.sum_congr rfl fun z hz => by dsimp only [p']; rw [if_neg (Finset.ne_of_mem_erase hz)] rw [hrest]; simp only [p', ↓reduceIte] have hSexp := hsum_rest (fun z => Real.exp (4 * Real.log 2 * p z)) (fun _ _ => rfl) rw [hSexp] have hR_nn : 0 ≤ ∑ z ∈ S'.erase y₁, Real.exp (4 * Real.log 2 * p z) := Finset.sum_nonneg fun _ _ => le_of_lt (Real.exp_pos _) have hR_le : ∑ z ∈ S'.erase y₁, Real.exp (4 * Real.log 2 * p z) ≤ Real.exp (4 * Real.log 2 * (a * b)) * ∑ z ∈ S'.erase y₁, Real.exp (4 * Real.log 2 * p z) := le_mul_of_one_le_left hR_nn hfac_ge1 dsimp only [a, b] at hmerge_mul ⊢ linarith have hcomb := le_trans (hfac_lhs ▸ hih) hrhs_le exact le_of_mul_le_mul_left hcomb (Real.exp_pos _) /-- **1-Step Multiclass Brier Halving Lemma**: For EVERY finite nonempty `S` and positive weights `w` with `∑ y ∈ S, w y = N`, `brierVal S (fun y => (1 / (4 * log 2)) * log (w y)) ≤ (1 / (4 * log 2)) * log N`! -/ theorem brierVal_quarter_log2_step {β : Type*} [DecidableEq β] {S : Finset β} (hS : S.Nonempty) {w : β → ℝ} (hw : ∀ y ∈ S, 0 < w y) (N : ℝ) (hN : ∑ y ∈ S, w y = N) : brierVal S (fun y => (1 / (4 * Real.log 2)) * Real.log (w y)) ≤ (1 / (4 * Real.log 2)) * Real.log N := by set C := 1 / (4 * Real.log 2) have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) have hC_pos : 0 < C := by positivity have hN_pos : 0 < N := by rcases hS with ⟨y0, hy0⟩ linarith [hw y0 hy0, Finset.single_le_sum (fun y hy => le_of_lt (hw y hy)) hy0] set v : β → ℝ := fun y => C * Real.log (w y) set T := brierVal S v set p := wfForecast S v have hp0 : ∀ y ∈ S, 0 ≤ p y := fun y _ => wfForecast_nonneg S v y have hpsum : ∑ y ∈ S, p y = 1 := wfForecast_sum_eq_one hS v -- On every y ∈ S, v y + brierLoss S p y ≤ T => w y ≥ exp((T - brierLoss S p y) / C)? -- Wait: we want the OPPOSITE direction! On active y (p y > 0), equality holds! -- Actually: on ALL y ∈ S, p y ≥ v y - lam => v y ≤ lam + p y = T - brierLoss S p y? -- Check: T = lam + (1 + ∑ p²)/2, so T - brierLoss S p y = lam + p y ≥ v y ALWAYS? -- WAIT: we need w y ≤ ... to sum to N, i.e. v y ≥ T - brierLoss S p y on the active set A! set A := S.filter fun y => 0 < p y have hp_zero : ∀ y ∈ S, y ∉ A → p y = 0 := fun y hy hnot => by have hle : p y ≤ 0 := by by_contra hpos; push Not at hpos; exact hnot (Finset.mem_filter.mpr ⟨hy, hpos⟩) exact le_antisymm hle (hp0 y hy) have hAsum : ∑ y ∈ A, p y = 1 := by rw [← hpsum] exact Finset.sum_subset (Finset.filter_subset _ S) fun y hy hnot => hp_zero y hy hnot have hAne : A.Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp rw [hemp, Finset.sum_empty] at hAsum; norm_num at hAsum have hAsq : ∑ y ∈ A, p y ^ 2 = ∑ y ∈ S, p y ^ 2 := Finset.sum_subset (Finset.filter_subset _ S) fun y hy hnot => by rw [hp_zero y hy hnot]; norm_num have hsimp := multiclass_brier_simplex_ineq A hAne p (fun y hy => hp0 y (Finset.mem_of_mem_filter y hy)) hAsum -- On every y ∈ A, v y + brierLoss S p y = T, so w y = exp(T / C) * exp(-brierLoss S p y / C)! have hw_eq : ∀ y ∈ A, w y = Real.exp (T / C) * Real.exp (-brierLoss S p y / C) := by intro y hy have hyS : y ∈ S := (Finset.mem_filter.mp hy).1 have hpos : 0 < p y := (Finset.mem_filter.mp hy).2 have heq := (brierVal_primal_upper hS v).2 y hyS hpos have hvy : Real.log (w y) = (T - brierLoss S p y) / C := by dsimp only [v, T] at heq ⊢ rw [eq_div_iff (ne_of_gt hC_pos)]; linarith rw [← Real.exp_log (hw y hyS), hvy, ← Real.exp_add] congr 1; ring have hsum_A_le_N : ∑ y ∈ A, w y ≤ N := by rw [← hN] exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ S) fun y hy _ => le_of_lt (hw y hy) have hsum_exp_ge1 : 1 ≤ ∑ y ∈ A, Real.exp (-brierLoss S p y / C) := by have hrew : ∀ y ∈ A, -brierLoss S p y / C = 4 * Real.log 2 * p y - 2 * Real.log 2 * (1 + ∑ z ∈ A, p z ^ 2) := by intro y _ dsimp only [brierLoss, C] rw [hAsq, div_div_eq_mul_div, div_one]; ring have hsum_rew : ∑ y ∈ A, Real.exp (-brierLoss S p y / C) = (∑ y ∈ A, Real.exp (4 * Real.log 2 * p y)) / Real.exp (2 * Real.log 2 * (1 + ∑ z ∈ A, p z ^ 2)) := by rw [Finset.sum_div] refine Finset.sum_congr rfl fun y hy => ?_ rw [hrew y hy, Real.exp_sub] rw [hsum_rew, one_le_div (Real.exp_pos _)] exact hsimp have hexp_le_N : Real.exp (T / C) ≤ N := by calc Real.exp (T / C) = Real.exp (T / C) * 1 := (mul_one _).symm _ ≤ Real.exp (T / C) * ∑ y ∈ A, Real.exp (-brierLoss S p y / C) := mul_le_mul_of_nonneg_left hsum_exp_ge1 (le_of_lt (Real.exp_pos _)) _ = ∑ y ∈ A, Real.exp (T / C) * Real.exp (-brierLoss S p y / C) := Finset.mul_sum _ _ _ _ = ∑ y ∈ A, w y := Finset.sum_congr rfl fun y hy => (hw_eq y hy).symm _ ≤ N := hsum_A_le_N have hlog := Real.log_le_log (Real.exp_pos _) hexp_le_N rw [Real.log_exp] at hlog have := (div_le_iff₀ hC_pos).mp hlog linarith /-- **UNIVERSAL MULTICLASS BRIER HALVING THEOREM (ZERO DEPENDENCE ON `|β|`)**: For EVERY finite nonempty concept class `V` over ANY label space `β` (binary, `k`-class, or infinite!): `BrierOpt V ≤ (1 / (4 * Real.log 2)) * Real.log |V|`, strictly improving Vovk's classical `(1/2) * log |V|` multiclass Brier aggregating bound by **> 27.8%**! -/ theorem BrierOpt_le_quarter_log2_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : BrierOpt V ≤ (1 / (4 * Real.log 2)) * Real.log (V.card : ℝ) := by have hC_nn : 0 ≤ 1 / (4 * Real.log 2) := by have := Real.log_pos (by norm_num : (1 : ℝ) < 2); positivity induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hlog_nn : 0 ≤ Real.log (V.card : ℝ) := Real.log_nonneg (by exact_mod_cast hV.card_pos) refine BrierOpt_le_of_forall_x V (mul_nonneg hC_nn hlog_nn) fun x hsp => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) calc brierVal (labels V x) (fun y => BrierOpt (restrict V x y)) ≤ brierVal (labels V x) (fun y => (1 / (4 * Real.log 2)) * Real.log ((restrict V x y).card : ℝ)) := brierVal_mono_v fun y hy => ih _ (card_restrict_lt_of_two_labels hsp y) ((restrict_nonempty_iff V x y).mpr hy) rfl _ ≤ (1 / (4 * Real.log 2)) * Real.log (V.card : ℝ) := brierVal_quarter_log2_step hS (w := fun y => ((restrict V x y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x y).mpr hy).card_pos) (V.card : ℝ) (by exact_mod_cast sum_card_restrict V x) /-- **Strict `> 27.8%` Improvement Over Vovk's Multiclass Brier Mixability Constant (`1/2`)**. -/ theorem BrierOpt_beats_vovk_by_27pct : 1 / (4 * Real.log 2) < (722 / 1000 : ℝ) * (1 / 2) := by have hlog2_lo := Real.log_two_gt_d9 rw [div_lt_iff₀ (by linarith : 0 < 4 * Real.log 2)]; linarith /-! ## Part 6: Universal Multiclass Pseudospherical & Spherical Halving Theorem (`q ≥ 1`, All `|β|`) -/ /-- Zero-root-finding endpoint minimum helper: if `g'` never goes from `< 0` to `> 0` on `(a, b)`, then `min (g a) (g b) ≤ g t` for all `t ∈ [a, b]`. -/ private lemma min_at_endpoints_of_deriv_sign_change {g : ℝ → ℝ} {a b : ℝ} (_hab : a ≤ b) (hcont : ContinuousOn g (Set.Icc a b)) (hdiff : ∀ x ∈ Set.Ioo a b, DifferentiableAt ℝ g x) (hsign : ∀ x ∈ Set.Ioo a b, ∀ y ∈ Set.Ioo a b, x < y → deriv g x < 0 → deriv g y ≤ 0) : ∀ t ∈ Set.Icc a b, min (g a) (g b) ≤ g t := by intro t ⟨hat, htb⟩ by_cases hneg : ∃ x₀ ∈ Set.Ioo a t, deriv g x₀ < 0 · rcases hneg with ⟨x₀, ⟨hax₀, hx₀t⟩, hdx₀⟩ refine le_trans (min_le_right _ _) ?_ refine antitoneOn_of_deriv_nonpos (convex_Icc t b) (hcont.mono fun z hz => ⟨le_trans hat hz.1, hz.2⟩) (fun z hz => by rw [interior_Icc] at hz exact (hdiff z ⟨lt_of_le_of_lt hat hz.1, hz.2⟩).differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz exact hsign x₀ ⟨hax₀, lt_of_lt_of_le hx₀t htb⟩ z ⟨lt_of_le_of_lt hat hz.1, hz.2⟩ (lt_trans hx₀t hz.1) hdx₀) (Set.left_mem_Icc.mpr htb) (Set.right_mem_Icc.mpr htb) htb · push Not at hneg refine le_trans (min_le_left _ _) ?_ refine monotoneOn_of_deriv_nonneg (convex_Icc a t) (hcont.mono fun z hz => ⟨hz.1, le_trans hz.2 htb⟩) (fun z hz => by rw [interior_Icc] at hz exact (hdiff z ⟨hz.1, lt_of_lt_of_le hz.2 htb⟩).differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz; exact hneg z hz) (Set.left_mem_Icc.mpr hat) (Set.right_mem_Icc.mpr hat) hat /-- The sharp pseudospherical halving constant `C_q = (1 - 2^(-1/q)) / log 2`. -/ def psphConst (q : ℝ) : ℝ := (1 - (2 : ℝ) ^ (-(1 / q))) / Real.log 2 lemma psphConst_pos {q : ℝ} (hq : 0 < q) : 0 < psphConst q := by have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) have hlt : (2 : ℝ) ^ (-(1 / q)) < (2 : ℝ) ^ (0 : ℝ) := Real.rpow_lt_rpow_of_exponent_lt (by norm_num) (by rw [neg_lt_zero]; positivity) rw [Real.rpow_zero] at hlt exact div_pos (by linarith) hlog2 /-- The pseudospherical exponential potential `φ_q(x) = exp (-(1 - x^(1/q)) / psphConst q)`. -/ def psphPhi (q x : ℝ) : ℝ := Real.exp (-(1 - x ^ (1 / q)) / psphConst q) /-- Elementary inequality `(1 - u / 2) * exp u < 1 + u / 2` for all `u > 0`, used to prove `Q'(1/2) > 0` for all `q > 1`! -/ private lemma one_sub_half_mul_exp_lt {u : ℝ} (hu0 : 0 < u) : (1 - u / 2) * Real.exp u < 1 + u / 2 := by set f : ℝ → ℝ := fun z => (1 - z / 2) * Real.exp z - (1 + z / 2) have hf_deriv : ∀ z : ℝ, HasDerivAt f ((1 - z) * Real.exp z / 2 - 1 / 2) z := by intro z have h1 : HasDerivAt (fun x : ℝ => 1 - x / 2) (-(1 / 2)) z := by simpa using HasDerivAt.const_sub 1 ((hasDerivAt_id z).div_const 2) have h2 : HasDerivAt (fun x : ℝ => 1 + x / 2) (1 / 2) z := by simpa using ((hasDerivAt_id z).div_const 2).const_add 1 exact ((h1.mul (Real.hasDerivAt_exp z)).sub h2).congr_deriv (by ring) have hf_neg : ∀ z > 0, (1 - z) * Real.exp z / 2 - 1 / 2 < 0 := by intro z hz -- (1 - z) * exp z < 1 since 1 - z < exp (-z) (from exp z > 1 + z? Wait: (1 - z) * exp z ≤ exp(-z) * exp z = 1, strict for z > 0!) have hlt : 1 - z < Real.exp (-z) := by have h1 := Real.add_one_lt_exp (ne_of_lt (neg_lt_zero.mpr hz)) linarith have hmul := mul_lt_mul_of_pos_right hlt (Real.exp_pos z) rw [← Real.exp_add, neg_add_cancel, Real.exp_zero] at hmul linarith have hanti : StrictAntiOn f (Set.Icc 0 u) := strictAntiOn_of_deriv_neg (convex_Icc 0 u) (fun z _ => (hf_deriv z).continuousAt.continuousWithinAt) (fun z hz => by rw [interior_Icc] at hz; rw [(hf_deriv z).deriv]; exact hf_neg z hz.1) have hf0 : f 0 = 0 := by simp [f] have hlt := hanti (Set.left_mem_Icc.mpr (le_of_lt hu0)) (Set.right_mem_Icc.mpr (le_of_lt hu0)) hu0 dsimp only [f] at hlt hf0; linarith /-- **Binary Pseudospherical Exponential Inequality (`∀ q ≥ 1, ∀ t ∈ [0, 1], φ_q(t) + φ_q(1 - t) ≥ 1`)**: proved via strict concavity of `K(t) = (1 - t) t^(1/q) + t (1 - t)^(1/q)` and zero-root-finding sign-change cascade! -/ theorem psphPhi_binary_ge_one {q : ℝ} (hq : 1 ≤ q) : ∀ t ∈ Set.Icc (0 : ℝ) 1, 1 ≤ psphPhi q t + psphPhi q (1 - t) := by have hq0 : 0 < q := by linarith have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) have hC_pos : 0 < psphConst q := psphConst_pos hq0 -- Reduce by symmetry t ↔ 1 - t to t ∈ [0, 1/2] suffices hhalf : ∀ t ∈ Set.Icc (0 : ℝ) (1 / 2), 1 ≤ psphPhi q t + psphPhi q (1 - t) by intro t ⟨ht0, ht1⟩ rcases le_total t (1 / 2) with hle | hge · exact hhalf t ⟨ht0, hle⟩ · rw [add_comm] have h := hhalf (1 - t) ⟨by linarith, by linarith⟩ simpa using h -- Case q = 1: elementary AM-GM! by_cases hq1 : q = 1 · subst hq1 intro t _ dsimp only [psphPhi, psphConst] have hC1 : (1 - (2 : ℝ) ^ (-(1 / (1 : ℝ)))) / Real.log 2 = 1 / (2 * Real.log 2) := by rw [div_one, Real.rpow_neg_one]; field_simp; ring rw [hC1, div_one, Real.rpow_one, Real.rpow_one] have he1 : Real.exp (-(1 - t) / (1 / (2 * Real.log 2))) = (1 / 2) * Real.exp (Real.log 2 * (2 * t - 1)) := by have hexp : -(1 - t) / (1 / (2 * Real.log 2)) = -Real.log 2 + Real.log 2 * (2 * t - 1) := by rw [div_div_eq_mul_div, div_one]; ring rw [hexp, Real.exp_add, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2), one_div] have he2 : Real.exp (-(1 - (1 - t)) / (1 / (2 * Real.log 2))) = (1 / 2) * (Real.exp (Real.log 2 * (2 * t - 1)))⁻¹ := by have hexp : -(1 - (1 - t)) / (1 / (2 * Real.log 2)) = -Real.log 2 + -(Real.log 2 * (2 * t - 1)) := by rw [div_div_eq_mul_div, div_one]; ring rw [hexp, Real.exp_add, Real.exp_neg, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2), one_div] rw [he1, he2] set a := Real.exp (Real.log 2 * (2 * t - 1)) have ha : 0 < a := Real.exp_pos _ have ham : 2 ≤ a + a⁻¹ := by have hdiv := (le_div_iff₀ ha).mpr (by nlinarith [sq_nonneg (a - 1)] : 2 * a ≤ a * a + 1) have hrew : (a * a + 1) / a = a + a⁻¹ := by rw [add_div, mul_div_cancel_right₀ _ (ne_of_gt ha), one_div] linarith linarith -- Case q > 1: let s = 1 / q ∈ (0, 1) and a = 1 / psphConst q = log 2 / (1 - 2^(-s)) > 0! have hq_gt1 : 1 < q := lt_of_le_of_ne hq (Ne.symm hq1) set s := 1 / q have hs0 : 0 < s := by positivity have hs1 : s < 1 := (div_lt_one hq0).mpr hq_gt1 set a := 1 / psphConst q have ha_pos : 0 < a := by positivity set g : ℝ → ℝ := fun t => psphPhi q t + psphPhi q (1 - t) set K : ℝ → ℝ := fun t => (1 - t) * t ^ s + t * (1 - t) ^ s set Q : ℝ → ℝ := fun t => (s - 1) * Real.log (t / (1 - t)) + a * (t ^ s - (1 - t) ^ s) -- Step 1: K is strictly increasing on (0, 1/2] because u(t) = (1 - t)*t^s has u''(t) < 0 on (0, 1)! have hK_deriv : ∀ t ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt K ((s * t ^ (s - 1) - (s + 1) * t ^ s) - (s * (1 - t) ^ (s - 1) - (s + 1) * (1 - t) ^ s)) t := by intro t ⟨ht0, ht1⟩ have hu : ∀ z > 0, HasDerivAt (fun x : ℝ => (1 - x) * x ^ s) (s * z ^ (s - 1) - (s + 1) * z ^ s) z := by intro z hz have h1 : HasDerivAt (fun x : ℝ => (1 : ℝ) - x) (-1) z := HasDerivAt.const_sub 1 (hasDerivAt_id z) have h2 : HasDerivAt (fun x : ℝ => x ^ s) (s * z ^ (s - 1)) z := Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt hz)) refine (h1.mul h2).congr_deriv ?_ have hpow : z ^ (s - 1) * z = z ^ s := by rw [← Real.rpow_add_one (ne_of_gt hz)]; ring_nf calc (-1) * z ^ s + (1 - z) * (s * z ^ (s - 1)) = s * z ^ (s - 1) - z ^ s - s * (z ^ (s - 1) * z) := by ring _ = s * z ^ (s - 1) - (s + 1) * z ^ s := by rw [hpow]; ring have hleft := hu t ht0 have hright : HasDerivAt (fun x : ℝ => x * (1 - x) ^ s) (-(s * (1 - t) ^ (s - 1) - (s + 1) * (1 - t) ^ s)) t := by have hcomp := (hu (1 - t) (sub_pos.mpr ht1)).comp t (HasDerivAt.const_sub 1 (hasDerivAt_id t)) have hfun : ((fun x : ℝ => (1 - x) * x ^ s) ∘ HSub.hSub 1) = fun x => x * (1 - x) ^ s := by ext x; simp only [Function.comp_apply]; ring rw [hfun] at hcomp exact hcomp.congr_deriv (by ring) exact (hleft.add hright).congr_deriv (by ring) have hK_strictMono : StrictMonoOn K (Set.Ioc 0 (1 / 2)) := by -- Show K'(t) > 0 on (0, 1/2) because φ(z) = s*z^(s-1) - (s+1)*z^s is STRICTLY DECREASING on (0, 1)! have hφ_anti : StrictAntiOn (fun z : ℝ => s * z ^ (s - 1) - (s + 1) * z ^ s) (Set.Ioi 0) := by intro x hx y hy hxy have h1 : y ^ (s - 1) < x ^ (s - 1) := Real.rpow_lt_rpow_of_neg hx hxy (by linarith) have h2 : x ^ s < y ^ s := Real.rpow_lt_rpow (le_of_lt hx) hxy hs0 nlinarith refine strictMonoOn_of_deriv_pos (convex_Ioc 0 (1 / 2)) ?_ ?_ · intro t ⟨ht0, ht2⟩ exact (hK_deriv t ⟨ht0, by linarith⟩).continuousAt.continuousWithinAt · intro t ht rw [interior_Ioc] at ht rw [(hK_deriv t ⟨ht.1, by linarith [ht.2]⟩).deriv] have hlt : t < 1 - t := by linarith [ht.2] have h := hφ_anti ht.1 (show (0 : ℝ) < 1 - t by linarith [ht.2]) hlt linarith -- Step 2: Q'(t) = (a * s * K(t) - (1 - s)) / (t * (1 - t)) on (0, 1), and Q'(1/2) > 0! have hQ_deriv : ∀ t ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt Q ((a * s * K t - (1 - s)) / (t * (1 - t))) t := by intro t ⟨ht0, ht1⟩ have h1t : 0 < 1 - t := sub_pos.mpr ht1 have hlog : HasDerivAt (fun z : ℝ => Real.log (z / (1 - z))) (1 / (t * (1 - t))) t := by have hq_d : HasDerivAt (fun z : ℝ => z / (1 - z)) ((1 * (1 - t) - t * (-1)) / (1 - t) ^ 2) t := (hasDerivAt_id t).div (HasDerivAt.const_sub 1 (hasDerivAt_id t)) (ne_of_gt h1t) have hl := hq_d.log (ne_of_gt (div_pos ht0 h1t)) refine hl.congr_deriv ?_ have ht_ne : t ≠ 0 := ne_of_gt ht0 have h1t_ne : 1 - t ≠ 0 := ne_of_gt h1t field_simp; ring have hd1 : HasDerivAt (fun z : ℝ => z ^ s) (s * t ^ (s - 1)) t := Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt ht0)) have hd2 : HasDerivAt (fun z : ℝ => (1 - z) ^ s) (s * (1 - t) ^ (s - 1) * (-1)) t := (Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt h1t))).comp t (HasDerivAt.const_sub 1 (hasDerivAt_id t)) refine ((hlog.const_mul (s - 1)).add ((hd1.sub hd2).const_mul a)).congr_deriv ?_ have hp1 : t ^ (s - 1) * t = t ^ s := by rw [← Real.rpow_add_one (ne_of_gt ht0)]; ring_nf have hp2 : (1 - t) ^ (s - 1) * (1 - t) = (1 - t) ^ s := by rw [← Real.rpow_add_one (ne_of_gt h1t)]; ring_nf have hK_eq : K t = t * (1 - t) * (t ^ (s - 1) + (1 - t) ^ (s - 1)) := by dsimp only [K] calc (1 - t) * t ^ s + t * (1 - t) ^ s = (1 - t) * (t ^ (s - 1) * t) + t * ((1 - t) ^ (s - 1) * (1 - t)) := by rw [hp1, hp2] _ = t * (1 - t) * (t ^ (s - 1) + (1 - t) ^ (s - 1)) := by ring rw [hK_eq] have ht_ne : t ≠ 0 := ne_of_gt ht0 have h1t_ne : 1 - t ≠ 0 := ne_of_gt h1t field_simp; ring have hQ'_half_pos : 0 < a * s * K (1 / 2) - (1 - s) := by -- Set u = s * log 2 ∈ (0, log 2): -- a * s * K(1/2) = s * log 2 * 2^(-s) / (1 - 2^(-s)) = u / (exp u - 1) > 1 - u/2 > 1 - s! set u := s * Real.log 2 have hu0 : 0 < u := mul_pos hs0 hlog2_pos have h2s : (2 : ℝ) ^ (-s) = Real.exp (-u) := by rw [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 2)]; dsimp only [u]; congr 1; ring have hK_half : K (1 / 2) = (2 : ℝ) ^ (-s) := by dsimp only [K] have h1 : (1 - (2 : ℝ)⁻¹) = (2 : ℝ)⁻¹ := by norm_num rw [show (1 / 2 : ℝ) = (2 : ℝ)⁻¹ by norm_num, h1, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2), Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2)] ring have hterm_eq : a * s * K (1 / 2) = u / (Real.exp u - 1) := by dsimp only [a, psphConst] rw [hK_half, h2s] have h1 : (1 - Real.exp (-u)) ≠ 0 := ne_of_gt (sub_pos.mpr (Real.exp_lt_one_iff.mpr (by linarith))) have h2 : Real.exp u - 1 ≠ 0 := ne_of_gt (sub_pos.mpr (Real.one_lt_exp_iff.mpr hu0)) have hmul : Real.exp u * Real.exp (-u) = 1 := by rw [← Real.exp_add, add_neg_cancel, Real.exp_zero] have hdiv_rew : 1 / ((1 - Real.exp (-u)) / Real.log 2) * s * Real.exp (-u) = (u * Real.exp (-u)) / (1 - Real.exp (-u)) := by dsimp only [u]; rw [one_div_div]; ring rw [hdiv_rew, div_eq_div_iff h1 h2] calc u * Real.exp (-u) * (Real.exp u - 1) = u * (Real.exp u * Real.exp (-u)) - u * Real.exp (-u) := by ring _ = u * 1 - u * Real.exp (-u) := by rw [hmul] _ = u * (1 - Real.exp (-u)) := by ring rw [hterm_eq] have hexp_sub_pos : 0 < Real.exp u - 1 := sub_pos.mpr (Real.one_lt_exp_iff.mpr hu0) have h1 : 1 - u / 2 < u / (Real.exp u - 1) := by rw [lt_div_iff₀ hexp_sub_pos] have h := one_sub_half_mul_exp_lt hu0 linarith have h2 : u / 2 < s := by have := Real.log_two_lt_d9; dsimp only [u]; nlinarith linarith -- Step 3: Q(x) < 0 → Q(y) ≤ 0 for 0 < x < y < 1/2! have hQ_neg_persist : ∀ x ∈ Set.Ioo (0 : ℝ) (1 / 2), ∀ y ∈ Set.Ioo (0 : ℝ) (1 / 2), x < y → Q x < 0 → Q y ≤ 0 := by intro x ⟨hx0, hx2⟩ y ⟨hy0, hy2⟩ hxy hQx by_contra hQy_pos; push Not at hQy_pos -- Since Q(1/2) = 0 and Q'(1/2) > 0, ∃ z ∈ (y, 1/2) with Q(z) < 0! have hQ_half : Q (1 / 2) = 0 := by dsimp only [Q] have h1 : (1 / 2 : ℝ) / (1 - 1 / 2) = 1 := by norm_num have h2 : (1 - 1 / 2 : ℝ) = 1 / 2 := by norm_num rw [h1, h2, Real.log_one, sub_self]; ring have hQ'_cont : ContinuousAt (fun z : ℝ => (a * s * K z - (1 - s)) / (z * (1 - z))) (1 / 2) := by have hKc : ContinuousAt K (1 / 2) := (hK_deriv (1 / 2) (by norm_num)).continuousAt exact ((continuousAt_const.mul hKc).sub continuousAt_const).div (continuousAt_id.mul (continuousAt_const.sub continuousAt_id)) (by norm_num) have hpos_val : 0 < (fun z : ℝ => (a * s * K z - (1 - s)) / (z * (1 - z))) (1 / 2) := div_pos hQ'_half_pos (by norm_num) have hev := hQ'_cont.eventually (lt_mem_nhds hpos_val) rcases Metric.eventually_nhds_iff.mp hev with ⟨δ, hδ_pos, hδ⟩ set z := max y (1 / 2 - δ / 2) have hz_lt_half : z < 1 / 2 := max_lt hy2 (by linarith) have hz_ge_y : y ≤ z := le_max_left _ _ have hQ_strict_mono : StrictMonoOn Q (Set.Icc z (1 / 2)) := strictMonoOn_of_deriv_pos (convex_Icc z (1 / 2)) (fun w hw => (hQ_deriv w ⟨lt_of_lt_of_le (lt_of_lt_of_le hy0 hz_ge_y) hw.1, lt_of_le_of_lt hw.2 (by norm_num)⟩).continuousAt.continuousWithinAt) (fun w hw => by rw [interior_Icc] at hw have hw0 : 0 < w := lt_trans (lt_of_lt_of_le hy0 hz_ge_y) hw.1 have hw1 : w < 1 := lt_trans hw.2 (by norm_num) rw [(hQ_deriv w ⟨hw0, hw1⟩).deriv] apply hδ rw [Real.dist_eq, abs_of_neg (sub_neg.mpr hw.2)] have : 1 / 2 - δ / 2 ≤ z := le_max_right _ _ linarith [hw.1]) have hQz_lt0 : Q z < 0 := by rw [← hQ_half] exact hQ_strict_mono (Set.left_mem_Icc.mpr (le_of_lt hz_lt_half)) (Set.right_mem_Icc.mpr (le_of_lt hz_lt_half)) hz_lt_half -- Now y < z (since Q y > 0 > Q z), so ∃ w ∈ (y, z) with Q'(w) < 0! have hyz : y < z := lt_of_le_of_ne hz_ge_y (fun heq => by rw [heq] at hQy_pos; linarith) have hex_w : ∃ w ∈ Set.Ioo y z, deriv Q w < 0 := by by_contra hall; push Not at hall have hmono : Q y ≤ Q z := monotoneOn_of_deriv_nonneg (convex_Icc y z) (fun u hu => (hQ_deriv u ⟨lt_of_lt_of_le hy0 hu.1, lt_of_le_of_lt hu.2 (lt_trans hz_lt_half (by norm_num))⟩).continuousAt.continuousWithinAt) (fun u hu => by rw [interior_Icc] at hu exact (hQ_deriv u ⟨lt_trans hy0 hu.1, lt_trans hu.2 (lt_trans hz_lt_half (by norm_num))⟩).differentiableAt.differentiableWithinAt) (fun u hu => by rw [interior_Icc] at hu; exact hall u hu) (Set.left_mem_Icc.mpr (le_of_lt hyz)) (Set.right_mem_Icc.mpr (le_of_lt hyz)) (le_of_lt hyz) linarith rcases hex_w with ⟨w, ⟨hyw, hwz⟩, hdw⟩ have hw1 : w < 1 := lt_trans (lt_trans hwz hz_lt_half) (by norm_num) have hKw_neg : a * s * K w - (1 - s) < 0 := by rw [(hQ_deriv w ⟨lt_trans hy0 hyw, hw1⟩).deriv] at hdw have hden : 0 < w * (1 - w) := mul_pos (lt_trans hy0 hyw) (sub_pos.mpr hw1) exact ((div_neg_iff.mp hdw).resolve_left (by push Not; intro _; linarith)).1 -- Since K is strictly increasing on (0, 1/2], for ALL u ∈ (x, y) ⊂ (0, w), K u < K w => Q'(u) < 0! have hQ_anti_xy : Q y ≤ Q x := antitoneOn_of_deriv_nonpos (convex_Icc x y) (fun u hu => (hQ_deriv u ⟨lt_of_lt_of_le hx0 hu.1, lt_of_le_of_lt hu.2 (lt_trans hy2 (by norm_num))⟩).continuousAt.continuousWithinAt) (fun u hu => by rw [interior_Icc] at hu exact (hQ_deriv u ⟨lt_trans hx0 hu.1, lt_trans hu.2 (lt_trans hy2 (by norm_num))⟩).differentiableAt.differentiableWithinAt) (fun u hu => by rw [interior_Icc] at hu have hu0 : 0 < u := lt_trans hx0 hu.1 have huw : u < w := lt_trans hu.2 hyw have hKu_lt : K u < K w := hK_strictMono ⟨hu0, le_of_lt (lt_trans hu.2 hy2)⟩ ⟨lt_trans hy0 hyw, le_of_lt (lt_trans hwz hz_lt_half)⟩ huw rw [(hQ_deriv u ⟨hu0, lt_trans hu.2 (lt_trans hy2 (by norm_num))⟩).deriv] have hmul_lt : a * s * K u < a * s * K w := mul_lt_mul_of_pos_left hKu_lt (mul_pos ha_pos hs0) have hnum : a * s * K u - (1 - s) ≤ 0 := by linarith exact div_nonpos_of_nonpos_of_nonneg hnum (le_of_lt (mul_pos hu0 (by linarith [hu.2])))) (Set.left_mem_Icc.mpr (le_of_lt hxy)) (Set.right_mem_Icc.mpr (le_of_lt hxy)) (le_of_lt hxy) linarith -- Step 4: g'(t) = a * s * (t^(s-1)*φ_q(t) - (1-t)^(s-1)*φ_q(1-t)), and g'(t) < 0 ↔ Q(t) < 0! have hg_deriv : ∀ t ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt g (a * s * (t ^ (s - 1) * psphPhi q t - (1 - t) ^ (s - 1) * psphPhi q (1 - t))) t := by intro t ⟨ht0, ht1⟩ have h1t : 0 < 1 - t := sub_pos.mpr ht1 have hphi1 : HasDerivAt (psphPhi q) (psphPhi q t * (a * (s * t ^ (s - 1)))) t := by have hd1 : HasDerivAt (fun z : ℝ => z ^ s) (s * t ^ (s - 1)) t := Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt ht0)) have hd2 : HasDerivAt (fun z : ℝ => -(1 - z ^ s) / psphConst q) ((0 - -(s * t ^ (s - 1))) / psphConst q) t := by simpa using ((HasDerivAt.const_sub 1 hd1).neg).div_const (psphConst q) have he : HasDerivAt (psphPhi q) (psphPhi q t * ((0 - -(s * t ^ (s - 1))) / psphConst q)) t := hd2.exp refine he.congr_deriv ?_ dsimp only [a]; rw [one_div_mul_eq_div]; ring have hphi2 : HasDerivAt (fun z : ℝ => psphPhi q (1 - z)) (-(psphPhi q (1 - t) * (a * (s * (1 - t) ^ (s - 1))))) t := by have hd1 : HasDerivAt (fun z : ℝ => (1 - z) ^ s) (s * (1 - t) ^ (s - 1) * (-1)) t := (Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt h1t))).comp t (HasDerivAt.const_sub 1 (hasDerivAt_id t)) have hd2 : HasDerivAt (fun z : ℝ => -(1 - (1 - z) ^ s) / psphConst q) ((-(0 - s * (1 - t) ^ (s - 1) * (-1))) / psphConst q) t := by simpa using ((HasDerivAt.const_sub 1 hd1).neg).div_const (psphConst q) have he : HasDerivAt (fun z : ℝ => psphPhi q (1 - z)) (psphPhi q (1 - t) * ((-(0 - s * (1 - t) ^ (s - 1) * (-1))) / psphConst q)) t := hd2.exp refine he.congr_deriv ?_ dsimp only [a]; rw [one_div_mul_eq_div]; ring exact (hphi1.add hphi2).congr_deriv (by ring) have hg_sign : ∀ x ∈ Set.Ioo (0 : ℝ) (1 / 2), ∀ y ∈ Set.Ioo (0 : ℝ) (1 / 2), x < y → deriv g x < 0 → deriv g y ≤ 0 := by intro x ⟨hx0, hx2⟩ y ⟨hy0, hy2⟩ hxy hdx rw [(hg_deriv x ⟨hx0, by linarith⟩).deriv] at hdx rw [(hg_deriv y ⟨hy0, by linarith⟩).deriv] have has_pos : 0 < a * s := mul_pos ha_pos hs0 have hphi_pos : ∀ z : ℝ, 0 < psphPhi q z := fun z => Real.exp_pos _ have hlt_x : x ^ (s - 1) * psphPhi q x < (1 - x) ^ (s - 1) * psphPhi q (1 - x) := by nlinarith have hQx : Q x < 0 := by have hlog := Real.log_lt_log (mul_pos (Real.rpow_pos_of_pos hx0 _) (hphi_pos x)) hlt_x rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos hx0 _)) (ne_of_gt (hphi_pos x)), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (hphi_pos (1 - x))), Real.log_rpow hx0, Real.log_rpow (by linarith)] at hlog dsimp only [psphPhi] at hlog rw [Real.log_exp, Real.log_exp] at hlog dsimp only [Q] rw [Real.log_div (ne_of_gt hx0) (by linarith)] have h1 : -(1 - x ^ s) / psphConst q = -a + a * x ^ s := by dsimp only [a]; rw [one_div_mul_eq_div]; ring have h2 : -(1 - (1 - x) ^ s) / psphConst q = -a + a * (1 - x) ^ s := by dsimp only [a]; rw [one_div_mul_eq_div]; ring rw [h1, h2] at hlog; linarith have hQy := hQ_neg_persist x ⟨hx0, hx2⟩ y ⟨hy0, hy2⟩ hxy hQx dsimp only [Q] at hQy rw [Real.log_div (ne_of_gt hy0) (by linarith)] at hQy have hlog_le : Real.log (y ^ (s - 1) * psphPhi q y) ≤ Real.log ((1 - y) ^ (s - 1) * psphPhi q (1 - y)) := by rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos hy0 _)) (ne_of_gt (hphi_pos y)), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (hphi_pos (1 - y))), Real.log_rpow hy0, Real.log_rpow (by linarith)] dsimp only [psphPhi] rw [Real.log_exp, Real.log_exp] have h1 : -(1 - y ^ s) / psphConst q = -a + a * y ^ s := by dsimp only [a]; rw [one_div_mul_eq_div]; ring have h2 : -(1 - (1 - y) ^ s) / psphConst q = -a + a * (1 - y) ^ s := by dsimp only [a]; rw [one_div_mul_eq_div]; ring rw [h1, h2]; linarith have hprod_le := (Real.log_le_log_iff (mul_pos (Real.rpow_pos_of_pos hy0 _) (hphi_pos y)) (mul_pos (Real.rpow_pos_of_pos (by linarith) _) (hphi_pos (1 - y)))).mp hlog_le nlinarith -- Step 5: Apply Endpoint Minimum Principle to g on [0, 1/2]! have hg_cont : ContinuousOn g (Set.Icc 0 (1 / 2)) := by have hc1 : Continuous (psphPhi q) := Real.continuous_exp.comp (((continuous_const.sub (continuous_id.rpow_const fun _ => Or.inr (le_of_lt hs0))).neg).div_const _) have hc2 : Continuous (fun z : ℝ => psphPhi q (1 - z)) := hc1.comp (continuous_const.sub continuous_id) exact (hc1.add hc2).continuousOn have hmin := min_at_endpoints_of_deriv_sign_change (by norm_num : (0 : ℝ) ≤ 1 / 2) hg_cont (fun z hz => (hg_deriv z ⟨hz.1, by linarith [hz.2]⟩).differentiableAt) hg_sign intro t ht have hg0 : 1 ≤ g 0 := by dsimp only [g, psphPhi] rw [sub_zero, Real.one_rpow, sub_self, neg_zero, zero_div, Real.exp_zero] linarith [Real.exp_pos (-(1 - (0 : ℝ) ^ (1 / q)) / psphConst q)] have hghalf : g (1 / 2) = 1 := by dsimp only [g, psphPhi, psphConst] have h1 : (1 - 1 / 2 : ℝ) = 1 / 2 := by norm_num have h2 : (1 / 2 : ℝ) ^ (1 / q) = (2 : ℝ) ^ (-(1 / q)) := by rw [one_div, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2), Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2)] rw [h1, h2] have hne : 1 - (2 : ℝ) ^ (-(1 / q)) ≠ 0 := by have hlt : (2 : ℝ) ^ (-(1 / q)) < (2 : ℝ) ^ (0 : ℝ) := Real.rpow_lt_rpow_of_exponent_lt (by norm_num) (by rw [neg_lt_zero]; positivity) rw [Real.rpow_zero] at hlt; linarith have hexp : -(1 - (2 : ℝ) ^ (-(1 / q))) / ((1 - (2 : ℝ) ^ (-(1 / q))) / Real.log 2) = -Real.log 2 := by field_simp rw [hexp, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2)] norm_num exact le_trans (le_min hg0 (le_of_eq hghalf.symm)) (hmin t ht) /-- **Pseudospherical Subadditivity Law**: for EVERY `q ≥ 1` and ALL `a, b ≥ 0` with `a + b ≤ 1`, `psphPhi q (a + b) ≤ psphPhi q a + psphPhi q b`! -/ theorem psphPhi_subadditive {q a b : ℝ} (hq : 1 ≤ q) (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b ≤ 1) : psphPhi q (a + b) ≤ psphPhi q a + psphPhi q b := by have hq0 : 0 < q := by linarith have hC_pos : 0 < psphConst q := psphConst_pos hq0 by_cases hs0 : a + b = 0 · have ha0 : a = 0 := by linarith have hb0 : b = 0 := by linarith subst ha0; subst hb0 rw [add_zero]; dsimp only [psphPhi] linarith [Real.exp_pos (-(1 - (0 : ℝ) ^ (1 / q)) / psphConst q)] have hs_pos : 0 < a + b := lt_of_le_of_ne (by linarith) (Ne.symm hs0) set s := a + b set θ := a / s have hθ0 : 0 ≤ θ := by positivity have hθ1 : θ ≤ 1 := (div_le_one hs_pos).mpr (by linarith) have ha_eq : a = θ * s := by dsimp only [θ]; rw [div_mul_cancel₀ _ (ne_of_gt hs_pos)] have hb_eq : b = (1 - θ) * s := by dsimp only [θ]; rw [sub_mul, one_mul, div_mul_cancel₀ _ (ne_of_gt hs_pos)]; dsimp only [s]; ring have hs_pow_le1 : s ^ (1 / q) ≤ 1 := Real.rpow_le_one (le_of_lt hs_pos) hab (by positivity) have hrat : ∀ u ∈ Set.Icc (0 : ℝ) 1, psphPhi q u ≤ psphPhi q (u * s) / psphPhi q s := by intro u ⟨hu0, hu1⟩ dsimp only [psphPhi] rw [← Real.exp_sub, Real.exp_le_exp] rw [Real.mul_rpow hu0 (le_of_lt hs_pos)] have hu_pow_le1 : u ^ (1 / q) ≤ 1 := Real.rpow_le_one hu0 hu1 (by positivity) have hnum : -(1 - u ^ (1 / q)) ≤ -(1 - u ^ (1 / q) * s ^ (1 / q)) - -(1 - s ^ (1 / q)) := by have : -(1 - u ^ (1 / q) * s ^ (1 / q)) - -(1 - s ^ (1 / q)) - -(1 - u ^ (1 / q)) = (1 - u ^ (1 / q)) * (1 - s ^ (1 / q)) := by ring nlinarith rw [← sub_div] exact div_le_div_of_nonneg_right hnum (le_of_lt hC_pos) have h1 := hrat θ ⟨hθ0, hθ1⟩ have h2 := hrat (1 - θ) ⟨by linarith, by linarith⟩ rw [← ha_eq] at h1 rw [← hb_eq] at h2 have hbin := psphPhi_binary_ge_one hq θ ⟨hθ0, hθ1⟩ have hsum : 1 ≤ (psphPhi q a + psphPhi q b) / psphPhi q s := by rw [add_div]; linarith exact (one_le_div (Real.exp_pos _)).mp hsum /-- **Multiclass Pseudospherical Simplex Inequality (Arbitrary Cardinality `|S| ≥ 1`)**: for EVERY `q ≥ 1`, finite nonempty `S`, and nonnegative `x` with `∑ y ∈ S, x y ≤ 1`, `psphPhi q (∑ y ∈ S, x y) ≤ ∑ y ∈ S, psphPhi q (x y)`! -/ theorem multiclass_psph_simplex_ineq {β : Type*} [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) : ∀ (S : Finset β), S.Nonempty → ∀ (x : β → ℝ), (∀ y ∈ S, 0 ≤ x y) → (∑ y ∈ S, x y ≤ 1) → psphPhi q (∑ y ∈ S, x y) ≤ ∑ y ∈ S, psphPhi q (x y) := by intro S induction S using Finset.induction with | empty => intro hS; exact absurd hS Finset.not_nonempty_empty | @insert y₀ S' hy₀ ih => intro _ x hx0 hxsum by_cases hS' : S'.Nonempty · rw [Finset.sum_insert hy₀] at hxsum rw [Finset.sum_insert hy₀, Finset.sum_insert hy₀] have hih := ih hS' x (fun y hy => hx0 y (Finset.mem_insert_of_mem hy)) (by linarith [hx0 y₀ (Finset.mem_insert_self y₀ S')]) have hsub := psphPhi_subadditive hq (hx0 y₀ (Finset.mem_insert_self y₀ S')) (Finset.sum_nonneg fun y hy => hx0 y (Finset.mem_insert_of_mem hy)) hxsum linarith · rw [Finset.not_nonempty_iff_eq_empty] at hS' subst hS'; simp /-- **1-Step Multiclass Pseudospherical Halving Lemma (`q ≥ 1`, Arbitrary `|S|`)**. -/ theorem psphVal_log_halving_step {β : Type*} [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) {S : Finset β} (hS : S.Nonempty) {w : β → ℝ} (hw : ∀ y ∈ S, 0 < w y) (N : ℝ) (hN : ∑ y ∈ S, w y = N) : psphVal q S (fun y => psphConst q * Real.log (w y)) ≤ psphConst q * Real.log N := by have hq0 : 0 < q := by linarith have hC_pos : 0 < psphConst q := psphConst_pos hq0 have hN_pos : 0 < N := by rcases hS with ⟨y0, hy0⟩ linarith [hw y0 hy0, Finset.single_le_sum (fun y hy => le_of_lt (hw y hy)) hy0] rw [psphVal_le_iff hq0 hS] refine ⟨fun y hy => mul_le_mul_of_nonneg_left (Real.log_le_log (hw y hy) (by rw [← hN]; exact Finset.single_le_sum (fun z hz => le_of_lt (hw z hz)) hy)) (le_of_lt hC_pos), ?_⟩ -- Suppose for contradiction ∑_{y ∈ S} u_y^q > 1, where u_y = max 0 (C * log(w_y) + 1 - C * log N) ∈ [0, 1]! set u : β → ℝ := fun y => max 0 (psphConst q * Real.log (w y) + 1 - psphConst q * Real.log N) by_contra hgt; push Not at hgt -- Define x_y = u_y^q / ∑ u^q ∈ [0, 1] (so ∑ x_y = 1 and x_y < u_y^q whenever u_y > 0)! set M := ∑ y ∈ S, u y ^ q have hM_gt1 : 1 < M := hgt have hM_pos : 0 < M := by linarith -- Restrict to the active set A = {y ∈ S | 0 < u y}! set A := S.filter fun y => 0 < u y have hM_eq : M = ∑ y ∈ A, u y ^ q := by dsimp only [M] refine (Finset.sum_subset (Finset.filter_subset _ S) fun y hy hnot => ?_).symm have hu_le : u y ≤ 0 := by by_contra hpos; push Not at hpos; exact hnot (Finset.mem_filter.mpr ⟨hy, hpos⟩) rw [le_antisymm hu_le (le_max_left 0 _), Real.zero_rpow (ne_of_gt hq0)] have hAne : A.Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp rw [hemp, Finset.sum_empty] at hM_eq; linarith set x : β → ℝ := fun y => u y ^ q / M have hx0 : ∀ y ∈ A, 0 ≤ x y := fun y _ => div_nonneg (Real.rpow_nonneg (le_max_left 0 _) q) (le_of_lt hM_pos) have hxsum : ∑ y ∈ A, x y = 1 := by dsimp only [x]; rw [← Finset.sum_div, ← hM_eq, div_self (ne_of_gt hM_pos)] have hsimp := multiclass_psph_simplex_ineq hq A hAne x hx0 (le_of_eq hxsum) rw [hxsum] at hsimp have hphi1 : psphPhi q 1 = 1 := by dsimp only [psphPhi]; rw [Real.one_rpow, sub_self, neg_zero, zero_div, Real.exp_zero] rw [hphi1] at hsimp -- On every active y ∈ A, u y > 0 and x y < u y ^ q, giving STRICT inequality psphPhi q (x y) < w y / N! have hlt_each : ∀ y ∈ A, psphPhi q (x y) < w y / N := by intro y hy have hyS : y ∈ S := (Finset.mem_filter.mp hy).1 have hu_pos : 0 < u y := (Finset.mem_filter.mp hy).2 have hxy_lt : x y < u y ^ q := (div_lt_iff₀ hM_pos).mpr (lt_mul_of_one_lt_right (Real.rpow_pos_of_pos hu_pos q) hM_gt1) have hpow_lt : x y ^ (1 / q) < u y := by have h1 := Real.rpow_lt_rpow (hx0 y hy) hxy_lt (div_pos one_pos hq0) rwa [← Real.rpow_mul (le_of_lt hu_pos), mul_one_div_cancel (ne_of_gt hq0), Real.rpow_one] at h1 have hueq : u y = psphConst q * Real.log (w y) + 1 - psphConst q * Real.log N := by dsimp only [u] at hu_pos ⊢ rcases le_total 0 (psphConst q * Real.log (w y) + 1 - psphConst q * Real.log N) with h | h · exact max_eq_right h · rw [max_eq_left h] at hu_pos; linarith have hvy_lt : -(1 - x y ^ (1 / q)) / psphConst q < Real.log (w y / N) := by rw [Real.log_div (ne_of_gt (hw y hyS)) (ne_of_gt hN_pos), div_lt_iff₀ hC_pos] linarith calc psphPhi q (x y) < Real.exp (Real.log (w y / N)) := Real.exp_lt_exp.mpr hvy_lt _ = w y / N := Real.exp_log (div_pos (hw y hyS) hN_pos) rcases hAne with ⟨y0, hy0⟩ have hsum_lt : ∑ y ∈ A, psphPhi q (x y) < ∑ y ∈ A, w y / N := Finset.sum_lt_sum (fun y hy => le_of_lt (hlt_each y hy)) ⟨y0, hy0, hlt_each y0 hy0⟩ have hsum_le1 : ∑ y ∈ A, w y / N ≤ 1 := by rw [← Finset.sum_div, div_le_one hN_pos, ← hN] exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ S) fun y hy _ => le_of_lt (hw y hy) linarith /-- **UNIVERSAL MULTICLASS PSEUDOSPHERICAL HALVING THEOREM (`q ≥ 1`, ZERO DEPENDENCE ON `|β|`)**: For EVERY `q ≥ 1` and EVERY finite nonempty multiclass concept class `V` over ANY label space `β`: `PsphOpt q V ≤ ((1 - 2^(-1/q)) / Real.log 2) * Real.log |V|`! -/ theorem PsphOpt_le_log_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℝ} (hq : 1 ≤ q) {V : Finset (α → β)} (hV : V.Nonempty) : PsphOpt q V ≤ psphConst q * Real.log (V.card : ℝ) := by have hq0 : 0 < q := by linarith have hC_nn : 0 ≤ psphConst q := le_of_lt (psphConst_pos hq0) induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hlog_nn : 0 ≤ Real.log (V.card : ℝ) := Real.log_nonneg (by exact_mod_cast hV.card_pos) refine PsphOpt_le_of_forall_x q V (mul_nonneg hC_nn hlog_nn) fun x hsp => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) calc psphVal q (labels V x) (fun y => PsphOpt q (restrict V x y)) ≤ psphVal q (labels V x) (fun y => psphConst q * Real.log ((restrict V x y).card : ℝ)) := psphVal_mono_v hq0 fun y hy => ih _ (card_restrict_lt_of_two_labels hsp y) ((restrict_nonempty_iff V x y).mpr hy) rfl _ ≤ psphConst q * Real.log (V.card : ℝ) := psphVal_log_halving_step hq hS (w := fun y => ((restrict V x y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x y).mpr hy).card_pos) (V.card : ℝ) (by exact_mod_cast sum_card_restrict V x) /-- **UNIVERSAL MULTICLASS SPHERICAL SCORE HALVING THEOREM (`q = 2`)**: For EVERY finite nonempty multiclass `V` over ANY label space `β`: `SphOpt V ≤ ((1 - 1 / Real.sqrt 2) / Real.log 2) * Real.log |V|`, strictly beating Vovk's classical `(1/2) * Real.log |V|` spherical mixability bound by **> 15.4%**! -/ theorem SphOpt_le_log_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : SphOpt V ≤ ((1 - 1 / Real.sqrt 2) / Real.log 2) * Real.log (V.card : ℝ) := by have h := PsphOpt_le_log_card (q := 2) (by norm_num) hV have hC : psphConst 2 = (1 - 1 / Real.sqrt 2) / Real.log 2 := by dsimp only [psphConst] rw [Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2), ← Real.sqrt_eq_rpow, one_div] rwa [hC] at h /-- **Strict `> 15.4%` Improvement Over Vovk's Classical Spherical Mixability Constant (`1/2`)**: `(1 - 1 / Real.sqrt 2) / Real.log 2 < (846 / 1000) * (1 / 2)`. -/ theorem SphOpt_beats_vovk_by_15pct : (1 - 1 / Real.sqrt 2) / Real.log 2 < (846 / 1000 : ℝ) * (1 / 2) := by have hlog2_lo := Real.log_two_gt_d9 have hsqrt2_hi : Real.sqrt 2 < (14143 / 10000 : ℝ) := by rw [Real.sqrt_lt' (by norm_num)]; norm_num have hinv_lo : (10000 / 14143 : ℝ) < 1 / Real.sqrt 2 := by rw [div_lt_div_iff₀ (by norm_num) (Real.sqrt_pos.mpr (by norm_num))]; linarith rw [div_lt_iff₀ (by linarith : 0 < Real.log 2)] linarith /-- **Multiclass `RLdim` Halving Corollary (`q = 1`)**: `RLdim V ≤ (1 / (2 * Real.log 2)) * Real.log |V|` for every finite nonempty multiclass `V`. -/ theorem RLdim_le_half_log2_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : RLdim V ≤ (1 / (2 * Real.log 2)) * Real.log (V.card : ℝ) := by have h := PsphOpt_le_log_card (q := 1) le_rfl hV have hC : psphConst 1 = 1 / (2 * Real.log 2) := by dsimp only [psphConst] rw [div_one, Real.rpow_neg_one]; field_simp; ring rwa [hC] at h /-! ## Part 7: Disjoint-Domain Product Additivity & Exact `r`-ary Cube Extremizers -/ def prodClass {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) : Finset (α₁ ⊕ α₂ → β) := (V₁ ×ˢ V₂).image fun pq => Sum.elim pq.1 pq.2 lemma sum_elim_injective {α₁ α₂ β : Type*} : Function.Injective (fun pq : (α₁ → β) × (α₂ → β) => Sum.elim pq.1 pq.2) := by intro ⟨f₁, f₂⟩ ⟨g₁, g₂⟩ h; ext x · exact congrFun h (Sum.inl x) · exact congrFun h (Sum.inr x) lemma prodClass_card {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) : (prodClass V₁ V₂).card = V₁.card * V₂.card := by rw [prodClass, Finset.card_image_of_injective _ sum_elim_injective, Finset.card_product] lemma labels_prodClass_inl {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₂ : V₂.Nonempty) (x : α₁) : labels (prodClass V₁ V₂) (Sum.inl x) = labels V₁ x := by ext y; simp only [labels, prodClass, Finset.mem_image, Finset.mem_product, Prod.exists] constructor · rintro ⟨_, ⟨h₁, h₂, ⟨hh₁, _⟩, rfl⟩, rfl⟩; exact ⟨h₁, hh₁, rfl⟩ · rintro ⟨h₁, hh₁, rfl⟩; rcases hV₂ with ⟨h₂, hh₂⟩ exact ⟨Sum.elim h₁ h₂, ⟨h₁, h₂, ⟨hh₁, hh₂⟩, rfl⟩, rfl⟩ lemma labels_prodClass_inr {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (x : α₂) : labels (prodClass V₁ V₂) (Sum.inr x) = labels V₂ x := by ext y; simp only [labels, prodClass, Finset.mem_image, Finset.mem_product, Prod.exists] constructor · rintro ⟨_, ⟨h₁, h₂, ⟨_, hh₂⟩, rfl⟩, rfl⟩; exact ⟨h₂, hh₂, rfl⟩ · rintro ⟨h₂, hh₂, rfl⟩; rcases hV₁ with ⟨h₁, hh₁⟩ exact ⟨Sum.elim h₁ h₂, ⟨h₁, h₂, ⟨hh₁, hh₂⟩, rfl⟩, rfl⟩ lemma restrict_prodClass_inl {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) (x : α₁) (y : β) : restrict (prodClass V₁ V₂) (Sum.inl x) y = prodClass (restrict V₁ x y) V₂ := by ext f; simp only [restrict, prodClass, Finset.mem_filter, Finset.mem_image, Finset.mem_product, Prod.exists] constructor · rintro ⟨⟨h₁, h₂, ⟨hh₁, hh₂⟩, rfl⟩, hfx⟩; exact ⟨h₁, h₂, ⟨⟨hh₁, hfx⟩, hh₂⟩, rfl⟩ · rintro ⟨h₁, h₂, ⟨⟨hh₁, hfx⟩, hh₂⟩, rfl⟩; exact ⟨⟨h₁, h₂, ⟨hh₁, hh₂⟩, rfl⟩, hfx⟩ lemma restrict_prodClass_inr {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) (x : α₂) (y : β) : restrict (prodClass V₁ V₂) (Sum.inr x) y = prodClass V₁ (restrict V₂ x y) := by ext f; simp only [restrict, prodClass, Finset.mem_filter, Finset.mem_image, Finset.mem_product, Prod.exists] constructor · rintro ⟨⟨h₁, h₂, ⟨hh₁, hh₂⟩, rfl⟩, hfx⟩; exact ⟨h₁, h₂, ⟨hh₁, ⟨hh₂, hfx⟩⟩, rfl⟩ · rintro ⟨h₁, h₂, ⟨hh₁, ⟨hh₂, hfx⟩⟩, rfl⟩; exact ⟨⟨h₁, h₂, ⟨hh₁, hh₂⟩, rfl⟩, hfx⟩ /-- **Exact Disjoint-Domain Product Additivity for Multiclass Brier Score**. -/ theorem BrierOpt_prod_eq_add {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : BrierOpt (prodClass V₁ V₂) = BrierOpt V₁ + BrierOpt V₂ := by induction hn : V₁.card + V₂.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => subst hn apply le_antisymm · refine BrierOpt_le_of_forall_x (prodClass V₁ V₂) (add_nonneg (BrierOpt_nonneg V₁) (BrierOpt_nonneg V₂)) fun x hsp => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl hV₂] at hsp ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, BrierOpt (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = BrierOpt (restrict V₁ x₁ y) + BrierOpt V₂ := fun y hy => by rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsp y exact ih _ (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [brierVal_congr hcongr, brierVal_add_const hS] linarith [BrierOpt_ge_brierVal V₁ x₁ hsp] | inr x₂ => rw [labels_prodClass_inr hV₁] at hsp ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₂ x₂, BrierOpt (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = BrierOpt (restrict V₂ x₂ y) + BrierOpt V₁ := fun y hy => by rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsp y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl, add_comm] rw [brierVal_congr hcongr, brierVal_add_const hS] linarith [BrierOpt_ge_brierVal V₂ x₂ hsp] · by_cases h1 : V₁.card ≤ 1 · rw [BrierOpt_eq_zero_of_card_le_one h1, zero_add] refine BrierOpt_le_of_forall_x V₂ (BrierOpt_nonneg _) fun x₂ hsp₂ => ?_ have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rw [labels_prodClass_inr hV₁]; exact hsp₂ have hcongr : ∀ y ∈ labels V₂ x₂, BrierOpt (restrict V₂ x₂ y) = BrierOpt (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := fun y hy => by rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsp₂ y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl, BrierOpt_eq_zero_of_card_le_one h1, zero_add] rw [brierVal_congr hcongr, ← labels_prodClass_inr hV₁] exact BrierOpt_ge_brierVal (prodClass V₁ V₂) (Sum.inr x₂) hsp · have hle1 : BrierOpt V₁ ≤ BrierOpt (prodClass V₁ V₂) - BrierOpt V₂ := by refine BrierOpt_le_of_forall_x V₁ ?_ fun x₁ hsp₁ => ?_ · have hle2 : BrierOpt V₂ ≤ BrierOpt (prodClass V₁ V₂) := by refine BrierOpt_le_of_forall_x V₂ (BrierOpt_nonneg _) fun x₂ hsp₂ => ?_ have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rw [labels_prodClass_inr hV₁]; exact hsp₂ have hmono : ∀ y ∈ labels V₂ x₂, BrierOpt (restrict V₂ x₂ y) ≤ BrierOpt (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := fun y hy => by rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsp₂ y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl] linarith [BrierOpt_nonneg V₁] calc brierVal (labels V₂ x₂) (fun y => BrierOpt (restrict V₂ x₂ y)) ≤ brierVal (labels V₂ x₂) (fun y => BrierOpt (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) := brierVal_mono_v hmono _ = brierVal (labels (prodClass V₁ V₂) (Sum.inr x₂)) (fun y => BrierOpt (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) := by rw [labels_prodClass_inr hV₁] _ ≤ BrierOpt (prodClass V₁ V₂) := BrierOpt_ge_brierVal (prodClass V₁ V₂) (Sum.inr x₂) hsp linarith · have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inl x₁)).card := by rw [labels_prodClass_inl hV₂]; exact hsp₁ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, BrierOpt (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = BrierOpt (restrict V₁ x₁ y) + BrierOpt V₂ := fun y hy => by rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsp₁ y exact ih _ (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl have hge := BrierOpt_ge_brierVal (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl hV₂, brierVal_congr hcongr, brierVal_add_const hS] at hge linarith linarith /-- **Exact Disjoint-Domain Product Additivity for Multiclass Pseudospherical Scores (`q > 0`)**. -/ theorem PsphOpt_prod_eq_add {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] {q : ℝ} (hq : 0 < q) {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : PsphOpt q (prodClass V₁ V₂) = PsphOpt q V₁ + PsphOpt q V₂ := by induction hn : V₁.card + V₂.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => subst hn apply le_antisymm · refine PsphOpt_le_of_forall_x q (prodClass V₁ V₂) (add_nonneg (PsphOpt_nonneg hq V₁) (PsphOpt_nonneg hq V₂)) fun x hsp => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl hV₂] at hsp ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = PsphOpt q (restrict V₁ x₁ y) + PsphOpt q V₂ := fun y hy => by rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsp y exact ih _ (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [psphVal_congr hq hcongr, psphVal_add_const hq hS] linarith [PsphOpt_ge_psphVal q V₁ x₁ hsp] | inr x₂ => rw [labels_prodClass_inr hV₁] at hsp ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₂ x₂, PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = PsphOpt q (restrict V₂ x₂ y) + PsphOpt q V₁ := fun y hy => by rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsp y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl, add_comm] rw [psphVal_congr hq hcongr, psphVal_add_const hq hS] linarith [PsphOpt_ge_psphVal q V₂ x₂ hsp] · by_cases h1 : V₁.card ≤ 1 · rw [PsphOpt_eq_zero_of_card_le_one q h1, zero_add] refine PsphOpt_le_of_forall_x q V₂ (PsphOpt_nonneg hq _) fun x₂ hsp₂ => ?_ have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rw [labels_prodClass_inr hV₁]; exact hsp₂ have hcongr : ∀ y ∈ labels V₂ x₂, PsphOpt q (restrict V₂ x₂ y) = PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := fun y hy => by rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsp₂ y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl, PsphOpt_eq_zero_of_card_le_one q h1, zero_add] rw [psphVal_congr hq hcongr, ← labels_prodClass_inr hV₁] exact PsphOpt_ge_psphVal q (prodClass V₁ V₂) (Sum.inr x₂) hsp · have hle1 : PsphOpt q V₁ ≤ PsphOpt q (prodClass V₁ V₂) - PsphOpt q V₂ := by refine PsphOpt_le_of_forall_x q V₁ ?_ fun x₁ hsp₁ => ?_ · have hle2 : PsphOpt q V₂ ≤ PsphOpt q (prodClass V₁ V₂) := by refine PsphOpt_le_of_forall_x q V₂ (PsphOpt_nonneg hq _) fun x₂ hsp₂ => ?_ have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rw [labels_prodClass_inr hV₁]; exact hsp₂ have hmono : ∀ y ∈ labels V₂ x₂, PsphOpt q (restrict V₂ x₂ y) ≤ PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := fun y hy => by rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsp₂ y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl] linarith [PsphOpt_nonneg hq V₁] calc psphVal q (labels V₂ x₂) (fun y => PsphOpt q (restrict V₂ x₂ y)) ≤ psphVal q (labels V₂ x₂) (fun y => PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) := psphVal_mono_v hq hmono _ = psphVal q (labels (prodClass V₁ V₂) (Sum.inr x₂)) (fun y => PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) := by rw [labels_prodClass_inr hV₁] _ ≤ PsphOpt q (prodClass V₁ V₂) := PsphOpt_ge_psphVal q (prodClass V₁ V₂) (Sum.inr x₂) hsp linarith · have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inl x₁)).card := by rw [labels_prodClass_inl hV₂]; exact hsp₁ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, PsphOpt q (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = PsphOpt q (restrict V₁ x₁ y) + PsphOpt q V₂ := fun y hy => by rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsp₁ y exact ih _ (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl have hge := PsphOpt_ge_psphVal q (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl hV₂, psphVal_congr hq hcongr, psphVal_add_const hq hS] at hge linarith linarith /-- Single-point `r`-class concept class on `Unit`. -/ def onePointClass (r : ℕ) : Finset (Unit → Fin r) := Finset.univ lemma onePointClass_card (r : ℕ) : (onePointClass r).card = r := by simp [onePointClass] lemma labels_onePointClass (r : ℕ) : labels (onePointClass r) () = Finset.univ := by ext y; simp only [labels, onePointClass, Finset.mem_image, Finset.mem_univ, true_and, iff_true] exact ⟨fun _ => y, rfl⟩ lemma restrict_onePointClass_card (r : ℕ) (y : Fin r) : (restrict (onePointClass r) () y).card = 1 := by have heq : restrict (onePointClass r) () y = {fun _ => y} := by ext f; simp only [restrict, onePointClass, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] exact ⟨fun h => funext fun u => by cases u; exact h, fun h => by rw [h]⟩ rw [heq, Finset.card_singleton] theorem BrierOpt_onePointClass {r : ℕ} (hr : 2 ≤ r) : BrierOpt (onePointClass r) = (1 - 1 / (r : ℝ)) / 2 := by have hsp : 2 ≤ (labels (onePointClass r) ()).card := by rw [labels_onePointClass, Finset.card_univ, Fintype.card_fin]; exact hr have hS : (labels (onePointClass r) ()).Nonempty := Finset.card_pos.mp (by omega) have hzero : ∀ y ∈ labels (onePointClass r) (), BrierOpt (restrict (onePointClass r) () y) = 0 := fun y _ => BrierOpt_eq_zero_of_card_le_one (by rw [restrict_onePointClass_card]) have hval : brierVal (labels (onePointClass r) ()) (fun y => BrierOpt (restrict (onePointClass r) () y)) = (1 - 1 / (r : ℝ)) / 2 := by rw [brierVal_congr hzero, brierVal_const hS, zero_add, labels_onePointClass, Finset.card_univ, Fintype.card_fin] apply le_antisymm · refine BrierOpt_le_of_forall_x (onePointClass r) (by have hr1 : (1 : ℝ) ≤ (r : ℝ) := by exact_mod_cast (by omega : 1 ≤ r) have : 1 / (r : ℝ) ≤ 1 := (div_le_one (by linarith)).mpr hr1 linarith) fun x _ => ?_ cases x; rw [hval] · rw [← hval]; exact BrierOpt_ge_brierVal (onePointClass r) () hsp theorem PsphOpt_onePointClass {r : ℕ} (hr : 2 ≤ r) {q : ℝ} (hq : 0 < q) : PsphOpt q (onePointClass r) = 1 - (r : ℝ) ^ (-(1 / q)) := by have hsp : 2 ≤ (labels (onePointClass r) ()).card := by rw [labels_onePointClass, Finset.card_univ, Fintype.card_fin]; exact hr have hS : (labels (onePointClass r) ()).Nonempty := Finset.card_pos.mp (by omega) have hzero : ∀ y ∈ labels (onePointClass r) (), PsphOpt q (restrict (onePointClass r) () y) = 0 := fun y _ => PsphOpt_eq_zero_of_card_le_one q (by rw [restrict_onePointClass_card]) have hval : psphVal q (labels (onePointClass r) ()) (fun y => PsphOpt q (restrict (onePointClass r) () y)) = 1 - (r : ℝ) ^ (-(1 / q)) := by rw [psphVal_congr hq hzero, psphVal_const hq hS, zero_add, labels_onePointClass, Finset.card_univ, Fintype.card_fin] apply le_antisymm · refine PsphOpt_le_of_forall_x q (onePointClass r) (by have hr1 : (1 : ℝ) ≤ (r : ℝ) := by exact_mod_cast (by omega : 1 ≤ r) have := Real.rpow_le_one_of_one_le_of_nonpos hr1 (by rw [neg_nonpos]; positivity : -(1 / q) ≤ 0) linarith) fun x _ => ?_ cases x; rw [hval] · rw [← hval]; exact PsphOpt_ge_psphVal q (onePointClass r) () hsp abbrev CubeDom : ℕ → Type | 0 => Empty | d + 1 => Unit ⊕ CubeDom d instance instFintypeCubeDom : ∀ d : ℕ, Fintype (CubeDom d) | 0 => inferInstanceAs (Fintype Empty) | d + 1 => @instFintypeSum Unit (CubeDom d) _ (instFintypeCubeDom d) instance instDecidableEqCubeDom : ∀ d : ℕ, DecidableEq (CubeDom d) | 0 => inferInstanceAs (DecidableEq Empty) | d + 1 => @instDecidableEqSum Unit (CubeDom d) _ (instDecidableEqCubeDom d) def cubeClass (r : ℕ) : ∀ d : ℕ, Finset (CubeDom d → Fin r) | 0 => {Empty.elim} | d + 1 => prodClass (onePointClass r) (cubeClass r d) lemma cubeClass_card (r : ℕ) : ∀ d : ℕ, (cubeClass r d).card = r ^ d | 0 => by rw [cubeClass, Finset.card_singleton, pow_zero] | d + 1 => by rw [cubeClass, prodClass_card, onePointClass_card, cubeClass_card r d, pow_succ'] lemma cubeClass_nonempty {r : ℕ} (hr : 1 ≤ r) (d : ℕ) : (cubeClass r d).Nonempty := Finset.card_pos.mp (by rw [cubeClass_card]; exact pow_pos hr d) /-- **Exact `r`-ary Cube Values for Multiclass Brier Score (`d * (1 - 1/r) / 2`)**. -/ theorem BrierOpt_cubeClass {r : ℕ} (hr : 2 ≤ r) : ∀ d : ℕ, BrierOpt (cubeClass r d) = (d : ℝ) * ((1 - 1 / (r : ℝ)) / 2) | 0 => by rw [BrierOpt_eq_zero_of_card_le_one (by rw [cubeClass_card]; simp)]; simp | d + 1 => by rw [cubeClass, BrierOpt_prod_eq_add (Finset.card_pos.mp (by rw [onePointClass_card]; omega)) (cubeClass_nonempty (by omega) d), BrierOpt_onePointClass hr, BrierOpt_cubeClass hr d] push_cast; ring /-- **Exact `r`-ary Cube Values for Multiclass Pseudospherical Score (`d * (1 - r^(-1/q))`)**. -/ theorem PsphOpt_cubeClass {r : ℕ} (hr : 2 ≤ r) {q : ℝ} (hq : 0 < q) : ∀ d : ℕ, PsphOpt q (cubeClass r d) = (d : ℝ) * (1 - (r : ℝ) ^ (-(1 / q))) | 0 => by rw [PsphOpt_eq_zero_of_card_le_one q (by rw [cubeClass_card]; simp)]; simp | d + 1 => by rw [cubeClass, PsphOpt_prod_eq_add hq (Finset.card_pos.mp (by rw [onePointClass_card]; omega)) (cubeClass_nonempty (by omega) d), PsphOpt_onePointClass hr hq, PsphOpt_cubeClass hr hq d] push_cast; ring /-- **Universal Sharpness Certificate on `cubeClass 2 d` & `cubeClass r d`**: 1. `BrierOpt (cubeClass 2 d) = (1 / (4 * log 2)) * log |cubeClass 2 d|` (exact Brier halving equality!), 2. `PsphOpt q (cubeClass 2 d) = psphConst q * log |cubeClass 2 d|` (exact Pseudospherical halving equality!), 3. `BrierOpt (cubeClass r d) = (1 / 2) * RLdim (cubeClass r d)` (exact `1/2` Brier/RLdim equality for ALL `r ≥ 2`!), 4. `SphOpt (cubeClass 2 d) = (2 - √2) * RLdim (cubeClass 2 d)` (exact `2 - √2` Spherical/RLdim equality!). -/ theorem cubeClass_achieves_all_sharp_constants {r : ℕ} (hr : 2 ≤ r) {q : ℝ} (hq : 0 < q) (d : ℕ) : BrierOpt (cubeClass 2 d) = (1 / (4 * Real.log 2)) * Real.log ((cubeClass 2 d).card : ℝ) ∧ PsphOpt q (cubeClass 2 d) = psphConst q * Real.log ((cubeClass 2 d).card : ℝ) ∧ BrierOpt (cubeClass r d) = (1 / 2 : ℝ) * RLdim (cubeClass r d) ∧ SphOpt (cubeClass 2 d) = (2 - Real.sqrt 2) * RLdim (cubeClass 2 d) := by have hlog2 : Real.log 2 ≠ 0 := ne_of_gt (Real.log_pos (by norm_num)) refine ⟨?_, ?_, ?_, ?_⟩ · rw [BrierOpt_cubeClass (by omega) d, cubeClass_card, Nat.cast_pow, Nat.cast_ofNat, Real.log_pow] field_simp; ring · rw [PsphOpt_cubeClass (by omega) hq d, cubeClass_card, Nat.cast_pow, Nat.cast_ofNat, Real.log_pow] dsimp only [psphConst]; field_simp · dsimp only [RLdim] rw [BrierOpt_cubeClass hr d, PsphOpt_cubeClass hr (by norm_num) d, div_one, Real.rpow_neg_one, one_div] ring · dsimp only [SphOpt, RLdim] rw [PsphOpt_cubeClass (by omega) (by norm_num) d, PsphOpt_cubeClass (by omega) (by norm_num) d] rw [Nat.cast_ofNat, div_one, Real.rpow_neg_one, Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2), ← Real.sqrt_eq_rpow] have hsq : Real.sqrt 2 * Real.sqrt 2 = 2 := Real.mul_self_sqrt (by norm_num) have hne : Real.sqrt 2 ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (by norm_num)) have h1 : 1 - (Real.sqrt 2)⁻¹ = (2 - Real.sqrt 2) * (1 - (2 : ℝ)⁻¹) := by have : 2 * (Real.sqrt 2)⁻¹ = Real.sqrt 2 := by calc 2 * (Real.sqrt 2)⁻¹ = (Real.sqrt 2 * Real.sqrt 2) * (Real.sqrt 2)⁻¹ := by rw [hsq] _ = Real.sqrt 2 := by rw [mul_assoc, mul_inv_cancel₀ hne, mul_one] linarith rw [h1]; ring /-! ## Part 8: Binary Singletons — Exact Recurrences & Exponential-vs-Polynomial Separation -/ def binSingletonSub {N : ℕ} (I : Finset (Fin N)) : Finset (Fin N → Bool) := insert (fun _ => false) (I.image fun i j => decide (j = i)) def sqSingRec : ℕ → ℝ | 0 => 0 | n + 1 => (1 + sqSingRec n) ^ 2 / 4 def sphSingRec : ℕ → ℝ | 0 => 0 | n + 1 => 1 + (sphSingRec n - Real.sqrt (2 - sphSingRec n ^ 2)) / 2 lemma sqSingRec_bounds : ∀ n : ℕ, 0 ≤ sqSingRec n ∧ sqSingRec n < 1 | 0 => by simp [sqSingRec] | n + 1 => by rcases sqSingRec_bounds n with ⟨h0, h1⟩ rw [sqSingRec]; exact ⟨by positivity, by nlinarith⟩ lemma sphSingRec_bounds : ∀ n : ℕ, 0 ≤ sphSingRec n ∧ sphSingRec n < 1 | 0 => by simp [sphSingRec] | n + 1 => by rcases sphSingRec_bounds n with ⟨h0, h1⟩ rw [sphSingRec] have hrad : 0 < 2 - sphSingRec n ^ 2 := by nlinarith have hsqrt_gt : sphSingRec n < Real.sqrt (2 - sphSingRec n ^ 2) := by rw [Real.lt_sqrt h0]; nlinarith have hsqrt_le : Real.sqrt (2 - sphSingRec n ^ 2) ≤ 2 + sphSingRec n := by rw [Real.sqrt_le_left (by linarith)]; nlinarith exact ⟨by linarith, by linarith⟩ theorem sqSingRec_exact_sandwich : ∀ n : ℕ, 1 - 4 / ((n : ℝ) + 4) ≤ sqSingRec n ∧ sqSingRec n ≤ 1 - 3 / ((n : ℝ) + 3) | 0 => by simp [sqSingRec] | n + 1 => by rcases sqSingRec_exact_sandwich n with ⟨hlo, hhi⟩ rcases sqSingRec_bounds n with ⟨hnn, hlt1⟩ have hn_nn : (0 : ℝ) ≤ (n : ℝ) := Nat.cast_nonneg n rw [sqSingRec]; push_cast constructor · have h1 : 2 - 4 / ((n : ℝ) + 4) ≤ 1 + sqSingRec n := by linarith have h2_nn : 0 ≤ 2 - 4 / ((n : ℝ) + 4) := by have : 4 / ((n : ℝ) + 4) ≤ 1 := (div_le_one (by linarith)).mpr (by linarith); linarith have hsq : (2 - 4 / ((n : ℝ) + 4)) ^ 2 / 4 ≤ (1 + sqSingRec n) ^ 2 / 4 := by have := mul_le_mul h1 h1 h2_nn (by linarith); nlinarith refine le_trans ?_ hsq have hd1 : (0 : ℝ) < (n : ℝ) + 4 := by linarith have hd2 : (0 : ℝ) < (n : ℝ) + 1 + 4 := by linarith have hsimp : (2 - 4 / ((n : ℝ) + 4)) ^ 2 / 4 = 1 - 4 * ((n : ℝ) + 3) / ((n : ℝ) + 4) ^ 2 := by field_simp [ne_of_gt hd1]; ring rw [hsimp] have hfrac : 4 * ((n : ℝ) + 3) / ((n : ℝ) + 4) ^ 2 ≤ 4 / ((n : ℝ) + 1 + 4) := by rw [div_le_div_iff₀ (pow_pos hd1 2) hd2]; nlinarith linarith · have h1 : 1 + sqSingRec n ≤ 2 - 3 / ((n : ℝ) + 3) := by linarith have hsq : (1 + sqSingRec n) ^ 2 / 4 ≤ (2 - 3 / ((n : ℝ) + 3)) ^ 2 / 4 := by have := mul_le_mul h1 h1 (by linarith) (by linarith); nlinarith refine le_trans hsq ?_ have hd1 : (0 : ℝ) < (n : ℝ) + 3 := by linarith have hd2 : (0 : ℝ) < (n : ℝ) + 1 + 3 := by linarith have hsimp : (2 - 3 / ((n : ℝ) + 3)) ^ 2 / 4 = 1 - 3 * (4 * (n : ℝ) + 9) / (4 * ((n : ℝ) + 3) ^ 2) := by field_simp [ne_of_gt hd1]; ring rw [hsimp] have hfrac : 3 / ((n : ℝ) + 1 + 3) ≤ 3 * (4 * (n : ℝ) + 9) / (4 * ((n : ℝ) + 3) ^ 2) := by rw [div_le_div_iff₀ hd2 (by positivity)]; nlinarith linarith /-- **Exact Upper Bound for Spherical Singletons (`sphSingRec n ≤ 1 - 2 / (n + 2)`)**. -/ theorem sphSingRec_le_one_sub_two_div : ∀ n : ℕ, sphSingRec n ≤ 1 - 2 / ((n : ℝ) + 2) | 0 => by simp [sphSingRec] | n + 1 => by have hih := sphSingRec_le_one_sub_two_div n rcases sphSingRec_bounds n with ⟨h0, h1⟩ have hn_nn : (0 : ℝ) ≤ (n : ℝ) := Nat.cast_nonneg n rw [sphSingRec]; push_cast -- Equivalently: 2 / (n + 3) ≤ (√(2 - v^2) - v) / 2 <=> v + 4 / (n + 3) ≤ √(2 - v^2)! -- Since v ↦ √(2 - v^2) - v is strictly decreasing on [0, 1], it suffices to prove at v = 1 - 2/(n+2)! set v := sphSingRec n set v₀ := 1 - 2 / ((n : ℝ) + 2) have hv₀_nn : 0 ≤ v₀ := by dsimp only [v₀]; have : 2 / ((n : ℝ) + 2) ≤ 1 := (div_le_one (by linarith)).mpr (by linarith); linarith have hv₀_le1 : v₀ ≤ 1 := by dsimp only [v₀]; have : 0 < 2 / ((n : ℝ) + 2) := div_pos (by norm_num) (by linarith); linarith have hv₀_le : v ≤ v₀ := hih have hsqrt_anti : Real.sqrt (2 - v₀ ^ 2) ≤ Real.sqrt (2 - v ^ 2) := Real.sqrt_le_sqrt (by nlinarith) have hstep_v0 : v₀ + 4 / ((n : ℝ) + 1 + 2) ≤ Real.sqrt (2 - v₀ ^ 2) := by rw [Real.le_sqrt (by positivity) (by nlinarith)] have hd1 : (0 : ℝ) < (n : ℝ) + 2 := by linarith have hd2 : (0 : ℝ) < (n : ℝ) + 1 + 2 := by linarith dsimp only [v₀] have hdiff : (2 - (1 - 2 / ((n : ℝ) + 2)) ^ 2) - (1 - 2 / ((n : ℝ) + 2) + 4 / ((n : ℝ) + 1 + 2)) ^ 2 = (8 * (n : ℝ) + 8) / (((n : ℝ) + 2) ^ 2 * ((n : ℝ) + 1 + 2) ^ 2) := by field_simp [ne_of_gt hd1, ne_of_gt hd2]; ring have hpos : 0 ≤ (8 * (n : ℝ) + 8) / (((n : ℝ) + 2) ^ 2 * ((n : ℝ) + 1 + 2) ^ 2) := by positivity linarith have h42 : 4 / ((n : ℝ) + 1 + 2) = 2 * (2 / ((n : ℝ) + 1 + 2)) := by ring linarith private lemma binSingletonSub_labels_not_mem {N : ℕ} (I : Finset (Fin N)) {x : Fin N} (hx : x ∉ I) : labels (binSingletonSub I) x = {false} := by ext y; simp only [labels, binSingletonSub, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | ⟨i, hi, rfl⟩, rfl⟩ · rfl · have hne : x ≠ i := fun h => hx (h ▸ hi); simp [hne] · rintro rfl; exact ⟨fun _ => false, Or.inl rfl, rfl⟩ private lemma binSingletonSub_labels_mem {N : ℕ} (I : Finset (Fin N)) {x : Fin N} (hx : x ∈ I) : labels (binSingletonSub I) x = {false, true} := by ext y; simp only [labels, binSingletonSub, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | ⟨i, _, rfl⟩, rfl⟩ · left; rfl · by_cases hxi : x = i <;> simp [hxi] · rintro (rfl | rfl) · exact ⟨fun _ => false, Or.inl rfl, rfl⟩ · exact ⟨fun j => decide (j = x), Or.inr ⟨x, hx, rfl⟩, by simp⟩ private lemma binSingletonSub_restrict_false {N : ℕ} (I : Finset (Fin N)) {x : Fin N} : restrict (binSingletonSub I) x false = binSingletonSub (I.erase x) := by ext f; simp only [restrict, binSingletonSub, Finset.mem_filter, Finset.mem_insert, Finset.mem_image, Finset.mem_erase] constructor · rintro ⟨rfl | ⟨i, hi, rfl⟩, hfx⟩ · left; rfl · right; have hne : i ≠ x := by intro heq; subst heq; simp at hfx exact ⟨i, ⟨hne, hi⟩, rfl⟩ · rintro (rfl | ⟨i, ⟨hne, hi⟩, rfl⟩) · exact ⟨Or.inl rfl, rfl⟩ · exact ⟨Or.inr ⟨i, hi, rfl⟩, by simp [hne.symm]⟩ private lemma binSingletonSub_restrict_true {N : ℕ} (I : Finset (Fin N)) {x : Fin N} (hx : x ∈ I) : restrict (binSingletonSub I) x true = {fun j => decide (j = x)} := by ext f; simp only [restrict, binSingletonSub, Finset.mem_filter, Finset.mem_insert, Finset.mem_image, Finset.mem_singleton] constructor · rintro ⟨rfl | ⟨i, _, rfl⟩, hfx⟩ · simp at hfx · by_cases hxi : x = i · subst hxi; rfl · simp [hxi] at hfx · rintro rfl; exact ⟨Or.inr ⟨x, hx, rfl⟩, by simp⟩ /-- **Exact Closed Forms on Binary Singletons for Brier, Spherical, and `RLdim`**: for EVERY `I : Finset (Fin N)`: - `BrierOpt (binSingletonSub I) = sqSingRec I.card`, - `SphOpt (binSingletonSub I) = sphSingRec I.card`, - `RLdim (binSingletonSub I) = 1 - (1 / 2) ^ I.card`! -/ theorem binSingletonSub_all_scores_exact {N : ℕ} (I : Finset (Fin N)) : BrierOpt (binSingletonSub I) = sqSingRec I.card ∧ SphOpt (binSingletonSub I) = sphSingRec I.card ∧ RLdim (binSingletonSub I) = 1 - (1 / 2 : ℝ) ^ I.card := by induction hn : I.card using Nat.strong_induction_on generalizing I with | h n ih => subst hn by_cases hI : I.Nonempty · have hcard_pos : 1 ≤ I.card := hI.card_pos have hrec : ∀ x ∈ I, BrierOpt (binSingletonSub (I.erase x)) = sqSingRec (I.card - 1) ∧ SphOpt (binSingletonSub (I.erase x)) = sphSingRec (I.card - 1) ∧ RLdim (binSingletonSub (I.erase x)) = 1 - (1 / 2 : ℝ) ^ (I.card - 1) := by intro x hx have hlt : (I.erase x).card < I.card := by rw [Finset.card_erase_of_mem hx]; omega have h := ih _ hlt (I.erase x) rfl rwa [Finset.card_erase_of_mem hx] at h have hne_ft : (false : Bool) ≠ true := by decide refine ⟨?_, ?_, ?_⟩ · -- BrierOpt have hstep : ∀ x ∈ I, brierVal (labels (binSingletonSub I) x) (fun y => BrierOpt (restrict (binSingletonSub I) x y)) = sqSingRec I.card := by intro x hx have h1 : BrierOpt (restrict (binSingletonSub I) x true) = 0 := by rw [binSingletonSub_restrict_true I hx]; exact BrierOpt_eq_zero_of_card_le_one (by simp) have h0 : BrierOpt (restrict (binSingletonSub I) x false) = sqSingRec (I.card - 1) := by rw [binSingletonSub_restrict_false, (hrec x hx).1] rw [binSingletonSub_labels_mem I hx, brierVal_binary hne_ft, h0, h1] rcases sqSingRec_bounds (I.card - 1) with ⟨hnn, hlt1⟩ rw [sub_zero, abs_of_nonneg hnn, if_neg (by linarith)] conv_rhs => rw [← Nat.sub_add_cancel hcard_pos, sqSingRec] ring apply le_antisymm · refine BrierOpt_le_of_forall_x _ (sqSingRec_bounds I.card).1 fun x hsp => ?_ have hxI : x ∈ I := by by_contra hnot; rw [binSingletonSub_labels_not_mem I hnot, Finset.card_singleton] at hsp; omega rw [hstep x hxI] · rcases hI with ⟨x0, hx0⟩ have hsp : 2 ≤ (labels (binSingletonSub I) x0).card := by rw [binSingletonSub_labels_mem I hx0, Finset.card_pair hne_ft] rw [← hstep x0 hx0]; exact BrierOpt_ge_brierVal _ x0 hsp · -- SphOpt have hstep : ∀ x ∈ I, psphVal 2 (labels (binSingletonSub I) x) (fun y => SphOpt (restrict (binSingletonSub I) x y)) = sphSingRec I.card := by intro x hx have h1 : SphOpt (restrict (binSingletonSub I) x true) = 0 := by rw [binSingletonSub_restrict_true I hx]; exact PsphOpt_eq_zero_of_card_le_one 2 (by simp) have h0 : SphOpt (restrict (binSingletonSub I) x false) = sphSingRec (I.card - 1) := by rw [binSingletonSub_restrict_false, (hrec x hx).2.1] rcases sphSingRec_bounds (I.card - 1) with ⟨hnn, hlt1⟩ rw [binSingletonSub_labels_mem I hx, sphVal_binary hne_ft _ (by rw [h0, h1, sub_zero, abs_of_nonneg hnn]; exact hlt1), h0, h1, add_zero, sub_zero] conv_rhs => rw [← Nat.sub_add_cancel hcard_pos, sphSingRec] apply le_antisymm · refine PsphOpt_le_of_forall_x 2 _ (sphSingRec_bounds I.card).1 fun x hsp => ?_ have hxI : x ∈ I := by by_contra hnot; rw [binSingletonSub_labels_not_mem I hnot, Finset.card_singleton] at hsp; omega rw [hstep x hxI] · rcases hI with ⟨x0, hx0⟩ have hsp : 2 ≤ (labels (binSingletonSub I) x0).card := by rw [binSingletonSub_labels_mem I hx0, Finset.card_pair hne_ft] rw [← hstep x0 hx0]; exact PsphOpt_ge_psphVal 2 _ x0 hsp · -- RLdim have hstep : ∀ x ∈ I, psphVal 1 (labels (binSingletonSub I) x) (fun y => RLdim (restrict (binSingletonSub I) x y)) = 1 - (1 / 2 : ℝ) ^ I.card := by intro x hx have h1 : RLdim (restrict (binSingletonSub I) x true) = 0 := by rw [binSingletonSub_restrict_true I hx]; exact PsphOpt_eq_zero_of_card_le_one 1 (by simp) have h0 : RLdim (restrict (binSingletonSub I) x false) = 1 - (1 / 2 : ℝ) ^ (I.card - 1) := by rw [binSingletonSub_restrict_false, (hrec x hx).2.2] have hpow : (1 / 2 : ℝ) ^ I.card = (1 / 2 : ℝ) * (1 / 2 : ℝ) ^ (I.card - 1) := by rw [← pow_succ', Nat.sub_add_cancel hcard_pos] have hnn : 0 ≤ (1 / 2 : ℝ) ^ (I.card - 1) := by positivity have hle1 : (1 / 2 : ℝ) ^ (I.card - 1) ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) have hS : ({false, true} : Finset Bool).Nonempty := ⟨false, by simp⟩ rw [binSingletonSub_labels_mem I hx] apply le_antisymm · rw [psphVal_le_iff (by norm_num : (0 : ℝ) < 1) hS] refine ⟨fun y hy => by simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl · dsimp only; rw [h0, hpow]; linarith · dsimp only; rw [h1, hpow]; linarith, ?_⟩ rw [Finset.sum_pair hne_ft, Real.rpow_one, Real.rpow_one] dsimp only; rw [h0, h1, hpow] rw [max_eq_right (by linarith), max_eq_right (by linarith)] linarith · have hsub := (psphVal_one_le_iff_subsets hS (fun y => RLdim (restrict (binSingletonSub I) x y)) (psphVal 1 ({false, true} : Finset Bool) (fun y => RLdim (restrict (binSingletonSub I) x y)))).mp le_rfl ({false, true} : Finset Bool) Subset.rfl hS rw [Finset.sum_pair hne_ft, Finset.card_pair hne_ft, h0, h1] at hsub push_cast at hsub linarith apply le_antisymm · refine PsphOpt_le_of_forall_x 1 _ (by have : (1 / 2 : ℝ) ^ I.card ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num); linarith) fun x hsp => ?_ have hxI : x ∈ I := by by_contra hnot; rw [binSingletonSub_labels_not_mem I hnot, Finset.card_singleton] at hsp; omega rw [hstep x hxI] · rcases hI with ⟨x0, hx0⟩ have hsp : 2 ≤ (labels (binSingletonSub I) x0).card := by rw [binSingletonSub_labels_mem I hx0, Finset.card_pair hne_ft] rw [← hstep x0 hx0]; exact PsphOpt_ge_psphVal 1 _ x0 hsp · have hemp : I = ∅ := Finset.not_nonempty_iff_eq_empty.mp hI subst hemp have hsing : binSingletonSub (N := N) ∅ = {fun _ => false} := by ext h; simp [binSingletonSub] dsimp only [SphOpt, RLdim] rw [hsing, BrierOpt_eq_zero_of_card_le_one (by simp), PsphOpt_eq_zero_of_card_le_one 2 (by simp), PsphOpt_eq_zero_of_card_le_one 1 (by simp)] simp [sqSingRec, sphSingRec] /-- **Triple Proper-Scoring Separation on Binary Singletons**: On the exact same concept class `binSingletonSub I` (`n = |I|`): - `1 - RLdim = 2^(-n)` (exponential convergence to `1`), - `2 / (n + 2) ≤ 1 - SphOpt ≤ 1 - BrierOpt ≤ 4 / (n + 4)` (both Spherical & Brier converge only polynomially as `Θ(1 / n)`!) -/ theorem proper_scoring_singleton_separation {N : ℕ} (I : Finset (Fin N)) : 1 - RLdim (binSingletonSub I) = (1 / 2 : ℝ) ^ I.card ∧ 2 / ((I.card : ℝ) + 2) ≤ 1 - SphOpt (binSingletonSub I) ∧ 1 - SphOpt (binSingletonSub I) ≤ 1 - BrierOpt (binSingletonSub I) ∧ 1 - BrierOpt (binSingletonSub I) ≤ 4 / ((I.card : ℝ) + 4) := by rcases binSingletonSub_all_scores_exact I with ⟨hb, hs, hr⟩ have hle_bs := BrierOpt_le_SphOpt (binSingletonSub I) have hsb := (sqSingRec_exact_sandwich I.card).1 have hss := sphSingRec_le_one_sub_two_div I.card rw [hb, hs] at hle_bs ⊢ rw [hr] exact ⟨by ring, by linarith, by linarith, by linarith⟩ end ProperScoringMinimax /-! ## Part 9: Machine-Checked `#print axioms` Verification (44 Headline Theorems) -/ #print axioms ProperScoringMinimax.brier_proper_identity #print axioms ProperScoringMinimax.wfThreshold_sum_eq_one #print axioms ProperScoringMinimax.brierVal_primal_upper #print axioms ProperScoringMinimax.brierVal_dual_lower #print axioms ProperScoringMinimax.brierVal_le_iff #print axioms ProperScoringMinimax.brierVal_eq_active_variance #print axioms ProperScoringMinimax.brierVal_binary #print axioms ProperScoringMinimax.psphVal_le_iff #print axioms ProperScoringMinimax.psphVal_primal_upper #print axioms ProperScoringMinimax.psphVal_dual_lower #print axioms ProperScoringMinimax.psphVal_const #print axioms ProperScoringMinimax.psphVal_one_le_iff_subsets #print axioms ProperScoringMinimax.sphVal_binary #print axioms ProperScoringMinimax.optBrierForecaster_expectedLoss_le #print axioms ProperScoringMinimax.optBrierAdversary_expectedLoss_ge #print axioms ProperScoringMinimax.online_brier_minimax_exact #print axioms ProperScoringMinimax.online_psph_minimax_exact #print axioms ProperScoringMinimax.brierVal_le_sphVal #print axioms ProperScoringMinimax.BrierOpt_le_SphOpt #print axioms ProperScoringMinimax.brier_not_pointwise_le_sph #print axioms ProperScoringMinimax.BrierOpt_ge_half_RLdim #print axioms ProperScoringMinimax.PsphOpt_anti_q #print axioms ProperScoringMinimax.PsphOpt_ge_alpha_mul_RLdim #print axioms ProperScoringMinimax.SphOpt_ge_two_sub_sqrt2_RLdim #print axioms ProperScoringMinimax.brier_merge_ineq #print axioms ProperScoringMinimax.multiclass_brier_simplex_ineq #print axioms ProperScoringMinimax.brierVal_quarter_log2_step #print axioms ProperScoringMinimax.BrierOpt_le_quarter_log2_card #print axioms ProperScoringMinimax.BrierOpt_beats_vovk_by_27pct #print axioms ProperScoringMinimax.psphPhi_binary_ge_one #print axioms ProperScoringMinimax.psphPhi_subadditive #print axioms ProperScoringMinimax.multiclass_psph_simplex_ineq #print axioms ProperScoringMinimax.psphVal_log_halving_step #print axioms ProperScoringMinimax.PsphOpt_le_log_card #print axioms ProperScoringMinimax.SphOpt_le_log_card #print axioms ProperScoringMinimax.SphOpt_beats_vovk_by_15pct #print axioms ProperScoringMinimax.RLdim_le_half_log2_card #print axioms ProperScoringMinimax.BrierOpt_prod_eq_add #print axioms ProperScoringMinimax.PsphOpt_prod_eq_add #print axioms ProperScoringMinimax.BrierOpt_cubeClass #print axioms ProperScoringMinimax.PsphOpt_cubeClass #print axioms ProperScoringMinimax.cubeClass_achieves_all_sharp_constants #print axioms ProperScoringMinimax.binSingletonSub_all_scores_exact #print axioms ProperScoringMinimax.proper_scoring_singleton_separation