import Mathlib /-! # Exact Minimax Theory & Sharp Phase Transition of Realizable Online ℓ_p Regression This file formalizes the complete, non-asymptotic minimax theory of realizable online regression under ℓ_p loss `|ŷ - y|^p` (`p ≥ 1`) over finite real-valued concept classes `V : Finset (α → ℝ)`. ## Headline Results 1. **Exact 1D Helly Pairwise Minimax Duality (`lpVal_le_iff`, `lpVal_primal_upper`, `lpVal_dual_lower`)**: For every `p ≥ 1`, finite nonempty `S ⊆ ℝ`, and continuation values `v : ℝ → ℝ`, `lpVal p S v = inf_{ŷ ∈ ℝ} max_{y ∈ S} (v y + |ŷ - y|^p) = max_{y₁, y₂ ∈ S} lpPair p y₁ y₂ (v y₁) (v y₂)`, with exact closed forms for `p = 1` (absolute loss) and `p = 2` (squared loss), exact 2-point dual adversary lower bound, zero randomization gain by convexity (`lp_jensen_randomization_no_gain`), and full multi-round adaptive minimax equivalence (`online_lp_minimax_exact`). 2. **Universal Exponential Halving Criterion (`OptLp_le_of_exp_criterion`)**: Whenever `∀ u ∈ [0, 1], exp (-u^p / C) + exp (-(1 - u)^p / C) ≥ 1`, every finite nonempty real-valued class `V` of range diameter `≤ D` satisfies `OptLp p V ≤ C * D^p * log |V|` with zero dependence on the number of distinct labels! 3. **Universal All-p Halving Law (`OptLp_le_inv_p_log_card`)**: For EVERY `p ≥ 1` (even `p > 2`, where Vovk's mixability constant collapses to `0`), `OptLp p V ≤ (D^p / p) * log |V|`. 4. **Sharp Critical Phase Transition at `pCrit = 1 / (1 - log 2) ≈ 3.25889135`**: - *Subcritical & Critical (`1 ≤ p ≤ pCrit`)* (`OptLp_le_hypercube_law_of_le_pCrit`): `OptLp p V ≤ (D^p / (2^p * log 2)) * log |V|`, attained with exact equality on `{0, 1}^d` (`OptLp_boolCube_exact`). At `p = 2` (squared loss), `OptLp 2 V ≤ (D^2 / (4 * log 2)) * log |V|`, strictly improving Vovk's classical `(1/2) * log |V|` aggregating bound by **> 27.8%** (`OptLp_two_beats_vovk_by_27pct`). At `p = 3`, `OptLp 3 V ≤ (D^3 / (8 * log 2)) * log |V|`. - *Supercritical (`p > pCrit`)* (`OptLp_supercritical_phase_transition`): Symmetry breaking occurs! For EVERY `p > 1 / (1 - log 2)`, a finite realizable binary 1D threshold class `threshClass N` strictly beats `(1 / (2^p * log 2)) * log N`; at `p = 4`, even the 3-concept class `threshClass 3` strictly violates the hypercube law (`OptLp_four_thresh3_beats_hypercube`). 5. **Exact ℓ_p vs. ℓ_q & Proper/Improper Sandwiches (`OptLp_binary_vs_Ldim`, `OptLp_binary_vs_OptLp`)**: For every `{0, 1}`-valued class `V`, `2^(-p) * Ldim V ≤ OptLp p V ≤ Ldim V` and for `1 ≤ p ≤ q`, `2^(p - q) * OptLp p V ≤ OptLp q V ≤ OptLp p V`. 6. **Product Additivity & Binary Singletons Quadratic Map (`OptLp_prod_eq_add`, `OptLp_two_binSingletonSub_exact`)**: Disjoint-domain product additivity for all `p ≥ 1`, exact logistic/quadratic recurrence `sqSingRec (n + 1) = (1 + sqSingRec n)^2 / 4` with `1 - 4/(n+4) ≤ OptLp 2 (binSingletonSub I) ≤ 1 - 3/(n+3)`, and an exponential-vs-polynomial gap-to-1 separation against `OptLp 1 (binSingletonSub I) = 1 - 2^(-n)`. -/ noncomputable section open scoped BigOperators open Finset namespace OnlineLpRegressionMinimax /-! ## Part 1: Exact 1-Round Pairwise & Multi-Label 1D Helly Minimax Duality for ℓ_p Loss (`p ≥ 1`) -/ /-- Feasibility predicate for the 1-round 2-point ℓ_p minimax value: `t` is feasible for `(y₁, v₁)` and `(y₂, v₂)` iff `max v₁ v₂ ≤ t` and the two radius-intervals `[yᵢ - (t - vᵢ)^(1/p), yᵢ + (t - vᵢ)^(1/p)]` intersect. -/ def lpPairFeas (p y₁ y₂ v₁ v₂ t : ℝ) : Prop := max v₁ v₂ ≤ t ∧ |y₁ - y₂| ≤ (t - v₁) ^ (1 / p) + (t - v₂) ^ (1 / p) /-- Exact 1-round 2-point minimax value for ℓ_p loss (`p ≥ 1`). -/ def lpPair (p y₁ y₂ v₁ v₂ : ℝ) : ℝ := sInf { t : ℝ | lpPairFeas p y₁ y₂ v₁ v₂ t } lemma lpPairFeas_mono {p y₁ y₂ v₁ v₂ t₁ t₂ : ℝ} (hp : 0 < p) (h1 : lpPairFeas p y₁ y₂ v₁ v₂ t₁) (hle : t₁ ≤ t₂) : lpPairFeas p y₁ y₂ v₁ v₂ t₂ := by rcases h1 with ⟨hm, hr⟩ have hinv : 0 ≤ 1 / p := by positivity refine ⟨le_trans hm hle, le_trans hr ?_⟩ have hv1 : 0 ≤ t₁ - v₁ := sub_nonneg.mpr (le_trans (le_max_left _ _) hm) have hv2 : 0 ≤ t₁ - v₂ := sub_nonneg.mpr (le_trans (le_max_right _ _) hm) exact add_le_add (Real.rpow_le_rpow hv1 (by linarith) hinv) (Real.rpow_le_rpow hv2 (by linarith) hinv) lemma lpPairFeas_nonempty {p y₁ y₂ v₁ v₂ : ℝ} (hp : 0 < p) : ({ t : ℝ | lpPairFeas p y₁ y₂ v₁ v₂ t }).Nonempty := by refine ⟨max v₁ v₂ + |y₁ - y₂| ^ p, ?_, ?_⟩ · have hnn : 0 ≤ |y₁ - y₂| ^ p := Real.rpow_nonneg (abs_nonneg _) p linarith · have hnn : 0 ≤ |y₁ - y₂| ^ p := Real.rpow_nonneg (abs_nonneg _) p have h1 : |y₁ - y₂| ^ p ≤ max v₁ v₂ + |y₁ - y₂| ^ p - v₁ := by linarith [le_max_left v₁ v₂] have h2 : (|y₁ - y₂| ^ p) ^ (1 / p) = |y₁ - y₂| := by rw [← Real.rpow_mul (abs_nonneg _), mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] have hinv : 0 ≤ 1 / p := by positivity have hle1 : |y₁ - y₂| ≤ (max v₁ v₂ + |y₁ - y₂| ^ p - v₁) ^ (1 / p) := calc |y₁ - y₂| = (|y₁ - y₂| ^ p) ^ (1 / p) := h2.symm _ ≤ (max v₁ v₂ + |y₁ - y₂| ^ p - v₁) ^ (1 / p) := Real.rpow_le_rpow hnn h1 hinv have hnn2 : 0 ≤ (max v₁ v₂ + |y₁ - y₂| ^ p - v₂) ^ (1 / p) := Real.rpow_nonneg (by linarith [le_max_right v₁ v₂]) _ linarith lemma lpPairFeas_bddBelow {p y₁ y₂ v₁ v₂ : ℝ} : BddBelow { t : ℝ | lpPairFeas p y₁ y₂ v₁ v₂ t } := ⟨max v₁ v₂, fun _ ht => ht.1⟩ lemma lpPairFeas_isClosed {p y₁ y₂ v₁ v₂ : ℝ} (hp : 0 < p) : IsClosed { t : ℝ | lpPairFeas p y₁ y₂ v₁ v₂ t } := by have h1 : IsClosed { t : ℝ | max v₁ v₂ ≤ t } := isClosed_Ici have hcont : Continuous (fun t : ℝ => (t - v₁) ^ (1 / p) + (t - v₂) ^ (1 / p)) := by have hinv : 0 ≤ 1 / p := by positivity exact ((continuous_id.sub continuous_const).rpow_const fun _ => Or.inr hinv).add ((continuous_id.sub continuous_const).rpow_const fun _ => Or.inr hinv) have h2 : IsClosed { t : ℝ | |y₁ - y₂| ≤ (t - v₁) ^ (1 / p) + (t - v₂) ^ (1 / p) } := isClosed_le continuous_const hcont exact h1.inter h2 /-- The infimum `lpPair p y₁ y₂ v₁ v₂` itself satisfies `lpPairFeas`. -/ lemma lpPair_mem_feas {p y₁ y₂ v₁ v₂ : ℝ} (hp : 0 < p) : lpPairFeas p y₁ y₂ v₁ v₂ (lpPair p y₁ y₂ v₁ v₂) := (lpPairFeas_isClosed hp).csInf_mem (lpPairFeas_nonempty hp) lpPairFeas_bddBelow /-- **Exact Feasibility Equivalence for `lpPair`**: for every `p > 0` and `t ∈ ℝ`, `lpPair p y₁ y₂ v₁ v₂ ≤ t ↔ max v₁ v₂ ≤ t ∧ |y₁ - y₂| ≤ (t - v₁)^(1/p) + (t - v₂)^(1/p)`. -/ theorem lpPair_le_iff {p y₁ y₂ v₁ v₂ t : ℝ} (hp : 0 < p) : lpPair p y₁ y₂ v₁ v₂ ≤ t ↔ lpPairFeas p y₁ y₂ v₁ v₂ t := ⟨fun hle => lpPairFeas_mono hp (lpPair_mem_feas hp) hle, fun ht => csInf_le lpPairFeas_bddBelow ht⟩ /-- **Exact Primal Equivalence for `lpPair`**: for `p > 0`, `lpPair p y₁ y₂ v₁ v₂ ≤ t ↔ ∃ y_hat : ℝ, v₁ + |y_hat - y₁|^p ≤ t ∧ v₂ + |y_hat - y₂|^p ≤ t`. -/ theorem lpPair_le_iff_exists {p y₁ y₂ v₁ v₂ t : ℝ} (hp : 0 < p) : lpPair p y₁ y₂ v₁ v₂ ≤ t ↔ ∃ y_hat : ℝ, v₁ + |y_hat - y₁| ^ p ≤ t ∧ v₂ + |y_hat - y₂| ^ p ≤ t := by rw [lpPair_le_iff hp] constructor · rintro ⟨hm, hr⟩ set r₁ := (t - v₁) ^ (1 / p) set r₂ := (t - v₂) ^ (1 / p) have ht1 : 0 ≤ t - v₁ := sub_nonneg.mpr (le_trans (le_max_left _ _) hm) have ht2 : 0 ≤ t - v₂ := sub_nonneg.mpr (le_trans (le_max_right _ _) hm) have hr1_nn : 0 ≤ r₁ := Real.rpow_nonneg ht1 _ have hr2_nn : 0 ≤ r₂ := Real.rpow_nonneg ht2 _ have hpow1 : r₁ ^ p = t - v₁ := by dsimp only [r₁]; rw [← Real.rpow_mul ht1, one_div_mul_cancel (ne_of_gt hp), Real.rpow_one] have hpow2 : r₂ ^ p = t - v₂ := by dsimp only [r₂]; rw [← Real.rpow_mul ht2, one_div_mul_cancel (ne_of_gt hp), Real.rpow_one] have hleft_le_right : max (y₁ - r₁) (y₂ - r₂) ≤ min (y₁ + r₁) (y₂ + r₂) := by have habs := abs_le.mp hr exact max_le (le_min (by linarith) (by linarith)) (le_min (by linarith) (by linarith)) refine ⟨max (y₁ - r₁) (y₂ - r₂), ?_, ?_⟩ · have habs1 : |max (y₁ - r₁) (y₂ - r₂) - y₁| ≤ r₁ := by rw [abs_le] exact ⟨by linarith [le_max_left (y₁ - r₁) (y₂ - r₂)], by linarith [le_trans hleft_le_right (min_le_left (y₁ + r₁) (y₂ + r₂))]⟩ have hp1 : |max (y₁ - r₁) (y₂ - r₂) - y₁| ^ p ≤ r₁ ^ p := Real.rpow_le_rpow (abs_nonneg _) habs1 (le_of_lt hp) linarith · have habs2 : |max (y₁ - r₁) (y₂ - r₂) - y₂| ≤ r₂ := by rw [abs_le] exact ⟨by linarith [le_max_right (y₁ - r₁) (y₂ - r₂)], by linarith [le_trans hleft_le_right (min_le_right (y₁ + r₁) (y₂ + r₂))]⟩ have hp2 : |max (y₁ - r₁) (y₂ - r₂) - y₂| ^ p ≤ r₂ ^ p := Real.rpow_le_rpow (abs_nonneg _) habs2 (le_of_lt hp) linarith · rintro ⟨y_hat, h1, h2⟩ have ht1 : 0 ≤ t - v₁ := by linarith [Real.rpow_nonneg (abs_nonneg (y_hat - y₁)) p] have ht2 : 0 ≤ t - v₂ := by linarith [Real.rpow_nonneg (abs_nonneg (y_hat - y₂)) p] refine ⟨max_le (by linarith) (by linarith), ?_⟩ have hinv : 0 ≤ 1 / p := by positivity have ha1 : |y_hat - y₁| ≤ (t - v₁) ^ (1 / p) := by have hpow : |y_hat - y₁| ^ p ≤ t - v₁ := by linarith have hrew : (|y_hat - y₁| ^ p) ^ (1 / p) = |y_hat - y₁| := by rw [← Real.rpow_mul (abs_nonneg _), mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] rw [← hrew] exact Real.rpow_le_rpow (Real.rpow_nonneg (abs_nonneg _) p) hpow hinv have ha2 : |y_hat - y₂| ≤ (t - v₂) ^ (1 / p) := by have hpow : |y_hat - y₂| ^ p ≤ t - v₂ := by linarith have hrew : (|y_hat - y₂| ^ p) ^ (1 / p) = |y_hat - y₂| := by rw [← Real.rpow_mul (abs_nonneg _), mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] rw [← hrew] exact Real.rpow_le_rpow (Real.rpow_nonneg (abs_nonneg _) p) hpow hinv calc |y₁ - y₂| = |(y₁ - y_hat) + (y_hat - y₂)| := by ring_nf _ ≤ |y₁ - y_hat| + |y_hat - y₂| := abs_add_le _ _ _ = |y_hat - y₁| + |y_hat - y₂| := by rw [abs_sub_comm] _ ≤ (t - v₁) ^ (1 / p) + (t - v₂) ^ (1 / p) := add_le_add ha1 ha2 lemma lpPair_comm {p y₁ y₂ v₁ v₂ : ℝ} (hp : 0 < p) : lpPair p y₁ y₂ v₁ v₂ = lpPair p y₂ y₁ v₂ v₁ := by apply le_antisymm · rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := y₂) (y₂ := y₁) (v₁ := v₂) (v₂ := v₁) with ⟨hm, hr⟩ exact ⟨by rwa [max_comm], by rw [abs_sub_comm, add_comm]; exact hr⟩ · rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := y₁) (y₂ := y₂) (v₁ := v₁) (v₂ := v₂) with ⟨hm, hr⟩ exact ⟨by rwa [max_comm], by rw [abs_sub_comm, add_comm]; exact hr⟩ lemma lpPair_self {p y v : ℝ} (hp : 0 < p) : lpPair p y y v v = v := by apply le_antisymm · rw [lpPair_le_iff hp] refine ⟨by simp, ?_⟩ rw [sub_self, sub_self, abs_zero, Real.zero_rpow (ne_of_gt (div_pos one_pos hp))]; norm_num · exact le_trans (le_max_left v v) (lpPair_mem_feas hp).1 lemma max_le_lpPair {p y₁ y₂ v₁ v₂ : ℝ} (hp : 0 < p) : max v₁ v₂ ≤ lpPair p y₁ y₂ v₁ v₂ := (lpPair_mem_feas hp).1 lemma lpPair_mono_v {p y₁ y₂ v₁ v₂ w₁ w₂ : ℝ} (hp : 0 < p) (h1 : v₁ ≤ w₁) (h2 : v₂ ≤ w₂) : lpPair p y₁ y₂ v₁ v₂ ≤ lpPair p y₁ y₂ w₁ w₂ := by rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := y₁) (y₂ := y₂) (v₁ := w₁) (v₂ := w₂) with ⟨hm, hr⟩ have hinv : 0 ≤ 1 / p := by positivity refine ⟨le_trans (max_le_max h1 h2) hm, le_trans hr ?_⟩ exact add_le_add (Real.rpow_le_rpow (sub_nonneg.mpr (le_trans (le_max_left _ _) hm)) (by linarith) hinv) (Real.rpow_le_rpow (sub_nonneg.mpr (le_trans (le_max_right _ _) hm)) (by linarith) hinv) lemma lpPair_mono_dist {p y₁ y₂ z₁ z₂ v₁ v₂ : ℝ} (hp : 0 < p) (hd : |y₁ - y₂| ≤ |z₁ - z₂|) : lpPair p y₁ y₂ v₁ v₂ ≤ lpPair p z₁ z₂ v₁ v₂ := by rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := z₁) (y₂ := z₂) (v₁ := v₁) (v₂ := v₂) with ⟨hm, hr⟩ exact ⟨hm, le_trans hd hr⟩ lemma lpPair_eq_const {p y₁ y₂ v : ℝ} (hp : 0 < p) : lpPair p y₁ y₂ v v = v + (|y₁ - y₂| / 2) ^ p := by have hnn : 0 ≤ |y₁ - y₂| / 2 := by positivity have hpow : ((|y₁ - y₂| / 2) ^ p) ^ (1 / p) = |y₁ - y₂| / 2 := by rw [← Real.rpow_mul hnn, mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] apply le_antisymm · rw [lpPair_le_iff hp] refine ⟨by simp [Real.rpow_nonneg hnn p], ?_⟩ simp only [add_sub_cancel_left, hpow] linarith · rcases lpPair_mem_feas hp (y₁ := y₁) (y₂ := y₂) (v₁ := v) (v₂ := v) with ⟨hm, hr⟩ have hge : v ≤ lpPair p y₁ y₂ v v := le_trans (le_max_left v v) hm have hr' : |y₁ - y₂| / 2 ≤ (lpPair p y₁ y₂ v v - v) ^ (1 / p) := by linarith have hp_le := Real.rpow_le_rpow hnn hr' (le_of_lt hp) rw [← Real.rpow_mul (sub_nonneg.mpr hge), one_div_mul_cancel (ne_of_gt hp), Real.rpow_one] at hp_le linarith lemma lpPair_add_const {p y₁ y₂ v₁ v₂ c : ℝ} (hp : 0 < p) : lpPair p y₁ y₂ (v₁ + c) (v₂ + c) = lpPair p y₁ y₂ v₁ v₂ + c := by apply le_antisymm · rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := y₁) (y₂ := y₂) (v₁ := v₁) (v₂ := v₂) with ⟨hm, hr⟩ refine ⟨max_le (by linarith [le_max_left v₁ v₂]) (by linarith [le_max_right v₁ v₂]), ?_⟩ simpa [add_sub_add_right_eq_sub] using hr · have hle : lpPair p y₁ y₂ v₁ v₂ ≤ lpPair p y₁ y₂ (v₁ + c) (v₂ + c) - c := by rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := y₁) (y₂ := y₂) (v₁ := v₁ + c) (v₂ := v₂ + c) with ⟨hm, hr⟩ refine ⟨max_le (by linarith [le_max_left (v₁ + c) (v₂ + c)]) (by linarith [le_max_right (v₁ + c) (v₂ + c)]), ?_⟩ have h1 : lpPair p y₁ y₂ (v₁ + c) (v₂ + c) - c - v₁ = lpPair p y₁ y₂ (v₁ + c) (v₂ + c) - (v₁ + c) := by ring have h2 : lpPair p y₁ y₂ (v₁ + c) (v₂ + c) - c - v₂ = lpPair p y₁ y₂ (v₁ + c) (v₂ + c) - (v₂ + c) := by ring rw [h1, h2]; exact hr linarith lemma lpPair_scale {p y₁ y₂ v₁ v₂ s : ℝ} (hp : 0 < p) (hs : 0 < s) : lpPair p (s * y₁) (s * y₂) (s ^ p * v₁) (s ^ p * v₂) = s ^ p * lpPair p y₁ y₂ v₁ v₂ := by have hsp : 0 < s ^ p := Real.rpow_pos_of_pos hs p have hsp_inv : (s ^ p) ^ (1 / p) = s := by rw [← Real.rpow_mul (le_of_lt hs), mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] apply le_antisymm · rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := y₁) (y₂ := y₂) (v₁ := v₁) (v₂ := v₂) with ⟨hm, hr⟩ have hm' : max (s ^ p * v₁) (s ^ p * v₂) ≤ s ^ p * lpPair p y₁ y₂ v₁ v₂ := max_le (mul_le_mul_of_nonneg_left (le_trans (le_max_left _ _) hm) (le_of_lt hsp)) (mul_le_mul_of_nonneg_left (le_trans (le_max_right _ _) hm) (le_of_lt hsp)) refine ⟨hm', ?_⟩ rw [← mul_sub, abs_mul, abs_of_pos hs, ← mul_sub, ← mul_sub, Real.mul_rpow (le_of_lt hsp) (sub_nonneg.mpr (le_trans (le_max_left _ _) hm)), Real.mul_rpow (le_of_lt hsp) (sub_nonneg.mpr (le_trans (le_max_right _ _) hm)), hsp_inv, ← mul_add] exact mul_le_mul_of_nonneg_left hr (le_of_lt hs) · have hle : lpPair p y₁ y₂ v₁ v₂ ≤ lpPair p (s * y₁) (s * y₂) (s ^ p * v₁) (s ^ p * v₂) / s ^ p := by rw [lpPair_le_iff hp] rcases lpPair_mem_feas hp (y₁ := s * y₁) (y₂ := s * y₂) (v₁ := s ^ p * v₁) (v₂ := s ^ p * v₂) with ⟨hm, hr⟩ set T := lpPair p (s * y₁) (s * y₂) (s ^ p * v₁) (s ^ p * v₂) have hm' : max v₁ v₂ ≤ T / s ^ p := by rw [le_div_iff₀ hsp] have h1' : v₁ * s ^ p ≤ T := by rw [mul_comm]; exact le_trans (le_max_left _ _) hm have h2' : v₂ * s ^ p ≤ T := by rw [mul_comm]; exact le_trans (le_max_right _ _) hm rcases le_total v₁ v₂ with h | h · rw [max_eq_right h]; exact h2' · rw [max_eq_left h]; exact h1' refine ⟨hm', ?_⟩ have h1 : T / s ^ p - v₁ = (T - s ^ p * v₁) / s ^ p := by field_simp [ne_of_gt hsp] have h2 : T / s ^ p - v₂ = (T - s ^ p * v₂) / s ^ p := by field_simp [ne_of_gt hsp] rw [h1, h2, Real.div_rpow (sub_nonneg.mpr (le_trans (le_max_left _ _) hm)) (le_of_lt hsp), Real.div_rpow (sub_nonneg.mpr (le_trans (le_max_right _ _) hm)) (le_of_lt hsp), hsp_inv, ← add_div, le_div_iff₀ hs] rw [← mul_sub, abs_mul, abs_of_pos hs] at hr linarith exact (le_div_iff₀ hsp).mp hle |> fun h => by linarith lemma lpPair_anti_p {p q y₁ y₂ v₁ v₂ : ℝ} (hp : 0 < p) (hpq : p ≤ q) (hd : |y₁ - y₂| ≤ 1) : lpPair q y₁ y₂ v₁ v₂ ≤ lpPair p y₁ y₂ v₁ v₂ := by have hq : 0 < q := lt_of_lt_of_le hp hpq rw [lpPair_le_iff_exists hq] obtain ⟨y_hat, h1, h2⟩ := (lpPair_le_iff_exists hp).mp (le_rfl : lpPair p y₁ y₂ v₁ v₂ ≤ _) set lo := min y₁ y₂ set hi := max y₁ y₂ set y' := max lo (min hi y_hat) have hclamp : ∀ z : ℝ, lo ≤ z → z ≤ hi → |y' - z| ≤ |y_hat - z| ∧ |y' - z| ≤ |y₁ - y₂| := by intro z hloz hz_hi have hlo_hi : lo ≤ hi := le_trans hloz hz_hi have hy'_lo : lo ≤ y' := le_max_left _ _ have hy'_hi : y' ≤ hi := max_le hlo_hi (min_le_left _ _) constructor · rcases le_total y_hat lo with h | h · have hy'eq : y' = lo := by dsimp only [y']; rw [min_eq_right (le_trans h hlo_hi), max_eq_left h] rw [hy'eq, abs_of_nonpos (by linarith), abs_of_nonpos (by linarith)]; linarith · rcases le_total y_hat hi with h' | h' · have hy'eq : y' = y_hat := by dsimp only [y']; rw [min_eq_right h', max_eq_right h] rw [hy'eq] · have hy'eq : y' = hi := by dsimp only [y']; rw [min_eq_left h', max_eq_right hlo_hi] rw [hy'eq, abs_of_nonneg (by linarith), abs_of_nonneg (by linarith)]; linarith · rw [abs_le] rcases le_total y₁ y₂ with hle | hle · have hlo_eq : lo = y₁ := min_eq_left hle have hhi_eq : hi = y₂ := max_eq_right hle rw [abs_of_nonpos (sub_nonpos.mpr hle)] exact ⟨by linarith, by linarith⟩ · have hlo_eq : lo = y₂ := min_eq_right hle have hhi_eq : hi = y₁ := max_eq_left hle rw [abs_of_nonneg (sub_nonneg.mpr hle)] exact ⟨by linarith, by linarith⟩ have h1' := hclamp y₁ (min_le_left _ _) (le_max_left _ _) have h2' := hclamp y₂ (min_le_right _ _) (le_max_right _ _) refine ⟨y', ?_, ?_⟩ · have hq_le_p : |y' - y₁| ^ q ≤ |y' - y₁| ^ p := Real.rpow_le_rpow_of_exponent_ge' (abs_nonneg _) (le_trans h1'.2 hd) (le_of_lt hp) hpq have hp_le : |y' - y₁| ^ p ≤ |y_hat - y₁| ^ p := Real.rpow_le_rpow (abs_nonneg _) h1'.1 (le_of_lt hp) linarith · have hq_le_p : |y' - y₂| ^ q ≤ |y' - y₂| ^ p := Real.rpow_le_rpow_of_exponent_ge' (abs_nonneg _) (le_trans h2'.2 hd) (le_of_lt hp) hpq have hp_le : |y' - y₂| ^ p ≤ |y_hat - y₂| ^ p := Real.rpow_le_rpow (abs_nonneg _) h2'.1 (le_of_lt hp) linarith /-- **Exact Closed Form of `lpPair` at `p = 1` (Absolute Loss)**: `lpPair 1 y₁ y₂ v₁ v₂ = max (max v₁ v₂) ((v₁ + v₂ + |y₁ - y₂|) / 2)`. -/ theorem lpPair_one_eq (y₁ y₂ v₁ v₂ : ℝ) : lpPair 1 y₁ y₂ v₁ v₂ = max (max v₁ v₂) ((v₁ + v₂ + |y₁ - y₂|) / 2) := by apply le_antisymm · rw [lpPair_le_iff (by norm_num : (0 : ℝ) < 1)] refine ⟨le_max_left _ _, ?_⟩ simp only [div_one, Real.rpow_one] linarith [le_max_right (max v₁ v₂) ((v₁ + v₂ + |y₁ - y₂|) / 2)] · rcases lpPair_mem_feas (by norm_num : (0 : ℝ) < 1) (y₁ := y₁) (y₂ := y₂) (v₁ := v₁) (v₂ := v₂) with ⟨hm, hr⟩ simp only [div_one, Real.rpow_one] at hr exact max_le hm (by linarith) /-- **Exact Closed Form of `lpPair` at `p = 2` (Squared Loss)**: when `|v₁ - v₂| ≥ (y₁ - y₂)^2`, `lpPair 2 = max v₁ v₂`; otherwise `lpPair 2 = (v₁ + v₂)/2 + (y₁ - y₂)^2 / 4 + (v₁ - v₂)^2 / (4 * (y₁ - y₂)^2)`. -/ theorem lpPair_two_eq (y₁ y₂ v₁ v₂ : ℝ) : lpPair 2 y₁ y₂ v₁ v₂ = if (y₁ - y₂) ^ 2 ≤ |v₁ - v₂| then max v₁ v₂ else (v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 + (v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2) := by split_ifs with hdom · apply le_antisymm · rw [lpPair_le_iff (by norm_num : (0 : ℝ) < 2)] refine ⟨le_rfl, ?_⟩ rcases le_total v₁ v₂ with h12 | h21 · have hdiff : (y₁ - y₂) ^ 2 ≤ v₂ - v₁ := by rw [abs_of_nonpos (sub_nonpos.mpr h12)] at hdom; linarith rw [max_eq_right h12, sub_self, Real.zero_rpow (by norm_num), add_zero] have hsqrt : |y₁ - y₂| ≤ (v₂ - v₁) ^ (1 / 2 : ℝ) := by rw [← Real.sqrt_eq_rpow, Real.le_sqrt (abs_nonneg _) (by linarith), sq_abs] exact hdiff exact hsqrt · have hdiff : (y₁ - y₂) ^ 2 ≤ v₁ - v₂ := by rw [abs_of_nonneg (sub_nonneg.mpr h21)] at hdom; linarith rw [max_eq_left h21, sub_self, Real.zero_rpow (by norm_num), zero_add] have hsqrt : |y₁ - y₂| ≤ (v₁ - v₂) ^ (1 / 2 : ℝ) := by rw [← Real.sqrt_eq_rpow, Real.le_sqrt (abs_nonneg _) (by linarith), sq_abs] exact hdiff exact hsqrt · exact max_le_lpPair (by norm_num) · push Not at hdom set d := |y₁ - y₂| have hd_sq : d ^ 2 = (y₁ - y₂) ^ 2 := sq_abs (y₁ - y₂) have hd_pos : 0 < d := by by_contra h0; push Not at h0 have hd0 : d = 0 := le_antisymm h0 (abs_nonneg _) have : (y₁ - y₂) ^ 2 = 0 := by rw [← hd_sq, hd0]; norm_num linarith [abs_nonneg (v₁ - v₂)] have hsq_pos : 0 < (y₁ - y₂) ^ 2 := by rw [← hd_sq]; positivity set T := (v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 + (v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2) have hT1 : T - v₁ = ((y₁ - y₂) ^ 2 + (v₂ - v₁)) ^ 2 / (4 * (y₁ - y₂) ^ 2) := by have hden : 4 * (y₁ - y₂) ^ 2 ≠ 0 := by positivity apply mul_left_cancel₀ hden dsimp only [T] rw [mul_div_cancel₀ _ hden] have hterm : 4 * (y₁ - y₂) ^ 2 * ((v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2)) = (v₁ - v₂) ^ 2 := mul_div_cancel₀ _ hden calc 4 * (y₁ - y₂) ^ 2 * ((v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 + (v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2) - v₁) = 4 * (y₁ - y₂) ^ 2 * ((v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 - v₁) + 4 * (y₁ - y₂) ^ 2 * ((v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2)) := by ring _ = 4 * (y₁ - y₂) ^ 2 * ((v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 - v₁) + (v₁ - v₂) ^ 2 := by rw [hterm] _ = ((y₁ - y₂) ^ 2 + (v₂ - v₁)) ^ 2 := by ring have hT2 : T - v₂ = ((y₁ - y₂) ^ 2 + (v₁ - v₂)) ^ 2 / (4 * (y₁ - y₂) ^ 2) := by have hden : 4 * (y₁ - y₂) ^ 2 ≠ 0 := by positivity apply mul_left_cancel₀ hden dsimp only [T] rw [mul_div_cancel₀ _ hden] have hterm : 4 * (y₁ - y₂) ^ 2 * ((v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2)) = (v₁ - v₂) ^ 2 := mul_div_cancel₀ _ hden calc 4 * (y₁ - y₂) ^ 2 * ((v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 + (v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2) - v₂) = 4 * (y₁ - y₂) ^ 2 * ((v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 - v₂) + 4 * (y₁ - y₂) ^ 2 * ((v₁ - v₂) ^ 2 / (4 * (y₁ - y₂) ^ 2)) := by ring _ = 4 * (y₁ - y₂) ^ 2 * ((v₁ + v₂) / 2 + (y₁ - y₂) ^ 2 / 4 - v₂) + (v₁ - v₂) ^ 2 := by rw [hterm] _ = ((y₁ - y₂) ^ 2 + (v₁ - v₂)) ^ 2 := by ring have hpos1 : 0 < (y₁ - y₂) ^ 2 + (v₂ - v₁) := by have := (abs_lt.mp hdom).2; linarith have hpos2 : 0 < (y₁ - y₂) ^ 2 + (v₁ - v₂) := by have := (abs_lt.mp hdom).1; linarith have hs1 : (T - v₁) ^ (1 / 2 : ℝ) = ((y₁ - y₂) ^ 2 + (v₂ - v₁)) / (2 * d) := by rw [← Real.sqrt_eq_rpow, hT1] have hrew : ((y₁ - y₂) ^ 2 + (v₂ - v₁)) ^ 2 / (4 * (y₁ - y₂) ^ 2) = (((y₁ - y₂) ^ 2 + (v₂ - v₁)) / (2 * d)) ^ 2 := by rw [div_pow, mul_pow, hd_sq]; ring rw [hrew, Real.sqrt_sq (by positivity)] have hs2 : (T - v₂) ^ (1 / 2 : ℝ) = ((y₁ - y₂) ^ 2 + (v₁ - v₂)) / (2 * d) := by rw [← Real.sqrt_eq_rpow, hT2] have hrew : ((y₁ - y₂) ^ 2 + (v₁ - v₂)) ^ 2 / (4 * (y₁ - y₂) ^ 2) = (((y₁ - y₂) ^ 2 + (v₁ - v₂)) / (2 * d)) ^ 2 := by rw [div_pow, mul_pow, hd_sq]; ring rw [hrew, Real.sqrt_sq (by positivity)] have hsum_eq : (T - v₁) ^ (1 / 2 : ℝ) + (T - v₂) ^ (1 / 2 : ℝ) = d := by rw [hs1, hs2, ← add_div] have hnum : (y₁ - y₂) ^ 2 + (v₂ - v₁) + ((y₁ - y₂) ^ 2 + (v₁ - v₂)) = 2 * d ^ 2 := by rw [hd_sq]; ring rw [hnum]; field_simp [ne_of_gt hd_pos] apply le_antisymm · rw [lpPair_le_iff (by norm_num : (0 : ℝ) < 2)] refine ⟨max_le (by rw [← sub_nonneg, hT1]; positivity) (by rw [← sub_nonneg, hT2]; positivity), by rw [hsum_eq]⟩ · by_contra hlt push Not at hlt rcases lpPair_mem_feas (by norm_num : (0 : ℝ) < 2) (y₁ := y₁) (y₂ := y₂) (v₁ := v₁) (v₂ := v₂) with ⟨hm, hr⟩ have h1 : (lpPair 2 y₁ y₂ v₁ v₂ - v₁) ^ (1 / 2 : ℝ) < (T - v₁) ^ (1 / 2 : ℝ) := Real.rpow_lt_rpow (sub_nonneg.mpr (le_trans (le_max_left _ _) hm)) (by linarith) (by norm_num) have h2 : (lpPair 2 y₁ y₂ v₁ v₂ - v₂) ^ (1 / 2 : ℝ) < (T - v₂) ^ (1 / 2 : ℝ) := Real.rpow_lt_rpow (sub_nonneg.mpr (le_trans (le_max_right _ _) hm)) (by linarith) (by norm_num) linarith /-- **Multi-Label 1-Round ℓ_p Minimax Operator**: defined via the exact pairwise 1D Helly maximum over `S × S`. -/ def lpVal (p : ℝ) (S : Finset ℝ) (v : ℝ → ℝ) : ℝ := if hS : S.Nonempty then S.sup' hS fun y₁ => S.sup' hS fun y₂ => lpPair p y₁ y₂ (v y₁) (v y₂) else 0 lemma lpVal_le_iff_pairs {p : ℝ} {S : Finset ℝ} (hS : S.Nonempty) (v : ℝ → ℝ) (t : ℝ) : lpVal p S v ≤ t ↔ ∀ y₁ ∈ S, ∀ y₂ ∈ S, lpPair p y₁ y₂ (v y₁) (v y₂) ≤ t := by simp only [lpVal, dif_pos hS, Finset.sup'_le_iff] lemma lpPair_le_lpVal {p : ℝ} {S : Finset ℝ} {y₁ y₂ : ℝ} (hy₁ : y₁ ∈ S) (hy₂ : y₂ ∈ S) (v : ℝ → ℝ) : lpPair p y₁ y₂ (v y₁) (v y₂) ≤ lpVal p S v := (lpVal_le_iff_pairs ⟨y₁, hy₁⟩ v (lpVal p S v)).mp le_rfl y₁ hy₁ y₂ hy₂ lemma le_lpVal_of_mem {p : ℝ} (hp : 0 < p) {S : Finset ℝ} {y : ℝ} (hy : y ∈ S) (v : ℝ → ℝ) : v y ≤ lpVal p S v := by calc v y = lpPair p y y (v y) (v y) := (lpPair_self hp).symm _ ≤ lpVal p S v := lpPair_le_lpVal hy hy v /-- **1D Helly Exact Minimax Theorem for Multi-Label ℓ_p Regression (`p > 0`)**: For EVERY finite nonempty label set `S ⊆ ℝ`, EVERY continuation function `v : ℝ → ℝ`, and `t ∈ ℝ`: `lpVal p S v ≤ t ↔ ∃ y_hat : ℝ, ∀ y ∈ S, v y + |y_hat - y|^p ≤ t`. -/ theorem lpVal_le_iff {p : ℝ} (hp : 0 < p) {S : Finset ℝ} (hS : S.Nonempty) (v : ℝ → ℝ) (t : ℝ) : lpVal p S v ≤ t ↔ ∃ y_hat : ℝ, ∀ y ∈ S, v y + |y_hat - y| ^ p ≤ t := by rw [lpVal_le_iff_pairs hS] constructor · intro hpair have hvt : ∀ y ∈ S, v y ≤ t := fun y hy => le_trans (le_max_left _ _) ((lpPair_le_iff hp).mp (hpair y hy y hy)).1 set a : ℝ → ℝ := fun y => y - (t - v y) ^ (1 / p) set b : ℝ → ℝ := fun y => y + (t - v y) ^ (1 / p) have hab : ∀ y₁ ∈ S, ∀ y₂ ∈ S, a y₁ ≤ b y₂ := by intro y₁ hy₁ y₂ hy₂ have hr := ((lpPair_le_iff hp).mp (hpair y₁ hy₁ y₂ hy₂)).2 have hsub : y₁ - y₂ ≤ (t - v y₁) ^ (1 / p) + (t - v y₂) ^ (1 / p) := le_trans (le_abs_self _) hr dsimp only [a, b]; linarith set y_hat := S.sup' hS a refine ⟨y_hat, fun y hy => ?_⟩ have hlow : a y ≤ y_hat := Finset.le_sup' a hy have hhigh : y_hat ≤ b y := Finset.sup'_le hS a fun y₁ hy₁ => hab y₁ hy₁ y hy have habs : |y_hat - y| ≤ (t - v y) ^ (1 / p) := by rw [abs_le]; dsimp only [a, b] at hlow hhigh; exact ⟨by linarith, by linarith⟩ have hpow := Real.rpow_le_rpow (abs_nonneg _) habs (le_of_lt hp) rw [← Real.rpow_mul (sub_nonneg.mpr (hvt y hy)), one_div_mul_cancel (ne_of_gt hp), Real.rpow_one] at hpow linarith · rintro ⟨y_hat, hy_hat⟩ y₁ hy₁ y₂ hy₂ exact (lpPair_le_iff_exists hp).mpr ⟨y_hat, hy_hat y₁ hy₁, hy_hat y₂ hy₂⟩ /-- **1-Round Primal Achievability**: there exists an explicit prediction `y_hat ∈ ℝ` whose worst-case loss over all `y ∈ S` is at most `lpVal p S v`. -/ theorem lpVal_primal_upper {p : ℝ} (hp : 0 < p) {S : Finset ℝ} (hS : S.Nonempty) (v : ℝ → ℝ) : ∃ y_hat : ℝ, ∀ y ∈ S, v y + |y_hat - y| ^ p ≤ lpVal p S v := (lpVal_le_iff hp hS v (lpVal p S v)).mp le_rfl /-- **Convexity / Zero Randomization Gain Lemma for ℓ_p Loss (`p ≥ 1`)**: for any finite probability distribution `(w, z)` on `ℝ` (`w ≥ 0, ∑ w = 1`), the deterministic expected prediction `∑ wᵢ zᵢ` incurs ℓ_p loss no larger than the expected ℓ_p loss `∑ wᵢ |zᵢ - y|^p`! -/ theorem lp_jensen_randomization_no_gain {ι : Type*} {p : ℝ} (hp : 1 ≤ p) (I : Finset ι) (w z : ι → ℝ) (hw : ∀ i ∈ I, 0 ≤ w i) (hsum : ∑ i ∈ I, w i = 1) (y : ℝ) : |(∑ i ∈ I, w i * z i) - y| ^ p ≤ ∑ i ∈ I, w i * |z i - y| ^ p := by have h1 : |(∑ i ∈ I, w i * z i) - y| ≤ ∑ i ∈ I, w i * |z i - y| := by have hrew : (∑ i ∈ I, w i * z i) - y = ∑ i ∈ I, w i * (z i - y) := by calc (∑ i ∈ I, w i * z i) - y = (∑ i ∈ I, w i * z i) - (∑ i ∈ I, w i) * y := by rw [hsum, one_mul] _ = (∑ i ∈ I, w i * z i) - ∑ i ∈ I, w i * y := by rw [Finset.sum_mul] _ = ∑ i ∈ I, (w i * z i - w i * y) := (Finset.sum_sub_distrib _ _).symm _ = ∑ i ∈ I, w i * (z i - y) := Finset.sum_congr rfl fun i _ => by ring rw [hrew] calc |∑ i ∈ I, w i * (z i - y)| ≤ ∑ i ∈ I, |w i * (z i - y)| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ i ∈ I, w i * |z i - y| := Finset.sum_congr rfl fun i hi => by rw [abs_mul, abs_of_nonneg (hw i hi)] have hconv : ConvexOn ℝ (Set.Ici (0 : ℝ)) (fun x : ℝ => x ^ p) := convexOn_rpow hp have hjensen := hconv.map_sum_le hw hsum (fun i _ => Set.mem_Ici.mpr (abs_nonneg (z i - y))) have hpow := Real.rpow_le_rpow (abs_nonneg _) h1 (by linarith : 0 ≤ p) exact le_trans hpow hjensen /-- **1-Round Exact 2-Point Dual Adversary Lower Bound (`p ≥ 1`)**: For every `p ≥ 1`, finite nonempty `S ⊆ ℝ`, and `v : ℝ → ℝ`, there exists an explicit probability distribution `ν` on `S` (supported on at most 2 points!) such that for EVERY prediction `y_hat : ℝ`, `∑ y ∈ S, ν y * (v y + |y_hat - y|^p) ≥ lpVal p S v`! -/ theorem lpVal_dual_lower {p : ℝ} (hp : 1 ≤ p) {S : Finset ℝ} (hS : S.Nonempty) (v : ℝ → ℝ) : ∃ ν : ℝ → ℝ, (∀ y ∈ S, 0 ≤ ν y) ∧ (∑ y ∈ S, ν y = 1) ∧ ∀ y_hat : ℝ, lpVal p S v ≤ ∑ y ∈ S, ν y * (v y + |y_hat - y| ^ p) := by have hp0 : 0 < p := by linarith -- Extract the maximizing pair (y₁, y₂) ∈ S × S achieving lpVal p S v obtain ⟨y₁, hy₁, houter⟩ := Finset.exists_mem_eq_sup' hS (fun y₁ => S.sup' hS fun y₂ => lpPair p y₁ y₂ (v y₁) (v y₂)) obtain ⟨y₂, hy₂, hinner⟩ := Finset.exists_mem_eq_sup' hS (fun y₂ => lpPair p y₁ y₂ (v y₁) (v y₂)) have hT_eq : lpVal p S v = lpPair p y₁ y₂ (v y₁) (v y₂) := by rw [lpVal, dif_pos hS, houter, hinner] set T := lpPair p y₁ y₂ (v y₁) (v y₂) rw [hT_eq] -- Case 1: T = v y₁ (point mass on y₁) by_cases h1 : T ≤ v y₁ · refine ⟨fun y => if y = y₁ then 1 else 0, fun y _ => by dsimp only; split_ifs <;> norm_num, by rw [Finset.sum_ite_eq' S y₁, if_pos hy₁], fun y_hat => ?_⟩ rw [Finset.sum_eq_single y₁ (fun y _ hne => by simp [hne]) (fun h => absurd hy₁ h)] simp only [↓reduceIte, one_mul] linarith [Real.rpow_nonneg (abs_nonneg (y_hat - y₁)) p] -- Case 2: T = v y₂ (point mass on y₂) by_cases h2 : T ≤ v y₂ · refine ⟨fun y => if y = y₂ then 1 else 0, fun y _ => by dsimp only; split_ifs <;> norm_num, by rw [Finset.sum_ite_eq' S y₂, if_pos hy₂], fun y_hat => ?_⟩ rw [Finset.sum_eq_single y₂ (fun y _ hne => by simp [hne]) (fun h => absurd hy₂ h)] simp only [↓reduceIte, one_mul] linarith [Real.rpow_nonneg (abs_nonneg (y_hat - y₂)) p] -- Case 3: v y₁ < T and v y₂ < T (strict interior saddle point on {y₁, y₂}) push Not at h1 h2 have hne : y₁ ≠ y₂ := by intro heq; subst heq have : T = v y₁ := lpPair_self hp0 linarith set r₁ := (T - v y₁) ^ (1 / p) set r₂ := (T - v y₂) ^ (1 / p) have hr₁_pos : 0 < r₁ := Real.rpow_pos_of_pos (sub_pos.mpr h1) _ have hr₂_pos : 0 < r₂ := Real.rpow_pos_of_pos (sub_pos.mpr h2) _ have hr₁_pow : r₁ ^ p = T - v y₁ := by dsimp only [r₁]; rw [← Real.rpow_mul (sub_nonneg.mpr (le_of_lt h1)), one_div_mul_cancel (ne_of_gt hp0), Real.rpow_one] have hr₂_pow : r₂ ^ p = T - v y₂ := by dsimp only [r₂]; rw [← Real.rpow_mul (sub_nonneg.mpr (le_of_lt h2)), one_div_mul_cancel (ne_of_gt hp0), Real.rpow_one] -- Prove |y₁ - y₂| = r₁ + r₂ (otherwise T could be strictly decreased!) have hsum_r : |y₁ - y₂| = r₁ + r₂ := by apply le_antisymm (lpPair_mem_feas hp0).2 by_contra hlt push Not at hlt -- Continuity of s ↦ (s - v y₁)^(1/p) + (s - v y₂)^(1/p) at T gives s < T still feasible! have hcont : ContinuousAt (fun s : ℝ => (s - v y₁) ^ (1 / p) + (s - v y₂) ^ (1 / p)) T := by have hinv : 0 ≤ 1 / p := by positivity exact ((continuous_id.sub continuous_const).rpow_const fun _ => Or.inr hinv).continuousAt.add ((continuous_id.sub continuous_const).rpow_const fun _ => Or.inr hinv).continuousAt have hev := (hcont.eventually (lt_mem_nhds hlt)).and (Ioo_mem_nhds (max_lt h1 h2) (lt_add_one T)) rcases Metric.eventually_nhds_iff.mp hev with ⟨δ, hδ_pos, hδ⟩ set s := T - δ / 2 have hdist : dist s T < δ := by rw [Real.dist_eq]; dsimp only [s]; rw [show T - δ / 2 - T = -(δ / 2) by ring, abs_neg, abs_of_pos (by linarith)]; linarith have hs := hδ hdist have hfeas : lpPairFeas p y₁ y₂ (v y₁) (v y₂) s := ⟨le_of_lt hs.2.1, le_of_lt hs.1⟩ have hle : T ≤ s := (lpPair_le_iff hp0).mpr hfeas dsimp only [s] at hle; linarith -- Choose exact slope-canceling dual weights on {y₁, y₂}: -- w₁ = r₂^(p-1) / (r₁^(p-1) + r₂^(p-1)), w₂ = r₁^(p-1) / (r₁^(p-1) + r₂^(p-1))! set a₁ := r₁ ^ (p - 1) set a₂ := r₂ ^ (p - 1) have ha₁_pos : 0 < a₁ := Real.rpow_pos_of_pos hr₁_pos _ have ha₂_pos : 0 < a₂ := Real.rpow_pos_of_pos hr₂_pos _ have hden_pos : 0 < a₁ + a₂ := by linarith set w₁ := a₂ / (a₁ + a₂) set w₂ := a₁ / (a₁ + a₂) have hw₁_pos : 0 < w₁ := div_pos ha₂_pos hden_pos have hw₂_pos : 0 < w₂ := div_pos ha₁_pos hden_pos have hw_sum : w₁ + w₂ = 1 := by dsimp only [w₁, w₂]; rw [← add_div, add_comm, div_self (ne_of_gt hden_pos)] refine ⟨fun y => if y = y₁ then w₁ else if y = y₂ then w₂ else 0, fun y _ => by dsimp only; split_ifs <;> linarith, ?_, fun y_hat => ?_⟩ · have hpair_sub : ({y₁, y₂} : Finset ℝ) ⊆ S := by intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl; exact hy₁; exact hy₂ rw [← Finset.sum_subset hpair_sub (fun y _ hnot => by simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hnot simp [hnot.1, hnot.2]), Finset.sum_pair hne] simp [hne.symm, hw_sum] · have hpair_sub : ({y₁, y₂} : Finset ℝ) ⊆ S := by intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl; exact hy₁; exact hy₂ rw [← Finset.sum_subset hpair_sub (fun y _ hnot => by simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hnot simp [hnot.1, hnot.2]), Finset.sum_pair hne] simp only [↓reduceIte, hne.symm] -- Elementary convexity inequality for x^p (p ≥ 1): for ALL x ≥ 0 and r > 0, -- x^p ≥ r^p + p * r^(p - 1) * (x - r) ! have hsubgrad : ∀ {r x : ℝ}, 0 < r → 0 ≤ x → r ^ p + p * r ^ (p - 1) * (x - r) ≤ x ^ p := by intro r x hr hx by_cases hx0 : x = 0 · subst hx0 rw [Real.zero_rpow (ne_of_gt hp0)] have hrew : r ^ (p - 1) * r = r ^ p := by rw [← Real.rpow_add_one (ne_of_gt hr)]; ring_nf have h1 : r ^ p + p * r ^ (p - 1) * (0 - r) = (1 - p) * r ^ p := by calc r ^ p + p * r ^ (p - 1) * (0 - r) = r ^ p - p * (r ^ (p - 1) * r) := by ring _ = r ^ p - p * r ^ p := by rw [hrew] _ = (1 - p) * r ^ p := by ring rw [h1] have hnn : 0 ≤ r ^ p := Real.rpow_nonneg (le_of_lt hr) p nlinarith · have hx_pos : 0 < x := lt_of_le_of_ne hx (Ne.symm hx0) set φ : ℝ → ℝ := fun z => z ^ p - r ^ p - p * r ^ (p - 1) * (z - r) have hφ_deriv : ∀ z > 0, HasDerivAt φ (p * (z ^ (p - 1) - r ^ (p - 1))) z := by intro z hz have h1 : HasDerivAt (fun u : ℝ => u ^ p) (p * z ^ (p - 1)) z := Real.hasDerivAt_rpow_const (Or.inl (ne_of_gt hz)) have h2 : HasDerivAt (fun u : ℝ => p * r ^ (p - 1) * (u - r)) (p * r ^ (p - 1) * 1) z := ((hasDerivAt_id z).sub_const r).const_mul (p * r ^ (p - 1)) exact ((h1.sub_const (r ^ p)).sub h2).congr_deriv (by ring) have hφ_r : φ r = 0 := by dsimp only [φ]; ring suffices hφ_nn : 0 ≤ φ x by dsimp only [φ] at hφ_nn; linarith rcases lt_trichotomy x r with hlt | rfl | hgt · rw [← hφ_r] refine antitoneOn_of_deriv_nonpos (convex_Icc x r) (fun z hz => (hφ_deriv z (lt_of_lt_of_le hx_pos hz.1)).continuousAt.continuousWithinAt) (fun z hz => by rw [interior_Icc] at hz exact (hφ_deriv z (lt_trans hx_pos hz.1)).differentiableAt.differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz rw [(hφ_deriv z (lt_trans hx_pos hz.1)).deriv] have hle : z ^ (p - 1) ≤ r ^ (p - 1) := Real.rpow_le_rpow (le_of_lt (lt_trans hx_pos hz.1)) (le_of_lt hz.2) (by linarith) nlinarith) (Set.left_mem_Icc.mpr (le_of_lt hlt)) (Set.right_mem_Icc.mpr (le_of_lt hlt)) (le_of_lt hlt) · linarith · rw [← hφ_r] refine monotoneOn_of_deriv_nonneg (convex_Icc r x) (fun z hz => (hφ_deriv z (lt_of_lt_of_le hr hz.1)).continuousAt.continuousWithinAt) (fun z hz => by rw [interior_Icc] at hz exact (hφ_deriv z (lt_trans hr hz.1)).differentiableAt.differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz rw [(hφ_deriv z (lt_trans hr hz.1)).deriv] have hle : r ^ (p - 1) ≤ z ^ (p - 1) := Real.rpow_le_rpow (le_of_lt hr) (le_of_lt hz.1) (by linarith) nlinarith) (Set.left_mem_Icc.mpr (le_of_lt hgt)) (Set.right_mem_Icc.mpr (le_of_lt hgt)) (le_of_lt hgt) have hs1 := hsubgrad hr₁_pos (abs_nonneg (y_hat - y₁)) have hs2 := hsubgrad hr₂_pos (abs_nonneg (y_hat - y₂)) have htri : r₁ + r₂ ≤ |y_hat - y₁| + |y_hat - y₂| := by rw [← hsum_r] calc |y₁ - y₂| = |(y₁ - y_hat) + (y_hat - y₂)| := by ring_nf _ ≤ |y₁ - y_hat| + |y_hat - y₂| := abs_add_le _ _ _ = |y_hat - y₁| + |y_hat - y₂| := by rw [abs_sub_comm] have hcancel : w₁ * a₁ = w₂ * a₂ := by dsimp only [w₁, w₂]; ring have h1_mul := mul_le_mul_of_nonneg_left hs1 (le_of_lt hw₁_pos) have h2_mul := mul_le_mul_of_nonneg_left hs2 (le_of_lt hw₂_pos) have hcoef_nn : 0 ≤ p * (w₁ * a₁) := by positivity have htri_mul := mul_le_mul_of_nonneg_left (sub_nonneg.mpr htri) hcoef_nn calc T = (w₁ + w₂) * T := by rw [hw_sum, one_mul] _ = w₁ * (v y₁ + r₁ ^ p) + w₂ * (v y₂ + r₂ ^ p) := by rw [hr₁_pow, hr₂_pow]; ring _ ≤ w₁ * (v y₁ + r₁ ^ p) + w₂ * (v y₂ + r₂ ^ p) + p * (w₁ * a₁) * (|y_hat - y₁| + |y_hat - y₂| - (r₁ + r₂)) := by linarith _ = w₁ * (v y₁ + (r₁ ^ p + p * a₁ * (|y_hat - y₁| - r₁))) + w₂ * (v y₂ + (r₂ ^ p + p * a₂ * (|y_hat - y₂| - r₂))) := by have : w₂ * (p * a₂ * (|y_hat - y₂| - r₂)) = p * (w₁ * a₁) * (|y_hat - y₂| - r₂) := by rw [hcancel]; ring linarith _ ≤ w₁ * (v y₁ + |y_hat - y₁| ^ p) + w₂ * (v y₂ + |y_hat - y₂| ^ p) := by linarith [h1_mul, h2_mul] lemma lpVal_mono_v {p : ℝ} (hp : 0 < p) {S : Finset ℝ} {v w : ℝ → ℝ} (hvw : ∀ y ∈ S, v y ≤ w y) : lpVal p S v ≤ lpVal p S w := by by_cases hS : S.Nonempty · rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ exact le_trans (lpPair_mono_v hp (hvw y₁ hy₁) (hvw y₂ hy₂)) (lpPair_le_lpVal hy₁ hy₂ w) · simp [lpVal, hS] lemma lpVal_congr {p : ℝ} (hp : 0 < p) {S : Finset ℝ} {v w : ℝ → ℝ} (hvw : ∀ y ∈ S, v y = w y) : lpVal p S v = lpVal p S w := le_antisymm (lpVal_mono_v hp fun y hy => le_of_eq (hvw y hy)) (lpVal_mono_v hp fun y hy => le_of_eq (hvw y hy).symm) lemma lpVal_add_const {p : ℝ} (hp : 0 < p) {S : Finset ℝ} (hS : S.Nonempty) (v : ℝ → ℝ) (c : ℝ) : lpVal p S (fun y => v y + c) = lpVal p S v + c := by apply le_antisymm · rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ rw [lpPair_add_const hp] linarith [lpPair_le_lpVal (p := p) hy₁ hy₂ v] · have hle : lpVal p S v ≤ lpVal p S (fun y => v y + c) - c := by rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ have h := lpPair_le_lpVal (p := p) hy₁ hy₂ (fun y => v y + c) rw [lpPair_add_const hp] at h linarith linarith lemma lpVal_anti_p {p q : ℝ} (hp : 0 < p) (hpq : p ≤ q) {S : Finset ℝ} (hd : ∀ y₁ ∈ S, ∀ y₂ ∈ S, |y₁ - y₂| ≤ 1) (v : ℝ → ℝ) : lpVal q S v ≤ lpVal p S v := by by_cases hS : S.Nonempty · rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ exact le_trans (lpPair_anti_p hp hpq (hd y₁ hy₁ y₂ hy₂)) (lpPair_le_lpVal hy₁ hy₂ v) · simp [lpVal, hS] lemma lpVal_binary {p : ℝ} (hp : 0 < p) (y₁ y₂ : ℝ) (v : ℝ → ℝ) : lpVal p ({y₁, y₂} : Finset ℝ) v = lpPair p y₁ y₂ (v y₁) (v y₂) := by have hS : ({y₁, y₂} : Finset ℝ).Nonempty := ⟨y₁, by simp⟩ apply le_antisymm · rw [lpVal_le_iff_pairs hS] intro a ha b hb simp only [Finset.mem_insert, Finset.mem_singleton] at ha hb rcases ha with rfl | rfl <;> rcases hb with rfl | rfl · rw [lpPair_self hp]; exact le_trans (le_max_left _ _) (max_le_lpPair hp) · exact le_rfl · rw [lpPair_comm hp] · rw [lpPair_self hp]; exact le_trans (le_max_right _ _) (max_le_lpPair hp) · exact lpPair_le_lpVal (by simp) (by simp) v /-! ## Part 2: Multi-Round Realizable Online ℓ_p Regression Minimax Value `OptLp p V` & Game Equivalence -/ /-- The set of realizable labels at query point `x` in version space `V`. -/ def labels {α : Type*} [DecidableEq α] (V : Finset (α → ℝ)) (x : α) : Finset ℝ := V.image fun h => h x /-- The restricted version space after observing `(x, y)`. -/ def restrict {α : Type*} [DecidableEq α] (V : Finset (α → ℝ)) (x : α) (y : ℝ) : Finset (α → ℝ) := V.filter fun h => h x = y lemma restrict_subset {α : Type*} [DecidableEq α] (V : Finset (α → ℝ)) (x : α) (y : ℝ) : restrict V x y ⊆ V := Finset.filter_subset _ _ lemma restrict_nonempty_iff {α : Type*} [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 α] {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 hcard := Finset.card_le_card hsub simp at hcard; 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 α] (V : Finset (α → ℝ)) (x : α) : ∑ y ∈ labels V x, (restrict V x y).card = V.card := by unfold labels restrict have h := 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) exact h.symm lemma labels_mono {α : Type*} [DecidableEq α] {V W : Finset (α → ℝ)} (hVW : V ⊆ W) (x : α) : labels V x ⊆ labels W x := Finset.image_subset_image hVW lemma restrict_mono {α : Type*} [DecidableEq α] {V W : Finset (α → ℝ)} (hVW : V ⊆ W) (x : α) (y : ℝ) : restrict V x y ⊆ restrict W x y := Finset.filter_subset_filter _ hVW /-- **Exact Minimax Cumulative ℓ_p Loss `OptLp p V`** of a finite real-valued concept class `V`: defined recursively on `|V|` via `lpVal p (labels V x)` over all splitting queries `x : α`. -/ def OptLp {α : Type*} [Fintype α] [DecidableEq α] (p : ℝ) (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 lpVal p (labels V x) fun y => OptLp p (restrict V x y) else 0 termination_by V.card decreasing_by exact _hlt y lemma OptLp_eq_zero_of_card_le_one {α : Type*} [Fintype α] [DecidableEq α] (p : ℝ) {V : Finset (α → ℝ)} (hV : V.card ≤ 1) : OptLp p V = 0 := by rw [OptLp, if_pos hV] lemma OptLp_unfold {α : Type*} [Fintype α] [DecidableEq α] (p : ℝ) {V : Finset (α → ℝ)} (hV : 1 < V.card) : OptLp p V = let splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card if hs : splits.Nonempty then splits.sup' hs fun x => lpVal p (labels V x) fun y => OptLp p (restrict V x y) else 0 := by conv_lhs => rw [OptLp, if_neg (by omega)] dsimp only split_ifs with hs · apply le_antisymm · refine Finset.sup'_le _ _ fun ⟨x, hx⟩ _ => ?_ exact Finset.le_sup' (f := fun x => lpVal p (labels V x) fun y => OptLp p (restrict V x y)) hx · refine Finset.sup'_le _ _ fun x hx => ?_ exact Finset.le_sup' (f := fun z : {x // x ∈ _} => lpVal p (labels V z.1) fun y => OptLp p (restrict V z.1 y)) (Finset.mem_attach _ ⟨x, hx⟩) · rfl lemma OptLp_nonneg {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 0 < p) : ∀ V : Finset (α → ℝ), 0 ≤ OptLp p 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 [OptLp_eq_zero_of_card_le_one p hV] · rw [OptLp_unfold p (by omega)] dsimp only split_ifs with hs · rcases hs with ⟨x, hx⟩ have hsp : 2 ≤ (labels V x).card := (Finset.mem_filter.mp hx).2 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rcases hS with ⟨y, hy⟩ calc (0 : ℝ) ≤ OptLp p (restrict V x y) := ih _ (card_restrict_lt_of_two_labels hsp y) _ rfl _ ≤ lpVal p (labels V x) (fun z => OptLp p (restrict V x z)) := le_lpVal_of_mem hp hy (fun z => OptLp p (restrict V x z)) _ ≤ _ := Finset.le_sup' (f := fun x => lpVal p (labels V x) fun z => OptLp p (restrict V x z)) hx · exact le_rfl lemma OptLp_le_of_forall_x {α : Type*} [Fintype α] [DecidableEq α] (p : ℝ) (V : Finset (α → ℝ)) {t : ℝ} (ht0 : 0 ≤ t) (h : ∀ x : α, 2 ≤ (labels V x).card → lpVal p (labels V x) (fun y => OptLp p (restrict V x y)) ≤ t) : OptLp p V ≤ t := by by_cases hV : V.card ≤ 1 · rw [OptLp_eq_zero_of_card_le_one p hV]; exact ht0 · rw [OptLp_unfold p (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 OptLp_ge_lpVal {α : Type*} [Fintype α] [DecidableEq α] (p : ℝ) (V : Finset (α → ℝ)) (x : α) (hsplit : 2 ≤ (labels V x).card) : lpVal p (labels V x) (fun y => OptLp p (restrict V x y)) ≤ OptLp p V := by have hV : 1 < V.card := by have hle : (labels V x).card ≤ V.card := Finset.card_image_le omega rw [OptLp_unfold p 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 => lpVal p (labels V z) fun y => OptLp p (restrict V z y)) hx lemma OptLp_ge_lpPair {α : Type*} [Fintype α] [DecidableEq α] (p : ℝ) (V : Finset (α → ℝ)) (x : α) {y₁ y₂ : ℝ} (hy₁ : y₁ ∈ labels V x) (hy₂ : y₂ ∈ labels V x) (hne : y₁ ≠ y₂) : lpPair p y₁ y₂ (OptLp p (restrict V x y₁)) (OptLp p (restrict V x y₂)) ≤ OptLp p V := by have hsplit : 2 ≤ (labels V x).card := by have hsub : ({y₁, y₂} : Finset ℝ) ⊆ labels V x := by intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl; exact hy₁; exact hy₂ have hcard := Finset.card_le_card hsub rw [Finset.card_pair hne] at hcard; exact hcard exact le_trans (lpPair_le_lpVal (p := p) hy₁ hy₂ (fun y => OptLp p (restrict V x y))) (OptLp_ge_lpVal p V x hsplit) /-- **Subset Monotonicity of `OptLp`**: if `V ⊆ W`, then `OptLp p V ≤ OptLp p W`. -/ theorem OptLp_mono {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 0 < p) {V W : Finset (α → ℝ)} (hVW : V ⊆ W) : OptLp p V ≤ OptLp p W := by induction hn : V.card using Nat.strong_induction_on generalizing V W with | h n ih => subst hn refine OptLp_le_of_forall_x p V (OptLp_nonneg hp W) fun x hsplit => ?_ have hsub := labels_mono hVW x have hsplitW : 2 ≤ (labels W x).card := le_trans hsplit (Finset.card_le_card hsub) have hSV : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [lpVal_le_iff_pairs hSV] intro y₁ hy₁ y₂ hy₂ have h1 := ih _ (card_restrict_lt_of_two_labels hsplit y₁) (restrict_mono hVW x y₁) rfl have h2 := ih _ (card_restrict_lt_of_two_labels hsplit y₂) (restrict_mono hVW x y₂) rfl exact le_trans (lpPair_mono_v hp h1 h2) (le_trans (lpPair_le_lpVal (p := p) (hsub hy₁) (hsub hy₂) (fun y => OptLp p (restrict W x y))) (OptLp_ge_lpVal p W x hsplitW)) /-- **Exponent Antitonicity (`OptLp q V ≤ OptLp p V`)** for `0 < p ≤ q` on classes of diameter `≤ 1`. -/ theorem OptLp_anti_p {α : Type*} [Fintype α] [DecidableEq α] {p q : ℝ} (hp : 0 < p) (hpq : p ≤ q) {V : Finset (α → ℝ)} (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ 1) : OptLp q V ≤ OptLp 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 OptLp_le_of_forall_x q V (OptLp_nonneg hp V) fun x hsplit => ?_ have hlab_diam : ∀ y₁ ∈ labels V x, ∀ y₂ ∈ labels V x, |y₁ - y₂| ≤ 1 := by intro y₁ hy₁ y₂ hy₂ rw [labels, Finset.mem_image] at hy₁ hy₂ rcases hy₁ with ⟨h₁, hh₁, rfl⟩; rcases hy₂ with ⟨h₂, hh₂, rfl⟩ exact hdiam h₁ hh₁ h₂ hh₂ x calc lpVal q (labels V x) (fun y => OptLp q (restrict V x y)) ≤ lpVal q (labels V x) (fun y => OptLp p (restrict V x y)) := lpVal_mono_v hq fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) (fun h₁ hh₁ h₂ hh₂ z => hdiam h₁ (restrict_subset V x y hh₁) h₂ (restrict_subset V x y hh₂) z) rfl _ ≤ lpVal p (labels V x) (fun y => OptLp p (restrict V x y)) := lpVal_anti_p hp hpq hlab_diam _ _ ≤ OptLp p V := OptLp_ge_lpVal p V x hsplit /-! ### Full Multi-Round Adaptive Online ℓ_p Regression Game Equivalence -/ /-- A deterministic online regression learner chooses a real prediction `ŷ ∈ ℝ` from `(V, x)`. -/ abbrev DetLpLearner (α : Type*) := Finset (α → ℝ) → α → ℝ /-- A randomized adaptive adversary for online regression: given version space `V`, chooses a query point `x` and a finite probability distribution `ν` over `labels V x` (or halts). -/ structure RandLpAdversary (α : Type*) [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) /-- Expected cumulative ℓ_p loss of learner `L` against randomized adaptive adversary `A` from `V`. -/ def expectedLpLoss {α : Type*} [DecidableEq α] (p : ℝ) (L : DetLpLearner α) (A : RandLpAdversary α) (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 * (|L V x - y| ^ p + expectedLpLoss p L A (restrict V x y)) termination_by V.card decreasing_by exact _hlt lemma expectedLpLoss_of_card_le_one {α : Type*} [DecidableEq α] (p : ℝ) (L : DetLpLearner α) (A : RandLpAdversary α) {V : Finset (α → ℝ)} (hV : V.card ≤ 1) : expectedLpLoss p L A V = 0 := by rw [expectedLpLoss, if_pos hV] lemma expectedLpLoss_of_none {α : Type*} [DecidableEq α] (p : ℝ) (L : DetLpLearner α) (A : RandLpAdversary α) {V : Finset (α → ℝ)} (hq : A.query V = none) : expectedLpLoss p L A V = 0 := by conv_lhs => rw [expectedLpLoss] split_ifs · rfl · split · rfl · rename_i x ν heq; rw [hq] at heq; cases heq lemma expectedLpLoss_of_some {α : Type*} [DecidableEq α] (p : ℝ) (L : DetLpLearner α) (A : RandLpAdversary α) {V : Finset (α → ℝ)} (hV : 1 < V.card) {x : α} {ν : ℝ → ℝ} (hq : A.query V = some (x, ν)) : expectedLpLoss p L A V = ∑ y ∈ labels V x, ν y * (|L V x - y| ^ p + expectedLpLoss p L A (restrict V x y)) := by conv_lhs => rw [expectedLpLoss, 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 Minimax Online ℓ_p Regression Learner**: at `(V, x)`, chooses the 1D Helly midpoint `y_hat` from `lpVal_primal_upper`. -/ def optLpLearner {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 0 < p) : DetLpLearner α := fun V x => if hS : (labels V x).Nonempty then Classical.choose (lpVal_primal_upper hp hS (fun y => OptLp p (restrict V x y))) else 0 /-- **Multi-Round Primal Upper Bound**: `optLpLearner` guarantees expected cumulative ℓ_p loss `≤ OptLp p V` against EVERY randomized adaptive adversary `A`! -/ theorem optLpLearner_expectedLoss_le {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 0 < p) (A : RandLpAdversary α) (V : Finset (α → ℝ)) : expectedLpLoss p (optLpLearner hp) A V ≤ OptLp p 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 [expectedLpLoss_of_card_le_one p _ A hV, OptLp_eq_zero_of_card_le_one p hV] · cases hq : A.query V with | none => rw [expectedLpLoss_of_none p _ A hq] exact OptLp_nonneg hp V | some xν => rcases xν with ⟨x, ν⟩ rw [expectedLpLoss_of_some p _ A (by omega) hq] rcases A.valid V x ν hq with ⟨hsplit, hν_nn, hν_sum⟩ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hspec := Classical.choose_spec (lpVal_primal_upper hp hS (fun y => OptLp p (restrict V x y))) have hopt_eq : optLpLearner hp V x = Classical.choose (lpVal_primal_upper hp hS (fun y => OptLp p (restrict V x y))) := by simp [optLpLearner, hS] have hstep : ∀ y ∈ labels V x, |optLpLearner hp V x - y| ^ p + expectedLpLoss p (optLpLearner hp) A (restrict V x y) ≤ OptLp p V := by intro y hy have hih := ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl have h1 := hspec y hy rw [← hopt_eq] at h1 have h2 := OptLp_ge_lpVal p V x hsplit linarith calc ∑ y ∈ labels V x, ν y * (|optLpLearner hp V x - y| ^ p + expectedLpLoss p (optLpLearner hp) A (restrict V x y)) ≤ ∑ y ∈ labels V x, ν y * OptLp p 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) * OptLp p V := (Finset.sum_mul _ _ _).symm _ = OptLp p V := by rw [hν_sum, one_mul] /-- **Optimal Minimax 2-Point Dual Adversary**: at each non-trivial `V`, picks a maximizing splitting query `x*` and the exact 2-point dual distribution `ν*` from `lpVal_dual_lower`. -/ def optLpAdversary {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 1 ≤ p) : RandLpAdversary α 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 x => lpVal p (labels V x) fun y => OptLp p (restrict V x y)) have hx : x ∈ splits := (Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun x => lpVal p (labels V x) fun y => OptLp p (restrict V x y))).1 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by have := (Finset.mem_filter.mp hx).2; omega) let ν := Classical.choose (lpVal_dual_lower hp hS fun y => OptLp p (restrict V x y)) some (x, ν) 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 => lpVal p (labels V z) fun y => OptLp p (restrict V z y)) have hx := (Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => lpVal p (labels V z) fun y => OptLp p (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 (lpVal_dual_lower hp hS fun y => OptLp p (restrict V x0 y)) injection hq with hpair rcases Prod.mk.inj hpair with ⟨hx_eq, hν_eq⟩ rw [← hx_eq, ← hν_eq] exact ⟨hsp, hν.1, hν.2.1⟩ /-- **Multi-Round Dual Lower Bound**: `optLpAdversary` forces expected cumulative ℓ_p loss `≥ OptLp p V` against EVERY learner `L`! -/ theorem optLpAdversary_expectedLoss_ge {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 1 ≤ p) (L : DetLpLearner α) (V : Finset (α → ℝ)) : OptLp p V ≤ expectedLpLoss p L (optLpAdversary hp) 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 [OptLp_eq_zero_of_card_le_one p hV, expectedLpLoss_of_card_le_one p L _ hV] · rw [OptLp_unfold p (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 => lpVal p (labels V z) fun y => OptLp p (restrict V z y)) have hx_spec := Classical.choose_spec (Finset.exists_mem_eq_sup' hs fun z => lpVal p (labels V z) fun y => OptLp p (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 ν := Classical.choose (lpVal_dual_lower hp hS fun y => OptLp p (restrict V x y)) have hν_spec := Classical.choose_spec (lpVal_dual_lower hp hS fun y => OptLp p (restrict V x y)) have hq : (optLpAdversary hp).query V = some (x, ν) := by dsimp only [optLpAdversary]; rw [dif_pos hs] rw [dif_pos hs, hx_spec.2, expectedLpLoss_of_some p L _ (by omega) hq] calc lpVal p (labels V x) (fun y => OptLp p (restrict V x y)) ≤ ∑ y ∈ labels V x, ν y * (OptLp p (restrict V x y) + |L V x - y| ^ p) := hν_spec.2.2 (L V x) _ ≤ ∑ y ∈ labels V x, ν y * (|L V x - y| ^ p + expectedLpLoss p L (optLpAdversary hp) (restrict V 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 : (optLpAdversary hp).query V = none := by dsimp only [optLpAdversary]; rw [dif_neg hs] rw [dif_neg hs, expectedLpLoss_of_none p L _ hq] /-- **Full Multi-Round Online ℓ_p Regression Minimax Saddle-Point Theorem**: `optLpLearner` and `optLpAdversary` form an exact minimax saddle point of value `OptLp p V`. -/ theorem online_lp_minimax_exact {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 1 ≤ p) (V : Finset (α → ℝ)) : (∀ A : RandLpAdversary α, expectedLpLoss p (optLpLearner (by linarith)) A V ≤ OptLp p V) ∧ (∀ L : DetLpLearner α, OptLp p V ≤ expectedLpLoss p L (optLpAdversary hp) V) ∧ expectedLpLoss p (optLpLearner (by linarith)) (optLpAdversary hp) V = OptLp p V := ⟨fun A => optLpLearner_expectedLoss_le (by linarith) A V, fun L => optLpAdversary_expectedLoss_ge hp L V, le_antisymm (optLpLearner_expectedLoss_le (by linarith) _ V) (optLpAdversary_expectedLoss_ge hp _ V)⟩ /-! ## Part 3: Universal Exponential Halving Criterion & All-p Bound `OptLp p V ≤ (D^p / p) * log |V|` -/ /-- **1-Step Universal Exponential Halving Lemma**: if `C > 0`, `D > 0`, `p > 0`, and `∀ u ∈ [0, 1], exp (-u^p / C) + exp (-(1 - u)^p / C) ≥ 1`, then for ANY pair `y₁, y₂` with `|y₁ - y₂| ≤ D` and positive weights `w₁ + w₂ ≤ N`, `lpPair p y₁ y₂ (C * D^p * log w₁) (C * D^p * log w₂) ≤ C * D^p * log N`! -/ theorem lpPair_exp_halving_step {p C D : ℝ} (hp : 0 < p) (hC : 0 < C) (hD : 0 < D) (hexp : ∀ u ∈ Set.Icc (0 : ℝ) 1, Real.exp (-(u ^ p) / C) + Real.exp (-((1 - u) ^ p) / C) ≥ 1) {y₁ y₂ w₁ w₂ N : ℝ} (hd : |y₁ - y₂| ≤ D) (hw₁ : 0 < w₁) (hw₂ : 0 < w₂) (hsum : w₁ + w₂ ≤ N) : lpPair p y₁ y₂ (C * D ^ p * Real.log w₁) (C * D ^ p * Real.log w₂) ≤ C * D ^ p * Real.log N := by have hN_pos : 0 < N := by linarith have hDp_pos : 0 < D ^ p := Real.rpow_pos_of_pos hD p have hCDp_pos : 0 < C * D ^ p := mul_pos hC hDp_pos have hw₁_le : w₁ ≤ N := by linarith have hw₂_le : w₂ ≤ N := by linarith rw [lpPair_le_iff hp] refine ⟨max_le (mul_le_mul_of_nonneg_left (Real.log_le_log hw₁ hw₁_le) (le_of_lt hCDp_pos)) (mul_le_mul_of_nonneg_left (Real.log_le_log hw₂ hw₂_le) (le_of_lt hCDp_pos)), ?_⟩ have hdiff1 : C * D ^ p * Real.log N - C * D ^ p * Real.log w₁ = D ^ p * (C * Real.log (N / w₁)) := by rw [Real.log_div (ne_of_gt hN_pos) (ne_of_gt hw₁)]; ring have hdiff2 : C * D ^ p * Real.log N - C * D ^ p * Real.log w₂ = D ^ p * (C * Real.log (N / w₂)) := by rw [Real.log_div (ne_of_gt hN_pos) (ne_of_gt hw₂)]; ring have hL1_nn : 0 ≤ C * Real.log (N / w₁) := mul_nonneg (le_of_lt hC) (Real.log_nonneg ((one_le_div hw₁).mpr hw₁_le)) have hL2_nn : 0 ≤ C * Real.log (N / w₂) := mul_nonneg (le_of_lt hC) (Real.log_nonneg ((one_le_div hw₂).mpr hw₂_le)) have hDp_inv : (D ^ p) ^ (1 / p) = D := by rw [← Real.rpow_mul (le_of_lt hD), mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] rw [hdiff1, hdiff2, Real.mul_rpow (le_of_lt hDp_pos) hL1_nn, Real.mul_rpow (le_of_lt hDp_pos) hL2_nn, hDp_inv, ← mul_add] refine le_trans hd ?_ calc D = D * 1 := (mul_one D).symm _ ≤ D * ((C * Real.log (N / w₁)) ^ (1 / p) + (C * Real.log (N / w₂)) ^ (1 / p)) := by refine mul_le_mul_of_nonneg_left ?_ (le_of_lt hD) set u₁ := (C * Real.log (N / w₁)) ^ (1 / p) set u₂ := (C * Real.log (N / w₂)) ^ (1 / p) have hu₁_nn : 0 ≤ u₁ := Real.rpow_nonneg hL1_nn _ have hu₂_nn : 0 ≤ u₂ := Real.rpow_nonneg hL2_nn _ by_contra hlt push Not at hlt have hu₁_le1 : u₁ ≤ 1 := by linarith have hu₂_lt : u₂ < 1 - u₁ := by linarith have hu₁_pow : u₁ ^ p = C * Real.log (N / w₁) := by dsimp only [u₁]; rw [← Real.rpow_mul hL1_nn, one_div_mul_cancel (ne_of_gt hp), Real.rpow_one] have hu₂_pow : u₂ ^ p = C * Real.log (N / w₂) := by dsimp only [u₂]; rw [← Real.rpow_mul hL2_nn, one_div_mul_cancel (ne_of_gt hp), Real.rpow_one] have hw1_eq : w₁ / N = Real.exp (-(u₁ ^ p) / C) := by rw [hu₁_pow, neg_div, mul_div_cancel_left₀ _ (ne_of_gt hC), Real.log_div (ne_of_gt hN_pos) (ne_of_gt hw₁), neg_sub, ← Real.log_div (ne_of_gt hw₁) (ne_of_gt hN_pos), Real.exp_log (div_pos hw₁ hN_pos)] have hw2_eq : w₂ / N = Real.exp (-(u₂ ^ p) / C) := by rw [hu₂_pow, neg_div, mul_div_cancel_left₀ _ (ne_of_gt hC), Real.log_div (ne_of_gt hN_pos) (ne_of_gt hw₂), neg_sub, ← Real.log_div (ne_of_gt hw₂) (ne_of_gt hN_pos), Real.exp_log (div_pos hw₂ hN_pos)] have hpow_lt : u₂ ^ p < (1 - u₁) ^ p := Real.rpow_lt_rpow hu₂_nn hu₂_lt hp have hexp_lt : Real.exp (-((1 - u₁) ^ p) / C) < Real.exp (-(u₂ ^ p) / C) := by apply Real.exp_lt_exp.mpr exact div_lt_div_of_pos_right (neg_lt_neg hpow_lt) hC have hsum_div : w₁ / N + w₂ / N ≤ 1 := by rw [← add_div, div_le_one hN_pos]; exact hsum have hcrit := hexp u₁ ⟨hu₁_nn, hu₁_le1⟩ linarith /-- **Universal Exponential Halving Theorem for Realizable Online ℓ_p Regression**: If `C > 0`, `D > 0`, `p > 0`, and `∀ u ∈ [0, 1], exp (-u^p / C) + exp (-(1 - u)^p / C) ≥ 1`, then for EVERY finite nonempty real-valued concept class `V` with range diameter `≤ D` (arbitrary domain `α`, arbitrary real label cardinality!): `OptLp p V ≤ C * D^p * Real.log |V|`. -/ theorem OptLp_le_of_exp_criterion {α : Type*} [Fintype α] [DecidableEq α] {p C D : ℝ} (hp : 0 < p) (hC : 0 < C) (hD : 0 < D) (hexp : ∀ u ∈ Set.Icc (0 : ℝ) 1, Real.exp (-(u ^ p) / C) + Real.exp (-((1 - u) ^ p) / C) ≥ 1) {V : Finset (α → ℝ)} (hV : V.Nonempty) (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ D) : OptLp p V ≤ C * D ^ p * Real.log (V.card : ℝ) := by have hDp_pos : 0 < D ^ p := Real.rpow_pos_of_pos hD p have hCDp_nn : 0 ≤ C * D ^ p := by 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 OptLp_le_of_forall_x p V (mul_nonneg hCDp_nn hlog_nn) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ have hne1 : (restrict V x y₁).Nonempty := (restrict_nonempty_iff V x y₁).mpr hy₁ have hne2 : (restrict V x y₂).Nonempty := (restrict_nonempty_iff V x y₂).mpr hy₂ have hih1 := ih _ (card_restrict_lt_of_two_labels hsplit y₁) hne1 (fun h₁ hh₁ h₂ hh₂ z => hdiam h₁ (restrict_subset V x y₁ hh₁) h₂ (restrict_subset V x y₁ hh₂) z) rfl have hih2 := ih _ (card_restrict_lt_of_two_labels hsplit y₂) hne2 (fun h₁ hh₁ h₂ hh₂ z => hdiam h₁ (restrict_subset V x y₂ hh₁) h₂ (restrict_subset V x y₂ hh₂) z) rfl by_cases heq : y₁ = y₂ · subst heq rw [lpPair_self hp] have hcard_le : ((restrict V x y₁).card : ℝ) ≤ (V.card : ℝ) := by exact_mod_cast Finset.card_le_card (restrict_subset V x y₁) exact le_trans hih1 (mul_le_mul_of_nonneg_left (Real.log_le_log (Nat.cast_pos.mpr hne1.card_pos) hcard_le) hCDp_nn) · have hpair_sum : ((restrict V x y₁).card : ℝ) + ((restrict V x y₂).card : ℝ) ≤ (V.card : ℝ) := by have hsub : ({y₁, y₂} : Finset ℝ) ⊆ labels V x := by intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl; exact hy₁; exact hy₂ have hsum_nat : (restrict V x y₁).card + (restrict V x y₂).card ≤ V.card := by calc (restrict V x y₁).card + (restrict V x y₂).card = ∑ y ∈ ({y₁, y₂} : Finset ℝ), (restrict V x y).card := (Finset.sum_pair (f := fun y => (restrict V x y).card) heq).symm _ ≤ ∑ y ∈ labels V x, (restrict V x y).card := Finset.sum_le_sum_of_subset hsub _ = V.card := sum_card_restrict V x exact_mod_cast hsum_nat have hd12 : |y₁ - y₂| ≤ D := by rw [labels, Finset.mem_image] at hy₁ hy₂ rcases hy₁ with ⟨h₁, hh₁, rfl⟩; rcases hy₂ with ⟨h₂, hh₂, rfl⟩ exact hdiam h₁ hh₁ h₂ hh₂ x exact le_trans (lpPair_mono_v hp hih1 hih2) (lpPair_exp_halving_step hp hC hD hexp hd12 (Nat.cast_pos.mpr hne1.card_pos) (Nat.cast_pos.mpr hne2.card_pos) hpair_sum) /-- Elementary Miracle Inequality: `1 / (e * log 2) ≤ 1 + log (log 2)` (with margin `> 0.10`). -/ lemma inv_e_log2_le_one_add_log_log2 : 1 / (Real.exp 1 * Real.log 2) ≤ 1 + Real.log (Real.log 2) := by have hlog2_lo : (69 / 100 : ℝ) < Real.log 2 := by have := Real.log_two_gt_d9; linarith have hlog2_hi : Real.log 2 < (70 / 100 : ℝ) := by have := Real.log_two_lt_d9; linarith have hlog2_pos : 0 < Real.log 2 := by linarith have he_lo : (271 / 100 : ℝ) < Real.exp 1 := by have := Real.exp_one_gt_d9; linarith have h1 : 1 / (Real.exp 1 * Real.log 2) < 54 / 100 := by rw [div_lt_iff₀ (mul_pos (Real.exp_pos 1) hlog2_pos)] nlinarith have h2 : -(38 / 100 : ℝ) < Real.log (Real.log 2) := by rw [← Real.exp_lt_exp, Real.exp_log hlog2_pos] -- Show exp(-38/100) < 69/100 <=> 100/69 < exp(38/100), using exp(x) ≥ 1 + x + x^2/2 + x^3/6 have hexp_ge : 1 + (38 / 100 : ℝ) + (38 / 100 : ℝ) ^ 2 / 2 ≤ Real.exp (38 / 100) := by have h := Real.sum_le_exp_of_nonneg (x := (38 / 100 : ℝ)) (by norm_num) 3 simp [Finset.sum_range_succ, Nat.factorial] at h linarith have hinv : Real.exp (-(38 / 100 : ℝ)) = (Real.exp (38 / 100))⁻¹ := Real.exp_neg _ rw [hinv] have hexp_pos : 0 < Real.exp (38 / 100) := Real.exp_pos _ have hgt : (100 / 69 : ℝ) < Real.exp (38 / 100) := by linarith have hlt1 : (Real.exp (38 / 100))⁻¹ < (100 / 69 : ℝ)⁻¹ := inv_strictAnti₀ (by norm_num) hgt have hval : (100 / 69 : ℝ)⁻¹ = 69 / 100 := by norm_num linarith linarith /-- **Elementary All-p Exponential Criterion (`C = 1 / p`)**: for EVERY `p ≥ 1` and EVERY `u ∈ [0, 1]`, `exp (-p * u^p) + exp (-p * (1 - u)^p) ≥ 1`! -/ theorem exp_criterion_inv_p {p : ℝ} (hp : 1 ≤ p) : ∀ u ∈ Set.Icc (0 : ℝ) 1, Real.exp (-(u ^ p) / (1 / p)) + Real.exp (-((1 - u) ^ p) / (1 / p)) ≥ 1 := by have hp0 : 0 < p := by linarith -- By symmetry u ↔ 1 - u, reduce to u ∈ [0, 1/2] suffices hhalf : ∀ u ∈ Set.Icc (0 : ℝ) (1 / 2), Real.exp (-(p * u ^ p)) + Real.exp (-(p * (1 - u) ^ p)) ≥ 1 by intro u ⟨hu0, hu1⟩ have hrew : ∀ x : ℝ, -(x ^ p) / (1 / p) = -(p * x ^ p) := fun x => by rw [div_div_eq_mul_div, div_one]; ring rw [hrew u, hrew (1 - u)] rcases le_total u (1 / 2) with hle | hge · exact hhalf u ⟨hu0, hle⟩ · rw [add_comm] have h := hhalf (1 - u) ⟨by linarith, by linarith⟩ simpa using h intro u ⟨hu0, hu_half⟩ -- For u = 0, exp 0 = 1 and exp(-p) > 0! by_cases hu_zero : u = 0 · subst hu_zero rw [Real.zero_rpow (ne_of_gt hp0), mul_zero, neg_zero, Real.exp_zero] linarith [Real.exp_pos (-(p * (1 - 0) ^ p))] have hu_pos : 0 < u := lt_of_le_of_ne hu0 (Ne.symm hu_zero) -- Since exp(-x) ≥ 1 - x, it suffices to prove p * u^p ≤ exp(-p * (1 - u)^p), -- i.e. h(u) := log p + p * log u + p * (1 - u)^p ≤ 0 on (0, 1/2]! suffices hmain : Real.log p + p * Real.log u + p * (1 - u) ^ p ≤ 0 by have h1 : p * u ^ p ≤ Real.exp (-(p * (1 - u) ^ p)) := by have hpos : 0 < p * u ^ p := mul_pos hp0 (Real.rpow_pos_of_pos hu_pos p) rw [← Real.exp_log hpos] apply Real.exp_le_exp.mpr rw [Real.log_mul (ne_of_gt hp0) (ne_of_gt (Real.rpow_pos_of_pos hu_pos p)), Real.log_rpow hu_pos] linarith have h2 : 1 - p * u ^ p ≤ Real.exp (-(p * u ^ p)) := by linarith [Real.add_one_le_exp (-(p * u ^ p))] linarith -- Step A: Show h(u) = log p + p * log u + p * (1 - u)^p is monotone increasing on (0, 1/2], -- because h'(x) = (p/x) * (1 - p * x * (1 - x)^(p-1)) ≥ 0! set h : ℝ → ℝ := fun x => Real.log p + p * Real.log x + p * (1 - x) ^ p have hderiv : ∀ x ∈ Set.Ioo (0 : ℝ) (1 : ℝ), HasDerivAt h (p / x - p * (p * (1 - x) ^ (p - 1))) x := by intro x ⟨hx0, hx1⟩ have h1 : HasDerivAt (fun z => p * Real.log z) (p * x⁻¹) x := (Real.hasDerivAt_log (ne_of_gt hx0)).const_mul p have h2 : HasDerivAt (fun z => (1 - z) ^ p) (p * (1 - x) ^ (p - 1) * (-1)) x := by have hi : HasDerivAt (fun z : ℝ => 1 - z) (-1) x := HasDerivAt.const_sub 1 (hasDerivAt_id x) exact (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt (sub_pos.mpr hx1)))).comp x hi have h3 : HasDerivAt (fun z => p * (1 - z) ^ p) (p * (p * (1 - x) ^ (p - 1) * (-1))) x := h2.const_mul p have hsum : HasDerivAt h (0 + p * x⁻¹ + p * (p * (1 - x) ^ (p - 1) * (-1))) x := ((hasDerivAt_const x (Real.log p)).add h1).add h3 exact hsum.congr_deriv (by rw [div_eq_mul_inv]; ring) have hderiv_nn : ∀ x ∈ Set.Ioo (0 : ℝ) (1 : ℝ), 0 ≤ p / x - p * (p * (1 - x) ^ (p - 1)) := by intro x ⟨hx0, hx1⟩ have h1x : 0 < 1 - x := sub_pos.mpr hx1 -- Show p * x * (1 - x)^(p - 1) ≤ 1! have hprod_le1 : p * x * (1 - x) ^ (p - 1) ≤ 1 := by by_cases hp1 : p = 1 · subst hp1; simp; linarith · have hp_gt1 : 1 < p := lt_of_le_of_ne hp (Ne.symm hp1) have hpm1 : 0 < p - 1 := sub_pos.mpr hp_gt1 have hpos_lhs : 0 < p * x * (1 - x) ^ (p - 1) := by positivity rw [← Real.log_le_log_iff hpos_lhs zero_lt_one, Real.log_one] rw [Real.log_mul (ne_of_gt (mul_pos hp0 hx0)) (ne_of_gt (Real.rpow_pos_of_pos h1x _)), Real.log_rpow h1x] -- Weighted log_le_sub_one: (1/p) * log(p*x) + ((p-1)/p) * log((p/(p-1))*(1-x)) ≤ 0! have hl1 : Real.log (p * x) ≤ p * x - 1 := Real.log_le_sub_one_of_pos (mul_pos hp0 hx0) have hq_pos : 0 < (p / (p - 1)) * (1 - x) := by positivity have hl2 : Real.log ((p / (p - 1)) * (1 - x)) ≤ (p / (p - 1)) * (1 - x) - 1 := Real.log_le_sub_one_of_pos hq_pos have hl2_split : Real.log ((p / (p - 1)) * (1 - x)) = Real.log (p / (p - 1)) + Real.log (1 - x) := Real.log_mul (ne_of_gt (div_pos hp0 hpm1)) (ne_of_gt h1x) have hlog_ratio_nn : 0 ≤ Real.log (p / (p - 1)) := Real.log_nonneg ((one_le_div hpm1).mpr (by linarith)) have hcomb : Real.log (p * x) + (p - 1) * Real.log ((p / (p - 1)) * (1 - x)) ≤ 0 := by have hmul2 := mul_le_mul_of_nonneg_left hl2 (le_of_lt hpm1) have hsimp : (p - 1) * ((p / (p - 1)) * (1 - x) - 1) = p * (1 - x) - (p - 1) := by rw [mul_sub, mul_one, ← mul_assoc, mul_div_cancel₀ _ (ne_of_gt hpm1)] linarith rw [hl2_split] at hcomb nlinarith have hmul : p * (p * (1 - x) ^ (p - 1)) * x ≤ p := by have : p * (p * (1 - x) ^ (p - 1)) * x = p * (p * x * (1 - x) ^ (p - 1)) := by ring rw [this]; nlinarith have hdiv : p * (p * (1 - x) ^ (p - 1)) ≤ p / x := (le_div_iff₀ hx0).mpr hmul linarith have hmono : h u ≤ h (1 / 2) := by by_cases heq : u = 1 / 2 · rw [heq] · have hlt : u < 1 / 2 := lt_of_le_of_ne hu_half heq have hcont : ContinuousOn h (Set.Icc u (1 / 2)) := by intro x ⟨hx_lo, hx_hi⟩ exact (hderiv x ⟨lt_of_lt_of_le hu_pos hx_lo, by linarith⟩).continuousAt.continuousWithinAt have hdiff : ∀ x ∈ Set.Ioo u (1 / 2), 0 ≤ deriv h x := by intro x ⟨hx_lo, hx_hi⟩ rw [(hderiv x ⟨lt_trans hu_pos hx_lo, by linarith⟩).deriv] exact hderiv_nn x ⟨lt_trans hu_pos hx_lo, by linarith⟩ exact monotoneOn_of_deriv_nonneg (convex_Icc u (1 / 2)) hcont (fun x hx => by rw [interior_Icc] at hx exact (hderiv x ⟨lt_trans hu_pos hx.1, by linarith [hx.2]⟩).differentiableAt.differentiableWithinAt) (fun x hx => by rw [interior_Icc] at hx; exact hdiff x hx) (Set.left_mem_Icc.mpr (le_of_lt hlt)) (Set.right_mem_Icc.mpr (le_of_lt hlt)) (le_of_lt hlt) -- Step B: Show h(1/2) = log p - p * log 2 + p * 2^(-p) ≤ 0 via the Miracle Comparison! have hhalf_le : h (1 / 2) ≤ 0 := by dsimp only [h] have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) have hpl2_pos : 0 < p * Real.log 2 := mul_pos hp0 hlog2_pos -- 1) log(p * log 2) ≤ p * log 2 - 1 => 1 + log(log 2) ≤ p * log 2 - log p have hb1 : 1 + Real.log (Real.log 2) ≤ p * Real.log 2 - Real.log p := by have := Real.log_le_sub_one_of_pos hpl2_pos rw [Real.log_mul (ne_of_gt hp0) (ne_of_gt hlog2_pos)] at this linarith -- 2) p * 2^(-p) ≤ 1 / (e * log 2) (since p * log 2 ≤ exp(p * log 2 - 1) = 2^p / e) have hb2 : p * (1 - 1 / 2 : ℝ) ^ p ≤ 1 / (Real.exp 1 * Real.log 2) := by have hrew : (1 - 1 / 2 : ℝ) ^ p = (Real.exp (p * Real.log 2))⁻¹ := by rw [show (1 - 1 / 2 : ℝ) = (2 : ℝ)⁻¹ by norm_num, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2), Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 2), mul_comm] rw [hrew] have hexp_ge : p * Real.log 2 ≤ Real.exp (p * Real.log 2 - 1) := by linarith [Real.add_one_le_exp (p * Real.log 2 - 1)] rw [Real.exp_sub] at hexp_ge have hmul : p * (Real.exp 1 * Real.log 2) ≤ Real.exp (p * Real.log 2) := by have := (le_div_iff₀ (Real.exp_pos 1)).mp hexp_ge linarith rw [← div_eq_mul_inv, div_le_div_iff₀ (Real.exp_pos _) (mul_pos (Real.exp_pos 1) hlog2_pos)] linarith have hlog_half : Real.log (1 / 2 : ℝ) = -Real.log 2 := by rw [Real.log_div (by norm_num) (by norm_num), Real.log_one, zero_sub] rw [hlog_half] linarith [inv_e_log2_le_one_add_log_log2] exact le_trans hmono hhalf_le /-- **Universal All-p Realizable Online ℓ_p Halving Theorem**: For EVERY `p ≥ 1` (including `p > 2` where Vovk's mixability constant is `0`!) and EVERY finite nonempty real-valued concept class `V` of range diameter `≤ D`: `OptLp p V ≤ (D^p / p) * Real.log |V|`. -/ theorem OptLp_le_inv_p_log_card {α : Type*} [Fintype α] [DecidableEq α] {p D : ℝ} (hp : 1 ≤ p) (hD : 0 < D) {V : Finset (α → ℝ)} (hV : V.Nonempty) (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ D) : OptLp p V ≤ (D ^ p / p) * Real.log (V.card : ℝ) := by have hp0 : 0 < p := by linarith have h := OptLp_le_of_exp_criterion hp0 (div_pos one_pos hp0) hD (exp_criterion_inv_p hp) hV hdiam have hrew : (1 / p) * D ^ p = D ^ p / p := by ring rwa [hrew] at h /-! ## Part 4: The Sharp Critical Phase Transition at `pCrit = 1 / (1 - Real.log 2) ≈ 3.25889135` -/ /-- The **Exact Critical Exponent** for realizable online ℓ_p regression: `pCrit = 1 / (1 - Real.log 2) ≈ 3.258891353271`. -/ def pCrit : ℝ := 1 / (1 - Real.log 2) lemma one_sub_log2_pos : 0 < 1 - Real.log 2 := by have := Real.log_two_lt_d9; linarith /-- Explicit numerical enclosure of the critical exponent: `3 < pCrit < 3.26`. -/ theorem pCrit_bounds : (3 : ℝ) < pCrit ∧ pCrit < 326 / 100 := by have hlo := Real.log_two_gt_d9 have hhi := Real.log_two_lt_d9 have hpos := one_sub_log2_pos dsimp only [pCrit] constructor · rw [lt_div_iff₀ hpos]; linarith · rw [div_lt_iff₀ hpos]; linarith /-- **Zero-Root-Finding Endpoint Minimum Principle**: if `g` is continuous on `[a, b]`, differentiable on `(a, b)`, and `g'` never returns from `< 0` to `> 0` (`∀ x < y ∈ (a, b), deriv g x < 0 → deriv g y ≤ 0`), then `min (g a) (g b) ≤ g t` for every `t ∈ [a, b]`. -/ 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 /-- Symmetric helper: if `g` is continuous on `[0, b]`, `g 0 = 0`, differentiable on `(0, b)`, and `deriv g` stays `< 0` once `< 0` (`∀ x < y ∈ (0, b), deriv g x < 0 → deriv g y ≤ 0`), then `g` itself stays `≤ 0` once `< 0`! -/ lemma nonpos_after_neg_of_deriv_sign_change {g : ℝ → ℝ} {b : ℝ} (_hb : 0 < b) (h0 : g 0 = 0) (hcont : ContinuousOn g (Set.Ico 0 b)) (hdiff : ∀ x ∈ Set.Ioo 0 b, DifferentiableAt ℝ g x) (hsign : ∀ x ∈ Set.Ioo 0 b, ∀ y ∈ Set.Ioo 0 b, x < y → deriv g x < 0 → deriv g y ≤ 0) : ∀ x ∈ Set.Ioo 0 b, ∀ y ∈ Set.Ioo 0 b, x < y → g x < 0 → g y ≤ 0 := by intro x ⟨hx0, hxb⟩ y ⟨hy0, hyb⟩ hxy hgx have hex : ∃ z₀ ∈ Set.Ioo 0 x, deriv g z₀ < 0 := by by_contra hall; push Not at hall have hge : g 0 ≤ g x := monotoneOn_of_deriv_nonneg (convex_Icc 0 x) (hcont.mono fun z hz => ⟨hz.1, lt_of_le_of_lt hz.2 hxb⟩) (fun z hz => by rw [interior_Icc] at hz exact (hdiff z ⟨hz.1, lt_trans hz.2 hxb⟩).differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz; exact hall z hz) (Set.left_mem_Icc.mpr (le_of_lt hx0)) (Set.right_mem_Icc.mpr (le_of_lt hx0)) (le_of_lt hx0) linarith rcases hex with ⟨z₀, ⟨hz0, hzx⟩, hdz⟩ have hanti : g y ≤ g x := antitoneOn_of_deriv_nonpos (convex_Icc x y) (hcont.mono fun z hz => ⟨le_trans (le_of_lt hx0) hz.1, lt_of_le_of_lt hz.2 hyb⟩) (fun z hz => by rw [interior_Icc] at hz exact (hdiff z ⟨lt_trans hx0 hz.1, lt_trans hz.2 hyb⟩).differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz exact hsign z₀ ⟨hz0, lt_trans hzx hxb⟩ z ⟨lt_trans hx0 hz.1, lt_trans hz.2 hyb⟩ (lt_trans hzx hz.1) hdz) (Set.left_mem_Icc.mpr (le_of_lt hxy)) (Set.right_mem_Icc.mpr (le_of_lt hxy)) (le_of_lt hxy) linarith /-- Symmetric helper (positivity version): if `g 0 = 0` and `deriv g` stays `≥ 0` once `> 0`, then `g` stays `> 0` once `> 0`! -/ lemma pos_after_pos_of_deriv_sign_change {g : ℝ → ℝ} {b : ℝ} (_hb : 0 < b) (h0 : g 0 = 0) (hcont : ContinuousOn g (Set.Ico 0 b)) (hdiff : ∀ x ∈ Set.Ioo 0 b, DifferentiableAt ℝ g x) (hsign : ∀ x ∈ Set.Ioo 0 b, ∀ y ∈ Set.Ioo 0 b, x < y → 0 < deriv g x → 0 ≤ deriv g y) : ∀ x ∈ Set.Ioo 0 b, ∀ y ∈ Set.Ioo 0 b, x < y → 0 < g x → 0 < g y := by intro x ⟨hx0, hxb⟩ y ⟨hy0, hyb⟩ hxy hgx have hex : ∃ z₀ ∈ Set.Ioo 0 x, 0 < deriv g z₀ := by by_contra hall; push Not at hall have hle : g x ≤ g 0 := antitoneOn_of_deriv_nonpos (convex_Icc 0 x) (hcont.mono fun z hz => ⟨hz.1, lt_of_le_of_lt hz.2 hxb⟩) (fun z hz => by rw [interior_Icc] at hz exact (hdiff z ⟨hz.1, lt_trans hz.2 hxb⟩).differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz; exact hall z hz) (Set.left_mem_Icc.mpr (le_of_lt hx0)) (Set.right_mem_Icc.mpr (le_of_lt hx0)) (le_of_lt hx0) linarith rcases hex with ⟨z₀, ⟨hz0, hzx⟩, hdz⟩ have hmono : g x ≤ g y := monotoneOn_of_deriv_nonneg (convex_Icc x y) (hcont.mono fun z hz => ⟨le_trans (le_of_lt hx0) hz.1, lt_of_le_of_lt hz.2 hyb⟩) (fun z hz => by rw [interior_Icc] at hz exact (hdiff z ⟨lt_trans hx0 hz.1, lt_trans hz.2 hyb⟩).differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz exact hsign z₀ ⟨hz0, lt_trans hzx hxb⟩ z ⟨lt_trans hx0 hz.1, lt_trans hz.2 hyb⟩ (lt_trans hzx hz.1) hdz) (Set.left_mem_Icc.mpr (le_of_lt hxy)) (Set.right_mem_Icc.mpr (le_of_lt hxy)) (le_of_lt hxy) linarith /-- Auxiliary functions for the 4-level cascade proof of the exact critical phase transition. -/ private def critF (p t : ℝ) : ℝ := Real.exp (-(Real.log 2 * (1 - t) ^ p)) + Real.exp (-(Real.log 2 * (1 + t) ^ p)) private def critQ (p t : ℝ) : ℝ := (p - 1) * Real.log ((1 - t) / (1 + t)) + Real.log 2 * ((1 + t) ^ p - (1 - t) ^ p) private def critH (p t : ℝ) : ℝ := (1 - t) * (1 + t) ^ p + (1 + t) * (1 - t) ^ p private def critL (p t : ℝ) : ℝ := Real.log ((p - 1 + (p + 1) * t) / (p - 1 - (p + 1) * t)) - (p - 1) * Real.log ((1 + t) / (1 - t)) private lemma hasDerivAt_critF {p t : ℝ} (_hp : 1 < p) (ht0 : 0 < t) (ht1 : t < 1) : HasDerivAt (critF p) (p * Real.log 2 * ((1 - t) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 - t) ^ p)) - (1 + t) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 + t) ^ p)))) t := by have h1m : 0 < 1 - t := by linarith have h1p : 0 < 1 + t := by linarith have hd1 : HasDerivAt (fun z : ℝ => (1 - z) ^ p) (p * (1 - t) ^ (p - 1) * (-1)) t := (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt h1m))).comp t (HasDerivAt.const_sub 1 (hasDerivAt_id t)) have hd2 : HasDerivAt (fun z : ℝ => (1 + z) ^ p) (p * (1 + t) ^ (p - 1) * 1) t := (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt h1p))).comp t ((hasDerivAt_id t).const_add 1) have he1 : HasDerivAt (fun z : ℝ => Real.exp (-(Real.log 2 * (1 - z) ^ p))) (Real.exp (-(Real.log 2 * (1 - t) ^ p)) * (-(Real.log 2 * (p * (1 - t) ^ (p - 1) * (-1))))) t := ((hd1.const_mul (Real.log 2)).neg).exp have he2 : HasDerivAt (fun z : ℝ => Real.exp (-(Real.log 2 * (1 + z) ^ p))) (Real.exp (-(Real.log 2 * (1 + t) ^ p)) * (-(Real.log 2 * (p * (1 + t) ^ (p - 1) * 1)))) t := ((hd2.const_mul (Real.log 2)).neg).exp exact (he1.add he2).congr_deriv (by ring) private lemma hasDerivAt_critQ {p t : ℝ} (ht_lo : -1 < t) (ht_hi : t < 1) : HasDerivAt (critQ p) ((p * Real.log 2 * critH p t - 2 * (p - 1)) / (1 - t ^ 2)) t := by have h1m : 0 < 1 - t := by linarith have h1p : 0 < 1 + t := by linarith have h1sq : 0 < 1 - t ^ 2 := by nlinarith have hlog_div : HasDerivAt (fun z : ℝ => Real.log ((1 - z) / (1 + z))) ((-1 / (1 - t)) - (1 / (1 + t))) t := by have hq : HasDerivAt (fun z : ℝ => (1 - z) / (1 + z)) ((-1 * (1 + t) - (1 - t) * 1) / (1 + t) ^ 2) t := (HasDerivAt.const_sub 1 (hasDerivAt_id t)).div ((hasDerivAt_id t).const_add 1) (ne_of_gt h1p) have hl := hq.log (ne_of_gt (div_pos h1m h1p)) refine hl.congr_deriv ?_ have h1m_ne : 1 - t ≠ 0 := ne_of_gt h1m have h1p_ne : 1 + t ≠ 0 := ne_of_gt h1p field_simp have hd1 : HasDerivAt (fun z : ℝ => (1 + z) ^ p) (p * (1 + t) ^ (p - 1) * 1) t := (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt h1p))).comp t ((hasDerivAt_id t).const_add 1) have hd2 : HasDerivAt (fun z : ℝ => (1 - z) ^ p) (p * (1 - t) ^ (p - 1) * (-1)) t := (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt h1m))).comp t (HasDerivAt.const_sub 1 (hasDerivAt_id t)) have htot := (hlog_div.const_mul (p - 1)).add ((hd1.sub hd2).const_mul (Real.log 2)) refine htot.congr_deriv ?_ have hpow_p : (1 + t) ^ p = (1 + t) ^ (p - 1) * (1 + t) := by rw [← Real.rpow_add_one (ne_of_gt h1p)]; ring_nf have hpow_m : (1 - t) ^ p = (1 - t) ^ (p - 1) * (1 - t) := by rw [← Real.rpow_add_one (ne_of_gt h1m)]; ring_nf have hH_rew : critH p t = (1 - t ^ 2) * ((1 + t) ^ (p - 1) + (1 - t) ^ (p - 1)) := by dsimp only [critH]; rw [hpow_p, hpow_m]; ring rw [hH_rew] have h1m_ne : 1 - t ≠ 0 := ne_of_gt h1m have h1p_ne : 1 + t ≠ 0 := ne_of_gt h1p have h1sq_ne : 1 - t ^ 2 ≠ 0 := ne_of_gt h1sq have hfac : 1 - t ^ 2 = (1 - t) * (1 + t) := by ring rw [hfac] field_simp ring private lemma hasDerivAt_critH {p t : ℝ} (ht_lo : -1 < t) (ht_hi : t < 1) : HasDerivAt (critH p) ((1 + t) ^ (p - 1) * (p - 1 - (p + 1) * t) - (1 - t) ^ (p - 1) * (p - 1 + (p + 1) * t)) t := by have h1m : 0 < 1 - t := by linarith have h1p : 0 < 1 + t := by linarith have hd1 : HasDerivAt (fun z : ℝ => (1 + z) ^ p) (p * (1 + t) ^ (p - 1) * 1) t := (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt h1p))).comp t ((hasDerivAt_id t).const_add 1) have hd2 : HasDerivAt (fun z : ℝ => (1 - z) ^ p) (p * (1 - t) ^ (p - 1) * (-1)) t := (Real.hasDerivAt_rpow_const (p := p) (Or.inl (ne_of_gt h1m))).comp t (HasDerivAt.const_sub 1 (hasDerivAt_id t)) have hm1 : HasDerivAt (fun z : ℝ => (1 - z) * (1 + z) ^ p) ((-1) * (1 + t) ^ p + (1 - t) * (p * (1 + t) ^ (p - 1) * 1)) t := (HasDerivAt.const_sub 1 (hasDerivAt_id t)).mul hd1 have hm2 : HasDerivAt (fun z : ℝ => (1 + z) * (1 - z) ^ p) (1 * (1 - t) ^ p + (1 + t) * (p * (1 - t) ^ (p - 1) * (-1))) t := ((hasDerivAt_id t).const_add 1).mul hd2 refine (hm1.add hm2).congr_deriv ?_ have hpow_p : (1 + t) ^ p = (1 + t) ^ (p - 1) * (1 + t) := by rw [← Real.rpow_add_one (ne_of_gt h1p)]; ring_nf have hpow_m : (1 - t) ^ p = (1 - t) ^ (p - 1) * (1 - t) := by rw [← Real.rpow_add_one (ne_of_gt h1m)]; ring_nf rw [hpow_p, hpow_m]; ring private lemma hasDerivAt_critL {p t : ℝ} (hp : 1 < p) (ht0 : 0 ≤ t) (htc : t < (p - 1) / (p + 1)) : HasDerivAt (critL p) (2 * p * (p - 1) * ((3 - p) + (p + 1) * t ^ 2) / (((p - 1) ^ 2 - (p + 1) ^ 2 * t ^ 2) * (1 - t ^ 2))) t := by have hp1_pos : 0 < p - 1 := by linarith have hpp1_pos : 0 < p + 1 := by linarith have ht_mul : (p + 1) * t < p - 1 := by have := (lt_div_iff₀ hpp1_pos).mp htc; linarith have hA_pos : 0 < p - 1 + (p + 1) * t := by nlinarith have hB_pos : 0 < p - 1 - (p + 1) * t := by linarith have ht1 : t < 1 := by have : (p - 1) / (p + 1) < 1 := (div_lt_one hpp1_pos).mpr (by linarith) linarith have h1m : 0 < 1 - t := by linarith have h1p : 0 < 1 + t := by linarith have hd_left : HasDerivAt (fun z : ℝ => Real.log ((p - 1 + (p + 1) * z) / (p - 1 - (p + 1) * z))) (2 * (p - 1) * (p + 1) / ((p - 1) ^ 2 - (p + 1) ^ 2 * t ^ 2)) t := by have hnum : HasDerivAt (fun z : ℝ => p - 1 + (p + 1) * z) (p + 1) t := by simpa using ((hasDerivAt_id t).const_mul (p + 1)).const_add (p - 1) have hden : HasDerivAt (fun z : ℝ => p - 1 - (p + 1) * z) (-(p + 1)) t := by simpa using HasDerivAt.const_sub (p - 1) ((hasDerivAt_id t).const_mul (p + 1)) have hq := hnum.div hden (ne_of_gt hB_pos) have hl := hq.log (ne_of_gt (div_pos hA_pos hB_pos)) refine hl.congr_deriv ?_ dsimp only [Pi.div_apply] have hA_ne : p - 1 + (p + 1) * t ≠ 0 := ne_of_gt hA_pos have hB_ne : p - 1 - (p + 1) * t ≠ 0 := ne_of_gt hB_pos have hfac : (p - 1) ^ 2 - (p + 1) ^ 2 * t ^ 2 = (p - 1 + (p + 1) * t) * (p - 1 - (p + 1) * t) := by ring rw [hfac]; field_simp; ring have hd_right : HasDerivAt (fun z : ℝ => Real.log ((1 + z) / (1 - z))) (2 / (1 - t ^ 2)) t := by have hq : HasDerivAt (fun z : ℝ => (1 + z) / (1 - z)) ((1 * (1 - t) - (1 + t) * (-1)) / (1 - t) ^ 2) t := ((hasDerivAt_id t).const_add 1).div (HasDerivAt.const_sub 1 (hasDerivAt_id t)) (ne_of_gt h1m) have hl := hq.log (ne_of_gt (div_pos h1p h1m)) refine hl.congr_deriv ?_ have h1m_ne : 1 - t ≠ 0 := ne_of_gt h1m have h1p_ne : 1 + t ≠ 0 := ne_of_gt h1p have hfac : 1 - t ^ 2 = (1 + t) * (1 - t) := by ring rw [hfac]; field_simp; ring refine (hd_left.sub (hd_right.const_mul (p - 1))).congr_deriv ?_ have hD1 : (p - 1) ^ 2 - (p + 1) ^ 2 * t ^ 2 ≠ 0 := ne_of_gt (by nlinarith) have hD2 : 1 - t ^ 2 ≠ 0 := ne_of_gt (by nlinarith) field_simp; ring /-- **THE CRITICAL EXPONENTIAL CRITERION (`1 ≤ p ≤ pCrit = 1 / (1 - log 2)`)**: For EVERY `p ∈ [1, 1 / (1 - log 2)]` and EVERY `u ∈ [0, 1]`: `exp (-(2^p * log 2) * u^p) + exp (-(2^p * log 2) * (1 - u)^p) ≥ 1`! -/ theorem exp_sym_criterion_of_le_pCrit {p : ℝ} (hp1 : 1 ≤ p) (hp_crit : p ≤ pCrit) : ∀ u ∈ Set.Icc (0 : ℝ) 1, Real.exp (-(u ^ p) / (1 / (2 ^ p * Real.log 2))) + Real.exp (-((1 - u) ^ p) / (1 / (2 ^ p * Real.log 2))) ≥ 1 := by have hp0 : 0 < p := by linarith have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) -- Rewrite exponent in terms of t = |1 - 2*u| ∈ [0, 1]: -- -(u^p) / (1 / (2^p * log 2)) = -(log 2 * (2 * u)^p) suffices hF : ∀ t ∈ Set.Icc (0 : ℝ) 1, 1 ≤ critF p t by intro u ⟨hu0, hu1⟩ have hrew : ∀ x : ℝ, 0 ≤ x → -(x ^ p) / (1 / (2 ^ p * Real.log 2)) = -(Real.log 2 * (2 * x) ^ p) := by intro x hx rw [div_div_eq_mul_div, div_one, Real.mul_rpow (by norm_num : (0 : ℝ) ≤ 2) hx] ring rw [hrew u hu0, hrew (1 - u) (by linarith)] rcases le_total u (1 / 2) with hle | hge · have h := hF (1 - 2 * u) ⟨by linarith, by linarith⟩ have h1 : 1 - (1 - 2 * u) = 2 * u := by ring have h2 : 1 + (1 - 2 * u) = 2 * (1 - u) := by ring dsimp only [critF] at h rw [h1, h2] at h; exact h · have h := hF (2 * u - 1) ⟨by linarith, by linarith⟩ have h1 : 1 - (2 * u - 1) = 2 * (1 - u) := by ring have h2 : 1 + (2 * u - 1) = 2 * u := by ring dsimp only [critF] at h rw [h1, h2, add_comm] at h; exact h -- Case p = 1: elementary AM-GM! by_cases hp_eq1 : p = 1 · subst hp_eq1 intro t _ dsimp only [critF] simp only [Real.rpow_one] have h1 : Real.exp (-(Real.log 2 * (1 - t))) = (1 / 2) * Real.exp (Real.log 2 * t) := by rw [show -(Real.log 2 * (1 - t)) = -Real.log 2 + Real.log 2 * t by ring, Real.exp_add, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2), one_div] have h2 : Real.exp (-(Real.log 2 * (1 + t))) = (1 / 2) * (Real.exp (Real.log 2 * t))⁻¹ := by rw [show -(Real.log 2 * (1 + t)) = -Real.log 2 + -(Real.log 2 * t) by ring, Real.exp_add, Real.exp_neg, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2), one_div] rw [h1, h2] set a := Real.exp (Real.log 2 * t) have ha : 0 < a := Real.exp_pos _ have ham : 2 ≤ a + a⁻¹ := by have hsq : 0 ≤ (a - 1) ^ 2 := sq_nonneg _ have hmul : 2 * a ≤ a * a + 1 := by nlinarith have hdiv := (le_div_iff₀ ha).mpr (by linarith : 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 1 < p ≤ pCrit: 4-level zero-root-finding sign-change cascade! have hp_gt1 : 1 < p := lt_of_le_of_ne hp1 (Ne.symm hp_eq1) have hp_cond : 2 * (p - 1) ≤ 2 * p * Real.log 2 := by have hpos := one_sub_log2_pos have hle := (le_div_iff₀ hpos).mp hp_crit linarith -- Level 1: L(x) > 0 → L(y) > 0 for 0 < x < y < c = (p - 1) / (p + 1) set c := (p - 1) / (p + 1) have hc_pos : 0 < c := div_pos (by linarith) (by linarith) have hc_lt1 : c < 1 := (div_lt_one (by linarith)).mpr (by linarith) have hL_pos_persist : ∀ x ∈ Set.Ioo 0 c, ∀ y ∈ Set.Ioo 0 c, x < y → 0 < critL p x → 0 < critL p y := by refine pos_after_pos_of_deriv_sign_change hc_pos (by simp [critL]) ?_ ?_ ?_ · intro x ⟨hx0, hxc⟩ exact (hasDerivAt_critL hp_gt1 hx0 hxc).continuousAt.continuousWithinAt · intro x ⟨hx0, hxc⟩ exact (hasDerivAt_critL hp_gt1 (le_of_lt hx0) hxc).differentiableAt · intro x ⟨hx0, hxc⟩ y ⟨hy0, hyc⟩ hxy hdx rw [(hasDerivAt_critL hp_gt1 (le_of_lt hx0) hxc).deriv] at hdx rw [(hasDerivAt_critL hp_gt1 (le_of_lt hy0) hyc).deriv] have hden_x : 0 < ((p - 1) ^ 2 - (p + 1) ^ 2 * x ^ 2) * (1 - x ^ 2) := by have h1 : (p + 1) * x < p - 1 := by have := (lt_div_iff₀ (by linarith : 0 < p + 1)).mp hxc; linarith have h2 : x < 1 := lt_trans hxc hc_lt1 have hf : (p - 1) ^ 2 - (p + 1) ^ 2 * x ^ 2 = (p - 1 - (p + 1) * x) * (p - 1 + (p + 1) * x) := by ring rw [hf] exact mul_pos (mul_pos (by linarith) (by nlinarith)) (by nlinarith) have hden_y : 0 < ((p - 1) ^ 2 - (p + 1) ^ 2 * y ^ 2) * (1 - y ^ 2) := by have h1 : (p + 1) * y < p - 1 := by have := (lt_div_iff₀ (by linarith : 0 < p + 1)).mp hyc; linarith have h2 : y < 1 := lt_trans hyc hc_lt1 have hf : (p - 1) ^ 2 - (p + 1) ^ 2 * y ^ 2 = (p - 1 - (p + 1) * y) * (p - 1 + (p + 1) * y) := by ring rw [hf] exact mul_pos (mul_pos (by linarith) (by nlinarith)) (by nlinarith) have hnum_x : 0 < 2 * p * (p - 1) * ((3 - p) + (p + 1) * x ^ 2) := (div_pos_iff_of_pos_right hden_x).mp hdx have hfac_x : 0 < (3 - p) + (p + 1) * x ^ 2 := by have hcoef : 0 < 2 * p * (p - 1) := by nlinarith nlinarith have hsq_xy : x ^ 2 < y ^ 2 := by nlinarith have hfac_y : 0 ≤ (3 - p) + (p + 1) * y ^ 2 := by nlinarith have hnum_y : 0 ≤ 2 * p * (p - 1) * ((3 - p) + (p + 1) * y ^ 2) := by have hcoef : 0 < 2 * p * (p - 1) := by nlinarith nlinarith exact div_nonneg hnum_y (le_of_lt hden_y) -- Level 2: H'(t) < 0 persists on (0, 1) have hH_deriv_neg_persist : ∀ x ∈ Set.Ioo (0 : ℝ) 1, ∀ y ∈ Set.Ioo (0 : ℝ) 1, x < y → deriv (critH p) x < 0 → deriv (critH p) y < 0 := by intro x ⟨hx0, hx1⟩ y ⟨hy0, hy1⟩ hxy hdx rw [(hasDerivAt_critH (by linarith) hx1).deriv] at hdx rw [(hasDerivAt_critH (by linarith) hy1).deriv] by_cases hyc : y < c · have hxc : x < c := lt_trans hxy hyc have hBx : 0 < p - 1 - (p + 1) * x := by have := (lt_div_iff₀ (by linarith : 0 < p + 1)).mp hxc; linarith have hAx : 0 < p - 1 + (p + 1) * x := by nlinarith have hBy : 0 < p - 1 - (p + 1) * y := by have := (lt_div_iff₀ (by linarith : 0 < p + 1)).mp hyc; linarith have hAy : 0 < p - 1 + (p + 1) * y := by nlinarith have hLx : 0 < critL p x := by -- From (1 + x)^(p-1) * B_x < (1 - x)^(p-1) * A_x, take log! have hlt_prod : (1 + x) ^ (p - 1) * (p - 1 - (p + 1) * x) < (1 - x) ^ (p - 1) * (p - 1 + (p + 1) * x) := by linarith have hpos1 : 0 < (1 + x) ^ (p - 1) * (p - 1 - (p + 1) * x) := by positivity have hlog := Real.log_lt_log hpos1 hlt_prod rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt hBx), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt hAx), Real.log_rpow (by linarith), Real.log_rpow (by linarith)] at hlog dsimp only [critL] rw [Real.log_div (ne_of_gt hAx) (ne_of_gt hBx), Real.log_div (by linarith) (by linarith)] linarith have hLy : 0 < critL p y := hL_pos_persist x ⟨hx0, hxc⟩ y ⟨hy0, hyc⟩ hxy hLx dsimp only [critL] at hLy rw [Real.log_div (ne_of_gt hAy) (ne_of_gt hBy), Real.log_div (by linarith) (by linarith)] at hLy have hlog_lt : Real.log ((1 + y) ^ (p - 1) * (p - 1 - (p + 1) * y)) < Real.log ((1 - y) ^ (p - 1) * (p - 1 + (p + 1) * y)) := by rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt hBy), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt hAy), Real.log_rpow (by linarith), Real.log_rpow (by linarith)] linarith have hprod_lt := (Real.log_lt_log_iff (by positivity) (by positivity)).mp hlog_lt linarith · -- y ≥ c = (p - 1) / (p + 1): first term ≤ 0, second term > 0! push Not at hyc have hBy : p - 1 - (p + 1) * y ≤ 0 := by have := (div_le_iff₀ (by linarith : 0 < p + 1)).mp hyc; linarith have hAy : 0 < p - 1 + (p + 1) * y := by nlinarith have ht1 : (1 + y) ^ (p - 1) * (p - 1 - (p + 1) * y) ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (Real.rpow_nonneg (by linarith) _) hBy have ht2 : 0 < (1 - y) ^ (p - 1) * (p - 1 + (p + 1) * y) := mul_pos (Real.rpow_pos_of_pos (by linarith) _) hAy linarith -- Level 3: Q'(t) < 0 persists on (0, 1) have hQ_deriv_neg_persist : ∀ x ∈ Set.Ioo (0 : ℝ) 1, ∀ y ∈ Set.Ioo (0 : ℝ) 1, x < y → deriv (critQ p) x < 0 → deriv (critQ p) y ≤ 0 := by intro x ⟨hx0, hx1⟩ y ⟨hy0, hy1⟩ hxy hdx rw [(hasDerivAt_critQ (by linarith) hx1).deriv] at hdx rw [(hasDerivAt_critQ (by linarith) hy1).deriv] have h1sq_x : 0 < 1 - x ^ 2 := by nlinarith have h1sq_y : 0 < 1 - y ^ 2 := by nlinarith have hHx_lt : p * Real.log 2 * critH p x < 2 * (p - 1) := by have := (div_neg_iff.mp hdx).resolve_left (by push Not; intro _; linarith) linarith have hH0 : critH p 0 = 2 := by simp [critH]; norm_num have hHx_lt_H0 : critH p x < critH p 0 := by rw [hH0] have hpl2 : 0 < p * Real.log 2 := mul_pos hp0 hlog2_pos nlinarith -- Since H x < H 0, ∃ z₀ ∈ (0, x) with H'(z₀) < 0, so H is antitone on [x, y]! have hex : ∃ z₀ ∈ Set.Ioo 0 x, deriv (critH p) z₀ < 0 := by by_contra hall; push Not at hall have hle : critH p 0 ≤ critH p x := monotoneOn_of_deriv_nonneg (convex_Icc 0 x) (fun z hz => (hasDerivAt_critH (by linarith [hz.1]) (lt_of_le_of_lt hz.2 hx1)).continuousAt.continuousWithinAt) (fun z hz => by rw [interior_Icc] at hz exact (hasDerivAt_critH (by linarith [hz.1]) (lt_trans hz.2 hx1)).differentiableAt.differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz; exact hall z hz) (Set.left_mem_Icc.mpr (le_of_lt hx0)) (Set.right_mem_Icc.mpr (le_of_lt hx0)) (le_of_lt hx0) linarith rcases hex with ⟨z₀, ⟨hz0, hzx⟩, hdz⟩ have hHy_le : critH p y ≤ critH p x := antitoneOn_of_deriv_nonpos (convex_Icc x y) (fun z hz => (hasDerivAt_critH (by linarith [hz.1]) (lt_of_le_of_lt hz.2 hy1)).continuousAt.continuousWithinAt) (fun z hz => by rw [interior_Icc] at hz exact (hasDerivAt_critH (by linarith [hz.1]) (lt_trans hz.2 hy1)).differentiableAt.differentiableWithinAt) (fun z hz => by rw [interior_Icc] at hz exact le_of_lt (hH_deriv_neg_persist z₀ ⟨hz0, lt_trans hzx hx1⟩ z ⟨lt_trans hx0 hz.1, lt_trans hz.2 hy1⟩ (lt_trans hzx hz.1) hdz)) (Set.left_mem_Icc.mpr (le_of_lt hxy)) (Set.right_mem_Icc.mpr (le_of_lt hxy)) (le_of_lt hxy) have hHy_num : p * Real.log 2 * critH p y - 2 * (p - 1) ≤ 0 := by have hpl2 : 0 < p * Real.log 2 := mul_pos hp0 hlog2_pos nlinarith exact div_nonpos_of_nonpos_of_nonneg hHy_num (le_of_lt h1sq_y) -- Level 3b: Q(t) < 0 → Q(y) ≤ 0 on (0, 1) have hQ_neg_persist : ∀ x ∈ Set.Ioo (0 : ℝ) 1, ∀ y ∈ Set.Ioo (0 : ℝ) 1, x < y → critQ p x < 0 → critQ p y ≤ 0 := nonpos_after_neg_of_deriv_sign_change zero_lt_one (by simp [critQ]) (fun z hz => (hasDerivAt_critQ (by linarith [hz.1]) hz.2).continuousAt.continuousWithinAt) (fun z hz => (hasDerivAt_critQ (by linarith [hz.1]) hz.2).differentiableAt) hQ_deriv_neg_persist -- Level 4: f'(t) < 0 ↔ Q(t) < 0, so f'(t) never returns from < 0 to > 0! have hF_sign : ∀ x ∈ Set.Ioo (0 : ℝ) 1, ∀ y ∈ Set.Ioo (0 : ℝ) 1, x < y → deriv (critF p) x < 0 → deriv (critF p) y ≤ 0 := by intro x ⟨hx0, hx1⟩ y ⟨hy0, hy1⟩ hxy hdx rw [(hasDerivAt_critF hp_gt1 hx0 hx1).deriv] at hdx rw [(hasDerivAt_critF hp_gt1 hy0 hy1).deriv] have hpl2 : 0 < p * Real.log 2 := mul_pos hp0 hlog2_pos have hdiff_x : (1 - x) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 - x) ^ p)) < (1 + x) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 + x) ^ p)) := by nlinarith have hQx : critQ p x < 0 := by have hlog := Real.log_lt_log (by positivity) hdiff_x rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (Real.exp_pos _)), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (Real.exp_pos _)), Real.log_rpow (by linarith), Real.log_rpow (by linarith), Real.log_exp, Real.log_exp] at hlog dsimp only [critQ] rw [Real.log_div (by linarith) (by linarith)] linarith have hQy : critQ p y ≤ 0 := hQ_neg_persist x ⟨hx0, hx1⟩ y ⟨hy0, hy1⟩ hxy hQx dsimp only [critQ] at hQy rw [Real.log_div (by linarith) (by linarith)] at hQy have hlog_le : Real.log ((1 - y) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 - y) ^ p))) ≤ Real.log ((1 + y) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 + y) ^ p))) := by rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (Real.exp_pos _)), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (Real.exp_pos _)), Real.log_rpow (by linarith), Real.log_rpow (by linarith), Real.log_exp, Real.log_exp] linarith have hprod_le := (Real.log_le_log_iff (by positivity) (by positivity)).mp hlog_le nlinarith -- Apply Endpoint Minimum Principle to critF p on [0, 1]! have hF_cont : ContinuousOn (critF p) (Set.Icc 0 1) := by have h1 : Continuous (fun z : ℝ => Real.exp (-(Real.log 2 * (1 - z) ^ p))) := Real.continuous_exp.comp ((continuous_const.mul ((continuous_const.sub continuous_id).rpow_const fun _ => Or.inr (le_of_lt hp0))).neg) have h2 : Continuous (fun z : ℝ => Real.exp (-(Real.log 2 * (1 + z) ^ p))) := Real.continuous_exp.comp ((continuous_const.mul ((continuous_const.add continuous_id).rpow_const fun _ => Or.inr (le_of_lt hp0))).neg) exact (h1.add h2).continuousOn have hmin := min_at_endpoints_of_deriv_sign_change (by norm_num : (0 : ℝ) ≤ 1) hF_cont (fun z hz => (hasDerivAt_critF hp_gt1 hz.1 hz.2).differentiableAt) hF_sign intro t ht have h0 : critF p 0 = 1 := by dsimp only [critF] simp only [sub_zero, add_zero, Real.one_rpow, mul_one, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2)] norm_num have h1 : 1 ≤ critF p 1 := by dsimp only [critF] rw [sub_self, Real.zero_rpow (ne_of_gt hp0), mul_zero, neg_zero, Real.exp_zero] linarith [Real.exp_pos (-(Real.log 2 * (1 + 1) ^ p))] exact le_trans (le_min (le_of_eq h0.symm) h1) (hmin t ht) /-- **SUBCRITICAL & CRITICAL UNIVERSAL HYPERCUBE HALVING THEOREM (`1 ≤ p ≤ 1 / (1 - log 2)`)**: For EVERY `p ∈ [1, 1 / (1 - log 2)]`, EVERY `D > 0`, and EVERY finite nonempty real-valued concept class `V` with range diameter `≤ D` (zero dependence on label cardinality!): `OptLp p V ≤ (D^p / (2^p * Real.log 2)) * Real.log |V|`. -/ theorem OptLp_le_hypercube_law_of_le_pCrit {α : Type*} [Fintype α] [DecidableEq α] {p D : ℝ} (hp1 : 1 ≤ p) (hp_crit : p ≤ pCrit) (hD : 0 < D) {V : Finset (α → ℝ)} (hV : V.Nonempty) (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ D) : OptLp p V ≤ (D ^ p / (2 ^ p * Real.log 2)) * Real.log (V.card : ℝ) := by have hp0 : 0 < p := by linarith have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) have hC_pos : 0 < 1 / (2 ^ p * Real.log 2) := by positivity have h := OptLp_le_of_exp_criterion hp0 hC_pos hD (exp_sym_criterion_of_le_pCrit hp1 hp_crit) hV hdiam have hrew : 1 / (2 ^ p * Real.log 2) * D ^ p = D ^ p / (2 ^ p * Real.log 2) := by ring rwa [hrew] at h /-- **Exact `p = 1` (Absolute Loss) Universal Halving Corollary**: `OptLp 1 V ≤ (D / (2 * Real.log 2)) * Real.log |V|`. -/ theorem OptLp_one_le_half_log2 {α : Type*} [Fintype α] [DecidableEq α] {D : ℝ} (hD : 0 < D) {V : Finset (α → ℝ)} (hV : V.Nonempty) (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ D) : OptLp 1 V ≤ (D / (2 * Real.log 2)) * Real.log (V.card : ℝ) := by have h := OptLp_le_hypercube_law_of_le_pCrit le_rfl (by linarith [pCrit_bounds.1]) hD hV hdiam simpa [Real.rpow_one] using h /-- **Exact `p = 2` (Squared Loss) Universal Halving Theorem**: `OptLp 2 V ≤ (D^2 / (4 * Real.log 2)) * Real.log |V|` — strictly beating Vovk's classical `(D^2 / 2) * Real.log |V|` aggregating bound by **> 27.8%**! -/ theorem OptLp_two_le_quarter_log2 {α : Type*} [Fintype α] [DecidableEq α] {D : ℝ} (hD : 0 < D) {V : Finset (α → ℝ)} (hV : V.Nonempty) (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ D) : OptLp 2 V ≤ (D ^ 2 / (4 * Real.log 2)) * Real.log (V.card : ℝ) := by have h := OptLp_le_hypercube_law_of_le_pCrit (p := 2) (by norm_num) (by linarith [pCrit_bounds.1]) hD hV hdiam have h22 : (2 : ℝ) ^ (2 : ℝ) = 4 := by norm_num have hD2 : D ^ (2 : ℝ) = D ^ 2 := Real.rpow_two D rwa [h22, hD2] at h /-- **Strict `> 27.8%` Improvement Over Vovk's Classical Squared-Loss Mixability Constant (`1 / 2`)**: `1 / (4 * Real.log 2) < (722 / 1000) * (1 / 2)`. -/ theorem OptLp_two_beats_vovk_by_27pct : 1 / (4 * Real.log 2) < (722 / 1000 : ℝ) * (1 / 2) := by have hlog2_lo := Real.log_two_gt_d9 have hpos : 0 < 4 * Real.log 2 := by linarith rw [div_lt_iff₀ hpos] linarith /-- **Exact `p = 3` (Cubic Loss) Universal Halving Theorem**: Even though cubic loss `|ŷ - y|^3` has Vovk mixability constant `η* = 0` (non-mixable!), `3 < pCrit`, so the exact hypercube law STILL holds: `OptLp 3 V ≤ (D^3 / (8 * Real.log 2)) * Real.log |V|`! -/ theorem OptLp_three_le_eighth_log2 {α : Type*} [Fintype α] [DecidableEq α] {D : ℝ} (hD : 0 < D) {V : Finset (α → ℝ)} (hV : V.Nonempty) (hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ D) : OptLp 3 V ≤ (D ^ 3 / (8 * Real.log 2)) * Real.log (V.card : ℝ) := by have h := OptLp_le_hypercube_law_of_le_pCrit (p := 3) (by norm_num) (by linarith [pCrit_bounds.1]) hD hV hdiam have h23 : (2 : ℝ) ^ (3 : ℝ) = 8 := by norm_num have hD3 : D ^ (3 : ℝ) = D ^ 3 := by rw [show (3 : ℝ) = ((3 : ℕ) : ℝ) by norm_num, Real.rpow_natCast] rwa [h23, hD3] at h /-- **SUPERCRITICAL INSTABILITY FOR EVERY `p > pCrit = 1 / (1 - log 2)`**: Whenever `p > pCrit`, the symmetric exponential criterion STRICTLY FAILS: there exists `u ∈ (0, 1)` and `C > 1 / (2^p * log 2)` such that `exp (-(u^p) / C) + exp (-((1 - u)^p) / C) < 1`! -/ theorem exp_sym_criterion_fails_of_gt_pCrit {p : ℝ} (hp : pCrit < p) : ∃ C : ℝ, 1 / (2 ^ p * Real.log 2) < C ∧ ∃ u ∈ Set.Ioo (0 : ℝ) 1, Real.exp (-(u ^ p) / C) + Real.exp (-((1 - u) ^ p) / C) < 1 := by have hp_gt1 : 1 < p := by linarith [pCrit_bounds.1] have hp0 : 0 < p := by linarith have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) -- At t = 0, (1 - 0) * Q'(0) = 2 * p * log 2 - 2 * (p - 1) = 2 * (1 - p * (1 - log 2)) < 0! have hQ0_neg : p * Real.log 2 * critH p 0 - 2 * (p - 1) < 0 := by have hH0 : critH p 0 = 2 := by simp [critH]; norm_num rw [hH0] have hgt : 1 < p * (1 - Real.log 2) := (div_lt_iff₀ one_sub_log2_pos).mp hp |> fun h => by linarith linarith have hH_cont : ContinuousAt (fun t : ℝ => p * Real.log 2 * critH p t - 2 * (p - 1)) 0 := by have h1 : ContinuousAt (critH p) 0 := (hasDerivAt_critH (by norm_num) (by norm_num)).continuousAt exact (continuousAt_const.mul h1).sub continuousAt_const have hev := (hH_cont.eventually (gt_mem_nhds hQ0_neg)).and (Ioo_mem_nhds (by norm_num : (-1 : ℝ) < 0) zero_lt_one) rcases Metric.eventually_nhds_iff.mp hev with ⟨δ, hδ_pos, hδ⟩ set ε := min (δ / 2) (1 / 2) have hε_pos : 0 < ε := lt_min (by linarith) (by norm_num) have hε_lt1 : ε < 1 := lt_of_le_of_lt (min_le_right _ _) (by norm_num) have hQ'_neg : ∀ t ∈ Set.Ioo 0 ε, deriv (critQ p) t < 0 := by intro t ⟨ht0, htε⟩ have ht1 : t < 1 := lt_trans htε hε_lt1 rw [(hasDerivAt_critQ (by linarith) ht1).deriv] have hdist : dist t 0 < δ := by rw [Real.dist_eq, sub_zero, abs_of_pos ht0] exact lt_of_lt_of_le htε (le_trans (min_le_left _ _) (by linarith)) have hnum := (hδ hdist).1 have h1sq : 0 < 1 - t ^ 2 := by nlinarith exact div_neg_of_neg_of_pos hnum h1sq have hQ_neg : ∀ t ∈ Set.Ioo 0 ε, critQ p t < 0 := by intro t ⟨ht0, htε⟩ have hanti : StrictAntiOn (critQ p) (Set.Icc 0 t) := strictAntiOn_of_deriv_neg (convex_Icc 0 t) (fun z hz => (hasDerivAt_critQ (by linarith [hz.1]) (lt_of_le_of_lt hz.2 (lt_trans htε hε_lt1))).continuousAt.continuousWithinAt) (fun z hz => by rw [interior_Icc] at hz exact hQ'_neg z ⟨hz.1, lt_trans hz.2 htε⟩) have hQ0 : critQ p 0 = 0 := by simp [critQ] rw [← hQ0] exact hanti (Set.left_mem_Icc.mpr (le_of_lt ht0)) (Set.right_mem_Icc.mpr (le_of_lt ht0)) ht0 have hF'_neg : ∀ t ∈ Set.Ioo 0 ε, deriv (critF p) t < 0 := by intro t ⟨ht0, htε⟩ have ht1 : t < 1 := lt_trans htε hε_lt1 rw [(hasDerivAt_critF hp_gt1 ht0 ht1).deriv] have hQt := hQ_neg t ⟨ht0, htε⟩ dsimp only [critQ] at hQt rw [Real.log_div (by linarith) (by linarith)] at hQt have hlog_lt : Real.log ((1 - t) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 - t) ^ p))) < Real.log ((1 + t) ^ (p - 1) * Real.exp (-(Real.log 2 * (1 + t) ^ p))) := by rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (Real.exp_pos _)), Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos (by linarith) _)) (ne_of_gt (Real.exp_pos _)), Real.log_rpow (by linarith), Real.log_rpow (by linarith), Real.log_exp, Real.log_exp] linarith have hprod_lt := (Real.log_lt_log_iff (by positivity) (by positivity)).mp hlog_lt have hpl2 : 0 < p * Real.log 2 := mul_pos hp0 hlog2_pos nlinarith -- Hence critF p (ε / 2) < critF p 0 = 1! have hF_lt1 : critF p (ε / 2) < 1 := by have hF0 : critF p 0 = 1 := by dsimp only [critF] simp only [sub_zero, add_zero, Real.one_rpow, mul_one, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2)] norm_num rw [← hF0] have hanti : StrictAntiOn (critF p) (Set.Icc 0 (ε / 2)) := strictAntiOn_of_deriv_neg (convex_Icc 0 (ε / 2)) (by have h1 : Continuous (fun z : ℝ => Real.exp (-(Real.log 2 * (1 - z) ^ p))) := Real.continuous_exp.comp ((continuous_const.mul ((continuous_const.sub continuous_id).rpow_const fun _ => Or.inr (le_of_lt hp0))).neg) have h2 : Continuous (fun z : ℝ => Real.exp (-(Real.log 2 * (1 + z) ^ p))) := Real.continuous_exp.comp ((continuous_const.mul ((continuous_const.add continuous_id).rpow_const fun _ => Or.inr (le_of_lt hp0))).neg) exact (h1.add h2).continuousOn) (fun z hz => by rw [interior_Icc] at hz exact hF'_neg z ⟨hz.1, by linarith [hz.2]⟩) exact hanti (Set.left_mem_Icc.mpr (by linarith)) (Set.right_mem_Icc.mpr (by linarith)) (by linarith) -- Convert t = ε / 2 to u = (1 - ε / 2) / 2 ∈ (0, 1) and bump C slightly above C_sym by continuity! set u := (1 - ε / 2) / 2 have hu0 : 0 < u := by dsimp only [u]; linarith have hu1 : u < 1 := by dsimp only [u]; linarith set C0 := 1 / (2 ^ p * Real.log 2) have hC0_pos : 0 < C0 := by positivity have hval_C0 : Real.exp (-(u ^ p) / C0) + Real.exp (-((1 - u) ^ p) / C0) < 1 := by have hrew : ∀ x : ℝ, 0 ≤ x → -(x ^ p) / C0 = -(Real.log 2 * (2 * x) ^ p) := by intro x hx dsimp only [C0] rw [div_div_eq_mul_div, div_one, Real.mul_rpow (by norm_num : (0 : ℝ) ≤ 2) hx] ring rw [hrew u (le_of_lt hu0), hrew (1 - u) (by linarith)] have h1 : 2 * u = 1 - ε / 2 := by dsimp only [u]; ring have h2 : 2 * (1 - u) = 1 + ε / 2 := by dsimp only [u]; ring rw [h1, h2] exact hF_lt1 have hcont_C : ContinuousAt (fun C : ℝ => Real.exp (-(u ^ p) / C) + Real.exp (-((1 - u) ^ p) / C)) C0 := by have hc1 : ContinuousAt (fun C : ℝ => Real.exp (-(u ^ p) / C)) C0 := Real.continuous_exp.continuousAt.comp (continuousAt_const.div continuousAt_id (ne_of_gt hC0_pos)) have hc2 : ContinuousAt (fun C : ℝ => Real.exp (-((1 - u) ^ p) / C)) C0 := Real.continuous_exp.continuousAt.comp (continuousAt_const.div continuousAt_id (ne_of_gt hC0_pos)) exact hc1.add hc2 have hevC := hcont_C.eventually (gt_mem_nhds hval_C0) rcases Metric.eventually_nhds_iff.mp hevC with ⟨η, hη_pos, hη⟩ refine ⟨C0 + η / 2, by linarith, u, ⟨hu0, hu1⟩, ?_⟩ apply hη rw [Real.dist_eq, show C0 + η / 2 - C0 = η / 2 by ring, abs_of_pos (by linarith)] linarith /-! ## Part 5: Exact ℓ_p vs. ℓ_q & Proper-vs-Improper Binary Sandwiches (`Ldim`, `RLdim`) -/ /-- 1-round deterministic mistake step on a finite label set `S ⊆ ℝ`. -/ def ldimStep (S : Finset ℝ) (d : ℝ → ℕ) : ℕ := if hS : S.Nonempty then S.sup' hS fun y₁ => S.sup' hS fun y₂ => if y₁ = y₂ then d y₁ else max (d y₁) (max (d y₂) (min (d y₁) (d y₂) + 1)) else 0 lemma ldimStep_le_iff {S : Finset ℝ} (hS : S.Nonempty) (d : ℝ → ℕ) (k : ℕ) : ldimStep S d ≤ k ↔ ∀ y₁ ∈ S, ∀ y₂ ∈ S, (if y₁ = y₂ then d y₁ else max (d y₁) (max (d y₂) (min (d y₁) (d y₂) + 1))) ≤ k := by simp only [ldimStep, dif_pos hS, Finset.sup'_le_iff] /-- Deterministic Littlestone Dimension `Ldim V` for finite real-valued classes (cost `1` per mistake, corresponding to proper deterministic binary online prediction on `{0, 1}`). -/ def Ldim {α : Type*} [Fintype α] [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 ldimStep (labels V x) fun y => Ldim (restrict V x y) else 0 termination_by V.card decreasing_by exact _hlt _ lemma Ldim_eq_zero_of_card_le_one {α : Type*} [Fintype α] [DecidableEq α] {V : Finset (α → ℝ)} (hV : V.card ≤ 1) : Ldim V = 0 := by rw [Ldim, if_pos hV] lemma Ldim_le_of_forall_x {α : Type*} [Fintype α] [DecidableEq α] (V : Finset (α → ℝ)) (k : ℕ) (h : ∀ x : α, 2 ≤ (labels V x).card → ∀ y₁ ∈ labels V x, ∀ y₂ ∈ labels V x, (if y₁ = y₂ then Ldim (restrict V x y₁) else max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1))) ≤ k) : Ldim V ≤ k := by by_cases hV : V.card ≤ 1 · rw [Ldim_eq_zero_of_card_le_one hV]; omega · conv_lhs => rw [Ldim, if_neg hV] dsimp only split_ifs with hs · refine Finset.sup'_le _ _ fun ⟨x, hx⟩ _ => ?_ have hsp := (Finset.mem_filter.mp hx).2 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) exact (ldimStep_le_iff hS _ k).mpr (h x hsp) · omega lemma Ldim_ge_pair {α : Type*} [Fintype α] [DecidableEq α] (V : Finset (α → ℝ)) (x : α) {y₁ y₂ : ℝ} (hy₁ : y₁ ∈ labels V x) (hy₂ : y₂ ∈ labels V x) (hne : y₁ ≠ y₂) : max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1)) ≤ Ldim V := by have hsp : 2 ≤ (labels V x).card := by have hsub : ({y₁, y₂} : Finset ℝ) ⊆ labels V x := by intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl; exact hy₁; exact hy₂ have hcard := Finset.card_le_card hsub rw [Finset.card_pair hne] at hcard; exact hcard have hV : ¬ V.card ≤ 1 := by have : (labels V x).card ≤ V.card := Finset.card_image_le omega conv_rhs => rw [Ldim, if_neg hV] dsimp only have hx : x ∈ Finset.univ.filter fun z : α => 2 ≤ (labels V z).card := by simp [hsp] rw [dif_pos ⟨x, hx⟩] have h1 : ldimStep (labels V x) (fun y => Ldim (restrict V x y)) ≤ (Finset.univ.filter fun z : α => 2 ≤ (labels V z).card).attach.sup' _ fun z => ldimStep (labels V z.1) fun y => Ldim (restrict V z.1 y) := Finset.le_sup' (f := fun z : {x // x ∈ _} => ldimStep (labels V z.1) fun y => Ldim (restrict V z.1 y)) (Finset.mem_attach _ ⟨x, hx⟩) have hS : (labels V x).Nonempty := ⟨y₁, hy₁⟩ have h2 := (ldimStep_le_iff hS (fun y => Ldim (restrict V x y)) _).mp le_rfl y₁ hy₁ y₂ hy₂ rw [if_neg hne] at h2 exact le_trans h2 h1 /-- **Exact Proper-vs-Improper Binary Sandwich (`2^(-p) * Ldim V ≤ OptLp p V ≤ Ldim V`)**: for EVERY `{0, 1}`-valued concept class `V` and EVERY `p ≥ 1`: `OptLp p V` is trapped between `(1 / 2^p) * Ldim V` (attained on `{0, 1}^d`) and `Ldim V` (approached arbitrarily closely on binary singletons)! -/ theorem OptLp_binary_vs_Ldim {α : Type*} [Fintype α] [DecidableEq α] {p : ℝ} (hp : 1 ≤ p) {V : Finset (α → ℝ)} (hbin : ∀ h ∈ V, ∀ x : α, h x = 0 ∨ h x = 1) : (1 / 2 ^ p) * (Ldim V : ℝ) ≤ OptLp p V ∧ OptLp p V ≤ (Ldim V : ℝ) := by have hp0 : 0 < p := by linarith have h2p_pos : 0 < (2 : ℝ) ^ p := Real.rpow_pos_of_pos (by norm_num) p have hcoef_pos : 0 < 1 / (2 : ℝ) ^ p := by positivity induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn constructor · -- Lower bound: (1 / 2^p) * Ldim V ≤ OptLp p V <=> Ldim V ≤ 2^p * OptLp p V by_cases hV : V.card ≤ 1 · rw [Ldim_eq_zero_of_card_le_one hV]; simp [OptLp_nonneg hp0] · -- Show every pair (y₁, y₂) in Ldim step is bounded by 2^p * OptLp p V have hstep : ∀ x : α, 2 ≤ (labels V x).card → ∀ y₁ ∈ labels V x, ∀ y₂ ∈ labels V x, ((if y₁ = y₂ then Ldim (restrict V x y₁) else max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1)) : ℕ) : ℝ) ≤ 2 ^ p * OptLp p V := by intro x hsp y₁ hy₁ y₂ hy₂ have hbin1 : ∀ h ∈ restrict V x y₁, ∀ z, h z = 0 ∨ h z = 1 := fun h hh => hbin h (restrict_subset V x y₁ hh) have hbin2 : ∀ h ∈ restrict V x y₂, ∀ z, h z = 0 ∨ h z = 1 := fun h hh => hbin h (restrict_subset V x y₂ hh) have ih1 := (ih _ (card_restrict_lt_of_two_labels hsp y₁) hbin1 rfl).1 have ih2 := (ih _ (card_restrict_lt_of_two_labels hsp y₂) hbin2 rfl).1 split_ifs with heq · have hle : OptLp p (restrict V x y₁) ≤ OptLp p V := le_trans (le_lpVal_of_mem hp0 hy₁ (fun y => OptLp p (restrict V x y))) (OptLp_ge_lpVal p V x hsp) have h1 : (Ldim (restrict V x y₁) : ℝ) ≤ 2 ^ p * OptLp p (restrict V x y₁) := by have := mul_le_mul_of_nonneg_left ih1 (le_of_lt h2p_pos) rw [← mul_assoc, mul_one_div_cancel (ne_of_gt h2p_pos), one_mul] at this exact this nlinarith · -- y₁ ≠ y₂ and both ∈ {0, 1}, so |y₁ - y₂| = 1! have hd1 : |y₁ - y₂| = 1 := by rw [labels, Finset.mem_image] at hy₁ hy₂ rcases hy₁ with ⟨h₁, hh₁, rfl⟩; rcases hy₂ with ⟨h₂, hh₂, rfl⟩ rcases hbin h₁ hh₁ x with h1 | h1 <;> rcases hbin h₂ hh₂ x with h2 | h2 · exact absurd (h1.trans h2.symm) heq · rw [h1, h2]; norm_num · rw [h1, h2]; norm_num · exact absurd (h1.trans h2.symm) heq set d₁ := Ldim (restrict V x y₁) set d₂ := Ldim (restrict V x y₂) have hpair_ge : lpPair p y₁ y₂ ((1 / 2 ^ p) * (d₁ : ℝ)) ((1 / 2 ^ p) * (d₂ : ℝ)) ≤ OptLp p V := le_trans (lpPair_mono_v hp0 ih1 ih2) (OptLp_ge_lpPair p V x hy₁ hy₂ heq) -- Show (1/2^p) * max d₁ (max d₂ (min d₁ d₂ + 1)) ≤ lpPair p y₁ y₂ ((1/2^p)*d₁) ((1/2^p)*d₂)! have hnat_bound : (1 / 2 ^ p) * ((max d₁ (max d₂ (min d₁ d₂ + 1)) : ℕ) : ℝ) ≤ lpPair p y₁ y₂ ((1 / 2 ^ p) * (d₁ : ℝ)) ((1 / 2 ^ p) * (d₂ : ℝ)) := by by_cases h12 : d₁ = d₂ · rw [h12, min_self, max_eq_right (Nat.le_succ d₂), max_eq_right (Nat.le_succ d₂)] have hhalf_p : (1 / 2 : ℝ) ^ p = 1 / 2 ^ p := by rw [one_div, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2), one_div] rw [lpPair_eq_const hp0, hd1, hhalf_p] push_cast; ring_nf; exact le_rfl · have hmax_eq : max d₁ (max d₂ (min d₁ d₂ + 1)) = max d₁ d₂ := by omega rw [hmax_eq] rcases le_total d₁ d₂ with hle | hge · rw [max_eq_right hle] exact le_trans (le_max_right _ _) (max_le_lpPair hp0) · rw [max_eq_left hge] exact le_trans (le_max_left _ _) (max_le_lpPair hp0) have hfinal := le_trans hnat_bound hpair_ge have := mul_le_mul_of_nonneg_left hfinal (le_of_lt h2p_pos) rw [← mul_assoc, mul_one_div_cancel (ne_of_gt h2p_pos), one_mul] at this exact this -- Extract Ldim V ≤ 2^p * OptLp p V directly from Ldim's unfolding! conv_lhs => rw [Ldim, if_neg hV] dsimp only split_ifs with hs · set splits := Finset.univ.filter fun x : α => 2 ≤ (labels V x).card obtain ⟨⟨x, hx⟩, _, hxeq⟩ := Finset.exists_mem_eq_sup' hs.attach (fun z : {x // x ∈ splits} => ldimStep (labels V z.1) fun y => Ldim (restrict V z.1 y)) rw [hxeq] have hsp := (Finset.mem_filter.mp hx).2 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [ldimStep, dif_pos hS] obtain ⟨y₁, hy₁, hy1eq⟩ := Finset.exists_mem_eq_sup' hS (fun y₁ => (labels V x).sup' hS fun y₂ => if y₁ = y₂ then Ldim (restrict V x y₁) else max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1))) rw [hy1eq] obtain ⟨y₂, hy₂, hy2eq⟩ := Finset.exists_mem_eq_sup' hS (fun y₂ => if y₁ = y₂ then Ldim (restrict V x y₁) else max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1))) rw [hy2eq] have hgoal := hstep x hsp y₁ hy₁ y₂ hy₂ have := mul_le_mul_of_nonneg_left hgoal (le_of_lt hcoef_pos) rw [← mul_assoc, one_div_mul_cancel (ne_of_gt h2p_pos), one_mul] at this exact this · simp [OptLp_nonneg hp0] · -- Upper bound: OptLp p V ≤ Ldim V refine OptLp_le_of_forall_x p V (Nat.cast_nonneg _) fun x hsp => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ have hbin1 : ∀ h ∈ restrict V x y₁, ∀ z, h z = 0 ∨ h z = 1 := fun h hh => hbin h (restrict_subset V x y₁ hh) have hbin2 : ∀ h ∈ restrict V x y₂, ∀ z, h z = 0 ∨ h z = 1 := fun h hh => hbin h (restrict_subset V x y₂ hh) have ih1 := (ih _ (card_restrict_lt_of_two_labels hsp y₁) hbin1 rfl).2 have ih2 := (ih _ (card_restrict_lt_of_two_labels hsp y₂) hbin2 rfl).2 by_cases heq : y₁ = y₂ · subst heq rw [lpPair_self hp0] have h1 : (Ldim (restrict V x y₁) : ℝ) ≤ (Ldim V : ℝ) := 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⟩ exact_mod_cast le_trans (le_max_left _ _) (Ldim_ge_pair V x hy₁ hy' hne.symm) linarith · have hd1 : |y₁ - y₂| ≤ 1 := by rw [labels, Finset.mem_image] at hy₁ hy₂ rcases hy₁ with ⟨h₁, hh₁, rfl⟩; rcases hy₂ with ⟨h₂, hh₂, rfl⟩ rcases hbin h₁ hh₁ x with h1 | h1 <;> rcases hbin h₂ hh₂ x with h2 | h2 <;> simp [h1, h2] have hstep_le : lpPair p y₁ y₂ (Ldim (restrict V x y₁) : ℝ) (Ldim (restrict V x y₂) : ℝ) ≤ ((max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1)) : ℕ) : ℝ) := by -- Use lpPair_anti_p (p ≥ 1) + lpPair_one_eq! have hle1 := lpPair_anti_p (by norm_num : (0 : ℝ) < 1) hp hd1 (v₁ := (Ldim (restrict V x y₁) : ℝ)) (v₂ := (Ldim (restrict V x y₂) : ℝ)) rw [lpPair_one_eq] at hle1 refine le_trans hle1 ?_ set d₁ := Ldim (restrict V x y₁) set d₂ := Ldim (restrict V x y₂) have h1 : (d₁ : ℝ) ≤ ((max d₁ (max d₂ (min d₁ d₂ + 1)) : ℕ) : ℝ) := by exact_mod_cast le_max_left _ _ have h2 : (d₂ : ℝ) ≤ ((max d₁ (max d₂ (min d₁ d₂ + 1)) : ℕ) : ℝ) := by exact_mod_cast le_trans (le_max_left _ _) (le_max_right _ _) have h3 : ((d₁ : ℝ) + (d₂ : ℝ) + 1) / 2 ≤ ((max d₁ (max d₂ (min d₁ d₂ + 1)) : ℕ) : ℝ) := by have hnat : d₁ + d₂ + 1 ≤ 2 * max d₁ (max d₂ (min d₁ d₂ + 1)) := by omega have hreal : (d₁ : ℝ) + (d₂ : ℝ) + 1 ≤ 2 * ((max d₁ (max d₂ (min d₁ d₂ + 1)) : ℕ) : ℝ) := by exact_mod_cast hnat linarith exact max_le (max_le h1 h2) (by linarith) have hL_ge : ((max (Ldim (restrict V x y₁)) (max (Ldim (restrict V x y₂)) (min (Ldim (restrict V x y₁)) (Ldim (restrict V x y₂)) + 1)) : ℕ) : ℝ) ≤ (Ldim V : ℝ) := by exact_mod_cast Ldim_ge_pair V x hy₁ hy₂ heq exact le_trans (lpPair_mono_v hp0 ih1 ih2) (le_trans hstep_le hL_ge) /-- **1-Step Binary Exponent-Scaling Lemma**: for `1 ≤ p ≤ q`, `|y₁ - y₂| = 1`, and ANY `v₁, v₂ : ℝ`, `2^(p - q) * lpPair p y₁ y₂ v₁ v₂ ≤ lpPair q y₁ y₂ (2^(p - q) * v₁) (2^(p - q) * v₂)`! -/ lemma lpPair_binary_exponent_scaling {p q y₁ y₂ v₁ v₂ : ℝ} (hp : 1 ≤ p) (hpq : p ≤ q) (hd : |y₁ - y₂| = 1) : 2 ^ (p - q) * lpPair p y₁ y₂ v₁ v₂ ≤ lpPair q y₁ y₂ (2 ^ (p - q) * v₁) (2 ^ (p - q) * v₂) := by have hp0 : 0 < p := by linarith have hq0 : 0 < q := by linarith set α := (2 : ℝ) ^ (p - q) have hα_pos : 0 < α := Real.rpow_pos_of_pos (by norm_num) _ set T := lpPair q y₁ y₂ (α * v₁) (α * v₂) have hle_div : lpPair p y₁ y₂ v₁ v₂ ≤ T / α := by rw [lpPair_le_iff hp0] rcases lpPair_mem_feas hq0 (y₁ := y₁) (y₂ := y₂) (v₁ := α * v₁) (v₂ := α * v₂) with ⟨hm, hr⟩ have hT1 : 0 ≤ T - α * v₁ := sub_nonneg.mpr (le_trans (le_max_left _ _) hm) have hT2 : 0 ≤ T - α * v₂ := sub_nonneg.mpr (le_trans (le_max_right _ _) hm) have hm' : max v₁ v₂ ≤ T / α := by rw [le_div_iff₀ hα_pos] rcases le_total v₁ v₂ with h | h · rw [max_eq_right h, mul_comm]; exact le_trans (le_max_right _ _) hm · rw [max_eq_left h, mul_comm]; exact le_trans (le_max_left _ _) hm refine ⟨hm', ?_⟩ rw [hd] at hr ⊢ -- Let a = (T - α v₁)^(1/q) ≥ 0, b = (T - α v₂)^(1/q) ≥ 0, with a + b ≥ 1! -- Then (T/α - v₁)^(1/p) = ((T - α v₁)/α)^(1/p) = (a^q / 2^(p-q))^(1/p) = 2^(q/p - 1) * a^(q/p)! -- By convexity of x ↦ x^(q/p) (since q/p ≥ 1), -- (a^(q/p) + b^(q/p)) / 2 ≥ ((a + b) / 2)^(q/p) ≥ (1 / 2)^(q/p) = 2^(-q/p)! -- Multiply by 2 * 2^(q/p - 1) = 2^(q/p): -- 2^(q/p - 1) * (a^(q/p) + b^(q/p)) ≥ 1 !! set a := (T - α * v₁) ^ (1 / q) set b := (T - α * v₂) ^ (1 / q) have ha_nn : 0 ≤ a := Real.rpow_nonneg hT1 _ have hb_nn : 0 ≤ b := Real.rpow_nonneg hT2 _ have ha_q : a ^ q = T - α * v₁ := by dsimp only [a]; rw [← Real.rpow_mul hT1, one_div_mul_cancel (ne_of_gt hq0), Real.rpow_one] have hb_q : b ^ q = T - α * v₂ := by dsimp only [b]; rw [← Real.rpow_mul hT2, one_div_mul_cancel (ne_of_gt hq0), Real.rpow_one] have hqp_ge1 : 1 ≤ q / p := (one_le_div hp0).mpr hpq have hα_inv_p : (α⁻¹) ^ (1 / p) = (2 : ℝ) ^ (q / p - 1) := by dsimp only [α] rw [← Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2), ← Real.rpow_mul (by norm_num : (0 : ℝ) ≤ 2)] congr 1; field_simp [ne_of_gt hp0]; ring have hterm : ∀ (x r : ℝ), 0 ≤ x → r = x ^ (1 / q) → (x / α) ^ (1 / p) = (2 : ℝ) ^ (q / p - 1) * r ^ (q / p) := by intro x r hx hr_eq rw [div_eq_mul_inv, Real.mul_rpow hx (le_of_lt (inv_pos.mpr hα_pos)), hα_inv_p, mul_comm] congr 1 rw [hr_eq, ← Real.rpow_mul hx] congr 1; field_simp [ne_of_gt hq0, ne_of_gt hp0] have h1_rew : T / α - v₁ = (T - α * v₁) / α := by field_simp [ne_of_gt hα_pos] have h2_rew : T / α - v₂ = (T - α * v₂) / α := by field_simp [ne_of_gt hα_pos] rw [h1_rew, h2_rew, hterm (T - α * v₁) a hT1 rfl, hterm (T - α * v₂) b hT2 rfl, ← mul_add] have hconv : ConvexOn ℝ (Set.Ici (0 : ℝ)) (fun z : ℝ => z ^ (q / p)) := convexOn_rpow hqp_ge1 have hjensen := hconv.2 (Set.mem_Ici.mpr ha_nn) (Set.mem_Ici.mpr hb_nn) (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num) simp only [smul_eq_mul] at hjensen have hab_half : (1 / 2 : ℝ) ≤ 1 / 2 * a + 1 / 2 * b := by linarith have hpow_half : (1 / 2 : ℝ) ^ (q / p) ≤ (1 / 2 * a + 1 / 2 * b) ^ (q / p) := Real.rpow_le_rpow (by norm_num) hab_half (by positivity) have hhalf_eq : (1 / 2 : ℝ) ^ (q / p) = (2 : ℝ) ^ (-(q / p)) := by rw [one_div, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2), Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2)] have hsum_ge : 2 * (2 : ℝ) ^ (-(q / p)) ≤ a ^ (q / p) + b ^ (q / p) := by rw [← hhalf_eq]; linarith have hmul_ge := mul_le_mul_of_nonneg_left hsum_ge (Real.rpow_nonneg (by norm_num : (0 : ℝ) ≤ 2) (q / p - 1)) have hprod_one : (2 : ℝ) ^ (q / p - 1) * (2 * (2 : ℝ) ^ (-(q / p))) = 1 := by calc (2 : ℝ) ^ (q / p - 1) * (2 * (2 : ℝ) ^ (-(q / p))) = ((2 : ℝ) ^ (q / p - 1) * (2 : ℝ) ^ (1 : ℝ)) * (2 : ℝ) ^ (-(q / p)) := by rw [Real.rpow_one]; ring _ = (2 : ℝ) ^ (q / p - 1 + 1 + -(q / p)) := by rw [← Real.rpow_add (by norm_num : (0 : ℝ) < 2), ← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] _ = (2 : ℝ) ^ (0 : ℝ) := by congr 1; ring _ = 1 := Real.rpow_zero 2 linarith exact (le_div_iff₀ hα_pos).mp hle_div |> fun h => by linarith /-- **Exact Binary ℓ_p vs. ℓ_q Exponent-Scaling Sandwich**: for EVERY `{0, 1}`-valued concept class `V` and EVERY `1 ≤ p ≤ q`: `2^(p - q) * OptLp p V ≤ OptLp q V ≤ OptLp p V`! In particular, for squared vs. absolute loss (`p = 1, q = 2`): `(1 / 2) * OptLp 1 V ≤ OptLp 2 V ≤ OptLp 1 V`! -/ theorem OptLp_binary_vs_OptLp {α : Type*} [Fintype α] [DecidableEq α] {p q : ℝ} (hp : 1 ≤ p) (hpq : p ≤ q) {V : Finset (α → ℝ)} (hbin : ∀ h ∈ V, ∀ x : α, h x = 0 ∨ h x = 1) : 2 ^ (p - q) * OptLp p V ≤ OptLp q V ∧ OptLp q V ≤ OptLp p V := by have hp0 : 0 < p := by linarith have hq0 : 0 < q := by linarith have hdiam : ∀ h₁ ∈ V, ∀ h₂ ∈ V, ∀ x : α, |h₁ x - h₂ x| ≤ 1 := by intro h₁ hh₁ h₂ hh₂ x rcases hbin h₁ hh₁ x with h1 | h1 <;> rcases hbin h₂ hh₂ x with h2 | h2 <;> simp [h1, h2] refine ⟨?_, OptLp_anti_p hp0 hpq hdiam⟩ clear hdiam set α := (2 : ℝ) ^ (p - q) have hα_pos : 0 < α := Real.rpow_pos_of_pos (by norm_num) _ induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hle : OptLp p V ≤ OptLp q V / α := by refine OptLp_le_of_forall_x p V (div_nonneg (OptLp_nonneg hq0 V) (le_of_lt hα_pos)) fun x hsp => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ have hbin1 : ∀ h ∈ restrict V x y₁, ∀ z, h z = 0 ∨ h z = 1 := fun h hh => hbin h (restrict_subset V x y₁ hh) have hbin2 : ∀ h ∈ restrict V x y₂, ∀ z, h z = 0 ∨ h z = 1 := fun h hh => hbin h (restrict_subset V x y₂ hh) have ih1 := ih _ (card_restrict_lt_of_two_labels hsp y₁) hbin1 rfl have ih2 := ih _ (card_restrict_lt_of_two_labels hsp y₂) hbin2 rfl rw [le_div_iff₀ hα_pos, mul_comm] by_cases heq : y₁ = y₂ · subst heq rw [lpPair_self hp0] exact le_trans ih1 (le_trans (le_lpVal_of_mem hq0 hy₁ (fun y => OptLp q (restrict V x y))) (OptLp_ge_lpVal q V x hsp)) · have hd1 : |y₁ - y₂| = 1 := by rw [labels, Finset.mem_image] at hy₁ hy₂ rcases hy₁ with ⟨h₁, hh₁, rfl⟩; rcases hy₂ with ⟨h₂, hh₂, rfl⟩ rcases hbin h₁ hh₁ x with h1 | h1 <;> rcases hbin h₂ hh₂ x with h2 | h2 · exact absurd (h1.trans h2.symm) heq · rw [h1, h2]; norm_num · rw [h1, h2]; norm_num · exact absurd (h1.trans h2.symm) heq exact le_trans (lpPair_binary_exponent_scaling hp hpq hd1) (le_trans (lpPair_mono_v hq0 ih1 ih2) (OptLp_ge_lpPair q V x hy₁ hy₂ heq)) exact (le_div_iff₀ hα_pos).mp hle |> fun h => by linarith /-- **Squared vs. Absolute Loss Exact Binary Sandwich**: `(1 / 2) * OptLp 1 V ≤ OptLp 2 V ≤ OptLp 1 V` for every `{0, 1}`-valued concept class `V`. -/ theorem OptLp_two_vs_one_binary {α : Type*} [Fintype α] [DecidableEq α] {V : Finset (α → ℝ)} (hbin : ∀ h ∈ V, ∀ x : α, h x = 0 ∨ h x = 1) : (1 / 2 : ℝ) * OptLp 1 V ≤ OptLp 2 V ∧ OptLp 2 V ≤ OptLp 1 V := by have h := OptLp_binary_vs_OptLp (p := 1) (q := 2) le_rfl (by norm_num) hbin have hpow : (2 : ℝ) ^ ((1 : ℝ) - 2) = 1 / 2 := by rw [show (1 : ℝ) - 2 = -1 by norm_num, Real.rpow_neg_one, one_div] rwa [hpow] at h /-! ## Part 6: Disjoint-Domain Product Additivity & Exact Hypercube / Grid-Cube Extremizers -/ /-- Disjoint-domain product of two finite real-valued concept classes `V₁, V₂`. -/ def prodClass {α₁ α₂ : Type*} [Fintype α₁] [Fintype α₂] [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 α₂] (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 α₂] {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 α₂] {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 α₂] (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 α₂] (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 Realizable Online ℓ_p Regression**: For EVERY `p > 0` and nonempty `V₁, V₂`, `OptLp p (prodClass V₁ V₂) = OptLp p V₁ + OptLp p V₂`! -/ theorem OptLp_prod_eq_add {α₁ α₂ : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] {p : ℝ} (hp : 0 < p) {V₁ : Finset (α₁ → ℝ)} {V₂ : Finset (α₂ → ℝ)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : OptLp p (prodClass V₁ V₂) = OptLp p V₁ + OptLp p 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 OptLp_le_of_forall_x p (prodClass V₁ V₂) (add_nonneg (OptLp_nonneg hp V₁) (OptLp_nonneg hp V₂)) fun x hsplit => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl hV₂] at hsplit ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, OptLp p (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = OptLp p (restrict V₁ x₁ y) + OptLp p V₂ := by intro y hy rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsplit y exact ih _ (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [lpVal_congr hp hcongr, lpVal_add_const hp hS] linarith [OptLp_ge_lpVal p V₁ x₁ hsplit] | inr x₂ => rw [labels_prodClass_inr hV₁] at hsplit ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₂ x₂, OptLp p (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = OptLp p (restrict V₂ x₂ y) + OptLp p V₁ := by intro y hy rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsplit y rw [ih _ (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl, add_comm] rw [lpVal_congr hp hcongr, lpVal_add_const hp hS] linarith [OptLp_ge_lpVal p V₂ x₂ hsplit] · by_cases h1 : V₁.card ≤ 1 · rw [OptLp_eq_zero_of_card_le_one p h1, zero_add] refine OptLp_le_of_forall_x p V₂ (OptLp_nonneg hp _) 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₂, OptLp p (restrict V₂ x₂ y) = OptLp p (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := by intro y hy 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, OptLp_eq_zero_of_card_le_one p h1, zero_add] rw [lpVal_congr hp hcongr, ← labels_prodClass_inr hV₁] exact OptLp_ge_lpVal p (prodClass V₁ V₂) (Sum.inr x₂) hsp · have hle1 : OptLp p V₁ ≤ OptLp p (prodClass V₁ V₂) - OptLp p V₂ := by refine OptLp_le_of_forall_x p V₁ ?_ fun x₁ hsp₁ => ?_ · -- Show OptLp p V₂ ≤ OptLp p (prodClass V₁ V₂) have hle2 : OptLp p V₂ ≤ OptLp p (prodClass V₁ V₂) := by refine OptLp_le_of_forall_x p V₂ (OptLp_nonneg hp _) 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₂, OptLp p (restrict V₂ x₂ y) ≤ OptLp p (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := by intro y hy 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 [OptLp_nonneg hp V₁] calc lpVal p (labels V₂ x₂) (fun y => OptLp p (restrict V₂ x₂ y)) ≤ lpVal p (labels V₂ x₂) (fun y => OptLp p (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) := lpVal_mono_v hp hmono _ = lpVal p (labels (prodClass V₁ V₂) (Sum.inr x₂)) (fun y => OptLp p (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) := by rw [labels_prodClass_inr hV₁] _ ≤ OptLp p (prodClass V₁ V₂) := OptLp_ge_lpVal p (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₁, OptLp p (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = OptLp p (restrict V₁ x₁ y) + OptLp p V₂ := by intro y hy 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 := OptLp_ge_lpVal p (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl hV₂, lpVal_congr hp hcongr, lpVal_add_const hp hS] at hge linarith linarith /-- Single-bit `{0, 1}` concept class on `Unit`. -/ def onePointBool : Finset (Unit → ℝ) := {fun _ => 0, fun _ => 1} lemma onePointBool_card : onePointBool.card = 2 := by rw [onePointBool, Finset.card_pair] intro h; have := congrFun h (); norm_num at this lemma labels_onePointBool : labels onePointBool () = ({0, 1} : Finset ℝ) := by ext y; simp [labels, onePointBool] lemma restrict_onePointBool_card (y : ℝ) : (restrict onePointBool () y).card ≤ 1 := by by_cases h0 : y = 0 · subst h0 have hsub : restrict onePointBool () 0 ⊆ {fun _ => 0} := by intro f hf; rw [restrict, Finset.mem_filter] at hf simp only [onePointBool, Finset.mem_insert, Finset.mem_singleton] at hf rcases hf.1 with rfl | rfl · simp · exfalso; norm_num at hf exact le_trans (Finset.card_le_card hsub) (by simp) · have hsub : restrict onePointBool () y ⊆ {fun _ => 1} := by intro f hf; rw [restrict, Finset.mem_filter] at hf simp only [onePointBool, Finset.mem_insert, Finset.mem_singleton] at hf rcases hf.1 with rfl | rfl · exact absurd hf.2.symm h0 · simp exact le_trans (Finset.card_le_card hsub) (by simp) /-- Exact 1-bit minimax ℓ_p loss: `OptLp p onePointBool = 1 / 2^p`. -/ theorem OptLp_onePointBool {p : ℝ} (hp : 0 < p) : OptLp p onePointBool = 1 / 2 ^ p := by have hsp : 2 ≤ (labels onePointBool ()).card := by rw [labels_onePointBool, Finset.card_pair (by norm_num)] have hzero : ∀ y ∈ labels onePointBool (), OptLp p (restrict onePointBool () y) = 0 := fun y _ => OptLp_eq_zero_of_card_le_one p (restrict_onePointBool_card y) have hval : lpVal p (labels onePointBool ()) (fun y => OptLp p (restrict onePointBool () y)) = 1 / 2 ^ p := by rw [lpVal_congr hp hzero, labels_onePointBool, lpVal_binary hp, lpPair_eq_const hp] simp only [zero_add, zero_sub, abs_neg, abs_one, one_div, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2)] apply le_antisymm · refine OptLp_le_of_forall_x p onePointBool (by positivity) fun x _ => ?_ cases x; rw [hval] · rw [← hval]; exact OptLp_ge_lpVal p onePointBool () 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) /-- The `d`-dimensional Boolean hypercube `{0, 1}^d` as a real-valued concept class. -/ def boolCube : ∀ d : ℕ, Finset (CubeDom d → ℝ) | 0 => {Empty.elim} | d + 1 => prodClass onePointBool (boolCube d) lemma boolCube_card : ∀ d : ℕ, (boolCube d).card = 2 ^ d | 0 => by rw [boolCube, Finset.card_singleton, pow_zero] | d + 1 => by rw [boolCube, prodClass_card, onePointBool_card, boolCube_card d, pow_succ'] lemma boolCube_nonempty (d : ℕ) : (boolCube d).Nonempty := Finset.card_pos.mp (by rw [boolCube_card]; positivity) /-- **Exact Boolean Hypercube Minimax Theorem**: For EVERY `p > 0` and EVERY `d : ℕ`, `OptLp p (boolCube d) = d / 2^p`. -/ theorem OptLp_boolCube_exact {p : ℝ} (hp : 0 < p) : ∀ d : ℕ, OptLp p (boolCube d) = (d : ℝ) / 2 ^ p | 0 => by rw [OptLp_eq_zero_of_card_le_one p (by rw [boolCube_card]; simp)]; simp | d + 1 => by rw [boolCube, OptLp_prod_eq_add hp (Finset.card_pos.mp (by rw [onePointBool_card]; omega)) (boolCube_nonempty d), OptLp_onePointBool hp, OptLp_boolCube_exact hp d] push_cast; ring /-- **Exact Sharpness of the Subcritical/Critical Halving Law on `{0, 1}^d`**: For EVERY `p > 0` and EVERY `d : ℕ`, `OptLp p (boolCube d) = (1 / (2^p * log 2)) * log |boolCube d|`! -/ theorem OptLp_boolCube_achieves_hypercube_law {p : ℝ} (hp : 0 < p) (d : ℕ) : OptLp p (boolCube d) = (1 / (2 ^ p * Real.log 2)) * Real.log ((boolCube d).card : ℝ) := by rw [OptLp_boolCube_exact hp d, boolCube_card, Nat.cast_pow, Nat.cast_ofNat, Real.log_pow] have hlog2 : Real.log 2 ≠ 0 := ne_of_gt (Real.log_pos (by norm_num)) have h2p : (2 : ℝ) ^ p ≠ 0 := ne_of_gt (Real.rpow_pos_of_pos (by norm_num) p) field_simp /-- Single-coordinate `(m + 1)`-level uniform grid `{0, 1/m, 2/m, ..., 1}` on `Unit`. -/ def onePointGrid (m : ℕ) : Finset (Unit → ℝ) := (Finset.range (m + 1)).image fun (i : ℕ) => (fun _ : Unit => (i : ℝ) / (m : ℝ)) lemma onePointGrid_card {m : ℕ} (hm : 1 ≤ m) : (onePointGrid m).card = m + 1 := by rw [onePointGrid, Finset.card_image_of_injOn] · simp · intro i _ j _ h have hfun := congrFun h () have hm_ne : (m : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (by omega) have hcast : (i : ℝ) = (j : ℝ) := (div_left_inj' hm_ne).mp hfun exact Nat.cast_injective hcast /-- **Grid Resolution Invariance (`OptLp p (onePointGrid m) = 1 / 2^p`)**: refining the label grid `{0, 1/m, ..., 1}` to arbitrarily fine resolution `m ≥ 1` does NOT change the minimax ℓ_p loss at all — it remains identically `1 / 2^p`! -/ theorem OptLp_onePointGrid {p : ℝ} (hp : 0 < p) {m : ℕ} (hm : 1 ≤ m) : OptLp p (onePointGrid m) = 1 / 2 ^ p := by have hm_pos : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr (by omega) have h0_mem : (0 : ℝ) ∈ labels (onePointGrid m) () := by rw [labels, Finset.mem_image] refine ⟨fun _ => (0 : ℕ) / (m : ℝ), ?_, by simp⟩ rw [onePointGrid, Finset.mem_image] exact ⟨0, Finset.mem_range.mpr (by omega), rfl⟩ have h1_mem : (1 : ℝ) ∈ labels (onePointGrid m) () := by rw [labels, Finset.mem_image] refine ⟨fun _ => (m : ℝ) / (m : ℝ), ?_, by simp [div_self (ne_of_gt hm_pos)]⟩ rw [onePointGrid, Finset.mem_image] exact ⟨m, Finset.mem_range.mpr (by omega), rfl⟩ have hrest_le1 : ∀ y : ℝ, (restrict (onePointGrid m) () y).card ≤ 1 := by intro y refine Finset.card_le_one.mpr fun f₁ hf₁ f₂ hf₂ => ?_ rw [restrict, Finset.mem_filter] at hf₁ hf₂ ext u; cases u; exact hf₁.2.trans hf₂.2.symm have hzero : ∀ y ∈ labels (onePointGrid m) (), OptLp p (restrict (onePointGrid m) () y) = 0 := fun y _ => OptLp_eq_zero_of_card_le_one p (hrest_le1 y) have hdiam : ∀ y₁ ∈ labels (onePointGrid m) (), ∀ y₂ ∈ labels (onePointGrid m) (), |y₁ - y₂| ≤ 1 := by intro y₁ hy₁ y₂ hy₂ rw [labels, Finset.mem_image] at hy₁ hy₂ rcases hy₁ with ⟨_, h1, rfl⟩; rcases hy₂ with ⟨_, h2, rfl⟩ rw [onePointGrid, Finset.mem_image] at h1 h2 rcases h1 with ⟨i₁, hi₁, rfl⟩; rcases h2 with ⟨i₂, hi₂, rfl⟩ rw [Finset.mem_range] at hi₁ hi₂ have h1_0 : 0 ≤ (i₁ : ℝ) / (m : ℝ) := by positivity have h1_1 : (i₁ : ℝ) / (m : ℝ) ≤ 1 := (div_le_one hm_pos).mpr (by exact_mod_cast Nat.lt_succ_iff.mp hi₁) have h2_0 : 0 ≤ (i₂ : ℝ) / (m : ℝ) := by positivity have h2_1 : (i₂ : ℝ) / (m : ℝ) ≤ 1 := (div_le_one hm_pos).mpr (by exact_mod_cast Nat.lt_succ_iff.mp hi₂) rw [abs_le]; exact ⟨by linarith, by linarith⟩ apply le_antisymm · refine OptLp_le_of_forall_x p (onePointGrid m) (by positivity) fun x hsp => ?_ cases x have hS : (labels (onePointGrid m) ()).Nonempty := ⟨0, h0_mem⟩ rw [lpVal_congr hp hzero, lpVal_le_iff_pairs hS] intro y₁ hy₁ y₂ hy₂ rw [lpPair_eq_const hp, zero_add] have hhalf_p : (1 / 2 : ℝ) ^ p = 1 / 2 ^ p := by rw [one_div, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2), one_div] rw [← hhalf_p] exact Real.rpow_le_rpow (by positivity) (by linarith [hdiam y₁ hy₁ y₂ hy₂]) (le_of_lt hp) · have hge := OptLp_ge_lpPair p (onePointGrid m) () h0_mem h1_mem (by norm_num) rw [hzero 0 h0_mem, hzero 1 h1_mem, lpPair_eq_const hp] at hge simpa [one_div, Real.inv_rpow (by norm_num : (0 : ℝ) ≤ 2)] using hge /-- `d`-dimensional `(m + 1)`-level real grid cube `{0, 1/m, ..., 1}^d`. -/ def gridCube (m : ℕ) : ∀ d : ℕ, Finset (CubeDom d → ℝ) | 0 => {Empty.elim} | d + 1 => prodClass (onePointGrid m) (gridCube m d) lemma gridCube_card {m : ℕ} (hm : 1 ≤ m) : ∀ d : ℕ, (gridCube m d).card = (m + 1) ^ d | 0 => by rw [gridCube, Finset.card_singleton, pow_zero] | d + 1 => by rw [gridCube, prodClass_card, onePointGrid_card hm, gridCube_card hm d, pow_succ'] /-- Exact real-valued `d`-dimensional grid cube minimax loss: `OptLp p (gridCube m d) = d / 2^p`. -/ theorem OptLp_gridCube_exact {p : ℝ} (hp : 0 < p) {m : ℕ} (hm : 1 ≤ m) : ∀ d : ℕ, OptLp p (gridCube m d) = (d : ℝ) / 2 ^ p | 0 => by rw [OptLp_eq_zero_of_card_le_one p (by rw [gridCube_card hm]; simp)]; simp | d + 1 => by rw [gridCube, OptLp_prod_eq_add hp (Finset.card_pos.mp (by rw [onePointGrid_card hm]; omega)) (Finset.card_pos.mp (by rw [gridCube_card hm]; positivity)), OptLp_onePointGrid hp hm, OptLp_gridCube_exact hp hm d] push_cast; ring /-! ## Part 7: 1D Threshold Classes & THE SUPERCRITICAL PHASE-TRANSITION REALIZABLE SEPARATION -/ /-- The `i`-th real-valued `{0, 1}` 1D threshold hypothesis on `Fin M`: `1` if `j < i`, else `0`. -/ def threshHyp (M i : ℕ) : Fin M → ℝ := fun j => if j.val < i then 1 else 0 /-- The 1D threshold interval class restricted to indices `i ∈ [lo, hi)`. -/ def threshInterval (M lo hi : ℕ) : Finset (Fin M → ℝ) := (Finset.Ico lo hi).image (threshHyp M) /-- The canonical 1D threshold concept class of size `N` on `Fin (N - 1)`. -/ def threshClass (N : ℕ) : Finset (Fin (N - 1) → ℝ) := threshInterval (N - 1) 0 N lemma threshHyp_injOn (M : ℕ) : Set.InjOn (threshHyp M) {i | i ≤ M} := by intro i₁ hi₁ i₂ hi₂ heq change i₁ ≤ M at hi₁ change i₂ ≤ M at hi₂ by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · have h := congrFun heq ⟨i₁, by omega⟩ simp [threshHyp, hlt] at h · have h := congrFun heq ⟨i₂, by omega⟩ simp [threshHyp, hgt] at h lemma threshInterval_card {M lo hi : ℕ} (hhi : hi ≤ M + 1) : (threshInterval M lo hi).card = hi - lo := by rw [threshInterval, Finset.card_image_of_injOn] · simp · intro i₁ hi₁ i₂ hi₂ heq have h1 : i₁ ≤ M := by have := (Finset.mem_Ico.mp hi₁).2; omega have h2 : i₂ ≤ M := by have := (Finset.mem_Ico.mp hi₂).2; omega exact threshHyp_injOn M h1 h2 heq lemma threshClass_card {N : ℕ} (hN : 1 ≤ N) : (threshClass N).card = N := by rw [threshClass, threshInterval_card (by omega)]; omega lemma threshInterval_restrict_zero {M lo mid hi : ℕ} (hlo : lo < mid) (hmid : mid < hi) (hhi : hi ≤ M + 1) : restrict (threshInterval M lo hi) ⟨mid - 1, by omega⟩ 0 = threshInterval M lo mid := by ext f simp only [restrict, threshInterval, Finset.mem_filter, Finset.mem_image, Finset.mem_Ico] constructor · rintro ⟨⟨i, ⟨h1, h2⟩, rfl⟩, hval⟩ refine ⟨i, ⟨h1, ?_⟩, rfl⟩ by_contra hge simp only [threshHyp] at hval rw [if_pos (by omega)] at hval norm_num at hval · rintro ⟨i, ⟨h1, h2⟩, rfl⟩ refine ⟨⟨i, ⟨h1, by omega⟩, rfl⟩, ?_⟩ simp only [threshHyp] rw [if_neg (by omega)] lemma threshInterval_restrict_one {M lo mid hi : ℕ} (hlo : lo < mid) (hmid : mid < hi) (hhi : hi ≤ M + 1) : restrict (threshInterval M lo hi) ⟨mid - 1, by omega⟩ 1 = threshInterval M mid hi := by ext f simp only [restrict, threshInterval, Finset.mem_filter, Finset.mem_image, Finset.mem_Ico] constructor · rintro ⟨⟨i, ⟨h1, h2⟩, rfl⟩, hval⟩ refine ⟨i, ⟨?_, h2⟩, rfl⟩ by_contra hlt simp only [threshHyp] at hval rw [if_neg (by omega)] at hval norm_num at hval · rintro ⟨i, ⟨h1, h2⟩, rfl⟩ refine ⟨⟨i, ⟨by omega, h2⟩, rfl⟩, ?_⟩ simp only [threshHyp] rw [if_pos (by omega)] lemma lpPair_ge_of_exact_radii {p T u : ℝ} (hp : 0 < p) (hu0 : 0 ≤ u) (hu1 : u ≤ 1) : T ≤ lpPair p 0 1 (T - u ^ p) (T - (1 - u) ^ p) := by by_contra hlt push Not at hlt rcases lpPair_mem_feas hp (y₁ := 0) (y₂ := 1) (v₁ := T - u ^ p) (v₂ := T - (1 - u) ^ p) with ⟨hm, hr⟩ set s := lpPair p 0 1 (T - u ^ p) (T - (1 - u) ^ p) have h1 : (s - (T - u ^ p)) ^ (1 / p) < u := by have hlt1 : s - (T - u ^ p) < u ^ p := by linarith have hpow := Real.rpow_lt_rpow (sub_nonneg.mpr (le_trans (le_max_left _ _) hm)) hlt1 (div_pos one_pos hp) rwa [← Real.rpow_mul hu0, mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] at hpow have h2 : (s - (T - (1 - u) ^ p)) ^ (1 / p) < 1 - u := by have hlt2 : s - (T - (1 - u) ^ p) < (1 - u) ^ p := by linarith have hpow := Real.rpow_lt_rpow (sub_nonneg.mpr (le_trans (le_max_right _ _) hm)) hlt2 (div_pos one_pos hp) rwa [← Real.rpow_mul (by linarith : 0 ≤ 1 - u), mul_one_div_cancel (ne_of_gt hp), Real.rpow_one] at hpow have habs : |(0 : ℝ) - 1| = 1 := by norm_num linarith /-- **Exact Reverse Exponential Criterion on 1D Thresholds**: Whenever `q₁ + q₂ < 1` for `q₁ = exp (-u^p / C)` and `q₂ = exp (-(1 - u)^p / C)` (`u ∈ (0, 1)`), every 1D threshold interval of size `n = hi - lo ≥ 1` satisfies: `C * log n - C * log N₀ ≤ OptLp p (threshInterval M lo hi)` where `N₀ = ⌈2 / (1 - q₁ - q₂)⌉ + 2`! -/ theorem OptLp_threshInterval_supercritical_lower {p C u : ℝ} (hp : 0 < p) (hC : 0 < C) (hu0 : 0 < u) (hu1 : u < 1) (hfail : Real.exp (-(u ^ p) / C) + Real.exp (-((1 - u) ^ p) / C) < 1) (M : ℕ) : let N₀ : ℕ := Nat.ceil (2 / (1 - Real.exp (-(u ^ p) / C) - Real.exp (-((1 - u) ^ p) / C))) + 2 ∀ lo hi : ℕ, lo < hi → hi ≤ M + 1 → C * Real.log ((hi - lo : ℕ) : ℝ) - C * Real.log (N₀ : ℝ) ≤ OptLp p (threshInterval M lo hi) := by set q₁ := Real.exp (-(u ^ p) / C) set q₂ := Real.exp (-((1 - u) ^ p) / C) have hq₁_pos : 0 < q₁ := Real.exp_pos _ have hq₂_pos : 0 < q₂ := Real.exp_pos _ have hgap : 0 < 1 - q₁ - q₂ := by linarith set N₀ : ℕ := Nat.ceil (2 / (1 - q₁ - q₂)) + 2 have hN₀_pos : (0 : ℝ) < (N₀ : ℝ) := Nat.cast_pos.mpr (by omega) have hN₀_bound : 2 / (1 - q₁ - q₂) ≤ (N₀ : ℝ) - 2 := by have h1 : 2 / (1 - q₁ - q₂) ≤ (Nat.ceil (2 / (1 - q₁ - q₂)) : ℝ) := Nat.le_ceil _ have h2 : (N₀ : ℝ) = (Nat.ceil (2 / (1 - q₁ - q₂)) : ℝ) + 2 := by dsimp only [N₀]; push_cast; ring linarith dsimp only intro lo hi hlo hhi induction hn : hi - lo using Nat.strong_induction_on generalizing lo hi with | h n ih => by_cases hle : n ≤ N₀ · have hlog_le : Real.log (n : ℝ) ≤ Real.log (N₀ : ℝ) := Real.log_le_log (Nat.cast_pos.mpr (by omega)) (by exact_mod_cast hle) have hnonpos : C * Real.log (n : ℝ) - C * Real.log (N₀ : ℝ) ≤ 0 := by nlinarith exact le_trans hnonpos (OptLp_nonneg hp _) · push Not at hle have hn_real : (N₀ : ℝ) < (n : ℝ) := by exact_mod_cast hle have hn_pos : (0 : ℝ) < (n : ℝ) := lt_trans hN₀_pos hn_real -- Choose integer split point a = ⌈q₁ * n⌉ so a ≥ q₁ * n AND n - a ≥ q₂ * n! set a : ℕ := Nat.ceil (q₁ * (n : ℝ)) have ha_ge : q₁ * (n : ℝ) ≤ (a : ℝ) := Nat.le_ceil _ have ha_pos : 1 ≤ a := by by_contra h0 have ha0 : a = 0 := by omega rw [ha0, Nat.cast_zero] at ha_ge nlinarith [mul_pos hq₁_pos hn_pos] have ha_lt : (a : ℝ) < q₁ * (n : ℝ) + 1 := Nat.ceil_lt_add_one (by positivity) have hgap_n : 2 < (1 - q₁ - q₂) * (n : ℝ) := by have h1 : 2 ≤ (1 - q₁ - q₂) * ((N₀ : ℝ) - 2) := by have := (div_le_iff₀ hgap).mp hN₀_bound; linarith nlinarith have hna_ge_real : q₂ * (n : ℝ) ≤ (n : ℝ) - (a : ℝ) := by nlinarith have ha_lt_n : a < n := by have hpos_diff : (0 : ℝ) < (n : ℝ) - (a : ℝ) := lt_of_lt_of_le (mul_pos hq₂_pos hn_pos) hna_ge_real have : (a : ℝ) < (n : ℝ) := by linarith exact_mod_cast this set mid := lo + a have hlo_mid : lo < mid := by omega have hmid_hi : mid < hi := by omega -- Query x = ⟨mid - 1, _⟩ splits threshInterval M lo hi into [lo, mid) (label 0) and [mid, hi) (label 1)! have h0_mem : (0 : ℝ) ∈ labels (threshInterval M lo hi) ⟨mid - 1, by omega⟩ := by rw [← restrict_nonempty_iff, threshInterval_restrict_zero hlo_mid hmid_hi hhi] exact Finset.card_pos.mp (by rw [threshInterval_card (by omega)]; omega) have h1_mem : (1 : ℝ) ∈ labels (threshInterval M lo hi) ⟨mid - 1, by omega⟩ := by rw [← restrict_nonempty_iff, threshInterval_restrict_one hlo_mid hmid_hi hhi] exact Finset.card_pos.mp (by rw [threshInterval_card hhi]; omega) have hge_pair := OptLp_ge_lpPair p (threshInterval M lo hi) ⟨mid - 1, by omega⟩ h0_mem h1_mem (by norm_num) rw [threshInterval_restrict_zero hlo_mid hmid_hi hhi, threshInterval_restrict_one hlo_mid hmid_hi hhi] at hge_pair have hih1 := ih a ha_lt_n lo mid hlo_mid (by omega) (by omega) have hih2 := ih (n - a) (by omega) mid hi hmid_hi hhi (by omega) have hna_cast : ((n - a : ℕ) : ℝ) = (n : ℝ) - (a : ℝ) := Nat.cast_sub (le_of_lt ha_lt_n) rw [hna_cast] at hih2 set T := C * Real.log (n : ℝ) - C * Real.log (N₀ : ℝ) have hv1 : T - u ^ p ≤ OptLp p (threshInterval M lo mid) := by have hlog1 : Real.log (q₁ * (n : ℝ)) ≤ Real.log (a : ℝ) := Real.log_le_log (mul_pos hq₁_pos hn_pos) ha_ge rw [Real.log_mul (ne_of_gt hq₁_pos) (ne_of_gt hn_pos), Real.log_exp] at hlog1 have hmul := mul_le_mul_of_nonneg_left hlog1 (le_of_lt hC) have hsimp : C * (-(u ^ p) / C + Real.log (n : ℝ)) = C * Real.log (n : ℝ) - u ^ p := by field_simp [ne_of_gt hC]; ring linarith have hv2 : T - (1 - u) ^ p ≤ OptLp p (threshInterval M mid hi) := by have hlog2 : Real.log (q₂ * (n : ℝ)) ≤ Real.log ((n : ℝ) - (a : ℝ)) := Real.log_le_log (mul_pos hq₂_pos hn_pos) hna_ge_real rw [Real.log_mul (ne_of_gt hq₂_pos) (ne_of_gt hn_pos), Real.log_exp] at hlog2 have hmul := mul_le_mul_of_nonneg_left hlog2 (le_of_lt hC) have hsimp : C * (-((1 - u) ^ p) / C + Real.log (n : ℝ)) = C * Real.log (n : ℝ) - (1 - u) ^ p := by field_simp [ne_of_gt hC]; ring linarith exact le_trans (lpPair_ge_of_exact_radii hp (le_of_lt hu0) (le_of_lt hu1)) (le_trans (lpPair_mono_v hp hv1 hv2) hge_pair) /-- **SHARP SUPERCRITICAL PHASE TRANSITION THEOREM (`p > pCrit = 1 / (1 - log 2)`)**: For EVERY `p > 1 / (1 - log 2)`, symmetry breaking occurs on realizable binary concepts: there exists `N ≥ 2` such that the 1D binary threshold class `threshClass N` STRICTLY VIOLATES the hypercube halving law: `(1 / (2^p * Real.log 2)) * Real.log |threshClass N| < OptLp p (threshClass N)`! -/ theorem OptLp_supercritical_phase_transition {p : ℝ} (hp : pCrit < p) : ∃ N : ℕ, 2 ≤ N ∧ (1 / (2 ^ p * Real.log 2)) * Real.log ((threshClass N).card : ℝ) < OptLp p (threshClass N) := by have hp0 : 0 < p := by linarith [pCrit_bounds.1] have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) obtain ⟨C, hC_gt, u, ⟨hu0, hu1⟩, hfail⟩ := exp_sym_criterion_fails_of_gt_pCrit hp have hC0_pos : 0 < 1 / (2 ^ p * Real.log 2) := by positivity have hC_pos : 0 < C := lt_trans hC0_pos hC_gt have hdiff_pos : 0 < C - 1 / (2 ^ p * Real.log 2) := sub_pos.mpr hC_gt set N₀ : ℕ := Nat.ceil (2 / (1 - Real.exp (-(u ^ p) / C) - Real.exp (-((1 - u) ^ p) / C))) + 2 set L : ℝ := (C * Real.log (N₀ : ℝ) + 1) / (C - 1 / (2 ^ p * Real.log 2)) set N : ℕ := Nat.ceil (Real.exp L) + 2 refine ⟨N, by omega, ?_⟩ have hlow := OptLp_threshInterval_supercritical_lower hp0 hC_pos hu0 hu1 hfail (N - 1) 0 N (by omega) (by omega) simp only [Nat.sub_zero] at hlow have hN_gt : Real.exp L < (N : ℝ) := by have h1 : Real.exp L ≤ (Nat.ceil (Real.exp L) : ℝ) := Nat.le_ceil _ have h2 : (N : ℝ) = (Nat.ceil (Real.exp L) : ℝ) + 2 := by dsimp only [N]; push_cast; ring linarith have hlogN_gt : L < Real.log (N : ℝ) := by rw [← Real.log_exp L] exact Real.log_lt_log (Real.exp_pos L) hN_gt have hmul : C * Real.log (N₀ : ℝ) + 1 < (C - 1 / (2 ^ p * Real.log 2)) * Real.log (N : ℝ) := by have := (div_lt_iff₀ hdiff_pos).mp hlogN_gt linarith rw [threshClass_card (by omega)] change (1 / (2 ^ p * Real.log 2)) * Real.log (N : ℝ) < OptLp p (threshInterval (N - 1) 0 N) linarith /-- Elementary upper bound `Real.log 3 < 11 / 10` (via `3 < exp (11 / 10)`). -/ lemma log_three_lt_11_div_10 : Real.log 3 < 11 / 10 := by rw [Real.log_lt_iff_lt_exp (by norm_num)] have h := Real.sum_le_exp_of_nonneg (x := (11 / 10 : ℝ)) (by norm_num) 6 simp [Finset.sum_range_succ, Nat.factorial] at h linarith /-- **EXPLICIT 3-CONCEPT FINITE SUPERCRITICAL WITNESS AT `p = 4`**: Even for `|V| = 3` (`threshClass 3`), `OptLp 4 (threshClass 3) > (1 / (16 * Real.log 2)) * Real.log 3`! -/ theorem OptLp_four_thresh3_beats_hypercube : (1 / (16 * Real.log 2)) * Real.log ((threshClass 3).card : ℝ) < OptLp 4 (threshClass 3) := by -- Step 1: Lower bound OptLp 4 (threshInterval 2 1 3) ≥ 1 / 16 have hsub2 : (1 / 16 : ℝ) ≤ OptLp 4 (threshInterval 2 1 3) := by have h0 : (0 : ℝ) ∈ labels (threshInterval 2 1 3) ⟨1, by omega⟩ := by rw [← restrict_nonempty_iff, threshInterval_restrict_zero (lo := 1) (mid := 2) (hi := 3) (by omega) (by omega) (by omega)] exact Finset.card_pos.mp (by rw [threshInterval_card (by omega)]; omega) have h1 : (1 : ℝ) ∈ labels (threshInterval 2 1 3) ⟨1, by omega⟩ := by rw [← restrict_nonempty_iff, threshInterval_restrict_one (lo := 1) (mid := 2) (hi := 3) (by omega) (by omega) (by omega)] exact Finset.card_pos.mp (by rw [threshInterval_card (by omega)]; omega) have hge := OptLp_ge_lpPair 4 (threshInterval 2 1 3) ⟨1, by omega⟩ h0 h1 (by norm_num) have hge0 := le_trans (lpPair_mono_v (by norm_num : (0 : ℝ) < 4) (OptLp_nonneg (by norm_num) _) (OptLp_nonneg (by norm_num) _)) hge rw [lpPair_eq_const (by norm_num : (0 : ℝ) < 4)] at hge0 have hval : (0 : ℝ) + (|(0 : ℝ) - 1| / 2) ^ (4 : ℝ) = 1 / 16 := by norm_num linarith -- Step 2: Lower bound OptLp 4 (threshClass 3) ≥ lpPair 4 0 1 0 (1 / 16) have hge3 : lpPair 4 0 1 0 (1 / 16) ≤ OptLp 4 (threshClass 3) := by change lpPair 4 0 1 0 (1 / 16) ≤ OptLp 4 (threshInterval 2 0 3) have h0 : (0 : ℝ) ∈ labels (threshInterval 2 0 3) ⟨0, by omega⟩ := by rw [← restrict_nonempty_iff, threshInterval_restrict_zero (lo := 0) (mid := 1) (hi := 3) (by omega) (by omega) (by omega)] exact Finset.card_pos.mp (by rw [threshInterval_card (by omega)]; omega) have h1 : (1 : ℝ) ∈ labels (threshInterval 2 0 3) ⟨0, by omega⟩ := by rw [← restrict_nonempty_iff, threshInterval_restrict_one (lo := 0) (mid := 1) (hi := 3) (by omega) (by omega) (by omega)] exact Finset.card_pos.mp (by rw [threshInterval_card (by omega)]; omega) have hge := OptLp_ge_lpPair 4 (threshInterval 2 0 3) ⟨0, by omega⟩ h0 h1 (by norm_num) rw [threshInterval_restrict_one (lo := 0) (mid := 1) (hi := 3) (by omega) (by omega) (by omega)] at hge exact le_trans (lpPair_mono_v (by norm_num : (0 : ℝ) < 4) (OptLp_nonneg (by norm_num) _) hsub2) hge -- Step 3: Exact rational witness u = 32 / 57 gives (32 / 57)^4 ≤ lpPair 4 0 1 0 (1 / 16)! have hu_le : (32 / 57 : ℝ) ^ (4 : ℕ) ≤ lpPair 4 0 1 0 (1 / 16) := by by_contra hlt push Not at hlt rcases lpPair_mem_feas (by norm_num : (0 : ℝ) < 4) (y₁ := 0) (y₂ := 1) (v₁ := 0) (v₂ := 1 / 16) with ⟨hm, hr⟩ set s := lpPair 4 0 1 0 (1 / 16) have hs_nn : 0 ≤ s := le_trans (le_max_left 0 (1 / 16)) hm have hs_sub_nn : 0 ≤ s - 1 / 16 := sub_nonneg.mpr (le_trans (le_max_right 0 (1 / 16)) hm) have h1 : s ^ (1 / 4 : ℝ) < 32 / 57 := by have hpow := Real.rpow_lt_rpow hs_nn hlt (by norm_num : (0 : ℝ) < 1 / 4) have hrew : ((32 / 57 : ℝ) ^ (4 : ℕ)) ^ (1 / 4 : ℝ) = 32 / 57 := by rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num : (0 : ℝ) ≤ 32 / 57)] norm_num linarith have h2 : (s - 1 / 16) ^ (1 / 4 : ℝ) < 25 / 57 := by have hlt2 : s - 1 / 16 < (25 / 57 : ℝ) ^ (4 : ℕ) := by linarith [show (32 / 57 : ℝ) ^ (4 : ℕ) - 1 / 16 < (25 / 57 : ℝ) ^ (4 : ℕ) by norm_num] have hpow := Real.rpow_lt_rpow hs_sub_nn hlt2 (by norm_num : (0 : ℝ) < 1 / 4) have hrew : ((25 / 57 : ℝ) ^ (4 : ℕ)) ^ (1 / 4 : ℝ) = 25 / 57 := by rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num : (0 : ℝ) ≤ 25 / 57)] norm_num linarith have habs : |(0 : ℝ) - 1| = 1 := by norm_num rw [sub_zero] at hr linarith -- Step 4: (1 / (16 * log 2)) * log 3 < (32 / 57)^4! have hstrict : (1 / (16 * Real.log 2)) * Real.log 3 < (32 / 57 : ℝ) ^ (4 : ℕ) := by have hlog2_lo := Real.log_two_gt_d9 have hlog3_hi := log_three_lt_11_div_10 have hden : 0 < 16 * Real.log 2 := by linarith rw [one_div_mul_eq_div, div_lt_iff₀ hden] linarith rw [threshClass_card (by norm_num)] push_cast linarith /-! ## Part 8: Exact Binary Singletons Quadratic Map (`p = 2`) & Exponential-vs-Polynomial Separation -/ /-- Real-valued binary singletons supported on `I ⊆ Fin N` (plus the all-zero concept). -/ def binSingletonSub {N : ℕ} (I : Finset (Fin N)) : Finset (Fin N → ℝ) := insert (fun _ => 0) (I.image fun i j => if j = i then 1 else 0) /-- Exact squared-loss singleton recurrence: `sqSingRec 0 = 0`, `sqSingRec (n + 1) = (1 + sqSingRec n)^2 / 4`. -/ def sqSingRec : ℕ → ℝ | 0 => 0 | n + 1 => (1 + sqSingRec n) ^ 2 / 4 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⟩ /-- **Exact Non-Asymptotic Sandwich for the Squared-Loss Singleton Quadratic Map**: for EVERY `n : ℕ`, `1 - 4 / (n + 4) ≤ sqSingRec n ≤ 1 - 3 / (n + 3)`! -/ 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 · -- Since 1 + sqSingRec n ≥ 2 - 4/(n+4), ((1 + sqSingRec n)/2)^2 ≥ (1 - 2/(n+4))^2 ≥ 1 - 4/(n+5)! 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 · -- Since 1 + sqSingRec n ≤ 2 - 3/(n+3), ((1 + sqSingRec n)/2)^2 ≤ (1 - 3/(2*(n+3)))^2 ≤ 1 - 3/(n+4)! 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 /-- Helper lemmas for `binSingletonSub` labels and restrictions. -/ private lemma binSingletonSub_labels_not_mem {N : ℕ} (I : Finset (Fin N)) {x : Fin N} (hx : x ∉ I) : labels (binSingletonSub I) x = {0} := 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 _ => 0, Or.inl rfl, rfl⟩ private lemma binSingletonSub_labels_mem {N : ℕ} (I : Finset (Fin N)) {x : Fin N} (hx : x ∈ I) : labels (binSingletonSub I) x = {0, 1} := 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 · right; simp [hxi] · left; simp [hxi] · rintro (rfl | rfl) · exact ⟨fun _ => 0, Or.inl rfl, rfl⟩ · exact ⟨fun j => if j = x then 1 else 0, Or.inr ⟨x, hx, rfl⟩, by simp⟩ private lemma binSingletonSub_restrict_zero {N : ℕ} (I : Finset (Fin N)) {x : Fin N} : restrict (binSingletonSub I) x 0 = 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_one {N : ℕ} (I : Finset (Fin N)) {x : Fin N} (hx : x ∈ I) : restrict (binSingletonSub I) x 1 = {fun j => if j = x then 1 else 0} := 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⟩ · exfalso; norm_num at hfx · by_cases hxi : x = i · subst hxi; rfl · exfalso; simp [hxi] at hfx · rintro rfl exact ⟨Or.inr ⟨x, hx, rfl⟩, by simp⟩ /-- **Exact Squared-Loss Binary Singleton Theorem**: `OptLp 2 (binSingletonSub I) = sqSingRec I.card` for EVERY `I : Finset (Fin N)`! -/ theorem OptLp_two_binSingletonSub_exact {N : ℕ} (I : Finset (Fin N)) : OptLp 2 (binSingletonSub I) = sqSingRec 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, OptLp 2 (binSingletonSub (I.erase x)) = sqSingRec (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 hstep : ∀ x ∈ I, lpVal 2 (labels (binSingletonSub I) x) (fun y => OptLp 2 (restrict (binSingletonSub I) x y)) = sqSingRec I.card := by intro x hx have h1 : OptLp 2 (restrict (binSingletonSub I) x 1) = 0 := by rw [binSingletonSub_restrict_one I hx]; exact OptLp_eq_zero_of_card_le_one 2 (by simp) have h0 : OptLp 2 (restrict (binSingletonSub I) x 0) = sqSingRec (I.card - 1) := by rw [binSingletonSub_restrict_zero, hrec x hx] rw [binSingletonSub_labels_mem I hx, lpVal_binary (by norm_num : (0 : ℝ) < 2), h0, h1, lpPair_two_eq] rcases sqSingRec_bounds (I.card - 1) with ⟨hnn, hlt1⟩ have hcond : ¬ ((0 : ℝ) - 1) ^ 2 ≤ |sqSingRec (I.card - 1) - 0| := by rw [sub_zero, abs_of_nonneg hnn]; norm_num; linarith rw [if_neg hcond] have hsucc : sqSingRec I.card = (1 + sqSingRec (I.card - 1)) ^ 2 / 4 := by conv_lhs => rw [← Nat.sub_add_cancel hcard_pos, sqSingRec] rw [hsucc]; ring apply le_antisymm · refine OptLp_le_of_forall_x 2 _ (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 (by norm_num)] rw [← hstep x0 hx0]; exact OptLp_ge_lpVal 2 _ x0 hsp · have hemp : I = ∅ := Finset.not_nonempty_iff_eq_empty.mp hI subst hemp have hsing : binSingletonSub (N := N) ∅ = {fun _ => 0} := by ext h; simp [binSingletonSub] rw [hsing, OptLp_eq_zero_of_card_le_one 2 (by simp)] simp [sqSingRec] /-- **Exact Absolute-Loss (`p = 1`) Binary Singleton Theorem**: `OptLp 1 (binSingletonSub I) = 1 - (1 / 2) ^ I.card` for EVERY `I : Finset (Fin N)`! -/ theorem OptLp_one_binSingletonSub_exact {N : ℕ} (I : Finset (Fin N)) : OptLp 1 (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, OptLp 1 (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 hstep : ∀ x ∈ I, lpVal 1 (labels (binSingletonSub I) x) (fun y => OptLp 1 (restrict (binSingletonSub I) x y)) = 1 - (1 / 2 : ℝ) ^ I.card := by intro x hx have h1 : OptLp 1 (restrict (binSingletonSub I) x 1) = 0 := by rw [binSingletonSub_restrict_one I hx]; exact OptLp_eq_zero_of_card_le_one 1 (by simp) have h0 : OptLp 1 (restrict (binSingletonSub I) x 0) = 1 - (1 / 2 : ℝ) ^ (I.card - 1) := by rw [binSingletonSub_restrict_zero, hrec x hx] rw [binSingletonSub_labels_mem I hx, lpVal_binary (by norm_num : (0 : ℝ) < 1), h0, h1, lpPair_one_eq] 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 havg : (1 - (1 / 2 : ℝ) ^ (I.card - 1) + 0 + |(0 : ℝ) - 1|) / 2 = 1 - (1 / 2 : ℝ) ^ I.card := by rw [hpow, show |(0 : ℝ) - 1| = 1 by norm_num]; ring rw [havg] exact max_eq_right (max_le (by linarith) (by linarith)) apply le_antisymm · refine OptLp_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 (by norm_num)] rw [← hstep x0 hx0]; exact OptLp_ge_lpVal 1 _ x0 hsp · have hemp : I = ∅ := Finset.not_nonempty_iff_eq_empty.mp hI subst hemp have hsing : binSingletonSub (N := N) ∅ = {fun _ => 0} := by ext h; simp [binSingletonSub] rw [hsing, OptLp_eq_zero_of_card_le_one 1 (by simp)] simp /-- **Exponential-vs-Polynomial Gap-to-1 Separation Between ℓ_1 and ℓ_2^2 on Binary Singletons**: On the exact same concept class `binSingletonSub I` of size `|I| + 1`: - Absolute loss (`p = 1`) approaches `1` **exponentially fast**: `1 - OptLp 1 = 2^(-|I|)`; - Squared loss (`p = 2`) approaches `1` only **polynomially**: `3 / (|I| + 3) ≤ 1 - OptLp 2 ≤ 4 / (|I| + 4)`! -/ theorem singleton_gap_l1_vs_l2_separation {N : ℕ} (I : Finset (Fin N)) : 1 - OptLp 1 (binSingletonSub I) = (1 / 2 : ℝ) ^ I.card ∧ 3 / ((I.card : ℝ) + 3) ≤ 1 - OptLp 2 (binSingletonSub I) ∧ 1 - OptLp 2 (binSingletonSub I) ≤ 4 / ((I.card : ℝ) + 4) := by rw [OptLp_one_binSingletonSub_exact I, OptLp_two_binSingletonSub_exact I] rcases sqSingRec_exact_sandwich I.card with ⟨hlo, hhi⟩ exact ⟨by ring, by linarith, by linarith⟩ end OnlineLpRegressionMinimax /-! ## Part 9: Machine-Checked `#print axioms` Verification (42 Headline Theorems) -/ #print axioms OnlineLpRegressionMinimax.lpPair_le_iff #print axioms OnlineLpRegressionMinimax.lpPair_le_iff_exists #print axioms OnlineLpRegressionMinimax.lpPair_one_eq #print axioms OnlineLpRegressionMinimax.lpPair_two_eq #print axioms OnlineLpRegressionMinimax.lpVal_le_iff #print axioms OnlineLpRegressionMinimax.lpVal_primal_upper #print axioms OnlineLpRegressionMinimax.lp_jensen_randomization_no_gain #print axioms OnlineLpRegressionMinimax.lpVal_dual_lower #print axioms OnlineLpRegressionMinimax.OptLp_mono #print axioms OnlineLpRegressionMinimax.OptLp_anti_p #print axioms OnlineLpRegressionMinimax.optLpLearner_expectedLoss_le #print axioms OnlineLpRegressionMinimax.optLpAdversary_expectedLoss_ge #print axioms OnlineLpRegressionMinimax.online_lp_minimax_exact #print axioms OnlineLpRegressionMinimax.lpPair_exp_halving_step #print axioms OnlineLpRegressionMinimax.OptLp_le_of_exp_criterion #print axioms OnlineLpRegressionMinimax.exp_criterion_inv_p #print axioms OnlineLpRegressionMinimax.OptLp_le_inv_p_log_card #print axioms OnlineLpRegressionMinimax.pCrit_bounds #print axioms OnlineLpRegressionMinimax.exp_sym_criterion_of_le_pCrit #print axioms OnlineLpRegressionMinimax.OptLp_le_hypercube_law_of_le_pCrit #print axioms OnlineLpRegressionMinimax.OptLp_one_le_half_log2 #print axioms OnlineLpRegressionMinimax.OptLp_two_le_quarter_log2 #print axioms OnlineLpRegressionMinimax.OptLp_two_beats_vovk_by_27pct #print axioms OnlineLpRegressionMinimax.OptLp_three_le_eighth_log2 #print axioms OnlineLpRegressionMinimax.exp_sym_criterion_fails_of_gt_pCrit #print axioms OnlineLpRegressionMinimax.OptLp_binary_vs_Ldim #print axioms OnlineLpRegressionMinimax.lpPair_binary_exponent_scaling #print axioms OnlineLpRegressionMinimax.OptLp_binary_vs_OptLp #print axioms OnlineLpRegressionMinimax.OptLp_two_vs_one_binary #print axioms OnlineLpRegressionMinimax.OptLp_prod_eq_add #print axioms OnlineLpRegressionMinimax.OptLp_onePointBool #print axioms OnlineLpRegressionMinimax.OptLp_boolCube_exact #print axioms OnlineLpRegressionMinimax.OptLp_boolCube_achieves_hypercube_law #print axioms OnlineLpRegressionMinimax.OptLp_onePointGrid #print axioms OnlineLpRegressionMinimax.OptLp_gridCube_exact #print axioms OnlineLpRegressionMinimax.OptLp_threshInterval_supercritical_lower #print axioms OnlineLpRegressionMinimax.OptLp_supercritical_phase_transition #print axioms OnlineLpRegressionMinimax.OptLp_four_thresh3_beats_hypercube #print axioms OnlineLpRegressionMinimax.sqSingRec_exact_sandwich #print axioms OnlineLpRegressionMinimax.OptLp_two_binSingletonSub_exact #print axioms OnlineLpRegressionMinimax.OptLp_one_binSingletonSub_exact #print axioms OnlineLpRegressionMinimax.singleton_gap_l1_vs_l2_separation