Pratik Patil

SliceProducts.lean

1module23public import SubentropyCertificates.TableMerging4import Mathlib.Tactic.Linarith5import Mathlib.Tactic.Ring67/-! Combining the reciprocal products over the middle label. The four8nonnegative terms in the product identity correspond to the four outcomes9of the auxiliary event construction in the manuscript. -/10@[expose] public section11noncomputable section12open scoped BigOperators13namespace SubentropyCertificates.ClassicalSSA1415private structure Comparison (x y a d : ℝ) : Prop where16  pos : 0 < a17  ax : a ≤ x18  ay : a ≤ y19  xd : x ≤ d20  yd : y ≤ d21  le : x+y ≤ a+d22  rigid : x+y = a+d → x=d ∨ y=d2324private theorem Comparison.eq_iff {x y a d : ℝ} (h : Comparison x y a d) :25    x+y = a+d ↔ x=d ∨ y=d := by26  refine ⟨h.rigid, ?_⟩27  rintro (hx | hy)28  · linarith only [hx, h.le, h.ay]29  · linarith only [hy, h.le, h.ax]3031private theorem Comparison.mul {x y a d X Y A D : ℝ}32    (h : Comparison x y a d) (H : Comparison X Y A D) :33    Comparison (x*X) (y*Y) (a*A) (d*D) := by34  have hd := (h.pos.trans_le h.ax).trans_le h.xd35  have hD := (H.pos.trans_le H.ax).trans_le H.xd36  have h₁ := mul_nonneg h.pos.le (sub_nonneg.mpr H.le)37  have h₂ := mul_nonneg (sub_nonneg.mpr h.ax) (sub_nonneg.mpr H.xd)38  have h₃ := mul_nonneg (sub_nonneg.mpr h.ay) (sub_nonneg.mpr H.yd)39  have h₄ := mul_nonneg (sub_nonneg.mpr h.le) hD.le40  refine ⟨mul_pos h.pos H.pos,41    mul_le_mul h.ax H.ax H.pos.le (h.pos.trans_le h.ax).le,42    mul_le_mul h.ay H.ay H.pos.le (h.pos.trans_le h.ay).le,43    mul_le_mul h.xd H.xd (H.pos.trans_le H.ax).le hd.le,44    mul_le_mul h.yd H.yd (H.pos.trans_le H.ay).le hd.le, ?_, ?_⟩45  · linarith only [h₁,h₂,h₃,h₄]46  · intro he47    have z₁ : a*(A+D-(X+Y)) = 0 := by linarith only [he,h₁,h₂,h₃,h₄]48    have z₄ : (a+d-(x+y))*D = 0 := by linarith only [he,h₁,h₂,h₃,h₄]49    have z₂ : (x-a)*(D-X) = 0 := by linarith only [he,h₁,h₂,h₃,h₄]50    have z₃ : (y-a)*(D-Y) = 0 := by linarith only [he,h₁,h₂,h₃,h₄]51    have e := h.rigid (sub_eq_zero.mp ((mul_eq_zero.mp z₄).resolve_right hD.ne')).symm52    have E := H.rigid (sub_eq_zero.mp ((mul_eq_zero.mp z₁).resolve_left h.pos.ne')).symm53    rcases e with e | e <;> rcases E with E | E54    · exact Or.inl (by rw [e,E])55    · rcases mul_eq_zero.mp z₂ with u | v56      · right; rw [E]; have := sub_eq_zero.mp u; rw [show y=d by linarith only [e,this,h.ay,h.yd]]57      · left; rw [e, sub_eq_zero.mp v]58    · rcases mul_eq_zero.mp z₃ with u | v59      · left; rw [E]; have := sub_eq_zero.mp u; rw [show x=d by linarith only [e,this,h.ax,h.xd]]60      · right; rw [e, sub_eq_zero.mp v]61    · exact Or.inr (by rw [e,E])6263private theorem comparison_prod {B : Type*} (s : Finset B) {x y a d : B → ℝ}64    (hs : ∀ j, Comparison (x j) (y j) (a j) (d j)) :65    Comparison (∏ j ∈ s, x j) (∏ j ∈ s, y j) (∏ j ∈ s, a j) (∏ j ∈ s, d j) := by66  classical67  induction s using Finset.induction_on with68  | empty => simpa using (show Comparison 1 1 1 1 from ⟨zero_lt_one, le_rfl, le_rfl,69      le_rfl, le_rfl, le_rfl, fun _ => Or.inl rfl⟩)70  | @insert j s hj ih =>71    simpa only [Finset.prod_insert hj] using (hs j).mul ih7273private theorem prod_eq_all {B : Type*} [Fintype B] (x d : B → ℝ) (hx : ∀ j, 0 < x j)74    (hd : ∀ j, x j ≤ d j) : (∏ j, x j) = ∏ j, d j ↔ ∀ j, x j = d j := by75  constructor76  · intro he j77    by_contra hn78    exact (Finset.prod_lt_prod₀ (fun k _ => hx k) (fun k _ => hd k)79      ⟨j, Finset.mem_univ j, lt_of_le_of_ne (hd j) hn⟩).ne he80  · intro he; rw [funext he]8182variable {I B J : Type*} [Fintype I] [Fintype B] [Fintype J]8384private theorem slice_comparison {t : ℝ} (ht : 0 < t) (p : I → J → ℝ)85    (hp : ∀ i j, 0 ≤ p i j) :86    Comparison (rows t Finset.univ p) (cols t Finset.univ p)87      (cells t Finset.univ p) (factor t (mass Finset.univ p)) := by88  let s : Finset I := Finset.univ89  have hx := refinement ht.le s (rowMass p) (row_nonneg hp)90  have hy := refinement ht.le Finset.univ (colMass s p) (col_nonneg hp s)91  rw [sum_colMass] at hy92  refine ⟨Finset.prod_pos (fun i _ => kernel_pos ht.le (hp i)), ?_, ?_, hx, hy,93    table_subadditivity ht.le s p hp, ?_⟩94  · exact Finset.prod_le_prod₀ (fun i _ => (kernel_pos ht.le (hp i)).le)95      (fun i _ => refinement ht.le Finset.univ _ (hp i))96  · unfold cells cols kernel97    rw [Finset.prod_comm]98    exact Finset.prod_le_prod₀ (fun j _ => (Finset.prod_pos fun i _ => factor_pos ht.le (hp i j)).le)99      (fun j _ => refinement ht.le _ _ (fun i => hp i j))100  · intro he101    by_contra! hn102    have hrow : varies s (rowMass p) := by103      by_contra hn'104      exact hn.1 ((refinement_eq_iff ht s (rowMass p) (row_nonneg hp)).mpr hn')105    have hcol : varies Finset.univ (colMass s p) := by106      by_contra hn'107      have eq := (refinement_eq_iff ht Finset.univ _ (col_nonneg hp s)).mpr hn'108      rw [sum_colMass] at eq109      exact hn.2 eq110    exact (table_subadditivity_strict ht s p hp hrow hcol).ne he111112/-- The two-variable comparison is an equality at positive t exactly when113there is at most one positive row or at most one positive column. -/114theorem table_subadditivity_eq_iff {t : ℝ} (ht : 0 < t) (p : I → J → ℝ)115    (hp : ∀ i j, 0 ≤ p i j) :116    rows t Finset.univ p + cols t Finset.univ p = cells t Finset.univ p + factor t (mass Finset.univ p) ↔117      ¬ varies Finset.univ (rowMass p) ∨ ¬ varies Finset.univ (colMass Finset.univ p) := by118  rw [(slice_comparison ht p hp).eq_iff]119  apply or_congr (refinement_eq_iff ht _ _ (row_nonneg hp))120  have h := refinement_eq_iff ht Finset.univ _ (col_nonneg hp Finset.univ)121  rw [sum_colMass] at h122  exact h123124/-- Equality for the slice products requires the same marginal to be125concentrated in every slice. Zero slices satisfy both alternatives. -/126theorem slice_product_comparison {t : ℝ} (ht : 0 < t) (p : B → I → J → ℝ)127    (hp : ∀ b i j, 0 ≤ p b i j) :128    let s : Finset I := Finset.univ129    let x := fun b => rows t s (p b)130    let y := fun b => cols t s (p b)131    let a := fun b => cells t s (p b)132    let d := fun b => factor t (mass s (p b))133    ((∏ b, x b) + (∏ b, y b) ≤ (∏ b, a b) + ∏ b, d b) ∧134    (((∏ b, x b) + (∏ b, y b) = (∏ b, a b) + ∏ b, d b) ↔135      (∀ b, ¬ varies s (rowMass (p b))) ∨ (∀ b, ¬ varies Finset.univ (colMass s (p b)))) := by136  dsimp only137  have h := fun b => slice_comparison ht (p b) (hp b)138  have H := comparison_prod Finset.univ h139  refine ⟨H.le, H.eq_iff.trans ?_⟩140  rw [prod_eq_all _ _ (fun b => (h b).pos.trans_le (h b).ax) (fun b => (h b).xd),141    prod_eq_all _ _ (fun b => (h b).pos.trans_le (h b).ay) (fun b => (h b).yd)]142  apply or_congr143  · exact forall_congr' (fun b => refinement_eq_iff ht _ _ (row_nonneg (hp b)))144  · apply forall_congr'145    intro b146    have eq := refinement_eq_iff ht Finset.univ _ (col_nonneg (hp b) Finset.univ)147    rw [sum_colMass] at eq148    exact eq149150end SubentropyCertificates.ClassicalSSA

Axioms used

Choose a statement to see which axioms its proof uses.