module public import SubentropyCertificates.ClassicalStrongSubadditivity public import Mathlib.Analysis.Complex.ExponentialBounds import all SubentropyCertificates.ClassicalStrongSubadditivity import all SubentropyCertificates.CounterexampleIntegral /-! The alternating deterministic slices after Theorem 22. -/ @[expose] public section noncomputable section set_option maxHeartbeats 1500000 set_option backward.isDefEq.respectTransparency false open MeasureTheory Set open scoped BigOperators namespace SubentropyCertificates.SSAExamples open SubentropyCertificates.ClassicalSSA open SubentropyCertificates.ClassicalCurve open SubentropyCertificates.QuantumCounterexample open D5.S3.Quantum.Subentropy.UniformIntegrals /-- With B=0, A=0 and C is uniform. With B=1, C=0 and A is uniform. -/ def alternating (u : Fin 2 × Fin 2 × Fin 2) : ℝ := if (u.2.1 = 0 ∧ u.1 = 0) ∨ (u.2.1 = 1 ∧ u.2.2 = 0) then 1/4 else 0 /-- The joint mass is normalized and its two slices factor conditionally on B. -/ theorem alternating_probability : alternating ∈ probabilitySimplex _ ∧ ∀ i j k, alternating (i,j,k) * marginalB alternating j = marginalAB alternating (i,j) * marginalBC alternating (j,k) := by constructor · constructor · intro u unfold alternating split <;> norm_num · norm_num [alternating, Fintype.sum_prod_type, Fin.sum_univ_two] · intro i j k fin_cases i <;> fin_cases j <;> fin_cases k <;> norm_num [alternating, marginalB, marginalAB, marginalBC, Fin.sum_univ_two] private def sliceGap (t : ℝ) := ((1+t/2)⁻¹ - ((1+t/4)⁻¹)^2)^2 /-- The full reciprocal determinant difference is the square displayed after Theorem 22. -/ theorem alternating_kernel (t : ℝ) : kernel t alternating + kernel t (marginalB alternating) - kernel t (marginalAB alternating) - kernel t (marginalBC alternating) = ((1+t/2)⁻¹ - ((1+t/4)⁻¹)^2)^2 := by norm_num [kernel, factor, alternating, marginalB, marginalAB, marginalBC, Fintype.prod_prod_type, Fin.prod_univ_two, Fin.sum_univ_two] ring_nf rw [show 1 + t * (1/2) + t^2 * (1/16) = (1 + t * (1/4))^2 by ring, ← inv_pow] ring theorem alternating_kernel_pos {t : ℝ} (ht : 0 < t) : 0 < ((1+t/2)⁻¹ - ((1+t/4)⁻¹)^2)^2 := by apply sq_pos_of_pos rw [inv_pow] apply sub_pos.mpr exact (inv_lt_inv₀ (by positivity) (by positivity)).2 (by nlinarith [sq_pos_of_pos ht]) private def sliceExpansion (s : ℝ) := -3 * diff (1/4) (1/2) s + 1/4 * sqInv (1/2) s + 1/2 * sqInv (1/4) s + (-1/16) * (1/(s+1/4)^3) + 1/256 * (1/(s+1/4)^4) private theorem slice_partial_fractions (s : ℝ) (hs : 0 < s) : sliceGap s⁻¹ = sliceExpansion s := by have h₁ : 0 < s+1/2 := by linarith have h₂ : 0 < s+1/4 := by linarith have hshift (a : ℝ) : 1 + s⁻¹*a = (s+a)/s := by field_simp unfold sliceGap sliceExpansion diff sqInv rw [show s⁻¹/2 = s⁻¹*(1/2) by ring, show s⁻¹/4 = s⁻¹*(1/4) by ring, hshift, hshift] simp only [inv_div] field_simp [hs.ne', h₁.ne', h₂.ne'] ring private theorem integral_slice : (∫ s in Ioi (0 : ℝ), sliceGap s⁻¹) = 25/12 - 3*Real.log 2 := by have h₃ : Evaluates (fun s : ℝ ↦ 1/(s+1/4)^3) (1/(2*(1/4)^2)) := by have h := inverse_power (1/4) (by norm_num) 1 norm_num [Evaluates] at h ⊢ exact h have h₄ : Evaluates (fun s : ℝ ↦ 1/(s+1/4)^4) (1/(3*(1/4)^3)) := by have h := inverse_power (1/4) (by norm_num) 2 norm_num [Evaluates] at h ⊢ exact h have ev := eval_add (eval_add (eval_add (eval_add (eval_scale (-3) (eval_diff (1/4) (1/2) (by norm_num) (by norm_num))) (eval_scale (1/4) (eval_sq (1/2) (by norm_num)))) (eval_scale (1/2) (eval_sq (1/4) (by norm_num)))) (eval_scale (-1/16) h₃)) (eval_scale (1/256) h₄) rw [setIntegral_congr_fun measurableSet_Ioi (fun s hs ↦ slice_partial_fractions s hs)] change (∫ s in Ioi (0 : ℝ), sliceExpansion s) = _ rw [show (∫ s in Ioi (0 : ℝ), sliceExpansion s) = _ from ev.2] rw [Real.log_div (by norm_num) (by norm_num), Real.log_div (by norm_num) (by norm_num), Real.log_one, show Real.log 4 = 2 * Real.log 2 by have h := Real.log_pow (2 : ℝ) 2 norm_num at h exact h] ring /-- The actual subentropy deficit of the conditionally independent triple is positive. -/ theorem alternating_subentropy_deficit : classicalSubentropy (marginalAB alternating) + classicalSubentropy (marginalBC alternating) - classicalSubentropy (marginalB alternating) - classicalSubentropy alternating = 25/12 - 3*Real.log 2 ∧ 0 < 25/12 - 3*Real.log 2 := by refine ⟨?_, by linarith [Real.log_two_lt_d9]⟩ have hpos {D : Type} [Fintype D] [DecidableEq D] (p : D → ℝ) (hp : p ∈ probabilitySimplex _) := kernel_integrable hp have hab : marginalAB alternating ∈ probabilitySimplex _ := by constructor · intro ⟨i,j⟩ exact Finset.sum_nonneg (fun k _ ↦ alternating_probability.1.1 (i,j,k)) · norm_num [marginalAB, alternating, Fintype.sum_prod_type, Fin.sum_univ_two] have hbc : marginalBC alternating ∈ probabilitySimplex _ := by constructor · intro ⟨j,k⟩ exact Finset.sum_nonneg (fun i _ ↦ alternating_probability.1.1 (i,j,k)) · norm_num [marginalBC, alternating, Fintype.sum_prod_type, Fin.sum_univ_two] have hb : marginalB alternating ∈ probabilitySimplex _ := by constructor · intro j exact Finset.sum_nonneg (fun i _ ↦ Finset.sum_nonneg (fun k _ ↦ alternating_probability.1.1 (i,j,k))) · norm_num [marginalB, alternating, Fin.sum_univ_two] rw [← integral_slice] let I {D : Type} [Fintype D] [DecidableEq D] (p : D → ℝ) := (∫ s in Ioi (0 : ℝ), densityKernel p s) change I (marginalAB alternating) + I (marginalBC alternating) - I (marginalB alternating) - I alternating = _ unfold I rw [← integral_add (hpos _ hab) (hpos _ hbc), ← integral_sub (f := fun s ↦ densityKernel (marginalAB alternating) s + densityKernel (marginalBC alternating) s) ((hpos _ hab).add (hpos _ hbc)) (hpos _ hb), ← integral_sub (f := fun s ↦ densityKernel (marginalAB alternating) s + densityKernel (marginalBC alternating) s - densityKernel (marginalB alternating) s) (((hpos _ hab).add (hpos _ hbc)).sub (hpos _ hb)) (hpos _ alternating_probability.1)] apply setIntegral_congr_fun measurableSet_Ioi intro s hs simp only [kernel_identity _ hs] unfold sliceGap linarith only [alternating_kernel s⁻¹] end SubentropyCertificates.SSAExamples