import Mathlib /-! # Exact Differential Privacy via Constructive Blackwell Dominance: # Sharp KOV Composition, Asymmetric Subsampling, Group-Privacy Vacuity Phase Transitions, # and Local-DP Contraction & Estimation Minimax Theory This self-contained Lean 4 formalization establishes a complete, non-asymptotic, measure-theory-free minimax theory of differential privacy and local differential privacy built from a **constructive 4-outcome Blackwell dominance kernel**: 1. **Part 1 — Hockey-Stick Divergence, Neyman–Pearson Variational Duality & Constructive 4-Outcome Blackwell Dominance Kernel (`epsDelta_blackwell_dominance`)**: - Exact Neyman–Pearson event & randomized-test variational characterizations of `E_γ(P ‖ Q)`. - Exact Markov post-processing Data Processing Inequalities for hockey-stick `E_γ`, TV, Bhattacharyya coefficient `BC`, and arbitrary convex `f`-divergences. - Explicit closed-form 3-regime stochastic kernel `K : Fin 4 → Ω → ℝ` proving that the canonical 4-outcome pair `(canonP ε δ, canonQ ε δ)` Blackwell-dominates **every** finite `(ε, δ)`-DP pair `(P, Q)` (`ε ≥ 0`, `δ ∈ [0, 1]`), yielding exact sharp extrema for TV (`(e^ε - 1 + 2δ) / (e^ε + 1)`), hockey-stick `E_γ`, Bhattacharyya `BC`, and all convex `f`-divergences. 2. **Part 2 — Adaptive `k`-Fold Composition & Exact Kairouz–Oh–Viswanath Binomial Tail Theorem**: - Explicit product-lifting kernel proving that **arbitrary `k`-fold adaptive composition** of `(ε, δ)`-DP mechanisms is Blackwell-dominated by `(canonP ε δ)^{⊗ k}` vs. `(canonQ ε δ)^{⊗ k}`. - Exact product reduction `E_γ((P*_{ε,δ})^{⊗ k} ‖ (Q*_{ε,δ})^{⊗ k}) = 1 - (1 - δ)^k (1 - E_γ((P*_{ε,0})^{⊗ k} ‖ (Q*_{ε,0})^{⊗ k}))`. - Exact KOV binomial tail formula for all `k ≥ 1`, `i ∈ {0, ..., k}`, with exact attainability and strict improvement over basic composition (`kov_strictly_beats_basic_k2`, `kov_strictly_beats_basic_k3`). 3. **Part 3 — Exact Poisson Subsampling Amplification & Asymmetric Zero-Divergence Phase Transition**: - Exact Add-direction identity `E_γ((1 - p) Q + p P ‖ Q) = p · E_{1 + (γ - 1) / p}(P ‖ Q)`. - Exact Remove-direction two-phase formula with **sharp zero-divergence collapse** at `γ* = 1 / (1 - p)`: `E_γ(Q ‖ (1 - p) Q + p P) = 0` identically for ALL `γ ≥ 1 / (1 - p)`. - Exact Balle–Barthe–Gaboardi amplification `(log(1 + p(e^ε - 1)), p δ)` and proof of **strict Add-vs-Remove asymmetry** on the canonical pair. 4. **Part 4 — Exact `(ε, δ)`-DP Group Privacy & Square-Root-Exponential Vacuity Phase Transition**: - Exact 1-step symmetric tradeoff envelope `g_{ε,δ}(a) = min(1, δ + e^ε a, 1 - e^{-ε}(1 - δ - a))`. - Exact tight `k`-group privacy theorem `sup E_{e^{kε}}(P_k ‖ P_0) = g_{ε,δ}^{∘ k}(0)`, attained by an explicit 2-outcome Markov chain. - Exact `k = 2` three-phase closed form strictly beating the textbook bound on `(1/(e^ε + 2), 1/2)`. - **Exact Universal Vacuity Threshold**: `g_{ε,δ}^{∘ k}(0) = 1 ↔ δ ≥ (e^ε - 1) / (e^{⌊k/2⌋ ε} + e^{⌈k/2⌉ ε} - 2)`, establishing a **square-root-exponential (`≥ (1/2) e^{⌊k/2⌋ ε}`) gain** over the textbook vacuity threshold `(e^ε - 1) / (e^{kε} - 1)`. 5. **Part 5 — Local-DP Contraction (`TV`, `χ²`-Capacity, `KL`-Capacity, Binary `χ²`-SDPI) & `n`-User Private Hypothesis Testing Minimax Risk**: - Exact `(ε, δ)`-LDP Dobrushin TV contraction `(e^ε - 1 + 2δ) / (e^ε + 1)`. - Exact `ε`-LDP `χ²`-mutual information capacity `I_{χ²}(Q; W) ≤ (e^ε - 1)² / (4 e^ε)`, attained by `k`-RR at `e^ε = k - 1`, and strict `KL`-mutual information bound `I_KL(Q; W) ≤ log((e^ε + 1)² / (4 e^ε)) < ε`. - Exact binary-input `ε`-LDP `χ²`-SDPI `((e^ε - 1) / (e^ε + 1))²` attained by Warner RR. - Exact 1-user `(ε, δ)`-LDP testing minimax error and exact `n`-user non-asymptotic sample complexity lower bound `n ≥ log(1 / (4 α (1 - α))) / (2 log cosh(ε / 2))`. 6. **Part 6 — Exact Local-DP Discrete Distribution Estimation: `s`-Subset Selection, `k`-RR, and RAPPOR Phase Transitions**: - Exact unbiasedness and closed-form per-sample `L₂²` MSE for `s`-Subset Selection, `k`-RR, and Unary RAPPOR on every distribution `p ∈ Δ_k`. - Exact subset-size phase transition `MSE_{(s+1)-SS} ≤ MSE_{s-SS} ↔ e^{2ε} ≤ (k-s)(k-s-1)/(s(s+1))` and Cauchy–Schwarz continuous lower envelope. - Exact `k`-RR vs. RAPPOR alphabet-size phase transition at `k* = 5` (`k ≤ 5`: `k`-RR always wins; `k ≥ 6`: sharp crossover in `ε`). - **Universal Strict Dominance of Optimal `s`-Subset Selection over RAPPOR** for ALL `k ≥ 2`, ALL `ε > 0`, and ALL `p ∈ Δ_k`. -/ namespace DifferentialPrivacyBlackwellMinimax open scoped BigOperators open Finset /-! ============================================================================ PART 1: PROBABILITY DISTRIBUTIONS, MARKOV KERNELS, HOCKEY-STICK DIVERGENCE, AND CONSTRUCTIVE 4-OUTCOME BLACKWELL DOMINANCE ============================================================================ -/ /-- A discrete probability distribution on a finite type `Ω`. -/ def IsProbDist {Ω : Type*} [Fintype Ω] (p : Ω → ℝ) : Prop := (∀ z, 0 ≤ p z) ∧ ∑ z : Ω, p z = 1 /-- A discrete Markov kernel (randomized mechanism) from `α` to `Ω`. -/ def IsMarkovKernel {α Ω : Type*} [Fintype Ω] (K : α → Ω → ℝ) : Prop := ∀ x, IsProbDist (K x) /-- Pushforward of distribution `p` on `α` through Markov kernel `K : α → Ω → ℝ`. -/ def pushforward {α Ω : Type*} [Fintype α] (K : α → Ω → ℝ) (p : α → ℝ) : Ω → ℝ := fun z => ∑ x : α, p x * K x z /-- Composition of Markov kernels `K₂ ∘ K₁`. -/ def compKernel {α β Ω : Type*} [Fintype β] (K₂ : β → Ω → ℝ) (K₁ : α → β → ℝ) : α → Ω → ℝ := fun x z => ∑ y : β, K₁ x y * K₂ y z lemma pushforward_isProbDist {α Ω : Type*} [Fintype α] [Fintype Ω] {K : α → Ω → ℝ} {p : α → ℝ} (hK : IsMarkovKernel K) (hp : IsProbDist p) : IsProbDist (pushforward K p) := by refine ⟨fun z => Finset.sum_nonneg fun x _ => mul_nonneg (hp.1 x) ((hK x).1 z), ?_⟩ dsimp only [pushforward] rw [Finset.sum_comm] calc ∑ x : α, ∑ z : Ω, p x * K x z = ∑ x : α, p x * ∑ z : Ω, K x z := by refine Finset.sum_congr rfl fun x _ => ?_; rw [Finset.mul_sum] _ = ∑ x : α, p x := by refine Finset.sum_congr rfl fun x _ => ?_; rw [(hK x).2, mul_one] _ = 1 := hp.2 lemma compKernel_isMarkovKernel {α β Ω : Type*} [Fintype β] [Fintype Ω] {K₂ : β → Ω → ℝ} {K₁ : α → β → ℝ} (hK₂ : IsMarkovKernel K₂) (hK₁ : IsMarkovKernel K₁) : IsMarkovKernel (compKernel K₂ K₁) := fun x => pushforward_isProbDist hK₂ (hK₁ x) lemma pushforward_comp {α β Ω : Type*} [Fintype α] [Fintype β] (K₂ : β → Ω → ℝ) (K₁ : α → β → ℝ) (p : α → ℝ) : pushforward K₂ (pushforward K₁ p) = pushforward (compKernel K₂ K₁) p := by funext z dsimp only [pushforward, compKernel] simp_rw [Finset.sum_mul, Finset.mul_sum, mul_assoc] exact Finset.sum_comm /-- Discrete hockey-stick divergence `E_γ(p ‖ q) = ∑ z, max 0 (p z - γ * q z)`. -/ def hockeyStick {Ω : Type*} [Fintype Ω] (γ : ℝ) (p q : Ω → ℝ) : ℝ := ∑ z : Ω, max 0 (p z - γ * q z) /-- Discrete total variation distance `TV(p, q) = (1/2) ∑ z, |p z - q z|`. -/ noncomputable def tvDist {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) : ℝ := (1 / 2 : ℝ) * ∑ z : Ω, |p z - q z| /-- Discrete Bhattacharyya coefficient `BC(p, q) = ∑ z, √(p z * q z)`. -/ noncomputable def bhattCoeff {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) : ℝ := ∑ z : Ω, Real.sqrt (p z * q z) /-- Two finite distributions `p, q` are `(ε, δ)`-indistinguishable iff both `E_{e^ε}(p ‖ q) ≤ δ` and `E_{e^ε}(q ‖ p) ≤ δ`. -/ noncomputable def IsEpsDeltaClose {Ω : Type*} [Fintype Ω] (ε δ : ℝ) (p q : Ω → ℝ) : Prop := hockeyStick (Real.exp ε) p q ≤ δ ∧ hockeyStick (Real.exp ε) q p ≤ δ /-- Finite Blackwell dominance: `(p, q)` is a Markov post-processing of `(p*, q*)`. -/ def BlackwellDom {α Ω : Type*} [Fintype α] [Fintype Ω] (p q : Ω → ℝ) (pStar qStar : α → ℝ) : Prop := ∃ K : α → Ω → ℝ, IsMarkovKernel K ∧ pushforward K pStar = p ∧ pushforward K qStar = q theorem hockeyStick_nonneg {Ω : Type*} [Fintype Ω] (γ : ℝ) (p q : Ω → ℝ) : 0 ≤ hockeyStick γ p q := Finset.sum_nonneg fun _ _ => le_max_left 0 _ theorem hockeyStick_le_one {Ω : Type*} [Fintype Ω] {γ : ℝ} {p q : Ω → ℝ} (hγ : 0 ≤ γ) (hp : IsProbDist p) (hq : IsProbDist q) : hockeyStick γ p q ≤ 1 := by calc hockeyStick γ p q ≤ ∑ z : Ω, p z := by refine Finset.sum_le_sum fun z _ => max_le (hp.1 z) ?_ linarith [mul_nonneg hγ (hq.1 z)] _ = 1 := hp.2 theorem hockeyStick_self {Ω : Type*} [Fintype Ω] {γ : ℝ} {p : Ω → ℝ} (hγ : 1 ≤ γ) (hp : IsProbDist p) : hockeyStick γ p p = 0 := by refine Finset.sum_eq_zero fun z _ => max_eq_left ?_ nlinarith [hp.1 z] theorem hockeyStick_antitone {Ω : Type*} [Fintype Ω] {γ₁ γ₂ : ℝ} {p q : Ω → ℝ} (hγ : γ₁ ≤ γ₂) (hq : ∀ z, 0 ≤ q z) : hockeyStick γ₂ p q ≤ hockeyStick γ₁ p q := by refine Finset.sum_le_sum fun z _ => max_le_max_left 0 ?_ have := mul_le_mul_of_nonneg_right hγ (hq z) linarith theorem hockeyStick_convex_gamma {Ω : Type*} [Fintype Ω] {γ₁ γ₂ t : ℝ} {p q : Ω → ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : hockeyStick (t * γ₁ + (1 - t) * γ₂) p q ≤ t * hockeyStick γ₁ p q + (1 - t) * hockeyStick γ₂ p q := by dsimp only [hockeyStick] rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib] refine Finset.sum_le_sum fun z _ => ?_ have hlin : p z - (t * γ₁ + (1 - t) * γ₂) * q z = t * (p z - γ₁ * q z) + (1 - t) * (p z - γ₂ * q z) := by ring rw [hlin] refine max_le (add_nonneg (mul_nonneg ht0 (le_max_left _ _)) (mul_nonneg (by linarith) (le_max_left _ _))) ?_ exact add_le_add (mul_le_mul_of_nonneg_left (le_max_right _ _) ht0) (mul_le_mul_of_nonneg_left (le_max_right _ _) (by linarith)) /-- Exact identity `E_1(p ‖ q) = TV(p, q)` for probability distributions `p, q`. -/ theorem hockeyStick_one_eq_tvDist {Ω : Type*} [Fintype Ω] {p q : Ω → ℝ} (hp : IsProbDist p) (hq : IsProbDist q) : hockeyStick 1 p q = tvDist p q := by have hsum0 : ∑ z : Ω, (p z - q z) = 0 := by rw [Finset.sum_sub_distrib, hp.2, hq.2, sub_self] have hpt : ∀ z : Ω, max 0 (p z - 1 * q z) = (1 / 2 : ℝ) * (|p z - q z| + (p z - q z)) := by intro z rw [one_mul] rcases le_total (p z) (q z) with h | h · rw [max_eq_left (by linarith), abs_of_nonpos (by linarith)]; ring · rw [max_eq_right (by linarith), abs_of_nonneg (by linarith)]; ring dsimp only [hockeyStick, tvDist] simp_rw [hpt, ← Finset.mul_sum, Finset.sum_add_distrib, hsum0, add_zero] lemma tvDist_symm {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) : tvDist p q = tvDist q p := by dsimp only [tvDist] congr 1 exact Finset.sum_congr rfl fun z _ => abs_sub_comm (p z) (q z) lemma tvDist_nonneg {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) : 0 ≤ tvDist p q := mul_nonneg (by norm_num) (Finset.sum_nonneg fun _ _ => abs_nonneg _) /-- **Exact Neyman–Pearson Event & Randomized-Test Variational Characterization**: 1. For every randomized test `f : Ω → [0, 1]`, `∑ z, f z * (p z - γ * q z) ≤ E_γ(p ‖ q)`. 2. For every event `S : Finset Ω`, `∑ z ∈ S, p z - γ * ∑ z ∈ S, q z ≤ E_γ(p ‖ q)`. 3. Equality is **attained** by the explicit likelihood-ratio event `S* = {z | γ * q z < p z}`! -/ theorem hockeyStick_eq_sup_event {Ω : Type*} [Fintype Ω] [DecidableEq Ω] (γ : ℝ) (p q : Ω → ℝ) : (∀ f : Ω → ℝ, (∀ z, 0 ≤ f z ∧ f z ≤ 1) → ∑ z : Ω, f z * (p z - γ * q z) ≤ hockeyStick γ p q) ∧ (∀ S : Finset Ω, (∑ z ∈ S, p z) - γ * (∑ z ∈ S, q z) ≤ hockeyStick γ p q) ∧ (∃ S : Finset Ω, (∑ z ∈ S, p z) - γ * (∑ z ∈ S, q z) = hockeyStick γ p q) := by have h1 : ∀ f : Ω → ℝ, (∀ z, 0 ≤ f z ∧ f z ≤ 1) → ∑ z : Ω, f z * (p z - γ * q z) ≤ hockeyStick γ p q := by intro f hf refine Finset.sum_le_sum fun z _ => ?_ rcases le_total (p z - γ * q z) 0 with h | h · calc f z * (p z - γ * q z) ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (hf z).1 h _ ≤ max 0 (p z - γ * q z) := le_max_left _ _ · calc f z * (p z - γ * q z) ≤ 1 * (p z - γ * q z) := mul_le_mul_of_nonneg_right (hf z).2 h _ = p z - γ * q z := one_mul _ _ ≤ max 0 (p z - γ * q z) := le_max_right _ _ refine ⟨h1, ?_, ?_⟩ · intro S classical have heq : (∑ z ∈ S, p z) - γ * (∑ z ∈ S, q z) = ∑ z : Ω, (if z ∈ S then (1 : ℝ) else 0) * (p z - γ * q z) := by rw [Finset.mul_sum, ← Finset.sum_sub_distrib] simp only [ite_mul, one_mul, zero_mul, Finset.sum_ite, Finset.sum_const_zero, add_zero, Finset.filter_mem_eq_inter, Finset.univ_inter] rw [heq] exact h1 _ (fun z => by split_ifs <;> norm_num) · classical refine ⟨Finset.univ.filter fun z : Ω => γ * q z < p z, ?_⟩ rw [Finset.mul_sum, ← Finset.sum_sub_distrib, Finset.sum_filter] dsimp only [hockeyStick] refine Finset.sum_congr rfl fun z _ => ?_ split_ifs with hz · exact (max_eq_right (by linarith)).symm · exact (max_eq_left (by linarith)).symm /-- **Exact Hockey-Stick Data Processing Inequality (Post-Processing Invariance)**: For EVERY Markov kernel `K`, `E_γ(K p ‖ K q) ≤ E_γ(p ‖ q)`. -/ theorem hockeyStick_dpi {α Ω : Type*} [Fintype α] [Fintype Ω] {K : α → Ω → ℝ} (hK : IsMarkovKernel K) (γ : ℝ) (p q : α → ℝ) : hockeyStick γ (pushforward K p) (pushforward K q) ≤ hockeyStick γ p q := by dsimp only [hockeyStick, pushforward] calc ∑ z : Ω, max 0 ((∑ x : α, p x * K x z) - γ * ∑ x : α, q x * K x z) = ∑ z : Ω, max 0 (∑ x : α, (p x - γ * q x) * K x z) := by refine Finset.sum_congr rfl fun z _ => ?_ congr 1 rw [Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun x _ => by ring _ ≤ ∑ z : Ω, ∑ x : α, max 0 ((p x - γ * q x) * K x z) := by refine Finset.sum_le_sum fun z _ => max_le (Finset.sum_nonneg fun _ _ => le_max_left _ _) (Finset.sum_le_sum fun x _ => le_max_right _ _) _ = ∑ x : α, ∑ z : Ω, max 0 (p x - γ * q x) * K x z := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun z _ => ?_ have hkz : 0 ≤ K x z := (hK x).1 z rcases le_total (p x - γ * q x) 0 with h | h · rw [max_eq_left h, zero_mul, max_eq_left (mul_nonpos_of_nonpos_of_nonneg h hkz)] · rw [max_eq_right h, max_eq_right (mul_nonneg h hkz)] _ = ∑ x : α, max 0 (p x - γ * q x) := by refine Finset.sum_congr rfl fun x _ => ?_ rw [← Finset.mul_sum, (hK x).2, mul_one] /-- **Exact Bhattacharyya Coefficient Data Processing Inequality**: For EVERY Markov kernel `K` and probability distributions `p, q`, `BC(p, q) ≤ BC(K p, K q)` (equivalently, squared Hellinger contracts under post-processing!). -/ theorem bhattCoeff_dpi {α Ω : Type*} [Fintype α] [Fintype Ω] {K : α → Ω → ℝ} {p q : α → ℝ} (hK : IsMarkovKernel K) (hp : ∀ x, 0 ≤ p x) (hq : ∀ x, 0 ≤ q x) : bhattCoeff p q ≤ bhattCoeff (pushforward K p) (pushforward K q) := by dsimp only [bhattCoeff, pushforward] have hcs : ∀ z : Ω, ∑ x : α, Real.sqrt (p x * K x z) * Real.sqrt (q x * K x z) ≤ Real.sqrt ((∑ x : α, p x * K x z) * (∑ x : α, q x * K x z)) := by intro z have hsq : (∑ x : α, Real.sqrt (p x * K x z) * Real.sqrt (q x * K x z)) ^ 2 ≤ (∑ x : α, Real.sqrt (p x * K x z) ^ 2) * (∑ x : α, Real.sqrt (q x * K x z) ^ 2) := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ _ _ have h1 : ∀ x : α, Real.sqrt (p x * K x z) ^ 2 = p x * K x z := fun x => Real.sq_sqrt (mul_nonneg (hp x) ((hK x).1 z)) have h2 : ∀ x : α, Real.sqrt (q x * K x z) ^ 2 = q x * K x z := fun x => Real.sq_sqrt (mul_nonneg (hq x) ((hK x).1 z)) simp_rw [h1, h2] at hsq exact Real.le_sqrt_of_sq_le hsq calc ∑ x : α, Real.sqrt (p x * q x) = ∑ x : α, Real.sqrt (p x * q x) * ∑ z : Ω, K x z := by refine Finset.sum_congr rfl fun x _ => ?_; rw [(hK x).2, mul_one] _ = ∑ z : Ω, ∑ x : α, Real.sqrt (p x * K x z) * Real.sqrt (q x * K x z) := by simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun z _ => Finset.sum_congr rfl fun x _ => ?_ have hkz : 0 ≤ K x z := (hK x).1 z rw [← Real.sqrt_mul (mul_nonneg (hp x) hkz), show p x * K x z * (q x * K x z) = (p x * q x) * (K x z * K x z) by ring, Real.sqrt_mul (mul_nonneg (hp x) (hq x)), Real.sqrt_mul_self hkz] _ ≤ ∑ z : Ω, Real.sqrt ((∑ x : α, p x * K x z) * (∑ x : α, q x * K x z)) := Finset.sum_le_sum fun z _ => hcs z /-- **Blackwell Dominance Implies Universal Hockey-Stick, TV, and Bhattacharyya Dominance**. -/ theorem blackwellDom_hockeyStick_le {α Ω : Type*} [Fintype α] [Fintype Ω] {p q : Ω → ℝ} {pStar qStar : α → ℝ} (hdom : BlackwellDom p q pStar qStar) (γ : ℝ) : hockeyStick γ p q ≤ hockeyStick γ pStar qStar := by rcases hdom with ⟨K, hK, rfl, rfl⟩ exact hockeyStick_dpi hK γ pStar qStar theorem blackwellDom_tvDist_le {α Ω : Type*} [Fintype α] [Fintype Ω] {p q : Ω → ℝ} {pStar qStar : α → ℝ} (hpStar : IsProbDist pStar) (hqStar : IsProbDist qStar) (hdom : BlackwellDom p q pStar qStar) : tvDist p q ≤ tvDist pStar qStar := by rcases hdom with ⟨K, hK, rfl, rfl⟩ rw [← hockeyStick_one_eq_tvDist (pushforward_isProbDist hK hpStar) (pushforward_isProbDist hK hqStar), ← hockeyStick_one_eq_tvDist hpStar hqStar] exact hockeyStick_dpi hK 1 pStar qStar theorem blackwellDom_bhattCoeff_ge {α Ω : Type*} [Fintype α] [Fintype Ω] {p q : Ω → ℝ} {pStar qStar : α → ℝ} (hpStar : ∀ x, 0 ≤ pStar x) (hqStar : ∀ x, 0 ≤ qStar x) (hdom : BlackwellDom p q pStar qStar) : bhattCoeff pStar qStar ≤ bhattCoeff p q := by rcases hdom with ⟨K, hK, rfl, rfl⟩ exact bhattCoeff_dpi hK hpStar hqStar /-- **General Convex `f`-Divergence Data Processing Inequality** (with `f` convex on `[0, ∞)` and strictly positive reference distribution `qStar > 0` on support): if `(p, q)` is Blackwell-dominated by `(pStar, qStar)` with `qStar > 0` and `q > 0`, then `∑ z, q z * f (p z / q z) ≤ ∑ x, qStar x * f (pStar x / qStar x)`. -/ theorem blackwellDom_fDiv_le {α Ω : Type*} [Fintype α] [Fintype Ω] {f : ℝ → ℝ} (hf : ConvexOn ℝ (Set.Ici (0 : ℝ)) f) {p q : Ω → ℝ} {pStar qStar : α → ℝ} (hpStar : ∀ x, 0 ≤ pStar x) (hqStar : ∀ x, 0 < qStar x) (hq : ∀ z, 0 < q z) (hdom : BlackwellDom p q pStar qStar) : ∑ z : Ω, q z * f (p z / q z) ≤ ∑ x : α, qStar x * f (pStar x / qStar x) := by rcases hdom with ⟨K, hK, rfl, rfl⟩ have hpt : ∀ z : Ω, pushforward K qStar z * f (pushforward K pStar z / pushforward K qStar z) ≤ ∑ x : α, qStar x * K x z * f (pStar x / qStar x) := by intro z have hqz : 0 < pushforward K qStar z := hq z let w : α → ℝ := fun x => qStar x * K x z / pushforward K qStar z have hw_nn : ∀ x ∈ (Finset.univ : Finset α), 0 ≤ w x := fun x _ => div_nonneg (mul_nonneg (le_of_lt (hqStar x)) ((hK x).1 z)) (le_of_lt hqz) have hw_sum : ∑ x ∈ (Finset.univ : Finset α), w x = 1 := by dsimp only [w] rw [← Finset.sum_div] exact div_self (ne_of_gt hqz) have hmem : ∀ x ∈ (Finset.univ : Finset α), pStar x / qStar x ∈ Set.Ici (0 : ℝ) := fun x _ => div_nonneg (hpStar x) (le_of_lt (hqStar x)) have hj := hf.map_sum_le hw_nn hw_sum hmem have harg : ∑ x : α, w x • (pStar x / qStar x) = pushforward K pStar z / pushforward K qStar z := by dsimp only [w, pushforward] simp_rw [smul_eq_mul, div_mul_eq_mul_div, ← Finset.sum_div] congr 1 refine Finset.sum_congr rfl fun x _ => ?_ have hqx : qStar x ≠ 0 := ne_of_gt (hqStar x) field_simp [hqx] rw [harg] at hj have hmul := mul_le_mul_of_nonneg_left hj (le_of_lt hqz) calc pushforward K qStar z * f (pushforward K pStar z / pushforward K qStar z) ≤ pushforward K qStar z * ∑ x : α, w x • f (pStar x / qStar x) := hmul _ = ∑ x : α, qStar x * K x z * f (pStar x / qStar x) := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => ?_ dsimp only [w] rw [smul_eq_mul] field_simp [ne_of_gt hqz] calc ∑ z : Ω, pushforward K qStar z * f (pushforward K pStar z / pushforward K qStar z) ≤ ∑ z : Ω, ∑ x : α, qStar x * K x z * f (pStar x / qStar x) := Finset.sum_le_sum fun z _ => hpt z _ = ∑ x : α, (qStar x * f (pStar x / qStar x)) * ∑ z : Ω, K x z := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun z _ => by ring _ = ∑ x : α, qStar x * f (pStar x / qStar x) := by refine Finset.sum_congr rfl fun x _ => by rw [(hK x).2, mul_one] /-! ### Canonical 4-Outcome `(ε, δ)`-DP Dominating Pair `(canonP ε δ, canonQ ε δ)` -/ /-- Canonical 4-outcome `(ε, δ)`-DP distribution `P*_{ε,δ}` on `Fin 4`: `(δ, (1 - δ) e^ε / (e^ε + 1), (1 - δ) / (e^ε + 1), 0)`. -/ noncomputable def canonP (ε δ : ℝ) : Fin 4 → ℝ | ⟨0, _⟩ => δ | ⟨1, _⟩ => (1 - δ) * Real.exp ε / (Real.exp ε + 1) | ⟨2, _⟩ => (1 - δ) / (Real.exp ε + 1) | ⟨3, _⟩ => 0 /-- Canonical 4-outcome `(ε, δ)`-DP distribution `Q*_{ε,δ}` on `Fin 4`: `(0, (1 - δ) / (e^ε + 1), (1 - δ) e^ε / (e^ε + 1), δ)`. -/ noncomputable def canonQ (ε δ : ℝ) : Fin 4 → ℝ | ⟨0, _⟩ => 0 | ⟨1, _⟩ => (1 - δ) / (Real.exp ε + 1) | ⟨2, _⟩ => (1 - δ) * Real.exp ε / (Real.exp ε + 1) | ⟨3, _⟩ => δ lemma canonP_isProbDist {ε δ : ℝ} (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : IsProbDist (canonP ε δ) := by have he : 0 < Real.exp ε := Real.exp_pos ε have hep : 0 < Real.exp ε + 1 := by linarith refine ⟨fun i => ?_, ?_⟩ · fin_cases i <;> dsimp only [canonP] · exact hδ0 · exact div_nonneg (mul_nonneg (by linarith) (le_of_lt he)) (le_of_lt hep) · exact div_nonneg (by linarith) (le_of_lt hep) · exact le_rfl · rw [Fin.sum_univ_four] dsimp only [canonP] field_simp [ne_of_gt hep]; ring lemma canonQ_isProbDist {ε δ : ℝ} (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : IsProbDist (canonQ ε δ) := by have he : 0 < Real.exp ε := Real.exp_pos ε have hep : 0 < Real.exp ε + 1 := by linarith refine ⟨fun i => ?_, ?_⟩ · fin_cases i <;> dsimp only [canonQ] · exact le_rfl · exact div_nonneg (by linarith) (le_of_lt hep) · exact div_nonneg (mul_nonneg (by linarith) (le_of_lt he)) (le_of_lt hep) · exact hδ0 · rw [Fin.sum_univ_four] dsimp only [canonQ] field_simp [ne_of_gt hep]; ring /-- Exact hockey-stick divergence of the canonical 4-outcome pair at ANY `γ ≥ 1`. -/ theorem canonPair_hockeyStick_general {ε δ γ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (hγ : 1 ≤ γ) : hockeyStick γ (canonP ε δ) (canonQ ε δ) = δ + (1 - δ) * max 0 (Real.exp ε - γ) / (Real.exp ε + 1) := by have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have hep : 0 < Real.exp ε + 1 := by linarith dsimp only [hockeyStick] rw [Fin.sum_univ_four] dsimp only [canonP, canonQ] have h0 : max 0 (δ - γ * 0) = δ := by rw [mul_zero, sub_zero, max_eq_right hδ0] have h3 : max 0 (0 - γ * δ) = 0 := max_eq_left (by nlinarith) have h2 : max 0 ((1 - δ) / (Real.exp ε + 1) - γ * ((1 - δ) * Real.exp ε / (Real.exp ε + 1))) = 0 := by refine max_eq_left ?_ have hnum : (1 - δ) * (1 - γ * Real.exp ε) ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (by linarith) (by nlinarith) have heq : (1 - δ) / (Real.exp ε + 1) - γ * ((1 - δ) * Real.exp ε / (Real.exp ε + 1)) = (1 - δ) * (1 - γ * Real.exp ε) / (Real.exp ε + 1) := by ring rw [heq] exact div_nonpos_of_nonpos_of_nonneg hnum (le_of_lt hep) have h1 : max 0 ((1 - δ) * Real.exp ε / (Real.exp ε + 1) - γ * ((1 - δ) / (Real.exp ε + 1))) = (1 - δ) * max 0 (Real.exp ε - γ) / (Real.exp ε + 1) := by have heq : (1 - δ) * Real.exp ε / (Real.exp ε + 1) - γ * ((1 - δ) / (Real.exp ε + 1)) = (1 - δ) * (Real.exp ε - γ) / (Real.exp ε + 1) := by ring rw [heq] rcases le_total (Real.exp ε - γ) 0 with h | h · rw [max_eq_left h, mul_zero, zero_div] exact max_eq_left (div_nonpos_of_nonpos_of_nonneg (mul_nonpos_of_nonneg_of_nonpos (by linarith) h) (le_of_lt hep)) · rw [max_eq_right h] exact max_eq_right (div_nonneg (mul_nonneg (by linarith) h) (le_of_lt hep)) rw [h0, h1, h2, h3]; ring /-- Symmetry of hockey-stick divergence on the canonical 4-outcome pair. -/ lemma canonPair_hockeyStick_symm (ε δ γ : ℝ) : hockeyStick γ (canonQ ε δ) (canonP ε δ) = hockeyStick γ (canonP ε δ) (canonQ ε δ) := by dsimp only [hockeyStick] rw [Fin.sum_univ_four, Fin.sum_univ_four] dsimp only [canonP, canonQ] ring theorem canonPair_isEpsDeltaClose {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : IsEpsDeltaClose ε δ (canonP ε δ) (canonQ ε δ) := by have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have hfwd : hockeyStick (Real.exp ε) (canonP ε δ) (canonQ ε δ) = δ := by rw [canonPair_hockeyStick_general hε hδ0 hδ1 he1, sub_self, max_self, mul_zero, zero_div, add_zero] exact ⟨le_of_eq hfwd, le_of_eq ((canonPair_hockeyStick_symm ε δ (Real.exp ε)).trans hfwd)⟩ theorem canonPair_tvDist_exact {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : tvDist (canonP ε δ) (canonQ ε δ) = (Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1) := by have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have hep : 0 < Real.exp ε + 1 := by linarith rw [← hockeyStick_one_eq_tvDist (canonP_isProbDist hδ0 hδ1) (canonQ_isProbDist hδ0 hδ1), canonPair_hockeyStick_general hε hδ0 hδ1 le_rfl, max_eq_right (by linarith)] field_simp [ne_of_gt hep]; ring theorem canonPair_bhattCoeff_exact {ε δ : ℝ} (_hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : bhattCoeff (canonP ε δ) (canonQ ε δ) = 2 * (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1) := by have he : 0 < Real.exp ε := Real.exp_pos ε have hep : 0 < Real.exp ε + 1 := by linarith have h1d : 0 ≤ 1 - δ := by linarith have hsqrt_e : Real.sqrt (Real.exp ε) = Real.exp (ε / 2) := by conv_lhs => rw [show ε = ε / 2 + ε / 2 by ring, Real.exp_add] exact Real.sqrt_mul_self (le_of_lt (Real.exp_pos _)) dsimp only [bhattCoeff] rw [Fin.sum_univ_four] dsimp only [canonP, canonQ] have hterm : Real.sqrt ((1 - δ) * Real.exp ε / (Real.exp ε + 1) * ((1 - δ) / (Real.exp ε + 1))) = (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1) := by have heq : (1 - δ) * Real.exp ε / (Real.exp ε + 1) * ((1 - δ) / (Real.exp ε + 1)) = ((1 - δ) / (Real.exp ε + 1)) ^ 2 * Real.exp ε := by ring rw [heq, Real.sqrt_mul (sq_nonneg _), Real.sqrt_sq (div_nonneg h1d (le_of_lt hep)), hsqrt_e] ring have hterm2 : Real.sqrt ((1 - δ) / (Real.exp ε + 1) * ((1 - δ) * Real.exp ε / (Real.exp ε + 1))) = (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1) := by rw [mul_comm]; exact hterm rw [mul_zero, zero_mul, Real.sqrt_zero, hterm, hterm2]; ring /-- Helper: given nonnegative weights `a, b, c, d : Ω → ℝ` satisfying the exact conical representation `p = a + e b + c`, `q = b + e c + d` with totals `∑ a = δ`, `∑ b = B`, `∑ c = B`, `∑ d = δ` where `B = (1 - δ) / (e + 1)`, assemble a valid Markov kernel `K : Fin 4 → Ω → ℝ` pushing `(canonP ε δ, canonQ ε δ)` onto `(p, q)`. -/ private lemma blackwellDom_of_cone_decomp {Ω : Type*} [Fintype Ω] [Nonempty Ω] {ε δ : ℝ} (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) {p q a b c d : Ω → ℝ} (ha : ∀ z, 0 ≤ a z) (hb : ∀ z, 0 ≤ b z) (hc : ∀ z, 0 ≤ c z) (hd : ∀ z, 0 ≤ d z) (hsa : ∑ z, a z = δ) (hsb : ∑ z, b z = (1 - δ) / (Real.exp ε + 1)) (hsc : ∑ z, c z = (1 - δ) / (Real.exp ε + 1)) (hsd : ∑ z, d z = δ) (hp : ∀ z, a z + Real.exp ε * b z + c z = p z) (hq : ∀ z, b z + Real.exp ε * c z + d z = q z) : BlackwellDom p q (canonP ε δ) (canonQ ε δ) := by classical let z0 : Ω := Classical.arbitrary Ω let e : ℝ := Real.exp ε let B : ℝ := (1 - δ) / (e + 1) have he_pos : 0 < e := Real.exp_pos ε have hep_pos : 0 < e + 1 := by linarith have hB_nn : 0 ≤ B := div_nonneg (by linarith) (le_of_lt hep_pos) let unif : Ω → ℝ := fun z => if z = z0 then 1 else 0 have hunif_prob : IsProbDist unif := by refine ⟨fun z => by dsimp only [unif]; split_ifs <;> norm_num, ?_⟩ dsimp only [unif]; simp let K : Fin 4 → Ω → ℝ | ⟨0, _⟩ => if δ = 0 then unif else fun z => a z / δ | ⟨1, _⟩ => if B = 0 then unif else fun z => b z / B | ⟨2, _⟩ => if B = 0 then unif else fun z => c z / B | ⟨3, _⟩ => if δ = 0 then unif else fun z => d z / δ have hK : IsMarkovKernel K := by intro i fin_cases i <;> dsimp only [K] · split_ifs with h0 · exact hunif_prob · have hpos : 0 < δ := lt_of_le_of_ne hδ0 (Ne.symm h0) exact ⟨fun z => div_nonneg (ha z) (le_of_lt hpos), by rw [← Finset.sum_div, hsa, div_self h0]⟩ · split_ifs with h0 · exact hunif_prob · have hpos : 0 < B := lt_of_le_of_ne hB_nn (Ne.symm h0) exact ⟨fun z => div_nonneg (hb z) (le_of_lt hpos), by rw [← Finset.sum_div, hsb, div_self h0]⟩ · split_ifs with h0 · exact hunif_prob · have hpos : 0 < B := lt_of_le_of_ne hB_nn (Ne.symm h0) exact ⟨fun z => div_nonneg (hc z) (le_of_lt hpos), by rw [← Finset.sum_div, hsc, div_self h0]⟩ · split_ifs with h0 · exact hunif_prob · have hpos : 0 < δ := lt_of_le_of_ne hδ0 (Ne.symm h0) exact ⟨fun z => div_nonneg (hd z) (le_of_lt hpos), by rw [← Finset.sum_div, hsd, div_self h0]⟩ have hzero_a : δ = 0 → ∀ z, a z = 0 := fun h0 z => le_antisymm (by rw [← h0, ← hsa]; exact Finset.single_le_sum (fun w _ => ha w) (Finset.mem_univ z)) (ha z) have hzero_d : δ = 0 → ∀ z, d z = 0 := fun h0 z => le_antisymm (by rw [← h0, ← hsd]; exact Finset.single_le_sum (fun w _ => hd w) (Finset.mem_univ z)) (hd z) have hzero_b : B = 0 → ∀ z, b z = 0 := fun h0 z => le_antisymm (by have hsb' : ∑ w, b w = B := hsb; rw [← h0, ← hsb']; exact Finset.single_le_sum (fun w _ => hb w) (Finset.mem_univ z)) (hb z) have hzero_c : B = 0 → ∀ z, c z = 0 := fun h0 z => le_antisymm (by have hsc' : ∑ w, c w = B := hsc; rw [← h0, ← hsc']; exact Finset.single_le_sum (fun w _ => hc w) (Finset.mem_univ z)) (hc z) refine ⟨K, hK, ?_, ?_⟩ · funext z dsimp only [pushforward] rw [Fin.sum_univ_four] have ht0 : canonP ε δ 0 * K 0 z = a z := by dsimp only [canonP, K] split_ifs with h0 · rw [h0, zero_mul, hzero_a h0 z] · exact mul_div_cancel₀ _ h0 have ht1 : canonP ε δ 1 * K 1 z = e * b z := by dsimp only [canonP, K] have hBe : (1 - δ) * Real.exp ε / (Real.exp ε + 1) = e * B := by dsimp only [e, B]; ring rw [hBe] split_ifs with h0 · rw [h0, mul_zero, zero_mul, hzero_b h0 z, mul_zero] · rw [mul_assoc, mul_div_cancel₀ _ h0] have ht2 : canonP ε δ 2 * K 2 z = c z := by dsimp only [canonP, K] have hB' : (1 - δ) / (Real.exp ε + 1) = B := rfl rw [hB'] split_ifs with h0 · rw [h0, zero_mul, hzero_c h0 z] · exact mul_div_cancel₀ _ h0 have ht3 : canonP ε δ 3 * K 3 z = 0 := by dsimp only [canonP]; rw [zero_mul] rw [ht0, ht1, ht2, ht3, add_zero] exact hp z · funext z dsimp only [pushforward] rw [Fin.sum_univ_four] have ht0 : canonQ ε δ 0 * K 0 z = 0 := by dsimp only [canonQ]; rw [zero_mul] have ht1 : canonQ ε δ 1 * K 1 z = b z := by dsimp only [canonQ, K] have hB' : (1 - δ) / (Real.exp ε + 1) = B := rfl rw [hB'] split_ifs with h0 · rw [h0, zero_mul, hzero_b h0 z] · exact mul_div_cancel₀ _ h0 have ht2 : canonQ ε δ 2 * K 2 z = e * c z := by dsimp only [canonQ, K] have hBe : (1 - δ) * Real.exp ε / (Real.exp ε + 1) = e * B := by dsimp only [e, B]; ring rw [hBe] split_ifs with h0 · rw [h0, mul_zero, zero_mul, hzero_c h0 z, mul_zero] · rw [mul_assoc, mul_div_cancel₀ _ h0] have ht3 : canonQ ε δ 3 * K 3 z = d z := by dsimp only [canonQ, K] split_ifs with h0 · rw [h0, zero_mul, hzero_d h0 z] · exact mul_div_cancel₀ _ h0 rw [ht0, ht1, ht2, ht3, zero_add] exact hq z /-- **CONSTRUCTIVE 4-OUTCOME BLACKWELL DOMINANCE THEOREM FOR `(ε, δ)`-DP**: For EVERY finite type `Ω`, EVERY `ε ≥ 0`, `δ ∈ [0, 1]`, and EVERY pair of probability distributions `(p, q)` satisfying `IsEpsDeltaClose ε δ p q`, there exists an **EXPLICIT** Markov kernel `K : Fin 4 → Ω → ℝ` pushing `(canonP ε δ, canonQ ε δ)` onto `(p, q)`! -/ theorem epsDelta_blackwell_dominance {Ω : Type*} [Fintype Ω] {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) {p q : Ω → ℝ} (hp : IsProbDist p) (hq : IsProbDist q) (hdp : IsEpsDeltaClose ε δ p q) : BlackwellDom p q (canonP ε δ) (canonQ ε δ) := by have hne : Nonempty Ω := by by_contra hemp have hEmpty : IsEmpty Ω := not_nonempty_iff.mp hemp have h0 : ∑ z : Ω, p z = 0 := Finset.sum_eq_zero fun z _ => hEmpty.elim z linarith [hp.2] -- Case 0: δ = 1 (trivial: K(0)=p, K(3)=q, and canonP 1 = (1,0,0,0), canonQ 1 = (0,0,0,1)!) by_cases hδ_one : δ = 1 · subst hδ_one refine blackwellDom_of_cone_decomp hδ0 le_rfl hp.1 (fun _ => le_rfl) (fun _ => le_rfl) hq.1 hp.2 (by simp) (by simp) hq.2 (fun z => by ring) (fun z => by ring) have hδ_lt1 : δ < 1 := lt_of_le_of_ne hδ1 hδ_one -- Case 1: ε = 0 (e = 1; decompose via m = min p q!) by_cases hε0 : ε = 0 · subst hε0 have he1 : Real.exp 0 = 1 := Real.exp_zero let a0 : Ω → ℝ := fun z => max 0 (p z - q z) let d0 : Ω → ℝ := fun z => max 0 (q z - p z) let m : Ω → ℝ := fun z => min (p z) (q z) have ha0_nn : ∀ z, 0 ≤ a0 z := fun z => le_max_left _ _ have hd0_nn : ∀ z, 0 ≤ d0 z := fun z => le_max_left _ _ have hm_nn : ∀ z, 0 ≤ m z := fun z => le_min (hp.1 z) (hq.1 z) have hpm : ∀ z, a0 z + m z = p z := fun z => by dsimp only [a0, m]; rcases le_total (p z) (q z) with h | h · rw [max_eq_left (by linarith), min_eq_left h, zero_add] · rw [max_eq_right (by linarith), min_eq_right h]; ring have hqm : ∀ z, d0 z + m z = q z := fun z => by dsimp only [d0, m]; rcases le_total (p z) (q z) with h | h · rw [max_eq_right (by linarith), min_eq_left h]; ring · rw [max_eq_left (by linarith), min_eq_right h, zero_add] have hsa_le : ∑ z, a0 z ≤ δ := by have h := hdp.1; dsimp only [hockeyStick] at h; rw [he1] at h simpa [a0, one_mul] using h have hsm : ∑ z, m z = 1 - ∑ z, a0 z := by have h := Finset.sum_congr (s₁ := Finset.univ) (s₂ := Finset.univ) rfl (fun z _ => hpm z) rw [Finset.sum_add_distrib, hp.2] at h; linarith have hsd_eq : ∑ z, d0 z = ∑ z, a0 z := by have h := Finset.sum_congr (s₁ := Finset.univ) (s₂ := Finset.univ) rfl (fun z _ => hqm z) rw [Finset.sum_add_distrib, hq.2] at h; linarith have hsm_pos : 0 < ∑ z, m z := by linarith let θ : ℝ := (1 - δ) / ∑ z, m z have hθ0 : 0 ≤ θ := div_nonneg (by linarith) (le_of_lt hsm_pos) have hθ1 : θ ≤ 1 := (div_le_one hsm_pos).mpr (by linarith) let a : Ω → ℝ := fun z => a0 z + (1 - θ) * m z let b : Ω → ℝ := fun z => (θ / 2) * m z let c : Ω → ℝ := fun z => (θ / 2) * m z let d : Ω → ℝ := fun z => d0 z + (1 - θ) * m z refine blackwellDom_of_cone_decomp (a := a) (b := b) (c := c) (d := d) hδ0 hδ1 (fun z => add_nonneg (ha0_nn z) (mul_nonneg (by linarith) (hm_nn z))) (fun z => mul_nonneg (by linarith) (hm_nn z)) (fun z => mul_nonneg (by linarith) (hm_nn z)) (fun z => add_nonneg (hd0_nn z) (mul_nonneg (by linarith) (hm_nn z))) ?_ ?_ ?_ ?_ ?_ ?_ · dsimp only [a]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] dsimp only [θ]; field_simp [ne_of_gt hsm_pos]; linarith · dsimp only [b]; rw [← Finset.mul_sum, he1] dsimp only [θ]; field_simp [ne_of_gt hsm_pos]; ring · dsimp only [c]; rw [← Finset.mul_sum, he1] dsimp only [θ]; field_simp [ne_of_gt hsm_pos]; ring · dsimp only [d]; rw [Finset.sum_add_distrib, ← Finset.mul_sum, hsd_eq] dsimp only [θ]; field_simp [ne_of_gt hsm_pos]; linarith · intro z; dsimp only [a, b, c]; rw [he1]; linarith [hpm z] · intro z; dsimp only [b, c, d]; rw [he1]; linarith [hqm z] -- Case 2: ε > 0 and δ < 1 — our exact 3-regime closed-form conical decomposition! have hε_pos : 0 < ε := lt_of_le_of_ne hε (Ne.symm hε0) set e : ℝ := Real.exp ε have he_gt1 : 1 < e := Real.one_lt_exp_iff.mpr hε_pos have he_pos : 0 < e := by linarith have hep_pos : 0 < e + 1 := by linarith have he2m1_pos : 0 < e ^ 2 - 1 := by nlinarith set B : ℝ := (1 - δ) / (e + 1) have hB_pos : 0 < B := div_pos (by linarith) hep_pos -- Step 1: peel off excess a0 = max(0, p - e*q), d0 = max(0, q - e*p), and solve 2x2 cone! let a0 : Ω → ℝ := fun z => max 0 (p z - e * q z) let d0 : Ω → ℝ := fun z => max 0 (q z - e * p z) let pm : Ω → ℝ := fun z => p z - a0 z let qm : Ω → ℝ := fun z => q z - d0 z let b0 : Ω → ℝ := fun z => (e * pm z - qm z) / (e ^ 2 - 1) let c0 : Ω → ℝ := fun z => (e * qm z - pm z) / (e ^ 2 - 1) have ha0_nn : ∀ z, 0 ≤ a0 z := fun _ => le_max_left _ _ have hd0_nn : ∀ z, 0 ≤ d0 z := fun _ => le_max_left _ _ have hpm_le : ∀ z, pm z ≤ e * qm z := by intro z dsimp only [pm, qm, a0, d0] rcases le_total (p z) (e * q z) with hp1 | hp1 · rw [max_eq_left (by linarith), sub_zero] rcases le_total (q z) (e * p z) with hq1 | hq1 · rw [max_eq_left (by linarith), sub_zero]; exact hp1 · rw [max_eq_right (by linarith)] have : q z - (q z - e * p z) = e * p z := by ring rw [this]; nlinarith [hp.1 z] · rw [max_eq_right (by linarith)] have h1 : p z - (p z - e * q z) = e * q z := by ring rw [h1] have hq1 : q z ≤ e * p z := by nlinarith [hq.1 z] rw [max_eq_left (by linarith), sub_zero] have hqm_le : ∀ z, qm z ≤ e * pm z := by intro z dsimp only [pm, qm, a0, d0] rcases le_total (q z) (e * p z) with hq1 | hq1 · rw [max_eq_left (by linarith), sub_zero] rcases le_total (p z) (e * q z) with hp1 | hp1 · rw [max_eq_left (by linarith), sub_zero]; exact hq1 · rw [max_eq_right (by linarith)] have : p z - (p z - e * q z) = e * q z := by ring rw [this]; nlinarith [hq.1 z] · rw [max_eq_right (by linarith)] have h1 : q z - (q z - e * p z) = e * p z := by ring rw [h1] have hp1 : p z ≤ e * q z := by nlinarith [hp.1 z] rw [max_eq_left (by linarith), sub_zero] have hb0_nn : ∀ z, 0 ≤ b0 z := fun z => div_nonneg (by linarith [hqm_le z]) (le_of_lt he2m1_pos) have hc0_nn : ∀ z, 0 ≤ c0 z := fun z => div_nonneg (by linarith [hpm_le z]) (le_of_lt he2m1_pos) have hrep_p : ∀ z, a0 z + e * b0 z + c0 z = p z := fun z => by dsimp only [b0, c0, pm, qm]; field_simp [ne_of_gt he2m1_pos]; ring have hrep_q : ∀ z, b0 z + e * c0 z + d0 z = q z := fun z => by dsimp only [b0, c0, pm, qm]; field_simp [ne_of_gt he2m1_pos]; ring set sa : ℝ := ∑ z, a0 z set sb : ℝ := ∑ z, b0 z set sc : ℝ := ∑ z, c0 z set sd : ℝ := ∑ z, d0 z have hsb_nn : 0 ≤ sb := Finset.sum_nonneg fun z _ => hb0_nn z have hsc_nn : 0 ≤ sc := Finset.sum_nonneg fun z _ => hc0_nn z have hsum_p : sa + e * sb + sc = 1 := by have h := Finset.sum_congr (s₁ := Finset.univ) (s₂ := Finset.univ) rfl (fun z _ => hrep_p z) simp_rw [Finset.sum_add_distrib, ← Finset.mul_sum] at h rw [hp.2] at h; exact h have hsum_q : sb + e * sc + sd = 1 := by have h := Finset.sum_congr (s₁ := Finset.univ) (s₂ := Finset.univ) rfl (fun z _ => hrep_q z) simp_rw [Finset.sum_add_distrib, ← Finset.mul_sum] at h rw [hq.2] at h; exact h set da : ℝ := δ - sa set dd : ℝ := δ - sd have hda_nn : 0 ≤ da := sub_nonneg.mpr hdp.1 have hdd_nn : 0 ≤ dd := sub_nonneg.mpr hdp.2 have hB_eq : δ + (e + 1) * B = 1 := by dsimp only [B]; field_simp [ne_of_gt hep_pos]; ring have hdiff_b : sb - B = (e * da - dd) / (e ^ 2 - 1) := by have h1 : e * (sb - B) + (sc - B) = da := by dsimp only [da]; linarith have h2 : (sb - B) + e * (sc - B) = dd := by dsimp only [dd]; linarith field_simp [ne_of_gt he2m1_pos]; nlinarith have hdiff_c : sc - B = (e * dd - da) / (e ^ 2 - 1) := by have h1 : e * (sb - B) + (sc - B) = da := by dsimp only [da]; linarith have h2 : (sb - B) + e * (sc - B) = dd := by dsimp only [dd]; linarith field_simp [ne_of_gt he2m1_pos]; nlinarith -- Now split into our exact 3 regimes! by_cases hreg1 : dd ≤ e * da ∧ da ≤ e * dd · -- Regime 1: both sb ≥ B and sc ≥ B! set x : ℝ := (e * da - dd) / (e ^ 2 - 1) set y : ℝ := (e * dd - da) / (e ^ 2 - 1) have hx_nn : 0 ≤ x := div_nonneg (by linarith [hreg1.1]) (le_of_lt he2m1_pos) have hy_nn : 0 ≤ y := div_nonneg (by linarith [hreg1.2]) (le_of_lt he2m1_pos) have hsb_eq : sb = B + x := by linarith [hdiff_b] have hsc_eq : sc = B + y := by linarith [hdiff_c] have hsb_pos : 0 < sb := by linarith have hsc_pos : 0 < sc := by linarith set fb : ℝ := x / sb set fc : ℝ := y / sc have hfb0 : 0 ≤ fb := div_nonneg hx_nn (le_of_lt hsb_pos) have hfb1 : fb ≤ 1 := (div_le_one hsb_pos).mpr (by linarith) have hfc0 : 0 ≤ fc := div_nonneg hy_nn (le_of_lt hsc_pos) have hfc1 : fc ≤ 1 := (div_le_one hsc_pos).mpr (by linarith) let a : Ω → ℝ := fun z => a0 z + e * fb * b0 z + fc * c0 z let b : Ω → ℝ := fun z => (1 - fb) * b0 z let c : Ω → ℝ := fun z => (1 - fc) * c0 z let d : Ω → ℝ := fun z => d0 z + fb * b0 z + e * fc * c0 z have hfb_sb : fb * sb = x := div_mul_cancel₀ _ (ne_of_gt hsb_pos) have hfc_sc : fc * sc = y := div_mul_cancel₀ _ (ne_of_gt hsc_pos) have hex_y : e * x + y = da := by dsimp only [x, y]; field_simp [ne_of_gt he2m1_pos]; ring have hx_ey : x + e * y = dd := by dsimp only [x, y]; field_simp [ne_of_gt he2m1_pos]; ring refine blackwellDom_of_cone_decomp (a := a) (b := b) (c := c) (d := d) hδ0 hδ1 (fun z => add_nonneg (add_nonneg (ha0_nn z) (mul_nonneg (mul_nonneg (le_of_lt he_pos) hfb0) (hb0_nn z))) (mul_nonneg hfc0 (hc0_nn z))) (fun z => mul_nonneg (by linarith) (hb0_nn z)) (fun z => mul_nonneg (by linarith) (hc0_nn z)) (fun z => add_nonneg (add_nonneg (hd0_nn z) (mul_nonneg hfb0 (hb0_nn z))) (mul_nonneg (mul_nonneg (le_of_lt he_pos) hfc0) (hc0_nn z))) ?_ ?_ ?_ ?_ ?_ ?_ · dsimp only [a]; simp_rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sa + e * fb * sb + fc * sc = δ rw [mul_assoc, hfb_sb, hfc_sc]; dsimp only [da] at hex_y; linarith · dsimp only [b]; rw [← Finset.mul_sum]; change (1 - fb) * sb = B rw [sub_mul, one_mul, hfb_sb]; linarith · dsimp only [c]; rw [← Finset.mul_sum]; change (1 - fc) * sc = B rw [sub_mul, one_mul, hfc_sc]; linarith · dsimp only [d]; simp_rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sd + fb * sb + e * fc * sc = δ rw [mul_assoc, hfb_sb, hfc_sc]; dsimp only [dd] at hx_ey; linarith · intro z; dsimp only [a, b, c]; linarith [hrep_p z] · intro z; dsimp only [b, c, d]; linarith [hrep_q z] · push Not at hreg1 by_cases hreg2 : e * da < dd · -- Regime 2: e * da < dd (so sc > B; split c0 into (v0, v1, v2, v3)!) set t1 : ℝ := da set t2 : ℝ := e * (dd - e * da) / (e ^ 2 - 1) have ht1_nn : 0 ≤ t1 := hda_nn have ht2_nn : 0 ≤ t2 := div_nonneg (mul_nonneg (le_of_lt he_pos) (by linarith)) (le_of_lt he2m1_pos) have ht_sum : t1 + t2 = sc - B := by rw [hdiff_c]; dsimp only [t1, t2]; field_simp [ne_of_gt he2m1_pos]; ring have hsc_pos : 0 < sc := by linarith set f1 : ℝ := t1 / sc set f2 : ℝ := t2 / sc have hf1_nn : 0 ≤ f1 := div_nonneg ht1_nn (le_of_lt hsc_pos) have hf2_nn : 0 ≤ f2 := div_nonneg ht2_nn (le_of_lt hsc_pos) have hf12_le : f1 + f2 ≤ 1 := by dsimp only [f1, f2]; rw [← add_div, div_le_one hsc_pos]; linarith have hf1_sc : f1 * sc = t1 := div_mul_cancel₀ _ (ne_of_gt hsc_pos) have hf2_sc : f2 * sc = t2 := div_mul_cancel₀ _ (ne_of_gt hsc_pos) let a : Ω → ℝ := fun z => a0 z + f1 * c0 z let b : Ω → ℝ := fun z => b0 z + (f2 / e) * c0 z let c : Ω → ℝ := fun z => (1 - f1 - f2) * c0 z let d : Ω → ℝ := fun z => d0 z + (e * f1 + (e - 1 / e) * f2) * c0 z have hcoef_d_nn : 0 ≤ e * f1 + (e - 1 / e) * f2 := by have he_sub : 0 ≤ e - 1 / e := by rw [sub_nonneg, div_le_iff₀ he_pos]; nlinarith exact add_nonneg (mul_nonneg (le_of_lt he_pos) hf1_nn) (mul_nonneg he_sub hf2_nn) refine blackwellDom_of_cone_decomp (a := a) (b := b) (c := c) (d := d) hδ0 hδ1 (fun z => add_nonneg (ha0_nn z) (mul_nonneg hf1_nn (hc0_nn z))) (fun z => add_nonneg (hb0_nn z) (mul_nonneg (div_nonneg hf2_nn (le_of_lt he_pos)) (hc0_nn z))) (fun z => mul_nonneg (by linarith) (hc0_nn z)) (fun z => add_nonneg (hd0_nn z) (mul_nonneg hcoef_d_nn (hc0_nn z))) ?_ ?_ ?_ ?_ ?_ ?_ · dsimp only [a]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sa + f1 * sc = δ; rw [hf1_sc]; dsimp only [t1, da]; ring · dsimp only [b]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sb + (f2 / e) * sc = B rw [div_mul_eq_mul_div, hf2_sc] have ht2e : t2 / e = -((e * da - dd) / (e ^ 2 - 1)) := by dsimp only [t2]; field_simp [ne_of_gt he_pos, ne_of_gt he2m1_pos]; ring rw [ht2e]; linarith [hdiff_b] · dsimp only [c]; rw [← Finset.mul_sum] change (1 - f1 - f2) * sc = B have : (1 - f1 - f2) * sc = sc - f1 * sc - f2 * sc := by ring rw [this, hf1_sc, hf2_sc]; linarith · dsimp only [d]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sd + (e * f1 + (e - 1 / e) * f2) * sc = δ have : (e * f1 + (e - 1 / e) * f2) * sc = e * (f1 * sc) + (e - 1 / e) * (f2 * sc) := by ring rw [this, hf1_sc, hf2_sc] have hdd_eq : e * t1 + (e - 1 / e) * t2 = dd := by dsimp only [t1, t2]; field_simp [ne_of_gt he_pos, ne_of_gt he2m1_pos]; ring rw [hdd_eq]; dsimp only [dd]; ring · intro z; dsimp only [a, b, c] have : a0 z + f1 * c0 z + e * (b0 z + f2 / e * c0 z) + (1 - f1 - f2) * c0 z = a0 z + e * b0 z + c0 z := by field_simp [ne_of_gt he_pos]; ring rw [this]; exact hrep_p z · intro z; dsimp only [b, c, d] have : b0 z + f2 / e * c0 z + e * ((1 - f1 - f2) * c0 z) + (d0 z + (e * f1 + (e - 1 / e) * f2) * c0 z) = b0 z + e * c0 z + d0 z := by field_simp [ne_of_gt he_pos]; ring rw [this]; exact hrep_q z · -- Regime 3: e * dd < da (symmetric to Regime 2; split b0!) have hreg3 : e * dd < da := hreg1 (not_lt.mp hreg2) set t1 : ℝ := dd set t2 : ℝ := e * (da - e * dd) / (e ^ 2 - 1) have ht1_nn : 0 ≤ t1 := hdd_nn have ht2_nn : 0 ≤ t2 := div_nonneg (mul_nonneg (le_of_lt he_pos) (by linarith)) (le_of_lt he2m1_pos) have ht_sum : t1 + t2 = sb - B := by rw [hdiff_b]; dsimp only [t1, t2]; field_simp [ne_of_gt he2m1_pos]; ring have hsb_pos : 0 < sb := by linarith set f1 : ℝ := t1 / sb set f2 : ℝ := t2 / sb have hf1_nn : 0 ≤ f1 := div_nonneg ht1_nn (le_of_lt hsb_pos) have hf2_nn : 0 ≤ f2 := div_nonneg ht2_nn (le_of_lt hsb_pos) have hf12_le : f1 + f2 ≤ 1 := by dsimp only [f1, f2]; rw [← add_div, div_le_one hsb_pos]; linarith have hf1_sb : f1 * sb = t1 := div_mul_cancel₀ _ (ne_of_gt hsb_pos) have hf2_sb : f2 * sb = t2 := div_mul_cancel₀ _ (ne_of_gt hsb_pos) let a : Ω → ℝ := fun z => a0 z + (e * f1 + (e - 1 / e) * f2) * b0 z let b : Ω → ℝ := fun z => (1 - f1 - f2) * b0 z let c : Ω → ℝ := fun z => c0 z + (f2 / e) * b0 z let d : Ω → ℝ := fun z => d0 z + f1 * b0 z have hcoef_a_nn : 0 ≤ e * f1 + (e - 1 / e) * f2 := by have he_sub : 0 ≤ e - 1 / e := by rw [sub_nonneg, div_le_iff₀ he_pos]; nlinarith exact add_nonneg (mul_nonneg (le_of_lt he_pos) hf1_nn) (mul_nonneg he_sub hf2_nn) refine blackwellDom_of_cone_decomp (a := a) (b := b) (c := c) (d := d) hδ0 hδ1 (fun z => add_nonneg (ha0_nn z) (mul_nonneg hcoef_a_nn (hb0_nn z))) (fun z => mul_nonneg (by linarith) (hb0_nn z)) (fun z => add_nonneg (hc0_nn z) (mul_nonneg (div_nonneg hf2_nn (le_of_lt he_pos)) (hb0_nn z))) (fun z => add_nonneg (hd0_nn z) (mul_nonneg hf1_nn (hb0_nn z))) ?_ ?_ ?_ ?_ ?_ ?_ · dsimp only [a]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sa + (e * f1 + (e - 1 / e) * f2) * sb = δ have : (e * f1 + (e - 1 / e) * f2) * sb = e * (f1 * sb) + (e - 1 / e) * (f2 * sb) := by ring rw [this, hf1_sb, hf2_sb] have hda_eq : e * t1 + (e - 1 / e) * t2 = da := by dsimp only [t1, t2]; field_simp [ne_of_gt he_pos, ne_of_gt he2m1_pos]; ring rw [hda_eq]; dsimp only [da]; ring · dsimp only [b]; rw [← Finset.mul_sum] change (1 - f1 - f2) * sb = B have : (1 - f1 - f2) * sb = sb - f1 * sb - f2 * sb := by ring rw [this, hf1_sb, hf2_sb]; linarith · dsimp only [c]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sc + (f2 / e) * sb = B rw [div_mul_eq_mul_div, hf2_sb] have ht2e : t2 / e = -((e * dd - da) / (e ^ 2 - 1)) := by dsimp only [t2]; field_simp [ne_of_gt he_pos, ne_of_gt he2m1_pos]; ring rw [ht2e]; linarith [hdiff_c] · dsimp only [d]; rw [Finset.sum_add_distrib, ← Finset.mul_sum] change sd + f1 * sb = δ; rw [hf1_sb]; dsimp only [t1, dd]; ring · intro z; dsimp only [a, b, c] have : a0 z + (e * f1 + (e - 1 / e) * f2) * b0 z + e * ((1 - f1 - f2) * b0 z) + (c0 z + f2 / e * b0 z) = a0 z + e * b0 z + c0 z := by field_simp [ne_of_gt he_pos]; ring rw [this]; exact hrep_p z · intro z; dsimp only [b, c, d] have : (1 - f1 - f2) * b0 z + e * (c0 z + f2 / e * b0 z) + (d0 z + f1 * b0 z) = b0 z + e * c0 z + d0 z := by field_simp [ne_of_gt he_pos]; ring rw [this]; exact hrep_q z /-- **Exact Sharp Maximum Total Variation under `(ε, δ)`-DP**: For EVERY `(ε, δ)`-DP pair `(p, q)`, `TV(p, q) ≤ (e^ε - 1 + 2δ) / (e^ε + 1)`, and equality is attained by `(canonP ε δ, canonQ ε δ)`. -/ theorem epsDelta_max_tvDist_exact {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : (∀ {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ), IsProbDist p → IsProbDist q → IsEpsDeltaClose ε δ p q → tvDist p q ≤ (Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1)) ∧ tvDist (canonP ε δ) (canonQ ε δ) = (Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1) := by refine ⟨fun p q hp hq hdp => ?_, canonPair_tvDist_exact hε hδ0 hδ1⟩ have hdom := epsDelta_blackwell_dominance hε hδ0 hδ1 hp hq hdp calc tvDist p q ≤ tvDist (canonP ε δ) (canonQ ε δ) := blackwellDom_tvDist_le (canonP_isProbDist hδ0 hδ1) (canonQ_isProbDist hδ0 hδ1) hdom _ = (Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1) := canonPair_tvDist_exact hε hδ0 hδ1 /-- **Exact Sharp Maximum Hockey-Stick Divergence `E_γ` under `(ε, δ)`-DP** for EVERY `γ ≥ 1`. -/ theorem epsDelta_max_hockeyStick_exact {ε δ γ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (hγ : 1 ≤ γ) : (∀ {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ), IsProbDist p → IsProbDist q → IsEpsDeltaClose ε δ p q → hockeyStick γ p q ≤ δ + (1 - δ) * max 0 (Real.exp ε - γ) / (Real.exp ε + 1)) ∧ hockeyStick γ (canonP ε δ) (canonQ ε δ) = δ + (1 - δ) * max 0 (Real.exp ε - γ) / (Real.exp ε + 1) := by refine ⟨fun p q hp hq hdp => ?_, canonPair_hockeyStick_general hε hδ0 hδ1 hγ⟩ have hdom := epsDelta_blackwell_dominance hε hδ0 hδ1 hp hq hdp calc hockeyStick γ p q ≤ hockeyStick γ (canonP ε δ) (canonQ ε δ) := blackwellDom_hockeyStick_le hdom γ _ = δ + (1 - δ) * max 0 (Real.exp ε - γ) / (Real.exp ε + 1) := canonPair_hockeyStick_general hε hδ0 hδ1 hγ /-- **Exact Sharp Minimum Bhattacharyya Coefficient under `(ε, δ)`-DP**: For EVERY `(ε, δ)`-DP pair `(p, q)`, `BC(p, q) ≥ 2(1 - δ) e^{ε/2} / (e^ε + 1)`, attained by `(canonP ε δ, canonQ ε δ)`. -/ theorem epsDelta_min_bhattCoeff_exact {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : (∀ {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ), IsProbDist p → IsProbDist q → IsEpsDeltaClose ε δ p q → 2 * (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1) ≤ bhattCoeff p q) ∧ bhattCoeff (canonP ε δ) (canonQ ε δ) = 2 * (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1) := by refine ⟨fun p q hp hq hdp => ?_, canonPair_bhattCoeff_exact hδ0 hδ1⟩ have hdom := epsDelta_blackwell_dominance hε hδ0 hδ1 hp hq hdp calc 2 * (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1) = bhattCoeff (canonP ε δ) (canonQ ε δ) := (canonPair_bhattCoeff_exact hδ0 hδ1).symm _ ≤ bhattCoeff p q := blackwellDom_bhattCoeff_ge (canonP_isProbDist hδ0 hδ1).1 (canonQ_isProbDist hδ0 hδ1).1 hdom /-! ============================================================================ PART 2: ADAPTIVE k-FOLD COMPOSITION & EXACT KAIROUZ–OH–VISWANATH THEOREM ============================================================================ -/ /-- Product distribution `p₁ ⊗ p₂` on `Ω₁ × Ω₂`. -/ def prodDist {Ω₁ Ω₂ : Type*} (p₁ : Ω₁ → ℝ) (p₂ : Ω₂ → ℝ) : Ω₁ × Ω₂ → ℝ := fun z => p₁ z.1 * p₂ z.2 /-- Adaptive 2-step composition distribution `p₁ ⋊ M₂` on `Ω₁ × Ω₂`. -/ def adaptiveCompDist {Ω₁ Ω₂ : Type*} (p₁ : Ω₁ → ℝ) (M₂ : Ω₁ → Ω₂ → ℝ) : Ω₁ × Ω₂ → ℝ := fun z => p₁ z.1 * M₂ z.1 z.2 lemma prodDist_isProbDist {Ω₁ Ω₂ : Type*} [Fintype Ω₁] [Fintype Ω₂] {p₁ : Ω₁ → ℝ} {p₂ : Ω₂ → ℝ} (hp₁ : IsProbDist p₁) (hp₂ : IsProbDist p₂) : IsProbDist (prodDist p₁ p₂) := by refine ⟨fun z => mul_nonneg (hp₁.1 z.1) (hp₂.1 z.2), ?_⟩ dsimp only [prodDist] rw [Fintype.sum_prod_type] simp_rw [← Finset.mul_sum, hp₂.2, mul_one] exact hp₁.2 lemma adaptiveCompDist_isProbDist {Ω₁ Ω₂ : Type*} [Fintype Ω₁] [Fintype Ω₂] {p₁ : Ω₁ → ℝ} {M₂ : Ω₁ → Ω₂ → ℝ} (hp₁ : IsProbDist p₁) (hM₂ : IsMarkovKernel M₂) : IsProbDist (adaptiveCompDist p₁ M₂) := by refine ⟨fun z => mul_nonneg (hp₁.1 z.1) ((hM₂ z.1).1 z.2), ?_⟩ dsimp only [adaptiveCompDist] rw [Fintype.sum_prod_type] simp_rw [← Finset.mul_sum] calc ∑ x : Ω₁, p₁ x * ∑ y : Ω₂, M₂ x y = ∑ x : Ω₁, p₁ x := Finset.sum_congr rfl fun x _ => by rw [(hM₂ x).2, mul_one] _ = 1 := hp₁.2 /-- **Adaptive 2-Step Blackwell Dominance Lifting**: If `(p₁, q₁) ⪯_BW (p₁*, q₁*)` and for EVERY first-step transcript `y₁`, `(M₂ y₁, N₂ y₁) ⪯_BW (p₂*, q₂*)`, then the **adaptive** joint composition `(p₁ ⋊ M₂, q₁ ⋊ N₂)` is Blackwell-dominated by the **non-adaptive product** `(p₁* ⊗ p₂*, q₁* ⊗ q₂*)` via an explicit lifting Markov kernel! -/ theorem blackwellDom_adaptive_comp {α₁ α₂ Ω₁ Ω₂ : Type*} [Fintype α₁] [Fintype α₂] [Fintype Ω₁] [Fintype Ω₂] {p₁ q₁ : Ω₁ → ℝ} {p₁Star q₁Star : α₁ → ℝ} {M₂ N₂ : Ω₁ → Ω₂ → ℝ} {p₂Star q₂Star : α₂ → ℝ} (h1 : BlackwellDom p₁ q₁ p₁Star q₁Star) (h2 : ∀ y₁ : Ω₁, BlackwellDom (M₂ y₁) (N₂ y₁) p₂Star q₂Star) : BlackwellDom (adaptiveCompDist p₁ M₂) (adaptiveCompDist q₁ N₂) (prodDist p₁Star p₂Star) (prodDist q₁Star q₂Star) := by classical rcases h1 with ⟨K₁, hK₁, hp₁, hq₁⟩ choose K₂ hK₂ hp₂ hq₂ using h2 let K : α₁ × α₂ → Ω₁ × Ω₂ → ℝ := fun x y => K₁ x.1 y.1 * K₂ y.1 x.2 y.2 have hK : IsMarkovKernel K := by intro ⟨x₁, x₂⟩ refine ⟨fun ⟨y₁, y₂⟩ => mul_nonneg ((hK₁ x₁).1 y₁) ((hK₂ y₁ x₂).1 y₂), ?_⟩ dsimp only [K] rw [Fintype.sum_prod_type] simp_rw [← Finset.mul_sum] calc ∑ y₁ : Ω₁, K₁ x₁ y₁ * ∑ y₂ : Ω₂, K₂ y₁ x₂ y₂ = ∑ y₁ : Ω₁, K₁ x₁ y₁ := Finset.sum_congr rfl fun y₁ _ => by rw [(hK₂ y₁ x₂).2, mul_one] _ = 1 := (hK₁ x₁).2 refine ⟨K, hK, ?_, ?_⟩ · funext ⟨y₁, y₂⟩ dsimp only [pushforward, prodDist, adaptiveCompDist, K] rw [Fintype.sum_prod_type] have hfac : ∑ x₁ : α₁, ∑ x₂ : α₂, (p₁Star x₁ * p₂Star x₂) * (K₁ x₁ y₁ * K₂ y₁ x₂ y₂) = (∑ x₁ : α₁, p₁Star x₁ * K₁ x₁ y₁) * (∑ x₂ : α₂, p₂Star x₂ * K₂ y₁ x₂ y₂) := by rw [Finset.sum_mul] refine Finset.sum_congr rfl fun x₁ _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun x₂ _ => by ring rw [hfac] have hp1' : ∑ x₁ : α₁, p₁Star x₁ * K₁ x₁ y₁ = p₁ y₁ := congrFun hp₁ y₁ have hp2' : ∑ x₂ : α₂, p₂Star x₂ * K₂ y₁ x₂ y₂ = M₂ y₁ y₂ := congrFun (hp₂ y₁) y₂ rw [hp1', hp2'] · funext ⟨y₁, y₂⟩ dsimp only [pushforward, prodDist, adaptiveCompDist, K] rw [Fintype.sum_prod_type] have hfac : ∑ x₁ : α₁, ∑ x₂ : α₂, (q₁Star x₁ * q₂Star x₂) * (K₁ x₁ y₁ * K₂ y₁ x₂ y₂) = (∑ x₁ : α₁, q₁Star x₁ * K₁ x₁ y₁) * (∑ x₂ : α₂, q₂Star x₂ * K₂ y₁ x₂ y₂) := by rw [Finset.sum_mul] refine Finset.sum_congr rfl fun x₁ _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun x₂ _ => by ring rw [hfac] have hq1' : ∑ x₁ : α₁, q₁Star x₁ * K₁ x₁ y₁ = q₁ y₁ := congrFun hq₁ y₁ have hq2' : ∑ x₂ : α₂, q₂Star x₂ * K₂ y₁ x₂ y₂ = N₂ y₁ y₂ := congrFun (hq₂ y₁) y₂ rw [hq1', hq2'] /-- `k`-fold i.i.d. product distribution `p^{⊗ k}` on `Fin k → α`. -/ def prodDistN {α : Type*} (k : ℕ) (p : α → ℝ) : (Fin k → α) → ℝ := fun x => ∏ i : Fin k, p (x i) lemma prodDistN_isProbDist {α : Type*} [Fintype α] (k : ℕ) {p : α → ℝ} (hp : IsProbDist p) : IsProbDist (prodDistN k p) := by refine ⟨fun x => Finset.prod_nonneg fun i _ => hp.1 (x i), ?_⟩ dsimp only [prodDistN] rw [← Fintype.prod_sum] simp [hp.2] /-- **Exact Multiplicative Tensorization of Bhattacharyya Coefficient**: `BC(p^{⊗ k}, q^{⊗ k}) = BC(p, q)^k`. -/ theorem prodDistN_bhattCoeff {α : Type*} [Fintype α] (k : ℕ) {p q : α → ℝ} (hp : ∀ x, 0 ≤ p x) (hq : ∀ x, 0 ≤ q x) : bhattCoeff (prodDistN k p) (prodDistN k q) = (bhattCoeff p q) ^ k := by dsimp only [bhattCoeff, prodDistN] have hterm : ∀ x : Fin k → α, Real.sqrt ((∏ i : Fin k, p (x i)) * (∏ i : Fin k, q (x i))) = ∏ i : Fin k, Real.sqrt (p (x i) * q (x i)) := by intro x rw [← Finset.prod_mul_distrib] exact Real.sqrt_prod Finset.univ (fun i _ => mul_nonneg (hp (x i)) (hq (x i))) simp_rw [hterm] rw [(Fintype.prod_sum (fun (_ : Fin k) (x : α) => Real.sqrt (p x * q x))).symm, Finset.prod_const, Finset.card_univ, Fintype.card_fin] /-- Inductive `k`-fold adaptive composition of mechanisms outputting transcripts in `Fin k → Ω`. -/ structure AdaptiveMech (Ω : Type*) (k : ℕ) where step : ∀ (t : Fin k), (Fin t.val → Ω) → Ω → ℝ /-- Joint transcript distribution on `Fin k → Ω` induced by an adaptive mechanism `M`. -/ def adaptiveTranscriptDist {Ω : Type*} : ∀ {k : ℕ}, AdaptiveMech Ω k → (Fin k → Ω) → ℝ | 0, _, _ => 1 | k + 1, M, y => adaptiveTranscriptDist ⟨fun t => M.step t.castSucc⟩ (fun i => y i.castSucc) * M.step (Fin.last k) (fun i => y i.castSucc) (y (Fin.last k)) /-- An adaptive `k`-step mechanism pair `(M, N)` is step-wise `(ε, δ)`-DP iff at every step `t` and every prefix transcript `h`, `(M.step t h, N.step t h)` is a valid `(ε, δ)`-close pair. -/ def IsAdaptiveEpsDeltaDP {Ω : Type*} [Fintype Ω] {k : ℕ} (ε δ : ℝ) (M N : AdaptiveMech Ω k) : Prop := ∀ (t : Fin k) (h : Fin t.val → Ω), IsProbDist (M.step t h) ∧ IsProbDist (N.step t h) ∧ IsEpsDeltaClose ε δ (M.step t h) (N.step t h) /-- Helper: transporting Blackwell dominance along an equivalence on the input and output spaces. -/ lemma blackwellDom_equiv {α₁ α₂ Ω₁ Ω₂ : Type*} [Fintype α₁] [Fintype α₂] [Fintype Ω₁] [Fintype Ω₂] (eα : α₁ ≃ α₂) (eΩ : Ω₁ ≃ Ω₂) {p q : Ω₂ → ℝ} {pStar qStar : α₂ → ℝ} (hdom : BlackwellDom (p ∘ eΩ) (q ∘ eΩ) (pStar ∘ eα) (qStar ∘ eα)) : BlackwellDom p q pStar qStar := by rcases hdom with ⟨K, hK, hp, hq⟩ let K' : α₂ → Ω₂ → ℝ := fun x z => K (eα.symm x) (eΩ.symm z) have hK' : IsMarkovKernel K' := fun x => ⟨fun z => (hK (eα.symm x)).1 (eΩ.symm z), by dsimp only [K'] rw [Equiv.sum_comp eΩ.symm] exact (hK (eα.symm x)).2⟩ refine ⟨K', hK', ?_, ?_⟩ · funext z dsimp only [pushforward, K'] rw [← Equiv.sum_comp eα] simp only [Equiv.symm_apply_apply] have := congrFun hp (eΩ.symm z) simpa [pushforward] using this · funext z dsimp only [pushforward, K'] rw [← Equiv.sum_comp eα] simp only [Equiv.symm_apply_apply] have := congrFun hq (eΩ.symm z) simpa [pushforward] using this /-- **UNIVERSAL `k`-FOLD ADAPTIVE COMPOSITION BLACKWELL DOMINANCE THEOREM**: For EVERY `k ≥ 0`, EVERY `ε ≥ 0`, `δ ∈ [0, 1]`, and EVERY step-wise `(ε, δ)`-DP adaptive mechanism pair `(M, N)`, the joint `k`-step transcript pair is Blackwell-dominated by `((canonP ε δ)^{⊗ k}, (canonQ ε δ)^{⊗ k})`! -/ theorem blackwellDom_kFold_adaptive_comp {Ω : Type*} [Fintype Ω] {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : ∀ {k : ℕ} (M N : AdaptiveMech Ω k), IsAdaptiveEpsDeltaDP ε δ M N → BlackwellDom (adaptiveTranscriptDist M) (adaptiveTranscriptDist N) (prodDistN k (canonP ε δ)) (prodDistN k (canonQ ε δ)) | 0, M, N, _ => by refine ⟨fun _ _ => 1, fun _ => ⟨fun _ => zero_le_one, by simp⟩, ?_, ?_⟩ · funext y; simp [pushforward, prodDistN, adaptiveTranscriptDist] · funext y; simp [pushforward, prodDistN, adaptiveTranscriptDist] | k + 1, M, N, hdp => by let M' : AdaptiveMech Ω k := ⟨fun t => M.step t.castSucc⟩ let N' : AdaptiveMech Ω k := ⟨fun t => N.step t.castSucc⟩ have hdp' : IsAdaptiveEpsDeltaDP ε δ M' N' := fun t h => hdp t.castSucc h have ih := blackwellDom_kFold_adaptive_comp hε hδ0 hδ1 M' N' hdp' have hlast : ∀ h : Fin k → Ω, BlackwellDom (M.step (Fin.last k) h) (N.step (Fin.last k) h) (canonP ε δ) (canonQ ε δ) := fun h => by have hstep := hdp (Fin.last k) h exact epsDelta_blackwell_dominance hε hδ0 hδ1 hstep.1 hstep.2.1 hstep.2.2 have hcomp := blackwellDom_adaptive_comp ih hlast let eα : (Fin k → Fin 4) × Fin 4 ≃ (Fin (k + 1) → Fin 4) := { toFun := fun xy => Fin.snoc (α := fun _ => Fin 4) xy.1 xy.2 invFun := fun x => (fun i => x i.castSucc, x (Fin.last k)) left_inv := fun ⟨x₀, a⟩ => Prod.ext (funext fun i => Fin.snoc_castSucc (α := fun _ => Fin 4) a x₀ i) (Fin.snoc_last (α := fun _ => Fin 4) a x₀) right_inv := fun x => by funext j refine Fin.lastCases ?_ (fun i => ?_) j · exact Fin.snoc_last (α := fun _ => Fin 4) _ _ · exact Fin.snoc_castSucc (α := fun _ => Fin 4) _ _ i } let eΩ : (Fin k → Ω) × Ω ≃ (Fin (k + 1) → Ω) := { toFun := fun hy => Fin.snoc (α := fun _ => Ω) hy.1 hy.2 invFun := fun y => (fun i => y i.castSucc, y (Fin.last k)) left_inv := fun ⟨h, y⟩ => Prod.ext (funext fun i => Fin.snoc_castSucc (α := fun _ => Ω) y h i) (Fin.snoc_last (α := fun _ => Ω) y h) right_inv := fun y => by funext j refine Fin.lastCases ?_ (fun i => ?_) j · exact Fin.snoc_last (α := fun _ => Ω) _ _ · exact Fin.snoc_castSucc (α := fun _ => Ω) _ _ i } refine blackwellDom_equiv eα eΩ ?_ have hp_eq : adaptiveTranscriptDist M ∘ eΩ = adaptiveCompDist (adaptiveTranscriptDist M') (M.step (Fin.last k)) := by funext ⟨h, y⟩ have hpref : (fun i : Fin k => Fin.snoc (α := fun _ => Ω) h y i.castSucc) = h := funext fun i => Fin.snoc_castSucc (α := fun _ => Ω) y h i change adaptiveTranscriptDist M' (fun i : Fin k => Fin.snoc (α := fun _ => Ω) h y i.castSucc) * M.step (Fin.last k) (fun i : Fin k => Fin.snoc (α := fun _ => Ω) h y i.castSucc) (Fin.snoc (α := fun _ => Ω) h y (Fin.last k)) = adaptiveTranscriptDist M' h * M.step (Fin.last k) h y rw [hpref, Fin.snoc_last (α := fun _ => Ω) y h] have hq_eq : adaptiveTranscriptDist N ∘ eΩ = adaptiveCompDist (adaptiveTranscriptDist N') (N.step (Fin.last k)) := by funext ⟨h, y⟩ have hpref : (fun i : Fin k => Fin.snoc (α := fun _ => Ω) h y i.castSucc) = h := funext fun i => Fin.snoc_castSucc (α := fun _ => Ω) y h i change adaptiveTranscriptDist N' (fun i : Fin k => Fin.snoc (α := fun _ => Ω) h y i.castSucc) * N.step (Fin.last k) (fun i : Fin k => Fin.snoc (α := fun _ => Ω) h y i.castSucc) (Fin.snoc (α := fun _ => Ω) h y (Fin.last k)) = adaptiveTranscriptDist N' h * N.step (Fin.last k) h y rw [hpref, Fin.snoc_last (α := fun _ => Ω) y h] have hpS_eq : prodDistN (k + 1) (canonP ε δ) ∘ eα = prodDist (prodDistN k (canonP ε δ)) (canonP ε δ) := by funext ⟨x₀, a⟩ dsimp only [Function.comp, prodDistN, prodDist, eα, Equiv.coe_fn_mk] rw [Fin.prod_univ_castSucc, Fin.snoc_last (α := fun _ => Fin 4) a x₀] congr 1 refine Finset.prod_congr rfl fun i _ => ?_ rw [Fin.snoc_castSucc (α := fun _ => Fin 4) a x₀ i] have hqS_eq : prodDistN (k + 1) (canonQ ε δ) ∘ eα = prodDist (prodDistN k (canonQ ε δ)) (canonQ ε δ) := by funext ⟨x₀, a⟩ dsimp only [Function.comp, prodDistN, prodDist, eα, Equiv.coe_fn_mk] rw [Fin.prod_univ_castSucc, Fin.snoc_last (α := fun _ => Fin 4) a x₀] congr 1 refine Finset.prod_congr rfl fun i _ => ?_ rw [Fin.snoc_castSucc (α := fun _ => Fin 4) a x₀ i] rw [hp_eq, hq_eq, hpS_eq, hqS_eq] exact hcomp /-- Pure binary Warner canonical distribution `P*_{ε,0}` on `Bool`: `true ↦ e^ε / (e^ε + 1)`, `false ↦ 1 / (e^ε + 1)`. -/ noncomputable def warnerP (ε : ℝ) (b : Bool) : ℝ := if b then Real.exp ε / (Real.exp ε + 1) else 1 / (Real.exp ε + 1) /-- Pure binary Warner partner distribution `Q*_{ε,0}` on `Bool`: `true ↦ 1 / (e^ε + 1)`, `false ↦ e^ε / (e^ε + 1)`. -/ noncomputable def warnerQ (ε : ℝ) (b : Bool) : ℝ := if b then 1 / (Real.exp ε + 1) else Real.exp ε / (Real.exp ε + 1) lemma warnerP_isProbDist (ε : ℝ) : IsProbDist (warnerP ε) := by have hep : 0 < Real.exp ε + 1 := by linarith [Real.exp_pos ε] refine ⟨fun b => by cases b <;> dsimp only [warnerP] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> positivity, ?_⟩ rw [Fintype.sum_bool]; dsimp only [warnerP]; simp only [↓reduceIte, Bool.false_eq_true]; field_simp [ne_of_gt hep] lemma warnerQ_isProbDist (ε : ℝ) : IsProbDist (warnerQ ε) := by have hep : 0 < Real.exp ε + 1 := by linarith [Real.exp_pos ε] refine ⟨fun b => by cases b <;> dsimp only [warnerQ] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> positivity, ?_⟩ rw [Fintype.sum_bool]; dsimp only [warnerQ]; simp only [↓reduceIte, Bool.false_eq_true]; field_simp [ne_of_gt hep]; ring /-- **Exact Product Reduction of Canonical 4-Outcome `k`-Fold Hockey-Stick Divergence**: For EVERY `k ≥ 0`, `ε ≥ 0`, `δ ∈ [0, 1]`, and `γ ≥ 0`: `E_γ((canonP ε δ)^{⊗ k} ‖ (canonQ ε δ)^{⊗ k}) = 1 - (1 - δ)^k (1 - E_γ((warnerP ε)^{⊗ k} ‖ (warnerQ ε)^{⊗ k}))`! -/ theorem canonPair_prod_hockeyStick_eq {ε δ γ : ℝ} (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (hγ : 0 ≤ γ) (k : ℕ) : hockeyStick γ (prodDistN k (canonP ε δ)) (prodDistN k (canonQ ε δ)) = 1 - (1 - δ) ^ k * (1 - hockeyStick γ (prodDistN k (warnerP ε)) (prodDistN k (warnerQ ε))) := by classical -- Partition Fin k → Fin 4 into trajectories staying inside {1, 2} (middle set M) vs hitting {0, 3}! let isMid : (Fin k → Fin 4) → Prop := fun x => ∀ i : Fin k, x i = 1 ∨ x i = 2 let M : Finset (Fin k → Fin 4) := Finset.univ.filter isMid dsimp only [hockeyStick] rw [← Finset.sum_filter_add_sum_filter_not Finset.univ isMid] -- 1) On the complement (hitting 0 or 3): either canonP = 0 or canonQ = 0! -- Specifically: if x hits 3, prodDistN P = 0; if x doesn't hit 3, it MUST hit 0 so prodDistN Q = 0! have hcomp_term : ∀ x : Fin k → Fin 4, ¬ isMid x → max 0 (prodDistN k (canonP ε δ) x - γ * prodDistN k (canonQ ε δ) x) = prodDistN k (canonP ε δ) x := by intro x hx have hP_nn : 0 ≤ prodDistN k (canonP ε δ) x := (prodDistN_isProbDist k (canonP_isProbDist hδ0 hδ1)).1 x have hQ_nn : 0 ≤ prodDistN k (canonQ ε δ) x := (prodDistN_isProbDist k (canonQ_isProbDist hδ0 hδ1)).1 x by_cases h3 : ∃ i : Fin k, x i = 3 · rcases h3 with ⟨i, hi⟩ have hP0 : prodDistN k (canonP ε δ) x = 0 := Finset.prod_eq_zero (Finset.mem_univ i) (by rw [hi]; rfl) rw [hP0, max_eq_left (by nlinarith)] · push Not at h3 have h0 : ∃ i : Fin k, x i = 0 := by by_contra hno0 push Not at hno0 apply hx intro i have hi0 := hno0 i have hi3 := h3 i match hxi : x i with | ⟨0, _⟩ => exact absurd hxi hi0 | ⟨1, _⟩ => exact Or.inl rfl | ⟨2, _⟩ => exact Or.inr rfl | ⟨3, _⟩ => exact absurd hxi hi3 rcases h0 with ⟨i, hi⟩ have hQ0 : prodDistN k (canonQ ε δ) x = 0 := Finset.prod_eq_zero (Finset.mem_univ i) (by rw [hi]; rfl) rw [hQ0, mul_zero, sub_zero, max_eq_right hP_nn] have hcomp_sum : ∑ x ∈ Finset.univ.filter (fun x => ¬ isMid x), max 0 (prodDistN k (canonP ε δ) x - γ * prodDistN k (canonQ ε δ) x) = 1 - (1 - δ) ^ k := by rw [Finset.sum_congr rfl fun x hx => hcomp_term x (Finset.mem_filter.mp hx).2] have htot := (prodDistN_isProbDist k (canonP_isProbDist (ε := ε) hδ0 hδ1)).2 rw [← Finset.sum_filter_add_sum_filter_not Finset.univ isMid] at htot -- Compute sum of prodDistN (canonP) on M: it equals (1 - δ)^k! have hmid_P : ∑ x ∈ Finset.univ.filter isMid, prodDistN k (canonP ε δ) x = (1 - δ) ^ k := by let emb : (Fin k → Bool) → (Fin k → Fin 4) := fun b i => if b i then 1 else 2 have hbij : ∑ x ∈ Finset.univ.filter isMid, prodDistN k (canonP ε δ) x = ∑ b : Fin k → Bool, prodDistN k (canonP ε δ) (emb b) := by refine (Finset.sum_bij (fun b _ => emb b) ?_ ?_ ?_ (fun _ _ => rfl)).symm · intro b _ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i => by dsimp only [emb]; split_ifs <;> simp⟩ · intro b₁ _ b₂ _ heq funext i have hi := congrFun heq i dsimp only [emb] at hi cases hb1 : b₁ i <;> cases hb2 : b₂ i <;> simp [hb1, hb2] at hi ⊢ · intro x hx have hxm := (Finset.mem_filter.mp hx).2 refine ⟨fun i => decide (x i = 1), Finset.mem_univ _, ?_⟩ funext i dsimp only [emb] rcases hxm i with h1 | h2 · simp [h1] · simp [h2] rw [hbij] have hfac : ∀ b : Fin k → Bool, prodDistN k (canonP ε δ) (emb b) = (1 - δ) ^ k * prodDistN k (warnerP ε) b := by intro b dsimp only [prodDistN, emb] have h1 : (1 - δ) ^ k = ∏ _i : Fin k, (1 - δ) := by simp rw [h1, ← Finset.prod_mul_distrib] refine Finset.prod_congr rfl fun i _ => ?_ cases b i <;> simp [canonP, warnerP] <;> ring simp_rw [hfac, ← Finset.mul_sum] rw [(prodDistN_isProbDist k (warnerP_isProbDist ε)).2, mul_one] linarith -- 2) On M: bijection with Fin k → Bool scales both P and Q by (1 - δ)^k! have hmid_sum : ∑ x ∈ Finset.univ.filter isMid, max 0 (prodDistN k (canonP ε δ) x - γ * prodDistN k (canonQ ε δ) x) = (1 - δ) ^ k * ∑ b : Fin k → Bool, max 0 (prodDistN k (warnerP ε) b - γ * prodDistN k (warnerQ ε) b) := by let emb : (Fin k → Bool) → (Fin k → Fin 4) := fun b i => if b i then 1 else 2 have hbij : ∑ x ∈ Finset.univ.filter isMid, max 0 (prodDistN k (canonP ε δ) x - γ * prodDistN k (canonQ ε δ) x) = ∑ b : Fin k → Bool, max 0 (prodDistN k (canonP ε δ) (emb b) - γ * prodDistN k (canonQ ε δ) (emb b)) := by refine (Finset.sum_bij (fun b _ => emb b) ?_ ?_ ?_ (fun _ _ => rfl)).symm · intro b _ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i => by dsimp only [emb]; split_ifs <;> simp⟩ · intro b₁ _ b₂ _ heq funext i have hi := congrFun heq i dsimp only [emb] at hi cases hb1 : b₁ i <;> cases hb2 : b₂ i <;> simp [hb1, hb2] at hi ⊢ · intro x hx have hxm := (Finset.mem_filter.mp hx).2 refine ⟨fun i => decide (x i = 1), Finset.mem_univ _, ?_⟩ funext i dsimp only [emb] rcases hxm i with h1 | h2 · simp [h1] · simp [h2] rw [hbij, Finset.mul_sum] refine Finset.sum_congr rfl fun b _ => ?_ have h1d_pow : 0 ≤ (1 - δ) ^ k := pow_nonneg (by linarith) k have hP_fac : prodDistN k (canonP ε δ) (emb b) = (1 - δ) ^ k * prodDistN k (warnerP ε) b := by dsimp only [prodDistN, emb] have h1 : (1 - δ) ^ k = ∏ _i : Fin k, (1 - δ) := by simp rw [h1, ← Finset.prod_mul_distrib] refine Finset.prod_congr rfl fun i _ => ?_ cases b i <;> simp [canonP, warnerP] <;> ring have hQ_fac : prodDistN k (canonQ ε δ) (emb b) = (1 - δ) ^ k * prodDistN k (warnerQ ε) b := by dsimp only [prodDistN, emb] have h1 : (1 - δ) ^ k = ∏ _i : Fin k, (1 - δ) := by simp rw [h1, ← Finset.prod_mul_distrib] refine Finset.prod_congr rfl fun i _ => ?_ cases b i <;> simp [canonQ, warnerQ] <;> ring rw [hP_fac, hQ_fac, show (1 - δ) ^ k * prodDistN k (warnerP ε) b - γ * ((1 - δ) ^ k * prodDistN k (warnerQ ε) b) = (1 - δ) ^ k * (prodDistN k (warnerP ε) b - γ * prodDistN k (warnerQ ε) b) by ring] rcases le_total (prodDistN k (warnerP ε) b - γ * prodDistN k (warnerQ ε) b) 0 with h | h · rw [max_eq_left h, mul_zero, max_eq_left (mul_nonpos_of_nonneg_of_nonpos h1d_pow h)] · rw [max_eq_right h, max_eq_right (mul_nonneg h1d_pow h)] rw [hmid_sum, hcomp_sum]; ring /-- Closed-form Kairouz–Oh–Viswanath (2015) pure-DP `k`-fold binomial tail formula at `ε_comp = (k - 2 i) ε` (`0 ≤ i ≤ k`): `δ_KOV(k, ε, i) = (1 / (e^ε + 1)^k) * ∑_{j ∈ range(k+1)} C(k, j) * max 0 (e^{jε} - e^{(k - 2i)ε} * e^{(k - j)ε})`. -/ noncomputable def kovPureDelta (k : ℕ) (ε : ℝ) (i : ℕ) : ℝ := (∑ j ∈ Finset.range (k + 1), ((Nat.choose k j : ℕ) : ℝ) * max 0 (Real.exp ((j : ℝ) * ε) - Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε) * Real.exp (((k - j : ℕ) : ℝ) * ε))) / (Real.exp ε + 1) ^ k /-- **EXACT KAIROUZ–OH–VISWANATH PURE-DP BINOMIAL TAIL IDENTITY**: For EVERY `k ≥ 0`, `ε ≥ 0`, and `i : ℕ`: `E_{e^{(k - 2i)ε}}((warnerP ε)^{⊗ k} ‖ (warnerQ ε)^{⊗ k}) = kovPureDelta k ε i`! -/ theorem kov_pure_composition_exact (k : ℕ) {ε : ℝ} (i : ℕ) : hockeyStick (Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε)) (prodDistN k (warnerP ε)) (prodDistN k (warnerQ ε)) = kovPureDelta k ε i := by classical have hep : 0 < Real.exp ε + 1 := by linarith [Real.exp_pos ε] have hep_k : 0 < (Real.exp ε + 1) ^ k := pow_pos hep k -- Helper: weight of b : Fin k → Bool equals (Finset.univ.filter (fun m => b m = true)).card let wt : (Fin k → Bool) → ℕ := fun b => (Finset.univ.filter fun m : Fin k => b m = true).card have hP_wt : ∀ b : Fin k → Bool, prodDistN k (warnerP ε) b = Real.exp ((wt b : ℝ) * ε) / (Real.exp ε + 1) ^ k := by intro b dsimp only [prodDistN, warnerP] have hsplit : ∏ m : Fin k, (if b m = true then Real.exp ε / (Real.exp ε + 1) else 1 / (Real.exp ε + 1)) = (∏ m : Fin k, (if b m = true then Real.exp ε else 1)) / (Real.exp ε + 1) ^ k := by have h1 : ∀ m : Fin k, (if b m = true then Real.exp ε / (Real.exp ε + 1) else 1 / (Real.exp ε + 1)) = (if b m = true then Real.exp ε else 1) / (Real.exp ε + 1) := by intro m; split_ifs <;> rfl simp_rw [h1, Finset.prod_div_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin] rw [hsplit] congr 1 rw [Finset.prod_ite, Finset.prod_const_one, mul_one, Finset.prod_const, ← Real.exp_nat_mul] have hQ_wt : ∀ b : Fin k → Bool, prodDistN k (warnerQ ε) b = Real.exp (((k - wt b : ℕ) : ℝ) * ε) / (Real.exp ε + 1) ^ k := by intro b dsimp only [prodDistN, warnerQ] have hsplit : ∏ m : Fin k, (if b m = true then 1 / (Real.exp ε + 1) else Real.exp ε / (Real.exp ε + 1)) = (∏ m : Fin k, (if b m = true then 1 else Real.exp ε)) / (Real.exp ε + 1) ^ k := by have h1 : ∀ m : Fin k, (if b m = true then 1 / (Real.exp ε + 1) else Real.exp ε / (Real.exp ε + 1)) = (if b m = true then 1 else Real.exp ε) / (Real.exp ε + 1) := by intro m; split_ifs <;> rfl simp_rw [h1, Finset.prod_div_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin] rw [hsplit] congr 1 rw [Finset.prod_ite, Finset.prod_const_one, one_mul, Finset.prod_const, ← Real.exp_nat_mul] have hcnt : (Finset.univ.filter fun m : Fin k => ¬ b m = true).card = k - wt b := by have htot := Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (Fin k))) (p := fun m : Fin k => b m = true) rw [Finset.card_univ, Fintype.card_fin] at htot dsimp only [wt]; omega rw [hcnt] -- Group sum over Fin k → Bool by wt b ∈ Finset.range (k + 1)! have hwt_mem : ∀ b ∈ (Finset.univ : Finset (Fin k → Bool)), wt b ∈ Finset.range (k + 1) := by intro b _ rw [Finset.mem_range] have hle : wt b ≤ (Finset.univ : Finset (Fin k)).card := Finset.card_le_card (Finset.filter_subset _ _) rw [Finset.card_univ, Fintype.card_fin] at hle; omega have hfiber_card : ∀ j ∈ Finset.range (k + 1), (Finset.univ.filter fun b : Fin k → Bool => wt b = j).card = Nat.choose k j := by intro j _ -- Bijection with powersetCard j (Finset.univ : Finset (Fin k))! have hbij : (Finset.univ.filter fun b : Fin k → Bool => wt b = j).card = (Finset.powersetCard j (Finset.univ : Finset (Fin k))).card := by refine Finset.card_bij (fun b _ => Finset.univ.filter fun m : Fin k => b m = true) ?_ ?_ ?_ · intro b hb exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, (Finset.mem_filter.mp hb).2⟩ · intro b₁ _ b₂ _ heq funext m have hm : m ∈ (Finset.univ.filter fun x : Fin k => b₁ x = true) ↔ m ∈ (Finset.univ.filter fun x : Fin k => b₂ x = true) := by rw [heq] simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hm cases hb1 : b₁ m <;> cases hb2 : b₂ m <;> simp [hb1, hb2] at hm ⊢ · intro S hS refine ⟨fun m => decide (m ∈ S), ?_, ?_⟩ · refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩ have heqS : (Finset.univ.filter fun m : Fin k => decide (m ∈ S) = true) = S := by ext m; simp dsimp only [wt]; rw [heqS]; exact (Finset.mem_powersetCard.mp hS).2 · ext m; simp rw [hbij, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] dsimp only [hockeyStick, kovPureDelta] rw [← Finset.sum_fiberwise_of_maps_to hwt_mem, Finset.sum_div] refine Finset.sum_congr rfl fun j hj => ?_ have hterm_j : ∀ b ∈ Finset.univ.filter (fun b : Fin k → Bool => wt b = j), max 0 (prodDistN k (warnerP ε) b - Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε) * prodDistN k (warnerQ ε) b) = max 0 (Real.exp ((j : ℝ) * ε) - Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε) * Real.exp (((k - j : ℕ) : ℝ) * ε)) / (Real.exp ε + 1) ^ k := by intro b hb have hwb : wt b = j := (Finset.mem_filter.mp hb).2 rw [hP_wt b, hQ_wt b, hwb, show Real.exp ((j : ℝ) * ε) / (Real.exp ε + 1) ^ k - Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε) * (Real.exp (((k - j : ℕ) : ℝ) * ε) / (Real.exp ε + 1) ^ k) = (Real.exp ((j : ℝ) * ε) - Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε) * Real.exp (((k - j : ℕ) : ℝ) * ε)) / (Real.exp ε + 1) ^ k by ring] rcases le_total (Real.exp ((j : ℝ) * ε) - Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε) * Real.exp (((k - j : ℕ) : ℝ) * ε)) 0 with h | h · rw [max_eq_left h, zero_div, max_eq_left (div_nonpos_of_nonpos_of_nonneg h (le_of_lt hep_k))] · rw [max_eq_right h, max_eq_right (div_nonneg h (le_of_lt hep_k))] rw [Finset.sum_congr rfl hterm_j, Finset.sum_const, hfiber_card j hj, nsmul_eq_mul, mul_div_assoc] /-- **EXACT KAIROUZ–OH–VISWANATH ADAPTIVE `k`-FOLD COMPOSITION THEOREM**: For EVERY `k ≥ 0`, `ε ≥ 0`, `δ ∈ [0, 1]`, and `i : ℕ`: 1. **Universal Upper Bound:** EVERY `k`-fold step-wise `(ε, δ)`-DP adaptive mechanism pair `(M, N)` satisfies `((k - 2i) ε, 1 - (1 - δ)^k (1 - kovPureDelta k ε i))`-DP! 2. **Exact Attainability:** Equality is achieved by the `k`-fold product of `(canonP ε δ, canonQ ε δ)`! -/ theorem kov_adaptive_composition_exact {Ω : Type*} [Fintype Ω] {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (k i : ℕ) : (∀ (M N : AdaptiveMech Ω k), IsAdaptiveEpsDeltaDP ε δ M N → IsEpsDeltaClose (((k : ℝ) - 2 * (i : ℝ)) * ε) (1 - (1 - δ) ^ k * (1 - kovPureDelta k ε i)) (adaptiveTranscriptDist M) (adaptiveTranscriptDist N)) ∧ hockeyStick (Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε)) (prodDistN k (canonP ε δ)) (prodDistN k (canonQ ε δ)) = 1 - (1 - δ) ^ k * (1 - kovPureDelta k ε i) := by have hcanon_eq : hockeyStick (Real.exp (((k : ℝ) - 2 * (i : ℝ)) * ε)) (prodDistN k (canonP ε δ)) (prodDistN k (canonQ ε δ)) = 1 - (1 - δ) ^ k * (1 - kovPureDelta k ε i) := by rw [canonPair_prod_hockeyStick_eq hδ0 hδ1 (le_of_lt (Real.exp_pos _)) k, kov_pure_composition_exact k i] refine ⟨fun M N hdp => ?_, hcanon_eq⟩ have hdom_fwd := blackwellDom_kFold_adaptive_comp hε hδ0 hδ1 M N hdp have hdp_rev : IsAdaptiveEpsDeltaDP ε δ N M := fun t h => ⟨(hdp t h).2.1, (hdp t h).1, ⟨(hdp t h).2.2.2, (hdp t h).2.2.1⟩⟩ have hdom_rev := blackwellDom_kFold_adaptive_comp hε hδ0 hδ1 N M hdp_rev exact ⟨(blackwellDom_hockeyStick_le hdom_fwd _).trans (le_of_eq hcanon_eq), (blackwellDom_hockeyStick_le hdom_rev _).trans (le_of_eq hcanon_eq)⟩ /-- **Exact Closed-Form KOV Evaluation at `k = 2, i = 1` (`ε_comp = 0`)**: Two-fold composition of pure `ε`-DP satisfies `(0, (e^ε - 1)/(e^ε + 1))`-DP — strictly nontrivial (`< 1`) even at `ε_comp = 0`! -/ theorem kov_strictly_beats_basic_k2 {ε : ℝ} (hε : 0 < ε) : kovPureDelta 2 ε 1 = (Real.exp ε - 1) / (Real.exp ε + 1) ∧ kovPureDelta 2 ε 1 < 1 := by have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have hep : 0 < Real.exp ε + 1 := by linarith have hval : kovPureDelta 2 ε 1 = (Real.exp ε - 1) / (Real.exp ε + 1) := by dsimp only [kovPureDelta] rw [Finset.sum_range_succ, Finset.sum_range_succ, Finset.sum_range_one] simp only [Nat.choose_zero_right, Nat.choose_one_right, Nat.choose_self, Nat.cast_zero, Nat.cast_one, Nat.cast_ofNat, zero_mul, Real.exp_zero, one_mul, sub_self, Nat.sub_zero, Nat.sub_self, show (2 - 1 : ℕ) = 1 by rfl, mul_one] have he2 : Real.exp (2 * ε) = Real.exp ε ^ 2 := by rw [two_mul, Real.exp_add, sq] rw [he2] have h0 : max 0 (1 - Real.exp ε ^ 2) = 0 := max_eq_left (by nlinarith) have h2 : max 0 (Real.exp ε ^ 2 - 1) = Real.exp ε ^ 2 - 1 := max_eq_right (by nlinarith) simp only [h0, h2, max_self, mul_zero, add_zero, zero_add] field_simp [ne_of_gt hep]; ring refine ⟨hval, ?_⟩ rw [hval, div_lt_one hep]; linarith /-- **Exact Closed-Form KOV Evaluation at `k = 3, i = 1` (`ε_comp = ε` vs Basic `3ε`)**: Three-fold composition of pure `ε`-DP satisfies `(ε, e^ε (e^ε - 1) / (e^ε + 1)²)`-DP! -/ theorem kov_strictly_beats_basic_k3 {ε : ℝ} (hε : 0 < ε) : kovPureDelta 3 ε 1 = Real.exp ε * (Real.exp ε - 1) / (Real.exp ε + 1) ^ 2 ∧ kovPureDelta 3 ε 1 < 1 := by have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have hep : 0 < Real.exp ε + 1 := by linarith have hval : kovPureDelta 3 ε 1 = Real.exp ε * (Real.exp ε - 1) / (Real.exp ε + 1) ^ 2 := by dsimp only [kovPureDelta] rw [Finset.sum_range_succ, Finset.sum_range_succ, Finset.sum_range_succ, Finset.sum_range_one] have h31 : (3 - 1 : ℕ) = 2 := rfl have h32 : (3 - 2 : ℕ) = 1 := rfl have hc0 : Nat.choose 3 0 = 1 := rfl have hc1 : Nat.choose 3 1 = 3 := rfl have hc2 : Nat.choose 3 2 = 3 := rfl have hc3 : Nat.choose 3 3 = 1 := rfl rw [hc0, hc1, hc2, hc3, h31, h32, Nat.sub_zero, Nat.sub_self] simp only [Nat.cast_zero, Nat.cast_one, Nat.cast_ofNat, zero_mul, Real.exp_zero, one_mul, mul_one] rw [show ((3 : ℝ) - 2) * ε = ε by ring] have he2 : Real.exp (2 * ε) = Real.exp ε ^ 2 := by rw [two_mul, Real.exp_add, sq] have he3 : Real.exp (3 * ε) = Real.exp ε ^ 3 := by rw [show (3 : ℝ) * ε = ε + (ε + ε) by ring, Real.exp_add, Real.exp_add]; ring rw [he2, he3] have hm0 : max 0 (1 - Real.exp ε * Real.exp ε ^ 3) = 0 := max_eq_left (by have : 1 ≤ Real.exp ε ^ 3 := one_le_pow₀ (le_of_lt he1); nlinarith) have hm1 : max 0 (Real.exp ε - Real.exp ε * Real.exp ε ^ 2) = 0 := max_eq_left (by nlinarith) have hm2 : max 0 (Real.exp ε ^ 2 - Real.exp ε * Real.exp ε) = 0 := by rw [← sq, sub_self, max_self] have hm3 : max 0 (Real.exp ε ^ 3 - Real.exp ε) = Real.exp ε ^ 3 - Real.exp ε := max_eq_right (by nlinarith) rw [hm0, hm1, hm2, hm3] field_simp [ne_of_gt hep]; ring refine ⟨hval, ?_⟩ rw [hval, div_lt_one (pow_pos hep 2)]; nlinarith /-! ============================================================================ PART 3: EXACT POISSON SUBSAMPLING AMPLIFICATION & ASYMMETRIC ZERO-DIVERGENCE PHASE TRANSITION ============================================================================ -/ /-- Poisson-`p` subsampled mixture distribution `(1 - p) Q + p P`. -/ def subMix {Ω : Type*} (p : ℝ) (P Q : Ω → ℝ) : Ω → ℝ := fun z => (1 - p) * Q z + p * P z lemma subMix_isProbDist {Ω : Type*} [Fintype Ω] {p : ℝ} {P Q : Ω → ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (hP : IsProbDist P) (hQ : IsProbDist Q) : IsProbDist (subMix p P Q) := by refine ⟨fun z => add_nonneg (mul_nonneg (by linarith) (hQ.1 z)) (mul_nonneg hp0 (hP.1 z)), ?_⟩ dsimp only [subMix] rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, hQ.2, hP.2]; ring /-- **EXACT POISSON SUBSAMPLING ADD-DIRECTION IDENTITY**: For EVERY subsampling rate `p ∈ (0, 1]`, EVERY `γ ≥ 1`, and EVERY pair `(P, Q)`: `E_γ((1 - p) Q + p P ‖ Q) = p · E_{1 + (γ - 1) / p}(P ‖ Q)`! -/ theorem poisson_subsampling_add_exact {Ω : Type*} [Fintype Ω] {p γ : ℝ} (hp : 0 < p) (P Q : Ω → ℝ) : hockeyStick γ (subMix p P Q) Q = p * hockeyStick (1 + (γ - 1) / p) P Q := by dsimp only [hockeyStick, subMix] rw [Finset.mul_sum] refine Finset.sum_congr rfl fun z _ => ?_ have hlin : (1 - p) * Q z + p * P z - γ * Q z = p * (P z - (1 + (γ - 1) / p) * Q z) := by field_simp [ne_of_gt hp]; ring rw [hlin] rcases le_total (P z - (1 + (γ - 1) / p) * Q z) 0 with h | h · rw [max_eq_left h, mul_zero, max_eq_left (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hp) h)] · rw [max_eq_right h, max_eq_right (mul_nonneg (le_of_lt hp) h)] /-- **EXACT POISSON SUBSAMPLING REMOVE-DIRECTION PHASE I (`1 ≤ γ < 1 / (1 - p)`)**: `E_γ(Q ‖ (1 - p) Q + p P) = (1 - γ (1 - p)) · E_{γ p / (1 - γ (1 - p))}(Q ‖ P)`! -/ theorem poisson_subsampling_remove_phase1 {Ω : Type*} [Fintype Ω] {p γ : ℝ} (hpos : 0 < 1 - γ * (1 - p)) (P Q : Ω → ℝ) : hockeyStick γ Q (subMix p P Q) = (1 - γ * (1 - p)) * hockeyStick (γ * p / (1 - γ * (1 - p))) Q P := by dsimp only [hockeyStick, subMix] rw [Finset.mul_sum] refine Finset.sum_congr rfl fun z _ => ?_ have hlin : Q z - γ * ((1 - p) * Q z + p * P z) = (1 - γ * (1 - p)) * (Q z - (γ * p / (1 - γ * (1 - p))) * P z) := by field_simp [ne_of_gt hpos]; ring rw [hlin] rcases le_total (Q z - (γ * p / (1 - γ * (1 - p))) * P z) 0 with h | h · rw [max_eq_left h, mul_zero, max_eq_left (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hpos) h)] · rw [max_eq_right h, max_eq_right (mul_nonneg (le_of_lt hpos) h)] /-- **EXACT POISSON SUBSAMPLING REMOVE-DIRECTION PHASE II (SHARP ZERO-DIVERGENCE COLLAPSE)**: Whenever `γ ≥ 1 / (1 - p)` (equivalently `1 - γ (1 - p) ≤ 0`), `E_γ(Q ‖ (1 - p) Q + p P) = 0` IDENTICALLY for ALL nonnegative distributions `P, Q`! -/ theorem poisson_subsampling_remove_zero_phase {Ω : Type*} [Fintype Ω] {p γ : ℝ} (hp0 : 0 ≤ p) (hγ0 : 0 ≤ γ) (hphase : 1 ≤ γ * (1 - p)) {P Q : Ω → ℝ} (hP : ∀ z, 0 ≤ P z) (hQ : ∀ z, 0 ≤ Q z) : hockeyStick γ Q (subMix p P Q) = 0 := by dsimp only [hockeyStick, subMix] refine Finset.sum_eq_zero fun z _ => max_eq_left ?_ have h1 : Q z - γ * ((1 - p) * Q z + p * P z) = (1 - γ * (1 - p)) * Q z - γ * p * P z := by ring rw [h1] have ha : (1 - γ * (1 - p)) * Q z ≤ 0 := mul_nonpos_of_nonpos_of_nonneg (by linarith) (hQ z) have hb : 0 ≤ γ * p * P z := mul_nonneg (mul_nonneg hγ0 hp0) (hP z) linarith /-- **EXACT BALLE–BARTHE–GABOARDI POISSON SUBSAMPLING AMPLIFICATION THEOREM**: If `(P, Q)` is `(ε, δ)`-close (`ε ≥ 0`, `δ ∈ [0, 1]`) and `p ∈ (0, 1]`, then `(subMix p P Q, Q)` is `(log(1 + p(e^ε - 1)), p δ)`-close, AND the Add-direction bound `p δ` is **EXACTLY ATTAINED** on `(canonP ε δ, canonQ ε δ)`! -/ theorem poisson_subsampling_amplification_exact {ε δ p : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (hp0 : 0 < p) (hp1 : p ≤ 1) : let ε' := Real.log (1 + p * (Real.exp ε - 1)) (∀ {Ω : Type*} [Fintype Ω] (P Q : Ω → ℝ), IsProbDist P → IsProbDist Q → IsEpsDeltaClose ε δ P Q → IsEpsDeltaClose ε' (p * δ) (subMix p P Q) Q) ∧ hockeyStick (Real.exp ε') (subMix p (canonP ε δ) (canonQ ε δ)) (canonQ ε δ) = p * δ := by intro ε' have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have harg_pos : 0 < 1 + p * (Real.exp ε - 1) := by nlinarith have hexp' : Real.exp ε' = 1 + p * (Real.exp ε - 1) := Real.exp_log harg_pos have hadd_id : 1 + (Real.exp ε' - 1) / p = Real.exp ε := by rw [hexp']; field_simp [ne_of_gt hp0]; ring refine ⟨fun P Q hP hQ hdp => ?_, ?_⟩ · constructor · rw [poisson_subsampling_add_exact hp0 P Q, hadd_id] exact mul_le_mul_of_nonneg_left hdp.1 (le_of_lt hp0) · by_cases hph : 1 ≤ Real.exp ε' * (1 - p) · rw [poisson_subsampling_remove_zero_phase (le_of_lt hp0) (le_of_lt (Real.exp_pos _)) hph hP.1 hQ.1] exact mul_nonneg (le_of_lt hp0) hδ0 · have hpos : 0 < 1 - Real.exp ε' * (1 - p) := by linarith rw [poisson_subsampling_remove_phase1 hpos P Q] have hcoef_le : 1 - Real.exp ε' * (1 - p) ≤ p := by rw [hexp'] have h3 : 0 ≤ p * (1 - p) * (Real.exp ε - 1) := mul_nonneg (mul_nonneg (le_of_lt hp0) (by linarith)) (by linarith) linarith have hgam_ge : Real.exp ε ≤ Real.exp ε' * p / (1 - Real.exp ε' * (1 - p)) := by rw [le_div_iff₀ hpos, hexp'] have hsq : 0 ≤ (1 - p) * (Real.exp ε - 1) ^ 2 := mul_nonneg (by linarith) (sq_nonneg _) nlinarith have hhs_le : hockeyStick (Real.exp ε' * p / (1 - Real.exp ε' * (1 - p))) Q P ≤ δ := (hockeyStick_antitone hgam_ge hP.1).trans hdp.2 calc (1 - Real.exp ε' * (1 - p)) * hockeyStick (Real.exp ε' * p / (1 - Real.exp ε' * (1 - p))) Q P ≤ (1 - Real.exp ε' * (1 - p)) * δ := mul_le_mul_of_nonneg_left hhs_le (le_of_lt hpos) _ ≤ p * δ := mul_le_mul_of_nonneg_right hcoef_le hδ0 · rw [poisson_subsampling_add_exact hp0, hadd_id, canonPair_hockeyStick_general hε hδ0 hδ1 he1, sub_self, max_self, mul_zero, zero_div, add_zero] /-- **STRICT SUBSAMPLING ADD-VS-REMOVE ASYMMETRY THEOREM**: For EVERY `p ∈ (0, 1)`, `ε > 0`, `δ ∈ (0, 1]`, at the exact amplified threshold `γ' = 1 + p (e^ε - 1)`, the Remove direction is **STRICTLY MORE PRIVATE** than the Add direction on the canonical `(ε, δ)`-DP pair: `E_{γ'}(Q* ‖ subMix p P* Q*) < p δ = E_{γ'}(subMix p P* Q* ‖ Q*)`! -/ theorem poisson_subsampling_strict_asymmetry {ε δ p : ℝ} (hε : 0 < ε) (hδ0 : 0 < δ) (hδ1 : δ ≤ 1) (hp0 : 0 < p) (hp1 : p < 1) : let γ' := 1 + p * (Real.exp ε - 1) hockeyStick γ' (canonQ ε δ) (subMix p (canonP ε δ) (canonQ ε δ)) < hockeyStick γ' (subMix p (canonP ε δ) (canonQ ε δ)) (canonQ ε δ) := by intro γ' have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have hadd : hockeyStick γ' (subMix p (canonP ε δ) (canonQ ε δ)) (canonQ ε δ) = p * δ := by rw [poisson_subsampling_add_exact hp0] have hid : 1 + (γ' - 1) / p = Real.exp ε := by dsimp only [γ']; field_simp [ne_of_gt hp0]; ring rw [hid, canonPair_hockeyStick_general (le_of_lt hε) (le_of_lt hδ0) hδ1 (le_of_lt he1), sub_self, max_self, mul_zero, zero_div, add_zero] rw [hadd] by_cases hph : 1 ≤ γ' * (1 - p) · rw [poisson_subsampling_remove_zero_phase (le_of_lt hp0) (by dsimp only [γ']; nlinarith) hph (canonP_isProbDist (le_of_lt hδ0) hδ1).1 (canonQ_isProbDist (le_of_lt hδ0) hδ1).1] exact mul_pos hp0 hδ0 · have hpos : 0 < 1 - γ' * (1 - p) := by linarith rw [poisson_subsampling_remove_phase1 hpos] have hcoef_lt : 1 - γ' * (1 - p) < p := by dsimp only [γ'] have h3 : 0 < p * (1 - p) * (Real.exp ε - 1) := mul_pos (mul_pos hp0 (by linarith)) (by linarith) linarith have hgam_ge : Real.exp ε ≤ γ' * p / (1 - γ' * (1 - p)) := by rw [le_div_iff₀ hpos]; dsimp only [γ'] have hsq : 0 ≤ (1 - p) * (Real.exp ε - 1) ^ 2 := mul_nonneg (by linarith) (sq_nonneg _) nlinarith have hhs_le : hockeyStick (γ' * p / (1 - γ' * (1 - p))) (canonQ ε δ) (canonP ε δ) ≤ δ := (hockeyStick_antitone hgam_ge (canonP_isProbDist (le_of_lt hδ0) hδ1).1).trans (canonPair_isEpsDeltaClose (le_of_lt hε) (le_of_lt hδ0) hδ1).2 calc (1 - γ' * (1 - p)) * hockeyStick (γ' * p / (1 - γ' * (1 - p))) (canonQ ε δ) (canonP ε δ) ≤ (1 - γ' * (1 - p)) * δ := mul_le_mul_of_nonneg_left hhs_le (le_of_lt hpos) _ < p * δ := mul_lt_mul_of_pos_right hcoef_lt hδ0 /-! ============================================================================ PART 4: EXACT (ε, δ)-DP GROUP PRIVACY & SQUARE-ROOT-EXPONENTIAL VACUITY PHASE TRANSITION ============================================================================ -/ /-- Exact 1-step symmetric `(ε, δ)`-DP event tradeoff envelope (`e = e^ε ≥ 1`): `g(a) = min(1, δ + e a, 1 - (1 - δ - a) / e)`. -/ noncomputable def groupEnv (e δ a : ℝ) : ℝ := min 1 (min (δ + e * a) (1 - (1 - δ - a) / e)) /-- `k`-fold iterate `g^{∘ k}(a)` of the exact group-privacy tradeoff envelope. -/ noncomputable def groupEnvIter : ℕ → ℝ → ℝ → ℝ → ℝ | 0, _, _, a => a | k + 1, e, δ, a => groupEnv e δ (groupEnvIter k e δ a) lemma groupEnv_mono {e δ a b : ℝ} (he : 0 < e) (hab : a ≤ b) : groupEnv e δ a ≤ groupEnv e δ b := by dsimp only [groupEnv] refine min_le_min le_rfl (min_le_min ?_ ?_) · nlinarith · have hdiv : (1 - δ - b) / e ≤ (1 - δ - a) / e := div_le_div_of_nonneg_right (by linarith) (le_of_lt he) linarith lemma groupEnvIter_mono {e δ a b : ℝ} (he : 0 < e) (hab : a ≤ b) : ∀ k : ℕ, groupEnvIter k e δ a ≤ groupEnvIter k e δ b | 0 => hab | k + 1 => groupEnv_mono he (groupEnvIter_mono he hab k) lemma groupEnv_le_one (e δ a : ℝ) : groupEnv e δ a ≤ 1 := min_le_left _ _ lemma groupEnv_ge_self {e δ a : ℝ} (he : 1 ≤ e) (hδ0 : 0 ≤ δ) (ha0 : 0 ≤ a) (ha1 : a ≤ 1) : a ≤ groupEnv e δ a := by dsimp only [groupEnv] refine le_min ha1 (le_min ?_ ?_) · nlinarith · rw [le_sub_comm, div_le_iff₀ (by linarith : 0 < e)] nlinarith lemma groupEnv_nonneg {e δ a : ℝ} (he : 1 ≤ e) (hδ0 : 0 ≤ δ) (ha0 : 0 ≤ a) (ha1 : a ≤ 1) : 0 ≤ groupEnv e δ a := le_trans ha0 (groupEnv_ge_self he hδ0 ha0 ha1) lemma groupEnvIter_mem_Icc {e δ a : ℝ} (he : 1 ≤ e) (hδ0 : 0 ≤ δ) (ha0 : 0 ≤ a) (ha1 : a ≤ 1) : ∀ k : ℕ, 0 ≤ groupEnvIter k e δ a ∧ groupEnvIter k e δ a ≤ 1 | 0 => ⟨ha0, ha1⟩ | k + 1 => let ih := groupEnvIter_mem_Icc he hδ0 ha0 ha1 k ⟨groupEnv_nonneg he hδ0 ih.1 ih.2, groupEnv_le_one _ _ _⟩ lemma groupEnv_lipschitz_le {e δ a b : ℝ} (he : 1 ≤ e) (hab : a ≤ b) : groupEnv e δ b - groupEnv e δ a ≤ e * (b - a) := by dsimp only [groupEnv] have he_pos : 0 < e := by linarith have h1 : min 1 (min (δ + e * b) (1 - (1 - δ - b) / e)) - 1 ≤ e * (b - a) := by have : min 1 (min (δ + e * b) (1 - (1 - δ - b) / e)) ≤ 1 := min_le_left _ _ nlinarith have h2 : min 1 (min (δ + e * b) (1 - (1 - δ - b) / e)) - (δ + e * a) ≤ e * (b - a) := by have : min 1 (min (δ + e * b) (1 - (1 - δ - b) / e)) ≤ δ + e * b := (min_le_right _ _).trans (min_le_left _ _) linarith have h3 : min 1 (min (δ + e * b) (1 - (1 - δ - b) / e)) - (1 - (1 - δ - a) / e) ≤ e * (b - a) := by have hle : min 1 (min (δ + e * b) (1 - (1 - δ - b) / e)) ≤ 1 - (1 - δ - b) / e := (min_le_right _ _).trans (min_le_right _ _) have hdiff : (1 - (1 - δ - b) / e) - (1 - (1 - δ - a) / e) = (b - a) / e := by field_simp [ne_of_gt he_pos]; ring have hdiv_le : (b - a) / e ≤ e * (b - a) := by rw [div_le_iff₀ he_pos] have h1 : b - a ≤ (e * e) * (b - a) := le_mul_of_one_le_left (by linarith) (by nlinarith) linarith linarith rcases le_total 1 (min (δ + e * a) (1 - (1 - δ - a) / e)) with hm1 | hm1 · rw [min_eq_left hm1]; exact h1 · rw [min_eq_right hm1] rcases le_total (δ + e * a) (1 - (1 - δ - a) / e) with hm2 | hm2 · rw [min_eq_left hm2]; exact h2 · rw [min_eq_right hm2]; exact h3 lemma groupEnvIter_lipschitz_le {e δ a b : ℝ} (he : 1 ≤ e) (hab : a ≤ b) : ∀ k : ℕ, groupEnvIter k e δ b - groupEnvIter k e δ a ≤ e ^ k * (b - a) | 0 => by simp [groupEnvIter] | k + 1 => by have hmono := groupEnvIter_mono (δ := δ) (by linarith : 0 < e) hab k have hstep := groupEnv_lipschitz_le (δ := δ) he hmono have ih := groupEnvIter_lipschitz_le (δ := δ) he hab k calc groupEnvIter (k + 1) e δ b - groupEnvIter (k + 1) e δ a ≤ e * (groupEnvIter k e δ b - groupEnvIter k e δ a) := hstep _ ≤ e * (e ^ k * (b - a)) := mul_le_mul_of_nonneg_left ih (by linarith) _ = e ^ (k + 1) * (b - a) := by rw [pow_succ]; ring /-- **Exact 1-Step Event Bound**: If `(P, Q)` is `(ε, δ)`-close, then for EVERY event `S : Finset Ω`, `P(S) ≤ groupEnv (e^ε) δ (Q(S))`! -/ theorem epsDelta_one_step_event_bound {Ω : Type*} [Fintype Ω] [DecidableEq Ω] {ε δ : ℝ} {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) (hdp : IsEpsDeltaClose ε δ P Q) (S : Finset Ω) : (∑ z ∈ S, P z) ≤ groupEnv (Real.exp ε) δ (∑ z ∈ S, Q z) := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε dsimp only [groupEnv] refine le_min ?_ (le_min ?_ ?_) · calc ∑ z ∈ S, P z ≤ ∑ z : Ω, P z := Finset.sum_le_univ_sum_of_nonneg hP.1 _ = 1 := hP.2 · have h1 := (hockeyStick_eq_sup_event (Real.exp ε) P Q).2.1 S linarith [hdp.1] · have hcompl := (hockeyStick_eq_sup_event (Real.exp ε) Q P).2.1 Sᶜ have hScP : ∑ z ∈ Sᶜ, P z = 1 - ∑ z ∈ S, P z := by have := Finset.sum_add_sum_compl S P; rw [hP.2] at this; linarith have hScQ : ∑ z ∈ Sᶜ, Q z = 1 - ∑ z ∈ S, Q z := by have := Finset.sum_add_sum_compl S Q; rw [hQ.2] at this; linarith rw [hScP, hScQ] at hcompl have h2 : (1 - ∑ z ∈ S, Q z) - Real.exp ε * (1 - ∑ z ∈ S, P z) ≤ δ := le_trans hcompl hdp.2 rw [le_sub_comm, div_le_iff₀ he_pos] linarith /-- **Exact `k`-Step Chain Event Bound**: For EVERY `k`-step chain `C : Fin (k + 1) → Ω → ℝ` of probability distributions where every consecutive pair `(C i, C (i+1))` is `(ε, δ)`-close, and EVERY event `S`: `C k (S) ≤ groupEnvIter k (e^ε) δ (C 0 (S))`! -/ theorem epsDelta_group_event_bound {Ω : Type*} [Fintype Ω] [DecidableEq Ω] {ε δ : ℝ} : ∀ {k : ℕ} (C : Fin (k + 1) → Ω → ℝ), (∀ i : Fin (k + 1), IsProbDist (C i)) → (∀ i : Fin k, IsEpsDeltaClose ε δ (C i.castSucc) (C i.succ)) → ∀ S : Finset Ω, (∑ z ∈ S, C (Fin.last k) z) ≤ groupEnvIter k (Real.exp ε) δ (∑ z ∈ S, C 0 z) | 0, C, _, _, S => by simp [groupEnvIter] | k + 1, C, hprob, hchain, S => by let C' : Fin (k + 1) → Ω → ℝ := fun i => C i.castSucc have ih := epsDelta_group_event_bound C' (fun i => hprob i.castSucc) (fun i => hchain i.castSucc) S have hlast_dp := hchain (Fin.last k) have hlast_rev : IsEpsDeltaClose ε δ (C (Fin.last (k + 1))) (C (Fin.last k).castSucc) := ⟨hlast_dp.2, hlast_dp.1⟩ have hstep := epsDelta_one_step_event_bound (hprob (Fin.last (k + 1))) (hprob (Fin.last k).castSucc) hlast_rev S exact hstep.trans (groupEnv_mono (Real.exp_pos ε) ih) /-- **EXACT TIGHT `k`-GROUP PRIVACY THEOREM**: For EVERY `k ≥ 0`, `ε ≥ 0`, `δ ∈ [0, 1]`: 1. **Universal Upper Bound:** For EVERY finite `Ω` and EVERY `(ε, δ)`-DP chain `C : Fin (k+1) → Ω → ℝ`, `E_{e^{kε}}(C k ‖ C 0) ≤ groupEnvIter k (e^ε) δ 0`! 2. **Exact Attainability:** The explicit 2-outcome Markov chain `C* i = (groupEnvIter i (e^ε) δ 0, 1 - groupEnvIter i (e^ε) δ 0)` on `Bool` is `(ε, δ)`-DP at every step and achieves **EXACT EQUALITY** `E_{e^{kε}}(C* k ‖ C* 0) = groupEnvIter k (e^ε) δ 0`! -/ theorem epsDelta_group_privacy_exact {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (_hδ1 : δ ≤ 1) (k : ℕ) : (∀ {Ω : Type*} [Fintype Ω] [DecidableEq Ω] (C : Fin (k + 1) → Ω → ℝ), (∀ i : Fin (k + 1), IsProbDist (C i)) → (∀ i : Fin k, IsEpsDeltaClose ε δ (C i.castSucc) (C i.succ)) → hockeyStick (Real.exp ((k : ℝ) * ε)) (C (Fin.last k)) (C 0) ≤ groupEnvIter k (Real.exp ε) δ 0) ∧ (∃ C : Fin (k + 1) → Bool → ℝ, (∀ i : Fin (k + 1), IsProbDist (C i)) ∧ (∀ i : Fin k, IsEpsDeltaClose ε δ (C i.castSucc) (C i.succ)) ∧ hockeyStick (Real.exp ((k : ℝ) * ε)) (C (Fin.last k)) (C 0) = groupEnvIter k (Real.exp ε) δ 0) := by have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have he_pos : 0 < Real.exp ε := by linarith have hexp_k : Real.exp ((k : ℝ) * ε) = Real.exp ε ^ k := by rw [Real.exp_nat_mul] constructor · intro Ω _ _ C hprob hchain obtain ⟨S, hS⟩ := (hockeyStick_eq_sup_event (Real.exp ((k : ℝ) * ε)) (C (Fin.last k)) (C 0)).2.2 rw [← hS, hexp_k] have h0_nn : 0 ≤ ∑ z ∈ S, C 0 z := Finset.sum_nonneg fun z _ => (hprob 0).1 z have hbound := epsDelta_group_event_bound C hprob hchain S have hlip := groupEnvIter_lipschitz_le (δ := δ) he1 h0_nn k linarith · let C : Fin (k + 1) → Bool → ℝ := fun i b => if b then groupEnvIter i.val (Real.exp ε) δ 0 else 1 - groupEnvIter i.val (Real.exp ε) δ 0 have hmem : ∀ j : ℕ, 0 ≤ groupEnvIter j (Real.exp ε) δ 0 ∧ groupEnvIter j (Real.exp ε) δ 0 ≤ 1 := fun j => groupEnvIter_mem_Icc he1 hδ0 le_rfl zero_le_one j refine ⟨C, ?_, ?_, ?_⟩ · intro i refine ⟨fun b => by cases b <;> dsimp only [C] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> linarith [hmem i.val], ?_⟩ rw [Fintype.sum_bool]; dsimp only [C]; simp only [↓reduceIte, Bool.false_eq_true]; ring · intro i set a := groupEnvIter i.val (Real.exp ε) δ 0 set b := groupEnvIter (i.val + 1) (Real.exp ε) δ 0 have hb_eq : b = groupEnv (Real.exp ε) δ a := rfl have ha_mem := hmem i.val have hb_mem := hmem (i.val + 1) have hab : a ≤ b := hb_eq ▸ groupEnv_ge_self he1 hδ0 ha_mem.1 ha_mem.2 have hb_le1 : b ≤ δ + Real.exp ε * a := hb_eq ▸ (min_le_right _ _).trans (min_le_left _ _) have hb_le2 : b ≤ 1 - (1 - δ - a) / Real.exp ε := hb_eq ▸ (min_le_right _ _).trans (min_le_right _ _) have h1mb_ge : (1 - a) - Real.exp ε * (1 - b) ≤ δ := by have h := hb_le2 rw [le_sub_comm, div_le_iff₀ he_pos] at h linarith constructor · dsimp only [hockeyStick, C] rw [Fintype.sum_bool] simp only [Fin.val_castSucc, Fin.val_succ, ↓reduceIte, Bool.false_eq_true] change max 0 (a - Real.exp ε * b) + max 0 ((1 - a) - Real.exp ε * (1 - b)) ≤ δ have ht1 : max 0 (a - Real.exp ε * b) = 0 := max_eq_left (by nlinarith) rw [ht1, zero_add] exact max_le hδ0 h1mb_ge · dsimp only [hockeyStick, C] rw [Fintype.sum_bool] simp only [Fin.val_castSucc, Fin.val_succ, ↓reduceIte, Bool.false_eq_true] change max 0 (b - Real.exp ε * a) + max 0 ((1 - b) - Real.exp ε * (1 - a)) ≤ δ have ht2 : max 0 ((1 - b) - Real.exp ε * (1 - a)) = 0 := max_eq_left (by nlinarith) rw [ht2, add_zero] exact max_le hδ0 (by linarith) · dsimp only [hockeyStick, C] rw [Fintype.sum_bool] simp only [Fin.val_last, Fin.val_zero, groupEnvIter, sub_zero, ↓reduceIte, Bool.false_eq_true] have hk_mem := hmem k have h1 : max 0 (groupEnvIter k (Real.exp ε) δ 0 - Real.exp ((k : ℝ) * ε) * 0) = groupEnvIter k (Real.exp ε) δ 0 := by rw [mul_zero, sub_zero, max_eq_right hk_mem.1] have h2 : max 0 (1 - groupEnvIter k (Real.exp ε) δ 0 - Real.exp ((k : ℝ) * ε) * 1) = 0 := by have hek1 : 1 ≤ Real.exp ((k : ℝ) * ε) := Real.one_le_exp (mul_nonneg (Nat.cast_nonneg k) hε) exact max_eq_left (by linarith) rw [h1, h2, add_zero] /-- **EXACT `k = 2` THREE-PHASE CLOSED FORM FOR GROUP PRIVACY**: `groupEnvIter 2 e δ 0 = min 1 (min ((1 + e) δ) (1 - (1 - 2 δ) / e))`! Moreover, on the middle regime `δ ∈ (1 / (e + 2), 1 / 2)` (with `e > 1`), this **STRICTLY BEATS** the textbook bound `min 1 ((1 + e) δ)`! -/ theorem epsDelta_group2_exact_closed_form {e δ : ℝ} (he : 1 < e) (_hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : groupEnvIter 2 e δ 0 = min 1 (min ((1 + e) * δ) (1 - (1 - 2 * δ) / e)) ∧ (1 / (e + 2) < δ → δ < 1 / 2 → groupEnvIter 2 e δ 0 = 1 - (1 - 2 * δ) / e ∧ groupEnvIter 2 e δ 0 < min 1 ((1 + e) * δ)) := by have he_pos : 0 < e := by linarith have hg1 : groupEnvIter 1 e δ 0 = δ := by dsimp only [groupEnvIter, groupEnv] rw [mul_zero, add_zero, sub_zero] have hle1 : δ ≤ 1 - (1 - δ) / e := by rw [le_sub_comm, div_le_iff₀ he_pos]; nlinarith rw [min_eq_left hle1, min_eq_right hδ1] have hg2 : groupEnvIter 2 e δ 0 = min 1 (min ((1 + e) * δ) (1 - (1 - 2 * δ) / e)) := by change groupEnv e δ (groupEnvIter 1 e δ 0) = _ rw [hg1] dsimp only [groupEnv] congr 1; congr 1 <;> ring refine ⟨hg2, fun hlo hhi => ?_⟩ have he2_pos : 0 < e + 2 := by linarith have h1 : 1 < (e + 2) * δ := by linarith [(div_lt_iff₀ he2_pos).mp hlo] have hlt1 : 1 - (1 - 2 * δ) / e < 1 := by rw [sub_lt_self_iff]; exact div_pos (by linarith) he_pos have hlt2 : 1 - (1 - 2 * δ) / e < (1 + e) * δ := by have hdiff : (1 + e) * δ - (1 - (1 - 2 * δ) / e) = (e - 1) * ((e + 2) * δ - 1) / e := by field_simp [ne_of_gt he_pos]; ring have hpos : 0 < (e - 1) * ((e + 2) * δ - 1) / e := div_pos (mul_pos (by linarith) (by linarith)) he_pos linarith rw [hg2, min_eq_right (le_of_lt hlt2), min_eq_right (le_of_lt hlt1)] exact ⟨rfl, lt_min hlt1 hlt2⟩ /-- Helper: closed-form `m`-fold iterate of the fast linear map `x ↦ δ + e x` from `0`. -/ private lemma fastIter_eq (e δ : ℝ) (he : 1 < e) : ∀ m : ℕ, (fun x => δ + e * x)^[m] 0 = δ * (e ^ m - 1) / (e - 1) | 0 => by simp | m + 1 => by rw [Function.iterate_succ_apply', fastIter_eq e δ he m, pow_succ] have hem1 : e - 1 ≠ 0 := ne_of_gt (by linarith) field_simp [hem1]; ring /-- Helper: closed-form `t`-fold iterate of the slow linear map `x ↦ 1 - (1 - δ - x) / e`. -/ private lemma slowIter_eq (e δ b : ℝ) (he : 1 < e) : ∀ t : ℕ, 1 - (fun x => 1 - (1 - δ - x) / e)^[t] b = (1 - b - δ * (e ^ t - 1) / (e - 1)) / e ^ t | 0 => by simp | t + 1 => by rw [Function.iterate_succ_apply', pow_succ] have hrec : 1 - (1 - (1 - δ - (fun x => 1 - (1 - δ - x) / e)^[t] b) / e) = (1 - (fun x => 1 - (1 - δ - x) / e)^[t] b - δ) / e := by ring rw [hrec, slowIter_eq e δ b he t] have he0 : e ≠ 0 := ne_of_gt (by linarith) have hem1 : e - 1 ≠ 0 := ne_of_gt (by linarith) have het0 : e ^ t ≠ 0 := pow_ne_zero t he0 field_simp [he0, hem1, het0]; ring /-- Helper: discrete symmetry minimum `e^{⌊k/2⌋} + e^{⌈k/2⌉} ≤ e^r + e^{k - r}` for all `r ≤ k`. -/ private lemma pow_sum_min_at_half {e : ℝ} (he : 1 ≤ e) {k r : ℕ} (hr : r ≤ k) : e ^ (k / 2) + e ^ (k - k / 2) ≤ e ^ r + e ^ (k - r) := by set m1 := k / 2 set m2 := k - k / 2 have hm_le : m1 ≤ m2 := by dsimp only [m1, m2]; omega by_cases hrm1 : r ≤ m1 · have hkr : k - r = m2 + (m1 - r) := by dsimp only [m1, m2]; omega have hm1r : m1 = r + (m1 - r) := by omega have hfac : e ^ r + e ^ (k - r) - (e ^ m1 + e ^ m2) = (e ^ m2 - e ^ r) * (e ^ (m1 - r) - 1) := by have h1 : e ^ (k - r) = e ^ m2 * e ^ (m1 - r) := by conv_lhs => rw [hkr, pow_add] have h2 : e ^ m1 = e ^ r * e ^ (m1 - r) := by conv_lhs => rw [hm1r, pow_add] rw [h1, h2]; ring have ha : 0 ≤ e ^ m2 - e ^ r := sub_nonneg.mpr (pow_le_pow_right₀ he (by omega)) have hb : 0 ≤ e ^ (m1 - r) - 1 := sub_nonneg.mpr (one_le_pow₀ he) linarith [mul_nonneg ha hb] · have hkr_le : k - r ≤ m1 := by dsimp only [m1]; omega have hkr2 : r = m2 + (m1 - (k - r)) := by dsimp only [m1, m2]; omega have hm1kr : m1 = (k - r) + (m1 - (k - r)) := by omega have hfac : e ^ r + e ^ (k - r) - (e ^ m1 + e ^ m2) = (e ^ m2 - e ^ (k - r)) * (e ^ (m1 - (k - r)) - 1) := by have h1 : e ^ r = e ^ m2 * e ^ (m1 - (k - r)) := by conv_lhs => rw [hkr2, pow_add] have h2 : e ^ m1 = e ^ (k - r) * e ^ (m1 - (k - r)) := by conv_lhs => rw [hm1kr, pow_add] rw [h1, h2]; ring have ha : 0 ≤ e ^ m2 - e ^ (k - r) := sub_nonneg.mpr (pow_le_pow_right₀ he (by omega)) have hb : 0 ≤ e ^ (m1 - (k - r)) - 1 := sub_nonneg.mpr (one_le_pow₀ he) linarith [mul_nonneg ha hb] /-- **EXACT UNIVERSAL GROUP-PRIVACY VACUITY THRESHOLD THEOREM**: For EVERY `k ≥ 1`, EVERY `ε > 0`, and EVERY `δ ∈ [0, 1]`, let `e = e^ε`, `m₁ = ⌊k / 2⌋`, `m₂ = k - m₁ = ⌈k / 2⌉`, and `δ_vac(k, ε) = (e - 1) / (e^{m₁} + e^{m₂} - 2)`. Then the exact `k`-group privacy parameter hits vacuity (`= 1`) **IF AND ONLY IF** `δ ≥ δ_vac(k, ε)`! -/ theorem epsDelta_group_vacuity_threshold_exact {k : ℕ} (hk : 1 ≤ k) {ε δ : ℝ} (hε : 0 < ε) (hδ0 : 0 ≤ δ) (_hδ1 : δ ≤ 1) : let e := Real.exp ε let δ_vac := (e - 1) / (e ^ (k / 2) + e ^ (k - k / 2) - 2) groupEnvIter k e δ 0 = 1 ↔ δ_vac ≤ δ := by intro e δ_vac have he1 : 1 < e := Real.one_lt_exp_iff.mpr hε have he_pos : 0 < e := by linarith have hem1_pos : 0 < e - 1 := by linarith set m1 := k / 2 set m2 := k - k / 2 have hm2_pos : 1 ≤ m2 := by dsimp only [m2]; omega have hden_pos : 0 < e ^ m1 + e ^ m2 - 2 := by have h1 : 1 ≤ e ^ m1 := one_le_pow₀ (le_of_lt he1) have h2 : 1 < e ^ m2 := one_lt_pow₀ he1 (by omega) linarith let f1 : ℝ → ℝ := fun x => δ + e * x let f2 : ℝ → ℝ := fun x => 1 - (1 - δ - x) / e have hf1_mono : Monotone f1 := fun _ _ hab => by dsimp only [f1]; nlinarith have hf2_mono : Monotone f2 := fun a b hab => by dsimp only [f2] have := div_le_div_of_nonneg_right (by linarith : 1 - δ - b ≤ 1 - δ - a) (le_of_lt he_pos) linarith have hg_le_f1 : ∀ x, groupEnv e δ x ≤ f1 x := fun x => (min_le_right _ _).trans (min_le_left _ _) have hg_le_f2 : ∀ x, groupEnv e δ x ≤ f2 x := fun x => (min_le_right _ _).trans (min_le_right _ _) -- General upper bound: groupEnvIter (j + t) e δ 0 ≤ f2^[t] (f1^[j] 0)! have hup_fast : ∀ j : ℕ, groupEnvIter j e δ 0 ≤ f1^[j] 0 := by intro j induction j with | zero => simp [groupEnvIter] | succ j ih => rw [Function.iterate_succ_apply'] exact (hg_le_f1 _).trans (hf1_mono ih) have hup_split : ∀ j t : ℕ, groupEnvIter (j + t) e δ 0 ≤ f2^[t] (f1^[j] 0) := by intro j t induction t with | zero => simpa using hup_fast j | succ t ih => rw [← Nat.add_assoc, Function.iterate_succ_apply'] exact (hg_le_f2 _).trans (hf2_mono ih) constructor · -- (→) If groupEnvIter k = 1, then δ_vac ≤ δ! intro hvac by_contra hlt push Not at hlt have hm_sum : m1 + m2 = k := by dsimp only [m1, m2]; omega have hle := hup_split m1 m2 rw [hm_sum, hvac] at hle have hrem : 1 - f2^[m2] (f1^[m1] 0) = (1 - δ * (e ^ m1 + e ^ m2 - 2) / (e - 1)) / e ^ m2 := by rw [slowIter_eq e δ (f1^[m1] 0) he1 m2, fastIter_eq e δ he1 m1] congr 1; ring have hnum_pos : 0 < 1 - δ * (e ^ m1 + e ^ m2 - 2) / (e - 1) := by have hmul : δ * (e ^ m1 + e ^ m2 - 2) < e - 1 := (lt_div_iff₀ hden_pos).mp hlt have hdiv : δ * (e ^ m1 + e ^ m2 - 2) / (e - 1) < 1 := (div_lt_one hem1_pos).mpr hmul linarith have hrem_pos : 0 < 1 - f2^[m2] (f1^[m1] 0) := by rw [hrem]; exact div_pos hnum_pos (pow_pos he_pos m2) linarith · -- (←) If δ_vac ≤ δ, then groupEnvIter k = 1! intro hge have hle1 : groupEnvIter k e δ 0 ≤ 1 := (groupEnvIter_mem_Icc (le_of_lt he1) hδ0 le_rfl zero_le_one k).2 by_contra hne have hlt1 : groupEnvIter k e δ 0 < 1 := lt_of_le_of_ne hle1 hne -- Sequence a_j = groupEnvIter j e δ 0 is nondecreasing and < 1 for ALL j ≤ k! have ha_mono : ∀ {j₁ j₂ : ℕ}, j₁ ≤ j₂ → groupEnvIter j₁ e δ 0 ≤ groupEnvIter j₂ e δ 0 := by intro j₁ j₂ hle induction hle with | refl => exact le_rfl | @step m _ ih => have hm := groupEnvIter_mem_Icc (le_of_lt he1) hδ0 le_rfl zero_le_one m exact ih.trans (groupEnv_ge_self (le_of_lt he1) hδ0 hm.1 hm.2) have ha_lt1 : ∀ j ≤ k, groupEnvIter j e δ 0 < 1 := fun j hj => lt_of_le_of_lt (ha_mono hj) hlt1 -- At every j < k, since a_{j+1} < 1, a_{j+1} = min (f1 a_j) (f2 a_j)! -- Moreover f1 x ≤ f2 x ↔ x ≤ α₁ := (1 - δ) / (e + 1)! set α₁ : ℝ := (1 - δ) / (e + 1) have hf1_le_f2 : ∀ x : ℝ, f1 x ≤ f2 x ↔ x ≤ α₁ := by intro x dsimp only [f1, f2, α₁] have hep : 0 < e + 1 := by linarith rw [le_div_iff₀ hep] constructor <;> intro h · have h1 := mul_le_mul_of_nonneg_left h (le_of_lt he_pos) have h2 : e * (1 - (1 - δ - x) / e) = e - (1 - δ - x) := by field_simp [ne_of_gt he_pos] rw [h2] at h1 have h3 : (e - 1) * (x * (e + 1)) ≤ (e - 1) * (1 - δ) := by nlinarith exact le_of_mul_le_mul_left h3 hem1_pos · have h3 : (e - 1) * (x * (e + 1)) ≤ (e - 1) * (1 - δ) := mul_le_mul_of_nonneg_left h (le_of_lt hem1_pos) have h1 : e * (δ + e * x) ≤ e - (1 - δ - x) := by nlinarith have h2 : e * (1 - (1 - δ - x) / e) = e - (1 - δ - x) := by field_simp [ne_of_gt he_pos] rw [← h2] at h1 exact le_of_mul_le_mul_left h1 he_pos -- Pick the exact split index r = number of indices j < k with a_j ≤ α₁! classical let S := (Finset.range k).filter fun j => groupEnvIter j e δ 0 ≤ α₁ set r : ℕ := S.card have hr_le : r ≤ k := by have := Finset.card_le_card (Finset.filter_subset (fun j => groupEnvIter j e δ 0 ≤ α₁) (Finset.range k)) rw [Finset.card_range] at this; exact this -- Because a_j is monotone, S = Finset.range r! have hS_eq : S = Finset.range r := by have hdown : ∀ j₁ j₂ : ℕ, j₁ ≤ j₂ → j₂ ∈ S → j₁ ∈ S := by intro j₁ j₂ hle hj₂ have hj₂' := Finset.mem_filter.mp hj₂ refine Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (lt_of_le_of_lt hle (Finset.mem_range.mp hj₂'.1)), (ha_mono hle).trans hj₂'.2⟩ by_contra hneS -- If S ≠ range r, since |S| = r, some x ∈ S must have x ≥ r; then range (x+1) ⊆ S, contradiction! have hex : ∃ x ∈ S, r ≤ x := by by_contra hall push Not at hall have hsub : S ⊆ Finset.range r := fun x hx => Finset.mem_range.mpr (hall x hx) exact hneS (Finset.eq_of_subset_of_card_le hsub (by rw [Finset.card_range])) rcases hex with ⟨x, hxS, hrx⟩ have hsub : Finset.range (x + 1) ⊆ S := fun y hy => hdown y x (Nat.lt_succ_iff.mp (Finset.mem_range.mp hy)) hxS have hcard := Finset.card_le_card hsub rw [Finset.card_range] at hcard; omega -- Compute a_r = f1^[r] 0 by induction on j ≤ r! have har : ∀ j ≤ r, groupEnvIter j e δ 0 = f1^[j] 0 := by intro j hj induction j with | zero => simp [groupEnvIter] | succ j ih => have hjS : j ∈ S := by rw [hS_eq, Finset.mem_range]; omega have hja : groupEnvIter j e δ 0 ≤ α₁ := (Finset.mem_filter.mp hjS).2 have h12 : f1 (groupEnvIter j e δ 0) ≤ f2 (groupEnvIter j e δ 0) := (hf1_le_f2 _).mpr hja have hltj : groupEnvIter (j + 1) e δ 0 < 1 := ha_lt1 (j + 1) (by omega) have hstep : groupEnvIter (j + 1) e δ 0 = f1 (groupEnvIter j e δ 0) := by change min 1 (min (f1 (groupEnvIter j e δ 0)) (f2 (groupEnvIter j e δ 0))) = _ rw [min_eq_left h12] rcases le_total 1 (f1 (groupEnvIter j e δ 0)) with h1 | h1 · exfalso; change min 1 (min (f1 _) (f2 _)) < 1 at hltj rw [min_eq_left h12, min_eq_left h1] at hltj; exact lt_irrefl _ hltj · exact min_eq_right h1 rw [hstep, ih (by omega), Function.iterate_succ_apply'] -- Compute a_{r + t} = f2^[t] (f1^[r] 0) for all t ≤ k - r! have hat : ∀ t ≤ k - r, groupEnvIter (r + t) e δ 0 = f2^[t] (f1^[r] 0) := by intro t ht induction t with | zero => simpa using har r le_rfl | succ t ih => have hj_notS : r + t ∉ S := by rw [hS_eq, Finset.mem_range]; omega have hja : ¬ groupEnvIter (r + t) e δ 0 ≤ α₁ := by intro hle exact hj_notS (Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (by omega), hle⟩) have h21 : f2 (groupEnvIter (r + t) e δ 0) ≤ f1 (groupEnvIter (r + t) e δ 0) := le_of_not_ge fun hle => hja ((hf1_le_f2 _).mp hle) have hltt : groupEnvIter (r + t + 1) e δ 0 < 1 := ha_lt1 (r + t + 1) (by omega) have hstep : groupEnvIter (r + t + 1) e δ 0 = f2 (groupEnvIter (r + t) e δ 0) := by change min 1 (min (f1 (groupEnvIter (r + t) e δ 0)) (f2 (groupEnvIter (r + t) e δ 0))) = _ rw [min_eq_right h21] rcases le_total 1 (f2 (groupEnvIter (r + t) e δ 0)) with h1 | h1 · exfalso; change min 1 (min (f1 _) (f2 _)) < 1 at hltt rw [min_eq_right h21, min_eq_left h1] at hltt; exact lt_irrefl _ hltt · exact min_eq_right h1 rw [← Nat.add_assoc, hstep, ih (by omega), Function.iterate_succ_apply'] have hak := hat (k - r) le_rfl rw [Nat.add_sub_cancel' hr_le] at hak have hrem : 1 - groupEnvIter k e δ 0 = (1 - δ * (e ^ r + e ^ (k - r) - 2) / (e - 1)) / e ^ (k - r) := by rw [hak, slowIter_eq e δ (f1^[r] 0) he1 (k - r), fastIter_eq e δ he1 r] congr 1; ring have hrem_pos : 0 < 1 - groupEnvIter k e δ 0 := by linarith rw [hrem] at hrem_pos have hnum_pos : 0 < 1 - δ * (e ^ r + e ^ (k - r) - 2) / (e - 1) := (div_pos_iff_of_pos_right (pow_pos he_pos (k - r))).mp hrem_pos have hpow_ge : e ^ m1 + e ^ m2 - 2 ≤ e ^ r + e ^ (k - r) - 2 := by linarith [pow_sum_min_at_half (le_of_lt he1) hr_le] have hprod_ge : e - 1 ≤ δ * (e ^ m1 + e ^ m2 - 2) := (div_le_iff₀ hden_pos).mp hge have hprod_ge2 : e - 1 ≤ δ * (e ^ r + e ^ (k - r) - 2) := hprod_ge.trans (mul_le_mul_of_nonneg_left hpow_ge hδ0) have hdiv_ge : 1 ≤ δ * (e ^ r + e ^ (k - r) - 2) / (e - 1) := (one_le_div hem1_pos).mpr hprod_ge2 linarith /-- **EXACT SQUARE-ROOT-EXPONENTIAL GAIN OVER TEXTBOOK GROUP PRIVACY**: For EVERY `k ≥ 2` and EVERY `ε > 0`, the exact vacuity threshold `δ_vac(k, ε)` exceeds the textbook vacuity threshold `δ_textbook(k, ε) = (e^ε - 1) / (e^{kε} - 1)` by a factor of at least `(1 / 2) e^{⌊k / 2⌋ ε}`! -/ theorem epsDelta_group_vacuity_exponential_gain {k : ℕ} (hk : 2 ≤ k) {ε : ℝ} (hε : 0 < ε) : let e := Real.exp ε let δ_vac := (e - 1) / (e ^ (k / 2) + e ^ (k - k / 2) - 2) let δ_tb := (e - 1) / (e ^ k - 1) (1 / 2 : ℝ) * e ^ (k / 2) * δ_tb ≤ δ_vac ∧ δ_tb < δ_vac := by intro e δ_vac δ_tb have he1 : 1 < e := Real.one_lt_exp_iff.mpr hε have hem1 : 0 < e - 1 := by linarith set m1 := k / 2 set m2 := k - k / 2 have hm1_pos : 1 ≤ m1 := by dsimp only [m1]; omega have hm2_pos : 1 ≤ m2 := by dsimp only [m2]; omega have hm_sum : m1 + m2 = k := by dsimp only [m1, m2]; omega have hm1_le_m2 : m1 ≤ m2 := by dsimp only [m1, m2]; omega have he_m1 : 1 < e ^ m1 := one_lt_pow₀ he1 (by omega) have he_m2 : 1 < e ^ m2 := one_lt_pow₀ he1 (by omega) have he_m1_le_m2 : e ^ m1 ≤ e ^ m2 := pow_le_pow_right₀ (le_of_lt he1) hm1_le_m2 have he_k : e ^ k = e ^ m1 * e ^ m2 := by rw [← hm_sum, pow_add] have hden_v : 0 < e ^ m1 + e ^ m2 - 2 := by linarith have hden_tb : 0 < e ^ k - 1 := by rw [he_k]; nlinarith constructor · dsimp only [δ_vac, δ_tb] rw [mul_div_assoc', div_le_div_iff₀ hden_tb hden_v] have hmain : e ^ m1 * (e ^ m1 + e ^ m2 - 2) ≤ 2 * (e ^ k - 1) := by rw [he_k] have h1 : e ^ m1 * e ^ m1 ≤ e ^ m1 * e ^ m2 := mul_le_mul_of_nonneg_left he_m1_le_m2 (by linarith) nlinarith nlinarith · dsimp only [δ_vac, δ_tb] rw [div_lt_div_iff₀ hden_tb hden_v] have hlt : e ^ m1 + e ^ m2 - 2 < e ^ k - 1 := by rw [he_k]; nlinarith exact mul_lt_mul_of_pos_left hlt hem1 /-! ============================================================================ PART 5: LOCAL-DP CONTRACTION (TV, χ²-CAPACITY, KL-CAPACITY, BINARY χ²-SDPI) AND n-USER PRIVATE HYPOTHESIS TESTING MINIMAX RISK ============================================================================ -/ /-- A Markov kernel `W : α → Ω → ℝ` is `(ε, δ)`-locally differentially private (`(ε, δ)`-LDP) iff EVERY pair of input rows `(W x, W x')` is `(ε, δ)`-indistinguishable. -/ def IsLDPChannel {α Ω : Type*} [Fintype Ω] (ε δ : ℝ) (W : α → Ω → ℝ) : Prop := IsMarkovKernel W ∧ ∀ x₁ x₂ : α, IsEpsDeltaClose ε δ (W x₁) (W x₂) /-- **EXACT `(ε, δ)`-LDP DOBRUSHIN / TOTAL VARIATION CONTRACTION THEOREM**: For EVERY `(ε, δ)`-LDP channel `W : α → Ω → ℝ` and EVERY pair of input distributions `P, Q`, `TV(W P, W Q) ≤ ((e^ε - 1 + 2δ) / (e^ε + 1)) · TV(P, Q)`, and this exact constant is **ATTAINED** by the canonical 4-outcome `(ε, δ)`-LDP channel! -/ theorem ldp_tv_contraction_exact {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : (∀ {α Ω : Type*} [Fintype α] [Fintype Ω] (W : α → Ω → ℝ) (P Q : α → ℝ), IsLDPChannel ε δ W → IsProbDist P → IsProbDist Q → tvDist (pushforward W P) (pushforward W Q) ≤ ((Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1)) * tvDist P Q) ∧ (∃ W : Bool → Fin 4 → ℝ, IsLDPChannel ε δ W ∧ tvDist (pushforward W (fun b => if b then 1 else 0)) (pushforward W (fun b => if b then 0 else 1)) = ((Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1)) * tvDist (fun b : Bool => if b then 1 else 0) (fun b : Bool => if b then 0 else 1)) := by set η : ℝ := (Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1) have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have hη_nn : 0 ≤ η := div_nonneg (by linarith) (by linarith) constructor · intro α Ω _ _ W P Q hW hP hQ -- Standard Dobrushin coupling decomposition of P - Q into pos/neg parts of total mass TV(P, Q)! let pos : α → ℝ := fun x => max 0 (P x - Q x) let neg : α → ℝ := fun x => max 0 (Q x - P x) have hpos_nn : ∀ x, 0 ≤ pos x := fun _ => le_max_left _ _ have hneg_nn : ∀ x, 0 ≤ neg x := fun _ => le_max_left _ _ have hdiff : ∀ x, P x - Q x = pos x - neg x := fun x => by dsimp only [pos, neg]; rcases le_total (P x) (Q x) with h | h · rw [max_eq_left (by linarith), max_eq_right (by linarith)]; ring · rw [max_eq_right (by linarith), max_eq_left (by linarith)]; ring have hs_pos : ∑ x : α, pos x = tvDist P Q := by have := hockeyStick_one_eq_tvDist hP hQ dsimp only [hockeyStick] at this; simpa [pos, one_mul] using this have hs_neg : ∑ x : α, neg x = tvDist P Q := by have := hockeyStick_one_eq_tvDist hQ hP rw [tvDist_symm] at this dsimp only [hockeyStick] at this; simpa [neg, one_mul] using this by_cases htv0 : tvDist P Q = 0 · have hPQ : P = Q := by funext x have h1 : pos x = 0 := le_antisymm (by rw [← htv0, ← hs_pos]; exact Finset.single_le_sum (fun y _ => hpos_nn y) (Finset.mem_univ x)) (hpos_nn x) have h2 : neg x = 0 := le_antisymm (by rw [← htv0, ← hs_neg]; exact Finset.single_le_sum (fun y _ => hneg_nn y) (Finset.mem_univ x)) (hneg_nn x) linarith [hdiff x] rw [htv0, mul_zero, hPQ]; dsimp only [tvDist]; simp have htv_pos : 0 < tvDist P Q := lt_of_le_of_ne (tvDist_nonneg P Q) (Ne.symm htv0) -- Express (W P)(z) - (W Q)(z) = (1 / TV) * ∑_{x, y} pos x * neg y * (W x z - W y z)! have hrep : ∀ z : Ω, pushforward W P z - pushforward W Q z = (∑ x : α, ∑ y : α, pos x * neg y * (W x z - W y z)) / tvDist P Q := by intro z dsimp only [pushforward] have h1 : ∑ x : α, ∑ y : α, pos x * neg y * (W x z - W y z) = (∑ y : α, neg y) * (∑ x : α, pos x * W x z) - (∑ x : α, pos x) * (∑ y : α, neg y * W y z) := by simp_rw [mul_sub, Finset.sum_sub_distrib] congr 1 · rw [Finset.sum_mul] simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by ring · rw [Finset.sum_mul] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring rw [h1, hs_pos, hs_neg, ← mul_sub, mul_div_cancel_left₀ _ (ne_of_gt htv_pos), ← Finset.sum_sub_distrib, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun x _ => ?_ rw [← sub_mul, ← sub_mul, hdiff x] have hpair_tv : ∀ x y : α, tvDist (W x) (W y) ≤ η := fun x y => (epsDelta_max_tvDist_exact hε hδ0 hδ1).1 (W x) (W y) (hW.1 x) (hW.1 y) (hW.2 x y) dsimp only [tvDist] calc (1 / 2 : ℝ) * ∑ z : Ω, |pushforward W P z - pushforward W Q z| = (1 / 2 : ℝ) * ∑ z : Ω, |(∑ x : α, ∑ y : α, pos x * neg y * (W x z - W y z)) / tvDist P Q| := by congr 1; exact Finset.sum_congr rfl fun z _ => by rw [hrep z] _ = ((1 / 2 : ℝ) * ∑ z : Ω, |∑ x : α, ∑ y : α, pos x * neg y * (W x z - W y z)|) / tvDist P Q := by simp_rw [abs_div, abs_of_pos htv_pos, ← Finset.sum_div, mul_div_assoc] _ ≤ ((1 / 2 : ℝ) * ∑ z : Ω, ∑ x : α, ∑ y : α, pos x * neg y * |W x z - W y z|) / tvDist P Q := by refine div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun z _ => ?_) (by norm_num)) (le_of_lt htv_pos) calc |∑ x : α, ∑ y : α, pos x * neg y * (W x z - W y z)| ≤ ∑ x : α, |∑ y : α, pos x * neg y * (W x z - W y z)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ x : α, ∑ y : α, |pos x * neg y * (W x z - W y z)| := Finset.sum_le_sum fun x _ => Finset.abs_sum_le_sum_abs _ _ _ = ∑ x : α, ∑ y : α, pos x * neg y * |W x z - W y z| := by refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => ?_ rw [abs_mul, abs_of_nonneg (mul_nonneg (hpos_nn x) (hneg_nn y))] _ = (∑ x : α, ∑ y : α, pos x * neg y * tvDist (W x) (W y)) / tvDist P Q := by congr 1 rw [Finset.mul_sum] simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.sum_comm] refine Finset.sum_congr rfl fun y _ => ?_ dsimp only [tvDist] rw [Finset.mul_sum, Finset.mul_sum] refine Finset.sum_congr rfl fun z _ => by ring _ ≤ (∑ x : α, ∑ y : α, pos x * neg y * η) / tvDist P Q := by refine div_le_div_of_nonneg_right (Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun y _ => ?_) (le_of_lt htv_pos) exact mul_le_mul_of_nonneg_left (hpair_tv x y) (mul_nonneg (hpos_nn x) (hneg_nn y)) _ = η * tvDist P Q := by have hsum_xy : ∑ x : α, ∑ y : α, pos x * neg y * η = η * tvDist P Q * tvDist P Q := by have h1 : ∀ x : α, ∑ y : α, pos x * neg y * η = pos x * η * ∑ y : α, neg y := by intro x; rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring simp_rw [h1, hs_neg, ← Finset.sum_mul, hs_pos]; ring rw [hsum_xy, mul_div_cancel_right₀ _ (ne_of_gt htv_pos)] · let W : Bool → Fin 4 → ℝ := fun b => if b then canonP ε δ else canonQ ε δ have hW : IsLDPChannel ε δ W := by refine ⟨fun b => by cases b <;> dsimp only [W] <;> simp [canonP_isProbDist hδ0 hδ1, canonQ_isProbDist hδ0 hδ1], fun b₁ b₂ => ?_⟩ cases b₁ <;> cases b₂ <;> dsimp only [W] · simp only [Bool.false_eq_true, ↓reduceIte] exact ⟨by rw [hockeyStick_self he1 (canonQ_isProbDist hδ0 hδ1)]; exact hδ0, by rw [hockeyStick_self he1 (canonQ_isProbDist hδ0 hδ1)]; exact hδ0⟩ · simp only [Bool.false_eq_true, ↓reduceIte] exact ⟨(canonPair_isEpsDeltaClose hε hδ0 hδ1).2, (canonPair_isEpsDeltaClose hε hδ0 hδ1).1⟩ · simp only [Bool.false_eq_true, ↓reduceIte] exact canonPair_isEpsDeltaClose hε hδ0 hδ1 · simp only [↓reduceIte] exact ⟨by rw [hockeyStick_self he1 (canonP_isProbDist hδ0 hδ1)]; exact hδ0, by rw [hockeyStick_self he1 (canonP_isProbDist hδ0 hδ1)]; exact hδ0⟩ refine ⟨W, hW, ?_⟩ have hpush1 : pushforward W (fun b => if b then 1 else 0) = canonP ε δ := by funext z; dsimp only [pushforward, W]; rw [Fintype.sum_bool]; simp have hpush0 : pushforward W (fun b => if b then 0 else 1) = canonQ ε δ := by funext z; dsimp only [pushforward, W]; rw [Fintype.sum_bool]; simp have htv_in : tvDist (fun b : Bool => if b then 1 else 0) (fun b : Bool => if b then 0 else 1) = 1 := by dsimp only [tvDist]; rw [Fintype.sum_bool]; norm_num rw [hpush1, hpush0, htv_in, mul_one] exact canonPair_tvDist_exact hε hδ0 hδ1 /-! ### Exact `ε`-LDP `χ²`-Capacity, `KL`-Capacity & Binary `χ²`-SDPI -/ /-- Discrete Pearson `χ²`-divergence `χ²(p ‖ q) = ∑ z, (p z - q z)² / q z`. -/ noncomputable def chi2Div {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) : ℝ := ∑ z : Ω, (p z - q z) ^ 2 / q z /-- Discrete Kullback–Leibler divergence `D_KL(p ‖ q) = ∑ z, p z * log(p z / q z)`. -/ noncomputable def klDiv {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) : ℝ := ∑ z : Ω, if p z = 0 then 0 else p z * Real.log (p z / q z) /-- Discrete `χ²`-mutual information `I_{χ²}(Q; W) = ∑ x, Q x * χ²(W x ‖ W Q)`. -/ noncomputable def chi2MutualInfo {α Ω : Type*} [Fintype α] [Fintype Ω] (Q : α → ℝ) (W : α → Ω → ℝ) : ℝ := ∑ x : α, Q x * chi2Div (W x) (pushforward W Q) /-- Discrete KL mutual information `I_KL(Q; W) = ∑ x, Q x * D_KL(W x ‖ W Q)`. -/ noncomputable def klMutualInfo {α Ω : Type*} [Fintype α] [Fintype Ω] (Q : α → ℝ) (W : α → Ω → ℝ) : ℝ := ∑ x : α, Q x * klDiv (W x) (pushforward W Q) /-- Pure `ε`-LDP channel characterization: `W x₁ z ≤ e^ε * W x₂ z` for ALL `x₁, x₂, z`. -/ lemma pureLDP_ratio_le {α Ω : Type*} [Fintype Ω] {ε : ℝ} {W : α → Ω → ℝ} (hW : IsLDPChannel ε 0 W) (x₁ x₂ : α) (z : Ω) : W x₁ z ≤ Real.exp ε * W x₂ z := by have h := (hW.2 x₁ x₂).1 have hterm : max 0 (W x₁ z - Real.exp ε * W x₂ z) ≤ 0 := by have hs := Finset.single_le_sum (f := fun w => max 0 (W x₁ w - Real.exp ε * W x₂ w)) (fun _ _ => le_max_left _ _) (Finset.mem_univ z) exact hs.trans h linarith [le_max_right (0 : ℝ) (W x₁ z - Real.exp ε * W x₂ z)] /-- Bhatia–Davis variance bound: if `m ≤ f x ≤ M` on support of `Q` with mean `μ = ∑ Q x * f x`, then `∑ Q x * (f x - μ)² ≤ (M - μ) * (μ - m)`. -/ private lemma bhatia_davis_var {α : Type*} [Fintype α] {Q f : α → ℝ} (hQ : IsProbDist Q) {m M : ℝ} (hlo : ∀ x, m ≤ f x) (hhi : ∀ x, f x ≤ M) : ∑ x : α, Q x * (f x - ∑ y : α, Q y * f y) ^ 2 ≤ (M - ∑ y : α, Q y * f y) * ((∑ y : α, Q y * f y) - m) := by set μ := ∑ y : α, Q y * f y have h0 : 0 ≤ ∑ x : α, Q x * ((M - f x) * (f x - m)) := Finset.sum_nonneg fun x _ => mul_nonneg (hQ.1 x) (mul_nonneg (by linarith [hhi x]) (by linarith [hlo x])) have hexp : ∑ x : α, Q x * ((M - f x) * (f x - m)) = (M - μ) * (μ - m) - ∑ x : α, Q x * (f x - μ) ^ 2 := by have hpt : ∀ x : α, Q x * ((M - f x) * (f x - m)) + Q x * (f x - μ) ^ 2 = Q x * (M * f x + m * f x - M * m - 2 * μ * f x + μ ^ 2) := fun x => by ring have hsum := Finset.sum_congr (s₁ := Finset.univ) (s₂ := Finset.univ) rfl (fun x _ => hpt x) rw [Finset.sum_add_distrib] at hsum have hrhs : ∑ x : α, Q x * (M * f x + m * f x - M * m - 2 * μ * f x + μ ^ 2) = (M - μ) * (μ - m) := by have h1 : ∀ x : α, Q x * (M * f x + m * f x - M * m - 2 * μ * f x + μ ^ 2) = (M + m - 2 * μ) * (Q x * f x) + (μ ^ 2 - M * m) * Q x := fun x => by ring simp_rw [h1, Finset.sum_add_distrib, ← Finset.mul_sum, hQ.2] change (M + m - 2 * μ) * μ + (μ ^ 2 - M * m) * 1 = (M - μ) * (μ - m) ring linarith linarith /-- **EXACT `ε`-LDP `χ²`-CAPACITY (MUTUAL INFORMATION) THEOREM**: For EVERY `ε ≥ 0`, EVERY finite `α, Ω`, EVERY pure `ε`-LDP channel `W : α → Ω → ℝ`, and EVERY prior `Q : α → ℝ`: `I_{χ²}(Q; W) ≤ (e^ε - 1)² / (4 e^ε)` (= `sinh²(ε / 2)`), AND for every `k ≥ 2` at `e^ε = k - 1`, `k`-ary Randomized Response with uniform prior `Q` achieves **EXACT EQUALITY**! -/ theorem pureLDP_chi2_capacity_exact {ε : ℝ} (hε : 0 ≤ ε) : (∀ {α Ω : Type*} [Fintype α] [Fintype Ω] (W : α → Ω → ℝ) (Q : α → ℝ), IsLDPChannel ε 0 W → IsProbDist Q → chi2MutualInfo Q W ≤ (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) ∧ (∀ (k : ℕ), 2 ≤ k → Real.exp ε = (k : ℝ) - 1 → let W : Fin k → Fin k → ℝ := fun x y => if x = y then Real.exp ε / (Real.exp ε + (k : ℝ) - 1) else 1 / (Real.exp ε + (k : ℝ) - 1) let Q : Fin k → ℝ := fun _ => 1 / (k : ℝ) IsLDPChannel ε 0 W ∧ IsProbDist Q ∧ chi2MutualInfo Q W = (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε constructor · intro α Ω _ _ W Q hW hQ by_cases hα : IsEmpty α · have h0 : ∑ x : α, Q x = 0 := Finset.sum_eq_zero fun x _ => hα.elim x linarith [hQ.2] have hne : Nonempty α := not_isEmpty_iff.mp hα -- Rewrite I_{χ²}(Q; W) = ∑ z, (∑ x, Q x * (W x z - μ z)²) / μ z! dsimp only [chi2MutualInfo, chi2Div] simp_rw [Finset.mul_sum] rw [Finset.sum_comm] have hpt : ∀ z : Ω, ∑ x : α, Q x * ((W x z - pushforward W Q z) ^ 2 / pushforward W Q z) ≤ ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * pushforward W Q z := by intro z set μ := pushforward W Q z have hμ_nn : 0 ≤ μ := (pushforward_isProbDist hW.1 hQ).1 z by_cases hμ0 : μ = 0 · simp [hμ0] have hμ_pos : 0 < μ := lt_of_le_of_ne hμ_nn (Ne.symm hμ0) -- Let m = min_x W x z, M = max_x W x z! Since W is ε-LDP, M ≤ e^ε * m and m > 0! have huniv : (Finset.univ : Finset α).Nonempty := Finset.univ_nonempty obtain ⟨x_min, _, hmin⟩ := Finset.exists_min_image Finset.univ (fun x => W x z) huniv obtain ⟨x_max, _, hmax⟩ := Finset.exists_max_image Finset.univ (fun x => W x z) huniv set m := W x_min z set M := W x_max z have hm_nn : 0 ≤ m := (hW.1 x_min).1 z have hM_le : M ≤ Real.exp ε * m := pureLDP_ratio_le hW x_max x_min z have hbd := bhatia_davis_var hQ (fun x => hmin x (Finset.mem_univ x)) (fun x => hmax x (Finset.mem_univ x)) have hμ_eq : ∑ y : α, Q y * W y z = μ := rfl rw [hμ_eq] at hbd have hvar_eq : ∑ x : α, Q x * ((W x z - μ) ^ 2 / μ) = (∑ x : α, Q x * (W x z - μ) ^ 2) / μ := by rw [Finset.sum_div]; refine Finset.sum_congr rfl fun x _ => by ring rw [hvar_eq, div_le_iff₀ hμ_pos] -- Show (M - μ) * (μ - m) ≤ ((e - 1)^2 / (4 e)) * μ^2! -- Since M ≤ e * m, (M - μ)(μ - m) ≤ (e * m - μ)(μ - m) = ((e-1)^2/(4e)) μ^2 - e * (m - (e+1)/(2e) μ)^2!! have hμ_ge_m : m ≤ μ := by calc m = ∑ x : α, Q x * m := by rw [← Finset.sum_mul, hQ.2, one_mul] _ ≤ ∑ x : α, Q x * W x z := Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_left (hmin x (Finset.mem_univ x)) (hQ.1 x) have hquad : (Real.exp ε * m - μ) * (μ - m) ≤ ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * μ ^ 2 := by have hsq : 0 ≤ (2 * Real.exp ε * m - (Real.exp ε + 1) * μ) ^ 2 / (4 * Real.exp ε) := by positivity have hid : ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * μ ^ 2 - (Real.exp ε * m - μ) * (μ - m) = (2 * Real.exp ε * m - (Real.exp ε + 1) * μ) ^ 2 / (4 * Real.exp ε) := by field_simp [ne_of_gt he_pos]; ring linarith calc ∑ x : α, Q x * (W x z - μ) ^ 2 ≤ (M - μ) * (μ - m) := hbd _ ≤ (Real.exp ε * m - μ) * (μ - m) := mul_le_mul_of_nonneg_right (by linarith) (by linarith) _ ≤ ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * μ ^ 2 := hquad _ = ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * μ * μ := by ring calc ∑ z : Ω, ∑ x : α, Q x * ((W x z - pushforward W Q z) ^ 2 / pushforward W Q z) ≤ ∑ z : Ω, ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * pushforward W Q z := Finset.sum_le_sum fun z _ => hpt z _ = ((Real.exp ε - 1) ^ 2 / (4 * Real.exp ε)) * ∑ z : Ω, pushforward W Q z := by rw [← Finset.mul_sum] _ = (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε) := by rw [(pushforward_isProbDist hW.1 hQ).2, mul_one] · intro k hk he_eq W Q have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr (by omega) have hden_pos : 0 < Real.exp ε + (k : ℝ) - 1 := by linarith have hQ : IsProbDist Q := by refine ⟨fun _ => by dsimp only [Q]; positivity, ?_⟩ dsimp only [Q]; simp [ne_of_gt hk_pos] have hW_mk : IsMarkovKernel W := by intro x refine ⟨fun y => by dsimp only [W]; split_ifs <;> positivity, ?_⟩ dsimp only [W] have hsum_ne : ∑ y ∈ Finset.univ.erase x, (1 / (Real.exp ε + (k : ℝ) - 1)) = ((k : ℝ) - 1) / (Real.exp ε + (k : ℝ) - 1) := by rw [Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_sub (by omega : 1 ≤ k), Nat.cast_one] ring have htot := Finset.add_sum_erase Finset.univ (fun y : Fin k => if x = y then Real.exp ε / (Real.exp ε + (k : ℝ) - 1) else 1 / (Real.exp ε + (k : ℝ) - 1)) (Finset.mem_univ x) rw [if_pos rfl] at htot have herase : ∑ y ∈ Finset.univ.erase x, (if x = y then Real.exp ε / (Real.exp ε + (k : ℝ) - 1) else 1 / (Real.exp ε + (k : ℝ) - 1)) = ((k : ℝ) - 1) / (Real.exp ε + (k : ℝ) - 1) := by rw [← hsum_ne] refine Finset.sum_congr rfl fun y hy => if_neg (Ne.symm (Finset.ne_of_mem_erase hy)) have : Real.exp ε / (Real.exp ε + (k : ℝ) - 1) + ((k : ℝ) - 1) / (Real.exp ε + (k : ℝ) - 1) = 1 := by field_simp [ne_of_gt hden_pos]; ring rw [← htot, herase, this] have hW_ldp : IsLDPChannel ε 0 W := by refine ⟨hW_mk, fun x₁ x₂ => ?_⟩ have hdir : ∀ a b : Fin k, hockeyStick (Real.exp ε) (W a) (W b) ≤ 0 := fun a b => by refine le_of_eq (Finset.sum_eq_zero fun y _ => max_eq_left ?_) dsimp only [W] split_ifs · have : Real.exp ε / (Real.exp ε + (k : ℝ) - 1) * (1 - Real.exp ε) ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (by positivity) (by linarith) linarith · have : Real.exp ε / (Real.exp ε + (k : ℝ) - 1) = Real.exp ε * (1 / (Real.exp ε + (k : ℝ) - 1)) := by ring linarith · have : (1 - Real.exp ε ^ 2) / (Real.exp ε + (k : ℝ) - 1) ≤ 0 := div_nonpos_of_nonpos_of_nonneg (by nlinarith) (le_of_lt hden_pos) have heq : 1 / (Real.exp ε + (k : ℝ) - 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + (k : ℝ) - 1)) = (1 - Real.exp ε ^ 2) / (Real.exp ε + (k : ℝ) - 1) := by ring linarith · have : (1 - Real.exp ε) / (Real.exp ε + (k : ℝ) - 1) ≤ 0 := div_nonpos_of_nonpos_of_nonneg (by linarith) (le_of_lt hden_pos) have heq : 1 / (Real.exp ε + (k : ℝ) - 1) - Real.exp ε * (1 / (Real.exp ε + (k : ℝ) - 1)) = (1 - Real.exp ε) / (Real.exp ε + (k : ℝ) - 1) := by ring linarith exact ⟨hdir x₁ x₂, hdir x₂ x₁⟩ refine ⟨hW_ldp, hQ, ?_⟩ have hpush : pushforward W Q = fun _ => 1 / (k : ℝ) := by funext y dsimp only [pushforward, Q, W] rw [← Finset.mul_sum] have hsum_y : ∑ x : Fin k, (if x = y then Real.exp ε / (Real.exp ε + (k : ℝ) - 1) else 1 / (Real.exp ε + (k : ℝ) - 1)) = 1 := by have hsym : ∀ x : Fin k, (if x = y then Real.exp ε / (Real.exp ε + (k : ℝ) - 1) else 1 / (Real.exp ε + (k : ℝ) - 1)) = W y x := by intro x; by_cases hxy : x = y · subst hxy; simp [W] · simp [W, hxy, Ne.symm hxy] simp_rw [hsym] exact (hW_mk y).2 rw [hsum_y, mul_one] dsimp only [chi2MutualInfo, chi2Div] rw [hpush] have hrow : ∀ x : Fin k, ∑ y : Fin k, (W x y - 1 / (k : ℝ)) ^ 2 / (1 / (k : ℝ)) = (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε) := by intro x rw [← Finset.add_sum_erase _ _ (Finset.mem_univ x)] have hdiag : (W x x - 1 / (k : ℝ)) ^ 2 / (1 / (k : ℝ)) = (k : ℝ) * (Real.exp ε / (Real.exp ε + (k : ℝ) - 1) - 1 / (k : ℝ)) ^ 2 := by dsimp only [W]; rw [if_pos rfl]; field_simp [ne_of_gt hk_pos] have hoff : ∀ y ∈ Finset.univ.erase x, (W x y - 1 / (k : ℝ)) ^ 2 / (1 / (k : ℝ)) = (k : ℝ) * (1 / (Real.exp ε + (k : ℝ) - 1) - 1 / (k : ℝ)) ^ 2 := by intro y hy dsimp only [W]; rw [if_neg (Ne.symm (Finset.ne_of_mem_erase hy))] field_simp [ne_of_gt hk_pos] rw [hdiag, Finset.sum_congr rfl hoff, Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_sub (by omega : 1 ≤ k), Nat.cast_one] have hden_ne : Real.exp ε + (k : ℝ) - 1 ≠ 0 := ne_of_gt hden_pos rw [he_eq] at hden_ne ⊢ have hk1 : (k : ℝ) - 1 ≠ 0 := by linarith field_simp [ne_of_gt hk_pos, hk1, hden_ne]; ring simp_rw [hrow] dsimp only [Q] rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp [ne_of_gt hk_pos] /-- **EXACT `ε`-LDP KL-MUTUAL INFORMATION CAPACITY BOUND (`2 log cosh(ε / 2) < ε`)**: For EVERY `ε ≥ 0`, EVERY pure `ε`-LDP channel `W`, and EVERY prior `Q`: `I_KL(Q; W) ≤ Real.log ((Real.exp ε + 1) ^ 2 / (4 * Real.exp ε))`, and for EVERY `ε > 0` this is **STRICTLY LESS THAN `ε`**! -/ theorem pureLDP_kl_mutual_info_le_log_cosh {α Ω : Type*} [Fintype α] [Fintype Ω] {ε : ℝ} (hε : 0 ≤ ε) {W : α → Ω → ℝ} {Q : α → ℝ} (hW : IsLDPChannel ε 0 W) (hQ : IsProbDist Q) : klMutualInfo Q W ≤ Real.log ((Real.exp ε + 1) ^ 2 / (4 * Real.exp ε)) ∧ (0 < ε → Real.log ((Real.exp ε + 1) ^ 2 / (4 * Real.exp ε)) < ε) := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε have hpush_prob := pushforward_isProbDist hW.1 hQ -- Step 1: For every x with Q x > 0, klDiv (W x) (W Q) ≤ log (1 + chi2Div (W x) (W Q))! have hkl_le_log_chi2 : ∀ x : α, Q x > 0 → klDiv (W x) (pushforward W Q) ≤ Real.log (1 + chi2Div (W x) (pushforward W Q)) := by intro x hQx -- By concavity of log on (0, ∞): ∑_{z : W x z > 0} W x z * log(W x z / μ z) ≤ log(∑ W x z * (W x z / μ z)) = log(1 + χ²)! set μ := pushforward W Q have hμ_pos_of_W : ∀ z : Ω, 0 < W x z → 0 < μ z := fun z hWz => by have hterm : Q x * W x z ≤ μ z := Finset.single_le_sum (f := fun a => Q a * W a z) (fun a _ => mul_nonneg (hQ.1 a) ((hW.1 a).1 z)) (Finset.mem_univ x) linarith [mul_pos hQx hWz] have hchi2_id : 1 + chi2Div (W x) μ = ∑ z : Ω, if W x z = 0 then 0 else W x z * (W x z / μ z) := by have hsum_W : ∑ z : Ω, W x z = 1 := (hW.1 x).2 have hsum_μ : ∑ z : Ω, μ z = 1 := hpush_prob.2 dsimp only [chi2Div] have hpt : ∀ z : Ω, (W x z - μ z) ^ 2 / μ z + 2 * W x z - μ z = if W x z = 0 then 0 else W x z * (W x z / μ z) := by intro z by_cases hWz : W x z = 0 · rw [if_pos hWz, hWz, zero_sub, mul_zero, add_zero, neg_sq] by_cases hμz : μ z = 0 · simp [hμz] · field_simp [hμz]; ring · rw [if_neg hWz] have hpos : 0 < W x z := lt_of_le_of_ne ((hW.1 x).1 z) (Ne.symm hWz) have hμp : 0 < μ z := hμ_pos_of_W z hpos field_simp [ne_of_gt hμp]; ring have htot := Finset.sum_congr (s₁ := Finset.univ) (s₂ := Finset.univ) rfl (fun z _ => hpt z) simp_rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, hsum_W, hsum_μ] at htot linarith -- Use log(u) ≤ u / c - 1 + log c with c = 1 + χ² > 0! set c := 1 + chi2Div (W x) μ have hchi2_nn : 0 ≤ chi2Div (W x) μ := Finset.sum_nonneg fun z _ => div_nonneg (sq_nonneg _) (hpush_prob.1 z) have hc_pos : 0 < c := by linarith have hpt_log : ∀ z : Ω, (if W x z = 0 then (0 : ℝ) else W x z * Real.log (W x z / μ z)) ≤ (if W x z = 0 then (0 : ℝ) else W x z * ((W x z / μ z) / c - 1 + Real.log c)) := by intro z by_cases hWz : W x z = 0 · simp [hWz] · rw [if_neg hWz, if_neg hWz] have hpos : 0 < W x z := lt_of_le_of_ne ((hW.1 x).1 z) (Ne.symm hWz) have hμp : 0 < μ z := hμ_pos_of_W z hpos have hr_pos : 0 < W x z / μ z := div_pos hpos hμp have hlog : Real.log (W x z / μ z) ≤ (W x z / μ z) / c - 1 + Real.log c := by have h1 := Real.log_le_sub_one_of_pos (div_pos hr_pos hc_pos) rw [Real.log_div (ne_of_gt hr_pos) (ne_of_gt hc_pos)] at h1 linarith exact mul_le_mul_of_nonneg_left hlog (le_of_lt hpos) calc klDiv (W x) μ ≤ ∑ z : Ω, (if W x z = 0 then (0 : ℝ) else W x z * ((W x z / μ z) / c - 1 + Real.log c)) := Finset.sum_le_sum fun z _ => hpt_log z _ = (∑ z : Ω, if W x z = 0 then (0 : ℝ) else W x z * (W x z / μ z)) / c + (Real.log c - 1) * ∑ z : Ω, W x z := by rw [Finset.sum_div, Finset.mul_sum, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun z _ => ?_ by_cases hWz : W x z = 0 · simp [hWz] · rw [if_neg hWz, if_neg hWz]; ring _ = c / c + (Real.log c - 1) * 1 := by rw [← hchi2_id, (hW.1 x).2] _ = Real.log c := by rw [div_self (ne_of_gt hc_pos)]; ring -- Step 2: Average over Q and use log(1 + u) ≤ (1 + u) / C - 1 + log C with C = 1 + I_{χ²}! set C := 1 + chi2MutualInfo Q W have hI_nn : 0 ≤ chi2MutualInfo Q W := Finset.sum_nonneg fun x _ => mul_nonneg (hQ.1 x) (Finset.sum_nonneg fun z _ => div_nonneg (sq_nonneg _) (hpush_prob.1 z)) have hC_pos : 0 < C := by linarith have hkl_le_logC : klMutualInfo Q W ≤ Real.log C := by calc klMutualInfo Q W ≤ ∑ x : α, Q x * ((1 + chi2Div (W x) (pushforward W Q)) / C - 1 + Real.log C) := by refine Finset.sum_le_sum fun x _ => ?_ by_cases hQx : Q x = 0 · simp [hQx] · have hQp : 0 < Q x := lt_of_le_of_ne (hQ.1 x) (Ne.symm hQx) have h1 := hkl_le_log_chi2 x hQp have hchi2_nn : 0 ≤ chi2Div (W x) (pushforward W Q) := Finset.sum_nonneg fun z _ => div_nonneg (sq_nonneg _) (hpush_prob.1 z) have h2 := Real.log_le_sub_one_of_pos (div_pos (by linarith : 0 < 1 + chi2Div (W x) (pushforward W Q)) hC_pos) rw [Real.log_div (by linarith) (ne_of_gt hC_pos)] at h2 exact mul_le_mul_of_nonneg_left (by linarith) (le_of_lt hQp) _ = (∑ x : α, Q x + chi2MutualInfo Q W) / C + (Real.log C - 1) * ∑ x : α, Q x := by dsimp only [chi2MutualInfo] rw [← Finset.sum_add_distrib, Finset.sum_div, Finset.mul_sum, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun x _ => by ring _ = C / C + (Real.log C - 1) * 1 := by rw [hQ.2] _ = Real.log C := by rw [div_self (ne_of_gt hC_pos)]; ring have hC_le : C ≤ (Real.exp ε + 1) ^ 2 / (4 * Real.exp ε) := by have hcap := (pureLDP_chi2_capacity_exact hε).1 W Q hW hQ have hid : 1 + (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε) = (Real.exp ε + 1) ^ 2 / (4 * Real.exp ε) := by field_simp [ne_of_gt he_pos]; ring linarith refine ⟨hkl_le_logC.trans (Real.log_le_log hC_pos hC_le), fun hε_pos => ?_⟩ have he_gt1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε_pos have hlt : (Real.exp ε + 1) ^ 2 / (4 * Real.exp ε) < Real.exp ε := by rw [div_lt_iff₀ (by positivity)] have h : 4 * Real.exp ε ^ 2 - (Real.exp ε + 1) ^ 2 = (3 * Real.exp ε + 1) * (Real.exp ε - 1) := by ring have hpos : 0 < (3 * Real.exp ε + 1) * (Real.exp ε - 1) := mul_pos (by linarith) (by linarith) nlinarith calc Real.log ((Real.exp ε + 1) ^ 2 / (4 * Real.exp ε)) < Real.log (Real.exp ε) := Real.log_lt_log (by positivity) hlt _ = ε := Real.log_exp ε /-- **EXACT BINARY-INPUT `ε`-LDP `χ²`-CONTRACTION THEOREM**: For EVERY `ε ≥ 0`, EVERY pure `ε`-LDP binary-input channel `W : Bool → Ω → ℝ`, and EVERY pair of binary distributions `P, Q : Bool → ℝ` with `Q > 0`: `χ²(W P ‖ W Q) ≤ ((e^ε - 1) / (e^ε + 1))² · χ²(P ‖ Q)`, and this exact constant is **ATTAINED** by Warner Randomized Response at uniform `Q`! -/ theorem pureLDP_binary_chi2_contraction_exact {ε : ℝ} (hε : 0 ≤ ε) : (∀ {Ω : Type*} [Fintype Ω] (W : Bool → Ω → ℝ) (P Q : Bool → ℝ), IsLDPChannel ε 0 W → IsProbDist P → IsProbDist Q → (∀ b, 0 < Q b) → (∀ z, 0 < pushforward W Q z) → chi2Div (pushforward W P) (pushforward W Q) ≤ ((Real.exp ε - 1) / (Real.exp ε + 1)) ^ 2 * chi2Div P Q) ∧ (∃ W : Bool → Bool → ℝ, IsLDPChannel ε 0 W ∧ let P : Bool → ℝ := fun b => if b then 1 else 0 let Q : Bool → ℝ := fun _ => 1 / 2 chi2Div (pushforward W P) (pushforward W Q) = ((Real.exp ε - 1) / (Real.exp ε + 1)) ^ 2 * chi2Div P Q) := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε have hep_pos : 0 < Real.exp ε + 1 := by linarith constructor · intro Ω _ W P Q hW hP hQ hQpos hWQpos -- Use our constructive Blackwell dominance kernel! (W true, W false) ⪯_BW (warnerP ε, warnerQ ε)! have hdom4 := epsDelta_blackwell_dominance hε le_rfl zero_le_one (hW.1 true) (hW.1 false) (hW.2 true false) rcases hdom4 with ⟨K4, hK4, hKt, hKf⟩ -- Build 2-outcome Markov kernel K : Bool → Ω → ℝ from K4 on {1, 2}! let K : Bool → Ω → ℝ := fun b z => if b then K4 1 z else K4 2 z have hK : IsMarkovKernel K := fun b => by cases b <;> dsimp only [K] <;> [exact hK4 2; exact hK4 1] have hK_true : pushforward K (warnerP ε) = W true := by funext z have hz := congrFun hKt z dsimp only [pushforward, canonP] at hz rw [Fin.sum_univ_four] at hz dsimp only [pushforward, warnerP, K] rw [Fintype.sum_bool] simpa using hz have hK_false : pushforward K (warnerQ ε) = W false := by funext z have hz := congrFun hKf z dsimp only [pushforward, canonQ] at hz rw [Fin.sum_univ_four] at hz dsimp only [pushforward, warnerQ, K] rw [Fintype.sum_bool] simpa using hz let W0 : Bool → Bool → ℝ := fun x => if x then warnerP ε else warnerQ ε have hW_eq : ∀ x, W x = pushforward K (W0 x) := fun x => by cases x <;> dsimp only [W0] <;> [exact hK_false.symm; exact hK_true.symm] have hpush_P : pushforward W P = pushforward K (pushforward W0 P) := by funext z; dsimp only [pushforward] simp_rw [hW_eq, pushforward, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun b _ => ?_ rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun x _ => by ring have hpush_Q : pushforward W Q = pushforward K (pushforward W0 Q) := by funext z; dsimp only [pushforward] simp_rw [hW_eq, pushforward, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun b _ => ?_ rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun x _ => by ring -- Apply our convex f-divergence DPI with f(u) = (u - 1)^2! have hconv : ConvexOn ℝ (Set.Ici (0 : ℝ)) (fun u : ℝ => (u - 1) ^ 2) := by refine ⟨convex_Ici 0, fun x _ y _ a b ha hb hab => ?_⟩ simp only [smul_eq_mul] have hid : a * (x - 1) ^ 2 + b * (y - 1) ^ 2 - (a * x + b * y - 1) ^ 2 = a * b * (x - y) ^ 2 := by have ha_eq : a = 1 - b := by linarith rw [ha_eq]; ring have hnn : 0 ≤ a * b * (x - y) ^ 2 := mul_nonneg (mul_nonneg ha hb) (sq_nonneg _) linarith have hW0_mk : IsMarkovKernel W0 := fun x => by cases x <;> dsimp only [W0] <;> [exact warnerQ_isProbDist ε; exact warnerP_isProbDist ε] have hW0Q_pos : ∀ b : Bool, 0 < pushforward W0 Q b := by intro b dsimp only [pushforward, W0] rw [Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true] cases b <;> dsimp only [warnerP, warnerQ] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> exact add_pos (mul_pos (hQpos true) (by positivity)) (mul_pos (hQpos false) (by positivity)) have hdpi : chi2Div (pushforward W P) (pushforward W Q) ≤ chi2Div (pushforward W0 P) (pushforward W0 Q) := by have hL : chi2Div (pushforward W P) (pushforward W Q) = ∑ z : Ω, pushforward W Q z * (pushforward W P z / pushforward W Q z - 1) ^ 2 := by dsimp only [chi2Div] refine Finset.sum_congr rfl fun z _ => ?_ field_simp [ne_of_gt (hWQpos z)] have hR : chi2Div (pushforward W0 P) (pushforward W0 Q) = ∑ z : Bool, pushforward W0 Q z * (pushforward W0 P z / pushforward W0 Q z - 1) ^ 2 := by dsimp only [chi2Div] refine Finset.sum_congr rfl fun z _ => ?_ field_simp [ne_of_gt (hW0Q_pos z)] rw [hL, hR] exact blackwellDom_fDiv_le hconv (pushforward_isProbDist hW0_mk hP).1 hW0Q_pos hWQpos ⟨K, hK, hpush_P.symm, hpush_Q.symm⟩ -- Direct algebraic evaluation on binary Warner W0! have hwarner_bound : chi2Div (pushforward W0 P) (pushforward W0 Q) ≤ ((Real.exp ε - 1) / (Real.exp ε + 1)) ^ 2 * chi2Div P Q := by set p := P true set q := Q true have hp_f : P false = 1 - p := by have := hP.2; rw [Fintype.sum_bool] at this; linarith have hq_f : Q false = 1 - q := by have := hQ.2; rw [Fintype.sum_bool] at this; linarith have hq0 : 0 < q := hQpos true have h1mq0 : 0 < 1 - q := by rw [← hq_f]; exact hQpos false set r := (Real.exp ε - 1) / (Real.exp ε + 1) have hr0 : 0 ≤ r := div_nonneg (by linarith) (le_of_lt hep_pos) have hr1 : r < 1 := (div_lt_one hep_pos).mpr (by linarith) have hW0_t : ∀ U : Bool → ℝ, U false = 1 - U true → pushforward W0 U true = (1 + r * (2 * U true - 1)) / 2 := by intro U hUf dsimp only [pushforward, W0, r] rw [Fintype.sum_bool, hUf] simp only [↓reduceIte, Bool.false_eq_true, warnerP, warnerQ] field_simp [ne_of_gt hep_pos]; ring have hW0_f : ∀ U : Bool → ℝ, U false = 1 - U true → pushforward W0 U false = (1 - r * (2 * U true - 1)) / 2 := by intro U hUf dsimp only [pushforward, W0, r] rw [Fintype.sum_bool, hUf] simp only [↓reduceIte, Bool.false_eq_true, warnerP, warnerQ] field_simp [ne_of_gt hep_pos]; ring dsimp only [chi2Div] rw [Fintype.sum_bool, Fintype.sum_bool, hW0_t P hp_f, hW0_f P hp_f, hW0_t Q hq_f, hW0_f Q hq_f, hp_f, hq_f] set a := (1 + r * (2 * q - 1)) / 2 set b := (1 - r * (2 * q - 1)) / 2 have ha_pos : 0 < a := by have h2q : |2 * q - 1| < 1 := abs_lt.mpr ⟨by linarith, by linarith⟩ have hmul : r * |2 * q - 1| < 1 := by nlinarith [abs_nonneg (2 * q - 1)] have : |r * (2 * q - 1)| < 1 := by rw [abs_mul, abs_of_nonneg hr0]; exact hmul dsimp only [a]; linarith [(abs_lt.mp this).1] have hb_pos : 0 < b := by have h2q : |2 * q - 1| < 1 := abs_lt.mpr ⟨by linarith, by linarith⟩ have hmul : r * |2 * q - 1| < 1 := by nlinarith [abs_nonneg (2 * q - 1)] have : |r * (2 * q - 1)| < 1 := by rw [abs_mul, abs_of_nonneg hr0]; exact hmul dsimp only [b]; linarith [(abs_lt.mp this).2] have hlhs : ((1 + r * (2 * p - 1)) / 2 - a) ^ 2 / a + ((1 - r * (2 * p - 1)) / 2 - b) ^ 2 / b = r ^ 2 * (p - q) ^ 2 / (a * b) := by have hab1 : a + b = 1 := by dsimp only [a, b]; ring have hda : (1 + r * (2 * p - 1)) / 2 - a = r * (p - q) := by dsimp only [a]; ring have hdb : (1 - r * (2 * p - 1)) / 2 - b = -(r * (p - q)) := by dsimp only [b]; ring rw [hda, hdb, neg_sq] have hcomb : (r * (p - q)) ^ 2 / a + (r * (p - q)) ^ 2 / b = r ^ 2 * (p - q) ^ 2 * (a + b) / (a * b) := by field_simp [ne_of_gt ha_pos, ne_of_gt hb_pos]; ring rw [hcomb, hab1]; ring have hrhs : (p - q) ^ 2 / q + (1 - p - (1 - q)) ^ 2 / (1 - q) = (p - q) ^ 2 / (q * (1 - q)) := by field_simp [ne_of_gt hq0, ne_of_gt h1mq0]; ring rw [hlhs, hrhs] have hab_ge : q * (1 - q) ≤ a * b := by have hid : a * b - q * (1 - q) = (1 - r ^ 2) * (2 * q - 1) ^ 2 / 4 := by dsimp only [a, b]; ring have hnn : 0 ≤ (1 - r ^ 2) * (2 * q - 1) ^ 2 / 4 := by have : 0 ≤ 1 - r ^ 2 := by nlinarith positivity linarith have hdiv : (p - q) ^ 2 / (a * b) ≤ (p - q) ^ 2 / (q * (1 - q)) := div_le_div_of_nonneg_left (sq_nonneg _) (mul_pos hq0 h1mq0) hab_ge calc r ^ 2 * (p - q) ^ 2 / (a * b) = r ^ 2 * ((p - q) ^ 2 / (a * b)) := by ring _ ≤ r ^ 2 * ((p - q) ^ 2 / (q * (1 - q))) := mul_le_mul_of_nonneg_left hdiv (sq_nonneg r) exact hdpi.trans hwarner_bound · let W : Bool → Bool → ℝ := fun x => if x then warnerP ε else warnerQ ε have hW : IsLDPChannel ε 0 W := by refine ⟨fun x => by cases x <;> dsimp only [W] <;> [exact warnerQ_isProbDist ε; exact warnerP_isProbDist ε], fun x₁ x₂ => ?_⟩ have hdir : ∀ a b : Bool, hockeyStick (Real.exp ε) (W a) (W b) ≤ 0 := fun a b => by cases a <;> cases b <;> dsimp only [W] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> dsimp only [hockeyStick, warnerP, warnerQ] <;> rw [Fintype.sum_bool] <;> simp only [↓reduceIte, Bool.false_eq_true] · have h1 : max 0 (1 / (Real.exp ε + 1) - Real.exp ε * (1 / (Real.exp ε + 1))) = 0 := max_eq_left (by have := mul_le_mul_of_nonneg_right he1 (by positivity : 0 ≤ 1 / (Real.exp ε + 1)); linarith) have h2 : max 0 (Real.exp ε / (Real.exp ε + 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + 1))) = 0 := max_eq_left (by have := mul_le_mul_of_nonneg_right he1 (by positivity : 0 ≤ Real.exp ε / (Real.exp ε + 1)); linarith) rw [h1, h2]; norm_num · have h1 : max 0 (1 / (Real.exp ε + 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + 1))) = 0 := max_eq_left (by rw [show 1 / (Real.exp ε + 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + 1)) = (1 - Real.exp ε ^ 2) / (Real.exp ε + 1) by ring]; exact div_nonpos_of_nonpos_of_nonneg (by nlinarith) (le_of_lt hep_pos)) have h2 : max 0 (Real.exp ε / (Real.exp ε + 1) - Real.exp ε * (1 / (Real.exp ε + 1))) = 0 := by rw [show Real.exp ε / (Real.exp ε + 1) - Real.exp ε * (1 / (Real.exp ε + 1)) = 0 by ring, max_self] rw [h1, h2]; norm_num · have h1 : max 0 (Real.exp ε / (Real.exp ε + 1) - Real.exp ε * (1 / (Real.exp ε + 1))) = 0 := by rw [show Real.exp ε / (Real.exp ε + 1) - Real.exp ε * (1 / (Real.exp ε + 1)) = 0 by ring, max_self] have h2 : max 0 (1 / (Real.exp ε + 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + 1))) = 0 := max_eq_left (by rw [show 1 / (Real.exp ε + 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + 1)) = (1 - Real.exp ε ^ 2) / (Real.exp ε + 1) by ring]; exact div_nonpos_of_nonpos_of_nonneg (by nlinarith) (le_of_lt hep_pos)) rw [h1, h2]; norm_num · have h1 : max 0 (Real.exp ε / (Real.exp ε + 1) - Real.exp ε * (Real.exp ε / (Real.exp ε + 1))) = 0 := max_eq_left (by have := mul_le_mul_of_nonneg_right he1 (by positivity : 0 ≤ Real.exp ε / (Real.exp ε + 1)); linarith) have h2 : max 0 (1 / (Real.exp ε + 1) - Real.exp ε * (1 / (Real.exp ε + 1))) = 0 := max_eq_left (by have := mul_le_mul_of_nonneg_right he1 (by positivity : 0 ≤ 1 / (Real.exp ε + 1)); linarith) rw [h1, h2]; norm_num exact ⟨hdir x₁ x₂, hdir x₂ x₁⟩ refine ⟨W, hW, ?_⟩ dsimp only [chi2Div, pushforward, W] rw [Fintype.sum_bool, Fintype.sum_bool, Fintype.sum_bool, Fintype.sum_bool, Fintype.sum_bool, Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true, warnerP, warnerQ] field_simp [ne_of_gt hep_pos]; ring /-! ### Exact 1-User & `n`-User Private Hypothesis Testing Minimax Risk -/ /-- Exact Bayes 0–1 hypothesis testing risk of a decision rule `φ : Ω → [0, 1]` between `P` and `Q`: `testRisk P Q φ = (1/2) * (∑ z, P z * (1 - φ z) + ∑ z, Q z * φ z)`. -/ noncomputable def testRisk {Ω : Type*} [Fintype Ω] (P Q φ : Ω → ℝ) : ℝ := (1 / 2 : ℝ) * (∑ z : Ω, P z * (1 - φ z) + ∑ z : Ω, Q z * φ z) /-- **Le Cam's Exact Binary Hypothesis Testing Identity**: For every randomized test `φ : Ω → [0, 1]`, `testRisk P Q φ ≥ (1 / 2) * (1 - TV(P, Q))`, and equality is attained by the likelihood-ratio test `φ*(z) = 1_{P z ≥ Q z}`! -/ theorem leCam_testRisk_exact {Ω : Type*} [Fintype Ω] [DecidableEq Ω] {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) : (∀ φ : Ω → ℝ, (∀ z, 0 ≤ φ z ∧ φ z ≤ 1) → (1 / 2 : ℝ) * (1 - tvDist P Q) ≤ testRisk P Q φ) ∧ (∃ φ : Ω → ℝ, (∀ z, 0 ≤ φ z ∧ φ z ≤ 1) ∧ testRisk P Q φ = (1 / 2 : ℝ) * (1 - tvDist P Q)) := by have hrew : ∀ φ : Ω → ℝ, testRisk P Q φ = (1 / 2 : ℝ) * (1 - ∑ z : Ω, φ z * (P z - Q z)) := by intro φ dsimp only [testRisk] congr 1 have h1 : ∑ z : Ω, P z * (1 - φ z) + ∑ z : Ω, Q z * φ z = (∑ z : Ω, P z) - ∑ z : Ω, φ z * (P z - Q z) := by rw [← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun z _ => by ring rw [h1, hP.2] constructor · intro φ hφ rw [hrew φ, ← hockeyStick_one_eq_tvDist hP hQ] have hsup := (hockeyStick_eq_sup_event 1 P Q).1 φ hφ simp only [one_mul] at hsup linarith · classical let φ : Ω → ℝ := fun z => if Q z < P z then 1 else 0 refine ⟨φ, fun z => by dsimp only [φ]; split_ifs <;> norm_num, ?_⟩ rw [hrew φ, ← hockeyStick_one_eq_tvDist hP hQ] congr 1; congr 1 dsimp only [hockeyStick, φ] refine Finset.sum_congr rfl fun z _ => ?_ rw [one_mul] split_ifs with hz · rw [one_mul, max_eq_right (by linarith)] · rw [zero_mul, max_eq_left (by linarith)] /-- Exact Bhattacharyya–TV inequality `TV(P, Q) ≤ √(1 - BC(P, Q)²)` for all probability distributions `P, Q`. -/ theorem tvDist_le_sqrt_one_sub_bhattCoeff_sq {Ω : Type*} [Fintype Ω] {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) : tvDist P Q ≤ Real.sqrt (1 - bhattCoeff P Q ^ 2) := by have hcs : (∑ z : Ω, |Real.sqrt (P z) - Real.sqrt (Q z)| * (Real.sqrt (P z) + Real.sqrt (Q z))) ^ 2 ≤ (∑ z : Ω, (Real.sqrt (P z) - Real.sqrt (Q z)) ^ 2) * (∑ z : Ω, (Real.sqrt (P z) + Real.sqrt (Q z)) ^ 2) := by have h := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ (fun z : Ω => |Real.sqrt (P z) - Real.sqrt (Q z)|) (fun z : Ω => Real.sqrt (P z) + Real.sqrt (Q z)) simpa only [sq_abs] using h have hlhs : ∑ z : Ω, |Real.sqrt (P z) - Real.sqrt (Q z)| * (Real.sqrt (P z) + Real.sqrt (Q z)) = 2 * tvDist P Q := by dsimp only [tvDist] rw [show 2 * ((1 / 2 : ℝ) * ∑ z : Ω, |P z - Q z|) = ∑ z : Ω, |P z - Q z| by ring] refine Finset.sum_congr rfl fun z _ => ?_ have hnn : 0 ≤ Real.sqrt (P z) + Real.sqrt (Q z) := add_nonneg (Real.sqrt_nonneg _) (Real.sqrt_nonneg _) rw [← abs_of_nonneg hnn, ← abs_mul, show (Real.sqrt (P z) - Real.sqrt (Q z)) * (Real.sqrt (P z) + Real.sqrt (Q z)) = Real.sqrt (P z) ^ 2 - Real.sqrt (Q z) ^ 2 by ring, Real.sq_sqrt (hP.1 z), Real.sq_sqrt (hQ.1 z)] have h1 : ∑ z : Ω, (Real.sqrt (P z) - Real.sqrt (Q z)) ^ 2 = 2 * (1 - bhattCoeff P Q) := by dsimp only [bhattCoeff] have hpt : ∀ z : Ω, (Real.sqrt (P z) - Real.sqrt (Q z)) ^ 2 = P z + Q z - 2 * Real.sqrt (P z * Q z) := fun z => by have : Real.sqrt (P z) * Real.sqrt (Q z) = Real.sqrt (P z * Q z) := (Real.sqrt_mul (hP.1 z) (Q z)).symm calc (Real.sqrt (P z) - Real.sqrt (Q z)) ^ 2 = Real.sqrt (P z) ^ 2 + Real.sqrt (Q z) ^ 2 - 2 * (Real.sqrt (P z) * Real.sqrt (Q z)) := by ring _ = P z + Q z - 2 * Real.sqrt (P z * Q z) := by rw [Real.sq_sqrt (hP.1 z), Real.sq_sqrt (hQ.1 z), this] simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, hP.2, hQ.2]; ring have h2 : ∑ z : Ω, (Real.sqrt (P z) + Real.sqrt (Q z)) ^ 2 = 2 * (1 + bhattCoeff P Q) := by dsimp only [bhattCoeff] have hpt : ∀ z : Ω, (Real.sqrt (P z) + Real.sqrt (Q z)) ^ 2 = P z + Q z + 2 * Real.sqrt (P z * Q z) := fun z => by have : Real.sqrt (P z) * Real.sqrt (Q z) = Real.sqrt (P z * Q z) := (Real.sqrt_mul (hP.1 z) (Q z)).symm calc (Real.sqrt (P z) + Real.sqrt (Q z)) ^ 2 = Real.sqrt (P z) ^ 2 + Real.sqrt (Q z) ^ 2 + 2 * (Real.sqrt (P z) * Real.sqrt (Q z)) := by ring _ = P z + Q z + 2 * Real.sqrt (P z * Q z) := by rw [Real.sq_sqrt (hP.1 z), Real.sq_sqrt (hQ.1 z), this] simp_rw [hpt, Finset.sum_add_distrib, ← Finset.mul_sum, hP.2, hQ.2]; ring rw [hlhs, h1, h2] at hcs have hsq : tvDist P Q ^ 2 ≤ 1 - bhattCoeff P Q ^ 2 := by nlinarith exact Real.le_sqrt_of_sq_le hsq /-- **EXACT 1-USER `(ε, δ)`-LDP HYPOTHESIS TESTING MINIMAX RISK**: For EVERY `ε ≥ 0`, `δ ∈ [0, 1]`, and EVERY pair of input distributions `(P₀, P₁)`: 1. For EVERY `(ε, δ)`-LDP channel `W` and EVERY randomized test `φ`: `testRisk (W P₀) (W P₁) φ ≥ (1 / 2) * (1 - ((e^ε - 1 + 2δ) / (e^ε + 1)) * TV(P₀, P₁))`! 2. Equality is **ATTAINED** by thresholding `P₀` vs `P₁` into `{false, true}` followed by the canonical 4-outcome `(ε, δ)`-LDP channel! -/ theorem ldp_one_user_testing_minimax_exact {α : Type*} [Fintype α] [DecidableEq α] {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) {P₀ P₁ : α → ℝ} (hP₀ : IsProbDist P₀) (hP₁ : IsProbDist P₁) : (∀ {Ω : Type*} [Fintype Ω] [DecidableEq Ω] (W : α → Ω → ℝ) (φ : Ω → ℝ), IsLDPChannel ε δ W → (∀ z, 0 ≤ φ z ∧ φ z ≤ 1) → (1 / 2 : ℝ) * (1 - ((Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1)) * tvDist P₀ P₁) ≤ testRisk (pushforward W P₀) (pushforward W P₁) φ) ∧ (∃ (W : α → Fin 4 → ℝ) (φ : Fin 4 → ℝ), IsLDPChannel ε δ W ∧ (∀ z, 0 ≤ φ z ∧ φ z ≤ 1) ∧ testRisk (pushforward W P₀) (pushforward W P₁) φ = (1 / 2 : ℝ) * (1 - ((Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1)) * tvDist P₀ P₁)) := by set η : ℝ := (Real.exp ε - 1 + 2 * δ) / (Real.exp ε + 1) have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε constructor · intro Ω _ _ W φ hW hφ have hlc := (leCam_testRisk_exact (pushforward_isProbDist hW.1 hP₀) (pushforward_isProbDist hW.1 hP₁)).1 φ hφ have htv := (ldp_tv_contraction_exact hε hδ0 hδ1).1 W P₀ P₁ hW hP₀ hP₁ linarith · classical let W : α → Fin 4 → ℝ := fun x => if P₁ x < P₀ x then canonP ε δ else canonQ ε δ have hW : IsLDPChannel ε δ W := by refine ⟨fun x => by dsimp only [W]; split_ifs <;> [exact canonP_isProbDist hδ0 hδ1; exact canonQ_isProbDist hδ0 hδ1], fun x₁ x₂ => ?_⟩ dsimp only [W] split_ifs · exact ⟨by rw [hockeyStick_self he1 (canonP_isProbDist hδ0 hδ1)]; exact hδ0, by rw [hockeyStick_self he1 (canonP_isProbDist hδ0 hδ1)]; exact hδ0⟩ · exact canonPair_isEpsDeltaClose hε hδ0 hδ1 · exact ⟨(canonPair_isEpsDeltaClose hε hδ0 hδ1).2, (canonPair_isEpsDeltaClose hε hδ0 hδ1).1⟩ · exact ⟨by rw [hockeyStick_self he1 (canonQ_isProbDist hδ0 hδ1)]; exact hδ0, by rw [hockeyStick_self he1 (canonQ_isProbDist hδ0 hδ1)]; exact hδ0⟩ -- Compute pushforward W P₀ and W P₁ explicitly! let S := Finset.univ.filter fun x : α => P₁ x < P₀ x set a0 : ℝ := ∑ x ∈ S, P₀ x set a1 : ℝ := ∑ x ∈ S, P₁ x have ha_diff : a0 - a1 = tvDist P₀ P₁ := by rw [← hockeyStick_one_eq_tvDist hP₀ hP₁] dsimp only [a0, a1, S, hockeyStick] rw [← Finset.sum_sub_distrib, Finset.sum_filter] refine Finset.sum_congr rfl fun x _ => ?_ rw [one_mul]; split_ifs with hx · exact (max_eq_right (by linarith)).symm · exact (max_eq_left (by linarith)).symm have hpush_eq : ∀ (U : α → ℝ), IsProbDist U → ∀ z : Fin 4, pushforward W U z = (∑ x ∈ S, U x) * canonP ε δ z + (1 - ∑ x ∈ S, U x) * canonQ ε δ z := by intro U hU z dsimp only [pushforward, W] simp_rw [apply_ite (fun f : Fin 4 → ℝ => f z)] rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun x : α => P₁ x < P₀ x)] have h1 : ∑ x ∈ Finset.univ.filter (fun x : α => P₁ x < P₀ x), U x * (if P₁ x < P₀ x then canonP ε δ z else canonQ ε δ z) = (∑ x ∈ S, U x) * canonP ε δ z := by rw [Finset.sum_mul] refine Finset.sum_congr rfl fun x hx => ?_ rw [if_pos (Finset.mem_filter.mp hx).2] have h2 : ∑ x ∈ Finset.univ.filter (fun x : α => ¬ P₁ x < P₀ x), U x * (if P₁ x < P₀ x then canonP ε δ z else canonQ ε δ z) = (1 - ∑ x ∈ S, U x) * canonQ ε δ z := by have hcomp : ∑ x ∈ Finset.univ.filter (fun x : α => ¬ P₁ x < P₀ x), U x = 1 - ∑ x ∈ S, U x := by have := Finset.sum_filter_add_sum_filter_not Finset.univ (fun x : α => P₁ x < P₀ x) U rw [hU.2] at this; linarith rw [← hcomp, Finset.sum_mul] refine Finset.sum_congr rfl fun x hx => ?_ rw [if_neg (Finset.mem_filter.mp hx).2] rw [h1, h2] have htv_eq : tvDist (pushforward W P₀) (pushforward W P₁) = η * tvDist P₀ P₁ := by dsimp only [tvDist] have hpt : ∀ z : Fin 4, |pushforward W P₀ z - pushforward W P₁ z| = tvDist P₀ P₁ * |canonP ε δ z - canonQ ε δ z| := by intro z rw [hpush_eq P₀ hP₀ z, hpush_eq P₁ hP₁ z] have hlin : a0 * canonP ε δ z + (1 - a0) * canonQ ε δ z - (a1 * canonP ε δ z + (1 - a1) * canonQ ε δ z) = (a0 - a1) * (canonP ε δ z - canonQ ε δ z) := by ring change |a0 * canonP ε δ z + (1 - a0) * canonQ ε δ z - (a1 * canonP ε δ z + (1 - a1) * canonQ ε δ z)| = _ rw [hlin, ha_diff, abs_mul, abs_of_nonneg (tvDist_nonneg P₀ P₁)] simp_rw [hpt, ← Finset.mul_sum] calc (1 / 2 : ℝ) * (tvDist P₀ P₁ * ∑ z : Fin 4, |canonP ε δ z - canonQ ε δ z|) = tvDist (canonP ε δ) (canonQ ε δ) * tvDist P₀ P₁ := by dsimp only [tvDist]; ring _ = η * tvDist P₀ P₁ := by rw [canonPair_tvDist_exact hε hδ0 hδ1] obtain ⟨φ, hφ_mem, hφ_eq⟩ := (leCam_testRisk_exact (pushforward_isProbDist hW.1 hP₀) (pushforward_isProbDist hW.1 hP₁)).2 exact ⟨W, φ, hW, hφ_mem, hφ_eq.trans (by rw [htv_eq])⟩ /-- **EXACT `n`-USER ADAPTIVE `(ε, δ)`-DP HYPOTHESIS TESTING LOWER BOUND**: For EVERY `n ≥ 1`, EVERY `ε ≥ 0`, `δ ∈ [0, 1]`, EVERY `n`-step adaptive `(ε, δ)`-DP mechanism pair `(M, N)`, and EVERY randomized test `φ` on the `n`-user transcript: `testRisk M N φ ≥ (1 / 2) * (1 - √(1 - (2 (1 - δ) e^{ε/2} / (e^ε + 1))^(2 n)))`! -/ theorem ldp_n_user_testing_lower_bound {Ω : Type*} [Fintype Ω] [DecidableEq Ω] {ε δ : ℝ} (hε : 0 ≤ ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) {n : ℕ} (M N : AdaptiveMech Ω n) (hdp : IsAdaptiveEpsDeltaDP ε δ M N) (φ : (Fin n → Ω) → ℝ) (hφ : ∀ y, 0 ≤ φ y ∧ φ y ≤ 1) : (1 / 2 : ℝ) * (1 - Real.sqrt (1 - (2 * (1 - δ) * Real.exp (ε / 2) / (Real.exp ε + 1)) ^ (2 * n))) ≤ testRisk (adaptiveTranscriptDist M) (adaptiveTranscriptDist N) φ := by have hdom := blackwellDom_kFold_adaptive_comp hε hδ0 hδ1 M N hdp have hPstar := prodDistN_isProbDist n (canonP_isProbDist (ε := ε) hδ0 hδ1) have hQstar := prodDistN_isProbDist n (canonQ_isProbDist (ε := ε) hδ0 hδ1) rcases hdom with ⟨K, hK, hKM, hKN⟩ have hM_prob : IsProbDist (adaptiveTranscriptDist M) := hKM ▸ pushforward_isProbDist hK hPstar have hN_prob : IsProbDist (adaptiveTranscriptDist N) := hKN ▸ pushforward_isProbDist hK hQstar have hlc := (leCam_testRisk_exact hM_prob hN_prob).1 φ hφ have htv_le : tvDist (adaptiveTranscriptDist M) (adaptiveTranscriptDist N) ≤ tvDist (prodDistN n (canonP ε δ)) (prodDistN n (canonQ ε δ)) := blackwellDom_tvDist_le hPstar hQstar ⟨K, hK, hKM, hKN⟩ have htv_bc := tvDist_le_sqrt_one_sub_bhattCoeff_sq hPstar hQstar rw [prodDistN_bhattCoeff n (canonP_isProbDist hδ0 hδ1).1 (canonQ_isProbDist hδ0 hδ1).1, canonPair_bhattCoeff_exact hδ0 hδ1, ← pow_mul, mul_comm n 2] at htv_bc linarith /-- **EXACT NON-ASYMPTOTIC `n`-USER `ε`-LDP SAMPLE COMPLEXITY LOWER BOUND**: To distinguish two hypotheses adaptively under pure `ε`-DP (`ε > 0`) with Bayes testing error `≤ α` (`0 < α < 1 / 2`), the number of users `n` MUST satisfy: `Real.log (1 / (4 * α * (1 - α))) / (2 * Real.log ((Real.exp (ε / 2) + Real.exp (-(ε / 2))) / 2)) ≤ n`! -/ theorem pureLDP_n_user_sample_complexity_lower {Ω : Type*} [Fintype Ω] [DecidableEq Ω] {ε α : ℝ} (hε : 0 < ε) (hα0 : 0 < α) (hα1 : α < 1 / 2) {n : ℕ} (M N : AdaptiveMech Ω n) (hdp : IsAdaptiveEpsDeltaDP ε 0 M N) (φ : (Fin n → Ω) → ℝ) (hφ : ∀ y, 0 ≤ φ y ∧ φ y ≤ 1) (herr : testRisk (adaptiveTranscriptDist M) (adaptiveTranscriptDist N) φ ≤ α) : Real.log (1 / (4 * α * (1 - α))) / (2 * Real.log ((Real.exp (ε / 2) + Real.exp (-(ε / 2))) / 2)) ≤ (n : ℝ) := by have hlb := ldp_n_user_testing_lower_bound (le_of_lt hε) le_rfl zero_le_one M N hdp φ hφ set c : ℝ := (Real.exp (ε / 2) + Real.exp (-(ε / 2))) / 2 have he2_pos : 0 < Real.exp (ε / 2) := Real.exp_pos (ε / 2) have he2_gt1 : 1 < Real.exp (ε / 2) := Real.one_lt_exp_iff.mpr (by linarith) have hc_gt1 : 1 < c := by dsimp only [c] rw [Real.exp_neg] have hsq : 0 < (Real.exp (ε / 2) - 1) ^ 2 := sq_pos_of_pos (by linarith) have hid : (Real.exp (ε / 2) + (Real.exp (ε / 2))⁻¹) / 2 - 1 = (Real.exp (ε / 2) - 1) ^ 2 / (2 * Real.exp (ε / 2)) := by field_simp [ne_of_gt he2_pos]; ring linarith [div_pos hsq (by linarith : 0 < 2 * Real.exp (ε / 2))] have hbc_eq : 2 * (1 - 0) * Real.exp (ε / 2) / (Real.exp ε + 1) = c⁻¹ := by dsimp only [c] have he_sq : Real.exp ε = Real.exp (ε / 2) * Real.exp (ε / 2) := by rw [← Real.exp_add]; congr 1; ring rw [he_sq, Real.exp_neg] field_simp [ne_of_gt he2_pos]; ring rw [hbc_eq] at hlb have hsqrt_ge : 1 - 2 * α ≤ Real.sqrt (1 - (c⁻¹) ^ (2 * n)) := by linarith have hsq_ge : (1 - 2 * α) ^ 2 ≤ 1 - (c⁻¹) ^ (2 * n) := by have hnn : 0 ≤ 1 - 2 * α := by linarith have h1 := pow_le_pow_left₀ hnn hsqrt_ge 2 have hnonneg : 0 ≤ 1 - (c⁻¹) ^ (2 * n) := by have hcinv_le1 : c⁻¹ ≤ 1 := inv_le_one_of_one_le₀ (le_of_lt hc_gt1) have : (c⁻¹) ^ (2 * n) ≤ 1 := pow_le_one₀ (by positivity) hcinv_le1 linarith rwa [Real.sq_sqrt hnonneg] at h1 have h4α : 4 * α * (1 - α) = 1 - (1 - 2 * α) ^ 2 := by ring have h4α_pos : 0 < 4 * α * (1 - α) := by nlinarith have hpow_le : (c⁻¹) ^ (2 * n) ≤ 4 * α * (1 - α) := by linarith have hinv_ge : 1 / (4 * α * (1 - α)) ≤ c ^ (2 * n) := by rw [inv_pow] at hpow_le rw [div_le_iff₀ h4α_pos] have hc_pow : 0 < c ^ (2 * n) := pow_pos (by linarith) (2 * n) have := mul_le_mul_of_nonneg_left hpow_le (le_of_lt hc_pow) rw [mul_inv_cancel₀ (ne_of_gt hc_pow)] at this linarith have hlog_le : Real.log (1 / (4 * α * (1 - α))) ≤ Real.log (c ^ (2 * n)) := Real.log_le_log (by positivity) hinv_ge rw [Real.log_pow, Nat.cast_mul, Nat.cast_ofNat] at hlog_le have hlogc_pos : 0 < Real.log c := Real.log_pos hc_gt1 rw [div_le_iff₀ (by positivity : 0 < 2 * Real.log c)] linarith /-! ============================================================================ PART 6: EXACT LOCAL-DP DISCRETE DISTRIBUTION ESTIMATION: s-SUBSET SELECTION, k-RR, RAPPOR & SHARP PHASE TRANSITIONS ============================================================================ -/ /-- The finite type of size-`s` subsets of `Fin k`. -/ abbrev SubsetCard (k s : ℕ) := {S : Finset (Fin k) // S.card = s} /-- Helper: count of size-`s` subsets of `Fin k` containing a fixed element `x`. -/ private lemma card_subsets_mem {k s : ℕ} (hs1 : 1 ≤ s) (x : Fin k) : (Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1).card = Nat.choose (k - 1) (s - 1) := by have hbij : (Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1).card = (Finset.powersetCard (s - 1) ((Finset.univ : Finset (Fin k)).erase x)).card := by refine Finset.card_bij (fun S _ => S.1.erase x) ?_ ?_ ?_ · intro S hS have hx : x ∈ S.1 := (Finset.mem_filter.mp hS).2 refine Finset.mem_powersetCard.mpr ⟨Finset.erase_subset_erase x (Finset.subset_univ S.1), ?_⟩ rw [Finset.card_erase_of_mem hx, S.2] · intro S₁ hS₁ S₂ hS₂ heq have hx₁ : x ∈ S₁.1 := (Finset.mem_filter.mp hS₁).2 have hx₂ : x ∈ S₂.1 := (Finset.mem_filter.mp hS₂).2 apply Subtype.ext rw [← Finset.insert_erase hx₁, ← Finset.insert_erase hx₂, heq] · intro T hT have hT' := Finset.mem_powersetCard.mp hT have hxT : x ∉ T := fun h => (Finset.notMem_erase x Finset.univ) (hT'.1 h) have hcard : (insert x T).card = s := by rw [Finset.card_insert_of_notMem hxT, hT'.2]; omega refine ⟨⟨insert x T, hcard⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, Finset.mem_insert_self x T⟩, ?_⟩ exact Finset.erase_insert hxT rw [hbij, Finset.card_powersetCard, Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin] /-- Helper: count of size-`s` subsets of `Fin k` NOT containing `x`. -/ private lemma card_subsets_not_mem {k s : ℕ} (x : Fin k) : (Finset.univ.filter fun S : SubsetCard k s => x ∉ S.1).card = Nat.choose (k - 1) s := by have hbij : (Finset.univ.filter fun S : SubsetCard k s => x ∉ S.1).card = (Finset.powersetCard s ((Finset.univ : Finset (Fin k)).erase x)).card := by refine Finset.card_bij (fun S _ => S.1) ?_ ?_ ?_ · intro S hS have hx : x ∉ S.1 := (Finset.mem_filter.mp hS).2 refine Finset.mem_powersetCard.mpr ⟨fun y hy => Finset.mem_erase.mpr ⟨fun h => hx (h ▸ hy), Finset.mem_univ y⟩, S.2⟩ · intro S₁ _ S₂ _ heq; exact Subtype.ext heq · intro T hT have hT' := Finset.mem_powersetCard.mp hT have hxT : x ∉ T := fun h => (Finset.notMem_erase x Finset.univ) (hT'.1 h) exact ⟨⟨T, hT'.2⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hxT⟩, rfl⟩ rw [hbij, Finset.card_powersetCard, Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin] /-- Helper: count of size-`s` subsets of `Fin k` containing BOTH distinct elements `x ≠ y`. -/ private lemma card_subsets_mem_both {k s : ℕ} (hs2 : 2 ≤ s) {x y : Fin k} (hxy : x ≠ y) : (Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card = Nat.choose (k - 2) (s - 2) := by have hbij : (Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card = (Finset.powersetCard (s - 2) (((Finset.univ : Finset (Fin k)).erase x).erase y)).card := by refine Finset.card_bij (fun S _ => (S.1.erase x).erase y) ?_ ?_ ?_ · intro S hS have ⟨hx, hy⟩ := (Finset.mem_filter.mp hS).2 have hy' : y ∈ S.1.erase x := Finset.mem_erase.mpr ⟨hxy.symm, hy⟩ refine Finset.mem_powersetCard.mpr ⟨Finset.erase_subset_erase y (Finset.erase_subset_erase x (Finset.subset_univ S.1)), ?_⟩ rw [Finset.card_erase_of_mem hy', Finset.card_erase_of_mem hx, S.2]; omega · intro S₁ hS₁ S₂ hS₂ heq have ⟨hx₁, hy₁⟩ := (Finset.mem_filter.mp hS₁).2 have ⟨hx₂, hy₂⟩ := (Finset.mem_filter.mp hS₂).2 have hy₁' : y ∈ S₁.1.erase x := Finset.mem_erase.mpr ⟨hxy.symm, hy₁⟩ have hy₂' : y ∈ S₂.1.erase x := Finset.mem_erase.mpr ⟨hxy.symm, hy₂⟩ apply Subtype.ext have h1 : S₁.1.erase x = S₂.1.erase x := by rw [← Finset.insert_erase hy₁', ← Finset.insert_erase hy₂', heq] rw [← Finset.insert_erase hx₁, ← Finset.insert_erase hx₂, h1] · intro T hT have hT' := Finset.mem_powersetCard.mp hT have hyT : y ∉ T := fun h => (Finset.notMem_erase y _) (hT'.1 h) have hxT : x ∉ T := fun h => (Finset.notMem_erase x _) (Finset.mem_of_mem_erase (hT'.1 h)) have hx_ins : x ∉ insert y T := by simp [hxy, hxT] have hcard : (insert x (insert y T)).card = s := by rw [Finset.card_insert_of_notMem hx_ins, Finset.card_insert_of_notMem hyT, hT'.2]; omega refine ⟨⟨insert x (insert y T), hcard⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, Finset.mem_insert_self x _, Finset.mem_insert_of_mem (Finset.mem_insert_self y _)⟩, ?_⟩ rw [Finset.erase_insert hx_ins, Finset.erase_insert hyT] rw [hbij, Finset.card_powersetCard, Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨hxy.symm, Finset.mem_univ y⟩), Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin] rfl /-- Helper: count of size-`s` subsets of `Fin k` NOT containing `x` AND containing `y` (`x ≠ y`). -/ private lemma card_subsets_not_mem_and_mem {k s : ℕ} (hs1 : 1 ≤ s) {x y : Fin k} (hxy : x ≠ y) : (Finset.univ.filter fun S : SubsetCard k s => x ∉ S.1 ∧ y ∈ S.1).card = Nat.choose (k - 2) (s - 1) := by have hbij : (Finset.univ.filter fun S : SubsetCard k s => x ∉ S.1 ∧ y ∈ S.1).card = (Finset.powersetCard (s - 1) (((Finset.univ : Finset (Fin k)).erase x).erase y)).card := by refine Finset.card_bij (fun S _ => S.1.erase y) ?_ ?_ ?_ · intro S hS have ⟨hx, hy⟩ := (Finset.mem_filter.mp hS).2 refine Finset.mem_powersetCard.mpr ⟨fun z hz => ?_, by rw [Finset.card_erase_of_mem hy, S.2]⟩ have ⟨hzy, hzS⟩ := Finset.mem_erase.mp hz exact Finset.mem_erase.mpr ⟨hzy, Finset.mem_erase.mpr ⟨fun h => hx (h ▸ hzS), Finset.mem_univ z⟩⟩ · intro S₁ hS₁ S₂ hS₂ heq have ⟨_, hy₁⟩ := (Finset.mem_filter.mp hS₁).2 have ⟨_, hy₂⟩ := (Finset.mem_filter.mp hS₂).2 apply Subtype.ext rw [← Finset.insert_erase hy₁, ← Finset.insert_erase hy₂, heq] · intro T hT have hT' := Finset.mem_powersetCard.mp hT have hyT : y ∉ T := fun h => (Finset.notMem_erase y _) (hT'.1 h) have hxT : x ∉ T := fun h => (Finset.notMem_erase x _) (Finset.mem_of_mem_erase (hT'.1 h)) have hcard : (insert y T).card = s := by rw [Finset.card_insert_of_notMem hyT, hT'.2]; omega refine ⟨⟨insert y T, hcard⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simp [hxy, hxT], Finset.mem_insert_self y T⟩, ?_⟩ exact Finset.erase_insert hyT rw [hbij, Finset.card_powersetCard, Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨hxy.symm, Finset.mem_univ y⟩), Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin] rfl /-- **Ye–Barg `s`-Subset Selection Mechanism** on alphabet `Fin k` (`1 ≤ s ≤ k - 1`, `ε ≥ 0`): outputs a subset `S` of size `s` with probability proportional to `e^ε` if `x ∈ S` and `1` if `x ∉ S`. -/ noncomputable def subsetSelZ (k s : ℕ) (ε : ℝ) : ℝ := (Nat.choose (k - 1) (s - 1) : ℝ) * Real.exp ε + (Nat.choose (k - 1) s : ℝ) noncomputable def subsetSelMech (k s : ℕ) (ε : ℝ) : Fin k → SubsetCard k s → ℝ := fun x S => (if x ∈ S.1 then Real.exp ε else 1) / subsetSelZ k s ε lemma subsetSelZ_pos {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s ≤ k - 1) (ε : ℝ) : 0 < subsetSelZ k s ε := by dsimp only [subsetSelZ] have hc1 : 0 < Nat.choose (k - 1) (s - 1) := Nat.choose_pos (by omega) have hc2 : 0 < Nat.choose (k - 1) s := Nat.choose_pos (by omega) have h1 : (0 : ℝ) < (Nat.choose (k - 1) (s - 1) : ℝ) * Real.exp ε := mul_pos (Nat.cast_pos.mpr hc1) (Real.exp_pos ε) have h2 : (0 : ℝ) < (Nat.choose (k - 1) s : ℝ) := Nat.cast_pos.mpr hc2 linarith /-- **`s`-Subset Selection Is a Pure `ε`-LDP Channel** for all `1 ≤ s ≤ k - 1`, `ε ≥ 0`. -/ theorem subsetSelMech_isLDP {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s ≤ k - 1) {ε : ℝ} (hε : 0 ≤ ε) : IsLDPChannel ε 0 (subsetSelMech k s ε) := by have hZ : 0 < subsetSelZ k s ε := subsetSelZ_pos hs1 hsk ε have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε refine ⟨fun x => ⟨fun S => by dsimp only [subsetSelMech]; split_ifs <;> positivity, ?_⟩, fun x₁ x₂ => ?_⟩ · dsimp only [subsetSelMech] rw [← Finset.sum_div, Finset.sum_ite, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_one, card_subsets_mem hs1 x, card_subsets_not_mem x] exact div_self (ne_of_gt hZ) · have hdir : ∀ a b : Fin k, hockeyStick (Real.exp ε) (subsetSelMech k s ε a) (subsetSelMech k s ε b) ≤ 0 := by intro a b refine le_of_eq (Finset.sum_eq_zero fun S _ => max_eq_left ?_) dsimp only [subsetSelMech] split_ifs · rw [show Real.exp ε / subsetSelZ k s ε - Real.exp ε * (Real.exp ε / subsetSelZ k s ε) = Real.exp ε * (1 - Real.exp ε) / subsetSelZ k s ε by ring] exact div_nonpos_of_nonpos_of_nonneg (mul_nonpos_of_nonneg_of_nonpos (le_of_lt (Real.exp_pos _)) (by linarith)) (le_of_lt hZ) · rw [show Real.exp ε / subsetSelZ k s ε - Real.exp ε * (1 / subsetSelZ k s ε) = 0 by ring] · rw [show 1 / subsetSelZ k s ε - Real.exp ε * (Real.exp ε / subsetSelZ k s ε) = (1 - Real.exp ε ^ 2) / subsetSelZ k s ε by ring] exact div_nonpos_of_nonpos_of_nonneg (by nlinarith) (le_of_lt hZ) · rw [show 1 / subsetSelZ k s ε - Real.exp ε * (1 / subsetSelZ k s ε) = (1 - Real.exp ε) / subsetSelZ k s ε by ring] exact div_nonpos_of_nonpos_of_nonneg (by linarith) (le_of_lt hZ) exact ⟨hdir x₁ x₂, hdir x₂ x₁⟩ /-- Inclusion probabilities `q₁ = P(x ∈ S | x)` and `q₂ = P(y ∈ S | x)` (`y ≠ x`) for `s`-Subset Selection. -/ noncomputable def ssQ1 (k s : ℕ) (ε : ℝ) : ℝ := (s : ℝ) * Real.exp ε / ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ))) noncomputable def ssQ2 (k s : ℕ) (ε : ℝ) : ℝ := ((s : ℝ) * ((s : ℝ) - 1) * Real.exp ε + (s : ℝ) * ((k : ℝ) - (s : ℝ))) / (((k : ℝ) - 1) * ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ)))) private lemma nat_succ_mul_choose (n r : ℕ) : (n + 1) * Nat.choose n r = (r + 1) * Nat.choose (n + 1) (r + 1) := by induction n generalizing r with | zero => cases r with | zero => rfl | succ r => rw [Nat.choose_eq_zero_of_lt (by omega : 0 < r + 1), Nat.choose_eq_zero_of_lt (by omega : 1 < r + 2)] simp | succ n ih => cases r with | zero => simp [Nat.choose_one_right] | succ r => have h0 := Nat.choose_succ_succ n r have h1 := ih r have h2 := ih (r + 1) rw [Nat.choose_succ_succ (n + 1) (r + 1)] calc (n + 1 + 1) * Nat.choose (n + 1) (r + 1) = (n + 1) * Nat.choose (n + 1) (r + 1) + Nat.choose (n + 1) (r + 1) := by ring _ = (n + 1) * (Nat.choose n r + Nat.choose n (r + 1)) + Nat.choose (n + 1) (r + 1) := by rw [h0] _ = (n + 1) * Nat.choose n r + (n + 1) * Nat.choose n (r + 1) + Nat.choose (n + 1) (r + 1) := by ring _ = (r + 1) * Nat.choose (n + 1) (r + 1) + (r + 1 + 1) * Nat.choose (n + 1) (r + 1 + 1) + Nat.choose (n + 1) (r + 1) := by rw [h1, h2] _ = (r + 1 + 1) * (Nat.choose (n + 1) (r + 1) + Nat.choose (n + 1) (r + 1 + 1)) := by ring /-- Exact marginal inclusion probabilities of `s`-Subset Selection. -/ theorem subsetSel_marginals_exact {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s ≤ k - 1) (ε : ℝ) : (∀ x : Fin k, ∑ S : SubsetCard k s, (if x ∈ S.1 then subsetSelMech k s ε x S else 0) = ssQ1 k s ε) ∧ (∀ x y : Fin k, x ≠ y → ∑ S : SubsetCard k s, (if y ∈ S.1 then subsetSelMech k s ε x S else 0) = ssQ2 k s ε) := by have hZ : 0 < subsetSelZ k s ε := subsetSelZ_pos hs1 hsk ε have hk2 : 2 ≤ k := by omega have hs_pos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) have hD_pos : 0 < (s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ)) := by have hks_pos : (0 : ℝ) < (k : ℝ) - (s : ℝ) := by have : (s : ℝ) < (k : ℝ) := Nat.cast_lt.mpr (by omega) linarith linarith [mul_pos hs_pos (Real.exp_pos ε)] have hc_pos : (0 : ℝ) < (Nat.choose (k - 1) (s - 1) : ℝ) := Nat.cast_pos.mpr (Nat.choose_pos (by omega)) -- Exact binomial identity: s * C(k-1, s) = (k - s) * C(k-1, s-1)! have hbinom1 : (s : ℝ) * (Nat.choose (k - 1) s : ℝ) = ((k : ℝ) - (s : ℝ)) * (Nat.choose (k - 1) (s - 1) : ℝ) := by have hnat : s * Nat.choose (k - 1) s = (k - s) * Nat.choose (k - 1) (s - 1) := by have h1 := Nat.choose_succ_right_eq (k - 1) (s - 1) have hs_eq : s - 1 + 1 = s := by omega have hks_eq : k - 1 - (s - 1) = k - s := by omega rw [hs_eq, hks_eq] at h1 linarith have hcast : ((s * Nat.choose (k - 1) s : ℕ) : ℝ) = (((k - s) * Nat.choose (k - 1) (s - 1) : ℕ) : ℝ) := congrArg Nat.cast hnat push_cast [Nat.cast_sub (by omega : s ≤ k)] at hcast exact hcast have hZ_eq : (s : ℝ) * subsetSelZ k s ε = (Nat.choose (k - 1) (s - 1) : ℝ) * ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ))) := by dsimp only [subsetSelZ]; linarith constructor · intro x dsimp only [subsetSelMech, ssQ1] have hpt : ∀ S : SubsetCard k s, (if x ∈ S.1 then (if x ∈ S.1 then Real.exp ε else 1) / subsetSelZ k s ε else 0) = if x ∈ S.1 then Real.exp ε / subsetSelZ k s ε else 0 := by intro S; split_ifs <;> rfl simp_rw [hpt, Finset.sum_ite, Finset.sum_const_zero, add_zero, Finset.sum_const, nsmul_eq_mul, card_subsets_mem hs1 x] rw [mul_div_assoc', div_eq_div_iff (ne_of_gt hZ) (ne_of_gt hD_pos)] linear_combination Real.exp ε * hZ_eq.symm · intro x y hxy have hk1_pos : (0 : ℝ) < (k : ℝ) - 1 := by have : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk2 linarith -- Split over x ∈ S vs x ∉ S! have hsplit : ∑ S : SubsetCard k s, (if y ∈ S.1 then subsetSelMech k s ε x S else 0) = ((Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card * Real.exp ε + (Finset.univ.filter fun S : SubsetCard k s => x ∉ S.1 ∧ y ∈ S.1).card) / subsetSelZ k s ε := by rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun S : SubsetCard k s => x ∈ S.1)] have h1 : ∑ S ∈ Finset.univ.filter (fun S : SubsetCard k s => x ∈ S.1), (if y ∈ S.1 then subsetSelMech k s ε x S else 0) = (Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card * Real.exp ε / subsetSelZ k s ε := by have hrew : ∀ S ∈ Finset.univ.filter (fun S : SubsetCard k s => x ∈ S.1), (if y ∈ S.1 then subsetSelMech k s ε x S else 0) = if y ∈ S.1 then Real.exp ε / subsetSelZ k s ε else 0 := by intro S hS; dsimp only [subsetSelMech]; rw [if_pos (Finset.mem_filter.mp hS).2] rw [Finset.sum_congr rfl hrew, Finset.sum_ite, Finset.sum_const_zero, add_zero, Finset.sum_const, nsmul_eq_mul, Finset.filter_filter, mul_div_assoc'] have h2 : ∑ S ∈ Finset.univ.filter (fun S : SubsetCard k s => x ∉ S.1), (if y ∈ S.1 then subsetSelMech k s ε x S else 0) = (Finset.univ.filter fun S : SubsetCard k s => x ∉ S.1 ∧ y ∈ S.1).card / subsetSelZ k s ε := by have hrew : ∀ S ∈ Finset.univ.filter (fun S : SubsetCard k s => x ∉ S.1), (if y ∈ S.1 then subsetSelMech k s ε x S else 0) = if y ∈ S.1 then 1 / subsetSelZ k s ε else 0 := by intro S hS; dsimp only [subsetSelMech]; rw [if_neg (Finset.mem_filter.mp hS).2] rw [Finset.sum_congr rfl hrew, Finset.sum_ite, Finset.sum_const_zero, add_zero, Finset.sum_const, nsmul_eq_mul, Finset.filter_filter, mul_one_div] rw [h1, h2, add_div] rw [hsplit, card_subsets_not_mem_and_mem hs1 hxy] -- Exact binomial identities: -- (k - 1) * C(k-2, s-1) = (k - s) * C(k-1, s-1) have hbin_not : ((k : ℝ) - 1) * (Nat.choose (k - 2) (s - 1) : ℝ) = ((k : ℝ) - (s : ℝ)) * (Nat.choose (k - 1) (s - 1) : ℝ) := by have hnat : (k - 1) * Nat.choose (k - 2) (s - 1) = (k - s) * Nat.choose (k - 1) (s - 1) := by have h2 : (k - 1) * Nat.choose (k - 2) (s - 1) = (k - 1 - (s - 1)) * Nat.choose (k - 1) (s - 1) := by have hk_sub : k - 2 + 1 = k - 1 := by omega have hsym := Nat.choose_symm (by omega : s - 1 ≤ k - 2) have hsym2 := Nat.choose_symm (by omega : s - 1 ≤ k - 1) have hstep := nat_succ_mul_choose (k - 2) (k - 2 - (s - 1)) rw [hk_sub] at hstep have heq1 : k - 2 - (s - 1) + 1 = k - 1 - (s - 1) := by omega rw [heq1, hsym, hsym2] at hstep linarith have hks : k - 1 - (s - 1) = k - s := by omega rwa [hks] at h2 have hcast : (((k - 1) * Nat.choose (k - 2) (s - 1) : ℕ) : ℝ) = (((k - s) * Nat.choose (k - 1) (s - 1) : ℕ) : ℝ) := congrArg Nat.cast hnat push_cast [Nat.cast_sub (by omega : 1 ≤ k), Nat.cast_sub (by omega : s ≤ k)] at hcast exact hcast -- (k - 1) * card{x ∈ S ∧ y ∈ S} = (s - 1) * C(k - 1, s - 1)! have hbin_both : ((k : ℝ) - 1) * ((Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card : ℝ) = ((s : ℝ) - 1) * (Nat.choose (k - 1) (s - 1) : ℝ) := by by_cases hs2 : 2 ≤ s · rw [card_subsets_mem_both hs2 hxy] have hnat : (k - 1) * Nat.choose (k - 2) (s - 2) = (s - 1) * Nat.choose (k - 1) (s - 1) := by have hstep := nat_succ_mul_choose (k - 2) (s - 2) have hk_sub : k - 2 + 1 = k - 1 := by omega have hs_sub : s - 2 + 1 = s - 1 := by omega rw [hk_sub, hs_sub] at hstep linarith have hcast : (((k - 1) * Nat.choose (k - 2) (s - 2) : ℕ) : ℝ) = (((s - 1) * Nat.choose (k - 1) (s - 1) : ℕ) : ℝ) := congrArg Nat.cast hnat push_cast [Nat.cast_sub (by omega : 1 ≤ k), Nat.cast_sub hs1] at hcast exact hcast · have hs_eq1 : s = 1 := by omega have hemp : (Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1) = ∅ := by rw [Finset.filter_eq_empty_iff] intro S _ ⟨hx, hy⟩ have hpair : ({x, y} : Finset (Fin k)) ⊆ S.1 := by intro z hz; simp only [Finset.mem_insert, Finset.mem_singleton] at hz rcases hz with rfl | rfl <;> assumption have hcard := Finset.card_le_card hpair rw [Finset.card_pair hxy, S.2] at hcard; omega rw [hemp, Finset.card_empty, Nat.cast_zero, mul_zero, hs_eq1, Nat.cast_one, sub_self, zero_mul] dsimp only [ssQ2] rw [div_eq_div_iff (ne_of_gt hZ) (ne_of_gt (mul_pos hk1_pos hD_pos))] -- Multiply both sides by (s : ℝ) > 0 and cancel! have hmul : (s : ℝ) * ((((Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card : ℝ) * Real.exp ε + (Nat.choose (k - 2) (s - 1) : ℝ)) * (((k : ℝ) - 1) * ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ))))) = (s : ℝ) * (((s : ℝ) * ((s : ℝ) - 1) * Real.exp ε + (s : ℝ) * ((k : ℝ) - (s : ℝ))) * subsetSelZ k s ε) := by have hL : (((Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card : ℝ) * Real.exp ε + (Nat.choose (k - 2) (s - 1) : ℝ)) * ((k : ℝ) - 1) = (((s : ℝ) - 1) * Real.exp ε + ((k : ℝ) - (s : ℝ))) * (Nat.choose (k - 1) (s - 1) : ℝ) := by linear_combination Real.exp ε * hbin_both + hbin_not calc (s : ℝ) * ((((Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card : ℝ) * Real.exp ε + (Nat.choose (k - 2) (s - 1) : ℝ)) * (((k : ℝ) - 1) * ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ))))) = (s : ℝ) * (((((Finset.univ.filter fun S : SubsetCard k s => x ∈ S.1 ∧ y ∈ S.1).card : ℝ) * Real.exp ε + (Nat.choose (k - 2) (s - 1) : ℝ)) * ((k : ℝ) - 1)) * ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ)))) := by ring _ = (s : ℝ) * ((((s : ℝ) - 1) * Real.exp ε + ((k : ℝ) - (s : ℝ))) * ((Nat.choose (k - 1) (s - 1) : ℝ) * ((s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ))))) := by rw [hL]; ring _ = (s : ℝ) * ((((s : ℝ) - 1) * Real.exp ε + ((k : ℝ) - (s : ℝ))) * ((s : ℝ) * subsetSelZ k s ε)) := by rw [← hZ_eq] _ = (s : ℝ) * (((s : ℝ) * ((s : ℝ) - 1) * Real.exp ε + (s : ℝ) * ((k : ℝ) - (s : ℝ))) * subsetSelZ k s ε) := by ring exact mul_left_cancel₀ (ne_of_gt hs_pos) hmul /-- Exact affine debiasing estimator for `s`-Subset Selection: `p̂_i(S) = (1_{i ∈ S} - q₂) / (q₁ - q₂)`. -/ noncomputable def subsetSelEst (k s : ℕ) (ε : ℝ) (S : SubsetCard k s) (i : Fin k) : ℝ := ((if i ∈ S.1 then (1 : ℝ) else 0) - ssQ2 k s ε) / (ssQ1 k s ε - ssQ2 k s ε) /-- Exact per-sample `L₂²` MSE of an estimator `est : Ω → Fin k → ℝ` under mechanism `W` and input distribution `p : Fin k → ℝ`. -/ def perSampleMSE {Ω : Type*} [Fintype Ω] {k : ℕ} (W : Fin k → Ω → ℝ) (est : Ω → Fin k → ℝ) (p : Fin k → ℝ) : ℝ := ∑ x : Fin k, p x * ∑ z : Ω, W x z * ∑ i : Fin k, (est z i - p i) ^ 2 /-- **EXACT UNBIASEDNESS AND CLOSED-FORM `L₂²` MSE OF `s`-SUBSET SELECTION**: For EVERY `k ≥ 2`, `1 ≤ s ≤ k - 1`, `ε > 0`, and EVERY distribution `p ∈ Δ_k`: 1. `E[subsetSelEst(S)_i] = p_i` for every `i : Fin k` (unbiased), 2. `perSampleMSE = (1 - ∑ i, p_i²) + ((k - 1)² / (e^ε - 1)²) * (e^{2ε} / (k - s) + 1 / s) - (k - 1)`! -/ theorem subsetSel_mse_exact {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s ≤ k - 1) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : (∀ i : Fin k, ∑ x : Fin k, p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * subsetSelEst k s ε S i = p i) ∧ perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p = (1 - ∑ i : Fin k, p i ^ 2) + (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1) := by have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have hs_pos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) have hks_pos : (0 : ℝ) < (k : ℝ) - (s : ℝ) := by have : (s : ℝ) < (k : ℝ) := Nat.cast_lt.mpr (by omega); linarith have hk1_pos : (0 : ℝ) < (k : ℝ) - 1 := by have hk2r : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast (by omega : 2 ≤ k) linarith set D : ℝ := (s : ℝ) * Real.exp ε + ((k : ℝ) - (s : ℝ)) have hD_pos : 0 < D := by dsimp only [D]; nlinarith set q1 := ssQ1 k s ε set q2 := ssQ2 k s ε set dq := q1 - q2 have hdq_eq : dq = (s : ℝ) * ((k : ℝ) - (s : ℝ)) * (Real.exp ε - 1) / (((k : ℝ) - 1) * D) := by dsimp only [dq, q1, q2, ssQ1, ssQ2, D] field_simp [ne_of_gt hk1_pos, ne_of_gt hD_pos]; ring have hdq_pos : 0 < dq := by rw [hdq_eq]; positivity have hmarg := subsetSel_marginals_exact hs1 hsk ε have hW := (subsetSelMech_isLDP hs1 hsk (le_of_lt hε)).1 -- Marginal P(i ∈ S) under p equals q2 + dq * p i! have hPi : ∀ i : Fin k, ∑ x : Fin k, p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0) = q2 + dq * p i := by intro i have hinner : ∀ x : Fin k, ∑ S : SubsetCard k s, subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0) = if x = i then q1 else q2 := by intro x have hrew : ∀ S : SubsetCard k s, subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0) = if i ∈ S.1 then subsetSelMech k s ε x S else 0 := fun S => by split_ifs <;> ring simp_rw [hrew] by_cases hxi : x = i · subst hxi; rw [if_pos rfl]; exact hmarg.1 x · rw [if_neg hxi]; exact hmarg.2 x i hxi simp_rw [hinner] have hpt : ∀ x : Fin k, p x * (if x = i then q1 else q2) = q2 * p x + (if x = i then dq * p x else 0) := by intro x; split_ifs <;> [dsimp only [dq]; skip] <;> ring simp_rw [hpt, Finset.sum_add_distrib, ← Finset.mul_sum, hp.2, Finset.sum_ite_eq', if_pos (Finset.mem_univ i)] ring have hunb : ∀ i : Fin k, ∑ x : Fin k, p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * subsetSelEst k s ε S i = p i := by intro i have hrew : ∀ x : Fin k, ∑ S : SubsetCard k s, subsetSelMech k s ε x S * subsetSelEst k s ε S i = ((∑ S : SubsetCard k s, subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0)) - q2) / dq := by intro x have h1 : ∀ S : SubsetCard k s, subsetSelMech k s ε x S * subsetSelEst k s ε S i = (subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0) - q2 * subsetSelMech k s ε x S) / dq := by intro S; dsimp only [subsetSelEst, dq, q1, q2]; ring simp_rw [h1, ← Finset.sum_div, Finset.sum_sub_distrib, ← Finset.mul_sum, (hW x).2, mul_one] simp_rw [hrew, ← mul_div_assoc] rw [← Finset.sum_div] simp_rw [mul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_mul, hp.2, one_mul, hPi i] have : q2 + dq * p i - q2 = dq * p i := by ring rw [this, mul_div_cancel_left₀ _ (ne_of_gt hdq_pos)] refine ⟨hunb, ?_⟩ -- Compute perSampleMSE = (s - k*q2^2 - 2*q2*dq) / dq^2 - ∑ p_i^2! dsimp only [perSampleMSE] have hmse_by_i : ∑ x : Fin k, p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * ∑ i : Fin k, (subsetSelEst k s ε S i - p i) ^ 2 = ∑ i : Fin k, (((q2 + dq * p i) * (1 - (q2 + dq * p i))) / dq ^ 2) := by have hstep1 : ∀ x : Fin k, ∑ S : SubsetCard k s, subsetSelMech k s ε x S * ∑ i : Fin k, (subsetSelEst k s ε S i - p i) ^ 2 = ∑ i : Fin k, ∑ S : SubsetCard k s, subsetSelMech k s ε x S * (subsetSelEst k s ε S i - p i) ^ 2 := by intro x; simp_rw [Finset.mul_sum]; exact Finset.sum_comm simp_rw [hstep1, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun i _ => ?_ -- For fixed i: E[( (B_i - q2)/dq - p_i )^2] = (E[B_i] - (q2 + dq*p_i)^2) / dq^2 since B_i^2 = B_i! have hsq_id : ∀ S : SubsetCard k s, (subsetSelEst k s ε S i - p i) ^ 2 = ((1 - 2 * (q2 + dq * p i)) * (if i ∈ S.1 then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) / dq ^ 2 := by intro S dsimp only [subsetSelEst] have hdiff : ((if i ∈ S.1 then (1 : ℝ) else 0) - q2) / dq - p i = ((if i ∈ S.1 then (1 : ℝ) else 0) - (q2 + dq * p i)) / dq := by field_simp [ne_of_gt hdq_pos]; ring rw [hdiff, div_pow] congr 1 split_ifs <;> ring have hnum : ∑ x : Fin k, p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * ((1 - 2 * (q2 + dq * p i)) * (if i ∈ S.1 then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (q2 + dq * p i) * (1 - (q2 + dq * p i)) := by have h1 : ∀ x : Fin k, ∑ S : SubsetCard k s, subsetSelMech k s ε x S * ((1 - 2 * (q2 + dq * p i)) * (if i ∈ S.1 then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (1 - 2 * (q2 + dq * p i)) * (∑ S : SubsetCard k s, subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0)) + (q2 + dq * p i) ^ 2 := by intro x have hrew : ∀ S : SubsetCard k s, subsetSelMech k s ε x S * ((1 - 2 * (q2 + dq * p i)) * (if i ∈ S.1 then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (1 - 2 * (q2 + dq * p i)) * (subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0)) + (q2 + dq * p i) ^ 2 * subsetSelMech k s ε x S := fun S => by ring simp_rw [hrew, Finset.sum_add_distrib, ← Finset.mul_sum, (hW x).2, mul_one] have h1' : ∀ x : Fin k, p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * ((1 - 2 * (q2 + dq * p i)) * (if i ∈ S.1 then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (1 - 2 * (q2 + dq * p i)) * (p x * ∑ S : SubsetCard k s, subsetSelMech k s ε x S * (if i ∈ S.1 then (1 : ℝ) else 0)) + (q2 + dq * p i) ^ 2 * p x := fun x => by rw [h1 x]; ring simp_rw [h1', Finset.sum_add_distrib, ← Finset.mul_sum, hp.2, mul_one, hPi i] ring simp_rw [hsq_id, ← mul_div_assoc, ← Finset.sum_div] rw [← hnum] congr 1 refine Finset.sum_congr rfl fun x _ => (Finset.mul_sum _ _ _).symm rw [hmse_by_i, ← Finset.sum_div] have hsum_num : ∑ i : Fin k, (q2 + dq * p i) * (1 - (q2 + dq * p i)) = ((k : ℝ) * q2 * (1 - q2) + dq * (1 - 2 * q2)) - dq ^ 2 * ∑ i : Fin k, p i ^ 2 := by have hpt : ∀ i : Fin k, (q2 + dq * p i) * (1 - (q2 + dq * p i)) = q2 * (1 - q2) + dq * (1 - 2 * q2) * p i - dq ^ 2 * p i ^ 2 := fun i => by ring simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, ← Finset.mul_sum, hp.2, mul_one]; ring rw [hsum_num, sub_div, mul_div_cancel_left₀ _ (ne_of_gt (pow_pos hdq_pos 2))] -- Pure algebraic identity matching our exact closed form! have halg : ((k : ℝ) * q2 * (1 - q2) + dq * (1 - 2 * q2)) / dq ^ 2 = 1 + (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1) := by rw [hdq_eq] dsimp only [q2, ssQ2, D] have hem1 : Real.exp ε - 1 ≠ 0 := ne_of_gt (by linarith) field_simp [ne_of_gt hk1_pos, ne_of_gt hD_pos, ne_of_gt hs_pos, ne_of_gt hks_pos, hem1] ring linarith /-- **`k`-ary Randomized Response Mechanism (`k`-RR)** on `Fin k` (`k ≥ 2`, `ε ≥ 0`). -/ noncomputable def kRRMech (k : ℕ) (ε : ℝ) : Fin k → Fin k → ℝ := fun x y => (if x = y then Real.exp ε else 1) / (Real.exp ε + (k : ℝ) - 1) /-- Affine debiasing estimator for `k`-RR. -/ noncomputable def kRREst (k : ℕ) (ε : ℝ) (y i : Fin k) : ℝ := ((if i = y then (1 : ℝ) else 0) - 1 / (Real.exp ε + (k : ℝ) - 1)) / ((Real.exp ε - 1) / (Real.exp ε + (k : ℝ) - 1)) /-- **`k`-RR Is Pure `ε`-LDP, Unbiased, and Achieves Exact Closed-Form `L₂²` MSE**: `perSampleMSE = (1 - ∑ i, p_i²) + (k - 1) * (2 e^ε + k - 2) / (e^ε - 1)²` (identical to `s = 1` Subset Selection!). -/ theorem kRR_mse_exact {k : ℕ} (hk : 2 ≤ k) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : IsLDPChannel ε 0 (kRRMech k ε) ∧ (∀ i : Fin k, ∑ x : Fin k, p x * ∑ y : Fin k, kRRMech k ε x y * kRREst k ε y i = p i) ∧ perSampleMSE (kRRMech k ε) (kRREst k ε) p = (1 - ∑ i : Fin k, p i ^ 2) + ((k : ℝ) - 1) * (2 * Real.exp ε + (k : ℝ) - 2) / (Real.exp ε - 1) ^ 2 := by -- Transport directly from s = 1 Subset Selection via the canonical bijection Fin k ≃ SubsetCard k 1! let e1 : Fin k ≃ SubsetCard k 1 := { toFun := fun y => ⟨{y}, Finset.card_singleton y⟩ invFun := fun S => (Finset.card_eq_one.mp S.2).choose left_inv := fun y => by have hspec := (Finset.card_eq_one.mp (Finset.card_singleton y)).choose_spec exact Finset.singleton_injective hspec.symm right_inv := fun S => by apply Subtype.ext exact (Finset.card_eq_one.mp S.2).choose_spec.symm } have hZ1 : subsetSelZ k 1 ε = Real.exp ε + (k : ℝ) - 1 := by dsimp only [subsetSelZ] rw [Nat.sub_self, Nat.choose_zero_right, Nat.choose_one_right, Nat.cast_one, one_mul, Nat.cast_sub (by omega : 1 ≤ k), Nat.cast_one]; ring have hmech_eq : ∀ x y : Fin k, kRRMech k ε x y = subsetSelMech k 1 ε x (e1 y) := by intro x y; dsimp only [kRRMech, subsetSelMech, e1, Equiv.coe_fn_mk] simp only [Finset.mem_singleton, hZ1] have hq1_eq : ssQ1 k 1 ε = Real.exp ε / (Real.exp ε + (k : ℝ) - 1) := by dsimp only [ssQ1]; simp only [Nat.cast_one, one_mul]; ring have hq2_eq : ssQ2 k 1 ε = 1 / (Real.exp ε + (k : ℝ) - 1) := by dsimp only [ssQ2]; simp only [Nat.cast_one, sub_self, mul_zero, zero_mul, zero_add, one_mul] have hk1 : (k : ℝ) - 1 ≠ 0 := by have : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk linarith have hden : Real.exp ε + (k : ℝ) - 1 ≠ 0 := by have : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk linarith [Real.exp_pos ε] rw [← add_sub_assoc] field_simp [hk1, hden] have hest_eq : ∀ y i : Fin k, kRREst k ε y i = subsetSelEst k 1 ε (e1 y) i := by intro y i; dsimp only [kRREst, subsetSelEst, e1, Equiv.coe_fn_mk] simp only [Finset.mem_singleton, hq1_eq, hq2_eq] have hdiff : Real.exp ε / (Real.exp ε + (k : ℝ) - 1) - 1 / (Real.exp ε + (k : ℝ) - 1) = (Real.exp ε - 1) / (Real.exp ε + (k : ℝ) - 1) := by ring rw [hdiff] have hss_ldp := subsetSelMech_isLDP (k := k) (s := 1) le_rfl (by omega) (le_of_lt hε) have hss_mse := subsetSel_mse_exact (k := k) (s := 1) le_rfl (by omega) hε hp refine ⟨?_, ?_, ?_⟩ · refine ⟨fun x => ⟨fun y => (hmech_eq x y).symm ▸ (hss_ldp.1 x).1 (e1 y), ?_⟩, fun x₁ x₂ => ?_⟩ · simp_rw [hmech_eq]; rw [Equiv.sum_comp e1 (fun S => subsetSelMech k 1 ε x S)]; exact (hss_ldp.1 x).2 · constructor · dsimp only [hockeyStick]; simp_rw [hmech_eq] rw [Equiv.sum_comp e1 (fun S => max 0 (subsetSelMech k 1 ε x₁ S - Real.exp ε * subsetSelMech k 1 ε x₂ S))] exact (hss_ldp.2 x₁ x₂).1 · dsimp only [hockeyStick]; simp_rw [hmech_eq] rw [Equiv.sum_comp e1 (fun S => max 0 (subsetSelMech k 1 ε x₂ S - Real.exp ε * subsetSelMech k 1 ε x₁ S))] exact (hss_ldp.2 x₁ x₂).2 · intro i have h1 : ∀ x : Fin k, ∑ y : Fin k, kRRMech k ε x y * kRREst k ε y i = ∑ S : SubsetCard k 1, subsetSelMech k 1 ε x S * subsetSelEst k 1 ε S i := by intro x; simp_rw [hmech_eq, hest_eq] exact Equiv.sum_comp e1 (fun S => subsetSelMech k 1 ε x S * subsetSelEst k 1 ε S i) simp_rw [h1]; exact hss_mse.1 i · dsimp only [perSampleMSE] have h1 : ∀ x : Fin k, ∑ y : Fin k, kRRMech k ε x y * ∑ i : Fin k, (kRREst k ε y i - p i) ^ 2 = ∑ S : SubsetCard k 1, subsetSelMech k 1 ε x S * ∑ i : Fin k, (subsetSelEst k 1 ε S i - p i) ^ 2 := by intro x; simp_rw [hmech_eq, hest_eq] exact Equiv.sum_comp e1 (fun S => subsetSelMech k 1 ε x S * ∑ i : Fin k, (subsetSelEst k 1 ε S i - p i) ^ 2) simp_rw [h1] have hss2 := hss_mse.2 dsimp only [perSampleMSE] at hss2 rw [hss2] have hk1 : (k : ℝ) - 1 ≠ 0 := by have : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk linarith have hem1 : Real.exp ε - 1 ≠ 0 := ne_of_gt (by linarith [Real.one_lt_exp_iff.mpr hε]) simp only [Nat.cast_one] field_simp [hk1, hem1]; ring /-- **Unary RAPPOR Mechanism** on `Fin k → (Fin k → Bool)`: independently sets bit `i` to `true` with prob `q₁ = e^{ε/2} / (e^{ε/2} + 1)` if `i = x` and `q₂ = 1 / (e^{ε/2} + 1)` if `i ≠ x`. -/ noncomputable def rapporBitProb (ε : ℝ) (matchBit b : Bool) : ℝ := if b = matchBit then Real.exp (ε / 2) / (Real.exp (ε / 2) + 1) else 1 / (Real.exp (ε / 2) + 1) noncomputable def rapporMech (k : ℕ) (ε : ℝ) : Fin k → (Fin k → Bool) → ℝ := fun x v => ∏ j : Fin k, rapporBitProb ε (decide (j = x)) (v j) /-- Affine debiasing estimator for Unary RAPPOR. -/ noncomputable def rapporEst (k : ℕ) (ε : ℝ) (v : Fin k → Bool) (i : Fin k) : ℝ := ((if v i then (1 : ℝ) else 0) - 1 / (Real.exp (ε / 2) + 1)) / ((Real.exp (ε / 2) - 1) / (Real.exp (ε / 2) + 1)) /-- **UNARY RAPPOR IS PURE `ε`-LDP, UNBIASED, AND ACHIEVES EXACT CLOSED-FORM `L₂²` MSE**: `perSampleMSE = (1 - ∑ i, p_i²) + k * e^{ε/2} / (e^{ε/2} - 1)²`! -/ theorem rappor_mse_exact {k : ℕ} {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : IsLDPChannel ε 0 (rapporMech k ε) ∧ (∀ i : Fin k, ∑ x : Fin k, p x * ∑ v : Fin k → Bool, rapporMech k ε x v * rapporEst k ε v i = p i) ∧ perSampleMSE (rapporMech k ε) (rapporEst k ε) p = (1 - ∑ i : Fin k, p i ^ 2) + (k : ℝ) * Real.exp (ε / 2) / (Real.exp (ε / 2) - 1) ^ 2 := by set u : ℝ := Real.exp (ε / 2) have hu1 : 1 < u := Real.one_lt_exp_iff.mpr (by linarith) have hu_pos : 0 < u := by linarith have hup_pos : 0 < u + 1 := by linarith have hum1_pos : 0 < u - 1 := by linarith have hu_sq : u * u = Real.exp ε := by dsimp only [u]; rw [← Real.exp_add]; congr 1; ring have hbit_nn : ∀ m b, 0 ≤ rapporBitProb ε m b := fun m b => by dsimp only [rapporBitProb]; split_ifs <;> positivity have hbit_sum : ∀ m, ∑ b : Bool, rapporBitProb ε m b = 1 := fun m => by rw [Fintype.sum_bool] cases m · dsimp only [rapporBitProb]; simp only [↓reduceIte, Bool.true_eq_false] field_simp [ne_of_gt hup_pos]; ring · dsimp only [rapporBitProb]; simp only [↓reduceIte, Bool.false_eq_true] field_simp [ne_of_gt hup_pos] have hbit_ratio : ∀ m₁ m₂ b, rapporBitProb ε m₁ b ≤ u * rapporBitProb ε m₂ b := fun m₁ m₂ b => by have hu_def : Real.exp (ε / 2) = u := rfl cases m₁ <;> cases m₂ <;> cases b <;> dsimp only [rapporBitProb] <;> simp only [↓reduceIte, Bool.false_eq_true, Bool.true_eq_false, hu_def] <;> first | exact le_mul_of_one_le_left (by positivity) (le_of_lt hu1) | rw [show u * (1 / (u + 1)) = u / (u + 1) by ring] | (rw [div_le_iff₀ hup_pos]; field_simp [ne_of_gt hup_pos]; nlinarith) -- Helper: expectation of a single coordinate function f (v i) under product distribution rapporMech! have hcoord_expect : ∀ (x i : Fin k) (f : Bool → ℝ), ∑ v : Fin k → Bool, rapporMech k ε x v * f (v i) = ∑ b : Bool, rapporBitProb ε (decide (i = x)) b * f b := by intro x i f have hprod_eq : ∀ v : Fin k → Bool, rapporMech k ε x v * f (v i) = ∏ j : Fin k, (if j = i then rapporBitProb ε (decide (j = x)) (v j) * f (v j) else rapporBitProb ε (decide (j = x)) (v j)) := by intro v dsimp only [rapporMech] rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ i), ← Finset.mul_prod_erase _ _ (Finset.mem_univ i), if_pos rfl, mul_right_comm] congr 1 refine Finset.prod_congr rfl fun j hj => (if_neg (Finset.ne_of_mem_erase hj)).symm simp_rw [hprod_eq] rw [(Fintype.prod_sum (fun j b => if j = i then rapporBitProb ε (decide (j = x)) b * f b else rapporBitProb ε (decide (j = x)) b)).symm, ← Finset.mul_prod_erase _ _ (Finset.mem_univ i)] simp only [↓reduceIte] have herase : ∏ j ∈ Finset.univ.erase i, ∑ b : Bool, (if j = i then rapporBitProb ε (decide (j = x)) b * f b else rapporBitProb ε (decide (j = x)) b) = 1 := by refine Finset.prod_eq_one fun j hj => ?_ have hne := Finset.ne_of_mem_erase hj simp_rw [if_neg hne] exact hbit_sum _ rw [herase, mul_one] -- 1) Pure ε-LDP! have hLDP : IsLDPChannel ε 0 (rapporMech k ε) := by refine ⟨fun x => ⟨fun v => Finset.prod_nonneg fun j _ => hbit_nn _ _, ?_⟩, fun x₁ x₂ => ?_⟩ · dsimp only [rapporMech] rw [(Fintype.prod_sum (fun j b => rapporBitProb ε (decide (j = x)) b)).symm] exact Finset.prod_eq_one fun j _ => hbit_sum _ · have hdir : ∀ a b : Fin k, hockeyStick (Real.exp ε) (rapporMech k ε a) (rapporMech k ε b) ≤ 0 := by intro a b refine le_of_eq (Finset.sum_eq_zero fun v _ => max_eq_left ?_) have hle : rapporMech k ε a v ≤ Real.exp ε * rapporMech k ε b v := by by_cases hab : a = b · subst hab; exact le_mul_of_one_le_left (Finset.prod_nonneg fun j _ => hbit_nn _ _) (le_of_lt (Real.one_lt_exp_iff.mpr hε)) · -- Only coordinates j = a and j = b can differ! Each differs by at most u = e^{ε/2}, so product ≤ u*u = e^ε! dsimp only [rapporMech] have hmem_b : b ∈ (Finset.univ : Finset (Fin k)).erase a := Finset.mem_erase.mpr ⟨Ne.symm hab, Finset.mem_univ b⟩ rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ a), ← Finset.mul_prod_erase _ _ hmem_b] conv_rhs => rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ a), ← Finset.mul_prod_erase _ _ hmem_b] have hrest : ∏ j ∈ (Finset.univ.erase a).erase b, rapporBitProb ε (decide (j = a)) (v j) = ∏ j ∈ (Finset.univ.erase a).erase b, rapporBitProb ε (decide (j = b)) (v j) := by refine Finset.prod_congr rfl fun j hj => ?_ have hjb := Finset.ne_of_mem_erase hj have hja := Finset.ne_of_mem_erase (Finset.mem_of_mem_erase hj) simp [hja, hjb] rw [hrest, ← hu_sq] have ha_le := hbit_ratio (decide (a = a)) (decide (a = b)) (v a) have hb_le := hbit_ratio (decide (b = a)) (decide (b = b)) (v b) have hrest_nn : 0 ≤ ∏ j ∈ (Finset.univ.erase a).erase b, rapporBitProb ε (decide (j = b)) (v j) := Finset.prod_nonneg fun j _ => hbit_nn _ _ have hmul : rapporBitProb ε (decide (a = a)) (v a) * rapporBitProb ε (decide (b = a)) (v b) ≤ (u * rapporBitProb ε (decide (a = b)) (v a)) * (u * rapporBitProb ε (decide (b = b)) (v b)) := mul_le_mul ha_le hb_le (hbit_nn _ _) (mul_nonneg (le_of_lt hu_pos) (hbit_nn _ _)) nlinarith linarith exact ⟨hdir x₁ x₂, hdir x₂ x₁⟩ -- 2) Marginal P(v i = true) under p equals q2 + dq * p i where q1 = u/(u+1), q2 = 1/(u+1), dq = (u-1)/(u+1)! set q1 : ℝ := u / (u + 1) set q2 : ℝ := 1 / (u + 1) set dq : ℝ := (u - 1) / (u + 1) have hdq_pos : 0 < dq := div_pos hum1_pos hup_pos have hPi : ∀ i : Fin k, ∑ x : Fin k, p x * ∑ v : Fin k → Bool, rapporMech k ε x v * (if v i then (1 : ℝ) else 0) = q2 + dq * p i := by intro i have hinner : ∀ x : Fin k, ∑ v : Fin k → Bool, rapporMech k ε x v * (if v i then (1 : ℝ) else 0) = if x = i then q1 else q2 := by intro x rw [hcoord_expect x i (fun b => if b then 1 else 0), Fintype.sum_bool] by_cases hxi : x = i · subst hxi; simp [rapporBitProb, q1, u] · have hix : i ≠ x := Ne.symm hxi simp [hxi, hix, rapporBitProb, q2, u] simp_rw [hinner] have hpt : ∀ x : Fin k, p x * (if x = i then q1 else q2) = q2 * p x + (if x = i then dq * p x else 0) := by intro x; split_ifs · dsimp only [q1, q2, dq]; field_simp [ne_of_gt hup_pos]; ring · ring simp_rw [hpt, Finset.sum_add_distrib, ← Finset.mul_sum, hp.2, Finset.sum_ite_eq', if_pos (Finset.mem_univ i)] ring have hunb : ∀ i : Fin k, ∑ x : Fin k, p x * ∑ v : Fin k → Bool, rapporMech k ε x v * rapporEst k ε v i = p i := by intro i have hrew : ∀ x : Fin k, ∑ v : Fin k → Bool, rapporMech k ε x v * rapporEst k ε v i = ((∑ v : Fin k → Bool, rapporMech k ε x v * (if v i then (1 : ℝ) else 0)) - q2) / dq := by intro x have h1 : ∀ v : Fin k → Bool, rapporMech k ε x v * rapporEst k ε v i = (rapporMech k ε x v * (if v i then (1 : ℝ) else 0) - q2 * rapporMech k ε x v) / dq := by intro v; dsimp only [rapporEst, q2, dq, u]; ring simp_rw [h1, ← Finset.sum_div, Finset.sum_sub_distrib, ← Finset.mul_sum, (hLDP.1 x).2, mul_one] simp_rw [hrew, ← mul_div_assoc] rw [← Finset.sum_div] simp_rw [mul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_mul, hp.2, one_mul, hPi i] have : q2 + dq * p i - q2 = dq * p i := by ring rw [this, mul_div_cancel_left₀ _ (ne_of_gt hdq_pos)] refine ⟨hLDP, hunb, ?_⟩ -- 3) Exact MSE! dsimp only [perSampleMSE] have hmse_by_i : ∑ x : Fin k, p x * ∑ v : Fin k → Bool, rapporMech k ε x v * ∑ i : Fin k, (rapporEst k ε v i - p i) ^ 2 = ∑ i : Fin k, ((q2 + dq * p i) * (1 - (q2 + dq * p i)) / dq ^ 2) := by have hstep1 : ∀ x : Fin k, ∑ v : Fin k → Bool, rapporMech k ε x v * ∑ i : Fin k, (rapporEst k ε v i - p i) ^ 2 = ∑ i : Fin k, ∑ v : Fin k → Bool, rapporMech k ε x v * (rapporEst k ε v i - p i) ^ 2 := by intro x; simp_rw [Finset.mul_sum]; exact Finset.sum_comm simp_rw [hstep1, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun i _ => ?_ have hsq_id : ∀ v : Fin k → Bool, (rapporEst k ε v i - p i) ^ 2 = ((1 - 2 * (q2 + dq * p i)) * (if v i then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) / dq ^ 2 := by intro v dsimp only [rapporEst] have hdiff : ((if v i then (1 : ℝ) else 0) - q2) / dq - p i = ((if v i then (1 : ℝ) else 0) - (q2 + dq * p i)) / dq := by field_simp [ne_of_gt hdq_pos]; ring rw [hdiff, div_pow]; congr 1; split_ifs <;> ring have hnum : ∑ x : Fin k, p x * ∑ v : Fin k → Bool, rapporMech k ε x v * ((1 - 2 * (q2 + dq * p i)) * (if v i then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (q2 + dq * p i) * (1 - (q2 + dq * p i)) := by have h1 : ∀ x : Fin k, ∑ v : Fin k → Bool, rapporMech k ε x v * ((1 - 2 * (q2 + dq * p i)) * (if v i then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (1 - 2 * (q2 + dq * p i)) * (∑ v : Fin k → Bool, rapporMech k ε x v * (if v i then (1 : ℝ) else 0)) + (q2 + dq * p i) ^ 2 := by intro x have hrew : ∀ v : Fin k → Bool, rapporMech k ε x v * ((1 - 2 * (q2 + dq * p i)) * (if v i then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (1 - 2 * (q2 + dq * p i)) * (rapporMech k ε x v * (if v i then (1 : ℝ) else 0)) + (q2 + dq * p i) ^ 2 * rapporMech k ε x v := fun v => by ring simp_rw [hrew, Finset.sum_add_distrib, ← Finset.mul_sum, (hLDP.1 x).2, mul_one] have h1' : ∀ x : Fin k, p x * ∑ v : Fin k → Bool, rapporMech k ε x v * ((1 - 2 * (q2 + dq * p i)) * (if v i then (1 : ℝ) else 0) + (q2 + dq * p i) ^ 2) = (1 - 2 * (q2 + dq * p i)) * (p x * ∑ v : Fin k → Bool, rapporMech k ε x v * (if v i then (1 : ℝ) else 0)) + (q2 + dq * p i) ^ 2 * p x := fun x => by rw [h1 x]; ring simp_rw [h1', Finset.sum_add_distrib, ← Finset.mul_sum, hp.2, mul_one, hPi i] ring simp_rw [hsq_id, ← mul_div_assoc, ← Finset.sum_div] rw [← hnum] congr 1 refine Finset.sum_congr rfl fun x _ => (Finset.mul_sum _ _ _).symm rw [hmse_by_i, ← Finset.sum_div] have hsum_num : ∑ i : Fin k, (q2 + dq * p i) * (1 - (q2 + dq * p i)) = ((k : ℝ) * q2 * (1 - q2) + dq * (1 - 2 * q2)) - dq ^ 2 * ∑ i : Fin k, p i ^ 2 := by have hpt : ∀ i : Fin k, (q2 + dq * p i) * (1 - (q2 + dq * p i)) = q2 * (1 - q2) + dq * (1 - 2 * q2) * p i - dq ^ 2 * p i ^ 2 := fun i => by ring simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, ← Finset.mul_sum, hp.2, mul_one]; ring rw [hsum_num, sub_div, mul_div_cancel_left₀ _ (ne_of_gt (pow_pos hdq_pos 2))] have halg : ((k : ℝ) * q2 * (1 - q2) + dq * (1 - 2 * q2)) / dq ^ 2 = 1 + (k : ℝ) * u / (u - 1) ^ 2 := by dsimp only [q2, dq] field_simp [ne_of_gt hup_pos, ne_of_gt hum1_pos]; ring linarith /-! ### Sharp Phase Transitions & Universal Dominance Theorems -/ /-- **EXACT WORST-CASE `L₂²` MSE AT UNIFORM PRIOR**: For EVERY `k ≥ 2`, `1 ≤ s ≤ k - 1`, `ε > 0`, and EVERY distribution `p ∈ Δ_k`, `perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p` is maximized at the uniform distribution `p_unif = (1/k, ..., 1/k)`! -/ theorem subsetSel_worstCase_at_uniform {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s ≤ k - 1) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p ≤ perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) (fun _ => 1 / (k : ℝ)) := by have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr (by omega) have hunif : IsProbDist (fun _ : Fin k => 1 / (k : ℝ)) := ⟨fun _ => by positivity, by simp [ne_of_gt hk_pos]⟩ rw [(subsetSel_mse_exact hs1 hsk hε hp).2, (subsetSel_mse_exact hs1 hsk hε hunif).2] -- By Cauchy–Schwarz: (∑ p_i)^2 ≤ k * ∑ p_i^2, so 1/k ≤ ∑ p_i^2! have hcs : (∑ i : Fin k, p i * (1 : ℝ)) ^ 2 ≤ (∑ i : Fin k, p i ^ 2) * (∑ _i : Fin k, (1 : ℝ) ^ 2) := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ p (fun _ => (1 : ℝ)) simp only [mul_one, one_pow, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, hp.2] at hcs have hunif_sq : ∑ _i : Fin k, (1 / (k : ℝ)) ^ 2 = 1 / (k : ℝ) := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp [ne_of_gt hk_pos] rw [hunif_sq] have hle : 1 / (k : ℝ) ≤ ∑ i : Fin k, p i ^ 2 := by rw [div_le_iff₀ hk_pos]; linarith linarith /-- **EXACT SUBSET-SIZE PHASE TRANSITION THRESHOLD**: For EVERY `k ≥ 3`, EVERY `1 ≤ s ≤ k - 2`, EVERY `ε > 0`, and EVERY `p ∈ Δ_k`: `MSE((s + 1)-SS, p) ≤ MSE(s-SS, p) ↔ e^{2 ε} ≤ ((k - s) * (k - s - 1)) / (s * (s + 1))`! -/ theorem subsetSel_step_phase_transition {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s + 1 ≤ k - 1) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : perSampleMSE (subsetSelMech k (s + 1) ε) (subsetSelEst k (s + 1) ε) p ≤ perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p ↔ Real.exp (2 * ε) ≤ (((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1)) / ((s : ℝ) * ((s : ℝ) + 1)) := by rw [(subsetSel_mse_exact (by omega : 1 ≤ s + 1) hsk hε hp).2, (subsetSel_mse_exact hs1 (by omega : s ≤ k - 1) hε hp).2] have hk1_pos : (0 : ℝ) < (k : ℝ) - 1 := by have hk3r : (3 : ℝ) ≤ (k : ℝ) := by exact_mod_cast (by omega : 3 ≤ k) linarith have hem1_pos : 0 < Real.exp ε - 1 := by linarith [Real.one_lt_exp_iff.mpr hε] have hs_pos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) have hs1_pos : (0 : ℝ) < (s : ℝ) + 1 := by linarith have hks_pos : (0 : ℝ) < (k : ℝ) - (s : ℝ) := by have : (s : ℝ) < (k : ℝ) := Nat.cast_lt.mpr (by omega); linarith have hks1_pos : (0 : ℝ) < (k : ℝ) - (s : ℝ) - 1 := by have : ((s + 1 : ℕ) : ℝ) < (k : ℝ) := Nat.cast_lt.mpr (by omega); push_cast at this; linarith have hexp2 : Real.exp (2 * ε) = Real.exp ε ^ 2 := by rw [two_mul, Real.exp_add, sq] rw [hexp2] have hcoef_pos : 0 < ((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2 := by positivity have hdiff : (Real.exp ε ^ 2 / ((k : ℝ) - ((s + 1 : ℕ) : ℝ)) + 1 / ((s + 1 : ℕ) : ℝ)) - (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) = (Real.exp ε ^ 2 * ((s : ℝ) * ((s : ℝ) + 1)) - ((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1)) / (((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1) * ((s : ℝ) * ((s : ℝ) + 1))) := by push_cast have hks1' : (k : ℝ) - ((s : ℝ) + 1) = (k : ℝ) - (s : ℝ) - 1 := by ring rw [hks1'] field_simp [ne_of_gt hks_pos, ne_of_gt hks1_pos, ne_of_gt hs_pos, ne_of_gt hs1_pos]; ring have hden_pos : 0 < ((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1) * ((s : ℝ) * ((s : ℝ) + 1)) := by positivity constructor · intro hle have hle' : Real.exp ε ^ 2 / ((k : ℝ) - ((s + 1 : ℕ) : ℝ)) + 1 / ((s + 1 : ℕ) : ℝ) ≤ Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ) := by have hsub : (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * ((Real.exp ε ^ 2 / ((k : ℝ) - ((s + 1 : ℕ) : ℝ)) + 1 / ((s + 1 : ℕ) : ℝ)) - (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ))) ≤ 0 := by linarith have := nonpos_of_mul_nonpos_right hsub hcoef_pos linarith have hnum_le : Real.exp ε ^ 2 * ((s : ℝ) * ((s : ℝ) + 1)) - ((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1) ≤ 0 := by have : (Real.exp ε ^ 2 * ((s : ℝ) * ((s : ℝ) + 1)) - ((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1)) / (((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1) * ((s : ℝ) * ((s : ℝ) + 1))) ≤ 0 := by linarith [hdiff] exact (div_nonpos_iff.mp this).resolve_left (fun ⟨_, hn⟩ => by linarith) |>.1 rw [le_div_iff₀ (mul_pos hs_pos hs1_pos)]; linarith · intro hle rw [le_div_iff₀ (mul_pos hs_pos hs1_pos)] at hle have hdiv_le : (Real.exp ε ^ 2 * ((s : ℝ) * ((s : ℝ) + 1)) - ((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1)) / (((k : ℝ) - (s : ℝ)) * ((k : ℝ) - (s : ℝ) - 1) * ((s : ℝ) * ((s : ℝ) + 1))) ≤ 0 := div_nonpos_of_nonpos_of_nonneg (by linarith) (le_of_lt hden_pos) have hmul : (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * ((Real.exp ε ^ 2 / ((k : ℝ) - ((s + 1 : ℕ) : ℝ)) + 1 / ((s + 1 : ℕ) : ℝ)) - (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ))) ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (le_of_lt hcoef_pos) (by linarith [hdiff]) linarith /-- **EXACT CONTINUOUS CAUCHY–SCHWARZ LOWER ENVELOPE FOR `s`-SUBSET SELECTION**: For EVERY `k ≥ 2`, `1 ≤ s ≤ k - 1`, `ε > 0`, and `p ∈ Δ_k`: `MSE(s-SS, p) ≥ (1 - ∑ p_i²) + ((k - 1)² (e^ε + 1)²) / (k (e^ε - 1)²) - (k - 1)`, with **EXACT EQUALITY** iff `s * (e^ε + 1) = k`! -/ theorem subsetSel_cauchy_schwarz_envelope {k s : ℕ} (hs1 : 1 ≤ s) (hsk : s ≤ k - 1) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : (1 - ∑ i : Fin k, p i ^ 2) + ((k : ℝ) - 1) ^ 2 * (Real.exp ε + 1) ^ 2 / ((k : ℝ) * (Real.exp ε - 1) ^ 2) - ((k : ℝ) - 1) ≤ perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p ∧ (perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p = (1 - ∑ i : Fin k, p i ^ 2) + ((k : ℝ) - 1) ^ 2 * (Real.exp ε + 1) ^ 2 / ((k : ℝ) * (Real.exp ε - 1) ^ 2) - ((k : ℝ) - 1) ↔ (s : ℝ) * (Real.exp ε + 1) = (k : ℝ)) := by rw [(subsetSel_mse_exact hs1 hsk hε hp).2] have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr (by omega) have hs_pos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) have hks_pos : (0 : ℝ) < (k : ℝ) - (s : ℝ) := by have : (s : ℝ) < (k : ℝ) := Nat.cast_lt.mpr (by omega); linarith have hk1_pos : (0 : ℝ) < (k : ℝ) - 1 := by have hk2r : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast (by omega : 2 ≤ k) linarith have hem1_pos : 0 < Real.exp ε - 1 := by linarith [Real.one_lt_exp_iff.mpr hε] have hcs_id : (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - (Real.exp ε + 1) ^ 2 / (k : ℝ) = ((s : ℝ) * (Real.exp ε + 1) - (k : ℝ)) ^ 2 / ((k : ℝ) * (s : ℝ) * ((k : ℝ) - (s : ℝ))) := by field_simp [ne_of_gt hk_pos, ne_of_gt hs_pos, ne_of_gt hks_pos]; ring have hcoef_pos : 0 < ((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2 := by positivity have hden_pos : 0 < (k : ℝ) * (s : ℝ) * ((k : ℝ) - (s : ℝ)) := by positivity have hmul_eq : ((k : ℝ) - 1) ^ 2 * (Real.exp ε + 1) ^ 2 / ((k : ℝ) * (Real.exp ε - 1) ^ 2) = (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * ((Real.exp ε + 1) ^ 2 / (k : ℝ)) := by field_simp [ne_of_gt hk_pos, ne_of_gt hem1_pos] rw [hmul_eq] constructor · have hnn : 0 ≤ ((s : ℝ) * (Real.exp ε + 1) - (k : ℝ)) ^ 2 / ((k : ℝ) * (s : ℝ) * ((k : ℝ) - (s : ℝ))) := by positivity have hle : (Real.exp ε + 1) ^ 2 / (k : ℝ) ≤ Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ) := by linarith have := mul_le_mul_of_nonneg_left hle (le_of_lt hcoef_pos) linarith · constructor · intro heq have h0 : (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * ((Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - (Real.exp ε + 1) ^ 2 / (k : ℝ)) = 0 := by linarith have h1 : (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - (Real.exp ε + 1) ^ 2 / (k : ℝ) = 0 := (mul_eq_zero.mp h0).resolve_left (ne_of_gt hcoef_pos) rw [hcs_id, div_eq_zero_iff] at h1 have hsq0 : ((s : ℝ) * (Real.exp ε + 1) - (k : ℝ)) ^ 2 = 0 := h1.resolve_right (ne_of_gt hden_pos) linarith [sq_eq_zero_iff.mp hsq0] · intro heq have h1 : (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - (Real.exp ε + 1) ^ 2 / (k : ℝ) = 0 := by rw [hcs_id, heq, sub_self, zero_pow two_ne_zero, zero_div] linarith [show (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) = (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * ((Real.exp ε + 1) ^ 2 / (k : ℝ)) by rw [show Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ) = (Real.exp ε + 1) ^ 2 / (k : ℝ) by linarith]] /-- **EXACT `k`-RR vs. RAPPOR ALGEBRAIC IDENTITY & ALPHABET-SIZE PHASE TRANSITION AT `k* = 5`**: For EVERY `k ≥ 2`, `ε > 0`, and `p ∈ Δ_k`, setting `u = e^{ε/2} > 1`: 1. **Exact Identity:** `(MSE(RAPPOR, p) - MSE(k-RR, p)) * (e^ε - 1)² = k * (u³ + u + 3 - k) + 2 * (u² - 1)`. 2. **Phase I (`2 ≤ k ≤ 5`):** `k`-RR **STRICTLY BEATS RAPPOR** for EVERY `ε > 0` and EVERY `p ∈ Δ_k`! 3. **Phase II (`k ≥ 6`):** Sharp crossover in `ε`: - For small `ε` (`u³ + u + 3 + 2(u² - 1)/k < k`), **RAPPOR STRICTLY BEATS `k`-RR**! - For large `ε` (`k ≤ u³ + u + 3`), **`k`-RR STRICTLY BEATS RAPPOR**! -/ theorem kRR_vs_rappor_phase_transition {k : ℕ} (hk : 2 ≤ k) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : let u := Real.exp (ε / 2) (perSampleMSE (rapporMech k ε) (rapporEst k ε) p - perSampleMSE (kRRMech k ε) (kRREst k ε) p) * (Real.exp ε - 1) ^ 2 = (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) + 2 * (u ^ 2 - 1) ∧ (k ≤ 5 → perSampleMSE (kRRMech k ε) (kRREst k ε) p < perSampleMSE (rapporMech k ε) (rapporEst k ε) p) ∧ (k ≥ 6 → (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) + 2 * (u ^ 2 - 1) < 0 → perSampleMSE (rapporMech k ε) (rapporEst k ε) p < perSampleMSE (kRRMech k ε) (kRREst k ε) p) ∧ ((k : ℝ) ≤ u ^ 3 + u + 3 → perSampleMSE (kRRMech k ε) (kRREst k ε) p < perSampleMSE (rapporMech k ε) (rapporEst k ε) p) := by intro u have hu1 : 1 < u := Real.one_lt_exp_iff.mpr (by linarith) have he_eq : Real.exp ε = u ^ 2 := by dsimp only [u]; rw [sq, ← Real.exp_add]; congr 1; ring have hem1_pos : 0 < Real.exp ε - 1 := by rw [he_eq]; nlinarith have hum1_pos : 0 < u - 1 := by linarith have hid : (perSampleMSE (rapporMech k ε) (rapporEst k ε) p - perSampleMSE (kRRMech k ε) (kRREst k ε) p) * (Real.exp ε - 1) ^ 2 = (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) + 2 * (u ^ 2 - 1) := by rw [(rappor_mse_exact hε hp).2.2, (kRR_mse_exact hk hε hp).2.2, he_eq] change (((1 - ∑ i : Fin k, p i ^ 2) + (k : ℝ) * u / (u - 1) ^ 2) - ((1 - ∑ i : Fin k, p i ^ 2) + ((k : ℝ) - 1) * (2 * u ^ 2 + (k : ℝ) - 2) / (u ^ 2 - 1) ^ 2)) * (u ^ 2 - 1) ^ 2 = _ have hu2m1 : u ^ 2 - 1 ≠ 0 := ne_of_gt (by nlinarith) field_simp [ne_of_gt hum1_pos, hu2m1]; ring refine ⟨hid, ?_, ?_, ?_⟩ · intro hk5 have hk5r : (k : ℝ) ≤ 5 := by exact_mod_cast hk5 have hpos : 0 < (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) + 2 * (u ^ 2 - 1) := by have hu3 : 5 < u ^ 3 + u + 3 := by nlinarith have h1 : 0 < (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) := mul_pos (Nat.cast_pos.mpr (by omega)) (by linarith) nlinarith rw [← hid] at hpos have hdiff := pos_of_mul_pos_left hpos (sq_nonneg (Real.exp ε - 1)) linarith · intro _ hneg rw [← hid] at hneg have hdiff := neg_of_mul_neg_left hneg (sq_nonneg (Real.exp ε - 1)) linarith · intro hge have hpos : 0 < (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) + 2 * (u ^ 2 - 1) := by have h1 : 0 ≤ (k : ℝ) * (u ^ 3 + u + 3 - (k : ℝ)) := mul_nonneg (Nat.cast_nonneg k) (by linarith) nlinarith rw [← hid] at hpos have hdiff := pos_of_mul_pos_left hpos (sq_nonneg (Real.exp ε - 1)) linarith /-- **UNIVERSAL STRICT DOMINANCE OF OPTIMAL `s`-SUBSET SELECTION OVER RAPPOR**: For **EVERY** alphabet size `k ≥ 2`, **EVERY** privacy parameter `ε > 0`, and **EVERY** distribution `p ∈ Δ_k`, there exists `s ∈ {1, ..., k - 1}` such that `s`-Subset Selection **STRICTLY BEATS** Unary RAPPOR in per-sample `L₂²` MSE! -/ theorem optimal_subsetSel_strictly_beats_rappor {k : ℕ} (hk : 2 ≤ k) {ε : ℝ} (hε : 0 < ε) {p : Fin k → ℝ} (hp : IsProbDist p) : ∃ (s : ℕ), 1 ≤ s ∧ s ≤ k - 1 ∧ perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) p < perSampleMSE (rapporMech k ε) (rapporEst k ε) p := by set u : ℝ := Real.exp (ε / 2) set e : ℝ := Real.exp ε have hu1 : 1 < u := Real.one_lt_exp_iff.mpr (by linarith) have he_eq : e = u ^ 2 := by dsimp only [e, u]; rw [sq, ← Real.exp_add]; congr 1; ring have he1 : 1 < e := by rw [he_eq]; nlinarith have hem1_pos : 0 < e - 1 := by linarith by_cases hcase : (k : ℝ) ≤ 2 * (e + 1) · -- Case 1: k ≤ 2 (e + 1) => take s = 1 (k-RR)! refine ⟨1, le_rfl, by omega, ?_⟩ have hle : (k : ℝ) ≤ u ^ 3 + u + 3 := by have hgap : u ^ 3 + u + 3 - 2 * (u ^ 2 + 1) = u * (u - 1) ^ 2 + 1 := by ring have hpos : 0 < u * (u - 1) ^ 2 + 1 := by positivity linarith [he_eq] have hlt := (kRR_vs_rappor_phase_transition hk hε hp).2.2.2 hle have hss1_eq : perSampleMSE (subsetSelMech k 1 ε) (subsetSelEst k 1 ε) p = perSampleMSE (kRRMech k ε) (kRREst k ε) p := by rw [(subsetSel_mse_exact le_rfl (by omega : 1 ≤ k - 1) hε hp).2, (kRR_mse_exact hk hε hp).2.2] have hk1 : (k : ℝ) - 1 ≠ 0 := by have hk2r : (2 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk linarith have hem1' : Real.exp ε - 1 ≠ 0 := ne_of_gt hem1_pos simp only [Nat.cast_one] field_simp [hk1, hem1']; ring rw [hss1_eq]; exact hlt · -- Case 2: k > 2 (e + 1) => take s = ⌊k / (e + 1)⌋ ≥ 2! push Not at hcase set x : ℝ := (k : ℝ) / (e + 1) have hep_pos : 0 < e + 1 := by linarith have hx_gt2 : 2 < x := (lt_div_iff₀ hep_pos).mpr (by linarith) set s : ℕ := Nat.floor x have hs_ge2 : 2 ≤ s := Nat.le_floor (le_of_lt hx_gt2) have hs_le_x : (s : ℝ) ≤ x := Nat.floor_le (by linarith) have hx_lt_s1 : x < (s : ℝ) + 1 := Nat.lt_floor_add_one x have hs_le_k1 : s ≤ k - 1 := by have h2x : 2 * (s : ℝ) < (k : ℝ) := by have hx_half : 2 * x < (k : ℝ) := by dsimp only [x]; rw [mul_div_assoc', div_lt_iff₀ hep_pos]; nlinarith linarith have h2s_lt : 2 * s < k := by exact_mod_cast h2x omega refine ⟨s, by omega, hs_le_k1, ?_⟩ rw [(subsetSel_mse_exact (by omega : 1 ≤ s) hs_le_k1 hε hp).2, (rappor_mse_exact hε hp).2.2] -- Show LHS * (e - 1)^2 < RHS * (e - 1)^2 via our exact 26-term positive polynomial! have hs_pos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) have hks_pos : (0 : ℝ) < (k : ℝ) - (s : ℝ) := by have : (s : ℝ) < (k : ℝ) := Nat.cast_lt.mpr (by omega); linarith have hkme_pos : 0 < (k : ℝ) - e - 1 := by linarith have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr (by omega) have h1 : e ^ 2 / ((k : ℝ) - (s : ℝ)) ≤ e * (e + 1) / (k : ℝ) := by have hks_ge : (k : ℝ) * e / (e + 1) ≤ (k : ℝ) - (s : ℝ) := by have : (k : ℝ) - x = (k : ℝ) * e / (e + 1) := by dsimp only [x]; field_simp [ne_of_gt hep_pos]; ring linarith rw [div_le_div_iff₀ hks_pos hk_pos] have hmul := mul_le_mul_of_nonneg_left hks_ge (le_of_lt (mul_pos (by linarith : 0 < e) hep_pos)) have hsimp : e * (e + 1) * ((k : ℝ) * e / (e + 1)) = e ^ 2 * (k : ℝ) := by field_simp [ne_of_gt hep_pos] linarith have h2 : 1 / (s : ℝ) ≤ (e + 1) / ((k : ℝ) - e - 1) := by have hs_ge : ((k : ℝ) - e - 1) / (e + 1) ≤ (s : ℝ) := by have : x - 1 = ((k : ℝ) - e - 1) / (e + 1) := by dsimp only [x]; field_simp [ne_of_gt hep_pos]; ring linarith rw [div_le_div_iff₀ hs_pos hkme_pos] have hmul := mul_le_mul_of_nonneg_left hs_ge (le_of_lt hep_pos) have hsimp : (e + 1) * (((k : ℝ) - e - 1) / (e + 1)) = (k : ℝ) - e - 1 := by field_simp [ne_of_gt hep_pos] linarith -- Multiply by (e - 1)^2 > 0! set r : ℝ := u - 1 set t : ℝ := (k : ℝ) - 2 * (e + 1) have hr_pos : 0 < r := by dsimp only [r]; linarith have ht_pos : 0 < t := by dsimp only [t]; linarith have hu_r : u = 1 + r := by dsimp only [r]; ring have he_r : e = (1 + r) ^ 2 := by rw [he_eq, hu_r] have hk_tr : (k : ℝ) = t + 2 * ((1 + r) ^ 2 + 1) := by dsimp only [t]; rw [he_r]; ring have hpoly_pos : ((k : ℝ) - 1) ^ 2 * (e * (e + 1) / (k : ℝ) + (e + 1) / ((k : ℝ) - e - 1)) - ((k : ℝ) - 1) * (e - 1) ^ 2 < (k : ℝ) * u * (u + 1) ^ 2 := by have hden_pos : 0 < (k : ℝ) * ((k : ℝ) - e - 1) := mul_pos hk_pos hkme_pos have hscaled : ((k : ℝ) * u * (u + 1) ^ 2 - (((k : ℝ) - 1) ^ 2 * (e * (e + 1) / (k : ℝ) + (e + 1) / ((k : ℝ) - e - 1)) - ((k : ℝ) - 1) * (e - 1) ^ 2)) * ((k : ℝ) * ((k : ℝ) - e - 1)) = 20 + 64 * r + 100 * r ^ 2 + 124 * r ^ 3 + 157 * r ^ 4 + 178 * r ^ 5 + 147 * r ^ 6 + 80 * r ^ 7 + 26 * r ^ 8 + 4 * r ^ 9 + 20 * t + 56 * t * r + 88 * t * r ^ 2 + 116 * t * r ^ 3 + 123 * t * r ^ 4 + 90 * t * r ^ 5 + 39 * t * r ^ 6 + 8 * t * r ^ 7 + 4 * t ^ 2 + 8 * t ^ 2 * r + 14 * t ^ 2 * r ^ 2 + 20 * t ^ 2 * r ^ 3 + 15 * t ^ 2 * r ^ 4 + 5 * t ^ 2 * r ^ 5 + t ^ 3 * r ^ 2 + t ^ 3 * r ^ 3 := by have hclears : ((k : ℝ) - 1) ^ 2 * (e * (e + 1) / (k : ℝ) + (e + 1) / ((k : ℝ) - e - 1)) * ((k : ℝ) * ((k : ℝ) - e - 1)) = ((k : ℝ) - 1) ^ 2 * (e * (e + 1) * ((k : ℝ) - e - 1) + (e + 1) * (k : ℝ)) := by field_simp [ne_of_gt hk_pos, ne_of_gt hkme_pos] rw [sub_mul, sub_mul, hclears, hu_r, he_r, hk_tr] ring have hpos_rhs : 0 < 20 + 64 * r + 100 * r ^ 2 + 124 * r ^ 3 + 157 * r ^ 4 + 178 * r ^ 5 + 147 * r ^ 6 + 80 * r ^ 7 + 26 * r ^ 8 + 4 * r ^ 9 + 20 * t + 56 * t * r + 88 * t * r ^ 2 + 116 * t * r ^ 3 + 123 * t * r ^ 4 + 90 * t * r ^ 5 + 39 * t * r ^ 6 + 8 * t * r ^ 7 + 4 * t ^ 2 + 8 * t ^ 2 * r + 14 * t ^ 2 * r ^ 2 + 20 * t ^ 2 * r ^ 3 + 15 * t ^ 2 * r ^ 4 + 5 * t ^ 2 * r ^ 5 + t ^ 3 * r ^ 2 + t ^ 3 * r ^ 3 := by positivity rw [← hscaled] at hpos_rhs have hdiff_pos := pos_of_mul_pos_left hpos_rhs (le_of_lt hden_pos) linarith have hstep_ub : ((k : ℝ) - 1) ^ 2 * (e ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1) * (e - 1) ^ 2 < (k : ℝ) * u * (u + 1) ^ 2 := by have hle_sum : e ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ) ≤ e * (e + 1) / (k : ℝ) + (e + 1) / ((k : ℝ) - e - 1) := add_le_add h1 h2 have hle_mul := mul_le_mul_of_nonneg_left hle_sum (sq_nonneg ((k : ℝ) - 1)) linarith have hdiv := div_lt_div_of_pos_right hstep_ub (pow_pos hem1_pos 2) have hlhs_div : (((k : ℝ) - 1) ^ 2 * (e ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1) * (e - 1) ^ 2) / (e - 1) ^ 2 = (((k : ℝ) - 1) ^ 2 / (e - 1) ^ 2) * (e ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1) := by field_simp [ne_of_gt hem1_pos] have hrhs_div : (k : ℝ) * u * (u + 1) ^ 2 / (e - 1) ^ 2 = (k : ℝ) * u / (u - 1) ^ 2 := by rw [he_eq] have hu2m1 : u ^ 2 - 1 ≠ 0 := ne_of_gt (by nlinarith) field_simp [ne_of_gt (by linarith : 0 < u - 1), hu2m1]; ring rw [hlhs_div, hrhs_div] at hdiv change (1 - ∑ i : Fin k, p i ^ 2) + (((k : ℝ) - 1) ^ 2 / (e - 1) ^ 2) * (e ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1) < (1 - ∑ i : Fin k, p i ^ 2) + (k : ℝ) * u / (u - 1) ^ 2 linarith /-! ============================================================================ PART 6.5: SHARP BOUNDARY COROLLARIES & EXACT SPECIALIZATIONS ============================================================================ -/ /-- **Pure `ε`-DP Exact Total Variation Bound**: For every pure `ε`-DP pair `(P, Q)` (`ε ≥ 0`, `δ = 0`), `TV(P, Q) ≤ (e^ε - 1) / (e^ε + 1)`, attained sharply by the binary Warner pair `(warnerP ε, warnerQ ε)`! -/ theorem epsDelta_tvDist_pure {Ω : Type*} [Fintype Ω] {ε : ℝ} (hε : 0 ≤ ε) {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) (hdp : IsEpsDeltaClose ε 0 P Q) : tvDist P Q ≤ (Real.exp ε - 1) / (Real.exp ε + 1) ∧ tvDist (warnerP ε) (warnerQ ε) = (Real.exp ε - 1) / (Real.exp ε + 1) := by have hep : 0 < Real.exp ε + 1 := by linarith [Real.exp_pos ε] have he1 : 1 ≤ Real.exp ε := Real.one_le_exp hε constructor · have h := (epsDelta_max_tvDist_exact hε le_rfl zero_le_one).1 P Q hP hQ hdp simpa only [mul_zero, add_zero] using h · dsimp only [tvDist, warnerP, warnerQ] rw [Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true] have h1 : Real.exp ε / (Real.exp ε + 1) - 1 / (Real.exp ε + 1) = (Real.exp ε - 1) / (Real.exp ε + 1) := by ring have h2 : 1 / (Real.exp ε + 1) - Real.exp ε / (Real.exp ε + 1) = -((Real.exp ε - 1) / (Real.exp ε + 1)) := by ring rw [h1, h2, abs_neg, abs_of_nonneg (div_nonneg (by linarith) (le_of_lt hep))] ring /-- **Pure `ε`-DP Exact Bhattacharyya Coefficient Lower Bound**: For every pure `ε`-DP pair `(P, Q)` (`ε ≥ 0`), `BC(P, Q) ≥ 2 √(e^ε) / (e^ε + 1)`, attained sharply by `(warnerP ε, warnerQ ε)`! -/ theorem epsDelta_bhattCoeff_pure {Ω : Type*} [Fintype Ω] {ε : ℝ} (hε : 0 ≤ ε) {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) (hdp : IsEpsDeltaClose ε 0 P Q) : 2 * Real.sqrt (Real.exp ε) / (Real.exp ε + 1) ≤ bhattCoeff P Q ∧ bhattCoeff (warnerP ε) (warnerQ ε) = 2 * Real.sqrt (Real.exp ε) / (Real.exp ε + 1) := by have hep : 0 < Real.exp ε + 1 := by linarith [Real.exp_pos ε] have hsq : Real.sqrt (Real.exp ε) = Real.exp (ε / 2) := by have he_sq : Real.exp ε = Real.exp (ε / 2) ^ 2 := by rw [sq, ← Real.exp_add]; congr 1; ring rw [he_sq, Real.sqrt_sq (le_of_lt (Real.exp_pos (ε / 2)))] constructor · have h := (epsDelta_min_bhattCoeff_exact hε le_rfl zero_le_one).1 P Q hP hQ hdp rw [hsq] simpa only [sub_zero, mul_one] using h · dsimp only [bhattCoeff, warnerP, warnerQ] rw [Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true] have hmul : Real.exp ε / (Real.exp ε + 1) * (1 / (Real.exp ε + 1)) = Real.exp ε / (Real.exp ε + 1) ^ 2 := by field_simp [ne_of_gt hep] have hmul2 : 1 / (Real.exp ε + 1) * (Real.exp ε / (Real.exp ε + 1)) = Real.exp ε / (Real.exp ε + 1) ^ 2 := by field_simp [ne_of_gt hep] rw [hmul, hmul2, Real.sqrt_div (le_of_lt (Real.exp_pos ε)), Real.sqrt_sq (le_of_lt hep)] ring /-- **UNIVERSAL PURE `ε`-DP `f`-DIVERGENCE EXTREMALITY OF WARNER'S PAIR**: For EVERY convex `f : ℝ → ℝ` on `[0, ∞)` and EVERY pure `ε`-DP pair `(P, Q)` with `∀ z, 0 < Q z`, the binary Warner pair `(warnerP ε, warnerQ ε)` simultaneously maximizes EVERY `f`-divergence: `D_f(P ‖ Q) ≤ D_f(warnerP ε ‖ warnerQ ε)`! -/ theorem epsDelta_pure_fDiv_max_attained {Ω : Type*} [Fintype Ω] {ε : ℝ} (hε : 0 ≤ ε) {f : ℝ → ℝ} (hf : ConvexOn ℝ (Set.Ici 0) f) {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) (hQpos : ∀ z, 0 < Q z) (hdp : IsEpsDeltaClose ε 0 P Q) : ∑ z : Ω, Q z * f (P z / Q z) ≤ ∑ b : Bool, warnerQ ε b * f (warnerP ε b / warnerQ ε b) := by obtain ⟨K4, hK4, hKP, hKQ⟩ := epsDelta_blackwell_dominance hε le_rfl zero_le_one hP hQ hdp let K : Bool → Ω → ℝ := fun b z => if b then K4 1 z else K4 2 z have hK : IsMarkovKernel K := fun b => by cases b <;> dsimp only [K] <;> [exact hK4 2; exact hK4 1] have hpushP : pushforward K (warnerP ε) = P := by rw [← hKP]; funext z dsimp only [pushforward, K, canonP, warnerP] rw [Fin.sum_univ_four, Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true, Fin.isValue] ring have hpushQ : pushforward K (warnerQ ε) = Q := by rw [← hKQ]; funext z dsimp only [pushforward, K, canonQ, warnerQ] rw [Fin.sum_univ_four, Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true, Fin.isValue] ring have hWQpos : ∀ b : Bool, 0 < warnerQ ε b := fun b => by cases b <;> dsimp only [warnerQ] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> positivity exact blackwellDom_fDiv_le hf (warnerP_isProbDist ε).1 hWQpos hQpos ⟨K, hK, hpushP, hpushQ⟩ /-- **EXACT PURE `ε`-DP `χ²`-DIVERGENCE EXTREMUM**: For EVERY pure `ε`-DP pair `(P, Q)` with `∀ z, 0 < Q z`, `χ²(P ‖ Q) ≤ (e^ε - 1)² / e^ε`, with exact equality attained by `(warnerP ε, warnerQ ε)`! -/ theorem epsDelta_chi2Div_pure_exact {Ω : Type*} [Fintype Ω] {ε : ℝ} (hε : 0 ≤ ε) {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) (hQpos : ∀ z, 0 < Q z) (hdp : IsEpsDeltaClose ε 0 P Q) : chi2Div P Q ≤ (Real.exp ε - 1) ^ 2 / Real.exp ε ∧ chi2Div (warnerP ε) (warnerQ ε) = (Real.exp ε - 1) ^ 2 / Real.exp ε := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε have hep_pos : 0 < Real.exp ε + 1 := by linarith have hwarner_eq : chi2Div (warnerP ε) (warnerQ ε) = (Real.exp ε - 1) ^ 2 / Real.exp ε := by dsimp only [chi2Div, warnerP, warnerQ] rw [Fintype.sum_bool] simp only [↓reduceIte, Bool.false_eq_true] field_simp [ne_of_gt he_pos, ne_of_gt hep_pos]; ring refine ⟨?_, hwarner_eq⟩ have hconv : ConvexOn ℝ (Set.Ici 0) (fun u : ℝ => (u - 1) ^ 2) := by refine ⟨convex_Ici 0, fun x _ y _ a b ha hb hab => ?_⟩ have hdiff : a * (x - 1) ^ 2 + b * (y - 1) ^ 2 - (a * x + b * y - 1) ^ 2 = a * b * (x - y) ^ 2 := by have h1 : a * x + b * y - 1 = a * (x - 1) + b * (y - 1) := by calc a * x + b * y - 1 = a * x + b * y - (a + b) := by rw [hab] _ = a * (x - 1) + b * (y - 1) := by ring rw [h1] calc a * (x - 1) ^ 2 + b * (y - 1) ^ 2 - (a * (x - 1) + b * (y - 1)) ^ 2 = a * (1 - a) * (x - 1) ^ 2 + b * (1 - b) * (y - 1) ^ 2 - 2 * a * b * (x - 1) * (y - 1) := by ring _ = a * b * (x - 1) ^ 2 + b * a * (y - 1) ^ 2 - 2 * a * b * (x - 1) * (y - 1) := by rw [show (1 : ℝ) - a = b by linarith, show (1 : ℝ) - b = a by linarith] _ = a * b * (x - y) ^ 2 := by ring have hnn : 0 ≤ a * b * (x - y) ^ 2 := mul_nonneg (mul_nonneg ha hb) (sq_nonneg _) simpa [smul_eq_mul] using show (a * x + b * y - 1) ^ 2 ≤ a * (x - 1) ^ 2 + b * (y - 1) ^ 2 by linarith have hf := epsDelta_pure_fDiv_max_attained hε hconv hP hQ hQpos hdp have hL : chi2Div P Q = ∑ z : Ω, Q z * (P z / Q z - 1) ^ 2 := by dsimp only [chi2Div]; refine Finset.sum_congr rfl fun z _ => ?_; field_simp [ne_of_gt (hQpos z)] have hR : chi2Div (warnerP ε) (warnerQ ε) = ∑ b : Bool, warnerQ ε b * (warnerP ε b / warnerQ ε b - 1) ^ 2 := by dsimp only [chi2Div]; refine Finset.sum_congr rfl fun b _ => ?_ have hb : 0 < warnerQ ε b := by cases b <;> dsimp only [warnerQ] <;> simp only [↓reduceIte, Bool.false_eq_true] <;> positivity field_simp [ne_of_gt hb] linarith /-- Nonnegativity of the KOV pure-DP composition function `kovPureDelta k ε i`. -/ theorem kov_pure_delta_nonneg (k : ℕ) (ε : ℝ) (i : ℕ) : 0 ≤ kovPureDelta k ε i := by dsimp only [kovPureDelta] refine div_nonneg (Finset.sum_nonneg fun j _ => ?_) (pow_nonneg (by linarith [Real.exp_pos ε]) k) exact mul_nonneg (Nat.cast_nonneg _) (le_max_left _ _) /-- Upper bound `kovPureDelta k ε i ≤ 1` for all `k, ε, i`. -/ theorem kov_pure_delta_le_one (k : ℕ) (ε : ℝ) (i : ℕ) : kovPureDelta k ε i ≤ 1 := by rw [← kov_pure_composition_exact k i] exact hockeyStick_le_one (le_of_lt (Real.exp_pos _)) (prodDistN_isProbDist k (warnerP_isProbDist ε)) (prodDistN_isProbDist k (warnerQ_isProbDist ε)) /-- **KOV Endpoint Recovery (`i = 0`)**: At `ε_comp = k ε` (`i = 0`), the KOV binomial tail vanishes identically (`kovPureDelta k ε 0 = 0`), recovering pure basic composition `(k ε, 0)`-DP as the exact endpoint of the KOV curve! -/ theorem kov_pure_delta_i0_eq_zero (k : ℕ) {ε : ℝ} (hε : 0 ≤ ε) : kovPureDelta k ε 0 = 0 := by dsimp only [kovPureDelta] have hzero : ∑ j ∈ Finset.range (k + 1), ((Nat.choose k j : ℕ) : ℝ) * max 0 (Real.exp ((j : ℝ) * ε) - Real.exp (((k : ℝ) - 2 * (0 : ℕ)) * ε) * Real.exp (((k - j : ℕ) : ℝ) * ε)) = 0 := by refine Finset.sum_eq_zero fun j hj => ?_ have hjk : j ≤ k := Nat.lt_succ_iff.mp (Finset.mem_range.mp hj) have hmax : max 0 (Real.exp ((j : ℝ) * ε) - Real.exp (((k : ℝ) - 2 * (0 : ℕ)) * ε) * Real.exp (((k - j : ℕ) : ℝ) * ε)) = 0 := by refine max_eq_left ?_ rw [← Real.exp_add] have harg : (j : ℝ) * ε ≤ ((k : ℝ) - 2 * ((0 : ℕ) : ℝ)) * ε + ((k - j : ℕ) : ℝ) * ε := by have hjr : (j : ℝ) ≤ (k : ℝ) := by exact_mod_cast hjk have hkjr : ((k - j : ℕ) : ℝ) = (k : ℝ) - (j : ℝ) := Nat.cast_sub hjk rw [hkjr, Nat.cast_zero]; nlinarith linarith [Real.exp_le_exp.mpr harg] rw [hmax, mul_zero] rw [hzero, zero_div] /-- **Pure Adaptive Basic Composition as `i = 0, δ = 0` Corollary of KOV**: Every `k`-fold adaptive composition of pure `ε`-DP mechanisms satisfies `(k ε, 0)`-DP! -/ theorem kov_adaptive_pure_basic_recovery {Ω : Type*} [Fintype Ω] {k : ℕ} {ε : ℝ} (hε : 0 ≤ ε) (M N : AdaptiveMech Ω k) (hdp : IsAdaptiveEpsDeltaDP ε 0 M N) : IsEpsDeltaClose ((k : ℝ) * ε) 0 (adaptiveTranscriptDist M) (adaptiveTranscriptDist N) := by have h := (kov_adaptive_composition_exact hε le_rfl zero_le_one k 0).1 M N hdp have h0 : ((k : ℝ) - 2 * ((0 : ℕ) : ℝ)) * ε = (k : ℝ) * ε := by simp have hd : 1 - (1 - (0 : ℝ)) ^ k * (1 - kovPureDelta k ε 0) = 0 := by rw [kov_pure_delta_i0_eq_zero k hε]; ring rw [h0, hd] at h exact h /-- **Exact Pure-DP Poisson Subsampling Amplification**: For pure `ε`-DP (`δ = 0`, `ε ≥ 0`) and sampling rate `p ∈ (0, 1]`, Poisson subsampling achieves exact pure `ε'`-DP with `ε' = log(1 + p (e^ε - 1))` (zero additive `δ'`)! -/ theorem poisson_subsampling_pure_dp_exact {Ω : Type*} [Fintype Ω] {ε p : ℝ} (hε : 0 ≤ ε) (hp0 : 0 < p) (hp1 : p ≤ 1) {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) (hdp : IsEpsDeltaClose ε 0 P Q) : let ε' := Real.log (1 + p * (Real.exp ε - 1)) IsEpsDeltaClose ε' 0 (subMix p P Q) Q := by have h := (poisson_subsampling_amplification_exact hε le_rfl zero_le_one hp0 hp1).1 P Q hP hQ hdp simpa only [mul_zero] using h /-- **Sharp Boundary of Poisson Subsampling Remove-Direction Collapse**: At the exact critical threshold `γ* = 1 / (1 - p)` (`0 ≤ p < 1`), the Remove-direction hockey-stick divergence collapses identically to `0` for EVERY pair of probability distributions `(P, Q)`! -/ theorem poisson_subsampling_remove_zero_at_threshold {Ω : Type*} [Fintype Ω] {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p < 1) {P Q : Ω → ℝ} (hP : IsProbDist P) (hQ : IsProbDist Q) : hockeyStick (1 / (1 - p)) Q (subMix p P Q) = 0 := poisson_subsampling_remove_zero_phase hp0 (div_nonneg zero_le_one (by linarith)) (by rw [div_mul_cancel₀ _ (ne_of_gt (by linarith : 0 < 1 - p))]) hP.1 hQ.1 /-- **STRICT DOMINANCE OVER TEXTBOOK DWORK–ROTH GROUP PRIVACY**: For EVERY `k : ℕ`, `ε ≥ 0`, and `δ ∈ [0, 1]`, our exact `k`-group privacy parameter `groupEnvIter k (e^ε) δ 0` is ALWAYS bounded above by the textbook geometric sum `(∑_{j < k} e^{jε}) δ` (which equals `((e^{kε} - 1) / (e^ε - 1)) δ` for `ε > 0`)! -/ theorem epsDelta_group_privacy_le_textbook (k : ℕ) (ε δ : ℝ) : groupEnvIter k (Real.exp ε) δ 0 ≤ (∑ j ∈ Finset.range k, Real.exp ε ^ j) * δ ∧ (0 < ε → groupEnvIter k (Real.exp ε) δ 0 ≤ ((Real.exp ε ^ k - 1) / (Real.exp ε - 1)) * δ) := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε have hmain : ∀ m : ℕ, groupEnvIter m (Real.exp ε) δ 0 ≤ (∑ j ∈ Finset.range m, Real.exp ε ^ j) * δ := by intro m induction m with | zero => simp [groupEnvIter] | succ m ih => have hstep : groupEnv (Real.exp ε) δ (groupEnvIter m (Real.exp ε) δ 0) ≤ δ + Real.exp ε * groupEnvIter m (Real.exp ε) δ 0 := min_le_of_right_le (min_le_left _ _) have hmul := mul_le_mul_of_nonneg_left ih (le_of_lt he_pos) have hpow : ∑ j ∈ Finset.range m, Real.exp ε ^ (j + 1) = Real.exp ε * ∑ j ∈ Finset.range m, Real.exp ε ^ j := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun j _ => by rw [pow_succ'] have hsum : Real.exp ε * ((∑ j ∈ Finset.range m, Real.exp ε ^ j) * δ) + δ = (∑ j ∈ Finset.range (m + 1), Real.exp ε ^ j) * δ := by rw [Finset.sum_range_succ', pow_zero, hpow]; ring dsimp only [groupEnvIter] linarith refine ⟨hmain k, fun hεpos => ?_⟩ have hne : Real.exp ε ≠ 1 := ne_of_gt (Real.one_lt_exp_iff.mpr hεpos) have hgeom : ∑ j ∈ Finset.range k, Real.exp ε ^ j = (Real.exp ε ^ k - 1) / (Real.exp ε - 1) := geom_sum_eq hne k rw [← hgeom] exact hmain k /-- **UNIVERSAL `ε`-INDEPENDENT VACUITY THRESHOLD AT `k = 2`**: For EVERY `ε > 0` and `δ ∈ [0, 1]`, 2-group privacy becomes vacuous (`= 1`) **IF AND ONLY IF** `δ ≥ 1 / 2` — completely independent of `ε`! -/ theorem epsDelta_group2_vacuity_exact {ε δ : ℝ} (hε : 0 < ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : groupEnvIter 2 (Real.exp ε) δ 0 = 1 ↔ 1 / 2 ≤ δ := by have h := epsDelta_group_vacuity_threshold_exact (by decide : 1 ≤ 2) hε hδ0 hδ1 have hem1 : Real.exp ε - 1 ≠ 0 := ne_of_gt (sub_pos.mpr (Real.one_lt_exp_iff.mpr hε)) have heq : (Real.exp ε - 1) / (Real.exp ε ^ (2 / 2) + Real.exp ε ^ (2 - 2 / 2) - 2) = 1 / 2 := by norm_num have hden : Real.exp ε + Real.exp ε - 2 = 2 * (Real.exp ε - 1) := by ring rw [hden]; field_simp [hem1] dsimp only at h rw [heq] at h exact h /-- **EXACT 3-GROUP PRIVACY VACUITY THRESHOLD**: For EVERY `ε > 0` and `δ ∈ [0, 1]`, 3-group privacy becomes vacuous (`= 1`) **IF AND ONLY IF** `δ ≥ 1 / (e^ε + 2)`! -/ theorem epsDelta_group3_vacuity_exact {ε δ : ℝ} (hε : 0 < ε) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) : groupEnvIter 3 (Real.exp ε) δ 0 = 1 ↔ 1 / (Real.exp ε + 2) ≤ δ := by have h := epsDelta_group_vacuity_threshold_exact (by decide : 1 ≤ 3) hε hδ0 hδ1 have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have hem1 : Real.exp ε - 1 ≠ 0 := ne_of_gt (by linarith) have hep2 : Real.exp ε + 2 ≠ 0 := ne_of_gt (by linarith) have heq : (Real.exp ε - 1) / (Real.exp ε ^ (3 / 2) + Real.exp ε ^ (3 - 3 / 2) - 2) = 1 / (Real.exp ε + 2) := by norm_num have hfac : Real.exp ε + Real.exp ε ^ 2 - 2 = (Real.exp ε - 1) * (Real.exp ε + 2) := by ring rw [hfac] field_simp [hem1, hep2] dsimp only at h rw [heq] at h exact h /-- **Pure `ε`-LDP Exact Dobrushin TV Contraction**: Specialization of `ldp_tv_contraction_exact` to `δ = 0`: every pure `ε`-LDP channel contracts total variation by at most `(e^ε - 1) / (e^ε + 1)`, with exact attainment! -/ theorem pureLDP_tv_contraction_exact {ε : ℝ} (hε : 0 ≤ ε) : (∀ {α Ω : Type*} [Fintype α] [Fintype Ω] (W : α → Ω → ℝ) (P Q : α → ℝ), IsLDPChannel ε 0 W → IsProbDist P → IsProbDist Q → tvDist (pushforward W P) (pushforward W Q) ≤ ((Real.exp ε - 1) / (Real.exp ε + 1)) * tvDist P Q) ∧ (∃ W : Bool → Fin 4 → ℝ, IsLDPChannel ε 0 W ∧ tvDist (pushforward W (fun b => if b then 1 else 0)) (pushforward W (fun b => if b then 0 else 1)) = ((Real.exp ε - 1) / (Real.exp ε + 1)) * tvDist (fun b : Bool => if b then 1 else 0) (fun b : Bool => if b then 0 else 1)) := by have h := ldp_tv_contraction_exact hε le_rfl zero_le_one have hsimp : (Real.exp ε - 1 + 2 * (0 : ℝ)) / (Real.exp ε + 1) = (Real.exp ε - 1) / (Real.exp ε + 1) := by ring simpa only [hsimp] using h /-- **STRICT IMPROVEMENT OF `log((e^ε + 1)² / (4 e^ε))` OVER NAIVE `ε` BOUND**: For EVERY `ε > 0`, our `ε`-LDP KL-mutual-information capacity bound `log((e^ε + 1)² / (4 e^ε))` is **STRICTLY LESS THAN `ε`** (and bounded above by `sinh²(ε/2)`)! -/ theorem pureLDP_kl_mutual_info_strictly_lt_eps {ε : ℝ} (hε : 0 < ε) : Real.log ((Real.exp ε + 1) ^ 2 / (4 * Real.exp ε)) < ε ∧ Real.log ((Real.exp ε + 1) ^ 2 / (4 * Real.exp ε)) ≤ (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε) := by have he_pos : 0 < Real.exp ε := Real.exp_pos ε have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have harg_pos : 0 < (Real.exp ε + 1) ^ 2 / (4 * Real.exp ε) := by positivity constructor · conv_rhs => rw [← Real.log_exp ε] refine Real.log_lt_log harg_pos ?_ rw [div_lt_iff₀ (by positivity : 0 < 4 * Real.exp ε)] have hfac : 4 * Real.exp ε * Real.exp ε - (Real.exp ε + 1) ^ 2 = (Real.exp ε - 1) * (3 * Real.exp ε + 1) := by ring have hpos : 0 < (Real.exp ε - 1) * (3 * Real.exp ε + 1) := mul_pos (by linarith) (by linarith) linarith · have hlog := Real.log_le_sub_one_of_pos harg_pos have hsub : (Real.exp ε + 1) ^ 2 / (4 * Real.exp ε) - 1 = (Real.exp ε - 1) ^ 2 / (4 * Real.exp ε) := by field_simp [ne_of_gt he_pos]; ring linarith /-- **EXACT 1-USER PURE `ε`-LDP HYPOTHESIS TESTING MINIMAX RISK**: For pure `ε`-LDP (`δ = 0`), the exact minimax Bayes testing risk between `P₀` and `P₁` is `(1 / 2) * (1 - ((e^ε - 1) / (e^ε + 1)) * TV(P₀, P₁))`, attained sharply! -/ theorem pureLDP_one_user_testing_minimax_exact {α : Type*} [Fintype α] [DecidableEq α] {ε : ℝ} (hε : 0 ≤ ε) {P₀ P₁ : α → ℝ} (hP₀ : IsProbDist P₀) (hP₁ : IsProbDist P₁) : let η := (Real.exp ε - 1) / (Real.exp ε + 1) (∀ {Ω : Type*} [Fintype Ω] [DecidableEq Ω] (W : α → Ω → ℝ) (φ : Ω → ℝ), IsLDPChannel ε 0 W → (∀ z, 0 ≤ φ z ∧ φ z ≤ 1) → (1 / 2 : ℝ) * (1 - η * tvDist P₀ P₁) ≤ testRisk (pushforward W P₀) (pushforward W P₁) φ) ∧ (∃ (W : α → Fin 4 → ℝ) (φ : Fin 4 → ℝ), IsLDPChannel ε 0 W ∧ (∀ z, 0 ≤ φ z ∧ φ z ≤ 1) ∧ testRisk (pushforward W P₀) (pushforward W P₁) φ = (1 / 2 : ℝ) * (1 - η * tvDist P₀ P₁)) := by have h := ldp_one_user_testing_minimax_exact hε le_rfl zero_le_one hP₀ hP₁ have hsimp : (Real.exp ε - 1 + 2 * (0 : ℝ)) / (Real.exp ε + 1) = (Real.exp ε - 1) / (Real.exp ε + 1) := by ring simpa only [hsimp] using h /-- **EXACT COINCIDENCE OF `1`-SUBSET SELECTION AND `k`-RR AT `k = 2`**: For binary alphabets `k = 2`, `1`-Subset Selection and `2`-RR achieve the identical exact MSE `(1 - ∑ p_i²) + 2 e^ε / (e^ε - 1)²` (and strictly beat Unary RAPPOR for every `ε > 0`)! -/ theorem subsetSel_k2_eq_kRR_mse {ε : ℝ} (hε : 0 < ε) {p : Fin 2 → ℝ} (hp : IsProbDist p) : perSampleMSE (subsetSelMech 2 1 ε) (subsetSelEst 2 1 ε) p = perSampleMSE (kRRMech 2 ε) (kRREst 2 ε) p ∧ perSampleMSE (kRRMech 2 ε) (kRREst 2 ε) p = (1 - ∑ i : Fin 2, p i ^ 2) + 2 * Real.exp ε / (Real.exp ε - 1) ^ 2 ∧ perSampleMSE (kRRMech 2 ε) (kRREst 2 ε) p < perSampleMSE (rapporMech 2 ε) (rapporEst 2 ε) p := by have he1 : 1 < Real.exp ε := Real.one_lt_exp_iff.mpr hε have hem1 : Real.exp ε - 1 ≠ 0 := ne_of_gt (by linarith) have hss := (subsetSel_mse_exact (k := 2) (s := 1) le_rfl (by decide) hε hp).2 have hkrr := (kRR_mse_exact (k := 2) le_rfl hε hp).2.2 have hlt := (kRR_vs_rappor_phase_transition (k := 2) le_rfl hε hp).2.1 (by decide) refine ⟨?_, ?_, hlt⟩ · rw [hss, hkrr] simp only [Nat.cast_ofNat, Nat.cast_one] have h1 : ((2 : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2 * (Real.exp ε ^ 2 / (2 - 1) + 1 / 1) - (2 - 1) = (2 - 1) * (2 * Real.exp ε + 2 - 2) / (Real.exp ε - 1) ^ 2 := by field_simp [hem1]; ring linarith · rw [hkrr] simp only [Nat.cast_ofNat] ring /-- **EXACT UNIFORM-DISTRIBUTION MSE OF `s`-SUBSET SELECTION & STRICT GAP OVER RAPPOR**: On the worst-case uniform distribution `u_i = 1 / k`, `s`-Subset Selection has exact closed-form MSE `(k - 1)/k + ((k - 1)² / (e^ε - 1)²) * (e^{2ε}/(k - s) + 1/s) - (k - 1)`, and optimal `s`-Subset Selection strictly beats Unary RAPPOR on the worst-case uniform prior! -/ theorem subsetSel_uniform_mse_and_beats_rappor {k : ℕ} (hk : 2 ≤ k) {ε : ℝ} (hε : 0 < ε) : let u : Fin k → ℝ := fun _ => 1 / (k : ℝ) (∀ s : ℕ, 1 ≤ s → s ≤ k - 1 → perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) u = ((k : ℝ) - 1) / (k : ℝ) + (((k : ℝ) - 1) ^ 2 / (Real.exp ε - 1) ^ 2) * (Real.exp ε ^ 2 / ((k : ℝ) - (s : ℝ)) + 1 / (s : ℝ)) - ((k : ℝ) - 1)) ∧ (∃ s : ℕ, 1 ≤ s ∧ s ≤ k - 1 ∧ perSampleMSE (subsetSelMech k s ε) (subsetSelEst k s ε) u < perSampleMSE (rapporMech k ε) (rapporEst k ε) u) := by intro u have hk_pos : (0 : ℝ) < (k : ℝ) := Nat.cast_pos.mpr (by omega) have hu : IsProbDist u := ⟨fun _ => by dsimp only [u]; positivity, by dsimp only [u] rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp [ne_of_gt hk_pos]⟩ refine ⟨fun s hs1 hsk => ?_, optimal_subsetSel_strictly_beats_rappor hk hε hu⟩ rw [(subsetSel_mse_exact hs1 hsk hε hu).2] have hsum : ∑ _i : Fin k, u _i ^ 2 = 1 / (k : ℝ) := by dsimp only [u] rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp [ne_of_gt hk_pos] rw [hsum] have h1 : 1 - 1 / (k : ℝ) = ((k : ℝ) - 1) / (k : ℝ) := by field_simp [ne_of_gt hk_pos] linarith end DifferentialPrivacyBlackwellMinimax /-! ============================================================================ PART 7: UNCOMMENTED `#print axioms` AUDIT OF ALL HEADLINE THEOREMS ============================================================================ -/ #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_nonneg #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_le_one #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_self #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_antitone #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_convex_gamma #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_one_eq_tvDist #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_eq_sup_event #print axioms DifferentialPrivacyBlackwellMinimax.hockeyStick_dpi #print axioms DifferentialPrivacyBlackwellMinimax.bhattCoeff_dpi #print axioms DifferentialPrivacyBlackwellMinimax.blackwellDom_hockeyStick_le #print axioms DifferentialPrivacyBlackwellMinimax.blackwellDom_tvDist_le #print axioms DifferentialPrivacyBlackwellMinimax.blackwellDom_bhattCoeff_ge #print axioms DifferentialPrivacyBlackwellMinimax.blackwellDom_fDiv_le #print axioms DifferentialPrivacyBlackwellMinimax.canonPair_hockeyStick_general #print axioms DifferentialPrivacyBlackwellMinimax.canonPair_isEpsDeltaClose #print axioms DifferentialPrivacyBlackwellMinimax.canonPair_tvDist_exact #print axioms DifferentialPrivacyBlackwellMinimax.canonPair_bhattCoeff_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_blackwell_dominance #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_max_tvDist_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_max_hockeyStick_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_min_bhattCoeff_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_tvDist_pure #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_bhattCoeff_pure #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_pure_fDiv_max_attained #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_chi2Div_pure_exact #print axioms DifferentialPrivacyBlackwellMinimax.blackwellDom_adaptive_comp #print axioms DifferentialPrivacyBlackwellMinimax.prodDistN_bhattCoeff #print axioms DifferentialPrivacyBlackwellMinimax.blackwellDom_kFold_adaptive_comp #print axioms DifferentialPrivacyBlackwellMinimax.canonPair_prod_hockeyStick_eq #print axioms DifferentialPrivacyBlackwellMinimax.kov_pure_composition_exact #print axioms DifferentialPrivacyBlackwellMinimax.kov_adaptive_composition_exact #print axioms DifferentialPrivacyBlackwellMinimax.kov_strictly_beats_basic_k2 #print axioms DifferentialPrivacyBlackwellMinimax.kov_strictly_beats_basic_k3 #print axioms DifferentialPrivacyBlackwellMinimax.kov_pure_delta_nonneg #print axioms DifferentialPrivacyBlackwellMinimax.kov_pure_delta_le_one #print axioms DifferentialPrivacyBlackwellMinimax.kov_pure_delta_i0_eq_zero #print axioms DifferentialPrivacyBlackwellMinimax.kov_adaptive_pure_basic_recovery #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_add_exact #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_remove_phase1 #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_remove_zero_phase #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_amplification_exact #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_strict_asymmetry #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_pure_dp_exact #print axioms DifferentialPrivacyBlackwellMinimax.poisson_subsampling_remove_zero_at_threshold #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_one_step_event_bound #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group_event_bound #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group_privacy_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group2_exact_closed_form #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group_vacuity_threshold_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group_vacuity_exponential_gain #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group_privacy_le_textbook #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group2_vacuity_exact #print axioms DifferentialPrivacyBlackwellMinimax.epsDelta_group3_vacuity_exact #print axioms DifferentialPrivacyBlackwellMinimax.ldp_tv_contraction_exact #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_tv_contraction_exact #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_chi2_capacity_exact #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_kl_mutual_info_le_log_cosh #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_kl_mutual_info_strictly_lt_eps #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_binary_chi2_contraction_exact #print axioms DifferentialPrivacyBlackwellMinimax.leCam_testRisk_exact #print axioms DifferentialPrivacyBlackwellMinimax.tvDist_le_sqrt_one_sub_bhattCoeff_sq #print axioms DifferentialPrivacyBlackwellMinimax.ldp_one_user_testing_minimax_exact #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_one_user_testing_minimax_exact #print axioms DifferentialPrivacyBlackwellMinimax.ldp_n_user_testing_lower_bound #print axioms DifferentialPrivacyBlackwellMinimax.pureLDP_n_user_sample_complexity_lower #print axioms DifferentialPrivacyBlackwellMinimax.subsetSelMech_isLDP #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_marginals_exact #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_mse_exact #print axioms DifferentialPrivacyBlackwellMinimax.kRR_mse_exact #print axioms DifferentialPrivacyBlackwellMinimax.rappor_mse_exact #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_worstCase_at_uniform #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_step_phase_transition #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_cauchy_schwarz_envelope #print axioms DifferentialPrivacyBlackwellMinimax.kRR_vs_rappor_phase_transition #print axioms DifferentialPrivacyBlackwellMinimax.optimal_subsetSel_strictly_beats_rappor #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_k2_eq_kRR_mse #print axioms DifferentialPrivacyBlackwellMinimax.subsetSel_uniform_mse_and_beats_rappor