import Mathlib /-! # Exact Minimax Theory of Randomized Bandit Online Learning & # Harmonic-Mean Randomized Bandit Littlestone Dimension (`RBLdim`) This module develops a completely self-contained, standard-foundations formalization of the exact minimax theory of multiclass online learning under bandit feedback, resolving structural questions on randomized vs. deterministic bandit online learning (Daniely–Helbertal 2013; Filmus–Hanneke– Mehalel–Moran COLT 2023 & NeurIPS 2024; Raman–Subedi–Tewari 2024). ## Structure of the File 1. **Section 1 (`BanditMinimaxGame`)**: Universal closed-form primal–dual saddle-point minimax theorem for **arbitrary** diagonal-plus-rank-1 bandit payoff matrices `A(y, yh) = if y = yh then a y else b yh` on any finite nonempty label set `S`, covering both the all-positive margin regime (`∀ j ∈ S, a j < b j`) via harmonic-mean weighting AND the general indifferent/trap regime (`∃ j ∈ S, b j ≤ a j`) via exact active-set duality. 2. **Section 2 (`FullInfoMinimaxGame`)**: Exact water-filling primal–dual minimax theorem for multiclass full-information payoff matrices `F(y, yh) = a y + 1_{y ≠ yh}`, plus comparison with `banditVal` and the universal half-deterministic lower bound. 3. **Section 3 (`OnlineLearningDimensions`)**: Exact recursive definitions of all four finite-class online learning dimensions (`RBLdim`, `BLdim`, `RLdim`, `Ldim`), nonnegativity, singleton vanishing, and universal subset monotonicity. 4. **Section 4 (`UniversalHierarchy`)**: Universal comparison chain `(1/2) * Ldim V ≤ RLdim V ≤ RBLdim V ≤ min (BLdim V) ((|V| - 1) / 2)` (including the proportional-sampling cardinality bound), plus exact binary (`Y = Fin 2`) collapse `RBLdim V = RLdim V` and `BLdim V = Ldim V`. 5. **Section 5 (`ExactBenchmarksAndSeparations`)**: - Exact closed-form values on the 1-point `k`-label class (`Ldim = 1`, `RLdim = (k-1)/k`, `RBLdim = (k-1)/2`, `BLdim = k - 1`, exact `k/2` linear price of bandit feedback); - **The Half-Factor Breaking Theorem**: explicit 5-hypothesis, 2-point, 3-class concept class `H5` with `BLdim H5 = 3` and `RBLdim H5 = 16/11 < 3/2 = (1/2) * BLdim H5`, refuting the binary Filmus–Hanneke–Mehalel–Moran `1/2`-factor lower bound under bandit feedback; - Exact tightness of `RBLdim ≤ BLdim` via the binary `m`-point indicator class (`BLdim = 1`, `RBLdim = 1 - 1/2^m → 1`). 6. **Section 6 (`OnlineGameSemantics`)**: Constructive minimax-optimal randomized bandit online learner achieving expected mistakes `≤ RBLdim V` against every bandit-state adaptive adversary, and matching dual adversary forcing expected mistakes `≥ RBLdim V` against every learner. -/ open scoped BigOperators open Finset namespace RandomizedBanditLittlestone /-! ## Section 1: Universal Closed-Form Primal–Dual Minimax Theorem for Bandit Games -/ section BanditMinimaxGame variable {α : Type*} [DecidableEq α] /-- A probability distribution supported on a finite set `S`. -/ def IsDist (S : Finset α) (p : α → ℝ) : Prop := (∀ j ∈ S, 0 ≤ p j) ∧ ∑ j ∈ S, p j = 1 /-- The diagonal-plus-rank-1 bandit payoff matrix `A(y, yh) = a y` if `y = yh`, else `b yh`. -/ def banditPayoff (a b : α → ℝ) (y yh : α) : ℝ := if y = yh then a y else b yh /-- Expected payoff to the adversary playing true label `y` against learner distribution `p`. -/ def banditRowVal (S : Finset α) (a b p : α → ℝ) (y : α) : ℝ := ∑ yh ∈ S, p yh * banditPayoff a b y yh /-- Expected payoff to the learner playing prediction `yh` against adversary distribution `q`. -/ def banditColVal (S : Finset α) (a b q : α → ℝ) (yh : α) : ℝ := ∑ y ∈ S, q y * banditPayoff a b y yh /-- Row payoff identity: `(A p)_y = (∑_{yh ∈ S} p yh * b yh) - p y * (b y - a y)`. -/ lemma banditRowVal_eq {S : Finset α} (a b p : α → ℝ) {y : α} (hy : y ∈ S) : banditRowVal S a b p y = (∑ yh ∈ S, p yh * b yh) - p y * (b y - a y) := by unfold banditRowVal banditPayoff have hsplit : ∑ yh ∈ S, p yh * (if y = yh then a y else b yh) = ∑ yh ∈ S, (p yh * b yh - if y = yh then p yh * (b y - a y) else 0) := by refine Finset.sum_congr rfl fun yh _ => ?_ split_ifs with h · subst h; ring · ring rw [hsplit, Finset.sum_sub_distrib] congr 1 rw [Finset.sum_ite_eq S y (fun yh => p yh * (b y - a y)), if_pos hy] /-- Column payoff identity: `(q^T A)_{yh} = b yh - q yh * (b yh - a yh)` for `IsDist S q`. -/ lemma banditColVal_eq {S : Finset α} (a b q : α → ℝ) (hq : ∑ y ∈ S, q y = 1) {yh : α} (hyh : yh ∈ S) : banditColVal S a b q yh = b yh - q yh * (b yh - a yh) := by unfold banditColVal banditPayoff have hsplit : ∑ y ∈ S, q y * (if y = yh then a y else b yh) = ∑ y ∈ S, (q y * b yh - if y = yh then q y * (b yh - a yh) else 0) := by refine Finset.sum_congr rfl fun y _ => ?_ split_ifs with h · subst h; ring · ring rw [hsplit, Finset.sum_sub_distrib, ← Finset.sum_mul, hq, one_mul] congr 1 rw [Finset.sum_ite_eq' S yh (fun y => q y * (b yh - a yh)), if_pos hyh] /-- Bilinear expectation identity `q^T (A p) = (q^T A) p`. -/ lemma bandit_bilinear_eq (S : Finset α) (a b p q : α → ℝ) : ∑ y ∈ S, q y * banditRowVal S a b p y = ∑ yh ∈ S, p yh * banditColVal S a b q yh := by unfold banditRowVal banditColVal simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun yh _ => Finset.sum_congr rfl fun y _ => by ring /-- Weak minimax duality for any bandit payoff matrix: every dual lower bound `L` is `≤` every primal upper bound `U`. -/ theorem bandit_weak_duality {S : Finset α} {a b p q : α → ℝ} {L U : ℝ} (hp : IsDist S p) (hq : IsDist S q) (hU : ∀ y ∈ S, banditRowVal S a b p y ≤ U) (hL : ∀ yh ∈ S, L ≤ banditColVal S a b q yh) : L ≤ U := by have h1 : L ≤ ∑ yh ∈ S, p yh * banditColVal S a b q yh := by calc L = ∑ yh ∈ S, p yh * L := by rw [← Finset.sum_mul, hp.2, one_mul] _ ≤ ∑ yh ∈ S, p yh * banditColVal S a b q yh := Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left (hL yh hyh) (hp.1 yh hyh) have h2 : ∑ y ∈ S, q y * banditRowVal S a b p y ≤ U := by calc ∑ y ∈ S, q y * banditRowVal S a b p y ≤ ∑ y ∈ S, q y * U := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left (hU y hy) (hq.1 y hy) _ = U := by rw [← Finset.sum_mul, hq.2, one_mul] linarith [bandit_bilinear_eq S a b p q] /-- Trap-set harmonic value for a nonempty subset `T` of trap labels (`b j < a j`). -/ noncomputable def trapSetVal (a b : α → ℝ) (T : Finset α) : ℝ := (1 + ∑ j ∈ T, b j / (a j - b j)) / (∑ j ∈ T, 1 / (a j - b j)) /-- **Exact Closed-Form Minimax Value of ANY Diagonal-Plus-Rank-1 Bandit Game**: - **Regime I** (`∀ j ∈ S, a j < b j`): `min (min_{j ∈ S} b j) ((∑_{j ∈ S} b j / (b j - a j) - 1) / (∑_{j ∈ S} 1 / (b j - a j)))`. - **Regime II** (`∃ j ∈ S, b j ≤ a j`): minimum over `{b j : j ∈ S, a j ≤ b j}` and `{trapSetVal a b T : ∅ ≠ T ⊆ {j ∈ S : b j < a j}}`. -/ noncomputable def banditVal (S : Finset α) (a b : α → ℝ) : ℝ := by classical exact if hS : S.Nonempty then if ∀ j ∈ S, a j < b j then min (S.inf' hS b) ((∑ j ∈ S, b j / (b j - a j) - 1) / (∑ j ∈ S, 1 / (b j - a j))) else let M := S.filter (fun j => a j ≤ b j) let N := S.filter (fun j => b j < a j) let Tset := N.powerset.filter Finset.Nonempty if hM : M.Nonempty then if hT : Tset.Nonempty then min (M.inf' hM b) (Tset.inf' hT (trapSetVal a b)) else M.inf' hM b else if hT : Tset.Nonempty then Tset.inf' hT (trapSetVal a b) else 0 else 0 omit [DecidableEq α] in /-- Helper: in Regime II, if `M` is empty then `N = S` is nonempty, so `Tset` is nonempty. -/ private lemma trap_nonempty_of_M_empty {S : Finset α} (hS : S.Nonempty) (a b : α → ℝ) (hM_empty : ¬ (S.filter (fun j => a j ≤ b j)).Nonempty) : ((S.filter (fun j => b j < a j)).powerset.filter Finset.Nonempty).Nonempty := by classical rcases hS with ⟨j₀, hj₀⟩ have hlt : b j₀ < a j₀ := by by_contra hle push Not at hle exact hM_empty ⟨j₀, Finset.mem_filter.mpr ⟨hj₀, hle⟩⟩ refine ⟨{j₀}, Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ?_, Finset.singleton_nonempty j₀⟩⟩ intro x hx rw [Finset.mem_singleton.mp hx] exact Finset.mem_filter.mpr ⟨hj₀, hlt⟩ /-- **Primal Optimal Strategy Theorem**: For EVERY nonempty `S` and EVERY `a, b : α → ℝ`, there exists an explicit probability distribution `p* ∈ Δ(S)` guaranteeing `(A p*)_y ≤ banditVal S a b` for every `y ∈ S`. -/ theorem banditVal_primal_upper {S : Finset α} (hS : S.Nonempty) (a b : α → ℝ) : ∃ p : α → ℝ, IsDist S p ∧ ∀ y ∈ S, banditRowVal S a b p y ≤ banditVal S a b := by classical unfold banditVal rw [dif_pos hS] by_cases hpos : ∀ j ∈ S, a j < b j · -- Regime I: `∀ j ∈ S, a j < b j` rw [if_pos hpos] set D : ℝ := ∑ j ∈ S, 1 / (b j - a j) set N_num : ℝ := ∑ j ∈ S, b j / (b j - a j) set v_int : ℝ := (N_num - 1) / D set bmin : ℝ := S.inf' hS b have hD_pos : 0 < D := by rcases hS with ⟨j₀, hj₀⟩ have hterm_pos : 0 < 1 / (b j₀ - a j₀) := by have := hpos j₀ hj₀; positivity exact lt_of_lt_of_le hterm_pos (Finset.single_le_sum (f := fun j => 1 / (b j - a j)) (fun j hj => by have := hpos j hj; positivity) hj₀) by_cases hcmp : bmin ≤ v_int · -- Boundary regime: play deterministic `p* = e_{j₀}` where `b j₀ = bmin`! rw [min_eq_left hcmp] obtain ⟨j₀, hj₀, hbj₀⟩ := Finset.exists_mem_eq_inf' hS b refine ⟨fun j => if j = j₀ then 1 else 0, ⟨?_, ?_⟩, ?_⟩ · intro j _; dsimp only; split_ifs <;> linarith · rw [Finset.sum_ite_eq' S j₀ (fun _ => (1 : ℝ)), if_pos hj₀] · intro y hy unfold banditRowVal banditPayoff rw [Finset.sum_eq_single j₀] · dsimp only; rw [if_pos rfl, one_mul] split_ifs with hyj · subst hyj; linarith [hpos y hy, hbj₀] · linarith [hbj₀] · intro j _ hne; dsimp only; rw [if_neg hne, zero_mul] · intro hnot; exact False.elim (hnot hj₀) · -- Interior regime: play harmonic distribution `p* j = (1 / (b j - a j)) / D`! push Not at hcmp rw [min_eq_right hcmp.le] let p : α → ℝ := fun j => (1 / (b j - a j)) / D have hp_nn : ∀ j ∈ S, 0 ≤ p j := fun j hj => by have := hpos j hj; dsimp only [p]; positivity have hp_sum : ∑ j ∈ S, p j = 1 := by dsimp only [p] rw [← Finset.sum_div, div_self hD_pos.ne'] refine ⟨p, ⟨hp_nn, hp_sum⟩, ?_⟩ intro y hy rw [banditRowVal_eq a b p hy] have hB : ∑ yh ∈ S, p yh * b yh = N_num / D := by dsimp only [p, N_num] rw [Finset.sum_div] refine Finset.sum_congr rfl fun yh _ => by ring have hd_ne : b y - a y ≠ 0 := by linarith [hpos y hy] have hpy : p y * (b y - a y) = 1 / D := by dsimp only [p]; field_simp [hd_ne, hD_pos.ne'] rw [hB, hpy] dsimp only [v_int] linarith [sub_div N_num 1 D] · -- Regime II: `∃ j ∈ S, b j ≤ a j` rw [if_neg hpos] set M := S.filter (fun j => a j ≤ b j) set N := S.filter (fun j => b j < a j) set Tset := N.powerset.filter Finset.Nonempty -- Helper: given `j₀ ∈ M`, `e_{j₀}` achieves `≤ b j₀`! have hM_strat : ∀ j₀ ∈ M, ∃ p : α → ℝ, IsDist S p ∧ ∀ y ∈ S, banditRowVal S a b p y ≤ b j₀ := by intro j₀ hj₀ rcases Finset.mem_filter.mp hj₀ with ⟨hj₀S, haj₀⟩ refine ⟨fun j => if j = j₀ then 1 else 0, ⟨?_, ?_⟩, ?_⟩ · intro j _; dsimp only; split_ifs <;> linarith · rw [Finset.sum_ite_eq' S j₀ (fun _ => (1 : ℝ)), if_pos hj₀S] · intro y _ unfold banditRowVal banditPayoff rw [Finset.sum_eq_single j₀] · dsimp only; rw [if_pos rfl, one_mul] split_ifs with hyj · subst hyj; exact haj₀ · exact le_rfl · intro j _ hne; dsimp only; rw [if_neg hne, zero_mul] · intro hnot; exact False.elim (hnot hj₀S) -- Helper: given `T ∈ Tset`, harmonic distribution on `T` achieves `≤ trapSetVal a b T`! have hT_strat : ∀ T ∈ Tset, ∃ p : α → ℝ, IsDist S p ∧ ∀ y ∈ S, banditRowVal S a b p y ≤ trapSetVal a b T := by intro T hT rcases Finset.mem_filter.mp hT with ⟨hTpow, hTne⟩ have hTN : T ⊆ N := Finset.mem_powerset.mp hTpow have hTS : T ⊆ S := hTN.trans (Finset.filter_subset _ S) have hT_lt : ∀ j ∈ T, b j < a j := fun j hj => (Finset.mem_filter.mp (hTN hj)).2 set D : ℝ := ∑ j ∈ T, 1 / (a j - b j) have hD_pos : 0 < D := by rcases hTne with ⟨j₀, hj₀⟩ have hterm : 0 < 1 / (a j₀ - b j₀) := by have := hT_lt j₀ hj₀; positivity exact lt_of_lt_of_le hterm (Finset.single_le_sum (f := fun j => 1 / (a j - b j)) (fun j hj => by have := hT_lt j hj; positivity) hj₀) let p : α → ℝ := fun j => if j ∈ T then (1 / (a j - b j)) / D else 0 have hp_nn : ∀ j ∈ S, 0 ≤ p j := fun j _ => by dsimp only [p] split_ifs with hjT · have := hT_lt j hjT; positivity · exact le_rfl have hp_sum : ∑ j ∈ S, p j = 1 := by have hsub : ∑ j ∈ S, p j = ∑ j ∈ T, (1 / (a j - b j)) / D := by dsimp only [p] rw [← Finset.sum_subset hTS (fun j _ hj => by simp [hj])] refine Finset.sum_congr rfl fun j hj => by simp [hj] rw [hsub, ← Finset.sum_div, div_self hD_pos.ne'] refine ⟨p, ⟨hp_nn, hp_sum⟩, ?_⟩ intro y hy rw [banditRowVal_eq a b p hy] have hB : ∑ yh ∈ S, p yh * b yh = (∑ j ∈ T, b j / (a j - b j)) / D := by have hsub : ∑ yh ∈ S, p yh * b yh = ∑ j ∈ T, ((1 / (a j - b j)) / D) * b j := by dsimp only [p] rw [← Finset.sum_subset hTS (fun j _ hj => by simp [hj])] refine Finset.sum_congr rfl fun j hj => by simp [hj] rw [hsub, Finset.sum_div] refine Finset.sum_congr rfl fun j _ => by ring rw [hB] unfold trapSetVal by_cases hyT : y ∈ T · have hd_ne : a y - b y ≠ 0 := by linarith [hT_lt y hyT] have hpy : -(p y * (b y - a y)) = 1 / D := by dsimp only [p]; rw [if_pos hyT]; field_simp [hd_ne, hD_pos.ne']; ring have hadd : (1 + ∑ j ∈ T, b j / (a j - b j)) / D = (∑ j ∈ T, b j / (a j - b j)) / D + 1 / D := by ring linarith · have hpy : p y = 0 := by dsimp only [p]; rw [if_neg hyT] rw [hpy, zero_mul, sub_zero] have hadd : (1 + ∑ j ∈ T, b j / (a j - b j)) / D = (∑ j ∈ T, b j / (a j - b j)) / D + 1 / D := by ring have h1D : 0 < 1 / D := by positivity linarith by_cases hM : M.Nonempty · rw [dif_pos hM] by_cases hT : Tset.Nonempty · rw [dif_pos hT] by_cases hcmp : M.inf' hM b ≤ Tset.inf' hT (trapSetVal a b) · rw [min_eq_left hcmp] obtain ⟨j₀, hj₀, hbj₀⟩ := Finset.exists_mem_eq_inf' hM b rw [hbj₀]; exact hM_strat j₀ hj₀ · push Not at hcmp rw [min_eq_right hcmp.le] obtain ⟨T₀, hT₀, hvT₀⟩ := Finset.exists_mem_eq_inf' hT (trapSetVal a b) rw [hvT₀]; exact hT_strat T₀ hT₀ · rw [dif_neg hT] obtain ⟨j₀, hj₀, hbj₀⟩ := Finset.exists_mem_eq_inf' hM b rw [hbj₀]; exact hM_strat j₀ hj₀ · rw [dif_neg hM] have hT : Tset.Nonempty := trap_nonempty_of_M_empty hS a b hM rw [dif_pos hT] obtain ⟨T₀, hT₀, hvT₀⟩ := Finset.exists_mem_eq_inf' hT (trapSetVal a b) change ∃ p, IsDist S p ∧ ∀ y ∈ S, banditRowVal S a b p y ≤ Tset.inf' hT (trapSetVal a b) rw [hvT₀]; exact hT_strat T₀ hT₀ /-- **Dual Optimal Strategy Theorem**: For EVERY nonempty `S` and EVERY `a, b : α → ℝ`, there exists an explicit probability distribution `q* ∈ Δ(S)` guaranteeing `banditVal S a b ≤ (q*^T A)_{yh}` for every `yh ∈ S`. -/ theorem banditVal_dual_lower {S : Finset α} (hS : S.Nonempty) (a b : α → ℝ) : ∃ q : α → ℝ, IsDist S q ∧ ∀ yh ∈ S, banditVal S a b ≤ banditColVal S a b q yh := by classical set v := banditVal S a b by_cases hpos : ∀ j ∈ S, a j < b j · -- Regime I: `∀ j ∈ S, a j < b j` have hv_eq : v = min (S.inf' hS b) ((∑ j ∈ S, b j / (b j - a j) - 1) / (∑ j ∈ S, 1 / (b j - a j))) := by dsimp only [v]; unfold banditVal; rw [dif_pos hS, if_pos hpos] set D : ℝ := ∑ j ∈ S, 1 / (b j - a j) set N_num : ℝ := ∑ j ∈ S, b j / (b j - a j) set v_int : ℝ := (N_num - 1) / D set bmin : ℝ := S.inf' hS b have hD_pos : 0 < D := by rcases hS with ⟨j₀, hj₀⟩ have hterm : 0 < 1 / (b j₀ - a j₀) := by have := hpos j₀ hj₀; positivity exact lt_of_lt_of_le hterm (Finset.single_le_sum (f := fun j => 1 / (b j - a j)) (fun j hj => by have := hpos j hj; positivity) hj₀) by_cases hcmp : v_int ≤ bmin · -- Interior regime: `q* j = (b j - v_int) / (b j - a j)`! have hv_int : v = v_int := by rw [hv_eq, min_eq_right hcmp] let q : α → ℝ := fun j => (b j - v_int) / (b j - a j) have hq_nn : ∀ j ∈ S, 0 ≤ q j := fun j hj => by dsimp only [q] have hbj : bmin ≤ b j := Finset.inf'_le b hj have hdj : 0 < b j - a j := by linarith [hpos j hj] exact div_nonneg (by linarith) hdj.le have hq_sum : ∑ j ∈ S, q j = 1 := by dsimp only [q] have hsplit : ∑ j ∈ S, (b j - v_int) / (b j - a j) = N_num - v_int * D := by dsimp only [N_num, D] rw [Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun j _ => by ring rw [hsplit] dsimp only [v_int] field_simp [hD_pos.ne'] ring refine ⟨q, ⟨hq_nn, hq_sum⟩, ?_⟩ intro yh hyh rw [banditColVal_eq a b q hq_sum hyh, hv_int] have hd_ne : b yh - a yh ≠ 0 := by linarith [hpos yh hyh] have hcancel : q yh * (b yh - a yh) = b yh - v_int := by dsimp only [q]; field_simp [hd_ne] linarith · -- Boundary regime: `v_int > bmin`, so `Z := ∑ j ∈ S, (b j - bmin) / (b j - a j) > 1`! push Not at hcmp have hv_min : v = bmin := by rw [hv_eq, min_eq_left hcmp.le] set Z : ℝ := ∑ j ∈ S, (b j - bmin) / (b j - a j) have hZ_gt1 : 1 < Z := by have hZ_eq : Z = N_num - bmin * D := by dsimp only [Z, N_num, D] rw [Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun j _ => by ring have hmul : bmin * D < N_num - 1 := by have := (lt_div_iff₀ hD_pos).mp hcmp linarith linarith have hZ_pos : 0 < Z := by linarith let q : α → ℝ := fun j => ((b j - bmin) / (b j - a j)) / Z have hq_nn : ∀ j ∈ S, 0 ≤ q j := fun j hj => by dsimp only [q] have hbj : bmin ≤ b j := Finset.inf'_le b hj have hdj : 0 < b j - a j := by linarith [hpos j hj] exact div_nonneg (div_nonneg (by linarith) hdj.le) hZ_pos.le have hq_sum : ∑ j ∈ S, q j = 1 := by dsimp only [q] rw [← Finset.sum_div, div_self hZ_pos.ne'] refine ⟨q, ⟨hq_nn, hq_sum⟩, ?_⟩ intro yh hyh rw [banditColVal_eq a b q hq_sum hyh, hv_min] have hd_ne : b yh - a yh ≠ 0 := by linarith [hpos yh hyh] have hbj : bmin ≤ b yh := Finset.inf'_le b hyh have hq_le : q yh * (b yh - a yh) ≤ b yh - bmin := by have heq : q yh * (b yh - a yh) = (b yh - bmin) / Z := by dsimp only [q]; field_simp [hd_ne, hZ_pos.ne'] rw [heq] exact div_le_self (by linarith) hZ_gt1.le linarith · -- Regime II: `∃ j ∈ S, b j ≤ a j` set M := S.filter (fun j => a j ≤ b j) set N := S.filter (fun j => b j < a j) set Tset := N.powerset.filter Finset.Nonempty -- Key properties of `v = banditVal S a b` in Regime II: have hv_le_M : ∀ j ∈ M, v ≤ b j := by intro j hj have hM : M.Nonempty := ⟨j, hj⟩ dsimp only [v]; unfold banditVal; rw [dif_pos hS, if_neg hpos] change (if hM' : M.Nonempty then if hT' : Tset.Nonempty then min (M.inf' hM' b) (Tset.inf' hT' (trapSetVal a b)) else M.inf' hM' b else _) ≤ b j rw [dif_pos hM] split_ifs with hT · exact (min_le_left _ _).trans (Finset.inf'_le b hj) · exact Finset.inf'_le b hj have hv_le_T : ∀ T ∈ Tset, v ≤ trapSetVal a b T := by intro T hTmem have hT : Tset.Nonempty := ⟨T, hTmem⟩ dsimp only [v]; unfold banditVal; rw [dif_pos hS, if_neg hpos] change (if hM' : M.Nonempty then if hT' : Tset.Nonempty then min (M.inf' hM' b) (Tset.inf' hT' (trapSetVal a b)) else M.inf' hM' b else if hT' : Tset.Nonempty then Tset.inf' hT' (trapSetVal a b) else 0) ≤ trapSetVal a b T by_cases hM : M.Nonempty · rw [dif_pos hM, dif_pos hT] exact (min_le_right _ _).trans (Finset.inf'_le (trapSetVal a b) hTmem) · rw [dif_neg hM, dif_pos hT] exact Finset.inf'_le (trapSetVal a b) hTmem -- Base dual weights on `N`: `q₀ j = max 0 ((v - b j) / (a j - b j))` let q₀ : α → ℝ := fun j => if j ∈ N then max 0 ((v - b j) / (a j - b j)) else 0 have hq₀_nn : ∀ j ∈ S, 0 ≤ q₀ j := fun j _ => by dsimp only [q₀]; split_ifs · exact le_max_left _ _ · exact le_rfl have hq₀_sum_le : ∑ j ∈ S, q₀ j ≤ 1 := by let Tpos := N.filter (fun j => b j < v) have hTpos_sub_N : Tpos ⊆ N := Finset.filter_subset _ N have hTpos_sub_S : Tpos ⊆ S := hTpos_sub_N.trans (Finset.filter_subset _ S) have hsum_eq : ∑ j ∈ S, q₀ j = ∑ j ∈ Tpos, (v - b j) / (a j - b j) := by rw [← Finset.sum_subset hTpos_sub_S] · refine Finset.sum_congr rfl fun j hj => ?_ rcases Finset.mem_filter.mp hj with ⟨hjN, hbv⟩ have hba : b j < a j := (Finset.mem_filter.mp hjN).2 dsimp only [q₀]; rw [if_pos hjN] exact max_eq_right (div_nonneg (by linarith) (by linarith)) · intro j _ hjnot dsimp only [q₀] by_cases hjN : j ∈ N · rw [if_pos hjN] have hvb : v ≤ b j := by by_contra hlt; push Not at hlt exact hjnot (Finset.mem_filter.mpr ⟨hjN, hlt⟩) have hba : b j < a j := (Finset.mem_filter.mp hjN).2 exact max_eq_left (div_nonpos_of_nonpos_of_nonneg (by linarith) (by linarith)) · rw [if_neg hjN] rw [hsum_eq] by_cases hTpos_ne : Tpos.Nonempty · have hTpos_mem : Tpos ∈ Tset := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hTpos_sub_N, hTpos_ne⟩ have hv_le := hv_le_T Tpos hTpos_mem unfold trapSetVal at hv_le set D : ℝ := ∑ j ∈ Tpos, 1 / (a j - b j) have hD_pos : 0 < D := by rcases hTpos_ne with ⟨j₀, hj₀⟩ have hba : b j₀ < a j₀ := (Finset.mem_filter.mp (hTpos_sub_N hj₀)).2 have hterm : 0 < 1 / (a j₀ - b j₀) := by positivity exact lt_of_lt_of_le hterm (Finset.single_le_sum (f := fun j => 1 / (a j - b j)) (fun j hj => by have := (Finset.mem_filter.mp (hTpos_sub_N hj)).2; positivity) hj₀) have hmul : v * D ≤ 1 + ∑ j ∈ Tpos, b j / (a j - b j) := (le_div_iff₀ hD_pos).mp hv_le have hdiff : ∑ j ∈ Tpos, (v - b j) / (a j - b j) = v * D - ∑ j ∈ Tpos, b j / (a j - b j) := by dsimp only [D] rw [Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun j _ => by ring linarith · rw [Finset.not_nonempty_iff_eq_empty.mp hTpos_ne, Finset.sum_empty] linarith -- Pick a dump index `j_dump ∈ S` with `b j_dump ≤ a j_dump`! have hex_dump : ∃ j ∈ S, b j ≤ a j := by push Not at hpos; exact hpos obtain ⟨j_dump, hj_dump_S, hbj_dump⟩ := hex_dump set rem : ℝ := 1 - ∑ j ∈ S, q₀ j have hrem_nn : 0 ≤ rem := by linarith let q : α → ℝ := fun j => q₀ j + if j = j_dump then rem else 0 have hq_nn : ∀ j ∈ S, 0 ≤ q j := fun j hj => by dsimp only [q] have h1 := hq₀_nn j hj split_ifs <;> linarith have hq_sum : ∑ j ∈ S, q j = 1 := by dsimp only [q] rw [Finset.sum_add_distrib, Finset.sum_ite_eq' S j_dump (fun _ => rem), if_pos hj_dump_S] dsimp only [rem]; ring refine ⟨q, ⟨hq_nn, hq_sum⟩, ?_⟩ intro yh hyh rw [banditColVal_eq a b q hq_sum hyh] by_cases hlt : b yh < a yh · -- `yh ∈ N`: `a yh - b yh > 0` and `q yh ≥ q₀ yh ≥ (v - b yh) / (a yh - b yh)` have hyhN : yh ∈ N := Finset.mem_filter.mpr ⟨hyh, hlt⟩ have hq_ge : (v - b yh) / (a yh - b yh) ≤ q yh := by have h1 : (v - b yh) / (a yh - b yh) ≤ q₀ yh := by dsimp only [q₀]; rw [if_pos hyhN]; exact le_max_right _ _ have h2 : q₀ yh ≤ q yh := by dsimp only [q]; split_ifs <;> linarith exact h1.trans h2 have hmul : v - b yh ≤ q yh * (a yh - b yh) := (div_le_iff₀ (by linarith)).mp hq_ge linarith · -- `yh ∈ M` (`a yh ≤ b yh`): push Not at hlt have hyhM : yh ∈ M := Finset.mem_filter.mpr ⟨hyh, hlt⟩ have hvb : v ≤ b yh := hv_le_M yh hyhM by_cases heq : a yh = b yh · rw [heq, sub_self, mul_zero, sub_zero]; exact hvb · -- `a yh < b yh`: so `yh ∉ N` AND `yh ≠ j_dump`, hence `q yh = 0`! have hyh_notN : yh ∉ N := fun h => by linarith [(Finset.mem_filter.mp h).2] have hyh_ne_dump : yh ≠ j_dump := fun h => by subst h; exact heq (le_antisymm hlt hbj_dump) have hq0 : q yh = 0 := by dsimp only [q, q₀]; rw [if_neg hyh_notN, if_neg hyh_ne_dump, add_zero] rw [hq0, zero_mul, sub_zero]; exact hvb /-- **Minimax Characterizations (`banditVal_le_of_primal` & `le_banditVal_of_dual`)**: Any learner distribution's worst-case row value is `≥ banditVal S a b`, and any adversary distribution's worst-case column value is `≤ banditVal S a b`. -/ theorem banditVal_le_of_primal {S : Finset α} (hS : S.Nonempty) {a b p : α → ℝ} {U : ℝ} (hp : IsDist S p) (hU : ∀ y ∈ S, banditRowVal S a b p y ≤ U) : banditVal S a b ≤ U := by obtain ⟨q, hq, hL⟩ := banditVal_dual_lower hS a b exact bandit_weak_duality hp hq hU hL theorem le_banditVal_of_dual {S : Finset α} (hS : S.Nonempty) {a b q : α → ℝ} {L : ℝ} (hq : IsDist S q) (hL : ∀ yh ∈ S, L ≤ banditColVal S a b q yh) : L ≤ banditVal S a b := by obtain ⟨p, hp, hU⟩ := banditVal_primal_upper hS a b exact bandit_weak_duality hp hq hU hL /-- **Universal Monotonicity of `banditVal`** in both `a` and `b` (3-line proof from minimax duality!). -/ theorem banditVal_mono {S : Finset α} (hS : S.Nonempty) {a b a' b' : α → ℝ} (ha : ∀ j ∈ S, a j ≤ a' j) (hb : ∀ j ∈ S, b j ≤ b' j) : banditVal S a b ≤ banditVal S a' b' := by obtain ⟨p', hp', hU'⟩ := banditVal_primal_upper hS a' b' refine banditVal_le_of_primal hS hp' fun y hy => ?_ have hle : banditRowVal S a b p' y ≤ banditRowVal S a' b' p' y := by unfold banditRowVal banditPayoff refine Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left ?_ (hp'.1 yh hyh) split_ifs with heq · subst heq; exact ha y hy · exact hb yh hyh exact hle.trans (hU' y hy) /-- `banditVal S a b ≥ 0` whenever `a, b ≥ 0` on `S`. -/ theorem banditVal_nonneg {S : Finset α} {a b : α → ℝ} (ha : ∀ j ∈ S, 0 ≤ a j) (hb : ∀ j ∈ S, 0 ≤ b j) : 0 ≤ banditVal S a b := by by_cases hS : S.Nonempty · rcases hS with ⟨j₀, hj₀⟩ refine le_banditVal_of_dual ⟨j₀, hj₀⟩ (q := fun j => if j = j₀ then 1 else 0) ⟨?_, ?_⟩ ?_ · intro j _; dsimp only; split_ifs <;> linarith · rw [Finset.sum_ite_eq' S j₀ (fun _ => (1 : ℝ)), if_pos hj₀] · intro yh hyh unfold banditColVal banditPayoff rw [Finset.sum_eq_single j₀] · dsimp only; rw [if_pos rfl, one_mul] split_ifs with heq · subst heq; exact ha j₀ hj₀ · exact hb yh hyh · intro j _ hne; dsimp only; rw [if_neg hne, zero_mul] · intro hnot; exact False.elim (hnot hj₀) · unfold banditVal; rw [dif_neg hS] /-- **Deterministic Upper Bound**: `banditVal S a b ≤ max (a yh) (b yh)` for every `yh ∈ S`. -/ theorem banditVal_le_det {S : Finset α} (hS : S.Nonempty) (a b : α → ℝ) {yh : α} (hyh : yh ∈ S) : banditVal S a b ≤ max (a yh) (b yh) := by refine banditVal_le_of_primal hS (p := fun j => if j = yh then 1 else 0) ⟨?_, ?_⟩ ?_ · intro j _; dsimp only; split_ifs <;> linarith · rw [Finset.sum_ite_eq' S yh (fun _ => (1 : ℝ)), if_pos hyh] · intro y _ unfold banditRowVal banditPayoff rw [Finset.sum_eq_single yh] · dsimp only; rw [if_pos rfl, one_mul] split_ifs with heq · subst heq; exact le_max_left _ _ · exact le_max_right _ _ · intro j _ hne; dsimp only; rw [if_neg hne, zero_mul] · intro hnot; exact False.elim (hnot hyh) /-- **Exact Closed Form for Symmetric Games**: When `a j = a₀` and `b j = b₀` on `|S| = m ≥ 1`, `banditVal S a b = (a₀ + (m - 1) * b₀) / m`. -/ theorem banditVal_symmetric {S : Finset α} (hS : S.Nonempty) {a b : α → ℝ} {a₀ b₀ : ℝ} (ha : ∀ j ∈ S, a j = a₀) (hb : ∀ j ∈ S, b j = b₀) : banditVal S a b = (a₀ + ((S.card : ℝ) - 1) * b₀) / (S.card : ℝ) := by have hm_pos : (0 : ℝ) < (S.card : ℝ) := by exact_mod_cast hS.card_pos have _hm_ge1 : (1 : ℝ) ≤ (S.card : ℝ) := by exact_mod_cast hS.card_pos let u : α → ℝ := fun _ => 1 / (S.card : ℝ) have hu : IsDist S u := by refine ⟨fun _ _ => by positivity, ?_⟩ dsimp only [u]; rw [Finset.sum_const, nsmul_eq_mul, mul_one_div, div_self hm_pos.ne'] have hval_eq : b₀ - 1 / (S.card : ℝ) * (b₀ - a₀) = (a₀ + ((S.card : ℝ) - 1) * b₀) / (S.card : ℝ) := by field_simp [hm_pos.ne']; ring apply le_antisymm · refine banditVal_le_of_primal hS hu fun y hy => ?_ rw [banditRowVal_eq a b u hy] have hB : ∑ yh ∈ S, u yh * b yh = b₀ := by have hcongr : ∑ yh ∈ S, u yh * b yh = ∑ _yh ∈ S, (1 / (S.card : ℝ)) * b₀ := Finset.sum_congr rfl fun yh hyh => by rw [hb yh hyh] rw [hcongr, Finset.sum_const, nsmul_eq_mul]; field_simp [hm_pos.ne'] rw [hB, ha y hy, hb y hy] dsimp only [u]; linarith · refine le_banditVal_of_dual hS hu fun yh hyh => ?_ rw [banditColVal_eq a b u hu.2 hyh, ha yh hyh, hb yh hyh] dsimp only [u]; linarith /-- **Exact Recovery of Filmus–Hanneke–Mehalel–Moran (COLT 2023) Binary `RLdim` Recursion**: On a 2-label set `S = {y₀, y₁}` (`y₀ ≠ y₁`) with binary bandit symmetry `b y₀ = 1 + a y₁` and `b y₁ = 1 + a y₀`, `banditVal S a b = max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2)`. -/ theorem banditVal_binary_eq {y₀ y₁ : α} (hne : y₀ ≠ y₁) (a b : α → ℝ) (hb0 : b y₀ = 1 + a y₁) (hb1 : b y₁ = 1 + a y₀) : banditVal ({y₀, y₁} : Finset α) a b = max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2) := by let S : Finset α := {y₀, y₁} have hS : S.Nonempty := ⟨y₀, Finset.mem_insert_self _ _⟩ have hy0 : y₀ ∈ S := Finset.mem_insert_self _ _ have hy1 : y₁ ∈ S := Finset.mem_insert_of_mem (Finset.mem_singleton_self _) -- Case split on whether `|a y₀ - a y₁| ≤ 1`! by_cases h1 : a y₀ ≥ 1 + a y₁ · -- `a y₀ ≥ 1 + a y₁ = b y₀`: target is `a y₀`! have hmax : max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2) = a y₀ := by have hm1 : max (a y₀) (a y₁) = a y₀ := max_eq_left (by linarith) rw [hm1, max_eq_left (by linarith)] rw [hmax] apply le_antisymm · have := banditVal_le_det hS a b hy0 rw [hb0, max_eq_left h1] at this; exact this · refine le_banditVal_of_dual hS (q := fun j => if j = y₀ then 1 else 0) ⟨?_, ?_⟩ ?_ · intro j _; dsimp only; split_ifs <;> linarith · rw [Finset.sum_ite_eq' S y₀ (fun _ => (1 : ℝ)), if_pos hy0] · intro yh hyh unfold banditColVal banditPayoff rw [Finset.sum_eq_single y₀] · dsimp only; rw [if_pos rfl, one_mul] split_ifs with heq · subst heq; exact le_rfl · have hyh1 : yh = y₁ := by rcases Finset.mem_insert.mp hyh with rfl | h · exact False.elim (heq rfl) · exact Finset.mem_singleton.mp h rw [hyh1, hb1]; linarith · intro j _ hne'; dsimp only; rw [if_neg hne', zero_mul] · intro hnot; exact False.elim (hnot hy0) · by_cases h2 : a y₁ ≥ 1 + a y₀ · -- Symmetric: `a y₁ ≥ 1 + a y₀ = b y₁`, target is `a y₁`! have hmax : max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2) = a y₁ := by have hm1 : max (a y₀) (a y₁) = a y₁ := max_eq_right (by linarith) rw [hm1, max_eq_left (by linarith)] rw [hmax] apply le_antisymm · have := banditVal_le_det hS a b hy1 rw [hb1, max_eq_left h2] at this; exact this · refine le_banditVal_of_dual hS (q := fun j => if j = y₁ then 1 else 0) ⟨?_, ?_⟩ ?_ · intro j _; dsimp only; split_ifs <;> linarith · rw [Finset.sum_ite_eq' S y₁ (fun _ => (1 : ℝ)), if_pos hy1] · intro yh hyh unfold banditColVal banditPayoff rw [Finset.sum_eq_single y₁] · dsimp only; rw [if_pos rfl, one_mul] split_ifs with heq · subst heq; exact le_rfl · have hyh0 : yh = y₀ := by rcases Finset.mem_insert.mp hyh with rfl | h · rfl · exact False.elim (heq (Finset.mem_singleton.mp h).symm) rw [hyh0, hb0]; linarith · intro j _ hne'; dsimp only; rw [if_neg hne', zero_mul] · intro hnot; exact False.elim (hnot hy1) · -- Interior: `|a y₀ - a y₁| < 1`, target is `(1 + a y₀ + a y₁) / 2`! push Not at h1 h2 have hmax : max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2) = (1 + a y₀ + a y₁) / 2 := by rw [max_eq_right (max_le (by linarith) (by linarith))] rw [hmax] apply le_antisymm · -- Learner plays `p y₀ = (1 + a y₀ - a y₁) / 2`, `p y₁ = (1 + a y₁ - a y₀) / 2`! let p : α → ℝ := fun j => if j = y₀ then (1 + a y₀ - a y₁) / 2 else (1 + a y₁ - a y₀) / 2 have hp : IsDist S p := by refine ⟨fun j hj => ?_, ?_⟩ · dsimp only [p]; split_ifs <;> linarith · rw [Finset.sum_pair hne]; dsimp only [p] rw [if_pos rfl, if_neg hne.symm]; ring refine banditVal_le_of_primal hS hp fun y hy => ?_ unfold banditRowVal banditPayoff rw [Finset.sum_pair hne] dsimp only [p] rw [if_pos rfl, if_neg hne.symm] rcases Finset.mem_insert.mp hy with rfl | hy' · rw [if_pos rfl, if_neg hne, hb1]; linarith · rw [Finset.mem_singleton.mp hy', if_neg hne.symm, if_pos rfl, hb0]; linarith · -- Adversary plays uniform `q = (1/2, 1/2)`! let q : α → ℝ := fun _ => 1 / 2 have hq : IsDist S q := by refine ⟨fun _ _ => by norm_num, ?_⟩ rw [Finset.sum_pair hne]; dsimp only [q]; ring refine le_banditVal_of_dual hS hq fun yh hyh => ?_ unfold banditColVal banditPayoff rw [Finset.sum_pair hne]; dsimp only [q] rcases Finset.mem_insert.mp hyh with rfl | hyh' · rw [if_pos rfl, if_neg hne.symm, hb0]; linarith · rw [Finset.mem_singleton.mp hyh', if_neg hne, if_pos rfl, hb1]; linarith end BanditMinimaxGame /-! ## Section 2: Multiclass Full-Information Water-Filling Minimax Theorem (`fullInfoVal`) -/ section FullInfoMinimaxGame variable {α : Type*} [DecidableEq α] /-- Full-information multiclass one-round payoff matrix `F(y, yh) = a y + 1_{y ≠ yh}`. -/ def fullInfoPayoff (a : α → ℝ) (y yh : α) : ℝ := a y + if y = yh then 0 else 1 /-- Expected full-information payoff to adversary playing `y` against learner `p`. -/ def fullInfoRowVal (S : Finset α) (a p : α → ℝ) (y : α) : ℝ := ∑ yh ∈ S, p yh * fullInfoPayoff a y yh /-- Expected full-information payoff to learner playing `yh` against adversary `q`. -/ def fullInfoColVal (S : Finset α) (a q : α → ℝ) (yh : α) : ℝ := ∑ y ∈ S, q y * fullInfoPayoff a y yh lemma fullInfoRowVal_eq {S : Finset α} (a p : α → ℝ) (hp : ∑ yh ∈ S, p yh = 1) {y : α} (hy : y ∈ S) : fullInfoRowVal S a p y = a y + 1 - p y := by unfold fullInfoRowVal fullInfoPayoff have hsplit : ∑ yh ∈ S, p yh * (a y + if y = yh then 0 else 1) = ∑ yh ∈ S, (p yh * (a y + 1) - if y = yh then p yh else 0) := by refine Finset.sum_congr rfl fun yh _ => ?_ split_ifs <;> ring rw [hsplit, Finset.sum_sub_distrib, ← Finset.sum_mul, hp, one_mul, Finset.sum_ite_eq S y p, if_pos hy] lemma fullInfoColVal_eq {S : Finset α} (a q : α → ℝ) (hq : ∑ y ∈ S, q y = 1) {yh : α} (hyh : yh ∈ S) : fullInfoColVal S a q yh = (∑ y ∈ S, q y * a y) + 1 - q yh := by unfold fullInfoColVal fullInfoPayoff have hsplit : ∑ y ∈ S, q y * (a y + if y = yh then 0 else 1) = ∑ y ∈ S, (q y * a y + q y - if y = yh then q y else 0) := by refine Finset.sum_congr rfl fun y _ => ?_ split_ifs <;> ring rw [hsplit, Finset.sum_sub_distrib, Finset.sum_add_distrib, hq, Finset.sum_ite_eq' S yh q, if_pos hyh] lemma fullInfo_bilinear_eq (S : Finset α) (a p q : α → ℝ) : ∑ y ∈ S, q y * fullInfoRowVal S a p y = ∑ yh ∈ S, p yh * fullInfoColVal S a q yh := by unfold fullInfoRowVal fullInfoColVal simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun yh _ => Finset.sum_congr rfl fun y _ => by ring theorem fullInfo_weak_duality {S : Finset α} {a p q : α → ℝ} {L U : ℝ} (hp : IsDist S p) (hq : IsDist S q) (hU : ∀ y ∈ S, fullInfoRowVal S a p y ≤ U) (hL : ∀ yh ∈ S, L ≤ fullInfoColVal S a q yh) : L ≤ U := by have h1 : L ≤ ∑ yh ∈ S, p yh * fullInfoColVal S a q yh := by calc L = ∑ yh ∈ S, p yh * L := by rw [← Finset.sum_mul, hp.2, one_mul] _ ≤ ∑ yh ∈ S, p yh * fullInfoColVal S a q yh := Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left (hL yh hyh) (hp.1 yh hyh) have h2 : ∑ y ∈ S, q y * fullInfoRowVal S a p y ≤ U := by calc ∑ y ∈ S, q y * fullInfoRowVal S a p y ≤ ∑ y ∈ S, q y * U := Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left (hU y hy) (hq.1 y hy) _ = U := by rw [← Finset.sum_mul, hq.2, one_mul] linarith [fullInfo_bilinear_eq S a p q] /-- Subset water-filling average `(∑_{y ∈ T} a y + |T| - 1) / |T|`. -/ noncomputable def fullInfoSubsetVal (a : α → ℝ) (T : Finset α) : ℝ := (∑ y ∈ T, a y + (T.card : ℝ) - 1) / (T.card : ℝ) /-- **Exact Closed-Form Multiclass Full-Information Minimax Value**: `fullInfoVal S a = max_{∅ ≠ T ⊆ S} (∑_{y ∈ T} a y + |T| - 1) / |T|`. -/ noncomputable def fullInfoVal (S : Finset α) (a : α → ℝ) : ℝ := by classical let Tset := S.powerset.filter Finset.Nonempty exact if hT : Tset.Nonempty then Tset.sup' hT (fullInfoSubsetVal a) else 0 omit [DecidableEq α] in private lemma powerset_nonempty_of_nonempty {S : Finset α} (hS : S.Nonempty) : (S.powerset.filter Finset.Nonempty).Nonempty := ⟨S, Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr Subset.rfl, hS⟩⟩ /-- **Full-Information Water-Filling Primal Optimal Strategy**: Play `p* y = max 0 (a y + 1 - v)` (plus any leftover mass `1 - ∑ p₀` anywhere in `S`)! -/ theorem fullInfoVal_primal_upper {S : Finset α} (hS : S.Nonempty) (a : α → ℝ) : ∃ p : α → ℝ, IsDist S p ∧ ∀ y ∈ S, fullInfoRowVal S a p y ≤ fullInfoVal S a := by classical set v := fullInfoVal S a have hTne : (S.powerset.filter Finset.Nonempty).Nonempty := powerset_nonempty_of_nonempty hS have hsub_le_v : ∀ T ∈ S.powerset.filter Finset.Nonempty, fullInfoSubsetVal a T ≤ v := by intro T hT dsimp only [v]; unfold fullInfoVal; rw [dif_pos hTne] exact Finset.le_sup' (fullInfoSubsetVal a) hT let p₀ : α → ℝ := fun y => max 0 (a y + 1 - v) have hp₀_nn : ∀ y ∈ S, 0 ≤ p₀ y := fun _ _ => le_max_left _ _ have hp₀_sum_le : ∑ y ∈ S, p₀ y ≤ 1 := by let Tpos := S.filter (fun y => 0 < a y + 1 - v) have hTpos_sub : Tpos ⊆ S := Finset.filter_subset _ S have hsum_eq : ∑ y ∈ S, p₀ y = ∑ y ∈ Tpos, (a y + 1 - v) := by rw [← Finset.sum_subset hTpos_sub] · refine Finset.sum_congr rfl fun y hy => by have hpos := (Finset.mem_filter.mp hy).2 exact max_eq_right hpos.le · intro y hyS hnot have hle : a y + 1 - v ≤ 0 := by by_contra hlt; push Not at hlt exact hnot (Finset.mem_filter.mpr ⟨hyS, hlt⟩) exact max_eq_left hle rw [hsum_eq] by_cases hTpos_ne : Tpos.Nonempty · have hle := hsub_le_v Tpos (Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hTpos_sub, hTpos_ne⟩) unfold fullInfoSubsetVal at hle have hc_pos : (0 : ℝ) < (Tpos.card : ℝ) := by exact_mod_cast hTpos_ne.card_pos have hmul : ∑ y ∈ Tpos, a y + (Tpos.card : ℝ) - 1 ≤ v * (Tpos.card : ℝ) := (div_le_iff₀ hc_pos).mp hle have hexp : ∑ y ∈ Tpos, (a y + 1 - v) = ∑ y ∈ Tpos, a y + (Tpos.card : ℝ) - v * (Tpos.card : ℝ) := by rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul]; ring linarith · rw [Finset.not_nonempty_iff_eq_empty.mp hTpos_ne, Finset.sum_empty]; norm_num rcases hS with ⟨y₀, hy₀⟩ set rem : ℝ := 1 - ∑ y ∈ S, p₀ y have hrem_nn : 0 ≤ rem := by linarith let p : α → ℝ := fun y => p₀ y + if y = y₀ then rem else 0 have hp_nn : ∀ y ∈ S, 0 ≤ p y := fun y hy => by dsimp only [p]; have := hp₀_nn y hy; split_ifs <;> linarith have hp_sum : ∑ y ∈ S, p y = 1 := by dsimp only [p] rw [Finset.sum_add_distrib, Finset.sum_ite_eq' S y₀ (fun _ => rem), if_pos hy₀] dsimp only [rem]; ring refine ⟨p, ⟨hp_nn, hp_sum⟩, ?_⟩ intro y hy rw [fullInfoRowVal_eq a p hp_sum hy] have hge : a y + 1 - v ≤ p y := by have h1 : a y + 1 - v ≤ p₀ y := le_max_right _ _ have h2 : p₀ y ≤ p y := by dsimp only [p]; split_ifs <;> linarith exact h1.trans h2 linarith /-- **Full-Information Dual Optimal Strategy**: Uniform distribution on the maximizing subset `T*`! -/ theorem fullInfoVal_dual_lower {S : Finset α} (hS : S.Nonempty) (a : α → ℝ) : ∃ q : α → ℝ, IsDist S q ∧ ∀ yh ∈ S, fullInfoVal S a ≤ fullInfoColVal S a q yh := by classical have hTne : (S.powerset.filter Finset.Nonempty).Nonempty := powerset_nonempty_of_nonempty hS obtain ⟨T, hTmem, hTeq⟩ := Finset.exists_mem_eq_sup' hTne (fullInfoSubsetVal a) have hv_eq : fullInfoVal S a = fullInfoSubsetVal a T := by unfold fullInfoVal; rw [dif_pos hTne, hTeq] rcases Finset.mem_filter.mp hTmem with ⟨hTpow, hT_ne⟩ have hTS : T ⊆ S := Finset.mem_powerset.mp hTpow have hc_pos : (0 : ℝ) < (T.card : ℝ) := by exact_mod_cast hT_ne.card_pos let q : α → ℝ := fun y => if y ∈ T then 1 / (T.card : ℝ) else 0 have hq_nn : ∀ y ∈ S, 0 ≤ q y := fun y _ => by dsimp only [q]; split_ifs <;> positivity have hq_sum : ∑ y ∈ S, q y = 1 := by have hsub : ∑ y ∈ S, q y = ∑ _y ∈ T, (1 / (T.card : ℝ)) := by dsimp only [q] rw [← Finset.sum_subset hTS (fun y _ hy => by simp [hy])] refine Finset.sum_congr rfl fun y hy => by simp [hy] rw [hsub, Finset.sum_const, nsmul_eq_mul, mul_one_div, div_self hc_pos.ne'] refine ⟨q, ⟨hq_nn, hq_sum⟩, ?_⟩ intro yh hyh rw [fullInfoColVal_eq a q hq_sum hyh, hv_eq] unfold fullInfoSubsetVal have hqa : ∑ y ∈ S, q y * a y = (∑ y ∈ T, a y) / (T.card : ℝ) := by have hsub : ∑ y ∈ S, q y * a y = ∑ y ∈ T, (1 / (T.card : ℝ)) * a y := by dsimp only [q] rw [← Finset.sum_subset hTS (fun y _ hy => by simp [hy])] refine Finset.sum_congr rfl fun y hy => by simp [hy] rw [hsub, Finset.sum_div] refine Finset.sum_congr rfl fun y _ => by ring rw [hqa] have hqyh_le : q yh ≤ 1 / (T.card : ℝ) := by dsimp only [q]; split_ifs · exact le_rfl · positivity have hrew : (∑ y ∈ T, a y + (T.card : ℝ) - 1) / (T.card : ℝ) = (∑ y ∈ T, a y) / (T.card : ℝ) + 1 - 1 / (T.card : ℝ) := by field_simp [hc_pos.ne'] linarith theorem fullInfoVal_le_of_primal {S : Finset α} (hS : S.Nonempty) {a p : α → ℝ} {U : ℝ} (hp : IsDist S p) (hU : ∀ y ∈ S, fullInfoRowVal S a p y ≤ U) : fullInfoVal S a ≤ U := by obtain ⟨q, hq, hL⟩ := fullInfoVal_dual_lower hS a exact fullInfo_weak_duality hp hq hU hL theorem le_fullInfoVal_of_dual {S : Finset α} (hS : S.Nonempty) {a q : α → ℝ} {L : ℝ} (hq : IsDist S q) (hL : ∀ yh ∈ S, L ≤ fullInfoColVal S a q yh) : L ≤ fullInfoVal S a := by obtain ⟨p, hp, hU⟩ := fullInfoVal_primal_upper hS a exact fullInfo_weak_duality hp hq hU hL theorem fullInfoVal_mono {S : Finset α} (hS : S.Nonempty) {a a' : α → ℝ} (ha : ∀ j ∈ S, a j ≤ a' j) : fullInfoVal S a ≤ fullInfoVal S a' := by obtain ⟨p', hp', hU'⟩ := fullInfoVal_primal_upper hS a' refine fullInfoVal_le_of_primal hS hp' fun y hy => ?_ have hle : fullInfoRowVal S a p' y ≤ fullInfoRowVal S a' p' y := by unfold fullInfoRowVal fullInfoPayoff exact Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left (by linarith [ha y hy]) (hp'.1 yh hyh) exact hle.trans (hU' y hy) omit [DecidableEq α] in theorem fullInfoVal_nonneg {S : Finset α} {a : α → ℝ} (ha : ∀ j ∈ S, 0 ≤ a j) : 0 ≤ fullInfoVal S a := by by_cases hS : S.Nonempty · rcases hS with ⟨y₀, hy₀⟩ have hTne := powerset_nonempty_of_nonempty ⟨y₀, hy₀⟩ have hmem : ({y₀} : Finset α) ∈ S.powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Finset.singleton_subset_iff.mpr hy₀), Finset.singleton_nonempty y₀⟩ unfold fullInfoVal; rw [dif_pos hTne] calc (0 : ℝ) ≤ a y₀ := ha y₀ hy₀ _ = fullInfoSubsetVal a {y₀} := by unfold fullInfoSubsetVal; simp _ ≤ _ := Finset.le_sup' (fullInfoSubsetVal a) hmem · unfold fullInfoVal have hEmpty : ¬ (S.powerset.filter Finset.Nonempty).Nonempty := by rintro ⟨T, hT⟩ rcases Finset.mem_filter.mp hT with ⟨hTpow, ⟨x, hx⟩⟩ exact hS ⟨x, Finset.mem_powerset.mp hTpow hx⟩ rw [dif_neg hEmpty] /-- **Pairwise Half-Factor Lower Bound**: For ANY two distinct labels `y₁ ≠ y₂` in `S`, `(1 + a y₁ + a y₂) / 2 ≤ fullInfoVal S a`! (Immediate from `T = {y₁, y₂}`!) -/ theorem fullInfoVal_ge_pair {S : Finset α} {a : α → ℝ} {y₁ y₂ : α} (hy₁ : y₁ ∈ S) (hy₂ : y₂ ∈ S) (hne : y₁ ≠ y₂) : (1 + a y₁ + a y₂) / 2 ≤ fullInfoVal S a := by classical have hS : S.Nonempty := ⟨y₁, hy₁⟩ have hTne := powerset_nonempty_of_nonempty hS let T : Finset α := {y₁, y₂} have hTmem : T ∈ S.powerset.filter Finset.Nonempty := by refine Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ?_, ⟨y₁, Finset.mem_insert_self _ _⟩⟩ intro x hx rcases Finset.mem_insert.mp hx with rfl | hx' · exact hy₁ · rw [Finset.mem_singleton.mp hx']; exact hy₂ unfold fullInfoVal; rw [dif_pos hTne] calc (1 + a y₁ + a y₂) / 2 = fullInfoSubsetVal a T := by unfold fullInfoSubsetVal have hcard : T.card = 2 := Finset.card_pair hne rw [Finset.sum_pair hne, hcard]; push_cast; ring _ ≤ _ := Finset.le_sup' (fullInfoSubsetVal a) hTmem /-- **Bandit vs. Full-Information One-Round Dominance**: Whenever `a y + 1 ≤ b yh` for all distinct `y ≠ yh` in `S` (and `a y ≤ a' y`), `fullInfoVal S a ≤ banditVal S a' b`! -/ theorem fullInfoVal_le_banditVal {S : Finset α} (hS : S.Nonempty) {a a' b : α → ℝ} (ha : ∀ y ∈ S, a y ≤ a' y) (hb : ∀ y ∈ S, ∀ yh ∈ S, y ≠ yh → a y + 1 ≤ b yh) : fullInfoVal S a ≤ banditVal S a' b := by obtain ⟨p, hp, hU⟩ := banditVal_primal_upper hS a' b refine fullInfoVal_le_of_primal hS hp fun y hy => ?_ have hle : fullInfoRowVal S a p y ≤ banditRowVal S a' b p y := by unfold fullInfoRowVal fullInfoPayoff banditRowVal banditPayoff refine Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left ?_ (hp.1 yh hyh) split_ifs with heq · subst heq; linarith [ha y hy] · exact hb y hy yh hyh heq exact hle.trans (hU y hy) /-- **Exact Full-Information Binary Formula**: On `S = {y₀, y₁}` (`y₀ ≠ y₁`), `fullInfoVal {y₀, y₁} a = max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2)`. -/ theorem fullInfoVal_binary_eq {y₀ y₁ : α} (hne : y₀ ≠ y₁) (a : α → ℝ) : fullInfoVal ({y₀, y₁} : Finset α) a = max (max (a y₀) (a y₁)) ((1 + a y₀ + a y₁) / 2) := by classical let S : Finset α := {y₀, y₁} have hTne := powerset_nonempty_of_nonempty (S := S) ⟨y₀, Finset.mem_insert_self _ _⟩ unfold fullInfoVal; rw [dif_pos hTne] apply le_antisymm · refine Finset.sup'_le hTne _ fun T hT => ?_ rcases Finset.mem_filter.mp hT with ⟨hTpow, hT_ne⟩ have hTS : T ⊆ S := Finset.mem_powerset.mp hTpow by_cases h0 : y₀ ∈ T · by_cases h1 : y₁ ∈ T · have hTeq : T = {y₀, y₁} := by ext x; constructor · intro hx; exact hTS hx · intro hx; rcases Finset.mem_insert.mp hx with rfl | hx' · exact h0 · rw [Finset.mem_singleton.mp hx']; exact h1 rw [hTeq]; unfold fullInfoSubsetVal rw [Finset.sum_pair hne, Finset.card_pair hne]; push_cast have : (a y₀ + a y₁ + 2 - 1) / 2 = (1 + a y₀ + a y₁) / 2 := by ring rw [this]; exact le_max_right _ _ · have hTeq : T = {y₀} := by ext x; constructor · intro hx; rcases Finset.mem_insert.mp (hTS hx) with rfl | hx' · exact Finset.mem_singleton_self _ · exact False.elim (h1 (Finset.mem_singleton.mp hx' ▸ hx)) · intro hx; rw [Finset.mem_singleton.mp hx]; exact h0 rw [hTeq]; unfold fullInfoSubsetVal; simp · have h1 : y₁ ∈ T := by rcases hT_ne with ⟨x, hx⟩ rcases Finset.mem_insert.mp (hTS hx) with rfl | hx' · exact False.elim (h0 hx) · exact Finset.mem_singleton.mp hx' ▸ hx have hTeq : T = {y₁} := by ext x; constructor · intro hx; rcases Finset.mem_insert.mp (hTS hx) with rfl | hx' · exact False.elim (h0 hx) · exact hx' · intro hx; rw [Finset.mem_singleton.mp hx]; exact h1 rw [hTeq]; unfold fullInfoSubsetVal; simp · refine max_le (max_le ?_ ?_) ?_ · have hmem : ({y₀} : Finset α) ∈ S.powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Finset.singleton_subset_iff.mpr (Finset.mem_insert_self _ _)), Finset.singleton_nonempty _⟩ calc a y₀ = fullInfoSubsetVal a {y₀} := by unfold fullInfoSubsetVal; simp _ ≤ _ := Finset.le_sup' (fullInfoSubsetVal a) hmem · have hmem : ({y₁} : Finset α) ∈ S.powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Finset.singleton_subset_iff.mpr (Finset.mem_insert_of_mem (Finset.mem_singleton_self _))), Finset.singleton_nonempty _⟩ calc a y₁ = fullInfoSubsetVal a {y₁} := by unfold fullInfoSubsetVal; simp _ ≤ _ := Finset.le_sup' (fullInfoSubsetVal a) hmem · have hmem : S ∈ S.powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr Subset.rfl, ⟨y₀, Finset.mem_insert_self _ _⟩⟩ calc (1 + a y₀ + a y₁) / 2 = fullInfoSubsetVal a S := by unfold fullInfoSubsetVal rw [Finset.sum_pair hne, Finset.card_pair hne]; push_cast; ring _ ≤ _ := Finset.le_sup' (fullInfoSubsetVal a) hmem /-- Exact symmetric full-information value: if `a j = a₀` for all `j ∈ S` (`|S| = m ≥ 1`), `fullInfoVal S a = a₀ + (m - 1) / m`. -/ theorem fullInfoVal_symmetric {S : Finset α} (hS : S.Nonempty) {a : α → ℝ} {a₀ : ℝ} (ha : ∀ j ∈ S, a j = a₀) : fullInfoVal S a = a₀ + ((S.card : ℝ) - 1) / (S.card : ℝ) := by have hm_pos : (0 : ℝ) < (S.card : ℝ) := by exact_mod_cast hS.card_pos let u : α → ℝ := fun _ => 1 / (S.card : ℝ) have hu : IsDist S u := by refine ⟨fun _ _ => by positivity, ?_⟩ dsimp only [u]; rw [Finset.sum_const, nsmul_eq_mul, mul_one_div, div_self hm_pos.ne'] have hval_eq : a₀ + 1 - 1 / (S.card : ℝ) = a₀ + ((S.card : ℝ) - 1) / (S.card : ℝ) := by field_simp [hm_pos.ne']; ring apply le_antisymm · refine fullInfoVal_le_of_primal hS hu fun y hy => ?_ rw [fullInfoRowVal_eq a u hu.2 hy, ha y hy] dsimp only [u]; linarith · refine le_fullInfoVal_of_dual hS hu fun yh hyh => ?_ rw [fullInfoColVal_eq a u hu.2 hyh] have hqa : ∑ y ∈ S, u y * a y = a₀ := by have hcongr : ∑ y ∈ S, u y * a y = ∑ _y ∈ S, (1 / (S.card : ℝ)) * a₀ := Finset.sum_congr rfl fun y hy => by rw [ha y hy] rw [hcongr, Finset.sum_const, nsmul_eq_mul]; field_simp [hm_pos.ne'] rw [hqa]; dsimp only [u]; linarith end FullInfoMinimaxGame /-! ## Section 3: Exact Recursive Online Learning Dimensions (`RBLdim`, `BLdim`, `RLdim`, `Ldim`) -/ section OnlineLearningDimensions variable {X Y : Type*} [DecidableEq Y] /-- Subset of hypotheses `h ∈ V` consistent with `h x = y`. -/ def restrictEq (V : Finset (X → Y)) (x : X) (y : Y) : Finset (X → Y) := V.filter fun h => h x = y /-- Subset of hypotheses `h ∈ V` consistent with `h x ≠ y` (bandit mistake update). -/ def restrictNe (V : Finset (X → Y)) (x : X) (y : Y) : Finset (X → Y) := V.filter fun h => h x ≠ y /-- Set of active labels `{h x : h ∈ V}` achievable on query `x`. -/ def activeLabels (V : Finset (X → Y)) (x : X) : Finset Y := V.image fun h => h x lemma restrictEq_subset (V : Finset (X → Y)) (x : X) (y : Y) : restrictEq V x y ⊆ V := Finset.filter_subset _ V lemma restrictNe_subset (V : Finset (X → Y)) (x : X) (y : Y) : restrictNe V x y ⊆ V := Finset.filter_subset _ V lemma restrictEq_mono {V W : Finset (X → Y)} (hVW : V ⊆ W) (x : X) (y : Y) : restrictEq V x y ⊆ restrictEq W x y := Finset.filter_subset_filter _ hVW lemma restrictNe_mono {V W : Finset (X → Y)} (hVW : V ⊆ W) (x : X) (y : Y) : restrictNe V x y ⊆ restrictNe W x y := Finset.filter_subset_filter _ hVW lemma activeLabels_mono {V W : Finset (X → Y)} (hVW : V ⊆ W) (x : X) : activeLabels V x ⊆ activeLabels W x := Finset.image_subset_image hVW lemma restrictEq_subset_restrictNe {V : Finset (X → Y)} {x : X} {y yh : Y} (hne : y ≠ yh) : restrictEq V x y ⊆ restrictNe V x yh := by intro h hh rcases Finset.mem_filter.mp hh with ⟨hV, hxy⟩ exact Finset.mem_filter.mpr ⟨hV, hxy.symm ▸ hne⟩ /-- When `2 ≤ (activeLabels V x).card`, BOTH `restrictEq V x y` and `restrictNe V x y` have strictly smaller cardinality than `V` for every `y ∈ activeLabels V x`! -/ lemma card_restrictEq_lt {V : Finset (X → Y)} {x : X} (hact : 2 ≤ (activeLabels V x).card) {y : Y} : (restrictEq V x y).card < V.card := by have hex : ∃ y' ∈ activeLabels V x, y' ≠ y := by by_contra h push Not at h have hsub : activeLabels V x ⊆ {y} := fun y' hy' => Finset.mem_singleton.mpr (h y' hy') have hle := (Finset.card_le_card hsub).trans (by simp : ({y} : Finset Y).card ≤ 1) omega rcases hex with ⟨y', hy', hne⟩ rcases Finset.mem_image.mp hy' with ⟨h, hV, hxy'⟩ refine Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨restrictEq_subset V x y, fun heq => ?_⟩) have hmem : h ∈ restrictEq V x y := heq.symm ▸ hV exact hne (hxy'.symm.trans (Finset.mem_filter.mp hmem).2) lemma card_restrictNe_lt {V : Finset (X → Y)} {x : X} {y : Y} (hy : y ∈ activeLabels V x) : (restrictNe V x y).card < V.card := by rcases Finset.mem_image.mp hy with ⟨h, hV, hxy⟩ refine Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨restrictNe_subset V x y, fun heq => ?_⟩) have hmem : h ∈ restrictNe V x y := heq.symm ▸ hV exact (Finset.mem_filter.mp hmem).2 hxy lemma card_restrictEq_add_restrictNe (V : Finset (X → Y)) (x : X) (y : Y) : (restrictEq V x y).card + (restrictNe V x y).card = V.card := by classical unfold restrictEq restrictNe have hunion : V.filter (fun h => h x = y) ∪ V.filter (fun h => h x ≠ y) = V := by ext h; simp only [Finset.mem_union, Finset.mem_filter]; tauto have hdisj : Disjoint (V.filter fun h => h x = y) (V.filter fun h => h x ≠ y) := Finset.disjoint_filter.mpr fun _ _ h1 h2 => h2 h1 rw [← Finset.card_union_of_disjoint hdisj, hunion] lemma sum_card_restrictEq (V : Finset (X → Y)) (x : X) : ∑ y ∈ activeLabels V x, (restrictEq V x y).card = V.card := by classical have hunion : V = (activeLabels V x).biUnion (fun y => restrictEq V x y) := by ext h simp only [Finset.mem_biUnion, activeLabels, Finset.mem_image, restrictEq, Finset.mem_filter] constructor · intro hV; exact ⟨h x, ⟨h, hV, rfl⟩, hV, rfl⟩ · rintro ⟨_, _, hV, _⟩; exact hV have hdisj : Set.PairwiseDisjoint (activeLabels V x : Set Y) (fun y => restrictEq V x y) := by intro y₁ _ y₂ _ hne dsimp only [Function.onFun] rw [Finset.disjoint_left] intro h h1 h2 exact hne ((Finset.mem_filter.mp h1).2.symm.trans (Finset.mem_filter.mp h2).2) conv_rhs => rw [hunion] rw [Finset.card_biUnion hdisj] variable [Fintype X] /-- **Harmonic-Mean Randomized Bandit Littlestone Dimension `RBLdim V`**: Exact minimax expected mistakes in realizable randomized online learning under bandit feedback (well-founded recursion on `V.card`). -/ noncomputable def RBLdim (V : Finset (X → Y)) : ℝ := if _hV : V.card ≤ 1 then 0 else let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) if hX : ActiveX.Nonempty then ActiveX.sup' hX fun x => banditVal (activeLabels V x) (fun y => if _hlt : (restrictEq V x y).card < V.card then RBLdim (restrictEq V x y) else 0) (fun yh => if _hlt : (restrictNe V x yh).card < V.card then 1 + RBLdim (restrictNe V x yh) else 0) else 0 termination_by V.card /-- **Deterministic Bandit Littlestone Dimension `BLdim V`** (Daniely–Helbertal 2013): Exact worst-case deterministic bandit mistake bound. -/ noncomputable def BLdim (V : Finset (X → Y)) : ℕ := if _hV : V.card ≤ 1 then 0 else let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) if hX : ActiveX.Nonempty then ActiveX.sup' hX fun x => if hL : (activeLabels V x).Nonempty then (activeLabels V x).inf' hL fun yh => max (if _ : (restrictEq V x yh).card < V.card then BLdim (restrictEq V x yh) else 0) (if _ : (restrictNe V x yh).card < V.card then 1 + BLdim (restrictNe V x yh) else 0) else 0 else 0 termination_by V.card /-- **Multiclass Randomized Full-Information Littlestone Dimension `RLdim V`**: Exact minimax expected mistakes in realizable multiclass full-information online learning. -/ noncomputable def RLdim (V : Finset (X → Y)) : ℝ := if _hV : V.card ≤ 1 then 0 else let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) if hX : ActiveX.Nonempty then ActiveX.sup' hX fun x => fullInfoVal (activeLabels V x) (fun y => if _ : (restrictEq V x y).card < V.card then RLdim (restrictEq V x y) else 0) else 0 termination_by V.card /-- **Multiclass Deterministic Littlestone Dimension `Ldim V`**: Exact worst-case deterministic full-information mistake bound. -/ noncomputable def Ldim (V : Finset (X → Y)) : ℕ := if _hV : V.card ≤ 1 then 0 else let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) if hX : ActiveX.Nonempty then ActiveX.sup' hX fun x => if hL : (activeLabels V x).Nonempty then (activeLabels V x).inf' hL fun yh => (activeLabels V x).sup' hL fun y => if y = yh then (if _ : (restrictEq V x y).card < V.card then Ldim (restrictEq V x y) else 0) else (if _ : (restrictEq V x y).card < V.card then 1 + Ldim (restrictEq V x y) else 0) else 0 else 0 termination_by V.card /-- Clean unfolding equations for all four dimensions! -/ lemma RBLdim_eq_zero_of_card_le_one {V : Finset (X → Y)} (hV : V.card ≤ 1) : RBLdim V = 0 := by rw [RBLdim, dif_pos hV] lemma BLdim_eq_zero_of_card_le_one {V : Finset (X → Y)} (hV : V.card ≤ 1) : BLdim V = 0 := by rw [BLdim, dif_pos hV] lemma RLdim_eq_zero_of_card_le_one {V : Finset (X → Y)} (hV : V.card ≤ 1) : RLdim V = 0 := by rw [RLdim, dif_pos hV] lemma Ldim_eq_zero_of_card_le_one {V : Finset (X → Y)} (hV : V.card ≤ 1) : Ldim V = 0 := by rw [Ldim, dif_pos hV] /-- Whenever `2 ≤ V.card`, there exists a distinguishing query `x : X` with `2 ≤ (activeLabels V x).card`. -/ lemma exists_activeX_of_two_le_card {V : Finset (X → Y)} (hV : 2 ≤ V.card) : ((Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card)).Nonempty := by obtain ⟨h₁, hh₁, h₂, hh₂, hne⟩ := Finset.one_lt_card.mp (by omega : 1 < V.card) have hex : ∃ x : X, h₁ x ≠ h₂ x := by by_contra h; push Not at h; exact hne (funext h) rcases hex with ⟨x, hx⟩ refine ⟨x, Finset.mem_filter.mpr ⟨Finset.mem_univ x, ?_⟩⟩ have hsub : ({h₁ x, h₂ x} : Finset Y) ⊆ activeLabels V x := by intro y hy rcases Finset.mem_insert.mp hy with rfl | hy' · exact Finset.mem_image_of_mem _ hh₁ · rw [Finset.mem_singleton.mp hy']; exact Finset.mem_image_of_mem _ hh₂ calc 2 = ({h₁ x, h₂ x} : Finset Y).card := (Finset.card_pair hx).symm _ ≤ (activeLabels V x).card := Finset.card_le_card hsub /-- Clean one-step formula for `RBLdim` when `2 ≤ V.card`. -/ theorem RBLdim_eq_sup {V : Finset (X → Y)} (hV : 2 ≤ V.card) : let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) RBLdim V = ActiveX.sup' (exists_activeX_of_two_le_card hV) fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh)) := by intro ActiveX rw [RBLdim, dif_neg (by omega), dif_pos (exists_activeX_of_two_le_card hV)] refine Finset.sup'_congr (exists_activeX_of_two_le_card hV) rfl fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) apply le_antisymm · refine banditVal_mono hLne (fun y _ => ?_) (fun yh hyh => ?_) · rw [dif_pos (card_restrictEq_lt hact)] · rw [dif_pos (card_restrictNe_lt hyh)] · refine banditVal_mono hLne (fun y _ => ?_) (fun yh hyh => ?_) · rw [dif_pos (card_restrictEq_lt hact)] · rw [dif_pos (card_restrictNe_lt hyh)] /-- Clean one-step formula for `RLdim` when `2 ≤ V.card`. -/ theorem RLdim_eq_sup {V : Finset (X → Y)} (hV : 2 ≤ V.card) : let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) RLdim V = ActiveX.sup' (exists_activeX_of_two_le_card hV) fun x => fullInfoVal (activeLabels V x) (fun y => RLdim (restrictEq V x y)) := by intro ActiveX rw [RLdim, dif_neg (by omega), dif_pos (exists_activeX_of_two_le_card hV)] refine Finset.sup'_congr (exists_activeX_of_two_le_card hV) rfl fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) apply le_antisymm <;> exact fullInfoVal_mono hLne fun y _ => by rw [dif_pos (card_restrictEq_lt hact)] /-- One-step deterministic bandit minimax operator on `S`: `min_{yh ∈ S} max (a yh) (b yh)`. -/ def detBanditVal {α : Type*} (S : Finset α) (a b : α → ℕ) : ℕ := if hS : S.Nonempty then S.inf' hS (fun yh => max (a yh) (b yh)) else 0 /-- One-step deterministic full-info minimax operator on `S`: `min_{yh ∈ S} max_{y ∈ S} (if y = yh then a y else 1 + a y)`. -/ def detFullVal {α : Type*} [DecidableEq α] (S : Finset α) (a : α → ℕ) : ℕ := if hS : S.Nonempty then S.inf' hS fun yh => S.sup' hS fun y => if y = yh then a y else 1 + a y else 0 lemma detBanditVal_mono {α : Type*} {S : Finset α} {a b a' b' : α → ℕ} (ha : ∀ j ∈ S, a j ≤ a' j) (hb : ∀ j ∈ S, b j ≤ b' j) : detBanditVal S a b ≤ detBanditVal S a' b' := by unfold detBanditVal split_ifs with hS · refine Finset.le_inf' hS _ fun yh hyh => ?_ exact (Finset.inf'_le _ hyh).trans (max_le_max (ha yh hyh) (hb yh hyh)) · exact le_rfl lemma detFullVal_mono {α : Type*} [DecidableEq α] {S : Finset α} {a a' : α → ℕ} (ha : ∀ j ∈ S, a j ≤ a' j) : detFullVal S a ≤ detFullVal S a' := by unfold detFullVal split_ifs with hS · refine Finset.le_inf' hS _ fun yh hyh => ?_ refine (Finset.inf'_le _ hyh).trans (Finset.sup'_le hS _ fun y hy => ?_) have hle : (if y = yh then a y else 1 + a y) ≤ (if y = yh then a' y else 1 + a' y) := by split_ifs <;> linarith [ha y hy] exact hle.trans (Finset.le_sup' (fun z => if z = yh then a' z else 1 + a' z) hy) · exact le_rfl /-- Clean one-step formula for `BLdim` when `2 ≤ V.card`. -/ theorem BLdim_eq_sup {V : Finset (X → Y)} (hV : 2 ≤ V.card) : let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) BLdim V = ActiveX.sup' (exists_activeX_of_two_le_card hV) fun x => detBanditVal (activeLabels V x) (fun y => BLdim (restrictEq V x y)) (fun yh => 1 + BLdim (restrictNe V x yh)) := by intro ActiveX rw [BLdim, dif_neg (by omega), dif_pos (exists_activeX_of_two_le_card hV)] refine Finset.sup'_congr (exists_activeX_of_two_le_card hV) rfl fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) unfold detBanditVal rw [dif_pos hLne, dif_pos hLne] refine Finset.inf'_congr hLne rfl fun yh hyh => ?_ rw [dif_pos (card_restrictEq_lt hact), dif_pos (card_restrictNe_lt hyh)] /-- Clean one-step formula for `Ldim` when `2 ≤ V.card`. -/ theorem Ldim_eq_sup {V : Finset (X → Y)} (hV : 2 ≤ V.card) : let ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) Ldim V = ActiveX.sup' (exists_activeX_of_two_le_card hV) fun x => detFullVal (activeLabels V x) (fun y => Ldim (restrictEq V x y)) := by intro ActiveX rw [Ldim, dif_neg (by omega), dif_pos (exists_activeX_of_two_le_card hV)] refine Finset.sup'_congr (exists_activeX_of_two_le_card hV) rfl fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) unfold detFullVal rw [dif_pos hLne, dif_pos hLne] refine Finset.inf'_congr hLne rfl fun yh _ => ?_ refine Finset.sup'_congr hLne rfl fun y _ => ?_ by_cases heq : y = yh · rw [if_pos heq, if_pos heq, dif_pos (card_restrictEq_lt hact)] · rw [if_neg heq, if_neg heq, dif_pos (card_restrictEq_lt hact)] /-- Nonnegativity of `RBLdim` and `RLdim`. -/ theorem RBLdim_nonneg : ∀ V : Finset (X → Y), 0 ≤ RBLdim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [RBLdim_eq_zero_of_card_le_one hV] · have hV2 : 2 ≤ V.card := by omega rw [RBLdim_eq_sup hV2] rcases exists_activeX_of_two_le_card hV2 with ⟨x₀, hx₀⟩ have hact : 2 ≤ (activeLabels V x₀).card := (Finset.mem_filter.mp hx₀).2 have h0 : 0 ≤ banditVal (activeLabels V x₀) (fun y => RBLdim (restrictEq V x₀ y)) (fun yh => 1 + RBLdim (restrictNe V x₀ yh)) := by refine banditVal_nonneg (fun y _ => ?_) (fun yh hyh => ?_) · exact ih _ (h ▸ card_restrictEq_lt hact) _ rfl · linarith [ih _ (h ▸ card_restrictNe_lt hyh) _ rfl] exact h0.trans (Finset.le_sup' (f := fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))) hx₀) theorem RLdim_nonneg : ∀ V : Finset (X → Y), 0 ≤ RLdim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [RLdim_eq_zero_of_card_le_one hV] · have hV2 : 2 ≤ V.card := by omega rw [RLdim_eq_sup hV2] rcases exists_activeX_of_two_le_card hV2 with ⟨x₀, hx₀⟩ have hact : 2 ≤ (activeLabels V x₀).card := (Finset.mem_filter.mp hx₀).2 have h0 : 0 ≤ fullInfoVal (activeLabels V x₀) (fun y => RLdim (restrictEq V x₀ y)) := fullInfoVal_nonneg fun y _ => ih _ (h ▸ card_restrictEq_lt hact) _ rfl exact h0.trans (Finset.le_sup' (f := fun x => fullInfoVal (activeLabels V x) (fun y => RLdim (restrictEq V x y))) hx₀) /-- Helper: enlarging the label set `S ⊆ S'` never decreases `banditVal` if every extra label `yh ∈ S' \ S` has `b' yh ≥ b yh`? Even better: in `banditVal`, extending `q ∈ Δ(S)` by `0` on `S' \ S` gives `banditVal S a b ≤ banditVal S' a' b'` whenever `a ≤ a'` on `S`, `b ≤ b'` on `S`, AND for every `yh ∈ S' \ S`, `banditVal S a b ≤ b' yh`! -/ lemma banditVal_subset_mono {α : Type*} [DecidableEq α] {S S' : Finset α} (hS : S.Nonempty) (hsub : S ⊆ S') {a b a' b' : α → ℝ} (ha : ∀ j ∈ S, a j ≤ a' j) (hb : ∀ j ∈ S, b j ≤ b' j) (hext : ∀ yh ∈ S', yh ∉ S → banditVal S a b ≤ b' yh) : banditVal S a b ≤ banditVal S' a' b' := by have hS' : S'.Nonempty := hS.mono hsub obtain ⟨q, hq, hL⟩ := banditVal_dual_lower hS a b let q' : α → ℝ := fun y => if y ∈ S then q y else 0 have hq' : IsDist S' q' := by refine ⟨fun y _ => ?_, ?_⟩ · dsimp only [q']; split_ifs with hy · exact hq.1 y hy · exact le_rfl · have hsum : ∑ y ∈ S', q' y = ∑ y ∈ S, q y := by dsimp only [q'] rw [← Finset.sum_subset hsub (fun y _ hy => by simp [hy])] exact Finset.sum_congr rfl fun y hy => by simp [hy] rw [hsum, hq.2] refine le_banditVal_of_dual hS' hq' fun yh hyh' => ?_ have hcol_eq : banditColVal S' a' b' q' yh = ∑ y ∈ S, q y * banditPayoff a' b' y yh := by unfold banditColVal dsimp only [q'] rw [← Finset.sum_subset hsub (fun y _ hy => by simp [hy])] exact Finset.sum_congr rfl fun y hy => by simp [hy] rw [hcol_eq] by_cases hyhS : yh ∈ S · have hle : banditColVal S a b q yh ≤ ∑ y ∈ S, q y * banditPayoff a' b' y yh := by unfold banditColVal banditPayoff refine Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left ?_ (hq.1 y hy) split_ifs with heq · subst heq; exact ha y hy · exact hb yh hyhS exact (hL yh hyhS).trans hle · have hpay : ∑ y ∈ S, q y * banditPayoff a' b' y yh = b' yh := by have hcongr : ∑ y ∈ S, q y * banditPayoff a' b' y yh = ∑ y ∈ S, q y * b' yh := by refine Finset.sum_congr rfl fun y hy => ?_ unfold banditPayoff have hne : y ≠ yh := fun heq => hyhS (heq ▸ hy) rw [if_neg hne] rw [hcongr, ← Finset.sum_mul, hq.2, one_mul] rw [hpay] exact hext yh hyh' hyhS /-- **Universal Subset Monotonicity of `RBLdim`**: `V ⊆ W → RBLdim V ≤ RBLdim W`! -/ theorem RBLdim_mono : ∀ {V W : Finset (X → Y)}, V ⊆ W → RBLdim V ≤ RBLdim W := by intro V W induction h : W.card using Nat.strong_induction_on generalizing V W with | _ n ih => intro hVW by_cases hV : V.card ≤ 1 · rw [RBLdim_eq_zero_of_card_le_one hV]; exact RBLdim_nonneg W · have hV2 : 2 ≤ V.card := by omega have hW2 : 2 ≤ W.card := le_trans hV2 (Finset.card_le_card hVW) rw [RBLdim_eq_sup hV2, RBLdim_eq_sup hW2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hactV : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hsubL : activeLabels V x ⊆ activeLabels W x := activeLabels_mono hVW x have hactW : 2 ≤ (activeLabels W x).card := le_trans hactV (Finset.card_le_card hsubL) have hxW : x ∈ (Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels W z).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ x, hactW⟩ have hLneV : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) have hstep : banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh)) ≤ banditVal (activeLabels W x) (fun y => RBLdim (restrictEq W x y)) (fun yh => 1 + RBLdim (restrictNe W x yh)) := by refine banditVal_subset_mono hLneV hsubL ?_ ?_ ?_ · intro y _ exact ih _ (h ▸ card_restrictEq_lt hactW) rfl (restrictEq_mono hVW x y) · intro yh hyhV have hlt := card_restrictNe_lt (hsubL hyhV) linarith [ih _ (h ▸ hlt) rfl (restrictNe_mono hVW x yh)] · intro yh hyhW hyh_notV -- Key insight: since `yh ∉ activeLabels V x`, EVERY `h ∈ V` satisfies `h x ≠ yh`, so `V ⊆ restrictNe W x yh`! have hV_sub_ne : V ⊆ restrictNe W x yh := by intro f hf refine Finset.mem_filter.mpr ⟨hVW hf, fun hfx => ?_⟩ exact hyh_notV (hfx ▸ Finset.mem_image_of_mem _ hf) have hlt := card_restrictNe_lt hyhW have hRBL_V_le : RBLdim V ≤ RBLdim (restrictNe W x yh) := ih _ (h ▸ hlt) rfl hV_sub_ne have hval_le_V : banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh' => 1 + RBLdim (restrictNe V x yh')) ≤ RBLdim V := by rw [RBLdim_eq_sup hV2] exact Finset.le_sup' (f := fun z => banditVal (activeLabels V z) (fun y => RBLdim (restrictEq V z y)) (fun yh' => 1 + RBLdim (restrictNe V z yh'))) hx linarith exact hstep.trans (Finset.le_sup' (f := fun z => banditVal (activeLabels W z) (fun y => RBLdim (restrictEq W z y)) (fun yh => 1 + RBLdim (restrictNe W z yh))) hxW) /-- **Universal Subset Monotonicity of `RLdim`**: `V ⊆ W → RLdim V ≤ RLdim W`! -/ theorem RLdim_mono : ∀ {V W : Finset (X → Y)}, V ⊆ W → RLdim V ≤ RLdim W := by intro V W induction h : W.card using Nat.strong_induction_on generalizing V W with | _ n ih => intro hVW by_cases hV : V.card ≤ 1 · rw [RLdim_eq_zero_of_card_le_one hV]; exact RLdim_nonneg W · have hV2 : 2 ≤ V.card := by omega have hW2 : 2 ≤ W.card := le_trans hV2 (Finset.card_le_card hVW) rw [RLdim_eq_sup hV2, RLdim_eq_sup hW2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hactV : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hsubL : activeLabels V x ⊆ activeLabels W x := activeLabels_mono hVW x have hactW : 2 ≤ (activeLabels W x).card := le_trans hactV (Finset.card_le_card hsubL) have hxW : x ∈ (Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels W z).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ x, hactW⟩ have hLneV : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) have hLneW : (activeLabels W x).Nonempty := hLneV.mono hsubL have hTneV := powerset_nonempty_of_nonempty hLneV have hTneW := powerset_nonempty_of_nonempty hLneW have hstep : fullInfoVal (activeLabels V x) (fun y => RLdim (restrictEq V x y)) ≤ fullInfoVal (activeLabels W x) (fun y => RLdim (restrictEq W x y)) := by unfold fullInfoVal rw [dif_pos hTneV, dif_pos hTneW] refine Finset.sup'_le hTneV _ fun T hT => ?_ rcases Finset.mem_filter.mp hT with ⟨hTpow, hTne⟩ have hTW : T ∈ (activeLabels W x).powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ((Finset.mem_powerset.mp hTpow).trans hsubL), hTne⟩ have hsub_le : fullInfoSubsetVal (fun y => RLdim (restrictEq V x y)) T ≤ fullInfoSubsetVal (fun y => RLdim (restrictEq W x y)) T := by unfold fullInfoSubsetVal have hc_pos : (0 : ℝ) < (T.card : ℝ) := by exact_mod_cast hTne.card_pos refine div_le_div_of_nonneg_right ?_ hc_pos.le have hsum : ∑ y ∈ T, RLdim (restrictEq V x y) ≤ ∑ y ∈ T, RLdim (restrictEq W x y) := Finset.sum_le_sum fun y _ => ih _ (h ▸ card_restrictEq_lt hactW) rfl (restrictEq_mono hVW x y) linarith exact hsub_le.trans (Finset.le_sup' (fullInfoSubsetVal (fun y => RLdim (restrictEq W x y))) hTW) exact hstep.trans (Finset.le_sup' (f := fun z => fullInfoVal (activeLabels W z) (fun y => RLdim (restrictEq W z y))) hxW) /-- **Universal Subset Monotonicity of `BLdim`**: `V ⊆ W → BLdim V ≤ BLdim W`! -/ theorem BLdim_mono : ∀ {V W : Finset (X → Y)}, V ⊆ W → BLdim V ≤ BLdim W := by intro V W induction h : W.card using Nat.strong_induction_on generalizing V W with | _ n ih => intro hVW by_cases hV : V.card ≤ 1 · rw [BLdim_eq_zero_of_card_le_one hV]; exact Nat.zero_le _ · have hV2 : 2 ≤ V.card := by omega have hW2 : 2 ≤ W.card := le_trans hV2 (Finset.card_le_card hVW) rw [BLdim_eq_sup hV2, BLdim_eq_sup hW2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hactV : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hsubL : activeLabels V x ⊆ activeLabels W x := activeLabels_mono hVW x have hactW : 2 ≤ (activeLabels W x).card := le_trans hactV (Finset.card_le_card hsubL) have hxW : x ∈ (Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels W z).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ x, hactW⟩ have hLneV : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) have hLneW : (activeLabels W x).Nonempty := hLneV.mono hsubL have hstep : detBanditVal (activeLabels V x) (fun y => BLdim (restrictEq V x y)) (fun yh => 1 + BLdim (restrictNe V x yh)) ≤ detBanditVal (activeLabels W x) (fun y => BLdim (restrictEq W x y)) (fun yh => 1 + BLdim (restrictNe W x yh)) := by unfold detBanditVal rw [dif_pos hLneV, dif_pos hLneW] refine Finset.le_inf' hLneW _ fun yh hyhW => ?_ by_cases hyhV : yh ∈ activeLabels V x · refine (Finset.inf'_le _ hyhV).trans ?_ exact max_le_max (ih _ (h ▸ card_restrictEq_lt hactW) rfl (restrictEq_mono hVW x yh)) (Nat.add_le_add_left (ih _ (h ▸ card_restrictNe_lt hyhW) rfl (restrictNe_mono hVW x yh)) 1) · -- `yh ∉ activeLabels V x` → `V ⊆ restrictNe W x yh`! have hV_sub_ne : V ⊆ restrictNe W x yh := by intro f hf exact Finset.mem_filter.mpr ⟨hVW hf, fun hfx => hyhV (hfx ▸ Finset.mem_image_of_mem _ hf)⟩ have hBL_V_le : BLdim V ≤ BLdim (restrictNe W x yh) := ih _ (h ▸ card_restrictNe_lt hyhW) rfl hV_sub_ne have hval_le_V : (activeLabels V x).inf' hLneV (fun yh' => max (BLdim (restrictEq V x yh')) (1 + BLdim (restrictNe V x yh'))) ≤ BLdim V := by rw [BLdim_eq_sup hV2] have := Finset.le_sup' (f := fun z => detBanditVal (activeLabels V z) (fun y => BLdim (restrictEq V z y)) (fun yh' => 1 + BLdim (restrictNe V z yh'))) hx unfold detBanditVal at this; rwa [dif_pos hLneV] at this exact le_trans (le_trans hval_le_V (le_trans hBL_V_le (Nat.le_add_left _ 1))) (le_max_right _ _) exact hstep.trans (Finset.le_sup' (f := fun z => detBanditVal (activeLabels W z) (fun y => BLdim (restrictEq W z y)) (fun yh => 1 + BLdim (restrictNe W z yh))) hxW) /-- **Universal Subset Monotonicity of `Ldim`**: `V ⊆ W → Ldim V ≤ Ldim W`! -/ theorem Ldim_mono : ∀ {V W : Finset (X → Y)}, V ⊆ W → Ldim V ≤ Ldim W := by intro V W induction h : W.card using Nat.strong_induction_on generalizing V W with | _ n ih => intro hVW by_cases hV : V.card ≤ 1 · rw [Ldim_eq_zero_of_card_le_one hV]; exact Nat.zero_le _ · have hV2 : 2 ≤ V.card := by omega have hW2 : 2 ≤ W.card := le_trans hV2 (Finset.card_le_card hVW) rw [Ldim_eq_sup hV2, Ldim_eq_sup hW2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hactV : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hsubL : activeLabels V x ⊆ activeLabels W x := activeLabels_mono hVW x have hactW : 2 ≤ (activeLabels W x).card := le_trans hactV (Finset.card_le_card hsubL) have hxW : x ∈ (Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels W z).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ x, hactW⟩ have hLneV : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) have hLneW : (activeLabels W x).Nonempty := hLneV.mono hsubL have hstep : detFullVal (activeLabels V x) (fun y => Ldim (restrictEq V x y)) ≤ detFullVal (activeLabels W x) (fun y => Ldim (restrictEq W x y)) := by unfold detFullVal rw [dif_pos hLneV, dif_pos hLneW] refine Finset.le_inf' hLneW _ fun yh hyhW => ?_ by_cases hyhV : yh ∈ activeLabels V x · refine (Finset.inf'_le _ hyhV).trans (Finset.sup'_le hLneV _ fun y hyV => ?_) have hle : (if y = yh then Ldim (restrictEq V x y) else 1 + Ldim (restrictEq V x y)) ≤ (if y = yh then Ldim (restrictEq W x y) else 1 + Ldim (restrictEq W x y)) := by have := ih _ (h ▸ card_restrictEq_lt hactW) rfl (restrictEq_mono hVW x y) split_ifs <;> omega exact hle.trans (Finset.le_sup' (f := fun z => if z = yh then Ldim (restrictEq W x z) else 1 + Ldim (restrictEq W x z)) (hsubL hyV)) · -- `yh ∉ activeLabels V x`: pick ANY `yh' ∈ activeLabels V x`; every `y ∈ activeLabels V x` has `y ≠ yh`! have ⟨yh', hyh'V⟩ := hLneV refine (Finset.inf'_le _ hyh'V).trans (Finset.sup'_le hLneV _ fun y hyV => ?_) have hy_ne : y ≠ yh := fun heq => hyhV (heq ▸ hyV) have hle : (if y = yh' then Ldim (restrictEq V x y) else 1 + Ldim (restrictEq V x y)) ≤ 1 + Ldim (restrictEq W x y) := by have := ih _ (h ▸ card_restrictEq_lt hactW) rfl (restrictEq_mono hVW x y) split_ifs <;> omega have hsup := Finset.le_sup' (f := fun z => if z = yh then Ldim (restrictEq W x z) else 1 + Ldim (restrictEq W x z)) (hsubL hyV) rw [if_neg hy_ne] at hsup exact le_trans hle hsup exact hstep.trans (Finset.le_sup' (f := fun z => detFullVal (activeLabels W z) (fun y => Ldim (restrictEq W z y))) hxW) end OnlineLearningDimensions /-! ## Section 4: Universal Hierarchy, Proportional-Sampling Bound & Binary Collapse -/ section UniversalHierarchy variable {X Y : Type*} [Fintype X] [DecidableEq Y] /-- **Universal Half-Littlestone Lower Bound for Multiclass Full-Information Learning**: For EVERY finite multiclass concept class `V`, `(1 / 2) * Ldim V ≤ RLdim V`! -/ theorem Ldim_half_le_RLdim : ∀ V : Finset (X → Y), ((Ldim V : ℝ) / 2) ≤ RLdim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [Ldim_eq_zero_of_card_le_one hV, RLdim_eq_zero_of_card_le_one hV]; norm_num · have hV2 : 2 ≤ V.card := by omega rw [Ldim_eq_sup hV2, RLdim_eq_sup hV2] set ActiveX := (Finset.univ : Finset X).filter (fun x => 2 ≤ (activeLabels V x).card) have hX := exists_activeX_of_two_le_card hV2 obtain ⟨x, hx, hx_eq⟩ := Finset.exists_mem_eq_sup' hX (fun z => detFullVal (activeLabels V z) (fun y => Ldim (restrictEq V z y))) rw [hx_eq] have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) set L := activeLabels V x set a : Y → ℕ := fun y => Ldim (restrictEq V x y) set r : Y → ℝ := fun y => RLdim (restrictEq V x y) have hih : ∀ y ∈ L, (a y : ℝ) / 2 ≤ r y := fun y _ => ih _ (h ▸ card_restrictEq_lt hact) _ rfl -- Pick `y₁ ∈ L` maximizing `a` on `L`, and `y₂ ∈ L.erase y₁` maximizing `a` on `L.erase y₁`! obtain ⟨y₁, hy₁L, hy₁_max⟩ := Finset.exists_max_image L a hLne have her_ne : (L.erase y₁).Nonempty := by rw [← Finset.card_pos, Finset.card_erase_of_mem hy₁L]; omega obtain ⟨y₂, hy₂er, hy₂_max⟩ := Finset.exists_max_image (L.erase y₁) a her_ne rcases Finset.mem_erase.mp hy₂er with ⟨hne21, hy₂L⟩ -- Playing `yh = y₁` in `detFullVal L a` gives `detFullVal L a ≤ max (a y₁) (1 + a y₂)`! have hdet_le : detFullVal L a ≤ max (a y₁) (1 + a y₂) := by unfold detFullVal; rw [dif_pos hLne] refine (Finset.inf'_le _ hy₁L).trans (Finset.sup'_le hLne _ fun y hy => ?_) by_cases heq : y = y₁ · rw [if_pos heq, heq]; exact le_max_left _ _ · rw [if_neg heq] have hmem : y ∈ L.erase y₁ := Finset.mem_erase.mpr ⟨heq, hy⟩ exact le_trans (Nat.add_le_add_left (hy₂_max y hmem) 1) (le_max_right _ _) have hstep : (detFullVal L a : ℝ) / 2 ≤ fullInfoVal L r := by have h12 : a y₂ ≤ a y₁ := hy₁_max y₂ hy₂L by_cases hgap : 1 + a y₂ ≤ a y₁ · -- `max (a y₁) (1 + a y₂) = a y₁` → singleton subset `{y₁}` beats `a y₁ / 2`! have hdet1 : detFullVal L a ≤ a y₁ := by rw [max_eq_left hgap] at hdet_le; exact hdet_le have hdet1r : (detFullVal L a : ℝ) ≤ (a y₁ : ℝ) := by exact_mod_cast hdet1 have hr1 : r y₁ ≤ fullInfoVal L r := by have hTne := powerset_nonempty_of_nonempty hLne have hmem : ({y₁} : Finset Y) ∈ L.powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Finset.singleton_subset_iff.mpr hy₁L), Finset.singleton_nonempty y₁⟩ unfold fullInfoVal; rw [dif_pos hTne] calc r y₁ = fullInfoSubsetVal r {y₁} := by unfold fullInfoSubsetVal; simp _ ≤ _ := Finset.le_sup' (fullInfoSubsetVal r) hmem linarith [hih y₁ hy₁L] · -- `a y₁ = a y₂` and `detFullVal L a ≤ 1 + a y₂` → pair `{y₁, y₂}` beats `(1 + a y₂) / 2`! have heq12 : a y₁ = a y₂ := by omega have hdet2 : detFullVal L a ≤ 1 + a y₂ := by rw [max_eq_right (by omega)] at hdet_le; exact hdet_le have hdet2r : (detFullVal L a : ℝ) ≤ 1 + (a y₂ : ℝ) := by exact_mod_cast hdet2 have hpair := fullInfoVal_ge_pair (S := L) (a := r) hy₁L hy₂L hne21.symm have h1 := hih y₁ hy₁L have h2 := hih y₂ hy₂L rw [heq12] at h1 linarith exact hstep.trans (Finset.le_sup' (f := fun z => fullInfoVal (activeLabels V z) (fun y => RLdim (restrictEq V z y))) hx) /-- **Universal Full-Information ≤ Bandit Dominance**: `RLdim V ≤ RBLdim V` for EVERY `V`! -/ theorem RLdim_le_RBLdim : ∀ V : Finset (X → Y), RLdim V ≤ RBLdim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [RLdim_eq_zero_of_card_le_one hV, RBLdim_eq_zero_of_card_le_one hV] · have hV2 : 2 ≤ V.card := by omega rw [RLdim_eq_sup hV2, RBLdim_eq_sup hV2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) have hstep : fullInfoVal (activeLabels V x) (fun y => RLdim (restrictEq V x y)) ≤ banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh)) := by refine fullInfoVal_le_banditVal hLne ?_ ?_ · intro y _ exact ih _ (h ▸ card_restrictEq_lt hact) _ rfl · intro y _ yh hyh hne have hsub : restrictEq V x y ⊆ restrictNe V x yh := restrictEq_subset_restrictNe hne have hmono := RLdim_mono hsub have hih := ih _ (h ▸ card_restrictNe_lt hyh) _ rfl linarith exact hstep.trans (Finset.le_sup' (f := fun z => banditVal (activeLabels V z) (fun y => RBLdim (restrictEq V z y)) (fun yh => 1 + RBLdim (restrictNe V z yh))) hx) /-- **Universal Randomized ≤ Deterministic Bandit Dominance**: `RBLdim V ≤ BLdim V` for EVERY `V`! -/ theorem RBLdim_le_BLdim : ∀ V : Finset (X → Y), RBLdim V ≤ (BLdim V : ℝ) := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [RBLdim_eq_zero_of_card_le_one hV, BLdim_eq_zero_of_card_le_one hV]; simp · have hV2 : 2 ≤ V.card := by omega rw [RBLdim_eq_sup hV2, BLdim_eq_sup hV2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) obtain ⟨yh, hyh, hyh_eq⟩ := Finset.exists_mem_eq_inf' hLne (fun z => max (BLdim (restrictEq V x z)) (1 + BLdim (restrictNe V x z))) have hstep : banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun z => 1 + RBLdim (restrictNe V x z)) ≤ (detBanditVal (activeLabels V x) (fun y => BLdim (restrictEq V x y)) (fun z => 1 + BLdim (restrictNe V x z)) : ℝ) := by unfold detBanditVal; rw [dif_pos hLne, hyh_eq] have h1 := banditVal_le_det hLne (fun y => RBLdim (restrictEq V x y)) (fun z => 1 + RBLdim (restrictNe V x z)) hyh have hih_eq := ih _ (h ▸ card_restrictEq_lt (y := yh) hact) _ rfl have hih_ne := ih _ (h ▸ card_restrictNe_lt hyh) _ rfl have hmax : max (RBLdim (restrictEq V x yh)) (1 + RBLdim (restrictNe V x yh)) ≤ ((max (BLdim (restrictEq V x yh)) (1 + BLdim (restrictNe V x yh)) : ℕ) : ℝ) := by rw [Nat.cast_max, Nat.cast_add, Nat.cast_one] exact max_le_max hih_eq (by linarith) exact h1.trans hmax have hsup : detBanditVal (activeLabels V x) (fun y => BLdim (restrictEq V x y)) (fun z => 1 + BLdim (restrictNe V x z)) ≤ ((Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels V z).card)).sup' (exists_activeX_of_two_le_card hV2) (fun z => detBanditVal (activeLabels V z) (fun y => BLdim (restrictEq V z y)) (fun w => 1 + BLdim (restrictNe V z w))) := Finset.le_sup' (f := fun z => detBanditVal (activeLabels V z) (fun y => BLdim (restrictEq V z y)) (fun w => 1 + BLdim (restrictNe V z w))) hx exact hstep.trans (by exact_mod_cast hsup) /-- **Universal Deterministic Cardinality Bound**: `BLdim V ≤ V.card - 1` for EVERY `V`. -/ theorem BLdim_le_card_sub_one : ∀ V : Finset (X → Y), BLdim V ≤ V.card - 1 := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [BLdim_eq_zero_of_card_le_one hV]; exact Nat.zero_le _ · have hV2 : 2 ≤ V.card := by omega rw [BLdim_eq_sup hV2] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) rcases hLne with ⟨yh, hyh⟩ unfold detBanditVal; rw [dif_pos ⟨yh, hyh⟩] refine (Finset.inf'_le _ hyh).trans ?_ have hlt_eq := card_restrictEq_lt (y := yh) hact have hlt_ne := card_restrictNe_lt hyh have h1 := ih _ (h ▸ hlt_eq) _ rfl have h2 := ih _ (h ▸ hlt_ne) _ rfl dsimp only exact max_le (by omega) (by omega) /-- **THE PROPORTIONAL-SAMPLING CARDINALITY BOUND (SHARP FOR EVERY `|V| ≥ 1`)**: For EVERY nonempty finite concept class `V`, `RBLdim V ≤ (|V| - 1) / 2`, proved via the explicit proportional-sampling learner `p(y) = |V_{x = y}| / |V|`! -/ theorem RBLdim_le_half_card_sub_one : ∀ {V : Finset (X → Y)}, V.Nonempty → RBLdim V ≤ ((V.card : ℝ) - 1) / 2 := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => intro hVne by_cases hV : V.card ≤ 1 · rw [RBLdim_eq_zero_of_card_le_one hV, ← h] have : (1 : ℝ) ≤ (V.card : ℝ) := by exact_mod_cast hVne.card_pos linarith · have hV2 : 2 ≤ V.card := by omega rw [RBLdim_eq_sup hV2, ← h] refine Finset.sup'_le (exists_activeX_of_two_le_card hV2) _ fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) set L := activeLabels V x set m : ℝ := (V.card : ℝ) have hm_pos : 0 < m := by dsimp only [m]; exact_mod_cast hVne.card_pos -- Proportional sampling strategy `p(yh) = |V_{x = yh}| / |V|`! let p : Y → ℝ := fun yh => ((restrictEq V x yh).card : ℝ) / m have hp_nn : ∀ yh ∈ L, 0 ≤ p yh := fun _ _ => by dsimp only [p]; positivity have hp_sum : ∑ yh ∈ L, p yh = 1 := by dsimp only [p] rw [← Finset.sum_div] have hsum_nat := sum_card_restrictEq V x have hsum_r : ∑ yh ∈ L, ((restrictEq V x yh).card : ℝ) = m := by dsimp only [L, m]; exact_mod_cast hsum_nat rw [hsum_r, div_self hm_pos.ne'] refine banditVal_le_of_primal hLne ⟨hp_nn, hp_sum⟩ fun y hy => ?_ -- Every `yh ∈ L` has `1 ≤ |V_{x = yh}|` and `1 ≤ |V_{x ≠ yh}|`! have hcard_eq_pos : ∀ yh ∈ L, 1 ≤ (restrictEq V x yh).card := by intro yh hyh rcases Finset.mem_image.mp hyh with ⟨f, hfV, hfxy⟩ exact Finset.one_le_card.mpr ⟨f, Finset.mem_filter.mpr ⟨hfV, hfxy⟩⟩ have hcard_ne_pos : ∀ yh ∈ L, 1 ≤ (restrictNe V x yh).card := by intro yh _ have hlt := card_restrictEq_lt (y := yh) hact have hadd := card_restrictEq_add_restrictNe V x yh omega -- Apply IH to `a y` and every `b yh`: have ha_le : RBLdim (restrictEq V x y) ≤ (((restrictEq V x y).card : ℝ) - 1) / 2 := ih _ (h ▸ card_restrictEq_lt (y := y) hact) rfl (Finset.card_pos.mp (hcard_eq_pos y hy)) have hb_le : ∀ yh ∈ L, 1 + RBLdim (restrictNe V x yh) ≤ (m - ((restrictEq V x yh).card : ℝ) + 1) / 2 := by intro yh hyh have h1 := ih _ (h ▸ card_restrictNe_lt hyh) rfl (Finset.card_pos.mp (hcard_ne_pos yh hyh)) have hadd : ((restrictEq V x yh).card : ℝ) + ((restrictNe V x yh).card : ℝ) = m := by dsimp only [m]; exact_mod_cast card_restrictEq_add_restrictNe V x yh linarith -- Expand `banditRowVal` by splitting off `yh = y`! unfold banditRowVal banditPayoff rw [← Finset.add_sum_erase L _ hy, if_pos rfl] dsimp only have hsum_er_le : ∑ yh ∈ L.erase y, p yh * (if y = yh then RBLdim (restrictEq V x y) else 1 + RBLdim (restrictNe V x yh)) ≤ ∑ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ) / m * ((m - ((restrictEq V x yh).card : ℝ) + 1) / 2) := by refine Finset.sum_le_sum fun yh hyh => ?_ rcases Finset.mem_erase.mp hyh with ⟨hne, hyhL⟩ rw [if_neg hne.symm] exact mul_le_mul_of_nonneg_left (hb_le yh hyhL) (hp_nn yh hyhL) have hterm_y : p y * RBLdim (restrictEq V x y) ≤ ((restrictEq V x y).card : ℝ) / m * ((((restrictEq V x y).card : ℝ) - 1) / 2) := mul_le_mul_of_nonneg_left ha_le (hp_nn y hy) -- Key bound on the erased sum: since `n_yh ≥ 1`, `n_yh * (m - n_yh + 1) ≤ n_yh * m`! have hsum_er_simp : ∑ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ) / m * ((m - ((restrictEq V x yh).card : ℝ) + 1) / 2) ≤ (m - ((restrictEq V x y).card : ℝ)) / 2 := by have hterm_le : ∀ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ) / m * ((m - ((restrictEq V x yh).card : ℝ) + 1) / 2) ≤ ((restrictEq V x yh).card : ℝ) / 2 := by intro yh hyh have hge1 : (1 : ℝ) ≤ ((restrictEq V x yh).card : ℝ) := by exact_mod_cast hcard_eq_pos yh (Finset.mem_erase.mp hyh).2 have hnum : ((restrictEq V x yh).card : ℝ) * (m - ((restrictEq V x yh).card : ℝ) + 1) ≤ ((restrictEq V x yh).card : ℝ) * m := by nlinarith have hrew1 : ((restrictEq V x yh).card : ℝ) / m * ((m - ((restrictEq V x yh).card : ℝ) + 1) / 2) = (((restrictEq V x yh).card : ℝ) * (m - ((restrictEq V x yh).card : ℝ) + 1)) / (2 * m) := by ring have hrew2 : ((restrictEq V x yh).card : ℝ) / 2 = (((restrictEq V x yh).card : ℝ) * m) / (2 * m) := by field_simp [hm_pos.ne'] rw [hrew1, hrew2] exact div_le_div_of_nonneg_right hnum (by positivity) calc ∑ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ) / m * ((m - ((restrictEq V x yh).card : ℝ) + 1) / 2) ≤ ∑ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ) / 2 := Finset.sum_le_sum hterm_le _ = (∑ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ)) / 2 := (Finset.sum_div _ _ _).symm _ = (m - ((restrictEq V x y).card : ℝ)) / 2 := by congr 1 have htot : ((restrictEq V x y).card : ℝ) + ∑ yh ∈ L.erase y, ((restrictEq V x yh).card : ℝ) = m := by rw [Finset.add_sum_erase L (fun yh => ((restrictEq V x yh).card : ℝ)) hy] dsimp only [L, m]; exact_mod_cast sum_card_restrictEq V x linarith -- Combine: `(ny / m) * (ny - 1) / 2 + (m - ny) / 2 ≤ (m - 1) / 2`! set ny : ℝ := ((restrictEq V x y).card : ℝ) have hny_ge1 : 1 ≤ ny := by dsimp only [ny]; exact_mod_cast hcard_eq_pos y hy have hny_le_m : ny ≤ m := by dsimp only [ny, m]; exact_mod_cast Finset.card_le_card (restrictEq_subset V x y) have hfinal : ny / m * ((ny - 1) / 2) + (m - ny) / 2 ≤ (m - 1) / 2 := by have hdiff : (m - 1) / 2 - (ny / m * ((ny - 1) / 2) + (m - ny) / 2) = (ny - 1) * (m - ny) / (2 * m) := by field_simp [hm_pos.ne']; ring have hnn : 0 ≤ (ny - 1) * (m - ny) / (2 * m) := by exact div_nonneg (mul_nonneg (by linarith) (by linarith)) (by positivity) linarith linarith /-- **Exact Binary Collapse (`Y = Fin 2`)**: On binary classification, bandit feedback equals full information identically (`RBLdim V = RLdim V` and `BLdim V = Ldim V`)! -/ theorem RBLdim_eq_RLdim_binary : ∀ V : Finset (X → Fin 2), RBLdim V = RLdim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [RBLdim_eq_zero_of_card_le_one hV, RLdim_eq_zero_of_card_le_one hV] · have hV2 : 2 ≤ V.card := by omega rw [RBLdim_eq_sup hV2, RLdim_eq_sup hV2] refine Finset.sup'_congr (exists_activeX_of_two_le_card hV2) rfl fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLeq : activeLabels V x = {(0 : Fin 2), (1 : Fin 2)} := by have hsub : activeLabels V x ⊆ Finset.univ := Finset.subset_univ _ have hcard : (activeLabels V x).card = (Finset.univ : Finset (Fin 2)).card := by have hle := Finset.card_le_card hsub simp only [Finset.card_univ, Fintype.card_fin] at hle ⊢ omega have huniv : activeLabels V x = Finset.univ := Finset.eq_of_subset_of_card_le hsub (by omega) rw [huniv]; decide have hne01 : (0 : Fin 2) ≠ (1 : Fin 2) := by decide have hne0 : restrictNe V x (0 : Fin 2) = restrictEq V x (1 : Fin 2) := by ext f; simp only [restrictNe, restrictEq, Finset.mem_filter] have h2 : f x = 0 ∨ f x = 1 := by generalize f x = v; fin_cases v <;> simp constructor · rintro ⟨hf, h0⟩; exact ⟨hf, h2.resolve_left h0⟩ · rintro ⟨hf, h1⟩; exact ⟨hf, by rw [h1]; decide⟩ have hne1 : restrictNe V x (1 : Fin 2) = restrictEq V x (0 : Fin 2) := by ext f; simp only [restrictNe, restrictEq, Finset.mem_filter] have h2 : f x = 0 ∨ f x = 1 := by generalize f x = v; fin_cases v <;> simp constructor · rintro ⟨hf, h1⟩; exact ⟨hf, h2.resolve_right h1⟩ · rintro ⟨hf, h0⟩; exact ⟨hf, by rw [h0]; decide⟩ rw [hLeq, banditVal_binary_eq hne01, fullInfoVal_binary_eq hne01] · have h0 := ih _ (h ▸ card_restrictEq_lt (y := (0 : Fin 2)) hact) _ rfl have h1 := ih _ (h ▸ card_restrictEq_lt (y := (1 : Fin 2)) hact) _ rfl rw [h0, h1] · rw [hne0] · rw [hne1] private lemma inf'_pair {α : Type*} [DecidableEq α] (a b : α) (f : α → ℕ) (h : ({a, b} : Finset α).Nonempty) : ({a, b} : Finset α).inf' h f = min (f a) (f b) := by apply le_antisymm · exact le_min (Finset.inf'_le f (by simp)) (Finset.inf'_le f (by simp)) · refine Finset.le_inf' h f fun x hx => ?_ rcases Finset.mem_insert.mp hx with rfl | hx' · exact min_le_left _ _ · rw [Finset.mem_singleton.mp hx']; exact min_le_right _ _ private lemma sup'_pair {α : Type*} [DecidableEq α] (a b : α) (f : α → ℕ) (h : ({a, b} : Finset α).Nonempty) : ({a, b} : Finset α).sup' h f = max (f a) (f b) := by apply le_antisymm · refine Finset.sup'_le h f fun x hx => ?_ rcases Finset.mem_insert.mp hx with rfl | hx' · exact le_max_left _ _ · rw [Finset.mem_singleton.mp hx']; exact le_max_right _ _ · exact max_le (Finset.le_sup' f (by simp)) (Finset.le_sup' f (by simp)) private lemma inf'_triple {α : Type*} [DecidableEq α] (a b c : α) (f : α → ℕ) (h : ({a, b, c} : Finset α).Nonempty) : ({a, b, c} : Finset α).inf' h f = min (f a) (min (f b) (f c)) := by apply le_antisymm · exact le_min (Finset.inf'_le f (by simp)) (le_min (Finset.inf'_le f (by simp)) (Finset.inf'_le f (by simp))) · refine Finset.le_inf' h f fun x hx => ?_ rcases Finset.mem_insert.mp hx with rfl | hx' · exact min_le_left _ _ · rcases Finset.mem_insert.mp hx' with rfl | hx'' · exact (min_le_right _ _).trans (min_le_left _ _) · rw [Finset.mem_singleton.mp hx'']; exact (min_le_right _ _).trans (min_le_right _ _) theorem BLdim_eq_Ldim_binary : ∀ V : Finset (X → Fin 2), BLdim V = Ldim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : V.card ≤ 1 · rw [BLdim_eq_zero_of_card_le_one hV, Ldim_eq_zero_of_card_le_one hV] · have hV2 : 2 ≤ V.card := by omega rw [BLdim_eq_sup hV2, Ldim_eq_sup hV2] refine Finset.sup'_congr (exists_activeX_of_two_le_card hV2) rfl fun x hx => ?_ have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLeq : activeLabels V x = {(0 : Fin 2), (1 : Fin 2)} := by have hsub : activeLabels V x ⊆ Finset.univ := Finset.subset_univ _ have huniv : activeLabels V x = Finset.univ := Finset.eq_of_subset_of_card_le hsub (by simp only [Finset.card_univ, Fintype.card_fin]; omega) rw [huniv]; decide have hne01 : (0 : Fin 2) ≠ (1 : Fin 2) := by decide have hne0 : restrictNe V x (0 : Fin 2) = restrictEq V x (1 : Fin 2) := by ext f; simp only [restrictNe, restrictEq, Finset.mem_filter] have h2 : f x = 0 ∨ f x = 1 := by generalize f x = v; fin_cases v <;> simp constructor · rintro ⟨hf, h0⟩; exact ⟨hf, h2.resolve_left h0⟩ · rintro ⟨hf, h1⟩; exact ⟨hf, by rw [h1]; decide⟩ have hne1 : restrictNe V x (1 : Fin 2) = restrictEq V x (0 : Fin 2) := by ext f; simp only [restrictNe, restrictEq, Finset.mem_filter] have h2 : f x = 0 ∨ f x = 1 := by generalize f x = v; fin_cases v <;> simp constructor · rintro ⟨hf, h1⟩; exact ⟨hf, h2.resolve_right h1⟩ · rintro ⟨hf, h0⟩; exact ⟨hf, by rw [h0]; decide⟩ have h0 := ih _ (h ▸ card_restrictEq_lt (y := (0 : Fin 2)) hact) _ rfl have h1 := ih _ (h ▸ card_restrictEq_lt (y := (1 : Fin 2)) hact) _ rfl rw [hLeq] unfold detBanditVal detFullVal have hLne : ({(0 : Fin 2), (1 : Fin 2)} : Finset (Fin 2)).Nonempty := ⟨0, by simp⟩ rw [dif_pos hLne, dif_pos hLne, inf'_pair, inf'_pair, sup'_pair, sup'_pair] simp only [ite_true, if_neg hne01, if_neg hne01.symm, hne0, hne1, h0, h1] congr 1; exact max_comm _ _ end UniversalHierarchy /-! ## Section 5: Exact Closed-Form Benchmarks, Half-Factor Breaking Theorem & Tightness -/ section ExactBenchmarksAndSeparations /-- Universal 2-hypothesis exact evaluation: EVERY concept class `V` with `V.card = 2` has `RBLdim V = 1 / 2` and `BLdim V = 1`! -/ theorem RBLdim_of_card_two {X Y : Type*} [Fintype X] [DecidableEq Y] {V : Finset (X → Y)} (hcard : V.card = 2) : RBLdim V = 1 / 2 := by have hV2 : 2 ≤ V.card := by omega rw [RBLdim_eq_sup hV2] have hX := exists_activeX_of_two_le_card hV2 have hconst : ∀ x ∈ (Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels V z).card), banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh)) = 1 / 2 := by intro x hx have hact : 2 ≤ (activeLabels V x).card := (Finset.mem_filter.mp hx).2 have hLcard : (activeLabels V x).card = 2 := by have hle : (activeLabels V x).card ≤ V.card := Finset.card_image_le omega have hLne : (activeLabels V x).Nonempty := Finset.card_pos.mp (by omega) have ha0 : ∀ y ∈ activeLabels V x, RBLdim (restrictEq V x y) = 0 := fun y _ => by have hlt := card_restrictEq_lt (y := y) hact exact RBLdim_eq_zero_of_card_le_one (by omega) have hb1 : ∀ yh ∈ activeLabels V x, 1 + RBLdim (restrictNe V x yh) = 1 := fun yh hyh => by have hlt := card_restrictNe_lt hyh rw [RBLdim_eq_zero_of_card_le_one (by omega), add_zero] rw [banditVal_symmetric hLne ha0 hb1, hLcard]; norm_num have hle : ((Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels V z).card)).sup' hX (fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))) ≤ 1 / 2 := Finset.sup'_le hX _ fun x hx => (hconst x hx).le rcases hX with ⟨x₀, hx₀⟩ have hge : 1 / 2 ≤ ((Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels V z).card)).sup' ⟨x₀, hx₀⟩ (fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))) := by rw [← hconst x₀ hx₀] exact Finset.le_sup' (f := fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))) hx₀ exact le_antisymm hle hge theorem BLdim_of_card_two {X Y : Type*} [Fintype X] [DecidableEq Y] {V : Finset (X → Y)} (hcard : V.card = 2) : BLdim V = 1 := by have h1 := BLdim_le_card_sub_one V have h2 := RBLdim_le_BLdim V rw [RBLdim_of_card_two hcard] at h2 have hpos : 1 ≤ BLdim V := by by_contra h0; push Not at h0 have hze : BLdim V = 0 := by omega rw [hze] at h2; norm_num at h2 omega /-! ### 5.1: Exact Closed-Form Theory on 1-Point `k`-Label Classes (`Fin 1 → Fin k`) -/ private lemma card_activeLabels_onePoint {k : ℕ} (V : Finset (Fin 1 → Fin k)) : (activeLabels V 0).card = V.card := by unfold activeLabels refine Finset.card_image_of_injective V fun f g hfg => ?_ funext i; fin_cases i; exact hfg private lemma card_restrictEq_onePoint {k : ℕ} {V : Finset (Fin 1 → Fin k)} {y : Fin k} (hy : y ∈ activeLabels V 0) : (restrictEq V 0 y).card = 1 := by rcases Finset.mem_image.mp hy with ⟨f, hfV, hfy⟩ have heq : restrictEq V 0 y = {f} := by ext g; simp only [restrictEq, Finset.mem_filter, Finset.mem_singleton] constructor · rintro ⟨_, hgy⟩; funext i; fin_cases i; exact hgy.trans hfy.symm · rintro rfl; exact ⟨hfV, hfy⟩ rw [heq, Finset.card_singleton] private lemma card_restrictNe_onePoint {k : ℕ} {V : Finset (Fin 1 → Fin k)} {y : Fin k} (hy : y ∈ activeLabels V 0) : (restrictNe V 0 y).card = V.card - 1 := by have hadd := card_restrictEq_add_restrictNe V 0 y have h1 := card_restrictEq_onePoint hy omega /-- **Exact Closed Form of `RBLdim` on ANY 1-Point Class (`Fin 1 → Fin k`)**: `RBLdim V = (|V| - 1) / 2` (achieving exact equality in the proportional-sampling bound!). -/ theorem RBLdim_onePoint_eq {k : ℕ} : ∀ {V : Finset (Fin 1 → Fin k)}, V.Nonempty → RBLdim V = ((V.card : ℝ) - 1) / 2 := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => intro hVne rw [← h] by_cases hV : V.card ≤ 1 · rw [RBLdim_eq_zero_of_card_le_one hV] have h1 : V.card = 1 := le_antisymm hV hVne.card_pos rw [h1]; norm_num · have hV2 : 2 ≤ V.card := by omega rw [RBLdim_eq_sup hV2] have hact0 : 2 ≤ (activeLabels V 0).card := by rw [card_activeLabels_onePoint]; omega have hsup_eq : ((Finset.univ : Finset (Fin 1)).filter (fun x => 2 ≤ (activeLabels V x).card)).sup' (exists_activeX_of_two_le_card hV2) (fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))) = banditVal (activeLabels V 0) (fun y => RBLdim (restrictEq V 0 y)) (fun yh => 1 + RBLdim (restrictNe V 0 yh)) := by have h0_mem : (0 : Fin 1) ∈ (Finset.univ : Finset (Fin 1)).filter (fun x => 2 ≤ (activeLabels V x).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ 0, hact0⟩ apply le_antisymm · refine Finset.sup'_le _ _ fun x _ => ?_ have hx0 : x = 0 := by fin_cases x; rfl rw [hx0] · exact Finset.le_sup' (f := fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))) h0_mem rw [hsup_eq] have hLne : (activeLabels V 0).Nonempty := Finset.card_pos.mp (by omega) have ha0 : ∀ y ∈ activeLabels V 0, RBLdim (restrictEq V 0 y) = 0 := fun y hy => RBLdim_eq_zero_of_card_le_one (by rw [card_restrictEq_onePoint hy]) have hb_const : ∀ yh ∈ activeLabels V 0, 1 + RBLdim (restrictNe V 0 yh) = (V.card : ℝ) / 2 := by intro yh hyh have hcard_ne := card_restrictNe_onePoint hyh have hne_ne : (restrictNe V 0 yh).Nonempty := Finset.card_pos.mp (by omega) have hih := ih _ (h ▸ card_restrictNe_lt hyh) rfl hne_ne rw [hih, hcard_ne, Nat.cast_sub (by omega : 1 ≤ V.card)]; push_cast; ring rw [banditVal_symmetric hLne ha0 hb_const, card_activeLabels_onePoint] have hm_ne : (V.card : ℝ) ≠ 0 := by exact_mod_cast (by omega : V.card ≠ 0) field_simp [hm_ne]; ring /-- **Exact Closed Form of `BLdim` on ANY 1-Point Class (`Fin 1 → Fin k`)**: `BLdim V = |V| - 1` (achieving exact equality in `BLdim_le_card_sub_one`!). -/ theorem BLdim_onePoint_eq {k : ℕ} : ∀ {V : Finset (Fin 1 → Fin k)}, V.Nonempty → BLdim V = V.card - 1 := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => intro hVne rw [← h] by_cases hV : V.card ≤ 1 · rw [BLdim_eq_zero_of_card_le_one hV]; omega · have hV2 : 2 ≤ V.card := by omega apply le_antisymm (BLdim_le_card_sub_one V) rw [BLdim_eq_sup hV2] have hact0 : 2 ≤ (activeLabels V 0).card := by rw [card_activeLabels_onePoint]; omega have h0_mem : (0 : Fin 1) ∈ (Finset.univ : Finset (Fin 1)).filter (fun x => 2 ≤ (activeLabels V x).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ 0, hact0⟩ have hLne : (activeLabels V 0).Nonempty := Finset.card_pos.mp (by omega) have hge : V.card - 1 ≤ detBanditVal (activeLabels V 0) (fun y => BLdim (restrictEq V 0 y)) (fun yh => 1 + BLdim (restrictNe V 0 yh)) := by unfold detBanditVal; rw [dif_pos hLne] refine Finset.le_inf' hLne _ fun yh hyh => ?_ have hcard_ne := card_restrictNe_onePoint hyh have hne_ne : (restrictNe V 0 yh).Nonempty := Finset.card_pos.mp (by omega) have hih := ih _ (h ▸ card_restrictNe_lt hyh) rfl hne_ne have h2 : V.card - 1 ≤ 1 + BLdim (restrictNe V 0 yh) := by rw [hih, hcard_ne]; omega dsimp only exact h2.trans (le_max_right _ _) exact hge.trans (Finset.le_sup' (f := fun x => detBanditVal (activeLabels V x) (fun y => BLdim (restrictEq V x y)) (fun yh => 1 + BLdim (restrictNe V x yh))) h0_mem) /-- **Exact Closed Form of `RLdim` on ANY 1-Point Class (`Fin 1 → Fin k`)**: `RLdim V = (|V| - 1) / |V|`. -/ theorem RLdim_onePoint_eq {k : ℕ} {V : Finset (Fin 1 → Fin k)} (hVne : V.Nonempty) : RLdim V = ((V.card : ℝ) - 1) / (V.card : ℝ) := by by_cases hV : V.card ≤ 1 · rw [RLdim_eq_zero_of_card_le_one hV] have h1 : V.card = 1 := le_antisymm hV hVne.card_pos rw [h1]; norm_num · have hV2 : 2 ≤ V.card := by omega rw [RLdim_eq_sup hV2] have hact0 : 2 ≤ (activeLabels V 0).card := by rw [card_activeLabels_onePoint]; omega have h0_mem : (0 : Fin 1) ∈ (Finset.univ : Finset (Fin 1)).filter (fun x => 2 ≤ (activeLabels V x).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ 0, hact0⟩ have hsup_eq : ((Finset.univ : Finset (Fin 1)).filter (fun x => 2 ≤ (activeLabels V x).card)).sup' (exists_activeX_of_two_le_card hV2) (fun x => fullInfoVal (activeLabels V x) (fun y => RLdim (restrictEq V x y))) = fullInfoVal (activeLabels V 0) (fun y => RLdim (restrictEq V 0 y)) := by apply le_antisymm · refine Finset.sup'_le _ _ fun x _ => by fin_cases x; exact le_rfl · exact Finset.le_sup' (f := fun x => fullInfoVal (activeLabels V x) (fun y => RLdim (restrictEq V x y))) h0_mem rw [hsup_eq] have hLne : (activeLabels V 0).Nonempty := Finset.card_pos.mp (by omega) have ha0 : ∀ y ∈ activeLabels V 0, RLdim (restrictEq V 0 y) = 0 := fun y hy => RLdim_eq_zero_of_card_le_one (by rw [card_restrictEq_onePoint hy]) rw [fullInfoVal_symmetric hLne ha0, card_activeLabels_onePoint, zero_add] /-- **Exact Linear `k / 2` Price of Bandit Feedback on the Full 1-Point `k`-Label Class**: For every `k ≥ 2`, on `onePointClass k = Finset.univ : Finset (Fin 1 → Fin k)`: `RBLdim = (k - 1) / 2`, `BLdim = k - 1`, `RLdim = (k - 1) / k`, and `RBLdim = (k / 2) * RLdim`! -/ theorem onePointClass_price_of_bandit {k : ℕ} (hk : 2 ≤ k) : let H : Finset (Fin 1 → Fin k) := Finset.univ RBLdim H = ((k : ℝ) - 1) / 2 ∧ BLdim H = k - 1 ∧ RLdim H = ((k : ℝ) - 1) / (k : ℝ) ∧ RBLdim H = ((k : ℝ) / 2) * RLdim H := by intro H have hcard : H.card = k := by dsimp only [H]; rw [Finset.card_univ, Fintype.card_fun, Fintype.card_fin, Fintype.card_fin, pow_one] have hne : H.Nonempty := Finset.card_pos.mp (by omega) have hRBL := RBLdim_onePoint_eq hne have hBL := BLdim_onePoint_eq hne have hRL := RLdim_onePoint_eq hne rw [hcard] at hRBL hBL hRL refine ⟨hRBL, hBL, hRL, ?_⟩ rw [hRBL, hRL] have hk_ne : (k : ℝ) ≠ 0 := by exact_mod_cast (by omega : k ≠ 0) field_simp [hk_ne] /-! ### 5.2: THE HALF-FACTOR BREAKING THEOREM (`H5`: `BLdim = 3`, `RBLdim = 16/11 < 3/2`) -/ /-- The 5 explicit hypotheses of our minimal 3-class Half-Factor Breaking class `H5 ⊆ (Fin 2 → Fin 3)`: `h0 = (0, 2)`, `h1 = (1, 0)`, `h2 = (1, 1)`, `h3 = (2, 0)`, `h4 = (2, 1)`. -/ def h5_0 : Fin 2 → Fin 3 := fun x => if x = 0 then 0 else 2 def h5_1 : Fin 2 → Fin 3 := fun x => if x = 0 then 1 else 0 def h5_2 : Fin 2 → Fin 3 := fun x => if x = 0 then 1 else 1 def h5_3 : Fin 2 → Fin 3 := fun x => if x = 0 then 2 else 0 def h5_4 : Fin 2 → Fin 3 := fun x => if x = 0 then 2 else 1 def H5 : Finset (Fin 2 → Fin 3) := {h5_0, h5_1, h5_2, h5_3, h5_4} def G4 : Finset (Fin 2 → Fin 3) := {h5_1, h5_2, h5_3, h5_4} private lemma H5_distinct : h5_0 ≠ h5_1 ∧ h5_0 ≠ h5_2 ∧ h5_0 ≠ h5_3 ∧ h5_0 ≠ h5_4 ∧ h5_1 ≠ h5_2 ∧ h5_1 ≠ h5_3 ∧ h5_1 ≠ h5_4 ∧ h5_2 ≠ h5_3 ∧ h5_2 ≠ h5_4 ∧ h5_3 ≠ h5_4 := by refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intro h <;> first | exact absurd (congrFun h 0) (by decide) | exact absurd (congrFun h 1) (by decide) /-- Helper: any 3-hypothesis class `V` with some query `x` attaining 3 distinct labels has `RBLdim V = 1` and `BLdim V = 2`! -/ private lemma card_three_all_distinct_dims {X Y : Type*} [Fintype X] [DecidableEq Y] {V : Finset (X → Y)} (hcard : V.card = 3) (x₀ : X) (hact3 : (activeLabels V x₀).card = 3) : RBLdim V = 1 ∧ BLdim V = 2 := by have hVne : V.Nonempty := Finset.card_pos.mp (by omega) have hV2 : 2 ≤ V.card := by omega have hact0 : 2 ≤ (activeLabels V x₀).card := by omega have hx₀ : x₀ ∈ (Finset.univ : Finset X).filter (fun z => 2 ≤ (activeLabels V z).card) := Finset.mem_filter.mpr ⟨Finset.mem_univ x₀, hact0⟩ have hLne : (activeLabels V x₀).Nonempty := Finset.card_pos.mp (by omega) -- Since `|activeLabels V x₀| = 3 = |V|`, every `restrictEq V x₀ y` (`y ∈ activeLabels`) has card `1`! have hcard_eq1 : ∀ y ∈ activeLabels V x₀, (restrictEq V x₀ y).card = 1 := by intro y hy have hge : ∀ z ∈ activeLabels V x₀, 1 ≤ (restrictEq V x₀ z).card := fun z hz => by rcases Finset.mem_image.mp hz with ⟨f, hfV, hf⟩ exact Finset.one_le_card.mpr ⟨f, Finset.mem_filter.mpr ⟨hfV, hf⟩⟩ have hsum := sum_card_restrictEq V x₀ have her : ∑ z ∈ (activeLabels V x₀).erase y, 1 ≤ ∑ z ∈ (activeLabels V x₀).erase y, (restrictEq V x₀ z).card := Finset.sum_le_sum fun z hz => hge z (Finset.mem_erase.mp hz).2 rw [Finset.sum_const, smul_eq_mul, mul_one, Finset.card_erase_of_mem hy, hact3] at her rw [← Finset.add_sum_erase _ _ hy] at hsum have hge_y := hge y hy omega have hcard_ne2 : ∀ yh ∈ activeLabels V x₀, (restrictNe V x₀ yh).card = 2 := fun yh hyh => by have hadd := card_restrictEq_add_restrictNe V x₀ yh have h1 := hcard_eq1 yh hyh omega -- `RBLdim V = 1`: upper bound from `RBLdim_le_half_card_sub_one`, lower bound from `x₀`! have hRBL_le : RBLdim V ≤ 1 := by have := RBLdim_le_half_card_sub_one hVne; rw [hcard] at this; norm_num at this; exact this have hRBL_ge : 1 ≤ RBLdim V := by rw [RBLdim_eq_sup hV2] have hval : banditVal (activeLabels V x₀) (fun y => RBLdim (restrictEq V x₀ y)) (fun yh => 1 + RBLdim (restrictNe V x₀ yh)) = 1 := by rw [banditVal_symmetric hLne (fun y hy => RBLdim_eq_zero_of_card_le_one (by rw [hcard_eq1 y hy])) (fun yh hyh => by rw [RBLdim_of_card_two (hcard_ne2 yh hyh)]), hact3] norm_num calc (1 : ℝ) = banditVal (activeLabels V x₀) (fun y => RBLdim (restrictEq V x₀ y)) (fun yh => 1 + RBLdim (restrictNe V x₀ yh)) := hval.symm _ ≤ _ := Finset.le_sup' (f := fun z => banditVal (activeLabels V z) (fun y => RBLdim (restrictEq V z y)) (fun yh => 1 + RBLdim (restrictNe V z yh))) hx₀ -- `BLdim V = 2`: upper bound from `BLdim_le_card_sub_one`, lower bound from `x₀`! have hBL_le : BLdim V ≤ 2 := by have := BLdim_le_card_sub_one V; omega have hBL_ge : 2 ≤ BLdim V := by rw [BLdim_eq_sup hV2] have hval : 2 ≤ detBanditVal (activeLabels V x₀) (fun y => BLdim (restrictEq V x₀ y)) (fun yh => 1 + BLdim (restrictNe V x₀ yh)) := by unfold detBanditVal; rw [dif_pos hLne] refine Finset.le_inf' hLne _ fun yh hyh => ?_ dsimp only rw [BLdim_of_card_two (hcard_ne2 yh hyh)] exact le_max_right _ _ exact hval.trans (Finset.le_sup' (f := fun z => detBanditVal (activeLabels V z) (fun y => BLdim (restrictEq V z y)) (fun yh => 1 + BLdim (restrictNe V z yh))) hx₀) exact ⟨le_antisymm hRBL_le hRBL_ge, le_antisymm hBL_le hBL_ge⟩ /-- Exact dimensions of the `2 × 2` grid `G4 = {h5_1, h5_2, h5_3, h5_4}`: `RBLdim G4 = 1` and `BLdim G4 = 2`! -/ private lemma G4_dims : RBLdim G4 = 1 ∧ BLdim G4 = 2 := by have hd := H5_distinct have hG4_card : G4.card = 4 := by unfold G4 rw [Finset.card_insert_of_notMem (by simp [hd.2.2.2.2.1, hd.2.2.2.2.2.1, hd.2.2.2.2.2.2.1]), Finset.card_insert_of_notMem (by simp [hd.2.2.2.2.2.2.2.1, hd.2.2.2.2.2.2.2.2.1]), Finset.card_pair hd.2.2.2.2.2.2.2.2.2] have hact0 : activeLabels G4 0 = {(1 : Fin 3), (2 : Fin 3)} := by ext y; simp only [activeLabels, G4, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl | rfl, rfl⟩ <;> simp [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) · exact ⟨h5_1, Or.inl rfl, by decide⟩ · exact ⟨h5_3, Or.inr (Or.inr (Or.inl rfl)), by decide⟩ have hact1 : activeLabels G4 1 = {(0 : Fin 3), (1 : Fin 3)} := by ext y; simp only [activeLabels, G4, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl | rfl, rfl⟩ <;> simp [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) · exact ⟨h5_1, Or.inl rfl, by decide⟩ · exact ⟨h5_2, Or.inr (Or.inl rfl), by decide⟩ have hG4_eq0_1 : restrictEq G4 0 1 = {h5_1, h5_2} := by ext f; simp only [restrictEq, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_1, h5_2] have hG4_eq0_2 : restrictEq G4 0 2 = {h5_3, h5_4} := by ext f; simp only [restrictEq, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_3, h5_4] have hG4_eq1_0 : restrictEq G4 1 0 = {h5_1, h5_3} := by ext f; simp only [restrictEq, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_1, h5_3] have hG4_eq1_1 : restrictEq G4 1 1 = {h5_2, h5_4} := by ext f; simp only [restrictEq, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_2, h5_4] have hG4_ne0_1 : restrictNe G4 0 1 = {h5_3, h5_4} := by ext f; simp only [restrictNe, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_3, h5_4] have hG4_ne0_2 : restrictNe G4 0 2 = {h5_1, h5_2} := by ext f; simp only [restrictNe, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_1, h5_2] have hG4_ne1_0 : restrictNe G4 1 0 = {h5_2, h5_4} := by ext f; simp only [restrictNe, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_2, h5_4] have hG4_ne1_1 : restrictNe G4 1 1 = {h5_1, h5_3} := by ext f; simp only [restrictNe, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_1, h5_3] have hc12 : ({h5_1, h5_2} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.1 have hc34 : ({h5_3, h5_4} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.2.2.2.2.2 have hc13 : ({h5_1, h5_3} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.2.1 have hc24 : ({h5_2, h5_4} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.2.2.2.2.1 -- Evaluate both `x = 0` and `x = 1`! have hval_RBL : ∀ x : Fin 2, banditVal (activeLabels G4 x) (fun y => RBLdim (restrictEq G4 x y)) (fun yh => 1 + RBLdim (restrictNe G4 x yh)) = 1 := by intro x have hx01 : x = 0 ∨ x = 1 := by fin_cases x <;> simp rcases hx01 with rfl | rfl · rw [hact0, banditVal_symmetric (S := {(1 : Fin 3), (2 : Fin 3)}) ⟨1, by simp⟩ (a₀ := 1 / 2) (b₀ := 3 / 2)] · rw [Finset.card_pair (by decide : (1 : Fin 3) ≠ 2)]; norm_num · intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl · rw [hG4_eq0_1, RBLdim_of_card_two hc12] · rw [hG4_eq0_2, RBLdim_of_card_two hc34] · intro yh hyh; simp only [Finset.mem_insert, Finset.mem_singleton] at hyh rcases hyh with rfl | rfl · rw [hG4_ne0_1, RBLdim_of_card_two hc34]; norm_num · rw [hG4_ne0_2, RBLdim_of_card_two hc12]; norm_num · rw [hact1, banditVal_symmetric (S := {(0 : Fin 3), (1 : Fin 3)}) ⟨0, by simp⟩ (a₀ := 1 / 2) (b₀ := 3 / 2)] · rw [Finset.card_pair (by decide : (0 : Fin 3) ≠ 1)]; norm_num · intro y hy; simp only [Finset.mem_insert, Finset.mem_singleton] at hy rcases hy with rfl | rfl · rw [hG4_eq1_0, RBLdim_of_card_two hc13] · rw [hG4_eq1_1, RBLdim_of_card_two hc24] · intro yh hyh; simp only [Finset.mem_insert, Finset.mem_singleton] at hyh rcases hyh with rfl | rfl · rw [hG4_ne1_0, RBLdim_of_card_two hc24]; norm_num · rw [hG4_ne1_1, RBLdim_of_card_two hc13]; norm_num have hval_BL : ∀ x : Fin 2, detBanditVal (activeLabels G4 x) (fun y => BLdim (restrictEq G4 x y)) (fun yh => 1 + BLdim (restrictNe G4 x yh)) = 2 := by intro x have hx01 : x = 0 ∨ x = 1 := by fin_cases x <;> simp rcases hx01 with rfl | rfl · rw [hact0]; unfold detBanditVal have hne : ({(1 : Fin 3), (2 : Fin 3)} : Finset (Fin 3)).Nonempty := ⟨1, by simp⟩ rw [dif_pos hne, inf'_pair] simp only [hG4_eq0_1, hG4_eq0_2, hG4_ne0_1, hG4_ne0_2, BLdim_of_card_two hc12, BLdim_of_card_two hc34] norm_num · rw [hact1]; unfold detBanditVal have hne : ({(0 : Fin 3), (1 : Fin 3)} : Finset (Fin 3)).Nonempty := ⟨0, by simp⟩ rw [dif_pos hne, inf'_pair] simp only [hG4_eq1_0, hG4_eq1_1, hG4_ne1_0, hG4_ne1_1, BLdim_of_card_two hc13, BLdim_of_card_two hc24] norm_num have hG4_2 : 2 ≤ G4.card := by omega have hX := exists_activeX_of_two_le_card hG4_2 constructor · rw [RBLdim_eq_sup hG4_2] apply le_antisymm · exact Finset.sup'_le hX _ fun x _ => (hval_RBL x).le · rcases hX with ⟨x₀, hx₀⟩ calc (1 : ℝ) = banditVal (activeLabels G4 x₀) (fun y => RBLdim (restrictEq G4 x₀ y)) (fun yh => 1 + RBLdim (restrictNe G4 x₀ yh)) := (hval_RBL x₀).symm _ ≤ _ := Finset.le_sup' (f := fun z => banditVal (activeLabels G4 z) (fun y => RBLdim (restrictEq G4 z y)) (fun yh => 1 + RBLdim (restrictNe G4 z yh))) hx₀ · rw [BLdim_eq_sup hG4_2] apply le_antisymm · exact Finset.sup'_le hX _ fun x _ => (hval_BL x).le · rcases hX with ⟨x₀, hx₀⟩ calc (2 : ℕ) = detBanditVal (activeLabels G4 x₀) (fun y => BLdim (restrictEq G4 x₀ y)) (fun yh => 1 + BLdim (restrictNe G4 x₀ yh)) := (hval_BL x₀).symm _ ≤ _ := Finset.le_sup' (f := fun z => detBanditVal (activeLabels G4 z) (fun y => BLdim (restrictEq G4 z y)) (fun yh => 1 + BLdim (restrictNe G4 z yh))) hx₀ /-- **THE HALF-FACTOR BREAKING THEOREM (Bandit vs. Full-Information Structural Separation)**: Unlike binary online learning where `(1 / 2) * Ldim V ≤ RLdim V` holds universally (Filmus–Hanneke–Mehalel–Moran, COLT 2023), under 3-class bandit feedback our explicit 5-hypothesis concept class `H5 ⊆ (Fin 2 → Fin 3)` satisfies: `RBLdim H5 = 16 / 11`, `BLdim H5 = 3`, and `RBLdim H5 < (1 / 2) * BLdim H5` (`16 / 11 < 3 / 2`)! -/ theorem half_factor_breaking_H5 : RBLdim H5 = 16 / 11 ∧ BLdim H5 = 3 ∧ RBLdim H5 < (1 / 2) * (BLdim H5 : ℝ) := by have hd := H5_distinct have hH5_card : H5.card = 5 := by unfold H5 rw [Finset.card_insert_of_notMem (by simp [hd.1, hd.2.1, hd.2.2.1, hd.2.2.2.1]), Finset.card_insert_of_notMem (by simp [hd.2.2.2.2.1, hd.2.2.2.2.2.1, hd.2.2.2.2.2.2.1]), Finset.card_insert_of_notMem (by simp [hd.2.2.2.2.2.2.2.1, hd.2.2.2.2.2.2.2.2.1]), Finset.card_pair hd.2.2.2.2.2.2.2.2.2] have hact0 : activeLabels H5 0 = {(0 : Fin 3), (1 : Fin 3), (2 : Fin 3)} := by ext y; simp only [activeLabels, H5, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl | rfl | rfl, rfl⟩ <;> simp [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl) · exact ⟨h5_0, Or.inl rfl, by decide⟩ · exact ⟨h5_1, Or.inr (Or.inl rfl), by decide⟩ · exact ⟨h5_3, Or.inr (Or.inr (Or.inr (Or.inl rfl))), by decide⟩ have hact1 : activeLabels H5 1 = {(0 : Fin 3), (1 : Fin 3), (2 : Fin 3)} := by ext y; simp only [activeLabels, H5, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl | rfl | rfl, rfl⟩ <;> simp [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl) · exact ⟨h5_1, Or.inr (Or.inl rfl), by decide⟩ · exact ⟨h5_2, Or.inr (Or.inr (Or.inl rfl)), by decide⟩ · exact ⟨h5_0, Or.inl rfl, by decide⟩ -- Explicit `restrictEq` and `restrictNe` sets for `H5` at `x = 0` and `x = 1`: have hEq0_0 : restrictEq H5 0 0 = {h5_0} := by ext f; simp only [restrictEq, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro rfl; simp [h5_0] have hEq0_1 : restrictEq H5 0 1 = {h5_1, h5_2} := by ext f; simp only [restrictEq, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_1, h5_2] have hEq0_2 : restrictEq H5 0 2 = {h5_3, h5_4} := by ext f; simp only [restrictEq, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_3, h5_4] have hNe0_0 : restrictNe H5 0 0 = G4 := by ext f; simp only [restrictNe, H5, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl | rfl) <;> simp [h5_1, h5_2, h5_3, h5_4] have hNe0_1 : restrictNe H5 0 1 = {h5_0, h5_3, h5_4} := by ext f; simp only [restrictNe, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl) <;> simp [h5_0, h5_3, h5_4] have hNe0_2 : restrictNe H5 0 2 = {h5_0, h5_1, h5_2} := by ext f; simp only [restrictNe, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl) <;> simp [h5_0, h5_1, h5_2] have hEq1_0 : restrictEq H5 1 0 = {h5_1, h5_3} := by ext f; simp only [restrictEq, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_1, h5_3] have hEq1_1 : restrictEq H5 1 1 = {h5_2, h5_4} := by ext f; simp only [restrictEq, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl) <;> simp [h5_2, h5_4] have hEq1_2 : restrictEq H5 1 2 = {h5_0} := by ext f; simp only [restrictEq, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro rfl; simp [h5_0] have hNe1_0 : restrictNe H5 1 0 = {h5_0, h5_2, h5_4} := by ext f; simp only [restrictNe, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl) <;> simp [h5_0, h5_2, h5_4] have hNe1_1 : restrictNe H5 1 1 = {h5_0, h5_1, h5_3} := by ext f; simp only [restrictNe, H5, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl) <;> simp [h5_0, h5_1, h5_3] have hNe1_2 : restrictNe H5 1 2 = G4 := by ext f; simp only [restrictNe, H5, G4, Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨rfl | rfl | rfl | rfl | rfl, h⟩ <;> simp_all [h5_0, h5_1, h5_2, h5_3, h5_4] · rintro (rfl | rfl | rfl | rfl) <;> simp [h5_1, h5_2, h5_3, h5_4] -- Card-2 and card-3 dimensions: have hc12 : ({h5_1, h5_2} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.1 have hc34 : ({h5_3, h5_4} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.2.2.2.2.2 have hc13 : ({h5_1, h5_3} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.2.1 have hc24 : ({h5_2, h5_4} : Finset _).card = 2 := Finset.card_pair hd.2.2.2.2.2.2.2.2.1 have h3_034 : RBLdim ({h5_0, h5_3, h5_4} : Finset _) = 1 ∧ BLdim ({h5_0, h5_3, h5_4} : Finset _) = 2 := by refine card_three_all_distinct_dims ?_ 1 ?_ · rw [Finset.card_insert_of_notMem (by simp [hd.2.2.1, hd.2.2.2.1]), hc34] · have : activeLabels ({h5_0, h5_3, h5_4} : Finset _) 1 = {(0 : Fin 3), 1, 2} := by ext y; simp only [activeLabels, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl, rfl⟩ <;> simp [h5_0, h5_3, h5_4] · rintro (rfl | rfl | rfl) · exact ⟨h5_3, Or.inr (Or.inl rfl), by decide⟩ · exact ⟨h5_4, Or.inr (Or.inr rfl), by decide⟩ · exact ⟨h5_0, Or.inl rfl, by decide⟩ rw [this]; decide have h3_012 : RBLdim ({h5_0, h5_1, h5_2} : Finset _) = 1 ∧ BLdim ({h5_0, h5_1, h5_2} : Finset _) = 2 := by refine card_three_all_distinct_dims ?_ 1 ?_ · rw [Finset.card_insert_of_notMem (by simp [hd.1, hd.2.1]), hc12] · have : activeLabels ({h5_0, h5_1, h5_2} : Finset _) 1 = {(0 : Fin 3), 1, 2} := by ext y; simp only [activeLabels, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl, rfl⟩ <;> simp [h5_0, h5_1, h5_2] · rintro (rfl | rfl | rfl) · exact ⟨h5_1, Or.inr (Or.inl rfl), by decide⟩ · exact ⟨h5_2, Or.inr (Or.inr rfl), by decide⟩ · exact ⟨h5_0, Or.inl rfl, by decide⟩ rw [this]; decide have h3_024 : RBLdim ({h5_0, h5_2, h5_4} : Finset _) = 1 ∧ BLdim ({h5_0, h5_2, h5_4} : Finset _) = 2 := by refine card_three_all_distinct_dims ?_ 0 ?_ · rw [Finset.card_insert_of_notMem (by simp [hd.2.1, hd.2.2.2.1]), hc24] · have : activeLabels ({h5_0, h5_2, h5_4} : Finset _) 0 = {(0 : Fin 3), 1, 2} := by ext y; simp only [activeLabels, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl, rfl⟩ <;> simp [h5_0, h5_2, h5_4] · rintro (rfl | rfl | rfl) · exact ⟨h5_0, Or.inl rfl, by decide⟩ · exact ⟨h5_2, Or.inr (Or.inl rfl), by decide⟩ · exact ⟨h5_4, Or.inr (Or.inr rfl), by decide⟩ rw [this]; decide have h3_013 : RBLdim ({h5_0, h5_1, h5_3} : Finset _) = 1 ∧ BLdim ({h5_0, h5_1, h5_3} : Finset _) = 2 := by refine card_three_all_distinct_dims ?_ 0 ?_ · rw [Finset.card_insert_of_notMem (by simp [hd.1, hd.2.2.1]), hc13] · have : activeLabels ({h5_0, h5_1, h5_3} : Finset _) 0 = {(0 : Fin 3), 1, 2} := by ext y; simp only [activeLabels, Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | rfl | rfl, rfl⟩ <;> simp [h5_0, h5_1, h5_3] · rintro (rfl | rfl | rfl) · exact ⟨h5_0, Or.inl rfl, by decide⟩ · exact ⟨h5_1, Or.inr (Or.inl rfl), by decide⟩ · exact ⟨h5_3, Or.inr (Or.inr rfl), by decide⟩ rw [this]; decide -- Helper: evaluate `banditVal {(0:Fin 3), 1, 2}` when `b ≡ 2` and `a` is a permutation of `(0, 1/2, 1/2)`! have hval_16_11 : ∀ (a b : Fin 3 → ℝ) (z₀ : Fin 3), a z₀ = 0 → (∀ j : Fin 3, j ≠ z₀ → a j = 1 / 2) → (∀ j : Fin 3, b j = 2) → banditVal ({(0 : Fin 3), 1, 2} : Finset (Fin 3)) a b = 16 / 11 := by intro a b z₀ haz ha_other hb2 set S : Finset (Fin 3) := {0, 1, 2} have hSuniv : S = Finset.univ := by decide have hSne : S.Nonempty := ⟨0, by simp [S]⟩ -- Primal `p*`: `3/11` on `z₀`, `4/11` on the other two! let p : Fin 3 → ℝ := fun j => if j = z₀ then 3 / 11 else 4 / 11 have hp : IsDist S p := by refine ⟨fun j _ => by dsimp only [p]; split_ifs <;> norm_num, ?_⟩ rw [hSuniv]; fin_cases z₀ <;> simp [p, Fin.sum_univ_three] <;> norm_num -- Dual `q*`: `3/11` on `z₀`, `4/11` on the other two! let q : Fin 3 → ℝ := fun j => if j = z₀ then 3 / 11 else 4 / 11 have hq : IsDist S q := hp apply le_antisymm · refine banditVal_le_of_primal hSne hp fun y hy => ?_ rw [banditRowVal_eq a b p hy] have hB : ∑ yh ∈ S, p yh * b yh = 2 := by have : ∑ yh ∈ S, p yh * b yh = ∑ yh ∈ S, p yh * 2 := Finset.sum_congr rfl fun yh _ => by rw [hb2 yh] rw [this, ← Finset.sum_mul, hp.2]; norm_num rw [hB, hb2 y] by_cases hyz : y = z₀ · subst hyz; rw [haz]; dsimp only [p]; rw [if_pos rfl]; norm_num · rw [ha_other y hyz]; dsimp only [p]; rw [if_neg hyz]; norm_num · refine le_banditVal_of_dual hSne hq fun yh hyh => ?_ rw [banditColVal_eq a b q hq.2 hyh, hb2 yh] by_cases hyz : yh = z₀ · subst hyz; rw [haz]; dsimp only [q]; rw [if_pos rfl]; norm_num · rw [ha_other yh hyz]; dsimp only [q]; rw [if_neg hyz]; norm_num -- Now evaluate `RBLdim H5 = 16 / 11` and `BLdim H5 = 3`! have hRBL_step : ∀ x : Fin 2, banditVal (activeLabels H5 x) (fun y => RBLdim (restrictEq H5 x y)) (fun yh => 1 + RBLdim (restrictNe H5 x yh)) = 16 / 11 := by intro x have hx01 : x = 0 ∨ x = 1 := by fin_cases x <;> simp rcases hx01 with rfl | rfl · rw [hact0] refine hval_16_11 _ _ 0 ?_ ?_ ?_ · rw [hEq0_0, RBLdim_eq_zero_of_card_le_one (by simp)] · intro j hj have hj3 : j = 0 ∨ j = 1 ∨ j = 2 := by fin_cases j <;> simp rcases hj3 with rfl | rfl | rfl · exact False.elim (hj rfl) · rw [hEq0_1, RBLdim_of_card_two hc12] · rw [hEq0_2, RBLdim_of_card_two hc34] · intro j have hj3 : j = 0 ∨ j = 1 ∨ j = 2 := by fin_cases j <;> simp rcases hj3 with rfl | rfl | rfl · rw [hNe0_0, G4_dims.1]; norm_num · rw [hNe0_1, h3_034.1]; norm_num · rw [hNe0_2, h3_012.1]; norm_num · rw [hact1] refine hval_16_11 _ _ 2 ?_ ?_ ?_ · rw [hEq1_2, RBLdim_eq_zero_of_card_le_one (by simp)] · intro j hj have hj3 : j = 0 ∨ j = 1 ∨ j = 2 := by fin_cases j <;> simp rcases hj3 with rfl | rfl | rfl · rw [hEq1_0, RBLdim_of_card_two hc13] · rw [hEq1_1, RBLdim_of_card_two hc24] · exact False.elim (hj rfl) · intro j have hj3 : j = 0 ∨ j = 1 ∨ j = 2 := by fin_cases j <;> simp rcases hj3 with rfl | rfl | rfl · rw [hNe1_0, h3_024.1]; norm_num · rw [hNe1_1, h3_013.1]; norm_num · rw [hNe1_2, G4_dims.1]; norm_num have hBL_step : ∀ x : Fin 2, detBanditVal (activeLabels H5 x) (fun y => BLdim (restrictEq H5 x y)) (fun yh => 1 + BLdim (restrictNe H5 x yh)) = 3 := by intro x have hx01 : x = 0 ∨ x = 1 := by fin_cases x <;> simp rcases hx01 with rfl | rfl · rw [hact0]; unfold detBanditVal have hne : ({(0 : Fin 3), 1, 2} : Finset (Fin 3)).Nonempty := ⟨0, by simp⟩ rw [dif_pos hne, inf'_triple] simp only [hEq0_0, hEq0_1, hEq0_2, hNe0_0, hNe0_1, hNe0_2, BLdim_eq_zero_of_card_le_one (show ({h5_0} : Finset _).card ≤ 1 by simp), BLdim_of_card_two hc12, BLdim_of_card_two hc34, G4_dims.2, h3_034.2, h3_012.2] norm_num · rw [hact1]; unfold detBanditVal have hne : ({(0 : Fin 3), 1, 2} : Finset (Fin 3)).Nonempty := ⟨0, by simp⟩ rw [dif_pos hne, inf'_triple] simp only [hEq1_0, hEq1_1, hEq1_2, hNe1_0, hNe1_1, hNe1_2, BLdim_eq_zero_of_card_le_one (show ({h5_0} : Finset _).card ≤ 1 by simp), BLdim_of_card_two hc13, BLdim_of_card_two hc24, G4_dims.2, h3_024.2, h3_013.2] norm_num have hH5_2 : 2 ≤ H5.card := by omega have hX := exists_activeX_of_two_le_card hH5_2 have hRBL_H5 : RBLdim H5 = 16 / 11 := by rw [RBLdim_eq_sup hH5_2] apply le_antisymm · exact Finset.sup'_le hX _ fun x _ => (hRBL_step x).le · rcases hX with ⟨x₀, hx₀⟩ calc (16 / 11 : ℝ) = banditVal (activeLabels H5 x₀) (fun y => RBLdim (restrictEq H5 x₀ y)) (fun yh => 1 + RBLdim (restrictNe H5 x₀ yh)) := (hRBL_step x₀).symm _ ≤ _ := Finset.le_sup' (f := fun z => banditVal (activeLabels H5 z) (fun y => RBLdim (restrictEq H5 z y)) (fun yh => 1 + RBLdim (restrictNe H5 z yh))) hx₀ have hBL_H5 : BLdim H5 = 3 := by rw [BLdim_eq_sup hH5_2] apply le_antisymm · exact Finset.sup'_le hX _ fun x _ => (hBL_step x).le · rcases hX with ⟨x₀, hx₀⟩ calc (3 : ℕ) = detBanditVal (activeLabels H5 x₀) (fun y => BLdim (restrictEq H5 x₀ y)) (fun yh => 1 + BLdim (restrictNe H5 x₀ yh)) := (hBL_step x₀).symm _ ≤ _ := Finset.le_sup' (f := fun z => detBanditVal (activeLabels H5 z) (fun y => BLdim (restrictEq H5 z y)) (fun yh => 1 + BLdim (restrictNe H5 z yh))) hx₀ refine ⟨hRBL_H5, hBL_H5, ?_⟩ rw [hRBL_H5, hBL_H5]; norm_num /-! ### 5.3: Exact Randomized-vs-Deterministic Tightness (`RBLdim / BLdim → 1` on Binary Indicators) -/ /-- All-zero function and point-indicator functions on `Fin m → Fin 2`. -/ def zeroHyp (m : ℕ) : Fin m → Fin 2 := fun _ => 0 def pointHyp {m : ℕ} (i : Fin m) : Fin m → Fin 2 := fun x => if x = i then 1 else 0 /-- Binary indicator concept class supported on `S ⊆ Fin m`: `{zeroHyp} ∪ {pointHyp i : i ∈ S}`. -/ def indClass {m : ℕ} (S : Finset (Fin m)) : Finset (Fin m → Fin 2) := insert (zeroHyp m) (S.image pointHyp) private lemma pointHyp_ne_zero {m : ℕ} (i : Fin m) : pointHyp i ≠ zeroHyp m := fun h => by have := congrFun h i; simp [pointHyp, zeroHyp] at this private lemma pointHyp_injective (m : ℕ) : Function.Injective (@pointHyp m) := fun i j h => by by_contra hne have := congrFun h i simp [pointHyp, hne] at this private lemma card_indClass {m : ℕ} (S : Finset (Fin m)) : (indClass S).card = S.card + 1 := by unfold indClass have hnot : zeroHyp m ∉ S.image pointHyp := by simp only [Finset.mem_image, not_exists, not_and] intro i _ h; exact pointHyp_ne_zero i h rw [Finset.card_insert_of_notMem hnot, Finset.card_image_of_injective S (pointHyp_injective m)] private lemma activeLabels_indClass {m : ℕ} (S : Finset (Fin m)) (x : Fin m) : activeLabels (indClass S) x = if x ∈ S then {(0 : Fin 2), 1} else {0} := by ext y; unfold activeLabels indClass split_ifs with hx · simp only [Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | ⟨i, _, rfl⟩, rfl⟩ · left; rfl · dsimp only [pointHyp]; split_ifs <;> simp · rintro (rfl | rfl) · exact ⟨zeroHyp m, Or.inl rfl, rfl⟩ · exact ⟨pointHyp x, Or.inr ⟨x, hx, rfl⟩, by simp [pointHyp]⟩ · simp only [Finset.mem_image, Finset.mem_insert, Finset.mem_singleton] constructor · rintro ⟨f, rfl | ⟨i, hi, rfl⟩, rfl⟩ · rfl · dsimp only [pointHyp] have hne : x ≠ i := fun h => hx (h ▸ hi) rw [if_neg hne] · rintro rfl; exact ⟨zeroHyp m, Or.inl rfl, rfl⟩ private lemma restrictEq_indClass_zero {m : ℕ} {S : Finset (Fin m)} {x : Fin m} (_hx : x ∈ S) : restrictEq (indClass S) x 0 = indClass (S.erase x) := by ext f; simp only [restrictEq, indClass, Finset.mem_filter, Finset.mem_insert, Finset.mem_image, Finset.mem_erase] constructor · rintro ⟨rfl | ⟨i, hi, rfl⟩, hfx⟩ · left; rfl · right have hix : i ≠ x := fun h => by subst h; simp [pointHyp] at hfx exact ⟨i, ⟨hix, hi⟩, rfl⟩ · rintro (rfl | ⟨i, ⟨hix, hi⟩, rfl⟩) · exact ⟨Or.inl rfl, rfl⟩ · exact ⟨Or.inr ⟨i, hi, rfl⟩, by simp [pointHyp, Ne.symm hix]⟩ private lemma restrictEq_indClass_one {m : ℕ} {S : Finset (Fin m)} {x : Fin m} (hx : x ∈ S) : restrictEq (indClass S) x 1 = {pointHyp x} := by ext f; simp only [restrictEq, indClass, Finset.mem_filter, Finset.mem_insert, Finset.mem_image, Finset.mem_singleton] constructor · rintro ⟨rfl | ⟨i, _, rfl⟩, hfx⟩ · simp [zeroHyp] at hfx · have hix : x = i := by by_contra hne; simp [pointHyp, hne] at hfx subst hix; rfl · rintro rfl; exact ⟨Or.inr ⟨x, hx, rfl⟩, by simp [pointHyp]⟩ /-- **Exact Closed Form on Binary Indicator Classes (`indClass S`)**: - `RBLdim (indClass S) = RLdim (indClass S) = 1 - (1 / 2) ^ S.card`, - `BLdim (indClass S) = Ldim (indClass S) = 1` for every nonempty `S`! -/ theorem RBLdim_indClass_eq {m : ℕ} : ∀ S : Finset (Fin m), RBLdim (indClass S) = 1 - (1 / 2 : ℝ) ^ S.card := by intro S rw [RBLdim_eq_RLdim_binary] induction h : S.card using Nat.strong_induction_on generalizing S with | _ n ih => rw [← h] by_cases hS : S.card = 0 · rw [RLdim_eq_zero_of_card_le_one (by rw [card_indClass]; omega), hS]; norm_num · have hV2 : 2 ≤ (indClass S).card := by rw [card_indClass]; omega rw [RLdim_eq_sup hV2] have hActive : (Finset.univ : Finset (Fin m)).filter (fun x => 2 ≤ (activeLabels (indClass S) x).card) = S := by ext x; simp only [Finset.mem_filter, Finset.mem_univ, true_and, activeLabels_indClass] split_ifs with hx <;> simp [hx] have hconst : ∀ x ∈ (Finset.univ : Finset (Fin m)).filter (fun z => 2 ≤ (activeLabels (indClass S) z).card), fullInfoVal (activeLabels (indClass S) x) (fun y => RLdim (restrictEq (indClass S) x y)) = 1 - (1 / 2 : ℝ) ^ S.card := by intro x hx have hxS : x ∈ S := hActive ▸ hx rw [activeLabels_indClass, if_pos hxS, fullInfoVal_binary_eq (by decide : (0 : Fin 2) ≠ 1)] rw [restrictEq_indClass_zero hxS, restrictEq_indClass_one hxS, RLdim_eq_zero_of_card_le_one (show ({pointHyp x} : Finset _).card ≤ 1 by simp)] have her_card : (S.erase x).card = S.card - 1 := Finset.card_erase_of_mem hxS have hih := ih _ (by omega : (S.erase x).card < n) (S.erase x) rfl rw [hih, her_card] have hpow_pos : (0 : ℝ) < (1 / 2 : ℝ) ^ (S.card - 1) := by positivity have hpow_le1 : (1 / 2 : ℝ) ^ (S.card - 1) ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) have hmax1 : max (1 - (1 / 2 : ℝ) ^ (S.card - 1)) 0 = 1 - (1 / 2 : ℝ) ^ (S.card - 1) := max_eq_left (by linarith) rw [hmax1, max_eq_right (by linarith)] have hsucc : S.card = (S.card - 1) + 1 := by omega conv_rhs => rw [hsucc, pow_succ] ring have hX := exists_activeX_of_two_le_card hV2 apply le_antisymm · exact Finset.sup'_le hX _ fun x hx => (hconst x hx).le · rcases hX with ⟨x₀, hx₀⟩ calc (1 - (1 / 2 : ℝ) ^ S.card) = fullInfoVal (activeLabels (indClass S) x₀) (fun y => RLdim (restrictEq (indClass S) x₀ y)) := (hconst x₀ hx₀).symm _ ≤ _ := Finset.le_sup' (f := fun z => fullInfoVal (activeLabels (indClass S) z) (fun y => RLdim (restrictEq (indClass S) z y))) hx₀ private lemma detFullVal_binary (f : Fin 2 → ℕ) : detFullVal ({(0 : Fin 2), 1} : Finset (Fin 2)) f = min (max (f 0) (1 + f 1)) (max (1 + f 0) (f 1)) := by unfold detFullVal have hne : ({(0 : Fin 2), 1} : Finset (Fin 2)).Nonempty := ⟨0, by simp⟩ rw [dif_pos hne, inf'_pair, sup'_pair, sup'_pair] have hne01 : (0 : Fin 2) ≠ 1 := by decide simp only [ite_true, if_neg hne01, if_neg hne01.symm] theorem BLdim_indClass_eq_one {m : ℕ} {S : Finset (Fin m)} (hS : S.Nonempty) : BLdim (indClass S) = 1 := by rw [BLdim_eq_Ldim_binary] induction h : S.card using Nat.strong_induction_on generalizing S with | _ n ih => have hV2 : 2 ≤ (indClass S).card := by rw [card_indClass]; have := hS.card_pos; omega rw [Ldim_eq_sup hV2] have hActive : (Finset.univ : Finset (Fin m)).filter (fun x => 2 ≤ (activeLabels (indClass S) x).card) = S := by ext x; simp only [Finset.mem_filter, Finset.mem_univ, true_and, activeLabels_indClass] split_ifs with hx <;> simp [hx] have hconst : ∀ x ∈ (Finset.univ : Finset (Fin m)).filter (fun z => 2 ≤ (activeLabels (indClass S) z).card), detFullVal (activeLabels (indClass S) x) (fun y => Ldim (restrictEq (indClass S) x y)) = 1 := by intro x hx have hxS : x ∈ S := hActive ▸ hx rw [activeLabels_indClass, if_pos hxS, detFullVal_binary] rw [restrictEq_indClass_zero hxS, restrictEq_indClass_one hxS, Ldim_eq_zero_of_card_le_one (show ({pointHyp x} : Finset _).card ≤ 1 by simp)] by_cases her : (S.erase x).Nonempty · have hlt : (S.erase x).card < n := by rw [Finset.card_erase_of_mem hxS]; have := hS.card_pos; omega have hih := ih _ hlt her rfl rw [hih]; decide · have hem : S.erase x = ∅ := Finset.not_nonempty_iff_eq_empty.mp her rw [hem, Ldim_eq_zero_of_card_le_one (by rw [card_indClass]; simp)]; decide have hX := exists_activeX_of_two_le_card hV2 apply le_antisymm · exact Finset.sup'_le hX _ fun x hx => (hconst x hx).le · rcases hX with ⟨x₀, hx₀⟩ calc (1 : ℕ) = detFullVal (activeLabels (indClass S) x₀) (fun y => Ldim (restrictEq (indClass S) x₀ y)) := (hconst x₀ hx₀).symm _ ≤ _ := Finset.le_sup' (f := fun z => detFullVal (activeLabels (indClass S) z) (fun y => Ldim (restrictEq (indClass S) z y))) hx₀ /-- **Exact Sharpness of `RBLdim ≤ BLdim`**: For EVERY `ε > 0`, there exists a finite concept class `V` (namely `indClass Finset.univ` on `Fin m → Fin 2`) with `BLdim V = 1` and `(1 - ε) * BLdim V < RBLdim V`! -/ theorem RBLdim_over_BLdim_approaches_one {ε : ℝ} (hε : 0 < ε) : ∃ m : ℕ, 1 ≤ m ∧ BLdim (indClass (Finset.univ : Finset (Fin m))) = 1 ∧ 1 - ε < RBLdim (indClass (Finset.univ : Finset (Fin m))) := by have htend : Filter.Tendsto (fun m : ℕ => (1 / 2 : ℝ) ^ m) Filter.atTop (nhds 0) := tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num) obtain ⟨M, hM⟩ := Filter.eventually_atTop.mp (htend.eventually (gt_mem_nhds hε)) refine ⟨max 1 M, le_max_left _ _, ?_, ?_⟩ · exact BLdim_indClass_eq_one (by have : 0 < max 1 M := by omega exact ⟨⟨0, this⟩, Finset.mem_univ _⟩) · rw [RBLdim_indClass_eq, Finset.card_univ, Fintype.card_fin] linarith [hM (max 1 M) (le_max_right _ _)] end ExactBenchmarksAndSeparations /-! ## Section 6: Online Game Semantics — Minimax-Optimal Randomized Bandit Learner & Adversary -/ section OnlineGameSemantics variable {X Y : Type*} [Fintype X] [DecidableEq Y] /-- A randomized bandit online learner: given version space `V` and query `x`, outputs a probability distribution over `activeLabels V x` whenever `2 ≤ (activeLabels V x).card`. -/ structure BanditLearner (X Y : Type*) [DecidableEq Y] where play : Finset (X → Y) → X → Y → ℝ valid : ∀ (V : Finset (X → Y)) (x : X), 2 ≤ (activeLabels V x).card → IsDist (activeLabels V x) (play V x) /-- A bandit-state adaptive adversary: given any non-singleton version space `V` (`2 ≤ V.card`), selects a distinguishing query `x : X` (`2 ≤ (activeLabels V x).card`) and a label distribution `q ∈ Δ(activeLabels V x)`. -/ structure BanditAdversary (X Y : Type*) [DecidableEq Y] where query : ∀ (V : Finset (X → Y)), 2 ≤ V.card → X query_active : ∀ (V : Finset (X → Y)) (hV : 2 ≤ V.card), 2 ≤ (activeLabels V (query V hV)).card labelDist : ∀ (V : Finset (X → Y)), 2 ≤ V.card → Y → ℝ labelDist_valid : ∀ (V : Finset (X → Y)) (hV : 2 ≤ V.card), IsDist (activeLabels V (query V hV)) (labelDist V hV) /-- Exact expected cumulative mistakes of `learner` against `adv` starting from version space `V` (by well-founded recursion on `V.card`). -/ noncomputable def expectedMistakes (L : BanditLearner X Y) (A : BanditAdversary X Y) (V : Finset (X → Y)) : ℝ := if hV : 2 ≤ V.card then let x := A.query V hV let S := activeLabels V x let p := L.play V x let q := A.labelDist V hV let a : Y → ℝ := fun y => if _ : (restrictEq V x y).card < V.card then expectedMistakes L A (restrictEq V x y) else 0 let b : Y → ℝ := fun yh => if _ : (restrictNe V x yh).card < V.card then 1 + expectedMistakes L A (restrictNe V x yh) else 0 ∑ y ∈ S, q y * banditRowVal S a b p y else 0 termination_by V.card omit [Fintype X] in lemma expectedMistakes_eq_zero_of_card_le_one (L : BanditLearner X Y) (A : BanditAdversary X Y) {V : Finset (X → Y)} (hV : V.card ≤ 1) : expectedMistakes L A V = 0 := by rw [expectedMistakes, dif_neg (by omega)] omit [Fintype X] in lemma expectedMistakes_unfold (L : BanditLearner X Y) (A : BanditAdversary X Y) {V : Finset (X → Y)} (hV : 2 ≤ V.card) : let x := A.query V hV let S := activeLabels V x expectedMistakes L A V = ∑ y ∈ S, A.labelDist V hV y * banditRowVal S (fun y => expectedMistakes L A (restrictEq V x y)) (fun yh => 1 + expectedMistakes L A (restrictNe V x yh)) (L.play V x) y := by intro x S rw [expectedMistakes, dif_pos hV] have hact := A.query_active V hV refine Finset.sum_congr rfl fun y _ => ?_ congr 1 unfold banditRowVal banditPayoff refine Finset.sum_congr rfl fun yh hyh => ?_ congr 1 split_ifs · dsimp only; rw [dif_pos (card_restrictEq_lt hact)] · dsimp only; rw [dif_pos (card_restrictNe_lt hyh)] /-- **Constructive Harmonic-Mean Minimax-Optimal Randomized Bandit Learner**: At every version space `V` and query `x`, plays the exact primal saddle-point distribution from `banditVal_primal_upper`! -/ noncomputable def optBanditLearner : BanditLearner X Y where play V x := if hact : 2 ≤ (activeLabels V x).card then (banditVal_primal_upper (Finset.card_pos.mp (by omega : 0 < (activeLabels V x).card)) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))).choose else fun _ => 0 valid V x hact := by rw [dif_pos hact] exact (banditVal_primal_upper (Finset.card_pos.mp (by omega)) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))).choose_spec.1 private lemma optBanditLearner_row_le (V : Finset (X → Y)) (x : X) (hact : 2 ≤ (activeLabels V x).card) {y : Y} (hy : y ∈ activeLabels V x) : banditRowVal (activeLabels V x) (fun y' => RBLdim (restrictEq V x y')) (fun yh => 1 + RBLdim (restrictNe V x yh)) (optBanditLearner.play V x) y ≤ banditVal (activeLabels V x) (fun y' => RBLdim (restrictEq V x y')) (fun yh => 1 + RBLdim (restrictNe V x yh)) := by change banditRowVal (activeLabels V x) _ _ (if h : 2 ≤ (activeLabels V x).card then (banditVal_primal_upper (Finset.card_pos.mp (by omega : 0 < (activeLabels V x).card)) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))).choose else fun _ => 0) y ≤ _ rw [dif_pos hact] exact (banditVal_primal_upper (Finset.card_pos.mp (by omega)) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh))).choose_spec.2 y hy private noncomputable def optQuery (V : Finset (X → Y)) (hV : 2 ≤ V.card) : X := (Finset.exists_mem_eq_sup' (exists_activeX_of_two_le_card hV) (fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh)))).choose private lemma optQuery_active (V : Finset (X → Y)) (hV : 2 ≤ V.card) : 2 ≤ (activeLabels V (optQuery V hV)).card := (Finset.mem_filter.mp (Finset.exists_mem_eq_sup' (exists_activeX_of_two_le_card hV) (fun x => banditVal (activeLabels V x) (fun y => RBLdim (restrictEq V x y)) (fun yh => 1 + RBLdim (restrictNe V x yh)))).choose_spec.1).2 private lemma optQuery_labels_nonempty (V : Finset (X → Y)) (hV : 2 ≤ V.card) : (activeLabels V (optQuery V hV)).Nonempty := Finset.card_pos.mp (lt_of_lt_of_le (by norm_num : 0 < 2) (optQuery_active V hV)) /-- **Constructive Minimax-Optimal Dual Bandit Adversary**: At every `V` with `2 ≤ V.card`, selects the `RBLdim`-maximizing query `x*` and plays the exact dual saddle-point label distribution from `banditVal_dual_lower`! -/ noncomputable def optBanditAdversary : BanditAdversary X Y where query := optQuery query_active := optQuery_active labelDist V hV := (banditVal_dual_lower (optQuery_labels_nonempty V hV) (fun y => RBLdim (restrictEq V (optQuery V hV) y)) (fun yh => 1 + RBLdim (restrictNe V (optQuery V hV) yh))).choose labelDist_valid V hV := (banditVal_dual_lower (optQuery_labels_nonempty V hV) (fun y => RBLdim (restrictEq V (optQuery V hV) y)) (fun yh => 1 + RBLdim (restrictNe V (optQuery V hV) yh))).choose_spec.1 private lemma optBanditAdversary_col_ge (V : Finset (X → Y)) (hV : 2 ≤ V.card) {yh : Y} (hyh : yh ∈ activeLabels V (optBanditAdversary.query V hV)) : banditVal (activeLabels V (optBanditAdversary.query V hV)) (fun y => RBLdim (restrictEq V (optBanditAdversary.query V hV) y)) (fun yh' => 1 + RBLdim (restrictNe V (optBanditAdversary.query V hV) yh')) ≤ banditColVal (activeLabels V (optBanditAdversary.query V hV)) (fun y => RBLdim (restrictEq V (optBanditAdversary.query V hV) y)) (fun yh' => 1 + RBLdim (restrictNe V (optBanditAdversary.query V hV) yh')) (optBanditAdversary.labelDist V hV) yh := (banditVal_dual_lower (optQuery_labels_nonempty V hV) (fun y => RBLdim (restrictEq V (optQuery V hV) y)) (fun yh' => 1 + RBLdim (restrictNe V (optQuery V hV) yh'))).choose_spec.2 yh hyh /-- **HEADLINE UPPER BOUND (Optimal Randomized Bandit Online Learning)**: `optBanditLearner` achieves expected cumulative mistakes `≤ RBLdim V` against EVERY adaptive bandit-state adversary `A` and EVERY finite concept class `V`! -/ theorem optBanditLearner_expectedMistakes_le (A : BanditAdversary X Y) : ∀ V : Finset (X → Y), expectedMistakes optBanditLearner A V ≤ RBLdim V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : 2 ≤ V.card · rw [expectedMistakes_unfold optBanditLearner A hV] set x := A.query V hV set S := activeLabels V x have hact : 2 ≤ S.card := A.query_active V hV have hSne : S.Nonempty := Finset.card_pos.mp (by omega) have hp := optBanditLearner.valid V x hact have hq := A.labelDist_valid V hV have hrow_mono : ∀ y ∈ S, banditRowVal S (fun y' => expectedMistakes optBanditLearner A (restrictEq V x y')) (fun yh => 1 + expectedMistakes optBanditLearner A (restrictNe V x yh)) (optBanditLearner.play V x) y ≤ banditRowVal S (fun y' => RBLdim (restrictEq V x y')) (fun yh => 1 + RBLdim (restrictNe V x yh)) (optBanditLearner.play V x) y := by intro y _ unfold banditRowVal banditPayoff refine Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left ?_ (hp.1 yh hyh) split_ifs with heq · subst heq; exact ih _ (h ▸ card_restrictEq_lt hact) _ rfl · linarith [ih _ (h ▸ card_restrictNe_lt hyh) _ rfl] have hrow_le_val : ∀ y ∈ S, banditRowVal S (fun y' => RBLdim (restrictEq V x y')) (fun yh => 1 + RBLdim (restrictNe V x yh)) (optBanditLearner.play V x) y ≤ banditVal S (fun y' => RBLdim (restrictEq V x y')) (fun yh => 1 + RBLdim (restrictNe V x yh)) := fun y hy => optBanditLearner_row_le V x hact hy have hval_le_RBL : banditVal S (fun y' => RBLdim (restrictEq V x y')) (fun yh => 1 + RBLdim (restrictNe V x yh)) ≤ RBLdim V := by rw [RBLdim_eq_sup hV] exact Finset.le_sup' (f := fun z => banditVal (activeLabels V z) (fun y' => RBLdim (restrictEq V z y')) (fun yh => 1 + RBLdim (restrictNe V z yh))) (Finset.mem_filter.mpr ⟨Finset.mem_univ x, hact⟩) calc ∑ y ∈ S, A.labelDist V hV y * banditRowVal S (fun y' => expectedMistakes optBanditLearner A (restrictEq V x y')) (fun yh => 1 + expectedMistakes optBanditLearner A (restrictNe V x yh)) (optBanditLearner.play V x) y ≤ ∑ y ∈ S, A.labelDist V hV y * RBLdim V := by refine Finset.sum_le_sum fun y hy => mul_le_mul_of_nonneg_left ((hrow_mono y hy).trans ((hrow_le_val y hy).trans hval_le_RBL)) (hq.1 y hy) _ = RBLdim V := by rw [← Finset.sum_mul, hq.2, one_mul] · rw [expectedMistakes_eq_zero_of_card_le_one _ _ (by omega), RBLdim_eq_zero_of_card_le_one (by omega)] /-- **HEADLINE LOWER BOUND (Adversary Optimality)**: `optBanditAdversary` forces expected cumulative mistakes `≥ RBLdim V` against EVERY randomized bandit online learner `L` and EVERY finite concept class `V`! -/ theorem optBanditAdversary_expectedMistakes_ge (L : BanditLearner X Y) : ∀ V : Finset (X → Y), RBLdim V ≤ expectedMistakes L optBanditAdversary V := by intro V induction h : V.card using Nat.strong_induction_on generalizing V with | _ n ih => by_cases hV : 2 ≤ V.card · rw [expectedMistakes_unfold L optBanditAdversary hV] set x := optBanditAdversary.query V hV set S := activeLabels V x have hact : 2 ≤ S.card := optBanditAdversary.query_active V hV have hSne : S.Nonempty := Finset.card_pos.mp (by omega) have hp := L.valid V x hact have hq := optBanditAdversary.labelDist_valid V hV rw [bandit_bilinear_eq] have hcol_mono : ∀ yh ∈ S, banditColVal S (fun y => RBLdim (restrictEq V x y)) (fun yh' => 1 + RBLdim (restrictNe V x yh')) (optBanditAdversary.labelDist V hV) yh ≤ banditColVal S (fun y => expectedMistakes L optBanditAdversary (restrictEq V x y)) (fun yh' => 1 + expectedMistakes L optBanditAdversary (restrictNe V x yh')) (optBanditAdversary.labelDist V hV) yh := by intro yh hyh unfold banditColVal banditPayoff refine Finset.sum_le_sum fun y _ => mul_le_mul_of_nonneg_left ?_ (hq.1 y (by assumption)) split_ifs with heq · subst heq; exact ih _ (h ▸ card_restrictEq_lt hact) _ rfl · linarith [ih _ (h ▸ card_restrictNe_lt hyh) _ rfl] have hval_le_col : ∀ yh ∈ S, banditVal S (fun y => RBLdim (restrictEq V x y)) (fun yh' => 1 + RBLdim (restrictNe V x yh')) ≤ banditColVal S (fun y => RBLdim (restrictEq V x y)) (fun yh' => 1 + RBLdim (restrictNe V x yh')) (optBanditAdversary.labelDist V hV) yh := fun yh hyh => optBanditAdversary_col_ge V hV hyh have hRBL_eq_val : RBLdim V = banditVal S (fun y => RBLdim (restrictEq V x y)) (fun yh' => 1 + RBLdim (restrictNe V x yh')) := by rw [RBLdim_eq_sup hV] exact (Finset.exists_mem_eq_sup' (exists_activeX_of_two_le_card hV) (fun z => banditVal (activeLabels V z) (fun y => RBLdim (restrictEq V z y)) (fun yh' => 1 + RBLdim (restrictNe V z yh')))).choose_spec.2 calc RBLdim V = ∑ yh ∈ S, L.play V x yh * RBLdim V := by rw [← Finset.sum_mul, hp.2, one_mul] _ ≤ ∑ yh ∈ S, L.play V x yh * banditColVal S (fun y => expectedMistakes L optBanditAdversary (restrictEq V x y)) (fun yh' => 1 + expectedMistakes L optBanditAdversary (restrictNe V x yh')) (optBanditAdversary.labelDist V hV) yh := by refine Finset.sum_le_sum fun yh hyh => mul_le_mul_of_nonneg_left (by rw [hRBL_eq_val]; exact (hval_le_col yh hyh).trans (hcol_mono yh hyh)) (hp.1 yh hyh) · rw [expectedMistakes_eq_zero_of_card_le_one _ _ (by omega), RBLdim_eq_zero_of_card_le_one (by omega)] /-- **EXACT ONLINE BANDIT MINIMAX VALUE THEOREM**: `expectedMistakes optBanditLearner optBanditAdversary V = RBLdim V`! -/ theorem online_bandit_minimax_exact (V : Finset (X → Y)) : expectedMistakes optBanditLearner optBanditAdversary V = RBLdim V := le_antisymm (optBanditLearner_expectedMistakes_le optBanditAdversary V) (optBanditAdversary_expectedMistakes_ge optBanditLearner V) end OnlineGameSemantics end RandomizedBanditLittlestone /-! ## Axiom Hygiene Verification (`[propext, Classical.choice, Quot.sound]` only) -/ #print axioms RandomizedBanditLittlestone.bandit_weak_duality #print axioms RandomizedBanditLittlestone.banditVal_primal_upper #print axioms RandomizedBanditLittlestone.banditVal_dual_lower #print axioms RandomizedBanditLittlestone.banditVal_mono #print axioms RandomizedBanditLittlestone.banditVal_symmetric #print axioms RandomizedBanditLittlestone.banditVal_binary_eq #print axioms RandomizedBanditLittlestone.fullInfoVal_primal_upper #print axioms RandomizedBanditLittlestone.fullInfoVal_dual_lower #print axioms RandomizedBanditLittlestone.fullInfoVal_le_banditVal #print axioms RandomizedBanditLittlestone.RBLdim_mono #print axioms RandomizedBanditLittlestone.RLdim_mono #print axioms RandomizedBanditLittlestone.BLdim_mono #print axioms RandomizedBanditLittlestone.Ldim_mono #print axioms RandomizedBanditLittlestone.Ldim_half_le_RLdim #print axioms RandomizedBanditLittlestone.RLdim_le_RBLdim #print axioms RandomizedBanditLittlestone.RBLdim_le_BLdim #print axioms RandomizedBanditLittlestone.BLdim_le_card_sub_one #print axioms RandomizedBanditLittlestone.RBLdim_le_half_card_sub_one #print axioms RandomizedBanditLittlestone.RBLdim_eq_RLdim_binary #print axioms RandomizedBanditLittlestone.BLdim_eq_Ldim_binary #print axioms RandomizedBanditLittlestone.RBLdim_onePoint_eq #print axioms RandomizedBanditLittlestone.BLdim_onePoint_eq #print axioms RandomizedBanditLittlestone.RLdim_onePoint_eq #print axioms RandomizedBanditLittlestone.onePointClass_price_of_bandit #print axioms RandomizedBanditLittlestone.half_factor_breaking_H5 #print axioms RandomizedBanditLittlestone.RBLdim_indClass_eq #print axioms RandomizedBanditLittlestone.BLdim_indClass_eq_one #print axioms RandomizedBanditLittlestone.RBLdim_over_BLdim_approaches_one #print axioms RandomizedBanditLittlestone.optBanditLearner_expectedMistakes_le #print axioms RandomizedBanditLittlestone.optBanditAdversary_expectedMistakes_ge #print axioms RandomizedBanditLittlestone.online_bandit_minimax_exact