/- # Exact Minimax Theory of Deterministic and Randomized Online Learning with Abstention Standalone Lean 4 formalization of Chow's risk / reject-option online classification with abstention cost `c ∈ [0, 1]` over arbitrary multiclass label alphabets `β`: 1. Exact 1-round Multiclass Capped-Abstention Minimax Duality (`abstVal_le_iff`, `abstVal_primal_upper`, `abstVal_dual_lower`) via an elementary zero-LP-theory 1D Helly interval-intersection proof. 2. Exact binary closed-form specialization (`abstVal_binary_le_half`, `abstVal_binary_ge_half`) and exact `k`-class Abstention Phase Transition at `c*_k = 1 - 1 / k` (`RALdim_eq_RLdim_of_ge_threshold`, `RALdim_strict_improvement_below_threshold`). 3. Full Multi-Round Online Abstention Game Minimax Equivalence (`optAbstLearner`, `optAbstAdversary`, `online_abst_minimax_exact`). 4. **Universal Multiclass Tent-Function Randomization Ratio Theorem**: for EVERY finite concept class `V` over ANY label space `β` and EVERY `c ∈ [0, 1]`, `tentRatio c * ALdim c V ≤ RALdim c V ≤ ALdim c V`, where `tentRatio c = min (1 / (2 - c)) (1 / (1 + c))` (peaking at `2 / 3` when `c = 1 / 2`, recovering `1 / 2` at `c = 1`), proved sharp via generalized Fibonacci recurrences. 5. Exact Cost-Scaling Laws (`ALdim_c_scaling`, `RALdim_c_scaling`) and `k`-class sandwich `(k / (k - 1)) * c * RLdim V ≤ RALdim c V ≤ RLdim V` (`2 * c * RLdim V ≤ RALdim c V` binary). 6. **Two Universal Multiclass Halving Theorems** (zero dependence on `|β|`): - Randomized Binary-Entropy Halving: `RALdim c V ≤ (c / h_e(c)) * log |V|` (`c ∈ (0, 1/2]`) and `RALdim c V ≤ (1 / (2 * log 2)) * log |V|` (`c ∈ [1/2, 1]`). - Deterministic Characteristic-Root & Golden-Ratio Halving: `ALdim c V ≤ log |V| / log (1 / x)` for every `x ∈ (0, 1)` with `x ^ c + x ≤ 1`, specializing to the exact Golden Ratio `1 / (2 * log φ)` at `c = 1/2` and Supergolden Ratio `1 / (3 * log ψ)` at `c = 1/3`. - Exact Non-Asymptotic Generalized-Fibonacci Cardinality Law: `|V| < genFib q (k + 1)` implies `ALdim (1 / q) V ≤ k / q` (exact Fibonacci `|V| < fib (k + 3)` at `c = 1/2`). 7. Exact Disjoint-Domain Product Additivity (`RALdim_prod_eq_add`, `ALdim_prod_eq_add`), exact 1D Threshold Class Fibonacci & Generalized-Fibonacci Theorems (`ALdim_half_threshClass_exact`, `ALdim_inv_threshClass_exact`), exact Binary Singleton Class (`binSingletonSub_exact`), full `r`-ary Cube (`cubeClass`), and exact Fibonacci tent-ratio tightness. -/ import Mathlib open scoped BigOperators open Finset namespace OnlineAbstentionMinimax /-! ## Part 1: Multiclass 1-Round Abstention Minimax Operator `abstVal` & Zero-LP Primal–Dual Theorem -/ /-- Intercept `b(A) = (∑ y ∈ A, (v y + 1) - 1) / |A|` for nonempty `A`. -/ noncomputable def subsetIntercept {β : Type*} (v : β → ℝ) (A : Finset β) : ℝ := ((∑ y ∈ A, (v y + 1)) - 1) / (A.card : ℝ) /-- Slope `m(A) = (1 - |A| * (1 - c)) / |A| = c - (1 - 1 / |A|)` for nonempty `A`. -/ noncomputable def subsetSlope {β : Type*} (c : ℝ) (A : Finset β) : ℝ := (1 - (A.card : ℝ) * (1 - c)) / (A.card : ℝ) /-- Pair-intersection ordinate `((-m_B) * b_A + m_A * b_B) / (m_A - m_B)`. -/ noncomputable def pairOrdinate {β : Type*} (c : ℝ) (v : β → ℝ) (A B : Finset β) : ℝ := ((-subsetSlope c B) * subsetIntercept v A + subsetSlope c A * subsetIntercept v B) / (subsetSlope c A - subsetSlope c B) lemma subsetIntercept_singleton {β : Type*} (v : β → ℝ) (y : β) : subsetIntercept v {y} = v y := by simp [subsetIntercept] lemma subsetSlope_singleton {β : Type*} (c : ℝ) (y : β) : subsetSlope c {y} = c := by simp [subsetSlope] lemma subsetSlope_eq_sub {β : Type*} (c : ℝ) {A : Finset β} (hA : A.Nonempty) : subsetSlope c A = c - (1 - 1 / (A.card : ℝ)) := by have hpos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA.card_pos dsimp only [subsetSlope] field_simp [ne_of_gt hpos] ring lemma subsetIntercept_add_slope {β : Type*} (c : ℝ) (v : β → ℝ) {A : Finset β} (hA : A.Nonempty) : subsetIntercept v A + subsetSlope c A = (∑ y ∈ A, v y) / (A.card : ℝ) + c := by have hpos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA.card_pos dsimp only [subsetIntercept, subsetSlope] rw [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul, mul_one] field_simp [ne_of_gt hpos] ring /-- Helper: maximum of `f` over a finite set `F` with fallback `d`. -/ noncomputable def supOr {γ : Type*} (F : Finset γ) (f : γ → ℝ) (d : ℝ) : ℝ := if hF : F.Nonempty then max d (F.sup' hF f) else d lemma le_supOr_left {γ : Type*} (F : Finset γ) (f : γ → ℝ) (d : ℝ) : d ≤ supOr F f d := by rw [supOr]; split_ifs; exact le_max_left _ _; exact le_rfl lemma le_supOr_of_mem {γ : Type*} {F : Finset γ} {f : γ → ℝ} {d : ℝ} {x : γ} (hx : x ∈ F) : f x ≤ supOr F f d := by have hF : F.Nonempty := ⟨x, hx⟩ rw [supOr, dif_pos hF] exact le_trans (Finset.le_sup' f hx) (le_max_right _ _) lemma supOr_le_iff {γ : Type*} {F : Finset γ} {f : γ → ℝ} {d t : ℝ} : supOr F f d ≤ t ↔ d ≤ t ∧ ∀ x ∈ F, f x ≤ t := by rw [supOr] split_ifs with hF · simp only [max_le_iff, Finset.sup'_le_iff] · constructor · intro hdt; exact ⟨hdt, fun x hx => absurd ⟨x, hx⟩ hF⟩ · exact And.left /-- Exact closed-form 1-round minimax value of multiclass randomized online learning with abstention cost `c ∈ [0, 1]` on label set `S` and continuation values `v`. -/ noncomputable def abstVal {β : Type*} [DecidableEq β] (c : ℝ) (S : Finset β) (v : β → ℝ) : ℝ := if hS : S.Nonempty then let F := S.powerset.filter Finset.Nonempty let base := S.sup' hS v let B0 := supOr (F.filter (fun A => 0 ≤ subsetSlope c A)) (subsetIntercept v) base let B1 := supOr (F.filter (fun B => subsetSlope c B ≤ 0)) (fun B => subsetIntercept v B + subsetSlope c B) base let BP := supOr ((F ×ˢ F).filter (fun p => 0 < subsetSlope c p.1 ∧ subsetSlope c p.2 < 0)) (fun p => pairOrdinate c v p.1 p.2) base max B0 (max B1 BP) else 0 lemma abstVal_empty {β : Type*} [DecidableEq β] (c : ℝ) (v : β → ℝ) : abstVal c (∅ : Finset β) v = 0 := by simp [abstVal] lemma le_abstVal_of_mem {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} {v : β → ℝ} {y : β} (hy : y ∈ S) : v y ≤ abstVal c S v := by have hS : S.Nonempty := ⟨y, hy⟩ rw [abstVal, dif_pos hS] dsimp only exact le_trans (Finset.le_sup' v hy) (le_trans (le_supOr_left _ _ _) (le_max_left _ _)) /-- Exact characterization of `abstVal c S v ≤ t` in terms of the three Helly dual branches. -/ lemma abstVal_le_branches_iff {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} (hS : S.Nonempty) {v : β → ℝ} (t : ℝ) : abstVal c S v ≤ t ↔ (∀ y ∈ S, v y ≤ t) ∧ (∀ A ⊆ S, A.Nonempty → 0 ≤ subsetSlope c A → subsetIntercept v A ≤ t) ∧ (∀ B ⊆ S, B.Nonempty → subsetSlope c B ≤ 0 → subsetIntercept v B + subsetSlope c B ≤ t) ∧ (∀ A ⊆ S, A.Nonempty → ∀ B ⊆ S, B.Nonempty → 0 < subsetSlope c A → subsetSlope c B < 0 → pairOrdinate c v A B ≤ t) := by rw [abstVal, dif_pos hS] dsimp only simp only [max_le_iff, supOr_le_iff, Finset.sup'_le_iff, Finset.mem_filter, Finset.mem_powerset, Finset.mem_product, Prod.forall, and_imp] constructor · rintro ⟨⟨hv, h0⟩, ⟨_, h1⟩, ⟨_, hp⟩⟩ exact ⟨hv, fun A hAS hAne hm => h0 A hAS hAne hm, fun B hBS hBne hm => h1 B hBS hBne hm, fun A hAS hAne B hBS hBne hmA hmB => hp A B hAS hAne hBS hBne hmA hmB⟩ · rintro ⟨hv, h0, h1, hp⟩ refine ⟨⟨hv, fun A hAS hAne hm => h0 A hAS hAne hm⟩, ⟨hv, fun B hBS hBne hm => h1 B hBS hBne hm⟩, ⟨hv, fun A B hAS hAne hBS hBne hmA hmB => hp A hAS hAne B hBS hBne hmA hmB⟩⟩ /-- **1D Helly / Interval-Intersection Characterization of `abstVal c S v ≤ t`**: For `c ∈ [0, 1]` and nonempty `S`, `abstVal c S v ≤ t` iff there exists an abstention probability `p_perp ∈ [0, 1]` such that `p_perp + ∑ y ∈ S, max 0 (v y + 1 - (1 - c) * p_perp - t) ≤ 1`. -/ theorem abstVal_le_iff {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (_hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) {v : β → ℝ} (t : ℝ) : abstVal c S v ≤ t ↔ ∃ p_perp : ℝ, 0 ≤ p_perp ∧ p_perp ≤ 1 ∧ p_perp + ∑ y ∈ S, max 0 (v y + 1 - (1 - c) * p_perp - t) ≤ 1 := by rw [abstVal_le_branches_iff hS] constructor · rintro ⟨hv, h0, h1, hp⟩ set F := S.powerset.filter Finset.Nonempty set Fneg := F.filter (fun B => subsetSlope c B < 0) set Fpos := F.filter (fun A => 0 < subsetSlope c A) set L : ℝ := supOr Fneg (fun B => (subsetIntercept v B - t) / (-subsetSlope c B)) 0 have hL0 : 0 ≤ L := le_supOr_left _ _ _ have hL1 : L ≤ 1 := by rw [supOr_le_iff] refine ⟨by norm_num, fun B hB => ?_⟩ rcases Finset.mem_filter.mp hB with ⟨hBF, hmB⟩ rcases Finset.mem_filter.mp hBF with ⟨hBpow, hBne⟩ have hBS : B ⊆ S := Finset.mem_powerset.mp hBpow have hpos : 0 < -subsetSlope c B := neg_pos.mpr hmB rw [div_le_one hpos] linarith [h1 B hBS hBne (le_of_lt hmB)] have hline : ∀ A ⊆ S, A.Nonempty → subsetIntercept v A + subsetSlope c A * L ≤ t := by intro A hAS hAne by_cases hmpos : 0 < subsetSlope c A · -- Show `L ≤ (t - b_A) / m_A`! have hLU : L ≤ (t - subsetIntercept v A) / subsetSlope c A := by rw [supOr_le_iff] refine ⟨div_nonneg (sub_nonneg.mpr (h0 A hAS hAne (le_of_lt hmpos))) (le_of_lt hmpos), fun B hB => ?_⟩ rcases Finset.mem_filter.mp hB with ⟨hBF, hmB⟩ rcases Finset.mem_filter.mp hBF with ⟨hBpow, hBne⟩ have hBS : B ⊆ S := Finset.mem_powerset.mp hBpow have hneg : 0 < -subsetSlope c B := neg_pos.mpr hmB have hpair := hp A hAS hAne B hBS hBne hmpos hmB have hdiff : 0 < subsetSlope c A - subsetSlope c B := by linarith dsimp only [pairOrdinate] at hpair rw [div_le_iff₀ hdiff] at hpair rw [div_le_div_iff₀ hneg hmpos] linarith have hmul := (le_div_iff₀ hmpos).mp hLU linarith · by_cases hmneg : subsetSlope c A < 0 · have hmem : A ∈ Fneg := Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hAS, hAne⟩, hmneg⟩ have hge : (subsetIntercept v A - t) / (-subsetSlope c A) ≤ L := le_supOr_of_mem (f := fun B => (subsetIntercept v B - t) / (-subsetSlope c B)) hmem have hpos : 0 < -subsetSlope c A := neg_pos.mpr hmneg have hmul := (div_le_iff₀ hpos).mp hge linarith · have hm0 : subsetSlope c A = 0 := le_antisymm (not_lt.mp hmpos) (not_lt.mp hmneg) rw [hm0, zero_mul, add_zero] exact h0 A hAS hAne (le_of_eq hm0.symm) refine ⟨L, hL0, hL1, ?_⟩ set A := S.filter (fun y => 0 < v y + 1 - (1 - c) * L - t) have hsum_eq : ∑ y ∈ S, max 0 (v y + 1 - (1 - c) * L - t) = ∑ y ∈ A, (v y + 1 - (1 - c) * L - t) := by rw [← Finset.sum_filter_add_sum_filter_not S (fun y => 0 < v y + 1 - (1 - c) * L - t)] have h1' : ∑ y ∈ A, max 0 (v y + 1 - (1 - c) * L - t) = ∑ y ∈ A, (v y + 1 - (1 - c) * L - t) := Finset.sum_congr rfl fun y hy => max_eq_right (le_of_lt (Finset.mem_filter.mp hy).2) have h2' : ∑ y ∈ S.filter (fun y => ¬ 0 < v y + 1 - (1 - c) * L - t), max 0 (v y + 1 - (1 - c) * L - t) = 0 := Finset.sum_eq_zero fun y hy => max_eq_left (not_lt.mp (Finset.mem_filter.mp hy).2) rw [h1', h2', add_zero] rw [hsum_eq] by_cases hA : A.Nonempty · have hAS : A ⊆ S := Finset.filter_subset _ S have hle := hline A hAS hA have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA.card_pos dsimp only [subsetIntercept, subsetSlope] at hle have hmul : ((∑ y ∈ A, (v y + 1)) - 1) + (1 - (A.card : ℝ) * (1 - c)) * L ≤ t * (A.card : ℝ) := by have := mul_le_mul_of_nonneg_right hle (le_of_lt hcard_pos) field_simp [ne_of_gt hcard_pos] at this linarith have hsub_sum : ∑ y ∈ A, (v y + 1 - (1 - c) * L - t) = (∑ y ∈ A, (v y + 1)) - (A.card : ℝ) * ((1 - c) * L) - t * (A.card : ℝ) := by rw [Finset.sum_sub_distrib, Finset.sum_sub_distrib, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_comm (A.card : ℝ) t] linarith · rw [Finset.not_nonempty_iff_eq_empty.mp hA, Finset.sum_empty, add_zero] exact hL1 · rintro ⟨p_perp, hp0, hp1, hsum⟩ -- First show `b(A) + m(A) * p_perp ≤ t` for EVERY nonempty `A ⊆ S`. have hline : ∀ A ⊆ S, A.Nonempty → subsetIntercept v A + subsetSlope c A * p_perp ≤ t := by intro A hAS hAne have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos have h1 : ∑ y ∈ A, (v y + 1 - (1 - c) * p_perp - t) ≤ ∑ y ∈ A, max 0 (v y + 1 - (1 - c) * p_perp - t) := Finset.sum_le_sum fun y _ => le_max_right _ _ have h2 : ∑ y ∈ A, max 0 (v y + 1 - (1 - c) * p_perp - t) ≤ ∑ y ∈ S, max 0 (v y + 1 - (1 - c) * p_perp - t) := Finset.sum_le_sum_of_subset_of_nonneg hAS fun y _ _ => le_max_left _ _ have hsub_sum : ∑ y ∈ A, (v y + 1 - (1 - c) * p_perp - t) = (∑ y ∈ A, (v y + 1)) - (A.card : ℝ) * ((1 - c) * p_perp) - t * (A.card : ℝ) := by rw [Finset.sum_sub_distrib, Finset.sum_sub_distrib, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_comm (A.card : ℝ) t] have hnum : ((∑ y ∈ A, (v y + 1)) - 1) + (1 - (A.card : ℝ) * (1 - c)) * p_perp ≤ t * (A.card : ℝ) := by linarith dsimp only [subsetIntercept, subsetSlope] rw [← mul_div_right_comm, ← add_div, div_le_iff₀ hcard_pos] linarith refine ⟨?_, ?_, ?_, ?_⟩ · intro y hy have hsing := hline {y} (Finset.singleton_subset_iff.mpr hy) (Finset.singleton_nonempty y) rw [subsetIntercept_singleton, subsetSlope_singleton] at hsing nlinarith · intro A hAS hAne hmA have := hline A hAS hAne nlinarith · intro B hBS hBne hmB have := hline B hBS hBne nlinarith · intro A hAS hAne B hBS hBne hmA hmB have hA := hline A hAS hAne have hB := hline B hBS hBne have hdiff : 0 < subsetSlope c A - subsetSlope c B := by linarith dsimp only [pairOrdinate] rw [div_le_iff₀ hdiff] nlinarith /-- Primal feasibility: any randomized abstention strategy `(p_perp, p)` with `p_perp ≥ 0`, `p_y ≥ 0`, `p_perp + ∑ y ∈ S, p_y ≤ 1` achieving `v y + 1 - (1 - c) * p_perp - p y ≤ t` certifies `abstVal c S v ≤ t`. -/ theorem abstVal_le_of_primal {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) {v p : β → ℝ} {p_perp t : ℝ} (hp_perp0 : 0 ≤ p_perp) (hp0 : ∀ y ∈ S, 0 ≤ p y) (hsum : p_perp + ∑ y ∈ S, p y ≤ 1) (hval : ∀ y ∈ S, v y + (1 - (1 - c) * p_perp - p y) ≤ t) : abstVal c S v ≤ t := by have hp_perp1 : p_perp ≤ 1 := by have : 0 ≤ ∑ y ∈ S, p y := Finset.sum_nonneg hp0 linarith rw [abstVal_le_iff hc0 hc1 hS] refine ⟨p_perp, hp_perp0, hp_perp1, ?_⟩ have hle : ∑ y ∈ S, max 0 (v y + 1 - (1 - c) * p_perp - t) ≤ ∑ y ∈ S, p y := Finset.sum_le_sum fun y hy => max_le (hp0 y hy) (by linarith [hval y hy]) linarith /-- **Exact Primal Optimal Mixed Abstention Strategy**: for `c ∈ [0, 1]` and nonempty `S`, there exists a probability distribution `(p_perp, p)` over `{⊥} ∪ S` achieving `v y + (1 - (1 - c) * p_perp - p y) ≤ abstVal c S v` for every `y ∈ S`. -/ theorem abstVal_primal_upper {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ (p_perp : ℝ) (p : β → ℝ), 0 ≤ p_perp ∧ (∀ y ∈ S, 0 ≤ p y) ∧ (p_perp + ∑ y ∈ S, p y ≤ 1) ∧ (∀ y ∈ S, v y + (1 - (1 - c) * p_perp - p y) ≤ abstVal c S v) := by set t := abstVal c S v obtain ⟨p_perp, hp0, _, hsum⟩ := (abstVal_le_iff hc0 hc1 hS t).mp le_rfl refine ⟨p_perp, fun y => max 0 (v y + 1 - (1 - c) * p_perp - t), hp0, fun y _ => le_max_left _ _, hsum, fun y _ => ?_⟩ have hle : v y + 1 - (1 - c) * p_perp - t ≤ max 0 (v y + 1 - (1 - c) * p_perp - t) := le_max_right _ _ linarith /-- Helper: uniform distribution on a nonempty subset `A ⊆ S` gives lower bound `b(A) + m(A) * p_perp` against any primal abstention strategy `(p_perp, p)`. -/ lemma unif_subset_dual_bound {β : Type*} [DecidableEq β] {c : ℝ} {S A : Finset β} (hAS : A ⊆ S) (hAne : A.Nonempty) (v p : β → ℝ) (p_perp : ℝ) (hp0 : ∀ y ∈ S, 0 ≤ p y) (hsum : p_perp + ∑ y ∈ S, p y ≤ 1) : subsetIntercept v A + subsetSlope c A * p_perp ≤ ∑ y ∈ S, (if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0) * (v y + (1 - (1 - c) * p_perp - p y)) := by have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos have hsum_A : ∑ y ∈ A, p y ≤ 1 - p_perp := by have := Finset.sum_le_sum_of_subset_of_nonneg hAS fun y hy _ => hp0 y hy linarith have hrew : ∑ y ∈ S, (if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0) * (v y + (1 - (1 - c) * p_perp - p y)) = (∑ y ∈ A, (v y + 1 - (1 - c) * p_perp - p y)) / (A.card : ℝ) := by have h1 : ∀ y ∈ S, (if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0) * (v y + (1 - (1 - c) * p_perp - p y)) = if y ∈ A then (v y + 1 - (1 - c) * p_perp - p y) / (A.card : ℝ) else 0 := by intro y _; split_ifs <;> ring rw [Finset.sum_congr rfl h1, Finset.sum_ite_mem, Finset.inter_eq_right.mpr hAS, ← Finset.sum_div] rw [hrew] dsimp only [subsetIntercept, subsetSlope] rw [← mul_div_right_comm, ← add_div] refine div_le_div_of_nonneg_right ?_ (le_of_lt hcard_pos) have hsum_split : ∑ y ∈ A, (v y + 1 - (1 - c) * p_perp - p y) = (∑ y ∈ A, (v y + 1)) - (A.card : ℝ) * ((1 - c) * p_perp) - ∑ y ∈ A, p y := by rw [Finset.sum_sub_distrib, Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] linarith /-- **Exact Dual Optimal Adversary Distribution**: for `c ∈ [0, 1]` and nonempty `S`, there exists a probability distribution `ν` on `S` (either uniform on a single subset or a convex combination of two uniform subset distributions whose `p_perp` slopes cancel identically!) such that EVERY randomized abstention strategy `(p_perp, p)` suffers expected cost `≥ abstVal c S v`. -/ theorem abstVal_dual_lower {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ ν : β → ℝ, (∀ y ∈ S, 0 ≤ ν y) ∧ (∑ y ∈ S, ν y = 1) ∧ ∀ (p_perp : ℝ) (p : β → ℝ), 0 ≤ p_perp → p_perp ≤ 1 → (∀ y ∈ S, 0 ≤ p y) → (p_perp + ∑ y ∈ S, p y ≤ 1) → abstVal c S v ≤ ∑ y ∈ S, ν y * (v y + (1 - (1 - c) * p_perp - p y)) := by have hsup_cases : ∀ {γ : Type _} (F : Finset γ) (f : γ → ℝ) (d : ℝ), supOr F f d = d ∨ ∃ x ∈ F, supOr F f d = f x := by intro γ F f d rw [supOr] split_ifs with hF · by_cases hle : F.sup' hF f ≤ d · exact Or.inl (max_eq_left hle) · obtain ⟨x, hx, hxeq⟩ := Finset.exists_mem_eq_sup' hF f exact Or.inr ⟨x, hx, by rw [max_eq_right (le_of_not_ge hle), hxeq]⟩ · exact Or.inl rfl set F := S.powerset.filter Finset.Nonempty set base := S.sup' hS v set B0 := supOr (F.filter (fun A => 0 ≤ subsetSlope c A)) (subsetIntercept v) base set B1 := supOr (F.filter (fun B => subsetSlope c B ≤ 0)) (fun B => subsetIntercept v B + subsetSlope c B) base set BP := supOr ((F ×ˢ F).filter (fun p => 0 < subsetSlope c p.1 ∧ subsetSlope c p.2 < 0)) (fun p => pairOrdinate c v p.1 p.2) base have habst_eq : abstVal c S v = max B0 (max B1 BP) := by rw [abstVal, dif_pos hS] have hbase_dual : ∃ ν : β → ℝ, (∀ y ∈ S, 0 ≤ ν y) ∧ (∑ y ∈ S, ν y = 1) ∧ ∀ (p_perp : ℝ) (p : β → ℝ), 0 ≤ p_perp → p_perp ≤ 1 → (∀ y ∈ S, 0 ≤ p y) → (p_perp + ∑ y ∈ S, p y ≤ 1) → base ≤ ∑ y ∈ S, ν y * (v y + (1 - (1 - c) * p_perp - p y)) := by obtain ⟨y0, hy0, hy0_eq⟩ := Finset.exists_mem_eq_sup' hS v refine ⟨fun y => if y = y0 then 1 else 0, fun y _ => by dsimp only; split_ifs <;> norm_num, by simp [hy0], fun p_perp p hp0 _ hp_nn hsum => ?_⟩ simp only [ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', hy0, ↓reduceIte] have hpy0 : p y0 ≤ 1 - p_perp := by have := Finset.single_le_sum hp_nn hy0 linarith dsimp only [base]; rw [hy0_eq] nlinarith have hmax_tri : abstVal c S v = B0 ∨ abstVal c S v = B1 ∨ abstVal c S v = BP := by rw [habst_eq] rcases max_choice B0 (max B1 BP) with h | h · exact Or.inl h · rcases max_choice B1 BP with h' | h' · exact Or.inr (Or.inl (h.trans h')) · exact Or.inr (Or.inr (h.trans h')) rcases hmax_tri with hEq | hEq | hEq · rcases hsup_cases (F.filter (fun A => 0 ≤ subsetSlope c A)) (subsetIntercept v) base with hB | ⟨A, hA, hAeq⟩ · rw [hEq]; dsimp only [B0]; rw [hB]; exact hbase_dual · rcases Finset.mem_filter.mp hA with ⟨hAF, hmA⟩ rcases Finset.mem_filter.mp hAF with ⟨hApow, hAne⟩ have hAS : A ⊆ S := Finset.mem_powerset.mp hApow have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos refine ⟨fun y => if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0, fun y _ => by dsimp only; split_ifs; exact div_nonneg (by norm_num) (le_of_lt hcard_pos); exact le_rfl, (by rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr hAS, Finset.sum_const, nsmul_eq_mul, mul_one_div_cancel (ne_of_gt hcard_pos)]), fun p_perp p hp0 _ hp_nn hsum => ?_⟩ rw [hEq]; dsimp only [B0]; rw [hAeq] have hdb := unif_subset_dual_bound (c := c) hAS hAne v p p_perp hp_nn hsum nlinarith · rcases hsup_cases (F.filter (fun B => subsetSlope c B ≤ 0)) (fun B => subsetIntercept v B + subsetSlope c B) base with hB | ⟨B, hBmem, hBeq⟩ · rw [hEq]; dsimp only [B1]; rw [hB]; exact hbase_dual · rcases Finset.mem_filter.mp hBmem with ⟨hBF, hmB⟩ rcases Finset.mem_filter.mp hBF with ⟨hBpow, hBne⟩ have hBS : B ⊆ S := Finset.mem_powerset.mp hBpow have hcard_pos : (0 : ℝ) < (B.card : ℝ) := Nat.cast_pos.mpr hBne.card_pos refine ⟨fun y => if y ∈ B then (1 : ℝ) / (B.card : ℝ) else 0, fun y _ => by dsimp only; split_ifs; exact div_nonneg (by norm_num) (le_of_lt hcard_pos); exact le_rfl, (by rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr hBS, Finset.sum_const, nsmul_eq_mul, mul_one_div_cancel (ne_of_gt hcard_pos)]), fun p_perp p _ hp1 hp_nn hsum => ?_⟩ rw [hEq]; dsimp only [B1]; rw [hBeq] have hdb := unif_subset_dual_bound (c := c) hBS hBne v p p_perp hp_nn hsum nlinarith · rcases hsup_cases ((F ×ˢ F).filter (fun p => 0 < subsetSlope c p.1 ∧ subsetSlope c p.2 < 0)) (fun p => pairOrdinate c v p.1 p.2) base with hB | ⟨⟨A, B⟩, hAB, hABeq⟩ · rw [hEq]; dsimp only [BP]; rw [hB]; exact hbase_dual · rcases Finset.mem_filter.mp hAB with ⟨hABprod, hmA, hmB⟩ rcases Finset.mem_product.mp hABprod with ⟨hAF, hBF⟩ rcases Finset.mem_filter.mp hAF with ⟨hApow, hAne⟩ rcases Finset.mem_filter.mp hBF with ⟨hBpow, hBne⟩ have hAS : A ⊆ S := Finset.mem_powerset.mp hApow have hBS : B ⊆ S := Finset.mem_powerset.mp hBpow have hcA : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos have hcB : (0 : ℝ) < (B.card : ℝ) := Nat.cast_pos.mpr hBne.card_pos have hdiff : 0 < subsetSlope c A - subsetSlope c B := by linarith set wA := (-subsetSlope c B) / (subsetSlope c A - subsetSlope c B) set wB := subsetSlope c A / (subsetSlope c A - subsetSlope c B) have hwA0 : 0 ≤ wA := div_nonneg (by linarith) (le_of_lt hdiff) have hwB0 : 0 ≤ wB := div_nonneg (le_of_lt hmA) (le_of_lt hdiff) have hwsum : wA + wB = 1 := by dsimp only [wA, wB]; field_simp [ne_of_gt hdiff]; ring let νA : β → ℝ := fun y => if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0 let νB : β → ℝ := fun y => if y ∈ B then (1 : ℝ) / (B.card : ℝ) else 0 have hνA0 : ∀ y ∈ S, 0 ≤ νA y := fun y _ => by dsimp only [νA]; split_ifs; exact div_nonneg (by norm_num) (le_of_lt hcA); exact le_rfl have hνB0 : ∀ y ∈ S, 0 ≤ νB y := fun y _ => by dsimp only [νB]; split_ifs; exact div_nonneg (by norm_num) (le_of_lt hcB); exact le_rfl have hνA1 : ∑ y ∈ S, νA y = 1 := by dsimp only [νA] rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr hAS, Finset.sum_const, nsmul_eq_mul, mul_one_div_cancel (ne_of_gt hcA)] have hνB1 : ∑ y ∈ S, νB y = 1 := by dsimp only [νB] rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr hBS, Finset.sum_const, nsmul_eq_mul, mul_one_div_cancel (ne_of_gt hcB)] refine ⟨fun y => wA * νA y + wB * νB y, fun y hy => by dsimp only; nlinarith [hνA0 y hy, hνB0 y hy], ?_, fun p_perp p _ _ hp_nn hsum => ?_⟩ · calc ∑ y ∈ S, (wA * νA y + wB * νB y) = wA * (∑ y ∈ S, νA y) + wB * (∑ y ∈ S, νB y) := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] _ = 1 := by rw [hνA1, hνB1]; linarith · rw [hEq]; dsimp only [BP]; rw [hABeq] have hdA := unif_subset_dual_bound (c := c) hAS hAne v p p_perp hp_nn hsum have hdB := unif_subset_dual_bound (c := c) hBS hBne v p p_perp hp_nn hsum have hlin : ∑ y ∈ S, (wA * νA y + wB * νB y) * (v y + (1 - (1 - c) * p_perp - p y)) = wA * (∑ y ∈ S, νA y * (v y + (1 - (1 - c) * p_perp - p y))) + wB * (∑ y ∈ S, νB y * (v y + (1 - (1 - c) * p_perp - p y))) := by have hrew : ∀ y ∈ S, (wA * νA y + wB * νB y) * (v y + (1 - (1 - c) * p_perp - p y)) = wA * (νA y * (v y + (1 - (1 - c) * p_perp - p y))) + wB * (νB y * (v y + (1 - (1 - c) * p_perp - p y))) := fun y _ => by ring rw [Finset.sum_congr rfl hrew, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] rw [hlin] have hcomb : wA * (subsetIntercept v A + subsetSlope c A * p_perp) + wB * (subsetIntercept v B + subsetSlope c B * p_perp) = pairOrdinate c v A B := by dsimp only [wA, wB, pairOrdinate] field_simp [ne_of_gt hdiff] ring have h1 := mul_le_mul_of_nonneg_left hdA hwA0 have h2 := mul_le_mul_of_nonneg_left hdB hwB0 linarith lemma abstVal_congr {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} {v₁ v₂ : β → ℝ} (h : ∀ y ∈ S, v₁ y = v₂ y) : abstVal c S v₁ = abstVal c S v₂ := by by_cases hS : S.Nonempty · apply le_antisymm · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS v₂ exact abstVal_le_of_primal hc0 hc1 hS hp0 hpn hsum fun y hy => by rw [h y hy]; exact hval y hy · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS v₁ exact abstVal_le_of_primal hc0 hc1 hS hp0 hpn hsum fun y hy => by rw [← h y hy]; exact hval y hy · simp [abstVal, hS] lemma abstVal_nonneg {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} {v : β → ℝ} (hv : ∀ y ∈ S, 0 ≤ v y) : 0 ≤ abstVal c S v := by by_cases hS : S.Nonempty · rcases hS with ⟨y, hy⟩ exact le_trans (hv y hy) (le_abstVal_of_mem hy) · simp [abstVal, hS] lemma abstVal_mono_v {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} {v₁ v₂ : β → ℝ} (hv : ∀ y ∈ S, v₁ y ≤ v₂ y) : abstVal c S v₁ ≤ abstVal c S v₂ := by by_cases hS : S.Nonempty · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS v₂ exact abstVal_le_of_primal hc0 hc1 hS hp0 hpn hsum fun y hy => by linarith [hv y hy, hval y hy] · simp [abstVal, hS] lemma abstVal_mono_c {β : Type*} [DecidableEq β] {c₁ c₂ : ℝ} (hc₁0 : 0 ≤ c₁) (hc12 : c₁ ≤ c₂) (hc₂1 : c₂ ≤ 1) (S : Finset β) (v : β → ℝ) : abstVal c₁ S v ≤ abstVal c₂ S v := by by_cases hS : S.Nonempty · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper (le_trans hc₁0 hc12) hc₂1 hS v exact abstVal_le_of_primal hc₁0 (le_trans hc12 hc₂1) hS hp0 hpn hsum fun y hy => by have := hval y hy; nlinarith · simp [abstVal, hS] lemma abstVal_mono_S {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S₁ S₂ : Finset β} (hS : S₁ ⊆ S₂) {v : β → ℝ} (hv : ∀ y ∈ S₂, 0 ≤ v y) : abstVal c S₁ v ≤ abstVal c S₂ v := by by_cases h1 : S₁.Nonempty · have h2 : S₂.Nonempty := h1.mono hS obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 h2 v refine abstVal_le_of_primal hc0 hc1 h1 hp0 (fun y hy => hpn y (hS hy)) ?_ (fun y hy => hval y (hS hy)) have := Finset.sum_le_sum_of_subset_of_nonneg hS fun y hy _ => hpn y hy linarith · rw [Finset.not_nonempty_iff_eq_empty.mp h1, abstVal_empty] exact abstVal_nonneg hv lemma abstVal_add_const {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (k : ℝ) : abstVal c S (fun y => v y + k) = abstVal c S v + k := by apply le_antisymm · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS v exact abstVal_le_of_primal hc0 hc1 hS hp0 hpn hsum fun y hy => by linarith [hval y hy] · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS (fun y => v y + k) have hle : abstVal c S v ≤ abstVal c S (fun y => v y + k) - k := abstVal_le_of_primal hc0 hc1 hS hp0 hpn hsum fun y hy => by linarith [hval y hy] linarith /-- Exact value of `abstVal` on constant continuation values: `k + min c (1 - 1 / |S|)`. -/ lemma abstVal_const {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) (k : ℝ) : abstVal c S (fun _ => k) = k + min c (1 - 1 / (S.card : ℝ)) := by have hcard_pos : (0 : ℝ) < (S.card : ℝ) := Nat.cast_pos.mpr hS.card_pos apply le_antisymm · by_cases hle : c ≤ 1 - 1 / (S.card : ℝ) · rw [min_eq_left hle] refine abstVal_le_of_primal hc0 hc1 hS (p_perp := 1) (p := fun _ => 0) (by norm_num) (fun _ _ => le_rfl) (by simp) (fun _ _ => by ring_nf; exact le_rfl) · rw [min_eq_right (le_of_not_ge hle)] refine abstVal_le_of_primal hc0 hc1 hS (p_perp := 0) (p := fun _ => 1 / (S.card : ℝ)) le_rfl (fun _ _ => by positivity) ?_ (fun _ _ => by ring_nf; exact le_rfl) rw [zero_add, Finset.sum_const, nsmul_eq_mul] field_simp [ne_of_gt hcard_pos]; exact le_rfl · obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS (fun _ => k) have hdb := unif_subset_dual_bound (c := c) Subset.rfl hS (fun _ => k) p p_perp hpn hsum have hupper : ∑ y ∈ S, (if y ∈ S then (1 : ℝ) / (S.card : ℝ) else 0) * (k + (1 - (1 - c) * p_perp - p y)) ≤ abstVal c S (fun _ => k) := by calc ∑ y ∈ S, (if y ∈ S then (1 : ℝ) / (S.card : ℝ) else 0) * (k + (1 - (1 - c) * p_perp - p y)) ≤ ∑ y ∈ S, (if y ∈ S then (1 : ℝ) / (S.card : ℝ) else 0) * abstVal c S (fun _ => k) := by refine Finset.sum_le_sum fun y hy => ?_ rw [if_pos hy] exact mul_le_mul_of_nonneg_left (hval y hy) (by positivity) _ = abstVal c S (fun _ => k) := by rw [← Finset.sum_mul, Finset.sum_ite_mem, Finset.inter_self, Finset.sum_const, nsmul_eq_mul] field_simp [ne_of_gt hcard_pos] have hhp1 : p_perp ≤ 1 := by have := Finset.sum_nonneg hpn; linarith have hb_eq : subsetIntercept (fun _ => k) S = k + (1 - 1 / (S.card : ℝ)) := by dsimp only [subsetIntercept] rw [Finset.sum_const, nsmul_eq_mul] field_simp [ne_of_gt hcard_pos]; ring have hm_eq : subsetSlope c S = c - (1 - 1 / (S.card : ℝ)) := subsetSlope_eq_sub c hS have hmin_le : k + min c (1 - 1 / (S.card : ℝ)) ≤ subsetIntercept (fun _ => k) S + subsetSlope c S * p_perp := by rw [hb_eq, hm_eq] by_cases hle : c ≤ 1 - 1 / (S.card : ℝ) · rw [min_eq_left hle]; nlinarith · rw [min_eq_right (le_of_not_ge hle)]; nlinarith linarith /-- **1-Round Multiclass Abstention Phase Transition**: whenever `1 - 1 / |S| ≤ c ≤ 1`, every nonempty subset `A ⊆ S` has `subsetSlope c A ≥ 0`, so abstaining is completely redundant and `abstVal c S v = abstVal 1 S v`! -/ theorem abstVal_eq_one_of_ge_threshold {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) (hthresh : 1 - 1 / (S.card : ℝ) ≤ c) (v : β → ℝ) : abstVal c S v = abstVal 1 S v := by apply le_antisymm (abstVal_mono_c hc0 hc1 le_rfl S v) -- Show `abstVal 1 S v ≤ abstVal c S v` using `abstVal_le_branches_iff`! set t := abstVal c S v have ht := (abstVal_le_branches_iff hS t).mp le_rfl rw [abstVal_le_branches_iff hS] have hslope_nn : ∀ A ⊆ S, A.Nonempty → 0 ≤ subsetSlope c A := by intro A hAS hAne rw [subsetSlope_eq_sub c hAne] have hA_le_S : (A.card : ℝ) ≤ (S.card : ℝ) := by exact_mod_cast Finset.card_le_card hAS have hA_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos have hinv : 1 / (S.card : ℝ) ≤ 1 / (A.card : ℝ) := one_div_le_one_div_of_le hA_pos hA_le_S linarith have hslope1_pos : ∀ A ⊆ S, A.Nonempty → 0 < subsetSlope 1 A := by intro A _ hAne dsimp only [subsetSlope] have hA_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos rw [sub_self, mul_zero, sub_zero] exact div_pos (by norm_num) hA_pos refine ⟨ht.1, fun A hAS hAne _ => ht.2.1 A hAS hAne (hslope_nn A hAS hAne), fun B hBS hBne hmB => absurd (hslope1_pos B hBS hBne) (not_lt.mpr hmB), fun A _ _ B hBS hBne _ hmB => absurd (hslope1_pos B hBS hBne) (not_lt.mpr (le_of_lt hmB))⟩ /-- **Exact Binary Closed Form for `c ∈ [0, 1 / 2]`**: on a 2-element set `{y₁, y₂}` with `v y₁ ≥ v y₂`, `abstVal c {y₁, y₂} v = max (v y₁) ((1 - c) * v y₁ + c * v y₂ + c)`. -/ theorem abstVal_binary_le_half {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc_half : c ≤ 1 / 2) {y₁ y₂ : β} (hne : y₁ ≠ y₂) {v : β → ℝ} (hge : v y₂ ≤ v y₁) : abstVal c ({y₁, y₂} : Finset β) v = max (v y₁) ((1 - c) * v y₁ + c * v y₂ + c) := by have hc1 : c ≤ 1 := by linarith have hS : ({y₁, y₂} : Finset β).Nonempty := ⟨y₁, by simp⟩ have hcard2 : ({y₁, y₂} : Finset β).card = 2 := Finset.card_pair hne apply le_antisymm · by_cases hgap : 1 ≤ v y₁ - v y₂ · have hmax : max (v y₁) ((1 - c) * v y₁ + c * v y₂ + c) = v y₁ := max_eq_left (by nlinarith) rw [hmax] refine abstVal_le_of_primal hc0 hc1 hS (p_perp := 0) (p := fun y => if y = y₁ then 1 else 0) le_rfl (fun y _ => by split_ifs <;> norm_num) (by simp [hne]) (fun y hy => ?_) simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl · simp · simp [hne.symm]; linarith · push Not at hgap have hmax : max (v y₁) ((1 - c) * v y₁ + c * v y₂ + c) = (1 - c) * v y₁ + c * v y₂ + c := max_eq_right (by nlinarith) rw [hmax] set p_perp : ℝ := 1 - (v y₁ - v y₂) refine abstVal_le_of_primal hc0 hc1 hS (p_perp := p_perp) (p := fun y => if y = y₁ then v y₁ - v y₂ else 0) (by dsimp only [p_perp]; linarith) (fun y _ => by split_ifs; linarith; exact le_rfl) (by dsimp only [p_perp]; simp [hne]) (fun y hy => ?_) simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl · dsimp only [p_perp]; simp; ring_nf; exact le_rfl · dsimp only [p_perp]; simp [hne.symm]; ring_nf; exact le_rfl · refine max_le (le_abstVal_of_mem (by simp)) ?_ obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS v have hsum2 : p_perp + p y₁ + p y₂ ≤ 1 := by have hs : ∑ y ∈ ({y₁, y₂} : Finset β), p y = p y₁ + p y₂ := Finset.sum_pair hne linarith have h1 := hval y₁ (by simp) have h2 := hval y₂ (by simp) have hp2 : 0 ≤ p y₂ := hpn y₂ (by simp) -- Multiply `h1` by `(1 - c)` and `h2` by `c`: -- `(1-c)*v1 + c*v2 + 1 - (1-c)*p_perp - (1-c)*p1 - c*p2 ≤ t`. -- Since `c ≤ 1/2`, `c ≤ 1 - c`, so `(1-c)*p_perp + (1-c)*p1 + c*p2 ≤ (1-c)*(p_perp + p1 + p2) ≤ 1 - c`! nlinarith /-- **Exact Binary Closed Form for `c ∈ [1 / 2, 1]`**: on `{y₁, y₂}` with `v y₁ ≥ v y₂`, `abstVal c {y₁, y₂} v = max (v y₁) ((v y₁ + v y₂ + 1) / 2)` (independent of `c`!). -/ theorem abstVal_binary_ge_half {β : Type*} [DecidableEq β] {c : ℝ} (hc_half : 1 / 2 ≤ c) (hc1 : c ≤ 1) {y₁ y₂ : β} (hne : y₁ ≠ y₂) {v : β → ℝ} (hge : v y₂ ≤ v y₁) : abstVal c ({y₁, y₂} : Finset β) v = max (v y₁) ((v y₁ + v y₂ + 1) / 2) := by have hc0 : 0 ≤ c := by linarith have hS : ({y₁, y₂} : Finset β).Nonempty := ⟨y₁, by simp⟩ have hcard2 : ({y₁, y₂} : Finset β).card = 2 := Finset.card_pair hne have heq1 : abstVal c ({y₁, y₂} : Finset β) v = abstVal (1 / 2) ({y₁, y₂} : Finset β) v := by have h1 := abstVal_eq_one_of_ge_threshold hc0 hc1 hS (by rw [hcard2]; norm_num; linarith) v have h2 := abstVal_eq_one_of_ge_threshold (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num) hS (by rw [hcard2]; norm_num) v exact h1.trans h2.symm rw [heq1, abstVal_binary_le_half (by norm_num) le_rfl hne hge] congr 1; ring /-- **1-Step Cost-Scaling Lemma for `abstVal`**: for `0 < c₁ ≤ c₂ ≤ 1`, `abstVal c₁ S ((c₁ / c₂) * v) ≥ (c₁ / c₂) * abstVal c₂ S v`. -/ lemma abstVal_c_scaling_step {β : Type*} [DecidableEq β] {c₁ c₂ : ℝ} (hc₁ : 0 < c₁) (hc12 : c₁ ≤ c₂) (hc₂1 : c₂ ≤ 1) {S : Finset β} (v : β → ℝ) : (c₁ / c₂) * abstVal c₂ S v ≤ abstVal c₁ S (fun y => (c₁ / c₂) * v y) := by by_cases hS : S.Nonempty · have hc₂_pos : 0 < c₂ := lt_of_lt_of_le hc₁ hc12 have hr_pos : 0 < c₁ / c₂ := div_pos hc₁ hc₂_pos obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper (le_of_lt hc₁) (le_trans hc12 hc₂1) hS (fun y => (c₁ / c₂) * v y) have hle : abstVal c₂ S v ≤ (c₂ / c₁) * abstVal c₁ S (fun y => (c₁ / c₂) * v y) := by refine abstVal_le_of_primal (le_of_lt hc₂_pos) hc₂1 hS hp0 hpn hsum fun y hy => ?_ have h1 := hval y hy have hpy : p_perp + p y ≤ 1 := by have := Finset.single_le_sum hpn hy; linarith have hratio_ge1 : 1 ≤ c₂ / c₁ := (one_le_div hc₁).mpr hc12 -- Instant loss at `c₂` is `c₂ * p_perp + (1 - p_perp - p y) ≤ (c₂ / c₁) * (c₁ * p_perp + (1 - p_perp - p y))`! have hloss : 1 - (1 - c₂) * p_perp - p y ≤ (c₂ / c₁) * (1 - (1 - c₁) * p_perp - p y) := by have hrew1 : 1 - (1 - c₂) * p_perp - p y = c₂ * p_perp + (1 - p_perp - p y) := by ring have hrew2 : (c₂ / c₁) * (1 - (1 - c₁) * p_perp - p y) = c₂ * p_perp + (c₂ / c₁) * (1 - p_perp - p y) := by field_simp [ne_of_gt hc₁]; ring rw [hrew1, hrew2] nlinarith have hmul := mul_le_mul_of_nonneg_left h1 (div_nonneg (le_of_lt hc₂_pos) (le_of_lt hc₁)) have hcancel : (c₂ / c₁) * ((c₁ / c₂) * v y + (1 - (1 - c₁) * p_perp - p y)) = v y + (c₂ / c₁) * (1 - (1 - c₁) * p_perp - p y) := by field_simp [ne_of_gt hc₁, ne_of_gt hc₂_pos] linarith have hmul := mul_le_mul_of_nonneg_left hle (le_of_lt hr_pos) have hcancel : (c₁ / c₂) * ((c₂ / c₁) * abstVal c₁ S (fun y => (c₁ / c₂) * v y)) = abstVal c₁ S (fun y => (c₁ / c₂) * v y) := by field_simp [ne_of_gt hc₁, ne_of_gt hc₂_pos] linarith · simp [abstVal, hS] /-- Binary natural-log entropy `h_e(c) = -c * log c - (1 - c) * log (1 - c)`. -/ noncomputable def binEntropy (c : ℝ) : ℝ := -c * Real.log c - (1 - c) * Real.log (1 - c) lemma binEntropy_pos {c : ℝ} (hc0 : 0 < c) (hc1 : c < 1) : 0 < binEntropy c := by dsimp only [binEntropy] have h1 : Real.log c < 0 := Real.log_neg hc0 hc1 have h2 : Real.log (1 - c) < 0 := Real.log_neg (by linarith) (by linarith) nlinarith /-- Weighted AM-GM / Gibbs inequality: for `c ∈ (0, 1)` and `w₁, w₂ > 0`, `(1 - c) * log w₁ + c * log w₂ + binEntropy c ≤ log (w₁ + w₂)`. -/ lemma weighted_log_add_entropy_le {c w₁ w₂ : ℝ} (hc0 : 0 < c) (hc1 : c < 1) (hw₁ : 0 < w₁) (hw₂ : 0 < w₂) : (1 - c) * Real.log w₁ + c * Real.log w₂ + binEntropy c ≤ Real.log (w₁ + w₂) := by have h1c : 0 < 1 - c := by linarith have hsum : 0 < w₁ + w₂ := by linarith -- Apply `log x ≤ x - 1` to `x₁ = w₁ / ((1 - c) * (w₁ + w₂))` and `x₂ = w₂ / (c * (w₁ + w₂))`! have hlog1 : Real.log (w₁ / ((1 - c) * (w₁ + w₂))) ≤ w₁ / ((1 - c) * (w₁ + w₂)) - 1 := Real.log_le_sub_one_of_pos (div_pos hw₁ (mul_pos h1c hsum)) have hlog2 : Real.log (w₂ / (c * (w₁ + w₂))) ≤ w₂ / (c * (w₁ + w₂)) - 1 := Real.log_le_sub_one_of_pos (div_pos hw₂ (mul_pos hc0 hsum)) rw [Real.log_div (ne_of_gt hw₁) (ne_of_gt (mul_pos h1c hsum)), Real.log_mul (ne_of_gt h1c) (ne_of_gt hsum)] at hlog1 rw [Real.log_div (ne_of_gt hw₂) (ne_of_gt (mul_pos hc0 hsum)), Real.log_mul (ne_of_gt hc0) (ne_of_gt hsum)] at hlog2 have hm1 := mul_le_mul_of_nonneg_left hlog1 (le_of_lt h1c) have hm2 := mul_le_mul_of_nonneg_left hlog2 (le_of_lt hc0) have hrhs : (1 - c) * (w₁ / ((1 - c) * (w₁ + w₂)) - 1) + c * (w₂ / (c * (w₁ + w₂)) - 1) = 0 := by field_simp [ne_of_gt h1c, ne_of_gt hc0, ne_of_gt hsum]; ring dsimp only [binEntropy] linarith /-- **1-Step Universal Multiclass Binary-Entropy Halving Lemma** (`0 < c ≤ 1 / 2`, ANY `|S| ≥ 2`): mixing ONLY between guessing the heaviest label `y₁ = argmax w` and abstaining reduces arbitrary multiclass halving to the exact binary entropy constant `C = c / binEntropy c`! -/ lemma abstVal_entropy_halving_step {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 < c) (hc_half : c ≤ 1 / 2) {S : Finset β} (hS2 : 2 ≤ S.card) {w : β → ℝ} (hw : ∀ y ∈ S, 0 < w y) (N : ℝ) (hN : ∑ y ∈ S, w y = N) : abstVal c S (fun y => (c / binEntropy c) * Real.log (w y)) ≤ (c / binEntropy c) * Real.log N := by have hc1 : c < 1 := by linarith have hS : S.Nonempty := Finset.card_pos.mp (by omega) have hH_pos : 0 < binEntropy c := binEntropy_pos hc0 hc1 set C := c / binEntropy c have hC_pos : 0 < C := div_pos hc0 hH_pos obtain ⟨y₁, hy₁, hy₁_max⟩ := Finset.exists_mem_eq_sup' hS w have hw₁ : 0 < w y₁ := hw y₁ hy₁ have hrem_pos : 0 < N - w y₁ := by have hne : (S.erase y₁).Nonempty := by have hcard : (S.erase y₁).card = S.card - 1 := Finset.card_erase_of_mem hy₁ exact Finset.card_pos.mp (by omega) rcases hne with ⟨y₂, hy₂⟩ have hy₂S : y₂ ∈ S := Finset.mem_of_mem_erase hy₂ have hy₂ne : y₂ ≠ y₁ := Finset.ne_of_mem_erase hy₂ have hsum_er : w y₁ + w y₂ ≤ ∑ y ∈ S, w y := by have hsub : ({y₁, y₂} : Finset β) ⊆ S := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl; exact hy₁; exact hy₂S calc w y₁ + w y₂ = ∑ y ∈ ({y₁, y₂} : Finset β), w y := (Finset.sum_pair hy₂ne.symm).symm _ ≤ ∑ y ∈ S, w y := Finset.sum_le_sum_of_subset_of_nonneg hsub fun y hy _ => le_of_lt (hw y hy) linarith [hw y₂ hy₂S] have hw_other : ∀ y ∈ S, y ≠ y₁ → w y ≤ N - w y₁ := by intro y hy hne have hsub : ({y₁, y} : Finset β) ⊆ S := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl; exact hy₁; exact hy have hpair : w y₁ + w y ≤ ∑ z ∈ S, w z := by calc w y₁ + w y = ∑ z ∈ ({y₁, y} : Finset β), w z := (Finset.sum_pair hne.symm).symm _ ≤ ∑ z ∈ S, w z := Finset.sum_le_sum_of_subset_of_nonneg hsub fun z hz _ => le_of_lt (hw z hz) linarith have hN_pos : 0 < N := by linarith set a := C * Real.log (w y₁) set b := C * Real.log (N - w y₁) have hgibbs : (1 - c) * a + c * b + c ≤ C * Real.log N := by have hwg := weighted_log_add_entropy_le hc0 hc1 hw₁ hrem_pos have hadd : w y₁ + (N - w y₁) = N := by ring rw [hadd] at hwg have hmul := mul_le_mul_of_nonneg_left hwg (le_of_lt hC_pos) have hCH : C * binEntropy c = c := div_mul_cancel₀ c (ne_of_gt hH_pos) dsimp only [a, b] linarith have ha_le : a ≤ C * Real.log N := mul_le_mul_of_nonneg_left (Real.log_le_log hw₁ (by linarith)) (le_of_lt hC_pos) -- Mix ONLY between guessing `y₁` (prob `1 - p_perp`) and abstaining (prob `p_perp`)! set p_perp : ℝ := max 0 (min 1 (1 - (a - b))) have hp_perp0 : 0 ≤ p_perp := le_max_left _ _ have hp_perp1 : p_perp ≤ 1 := max_le (by norm_num) (min_le_left _ _) refine abstVal_le_of_primal (le_of_lt hc0) (le_of_lt hc1) hS (p_perp := p_perp) (p := fun y => if y = y₁ then 1 - p_perp else 0) hp_perp0 (fun y _ => by split_ifs; linarith; exact le_rfl) (by rw [Finset.sum_ite_eq' S y₁, if_pos hy₁]; linarith) fun y hy => ?_ by_cases hy_eq : y = y₁ · subst hy_eq simp only [↓reduceIte] have hrew : C * Real.log (w y) + (1 - (1 - c) * p_perp - (1 - p_perp)) = a + c * p_perp := by dsimp only [a]; ring rw [hrew] by_cases h1 : 1 - (a - b) ≤ 0 · have hp0 : p_perp = 0 := by dsimp only [p_perp]; rw [min_eq_right (by linarith), max_eq_left h1] rw [hp0, mul_zero, add_zero]; exact ha_le · push Not at h1 have hple : p_perp ≤ 1 - (a - b) := by dsimp only [p_perp]; exact max_le (le_of_lt h1) (min_le_right _ _) nlinarith · simp only [if_neg hy_eq, sub_zero] have hwy_le : C * Real.log (w y) ≤ b := mul_le_mul_of_nonneg_left (Real.log_le_log (hw y hy) (hw_other y hy hy_eq)) (le_of_lt hC_pos) by_cases h2 : 1 ≤ 1 - (a - b) · have hp1 : p_perp = 1 := by dsimp only [p_perp]; rw [min_eq_left h2, max_eq_right (by norm_num)] rw [hp1] have hba : a ≤ b := by linarith have hb_le : b ≤ C * Real.log N := mul_le_mul_of_nonneg_left (Real.log_le_log hrem_pos (by linarith)) (le_of_lt hC_pos) -- Wait: if `b ≥ a` (so `N - w y₁ ≥ w y₁`), then `b + c ≤ C * log N`? -- Careful! `b + c` vs `(1-c)*a + c*b + c`: if `b ≥ a`, `b + c > (1-c)*a + c*b + c`! -- Let's check: when `b > a` (i.e. `w y₁ < N / 2`), EVERY `w y ≤ w y₁ < N / 2`! -- So `C * log (w y) ≤ a` (NOT just `b`!), and `a + c ≤ (1 - c)*a + c*b + c ≤ C * log N`! have hwy_le_a : C * Real.log (w y) ≤ a := by have hle_max : w y ≤ w y₁ := by rw [← hy₁_max]; exact Finset.le_sup' w hy exact mul_le_mul_of_nonneg_left (Real.log_le_log (hw y hy) hle_max) (le_of_lt hC_pos) nlinarith · push Not at h2 have hpge : 1 - (a - b) ≤ p_perp := by dsimp only [p_perp]; rw [min_eq_right (le_of_lt h2)]; exact le_max_right _ _ nlinarith /-- **1-Step Universal Multiclass `(1 / 2) log₂ |V|` Halving Lemma** (for `c = 1`, hence all `c ∈ [0, 1]` by monotonicity): for ANY `S` and positive weights `w` with `∑ w = N`, `abstVal 1 S ((1 / (2 * log 2)) * log w) ≤ (1 / (2 * log 2)) * log N`. -/ lemma abstVal_one_log2_halving_step {β : Type*} [DecidableEq β] {S : Finset β} (hS : S.Nonempty) {w : β → ℝ} (hw : ∀ y ∈ S, 0 < w y) (N : ℝ) (hN : ∑ y ∈ S, w y = N) : abstVal 1 S (fun y => (1 / (2 * Real.log 2)) * Real.log (w y)) ≤ (1 / (2 * Real.log 2)) * Real.log N := by have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) set C := 1 / (2 * Real.log 2) have hC : 0 < C := by positivity have hN_pos : 0 < N := by rcases hS with ⟨y0, hy0⟩ have := Finset.single_le_sum (fun y hy => le_of_lt (hw y hy)) hy0 linarith [hw y0 hy0] rw [abstVal_le_branches_iff hS] have hslope1_pos : ∀ A ⊆ S, A.Nonempty → 0 < subsetSlope 1 A := by intro A _ hAne dsimp only [subsetSlope] rw [sub_self, mul_zero, sub_zero] exact div_pos (by norm_num) (Nat.cast_pos.mpr hAne.card_pos) refine ⟨fun y hy => mul_le_mul_of_nonneg_left (Real.log_le_log (hw y hy) (by linarith [Finset.single_le_sum (fun z hz => le_of_lt (hw z hz)) hy])) (le_of_lt hC), fun A hAS hAne _ => ?_, fun B hBS hBne hmB => absurd (hslope1_pos B hBS hBne) (not_lt.mpr hmB), fun A _ _ B hBS hBne _ hmB => absurd (hslope1_pos B hBS hBne) (not_lt.mpr (le_of_lt hmB))⟩ have hr_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hAne.card_pos dsimp only [subsetIntercept] rw [div_le_iff₀ hr_pos] -- AM-GM on `A`: `∑ y ∈ A, log (w y) ≤ |A| * (log N - log |A|)`. have hsum_A : ∑ y ∈ A, w y ≤ N := by rw [← hN]; exact Finset.sum_le_sum_of_subset_of_nonneg hAS fun y hy _ => le_of_lt (hw y hy) have hlog_sum : ∑ y ∈ A, Real.log (w y) ≤ (A.card : ℝ) * (Real.log N - Real.log (A.card : ℝ)) := by have hNr : 0 < N / (A.card : ℝ) := div_pos hN_pos hr_pos have hpt : ∀ y ∈ A, Real.log (w y) - Real.log (N / (A.card : ℝ)) ≤ w y / (N / (A.card : ℝ)) - 1 := by intro y hy rw [← Real.log_div (ne_of_gt (hw y (hAS hy))) (ne_of_gt hNr)] exact Real.log_le_sub_one_of_pos (div_pos (hw y (hAS hy)) hNr) have htot := Finset.sum_le_sum hpt rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, mul_one, ← Finset.sum_div] at htot have hdiv_le : (∑ y ∈ A, w y) / (N / (A.card : ℝ)) ≤ (A.card : ℝ) := by rw [div_div_eq_mul_div, div_le_iff₀ hN_pos]; nlinarith rw [Real.log_div (ne_of_gt hN_pos) (ne_of_gt hr_pos)] at htot linarith -- Elementary bound: `r - 1 ≤ (1 / (2 * log 2)) * r * log r` for every `r ≥ 1`! have hr_ineq : (A.card : ℝ) - 1 ≤ C * (A.card : ℝ) * Real.log (A.card : ℝ) := by by_cases hr1 : A.card = 1 · rw [hr1]; simp · have hr2 : (2 : ℝ) ≤ (A.card : ℝ) := by exact_mod_cast (by have := hAne.card_pos; omega : 2 ≤ A.card) have hlogr : 0 < Real.log (A.card : ℝ) := Real.log_pos (by linarith) -- Since `log (r / 2) ≥ 1 - 2 / r` and `log 2 ≤ 1`, `(1 - 1/r) / log r ≤ (1/2) / log 2`! have hlog_ge : 1 - 2 / (A.card : ℝ) ≤ Real.log ((A.card : ℝ) / 2) := by have h1 := Real.log_le_sub_one_of_pos (div_pos (by norm_num : (0 : ℝ) < 2) hr_pos) have h2 : Real.log (2 / (A.card : ℝ)) = -Real.log ((A.card : ℝ) / 2) := by rw [Real.log_div (by norm_num) (ne_of_gt hr_pos), Real.log_div (ne_of_gt hr_pos) (by norm_num)]; ring linarith have hlog_split : Real.log (A.card : ℝ) = Real.log 2 + Real.log ((A.card : ℝ) / 2) := by rw [Real.log_div (ne_of_gt hr_pos) (by norm_num)]; ring have hlog2_le1 : Real.log 2 ≤ 1 := by have := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2); linarith have hstep : (1 - 1 / (A.card : ℝ)) * (2 * Real.log 2) ≤ Real.log (A.card : ℝ) := by rw [hlog_split] have hdiff : (1 - 1 / (A.card : ℝ)) * (2 * Real.log 2) - Real.log 2 = Real.log 2 * (1 - 2 / (A.card : ℝ)) := by ring have hnn : 0 ≤ 1 - 2 / (A.card : ℝ) := by rw [sub_nonneg, div_le_one hr_pos]; exact hr2 nlinarith have hmul := mul_le_mul_of_nonneg_left hstep (le_of_lt hr_pos) have hrew : (A.card : ℝ) * (1 - 1 / (A.card : ℝ)) = (A.card : ℝ) - 1 := by field_simp [ne_of_gt hr_pos] have hmul2 : ((A.card : ℝ) - 1) * (2 * Real.log 2) ≤ (A.card : ℝ) * Real.log (A.card : ℝ) := by linarith [show (A.card : ℝ) * ((1 - 1 / (A.card : ℝ)) * (2 * Real.log 2)) = ((A.card : ℝ) - 1) * (2 * Real.log 2) by rw [← mul_assoc, hrew]] have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 2 * Real.log 2)).mpr hmul2 dsimp only [C] calc (A.card : ℝ) - 1 ≤ (A.card : ℝ) * Real.log (A.card : ℝ) / (2 * Real.log 2) := hdiv _ = 1 / (2 * Real.log 2) * (A.card : ℝ) * Real.log (A.card : ℝ) := by ring have hsum_rew : ∑ y ∈ A, (C * Real.log (w y) + 1) = C * (∑ y ∈ A, Real.log (w y)) + (A.card : ℝ) := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, nsmul_eq_mul, mul_one] rw [hsum_rew] have hCmul := mul_le_mul_of_nonneg_left hlog_sum (le_of_lt hC) linarith /-! ## Part 2: Deterministic 1-Round Abstention Operator `dAbstStep` & Tent-Function Ratio -/ /-- 1-round deterministic abstention minimax step: learner either abstains (cost `c + max_{y ∈ S} d y`) or predicts a label `ŷ ∈ S` (cost `max (d ŷ) (1 + max_{y ≠ ŷ} d y)`). Equivalently, `dAbstStep c S d = min (c + sup_{y ∈ S} d y) (inf_{ŷ ∈ S} max (d ŷ) (sup_{y ∈ S \ {ŷ}} (d y + 1)))`. -/ noncomputable def dAbstStep {β : Type*} [DecidableEq β] (c : ℝ) (S : Finset β) (d : β → ℝ) : ℝ := if hS : S.Nonempty then min (S.sup' hS d + c) (S.inf' hS fun y0 => supOr (S.erase y0) (fun y => d y + 1) (d y0)) else 0 lemma dAbstStep_empty {β : Type*} [DecidableEq β] (c : ℝ) (d : β → ℝ) : dAbstStep c (∅ : Finset β) d = 0 := by simp [dAbstStep] lemma dAbstStep_le_iff {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} (hS : S.Nonempty) {d : β → ℝ} (t : ℝ) : dAbstStep c S d ≤ t ↔ (∀ y ∈ S, d y + c ≤ t) ∨ ∃ y0 ∈ S, d y0 ≤ t ∧ ∀ y ∈ S, y ≠ y0 → d y + 1 ≤ t := by rw [dAbstStep, dif_pos hS] simp only [min_le_iff, Finset.inf'_le_iff, supOr_le_iff, Finset.mem_erase, and_imp] constructor · rintro (h | ⟨y0, hy0, h1, h2⟩) · exact Or.inl fun y hy => by linarith [Finset.le_sup' d hy] · exact Or.inr ⟨y0, hy0, h1, fun y hy hne => h2 y hne hy⟩ · rintro (h | ⟨y0, hy0, h1, h2⟩) · refine Or.inl ?_ have hle : S.sup' hS d ≤ t - c := Finset.sup'_le hS d fun y hy => by linarith [h y hy] linarith · exact Or.inr ⟨y0, hy0, h1, fun y hne hy => h2 y hy hne⟩ lemma le_dAbstStep_of_mem {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) {S : Finset β} {d : β → ℝ} {y : β} (hy : y ∈ S) : d y ≤ dAbstStep c S d := by have hS : S.Nonempty := ⟨y, hy⟩ rcases (dAbstStep_le_iff hS (dAbstStep c S d)).mp le_rfl with h | ⟨y0, _, h1, h2⟩ · linarith [h y hy] · by_cases heq : y = y0 · subst heq; exact h1 · linarith [h2 y hy heq] lemma dAbstStep_congr {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} {d₁ d₂ : β → ℝ} (h : ∀ y ∈ S, d₁ y = d₂ y) : dAbstStep c S d₁ = dAbstStep c S d₂ := by by_cases hS : S.Nonempty · rw [dAbstStep, dif_pos hS, dAbstStep, dif_pos hS] congr 1 · rw [Finset.sup'_congr hS rfl h] · refine Finset.inf'_congr hS rfl fun y0 hy0 => ?_ rw [h y0 hy0] rw [supOr, supOr] split_ifs with hE · congr 1 exact Finset.sup'_congr hE rfl fun y hy => by rw [h y (Finset.mem_of_mem_erase hy)] · rfl · simp [dAbstStep, hS] lemma dAbstStep_nonneg {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) {S : Finset β} {d : β → ℝ} (hd : ∀ y ∈ S, 0 ≤ d y) : 0 ≤ dAbstStep c S d := by by_cases hS : S.Nonempty · rcases hS with ⟨y, hy⟩ exact le_trans (hd y hy) (le_dAbstStep_of_mem hc0 hy) · simp [dAbstStep, hS] lemma dAbstStep_mono_d {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} {d₁ d₂ : β → ℝ} (hd : ∀ y ∈ S, d₁ y ≤ d₂ y) : dAbstStep c S d₁ ≤ dAbstStep c S d₂ := by by_cases hS : S.Nonempty · rw [dAbstStep_le_iff hS] rcases (dAbstStep_le_iff hS (dAbstStep c S d₂)).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · exact Or.inl fun y hy => by linarith [hd y hy, h y hy] · exact Or.inr ⟨y0, hy0, le_trans (hd y0 hy0) h1, fun y hy hne => by linarith [hd y hy, h2 y hy hne]⟩ · simp [dAbstStep, hS] lemma dAbstStep_mono_c {β : Type*} [DecidableEq β] {c₁ c₂ : ℝ} (hc : c₁ ≤ c₂) (S : Finset β) (d : β → ℝ) : dAbstStep c₁ S d ≤ dAbstStep c₂ S d := by by_cases hS : S.Nonempty · rw [dAbstStep_le_iff hS] rcases (dAbstStep_le_iff hS (dAbstStep c₂ S d)).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · exact Or.inl fun y hy => by linarith [h y hy] · exact Or.inr ⟨y0, hy0, h1, h2⟩ · simp [dAbstStep, hS] lemma dAbstStep_mono_S {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) {S₁ S₂ : Finset β} (hS : S₁ ⊆ S₂) {d : β → ℝ} (hd : ∀ y ∈ S₂, 0 ≤ d y) : dAbstStep c S₁ d ≤ dAbstStep c S₂ d := by by_cases h1 : S₁.Nonempty · have h2 : S₂.Nonempty := h1.mono hS rw [dAbstStep_le_iff h1] rcases (dAbstStep_le_iff h2 (dAbstStep c S₂ d)).mp le_rfl with h | ⟨y0, hy0, h1', h2'⟩ · exact Or.inl fun y hy => h y (hS hy) · by_cases hy01 : y0 ∈ S₁ · exact Or.inr ⟨y0, hy01, h1', fun y hy hne => h2' y (hS hy) hne⟩ · rcases h1 with ⟨y1, hy1⟩ refine Or.inr ⟨y1, hy1, ?_, fun y hy _ => h2' y (hS hy) (fun heq => hy01 (heq ▸ hy))⟩ have hne : y1 ≠ y0 := fun heq => hy01 (heq ▸ hy1) linarith [h2' y1 (hS hy1) hne] · rw [Finset.not_nonempty_iff_eq_empty.mp h1, dAbstStep_empty] exact dAbstStep_nonneg hc0 hd lemma dAbstStep_add_const {β : Type*} [DecidableEq β] {c : ℝ} {S : Finset β} (hS : S.Nonempty) (d : β → ℝ) (k : ℝ) : dAbstStep c S (fun y => d y + k) = dAbstStep c S d + k := by apply le_antisymm · rw [dAbstStep_le_iff hS] rcases (dAbstStep_le_iff hS (dAbstStep c S d)).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · exact Or.inl fun y hy => by linarith [h y hy] · exact Or.inr ⟨y0, hy0, by linarith, fun y hy hne => by linarith [h2 y hy hne]⟩ · have hle : dAbstStep c S d ≤ dAbstStep c S (fun y => d y + k) - k := by rw [dAbstStep_le_iff hS] rcases (dAbstStep_le_iff hS (dAbstStep c S (fun y => d y + k))).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · exact Or.inl fun y hy => by linarith [h y hy] · exact Or.inr ⟨y0, hy0, by linarith, fun y hy hne => by linarith [h2 y hy hne]⟩ linarith lemma dAbstStep_const {β : Type*} [DecidableEq β] {c : ℝ} (_hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS2 : 2 ≤ S.card) (k : ℝ) : dAbstStep c S (fun _ => k) = k + c := by have hS : S.Nonempty := Finset.card_pos.mp (by omega) apply le_antisymm · rw [dAbstStep_le_iff hS]; exact Or.inl fun _ _ => le_rfl · rcases (dAbstStep_le_iff hS (dAbstStep c S (fun _ => k))).mp le_rfl with h | ⟨y0, hy0, _, h2⟩ · rcases hS with ⟨y, hy⟩; exact h y hy · have hne : (S.erase y0).Nonempty := Finset.card_pos.mp (by rw [Finset.card_erase_of_mem hy0]; omega) rcases hne with ⟨y1, hy1⟩ linarith [h2 y1 (Finset.mem_of_mem_erase hy1) (Finset.ne_of_mem_erase hy1)] /-- Exact binary closed form of `dAbstStep`: for `y₁ ≠ y₂` and `d y₂ ≤ d y₁`, `dAbstStep c {y₁, y₂} d = max (d y₁) (min (d y₁ + c) (d y₂ + 1))`. -/ lemma dAbstStep_binary {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) {y₁ y₂ : β} (hne : y₁ ≠ y₂) {d : β → ℝ} (hge : d y₂ ≤ d y₁) : dAbstStep c ({y₁, y₂} : Finset β) d = max (d y₁) (min (d y₁ + c) (d y₂ + 1)) := by have hS : ({y₁, y₂} : Finset β).Nonempty := ⟨y₁, by simp⟩ apply le_antisymm · rw [dAbstStep_le_iff hS] by_cases hle : d y₁ + c ≤ d y₂ + 1 · left intro y hy simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with hy1 | hy2 · rw [hy1]; exact le_trans (le_min le_rfl hle) (le_max_right _ _) · rw [hy2]; linarith [le_max_right (d y₁) (min (d y₁ + c) (d y₂ + 1)), min_eq_left hle] · right refine ⟨y₁, by simp, le_max_left _ _, fun y hy hne' => ?_⟩ simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with hy1 | hy2 · exact absurd hy1 hne' · rw [hy2]; exact le_trans (le_min (le_of_not_ge hle) le_rfl) (le_max_right _ _) · refine max_le (le_dAbstStep_of_mem hc0 (by simp)) ?_ rcases (dAbstStep_le_iff hS (dAbstStep c ({y₁, y₂} : Finset β) d)).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · exact le_trans (min_le_left _ _) (h y₁ (by simp)) · simp only [Finset.mem_insert, Finset.mem_singleton] at hy0 rcases hy0 with hy01 | hy02 · rw [hy01] at h2; exact le_trans (min_le_right _ _) (h2 y₂ (by simp) hne.symm) · rw [hy02] at h2; exact le_trans (min_le_right _ _) (by linarith [h2 y₁ (by simp) hne]) /-- **1-Step Primal Dominance**: `abstVal c S v ≤ dAbstStep c S v` (randomization never hurts!). -/ lemma abstVal_le_dAbstStep {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (S : Finset β) (v : β → ℝ) : abstVal c S v ≤ dAbstStep c S v := by by_cases hS : S.Nonempty · rcases (dAbstStep_le_iff hS (dAbstStep c S v)).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · exact abstVal_le_of_primal hc0 hc1 hS (p_perp := 1) (p := fun _ => 0) (by norm_num) (fun _ _ => le_rfl) (by simp) (fun y hy => by linarith [h y hy]) · refine abstVal_le_of_primal hc0 hc1 hS (p_perp := 0) (p := fun y => if y = y0 then 1 else 0) le_rfl (fun y _ => by split_ifs <;> norm_num) (by rw [Finset.sum_ite_eq' S y0, if_pos hy0]; linarith) (fun y hy => ?_) by_cases heq : y = y0 · subst heq; simp [h1] · simp [heq]; linarith [h2 y hy heq] · simp [abstVal, dAbstStep, hS] /-- The **Exact Tent-Function Ratio** `α*(c) = min (1 / (2 - c)) (1 / (1 + c))`: equals `1 / (2 - c)` on `[0, 1/2]`, peaks at `2 / 3` at `c = 1/2`, and equals `1 / (1 + c)` on `[1/2, 1]` (recovering `1 / 2` at `c = 1`). -/ noncomputable def tentRatio (c : ℝ) : ℝ := if c ≤ 1 / 2 then 1 / (2 - c) else 1 / (1 + c) lemma tentRatio_pos {c : ℝ} (_hc0 : 0 ≤ c) (hc1 : c ≤ 1) : 0 < tentRatio c := by dsimp only [tentRatio] split_ifs with h · exact div_pos (by norm_num) (by linarith) · exact div_pos (by norm_num) (by linarith) lemma tentRatio_le_one {c : ℝ} (_hc0 : 0 ≤ c) (hc1 : c ≤ 1) : tentRatio c ≤ 1 := by dsimp only [tentRatio] split_ifs with h · rw [div_le_one (by linarith)]; linarith · rw [div_le_one (by linarith)]; linarith lemma tentRatio_half : tentRatio (1 / 2) = 2 / 3 := by simp [tentRatio]; norm_num lemma tentRatio_one : tentRatio 1 = 1 / 2 := by rw [tentRatio, if_neg (by norm_num)]; norm_num /-- **1-Step Universal Multiclass Tent-Function Lower Bound**: for EVERY nonempty `S` of size `≥ 2`, EVERY `c ∈ [0, 1]`, and EVERY `d : β → ℝ` with `d ≥ 0`: `tentRatio c * dAbstStep c S d ≤ abstVal c S (fun y => tentRatio c * d y)`. -/ lemma tentRatio_mul_dAbstStep_le_abstVal {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS2 : 2 ≤ S.card) {d : β → ℝ} (hd : ∀ y ∈ S, 0 ≤ d y) : tentRatio c * dAbstStep c S d ≤ abstVal c S (fun y => tentRatio c * d y) := by have hS : S.Nonempty := Finset.card_pos.mp (by omega) have hα_pos : 0 < tentRatio c := tentRatio_pos hc0 hc1 -- Pick `y₁ = argmax_{y ∈ S} d y`, and `y₂ = argmax_{y ∈ S \ {y₁}} d y`! obtain ⟨y₁, hy₁, hy₁_eq⟩ := Finset.exists_mem_eq_sup' hS d have hE : (S.erase y₁).Nonempty := Finset.card_pos.mp (by rw [Finset.card_erase_of_mem hy₁]; omega) obtain ⟨y₂, hy₂E, hy₂_eq⟩ := Finset.exists_mem_eq_sup' hE d have hy₂ : y₂ ∈ S := Finset.mem_of_mem_erase hy₂E have hne : y₁ ≠ y₂ := (Finset.ne_of_mem_erase hy₂E).symm have hge : d y₂ ≤ d y₁ := by rw [← hy₁_eq]; exact Finset.le_sup' d hy₂ -- Observe `dAbstStep c S d ≤ max (d y₁) (min (d y₁ + c) (d y₂ + 1))`! have hd_le : dAbstStep c S d ≤ max (d y₁) (min (d y₁ + c) (d y₂ + 1)) := by rw [dAbstStep_le_iff hS] by_cases hle : d y₁ + c ≤ d y₂ + 1 · left intro y hy have hy_le : d y ≤ d y₁ := by rw [← hy₁_eq]; exact Finset.le_sup' d hy linarith [le_max_right (d y₁) (min (d y₁ + c) (d y₂ + 1)), min_eq_left hle] · right refine ⟨y₁, hy₁, le_max_left _ _, fun y hy hne' => ?_⟩ have hy_le : d y ≤ d y₂ := by rw [← hy₂_eq]; exact Finset.le_sup' d (Finset.mem_erase.mpr ⟨hne', hy⟩) linarith [le_max_right (d y₁) (min (d y₁ + c) (d y₂ + 1)), min_eq_right (le_of_not_ge hle)] -- Restrict `abstVal` to the 2-element subset `{y₁, y₂} ⊆ S`! have hpair_sub : ({y₁, y₂} : Finset β) ⊆ S := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl; exact hy₁; exact hy₂ have hmono := abstVal_mono_S hc0 hc1 hpair_sub (v := fun y => tentRatio c * d y) (fun y hy => mul_nonneg (le_of_lt hα_pos) (hd y hy)) have hge_scaled : tentRatio c * d y₂ ≤ tentRatio c * d y₁ := mul_le_mul_of_nonneg_left hge (le_of_lt hα_pos) set M := min (d y₁ + c) (d y₂ + 1) have hM1 : M - c ≤ d y₁ := by dsimp only [M]; linarith [min_le_left (d y₁ + c) (d y₂ + 1)] have hM2 : M - 1 ≤ d y₂ := by dsimp only [M]; linarith [min_le_right (d y₁ + c) (d y₂ + 1)] refine le_trans (mul_le_mul_of_nonneg_left hd_le (le_of_lt hα_pos)) (le_trans ?_ hmono) by_cases hchalf : c ≤ 1 / 2 · rw [abstVal_binary_le_half hc0 hchalf hne hge_scaled] have hα_eq : tentRatio c = 1 / (2 - c) := by rw [tentRatio, if_pos hchalf] have hα_ident : tentRatio c * (2 - c) = 1 := by rw [hα_eq]; field_simp [(by linarith : 2 - c ≠ 0)] rw [mul_max_of_nonneg _ _ (le_of_lt hα_pos)] refine max_le (le_max_left _ _) (le_trans ?_ (le_max_right _ _)) -- `(1 - c) * α * d1 + c * α * d2 + c ≥ α * M + c * (1 - α * (2 - c)) = α * M`! have h1 : (1 - c) * (tentRatio c * (M - c)) ≤ (1 - c) * (tentRatio c * d y₁) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hM1 (le_of_lt hα_pos)) (by linarith) have h2 : c * (tentRatio c * (M - 1)) ≤ c * (tentRatio c * d y₂) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hM2 (le_of_lt hα_pos)) hc0 have hrew : (1 - c) * (tentRatio c * (M - c)) + c * (tentRatio c * (M - 1)) + c = tentRatio c * M + c * (1 - tentRatio c * (2 - c)) := by ring rw [hα_ident, sub_self, mul_zero, add_zero] at hrew linarith · push Not at hchalf rw [abstVal_binary_ge_half (le_of_lt hchalf) hc1 hne hge_scaled] have hα_eq : tentRatio c = 1 / (1 + c) := by rw [tentRatio, if_neg (not_le.mpr hchalf)] have hα_ident : tentRatio c * (1 + c) = 1 := by rw [hα_eq]; field_simp [(by linarith : 1 + c ≠ 0)] rw [mul_max_of_nonneg _ _ (le_of_lt hα_pos)] refine max_le (le_max_left _ _) (le_trans ?_ (le_max_right _ _)) have h1 : tentRatio c * (M - c) ≤ tentRatio c * d y₁ := mul_le_mul_of_nonneg_left hM1 (le_of_lt hα_pos) have h2 : tentRatio c * (M - 1) ≤ tentRatio c * d y₂ := mul_le_mul_of_nonneg_left hM2 (le_of_lt hα_pos) have hrew : (tentRatio c * (M - c) + tentRatio c * (M - 1) + 1) / 2 = tentRatio c * M + (1 - tentRatio c * (1 + c)) / 2 := by ring rw [hα_ident, sub_self, zero_div, add_zero] at hrew linarith /-- **1-Step Cost-Scaling Lemma for `dAbstStep`**: for `0 < c₁ ≤ c₂ ≤ 1`, `(c₁ / c₂) * dAbstStep c₂ S d ≤ dAbstStep c₁ S ((c₁ / c₂) * d)`. -/ lemma dAbstStep_c_scaling_step {β : Type*} [DecidableEq β] {c₁ c₂ : ℝ} (hc₁ : 0 < c₁) (hc12 : c₁ ≤ c₂) {S : Finset β} (d : β → ℝ) : (c₁ / c₂) * dAbstStep c₂ S d ≤ dAbstStep c₁ S (fun y => (c₁ / c₂) * d y) := by by_cases hS : S.Nonempty · have hc₂_pos : 0 < c₂ := lt_of_lt_of_le hc₁ hc12 have hr_pos : 0 < c₁ / c₂ := div_pos hc₁ hc₂_pos have hr_le1 : c₁ / c₂ ≤ 1 := (div_le_one hc₂_pos).mpr hc12 have hle : dAbstStep c₂ S d ≤ (c₂ / c₁) * dAbstStep c₁ S (fun y => (c₁ / c₂) * d y) := by rw [dAbstStep_le_iff hS] rcases (dAbstStep_le_iff hS (dAbstStep c₁ S (fun y => (c₁ / c₂) * d y))).mp le_rfl with h | ⟨y0, hy0, h1, h2⟩ · left intro y hy have hy1 := h y hy have hmul := mul_le_mul_of_nonneg_left hy1 (div_nonneg (le_of_lt hc₂_pos) (le_of_lt hc₁)) have hcancel : (c₂ / c₁) * ((c₁ / c₂) * d y + c₁) = d y + c₂ := by field_simp [ne_of_gt hc₁, ne_of_gt hc₂_pos] linarith · right refine ⟨y0, hy0, ?_, fun y hy hne => ?_⟩ · have hmul := mul_le_mul_of_nonneg_left h1 (div_nonneg (le_of_lt hc₂_pos) (le_of_lt hc₁)) have hcancel : (c₂ / c₁) * ((c₁ / c₂) * d y0) = d y0 := by field_simp [ne_of_gt hc₁, ne_of_gt hc₂_pos] linarith · have hmul := mul_le_mul_of_nonneg_left (h2 y hy hne) (div_nonneg (le_of_lt hc₂_pos) (le_of_lt hc₁)) have hcancel : (c₂ / c₁) * ((c₁ / c₂) * d y + 1) = d y + c₂ / c₁ := by field_simp [ne_of_gt hc₁, ne_of_gt hc₂_pos] have hge1 : 1 ≤ c₂ / c₁ := (one_le_div hc₁).mpr hc12 linarith have hmul := mul_le_mul_of_nonneg_left hle (le_of_lt hr_pos) have hcancel : (c₁ / c₂) * ((c₂ / c₁) * dAbstStep c₁ S (fun y => (c₁ / c₂) * d y)) = dAbstStep c₁ S (fun y => (c₁ / c₂) * d y) := by field_simp [ne_of_gt hc₁, ne_of_gt hc₂_pos] linarith · simp [dAbstStep, hS] /-- **1-Step Universal Multiclass Characteristic-Root Halving Lemma for Deterministic Abstention**: if `x ∈ (0, 1)` satisfies `1 ≤ x ^ c + x` (in particular, the exact characteristic root `x ^ c + x = 1`), then for EVERY `S` (`|S| ≥ 2`) and positive weights `w` with `∑ w = N`, `dAbstStep c S ((1 / log (1 / x)) * log w) ≤ (1 / log (1 / x)) * log N`! -/ lemma dAbstStep_charRoot_halving_step {β : Type*} [DecidableEq β] {c x : ℝ} (_hc0 : 0 < c) (hx0 : 0 < x) (hx1 : x < 1) (hroot : 1 ≤ x ^ c + x) {S : Finset β} (hS : S.Nonempty) {w : β → ℝ} (hw : ∀ y ∈ S, 0 < w y) (N : ℝ) (hN : ∑ y ∈ S, w y = N) : dAbstStep c S (fun y => (1 / Real.log (1 / x)) * Real.log (w y)) ≤ (1 / Real.log (1 / x)) * Real.log N := by have hinv_gt1 : 1 < 1 / x := (one_lt_div hx0).mpr hx1 have hL_pos : 0 < Real.log (1 / x) := Real.log_pos hinv_gt1 set C := 1 / Real.log (1 / x) have hC_pos : 0 < C := div_pos (by norm_num) hL_pos have hN_pos : 0 < N := by rcases hS with ⟨y0, hy0⟩ linarith [hw y0 hy0, Finset.single_le_sum (fun y hy => le_of_lt (hw y hy)) hy0] obtain ⟨y₁, hy₁, hy₁_eq⟩ := Finset.exists_mem_eq_sup' hS w rw [dAbstStep_le_iff hS] by_cases hbig : w y₁ ≤ x ^ c * N · left intro y hy have hwy : w y ≤ x ^ c * N := le_trans (by rw [← hy₁_eq]; exact Finset.le_sup' w hy) hbig have hlog_le : Real.log (w y) ≤ Real.log (x ^ c * N) := Real.log_le_log (hw y hy) hwy have hlog_xc : Real.log (x ^ c * N) = -c * Real.log (1 / x) + Real.log N := by rw [Real.log_mul (ne_of_gt (Real.rpow_pos_of_pos hx0 c)) (ne_of_gt hN_pos), Real.log_rpow hx0, Real.log_div (by norm_num) (ne_of_gt hx0), Real.log_one] ring rw [hlog_xc] at hlog_le have hmul := mul_le_mul_of_nonneg_left hlog_le (le_of_lt hC_pos) have hcancel : C * (-c * Real.log (1 / x) + Real.log N) = C * Real.log N - c := by dsimp only [C]; field_simp [ne_of_gt hL_pos]; ring linarith · right push Not at hbig refine ⟨y₁, hy₁, ?_, fun y hy hne => ?_⟩ · have hwy₁_le : w y₁ ≤ N := by rw [← hN]; exact Finset.single_le_sum (fun z hz => le_of_lt (hw z hz)) hy₁ exact mul_le_mul_of_nonneg_left (Real.log_le_log (hw y₁ hy₁) hwy₁_le) (le_of_lt hC_pos) · -- Since `w y₁ > x ^ c * N` and `1 ≤ x ^ c + x`, every `y ≠ y₁` has `w y ≤ N - w y₁ ≤ x * N`! have hpair : w y₁ + w y ≤ N := by have hsub : ({y₁, y} : Finset β) ⊆ S := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl; exact hy₁; exact hy rw [← hN] calc w y₁ + w y = ∑ z ∈ ({y₁, y} : Finset β), w z := (Finset.sum_pair hne.symm).symm _ ≤ ∑ z ∈ S, w z := Finset.sum_le_sum_of_subset_of_nonneg hsub fun z hz _ => le_of_lt (hw z hz) have hwy : w y ≤ x * N := by have hmul_root : N ≤ x ^ c * N + x * N := by nlinarith linarith have hlog_le : Real.log (w y) ≤ Real.log (x * N) := Real.log_le_log (hw y hy) hwy have hlog_x : Real.log (x * N) = -Real.log (1 / x) + Real.log N := by rw [Real.log_mul (ne_of_gt hx0) (ne_of_gt hN_pos), Real.log_div (by norm_num) (ne_of_gt hx0), Real.log_one] ring rw [hlog_x] at hlog_le have hmul := mul_le_mul_of_nonneg_left hlog_le (le_of_lt hC_pos) have hcancel : C * (-Real.log (1 / x) + Real.log N) = C * Real.log N - 1 := by dsimp only [C]; field_simp [ne_of_gt hL_pos]; ring linarith /-! ## Part 3: Deterministic `ALdim` & Randomized `RALdim` Online Abstention Dimensions -/ /-- Version-space restriction to hypotheses predicting `y` at `x`. -/ def restrict {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : Finset (α → β) := V.filter (fun h => h x = y) /-- Distinct labels predicted on `x` by hypotheses in `V`. -/ def labels {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) : Finset β := V.image (fun h => h x) lemma restrict_subset {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : restrict V x y ⊆ V := Finset.filter_subset _ V 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 hsub : restrict V x y ⊂ V := by refine Finset.ssubset_iff_subset_ne.mpr ⟨restrict_subset V x y, fun heq => ?_⟩ have hle1 : (labels V x).card ≤ 1 := by rw [labels] have hsub_sing : V.image (fun h => h x) ⊆ {y} := by intro z hz rcases Finset.mem_image.mp hz with ⟨h, hh, rfl⟩ rw [← heq] at hh exact Finset.mem_singleton.mpr (Finset.mem_filter.mp hh).2 exact le_trans (Finset.card_le_card hsub_sing) (by simp) omega exact Finset.card_lt_card hsub lemma sum_card_restrict {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) : ∑ y ∈ labels V x, (restrict V x y).card = V.card := (Finset.card_eq_sum_card_fiberwise (f := fun h : α → β => h x) (s := V) (t := labels V x) (fun h hh => Finset.mem_image.mpr ⟨h, hh, rfl⟩)).symm /-- **Deterministic Abstention Littlestone Dimension** `ALdim c V` at abstention cost `c ∈ [0, 1]`. -/ noncomputable def ALdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else if hα : (Finset.univ : Finset α).Nonempty then Finset.univ.sup' hα fun x : α => if hsplit : 2 ≤ (labels V x).card then dAbstStep c (labels V x) fun y => have _ : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y ALdim c (restrict V x y) else 0 else 0 termination_by V.card /-- **Randomized Abstention Littlestone Dimension** `RALdim c V` at abstention cost `c ∈ [0, 1]`. -/ noncomputable def RALdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else if hα : (Finset.univ : Finset α).Nonempty then Finset.univ.sup' hα fun x : α => if hsplit : 2 ≤ (labels V x).card then abstVal c (labels V x) fun y => have _ : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y RALdim c (restrict V x y) else 0 else 0 termination_by V.card lemma ALdim_eq_zero_of_card_le_one {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) {V : Finset (α → β)} (hV : V.card ≤ 1) : ALdim c V = 0 := by rw [ALdim, if_pos hV] lemma RALdim_eq_zero_of_card_le_one {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) {V : Finset (α → β)} (hV : V.card ≤ 1) : RALdim c V = 0 := by rw [RALdim, if_pos hV] lemma ALdim_nonneg {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (V : Finset (α → β)) : 0 ≤ ALdim c V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn rw [ALdim] split_ifs with hV hα · exact le_rfl · rcases hα with ⟨x0, hx0⟩ refine le_trans ?_ (Finset.le_sup' (f := fun x : α => if hsplit : 2 ≤ (labels V x).card then dAbstStep c (labels V x) fun y => ALdim c (restrict V x y) else 0) hx0) split_ifs with hsplit · exact dAbstStep_nonneg hc0 fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl · exact le_rfl · exact le_rfl lemma RALdim_nonneg {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) : 0 ≤ RALdim c V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn rw [RALdim] split_ifs with hV hα · exact le_rfl · rcases hα with ⟨x0, hx0⟩ refine le_trans ?_ (Finset.le_sup' (f := fun x : α => if hsplit : 2 ≤ (labels V x).card then abstVal c (labels V x) fun y => RALdim c (restrict V x y) else 0) hx0) split_ifs with hsplit · exact abstVal_nonneg fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl · exact le_rfl · exact le_rfl lemma ALdim_ge_dAbstStep {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) (x : α) (hsplit : 2 ≤ (labels V x).card) : dAbstStep c (labels V x) (fun y => ALdim c (restrict V x y)) ≤ ALdim c V := by have hV_gt1 : ¬ V.card ≤ 1 := by have : (labels V x).card ≤ V.card := Finset.card_image_le; omega have hα : (Finset.univ : Finset α).Nonempty := ⟨x, Finset.mem_univ x⟩ rw [ALdim, if_neg hV_gt1, dif_pos hα] have hle := Finset.le_sup' (f := fun x' : α => if h : 2 ≤ (labels V x').card then dAbstStep c (labels V x') fun y => ALdim c (restrict V x' y) else 0) (Finset.mem_univ x) rw [dif_pos hsplit] at hle exact hle lemma ALdim_le_of_forall_x {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) {t : ℝ} (ht : 0 ≤ t) (hx : ∀ x : α, 2 ≤ (labels V x).card → dAbstStep c (labels V x) (fun y => ALdim c (restrict V x y)) ≤ t) : ALdim c V ≤ t := by rw [ALdim] split_ifs with hV hα · exact ht · refine Finset.sup'_le hα _ fun x _ => ?_ split_ifs with hsplit · exact hx x hsplit · exact ht · exact ht lemma RALdim_ge_abstVal {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) (x : α) (hsplit : 2 ≤ (labels V x).card) : abstVal c (labels V x) (fun y => RALdim c (restrict V x y)) ≤ RALdim c V := by have hV_gt1 : ¬ V.card ≤ 1 := by have : (labels V x).card ≤ V.card := Finset.card_image_le; omega have hα : (Finset.univ : Finset α).Nonempty := ⟨x, Finset.mem_univ x⟩ rw [RALdim, if_neg hV_gt1, dif_pos hα] have hle := Finset.le_sup' (f := fun x' : α => if h : 2 ≤ (labels V x').card then abstVal c (labels V x') fun y => RALdim c (restrict V x' y) else 0) (Finset.mem_univ x) rw [dif_pos hsplit] at hle exact hle lemma RALdim_le_of_forall_x {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) {t : ℝ} (ht : 0 ≤ t) (hx : ∀ x : α, 2 ≤ (labels V x).card → abstVal c (labels V x) (fun y => RALdim c (restrict V x y)) ≤ t) : RALdim c V ≤ t := by rw [RALdim] split_ifs with hV hα · exact ht · refine Finset.sup'_le hα _ fun x _ => ?_ split_ifs with hsplit · exact hx x hsplit · exact ht · exact ht theorem ALdim_mono {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) {V₁ V₂ : Finset (α → β)} (hsub : V₁ ⊆ V₂) : ALdim c V₁ ≤ ALdim c V₂ := by induction hn : V₁.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => subst hn refine ALdim_le_of_forall_x c V₁ (ALdim_nonneg hc0 V₂) fun x hsplit1 => ?_ have hlab : labels V₁ x ⊆ labels V₂ x := Finset.image_subset_image hsub have hsplit2 : 2 ≤ (labels V₂ x).card := le_trans hsplit1 (Finset.card_le_card hlab) calc dAbstStep c (labels V₁ x) (fun y => ALdim c (restrict V₁ x y)) ≤ dAbstStep c (labels V₁ x) (fun y => ALdim c (restrict V₂ x y)) := dAbstStep_mono_d fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit1 y) (Finset.filter_subset_filter _ hsub) rfl _ ≤ dAbstStep c (labels V₂ x) (fun y => ALdim c (restrict V₂ x y)) := dAbstStep_mono_S hc0 hlab fun y _ => ALdim_nonneg hc0 _ _ ≤ ALdim c V₂ := ALdim_ge_dAbstStep c V₂ x hsplit2 theorem RALdim_mono {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {V₁ V₂ : Finset (α → β)} (hsub : V₁ ⊆ V₂) : RALdim c V₁ ≤ RALdim c V₂ := by induction hn : V₁.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => subst hn refine RALdim_le_of_forall_x c V₁ (RALdim_nonneg c V₂) fun x hsplit1 => ?_ have hlab : labels V₁ x ⊆ labels V₂ x := Finset.image_subset_image hsub have hsplit2 : 2 ≤ (labels V₂ x).card := le_trans hsplit1 (Finset.card_le_card hlab) calc abstVal c (labels V₁ x) (fun y => RALdim c (restrict V₁ x y)) ≤ abstVal c (labels V₁ x) (fun y => RALdim c (restrict V₂ x y)) := abstVal_mono_v hc0 hc1 fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit1 y) (Finset.filter_subset_filter _ hsub) rfl _ ≤ abstVal c (labels V₂ x) (fun y => RALdim c (restrict V₂ x y)) := abstVal_mono_S hc0 hc1 hlab fun y _ => RALdim_nonneg c _ _ ≤ RALdim c V₂ := RALdim_ge_abstVal c V₂ x hsplit2 theorem ALdim_mono_c {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c₁ c₂ : ℝ} (hc₁0 : 0 ≤ c₁) (hc12 : c₁ ≤ c₂) (V : Finset (α → β)) : ALdim c₁ V ≤ ALdim c₂ V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn refine ALdim_le_of_forall_x c₁ V (ALdim_nonneg (le_trans hc₁0 hc12) V) fun x hsplit => ?_ calc dAbstStep c₁ (labels V x) (fun y => ALdim c₁ (restrict V x y)) ≤ dAbstStep c₁ (labels V x) (fun y => ALdim c₂ (restrict V x y)) := dAbstStep_mono_d fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl _ ≤ dAbstStep c₂ (labels V x) (fun y => ALdim c₂ (restrict V x y)) := dAbstStep_mono_c hc12 _ _ _ ≤ ALdim c₂ V := ALdim_ge_dAbstStep c₂ V x hsplit theorem RALdim_mono_c {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c₁ c₂ : ℝ} (hc₁0 : 0 ≤ c₁) (hc12 : c₁ ≤ c₂) (hc₂1 : c₂ ≤ 1) (V : Finset (α → β)) : RALdim c₁ V ≤ RALdim c₂ V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn refine RALdim_le_of_forall_x c₁ V (RALdim_nonneg c₂ V) fun x hsplit => ?_ calc abstVal c₁ (labels V x) (fun y => RALdim c₁ (restrict V x y)) ≤ abstVal c₁ (labels V x) (fun y => RALdim c₂ (restrict V x y)) := abstVal_mono_v hc₁0 (le_trans hc12 hc₂1) fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl _ ≤ abstVal c₂ (labels V x) (fun y => RALdim c₂ (restrict V x y)) := abstVal_mono_c hc₁0 hc12 hc₂1 _ _ _ ≤ RALdim c₂ V := RALdim_ge_abstVal c₂ V x hsplit /-! ## Part 4: Full Multi-Round Online Abstention Game Minimax Equivalence -/ /-- A randomized abstention action on label space `β`: abstention probability `p_perp ≥ 0` and label prediction probabilities `p : β → ℝ` with `p_perp + ∑_{y ∈ S} p y ≤ 1` for every `S`. -/ structure AbstAction (β : Type*) where p_perp : ℝ p : β → ℝ hp_perp0 : 0 ≤ p_perp hp0 : ∀ y, 0 ≤ p y hsum : ∀ S : Finset β, p_perp + ∑ y ∈ S, p y ≤ 1 /-- Expected instant Chow risk of action `act` when the true label is `y` at abstention cost `c`. -/ noncomputable def AbstAction.instantLoss {β : Type*} (c : ℝ) (act : AbstAction β) (y : β) : ℝ := 1 - (1 - c) * act.p_perp - act.p y /-- A stateful randomized online learner with abstention option. -/ def RandomizedAbstLearner (α β : Type*) := Finset (α → β) → α → AbstAction β /-- An adaptive realizable adversary for online learning with abstention. -/ structure AdaptiveAbstAdversary (α β : Type*) [DecidableEq β] where move : (V : Finset (α → β)) → Option { p : α × (β → ℝ) // 2 ≤ (labels V p.1).card ∧ (∀ y ∈ labels V p.1, 0 ≤ p.2 y) ∧ (∑ y ∈ labels V p.1, p.2 y = 1) } /-- Expected cumulative Chow risk of learner `A` against adversary `Adv` starting from `V`. -/ noncomputable def expectedAbstLoss {α β : Type*} [DecidableEq β] (c : ℝ) (A : RandomizedAbstLearner α β) (Adv : AdaptiveAbstAdversary α β) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else match Adv.move V with | none => 0 | some ⟨⟨x, ν⟩, hsplit, _, _⟩ => ∑ y ∈ labels V x, ν y * ((A V x).instantLoss c y + have _ : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y expectedAbstLoss c A Adv (restrict V x y)) termination_by V.card /-- Helper packaging `abstVal_primal_upper` into an `AbstAction β`. -/ theorem exists_optAbstAction {β : Type*} [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ act : AbstAction β, ∀ y ∈ S, v y + act.instantLoss c y ≤ abstVal c S v := by obtain ⟨p_perp, p, hp0, hpn, hsum, hval⟩ := abstVal_primal_upper hc0 hc1 hS v refine ⟨⟨p_perp, fun y => if y ∈ S then p y else 0, hp0, fun y => by split_ifs with hy; exact hpn y hy; exact le_rfl, fun T => ?_⟩, fun y hy => ?_⟩ · have hle : ∑ y ∈ T, (if y ∈ S then p y else 0) ≤ ∑ y ∈ S, p y := by rw [Finset.sum_ite_mem] exact Finset.sum_le_sum_of_subset_of_nonneg Finset.inter_subset_right fun y hy _ => hpn y hy linarith · dsimp only [AbstAction.instantLoss] rw [if_pos hy] exact hval y hy /-- Minimax-optimal randomized online learner with abstention cost `c ∈ [0, 1]`. -/ noncomputable def optAbstLearner {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) : RandomizedAbstLearner α β := fun V x => if hS : (labels V x).Nonempty then (exists_optAbstAction hc0 hc1 hS (fun y => RALdim c (restrict V x y))).choose else ⟨1, fun _ => 0, by norm_num, fun _ => le_rfl, fun _ => by simp⟩ /-- **Primal Online Abstention Minimax Upper Bound**. -/ theorem optAbstLearner_expectedLoss_le {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (Adv : AdaptiveAbstAdversary α β) (V : Finset (α → β)) : expectedAbstLoss c (optAbstLearner hc0 hc1) Adv V ≤ RALdim c V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn rw [expectedAbstLoss] split_ifs with hV · exact RALdim_nonneg c V · cases hmv : Adv.move V with | none => exact RALdim_nonneg c V | some s => rcases s with ⟨⟨x, ν⟩, hsplit, hν0, hν1⟩ dsimp only at hsplit hν0 hν1 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hopt : ∀ y ∈ labels V x, RALdim c (restrict V x y) + (optAbstLearner hc0 hc1 V x).instantLoss c y ≤ abstVal c (labels V x) (fun z => RALdim c (restrict V x z)) := by intro y hy simp only [optAbstLearner, dif_pos hS] exact (exists_optAbstAction hc0 hc1 hS (fun z => RALdim c (restrict V x z))).choose_spec y hy calc ∑ y ∈ labels V x, ν y * ((optAbstLearner hc0 hc1 V x).instantLoss c y + expectedAbstLoss c (optAbstLearner hc0 hc1) Adv (restrict V x y)) ≤ ∑ y ∈ labels V x, ν y * abstVal c (labels V x) (fun z => RALdim c (restrict V x z)) := by refine Finset.sum_le_sum fun y hy => ?_ have hrec := ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl exact mul_le_mul_of_nonneg_left (by linarith [hopt y hy]) (hν0 y hy) _ = (∑ y ∈ labels V x, ν y) * abstVal c (labels V x) (fun z => RALdim c (restrict V x z)) := by rw [← Finset.sum_mul] _ = abstVal c (labels V x) (fun z => RALdim c (restrict V x z)) := by rw [hν1, one_mul] _ ≤ RALdim c V := RALdim_ge_abstVal c V x hsplit /-- Point selector score for the minimax-optimal abstention adversary. -/ noncomputable def optAbstAdvScore {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (c : ℝ) (V : Finset (α → β)) (x : α) : ℝ := if 2 ≤ (labels V x).card then abstVal c (labels V x) (fun y => RALdim c (restrict V x y)) else 0 /-- Minimax-optimal adaptive adversary for randomized online learning with abstention. -/ noncomputable def optAbstAdversary {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) : AdaptiveAbstAdversary α β where move V := if V.card ≤ 1 then none else if hα : (Finset.univ : Finset α).Nonempty then let x0 := (Finset.exists_mem_eq_sup' hα (optAbstAdvScore c V)).choose if hsplit : 2 ≤ (labels V x0).card then let hS : (labels V x0).Nonempty := Finset.card_pos.mp (by omega) let hdual := abstVal_dual_lower hc0 hS (fun y => RALdim c (restrict V x0 y)) some ⟨⟨x0, hdual.choose⟩, hsplit, hdual.choose_spec.1, hdual.choose_spec.2.1⟩ else none else none /-- **Dual Online Abstention Minimax Lower Bound**. -/ theorem optAbstAdversary_expectedLoss_ge {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (A : RandomizedAbstLearner α β) (V : Finset (α → β)) : RALdim c V ≤ expectedAbstLoss c A (optAbstAdversary hc0) V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn rw [expectedAbstLoss] by_cases hV : V.card ≤ 1 · rw [if_pos hV, RALdim_eq_zero_of_card_le_one c hV] · rw [if_neg hV] by_cases hα : (Finset.univ : Finset α).Nonempty · set x0 := (Finset.exists_mem_eq_sup' hα (optAbstAdvScore c V)).choose have hx0_eq : Finset.univ.sup' hα (optAbstAdvScore c V) = optAbstAdvScore c V x0 := (Finset.exists_mem_eq_sup' hα (optAbstAdvScore c V)).choose_spec.2 have hRL_eq : RALdim c V = optAbstAdvScore c V x0 := by rw [RALdim, if_neg hV, dif_pos hα]; exact hx0_eq by_cases hsplit : 2 ≤ (labels V x0).card · have hS : (labels V x0).Nonempty := Finset.card_pos.mp (by omega) set hdual := abstVal_dual_lower hc0 hS (fun y => RALdim c (restrict V x0 y)) set ν := hdual.choose have hν0 : ∀ y ∈ labels V x0, 0 ≤ ν y := hdual.choose_spec.1 have hν_lb := hdual.choose_spec.2.2 have hmove : (optAbstAdversary hc0).move V = some ⟨⟨x0, ν⟩, hsplit, hν0, hdual.choose_spec.2.1⟩ := by dsimp only [optAbstAdversary] rw [if_neg hV, dif_pos hα] change (if h : 2 ≤ (labels V x0).card then _ else none) = _ rw [dif_pos hsplit] rw [hmove] dsimp only have hf_val : optAbstAdvScore c V x0 = abstVal c (labels V x0) (fun y => RALdim c (restrict V x0 y)) := by simp only [optAbstAdvScore, if_pos hsplit] rw [hRL_eq, hf_val] have hp_perp1 : (A V x0).p_perp ≤ 1 := by have := (A V x0).hsum ∅; simp at this; exact this calc abstVal c (labels V x0) (fun y => RALdim c (restrict V x0 y)) ≤ ∑ y ∈ labels V x0, ν y * (RALdim c (restrict V x0 y) + (A V x0).instantLoss c y) := hν_lb (A V x0).p_perp (A V x0).p (A V x0).hp_perp0 hp_perp1 (fun y _ => (A V x0).hp0 y) ((A V x0).hsum (labels V x0)) _ ≤ ∑ y ∈ labels V x0, ν y * ((A V x0).instantLoss c y + expectedAbstLoss c A (optAbstAdversary hc0) (restrict V x0 y)) := by refine Finset.sum_le_sum fun y hy => ?_ have hrec := ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl exact mul_le_mul_of_nonneg_left (by linarith) (hν0 y hy) · have hmove : (optAbstAdversary hc0).move V = none := by dsimp only [optAbstAdversary] rw [if_neg hV, dif_pos hα] change (if h : 2 ≤ (labels V x0).card then _ else none) = none rw [dif_neg hsplit] rw [hmove, hRL_eq]; simp [optAbstAdvScore, hsplit] · have hmove : (optAbstAdversary hc0).move V = none := by dsimp only [optAbstAdversary]; rw [if_neg hV, dif_neg hα] rw [hmove, RALdim, if_neg hV, dif_neg hα] /-- **Exact Multi-Round Online Abstention Minimax Theorem**: `RALdim c V` is the exact minimax expected Chow risk of randomized online learning with abstention cost `c ∈ [0, 1]`. -/ theorem online_abst_minimax_exact {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (V : Finset (α → β)) : (∀ Adv : AdaptiveAbstAdversary α β, expectedAbstLoss c (optAbstLearner hc0 hc1) Adv V ≤ RALdim c V) ∧ (∀ A : RandomizedAbstLearner α β, RALdim c V ≤ expectedAbstLoss c A (optAbstAdversary hc0) V) ∧ expectedAbstLoss c (optAbstLearner hc0 hc1) (optAbstAdversary hc0) V = RALdim c V := ⟨fun Adv => optAbstLearner_expectedLoss_le hc0 hc1 Adv V, fun A => optAbstAdversary_expectedLoss_ge hc0 A V, le_antisymm (optAbstLearner_expectedLoss_le hc0 hc1 _ V) (optAbstAdversary_expectedLoss_ge hc0 _ V)⟩ /-! ## Part 5: Phase Transition, Tent-Function Randomization Ratio, & Exact Cost-Scaling Laws -/ /-- **Universal Multiclass Phase Transition at `c*_k = 1 - 1 / k`**: for EVERY `k`-class concept class (`|β| ≤ k`) and EVERY `c ∈ [1 - 1 / k, 1]`, abstention gives ZERO advantage to a randomized online learner: `RALdim c V = RALdim 1 V` (= no-abstention `RLdim`). -/ theorem RALdim_eq_noAbst_of_ge_threshold {α β : Type*} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (_hβ_pos : 1 ≤ Fintype.card β) (hthresh : 1 - 1 / (Fintype.card β : ℝ) ≤ c) (V : Finset (α → β)) : RALdim c V = RALdim 1 V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn apply le_antisymm (RALdim_mono_c hc0 hc1 le_rfl V) refine RALdim_le_of_forall_x 1 V (RALdim_nonneg c V) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hlab_le : ((labels V x).card : ℝ) ≤ (Fintype.card β : ℝ) := by exact_mod_cast Finset.card_le_univ (labels V x) have hlab_pos : (0 : ℝ) < ((labels V x).card : ℝ) := Nat.cast_pos.mpr hS.card_pos have hthresh_x : 1 - 1 / ((labels V x).card : ℝ) ≤ c := by have hinv : 1 / (Fintype.card β : ℝ) ≤ 1 / ((labels V x).card : ℝ) := one_div_le_one_div_of_le hlab_pos hlab_le linarith have hcongr : ∀ y ∈ labels V x, RALdim 1 (restrict V x y) = RALdim c (restrict V x y) := fun y _ => (ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl).symm rw [abstVal_congr (by norm_num) le_rfl hcongr, ← abstVal_eq_one_of_ge_threshold hc0 hc1 hS hthresh_x] exact RALdim_ge_abstVal c V x hsplit /-- **Binary Phase Transition Corollary (`c ≥ 1 / 2`)**: for EVERY binary concept class `V` (`β = Bool` or `Fin 2`) and EVERY `c ∈ [1 / 2, 1]`, `RALdim c V = RALdim 1 V`. -/ theorem RALdim_binary_eq_noAbst_of_ge_half {α : Type*} [Fintype α] [DecidableEq α] {c : ℝ} (hc_half : 1 / 2 ≤ c) (hc1 : c ≤ 1) (V : Finset (α → Bool)) : RALdim c V = RALdim 1 V := RALdim_eq_noAbst_of_ge_threshold (by linarith) hc1 (by simp) (by simp; linarith) V /-- **Universal Primal Dominance (`RALdim c V ≤ ALdim c V`)** for every `c ∈ [0, 1]` and arbitrary multiclass `V`. -/ theorem RALdim_le_ALdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (V : Finset (α → β)) : RALdim c V ≤ ALdim c V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn refine RALdim_le_of_forall_x c V (ALdim_nonneg hc0 V) fun x hsplit => ?_ calc abstVal c (labels V x) (fun y => RALdim c (restrict V x y)) ≤ abstVal c (labels V x) (fun y => ALdim c (restrict V x y)) := abstVal_mono_v hc0 hc1 fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl _ ≤ dAbstStep c (labels V x) (fun y => ALdim c (restrict V x y)) := abstVal_le_dAbstStep hc0 hc1 _ _ _ ≤ ALdim c V := ALdim_ge_dAbstStep c V x hsplit /-- **Universal Multiclass Tent-Function Randomization Ratio Theorem**: for EVERY finite concept class `V` over ANY label space `β` (binary, `k`-class, or infinite!) and EVERY abstention cost `c ∈ [0, 1]`: ``` tentRatio c * ALdim c V ≤ RALdim c V ≤ ALdim c V ``` where `tentRatio c = 1 / (2 - c)` for `c ≤ 1 / 2` (peaking at `2 / 3` at `c = 1 / 2`) and `tentRatio c = 1 / (1 + c)` for `c ≥ 1 / 2` (recovering `1 / 2` at `c = 1`). -/ theorem RALdim_ge_tentRatio_mul_ALdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (V : Finset (α → β)) : tentRatio c * ALdim c V ≤ RALdim c V := by have hα_pos : 0 < tentRatio c := tentRatio_pos hc0 hc1 induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hle : ALdim c V ≤ RALdim c V / tentRatio c := by refine ALdim_le_of_forall_x c V (div_nonneg (RALdim_nonneg c V) (le_of_lt hα_pos)) fun x hsplit => ?_ rw [le_div_iff₀ hα_pos, mul_comm] calc tentRatio c * dAbstStep c (labels V x) (fun y => ALdim c (restrict V x y)) ≤ abstVal c (labels V x) (fun y => tentRatio c * ALdim c (restrict V x y)) := tentRatio_mul_dAbstStep_le_abstVal hc0 hc1 hsplit fun y _ => ALdim_nonneg hc0 _ _ ≤ abstVal c (labels V x) (fun y => RALdim c (restrict V x y)) := abstVal_mono_v hc0 hc1 fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl _ ≤ RALdim c V := RALdim_ge_abstVal c V x hsplit exact (le_div_iff₀ hα_pos).mp hle |> fun h => by linarith /-- Peak `2 / 3` Corollary at `c = 1 / 2`: for EVERY multiclass concept class `V`, `(2 / 3) * ALdim (1 / 2) V ≤ RALdim (1 / 2) V`. -/ theorem RALdim_half_ge_two_thirds_ALdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (V : Finset (α → β)) : (2 / 3 : ℝ) * ALdim (1 / 2) V ≤ RALdim (1 / 2) V := by have h := RALdim_ge_tentRatio_mul_ALdim (c := 1 / 2) (by norm_num) (by norm_num) V rwa [tentRatio_half] at h /-- **Exact Cost-Scaling Law for Deterministic Abstention**: for `0 < c₁ ≤ c₂`, `(c₁ / c₂) * ALdim c₂ V ≤ ALdim c₁ V ≤ ALdim c₂ V`. In particular `c * ALdim 1 V ≤ ALdim c V`. -/ theorem ALdim_c_scaling {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c₁ c₂ : ℝ} (hc₁ : 0 < c₁) (hc12 : c₁ ≤ c₂) (V : Finset (α → β)) : (c₁ / c₂) * ALdim c₂ V ≤ ALdim c₁ V ∧ ALdim c₁ V ≤ ALdim c₂ V := by refine ⟨?_, ALdim_mono_c (le_of_lt hc₁) hc12 V⟩ have hc₂ : 0 < c₂ := lt_of_lt_of_le hc₁ hc12 have hr_pos : 0 < c₁ / c₂ := div_pos hc₁ hc₂ induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hle : ALdim c₂ V ≤ ALdim c₁ V / (c₁ / c₂) := by refine ALdim_le_of_forall_x c₂ V (div_nonneg (ALdim_nonneg (le_of_lt hc₁) V) (le_of_lt hr_pos)) fun x hsplit => ?_ rw [le_div_iff₀ hr_pos, mul_comm] calc (c₁ / c₂) * dAbstStep c₂ (labels V x) (fun y => ALdim c₂ (restrict V x y)) ≤ dAbstStep c₁ (labels V x) (fun y => (c₁ / c₂) * ALdim c₂ (restrict V x y)) := dAbstStep_c_scaling_step hc₁ hc12 _ _ ≤ dAbstStep c₁ (labels V x) (fun y => ALdim c₁ (restrict V x y)) := dAbstStep_mono_d fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl _ ≤ ALdim c₁ V := ALdim_ge_dAbstStep c₁ V x hsplit exact (le_div_iff₀ hr_pos).mp hle |> fun h => by linarith /-- **Exact Cost-Scaling Law for Randomized Abstention**: for `0 < c₁ ≤ c₂ ≤ 1`, `(c₁ / c₂) * RALdim c₂ V ≤ RALdim c₁ V ≤ RALdim c₂ V`. -/ theorem RALdim_c_scaling {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c₁ c₂ : ℝ} (hc₁ : 0 < c₁) (hc12 : c₁ ≤ c₂) (hc₂1 : c₂ ≤ 1) (V : Finset (α → β)) : (c₁ / c₂) * RALdim c₂ V ≤ RALdim c₁ V ∧ RALdim c₁ V ≤ RALdim c₂ V := by refine ⟨?_, RALdim_mono_c (le_of_lt hc₁) hc12 hc₂1 V⟩ have hc₂ : 0 < c₂ := lt_of_lt_of_le hc₁ hc12 have hr_pos : 0 < c₁ / c₂ := div_pos hc₁ hc₂ induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hle : RALdim c₂ V ≤ RALdim c₁ V / (c₁ / c₂) := by refine RALdim_le_of_forall_x c₂ V (div_nonneg (RALdim_nonneg c₁ V) (le_of_lt hr_pos)) fun x hsplit => ?_ rw [le_div_iff₀ hr_pos, mul_comm] calc (c₁ / c₂) * abstVal c₂ (labels V x) (fun y => RALdim c₂ (restrict V x y)) ≤ abstVal c₁ (labels V x) (fun y => (c₁ / c₂) * RALdim c₂ (restrict V x y)) := abstVal_c_scaling_step hc₁ hc12 hc₂1 _ _ ≤ abstVal c₁ (labels V x) (fun y => RALdim c₁ (restrict V x y)) := abstVal_mono_v (le_of_lt hc₁) (le_trans hc12 hc₂1) fun y _ => ih _ (card_restrict_lt_of_two_labels hsplit y) _ rfl _ ≤ RALdim c₁ V := RALdim_ge_abstVal c₁ V x hsplit exact (le_div_iff₀ hr_pos).mp hle |> fun h => by linarith /-- **Exact `k`-Class Cost-Scaling Sandwich**: for EVERY `k`-class concept class (`|β| = k ≥ 2`) and EVERY `c ∈ (0, 1 - 1 / k]`, `(k / (k - 1)) * c * RALdim 1 V ≤ RALdim c V ≤ RALdim 1 V`. In particular, for binary (`k = 2`), `2 * c * RALdim 1 V ≤ RALdim c V ≤ RALdim 1 V`! -/ theorem RALdim_kClass_scaling_sandwich {α β : Type*} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] (hβ2 : 2 ≤ Fintype.card β) {c : ℝ} (hc0 : 0 < c) (hc_le : c ≤ 1 - 1 / (Fintype.card β : ℝ)) (V : Finset (α → β)) : ((Fintype.card β : ℝ) / ((Fintype.card β : ℝ) - 1)) * c * RALdim 1 V ≤ RALdim c V ∧ RALdim c V ≤ RALdim 1 V := by set k : ℝ := (Fintype.card β : ℝ) have hk2 : 2 ≤ k := show (2 : ℝ) ≤ (Fintype.card β : ℝ) from by exact_mod_cast hβ2 have hk_pos : 0 < k := by linarith have hk1_pos : 0 < k - 1 := by linarith set c_star : ℝ := 1 - 1 / k have hc_star_le1 : c_star ≤ 1 := by dsimp only [c_star] have h1k : 0 < 1 / k := by positivity linarith have hsc := RALdim_c_scaling hc0 hc_le hc_star_le1 V have heq : RALdim c_star V = RALdim 1 V := RALdim_eq_noAbst_of_ge_threshold (by linarith) hc_star_le1 (by omega) le_rfl V rw [heq] at hsc have hrat : c / c_star = (k / (k - 1)) * c := by have hc_star_eq : c_star = (k - 1) / k := by dsimp only [c_star]; rw [sub_div, div_self (ne_of_gt hk_pos)] rw [hc_star_eq, div_div_eq_mul_div, mul_comm c k, div_mul_eq_mul_div] rw [hrat] at hsc exact ⟨hsc.1, RALdim_mono_c (le_of_lt hc0) (le_trans hc_le hc_star_le1) le_rfl V⟩ /-! ## Part 6: Universal Multiclass Halving Theorems (Binary Entropy, Golden Ratio, & Generalized Fibonacci) -/ /-- **Universal Multiclass Binary-Entropy Halving Theorem for Randomized Abstention (`0 < c ≤ 1/2`)**: For EVERY finite nonempty concept class `V` over ANY label space `β` (zero dependence on `|β|`!): `RALdim c V ≤ (c / binEntropy c) * Real.log |V|`. -/ theorem RALdim_le_entropy_halving {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 < c) (hc_half : c ≤ 1 / 2) {V : Finset (α → β)} (hV : V.Nonempty) : RALdim c V ≤ (c / binEntropy c) * Real.log (V.card : ℝ) := by have hc1 : c < 1 := by linarith have hH_pos : 0 < binEntropy c := binEntropy_pos hc0 hc1 have hC_pos : 0 < c / binEntropy c := div_pos hc0 hH_pos 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 RALdim_le_of_forall_x c V (mul_nonneg (le_of_lt hC_pos) hlog_nn) fun x hsplit => ?_ calc abstVal c (labels V x) (fun y => RALdim c (restrict V x y)) ≤ abstVal c (labels V x) (fun y => (c / binEntropy c) * Real.log ((restrict V x y).card : ℝ)) := by refine abstVal_mono_v (le_of_lt hc0) (le_of_lt hc1) fun y hy => ?_ exact ih _ (card_restrict_lt_of_two_labels hsplit y) ((restrict_nonempty_iff V x y).mpr hy) rfl _ ≤ (c / binEntropy c) * Real.log (V.card : ℝ) := by refine abstVal_entropy_halving_step hc0 hc_half hsplit (w := fun y => ((restrict V x y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x y).mpr hy).card_pos) (V.card : ℝ) (by exact_mod_cast sum_card_restrict V x) /-- **Universal Multiclass `(1 / 2) log₂ |V|` Halving Theorem for ALL `c ∈ [0, 1]`**: `RALdim c V ≤ (1 / (2 * Real.log 2)) * Real.log |V|`. -/ theorem RALdim_le_half_log2_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {V : Finset (α → β)} (hV : V.Nonempty) : RALdim c V ≤ (1 / (2 * Real.log 2)) * Real.log (V.card : ℝ) := by refine le_trans (RALdim_mono_c hc0 hc1 le_rfl V) ?_ have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) have hC_nn : 0 ≤ 1 / (2 * Real.log 2) := 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 RALdim_le_of_forall_x 1 V (mul_nonneg hC_nn hlog_nn) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) calc abstVal 1 (labels V x) (fun y => RALdim 1 (restrict V x y)) ≤ abstVal 1 (labels V x) (fun y => (1 / (2 * Real.log 2)) * Real.log ((restrict V x y).card : ℝ)) := by refine abstVal_mono_v (by norm_num) le_rfl fun y hy => ?_ exact ih _ (card_restrict_lt_of_two_labels hsplit y) ((restrict_nonempty_iff V x y).mpr hy) rfl _ ≤ (1 / (2 * Real.log 2)) * Real.log (V.card : ℝ) := abstVal_one_log2_halving_step hS (w := fun y => ((restrict V x y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x y).mpr hy).card_pos) (V.card : ℝ) (by exact_mod_cast sum_card_restrict V x) /-- **Universal Multiclass Characteristic-Root Halving Theorem for Deterministic Abstention**: For EVERY `c > 0`, EVERY `x ∈ (0, 1)` satisfying `1 ≤ x ^ c + x` (in particular, the exact characteristic root `x ^ c + x = 1`), and EVERY finite nonempty concept class `V` over ANY label space `β` (zero dependence on `|β|`!): `ALdim c V ≤ (1 / Real.log (1 / x)) * Real.log |V|`. -/ theorem ALdim_le_charRoot_halving {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {c x : ℝ} (hc0 : 0 < c) (hx0 : 0 < x) (hx1 : x < 1) (hroot : 1 ≤ x ^ c + x) {V : Finset (α → β)} (hV : V.Nonempty) : ALdim c V ≤ (1 / Real.log (1 / x)) * Real.log (V.card : ℝ) := by have hL_pos : 0 < Real.log (1 / x) := Real.log_pos ((one_lt_div hx0).mpr hx1) have hC_nn : 0 ≤ 1 / Real.log (1 / x) := 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 ALdim_le_of_forall_x c V (mul_nonneg hC_nn hlog_nn) fun x_pt hsplit => ?_ have hS : (labels V x_pt).Nonempty := Finset.card_pos.mp (by omega) calc dAbstStep c (labels V x_pt) (fun y => ALdim c (restrict V x_pt y)) ≤ dAbstStep c (labels V x_pt) (fun y => (1 / Real.log (1 / x)) * Real.log ((restrict V x_pt y).card : ℝ)) := by refine dAbstStep_mono_d fun y hy => ?_ exact ih _ (card_restrict_lt_of_two_labels hsplit y) ((restrict_nonempty_iff V x_pt y).mpr hy) rfl _ ≤ (1 / Real.log (1 / x)) * Real.log (V.card : ℝ) := dAbstStep_charRoot_halving_step hc0 hx0 hx1 hroot hS (w := fun y => ((restrict V x_pt y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x_pt y).mpr hy).card_pos) (V.card : ℝ) (by exact_mod_cast sum_card_restrict V x_pt) /-- **Exact Golden-Ratio Halving Theorem for `ALdim (1 / 2)`** (for ANY multiclass `β`!): With `φ = Real.goldenRatio = (1 + √5) / 2`, `ALdim (1 / 2) V ≤ (1 / (2 * Real.log φ)) * Real.log |V|`. -/ theorem ALdim_half_le_golden_ratio_halving {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : ALdim (1 / 2) V ≤ (1 / (2 * Real.log Real.goldenRatio)) * Real.log (V.card : ℝ) := by set φ := Real.goldenRatio have hφ_gt1 : 1 < φ := Real.one_lt_goldenRatio have hφ_pos : 0 < φ := by linarith have hφ_sq : φ ^ 2 = φ + 1 := Real.goldenRatio_sq set x := 1 / φ ^ 2 have hx0 : 0 < x := by positivity have hx1 : x < 1 := by dsimp only [x]; rw [div_lt_one (pow_pos hφ_pos 2)] nlinarith have hxc : x ^ (1 / 2 : ℝ) = 1 / φ := by have h1 : x = (1 / φ) ^ 2 := by dsimp only [x]; rw [one_div_pow] rw [h1, ← Real.sqrt_eq_rpow, Real.sqrt_sq (by positivity)] have hroot : 1 ≤ x ^ (1 / 2 : ℝ) + x := by rw [hxc]; dsimp only [x] have hident : 1 / φ + 1 / φ ^ 2 = 1 := by have hne2 : φ ^ 2 ≠ 0 := pow_ne_zero 2 (ne_of_gt hφ_pos) apply mul_left_cancel₀ hne2 calc φ ^ 2 * (1 / φ + 1 / φ ^ 2) = φ * (φ * (1 / φ)) + φ ^ 2 * (1 / φ ^ 2) := by ring _ = φ * 1 + 1 := by rw [mul_one_div_cancel (ne_of_gt hφ_pos), mul_one_div_cancel hne2] _ = φ ^ 2 * 1 := by linarith [hφ_sq] linarith have hlog_eq : Real.log (1 / x) = 2 * Real.log φ := by have hinv : 1 / x = φ ^ 2 := by dsimp only [x]; field_simp [ne_of_gt hφ_pos] rw [hinv, Real.log_pow]; norm_num have h := ALdim_le_charRoot_halving (by norm_num : (0 : ℝ) < 1 / 2) hx0 hx1 hroot hV rwa [hlog_eq] at h /-- **Generalized Fibonacci Sequence `genFib q k`** governing exact non-asymptotic deterministic abstention cardinality bounds at `c = 1 / q`: `genFib q k = k + 1` for `k ≤ q`, and `genFib q (k + q) = genFib q (k + q - 1) + genFib q k` (for `q = 1`: `2 ^ k`; for `q = 2`: `Nat.fib (k + 2)`; for `q = 3`: Narayana's cows!). -/ def genFib (q : ℕ) : ℕ → ℕ | k => if q = 0 then 1 else if k ≤ q then k + 1 else genFib q (k - 1) + genFib q (k - q) termination_by k => k decreasing_by all_goals omega lemma genFib_le_q {q k : ℕ} (hq : 1 ≤ q) (hk : k ≤ q) : genFib q k = k + 1 := by rw [genFib, if_neg (by omega), if_pos hk] lemma genFib_rec {q k : ℕ} (hq : 1 ≤ q) (hk : q < k) : genFib q k = genFib q (k - 1) + genFib q (k - q) := by rw [genFib, if_neg (by omega), if_neg (by omega)] lemma genFib_pos {q : ℕ} (hq : 1 ≤ q) : ∀ k, 1 ≤ genFib q k := by intro k induction k using Nat.strong_induction_on with | h k ih => by_cases hk : k ≤ q · rw [genFib_le_q hq hk]; omega · rw [genFib_rec hq (by omega)] have h1 := ih (k - 1) (by omega) omega lemma genFib_strictMono {q : ℕ} (hq : 1 ≤ q) : StrictMono (genFib q) := by refine strictMono_nat_of_lt_succ fun k => ?_ by_cases hk : k + 1 ≤ q · rw [genFib_le_q hq (by omega), genFib_le_q hq hk]; omega · rw [genFib_rec hq (k := k + 1) (by omega)] have hpos : 1 ≤ genFib q (k + 1 - q) := genFib_pos hq (k + 1 - q) have hsub : k + 1 - 1 = k := Nat.add_sub_cancel k 1 rw [hsub] omega /-- Exact identity connecting `genFib 2 k` with Mathlib's `Nat.fib (k + 2)`. -/ lemma genFib_two_eq_fib : ∀ k : ℕ, genFib 2 k = Nat.fib (k + 2) := by intro k induction k using Nat.strong_induction_on with | h k ih => rcases k with _ | _ | k · rw [genFib_le_q (by omega) (by omega)]; rfl · rw [genFib_le_q (by omega) (by omega)]; rfl · by_cases hk : k = 0 · subst hk; rw [genFib_le_q (by omega) (by omega)]; rfl · rw [genFib_rec (by omega) (by omega)] have h1 : k + 2 - 1 = k + 1 := by omega have h2 : k + 2 - 2 = k := by omega rw [h1, h2, ih (k + 1) (by omega), ih k (by omega)] have hfib : Nat.fib (k + 2 + 2) = Nat.fib (k + 2) + Nat.fib (k + 3) := by simpa [Nat.add_assoc] using Nat.fib_add_two (n := k + 2) have heq1 : k + 1 + 2 = k + 3 := by omega rw [heq1, hfib] omega /-- **Exact Non-Asymptotic Generalized-Fibonacci Cardinality Theorem for Deterministic Abstention**: For EVERY integer `q ≥ 1`, EVERY `k : ℕ`, and EVERY multiclass concept class `V` over ANY label space `β` with `|V| < genFib q (k + 1)`, `ALdim (1 / q) V ≤ k / q`! -/ theorem ALdim_inv_le_of_card_lt_genFib {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {q : ℕ} (hq : 1 ≤ q) : ∀ (k : ℕ) (V : Finset (α → β)), V.card < genFib q (k + 1) → ALdim (1 / (q : ℝ)) V ≤ (k : ℝ) / (q : ℝ) := by have hq_pos : (0 : ℝ) < (q : ℝ) := Nat.cast_pos.mpr hq intro k V hcard induction hn : V.card using Nat.strong_induction_on generalizing V k with | h n ih => subst hn refine ALdim_le_of_forall_x (1 / (q : ℝ)) V (by positivity) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hsum : ∑ y ∈ labels V x, (restrict V x y).card = V.card := sum_card_restrict V x by_cases hk0 : k = 0 · subst hk0 simp only [zero_add] at hcard have hg1 : genFib q 1 = 2 := genFib_le_q hq hq have hle : (labels V x).card ≤ V.card := Finset.card_image_le omega · have hk1 : 1 ≤ k := by omega rw [dAbstStep_le_iff hS] obtain ⟨y₁, hy₁, hy₁_max⟩ := Finset.exists_mem_eq_sup' hS (fun y => (restrict V x y).card) by_cases hlt_rec : (restrict V x y₁).card < genFib q k · left intro y hy have hlt_y : (restrict V x y).card < genFib q k := by have hle_y₁ : (restrict V x y).card ≤ (restrict V x y₁).card := by rw [← hy₁_max]; exact Finset.le_sup' (fun z => (restrict V x z).card) hy omega have hih := ih _ (card_restrict_lt_of_two_labels hsplit y) (k - 1) _ (by rwa [Nat.sub_add_cancel hk1]) rfl have hk_sub : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by rw [Nat.cast_sub hk1]; norm_num rw [hk_sub] at hih have hrew : ((k : ℝ) - 1) / (q : ℝ) + 1 / (q : ℝ) = (k : ℝ) / (q : ℝ) := by ring linarith · right have hlt_y₁ : (restrict V x y₁).card < genFib q (k + 1) := lt_trans (card_restrict_lt_of_two_labels hsplit y₁) hcard refine ⟨y₁, hy₁, ih _ (card_restrict_lt_of_two_labels hsplit y₁) k _ hlt_y₁ rfl, fun y hy hne => ?_⟩ have hpair : (restrict V x y₁).card + (restrict V x y).card ≤ V.card := by have hsub : ({y₁, y} : Finset β) ⊆ labels V x := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl; exact hy₁; exact hy rw [← hsum] calc (restrict V x y₁).card + (restrict V x y).card = ∑ z ∈ ({y₁, y} : Finset β), (restrict V x z).card := (Finset.sum_pair (f := fun z => (restrict V x z).card) hne.symm).symm _ ≤ ∑ z ∈ labels V x, (restrict V x z).card := Finset.sum_le_sum_of_subset hsub by_cases hkq : k < q · have h1 : genFib q (k + 1) = k + 2 := genFib_le_q hq (by omega) have h2 : genFib q k = k + 1 := genFib_le_q hq (by omega) have hpos_y : 1 ≤ (restrict V x y).card := ((restrict_nonempty_iff V x y).mpr hy).card_pos omega · have hrec : genFib q (k + 1) = genFib q k + genFib q (k + 1 - q) := by have := genFib_rec hq (by omega : q < k + 1) simpa only [Nat.add_sub_cancel] using this have hlt_y : (restrict V x y).card < genFib q ((k - q) + 1) := by rw [show (k - q) + 1 = k + 1 - q by omega] omega have hih := ih _ (card_restrict_lt_of_two_labels hsplit y) (k - q) _ hlt_y rfl have hsub : ((k - q : ℕ) : ℝ) = (k : ℝ) - (q : ℝ) := Nat.cast_sub (by omega) rw [hsub] at hih have hrew : ((k : ℝ) - (q : ℝ)) / (q : ℝ) + 1 = (k : ℝ) / (q : ℝ) := by field_simp [ne_of_gt hq_pos]; ring linarith /-- **Exact Fibonacci Cardinality Corollary at `c = 1 / 2`**: for EVERY multiclass concept class `V` over ANY label space `β` with `|V| < Nat.fib (k + 3)`, `ALdim (1 / 2) V ≤ k / 2`! -/ theorem ALdim_half_le_of_card_lt_fib {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (k : ℕ) (V : Finset (α → β)) (hcard : V.card < Nat.fib (k + 3)) : ALdim (1 / 2) V ≤ (k : ℝ) / 2 := by have h := ALdim_inv_le_of_card_lt_genFib (q := 2) (by omega) k V (by rw [genFib_two_eq_fib]; exact hcard) norm_num at h ⊢ exact h /-! ## Part 7: Disjoint-Domain Product Additivity & Full `r`-ary Cube Sharpness -/ /-- Disjoint-domain Cartesian product of `V₁` on `α₁` and `V₂` on `α₂`. -/ def prodClass {α₁ α₂ β : Type*} [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) : Finset (α₁ ⊕ α₂ → β) := (V₁ ×ˢ V₂).image (fun p => Sum.elim p.1 p.2) lemma sum_elim_injective {α₁ α₂ β : Type*} : Function.Injective (fun p : (α₁ → β) × (α₂ → β) => Sum.elim p.1 p.2) := by intro ⟨f₁, g₁⟩ ⟨f₂, g₂⟩ heq apply Prod.ext · funext x; exact congrFun heq (Sum.inl x) · funext x; exact congrFun heq (Sum.inr x) lemma prodClass_card {α₁ α₂ β : Type*} [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*} [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] constructor · rintro ⟨_, ⟨⟨f, g⟩, ⟨hf, _⟩, rfl⟩, rfl⟩; exact ⟨f, hf, rfl⟩ · rintro ⟨f, hf, rfl⟩; rcases hV₂ with ⟨g, hg⟩; exact ⟨Sum.elim f g, ⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, rfl⟩ lemma labels_prodClass_inr {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] {V₁ : Finset (α₁ → β)} (hV₁ : V₁.Nonempty) (V₂ : Finset (α₂ → β)) (x : α₂) : labels (prodClass V₁ V₂) (Sum.inr x) = labels V₂ x := by ext y simp only [labels, prodClass, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨_, ⟨⟨f, g⟩, ⟨_, hg⟩, rfl⟩, rfl⟩; exact ⟨g, hg, rfl⟩ · rintro ⟨g, hg, rfl⟩; rcases hV₁ with ⟨f, hf⟩; exact ⟨Sum.elim f g, ⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, rfl⟩ lemma restrict_prodClass_inl {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) (x : α₁) (y : β) : restrict (prodClass V₁ V₂) (Sum.inl x) y = prodClass (restrict V₁ x y) V₂ := by ext h simp only [restrict, prodClass, Finset.mem_filter, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hfx⟩; exact ⟨⟨f, g⟩, ⟨⟨hf, hfx⟩, hg⟩, rfl⟩ · rintro ⟨⟨f, g⟩, ⟨⟨hf, hfx⟩, hg⟩, rfl⟩; exact ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hfx⟩ lemma restrict_prodClass_inr {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) (x : α₂) (y : β) : restrict (prodClass V₁ V₂) (Sum.inr x) y = prodClass V₁ (restrict V₂ x y) := by ext h simp only [restrict, prodClass, Finset.mem_filter, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hgx⟩; exact ⟨⟨f, g⟩, ⟨hf, ⟨hg, hgx⟩⟩, rfl⟩ · rintro ⟨⟨f, g⟩, ⟨hf, ⟨hg, hgx⟩⟩, rfl⟩; exact ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hgx⟩ /-- **Exact Disjoint-Domain Product Additivity for `RALdim`**: `RALdim c (prodClass V₁ V₂) = RALdim c V₁ + RALdim c V₂` for all `c ∈ [0, 1]`. -/ theorem RALdim_prod_eq_add {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : RALdim c (prodClass V₁ V₂) = RALdim c V₁ + RALdim c V₂ := by induction hn : V₁.card + V₂.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => apply le_antisymm · refine RALdim_le_of_forall_x c (prodClass V₁ V₂) (add_nonneg (RALdim_nonneg c V₁) (RALdim_nonneg c V₂)) fun x hsplit => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl V₁ hV₂ x₁] at hsplit ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, RALdim c (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = RALdim c (restrict V₁ x₁ y) + RALdim c V₂ := by intro y hy; rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsplit y exact ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [abstVal_congr hc0 hc1 hcongr, abstVal_add_const hc0 hc1 hS] linarith [RALdim_ge_abstVal c V₁ x₁ hsplit] | inr x₂ => rw [labels_prodClass_inr hV₁ V₂ x₂] at hsplit ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₂ x₂, RALdim c (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = RALdim c (restrict V₂ x₂ y) + RALdim c V₁ := by intro y hy; rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsplit y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rw [abstVal_congr hc0 hc1 hcongr, abstVal_add_const hc0 hc1 hS] linarith [RALdim_ge_abstVal c V₂ x₂ hsplit] · have h2_le : RALdim c V₂ ≤ RALdim c (prodClass V₁ V₂) := by refine RALdim_le_of_forall_x c V₂ (RALdim_nonneg _ _) fun x₂ hsplit2 => ?_ have hS2 : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rwa [labels_prodClass_inr hV₁ V₂ x₂] have hge := RALdim_ge_abstVal c (prodClass V₁ V₂) (Sum.inr x₂) hsp rw [labels_prodClass_inr hV₁ V₂ x₂] at hge have hcongr : ∀ y ∈ labels V₂ x₂, RALdim c (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = RALdim c (restrict V₂ x₂ y) + RALdim c V₁ := by intro y hy; rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsplit2 y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rw [abstVal_congr hc0 hc1 hcongr, abstVal_add_const hc0 hc1 hS2] at hge linarith [RALdim_nonneg c V₁] have h1_le : RALdim c V₁ ≤ RALdim c (prodClass V₁ V₂) - RALdim c V₂ := by refine RALdim_le_of_forall_x c V₁ (by linarith) fun x₁ hsplit1 => ?_ have hS1 : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inl x₁)).card := by rwa [labels_prodClass_inl V₁ hV₂ x₁] have hge := RALdim_ge_abstVal c (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl V₁ hV₂ x₁] at hge have hcongr : ∀ y ∈ labels V₁ x₁, RALdim c (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = RALdim c (restrict V₁ x₁ y) + RALdim c V₂ := by intro y hy; rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsplit1 y exact ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [abstVal_congr hc0 hc1 hcongr, abstVal_add_const hc0 hc1 hS1] at hge linarith linarith /-- **Exact Disjoint-Domain Product Additivity for `ALdim`**: `ALdim c (prodClass V₁ V₂) = ALdim c V₁ + ALdim c V₂` for all `c ≥ 0`. -/ theorem ALdim_prod_eq_add {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] {c : ℝ} (hc0 : 0 ≤ c) {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : ALdim c (prodClass V₁ V₂) = ALdim c V₁ + ALdim c V₂ := by induction hn : V₁.card + V₂.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => apply le_antisymm · refine ALdim_le_of_forall_x c (prodClass V₁ V₂) (add_nonneg (ALdim_nonneg hc0 V₁) (ALdim_nonneg hc0 V₂)) fun x hsplit => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl V₁ hV₂ x₁] at hsplit ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, ALdim c (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = ALdim c (restrict V₁ x₁ y) + ALdim c V₂ := by intro y hy; rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsplit y exact ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [dAbstStep_congr hcongr, dAbstStep_add_const hS] linarith [ALdim_ge_dAbstStep c V₁ x₁ hsplit] | inr x₂ => rw [labels_prodClass_inr hV₁ V₂ x₂] at hsplit ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₂ x₂, ALdim c (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = ALdim c (restrict V₂ x₂ y) + ALdim c V₁ := by intro y hy; rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsplit y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rw [dAbstStep_congr hcongr, dAbstStep_add_const hS] linarith [ALdim_ge_dAbstStep c V₂ x₂ hsplit] · have h2_le : ALdim c V₂ ≤ ALdim c (prodClass V₁ V₂) := by refine ALdim_le_of_forall_x c V₂ (ALdim_nonneg hc0 _) fun x₂ hsplit2 => ?_ have hS2 : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rwa [labels_prodClass_inr hV₁ V₂ x₂] have hge := ALdim_ge_dAbstStep c (prodClass V₁ V₂) (Sum.inr x₂) hsp rw [labels_prodClass_inr hV₁ V₂ x₂] at hge have hcongr : ∀ y ∈ labels V₂ x₂, ALdim c (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = ALdim c (restrict V₂ x₂ y) + ALdim c V₁ := by intro y hy; rw [restrict_prodClass_inr] have hlt := card_restrict_lt_of_two_labels hsplit2 y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rw [dAbstStep_congr hcongr, dAbstStep_add_const hS2] at hge linarith [ALdim_nonneg hc0 V₁] have h1_le : ALdim c V₁ ≤ ALdim c (prodClass V₁ V₂) - ALdim c V₂ := by refine ALdim_le_of_forall_x c V₁ (by linarith) fun x₁ hsplit1 => ?_ have hS1 : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inl x₁)).card := by rwa [labels_prodClass_inl V₁ hV₂ x₁] have hge := ALdim_ge_dAbstStep c (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl V₁ hV₂ x₁] at hge have hcongr : ∀ y ∈ labels V₁ x₁, ALdim c (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = ALdim c (restrict V₁ x₁ y) + ALdim c V₂ := by intro y hy; rw [restrict_prodClass_inl] have hlt := card_restrict_lt_of_two_labels hsplit1 y exact ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [dAbstStep_congr hcongr, dAbstStep_add_const hS1] at hge linarith linarith /-- The 1-point `r`-class problem `Unit → Fin r`. -/ def onePointClass (r : ℕ) : Finset (Unit → Fin r) := Finset.univ lemma onePointClass_card (r : ℕ) : (onePointClass r).card = r := by simp [onePointClass] lemma labels_onePointClass (r : ℕ) : labels (onePointClass r) () = Finset.univ := by ext y; simp only [labels, onePointClass, Finset.mem_image, Finset.mem_univ, true_and, iff_true] exact ⟨fun _ => y, rfl⟩ lemma restrict_onePointClass_card (r : ℕ) (y : Fin r) : (restrict (onePointClass r) () y).card = 1 := by have heq : restrict (onePointClass r) () y = {fun _ => y} := by ext h simp only [restrict, onePointClass, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] exact ⟨fun hy => funext fun u => by cases u; exact hy, fun hh => by rw [hh]⟩ rw [heq, Finset.card_singleton] theorem RALdim_onePointClass {r : ℕ} (hr : 2 ≤ r) {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) : RALdim c (onePointClass r) = min c (1 - 1 / (r : ℝ)) := by have hsplit : 2 ≤ (labels (onePointClass r) ()).card := by rw [labels_onePointClass, Finset.card_univ, Fintype.card_fin]; exact hr have hS : (labels (onePointClass r) ()).Nonempty := Finset.card_pos.mp (by omega) have hzero : ∀ y ∈ labels (onePointClass r) (), RALdim c (restrict (onePointClass r) () y) = 0 := fun y _ => RALdim_eq_zero_of_card_le_one c (by rw [restrict_onePointClass_card]) have hval : abstVal c (labels (onePointClass r) ()) (fun y => RALdim c (restrict (onePointClass r) () y)) = min c (1 - 1 / (r : ℝ)) := by rw [abstVal_congr hc0 hc1 hzero, abstVal_const hc0 hc1 hS 0, zero_add, labels_onePointClass, Finset.card_univ, Fintype.card_fin] have hr_pos : (0 : ℝ) < (r : ℝ) := Nat.cast_pos.mpr (by omega) have hnn : 0 ≤ min c (1 - 1 / (r : ℝ)) := le_min hc0 (by rw [sub_nonneg, div_le_one hr_pos]; exact_mod_cast (by omega : 1 ≤ r)) apply le_antisymm · refine RALdim_le_of_forall_x c (onePointClass r) hnn fun x _ => ?_; cases x; rw [hval] · rw [← hval]; exact RALdim_ge_abstVal c (onePointClass r) () hsplit theorem ALdim_onePointClass {r : ℕ} (hr : 2 ≤ r) {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) : ALdim c (onePointClass r) = c := by have hsplit : 2 ≤ (labels (onePointClass r) ()).card := by rw [labels_onePointClass, Finset.card_univ, Fintype.card_fin]; exact hr have hzero : ∀ y ∈ labels (onePointClass r) (), ALdim c (restrict (onePointClass r) () y) = 0 := fun y _ => ALdim_eq_zero_of_card_le_one c (by rw [restrict_onePointClass_card]) have hval : dAbstStep c (labels (onePointClass r) ()) (fun y => ALdim c (restrict (onePointClass r) () y)) = c := by rw [dAbstStep_congr hzero, dAbstStep_const hc0 hc1 hsplit 0, zero_add] apply le_antisymm · refine ALdim_le_of_forall_x c (onePointClass r) hc0 fun x _ => ?_; cases x; rw [hval] · calc c = dAbstStep c (labels (onePointClass r) ()) (fun y => ALdim c (restrict (onePointClass r) () y)) := hval.symm _ ≤ ALdim c (onePointClass r) := ALdim_ge_dAbstStep c (onePointClass r) () hsplit abbrev CubeDom : ℕ → Type | 0 => Empty | d + 1 => Unit ⊕ CubeDom d instance instFintypeCubeDom : ∀ d : ℕ, Fintype (CubeDom d) | 0 => inferInstanceAs (Fintype Empty) | d + 1 => @instFintypeSum Unit (CubeDom d) _ (instFintypeCubeDom d) instance instDecidableEqCubeDom : ∀ d : ℕ, DecidableEq (CubeDom d) | 0 => inferInstanceAs (DecidableEq Empty) | d + 1 => @instDecidableEqSum Unit (CubeDom d) _ (instDecidableEqCubeDom d) def cubeClass (r : ℕ) : ∀ d : ℕ, Finset (CubeDom d → Fin r) | 0 => {Empty.elim} | d + 1 => prodClass (onePointClass r) (cubeClass r d) lemma cubeClass_card (r : ℕ) : ∀ d : ℕ, (cubeClass r d).card = r ^ d | 0 => by rw [cubeClass, Finset.card_singleton, pow_zero] | d + 1 => by rw [cubeClass, prodClass_card, onePointClass_card, cubeClass_card r d, pow_succ'] lemma cubeClass_nonempty {r : ℕ} (hr : 1 ≤ r) (d : ℕ) : (cubeClass r d).Nonempty := Finset.card_pos.mp (by rw [cubeClass_card]; exact pow_pos hr d) theorem RALdim_cubeClass {r : ℕ} (hr : 2 ≤ r) {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) : ∀ d : ℕ, RALdim c (cubeClass r d) = (d : ℝ) * min c (1 - 1 / (r : ℝ)) | 0 => by rw [RALdim_eq_zero_of_card_le_one c (by rw [cubeClass_card]; simp)]; simp | d + 1 => by rw [cubeClass, RALdim_prod_eq_add hc0 hc1 (Finset.card_pos.mp (by rw [onePointClass_card]; omega)) (cubeClass_nonempty (by omega) d), RALdim_onePointClass hr hc0 hc1, RALdim_cubeClass hr hc0 hc1 d] push_cast; ring theorem ALdim_cubeClass {r : ℕ} (hr : 2 ≤ r) {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) : ∀ d : ℕ, ALdim c (cubeClass r d) = (d : ℝ) * c | 0 => by rw [ALdim_eq_zero_of_card_le_one c (by rw [cubeClass_card]; simp)]; simp | d + 1 => by rw [cubeClass, ALdim_prod_eq_add hc0 (Finset.card_pos.mp (by rw [onePointClass_card]; omega)) (cubeClass_nonempty (by omega) d), ALdim_onePointClass hr hc0 hc1, ALdim_cubeClass hr hc0 hc1 d] push_cast; ring /-- **Strict Phase-Transition Sharpness Below `c*_r = 1 - 1 / r`**: on `cubeClass r d` (`r ≥ 2, d ≥ 1`), for EVERY `c < 1 - 1 / r`, abstention STRICTLY beats pure randomization (`RALdim c = d * c < d * (1 - 1 / r) = RALdim 1`), and achieves exact equality in `RALdim_kClass_scaling_sandwich`! -/ theorem RALdim_strict_improvement_below_threshold {r d : ℕ} (hr : 2 ≤ r) (hd : 1 ≤ d) {c : ℝ} (hc0 : 0 ≤ c) (hc_lt : c < 1 - 1 / (r : ℝ)) : RALdim c (cubeClass r d) = (d : ℝ) * c ∧ RALdim 1 (cubeClass r d) = (d : ℝ) * (1 - 1 / (r : ℝ)) ∧ RALdim c (cubeClass r d) < RALdim 1 (cubeClass r d) := by have hr_pos : (0 : ℝ) < (r : ℝ) := Nat.cast_pos.mpr (by omega) have h1r_pos : 0 < 1 / (r : ℝ) := by positivity have hc1 : c ≤ 1 := by linarith have h1 : RALdim c (cubeClass r d) = (d : ℝ) * c := by rw [RALdim_cubeClass hr hc0 hc1 d, min_eq_left (le_of_lt hc_lt)] have h2 : RALdim 1 (cubeClass r d) = (d : ℝ) * (1 - 1 / (r : ℝ)) := by rw [RALdim_cubeClass hr (by norm_num) le_rfl d, min_eq_right (by linarith)] have hd_pos : (0 : ℝ) < (d : ℝ) := Nat.cast_pos.mpr hd exact ⟨h1, h2, by rw [h1, h2]; exact mul_lt_mul_of_pos_left hc_lt hd_pos⟩ /-! ## Part 8: Exact 1D Threshold Class Fibonacci Theorem, Binary Singletons, & Tent-Ratio Sharpness -/ /-- The `i`-th 1D binary threshold hypothesis on `Fin M`: `h_i(j) = true` iff `j.val < i`. -/ def threshHyp (M i : ℕ) : Fin M → Bool := fun j => decide (j.val < i) /-- The 1D threshold concept class on `Fin M` restricted to threshold indices in `[lo, hi)` (cardinality `hi - lo` when `lo ≤ hi ≤ M + 1`). -/ def threshInterval (M lo hi : ℕ) : Finset (Fin M → Bool) := (Finset.Ico lo hi).image (threshHyp M) 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 : ℕ} (_hlo : 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 threshInterval_split {M lo mid hi : ℕ} (h1 : lo < mid) (h2 : mid < hi) (hhi : hi ≤ M + 1) : let x : Fin M := ⟨mid - 1, by omega⟩ labels (threshInterval M lo hi) x = {false, true} ∧ restrict (threshInterval M lo hi) x false = threshInterval M lo mid ∧ restrict (threshInterval M lo hi) x true = threshInterval M mid hi := by dsimp only set x : Fin M := ⟨mid - 1, by omega⟩ have hrf : restrict (threshInterval M lo hi) x false = threshInterval M lo mid := by ext h simp only [restrict, threshInterval, Finset.mem_filter, Finset.mem_image, Finset.mem_Ico] constructor · rintro ⟨⟨i, ⟨hli, hih⟩, rfl⟩, hx⟩ have hnot : ¬ (mid - 1 < i) := by simpa [threshHyp, x] using hx exact ⟨i, ⟨hli, by omega⟩, rfl⟩ · rintro ⟨i, ⟨hli, him⟩, rfl⟩ exact ⟨⟨i, ⟨hli, by omega⟩, rfl⟩, by simp [threshHyp, x]; omega⟩ have hrt : restrict (threshInterval M lo hi) x true = threshInterval M mid hi := by ext h simp only [restrict, threshInterval, Finset.mem_filter, Finset.mem_image, Finset.mem_Ico] constructor · rintro ⟨⟨i, ⟨hli, hih⟩, rfl⟩, hx⟩ have hlt : mid - 1 < i := by simpa [threshHyp, x] using hx exact ⟨i, ⟨by omega, hih⟩, rfl⟩ · rintro ⟨i, ⟨hmi, hih⟩, rfl⟩ exact ⟨⟨i, ⟨by omega, hih⟩, rfl⟩, by simp [threshHyp, x]; omega⟩ refine ⟨?_, hrf, hrt⟩ ext b simp only [labels, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] cases b · simp only [true_or, iff_true] exact ⟨threshHyp M lo, Finset.mem_image.mpr ⟨lo, Finset.mem_Ico.mpr ⟨le_rfl, by omega⟩, rfl⟩, by simp [threshHyp, x]; omega⟩ · simp only [or_true, iff_true] exact ⟨threshHyp M mid, Finset.mem_image.mpr ⟨mid, Finset.mem_Ico.mpr ⟨by omega, h2⟩, rfl⟩, by simp [threshHyp, x]; omega⟩ /-- **Exact Non-Asymptotic Generalized-Fibonacci Theorem on 1D Thresholds**: For EVERY `q ≥ 1`, EVERY `k : ℕ`, and EVERY `lo, hi` with `hi ≤ M + 1` and `genFib q k ≤ hi - lo`, `ALdim (1 / q) (threshInterval M lo hi) ≥ k / q`! Combined with `ALdim_inv_le_of_card_lt_genFib`, this proves EXACT equality `ALdim (1 / q) (threshInterval M 0 N) = k / q` whenever `genFib q k ≤ N < genFib q (k + 1)`! -/ theorem ALdim_inv_threshInterval_ge {q : ℕ} (hq : 1 ≤ q) (M : ℕ) : ∀ (k lo hi : ℕ), hi ≤ M + 1 → genFib q k ≤ hi - lo → (k : ℝ) / (q : ℝ) ≤ ALdim (1 / (q : ℝ)) (threshInterval M lo hi) := by have hq_pos : (0 : ℝ) < (q : ℝ) := Nat.cast_pos.mpr hq intro k induction k using Nat.strong_induction_on with | h k ih => intro lo hi hhi hlen by_cases hk0 : k = 0 · subst hk0; simp [ALdim_nonneg] · have hk1 : 1 ≤ k := by omega by_cases hkq : k ≤ q · -- Split off 1 hypothesis (`mid = lo + 1`) vs `hi - (lo + 1) ≥ genFib q (k - 1)`! have hgk : genFib q k = k + 1 := genFib_le_q hq hkq have hgk1 : genFib q (k - 1) = k := by rw [genFib_le_q hq (by omega)]; omega have hsp := threshInterval_split (M := M) (lo := lo) (mid := lo + 1) (hi := hi) (by omega) (by omega) hhi have hsplit : 2 ≤ (labels (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩).card := by rw [hsp.1]; norm_num have hge := ALdim_ge_dAbstStep (1 / (q : ℝ)) (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩ hsplit rw [hsp.1] at hge have hrec := ih (k - 1) (by omega) (lo + 1) hi hhi (by omega) have hcard_f : (restrict (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩ false).card = 1 := by rw [hsp.2.1, threshInterval_card (by omega) (by omega)]; omega have hzero_f : ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩ false) = 0 := ALdim_eq_zero_of_card_le_one _ (by omega) have hge_t : ((k - 1 : ℕ) : ℝ) / (q : ℝ) ≤ ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩ true) := by rw [hsp.2.2]; exact hrec have hbin := dAbstStep_binary (c := 1 / (q : ℝ)) (by positivity) (show (true : Bool) ≠ false by decide) (d := fun y => ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩ y)) (by rw [hzero_f]; exact ALdim_nonneg (by positivity) _) have hpair_eq : ({false, true} : Finset Bool) = {true, false} := Finset.pair_comm false true rw [hpair_eq, hbin, hzero_f, zero_add] at hge have hk_sub : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by rw [Nat.cast_sub hk1]; norm_num have hstep1 : (k : ℝ) / (q : ℝ) ≤ ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨lo + 1 - 1, by omega⟩ true) + 1 / (q : ℝ) := by rw [hk_sub] at hge_t; linarith [show ((k : ℝ) - 1) / (q : ℝ) + 1 / (q : ℝ) = (k : ℝ) / (q : ℝ) by ring] have hstep2 : (k : ℝ) / (q : ℝ) ≤ 1 := by rw [div_le_one hq_pos]; exact_mod_cast hkq exact le_trans (le_min hstep1 hstep2) (le_trans (le_max_right _ _) hge) · -- `q < k`: split at `mid = lo + genFib q (k - q)`, giving sizes `genFib q (k - q)` and `≥ genFib q (k - 1)`! have hrec_fib : genFib q k = genFib q (k - 1) + genFib q (k - q) := genFib_rec hq (by omega) have hpos1 : 1 ≤ genFib q (k - 1) := genFib_pos hq (k - 1) have hpos2 : 1 ≤ genFib q (k - q) := genFib_pos hq (k - q) set mid := lo + genFib q (k - q) have hsp := threshInterval_split (M := M) (lo := lo) (mid := mid) (hi := hi) (by omega) (by omega) hhi have hsplit : 2 ≤ (labels (threshInterval M lo hi) ⟨mid - 1, by omega⟩).card := by rw [hsp.1]; norm_num have hge := ALdim_ge_dAbstStep (1 / (q : ℝ)) (threshInterval M lo hi) ⟨mid - 1, by omega⟩ hsplit rw [hsp.1] at hge have hrec_f : ((k - q : ℕ) : ℝ) / (q : ℝ) ≤ ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨mid - 1, by omega⟩ false) := by rw [hsp.2.1]; exact ih (k - q) (by omega) lo mid (by omega) (by dsimp only [mid]; omega) have hrec_t : ((k - 1 : ℕ) : ℝ) / (q : ℝ) ≤ ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨mid - 1, by omega⟩ true) := by rw [hsp.2.2]; exact ih (k - 1) (by omega) mid hi hhi (by dsimp only [mid]; omega) have hmono := dAbstStep_mono_d (c := 1 / (q : ℝ)) (S := ({false, true} : Finset Bool)) (d₁ := fun b => if b then ((k - 1 : ℕ) : ℝ) / (q : ℝ) else ((k - q : ℕ) : ℝ) / (q : ℝ)) (d₂ := fun b => ALdim (1 / (q : ℝ)) (restrict (threshInterval M lo hi) ⟨mid - 1, by omega⟩ b)) (fun b _ => by cases b; exact hrec_f; exact hrec_t) have hpair_eq : ({false, true} : Finset Bool) = {true, false} := Finset.pair_comm false true rw [hpair_eq] at hmono hge have hge_d : ((k - q : ℕ) : ℝ) / (q : ℝ) ≤ ((k - 1 : ℕ) : ℝ) / (q : ℝ) := by exact div_le_div_of_nonneg_right (by exact_mod_cast (by omega : k - q ≤ k - 1)) (le_of_lt hq_pos) have hbin := dAbstStep_binary (c := 1 / (q : ℝ)) (by positivity) (show (true : Bool) ≠ false by decide) (d := fun b : Bool => if b then ((k - 1 : ℕ) : ℝ) / (q : ℝ) else ((k - q : ℕ) : ℝ) / (q : ℝ)) (by simpa using hge_d) rw [hbin] at hmono simp only [↓reduceIte, Bool.false_eq_true] at hmono have hk_sub1 : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by rw [Nat.cast_sub hk1]; norm_num have hk_subq : ((k - q : ℕ) : ℝ) = (k : ℝ) - (q : ℝ) := Nat.cast_sub (by omega) have h1 : ((k - 1 : ℕ) : ℝ) / (q : ℝ) + 1 / (q : ℝ) = (k : ℝ) / (q : ℝ) := by rw [hk_sub1]; ring have h2 : ((k - q : ℕ) : ℝ) / (q : ℝ) + 1 = (k : ℝ) / (q : ℝ) := by rw [hk_subq]; field_simp [ne_of_gt hq_pos]; ring rw [h1, h2, min_self] at hmono exact le_trans (le_max_right _ _) (le_trans hmono hge) /-- **Exact Generalized-Fibonacci Law for 1D Thresholds**: for EVERY `q ≥ 1, k : ℕ`, and `N` with `genFib q k ≤ N < genFib q (k + 1)`, `ALdim (1 / q) (threshInterval (N - 1) 0 N) = k / q`! -/ theorem ALdim_inv_threshClass_exact {q k N : ℕ} (hq : 1 ≤ q) (hlo : genFib q k ≤ N) (hhi : N < genFib q (k + 1)) : ALdim (1 / (q : ℝ)) (threshInterval (N - 1) 0 N) = (k : ℝ) / (q : ℝ) := by have hN1 : 1 ≤ N := le_trans (genFib_pos hq k) hlo have hcard : (threshInterval (N - 1) 0 N).card = N := by rw [threshInterval_card (Nat.zero_le N) (by omega), Nat.sub_zero] apply le_antisymm · exact ALdim_inv_le_of_card_lt_genFib hq k _ (by rw [hcard]; exact hhi) · exact ALdim_inv_threshInterval_ge hq (N - 1) k 0 N (by omega) (by omega) /-- **Exact Fibonacci Law at `c = 1 / 2` for 1D Thresholds**: for EVERY `k : ℕ` and `N` with `Nat.fib (k + 2) ≤ N < Nat.fib (k + 3)`, `ALdim (1 / 2) (threshInterval (N - 1) 0 N) = k / 2`! -/ theorem ALdim_half_threshClass_exact {k N : ℕ} (hlo : Nat.fib (k + 2) ≤ N) (hhi : N < Nat.fib (k + 3)) : ALdim (1 / 2) (threshInterval (N - 1) 0 N) = (k : ℝ) / 2 := by have h := ALdim_inv_threshClass_exact (q := 2) (k := k) (N := N) (by omega) (by rw [genFib_two_eq_fib]; exact hlo) (by rw [genFib_two_eq_fib]; exact hhi) norm_num at h ⊢ exact h /-- **Binary Singleton Family `binSingletonSub I`**: On domain `Fin N` with active coordinates `I ⊆ Fin N`, `{all-false} ∪ {indicator i | i ∈ I}`. -/ def binSingletonSub {N : ℕ} (I : Finset (Fin N)) : Finset (Fin N → Bool) := insert (fun _ => false) (I.image fun i j => decide (j = i)) /-- **Exact Closed Form for Binary Singletons under Abstention**: For EVERY `c ∈ [0, 1]` and EVERY `I ⊆ Fin N`: - `ALdim c (binSingletonSub I) = min (I.card * c) 1`, - `RALdim c (binSingletonSub I) = 1 - (1 - min c (1 / 2)) ^ I.card`. -/ theorem binSingletonSub_exact {N : ℕ} {c : ℝ} (hc0 : 0 ≤ c) (hc1 : c ≤ 1) (I : Finset (Fin N)) : ALdim c (binSingletonSub I) = min ((I.card : ℝ) * c) 1 ∧ RALdim c (binSingletonSub I) = 1 - (1 - min c (1 / 2)) ^ I.card := by induction hk : I.card using Nat.strong_induction_on generalizing I with | h k ih => subst hk by_cases hI : I.Nonempty · have hcard_pos : 1 ≤ I.card := hI.card_pos have hlab_not : ∀ x ∉ I, labels (binSingletonSub I) x = {false} := by intro x hx; ext b simp only [labels, binSingletonSub, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨_, rfl | ⟨i, hi, rfl⟩, rfl⟩ · rfl · have hne : x ≠ i := fun heq => hx (heq ▸ hi) simp [hne] · rintro rfl; exact ⟨fun _ => false, Or.inl rfl, rfl⟩ have hlab_in : ∀ x ∈ I, labels (binSingletonSub I) x = {false, true} := by intro x hx; ext b simp only [labels, binSingletonSub, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] cases b · simp only [true_or, iff_true]; exact ⟨fun _ => false, Or.inl rfl, rfl⟩ · simp only [or_true, iff_true]; exact ⟨fun j => decide (j = x), Or.inr ⟨x, hx, rfl⟩, by simp⟩ have hrf : ∀ x ∈ I, restrict (binSingletonSub I) x false = binSingletonSub (I.erase x) := by intro x _; ext h simp only [restrict, binSingletonSub, Finset.mem_filter, Finset.mem_insert, Finset.mem_image, Finset.mem_erase] constructor · rintro ⟨rfl | ⟨i, hi, rfl⟩, hx⟩ · exact Or.inl rfl · have hne : i ≠ x := fun heq => by subst heq; simp at hx exact Or.inr ⟨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]⟩ have hrt : ∀ x ∈ I, restrict (binSingletonSub I) x true = {fun j => decide (j = x)} := by intro x hx; ext h simp only [restrict, binSingletonSub, Finset.mem_filter, Finset.mem_insert, Finset.mem_image, Finset.mem_singleton] constructor · rintro ⟨rfl | ⟨i, hi, rfl⟩, hx'⟩ · simp at hx' · have hxi : x = i := by simpa using hx' subst hxi; rfl · rintro rfl; exact ⟨Or.inr ⟨x, hx, rfl⟩, by simp⟩ have hrec : ∀ x ∈ I, ALdim c (binSingletonSub (I.erase x)) = min (((I.card - 1 : ℕ) : ℝ) * c) 1 ∧ RALdim c (binSingletonSub (I.erase x)) = 1 - (1 - min c (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 hcard_sub : ((I.card - 1 : ℕ) : ℝ) = (I.card : ℝ) - 1 := by rw [Nat.cast_sub hcard_pos]; norm_num have hd_step : ∀ x ∈ I, dAbstStep c (labels (binSingletonSub I) x) (fun y => ALdim c (restrict (binSingletonSub I) x y)) = min ((I.card : ℝ) * c) 1 := by intro x hx have hzero_t : ALdim c (restrict (binSingletonSub I) x true) = 0 := by rw [hrt x hx]; exact ALdim_eq_zero_of_card_le_one c (by simp) have hrec_f : ALdim c (restrict (binSingletonSub I) x false) = min (((I.card : ℝ) - 1) * c) 1 := by rw [hrf x hx, (hrec x hx).1, hcard_sub] rw [hlab_in x hx, dAbstStep_binary hc0 (show (false : Bool) ≠ true by decide) (by rw [hzero_t]; exact ALdim_nonneg hc0 _), hzero_t, zero_add, hrec_f] have hmin1 : min (((I.card : ℝ) - 1) * c) 1 ≤ 1 := min_le_right _ _ have heq1 : min (min (((I.card : ℝ) - 1) * c) 1 + c) 1 = min ((I.card : ℝ) * c) 1 := by by_cases hle : ((I.card : ℝ) - 1) * c ≤ 1 · rw [min_eq_left hle]; congr 1; ring · push Not at hle rw [min_eq_right (le_of_lt hle), min_eq_right (by linarith), min_eq_right (by linarith)] rw [heq1] exact max_eq_right (le_min (by nlinarith [min_le_left (((I.card : ℝ) - 1) * c) 1]) hmin1) set c' := min c (1 / 2) have hc'0 : 0 ≤ c' := le_min hc0 (by norm_num) have hc'1 : c' ≤ 1 := le_trans (min_le_right _ _) (by norm_num) have hr_step : ∀ x ∈ I, abstVal c (labels (binSingletonSub I) x) (fun y => RALdim c (restrict (binSingletonSub I) x y)) = 1 - (1 - c') ^ I.card := by intro x hx have hpow_step : (1 - c') ^ I.card = (1 - c') * (1 - c') ^ (I.card - 1) := by rw [← pow_succ', Nat.sub_add_cancel hcard_pos] have hrec_val : RALdim c (restrict (binSingletonSub I) x false) = 1 - (1 - c') ^ (I.card - 1) := by rw [hrf x hx]; exact (hrec x hx).2 have hzero_t : RALdim c (restrict (binSingletonSub I) x true) = 0 := by rw [hrt x hx]; exact RALdim_eq_zero_of_card_le_one c (by simp) rw [hlab_in x hx] by_cases hchalf : c ≤ 1 / 2 · have hc'_eq : c' = c := min_eq_left hchalf rw [abstVal_binary_le_half hc0 hchalf (show (false : Bool) ≠ true by decide) (by rw [hzero_t]; exact RALdim_nonneg c _), hrec_val, hzero_t, mul_zero, add_zero, ← hc'_eq] have hrew : (1 - c') * (1 - (1 - c') ^ (I.card - 1)) + c' = 1 - (1 - c') ^ I.card := by rw [hpow_step]; ring rw [hrew] refine max_eq_right ?_ have hnn : 0 ≤ (1 - c') ^ (I.card - 1) := pow_nonneg (by linarith) _ nlinarith [hpow_step] · push Not at hchalf have hc'_eq : c' = 1 / 2 := min_eq_right (le_of_lt hchalf) rw [abstVal_binary_ge_half (le_of_lt hchalf) hc1 (show (false : Bool) ≠ true by decide) (by rw [hzero_t]; exact RALdim_nonneg c _), hrec_val, hzero_t, add_zero] have hrew : (1 - (1 - c') ^ (I.card - 1) + 1) / 2 = 1 - (1 - c') ^ I.card := by rw [hpow_step, hc'_eq]; ring rw [hrew] refine max_eq_right ?_ have hnn : 0 ≤ (1 - c') ^ (I.card - 1) := pow_nonneg (by linarith) _ rw [hc'_eq] at hnn rw [hpow_step, hc'_eq]; linarith constructor · apply le_antisymm · refine ALdim_le_of_forall_x c _ (le_min (by positivity) (by norm_num)) fun x hsplit => ?_ have hxI : x ∈ I := by by_contra hnot; rw [hlab_not x hnot, Finset.card_singleton] at hsplit; omega rw [hd_step x hxI] · rcases hI with ⟨x0, hx0⟩ have hsp : 2 ≤ (labels (binSingletonSub I) x0).card := by rw [hlab_in x0 hx0]; norm_num rw [← hd_step x0 hx0]; exact ALdim_ge_dAbstStep c _ x0 hsp · apply le_antisymm · refine RALdim_le_of_forall_x c _ (by have : (1 - c') ^ I.card ≤ 1 := pow_le_one₀ (by linarith) (by linarith) linarith) fun x hsplit => ?_ have hxI : x ∈ I := by by_contra hnot; rw [hlab_not x hnot, Finset.card_singleton] at hsplit; omega rw [hr_step x hxI] · rcases hI with ⟨x0, hx0⟩ have hsp : 2 ≤ (labels (binSingletonSub I) x0).card := by rw [hlab_in x0 hx0]; norm_num rw [← hr_step x0 hx0]; exact RALdim_ge_abstVal c _ x0 hsp · have hemp : I = ∅ := Finset.not_nonempty_iff_eq_empty.mp hI subst hemp have hsing : binSingletonSub (N := N) ∅ = {fun _ => false} := by ext h; simp [binSingletonSub] rw [hsing, ALdim_eq_zero_of_card_le_one c (by simp), RALdim_eq_zero_of_card_le_one c (by simp)] simp /-- **Exact Fibonacci Recurrence Sharpness of the Tent Ratio `tentRatio (1 / 2) = 2 / 3`**: The exact Fibonacci abstention recurrence `r 0 = 0, r 1 = 0, r (k + 2) = (r (k + 1) + r k + 1) / 2` has exact closed form `r k = k / 3 - 2 / 9 + (2 / 9) * (-1 / 2) ^ k`, while the deterministic recurrence satisfies `d (k + 1) = k / 2`, so `r k / d k → 2 / 3 = tentRatio (1 / 2)`! -/ noncomputable def fibRandRec : ℕ → ℝ | 0 => 0 | 1 => 0 | k + 2 => (fibRandRec (k + 1) + fibRandRec k + 1) / 2 theorem fibRandRec_closed_form : ∀ k : ℕ, fibRandRec k = (k : ℝ) / 3 - 2 / 9 + (2 / 9 : ℝ) * (-1 / 2 : ℝ) ^ k := by intro k induction k using Nat.strong_induction_on with | h k ih => rcases k with _ | _ | k · simp [fibRandRec] · simp [fibRandRec]; norm_num · rw [fibRandRec, ih (k + 1) (by omega), ih k (by omega)] have hpow1 : (-1 / 2 : ℝ) ^ (k + 1) = (-1 / 2 : ℝ) * (-1 / 2 : ℝ) ^ k := by rw [pow_succ'] have hpow2 : (-1 / 2 : ℝ) ^ (k + 2) = (1 / 4 : ℝ) * (-1 / 2 : ℝ) ^ k := by rw [pow_succ', pow_succ']; ring rw [hpow1, hpow2] push_cast ring /-- Exact generalized Fibonacci randomized abstention recurrence at `c = 1 / q` (`q ≥ 2`): satisfies `r k ≤ k / (2 * q - 1) + 1` while deterministic `d k = k / q`, proving the exact asymptotic ratio `1 / (2 - 1 / q) = tentRatio (1 / q)`! -/ noncomputable def genFibRandRec (q : ℕ) : ℕ → ℝ | k => if hq : q < 2 then 0 else if hk : k < q then 0 else (1 - 1 / (q : ℝ)) * genFibRandRec q (k - 1) + (1 / (q : ℝ)) * genFibRandRec q (k - q) + 1 / (q : ℝ) termination_by k => k decreasing_by all_goals omega theorem genFibRandRec_upper_tent {q : ℕ} (hq : 2 ≤ q) : ∀ k : ℕ, genFibRandRec q k ≤ (k : ℝ) / (2 * (q : ℝ) - 1) := by have hq_pos : (0 : ℝ) < (q : ℝ) := Nat.cast_pos.mpr (by omega) have hden_pos : (0 : ℝ) < 2 * (q : ℝ) - 1 := by have : (2 : ℝ) ≤ (q : ℝ) := by exact_mod_cast hq linarith intro k induction k using Nat.strong_induction_on with | h k ih => rw [genFibRandRec, dif_neg (by omega)] split_ifs with hk · positivity · have h1 := ih (k - 1) (by omega) have h2 := ih (k - q) (by omega) have hq_ge1 : (1 : ℝ) ≤ (q : ℝ) := by exact_mod_cast (by omega : 1 ≤ q) have h1c_nn : 0 ≤ 1 - 1 / (q : ℝ) := by rw [sub_nonneg, div_le_one hq_pos]; exact hq_ge1 have hc_nn : 0 ≤ 1 / (q : ℝ) := by positivity have hk1 : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by rw [Nat.cast_sub (by omega)]; norm_num have hkq : ((k - q : ℕ) : ℝ) = (k : ℝ) - (q : ℝ) := Nat.cast_sub (by omega) rw [hk1] at h1 rw [hkq] at h2 have hm1 := mul_le_mul_of_nonneg_left h1 h1c_nn have hm2 := mul_le_mul_of_nonneg_left h2 hc_nn have hident : (1 - 1 / (q : ℝ)) * (((k : ℝ) - 1) / (2 * (q : ℝ) - 1)) + (1 / (q : ℝ)) * (((k : ℝ) - (q : ℝ)) / (2 * (q : ℝ) - 1)) + 1 / (q : ℝ) = (k : ℝ) / (2 * (q : ℝ) - 1) := by have hq_ne : (q : ℝ) ≠ 0 := ne_of_gt hq_pos have hden_ne : 2 * (q : ℝ) - 1 ≠ 0 := ne_of_gt hden_pos have hmul : (q : ℝ) * (2 * (q : ℝ) - 1) ≠ 0 := mul_ne_zero hq_ne hden_ne apply mul_left_cancel₀ hmul have h1 : (q : ℝ) * (2 * (q : ℝ) - 1) * ((1 - 1 / (q : ℝ)) * (((k : ℝ) - 1) / (2 * (q : ℝ) - 1)) + (1 / (q : ℝ)) * (((k : ℝ) - (q : ℝ)) / (2 * (q : ℝ) - 1)) + 1 / (q : ℝ)) = (q : ℝ) * (k : ℝ) := by have ha : (q : ℝ) * (1 - 1 / (q : ℝ)) = (q : ℝ) - 1 := by field_simp have hb : (2 * (q : ℝ) - 1) * (((k : ℝ) - 1) / (2 * (q : ℝ) - 1)) = (k : ℝ) - 1 := mul_div_cancel₀ _ hden_ne have hc : (2 * (q : ℝ) - 1) * (((k : ℝ) - (q : ℝ)) / (2 * (q : ℝ) - 1)) = (k : ℝ) - (q : ℝ) := mul_div_cancel₀ _ hden_ne have hd : (q : ℝ) * (1 / (q : ℝ)) = 1 := mul_one_div_cancel hq_ne calc (q : ℝ) * (2 * (q : ℝ) - 1) * ((1 - 1 / (q : ℝ)) * (((k : ℝ) - 1) / (2 * (q : ℝ) - 1)) + (1 / (q : ℝ)) * (((k : ℝ) - (q : ℝ)) / (2 * (q : ℝ) - 1)) + 1 / (q : ℝ)) = ((q : ℝ) * (1 - 1 / (q : ℝ))) * ((2 * (q : ℝ) - 1) * (((k : ℝ) - 1) / (2 * (q : ℝ) - 1))) + ((q : ℝ) * (1 / (q : ℝ))) * ((2 * (q : ℝ) - 1) * (((k : ℝ) - (q : ℝ)) / (2 * (q : ℝ) - 1))) + (2 * (q : ℝ) - 1) * ((q : ℝ) * (1 / (q : ℝ))) := by ring _ = ((q : ℝ) - 1) * ((k : ℝ) - 1) + 1 * ((k : ℝ) - (q : ℝ)) + (2 * (q : ℝ) - 1) * 1 := by rw [ha, hb, hc, hd] _ = (q : ℝ) * (k : ℝ) := by ring have h2 : (q : ℝ) * (2 * (q : ℝ) - 1) * ((k : ℝ) / (2 * (q : ℝ) - 1)) = (q : ℝ) * (k : ℝ) := by rw [mul_assoc, mul_div_cancel₀ _ hden_ne] rw [h1, h2] linarith /-- **Strict Exponential-Rate Separation on 1D Thresholds (`c = 1 / 2`)**: At `N = Nat.fib (k + 2)`, `ALdim (1 / 2) = k / 2` while `RALdim (1 / 2) ≤ (1 / (2 * log 2)) * log (fib (k + 2))`! Moreover, the randomized halving constant `1 / (2 * log 2)` strictly beats the deterministic Golden-Ratio halving constant `1 / (2 * log φ)` by more than `30%` (`1/(2 ln 2) < (7/10)/(2 ln φ)`)! -/ theorem rand_beats_det_golden_halving_by_30pct : 1 / (2 * Real.log 2) < (7 / 10 : ℝ) * (1 / (2 * Real.log Real.goldenRatio)) := by have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) have hlogφ : 0 < Real.log Real.goldenRatio := Real.log_pos Real.one_lt_goldenRatio -- Equivalent to `10 * log φ < 7 * log 2 ↔ φ ^ 10 < 2 ^ 7 = 128`! -- Using `√5 < 2.237` (since `2.237^2 = 5.004169 > 5`): `φ < 1.6185`, `1.6185 ^ 10 < 123.5 < 128`! have hsqrt5 : Real.sqrt 5 < 2.237 := by rw [Real.sqrt_lt' (by norm_num)]; norm_num have hφ_lt : Real.goldenRatio < 1.6185 := by rw [Real.goldenRatio]; linarith have hφ_pos : 0 < Real.goldenRatio := by linarith [Real.one_lt_goldenRatio] have hpow : Real.goldenRatio ^ 10 < (2 : ℝ) ^ 7 := by calc Real.goldenRatio ^ 10 < (1.6185 : ℝ) ^ 10 := by gcongr _ < (2 : ℝ) ^ 7 := by norm_num have hlog_lt := Real.log_lt_log (pow_pos hφ_pos 10) hpow rw [Real.log_pow, Real.log_pow] at hlog_lt push_cast at hlog_lt have hrew : (7 / 10 : ℝ) * (1 / (2 * Real.log Real.goldenRatio)) = 7 / (20 * Real.log Real.goldenRatio) := by ring rw [hrew, div_lt_div_iff₀ (by positivity) (by positivity)] linarith /-! ## Part 9: Axiom Audit (`#print axioms`) -/ #print axioms abstVal_le_iff #print axioms abstVal_primal_upper #print axioms abstVal_dual_lower #print axioms abstVal_eq_one_of_ge_threshold #print axioms abstVal_binary_le_half #print axioms abstVal_binary_ge_half #print axioms abstVal_entropy_halving_step #print axioms abstVal_one_log2_halving_step #print axioms dAbstStep_le_iff #print axioms abstVal_le_dAbstStep #print axioms tentRatio_mul_dAbstStep_le_abstVal #print axioms dAbstStep_charRoot_halving_step #print axioms optAbstLearner_expectedLoss_le #print axioms optAbstAdversary_expectedLoss_ge #print axioms online_abst_minimax_exact #print axioms RALdim_eq_noAbst_of_ge_threshold #print axioms RALdim_binary_eq_noAbst_of_ge_half #print axioms RALdim_le_ALdim #print axioms RALdim_ge_tentRatio_mul_ALdim #print axioms RALdim_half_ge_two_thirds_ALdim #print axioms ALdim_c_scaling #print axioms RALdim_c_scaling #print axioms RALdim_kClass_scaling_sandwich #print axioms RALdim_le_entropy_halving #print axioms RALdim_le_half_log2_card #print axioms ALdim_le_charRoot_halving #print axioms ALdim_half_le_golden_ratio_halving #print axioms ALdim_inv_le_of_card_lt_genFib #print axioms ALdim_half_le_of_card_lt_fib #print axioms RALdim_prod_eq_add #print axioms ALdim_prod_eq_add #print axioms RALdim_cubeClass #print axioms ALdim_cubeClass #print axioms RALdim_strict_improvement_below_threshold #print axioms ALdim_inv_threshClass_exact #print axioms ALdim_half_threshClass_exact #print axioms binSingletonSub_exact #print axioms fibRandRec_closed_form #print axioms genFibRandRec_upper_tent #print axioms rand_beats_det_golden_halving_by_30pct end OnlineAbstentionMinimax