Pratik Patil

BinarySplitting.lean

1module23public import SubentropyCertificates.FourCell4public import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset5import Mathlib.Tactic.GCongr6import Mathlib.Tactic.Linarith7import Mathlib.Tactic.Positivity8import Mathlib.Tactic.Ring910/-! Binary splitting of reciprocal products and its strict form. -/11@[expose] public section12noncomputable section13open scoped BigOperators14namespace SubentropyCertificates.ClassicalSSA15open SubentropyCertificates.FourCell16variable {I : Type*}1718def factor (t x : ℝ) : ℝ := (1+x*t)⁻¹1920@[simp]21theorem factor_zero (t : ℝ) : factor t 0 = 1 := by simp [factor]2223theorem factor_pos {t x : ℝ} (ht : 0 ≤ t) (hx : 0 ≤ x) : 0 < factor t x := by24  unfold factor; positivity2526private theorem factor_pair {t x y : ℝ} (ht : 0 ≤ t) (hx : 0 ≤ x) (hy : 0 ≤ y) :27    factor t x * factor t y ≤ factor t (x+y) := by28  unfold factor29  rw [← mul_inv]30  apply inv_anti₀ (by positivity)31  nlinarith only [mul_nonneg (mul_nonneg hx hy) (sq_nonneg t)]3233theorem refinement {t : ℝ} (ht : 0 ≤ t) (s : Finset I) (x : I → ℝ) (hx : ∀ i, 0 ≤ x i) :34    ∏ i ∈ s, factor t (x i) ≤ factor t (∑ i ∈ s, x i) := by35  classical36  induction s using Finset.induction_on with37  | empty => simp38  | @insert i s hi ih =>39    rw [Finset.prod_insert hi, Finset.sum_insert hi]40    exact (mul_le_mul_of_nonneg_left ih (factor_pos ht (hx i)).le).trans41      (factor_pair ht (hx i) (Finset.sum_nonneg fun j _ => hx j))4243/-- Before using the four-cell inequality, collapse the old indices to a44single pair of masses X,Y and keep the new pair x,y separate. -/45private theorem collapse_previous {A B X Y x y t : ℝ} (ht : 0 ≤ t)46    (hx : 0 ≤ x) (hy : 0 ≤ y)47    (ih : A-B ≤ factor t (X+Y) - factor t X * factor t Y)48    (hB : B ≤ factor t X * factor t Y) :49    factor t (x+y)*A - (factor t x*factor t y)*B ≤50      factor t (x+y)*factor t (X+Y) - (factor t x*factor t y)*(factor t X*factor t Y) := by51  linarith only [mul_le_mul_of_nonneg_left ih (factor_pos ht (add_nonneg hx hy)).le,52    mul_le_mul_of_nonneg_left hB (sub_nonneg.mpr (factor_pair ht hx hy))]5354private theorem four_cell_factors {x y X Y t : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y)55    (hX : 0 ≤ X) (hY : 0 ≤ Y) (ht : 0 ≤ t) :56    factor t (x+y)*factor t (X+Y) - (factor t x*factor t y)*(factor t X*factor t Y) ≤57      factor t ((x+X)+(y+Y)) - factor t (x+X)*factor t (y+Y) := by58  have h := four_cell x y X Y t hx hy hX hY ht59  simp only [rowKernel, columnKernel, cellKernel, totalKernel, one_div, mul_inv] at h60  unfold factor61  rw [show (x+X)+(y+Y) = x+y+X+Y by ring, mul_comm (x+y+X+Y) t]62  linarith only [h]6364/-- Binary splitting (lem:split), with the parameter t absorbed into65each factor. Taking t=1 gives the manuscript's displayed formula. -/66theorem binary_splitting {t : ℝ} (ht : 0 ≤ t) (s : Finset I) (x y : I → ℝ)67    (hx : ∀ i, 0 ≤ x i) (hy : ∀ i, 0 ≤ y i) :68    (∏ i ∈ s, factor t (x i+y i)) - (∏ i ∈ s, factor t (x i))*(∏ i ∈ s, factor t (y i)) ≤69      factor t ((∑ i ∈ s, x i)+(∑ i ∈ s, y i)) -70        factor t (∑ i ∈ s, x i)*factor t (∑ i ∈ s, y i) := by71  classical72  induction s using Finset.induction_on with73  | empty => simp74  | @insert i s hi ih =>75    simp only [Finset.prod_insert hi, Finset.sum_insert hi]76    rw [mul_mul_mul_comm (factor t (x i)) _ (factor t (y i))]77    have hB := mul_le_mul (refinement ht s x hx) (refinement ht s y hy)78      (Finset.prod_nonneg fun j _ => (factor_pos ht (hy j)).le)79      (factor_pos ht (Finset.sum_nonneg fun j _ => hx j)).le80    exact (collapse_previous ht (hx i) (hy i) ih hB).trans81      (four_cell_factors (hx i) (hy i) (Finset.sum_nonneg fun j _ => hx j)82        (Finset.sum_nonneg fun j _ => hy j) ht)8384/-- Strict splitting when both column totals are positive and two85different rows have positive mass. -/86theorem binary_splitting_strict {t : ℝ} (ht : 0 < t) (s : Finset I) (x y : I → ℝ)87    (hx : ∀ i, 0 ≤ x i) (hy : ∀ i, 0 ≤ y i)88    (hX : 0 < ∑ i ∈ s, x i) (hY : 0 < ∑ i ∈ s, y i)89    {i j : I} (hi : i ∈ s) (hj : j ∈ s) (hne : j ≠ i)90    (hpi : 0 < x i+y i) (hpj : 0 < x j+y j) :91    (∏ k ∈ s, factor t (x k+y k)) - (∏ k ∈ s, factor t (x k))*(∏ k ∈ s, factor t (y k)) <92      factor t ((∑ k ∈ s, x k)+(∑ k ∈ s, y k)) -93        factor t (∑ k ∈ s, x k)*factor t (∑ k ∈ s, y k) := by94  classical95  let r := s.erase i96  have hir : i ∉ r := Finset.notMem_erase i s97  have he : s = insert i r := (Finset.insert_erase hi).symm98  let X := ∑ k ∈ r, x k99  let Y := ∑ k ∈ r, y k100  have hnX : 0 ≤ X := Finset.sum_nonneg fun k _ => hx k101  have hnY : 0 ≤ Y := Finset.sum_nonneg fun k _ => hy k102  have hjr : j ∈ r := Finset.mem_erase.mpr ⟨hne,hj⟩103  have hXY : 0 < X+Y := by104    linarith only [hpj, Finset.single_le_sum (fun k (_ : k ∈ r) => hx k) hjr,105      Finset.single_le_sum (fun k (_ : k ∈ r) => hy k) hjr]106  rw [he, Finset.sum_insert hir] at hX hY107  rw [he]108  simp only [Finset.prod_insert hir, Finset.sum_insert hir]109  rw [mul_mul_mul_comm (factor t (x i)) _ (factor t (y i))]110  have hB := mul_le_mul (refinement ht.le r x hx) (refinement ht.le r y hy)111    (Finset.prod_nonneg fun k _ => (factor_pos ht.le (hy k)).le) (factor_pos ht.le hnX).le112  apply lt_of_le_of_lt (collapse_previous ht.le (hx i) (hy i) (binary_splitting ht.le r x y hx hy) hB)113  have hf := (four_cell_strict_iff (x i) (y i) X Y t (hx i) (hy i) hnX hnY ht).mpr114    ⟨hpi,hXY,hX,hY⟩115  simp only [rowKernel, columnKernel, cellKernel, totalKernel, one_div, mul_inv] at hf116  change factor t (x i+y i)*factor t (X+Y) - _ < factor t ((x i+X)+(y i+Y)) - _117  unfold factor118  rw [show (x i+X)+(y i+Y) = x i+y i+X+Y by ring, mul_comm (x i+y i+X+Y) t]119  linarith only [hf]120121/-- Two distinct positive entries in the indicated marginal. -/122def varies (s : Finset I) (x : I → ℝ) : Prop :=123  ∃ i ∈ s, ∃ j ∈ s, j ≠ i ∧ 0 < x i ∧ 0 < x j124125theorem refinement_eq_iff {t : ℝ} (ht : 0 < t) (s : Finset I) (x : I → ℝ) (hx : ∀ i, 0 ≤ x i) :126    (∏ i ∈ s, factor t (x i)) = factor t (∑ i ∈ s, x i) ↔ ¬ varies s x := by127  classical128  constructor129  · rintro he ⟨i, hi, j, hj, hji, hxi, hxj⟩130    let r := s.erase i131    have hir : i ∉ r := Finset.notMem_erase i s132    have heq : s = insert i r := (Finset.insert_erase hi).symm133    have hxr : 0 < ∑ k ∈ r, x k := hxj.trans_le (Finset.single_le_sum134      (fun k (_ : k ∈ r) => hx k) (Finset.mem_erase.mpr ⟨hji,hj⟩))135    rw [heq, Finset.prod_insert hir, Finset.sum_insert hir] at he136    apply ne_of_lt _ he137    apply lt_of_le_of_lt (mul_le_mul_of_nonneg_left (refinement ht.le r x hx) (factor_pos ht.le hxi.le).le)138    unfold factor139    rw [← mul_inv]140    apply inv_strictAnti₀ (by positivity)141    nlinarith only [mul_pos (mul_pos hxi hxr) (sq_pos_of_pos ht)]142  · intro h143    by_cases hex : ∃ i ∈ s, 0 < x i144    · obtain ⟨i,hi,hxi⟩ := hex145      have hz (j) (hj : j ∈ s) (hji : j ≠ i) : x j = 0 := by146        by_contra h0147        exact h ⟨i,hi,j,hj,hji,hxi,lt_of_le_of_ne (hx j) (Ne.symm h0)⟩148      rw [Finset.sum_eq_single_of_mem i hi hz, Finset.prod_eq_single_of_mem i hi]149      intro j hj hji150      simp [hz j hj hji]151    · have hz (j) (hj : j ∈ s) : x j = 0 := le_antisymm152        (le_of_not_gt (fun h => hex ⟨j,hj,h⟩)) (hx j)153      rw [Finset.sum_eq_zero hz, Finset.prod_eq_one (fun j hj => by simp [hz j hj]), factor_zero]154155end SubentropyCertificates.ClassicalSSA

Axioms used

Choose a statement to see which axioms its proof uses.