Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.QuantumCodingSampling

Download original .lean · View on GitHub · Jump to source

Direct imports

  • Mathlib.Algebra.BigOperators.Ring.Finset dependency
  • Mathlib.Algebra.Order.BigOperators.Ring.Finset dependency
  • Mathlib.Tactic dependency

Imported by project modules

2 direct reverse imports

Relationships above come from literal import commands. The declarations below link to types and references extracted from Lean’s environment. Source text is complete and unchanged.

Declarations in this module

26 project constants, including generated, internal and private declarations.

26 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Mathlib.Algebra.BigOperators.Ring.Finset7import Mathlib.Algebra.Order.BigOperators.Ring.Finset8import Mathlib.Tactic910/-! # Finite independent random codebooks and their exact marginal averages -/1112noncomputable section13namespace Nonadditivity.QuantumCoding.Sampling14open scoped BigOperators1516variable {α J : Type*} [Fintype α] [Fintype J] [DecidableEq J]1718def weight (p : α → ℝ) (c : J → α) : ℝ := ∏ i, p (c i)1920def expect (p : α → ℝ) (f : (J → α) → ℝ) : ℝ := ∑ c, weight p c * f c2122omit [Fintype α] [DecidableEq J] in23theorem weight_nonneg (p : α → ℝ) (hp : ∀x, 0 ≤ p x) (c : J → α) :24    0 ≤ weight p c := Finset.prod_nonneg (fun i _ => hp (c i))2526theorem weight_sum (p : α → ℝ) (hsum : ∑x, p x = 1) :27    ∑ c : J → α, weight p c = 1 := by28  unfold weight29  rw [← Fintype.prod_sum]30  simp only [hsum, Finset.prod_const_one]3132theorem expect_const (p : α → ℝ) (hsum : ∑x, p x = 1) (r : ℝ) :33    expect p (fun _ : J → α => r) = r := by34  rw [expect, ← Finset.sum_mul, weight_sum p hsum, one_mul]3536theorem expect_add (p : α → ℝ) (f g : (J → α) → ℝ) :37    expect p (fun c => f c + g c) = expect p f + expect p g := by38  simp only [expect, mul_add, Finset.sum_add_distrib]3940theorem expect_sum {K : Type*} [Fintype K] (p : α → ℝ)41    (f : K → (J → α) → ℝ) : expect p (fun c => ∑ k, f k c) = ∑ k, expect p (f k) := by42  simp only [expect, Finset.mul_sum]43  exact Finset.sum_comm4445theorem expect_finset_sum {K : Type*} (p : α → ℝ) (s : Finset K)46    (f : K → (J → α) → ℝ) :47    expect p (fun c => ∑ k ∈ s, f k c) = ∑ k ∈ s, expect p (f k) := by48  simp only [expect, Finset.mul_sum]49  exact Finset.sum_comm5051theorem expect_mul_const (p : α → ℝ) (f : (J → α) → ℝ) (a : ℝ) :52    expect p (fun c => a * f c) = a * expect p f := by53  simp only [expect, Finset.mul_sum]54  congr 155  funext c56  ring5758theorem expect_mono (p : α → ℝ) (hp : ∀x, 0 ≤ p x)59    {f g : (J → α) → ℝ} (h : ∀c, f c ≤ g c) : expect p f ≤ expect p g :=60  Finset.sum_le_sum (fun c _ => mul_le_mul_of_nonneg_left (h c) (weight_nonneg p hp c))6162theorem expect_product (p : α → ℝ) (f : J → α → ℝ) :63    expect p (fun c => ∏ i, f i (c i)) = ∏ i, ∑x, p x * f i x := by64  simp only [expect, weight, ← Finset.prod_mul_distrib]65  exact (Fintype.prod_sum (fun i x => p x * f i x)).symm6667theorem expect_one (p : α → ℝ) (hsum : ∑x, p x = 1) (i : J) (f : α → ℝ) :68    expect p (fun c => f (c i)) = ∑x, p x * f x := by69  have h := expect_product p (fun j x => if j = i then f x else 1)70  simpa only [Fintype.prod_ite_eq', mul_ite, mul_one,71    Finset.sum_ite_irrel, hsum] using h7273theorem expect_two_product (p : α → ℝ) (hsum : ∑x, p x = 1)74    {i j : J} (hij : i ≠ j) (f g : α → ℝ) :75    expect p (fun c => f (c i) * g (c j)) =76      (∑x, p x * f x) * (∑y, p y * g y) := by77  have h := expect_product p78    (fun k x => (if k = i then f x else 1) * (if k = j then g x else 1))79  have hprod (c : J → α) :80      (∏ k, (if k = i then f (c k) else 1) * (if k = j then g (c k) else 1)) =81        f (c i) * g (c j) := by82    rw [Finset.prod_mul_distrib, Fintype.prod_ite_eq', Fintype.prod_ite_eq']83  have hsum' (k : J) :84      (∑x, p x * ((if k = i then f x else 1) * (if k = j then g x else 1))) =85        (if k = i then ∑x, p x * f x else 1) *86        (if k = j then ∑x, p x * g x else 1) := by87    by_cases hi : k=i88    · subst k89      simp only [ite_true, if_neg hij, mul_one]90    · by_cases hj : k=j91      · subst k92        simp only [if_neg hi, ite_true, one_mul]93      · simp only [if_neg hi, if_neg hj, mul_one, hsum]94  simp_rw [hprod, hsum'] at h95  simpa only [Finset.prod_mul_distrib, Fintype.prod_ite_eq'] using h9697theorem expect_two (p : α → ℝ) (hsum : ∑x, p x = 1)98    {i j : J} (hij : i ≠ j) (f : α → α → ℝ) :99    expect p (fun c => f (c i) (c j)) = ∑x, ∑y, p x * p y * f x y := by100  classical101  have hexp (c : J → α) : f (c i) (c j) =102      ∑x, ∑y, f x y * ((if c i = x then 1 else 0) * (if c j = y then 1 else 0)) := by103    simp104  simp_rw [hexp]105  rw [expect_sum]106  apply Finset.sum_congr rfl107  intro x _108  rw [expect_sum]109  apply Finset.sum_congr rfl110  intro y _111  rw [expect_mul_const, expect_two_product p hsum hij112    (fun z => if z=x then 1 else 0) (fun z => if z=y then 1 else 0)]113  simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, if_true]114  ring115116/-- A finite probability average has at least one outcome no larger than it. -/117theorem exists_le_expect (p : α → ℝ) (hp : ∀x, 0 ≤ p x) (hsum : ∑x, p x = 1)118    (f : (J → α) → ℝ) : ∃c, f c ≤ expect p f := by119  classical120  by_contra h121  push_neg at h122  have hnonempty : Nonempty (J → α) := by123    have hs := weight_sum (J := J) p hsum124    by_contra hne125    letI : IsEmpty (J → α) := not_nonempty_iff.mp hne126    simp at hs127  letI := hnonempty128  obtain ⟨c, hcmem, hc⟩ := Finset.exists_lt_of_sum_lt129    (show (∑ _c : J → α, (0 : ℝ)) < ∑ c : J → α, weight p c by130      rw [weight_sum p hsum]; simp)131  have hs : expect p f < expect p f := by132    calc133      expect p f = ∑ c : J → α, weight p c * expect p f := by134        rw [← Finset.sum_mul, weight_sum p hsum, one_mul]135      _ < ∑ c, weight p c * f c := by136        apply Finset.sum_lt_sum137        · intro a _138          exact mul_le_mul_of_nonneg_left (h a).le (weight_nonneg p hp a)139        · exact ⟨c, hcmem, mul_lt_mul_of_pos_left (h c) hc⟩140      _ = expect p f := rfl141  exact (lt_irrefl _) hs142143/-- The explicit three-term cost of an independently sampled finite codebook. -/144def codebookCost {M : ℕ} (f g : α → ℝ) (cross : α → α → ℝ) (c : Fin M → α) : ℝ :=145  (M : ℝ)⁻¹ * ∑ i, (9*f (c i) + 8*g (c i) +146    4*∑ j ∈ Finset.univ.erase i, cross (c i) (c j))147148theorem expect_codebookCost_le (p : α → ℝ) (hsum : ∑x, p x = 1)149    {M : ℕ} (hM : 0 < M) (f g : α → ℝ) (cross : α → α → ℝ)150    {εf εg β : ℝ} (hf : ∑x, p x * f x ≤ εf) (hg : ∑x, p x * g x ≤ εg)151    (hc : ∑x, ∑y, p x * p y * cross x y ≤ β) :152    expect p (codebookCost (M := M) f g cross) ≤ 9*εf+8*εg+4*(M-1:ℕ)*β := by153  have hlocal (i : Fin M) :154      expect p (fun c : Fin M → α => 9*f (c i)+8*g (c i)+155        4*∑ j ∈ Finset.univ.erase i, cross (c i) (c j)) ≤ 9*εf+8*εg+4*(M-1:ℕ)*β := by156    rw [expect_add, expect_add, expect_mul_const, expect_mul_const, expect_mul_const,157      expect_one p hsum, expect_one p hsum, expect_finset_sum]158    have hcross : (∑ j ∈ Finset.univ.erase i,159        expect p (fun c : Fin M → α => cross (c i) (c j))) ≤ (M-1:ℕ)*β := by160      calc161        _ ≤ ∑ j ∈ Finset.univ.erase i, β := by162          apply Finset.sum_le_sum163          intro j hj164          rw [expect_two p hsum (Ne.symm (Finset.mem_erase.mp hj).1) cross]165          exact hc166        _ = (M-1:ℕ)*β := by simp167    linarith168  unfold codebookCost169  rw [expect_mul_const, expect_sum]170  have hs := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hlocal i)171  have hm : (M : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hM)172  calc173    _ ≤ (M : ℝ)⁻¹ * ∑ _i : Fin M, (9*εf+8*εg+4*(M-1:ℕ)*β) :=174      mul_le_mul_of_nonneg_left hs (inv_nonneg.mpr (Nat.cast_nonneg _))175    _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin,176      nsmul_eq_mul]; rw [← mul_assoc, inv_mul_cancel₀ hm, one_mul]177178theorem exists_codebook_cost_le (p : α → ℝ) (hp : ∀x, 0 ≤ p x) (hsum : ∑x, p x = 1)179    {M : ℕ} (hM : 0 < M) (f g : α → ℝ) (cross : α → α → ℝ)180    {εf εg β : ℝ} (hf : ∑x, p x * f x ≤ εf) (hg : ∑x, p x * g x ≤ εg)181    (hc : ∑x, ∑y, p x * p y * cross x y ≤ β) :182    ∃c : Fin M → α, codebookCost f g cross c ≤ 9*εf+8*εg+4*(M-1:ℕ)*β := by183  obtain ⟨c, hc⟩ := exists_le_expect p hp hsum (codebookCost (M := M) f g cross)184  exact ⟨c, hc.trans (expect_codebookCost_le p hsum hM f g cross hf hg ‹_›)⟩185186end Nonadditivity.QuantumCoding.Sampling