/- # Exact Minimax Theory of Randomized m-List and Fractional-Budget Online Learning Standalone Lean 4 formalization of: 1. Exact Capped Water-Filling Minimax Duality for arbitrary real expected list budgets `μ ≥ 0` (`listVal_le_iff`, `listVal_primal_upper`, `listVal_dual_lower`). 2. Constructive Cyclic-Interval Dependent Rounding (elementary Birkhoff-von Neumann for m-subsets): every marginal vector `p : S → [0, 1]` with `∑ p = m` decomposes into an explicit probability distribution over `m`-element subsets of `S` of support size `≤ |S|` (`exists_mSubset_dist_of_marginals`, `exists_mSubset_dist_of_sum_le`). 3. Deterministic and Randomized m-List Littlestone Dimensions (`Ldim m V`, `RLdim μ V`), full multi-round online m-list game minimax equivalence (`online_list_minimax_exact`), and universal `1 / (m + 1)`-factor hierarchy (`Ldim_div_succ_le_RLdim`, `RLdim_le_Ldim`). 4. Universal Geometric Laws of the List-Size Curve `μ ↦ RLdim μ V`: - Universal convexity (`RLdim_convex`, `RLdim_midpoint_convex`) vs. strict deterministic convexity failure (`Ldim_not_convex`). - Exact k-class Monotone Ratio Law (`RLdim_monotone_ratio_kClass`). 5. Exact Sharp Super-Branching Cardinality / Halving Theorem: - Universal AM-GM halving bound (`RLdim_le_const_mul_log_card`, `RLdim_le_const_mul_log_card_kClass`). - Exact global integer maximizers: `r*(1) = 2` (`RLdim 1 V ≤ (1/2) log₂ |V|` for arbitrary multiclass `Y`), `r*(2) = 5` (Super-Branching Phase Transition: `3 / (5 ln 5)` beating ternary trees by >22.8%), `r*(3) = 10` (`7 / (10 ln 10)` beating 4-ary trees by >68.5%), `(m + 1)`-class halving (`RLdim m V ≤ (1 / (m + 1)) log_{m+1} |V|`), and universal closed-form ceiling `RLdim μ V ≤ ln |V| / (1 + ln μ)` for all `μ ≥ 1`. 6. Exact Structural Composition Calculus: - List-Additive Union (`RLdim_union_list_additive`), - Sharp Same-List `+ 1/2` Union (`RLdim_union_same_list_half`, `RLdim_union_half_sharp`), - Exact Disjoint-Domain Product Additivity (`RLdim_prod_eq_add`, `Ldim_prod_eq_add`). 7. Exact Extremizers & Bifurcation Families: - Full `r`-ary cube `cubeClass r d` proving exact sharpness of `1/(m+1)`, monotone ratio, super-branching halving constants, and deterministic convexity failure. - Dual `(m + 1)`-class Singleton vs. Co-Singleton/Threshold bifurcation (`singletonListClass` converging to `1 / m` vs. `thresholdListClass` converging to `1` while both have `Ldim m = 1`). 8. Randomized m-List Bandit Online Learning (`RBLdim_m`) & Exact Price of List-Bandit Feedback (`onePointListBandit_exact`, `onePointListBandit_sandwich`, `price_of_list_bandit_feedback`). -/ import Mathlib open scoped BigOperators open Finset namespace RandomizedListOnlineLearning /-! ## Part 1: Capped Water-Filling Minimax Operator `listVal` -/ /-- Exact closed-form 1-round minimax value of the fractional/randomized list-prediction game with expected list budget `μ` on label set `S` and continuation values `v`. -/ noncomputable def listVal {β : Type*} [DecidableEq β] (μ : ℝ) (S : Finset β) (v : β → ℝ) : ℝ := if hS : S.Nonempty then max (S.sup' hS v) ((S.powerset.filter Finset.Nonempty).sup' ⟨S, Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr Subset.rfl, hS⟩⟩ (fun A => ((∑ y ∈ A, (v y + 1)) - μ) / (A.card : ℝ))) else 0 lemma listVal_empty {β : Type*} [DecidableEq β] (μ : ℝ) (v : β → ℝ) : listVal μ (∅ : Finset β) v = 0 := by simp [listVal] lemma le_listVal_of_mem {β : Type*} [DecidableEq β] {μ : ℝ} {S : Finset β} {v : β → ℝ} {y : β} (hy : y ∈ S) : v y ≤ listVal μ S v := by have hS : S.Nonempty := ⟨y, hy⟩ rw [listVal, dif_pos hS] exact le_trans (Finset.le_sup' v hy) (le_max_left _ _) lemma subset_avg_le_listVal {β : Type*} [DecidableEq β] {μ : ℝ} {S A : Finset β} {v : β → ℝ} (hAS : A ⊆ S) (hA : A.Nonempty) : ((∑ y ∈ A, (v y + 1)) - μ) / (A.card : ℝ) ≤ listVal μ S v := by have hS : S.Nonempty := hA.mono hAS rw [listVal, dif_pos hS] have hmem : A ∈ S.powerset.filter Finset.Nonempty := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hAS, hA⟩ exact le_trans (Finset.le_sup' (fun B : Finset β => ((∑ y ∈ B, (v y + 1)) - μ) / (B.card : ℝ)) hmem) (le_max_right _ _) /-- Exact characterization of `listVal μ S v ≤ t` for `μ ≥ 0` and nonempty `S`: every continuation value is `≤ t` and the total required marginal inclusion mass `∑ y ∈ S, max 0 (v y + 1 - t)` is at most `μ`. -/ theorem listVal_le_iff {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S : Finset β} (hS : S.Nonempty) {v : β → ℝ} (t : ℝ) : listVal μ S v ≤ t ↔ (∀ y ∈ S, v y ≤ t) ∧ ∑ y ∈ S, max 0 (v y + 1 - t) ≤ μ := by constructor · intro ht refine ⟨fun y hy => le_trans (le_listVal_of_mem hy) ht, ?_⟩ set A := S.filter (fun y => 0 < v y + 1 - t) have hsum_eq : ∑ y ∈ S, max 0 (v y + 1 - t) = ∑ y ∈ A, (v y + 1 - t) := by rw [← Finset.sum_filter_add_sum_filter_not S (fun y => 0 < v y + 1 - t)] have h1 : ∑ y ∈ A, max 0 (v y + 1 - t) = ∑ y ∈ A, (v y + 1 - t) := by refine Finset.sum_congr rfl fun y hy => ?_ exact max_eq_right (le_of_lt (Finset.mem_filter.mp hy).2) have h2 : ∑ y ∈ S.filter (fun y => ¬ 0 < v y + 1 - t), max 0 (v y + 1 - t) = 0 := by refine Finset.sum_eq_zero fun y hy => ?_ exact max_eq_left (not_lt.mp (Finset.mem_filter.mp hy).2) rw [h1, h2, add_zero] rw [hsum_eq] by_cases hA : A.Nonempty · have hsub : A ⊆ S := Finset.filter_subset _ S have havg := le_trans (subset_avg_le_listVal hsub hA) ht have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA.card_pos have hmul : (∑ y ∈ A, (v y + 1)) - μ ≤ t * (A.card : ℝ) := (div_le_iff₀ hcard_pos).mp havg have hsub_sum : ∑ y ∈ A, (v y + 1 - t) = (∑ y ∈ A, (v y + 1)) - t * (A.card : ℝ) := by rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, mul_comm] linarith · rw [Finset.not_nonempty_iff_eq_empty.mp hA, Finset.sum_empty] exact hμ · intro ⟨hv, hsum⟩ rw [listVal, dif_pos hS] refine max_le (Finset.sup'_le hS v hv) ?_ refine Finset.sup'_le _ _ fun A hA => ?_ rcases Finset.mem_filter.mp hA with ⟨hA_pow, hA_ne⟩ have hAS : A ⊆ S := Finset.mem_powerset.mp hA_pow have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA_ne.card_pos rw [div_le_iff₀ hcard_pos] have h1 : ∑ y ∈ A, (v y + 1 - t) ≤ ∑ y ∈ A, max 0 (v y + 1 - t) := Finset.sum_le_sum fun y _ => le_max_right _ _ have h2 : ∑ y ∈ A, max 0 (v y + 1 - t) ≤ ∑ y ∈ S, max 0 (v y + 1 - t) := Finset.sum_le_sum_of_subset_of_nonneg hAS fun y _ _ => le_max_left _ _ have h3 : ∑ y ∈ A, (v y + 1 - t) = (∑ y ∈ A, (v y + 1)) - t * (A.card : ℝ) := by rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, mul_comm] linarith /-- Primal feasibility: any marginal vector `p : β → ℝ` in `[0, 1]` with `∑ y ∈ S, p y ≤ μ` achieving `v y + (1 - p y) ≤ t` certifies `listVal μ S v ≤ t`. -/ theorem listVal_le_of_primal {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S : Finset β} (hS : S.Nonempty) {v p : β → ℝ} {t : ℝ} (hp0 : ∀ y ∈ S, 0 ≤ p y) (hp1 : ∀ y ∈ S, p y ≤ 1) (hsum : ∑ y ∈ S, p y ≤ μ) (hval : ∀ y ∈ S, v y + (1 - p y) ≤ t) : listVal μ S v ≤ t := by rw [listVal_le_iff hμ hS] refine ⟨fun y hy => by linarith [hp1 y hy, hval y hy], ?_⟩ refine le_trans (Finset.sum_le_sum fun y hy => ?_) hsum exact max_le (hp0 y hy) (by linarith [hval y hy]) /-- Exact Primal Optimal Strategy: for `μ ≥ 0` and nonempty `S`, the capped water-filling vector `p*(y) = max 0 (v y + 1 - listVal μ S v)` lies in `[0, 1]`, has total mass `≤ μ`, and achieves `v y + (1 - p* y) ≤ listVal μ S v` for every `y ∈ S`. -/ theorem listVal_primal_upper {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ p : β → ℝ, (∀ y ∈ S, 0 ≤ p y) ∧ (∀ y ∈ S, p y ≤ 1) ∧ (∑ y ∈ S, p y ≤ μ) ∧ (∀ y ∈ S, v y + (1 - p y) ≤ listVal μ S v) := by set t := listVal μ S v have ht : listVal μ S v ≤ t := le_rfl rw [listVal_le_iff hμ hS] at ht refine ⟨fun y => max 0 (v y + 1 - t), fun y _ => le_max_left _ _, ?_, ht.2, ?_⟩ · intro y hy exact max_le (by norm_num) (by linarith [ht.1 y hy]) · intro y _ have hle : v y + 1 - t ≤ max 0 (v y + 1 - t) := le_max_right _ _ linarith /-- Exact Dual Optimal Adversary: for any `μ ≥ 0` and nonempty `S`, there exists a probability distribution `ν` on `S` such that EVERY fractional list strategy `p ∈ [0, 1]^S` with `∑ y ∈ S, p y ≤ μ` suffers expected total cost `∑ y ∈ S, ν y * (v y + 1 - p y) ≥ listVal μ S v`. -/ theorem listVal_dual_lower {β : Type*} [DecidableEq β] {μ : ℝ} {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ ν : β → ℝ, (∀ y ∈ S, 0 ≤ ν y) ∧ (∑ y ∈ S, ν y = 1) ∧ ∀ p : β → ℝ, (∀ y ∈ S, 0 ≤ p y) → (∀ y ∈ S, p y ≤ 1) → (∑ y ∈ S, p y ≤ μ) → listVal μ S v ≤ ∑ y ∈ S, ν y * (v y + (1 - p y)) := by rw [listVal, dif_pos hS] set M1 := S.sup' hS v set F := S.powerset.filter Finset.Nonempty have hF : F.Nonempty := ⟨S, Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr Subset.rfl, hS⟩⟩ set f : Finset β → ℝ := fun A => ((∑ y ∈ A, (v y + 1)) - μ) / (A.card : ℝ) set M2 := F.sup' hF f by_cases hM : M2 ≤ M1 · rw [max_eq_left hM] obtain ⟨y0, hy0, hy0_eq⟩ := Finset.exists_mem_eq_sup' hS v refine ⟨fun y => if y = y0 then 1 else 0, ?_, ?_, ?_⟩ · intro y _ dsimp only split_ifs <;> norm_num · simp [hy0] · intro p _ hp1 _ simp only [ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', hy0, ↓reduceIte] dsimp only [M1] rw [hy0_eq] linarith [hp1 y0 hy0] · rw [max_eq_right (le_of_not_ge hM)] obtain ⟨A, hA_mem, hA_eq⟩ := Finset.exists_mem_eq_sup' hF f rcases Finset.mem_filter.mp hA_mem with ⟨hA_pow, hA_ne⟩ have hAS : A ⊆ S := Finset.mem_powerset.mp hA_pow have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA_ne.card_pos refine ⟨fun y => if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0, ?_, ?_, ?_⟩ · intro y _ dsimp only split_ifs · exact div_nonneg (by norm_num) (le_of_lt hcard_pos) · exact le_rfl · rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr hAS, Finset.sum_const, nsmul_eq_mul] field_simp [ne_of_gt hcard_pos] · intro p hp0 _ hsum have hsum_A : ∑ y ∈ A, p y ≤ μ := le_trans (Finset.sum_le_sum_of_subset_of_nonneg hAS fun y hy _ => hp0 y hy) hsum have hrew : ∑ y ∈ S, (if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0) * (v y + (1 - p y)) = (∑ y ∈ A, (v y + 1 - p y)) / (A.card : ℝ) := by have h1 : ∀ y ∈ S, (if y ∈ A then (1 : ℝ) / (A.card : ℝ) else 0) * (v y + (1 - p y)) = if y ∈ A then (v y + 1 - p y) / (A.card : ℝ) else 0 := by intro y _ split_ifs <;> ring rw [Finset.sum_congr rfl h1, Finset.sum_ite_mem, Finset.inter_eq_right.mpr hAS, ← Finset.sum_div] rw [hrew] dsimp only [M2] rw [hA_eq] dsimp only [f] rw [Finset.sum_sub_distrib] exact div_le_div_of_nonneg_right (by linarith) (le_of_lt hcard_pos) lemma listVal_congr {β : Type*} [DecidableEq β] {μ : ℝ} {S : Finset β} {v₁ v₂ : β → ℝ} (h : ∀ y ∈ S, v₁ y = v₂ y) : listVal μ S v₁ = listVal μ S v₂ := by by_cases hS : S.Nonempty · rw [listVal, dif_pos hS, listVal, dif_pos hS] congr 1 · exact Finset.sup'_congr hS rfl h · refine Finset.sup'_congr _ rfl fun A hA => ?_ have hAS : A ⊆ S := Finset.mem_powerset.mp (Finset.mem_filter.mp hA).1 congr 2 exact Finset.sum_congr rfl fun y hy => by rw [h y (hAS hy)] · simp [listVal, hS] lemma listVal_nonneg {β : Type*} [DecidableEq β] {μ : ℝ} {S : Finset β} {v : β → ℝ} (hv : ∀ y ∈ S, 0 ≤ v y) : 0 ≤ listVal μ S v := by by_cases hS : S.Nonempty · rcases hS with ⟨y, hy⟩ exact le_trans (hv y hy) (le_listVal_of_mem hy) · simp [listVal, hS] lemma listVal_mono_v {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S : Finset β} {v₁ v₂ : β → ℝ} (hv : ∀ y ∈ S, v₁ y ≤ v₂ y) : listVal μ S v₁ ≤ listVal μ S v₂ := by by_cases hS : S.Nonempty · rw [listVal_le_iff hμ hS] have h2 : listVal μ S v₂ ≤ listVal μ S v₂ := le_rfl rw [listVal_le_iff hμ hS] at h2 refine ⟨fun y hy => le_trans (hv y hy) (h2.1 y hy), ?_⟩ exact le_trans (Finset.sum_le_sum fun y hy => max_le_max_left 0 (by linarith [hv y hy])) h2.2 · simp [listVal, hS] lemma listVal_anti_mu {β : Type*} [DecidableEq β] {μ₁ μ₂ : ℝ} (hμ : μ₁ ≤ μ₂) (S : Finset β) (v : β → ℝ) : listVal μ₂ S v ≤ listVal μ₁ S v := by by_cases hS : S.Nonempty · rw [listVal, dif_pos hS, listVal, dif_pos hS] refine max_le (le_max_left _ _) (le_trans ?_ (le_max_right _ _)) refine Finset.sup'_le _ _ fun A hA => ?_ have hA_ne : A.Nonempty := (Finset.mem_filter.mp hA).2 have hcard_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hA_ne.card_pos exact le_trans (div_le_div_of_nonneg_right (by linarith) (le_of_lt hcard_pos)) (Finset.le_sup' (fun B : Finset β => ((∑ y ∈ B, (v y + 1)) - μ₁) / (B.card : ℝ)) hA) · simp [listVal, hS] lemma listVal_mono_S {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S₁ S₂ : Finset β} (hS : S₁ ⊆ S₂) {v : β → ℝ} (hv : ∀ y ∈ S₂, 0 ≤ v y) : listVal μ S₁ v ≤ listVal μ S₂ v := by by_cases h1 : S₁.Nonempty · have h2 : S₂.Nonempty := h1.mono hS rw [listVal_le_iff hμ h1] have hle : listVal μ S₂ v ≤ listVal μ S₂ v := le_rfl rw [listVal_le_iff hμ h2] at hle exact ⟨fun y hy => hle.1 y (hS hy), le_trans (Finset.sum_le_sum_of_subset_of_nonneg hS fun y _ _ => le_max_left _ _) hle.2⟩ · rw [Finset.not_nonempty_iff_eq_empty.mp h1, listVal_empty] exact listVal_nonneg hv lemma listVal_eq_sup_of_card_le_mu {β : Type*} [DecidableEq β] {μ : ℝ} {S : Finset β} (hS : S.Nonempty) (hcard : (S.card : ℝ) ≤ μ) (v : β → ℝ) : listVal μ S v = S.sup' hS v := by have hμ : 0 ≤ μ := le_trans (Nat.cast_nonneg _) hcard apply le_antisymm · rw [listVal_le_iff hμ hS] refine ⟨fun y hy => Finset.le_sup' v hy, ?_⟩ calc ∑ y ∈ S, max 0 (v y + 1 - S.sup' hS v) ≤ ∑ _y ∈ S, (1 : ℝ) := Finset.sum_le_sum fun y hy => max_le (by norm_num) (by linarith [Finset.le_sup' v hy]) _ = (S.card : ℝ) := by simp _ ≤ μ := hcard · exact Finset.sup'_le hS v fun y hy => le_listVal_of_mem hy lemma listVal_const {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S : Finset β} (hS : S.Nonempty) (c : ℝ) : listVal μ S (fun _ => c) = c + max 0 (1 - μ / (S.card : ℝ)) := by have hcard_pos : (0 : ℝ) < (S.card : ℝ) := Nat.cast_pos.mpr hS.card_pos apply le_antisymm · rw [listVal_le_iff hμ hS] refine ⟨fun _ _ => by linarith [le_max_left (0 : ℝ) (1 - μ / (S.card : ℝ))], ?_⟩ have hterm : max 0 (c + 1 - (c + max 0 (1 - μ / (S.card : ℝ)))) ≤ μ / (S.card : ℝ) := by refine max_le (div_nonneg hμ (le_of_lt hcard_pos)) ?_ linarith [le_max_right (0 : ℝ) (1 - μ / (S.card : ℝ))] calc ∑ _y ∈ S, max 0 (c + 1 - (c + max 0 (1 - μ / (S.card : ℝ)))) ≤ ∑ _y ∈ S, (μ / (S.card : ℝ)) := Finset.sum_le_sum fun _ _ => hterm _ = (S.card : ℝ) * (μ / (S.card : ℝ)) := by simp _ = μ := mul_div_cancel₀ μ (ne_of_gt hcard_pos) · rcases hS with ⟨y0, hy0⟩ have h1 : c ≤ listVal μ S (fun _ => c) := le_listVal_of_mem (v := fun _ => c) hy0 have h2 : c + (1 - μ / (S.card : ℝ)) ≤ listVal μ S (fun _ => c) := by have havg := subset_avg_le_listVal (μ := μ) (v := fun _ => c) Subset.rfl ⟨y0, hy0⟩ have hrew : ((∑ _y ∈ S, (c + 1)) - μ) / (S.card : ℝ) = c + (1 - μ / (S.card : ℝ)) := by rw [Finset.sum_const, nsmul_eq_mul] field_simp [ne_of_gt hcard_pos] ring rwa [hrew] at havg by_cases hle : 1 - μ / (S.card : ℝ) ≤ 0 · rw [max_eq_left hle, add_zero]; exact h1 · rw [max_eq_right (le_of_not_ge hle)]; exact h2 lemma listVal_add_const {β : Type*} [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) (c : ℝ) : listVal μ S (fun y => v y + c) = listVal μ S v + c := by apply le_antisymm · rw [listVal_le_iff hμ hS] have h := (listVal_le_iff hμ hS (listVal μ S v)).mp le_rfl refine ⟨fun y hy => by linarith [h.1 y hy], ?_⟩ have hrew : ∀ y ∈ S, max 0 (v y + c + 1 - (listVal μ S v + c)) = max 0 (v y + 1 - listVal μ S v) := fun y _ => by ring_nf rw [Finset.sum_congr rfl hrew] exact h.2 · have h := (listVal_le_iff hμ hS (listVal μ S (fun y => v y + c))).mp le_rfl have hle : listVal μ S v ≤ listVal μ S (fun y => v y + c) - c := by rw [listVal_le_iff hμ hS] refine ⟨fun y hy => by linarith [h.1 y hy], ?_⟩ have hrew : ∀ y ∈ S, max 0 (v y + 1 - (listVal μ S (fun y => v y + c) - c)) = max 0 (v y + c + 1 - listVal μ S (fun y => v y + c)) := fun y _ => by congr 1; ring rw [Finset.sum_congr rfl hrew] exact h.2 linarith /-- Joint convexity of `listVal` in `(μ, v)`: the core 1-step engine behind universal convexity of `μ ↦ RLdim μ V`. -/ lemma listVal_convex {β : Type*} [DecidableEq β] {μ₁ μ₂ α : ℝ} (hμ₁ : 0 ≤ μ₁) (hμ₂ : 0 ≤ μ₂) (hα0 : 0 ≤ α) (hα1 : α ≤ 1) {S : Finset β} (v₁ v₂ : β → ℝ) : listVal (α * μ₁ + (1 - α) * μ₂) S (fun y => α * v₁ y + (1 - α) * v₂ y) ≤ α * listVal μ₁ S v₁ + (1 - α) * listVal μ₂ S v₂ := by by_cases hS : S.Nonempty · obtain ⟨p₁, hp₁0, hp₁1, hp₁s, hp₁v⟩ := listVal_primal_upper hμ₁ hS v₁ obtain ⟨p₂, hp₂0, hp₂1, hp₂s, hp₂v⟩ := listVal_primal_upper hμ₂ hS v₂ have hμ : 0 ≤ α * μ₁ + (1 - α) * μ₂ := by nlinarith refine listVal_le_of_primal hμ hS (p := fun y => α * p₁ y + (1 - α) * p₂ y) (fun y hy => by nlinarith [hp₁0 y hy, hp₂0 y hy]) (fun y hy => by nlinarith [hp₁1 y hy, hp₂1 y hy]) ?_ ?_ · calc ∑ y ∈ S, (α * p₁ y + (1 - α) * p₂ y) = α * (∑ y ∈ S, p₁ y) + (1 - α) * (∑ y ∈ S, p₂ y) := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] _ ≤ α * μ₁ + (1 - α) * μ₂ := by nlinarith · intro y hy have h1 := hp₁v y hy have h2 := hp₂v y hy nlinarith · simp [listVal, hS] /-- Exact 1-step Monotone Ratio Lemma: when `|S| ≤ k` and `0 ≤ μ₁ ≤ μ₂ ≤ k`, scaling mistake probabilities by `c = (k - μ₂) / (k - μ₁)` preserves list-budget feasibility! -/ lemma listVal_ratio_le {β : Type*} [DecidableEq β] {k : ℝ} {μ₁ μ₂ : ℝ} (hμ₁ : 0 ≤ μ₁) (hμ12 : μ₁ ≤ μ₂) (hμ₂k : μ₂ ≤ k) (hμ₁k : μ₁ < k) {S : Finset β} (hSk : (S.card : ℝ) ≤ k) (v : β → ℝ) : listVal μ₂ S (fun y => ((k - μ₂) / (k - μ₁)) * v y) ≤ ((k - μ₂) / (k - μ₁)) * listVal μ₁ S v := by by_cases hS : S.Nonempty · set c := (k - μ₂) / (k - μ₁) have hden_pos : 0 < k - μ₁ := sub_pos.mpr hμ₁k have hc0 : 0 ≤ c := div_nonneg (sub_nonneg.mpr hμ₂k) (le_of_lt hden_pos) have hc1 : c ≤ 1 := (div_le_one hden_pos).mpr (by linarith) obtain ⟨p₁, hp₁0, hp₁1, hp₁s, hp₁v⟩ := listVal_primal_upper hμ₁ hS v set p₂ : β → ℝ := fun y => 1 - c * (1 - p₁ y) have hp₂0 : ∀ y ∈ S, 0 ≤ p₂ y := fun y hy => by dsimp only [p₂] nlinarith [hp₁0 y hy, hp₁1 y hy] have hp₂1 : ∀ y ∈ S, p₂ y ≤ 1 := fun y hy => by dsimp only [p₂] nlinarith [hp₁1 y hy] have hp₂s : ∑ y ∈ S, p₂ y ≤ μ₂ := by have hsum_eq : ∑ y ∈ S, p₂ y = (1 - c) * (S.card : ℝ) + c * (∑ y ∈ S, p₁ y) := by have hrew : ∀ y ∈ S, p₂ y = (1 - c) + c * p₁ y := fun y _ => by dsimp only [p₂]; ring rw [Finset.sum_congr rfl hrew, Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul, ← Finset.mul_sum, mul_comm (S.card : ℝ)] rw [hsum_eq] have hkey : (1 - c) * k + c * μ₁ = μ₂ := by dsimp only [c] field_simp [ne_of_gt hden_pos] ring nlinarith have hμ₂ : 0 ≤ μ₂ := le_trans hμ₁ hμ12 refine listVal_le_of_primal hμ₂ hS hp₂0 hp₂1 hp₂s fun y hy => ?_ have hrew : c * v y + (1 - p₂ y) = c * (v y + (1 - p₁ y)) := by dsimp only [p₂]; ring rw [hrew] exact mul_le_mul_of_nonneg_left (hp₁v y hy) hc0 · simp [listVal, hS] /-- 1-step AM-GM Logarithmic Halving Lemma: if every subset size `r` satisfies `r - μ ≤ C * r * log r` (for `1 ≤ r ≤ |S|`), then `listVal μ S (C * log w) ≤ C * log (∑ w)`. -/ lemma listVal_log_halving_step {β : Type*} [DecidableEq β] {μ C : ℝ} (hμ : 0 ≤ μ) (hC : 0 ≤ C) {S : Finset β} (hS : S.Nonempty) {w : β → ℝ} (hw : ∀ y ∈ S, 0 < w y) (N : ℝ) (hN : ∑ y ∈ S, w y ≤ N) (hbound : ∀ r : ℕ, 1 ≤ r → r ≤ S.card → (r : ℝ) - μ ≤ C * (r : ℝ) * Real.log (r : ℝ)) : listVal μ S (fun y => C * Real.log (w y)) ≤ C * Real.log N := by have hN_pos : 0 < N := by rcases hS with ⟨y0, hy0⟩ have hle : w y0 ≤ ∑ y ∈ S, w y := Finset.single_le_sum (fun y hy => le_of_lt (hw y hy)) hy0 linarith [hw y0 hy0] rw [listVal, dif_pos hS] refine max_le ?_ ?_ · refine Finset.sup'_le hS _ fun y hy => ?_ have hwy : w y ≤ N := le_trans (Finset.single_le_sum (fun z hz => le_of_lt (hw z hz)) hy) hN exact mul_le_mul_of_nonneg_left (Real.log_le_log (hw y hy) hwy) hC · refine Finset.sup'_le _ _ fun A hA => ?_ rcases Finset.mem_filter.mp hA with ⟨hA_pow, hA_ne⟩ have hAS : A ⊆ S := Finset.mem_powerset.mp hA_pow have hr1 : 1 ≤ A.card := hA_ne.card_pos have hrS : A.card ≤ S.card := Finset.card_le_card hAS have hr_pos : (0 : ℝ) < (A.card : ℝ) := Nat.cast_pos.mpr hr1 rw [div_le_iff₀ hr_pos] -- AM-GM via concavity of `Real.log` (`Real.log_le_sub_one_of_pos`): -- For each `y ∈ A`, `log(w y / (N / r)) ≤ w y / (N / r) - 1`. -- Summing over `y ∈ A` gives `∑ log(w y) - r * log(N / r) ≤ (r / N) * (∑ w y) - r ≤ 0`. have hsum_wA : ∑ y ∈ A, w y ≤ N := le_trans (Finset.sum_le_sum_of_subset_of_nonneg hAS fun y hy _ => le_of_lt (hw y hy)) hN have hlog_sum : ∑ y ∈ A, Real.log (w y) ≤ (A.card : ℝ) * Real.log (N / (A.card : ℝ)) := by have hNr_pos : 0 < N / (A.card : ℝ) := div_pos hN_pos hr_pos have hpt : ∀ y ∈ A, Real.log (w y) - Real.log (N / (A.card : ℝ)) ≤ w y / (N / (A.card : ℝ)) - 1 := by intro y hy have hwy_pos : 0 < w y := hw y (hAS hy) rw [← Real.log_div (ne_of_gt hwy_pos) (ne_of_gt hNr_pos)] exact Real.log_le_sub_one_of_pos (div_pos hwy_pos hNr_pos) have htot := Finset.sum_le_sum hpt rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, mul_one, ← Finset.sum_div] at htot have hdiv_le : (∑ y ∈ A, w y) / (N / (A.card : ℝ)) ≤ (A.card : ℝ) := by rw [div_div_eq_mul_div, div_le_iff₀ hN_pos] nlinarith linarith have hlog_div : Real.log (N / (A.card : ℝ)) = Real.log N - Real.log (A.card : ℝ) := Real.log_div (ne_of_gt hN_pos) (ne_of_gt hr_pos) rw [hlog_div] at hlog_sum have hsum_rew : ∑ y ∈ A, (C * Real.log (w y) + 1) = C * (∑ y ∈ A, Real.log (w y)) + (A.card : ℝ) := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, nsmul_eq_mul, mul_one] rw [hsum_rew] have hCmul : C * (∑ y ∈ A, Real.log (w y)) ≤ C * ((A.card : ℝ) * (Real.log N - Real.log (A.card : ℝ))) := mul_le_mul_of_nonneg_left hlog_sum hC have hstep := hbound A.card hr1 hrS have _ := hμ linarith /-! ## Part 2: Constructive Cyclic-Interval Dependent Rounding (`m`-Subset Decomposition) Given any marginal vector `p : Fin k → ℝ` with `0 ≤ p i ≤ 1` and `∑ i, p i = m` (`m : ℕ`), we explicitly construct a finite probability distribution over `m`-element subsets of `Fin k` (and lift it to arbitrary `Finset β`) whose exact inclusion probability on every element `i` equals `p i`, with support size `≤ k`. -/ section CyclicIntervalRounding /-- Prefix sums of a marginal vector `p : Fin k → ℝ`. -/ def prefSum {k : ℕ} (p : Fin k → ℝ) : ℕ → ℝ | 0 => 0 | i + 1 => prefSum p i + if h : i < k then p ⟨i, h⟩ else 0 lemma prefSum_zero {k : ℕ} (p : Fin k → ℝ) : prefSum p 0 = 0 := rfl lemma prefSum_succ_lt {k : ℕ} (p : Fin k → ℝ) {i : ℕ} (hi : i < k) : prefSum p (i + 1) = prefSum p i + p ⟨i, hi⟩ := by simp [prefSum, hi] lemma prefSum_eq_sum {k : ℕ} (p : Fin k → ℝ) : ∀ n : ℕ, n ≤ k → prefSum p n = ∑ i : Fin k, if i.val < n then p i else 0 := by intro n induction n with | zero => intro _ simp [prefSum] | succ n ih => intro hnk have hn : n < k := Nat.lt_of_succ_le hnk rw [prefSum_succ_lt p hn, ih (le_of_lt hn)] have hsplit : ∀ i : Fin k, (if i.val < n + 1 then p i else 0) = (if i.val < n then p i else 0) + (if i = ⟨n, hn⟩ then p i else 0) := by intro i by_cases h1 : i.val < n · have h2 : i.val < n + 1 := Nat.lt_succ_of_lt h1 have h3 : i ≠ ⟨n, hn⟩ := fun heq => by subst heq; exact Nat.lt_irrefl n h1 simp [h1, h2, h3] · by_cases h2 : i = ⟨n, hn⟩ · subst h2; simp · have h3 : ¬ i.val < n + 1 := by intro hlt have heq : i.val = n := by omega exact h2 (Fin.ext heq) simp [h1, h2, h3] simp_rw [hsplit] rw [Finset.sum_add_distrib] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] lemma prefSum_k {k : ℕ} (p : Fin k → ℝ) : prefSum p k = ∑ i : Fin k, p i := by rw [prefSum_eq_sum p k le_rfl] refine Finset.sum_congr rfl fun i _ => ?_ simp [i.isLt] lemma prefSum_mono {k : ℕ} {p : Fin k → ℝ} (hp0 : ∀ i, 0 ≤ p i) : Monotone (prefSum p) := by refine monotone_nat_of_le_succ fun n => ?_ dsimp only [prefSum] split_ifs with h · linarith [hp0 ⟨n, h⟩] · linarith lemma prefSum_nonneg {k : ℕ} {p : Fin k → ℝ} (hp0 : ∀ i, 0 ≤ p i) (n : ℕ) : 0 ≤ prefSum p n := by simpa [prefSum_zero] using prefSum_mono hp0 (Nat.zero_le n) /-- The cyclic-interval rounded subset at offset `u ∈ [0, 1)`: includes `i : Fin k` iff some integer shift `u + j` (`j : Fin m`) lands in `[prefSum p i, prefSum p (i + 1))`. -/ noncomputable def cyclicRoundSet {k : ℕ} (p : Fin k → ℝ) (m : ℕ) (u : ℝ) : Finset (Fin k) := Finset.univ.filter fun i : Fin k => ∃ j : Fin m, prefSum p i.val ≤ u + (j.val : ℝ) ∧ u + (j.val : ℝ) < prefSum p (i.val + 1) /-- Every real `x ∈ [0, prefSum p k)` lies in a unique interval `[prefSum p i, prefSum p (i + 1))`. -/ lemma existsUnique_prefSum_interval {k : ℕ} {p : Fin k → ℝ} (hp0 : ∀ i, 0 ≤ p i) {x : ℝ} (hx0 : 0 ≤ x) (hxk : x < prefSum p k) : ∃! i : Fin k, prefSum p i.val ≤ x ∧ x < prefSum p (i.val + 1) := by have hex : ∃ n : ℕ, n < k ∧ x < prefSum p (n + 1) := by by_cases hk : k = 0 · subst hk; simp [prefSum] at hxk; linarith · refine ⟨k - 1, Nat.sub_lt (Nat.pos_of_ne_zero hk) Nat.one_pos, ?_⟩ rwa [Nat.sub_add_cancel (Nat.one_le_iff_ne_zero.mpr hk)] classical set n := Nat.find hex have hn_spec : n < k ∧ x < prefSum p (n + 1) := Nat.find_spec hex have hn_le : prefSum p n ≤ x := by cases hn_eq : n with | zero => simpa [prefSum_zero] using hx0 | succ r => by_contra hlt push Not at hlt have hr1 : r < k := by have := hn_spec.1; omega have hr2 : r < Nat.find hex := by change r < n; omega exact Nat.find_min hex hr2 ⟨hr1, hlt⟩ refine ⟨⟨n, hn_spec.1⟩, ⟨hn_le, hn_spec.2⟩, ?_⟩ intro i ⟨hi1, hi2⟩ ext by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · have hstep : prefSum p (i.val + 1) ≤ prefSum p n := prefSum_mono hp0 (Nat.succ_le_of_lt hlt) linarith · have hstep : prefSum p (n + 1) ≤ prefSum p i.val := prefSum_mono hp0 (Nat.succ_le_of_lt hgt) linarith /-- For every `u ∈ [0, 1)`, the cyclic-interval rounded subset has exact cardinality `m`. -/ theorem cyclicRoundSet_card {k m : ℕ} {p : Fin k → ℝ} (hp0 : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1) (hsum : ∑ i, p i = (m : ℝ)) {u : ℝ} (hu0 : 0 ≤ u) (hu1 : u < 1) : (cyclicRoundSet p m u).card = m := by classical have hbound : ∀ j : Fin m, 0 ≤ u + (j.val : ℝ) ∧ u + (j.val : ℝ) < prefSum p k := by intro j rw [prefSum_k, hsum] have hj : (j.val : ℝ) + 1 ≤ (m : ℝ) := by exact_mod_cast Nat.succ_le_of_lt j.isLt exact ⟨by positivity, by linarith⟩ let f : Fin m → Fin k := fun j => (existsUnique_prefSum_interval hp0 (hbound j).1 (hbound j).2).choose have hf_spec : ∀ j : Fin m, prefSum p (f j).val ≤ u + (j.val : ℝ) ∧ u + (j.val : ℝ) < prefSum p ((f j).val + 1) := fun j => (existsUnique_prefSum_interval hp0 (hbound j).1 (hbound j).2).choose_spec.1 have hf_inj : Function.Injective f := by intro j₁ j₂ hfeq by_contra hne have h1 := hf_spec j₁ have h2 := hf_spec j₂ rw [hfeq] at h1 have hgap : prefSum p ((f j₂).val + 1) - prefSum p (f j₂).val ≤ 1 := by rw [prefSum_succ_lt p (f j₂).isLt] linarith [hp1 (f j₂)] rcases lt_or_gt_of_ne (Fin.val_ne_of_ne hne) with hlt | hgt · have hj : (j₁.val : ℝ) + 1 ≤ (j₂.val : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hlt linarith · have hj : (j₂.val : ℝ) + 1 ≤ (j₁.val : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hgt linarith have hset_eq : cyclicRoundSet p m u = Finset.univ.image f := by ext i simp only [cyclicRoundSet, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image] constructor · rintro ⟨j, hj1, hj2⟩ refine ⟨j, ?_⟩ exact ((existsUnique_prefSum_interval hp0 (hbound j).1 (hbound j).2).choose_spec.2 i ⟨hj1, hj2⟩).symm · rintro ⟨j, rfl⟩ exact ⟨j, hf_spec j⟩ rw [hset_eq, Finset.card_image_of_injective _ hf_inj, Finset.card_univ, Fintype.card_fin] /-- Telescoping sum over consecutive pairs of a sorted list: `∑ (b - a) = last - head`. -/ lemma list_zipWith_sub_sum : ∀ (l : List ℝ) (h : l ≠ []), (List.zipWith (fun a b => b - a) l l.tail).sum = l.getLast h - l.head h | [], h => absurd rfl h | [a], _ => by simp | a :: b :: t, _ => by have hne : b :: t ≠ [] := List.cons_ne_nil _ _ have ih := list_zipWith_sub_sum (b :: t) hne simp only [List.tail_cons, List.zipWith_cons_cons, List.sum_cons, List.head_cons] at ih ⊢ rw [ih] have hlast : (a :: b :: t).getLast (List.cons_ne_nil _ _) = (b :: t).getLast hne := rfl rw [hlast] ring /-- Sum of `b - a` over consecutive intervals `[a, b]` of a strictly increasing list contained in `[lo, hi]` equals `hi - lo`, provided `lo, hi` both belong to the list and `lo ≤ hi`. -/ lemma list_zipWith_sub_filter_sum : ∀ (l : List ℝ), l.Pairwise (· < ·) → ∀ {lo hi : ℝ}, lo ≤ hi → lo ∈ l → hi ∈ l → (List.zipWith (fun a b => if lo ≤ a ∧ b ≤ hi then b - a else 0) l l.tail).sum = hi - lo | [], _, _, _, _, hlo, _ => by simp at hlo | [a], _, lo, hi, _, hlo, hhi => by simp only [List.mem_singleton] at hlo hhi subst hlo; subst hhi; simp | a :: b :: t, hpw, lo, hi, hlohi, hlo, hhi => by have hab : a < b := (List.pairwise_cons.mp hpw).1 b List.mem_cons_self have hpw_tail : (b :: t).Pairwise (· < ·) := (List.pairwise_cons.mp hpw).2 have hall_a : ∀ x ∈ b :: t, a < x := (List.pairwise_cons.mp hpw).1 simp only [List.tail_cons, List.zipWith_cons_cons, List.sum_cons] by_cases hlo_eq : lo = a · subst hlo_eq by_cases hhi_eq : hi = lo · subst hhi_eq have hhead : (if hi ≤ hi ∧ b ≤ hi then b - hi else 0) = 0 := by rw [if_neg (fun h => not_lt.mpr h.2 hab)] have htail_zero : ∀ (l₁ l₂ : List ℝ), (∀ y ∈ l₂, hi < y) → (List.zipWith (fun x y => if hi ≤ x ∧ y ≤ hi then y - x else 0) l₁ l₂).sum = 0 := by intro l₁ induction l₁ with | nil => intro _ _; simp | cons x xs ih₁ => intro l₂ hy cases l₂ with | nil => simp | cons y ys => have hay : hi < y := hy y List.mem_cons_self simp only [List.zipWith_cons_cons, List.sum_cons, if_neg (fun h : hi ≤ x ∧ y ≤ hi => not_lt.mpr h.2 hay), zero_add] exact ih₁ ys (fun z hz => hy z (List.mem_cons_of_mem y hz)) rw [hhead, zero_add, htail_zero (b :: t) t (fun z hz => hall_a z (List.mem_cons_of_mem b hz)), sub_self] · have hhi_in : hi ∈ b :: t := by rcases List.mem_cons.mp hhi with rfl | hmem · exact absurd rfl hhi_eq · exact hmem have hb_le_hi : b ≤ hi := by rcases List.mem_cons.mp hhi_in with rfl | hmem · exact le_rfl · exact le_of_lt ((List.pairwise_cons.mp hpw_tail).1 hi hmem) have hhead : (if lo ≤ lo ∧ b ≤ hi then b - lo else 0) = b - lo := by rw [if_pos ⟨le_rfl, hb_le_hi⟩] rw [hhead] have ih := list_zipWith_sub_filter_sum (b :: t) hpw_tail hb_le_hi List.mem_cons_self hhi_in simp only [List.tail_cons] at ih have hall_b : ∀ x ∈ b :: t, b ≤ x := fun x hx => by rcases List.mem_cons.mp hx with rfl | hm · exact le_rfl · exact le_of_lt ((List.pairwise_cons.mp hpw_tail).1 x hm) have hgen : ∀ (l₁ l₂ : List ℝ), (∀ x ∈ l₁, b ≤ x) → List.zipWith (fun x y => if lo ≤ x ∧ y ≤ hi then y - x else 0) l₁ l₂ = List.zipWith (fun x y => if b ≤ x ∧ y ≤ hi then y - x else 0) l₁ l₂ := by intro l₁ induction l₁ with | nil => intro _ _; rfl | cons x xs ih₁ => intro l₂ hx cases l₂ with | nil => rfl | cons y ys => have hbx : b ≤ x := hx x List.mem_cons_self have hax : lo ≤ x := le_trans (le_of_lt hab) hbx simp only [List.zipWith_cons_cons, hax, hbx, true_and] congr 1 exact ih₁ ys (fun z hz => hx z (List.mem_cons_of_mem x hz)) rw [hgen (b :: t) t hall_b, ih]; ring · have hlo_in : lo ∈ b :: t := by rcases List.mem_cons.mp hlo with rfl | hm · exact absurd rfl hlo_eq · exact hm have ha_lt_lo : a < lo := hall_a lo hlo_in have hhi_in : hi ∈ b :: t := by rcases List.mem_cons.mp hhi with rfl | hm · linarith · exact hm have hhead : (if lo ≤ a ∧ b ≤ hi then b - a else 0) = 0 := by rw [if_neg (fun h => not_lt.mpr h.1 ha_lt_lo)] rw [hhead, zero_add] exact list_zipWith_sub_filter_sum (b :: t) hpw_tail hlohi hlo_in hhi_in /-- No element of a strictly increasing list lies strictly between consecutive elements. -/ lemma list_pairwise_lt_no_between : ∀ (l : List ℝ), l.Pairwise (· < ·) → ∀ (i : ℕ) (hi : i + 1 < l.length) (c : ℝ), c ∈ l → c ≤ l[i] ∨ l[i + 1] ≤ c | [], _, _, hi, _, _ => by simp at hi | [_], _, _, hi, _, _ => by simp at hi | a :: b :: t, hpw, 0, _, c, hc => by simp only [List.getElem_cons_zero, List.getElem_cons_succ] rcases List.mem_cons.mp hc with rfl | hct · exact Or.inl le_rfl · rcases List.mem_cons.mp hct with rfl | hct' · exact Or.inr le_rfl · exact Or.inr (le_of_lt ((List.pairwise_cons.mp (List.pairwise_cons.mp hpw).2).1 c hct')) | a :: b :: t, hpw, i + 1, hi, c, hc => by have hpw_tail : (b :: t).Pairwise (· < ·) := (List.pairwise_cons.mp hpw).2 have hi' : i + 1 < (b :: t).length := Nat.lt_of_succ_lt_succ hi simp only [List.getElem_cons_succ] rcases List.mem_cons.mp hc with rfl | hct · left have hmem : (b :: t)[i] ∈ b :: t := List.getElem_mem (Nat.lt_of_succ_lt hi') exact le_of_lt ((List.pairwise_cons.mp hpw).1 _ hmem) · exact list_pairwise_lt_no_between (b :: t) hpw_tail i hi' c hct lemma list_zipWith_getElem {α β γ : Type*} (f : α → β → γ) (l₁ : List α) (l₂ : List β) (i : ℕ) (h1 : i < l₁.length) (h2 : i < l₂.length) : (List.zipWith f l₁ l₂)[i]'(by simp [h1, h2]) = f l₁[i] l₂[i] := by induction l₁ generalizing l₂ i with | nil => simp at h1 | cons a as ih => cases l₂ with | nil => simp at h2 | cons b bs => cases i with | zero => rfl | succ i => exact ih bs i (Nat.lt_of_succ_lt_succ h1) (Nat.lt_of_succ_lt_succ h2) /-- Helper: rewriting a `List.zipWith` sum via pointwise equivalence on consecutive pairs of a strictly increasing list. -/ lemma list_zipWith_sum_eq_of_forall : ∀ (l : List ℝ) (f g : ℝ → ℝ → ℝ), (∀ (i : ℕ) (hi : i + 1 < l.length), f l[i] l[i + 1] = g l[i] l[i + 1]) → (List.zipWith f l l.tail).sum = (List.zipWith g l l.tail).sum := by intro l f g hfg congr 1 refine List.ext_getElem ?_ fun i h1 h2 => ?_ · simp · have hlen : i + 1 < l.length := by have hlt : i < l.tail.length := by simp only [List.length_zipWith, lt_min_iff] at h1 exact h1.2 cases l with | nil => simp at hlt | cons a as => simp at hlt ⊢; omega have hlt1 : i < l.length := Nat.lt_of_succ_lt hlen have hlt2 : i < l.tail.length := by cases l with | nil => simp at hlen | cons a as => simp at hlen ⊢; omega rw [list_zipWith_getElem f l l.tail i hlt1 hlt2, list_zipWith_getElem g l l.tail i hlt1 hlt2] have htail : l.tail[i] = l[i + 1] := by cases l with | nil => simp at hlen | cons a as => rfl rw [htail] exact hfg i hlen lemma list_zipWith_sum_add : ∀ (l : List ℝ) (f g : ℝ → ℝ → ℝ), (List.zipWith (fun a b => f a b + g a b) l l.tail).sum = (List.zipWith f l l.tail).sum + (List.zipWith g l l.tail).sum := by intro l f g have hgen : ∀ (l₁ l₂ : List ℝ), (List.zipWith (fun a b => f a b + g a b) l₁ l₂).sum = (List.zipWith f l₁ l₂).sum + (List.zipWith g l₁ l₂).sum := by intro l₁ induction l₁ with | nil => intro _; simp | cons a as ih => intro l₂ cases l₂ with | nil => simp | cons b bs => simp only [List.zipWith_cons_cons, List.sum_cons, ih bs] ring exact hgen l l.tail /-- **Constructive Cyclic-Interval Dependent Rounding Theorem on `Fin k`**: Every marginal vector `p : Fin k → ℝ` with `0 ≤ p i ≤ 1` and `∑ i, p i = m` (`m : ℕ`) is realized by an explicit finite probability distribution over `m`-element subsets of `Fin k`, with support size at most `max 1 k`. -/ theorem cyclicIntervalRounding_fin {k m : ℕ} {p : Fin k → ℝ} (hp0 : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1) (hsum : ∑ i, p i = (m : ℝ)) : ∃ (n : ℕ) (w : Fin n → ℝ) (L : Fin n → Finset (Fin k)), n ≤ max 1 k ∧ (∀ t, 0 ≤ w t) ∧ (∑ t, w t = 1) ∧ (∀ t, (L t).card = m) ∧ (∀ i : Fin k, ∑ t, (if i ∈ L t then w t else 0) = p i) := by classical -- Build the finite set of breakpoints in `[0, 1]`. set cutSet : Finset ℝ := ({0, 1} : Finset ℝ) ∪ (Finset.range (k + 1)).image (fun r => Int.fract (prefSum p r)) set cuts : List ℝ := cutSet.sort (· ≤ ·) have hmem_cuts : ∀ x, x ∈ cuts ↔ x ∈ cutSet := fun x => Finset.mem_sort (· ≤ ·) have h0_in : (0 : ℝ) ∈ cuts := (hmem_cuts 0).mpr (Finset.mem_union_left _ (by simp)) have h1_in : (1 : ℝ) ∈ cuts := (hmem_cuts 1).mpr (Finset.mem_union_left _ (by simp)) have hcuts_pw_le : cuts.Pairwise (· ≤ ·) := Finset.pairwise_sort cutSet (· ≤ ·) have hcuts_nodup : cuts.Nodup := Finset.sort_nodup cutSet (· ≤ ·) have hcuts_pw_lt : cuts.Pairwise (· < ·) := by have h := List.pairwise_and_iff.mpr ⟨hcuts_pw_le, List.nodup_iff_pairwise_ne.mp hcuts_nodup⟩ exact h.imp fun {x y} hxy => lt_of_le_of_ne hxy.1 hxy.2 have hcuts_bounds : ∀ x ∈ cuts, 0 ≤ x ∧ x ≤ 1 := by intro x hx rw [hmem_cuts] at hx rcases Finset.mem_union.mp hx with h01 | himg · simp only [Finset.mem_insert, Finset.mem_singleton] at h01 rcases h01 with rfl | rfl <;> norm_num · rcases Finset.mem_image.mp himg with ⟨r, _, rfl⟩ exact ⟨Int.fract_nonneg _, le_of_lt (Int.fract_lt_one _)⟩ have hcuts_len_ge2 : 2 ≤ cuts.length := by have hsub : ({0, 1} : Finset ℝ) ⊆ cutSet := Finset.subset_union_left have hcard : 2 ≤ cutSet.card := by calc 2 = ({0, 1} : Finset ℝ).card := by norm_num _ ≤ cutSet.card := Finset.card_le_card hsub simpa [cuts, Finset.length_sort] using hcard have hcuts_ne : cuts ≠ [] := by intro heq; rw [heq] at hcuts_len_ge2; simp at hcuts_len_ge2 have hhead : cuts.head hcuts_ne = 0 := by have hmem_head : cuts.head hcuts_ne ∈ cuts := List.head_mem hcuts_ne have hge0 : 0 ≤ cuts.head hcuts_ne := (hcuts_bounds _ hmem_head).1 have hle0 : cuts.head hcuts_ne ≤ 0 := by rw [List.head_eq_getElem] obtain ⟨idx, hidx_lt, hidx_eq⟩ := List.getElem_of_mem h0_in rw [← hidx_eq] by_cases h0 : idx = 0 · subst h0; exact le_rfl · exact le_of_lt (List.pairwise_iff_getElem.mp hcuts_pw_lt 0 idx (by omega) hidx_lt (Nat.pos_of_ne_zero h0)) exact le_antisymm hle0 hge0 have hlast : cuts.getLast hcuts_ne = 1 := by have hmem_last : cuts.getLast hcuts_ne ∈ cuts := List.getLast_mem hcuts_ne have hle1 : cuts.getLast hcuts_ne ≤ 1 := (hcuts_bounds _ hmem_last).2 have hge1 : 1 ≤ cuts.getLast hcuts_ne := by have hpw_rev := hcuts_pw_le have hidx : ∀ x ∈ cuts, x ≤ cuts.getLast hcuts_ne := by intro x hx obtain ⟨idx, hidx_lt, rfl⟩ := List.getElem_of_mem hx rw [List.getLast_eq_getElem] by_cases heq : idx = cuts.length - 1 · subst heq; exact le_rfl · have hlt : idx < cuts.length - 1 := by omega exact le_of_lt (List.pairwise_iff_getElem.mp hcuts_pw_lt idx (cuts.length - 1) hidx_lt (by omega) hlt) exact hidx 1 h1_in exact le_antisymm hle1 hge1 -- Cardinality bound: `cuts.length - 1 ≤ max 1 k`. have hcard_le : cuts.length - 1 ≤ max 1 k := by rw [Finset.length_sort] by_cases hk : k = 0 · subst hk have hsub : cutSet ⊆ ({0, 1} : Finset ℝ) := by intro x hx rcases Finset.mem_union.mp hx with h01 | himg · exact h01 · rcases Finset.mem_image.mp himg with ⟨r, hr, rfl⟩ have hr0 : r = 0 := by simp at hr; exact hr subst hr0 simp [prefSum] have hle2 : cutSet.card ≤ 2 := le_trans (Finset.card_le_card hsub) (by norm_num) omega · have hsub : cutSet ⊆ ({0, 1} : Finset ℝ) ∪ (Finset.Ico 1 k).image (fun r => Int.fract (prefSum p r)) := by intro x hx rcases Finset.mem_union.mp hx with h01 | himg · exact Finset.mem_union_left _ h01 · rcases Finset.mem_image.mp himg with ⟨r, hr, rfl⟩ have hr_le : r ≤ k := Nat.lt_succ_iff.mp (Finset.mem_range.mp hr) by_cases hr0 : r = 0 · subst hr0; exact Finset.mem_union_left _ (by simp [prefSum]) · by_cases hrk : r = k · subst hrk rw [prefSum_k, hsum, Int.fract_natCast] exact Finset.mem_union_left _ (by simp) · refine Finset.mem_union_right _ (Finset.mem_image.mpr ⟨r, ?_, rfl⟩) exact Finset.mem_Ico.mpr ⟨Nat.pos_of_ne_zero hr0, lt_of_le_of_ne hr_le hrk⟩ have hle : cutSet.card ≤ 2 + (k - 1) := by calc cutSet.card ≤ (({0, 1} : Finset ℝ) ∪ (Finset.Ico 1 k).image (fun r => Int.fract (prefSum p r))).card := Finset.card_le_card hsub _ ≤ ({0, 1} : Finset ℝ).card + ((Finset.Ico 1 k).image (fun r => Int.fract (prefSum p r))).card := Finset.card_union_le _ _ _ ≤ 2 + (Finset.Ico 1 k).card := by have h1 : ({0, 1} : Finset ℝ).card ≤ 2 := by norm_num have h2 := Finset.card_image_le (f := fun r => Int.fract (prefSum p r)) (s := Finset.Ico 1 k) omega _ = 2 + (k - 1) := by simp omega set n := cuts.length - 1 have hn_succ : ∀ t : Fin n, t.val + 1 < cuts.length := fun t => by omega let w : Fin n → ℝ := fun t => cuts[t.val + 1]'(hn_succ t) - cuts[t.val]'(by omega) let mid : Fin n → ℝ := fun t => (cuts[t.val]'(by omega) + cuts[t.val + 1]'(hn_succ t)) / 2 let L : Fin n → Finset (Fin k) := fun t => cyclicRoundSet p m (mid t) -- Helper connecting `∑ t : Fin n, F (cuts[t]) (cuts[t+1])` with `List.zipWith`. have hsum_zip : ∀ F : ℝ → ℝ → ℝ, (∑ t : Fin n, F (cuts[t.val]'(by omega)) (cuts[t.val + 1]'(hn_succ t))) = (List.zipWith F cuts cuts.tail).sum := by intro F have hlen_zip : (List.zipWith F cuts cuts.tail).length = n := by simp [n] rw [← List.sum_ofFn (f := fun t : Fin n => F (cuts[t.val]'(by omega)) (cuts[t.val + 1]'(hn_succ t)))] congr 1 refine List.ext_getElem (by simp [hlen_zip]) fun t h1 h2 => ?_ simp only [List.getElem_ofFn] have ht : t + 1 < cuts.length := by simp at h1; omega have hlt1 : t < cuts.length := Nat.lt_of_succ_lt ht have hlt2 : t < cuts.tail.length := by simp; omega rw [list_zipWith_getElem F cuts cuts.tail t hlt1 hlt2, List.getElem_tail] have hw_pos : ∀ t : Fin n, cuts[t.val]'(by omega) < cuts[t.val + 1]'(hn_succ t) := fun t => List.pairwise_iff_getElem.mp hcuts_pw_lt t.val (t.val + 1) (by omega) (hn_succ t) (Nat.lt_succ_self _) have hmid_bounds : ∀ t : Fin n, 0 ≤ mid t ∧ mid t < 1 := by intro t have h1 := hcuts_bounds (cuts[t.val]'(by omega)) (List.getElem_mem _) have h2 := hcuts_bounds (cuts[t.val + 1]'(hn_succ t)) (List.getElem_mem _) have hlt := hw_pos t dsimp only [mid] exact ⟨by linarith, by linarith⟩ refine ⟨n, w, L, hcard_le, ?_, ?_, ?_, ?_⟩ · intro t; dsimp only [w]; linarith [hw_pos t] · change (∑ t : Fin n, (cuts[t.val + 1]'(hn_succ t) - cuts[t.val]'(by omega))) = 1 rw [hsum_zip (fun a b => b - a), list_zipWith_sub_sum cuts hcuts_ne, hhead, hlast, sub_zero] · intro t exact cyclicRoundSet_card hp0 hp1 hsum (hmid_bounds t).1 (hmid_bounds t).2 · intro i set a_i := prefSum p i.val set b_i := prefSum p (i.val + 1) have hbi_eq : b_i = a_i + p i := prefSum_succ_lt p i.isLt have ha0 : 0 ≤ a_i := prefSum_nonneg hp0 i.val have hbk : b_i ≤ (m : ℝ) := by calc b_i ≤ prefSum p k := prefSum_mono hp0 (Nat.succ_le_of_lt i.isLt) _ = (m : ℝ) := by rw [prefSum_k, hsum] by_cases hpi0 : p i = 0 · rw [hpi0] refine Finset.sum_eq_zero fun t _ => ?_ have hnot : i ∉ L t := by simp only [L, cyclicRoundSet, Finset.mem_filter, Finset.mem_univ, true_and, not_exists] intro j ⟨h1, h2⟩ have : a_i = b_i := by linarith linarith simp [hnot] · have hpi_pos : 0 < p i := lt_of_le_of_ne (hp0 i) (Ne.symm hpi0) have hab_lt : a_i < b_i := by linarith have hab_le1 : b_i - a_i ≤ 1 := by linarith [hp1 i] set qa : ℤ := ⌊a_i⌋ set qb : ℤ := ⌊b_i⌋ set ra : ℝ := Int.fract a_i set rb : ℝ := Int.fract b_i have hqa0 : 0 ≤ qa := Int.floor_nonneg.mpr ha0 have hqb0 : 0 ≤ qb := Int.floor_nonneg.mpr (le_trans ha0 (le_of_lt hab_lt)) have hra_in : ra ∈ cuts := (hmem_cuts ra).mpr <| Finset.mem_union_right _ <| Finset.mem_image.mpr ⟨i.val, Finset.mem_range.mpr (by omega), rfl⟩ have hrb_in : rb ∈ cuts := (hmem_cuts rb).mpr <| Finset.mem_union_right _ <| Finset.mem_image.mpr ⟨i.val + 1, Finset.mem_range.mpr (by omega), rfl⟩ have ha_decomp : (qa : ℝ) + ra = a_i := Int.floor_add_fract a_i have hb_decomp : (qb : ℝ) + rb = b_i := Int.floor_add_fract b_i have hra_lt1 : ra < 1 := Int.fract_lt_one a_i have hrb_lt1 : rb < 1 := Int.fract_lt_one b_i have hra_nn : 0 ≤ ra := Int.fract_nonneg a_i have hrb_nn : 0 ≤ rb := Int.fract_nonneg b_i have hqa_le_qb : qa ≤ qb := Int.floor_mono (le_of_lt hab_lt) have hqb_le_succ : qb ≤ qa + 1 := by have hlt : b_i < ((qa + 1 : ℤ) : ℝ) + 1 := by push_cast; linarith exact Int.le_of_lt_add_one (Int.floor_lt.mpr (by push_cast; linarith)) -- Helper: for any breakpoint `c ∈ cuts` and interval `t`, `c ≤ mid t ↔ c ≤ cuts[t]` and `mid t < c ↔ cuts[t+1] ≤ c`. have hcut_le_mid : ∀ (t : Fin n) (c : ℝ), c ∈ cuts → (c ≤ mid t ↔ c ≤ cuts[t.val]'(by omega)) := by intro t c hc have hlt := hw_pos t dsimp only [mid] constructor · intro hcm rcases list_pairwise_lt_no_between cuts hcuts_pw_lt t.val (hn_succ t) c hc with h1 | h2 · exact h1 · linarith · intro h1; linarith have hmid_lt_cut : ∀ (t : Fin n) (c : ℝ), c ∈ cuts → (mid t < c ↔ cuts[t.val + 1]'(hn_succ t) ≤ c) := by intro t c hc have hlt := hw_pos t dsimp only [mid] constructor · intro hmc rcases list_pairwise_lt_no_between cuts hcuts_pw_lt t.val (hn_succ t) c hc with h1 | h2 · linarith · exact h2 · intro h2; linarith have hqa_lt_m : qa.toNat < m := by have hlt_r : (qa : ℝ) < (m : ℝ) := by linarith have hlt_z : qa < (m : ℤ) := by exact_mod_cast hlt_r omega -- Split into `qa = qb` (non-wrapping) vs `qb = qa + 1` (wrapping once). by_cases hqeq : qa = qb · have hra_lt_rb : ra < rb := by have : (qa : ℝ) = (qb : ℝ) := by exact_mod_cast hqeq linarith have hiff : ∀ t : Fin n, i ∈ L t ↔ ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ rb := by intro t rw [← hcut_le_mid t ra hra_in, ← hmid_lt_cut t rb hrb_in] simp only [L, cyclicRoundSet, Finset.mem_filter, Finset.mem_univ, true_and] have hm0 := (hmid_bounds t).1 have hm1 := (hmid_bounds t).2 constructor · rintro ⟨j, hj1, hj2⟩ have hj_eq : (j.val : ℤ) = qa := by have hq1 : (qa : ℝ) ≤ (j.val : ℝ) + mid t := by linarith have hq2 : (j.val : ℝ) + mid t < (qa : ℝ) + 1 := by have : (qa : ℝ) = (qb : ℝ) := by exact_mod_cast hqeq linarith have h1 : qa ≤ (j.val : ℤ) := by by_contra hlt; push Not at hlt have : ((j.val : ℤ) : ℝ) + 1 ≤ (qa : ℝ) := by exact_mod_cast Int.add_one_le_iff.mpr hlt push_cast at this; linarith have h2 : (j.val : ℤ) ≤ qa := by by_contra hlt; push Not at hlt have : (qa : ℝ) + 1 ≤ ((j.val : ℤ) : ℝ) := by exact_mod_cast Int.add_one_le_iff.mpr hlt push_cast at this; linarith omega have hjr : (j.val : ℝ) = (qa : ℝ) := by exact_mod_cast hj_eq have hqr : (qa : ℝ) = (qb : ℝ) := by exact_mod_cast hqeq exact ⟨by linarith, by linarith⟩ · intro ⟨h1, h2⟩ refine ⟨⟨qa.toNat, hqa_lt_m⟩, ?_, ?_⟩ · have hcast : (qa.toNat : ℝ) = (qa : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqa0 linarith · have hcast : (qa.toNat : ℝ) = (qa : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqa0 have hqr : (qa : ℝ) = (qb : ℝ) := by exact_mod_cast hqeq linarith have hsum_eq : (∑ t : Fin n, if i ∈ L t then w t else 0) = ∑ t : Fin n, if ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ rb then cuts[t.val + 1]'(hn_succ t) - cuts[t.val]'(by omega) else 0 := Finset.sum_congr rfl fun t _ => by simp only [hiff t, w] rw [hsum_eq, hsum_zip (fun a b => if ra ≤ a ∧ b ≤ rb then b - a else 0), list_zipWith_sub_filter_sum cuts hcuts_pw_lt (le_of_lt hra_lt_rb) hra_in hrb_in] have hqr : (qa : ℝ) = (qb : ℝ) := by exact_mod_cast hqeq linarith · have hqb_eq : qb = qa + 1 := by omega have hqbr : (qb : ℝ) = (qa : ℝ) + 1 := by exact_mod_cast hqb_eq have hrb_le_ra : rb ≤ ra := by linarith by_cases hrb0 : rb = 0 · have hiff : ∀ t : Fin n, i ∈ L t ↔ ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ 1 := by intro t rw [← hcut_le_mid t ra hra_in, ← hmid_lt_cut t 1 h1_in] simp only [L, cyclicRoundSet, Finset.mem_filter, Finset.mem_univ, true_and] have hm0 := (hmid_bounds t).1 have hm1 := (hmid_bounds t).2 constructor · rintro ⟨j, hj1, hj2⟩ have hj_eq : (j.val : ℤ) = qa := by have h1 : qa ≤ (j.val : ℤ) := by by_contra hlt; push Not at hlt have : ((j.val : ℤ) : ℝ) + 1 ≤ (qa : ℝ) := by exact_mod_cast Int.add_one_le_iff.mpr hlt push_cast at this; linarith have h2 : (j.val : ℤ) ≤ qa := by by_contra hlt; push Not at hlt have : (qa : ℝ) + 1 ≤ ((j.val : ℤ) : ℝ) := by exact_mod_cast Int.add_one_le_iff.mpr hlt push_cast at this; linarith omega have hjr : (j.val : ℝ) = (qa : ℝ) := by exact_mod_cast hj_eq exact ⟨by linarith, hm1⟩ · intro ⟨h1, _⟩ refine ⟨⟨qa.toNat, hqa_lt_m⟩, ?_, ?_⟩ · have hcast : (qa.toNat : ℝ) = (qa : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqa0 linarith · have hcast : (qa.toNat : ℝ) = (qa : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqa0 linarith have hsum_eq : (∑ t : Fin n, if i ∈ L t then w t else 0) = ∑ t : Fin n, if ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ 1 then cuts[t.val + 1]'(hn_succ t) - cuts[t.val]'(by omega) else 0 := Finset.sum_congr rfl fun t _ => by simp only [hiff t, w] rw [hsum_eq, hsum_zip (fun a b => if ra ≤ a ∧ b ≤ 1 then b - a else 0), list_zipWith_sub_filter_sum cuts hcuts_pw_lt (le_of_lt hra_lt1) hra_in h1_in] linarith · have hrb_pos : 0 < rb := lt_of_le_of_ne hrb_nn (Ne.symm hrb0) have hqb_lt_m : qb.toNat < m := by have hlt_r : (qb : ℝ) < (m : ℝ) := by linarith have hlt_z : qb < (m : ℤ) := by exact_mod_cast hlt_r omega have hiff : ∀ t : Fin n, i ∈ L t ↔ (ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ 1) ∨ (0 ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ rb) := by intro t rw [← hcut_le_mid t ra hra_in, ← hmid_lt_cut t 1 h1_in, ← hcut_le_mid t 0 h0_in, ← hmid_lt_cut t rb hrb_in] simp only [L, cyclicRoundSet, Finset.mem_filter, Finset.mem_univ, true_and] have hm0 := (hmid_bounds t).1 have hm1 := (hmid_bounds t).2 constructor · rintro ⟨j, hj1, hj2⟩ have h1 : qa ≤ (j.val : ℤ) := by by_contra hlt; push Not at hlt have : ((j.val : ℤ) : ℝ) + 1 ≤ (qa : ℝ) := by exact_mod_cast Int.add_one_le_iff.mpr hlt push_cast at this; linarith have h2 : (j.val : ℤ) ≤ qb := by by_contra hlt; push Not at hlt have : (qb : ℝ) + 1 ≤ ((j.val : ℤ) : ℝ) := by exact_mod_cast Int.add_one_le_iff.mpr hlt push_cast at this; linarith have hcases : (j.val : ℤ) = qa ∨ (j.val : ℤ) = qb := by omega rcases hcases with hja | hjb · have hjr : (j.val : ℝ) = (qa : ℝ) := by exact_mod_cast hja exact Or.inl ⟨by linarith, hm1⟩ · have hjr : (j.val : ℝ) = (qb : ℝ) := by exact_mod_cast hjb exact Or.inr ⟨hm0, by linarith⟩ · rintro (⟨h1, _⟩ | ⟨_, h2⟩) · refine ⟨⟨qa.toNat, hqa_lt_m⟩, ?_, ?_⟩ · have hcast : (qa.toNat : ℝ) = (qa : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqa0 linarith · have hcast : (qa.toNat : ℝ) = (qa : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqa0 linarith · refine ⟨⟨qb.toNat, hqb_lt_m⟩, ?_, ?_⟩ · have hcast : (qb.toNat : ℝ) = (qb : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqb0 linarith · have hcast : (qb.toNat : ℝ) = (qb : ℝ) := by exact_mod_cast Int.toNat_of_nonneg hqb0 linarith have hsum_eq : (∑ t : Fin n, if i ∈ L t then w t else 0) = ∑ t : Fin n, ((if ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ 1 then cuts[t.val + 1]'(hn_succ t) - cuts[t.val]'(by omega) else 0) + (if 0 ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ rb then cuts[t.val + 1]'(hn_succ t) - cuts[t.val]'(by omega) else 0)) := by refine Finset.sum_congr rfl fun t _ => ?_ have hlt := hw_pos t simp only [hiff t] by_cases hA : ra ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ 1 · have hnotB : ¬ (0 ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ rb) := by intro hB; linarith simp [hA, hnotB, w] · by_cases hB : 0 ≤ cuts[t.val]'(by omega) ∧ cuts[t.val + 1]'(hn_succ t) ≤ rb · simp [hA, hB, w] · simp [hA, hB, w] rw [hsum_eq, hsum_zip (fun a b => (if ra ≤ a ∧ b ≤ 1 then b - a else 0) + (if 0 ≤ a ∧ b ≤ rb then b - a else 0)), list_zipWith_sum_add cuts, list_zipWith_sub_filter_sum cuts hcuts_pw_lt (le_of_lt hra_lt1) hra_in h1_in, list_zipWith_sub_filter_sum cuts hcuts_pw_lt hrb_nn h0_in hrb_in] linarith /-- Padding lemma: any marginal vector `p : Fin k → ℝ` in `[0, 1]` with `∑ p ≤ m` and `m ≤ k` can be raised pointwise to `q : Fin k → ℝ` in `[0, 1]` with `p i ≤ q i` and `∑ q = m`. -/ lemma exists_padded_marginals {k m : ℕ} {p : Fin k → ℝ} (hmk : m ≤ k) (hp0 : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1) (hsum : ∑ i, p i ≤ (m : ℝ)) : ∃ q : Fin k → ℝ, (∀ i, p i ≤ q i) ∧ (∀ i, 0 ≤ q i) ∧ (∀ i, q i ≤ 1) ∧ (∑ i, q i = (m : ℝ)) := by by_cases hsum_eq : ∑ i, p i = (k : ℝ) · have hmk_eq : (m : ℝ) = (k : ℝ) := le_antisymm (by exact_mod_cast hmk) (by linarith) exact ⟨p, fun _ => le_rfl, hp0, hp1, by linarith⟩ · have hsum_lt : ∑ i, p i < (k : ℝ) := by have hle : ∑ i : Fin k, p i ≤ (k : ℝ) := by calc ∑ i : Fin k, p i ≤ ∑ _i : Fin k, (1 : ℝ) := Finset.sum_le_sum fun i _ => hp1 i _ = (k : ℝ) := by simp exact lt_of_le_of_ne hle hsum_eq set den : ℝ := (k : ℝ) - ∑ i, p i have hden_pos : 0 < den := sub_pos.mpr hsum_lt set α : ℝ := ((m : ℝ) - ∑ i, p i) / den have hα0 : 0 ≤ α := div_nonneg (sub_nonneg.mpr hsum) (le_of_lt hden_pos) have hα1 : α ≤ 1 := (div_le_one hden_pos).mpr (by have hmk_r : (m : ℝ) ≤ (k : ℝ) := by exact_mod_cast hmk linarith) refine ⟨fun i => p i + α * (1 - p i), ?_, ?_, ?_, ?_⟩ · intro i; nlinarith [hp1 i] · intro i; nlinarith [hp0 i, hp1 i] · intro i; nlinarith [hp1 i] · have hrew : ∑ i : Fin k, (p i + α * (1 - p i)) = (∑ i, p i) + α * den := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_sub_distrib] simp [den] rw [hrew] dsimp only [α] rw [div_mul_cancel₀ _ (ne_of_gt hden_pos)] ring /-- **Lifted Constructive `m`-Subset Decomposition Theorem on arbitrary `Finset β`**: For any `S : Finset β` with `m ≤ S.card` and any marginal vector `p : β → ℝ` in `[0, 1]` on `S` with `∑ y ∈ S, p y ≤ m`, there exists an explicit finite probability distribution over `m`-element subsets of `S` (support size `≤ max 1 S.card`) whose inclusion probability on every `y ∈ S` is at least `p y` (and equals `p y` when `∑ y ∈ S, p y = m`). -/ theorem exists_mSubset_dist_of_marginals {β : Type*} [DecidableEq β] {S : Finset β} {m : ℕ} (hmS : m ≤ S.card) {p : β → ℝ} (hp0 : ∀ y ∈ S, 0 ≤ p y) (hp1 : ∀ y ∈ S, p y ≤ 1) (hsum : ∑ y ∈ S, p y = (m : ℝ)) : ∃ (n : ℕ) (w : Fin n → ℝ) (L : Fin n → Finset β), n ≤ max 1 S.card ∧ (∀ t, 0 ≤ w t) ∧ (∑ t, w t = 1) ∧ (∀ t, L t ⊆ S ∧ (L t).card = m) ∧ (∀ y ∈ S, ∑ t, (if y ∈ L t then w t else 0) = p y) := by classical let e : Fin S.card ≃ S := (Fintype.equivFinOfCardEq (Fintype.card_coe S)).symm let p' : Fin S.card → ℝ := fun i => p (e i).val have hp'0 : ∀ i, 0 ≤ p' i := fun i => hp0 (e i).val (e i).property have hp'1 : ∀ i, p' i ≤ 1 := fun i => hp1 (e i).val (e i).property have hsum' : ∑ i : Fin S.card, p' i = (m : ℝ) := by have h1 : ∑ i : Fin S.card, p (e i).val = ∑ x : S, p x.val := Equiv.sum_comp e (fun x : S => p x.val) rw [show ∑ i, p' i = ∑ x : S, p x.val from h1, Finset.sum_coe_sort S p, hsum] have _ := hmS obtain ⟨n, w, L', hn, hw0, hw1, hLcard, hmarg⟩ := cyclicIntervalRounding_fin hp'0 hp'1 hsum' let emb : Fin S.card → β := fun i => (e i).val have hemb_inj : Function.Injective emb := fun i j hij => e.injective (Subtype.ext hij) let L : Fin n → Finset β := fun t => (L' t).image emb refine ⟨n, w, L, hn, hw0, hw1, ?_, ?_⟩ · intro t refine ⟨?_, ?_⟩ · intro y hy rcases Finset.mem_image.mp hy with ⟨i, _, rfl⟩ exact (e i).property · rw [Finset.card_image_of_injective _ hemb_inj, hLcard t] · intro y hy set i : Fin S.card := e.symm ⟨y, hy⟩ have hei : emb i = y := congrArg Subtype.val (e.apply_symm_apply ⟨y, hy⟩) have hrew : ∀ t : Fin n, (if y ∈ L t then w t else 0) = (if i ∈ L' t then w t else 0) := by intro t have hmem : y ∈ L t ↔ i ∈ L' t := by simp only [L, Finset.mem_image] constructor · rintro ⟨j, hj, hjeq⟩ have : j = i := hemb_inj (hjeq.trans hei.symm) rwa [← this] · intro hi; exact ⟨i, hi, hei⟩ simp only [hmem] rw [Finset.sum_congr rfl fun t _ => hrew t, hmarg i] change p (emb i) = p y rw [hei] theorem exists_mSubset_dist_of_sum_le {β : Type*} [DecidableEq β] {S : Finset β} {m : ℕ} (hmS : m ≤ S.card) {p : β → ℝ} (hp0 : ∀ y ∈ S, 0 ≤ p y) (hp1 : ∀ y ∈ S, p y ≤ 1) (hsum : ∑ y ∈ S, p y ≤ (m : ℝ)) : ∃ (n : ℕ) (w : Fin n → ℝ) (L : Fin n → Finset β), n ≤ max 1 S.card ∧ (∀ t, 0 ≤ w t) ∧ (∑ t, w t = 1) ∧ (∀ t, L t ⊆ S ∧ (L t).card = m) ∧ (∀ y ∈ S, p y ≤ ∑ t, (if y ∈ L t then w t else 0)) := by classical let e : Fin S.card ≃ S := (Fintype.equivFinOfCardEq (Fintype.card_coe S)).symm let p' : Fin S.card → ℝ := fun i => p (e i).val have hp'0 : ∀ i, 0 ≤ p' i := fun i => hp0 (e i).val (e i).property have hp'1 : ∀ i, p' i ≤ 1 := fun i => hp1 (e i).val (e i).property have hsum' : ∑ i : Fin S.card, p' i ≤ (m : ℝ) := by have h1 : ∑ i : Fin S.card, p (e i).val = ∑ x : S, p x.val := Equiv.sum_comp e (fun x : S => p x.val) rw [show ∑ i, p' i = ∑ x : S, p x.val from h1, Finset.sum_coe_sort S p] exact hsum obtain ⟨q', hle', hq'0, hq'1, hq'sum⟩ := exists_padded_marginals hmS hp'0 hp'1 hsum' let q : β → ℝ := fun y => if hy : y ∈ S then q' (e.symm ⟨y, hy⟩) else 0 have hq0 : ∀ y ∈ S, 0 ≤ q y := fun y hy => by simp [q, hy, hq'0] have hq1 : ∀ y ∈ S, q y ≤ 1 := fun y hy => by simp [q, hy, hq'1] have hq_ge : ∀ y ∈ S, p y ≤ q y := fun y hy => by simp only [q, dif_pos hy] have := hle' (e.symm ⟨y, hy⟩) dsimp only [p'] at this rwa [show (e (e.symm ⟨y, hy⟩)).val = y from congrArg Subtype.val (e.apply_symm_apply ⟨y, hy⟩)] at this have hqsum : ∑ y ∈ S, q y = (m : ℝ) := by rw [← Finset.sum_coe_sort S q] have h1 : ∑ x : S, q x.val = ∑ i : Fin S.card, q (e i).val := (Equiv.sum_comp e (fun x : S => q x.val)).symm rw [h1] have h2 : ∀ i : Fin S.card, q (e i).val = q' i := fun i => by simp [q, (e i).property] simp_rw [h2] exact hq'sum obtain ⟨n, w, L, hn, hw0, hw1, hLcard, hmarg⟩ := exists_mSubset_dist_of_marginals hmS hq0 hq1 hqsum exact ⟨n, w, L, hn, hw0, hw1, hLcard, fun y hy => by rw [hmarg y hy]; exact hq_ge y hy⟩ end CyclicIntervalRounding /-! ## Part 3: Deterministic `Ldim` and Randomized `RLdim` for `m`-List & Fractional-`μ` Online Learning -/ /-- Version-space restriction to hypotheses predicting `y` at `x`. -/ def restrict {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : Finset (α → β) := V.filter (fun h => h x = y) /-- Distinct labels predicted on `x` by hypotheses in `V`. -/ def labels {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) : Finset β := V.image (fun h => h x) lemma restrict_subset {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : restrict V x y ⊆ V := Finset.filter_subset _ V lemma restrict_nonempty_iff {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) (y : β) : (restrict V x y).Nonempty ↔ y ∈ labels V x := by simp [restrict, labels, Finset.Nonempty] lemma labels_nonempty_of_nonempty {α β : Type*} [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) (x : α) : (labels V x).Nonempty := hV.image (fun h => h x) lemma card_restrict_lt_of_two_labels {α β : Type*} [DecidableEq β] {V : Finset (α → β)} {x : α} (hsplit : 2 ≤ (labels V x).card) (y : β) : (restrict V x y).card < V.card := by have hsub : restrict V x y ⊂ V := by refine Finset.ssubset_iff_subset_ne.mpr ⟨restrict_subset V x y, fun heq => ?_⟩ have hle1 : (labels V x).card ≤ 1 := by rw [labels] have hsub_sing : V.image (fun h => h x) ⊆ {y} := by intro z hz rcases Finset.mem_image.mp hz with ⟨h, hh, rfl⟩ rw [← heq] at hh exact Finset.mem_singleton.mpr (Finset.mem_filter.mp hh).2 exact le_trans (Finset.card_le_card hsub_sing) (by simp) omega exact Finset.card_lt_card hsub lemma sum_card_restrict {α β : Type*} [DecidableEq β] (V : Finset (α → β)) (x : α) : ∑ y ∈ labels V x, (restrict V x y).card = V.card := by have h := Finset.card_eq_sum_card_fiberwise (f := fun h : α → β => h x) (s := V) (t := labels V x) (fun h hh => Finset.mem_image.mpr ⟨h, hh, rfl⟩) exact h.symm /-- 1-round deterministic `m`-list step: minimal `t : ℕ` such that every `y ∈ S` has `d y ≤ t` and at most `m` labels `y ∈ S` achieve `d y = t` (equivalently, there exists an `m`-list `L ⊆ S` such that `y ∈ L → d y ≤ t` and `y ∉ L → d y + 1 ≤ t`). -/ def dlistStep {β : Type*} [DecidableEq β] (m : ℕ) (S : Finset β) (d : β → ℕ) : ℕ := if hS : S.Nonempty then let M := S.sup' hS d if (S.filter (fun y => d y = M)).card ≤ m then M else M + 1 else 0 lemma dlistStep_le_iff {β : Type*} [DecidableEq β] {m : ℕ} {S : Finset β} (hS : S.Nonempty) {d : β → ℕ} (t : ℕ) : dlistStep m S d ≤ t ↔ (∀ y ∈ S, d y ≤ t) ∧ (S.filter (fun y => t ≤ d y)).card ≤ m := by rw [dlistStep, dif_pos hS] dsimp only set M := S.sup' hS d have hle_M : ∀ y ∈ S, d y ≤ M := fun y hy => Finset.le_sup' d hy split_ifs with hcard · constructor · intro hMt refine ⟨fun y hy => le_trans (hle_M y hy) hMt, ?_⟩ by_cases heq : M = t · subst heq have hfeq : S.filter (fun y => M ≤ d y) = S.filter (fun y => d y = M) := by ext y simp only [Finset.mem_filter, and_congr_right_iff] intro hy exact ⟨fun h => le_antisymm (hle_M y hy) h, fun h => by rw [h]⟩ rwa [hfeq] · have hlt : M < t := lt_of_le_of_ne hMt heq have hemp : S.filter (fun y => t ≤ d y) = ∅ := by ext y simp only [Finset.mem_filter, Finset.notMem_empty, iff_false, not_and, not_le] intro hy; exact lt_of_le_of_lt (hle_M y hy) hlt rw [hemp, Finset.card_empty] exact Nat.zero_le m · intro ⟨hdt, _⟩ exact Finset.sup'_le hS d hdt · constructor · intro hM1t have hMt : M < t := Nat.lt_of_succ_le hM1t refine ⟨fun y hy => le_of_lt (lt_of_le_of_lt (hle_M y hy) hMt), ?_⟩ have hemp : S.filter (fun y => t ≤ d y) = ∅ := by ext y simp only [Finset.mem_filter, Finset.notMem_empty, iff_false, not_and, not_le] intro hy; exact lt_of_le_of_lt (hle_M y hy) hMt rw [hemp, Finset.card_empty] exact Nat.zero_le m · intro ⟨hdt, hfc⟩ have hMt : M ≤ t := Finset.sup'_le hS d hdt by_cases heq : M = t · subst heq have hfeq : S.filter (fun y => M ≤ d y) = S.filter (fun y => d y = M) := by ext y simp only [Finset.mem_filter, and_congr_right_iff] intro hy exact ⟨fun h => le_antisymm (hle_M y hy) h, fun h => by rw [h]⟩ rw [hfeq] at hfc exact absurd hfc hcard · exact Nat.succ_le_of_lt (lt_of_le_of_ne hMt heq) lemma dlistStep_mono_d {β : Type*} [DecidableEq β] {m : ℕ} {S : Finset β} {d₁ d₂ : β → ℕ} (hd : ∀ y ∈ S, d₁ y ≤ d₂ y) : dlistStep m S d₁ ≤ dlistStep m S d₂ := by by_cases hS : S.Nonempty · rw [dlistStep_le_iff hS] have h2 := (dlistStep_le_iff (m := m) hS (d := d₂) (dlistStep m S d₂)).mp le_rfl refine ⟨fun y hy => le_trans (hd y hy) (h2.1 y hy), ?_⟩ refine le_trans (Finset.card_le_card ?_) h2.2 intro y hy rcases Finset.mem_filter.mp hy with ⟨hyS, hle⟩ exact Finset.mem_filter.mpr ⟨hyS, le_trans hle (hd y hyS)⟩ · simp [dlistStep, hS] lemma dlistStep_mono_S {β : Type*} [DecidableEq β] {m : ℕ} {S₁ S₂ : Finset β} (hS : S₁ ⊆ S₂) (d : β → ℕ) : dlistStep m S₁ d ≤ dlistStep m S₂ d := by by_cases h1 : S₁.Nonempty · have h2 : S₂.Nonempty := h1.mono hS rw [dlistStep_le_iff h1] have ht := (dlistStep_le_iff (m := m) h2 (d := d) (dlistStep m S₂ d)).mp le_rfl refine ⟨fun y hy => ht.1 y (hS hy), le_trans (Finset.card_le_card ?_) ht.2⟩ intro y hy rcases Finset.mem_filter.mp hy with ⟨hy1, hle⟩ exact Finset.mem_filter.mpr ⟨hS hy1, hle⟩ · simp [dlistStep, h1] lemma dlistStep_add_const {β : Type*} [DecidableEq β] {m : ℕ} {S : Finset β} (hS : S.Nonempty) (d : β → ℕ) (c : ℕ) : dlistStep m S (fun y => d y + c) = dlistStep m S d + c := by apply le_antisymm · rw [dlistStep_le_iff hS] have h := (dlistStep_le_iff (m := m) hS (d := d) (dlistStep m S d)).mp le_rfl refine ⟨fun y hy => Nat.add_le_add_right (h.1 y hy) c, ?_⟩ have hfeq : S.filter (fun y => dlistStep m S d + c ≤ d y + c) = S.filter (fun y => dlistStep m S d ≤ d y) := by ext y; simp rw [hfeq]; exact h.2 · have h := (dlistStep_le_iff (m := m) hS (d := fun y => d y + c) (dlistStep m S (fun y => d y + c))).mp le_rfl have hge_c : c ≤ dlistStep m S (fun y => d y + c) := by rcases hS with ⟨y0, hy0⟩ exact le_trans (Nat.le_add_left c (d y0)) (h.1 y0 hy0) have hle : dlistStep m S d ≤ dlistStep m S (fun y => d y + c) - c := by rw [dlistStep_le_iff hS] refine ⟨fun y hy => by have := h.1 y hy; omega, ?_⟩ have hfeq : S.filter (fun y => dlistStep m S (fun y => d y + c) - c ≤ d y) = S.filter (fun y => dlistStep m S (fun y => d y + c) ≤ d y + c) := by ext y; simp only [Finset.mem_filter, and_congr_right_iff]; intro _; omega rw [hfeq]; exact h.2 omega /-- **Deterministic `m`-List Littlestone Dimension** `Ldim m V` (Moran–Sharon–Tsubari–Yosebashvili, COLT 2023), defined by well-founded recursion on `V.card`. -/ def Ldim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) : ℕ := if V.card ≤ 1 then 0 else Finset.univ.sup fun x : α => if hsplit : 2 ≤ (labels V x).card then dlistStep m (labels V x) fun y => have _ : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y Ldim m (restrict V x y) else 0 termination_by V.card /-- **Randomized `μ`-List Littlestone Dimension** `RLdim μ V` for any real expected list budget `μ : ℝ`, defined by well-founded recursion on `V.card`. -/ noncomputable def RLdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (μ : ℝ) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else if hα : (Finset.univ : Finset α).Nonempty then Finset.univ.sup' hα fun x : α => if hsplit : 2 ≤ (labels V x).card then listVal μ (labels V x) fun y => have _ : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y RLdim μ (restrict V x y) else 0 else 0 termination_by V.card lemma Ldim_eq_zero_of_card_le_one {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) {V : Finset (α → β)} (hV : V.card ≤ 1) : Ldim m V = 0 := by rw [Ldim, if_pos hV] lemma RLdim_eq_zero_of_card_le_one {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (μ : ℝ) {V : Finset (α → β)} (hV : V.card ≤ 1) : RLdim μ V = 0 := by rw [RLdim, if_pos hV] lemma RLdim_nonneg {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (μ : ℝ) (V : Finset (α → β)) : 0 ≤ RLdim μ V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => rw [RLdim] split_ifs with hV hα · exact le_rfl · rcases hα with ⟨x0, hx0⟩ refine le_trans ?_ (Finset.le_sup' (f := fun x : α => if hsplit : 2 ≤ (labels V x).card then listVal μ (labels V x) fun y => RLdim μ (restrict V x y) else 0) hx0) split_ifs with hsplit · refine listVal_nonneg fun y _ => ?_ have hlt : (restrict V x0 y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl · exact le_rfl · exact le_rfl lemma RLdim_ge_listVal {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (μ : ℝ) (V : Finset (α → β)) (x : α) (hsplit : 2 ≤ (labels V x).card) : listVal μ (labels V x) (fun y => RLdim μ (restrict V x y)) ≤ RLdim μ V := by have hV_gt1 : ¬ V.card ≤ 1 := by have hle : (labels V x).card ≤ V.card := Finset.card_image_le omega have hα : (Finset.univ : Finset α).Nonempty := ⟨x, Finset.mem_univ x⟩ rw [RLdim, if_neg hV_gt1, dif_pos hα] have hle := Finset.le_sup' (f := fun x' : α => if h : 2 ≤ (labels V x').card then listVal μ (labels V x') fun y => RLdim μ (restrict V x' y) else 0) (Finset.mem_univ x) rw [dif_pos hsplit] at hle exact hle lemma RLdim_le_of_forall_x {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (μ : ℝ) (V : Finset (α → β)) {t : ℝ} (ht : 0 ≤ t) (hx : ∀ x : α, 2 ≤ (labels V x).card → listVal μ (labels V x) (fun y => RLdim μ (restrict V x y)) ≤ t) : RLdim μ V ≤ t := by rw [RLdim] split_ifs with hV hα · exact ht · refine Finset.sup'_le hα _ fun x _ => ?_ split_ifs with hsplit · exact hx x hsplit · exact ht · exact ht lemma Ldim_ge_dlistStep {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) (x : α) (hsplit : 2 ≤ (labels V x).card) : dlistStep m (labels V x) (fun y => Ldim m (restrict V x y)) ≤ Ldim m V := by have hV_gt1 : ¬ V.card ≤ 1 := by have hle : (labels V x).card ≤ V.card := Finset.card_image_le omega rw [Ldim, if_neg hV_gt1] have hle := Finset.le_sup (f := fun x' : α => if h : 2 ≤ (labels V x').card then dlistStep m (labels V x') fun y => Ldim m (restrict V x' y) else 0) (Finset.mem_univ x) simpa [dif_pos hsplit] using hle lemma Ldim_le_of_forall_x {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) {t : ℕ} (hx : ∀ x : α, 2 ≤ (labels V x).card → dlistStep m (labels V x) (fun y => Ldim m (restrict V x y)) ≤ t) : Ldim m V ≤ t := by rw [Ldim] split_ifs with hV · exact Nat.zero_le t · refine Finset.sup_le fun x _ => ?_ split_ifs with hsplit · exact hx x hsplit · exact Nat.zero_le t /-- Monotonicity of `RLdim μ V` in the concept class `V`. -/ theorem RLdim_mono {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ : ℝ} (hμ : 0 ≤ μ) {V₁ V₂ : Finset (α → β)} (hsub : V₁ ⊆ V₂) : RLdim μ V₁ ≤ RLdim μ V₂ := by induction hn : V₁.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => refine RLdim_le_of_forall_x μ V₁ (RLdim_nonneg μ V₂) fun x hsplit1 => ?_ have hlab_sub : labels V₁ x ⊆ labels V₂ x := Finset.image_subset_image hsub have hsplit2 : 2 ≤ (labels V₂ x).card := le_trans hsplit1 (Finset.card_le_card hlab_sub) calc listVal μ (labels V₁ x) (fun y => RLdim μ (restrict V₁ x y)) ≤ listVal μ (labels V₁ x) (fun y => RLdim μ (restrict V₂ x y)) := by refine listVal_mono_v hμ fun y _ => ?_ have hlt : (restrict V₁ x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit1 y exact ih _ hlt (Finset.filter_subset_filter _ hsub) rfl _ ≤ listVal μ (labels V₂ x) (fun y => RLdim μ (restrict V₂ x y)) := listVal_mono_S hμ hlab_sub fun y _ => RLdim_nonneg μ _ _ ≤ RLdim μ V₂ := RLdim_ge_listVal μ V₂ x hsplit2 /-- Monotonicity of `Ldim m V` in the concept class `V`. -/ theorem Ldim_mono {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) {V₁ V₂ : Finset (α → β)} (hsub : V₁ ⊆ V₂) : Ldim m V₁ ≤ Ldim m V₂ := by induction hn : V₁.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => refine Ldim_le_of_forall_x m V₁ fun x hsplit1 => ?_ have hlab_sub : labels V₁ x ⊆ labels V₂ x := Finset.image_subset_image hsub have hsplit2 : 2 ≤ (labels V₂ x).card := le_trans hsplit1 (Finset.card_le_card hlab_sub) calc dlistStep m (labels V₁ x) (fun y => Ldim m (restrict V₁ x y)) ≤ dlistStep m (labels V₁ x) (fun y => Ldim m (restrict V₂ x y)) := by refine dlistStep_mono_d fun y _ => ?_ have hlt : (restrict V₁ x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit1 y exact ih _ hlt (Finset.filter_subset_filter _ hsub) rfl _ ≤ dlistStep m (labels V₂ x) (fun y => Ldim m (restrict V₂ x y)) := dlistStep_mono_S hlab_sub _ _ ≤ Ldim m V₂ := Ldim_ge_dlistStep m V₂ x hsplit2 /-- Antitonicity of `RLdim μ V` in the list budget `μ`. -/ theorem RLdim_anti_mu {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ₁ μ₂ : ℝ} (hμ₁ : 0 ≤ μ₁) (hμ : μ₁ ≤ μ₂) (V : Finset (α → β)) : RLdim μ₂ V ≤ RLdim μ₁ V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => have hμ₂ : 0 ≤ μ₂ := le_trans hμ₁ hμ refine RLdim_le_of_forall_x μ₂ V (RLdim_nonneg μ₁ V) fun x hsplit => ?_ calc listVal μ₂ (labels V x) (fun y => RLdim μ₂ (restrict V x y)) ≤ listVal μ₂ (labels V x) (fun y => RLdim μ₁ (restrict V x y)) := by refine listVal_mono_v hμ₂ fun y _ => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl _ ≤ listVal μ₁ (labels V x) (fun y => RLdim μ₁ (restrict V x y)) := listVal_anti_mu hμ _ _ _ ≤ RLdim μ₁ V := RLdim_ge_listVal μ₁ V x hsplit /-- Zero-collapse: whenever `|V| ≤ μ`, `RLdim μ V = 0`. -/ theorem RLdim_eq_zero_of_card_le_mu {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ : ℝ} {V : Finset (α → β)} (hcard : (V.card : ℝ) ≤ μ) : RLdim μ V = 0 := by apply le_antisymm _ (RLdim_nonneg μ V) induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => refine RLdim_le_of_forall_x μ V le_rfl fun x hsplit => ?_ have hlab_ne : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hlab_le : ((labels V x).card : ℝ) ≤ μ := by have h1 : (labels V x).card ≤ V.card := Finset.card_image_le exact le_trans (by exact_mod_cast h1) hcard rw [listVal_eq_sup_of_card_le_mu hlab_ne hlab_le] refine Finset.sup'_le hlab_ne _ fun y _ => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y have hsub_le : ((restrict V x y).card : ℝ) ≤ μ := by have h1 : (restrict V x y).card ≤ V.card := Finset.card_le_card (restrict_subset V x y) exact le_trans (by exact_mod_cast h1) hcard exact ih _ hlt hsub_le rfl /-- Zero-collapse by label space size: whenever `|β| ≤ μ`, `RLdim μ V = 0`. -/ theorem RLdim_eq_zero_of_fintype_le_mu {α β : Type*} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] {μ : ℝ} (hβ : (Fintype.card β : ℝ) ≤ μ) (V : Finset (α → β)) : RLdim μ V = 0 := by apply le_antisymm _ (RLdim_nonneg μ V) induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => refine RLdim_le_of_forall_x μ V le_rfl fun x hsplit => ?_ have hlab_ne : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hlab_le : ((labels V x).card : ℝ) ≤ μ := le_trans (by exact_mod_cast Finset.card_le_univ (labels V x)) hβ rw [listVal_eq_sup_of_card_le_mu hlab_ne hlab_le] refine Finset.sup'_le hlab_ne _ fun y _ => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl /-- **Universal Upper Comparison (`RLdim m V ≤ Ldim m V`)** for every integer list size `m`. -/ theorem RLdim_le_Ldim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) : RLdim (m : ℝ) V ≤ (Ldim m V : ℝ) := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => refine RLdim_le_of_forall_x (m : ℝ) V (Nat.cast_nonneg _) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) set t : ℕ := dlistStep m (labels V x) (fun y => Ldim m (restrict V x y)) have ht_spec := (dlistStep_le_iff (m := m) hS (d := fun y => Ldim m (restrict V x y)) t).mp le_rfl have hle_t : listVal (m : ℝ) (labels V x) (fun y => RLdim (m : ℝ) (restrict V x y)) ≤ (t : ℝ) := by rw [listVal_le_iff (Nat.cast_nonneg m) hS] refine ⟨fun y hy => ?_, ?_⟩ · have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact le_trans (ih _ hlt _ rfl) (by exact_mod_cast ht_spec.1 y hy) · set H := (labels V x).filter (fun y => t ≤ Ldim m (restrict V x y)) calc ∑ y ∈ labels V x, max 0 (RLdim (m : ℝ) (restrict V x y) + 1 - (t : ℝ)) ≤ ∑ y ∈ labels V x, (if y ∈ H then (1 : ℝ) else 0) := by refine Finset.sum_le_sum fun y hy => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y have hih : RLdim (m : ℝ) (restrict V x y) ≤ (Ldim m (restrict V x y) : ℝ) := ih _ hlt _ rfl by_cases hyH : y ∈ H · rw [if_pos hyH] have hd : (Ldim m (restrict V x y) : ℝ) ≤ (t : ℝ) := by exact_mod_cast ht_spec.1 y hy exact max_le (by norm_num) (by linarith) · rw [if_neg hyH] have hlt_nat : Ldim m (restrict V x y) < t := by simp only [H, Finset.mem_filter, hy, true_and, not_le] at hyH exact hyH have hle_r : (Ldim m (restrict V x y) : ℝ) + 1 ≤ (t : ℝ) := by exact_mod_cast Nat.succ_le_of_lt hlt_nat exact max_le le_rfl (by linarith) _ = (H.card : ℝ) := by rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr (Finset.filter_subset _ _), Finset.sum_const, nsmul_eq_mul, mul_one] _ ≤ (m : ℝ) := by exact_mod_cast ht_spec.2 exact le_trans hle_t (by exact_mod_cast Ldim_ge_dlistStep m V x hsplit) /-- **Universal `1 / (m + 1)`-Factor Lower Comparison**: for EVERY finite concept class `V` and EVERY list size `m : ℕ`, `(Ldim m V : ℝ) / (m + 1) ≤ RLdim m V`. Generalizes Filmus–Hanneke–Mehalel–Moran (COLT 2023)'s `Ldim / 2 ≤ RLdim` to every list size `m`. -/ theorem Ldim_div_succ_le_RLdim {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) : (Ldim m V : ℝ) / ((m : ℝ) + 1) ≤ RLdim (m : ℝ) V := by have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => rw [div_le_iff₀ hm1_pos] by_cases hV : V.card ≤ 1 · rw [Ldim_eq_zero_of_card_le_one m hV, RLdim_eq_zero_of_card_le_one _ hV]; simp · have hle : ∀ x : α, (if hsplit : 2 ≤ (labels V x).card then (dlistStep m (labels V x) (fun y => Ldim m (restrict V x y)) : ℝ) else 0) ≤ RLdim (m : ℝ) V * ((m : ℝ) + 1) := by intro x split_ifs with hsplit · have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hih : ∀ y ∈ labels V x, (Ldim m (restrict V x y) : ℝ) / ((m : ℝ) + 1) ≤ RLdim (m : ℝ) (restrict V x y) := by intro y _ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl set M := (labels V x).sup' hS (fun y => Ldim m (restrict V x y)) have hM_le : (M : ℝ) / ((m : ℝ) + 1) ≤ RLdim (m : ℝ) V := by obtain ⟨y0, hy0, hy0_eq⟩ := Finset.exists_mem_eq_sup' hS (fun y => Ldim m (restrict V x y)) calc (M : ℝ) / ((m : ℝ) + 1) = (Ldim m (restrict V x y0) : ℝ) / ((m : ℝ) + 1) := by dsimp only [M]; rw [hy0_eq] _ ≤ RLdim (m : ℝ) (restrict V x y0) := hih y0 hy0 _ ≤ listVal (m : ℝ) (labels V x) (fun y => RLdim (m : ℝ) (restrict V x y)) := le_listVal_of_mem (v := fun y => RLdim (m : ℝ) (restrict V x y)) hy0 _ ≤ RLdim (m : ℝ) V := RLdim_ge_listVal (m : ℝ) V x hsplit rw [dlistStep, dif_pos hS] dsimp only split_ifs with hcard · exact (div_le_iff₀ hm1_pos).mp hM_le · -- More than `m` labels achieve `Ldim = M`: pick a subset `A` of size `m + 1`! have hcard' : ¬ ((labels V x).filter (fun y => Ldim m (restrict V x y) = M)).card ≤ m := hcard have hge : m + 1 ≤ ((labels V x).filter (fun y => Ldim m (restrict V x y) = M)).card := by omega obtain ⟨A, hAsub, hAcard⟩ := Finset.exists_subset_card_eq hge have hAS : A ⊆ labels V x := Subset.trans hAsub (Finset.filter_subset _ _) have hAne : A.Nonempty := Finset.card_pos.mp (by omega) have havg := le_trans (subset_avg_le_listVal (μ := (m : ℝ)) (v := fun y => RLdim (m : ℝ) (restrict V x y)) hAS hAne) (RLdim_ge_listVal (m : ℝ) V x hsplit) have hsum_A : ((m : ℝ) + 1) * ((M : ℝ) / ((m : ℝ) + 1) + 1) ≤ ∑ y ∈ A, (RLdim (m : ℝ) (restrict V x y) + 1) := by calc ((m : ℝ) + 1) * ((M : ℝ) / ((m : ℝ) + 1) + 1) = ∑ _y ∈ A, ((M : ℝ) / ((m : ℝ) + 1) + 1) := by rw [Finset.sum_const, hAcard, nsmul_eq_mul]; push_cast; rfl _ ≤ ∑ y ∈ A, (RLdim (m : ℝ) (restrict V x y) + 1) := by refine Finset.sum_le_sum fun y hy => ?_ have hyM : Ldim m (restrict V x y) = M := (Finset.mem_filter.mp (hAsub hy)).2 have := hih y (hAS hy) rw [hyM] at this linarith have hcard_r : (A.card : ℝ) = (m : ℝ) + 1 := by exact_mod_cast hAcard rw [hcard_r, div_le_iff₀ hm1_pos] at havg have hsimp : ((m : ℝ) + 1) * ((M : ℝ) / ((m : ℝ) + 1) + 1) - (m : ℝ) = (M : ℝ) + 1 := by field_simp [ne_of_gt hm1_pos]; ring change ((M + 1 : ℕ) : ℝ) ≤ RLdim (m : ℝ) V * ((m : ℝ) + 1) push_cast linarith · exact mul_nonneg (RLdim_nonneg (m : ℝ) V) (le_of_lt hm1_pos) have hnat : Ldim m V ≤ Finset.univ.sup (fun x : α => if hsplit : 2 ≤ (labels V x).card then dlistStep m (labels V x) (fun y => Ldim m (restrict V x y)) else 0) := by rw [Ldim, if_neg hV] have hcast_le : (Ldim m V : ℝ) ≤ RLdim (m : ℝ) V * ((m : ℝ) + 1) := by by_cases h0 : Ldim m V = 0 · rw [h0, Nat.cast_zero]; exact mul_nonneg (RLdim_nonneg (m : ℝ) V) (le_of_lt hm1_pos) · rw [Ldim, if_neg hV] at h0 ⊢ have hne : (Finset.univ : Finset α).Nonempty := by by_contra hemp rw [Finset.not_nonempty_iff_eq_empty.mp hemp, Finset.sup_empty] at h0 exact h0 rfl obtain ⟨x0, _, hx0⟩ := Finset.exists_mem_eq_sup Finset.univ hne (fun x : α => if hsplit : 2 ≤ (labels V x).card then dlistStep m (labels V x) (fun y => Ldim m (restrict V x y)) else 0) rw [hx0] have := hle x0 split_ifs at this ⊢ <;> simpa using this exact hcast_le /-! ## Part 4: Full Multi-Round Online `m`-List Game Minimax Theorem We formalize finite-horizon randomized `m`-list online learners (playing genuine probability distributions over `m`-element subsets of `β` at each round) and adaptive adversaries, construct the exact minimax-optimal randomized `m`-list learner via our Constructive Cyclic-Interval Dependent Rounding Theorem (`exists_mSubset_dist_of_sum_le`), and prove exact minimax equality with `RLdim (m : ℝ) V`. -/ /-- A finite probability distribution over `m`-element subsets of `β` (represented by a finite support `Fin n`, nonnegative weights summing to `1`, and subsets of size `≤ m`). -/ structure MListDist (β : Type*) (m : ℕ) where n : ℕ w : Fin n → ℝ L : Fin n → Finset β hw0 : ∀ t, 0 ≤ w t hw1 : ∑ t, w t = 1 hcard : ∀ t, (L t).card ≤ m /-- Marginal inclusion probability of label `y` under an `m`-list distribution `D`. -/ def MListDist.inclProb {β : Type*} [DecidableEq β] {m : ℕ} (D : MListDist β m) (y : β) : ℝ := ∑ t, if y ∈ D.L t then D.w t else 0 lemma MListDist.inclProb_nonneg {β : Type*} [DecidableEq β] {m : ℕ} (D : MListDist β m) (y : β) : 0 ≤ D.inclProb y := Finset.sum_nonneg fun t _ => by split_ifs; exact D.hw0 t; exact le_rfl lemma MListDist.inclProb_le_one {β : Type*} [DecidableEq β] {m : ℕ} (D : MListDist β m) (y : β) : D.inclProb y ≤ 1 := by calc D.inclProb y ≤ ∑ t, D.w t := Finset.sum_le_sum fun t _ => by split_ifs; exact le_rfl; exact D.hw0 t _ = 1 := D.hw1 lemma MListDist.sum_inclProb_le {β : Type*} [DecidableEq β] {m : ℕ} (D : MListDist β m) (S : Finset β) : ∑ y ∈ S, D.inclProb y ≤ (m : ℝ) := by calc ∑ y ∈ S, D.inclProb y = ∑ t : Fin D.n, ∑ y ∈ S, (if y ∈ D.L t then D.w t else 0) := Finset.sum_comm _ = ∑ t : Fin D.n, ((S ∩ D.L t).card : ℝ) * D.w t := by refine Finset.sum_congr rfl fun t _ => ?_ rw [Finset.sum_ite_mem, Finset.sum_const, nsmul_eq_mul] _ ≤ ∑ t : Fin D.n, (m : ℝ) * D.w t := by refine Finset.sum_le_sum fun t _ => ?_ have hle : (S ∩ D.L t).card ≤ m := le_trans (Finset.card_le_card Finset.inter_subset_right) (D.hcard t) exact mul_le_mul_of_nonneg_right (by exact_mod_cast hle) (D.hw0 t) _ = (m : ℝ) * ∑ t, D.w t := by rw [← Finset.mul_sum] _ = (m : ℝ) := by rw [D.hw1, mul_one] /-- A stateful randomized `m`-list online learner: given the current version space `V` and query point `x`, outputs a genuine probability distribution over `m`-element subsets of `β`. -/ def RandomizedListLearner (α β : Type*) (m : ℕ) := Finset (α → β) → α → MListDist β m /-- An adaptive realizable adversary: given a version space `V` with `V.card ≥ 2`, either stops (`none`) or presents a splitting query point `x` together with a probability distribution `ν` supported on `labels V x`. -/ structure AdaptiveListAdversary (α β : Type*) [DecidableEq β] where move : (V : Finset (α → β)) → Option { p : α × (β → ℝ) // 2 ≤ (labels V p.1).card ∧ (∀ y ∈ labels V p.1, 0 ≤ p.2 y) ∧ (∑ y ∈ labels V p.1, p.2 y = 1) } /-- Expected cumulative mistakes of randomized `m`-list learner `A` against adaptive adversary `Adv` starting from version space `V` (well-founded on `V.card`). -/ noncomputable def expectedListMistakes {α β : Type*} [DecidableEq β] {m : ℕ} (A : RandomizedListLearner α β m) (Adv : AdaptiveListAdversary α β) (V : Finset (α → β)) : ℝ := if V.card ≤ 1 then 0 else match Adv.move V with | none => 0 | some ⟨⟨x, ν⟩, hsplit, _, _⟩ => ∑ y ∈ labels V x, ν y * ((1 - (A V x).inclProb y) + have _ : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y expectedListMistakes A Adv (restrict V x y)) termination_by V.card /-- Constructive realization of any `listVal`-optimal marginal strategy on `S` as a genuine `MListDist β m` (using `S` directly when `|S| ≤ m`, and Cyclic-Interval Dependent Rounding when `m ≤ |S|`). -/ theorem exists_optMListDist {β : Type*} [DecidableEq β] (m : ℕ) {S : Finset β} (hS : S.Nonempty) (v : β → ℝ) : ∃ D : MListDist β m, ∀ y ∈ S, v y + (1 - D.inclProb y) ≤ listVal (m : ℝ) S v := by by_cases hSm : S.card ≤ m · refine ⟨⟨1, fun _ => 1, fun _ => S, fun _ => by norm_num, by simp, fun _ => hSm⟩, ?_⟩ intro y hy have hincl : (⟨1, fun _ => 1, fun _ => S, fun _ => by norm_num, by simp, fun _ => hSm⟩ : MListDist β m).inclProb y = 1 := by simp [MListDist.inclProb, hy] rw [hincl, sub_self, add_zero] exact le_listVal_of_mem hy · have hmS : m ≤ S.card := by omega obtain ⟨p, hp0, hp1, hpsum, hpval⟩ := listVal_primal_upper (Nat.cast_nonneg m) hS v obtain ⟨n, w, L, _, hw0, hw1, hL, hmarg⟩ := exists_mSubset_dist_of_sum_le hmS hp0 hp1 hpsum refine ⟨⟨n, w, L, hw0, hw1, fun t => le_of_eq (hL t).2⟩, ?_⟩ intro y hy have hle := hmarg y hy change p y ≤ (⟨n, w, L, hw0, hw1, fun t => le_of_eq (hL t).2⟩ : MListDist β m).inclProb y at hle linarith [hpval y hy] /-- The minimax-optimal randomized `m`-list online learner, constructed from `exists_optMListDist`. -/ noncomputable def optListLearner {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) : RandomizedListLearner α β m := fun V x => if hS : (labels V x).Nonempty then (exists_optMListDist m hS (fun y => RLdim (m : ℝ) (restrict V x y))).choose else ⟨1, fun _ => 1, fun _ => ∅, fun _ => by norm_num, by simp, fun _ => by simp⟩ /-- **Primal Online Minimax Upper Bound**: `optListLearner m` achieves expected mistakes at most `RLdim (m : ℝ) V` against EVERY adaptive realizable adversary `Adv`. -/ theorem optListLearner_expectedMistakes_le {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (Adv : AdaptiveListAdversary α β) (V : Finset (α → β)) : expectedListMistakes (optListLearner m) Adv V ≤ RLdim (m : ℝ) V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => rw [expectedListMistakes] split_ifs with hV · exact RLdim_nonneg _ _ · cases hmv : Adv.move V with | none => exact RLdim_nonneg _ _ | some s => rcases s with ⟨⟨x, ν⟩, hsplit, hν0, hν1⟩ dsimp only at hsplit hν0 hν1 have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) have hopt : ∀ y ∈ labels V x, RLdim (m : ℝ) (restrict V x y) + (1 - (optListLearner m V x).inclProb y) ≤ listVal (m : ℝ) (labels V x) (fun z => RLdim (m : ℝ) (restrict V x z)) := by intro y hy simp only [optListLearner, dif_pos hS] exact (exists_optMListDist m hS (fun z => RLdim (m : ℝ) (restrict V x z))).choose_spec y hy calc ∑ y ∈ labels V x, ν y * ((1 - (optListLearner m V x).inclProb y) + expectedListMistakes (optListLearner m) Adv (restrict V x y)) ≤ ∑ y ∈ labels V x, ν y * listVal (m : ℝ) (labels V x) (fun z => RLdim (m : ℝ) (restrict V x z)) := by refine Finset.sum_le_sum fun y hy => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y have hrec := ih _ hlt _ rfl have h1 := hopt y hy exact mul_le_mul_of_nonneg_left (by linarith) (hν0 y hy) _ = (∑ y ∈ labels V x, ν y) * listVal (m : ℝ) (labels V x) (fun z => RLdim (m : ℝ) (restrict V x z)) := by rw [← Finset.sum_mul] _ = listVal (m : ℝ) (labels V x) (fun z => RLdim (m : ℝ) (restrict V x z)) := by rw [hν1, one_mul] _ ≤ RLdim (m : ℝ) V := RLdim_ge_listVal (m : ℝ) V x hsplit /-- Auxiliary point selector for the minimax-optimal adaptive adversary. -/ noncomputable def optAdvScore {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) (x : α) : ℝ := if 2 ≤ (labels V x).card then listVal (m : ℝ) (labels V x) (fun y => RLdim (m : ℝ) (restrict V x y)) else 0 /-- The minimax-optimal adaptive adversary for randomized `m`-list online learning. -/ noncomputable def optListAdversary {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) : AdaptiveListAdversary α β where move V := if V.card ≤ 1 then none else if hα : (Finset.univ : Finset α).Nonempty then let x0 := (Finset.exists_mem_eq_sup' hα (optAdvScore m V)).choose if hsplit : 2 ≤ (labels V x0).card then let hS : (labels V x0).Nonempty := Finset.card_pos.mp (by omega) let hdual := listVal_dual_lower (μ := (m : ℝ)) hS (fun y => RLdim (m : ℝ) (restrict V x0 y)) some ⟨⟨x0, hdual.choose⟩, hsplit, hdual.choose_spec.1, hdual.choose_spec.2.1⟩ else none else none /-- **Dual Online Minimax Lower Bound**: EVERY randomized `m`-list online learner `A` suffers expected mistakes at least `RLdim (m : ℝ) V` against `optListAdversary m`. -/ theorem optListAdversary_expectedMistakes_ge {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (A : RandomizedListLearner α β m) (V : Finset (α → β)) : RLdim (m : ℝ) V ≤ expectedListMistakes A (optListAdversary m) V := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => rw [expectedListMistakes] by_cases hV : V.card ≤ 1 · rw [if_pos hV, RLdim_eq_zero_of_card_le_one _ hV] · rw [if_neg hV] by_cases hα : (Finset.univ : Finset α).Nonempty · set x0 := (Finset.exists_mem_eq_sup' hα (optAdvScore m V)).choose have hx0_eq : Finset.univ.sup' hα (optAdvScore m V) = optAdvScore m V x0 := (Finset.exists_mem_eq_sup' hα (optAdvScore m V)).choose_spec.2 have hRL_eq : RLdim (m : ℝ) V = optAdvScore m V x0 := by rw [RLdim, if_neg hV, dif_pos hα] exact hx0_eq by_cases hsplit : 2 ≤ (labels V x0).card · have hS : (labels V x0).Nonempty := Finset.card_pos.mp (by omega) set hdual := listVal_dual_lower (μ := (m : ℝ)) hS (fun y => RLdim (m : ℝ) (restrict V x0 y)) set ν := hdual.choose have hν0 : ∀ y ∈ labels V x0, 0 ≤ ν y := hdual.choose_spec.1 have hν_lb := hdual.choose_spec.2.2 have hmove : (optListAdversary m).move V = some ⟨⟨x0, ν⟩, hsplit, hν0, hdual.choose_spec.2.1⟩ := by dsimp only [optListAdversary] rw [if_neg hV, dif_pos hα] change (if h : 2 ≤ (labels V x0).card then _ else none) = _ rw [dif_pos hsplit] rw [hmove] dsimp only have hf_val : optAdvScore m V x0 = listVal (m : ℝ) (labels V x0) (fun y => RLdim (m : ℝ) (restrict V x0 y)) := by simp only [optAdvScore, if_pos hsplit] rw [hRL_eq, hf_val] calc listVal (m : ℝ) (labels V x0) (fun y => RLdim (m : ℝ) (restrict V x0 y)) ≤ ∑ y ∈ labels V x0, ν y * (RLdim (m : ℝ) (restrict V x0 y) + (1 - (A V x0).inclProb y)) := hν_lb (fun y => (A V x0).inclProb y) (fun y _ => (A V x0).inclProb_nonneg y) (fun y _ => (A V x0).inclProb_le_one y) ((A V x0).sum_inclProb_le (labels V x0)) _ ≤ ∑ y ∈ labels V x0, ν y * ((1 - (A V x0).inclProb y) + expectedListMistakes A (optListAdversary m) (restrict V x0 y)) := by refine Finset.sum_le_sum fun y hy => ?_ have hlt : (restrict V x0 y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y have hrec := ih _ hlt _ rfl exact mul_le_mul_of_nonneg_left (by linarith) (hν0 y hy) · have hmove : (optListAdversary m).move V = none := by dsimp only [optListAdversary] rw [if_neg hV, dif_pos hα] change (if h : 2 ≤ (labels V x0).card then _ else none) = none rw [dif_neg hsplit] rw [hmove, hRL_eq] simp [optAdvScore, hsplit] · have hmove : (optListAdversary m).move V = none := by dsimp only [optListAdversary] rw [if_neg hV, dif_neg hα] rw [hmove, RLdim, if_neg hV, dif_neg hα] /-- **Exact Online `m`-List Minimax Theorem**: `RLdim (m : ℝ) V` is the exact minimax optimal expected mistake bound of randomized `m`-list online learning for `V`, attained simultaneously by `optListLearner m` and `optListAdversary m`. -/ theorem online_list_minimax_exact {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (V : Finset (α → β)) : (∀ Adv : AdaptiveListAdversary α β, expectedListMistakes (optListLearner m) Adv V ≤ RLdim (m : ℝ) V) ∧ (∀ A : RandomizedListLearner α β m, RLdim (m : ℝ) V ≤ expectedListMistakes A (optListAdversary m) V) ∧ expectedListMistakes (optListLearner m) (optListAdversary m) V = RLdim (m : ℝ) V := by refine ⟨fun Adv => optListLearner_expectedMistakes_le m Adv V, fun A => optListAdversary_expectedMistakes_ge m A V, le_antisymm (optListLearner_expectedMistakes_le m _ V) (optListAdversary_expectedMistakes_ge m _ V)⟩ /-! ## Part 5: Universal Geometric Laws of the List-Size Curve `μ ↦ RLdim μ V` -/ /-- **Universal Convexity Theorem**: for EVERY finite concept class `V`, the function `μ ↦ RLdim μ V` is convex on `[0, ∞)`. -/ theorem RLdim_convex {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ₁ μ₂ t : ℝ} (hμ₁ : 0 ≤ μ₁) (hμ₂ : 0 ≤ μ₂) (ht0 : 0 ≤ t) (ht1 : t ≤ 1) (V : Finset (α → β)) : RLdim (t * μ₁ + (1 - t) * μ₂) V ≤ t * RLdim μ₁ V + (1 - t) * RLdim μ₂ V := by have hμ : 0 ≤ t * μ₁ + (1 - t) * μ₂ := by nlinarith induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => refine RLdim_le_of_forall_x _ V (by nlinarith [RLdim_nonneg μ₁ V, RLdim_nonneg μ₂ V]) fun x hsplit => ?_ calc listVal (t * μ₁ + (1 - t) * μ₂) (labels V x) (fun y => RLdim (t * μ₁ + (1 - t) * μ₂) (restrict V x y)) ≤ listVal (t * μ₁ + (1 - t) * μ₂) (labels V x) (fun y => t * RLdim μ₁ (restrict V x y) + (1 - t) * RLdim μ₂ (restrict V x y)) := by refine listVal_mono_v hμ fun y _ => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl _ ≤ t * listVal μ₁ (labels V x) (fun y => RLdim μ₁ (restrict V x y)) + (1 - t) * listVal μ₂ (labels V x) (fun y => RLdim μ₂ (restrict V x y)) := listVal_convex hμ₁ hμ₂ ht0 ht1 _ _ _ ≤ t * RLdim μ₁ V + (1 - t) * RLdim μ₂ V := by nlinarith [RLdim_ge_listVal μ₁ V x hsplit, RLdim_ge_listVal μ₂ V x hsplit] /-- **Integer Midpoint Convexity Corollary**: for every `m ≥ 1` and every finite class `V`, `RLdim m V ≤ (RLdim (m - 1) V + RLdim (m + 1) V) / 2` (contrasting with strict convexity failure of deterministic `Ldim m V`, proved in Part 8). -/ theorem RLdim_midpoint_convex {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] (m : ℕ) (hm : 1 ≤ m) (V : Finset (α → β)) : RLdim (m : ℝ) V ≤ (RLdim ((m - 1 : ℕ) : ℝ) V + RLdim ((m + 1 : ℕ) : ℝ) V) / 2 := by have hcast : ((1 / 2 : ℝ) * ((m - 1 : ℕ) : ℝ) + (1 - 1 / 2 : ℝ) * ((m + 1 : ℕ) : ℝ)) = (m : ℝ) := by have hsub : ((m - 1 : ℕ) : ℝ) = (m : ℝ) - 1 := by rw [Nat.cast_sub hm]; norm_num rw [hsub]; push_cast; ring have h := RLdim_convex (μ₁ := ((m - 1 : ℕ) : ℝ)) (μ₂ := ((m + 1 : ℕ) : ℝ)) (t := 1 / 2) (Nat.cast_nonneg _) (Nat.cast_nonneg _) (by norm_num) (by norm_num) V rw [hcast] at h linarith /-- **Exact `k`-Class Monotone Ratio Law**: for EVERY `k`-class concept class `V` (label set `|β| ≤ k`) and EVERY `0 ≤ μ₁ ≤ μ₂ ≤ k` with `μ₁ < k`, `RLdim μ₂ V ≤ ((k - μ₂) / (k - μ₁)) * RLdim μ₁ V`. -/ theorem RLdim_monotone_ratio_kClass {α β : Type*} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] {k : ℝ} (hβk : (Fintype.card β : ℝ) ≤ k) {μ₁ μ₂ : ℝ} (hμ₁ : 0 ≤ μ₁) (hμ12 : μ₁ ≤ μ₂) (hμ₂k : μ₂ ≤ k) (hμ₁k : μ₁ < k) (V : Finset (α → β)) : RLdim μ₂ V ≤ ((k - μ₂) / (k - μ₁)) * RLdim μ₁ V := by have hμ₂ : 0 ≤ μ₂ := le_trans hμ₁ hμ12 have hc0 : 0 ≤ (k - μ₂) / (k - μ₁) := div_nonneg (sub_nonneg.mpr hμ₂k) (le_of_lt (sub_pos.mpr hμ₁k)) induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => refine RLdim_le_of_forall_x μ₂ V (mul_nonneg hc0 (RLdim_nonneg μ₁ V)) fun x hsplit => ?_ have hSk : ((labels V x).card : ℝ) ≤ k := le_trans (by exact_mod_cast Finset.card_le_univ (labels V x)) hβk calc listVal μ₂ (labels V x) (fun y => RLdim μ₂ (restrict V x y)) ≤ listVal μ₂ (labels V x) (fun y => ((k - μ₂) / (k - μ₁)) * RLdim μ₁ (restrict V x y)) := by refine listVal_mono_v hμ₂ fun y _ => ?_ have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl _ ≤ ((k - μ₂) / (k - μ₁)) * listVal μ₁ (labels V x) (fun y => RLdim μ₁ (restrict V x y)) := listVal_ratio_le hμ₁ hμ12 hμ₂k hμ₁k hSk _ _ ≤ ((k - μ₂) / (k - μ₁)) * RLdim μ₁ V := mul_le_mul_of_nonneg_left (RLdim_ge_listVal μ₁ V x hsplit) hc0 /-! ## Part 6: Exact Sharp Super-Branching Cardinality / Halving Theorem -/ /-- **Universal Sharp Halving / Cardinality Theorem** (arbitrary label space `β`, even infinite!): If `C ≥ 0` satisfies `(1 - μ / r) / log r ≤ C` for every integer `r > μ`, then `RLdim μ V ≤ C * Real.log (V.card : ℝ)` for EVERY finite nonempty concept class `V`. -/ theorem RLdim_le_const_mul_log_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ C : ℝ} (hμ : 0 ≤ μ) (hC : 0 ≤ C) (hbound : ∀ r : ℕ, 1 ≤ r → (r : ℝ) - μ ≤ C * (r : ℝ) * Real.log (r : ℝ)) {V : Finset (α → β)} (hV : V.Nonempty) : RLdim μ V ≤ C * Real.log (V.card : ℝ) := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hlog_nn : 0 ≤ Real.log (V.card : ℝ) := Real.log_nonneg (by exact_mod_cast hV.card_pos) refine RLdim_le_of_forall_x μ V (mul_nonneg hC hlog_nn) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) calc listVal μ (labels V x) (fun y => RLdim μ (restrict V x y)) ≤ listVal μ (labels V x) (fun y => C * Real.log ((restrict V x y).card : ℝ)) := by refine listVal_mono_v hμ fun y hy => ?_ have hlt : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y have hne : (restrict V x y).Nonempty := (restrict_nonempty_iff V x y).mpr hy exact ih _ hlt hne rfl _ ≤ C * Real.log (V.card : ℝ) := by refine listVal_log_halving_step hμ hC hS (w := fun y => ((restrict V x y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x y).mpr hy).card_pos) (V.card : ℝ) ?_ (fun r hr1 _ => hbound r hr1) have hsum : ∑ y ∈ labels V x, ((restrict V x y).card : ℝ) = (V.card : ℝ) := by exact_mod_cast sum_card_restrict V x exact le_of_eq hsum /-- **`k`-Class Sharp Halving / Cardinality Theorem**: when `|β| ≤ k`, the condition only needs to hold for integers `1 ≤ r ≤ k`. -/ theorem RLdim_le_const_mul_log_card_kClass {α β : Type*} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] {μ C : ℝ} (hμ : 0 ≤ μ) (hC : 0 ≤ C) (hbound : ∀ r : ℕ, 1 ≤ r → r ≤ Fintype.card β → (r : ℝ) - μ ≤ C * (r : ℝ) * Real.log (r : ℝ)) {V : Finset (α → β)} (hV : V.Nonempty) : RLdim μ V ≤ C * Real.log (V.card : ℝ) := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => subst hn have hlog_nn : 0 ≤ Real.log (V.card : ℝ) := Real.log_nonneg (by exact_mod_cast hV.card_pos) refine RLdim_le_of_forall_x μ V (mul_nonneg hC hlog_nn) fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) calc listVal μ (labels V x) (fun y => RLdim μ (restrict V x y)) ≤ listVal μ (labels V x) (fun y => C * Real.log ((restrict V x y).card : ℝ)) := by refine listVal_mono_v hμ fun y hy => ?_ have hlt : (restrict V x y).card < V.card := card_restrict_lt_of_two_labels hsplit y have hne : (restrict V x y).Nonempty := (restrict_nonempty_iff V x y).mpr hy exact ih _ hlt hne rfl _ ≤ C * Real.log (V.card : ℝ) := by refine listVal_log_halving_step hμ hC hS (w := fun y => ((restrict V x y).card : ℝ)) (fun y hy => Nat.cast_pos.mpr ((restrict_nonempty_iff V x y).mpr hy).card_pos) (V.card : ℝ) ?_ (fun r hr1 hrS => hbound r hr1 (le_trans hrS (Finset.card_le_univ _))) have hsum : ∑ y ∈ labels V x, ((restrict V x y).card : ℝ) = (V.card : ℝ) := by exact_mod_cast sum_card_restrict V x exact le_of_eq hsum /-- Elementary monotonicity criterion for `f_μ(x) = (1 - μ / x) / log x`: if `x₀ ≥ μ > 0` and `μ * log x₀ ≤ x₀ - μ`, then `f_μ` is antitone on `[x₀, ∞)`. -/ lemma superBranch_antitone_tail {μ x₀ x : ℝ} (_hμ : 0 < μ) (hx₀_ge : μ ≤ x₀) (hx₀_gt1 : 1 < x₀) (hcrit : μ * Real.log x₀ ≤ x₀ - μ) (hx : x₀ ≤ x) : (1 - μ / x) / Real.log x ≤ (1 - μ / x₀) / Real.log x₀ := by have hx_gt1 : 1 < x := lt_of_lt_of_le hx₀_gt1 hx have hx₀_pos : 0 < x₀ := by linarith have hx_pos : 0 < x := by linarith have hlog0 : 0 < Real.log x₀ := Real.log_pos hx₀_gt1 have hlogx : 0 < Real.log x := Real.log_pos hx_gt1 -- Proof via `Real.log (x / x₀) ≤ x / x₀ - 1`: -- We need `(1 - μ/x) log x₀ ≤ (1 - μ/x₀) log x` -- `↔ (1 - μ/x) log x₀ ≤ (1 - μ/x₀) (log x₀ + log(x/x₀))` -- `↔ μ (1/x₀ - 1/x) log x₀ ≤ (1 - μ/x₀) log(x/x₀)`. --Wait: use the EXACT lower bound `log(x / x₀) ≥ 1 - x₀ / x` (from `log(x₀ / x) ≤ x₀ / x - 1`)! have hlog_ge : 1 - x₀ / x ≤ Real.log (x / x₀) := by have h1 := Real.log_le_sub_one_of_pos (div_pos hx₀_pos hx_pos) have h2 : Real.log (x₀ / x) = -Real.log (x / x₀) := by rw [Real.log_div (ne_of_gt hx₀_pos) (ne_of_gt hx_pos), Real.log_div (ne_of_gt hx_pos) (ne_of_gt hx₀_pos)] ring linarith have hlog_split : Real.log x = Real.log x₀ + Real.log (x / x₀) := by rw [Real.log_div (ne_of_gt hx_pos) (ne_of_gt hx₀_pos)]; ring rw [div_le_div_iff₀ hlogx hlog0, hlog_split] have h1m : 0 ≤ 1 - μ / x₀ := by rw [sub_nonneg, div_le_one hx₀_pos]; exact hx₀_ge have hstep1 : (1 - μ / x₀) * (1 - x₀ / x) ≤ (1 - μ / x₀) * Real.log (x / x₀) := mul_le_mul_of_nonneg_left hlog_ge h1m have hstep2 : (1 - μ / x) * Real.log x₀ - (1 - μ / x₀) * Real.log x₀ = (μ * Real.log x₀) * (1 / x₀ - 1 / x) := by ring have hstep3 : (1 - μ / x₀) * (1 - x₀ / x) = (x₀ - μ) * (1 / x₀ - 1 / x) := by field_simp [ne_of_gt hx₀_pos, ne_of_gt hx_pos] have hinv_nn : 0 ≤ 1 / x₀ - 1 / x := by rw [sub_nonneg] exact one_div_le_one_div_of_le hx₀_pos hx have hstep4 : (μ * Real.log x₀) * (1 / x₀ - 1 / x) ≤ (x₀ - μ) * (1 / x₀ - 1 / x) := mul_le_mul_of_nonneg_right hcrit hinv_nn linarith /-- **Universal Closed-Form Super-Branching Ceiling**: for EVERY `μ ≥ 1` and EVERY `x > 1`, `(1 - μ / x) / log x ≤ 1 / (1 + log μ)` (equivalently `x - μ ≤ (x * log x) / (1 + log μ)`). -/ theorem superBranch_universal_ceiling {μ x : ℝ} (hμ : 1 ≤ μ) (hx : 1 < x) : (1 - μ / x) / Real.log x ≤ 1 / (1 + Real.log μ) := by have hμ_pos : 0 < μ := by linarith have hx_pos : 0 < x := by linarith have hlogx : 0 < Real.log x := Real.log_pos hx have hlogμ : 0 ≤ Real.log μ := Real.log_nonneg hμ have hden_pos : 0 < 1 + Real.log μ := by linarith rw [div_le_div_iff₀ hlogx hden_pos, one_mul] -- Need: `(1 - μ / x) * (1 + log μ) ≤ log x`, i.e., `1 + log μ - μ(1 + log μ)/x ≤ log x`. -- Write `y = μ * (1 + log μ) / x > 0`. By `log y ≤ y - 1`: -- `log(μ(1 + log μ)) - log x ≤ μ(1 + log μ)/x - 1`, -- and `log(1 + log μ) ≥ 0` since `1 + log μ ≥ 1`! set y := μ * (1 + Real.log μ) / x have hy_pos : 0 < y := div_pos (mul_pos hμ_pos hden_pos) hx_pos have hlog_y : Real.log y ≤ y - 1 := Real.log_le_sub_one_of_pos hy_pos have hlog_expand : Real.log y = Real.log μ + Real.log (1 + Real.log μ) - Real.log x := by dsimp only [y] rw [Real.log_div (ne_of_gt (mul_pos hμ_pos hden_pos)) (ne_of_gt hx_pos), Real.log_mul (ne_of_gt hμ_pos) (ne_of_gt hden_pos)] have hlog1 : 0 ≤ Real.log (1 + Real.log μ) := Real.log_nonneg (by linarith) have hrew : (1 - μ / x) * (1 + Real.log μ) = 1 + Real.log μ - y := by dsimp only [y]; ring linarith /-- **Universal Closed-Form Cardinality Bound for ALL `μ ≥ 1` and ALL label spaces `β`**: `RLdim μ V ≤ Real.log |V| / (1 + Real.log μ)`. -/ theorem RLdim_le_log_card_div_one_add_log {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ : ℝ} (hμ : 1 ≤ μ) {V : Finset (α → β)} (hV : V.Nonempty) : RLdim μ V ≤ (1 / (1 + Real.log μ)) * Real.log (V.card : ℝ) := by have hlogμ : 0 ≤ Real.log μ := Real.log_nonneg hμ have hC : 0 ≤ 1 / (1 + Real.log μ) := div_nonneg (by norm_num) (by linarith) refine RLdim_le_const_mul_log_card (by linarith) hC (fun r hr1 => ?_) hV by_cases hr_eq1 : r = 1 · subst hr_eq1; simp; linarith · have hr2 : 2 ≤ r := by omega have hr_gt1 : (1 : ℝ) < (r : ℝ) := by exact_mod_cast (by omega : 1 < r) have hr_pos : (0 : ℝ) < (r : ℝ) := by linarith have hlogr : 0 < Real.log (r : ℝ) := Real.log_pos hr_gt1 have hceil := superBranch_universal_ceiling hμ hr_gt1 have hmul := (div_le_iff₀ hlogr).mp hceil have hmul2 := mul_le_mul_of_nonneg_left hmul (le_of_lt hr_pos) have hrew : (r : ℝ) * (1 - μ / (r : ℝ)) = (r : ℝ) - μ := by field_simp [ne_of_gt hr_pos] linarith /-- **Exact `m = 1` Multiclass Halving Theorem**: `r* = 2` is the unique global integer maximizer of `(1 - 1 / r) / log r`, giving `RLdim 1 V ≤ (1 / (2 * log 2)) * log |V| = (1/2) log₂ |V|` for EVERY finite concept class `V` over ANY label space `β` (zero dependence on `|β|`!). -/ theorem superBranch_m1_global_max (r : ℕ) (hr : 1 ≤ r) : (r : ℝ) - 1 ≤ (1 / (2 * Real.log 2)) * (r : ℝ) * Real.log (r : ℝ) := by by_cases hr1 : r = 1 · subst hr1; simp · have hr2 : 2 ≤ r := by omega have hr2_r : (2 : ℝ) ≤ (r : ℝ) := by exact_mod_cast hr2 have hcrit : (1 : ℝ) * Real.log 2 ≤ 2 - 1 := by have := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) linarith have htail := superBranch_antitone_tail (μ := 1) (x₀ := 2) (x := (r : ℝ)) (by norm_num) (by norm_num) (by norm_num) hcrit hr2_r have hlogr : 0 < Real.log (r : ℝ) := Real.log_pos (by linarith) have hr_pos : (0 : ℝ) < (r : ℝ) := by linarith have hstep := (div_le_iff₀ hlogr).mp htail have hrew_r : (1 - (1 : ℝ) / 2) / Real.log 2 = 1 / (2 * Real.log 2) := by ring rw [hrew_r] at hstep have hmul := mul_le_mul_of_nonneg_left hstep (le_of_lt hr_pos) have hrew : (r : ℝ) * (1 - 1 / (r : ℝ)) = (r : ℝ) - 1 := by field_simp [ne_of_gt hr_pos] linarith theorem RLdim_one_le_half_log2_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : RLdim 1 V ≤ (1 / (2 * Real.log 2)) * Real.log (V.card : ℝ) := RLdim_le_const_mul_log_card (by norm_num) (div_nonneg (by norm_num) (mul_nonneg (by norm_num) (le_of_lt (Real.log_pos (by norm_num))))) superBranch_m1_global_max hV /-- Helper: integer power comparison `a^p < b^q` implies `p * log a < q * log b`. -/ lemma mul_log_lt_mul_log_of_pow_lt {a b : ℝ} {p q : ℕ} (ha : 0 < a) (_hb : 0 < b) (hpow : a ^ p < b ^ q) : (p : ℝ) * Real.log a < (q : ℝ) * Real.log b := by have h := Real.log_lt_log (pow_pos ha p) hpow rwa [Real.log_pow, Real.log_pow] at h /-- **Super-Branching Phase Transition at `m = 2`**: `r* = 5` is the UNIQUE global integer maximizer of `(1 - 2 / r) / log r` over all `r ≥ 3`, strictly beating `r = 3` (ternary trees, by `> 22.8%`), `r = 4`, `r = 6`, and every `r ≥ 7`! -/ theorem superBranch_m2_global_max (r : ℕ) (hr : 1 ≤ r) : (r : ℝ) - 2 ≤ (3 / (5 * Real.log 5)) * (r : ℝ) * Real.log (r : ℝ) := by have hlog5 : 0 < Real.log 5 := Real.log_pos (by norm_num) have hC0 : 0 ≤ 3 / (5 * Real.log 5) := div_nonneg (by norm_num) (by positivity) by_cases h12 : r ≤ 2 · have hle0 : (r : ℝ) - 2 ≤ 0 := by have : (r : ℝ) ≤ 2 := by exact_mod_cast h12 linarith have hlogr : 0 ≤ Real.log (r : ℝ) := Real.log_nonneg (by exact_mod_cast hr) exact le_trans hle0 (mul_nonneg (mul_nonneg hC0 (Nat.cast_nonneg r)) hlogr) · by_cases hr3 : r = 3 · subst hr3 have hpow : (5 : ℝ) ^ 5 < (3 : ℝ) ^ 9 := by norm_num have hcmp := mul_log_lt_mul_log_of_pow_lt (by norm_num) (by norm_num) hpow push_cast at hcmp ⊢ have hmul : (3 - 2 : ℝ) * (5 * Real.log 5) ≤ 3 * 3 * Real.log 3 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 5 * Real.log 5)).mpr hmul calc (3 : ℝ) - 2 ≤ 3 * 3 * Real.log 3 / (5 * Real.log 5) := hdiv _ = 3 / (5 * Real.log 5) * 3 * Real.log 3 := by ring · by_cases hr4 : r = 4 · subst hr4 have hpow : (5 : ℝ) ^ 5 < (4 : ℝ) ^ 6 := by norm_num have hcmp := mul_log_lt_mul_log_of_pow_lt (by norm_num) (by norm_num) hpow push_cast at hcmp ⊢ have hmul : (4 - 2 : ℝ) * (5 * Real.log 5) ≤ 3 * 4 * Real.log 4 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 5 * Real.log 5)).mpr hmul calc (4 : ℝ) - 2 ≤ 3 * 4 * Real.log 4 / (5 * Real.log 5) := hdiv _ = 3 / (5 * Real.log 5) * 4 * Real.log 4 := by ring · by_cases hr5 : r = 5 · subst hr5; push_cast; field_simp [ne_of_gt hlog5]; ring_nf; exact le_rfl · have hr6 : 6 ≤ r := by omega have hr6_r : (6 : ℝ) ≤ (r : ℝ) := by exact_mod_cast hr6 have hcrit6 : (2 : ℝ) * Real.log 6 ≤ 6 - 2 := by have he : (2.718 : ℝ) < Real.exp 1 := by linarith [Real.exp_one_gt_d9] have hpow : (6 : ℝ) ^ 2 < (Real.exp 1) ^ 4 := by have h1 : (6 : ℝ) ^ 2 < (2.718 : ℝ) ^ 4 := by norm_num have h2 : (2.718 : ℝ) ^ 4 < (Real.exp 1) ^ 4 := by gcongr linarith have hlog_lt := Real.log_lt_log (by norm_num : (0 : ℝ) < 6 ^ 2) hpow rw [Real.log_pow, Real.log_pow, Real.log_exp] at hlog_lt push_cast at hlog_lt linarith have htail := superBranch_antitone_tail (μ := 2) (x₀ := 6) (x := (r : ℝ)) (by norm_num) (by norm_num) (by norm_num) hcrit6 hr6_r have h6_le_5 : (1 - (2 : ℝ) / 6) / Real.log 6 ≤ 3 / (5 * Real.log 5) := by have hlog6 : 0 < Real.log 6 := Real.log_pos (by norm_num) have hpow : (5 : ℝ) ^ 10 < (6 : ℝ) ^ 9 := by norm_num have hcmp := mul_log_lt_mul_log_of_pow_lt (by norm_num) (by norm_num) hpow rw [div_le_div_iff₀ hlog6 (by positivity)] push_cast at hcmp linarith have hcomb := le_trans htail h6_le_5 have hlogr : 0 < Real.log (r : ℝ) := Real.log_pos (by linarith) have hr_pos : (0 : ℝ) < (r : ℝ) := by linarith have hstep := (div_le_iff₀ hlogr).mp hcomb have hmul := mul_le_mul_of_nonneg_left hstep (le_of_lt hr_pos) have hrew : (r : ℝ) * (1 - 2 / (r : ℝ)) = (r : ℝ) - 2 := by field_simp [ne_of_gt hr_pos] linarith /-- **Exact Sharp `m = 2` Universal Halving Bound**: `RLdim 2 V ≤ (3 / (5 * log 5)) * log |V|` for EVERY finite nonempty concept class `V` over ANY label space `β`. -/ theorem RLdim_two_le_superBranch_log_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : RLdim 2 V ≤ (3 / (5 * Real.log 5)) * Real.log (V.card : ℝ) := RLdim_le_const_mul_log_card (by norm_num) (div_nonneg (by norm_num) (mul_nonneg (by norm_num) (le_of_lt (Real.log_pos (by norm_num))))) superBranch_m2_global_max hV /-- Strict separation: the `m = 2` super-branching constant `3 / (5 * log 5)` strictly exceeds the `(m + 1) = 3`-ary tree rate `1 / (3 * log 3)` by more than `22%` (`3/(5 ln 5) > (11/9)/(3 ln 3)`). -/ theorem superBranch_m2_beats_ternary_by_22pct : (11 / 9 : ℝ) * (1 / (3 * Real.log 3)) < 3 / (5 * Real.log 5) := by have hlog3 : 0 < Real.log 3 := Real.log_pos (by norm_num) have hlog5 : 0 < Real.log 5 := Real.log_pos (by norm_num) have hpow : (5 : ℝ) ^ 55 < (3 : ℝ) ^ 81 := by norm_num have hcmp := mul_log_lt_mul_log_of_pow_lt (by norm_num) (by norm_num) hpow have hrew : (11 / 9 : ℝ) * (1 / (3 * Real.log 3)) = 11 / (27 * Real.log 3) := by ring rw [hrew, div_lt_div_iff₀ (by positivity) (by positivity)] push_cast at hcmp linarith /-- **Exact `m = 3` Super-Branching Global Maximizer (`r* = 10`)**: `7 / (10 * log 10)` beats every integer `r ≥ 4` (and beats 4-ary trees `1 / (4 * log 4)` by `> 68%`!). -/ theorem superBranch_m3_global_max (r : ℕ) (hr : 1 ≤ r) : (r : ℝ) - 3 ≤ (7 / (10 * Real.log 10)) * (r : ℝ) * Real.log (r : ℝ) := by have hlog10 : 0 < Real.log 10 := Real.log_pos (by norm_num) have hC0 : 0 ≤ 7 / (10 * Real.log 10) := div_nonneg (by norm_num) (by positivity) by_cases h13 : r ≤ 3 · have hle0 : (r : ℝ) - 3 ≤ 0 := by have : (r : ℝ) ≤ 3 := by exact_mod_cast h13 linarith have hlogr : 0 ≤ Real.log (r : ℝ) := Real.log_nonneg (by exact_mod_cast hr) exact le_trans hle0 (mul_nonneg (mul_nonneg hC0 (Nat.cast_nonneg r)) hlogr) · by_cases hlt10 : r < 10 · have hcase : r = 4 ∨ r = 5 ∨ r = 6 ∨ r = 7 ∨ r = 8 ∨ r = 9 := by omega rcases hcase with rfl | rfl | rfl | rfl | rfl | rfl · have hcmp := mul_log_lt_mul_log_of_pow_lt (a := 10) (b := 4) (p := 10) (q := 28) (by norm_num) (by norm_num) (by norm_num) push_cast at hcmp ⊢ have hmul : (4 - 3 : ℝ) * (10 * Real.log 10) ≤ 7 * 4 * Real.log 4 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 10 * Real.log 10)).mpr hmul calc (4 : ℝ) - 3 ≤ 7 * 4 * Real.log 4 / (10 * Real.log 10) := hdiv _ = 7 / (10 * Real.log 10) * 4 * Real.log 4 := by ring · have hcmp := mul_log_lt_mul_log_of_pow_lt (a := 10) (b := 5) (p := 20) (q := 35) (by norm_num) (by norm_num) (by norm_num) push_cast at hcmp ⊢ have hmul : (5 - 3 : ℝ) * (10 * Real.log 10) ≤ 7 * 5 * Real.log 5 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 10 * Real.log 10)).mpr hmul calc (5 : ℝ) - 3 ≤ 7 * 5 * Real.log 5 / (10 * Real.log 10) := hdiv _ = 7 / (10 * Real.log 10) * 5 * Real.log 5 := by ring · have hcmp := mul_log_lt_mul_log_of_pow_lt (a := 10) (b := 6) (p := 30) (q := 42) (by norm_num) (by norm_num) (by norm_num) push_cast at hcmp ⊢ have hmul : (6 - 3 : ℝ) * (10 * Real.log 10) ≤ 7 * 6 * Real.log 6 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 10 * Real.log 10)).mpr hmul calc (6 : ℝ) - 3 ≤ 7 * 6 * Real.log 6 / (10 * Real.log 10) := hdiv _ = 7 / (10 * Real.log 10) * 6 * Real.log 6 := by ring · have hcmp := mul_log_lt_mul_log_of_pow_lt (a := 10) (b := 7) (p := 40) (q := 49) (by norm_num) (by norm_num) (by norm_num) push_cast at hcmp ⊢ have hmul : (7 - 3 : ℝ) * (10 * Real.log 10) ≤ 7 * 7 * Real.log 7 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 10 * Real.log 10)).mpr hmul calc (7 : ℝ) - 3 ≤ 7 * 7 * Real.log 7 / (10 * Real.log 10) := hdiv _ = 7 / (10 * Real.log 10) * 7 * Real.log 7 := by ring · have hcmp := mul_log_lt_mul_log_of_pow_lt (a := 10) (b := 8) (p := 50) (q := 56) (by norm_num) (by norm_num) (by norm_num) push_cast at hcmp ⊢ have hmul : (8 - 3 : ℝ) * (10 * Real.log 10) ≤ 7 * 8 * Real.log 8 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 10 * Real.log 10)).mpr hmul calc (8 : ℝ) - 3 ≤ 7 * 8 * Real.log 8 / (10 * Real.log 10) := hdiv _ = 7 / (10 * Real.log 10) * 8 * Real.log 8 := by ring · have hcmp := mul_log_lt_mul_log_of_pow_lt (a := 10) (b := 9) (p := 60) (q := 63) (by norm_num) (by norm_num) (by norm_num) push_cast at hcmp ⊢ have hmul : (9 - 3 : ℝ) * (10 * Real.log 10) ≤ 7 * 9 * Real.log 9 := by linarith have hdiv := (le_div_iff₀ (by positivity : (0 : ℝ) < 10 * Real.log 10)).mpr hmul calc (9 : ℝ) - 3 ≤ 7 * 9 * Real.log 9 / (10 * Real.log 10) := hdiv _ = 7 / (10 * Real.log 10) * 9 * Real.log 9 := by ring · have hr10 : (10 : ℝ) ≤ (r : ℝ) := by exact_mod_cast (by omega : 10 ≤ r) have hcrit10 : (3 : ℝ) * Real.log 10 ≤ 10 - 3 := by have he : (2.718 : ℝ) < Real.exp 1 := by linarith [Real.exp_one_gt_d9] have hpow : (10 : ℝ) ^ 3 < (Real.exp 1) ^ 7 := by have h1 : (10 : ℝ) ^ 3 < (2.718 : ℝ) ^ 7 := by norm_num have h2 : (2.718 : ℝ) ^ 7 < (Real.exp 1) ^ 7 := by gcongr linarith have hlog_lt := Real.log_lt_log (by norm_num : (0 : ℝ) < 10 ^ 3) hpow rw [Real.log_pow, Real.log_pow, Real.log_exp] at hlog_lt push_cast at hlog_lt linarith have htail := superBranch_antitone_tail (μ := 3) (x₀ := 10) (x := (r : ℝ)) (by norm_num) (by norm_num) (by norm_num) hcrit10 hr10 have hlogr : 0 < Real.log (r : ℝ) := Real.log_pos (by linarith) have hr_pos : (0 : ℝ) < (r : ℝ) := by linarith have hstep := (div_le_iff₀ hlogr).mp htail have hrew10 : (1 - (3 : ℝ) / 10) / Real.log 10 = 7 / (10 * Real.log 10) := by ring rw [hrew10] at hstep have hmul := mul_le_mul_of_nonneg_left hstep (le_of_lt hr_pos) have hrew : (r : ℝ) * (1 - 3 / (r : ℝ)) = (r : ℝ) - 3 := by field_simp [ne_of_gt hr_pos] linarith theorem RLdim_three_le_superBranch_log_card {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {V : Finset (α → β)} (hV : V.Nonempty) : RLdim 3 V ≤ (7 / (10 * Real.log 10)) * Real.log (V.card : ℝ) := RLdim_le_const_mul_log_card (by norm_num) (div_nonneg (by norm_num) (mul_nonneg (by norm_num) (le_of_lt (Real.log_pos (by norm_num))))) superBranch_m3_global_max hV /-- **Exact `(m + 1)`-Class Halving Theorem**: whenever `|β| ≤ m + 1` (generalizing binary classification `|β| = 2, m = 1`), `RLdim m V ≤ (1 / ((m + 1) * log (m + 1))) * log |V| = (1 / (m + 1)) * log_{m+1} |V|`. -/ theorem RLdim_m_le_log_card_succ_class {α β : Type*} [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] {m : ℕ} (hm : 1 ≤ m) (hβ : Fintype.card β ≤ m + 1) {V : Finset (α → β)} (hV : V.Nonempty) : RLdim (m : ℝ) V ≤ (1 / (((m : ℝ) + 1) * Real.log ((m : ℝ) + 1))) * Real.log (V.card : ℝ) := by have hm1_gt1 : (1 : ℝ) < (m : ℝ) + 1 := by have : (1 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm linarith have hlogm1 : 0 < Real.log ((m : ℝ) + 1) := Real.log_pos hm1_gt1 have hC : 0 ≤ 1 / (((m : ℝ) + 1) * Real.log ((m : ℝ) + 1)) := by positivity refine RLdim_le_const_mul_log_card_kClass (Nat.cast_nonneg m) hC (fun r hr1 hrβ => ?_) hV by_cases hrm : r ≤ m · have hle0 : (r : ℝ) - (m : ℝ) ≤ 0 := by have : (r : ℝ) ≤ (m : ℝ) := by exact_mod_cast hrm linarith have hlogr : 0 ≤ Real.log (r : ℝ) := Real.log_nonneg (by exact_mod_cast hr1) exact le_trans hle0 (mul_nonneg (mul_nonneg hC (Nat.cast_nonneg r)) hlogr) · have hreq : r = m + 1 := by omega subst hreq push_cast field_simp [ne_of_gt hlogm1, (by positivity : (m : ℝ) + 1 ≠ 0)] linarith /-! ## Part 7: Exact Structural Composition Calculus (Unions & Disjoint-Domain Products) -/ /-- Universal 1-step marginal strategy helper for `1 ≤ μ`: even when `|labels V x| ≤ 1`, a budget `μ ≥ 1` suffices to cover the unique label with probability `1` at zero mistake cost! -/ lemma exists_one_step_marginal {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ : ℝ} (hμ1 : 1 ≤ μ) (V : Finset (α → β)) (x : α) {S : Finset β} (hsub : labels V x ⊆ S) : ∃ p : β → ℝ, (∀ y ∈ S, 0 ≤ p y) ∧ (∀ y ∈ S, p y ≤ 1) ∧ (∑ y ∈ S, p y ≤ μ) ∧ (∀ y ∈ labels V x, RLdim μ (restrict V x y) + (1 - p y) ≤ RLdim μ V) := by have hμ0 : 0 ≤ μ := by linarith by_cases hsplit : 2 ≤ (labels V x).card · have hS1 : (labels V x).Nonempty := Finset.card_pos.mp (by omega) obtain ⟨q, hq0, hq1, hqsum, hqval⟩ := listVal_primal_upper hμ0 hS1 (fun y => RLdim μ (restrict V x y)) refine ⟨fun y => if y ∈ labels V x then q y else 0, ?_, ?_, ?_, ?_⟩ · intro y _; dsimp only; split_ifs with hy; exact hq0 y hy; exact le_rfl · intro y _; dsimp only; split_ifs with hy; exact hq1 y hy; norm_num · rw [Finset.sum_ite_mem, Finset.inter_eq_right.mpr hsub] exact hqsum · intro y hy dsimp only rw [if_pos hy] exact le_trans (hqval y hy) (RLdim_ge_listVal μ V x hsplit) · by_cases hne : (labels V x).Nonempty · have h1 : (labels V x).card = 1 := by have := hne.card_pos; omega obtain ⟨y₁, hy₁_eq⟩ := Finset.card_eq_one.mp h1 refine ⟨fun y => if y = y₁ then 1 else 0, ?_, ?_, ?_, ?_⟩ · intro y _; dsimp only; split_ifs <;> norm_num · intro y _; dsimp only; split_ifs <;> norm_num · have hy₁S : y₁ ∈ S := hsub (by rw [hy₁_eq]; simp) rw [Finset.sum_ite_eq' S y₁, if_pos hy₁S] exact hμ1 · intro y hy rw [hy₁_eq, Finset.mem_singleton] at hy rcases hy with rfl have hreq : restrict V x y = V := by ext h simp only [restrict, Finset.mem_filter, and_iff_left_iff_imp] intro hh have hmem : h x ∈ labels V x := Finset.mem_image.mpr ⟨h, hh, rfl⟩ rw [hy₁_eq, Finset.mem_singleton] at hmem exact hmem simp [hreq] · refine ⟨fun _ => 0, fun _ _ => le_rfl, fun _ _ => by norm_num, by simp [hμ0], ?_⟩ intro y hy; exact absurd ⟨y, hy⟩ hne /-- **List-Additive Union Theorem**: for EVERY `μ₁, μ₂ ≥ 1` and finite classes `V₁, V₂`, combining a `μ₁`-list learner for `V₁` and a `μ₂`-list learner for `V₂` into a `(μ₁ + μ₂)`-list learner for `V₁ ∪ V₂` incurs ZERO additive penalty: `RLdim (μ₁ + μ₂) (V₁ ∪ V₂) ≤ max (RLdim μ₁ V₁) (RLdim μ₂ V₂)`. -/ theorem RLdim_union_list_additive {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ₁ μ₂ : ℝ} (hμ₁ : 1 ≤ μ₁) (hμ₂ : 1 ≤ μ₂) (V₁ V₂ : Finset (α → β)) : RLdim (μ₁ + μ₂) (V₁ ∪ V₂) ≤ max (RLdim μ₁ V₁) (RLdim μ₂ V₂) := by have hμ₁0 : 0 ≤ μ₁ := by linarith have hμ₂0 : 0 ≤ μ₂ := by linarith have hμ12 : 0 ≤ μ₁ + μ₂ := by linarith induction hn : (V₁ ∪ V₂).card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => have hM_nn : 0 ≤ max (RLdim μ₁ V₁) (RLdim μ₂ V₂) := le_trans (RLdim_nonneg μ₁ V₁) (le_max_left _ _) refine RLdim_le_of_forall_x (μ₁ + μ₂) (V₁ ∪ V₂) hM_nn fun x hsplit => ?_ set S := labels (V₁ ∪ V₂) x have hS : S.Nonempty := Finset.card_pos.mp (by omega) have hSunion : S = labels V₁ x ∪ labels V₂ x := Finset.image_union _ _ have hsub1 : labels V₁ x ⊆ S := by rw [hSunion]; exact Finset.subset_union_left have hsub2 : labels V₂ x ⊆ S := by rw [hSunion]; exact Finset.subset_union_right obtain ⟨p₁, hp₁0, hp₁1, hp₁s, hp₁v⟩ := exists_one_step_marginal hμ₁ V₁ x hsub1 obtain ⟨p₂, hp₂0, hp₂1, hp₂s, hp₂v⟩ := exists_one_step_marginal hμ₂ V₂ x hsub2 set p : β → ℝ := fun y => min 1 (p₁ y + p₂ y) refine listVal_le_of_primal hμ12 hS (p := p) (fun y hy => le_min (by norm_num) (by linarith [hp₁0 y hy, hp₂0 y hy])) (fun y _ => min_le_left _ _) ?_ ?_ · calc ∑ y ∈ S, p y ≤ ∑ y ∈ S, (p₁ y + p₂ y) := Finset.sum_le_sum fun y _ => min_le_right _ _ _ = (∑ y ∈ S, p₁ y) + (∑ y ∈ S, p₂ y) := Finset.sum_add_distrib _ ≤ μ₁ + μ₂ := add_le_add hp₁s hp₂s · intro y hy have hlt : (restrict (V₁ ∪ V₂) x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y have hru : restrict (V₁ ∪ V₂) x y = restrict V₁ x y ∪ restrict V₂ x y := Finset.filter_union _ _ _ have hih : RLdim (μ₁ + μ₂) (restrict (V₁ ∪ V₂) x y) ≤ max (RLdim μ₁ (restrict V₁ x y)) (RLdim μ₂ (restrict V₂ x y)) := by rw [hru]; exact ih _ hlt _ _ (by rw [← hru]) have hp_ge1 : p₁ y ≤ p y := le_min (hp₁1 y hy) (by linarith [hp₂0 y hy]) have hp_ge2 : p₂ y ≤ p y := le_min (hp₂1 y hy) (by linarith [hp₁0 y hy]) rw [hSunion] at hy by_cases hy1 : y ∈ labels V₁ x · by_cases hy2 : y ∈ labels V₂ x · have h1 := hp₁v y hy1 have h2 := hp₂v y hy2 have hm : max (RLdim μ₁ (restrict V₁ x y)) (RLdim μ₂ (restrict V₂ x y)) + (1 - p y) ≤ max (RLdim μ₁ V₁) (RLdim μ₂ V₂) := by rw [← max_add_add_right] exact max_le (le_trans (by linarith) (le_max_left _ _)) (le_trans (by linarith) (le_max_right _ _)) linarith · have hemp2 : restrict V₂ x y = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro h hh exact hy2 (Finset.mem_image.mpr ⟨h, (Finset.mem_filter.mp hh).1, (Finset.mem_filter.mp hh).2⟩) have hrl2 : RLdim μ₂ (restrict V₂ x y) = 0 := by rw [hemp2]; exact RLdim_eq_zero_of_card_le_one _ (by simp) have h1 := hp₁v y hy1 have hmax_eq : max (RLdim μ₁ (restrict V₁ x y)) (RLdim μ₂ (restrict V₂ x y)) = RLdim μ₁ (restrict V₁ x y) := by rw [hrl2]; exact max_eq_left (RLdim_nonneg _ _) have hle1 : RLdim μ₁ V₁ ≤ max (RLdim μ₁ V₁) (RLdim μ₂ V₂) := le_max_left _ _ linarith · have hy2 : y ∈ labels V₂ x := by rcases Finset.mem_union.mp hy with h | h · exact absurd h hy1 · exact h have hemp1 : restrict V₁ x y = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro h hh exact hy1 (Finset.mem_image.mpr ⟨h, (Finset.mem_filter.mp hh).1, (Finset.mem_filter.mp hh).2⟩) have hrl1 : RLdim μ₁ (restrict V₁ x y) = 0 := by rw [hemp1]; exact RLdim_eq_zero_of_card_le_one _ (by simp) have h2 := hp₂v y hy2 have hmax_eq : max (RLdim μ₁ (restrict V₁ x y)) (RLdim μ₂ (restrict V₂ x y)) = RLdim μ₂ (restrict V₂ x y) := by rw [hrl1]; exact max_eq_right (RLdim_nonneg _ _) have hle2 : RLdim μ₂ V₂ ≤ max (RLdim μ₁ V₁) (RLdim μ₂ V₂) := le_max_right _ _ linarith /-- **Sharp Same-List `+ 1 / 2` Union Theorem**: for EVERY `μ ≥ 1` and EVERY two finite concept classes `V₁, V₂`, `RLdim μ (V₁ ∪ V₂) ≤ RLdim μ V₁ + RLdim μ V₂ + 1 / 2`. (Sharp for every integer `m ≥ 1`: attained when `|V₁| = |V₂| = m` on `2m` distinct labels.) -/ theorem RLdim_union_same_list_half {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] {μ : ℝ} (hμ1 : 1 ≤ μ) (V₁ V₂ : Finset (α → β)) : RLdim μ (V₁ ∪ V₂) ≤ RLdim μ V₁ + RLdim μ V₂ + 1 / 2 := by have hμ0 : 0 ≤ μ := by linarith induction hn : (V₁ ∪ V₂).card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => have hRHS_nn : 0 ≤ RLdim μ V₁ + RLdim μ V₂ + 1 / 2 := by linarith [RLdim_nonneg μ V₁, RLdim_nonneg μ V₂] refine RLdim_le_of_forall_x μ (V₁ ∪ V₂) hRHS_nn fun x hsplit => ?_ set S := labels (V₁ ∪ V₂) x have hS : S.Nonempty := Finset.card_pos.mp (by omega) have hSunion : S = labels V₁ x ∪ labels V₂ x := Finset.image_union _ _ have hsub1 : labels V₁ x ⊆ S := by rw [hSunion]; exact Finset.subset_union_left have hsub2 : labels V₂ x ⊆ S := by rw [hSunion]; exact Finset.subset_union_right obtain ⟨p₁, hp₁0, hp₁1, hp₁s, hp₁v⟩ := exists_one_step_marginal hμ1 V₁ x hsub1 obtain ⟨p₂, hp₂0, hp₂1, hp₂s, hp₂v⟩ := exists_one_step_marginal hμ1 V₂ x hsub2 set p : β → ℝ := fun y => (p₁ y + p₂ y) / 2 refine listVal_le_of_primal hμ0 hS (p := p) (fun y hy => by dsimp only [p]; linarith [hp₁0 y hy, hp₂0 y hy]) (fun y hy => by dsimp only [p]; linarith [hp₁1 y hy, hp₂1 y hy]) ?_ ?_ · calc ∑ y ∈ S, p y = ((∑ y ∈ S, p₁ y) + (∑ y ∈ S, p₂ y)) / 2 := by dsimp only [p]; rw [← Finset.sum_div, Finset.sum_add_distrib] _ ≤ μ := by linarith · intro y hy have hlt : (restrict (V₁ ∪ V₂) x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y have hru : restrict (V₁ ∪ V₂) x y = restrict V₁ x y ∪ restrict V₂ x y := Finset.filter_union _ _ _ rw [hSunion] at hy by_cases hy1 : y ∈ labels V₁ x · by_cases hy2 : y ∈ labels V₂ x · have hih : RLdim μ (restrict (V₁ ∪ V₂) x y) ≤ RLdim μ (restrict V₁ x y) + RLdim μ (restrict V₂ x y) + 1 / 2 := by rw [hru]; exact ih _ hlt _ _ (by rw [← hru]) have h1 := hp₁v y hy1 have h2 := hp₂v y hy2 have hp1_le := hp₁1 y (hsub1 hy1) have hp2_le := hp₂1 y (hsub2 hy2) dsimp only [p] linarith · have hemp2 : restrict V₂ x y = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro h hh exact hy2 (Finset.mem_image.mpr ⟨h, (Finset.mem_filter.mp hh).1, (Finset.mem_filter.mp hh).2⟩) have hreq : restrict (V₁ ∪ V₂) x y = restrict V₁ x y := by rw [hru, hemp2, Finset.union_empty] rw [hreq] have h1 := hp₁v y hy1 have hp1_le := hp₁1 y (hsub1 hy1) have hp2_nn := hp₂0 y (hsub1 hy1) have hrl2_nn := RLdim_nonneg μ V₂ dsimp only [p] linarith · have hy2 : y ∈ labels V₂ x := by rcases Finset.mem_union.mp hy with h | h · exact absurd h hy1 · exact h have hemp1 : restrict V₁ x y = ∅ := by rw [Finset.eq_empty_iff_forall_notMem] intro h hh exact hy1 (Finset.mem_image.mpr ⟨h, (Finset.mem_filter.mp hh).1, (Finset.mem_filter.mp hh).2⟩) have hreq : restrict (V₁ ∪ V₂) x y = restrict V₂ x y := by rw [hru, hemp1, Finset.empty_union] rw [hreq] have h2 := hp₂v y hy2 have hp2_le := hp₂1 y (hsub2 hy2) have hp1_nn := hp₁0 y (hsub2 hy2) have hrl1_nn := RLdim_nonneg μ V₁ dsimp only [p] linarith /-- Disjoint-domain Cartesian product of two concept classes `V₁` on `α₁` and `V₂` on `α₂`, living on the disjoint union domain `α₁ ⊕ α₂`. -/ def prodClass {α₁ α₂ β : Type*} [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) : Finset (α₁ ⊕ α₂ → β) := (V₁ ×ˢ V₂).image (fun p => Sum.elim p.1 p.2) lemma sum_elim_injective {α₁ α₂ β : Type*} : Function.Injective (fun p : (α₁ → β) × (α₂ → β) => Sum.elim p.1 p.2) := by intro ⟨f₁, g₁⟩ ⟨f₂, g₂⟩ heq apply Prod.ext · funext x; exact congrFun heq (Sum.inl x) · funext x; exact congrFun heq (Sum.inr x) lemma prodClass_card {α₁ α₂ β : Type*} [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) : (prodClass V₁ V₂).card = V₁.card * V₂.card := by rw [prodClass, Finset.card_image_of_injective _ sum_elim_injective, Finset.card_product] lemma labels_prodClass_inl {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) {V₂ : Finset (α₂ → β)} (hV₂ : V₂.Nonempty) (x : α₁) : labels (prodClass V₁ V₂) (Sum.inl x) = labels V₁ x := by ext y simp only [labels, prodClass, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨_, ⟨⟨f, g⟩, ⟨hf, _⟩, rfl⟩, rfl⟩ exact ⟨f, hf, rfl⟩ · rintro ⟨f, hf, rfl⟩ rcases hV₂ with ⟨g, hg⟩ exact ⟨Sum.elim f g, ⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, rfl⟩ lemma labels_prodClass_inr {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] {V₁ : Finset (α₁ → β)} (hV₁ : V₁.Nonempty) (V₂ : Finset (α₂ → β)) (x : α₂) : labels (prodClass V₁ V₂) (Sum.inr x) = labels V₂ x := by ext y simp only [labels, prodClass, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨_, ⟨⟨f, g⟩, ⟨_, hg⟩, rfl⟩, rfl⟩ exact ⟨g, hg, rfl⟩ · rintro ⟨g, hg, rfl⟩ rcases hV₁ with ⟨f, hf⟩ exact ⟨Sum.elim f g, ⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, rfl⟩ lemma restrict_prodClass_inl {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) (x : α₁) (y : β) : restrict (prodClass V₁ V₂) (Sum.inl x) y = prodClass (restrict V₁ x y) V₂ := by ext h simp only [restrict, prodClass, Finset.mem_filter, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hfx⟩ exact ⟨⟨f, g⟩, ⟨⟨hf, hfx⟩, hg⟩, rfl⟩ · rintro ⟨⟨f, g⟩, ⟨⟨hf, hfx⟩, hg⟩, rfl⟩ exact ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hfx⟩ lemma restrict_prodClass_inr {α₁ α₂ β : Type*} [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] (V₁ : Finset (α₁ → β)) (V₂ : Finset (α₂ → β)) (x : α₂) (y : β) : restrict (prodClass V₁ V₂) (Sum.inr x) y = prodClass V₁ (restrict V₂ x y) := by ext h simp only [restrict, prodClass, Finset.mem_filter, Finset.mem_image, Finset.mem_product] constructor · rintro ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hgx⟩ exact ⟨⟨f, g⟩, ⟨hf, ⟨hg, hgx⟩⟩, rfl⟩ · rintro ⟨⟨f, g⟩, ⟨hf, ⟨hg, hgx⟩⟩, rfl⟩ exact ⟨⟨⟨f, g⟩, ⟨hf, hg⟩, rfl⟩, hgx⟩ /-- **Exact Disjoint-Domain Product Additivity for `RLdim`**: for EVERY `μ ≥ 0` and nonempty finite concept classes `V₁, V₂`, `RLdim μ (prodClass V₁ V₂) = RLdim μ V₁ + RLdim μ V₂`. -/ theorem RLdim_prod_eq_add {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] {μ : ℝ} (hμ : 0 ≤ μ) {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : RLdim μ (prodClass V₁ V₂) = RLdim μ V₁ + RLdim μ V₂ := by induction hn : V₁.card + V₂.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => apply le_antisymm · refine RLdim_le_of_forall_x μ (prodClass V₁ V₂) (add_nonneg (RLdim_nonneg μ V₁) (RLdim_nonneg μ V₂)) fun x hsplit => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl V₁ hV₂ x₁] at hsplit ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₁ x₁, RLdim μ (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = RLdim μ (restrict V₁ x₁ y) + RLdim μ V₂ := by intro y hy rw [restrict_prodClass_inl] have hlt : (restrict V₁ x₁ y).card < V₁.card := card_restrict_lt_of_two_labels hsplit y exact ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [listVal_congr hcongr, listVal_add_const hμ hS] linarith [RLdim_ge_listVal μ V₁ x₁ hsplit] | inr x₂ => rw [labels_prodClass_inr hV₁ V₂ x₂] at hsplit ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hcongr : ∀ y ∈ labels V₂ x₂, RLdim μ (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = RLdim μ (restrict V₂ x₂ y) + RLdim μ V₁ := by intro y hy rw [restrict_prodClass_inr] have hlt : (restrict V₂ x₂ y).card < V₂.card := card_restrict_lt_of_two_labels hsplit y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rw [listVal_congr hcongr, listVal_add_const hμ hS] linarith [RLdim_ge_listVal μ V₂ x₂ hsplit] · -- Lower bound: by induction, either `V₁` splits (or `RLdim μ V₁ = 0`) and `V₂` splits (or `RLdim μ V₂ = 0`). by_cases h1 : ∃ x₁ : α₁, 2 ≤ (labels V₁ x₁).card · have hle1 : RLdim μ V₁ ≤ RLdim μ (prodClass V₁ V₂) - RLdim μ V₂ := by refine RLdim_le_of_forall_x μ V₁ ?_ fun x₁ hsplit1 => ?_ · -- First note `RLdim μ V₂ ≤ RLdim μ (prodClass V₁ V₂)`. have h2_le : RLdim μ V₂ ≤ RLdim μ (prodClass V₁ V₂) := by refine RLdim_le_of_forall_x μ V₂ (RLdim_nonneg _ _) fun x₂ hsplit2 => ?_ have hS2 : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rwa [labels_prodClass_inr hV₁ V₂ x₂] have hge := RLdim_ge_listVal μ (prodClass V₁ V₂) (Sum.inr x₂) hsp rw [labels_prodClass_inr hV₁ V₂ x₂] at hge have hcongr : ∀ y ∈ labels V₂ x₂, RLdim μ (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = RLdim μ (restrict V₂ x₂ y) + RLdim μ V₁ := by intro y hy rw [restrict_prodClass_inr] have hlt : (restrict V₂ x₂ y).card < V₂.card := card_restrict_lt_of_two_labels hsplit2 y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rw [listVal_congr hcongr, listVal_add_const hμ hS2] at hge linarith [RLdim_nonneg μ V₁] linarith · have hS1 : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inl x₁)).card := by rwa [labels_prodClass_inl V₁ hV₂ x₁] have hge := RLdim_ge_listVal μ (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl V₁ hV₂ x₁] at hge have hcongr : ∀ y ∈ labels V₁ x₁, RLdim μ (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) = RLdim μ (restrict V₁ x₁ y) + RLdim μ V₂ := by intro y hy rw [restrict_prodClass_inl] have hlt : (restrict V₁ x₁ y).card < V₁.card := card_restrict_lt_of_two_labels hsplit1 y exact ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl rw [listVal_congr hcongr, listVal_add_const hμ hS1] at hge linarith linarith · have hRL1 : RLdim μ V₁ = 0 := le_antisymm (RLdim_le_of_forall_x μ V₁ le_rfl fun x₁ hsp => absurd ⟨x₁, hsp⟩ h1) (RLdim_nonneg μ V₁) rw [hRL1, zero_add] refine RLdim_le_of_forall_x μ V₂ (RLdim_nonneg _ _) fun x₂ hsplit2 => ?_ have hS2 : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rwa [labels_prodClass_inr hV₁ V₂ x₂] have hge := RLdim_ge_listVal μ (prodClass V₁ V₂) (Sum.inr x₂) hsp rw [labels_prodClass_inr hV₁ V₂ x₂] at hge have hcongr : ∀ y ∈ labels V₂ x₂, RLdim μ (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) = RLdim μ (restrict V₂ x₂ y) := by intro y hy rw [restrict_prodClass_inr] have hlt : (restrict V₂ x₂ y).card < V₂.card := card_restrict_lt_of_two_labels hsplit2 y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl linarith rwa [listVal_congr hcongr] at hge /-- **Exact Disjoint-Domain Product Additivity for Deterministic `Ldim`**: `Ldim m (prodClass V₁ V₂) = Ldim m V₁ + Ldim m V₂`. -/ theorem Ldim_prod_eq_add {α₁ α₂ β : Type*} [Fintype α₁] [Fintype α₂] [DecidableEq α₁] [DecidableEq α₂] [DecidableEq β] [DecidableEq (α₁ ⊕ α₂ → β)] (m : ℕ) {V₁ : Finset (α₁ → β)} {V₂ : Finset (α₂ → β)} (hV₁ : V₁.Nonempty) (hV₂ : V₂.Nonempty) : Ldim m (prodClass V₁ V₂) = Ldim m V₁ + Ldim m V₂ := by induction hn : V₁.card + V₂.card using Nat.strong_induction_on generalizing V₁ V₂ with | h n ih => apply le_antisymm · refine Ldim_le_of_forall_x m (prodClass V₁ V₂) fun x hsplit => ?_ cases x with | inl x₁ => rw [labels_prodClass_inl V₁ hV₂ x₁] at hsplit ⊢ have hS : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hle_d : ∀ y ∈ labels V₁ x₁, Ldim m (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) ≤ Ldim m (restrict V₁ x₁ y) + Ldim m V₂ := by intro y hy rw [restrict_prodClass_inl] have hlt : (restrict V₁ x₁ y).card < V₁.card := card_restrict_lt_of_two_labels hsplit y exact le_of_eq (ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl) calc dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict (prodClass V₁ V₂) (Sum.inl x₁) y)) ≤ dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict V₁ x₁ y) + Ldim m V₂) := dlistStep_mono_d hle_d _ = dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict V₁ x₁ y)) + Ldim m V₂ := dlistStep_add_const hS _ _ _ ≤ Ldim m V₁ + Ldim m V₂ := Nat.add_le_add_right (Ldim_ge_dlistStep m V₁ x₁ hsplit) _ | inr x₂ => rw [labels_prodClass_inr hV₁ V₂ x₂] at hsplit ⊢ have hS : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hle_d : ∀ y ∈ labels V₂ x₂, Ldim m (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) ≤ Ldim m (restrict V₂ x₂ y) + Ldim m V₁ := by intro y hy rw [restrict_prodClass_inr] have hlt : (restrict V₂ x₂ y).card < V₂.card := card_restrict_lt_of_two_labels hsplit y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl omega calc dlistStep m (labels V₂ x₂) (fun y => Ldim m (restrict (prodClass V₁ V₂) (Sum.inr x₂) y)) ≤ dlistStep m (labels V₂ x₂) (fun y => Ldim m (restrict V₂ x₂ y) + Ldim m V₁) := dlistStep_mono_d hle_d _ = dlistStep m (labels V₂ x₂) (fun y => Ldim m (restrict V₂ x₂ y)) + Ldim m V₁ := dlistStep_add_const hS _ _ _ ≤ Ldim m V₂ + Ldim m V₁ := Nat.add_le_add_right (Ldim_ge_dlistStep m V₂ x₂ hsplit) _ _ = Ldim m V₁ + Ldim m V₂ := Nat.add_comm _ _ · have h2_le : Ldim m V₂ ≤ Ldim m (prodClass V₁ V₂) := by refine Ldim_le_of_forall_x m V₂ fun x₂ hsplit2 => ?_ have hS2 : (labels V₂ x₂).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inr x₂)).card := by rwa [labels_prodClass_inr hV₁ V₂ x₂] have hge := Ldim_ge_dlistStep m (prodClass V₁ V₂) (Sum.inr x₂) hsp rw [labels_prodClass_inr hV₁ V₂ x₂] at hge have hmono : ∀ y ∈ labels V₂ x₂, Ldim m (restrict V₂ x₂ y) ≤ Ldim m (restrict (prodClass V₁ V₂) (Sum.inr x₂) y) := by intro y hy rw [restrict_prodClass_inr] have hlt : (restrict V₂ x₂ y).card < V₂.card := card_restrict_lt_of_two_labels hsplit2 y have hrec := ih (V₁.card + (restrict V₂ x₂ y).card) (by omega) hV₁ ((restrict_nonempty_iff V₂ x₂ y).mpr hy) rfl omega exact le_trans (dlistStep_mono_d hmono) hge have h1_le : Ldim m V₁ ≤ Ldim m (prodClass V₁ V₂) - Ldim m V₂ := by refine Ldim_le_of_forall_x m V₁ fun x₁ hsplit1 => ?_ have hS1 : (labels V₁ x₁).Nonempty := Finset.card_pos.mp (by omega) have hsp : 2 ≤ (labels (prodClass V₁ V₂) (Sum.inl x₁)).card := by rwa [labels_prodClass_inl V₁ hV₂ x₁] have hge := Ldim_ge_dlistStep m (prodClass V₁ V₂) (Sum.inl x₁) hsp rw [labels_prodClass_inl V₁ hV₂ x₁] at hge have hmono : ∀ y ∈ labels V₁ x₁, Ldim m (restrict V₁ x₁ y) + Ldim m V₂ ≤ Ldim m (restrict (prodClass V₁ V₂) (Sum.inl x₁) y) := by intro y hy rw [restrict_prodClass_inl] have hlt : (restrict V₁ x₁ y).card < V₁.card := card_restrict_lt_of_two_labels hsplit1 y have hrec := ih ((restrict V₁ x₁ y).card + V₂.card) (by omega) ((restrict_nonempty_iff V₁ x₁ y).mpr hy) hV₂ rfl omega have hstep : dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict V₁ x₁ y)) + Ldim m V₂ ≤ Ldim m (prodClass V₁ V₂) := by calc dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict V₁ x₁ y)) + Ldim m V₂ = dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict V₁ x₁ y) + Ldim m V₂) := (dlistStep_add_const hS1 _ _).symm _ ≤ dlistStep m (labels V₁ x₁) (fun y => Ldim m (restrict (prodClass V₁ V₂) (Sum.inl x₁) y)) := dlistStep_mono_d hmono _ ≤ Ldim m (prodClass V₁ V₂) := hge omega omega /-! ## Part 8: Exact Extremizers, Deterministic Convexity Refutation, & Dual `(m + 1)`-Class Bifurcation -/ /-- The 1-point `r`-class concept class `Unit → Fin r` containing all `r` constant hypotheses. -/ def onePointClass (r : ℕ) : Finset (Unit → Fin r) := Finset.univ lemma onePointClass_card (r : ℕ) : (onePointClass r).card = r := by simp [onePointClass] lemma labels_onePointClass (r : ℕ) : labels (onePointClass r) () = Finset.univ := by ext y simp only [labels, onePointClass, Finset.mem_image, Finset.mem_univ, true_and, iff_true] exact ⟨fun _ => y, rfl⟩ lemma restrict_onePointClass_card (r : ℕ) (y : Fin r) : (restrict (onePointClass r) () y).card = 1 := by have heq : restrict (onePointClass r) () y = {fun _ => y} := by ext h simp only [restrict, onePointClass, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] exact ⟨fun hy => funext fun u => by cases u; exact hy, fun hh => by rw [hh]⟩ rw [heq, Finset.card_singleton] /-- Exact `RLdim` of the 1-point `r`-class problem (`r ≥ 2`, `μ ≥ 0`). -/ theorem RLdim_onePointClass {r : ℕ} (hr : 2 ≤ r) {μ : ℝ} (hμ : 0 ≤ μ) : RLdim μ (onePointClass r) = max 0 (1 - μ / (r : ℝ)) := by have hsplit : 2 ≤ (labels (onePointClass r) ()).card := by rw [labels_onePointClass, Finset.card_univ, Fintype.card_fin]; exact hr have hS : (labels (onePointClass r) ()).Nonempty := Finset.card_pos.mp (by omega) have hzero : ∀ y ∈ labels (onePointClass r) (), RLdim μ (restrict (onePointClass r) () y) = 0 := fun y _ => RLdim_eq_zero_of_card_le_one μ (by rw [restrict_onePointClass_card]) have hlv : listVal μ (labels (onePointClass r) ()) (fun y => RLdim μ (restrict (onePointClass r) () y)) = max 0 (1 - μ / (r : ℝ)) := by rw [listVal_congr hzero, listVal_const hμ hS 0, zero_add, labels_onePointClass, Finset.card_univ, Fintype.card_fin] apply le_antisymm · refine RLdim_le_of_forall_x μ (onePointClass r) (le_max_left _ _) fun x _ => ?_ cases x; rw [hlv] · rw [← hlv]; exact RLdim_ge_listVal μ (onePointClass r) () hsplit /-- Exact `Ldim` of the 1-point `r`-class problem (`r ≥ 2`). -/ theorem Ldim_onePointClass {r : ℕ} (hr : 2 ≤ r) (m : ℕ) : Ldim m (onePointClass r) = if r ≤ m then 0 else 1 := by have hsplit : 2 ≤ (labels (onePointClass r) ()).card := by rw [labels_onePointClass, Finset.card_univ, Fintype.card_fin]; exact hr have hS : (labels (onePointClass r) ()).Nonempty := Finset.card_pos.mp (by omega) have hstep : dlistStep m (labels (onePointClass r) ()) (fun y => Ldim m (restrict (onePointClass r) () y)) = if r ≤ m then 0 else 1 := by have hzero : ∀ y : Fin r, Ldim m (restrict (onePointClass r) () y) = 0 := fun y => Ldim_eq_zero_of_card_le_one m (by rw [restrict_onePointClass_card]) simp_rw [hzero] rw [dlistStep, dif_pos hS] dsimp only have hsup : (labels (onePointClass r) ()).sup' hS (fun _ => 0) = 0 := by apply le_antisymm (Finset.sup'_le hS _ fun _ _ => le_rfl) (Nat.zero_le _) rw [hsup] have hfilt : (labels (onePointClass r) ()).filter (fun _ => (0 : ℕ) = 0) = Finset.univ := by rw [labels_onePointClass]; ext y; simp rw [hfilt, Finset.card_univ, Fintype.card_fin] apply le_antisymm · refine Ldim_le_of_forall_x m (onePointClass r) fun x _ => ?_ cases x; rw [hstep] · rw [← hstep]; exact Ldim_ge_dlistStep m (onePointClass r) () hsplit /-- **Exact Sharpness of Same-List `+ 1 / 2` Union Bound**: for every integer `m ≥ 1`, there exist classes `V₁, V₂` with `RLdim m V₁ = 0`, `RLdim m V₂ = 0`, and `RLdim m (V₁ ∪ V₂) = 1 / 2 = RLdim m V₁ + RLdim m V₂ + 1 / 2`. -/ theorem RLdim_union_half_sharp {m : ℕ} (hm : 1 ≤ m) : ∃ V₁ V₂ : Finset (Unit → Fin (2 * m)), RLdim (m : ℝ) V₁ = 0 ∧ RLdim (m : ℝ) V₂ = 0 ∧ RLdim (m : ℝ) (V₁ ∪ V₂) = RLdim (m : ℝ) V₁ + RLdim (m : ℝ) V₂ + 1 / 2 := by set V₁ : Finset (Unit → Fin (2 * m)) := Finset.univ.filter (fun h => (h ()).val < m) set V₂ : Finset (Unit → Fin (2 * m)) := Finset.univ.filter (fun h => m ≤ (h ()).val) have hcard1 : V₁.card = m := by have hbij : V₁ = (Finset.univ : Finset (Fin m)).image (fun i => fun _ : Unit => (⟨i.val, by omega⟩ : Fin (2 * m))) := by ext h simp only [V₁, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image] constructor · intro hlt refine ⟨⟨(h ()).val, hlt⟩, ?_⟩ funext u; cases u; ext; rfl · rintro ⟨i, rfl⟩; exact i.isLt rw [hbij, Finset.card_image_of_injective] · simp · intro i j hij have := congrArg Fin.val (congrFun hij ()) exact Fin.ext this have hcard2 : V₂.card = m := by have hbij : V₂ = (Finset.univ : Finset (Fin m)).image (fun i => fun _ : Unit => (⟨m + i.val, by omega⟩ : Fin (2 * m))) := by ext h simp only [V₂, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_image] constructor · intro hge have hlt : (h ()).val - m < m := by have := (h ()).isLt; omega refine ⟨⟨(h ()).val - m, hlt⟩, ?_⟩ funext u; cases u; ext; change m + ((h ()).val - m) = (h ()).val; omega · rintro ⟨i, rfl⟩; dsimp; omega rw [hbij, Finset.card_image_of_injective] · simp · intro i j hij have := congrArg Fin.val (congrFun hij ()) dsimp at this exact Fin.ext (by omega) have hunion : V₁ ∪ V₂ = onePointClass (2 * m) := by ext h simp only [V₁, V₂, onePointClass, Finset.mem_union, Finset.mem_filter, Finset.mem_univ, true_and, iff_true] omega have hrl1 : RLdim (m : ℝ) V₁ = 0 := RLdim_eq_zero_of_card_le_mu (by rw [hcard1]) have hrl2 : RLdim (m : ℝ) V₂ = 0 := RLdim_eq_zero_of_card_le_mu (by rw [hcard2]) refine ⟨V₁, V₂, hrl1, hrl2, ?_⟩ rw [hunion, hrl1, hrl2, zero_add, zero_add, RLdim_onePointClass (by omega) (Nat.cast_nonneg m)] have hm_pos : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr hm have hcalc : (1 : ℝ) - (m : ℝ) / ((2 * m : ℕ) : ℝ) = 1 / 2 := by push_cast; field_simp [ne_of_gt hm_pos]; ring rw [hcalc] exact max_eq_right (by norm_num) /-- Recursive domain of the `d`-dimensional `r`-ary cube class `cubeClass r d`. -/ abbrev CubeDom : ℕ → Type | 0 => Empty | d + 1 => Unit ⊕ CubeDom d instance instFintypeCubeDom : ∀ d : ℕ, Fintype (CubeDom d) | 0 => inferInstanceAs (Fintype Empty) | d + 1 => @instFintypeSum Unit (CubeDom d) _ (instFintypeCubeDom d) instance instDecidableEqCubeDom : ∀ d : ℕ, DecidableEq (CubeDom d) | 0 => inferInstanceAs (DecidableEq Empty) | d + 1 => @instDecidableEqSum Unit (CubeDom d) _ (instDecidableEqCubeDom d) /-- The `d`-dimensional full `r`-ary cube concept class of cardinality `r ^ d`, built as the `d`-fold disjoint-domain product of `onePointClass r`. -/ def cubeClass (r : ℕ) : ∀ d : ℕ, Finset (CubeDom d → Fin r) | 0 => {Empty.elim} | d + 1 => prodClass (onePointClass r) (cubeClass r d) lemma cubeClass_card (r : ℕ) : ∀ d : ℕ, (cubeClass r d).card = r ^ d | 0 => by rw [cubeClass, Finset.card_singleton, pow_zero] | d + 1 => by rw [cubeClass, prodClass_card, onePointClass_card, cubeClass_card r d, pow_succ'] lemma cubeClass_nonempty {r : ℕ} (hr : 1 ≤ r) (d : ℕ) : (cubeClass r d).Nonempty := Finset.card_pos.mp (by rw [cubeClass_card]; exact pow_pos hr d) /-- Exact `RLdim` of the `d`-dimensional `r`-ary cube: `d * max 0 (1 - μ / r)`. -/ theorem RLdim_cubeClass {r : ℕ} (hr : 2 ≤ r) {μ : ℝ} (hμ : 0 ≤ μ) : ∀ d : ℕ, RLdim μ (cubeClass r d) = (d : ℝ) * max 0 (1 - μ / (r : ℝ)) | 0 => by rw [RLdim_eq_zero_of_card_le_one μ (by rw [cubeClass_card]; simp)] simp | d + 1 => by rw [cubeClass, RLdim_prod_eq_add hμ (Finset.card_pos.mp (by rw [onePointClass_card]; omega)) (cubeClass_nonempty (by omega) d), RLdim_onePointClass hr hμ, RLdim_cubeClass hr hμ d] push_cast; ring /-- Exact `Ldim` of the `d`-dimensional `r`-ary cube: `0` if `r ≤ m`, else `d`. -/ theorem Ldim_cubeClass {r : ℕ} (hr : 2 ≤ r) (m : ℕ) : ∀ d : ℕ, Ldim m (cubeClass r d) = if r ≤ m then 0 else d | 0 => by rw [Ldim_eq_zero_of_card_le_one m (by rw [cubeClass_card]; simp)] split_ifs <;> rfl | d + 1 => by rw [cubeClass, Ldim_prod_eq_add m (Finset.card_pos.mp (by rw [onePointClass_card]; omega)) (cubeClass_nonempty (by omega) d), Ldim_onePointClass hr m, Ldim_cubeClass hr m d] split_ifs <;> omega /-- **Exact Sharpness of `1 / (m + 1)`-Factor Law**: on `cubeClass (m + 1) d`, `Ldim m = d` and `RLdim m = d / (m + 1)`. -/ theorem Ldim_div_succ_sharp {m : ℕ} (hm : 1 ≤ m) (d : ℕ) : Ldim m (cubeClass (m + 1) d) = d ∧ RLdim (m : ℝ) (cubeClass (m + 1) d) = (d : ℝ) / ((m : ℝ) + 1) := by have hr : 2 ≤ m + 1 := by omega refine ⟨?_, ?_⟩ · rw [Ldim_cubeClass hr m d, if_neg (by omega)] · rw [RLdim_cubeClass hr (Nat.cast_nonneg m) d] have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hcalc : (1 : ℝ) - (m : ℝ) / ((m + 1 : ℕ) : ℝ) = 1 / ((m : ℝ) + 1) := by push_cast; field_simp [ne_of_gt hm1_pos]; ring rw [hcalc, max_eq_right (by positivity)] ring /-- **Exact Sharpness of the `k`-Class Monotone Ratio Law**: on `cubeClass k d`, `RLdim μ₂ = ((k - μ₂) / (k - μ₁)) * RLdim μ₁` with exact equality for every `0 ≤ μ₁ ≤ μ₂ ≤ k`. -/ theorem RLdim_monotone_ratio_sharp {k : ℕ} (hk : 2 ≤ k) {μ₁ μ₂ : ℝ} (hμ₁ : 0 ≤ μ₁) (hμ12 : μ₁ ≤ μ₂) (hμ₂k : μ₂ ≤ (k : ℝ)) (hμ₁k : μ₁ < (k : ℝ)) (d : ℕ) : RLdim μ₂ (cubeClass k d) = (((k : ℝ) - μ₂) / ((k : ℝ) - μ₁)) * RLdim μ₁ (cubeClass k d) := by have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr (by omega) have hμ₂ : 0 ≤ μ₂ := le_trans hμ₁ hμ12 rw [RLdim_cubeClass hk hμ₂ d, RLdim_cubeClass hk hμ₁ d] have h1 : 0 ≤ 1 - μ₁ / (k : ℝ) := by rw [sub_nonneg, div_le_one hk_pos]; linarith have h2 : 0 ≤ 1 - μ₂ / (k : ℝ) := by rw [sub_nonneg, div_le_one hk_pos]; linarith rw [max_eq_right h1, max_eq_right h2] have hden : (k : ℝ) - μ₁ ≠ 0 := ne_of_gt (sub_pos.mpr hμ₁k) field_simp [ne_of_gt hk_pos, hden] /-- **Exact Asymptotic Sharpness of Super-Branching Halving Constants**: for EVERY `r ≥ 2`, `0 ≤ μ ≤ r`, and EVERY depth `d ≥ 1`, `cubeClass r d` achieves EXACT equality `RLdim μ (cubeClass r d) = ((1 - μ / r) / Real.log r) * Real.log (cubeClass r d).card`! Instantiated at `r = 2` (`m = 1`), `r = 5` (`m = 2`), and `r = 10` (`m = 3`), this proves our global halving constants `1/(2 ln 2)`, `3/(5 ln 5)`, and `7/(10 ln 10)` are 100% unimprovable! -/ theorem superBranch_halving_sharp {r : ℕ} (hr : 2 ≤ r) {μ : ℝ} (hμ0 : 0 ≤ μ) (hμr : μ ≤ (r : ℝ)) (d : ℕ) : RLdim μ (cubeClass r d) = ((1 - μ / (r : ℝ)) / Real.log (r : ℝ)) * Real.log ((cubeClass r d).card : ℝ) := by have hr_pos : (0 : ℝ) < (r : ℝ) := Nat.cast_pos.mpr (by omega) have hlogr : 0 < Real.log (r : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < r)) rw [RLdim_cubeClass hr hμ0 d, cubeClass_card r d, Nat.cast_pow, Real.log_pow] have hnn : 0 ≤ 1 - μ / (r : ℝ) := by rw [sub_nonneg, div_le_one hr_pos]; exact hμr rw [max_eq_right hnn] field_simp [ne_of_gt hlogr] /-- **Deterministic Convexity Refutation**: in stark contrast to `RLdim_midpoint_convex`, deterministic `m ↦ Ldim m V` STRICTLY VIOLATES convexity on `cubeClass 4 d` for EVERY `d ≥ 1`! (`Ldim 2 = d`, `Ldim 3 = d`, `Ldim 4 = 0`, so `(Ldim 2 + Ldim 4) / 2 = d / 2 < d = Ldim 3`.) -/ theorem Ldim_not_convex {d : ℕ} (hd : 1 ≤ d) : Ldim 2 (cubeClass 4 d) = d ∧ Ldim 3 (cubeClass 4 d) = d ∧ Ldim 4 (cubeClass 4 d) = 0 ∧ ((Ldim 2 (cubeClass 4 d) : ℝ) + (Ldim 4 (cubeClass 4 d) : ℝ)) / 2 < (Ldim 3 (cubeClass 4 d) : ℝ) := by have h2 : Ldim 2 (cubeClass 4 d) = d := by rw [Ldim_cubeClass (by omega) 2 d, if_neg (by omega)] have h3 : Ldim 3 (cubeClass 4 d) = d := by rw [Ldim_cubeClass (by omega) 3 d, if_neg (by omega)] have h4 : Ldim 4 (cubeClass 4 d) = 0 := by rw [Ldim_cubeClass (by omega) 4 d, if_pos (by omega)] refine ⟨h2, h3, h4, ?_⟩ rw [h2, h3, h4] have hd_pos : (0 : ℝ) < (d : ℝ) := Nat.cast_pos.mpr hd push_cast linarith /-! ### Dual `(m + 1)`-Class Bifurcation: Singleton Family (`→ 1 / m`) vs. Comb Family (`→ 1`) At `m = 1` (binary), singletons and co-singletons coincide (`1 - 2^(-N) → 1`). For EVERY `m ≥ 2`, they bifurcate sharply while BOTH maintain exact `Ldim m = 1`: 1. `singletonSub m I`: `Ldim m = 1` and exact `RLdim m = (1 / m) * (1 - (m + 1)^(-N)) → 1 / m`. 2. `combClass m N`: `Ldim m = 1` and `1 - (m / (m + 1))^N ≤ RLdim m ≤ 1` (approaching `1`!). -/ /-- The `(m + 1)`-class singleton hypothesis supported at coordinate `i` with nonzero label `c`. -/ def singleHyp {N m : ℕ} (i : Fin N) (c : Fin (m + 1)) : Fin N → Fin (m + 1) := fun j => if j = i then c else 0 /-- The `(m + 1)`-class singleton family on active coordinate set `I ⊆ Fin N`. -/ def singletonSub {N : ℕ} (m : ℕ) (I : Finset (Fin N)) : Finset (Fin N → Fin (m + 1)) := insert (fun _ => 0) ((I ×ˢ (Finset.univ.filter (fun c : Fin (m + 1) => c ≠ 0))).image (fun p => singleHyp p.1 p.2)) lemma mem_singletonSub_iff {N m : ℕ} {I : Finset (Fin N)} {h : Fin N → Fin (m + 1)} : h ∈ singletonSub m I ↔ h = (fun _ => 0) ∨ ∃ i ∈ I, ∃ c : Fin (m + 1), c ≠ 0 ∧ h = singleHyp i c := by simp only [singletonSub, Finset.mem_insert, Finset.mem_image, Finset.mem_product, Finset.mem_filter, Finset.mem_univ, true_and, Prod.exists] constructor · rintro (rfl | ⟨i, c, ⟨hi, hc⟩, rfl⟩) · exact Or.inl rfl · exact Or.inr ⟨i, hi, c, hc, rfl⟩ · rintro (rfl | ⟨i, hi, c, hc, rfl⟩) · exact Or.inl rfl · exact Or.inr ⟨i, c, ⟨hi, hc⟩, rfl⟩ lemma labels_singletonSub_of_notMem {N m : ℕ} {I : Finset (Fin N)} {x : Fin N} (hx : x ∉ I) : labels (singletonSub m I) x = {0} := by ext y simp only [labels, Finset.mem_image, Finset.mem_singleton] constructor · rintro ⟨h, hh, rfl⟩ rcases mem_singletonSub_iff.mp hh with rfl | ⟨i, hi, c, _, rfl⟩ · rfl · have hne : x ≠ i := fun heq => hx (heq ▸ hi) simp [singleHyp, hne] · rintro rfl exact ⟨fun _ => 0, mem_singletonSub_iff.mpr (Or.inl rfl), rfl⟩ lemma labels_singletonSub_of_mem {N m : ℕ} {I : Finset (Fin N)} {x : Fin N} (hx : x ∈ I) : labels (singletonSub m I) x = Finset.univ := by ext y simp only [labels, Finset.mem_image, Finset.mem_univ, iff_true] by_cases hy : y = 0 · subst hy; exact ⟨fun _ => 0, mem_singletonSub_iff.mpr (Or.inl rfl), rfl⟩ · exact ⟨singleHyp x y, mem_singletonSub_iff.mpr (Or.inr ⟨x, hx, y, hy, rfl⟩), by simp [singleHyp]⟩ lemma restrict_singletonSub_zero {N m : ℕ} {I : Finset (Fin N)} {x : Fin N} : restrict (singletonSub m I) x 0 = singletonSub m (I.erase x) := by ext h simp only [restrict, Finset.mem_filter, mem_singletonSub_iff, Finset.mem_erase] constructor · rintro ⟨rfl | ⟨i, hi, c, hc, rfl⟩, hx0⟩ · exact Or.inl rfl · have hne : i ≠ x := by intro heq; subst heq; simp [singleHyp] at hx0; exact hc hx0 exact Or.inr ⟨i, ⟨hne, hi⟩, c, hc, rfl⟩ · rintro (rfl | ⟨i, ⟨hne, hi⟩, c, hc, rfl⟩) · exact ⟨Or.inl rfl, rfl⟩ · exact ⟨Or.inr ⟨i, hi, c, hc, rfl⟩, by simp [singleHyp, hne.symm]⟩ lemma restrict_singletonSub_nonzero {N m : ℕ} {I : Finset (Fin N)} {x : Fin N} (hx : x ∈ I) {c : Fin (m + 1)} (hc : c ≠ 0) : restrict (singletonSub m I) x c = {singleHyp x c} := by ext h simp only [restrict, Finset.mem_filter, mem_singletonSub_iff, Finset.mem_singleton] constructor · rintro ⟨rfl | ⟨i, hi, c', hc', rfl⟩, hxc⟩ · exact absurd hxc.symm hc · by_cases hxi : x = i · subst hxi; simp [singleHyp] at hxc; subst hxc; rfl · simp [singleHyp, hxi] at hxc; exact absurd hxc.symm hc · rintro rfl exact ⟨Or.inr ⟨x, hx, c, hc, rfl⟩, by simp [singleHyp]⟩ /-- Helper evaluating `listVal m` on `Fin (m + 1)` with value `a ∈ [0, 1 / m]` at `0` and `0` elsewhere. -/ lemma listVal_singleton_branch {m : ℕ} (hm : 1 ≤ m) {a : ℝ} (ha0 : 0 ≤ a) (ha1 : a ≤ 1 / (m : ℝ)) : listVal (m : ℝ) (Finset.univ : Finset (Fin (m + 1))) (fun y => if y = 0 then a else 0) = (a + 1) / ((m : ℝ) + 1) := by have hS : (Finset.univ : Finset (Fin (m + 1))).Nonempty := ⟨0, Finset.mem_univ 0⟩ have hm_pos : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr hm have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hm1 : (1 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm have ham : a * (m : ℝ) ≤ 1 := (le_div_iff₀ hm_pos).mp ha1 have ha_le1 : a ≤ 1 := by nlinarith set t := (a + 1) / ((m : ℝ) + 1) have ht_ge_a : a ≤ t := by dsimp only [t]; rw [le_div_iff₀ hm1_pos] nlinarith have ht_ge_0 : 0 ≤ t := le_trans ha0 ht_ge_a have ht_le_1 : t ≤ 1 := by dsimp only [t]; rw [div_le_one hm1_pos] linarith apply le_antisymm · rw [listVal_le_iff (Nat.cast_nonneg m) hS] refine ⟨fun y _ => by split_ifs; exact ht_ge_a; exact ht_ge_0, ?_⟩ have hsplit : ∑ y : Fin (m + 1), max 0 ((if y = 0 then a else 0) + 1 - t) = (a + 1 - t) + (m : ℝ) * (1 - t) := by have hterm : ∀ y : Fin (m + 1), max 0 ((if y = 0 then a else 0) + 1 - t) = if y = 0 then a + 1 - t else 1 - t := by intro y by_cases hy0 : y = 0 · subst hy0; simp only [↓reduceIte]; exact max_eq_right (by linarith) · simp only [if_neg hy0, zero_add]; exact max_eq_right (by linarith) simp_rw [hterm] rw [Finset.sum_ite, Finset.filter_eq' Finset.univ 0, if_pos (Finset.mem_univ 0), Finset.sum_singleton, Finset.sum_const, nsmul_eq_mul] have hcard : (Finset.univ.filter (fun y : Fin (m + 1) => y ≠ 0)).card = m := by have h1 : Finset.univ.filter (fun y : Fin (m + 1) => y ≠ 0) = Finset.univ.erase 0 := by ext y; simp rw [h1, Finset.card_erase_of_mem (Finset.mem_univ 0), Finset.card_univ, Fintype.card_fin] omega rw [hcard] rw [hsplit] dsimp only [t] have hident : a + 1 - (a + 1) / ((m : ℝ) + 1) + (m : ℝ) * (1 - (a + 1) / ((m : ℝ) + 1)) = (m : ℝ) := by field_simp [ne_of_gt hm1_pos]; ring linarith · have havg := subset_avg_le_listVal (μ := (m : ℝ)) (S := (Finset.univ : Finset (Fin (m + 1)))) (A := Finset.univ) (v := fun y => if y = 0 then a else 0) Subset.rfl hS have hsum : ∑ y : Fin (m + 1), ((if y = 0 then a else 0) + 1) = a + ((m : ℝ) + 1) := by rw [Finset.sum_add_distrib, Finset.sum_ite_eq' Finset.univ 0, if_pos (Finset.mem_univ 0), Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] push_cast; rfl rw [hsum, Finset.card_univ, Fintype.card_fin] at havg have hrew : (a + ((m : ℝ) + 1) - (m : ℝ)) / ((m + 1 : ℕ) : ℝ) = t := by dsimp only [t]; push_cast; ring rwa [hrew] at havg /-- **Exact `Ldim` and `RLdim` of the `(m + 1)`-Class Singleton Family**: for EVERY `m ≥ 1` and `I ⊆ Fin N`: - `Ldim m (singletonSub m I) = if I.Nonempty then 1 else 0`, - `RLdim m (singletonSub m I) = (1 / m) * (1 - (1 / (m + 1)) ^ |I|)` (converging to `1 / m`!). -/ theorem singletonSub_exact {N m : ℕ} (hm : 1 ≤ m) (I : Finset (Fin N)) : Ldim m (singletonSub m I) = (if I.Nonempty then 1 else 0) ∧ RLdim (m : ℝ) (singletonSub m I) = (1 / (m : ℝ)) * (1 - (1 / ((m : ℝ) + 1)) ^ I.card) := by induction hk : I.card using Nat.strong_induction_on generalizing I with | h k ih => subst hk by_cases hI : I.Nonempty · have hm_pos : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr hm have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hcard_pos : 1 ≤ I.card := hI.card_pos have hrec : ∀ x ∈ I, Ldim m (singletonSub m (I.erase x)) ≤ 1 ∧ RLdim (m : ℝ) (singletonSub m (I.erase x)) = (1 / (m : ℝ)) * (1 - (1 / ((m : ℝ) + 1)) ^ (I.card - 1)) := by intro x hx have hlt : (I.erase x).card < I.card := by rw [Finset.card_erase_of_mem hx]; omega have h := ih _ hlt (I.erase x) rfl rw [Finset.card_erase_of_mem hx] at h exact ⟨by rw [h.1]; split_ifs <;> omega, h.2⟩ -- Part 1: exact `Ldim = 1` have hL_le : Ldim m (singletonSub m I) ≤ 1 := by refine Ldim_le_of_forall_x m (singletonSub m I) fun x hsplit => ?_ have hxI : x ∈ I := by by_contra hnot rw [labels_singletonSub_of_notMem hnot, Finset.card_singleton] at hsplit; omega have hS : (labels (singletonSub m I) x).Nonempty := Finset.card_pos.mp (by omega) rw [dlistStep_le_iff hS] refine ⟨fun y _ => ?_, ?_⟩ · by_cases hy0 : y = 0 · subst hy0; rw [restrict_singletonSub_zero]; exact (hrec x hxI).1 · rw [restrict_singletonSub_nonzero hxI hy0, Ldim_eq_zero_of_card_le_one m (by simp)] exact Nat.zero_le 1 · have hsub : (labels (singletonSub m I) x).filter (fun y => 1 ≤ Ldim m (restrict (singletonSub m I) x y)) ⊆ {0} := by intro y hy have hy_ge := (Finset.mem_filter.mp hy).2 by_contra hy0 rw [Finset.mem_singleton] at hy0 rw [restrict_singletonSub_nonzero hxI hy0, Ldim_eq_zero_of_card_le_one m (by simp)] at hy_ge omega exact le_trans (Finset.card_le_card hsub) (by simp [hm]) have hL_ge : 1 ≤ Ldim m (singletonSub m I) := by rcases hI with ⟨x0, hx0⟩ have hsplit : 2 ≤ (labels (singletonSub m I) x0).card := by rw [labels_singletonSub_of_mem hx0, Finset.card_univ, Fintype.card_fin]; omega have hS : (labels (singletonSub m I) x0).Nonempty := Finset.card_pos.mp (by omega) have hge := Ldim_ge_dlistStep m (singletonSub m I) x0 hsplit by_contra hlt have hle0 : dlistStep m (labels (singletonSub m I) x0) (fun y => Ldim m (restrict (singletonSub m I) x0 y)) ≤ 0 := by omega have hspec := (dlistStep_le_iff hS 0).mp hle0 have hfilt : (labels (singletonSub m I) x0).filter (fun y => 0 ≤ Ldim m (restrict (singletonSub m I) x0 y)) = Finset.univ := by rw [labels_singletonSub_of_mem hx0]; ext y; simp have hc := hspec.2 rw [hfilt, Finset.card_univ, Fintype.card_fin] at hc omega -- Part 2: exact `RLdim` set a := (1 / (m : ℝ)) * (1 - (1 / ((m : ℝ) + 1)) ^ (I.card - 1)) have ha0 : 0 ≤ a := by dsimp only [a] have hpow_le : (1 / ((m : ℝ) + 1)) ^ (I.card - 1) ≤ 1 := pow_le_one₀ (by positivity) (by rw [div_le_one hm1_pos]; linarith) exact mul_nonneg (by positivity) (by linarith) have ha1 : a ≤ 1 / (m : ℝ) := by dsimp only [a] have hpow_nn : 0 ≤ (1 / ((m : ℝ) + 1)) ^ (I.card - 1) := by positivity have hinv_nn : 0 ≤ 1 / (m : ℝ) := by positivity nlinarith have hstep_val : (a + 1) / ((m : ℝ) + 1) = (1 / (m : ℝ)) * (1 - (1 / ((m : ℝ) + 1)) ^ I.card) := by dsimp only [a] have hpow : (1 / ((m : ℝ) + 1)) ^ I.card = (1 / ((m : ℝ) + 1)) ^ (I.card - 1) * (1 / ((m : ℝ) + 1)) := by rw [← pow_succ, Nat.sub_add_cancel hcard_pos] rw [hpow] field_simp [ne_of_gt hm_pos, ne_of_gt hm1_pos] ring have hlv_eq : ∀ x ∈ I, listVal (m : ℝ) (labels (singletonSub m I) x) (fun y => RLdim (m : ℝ) (restrict (singletonSub m I) x y)) = (1 / (m : ℝ)) * (1 - (1 / ((m : ℝ) + 1)) ^ I.card) := by intro x hx rw [labels_singletonSub_of_mem hx] have hcongr : ∀ y ∈ (Finset.univ : Finset (Fin (m + 1))), RLdim (m : ℝ) (restrict (singletonSub m I) x y) = if y = 0 then a else 0 := by intro y _ by_cases hy0 : y = 0 · subst hy0; rw [if_pos rfl, restrict_singletonSub_zero]; exact (hrec x hx).2 · rw [if_neg hy0, restrict_singletonSub_nonzero hx hy0, RLdim_eq_zero_of_card_le_one _ (by simp)] rw [listVal_congr hcongr, listVal_singleton_branch hm ha0 ha1, hstep_val] refine ⟨by rw [if_pos hI]; omega, le_antisymm ?_ ?_⟩ · refine RLdim_le_of_forall_x (m : ℝ) (singletonSub m I) (by rw [← hstep_val]; positivity) fun x hsplit => ?_ have hxI : x ∈ I := by by_contra hnot rw [labels_singletonSub_of_notMem hnot, Finset.card_singleton] at hsplit; omega rw [hlv_eq x hxI] · rcases hI with ⟨x0, hx0⟩ have hsplit : 2 ≤ (labels (singletonSub m I) x0).card := by rw [labels_singletonSub_of_mem hx0, Finset.card_univ, Fintype.card_fin]; omega rw [← hlv_eq x0 hx0] exact RLdim_ge_listVal (m : ℝ) (singletonSub m I) x0 hsplit · have hemp : I = ∅ := Finset.not_nonempty_iff_eq_empty.mp hI subst hemp have hsing : singletonSub (N := N) m ∅ = {fun _ => 0} := by ext h; simp [mem_singletonSub_iff] rw [hsing, Ldim_eq_zero_of_card_le_one m (by simp), RLdim_eq_zero_of_card_le_one _ (by simp), if_neg hI] simp /-- Domain of the `(m + 1)`-class Comb / Co-Singleton family `combClass m N`. -/ def CombDom (m : ℕ) : ℕ → Type | 0 => Empty | N + 1 => Unit ⊕ (Fin m × CombDom m N) instance instFintypeCombDom (m : ℕ) : ∀ N : ℕ, Fintype (CombDom m N) | 0 => inferInstanceAs (Fintype Empty) | N + 1 => @instFintypeSum Unit (Fin m × CombDom m N) _ (@instFintypeProd (Fin m) (CombDom m N) _ (instFintypeCombDom m N)) instance instDecidableEqCombDom (m : ℕ) : ∀ N : ℕ, DecidableEq (CombDom m N) | 0 => inferInstanceAs (DecidableEq Empty) | N + 1 => @instDecidableEqSum Unit (Fin m × CombDom m N) _ (@instDecidableEqProd (Fin m) (CombDom m N) _ (instDecidableEqCombDom m N)) /-- Lifting a hypothesis on `CombDom m N` into branch `c : Fin m` of `CombDom m (N + 1)`, with off-branch default label `1 : Fin (m + 1)` (preserving the unique-zero invariant!). -/ def combBranch {m N : ℕ} (hm : 1 ≤ m) (c : Fin m) (h : CombDom m N → Fin (m + 1)) : CombDom m (N + 1) → Fin (m + 1) | Sum.inl () => c.succ | Sum.inr (c', x) => if c' = c then h x else ⟨1, by omega⟩ /-- The root leaf hypothesis outputting `0` at the root and `1` everywhere below. -/ def combLeaf {m N : ℕ} (hm : 1 ≤ m) : CombDom m (N + 1) → Fin (m + 1) | Sum.inl () => 0 | Sum.inr _ => ⟨1, by omega⟩ /-- **The `(m + 1)`-Class Comb Family `combClass m N`**: achieves `Ldim m = 1` for EVERY `N ≥ 1` while `RLdim m (combClass m N) ≥ 1 - (m / (m + 1)) ^ N → 1`! -/ def combClass {m : ℕ} (hm : 1 ≤ m) : ∀ N : ℕ, Finset (CombDom m N → Fin (m + 1)) | 0 => {Empty.elim} | N + 1 => insert (combLeaf hm) ((Finset.univ ×ˢ combClass hm N).image (fun p => combBranch hm p.1 p.2)) /-- **Unique-Zero Invariant**: at EVERY point `x ∈ CombDom m N`, AT MOST ONE hypothesis in `combClass hm N` outputs `0`! -/ lemma combClass_unique_zero {m : ℕ} (hm : 1 ≤ m) : ∀ (N : ℕ) (x : CombDom m N), (restrict (combClass hm N) x 0).card ≤ 1 | 0, x => Empty.elim x | N + 1, Sum.inl () => by have hsub : restrict (combClass hm (N + 1)) (Sum.inl ()) 0 ⊆ {combLeaf hm} := by intro h hh rcases Finset.mem_filter.mp hh with ⟨hmem, h0⟩ rw [combClass, Finset.mem_insert] at hmem rcases hmem with rfl | himg · exact Finset.mem_singleton_self _ · rcases Finset.mem_image.mp himg with ⟨⟨c, h'⟩, _, rfl⟩ exact absurd h0 (Fin.succ_ne_zero c) exact le_trans (Finset.card_le_card hsub) (by simp) | N + 1, Sum.inr (c, x) => by have hsub : restrict (combClass hm (N + 1)) (Sum.inr (c, x)) 0 ⊆ (restrict (combClass hm N) x 0).image (combBranch hm c) := by intro h hh rcases Finset.mem_filter.mp hh with ⟨hmem, h0⟩ rw [combClass, Finset.mem_insert] at hmem rcases hmem with rfl | himg · simp [combLeaf] at h0 · rcases Finset.mem_image.mp himg with ⟨⟨c', h'⟩, hprod, rfl⟩ have hh' : h' ∈ combClass hm N := (Finset.mem_product.mp hprod).2 by_cases hcc : c = c' · subst hcc simp only [combBranch, ↓reduceIte] at h0 exact Finset.mem_image.mpr ⟨h', Finset.mem_filter.mpr ⟨hh', h0⟩, rfl⟩ · simp only [combBranch, if_neg hcc] at h0 exact absurd (congrArg Fin.val h0) (by simp) exact le_trans (Finset.card_le_card hsub) (le_trans Finset.card_image_le (combClass_unique_zero hm N x)) /-- Because at most one hypothesis outputs `0` at every point, EVERY subset of `combClass hm N` has `Ldim m ≤ 1`! -/ lemma Ldim_le_one_of_unique_zero {α : Type*} [Fintype α] [DecidableEq α] {m : ℕ} {V : Finset (α → Fin (m + 1))} (huz : ∀ x : α, (restrict V x 0).card ≤ 1) : Ldim m V ≤ 1 := by induction hn : V.card using Nat.strong_induction_on generalizing V with | h n ih => refine Ldim_le_of_forall_x m V fun x hsplit => ?_ have hS : (labels V x).Nonempty := Finset.card_pos.mp (by omega) rw [dlistStep_le_iff hS] refine ⟨fun y _ => ?_, ?_⟩ · have hlt : (restrict V x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y refine ih _ hlt (fun z => le_trans (Finset.card_le_card ?_) (huz z)) rfl exact Finset.filter_subset_filter _ (restrict_subset V x y) · have hsub : (labels V x).filter (fun y => 1 ≤ Ldim m (restrict V x y)) ⊆ Finset.univ.erase (0 : Fin (m + 1)) := by intro y hy have hge := (Finset.mem_filter.mp hy).2 refine Finset.mem_erase.mpr ⟨fun hy0 => ?_, Finset.mem_univ y⟩ subst hy0 rw [Ldim_eq_zero_of_card_le_one m (huz x)] at hge omega calc ((labels V x).filter (fun y => 1 ≤ Ldim m (restrict V x y))).card ≤ (Finset.univ.erase (0 : Fin (m + 1))).card := Finset.card_le_card hsub _ = m := by rw [Finset.card_erase_of_mem (Finset.mem_univ 0), Finset.card_univ, Fintype.card_fin]; omega /-- Helper: pulling `RLdim` along a domain embedding (`CombDom m N → CombDom m (N + 1)`). -/ lemma RLdim_image_combBranch_ge {m N : ℕ} (hm : 1 ≤ m) (c : Fin m) (μ : ℝ) (hμ : 0 ≤ μ) (W : Finset (CombDom m N → Fin (m + 1))) : RLdim μ W ≤ RLdim μ (W.image (combBranch hm c)) := by induction hn : W.card using Nat.strong_induction_on generalizing W with | h n ih => have hinj : Function.Injective (combBranch hm (N := N) c) := by intro h₁ h₂ heq funext x have := congrFun heq (Sum.inr (c, x)) simpa [combBranch] using this refine RLdim_le_of_forall_x μ W (RLdim_nonneg _ _) fun x hsplit => ?_ have hlab : labels (W.image (combBranch hm c)) (Sum.inr (c, x)) = labels W x := by ext y simp only [labels, Finset.mem_image] constructor · rintro ⟨_, ⟨h, hh, rfl⟩, rfl⟩; exact ⟨h, hh, by simp [combBranch]⟩ · rintro ⟨h, hh, rfl⟩; exact ⟨combBranch hm c h, ⟨h, hh, rfl⟩, by simp [combBranch]⟩ have hsp' : 2 ≤ (labels (W.image (combBranch hm c)) (Sum.inr (c, x))).card := by rwa [hlab] have hrest : ∀ y, restrict (W.image (combBranch hm c)) (Sum.inr (c, x)) y = (restrict W x y).image (combBranch hm c) := by intro y ext g simp only [restrict, Finset.mem_filter, Finset.mem_image] constructor · rintro ⟨⟨h, hh, rfl⟩, hgy⟩ exact ⟨h, ⟨hh, by simpa [combBranch] using hgy⟩, rfl⟩ · rintro ⟨h, ⟨hh, hxy⟩, rfl⟩ exact ⟨⟨h, hh, rfl⟩, by simpa [combBranch] using hxy⟩ calc listVal μ (labels W x) (fun y => RLdim μ (restrict W x y)) ≤ listVal μ (labels W x) (fun y => RLdim μ (restrict (W.image (combBranch hm c)) (Sum.inr (c, x)) y)) := by refine listVal_mono_v hμ fun y _ => ?_ rw [hrest y] have hlt : (restrict W x y).card < n := by rw [← hn]; exact card_restrict_lt_of_two_labels hsplit y exact ih _ hlt _ rfl _ = listVal μ (labels (W.image (combBranch hm c)) (Sum.inr (c, x))) (fun y => RLdim μ (restrict (W.image (combBranch hm c)) (Sum.inr (c, x)) y)) := by rw [hlab] _ ≤ RLdim μ (W.image (combBranch hm c)) := RLdim_ge_listVal μ _ (Sum.inr (c, x)) hsp' /-- **Exact Upper Sharpness of `RLdim m ≤ Ldim m` Even on `(m + 1)`-Class Problems**: for EVERY `m ≥ 1` and EVERY `N ≥ 1`, `combClass hm N` satisfies - `Ldim m (combClass hm N) = 1`, - `1 - (m / (m + 1)) ^ N ≤ RLdim m (combClass hm N) ≤ 1`, proving `RLdim m / Ldim m → 1` as `N → ∞` even with fixed label set `|β| = m + 1`! -/ theorem combClass_sharp_ratio_one {m : ℕ} (hm : 1 ≤ m) : ∀ N : ℕ, 1 ≤ N → Ldim m (combClass hm N) = 1 ∧ 1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N ≤ RLdim (m : ℝ) (combClass hm N) ∧ RLdim (m : ℝ) (combClass hm N) ≤ 1 := by have hRL_ge : ∀ N : ℕ, 1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N ≤ RLdim (m : ℝ) (combClass hm N) := by intro N induction N with | zero => simp [RLdim_nonneg] | succ N ih => have hne_sub : (combClass hm N).Nonempty := by cases N with | zero => exact ⟨Empty.elim, by rw [combClass]; exact Finset.mem_singleton_self _⟩ | succ k => exact ⟨combLeaf hm, by rw [combClass]; exact Finset.mem_insert_self _ _⟩ have hlab_root : labels (combClass hm (N + 1)) (Sum.inl ()) = Finset.univ := by ext y simp only [labels, Finset.mem_image, Finset.mem_univ, iff_true] refine Fin.cases ?_ ?_ y · exact ⟨combLeaf hm, by simp [combClass], rfl⟩ · intro c rcases hne_sub with ⟨h0, hh0⟩ refine ⟨combBranch hm c h0, ?_, rfl⟩ rw [combClass] exact Finset.mem_insert_of_mem (Finset.mem_image.mpr ⟨(c, h0), Finset.mem_product.mpr ⟨Finset.mem_univ c, hh0⟩, rfl⟩) have hsplit : 2 ≤ (labels (combClass hm (N + 1)) (Sum.inl ())).card := by rw [hlab_root, Finset.card_univ, Fintype.card_fin]; omega have hS : (labels (combClass hm (N + 1)) (Sum.inl ())).Nonempty := Finset.card_pos.mp (by omega) have havg := le_trans (subset_avg_le_listVal (μ := (m : ℝ)) (v := fun y => RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) y)) Subset.rfl hS) (RLdim_ge_listVal (m : ℝ) (combClass hm (N + 1)) (Sum.inl ()) hsplit) rw [hlab_root, Finset.card_univ, Fintype.card_fin] at havg -- Lower bound the sum over `Fin (m + 1)` via `c.succ` branches! have hbranch_sub : ∀ c : Fin m, (combClass hm N).image (combBranch hm c) ⊆ restrict (combClass hm (N + 1)) (Sum.inl ()) c.succ := by intro c g hg rcases Finset.mem_image.mp hg with ⟨h, hh, rfl⟩ refine Finset.mem_filter.mpr ⟨?_, rfl⟩ rw [combClass] exact Finset.mem_insert_of_mem (Finset.mem_image.mpr ⟨(c, h), Finset.mem_product.mpr ⟨Finset.mem_univ c, hh⟩, rfl⟩) have hbranch_ge : ∀ c : Fin m, 1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N ≤ RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) c.succ) := fun c => le_trans ih (le_trans (RLdim_image_combBranch_ge hm c (m : ℝ) (Nat.cast_nonneg m) _) (RLdim_mono (Nat.cast_nonneg m) (hbranch_sub c))) have hsum_ge : (m : ℝ) * (1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N) + ((m : ℝ) + 1) ≤ ∑ y : Fin (m + 1), (RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) y) + 1) := by rw [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one, Fin.sum_univ_succ] have h0 : 0 ≤ RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) 0) := RLdim_nonneg _ _ have hsucc : (m : ℝ) * (1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N) ≤ ∑ c : Fin m, RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) c.succ) := by calc (m : ℝ) * (1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N) = ∑ _c : Fin m, (1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ N) := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] _ ≤ ∑ c : Fin m, RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) c.succ) := Finset.sum_le_sum fun c _ => hbranch_ge c push_cast linarith have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hdiv_ge : 1 - ((m : ℝ) / ((m : ℝ) + 1)) ^ (N + 1) ≤ ((∑ y : Fin (m + 1), (RLdim (m : ℝ) (restrict (combClass hm (N + 1)) (Sum.inl ()) y) + 1)) - (m : ℝ)) / ((m + 1 : ℕ) : ℝ) := by push_cast rw [le_div_iff₀ hm1_pos] have hpow_step : ((m : ℝ) / ((m : ℝ) + 1)) ^ (N + 1) * ((m : ℝ) + 1) = (m : ℝ) * ((m : ℝ) / ((m : ℝ) + 1)) ^ N := by rw [pow_succ]; field_simp [ne_of_gt hm1_pos] linarith exact le_trans hdiv_ge havg intro N hN have hL_le : Ldim m (combClass hm N) ≤ 1 := Ldim_le_one_of_unique_zero (combClass_unique_zero hm N) have hRL_le : RLdim (m : ℝ) (combClass hm N) ≤ 1 := le_trans (RLdim_le_Ldim m _) (by exact_mod_cast hL_le) have hRL_pos : 0 < RLdim (m : ℝ) (combClass hm N) := by have hlt1 : ((m : ℝ) / ((m : ℝ) + 1)) ^ N < 1 := by have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hfrac_lt : (m : ℝ) / ((m : ℝ) + 1) < 1 := (div_lt_one hm1_pos).mpr (by linarith) exact pow_lt_one₀ (by positivity) hfrac_lt (by omega) linarith [hRL_ge N] have hL_ge : 1 ≤ Ldim m (combClass hm N) := by by_contra hlt have h0 : Ldim m (combClass hm N) = 0 := by omega have hle0 : RLdim (m : ℝ) (combClass hm N) ≤ 0 := by have := RLdim_le_Ldim m (combClass hm N) rw [h0, Nat.cast_zero] at this exact this linarith exact ⟨by omega, hRL_ge N, hRL_le⟩ /-! ## Part 9: Randomized `m`-List Bandit Online Learning (`RBLdim_m`) & Exact Price of List-Bandit Feedback On the 1-point `k`-class problem under `m`-list bandit feedback, the learner outputs a random `m`-subset `L ⊆ Fin k`; if `y* ∈ L` it incurs `0` mistakes and finishes (only `≤ m` labels remain), while if `y* ∉ L` it incurs `1` mistake and learns `y* ∉ L`, reducing the remaining label set from size `k` to size `k - m`. -/ /-- Exact recursive deterministic `m`-list bandit dimension on the 1-point `k`-class problem: each wrong `m`-list eliminates `m` labels until `≤ m` remain. -/ def onePointDetListBandit (m : ℕ) (k : ℕ) : ℕ := if m = 0 then 0 else (k - 1) / m /-- Exact recursive randomized `m`-list bandit minimax mistake bound on the 1-point `k`-class problem (`m ≥ 1`): at size `k ≤ m` it is `0`; at `k > m`, a uniform random `m`-subset misses with probability `(k - m) / k` and transitions to `k - m` remaining labels. -/ noncomputable def onePointListBandit (m : ℕ) (k : ℕ) : ℝ := if hm : m = 0 then 0 else if hk : k ≤ m then 0 else (((k - m : ℕ) : ℝ) / (k : ℝ)) * (1 + onePointListBandit m (k - m)) termination_by k decreasing_by omega /-- **Exact Closed-Form Formula for Randomized `m`-List Bandit Online Learning**: For EVERY `m ≥ 1` and `k ≥ 1`, writing `q = (k - 1) / m` and `r = k - q * m` (`1 ≤ r ≤ m`), `onePointListBandit m k = q * (k - m + r) / (2 * k)`. -/ theorem onePointListBandit_exact {m : ℕ} (hm : 1 ≤ m) : ∀ k : ℕ, 1 ≤ k → let q := (k - 1) / m let r := k - q * m onePointListBandit m k = ((q : ℝ) * (((k : ℝ) - (m : ℝ)) + (r : ℝ))) / (2 * (k : ℝ)) := by intro k induction k using Nat.strong_induction_on with | h k ih => intro hk1 have hm0 : m ≠ 0 := by omega have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr hk1 dsimp only by_cases hkm : k ≤ m · rw [onePointListBandit, dif_neg hm0, dif_pos hkm] have hq0 : (k - 1) / m = 0 := Nat.div_eq_of_lt (by omega) rw [hq0]; simp · rw [onePointListBandit, dif_neg hm0, dif_neg hkm] have hkm_pos : 1 ≤ k - m := by omega have hrec := ih (k - m) (by omega) hkm_pos dsimp only at hrec rw [hrec] set q := (k - 1) / m set r := k - q * m have hq_sub : (k - m - 1) / m = q - 1 := by have h1 : k - 1 = (k - m - 1) + m := by omega have h2 : q = (k - m - 1) / m + 1 := by dsimp only [q] rw [h1, Nat.add_div_right _ hm] rw [h2]; simp have hq_ge1 : 1 ≤ q := by have : m ≤ k - 1 := by omega exact Nat.div_pos this hm have hr_eq : (k - m) - (q - 1) * m = r := by have hqm : q * m = (q - 1) * m + m := by calc q * m = ((q - 1) + 1) * m := by rw [Nat.sub_add_cancel hq_ge1] _ = (q - 1) * m + m := by ring dsimp only [r]; omega rw [hq_sub, hr_eq] have hkm_cast : ((k - m : ℕ) : ℝ) = (k : ℝ) - (m : ℝ) := Nat.cast_sub (by omega) have hq_cast : ((q - 1 : ℕ) : ℝ) = (q : ℝ) - 1 := by rw [Nat.cast_sub hq_ge1]; norm_num have hkm_ne : (k : ℝ) - (m : ℝ) ≠ 0 := by have : (m : ℝ) < (k : ℝ) := by exact_mod_cast (by omega : m < k) linarith rw [hkm_cast, hq_cast] have hkr : (k : ℝ) = (q : ℝ) * (m : ℝ) + (r : ℝ) := by have hmul_le : q * m ≤ k - 1 := Nat.div_mul_le_self (k - 1) m have hnat : k = q * m + r := by dsimp only [r]; omega exact_mod_cast hnat field_simp [ne_of_gt hk_pos, hkm_ne] nlinarith /-- **Sharp Two-Sided Sandwich for `m`-List Bandit Learning**: For EVERY `m ≥ 1` and `k ≥ 1`, `(1 / (m + 1)) * BLdim_m(C_k) ≤ RBLdim_m(C_k) ≤ (1 / 2) * BLdim_m(C_k)`, with exact equality on the left at `k = m + 1` and exact equality on the right whenever `m ∣ k`! -/ theorem onePointListBandit_sandwich {m k : ℕ} (hm : 1 ≤ m) (hk : 1 ≤ k) : (onePointDetListBandit m k : ℝ) / ((m : ℝ) + 1) ≤ onePointListBandit m k ∧ onePointListBandit m k ≤ (onePointDetListBandit m k : ℝ) / 2 := by have hm0 : m ≠ 0 := by omega rw [onePointListBandit_exact hm k hk, onePointDetListBandit, if_neg hm0] set q := (k - 1) / m set r := k - q * m have hqm_le : q * m ≤ k - 1 := Nat.div_mul_le_self (k - 1) m have hlt_rem : k - 1 - q * m < m := by have hmod : (k - 1) % m < m := Nat.mod_lt (k - 1) hm have hdiv : m * q + (k - 1) % m = k - 1 := Nat.div_add_mod (k - 1) m have hcomm : q * m = m * q := Nat.mul_comm q m omega have hr1 : 1 ≤ r := by dsimp only [r]; omega have hrm : r ≤ m := by dsimp only [r]; omega have hk_eq : (k : ℝ) = (q : ℝ) * (m : ℝ) + (r : ℝ) := by have hnat : k = q * m + r := by dsimp only [r]; omega exact_mod_cast hnat have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr hk have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hr1_r : (1 : ℝ) ≤ (r : ℝ) := by exact_mod_cast hr1 have hrm_r : (r : ℝ) ≤ (m : ℝ) := by exact_mod_cast hrm have hq0 : (0 : ℝ) ≤ (q : ℝ) := Nat.cast_nonneg q have hm_r : (1 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm constructor · rw [div_le_div_iff₀ hm1_pos (by positivity : (0 : ℝ) < 2 * (k : ℝ))] by_cases hq_zero : q = 0 · rw [hq_zero]; simp · have hq1 : (1 : ℝ) ≤ (q : ℝ) := by exact_mod_cast (Nat.pos_of_ne_zero hq_zero) have hinner : 2 * (k : ℝ) ≤ ((m : ℝ) + 1) * ((k : ℝ) - (m : ℝ) + (r : ℝ)) := by rw [hk_eq] have hfac : ((m : ℝ) + 1) * ((q : ℝ) * (m : ℝ) + (r : ℝ) - (m : ℝ) + (r : ℝ)) - 2 * ((q : ℝ) * (m : ℝ) + (r : ℝ)) = (m : ℝ) * (((q : ℝ) - 1) * ((m : ℝ) - 1) + 2 * ((r : ℝ) - 1)) := by ring have hnn : 0 ≤ (m : ℝ) * (((q : ℝ) - 1) * ((m : ℝ) - 1) + 2 * ((r : ℝ) - 1)) := by have h1 : 0 ≤ ((q : ℝ) - 1) * ((m : ℝ) - 1) := mul_nonneg (by linarith) (by linarith) have h2 : 0 ≤ 2 * ((r : ℝ) - 1) := by linarith exact mul_nonneg (by linarith) (by linarith) linarith nlinarith · rw [div_le_div_iff₀ (by positivity : (0 : ℝ) < 2 * (k : ℝ)) (by norm_num)] nlinarith /-- **Exact Linear `k / (2m)` Price of List-Bandit Feedback**: When `k = (q + 1) * m` (`q ≥ 1, m ≥ 1`): - Full-information `RLdim m (onePointClass k) = q / (q + 1) < 1`, - Deterministic `BLdim m = q`, - Randomized `m`-list bandit `RBLdim m = q / 2`, - Exact price-of-bandit-feedback ratio `RBLdim m / RLdim m = (q + 1) / 2 = k / (2 * m)`! -/ theorem price_of_list_bandit_feedback {m q : ℕ} (hm : 1 ≤ m) (hq : 1 ≤ q) : let k := (q + 1) * m RLdim (m : ℝ) (onePointClass k) = (q : ℝ) / ((q : ℝ) + 1) ∧ onePointDetListBandit m k = q ∧ onePointListBandit m k = (q : ℝ) / 2 ∧ onePointListBandit m k / RLdim (m : ℝ) (onePointClass k) = (k : ℝ) / (2 * (m : ℝ)) := by dsimp only set k := (q + 1) * m have hk2 : 2 ≤ k := by dsimp only [k]; nlinarith have hk1 : 1 ≤ k := by omega have hm_pos : (0 : ℝ) < (m : ℝ) := Nat.cast_pos.mpr hm have hq_pos : (0 : ℝ) < (q : ℝ) := Nat.cast_pos.mpr hq have hq1_pos : (0 : ℝ) < (q : ℝ) + 1 := by positivity have hRL : RLdim (m : ℝ) (onePointClass k) = (q : ℝ) / ((q : ℝ) + 1) := by rw [RLdim_onePointClass hk2 (Nat.cast_nonneg m)] have hcalc : (1 : ℝ) - (m : ℝ) / (k : ℝ) = (q : ℝ) / ((q : ℝ) + 1) := by dsimp only [k]; push_cast field_simp [ne_of_gt hm_pos, ne_of_gt hq1_pos]; ring rw [hcalc, max_eq_right (by positivity)] have hdiv_eq : (k - 1) / m = q := by have hkm : k = q * m + m := by dsimp only [k]; ring have h1 : k - 1 = q * m + (m - 1) := by omega rw [h1, mul_comm q m, Nat.mul_add_div hm, Nat.div_eq_of_lt (by omega), add_zero] have hBL : onePointDetListBandit m k = q := by rw [onePointDetListBandit, if_neg (by omega), hdiv_eq] have hRBL : onePointListBandit m k = (q : ℝ) / 2 := by rw [onePointListBandit_exact hm k hk1] rw [hdiv_eq] have hr_eq : k - q * m = m := by have hkm : k = q * m + m := by dsimp only [k]; ring omega rw [hr_eq] have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr hk1 field_simp [ne_of_gt hk_pos] ring refine ⟨hRL, hBL, hRBL, ?_⟩ rw [hRBL, hRL] dsimp only [k]; push_cast field_simp [ne_of_gt hm_pos, ne_of_gt hq_pos, ne_of_gt hq1_pos] /-! ## Part 10: Axiom Audit (`#print axioms`) -/ #print axioms listVal_le_iff #print axioms listVal_primal_upper #print axioms listVal_dual_lower #print axioms cyclicIntervalRounding_fin #print axioms exists_mSubset_dist_of_marginals #print axioms exists_mSubset_dist_of_sum_le #print axioms RLdim_le_Ldim #print axioms Ldim_div_succ_le_RLdim #print axioms optListLearner_expectedMistakes_le #print axioms optListAdversary_expectedMistakes_ge #print axioms online_list_minimax_exact #print axioms RLdim_convex #print axioms RLdim_midpoint_convex #print axioms RLdim_monotone_ratio_kClass #print axioms RLdim_le_const_mul_log_card #print axioms RLdim_le_const_mul_log_card_kClass #print axioms superBranch_universal_ceiling #print axioms RLdim_le_log_card_div_one_add_log #print axioms RLdim_one_le_half_log2_card #print axioms RLdim_two_le_superBranch_log_card #print axioms superBranch_m2_beats_ternary_by_22pct #print axioms RLdim_three_le_superBranch_log_card #print axioms RLdim_m_le_log_card_succ_class #print axioms RLdim_union_list_additive #print axioms RLdim_union_same_list_half #print axioms RLdim_union_half_sharp #print axioms RLdim_prod_eq_add #print axioms Ldim_prod_eq_add #print axioms Ldim_div_succ_sharp #print axioms RLdim_monotone_ratio_sharp #print axioms superBranch_halving_sharp #print axioms Ldim_not_convex #print axioms singletonSub_exact #print axioms combClass_sharp_ratio_one #print axioms onePointListBandit_exact #print axioms onePointListBandit_sandwich #print axioms price_of_list_bandit_feedback end RandomizedListOnlineLearning