Pratik Patil

AncillaLogRemainder.lean

1module23public import SubentropyCertificates.AncillaReplicatedFactor45/-! A finite-dimension error estimate for the logarithm expansion in Appendix C. -/6@[expose] public section7noncomputable section8open Set9open scoped BigOperators1011namespace SubentropyCertificates.AncillaLimit1213private theorem nonneg_from_zero {f d : ℝ → ℝ} (h0 : f 0 = 0)14    (hd : ∀ x, 0 ≤ x → HasDerivAt f (d x) x) (hpos : ∀ x, 0 ≤ x → 0 ≤ d x)15    {u : ℝ} (hu : 0 ≤ u) : 0 ≤ f u := by16  have hm : MonotoneOn f (Ici 0) := monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ici _)17    (fun x hx ↦ (hd x hx).continuousAt.continuousWithinAt)18    (fun x hx ↦ (hd x (interior_subset hx)).hasDerivWithinAt)19    (fun x hx ↦ hpos x (interior_subset hx))20  simpa only [h0] using hm (le_refl 0 : (0 : ℝ) ∈ Ici 0) hu hu2122private theorem log_quadratic_error {u : ℝ} (hu : 0 ≤ u) :23    0 ≤ Real.log (1+u) - u + u^2/2 ∧ Real.log (1+u) - u + u^2/2 ≤ u^3/3 := by24  let R := fun x : ℝ ↦ Real.log (1+x) - x + x^2/225  have hR (x : ℝ) (hx : 0 ≤ x) : HasDerivAt R (x^2/(1+x)) x := by26    have hn : 0 < 1+x := by linarith27    have hlog := ((hasDerivAt_id x).const_add 1).log hn.ne'28    apply ((hlog.sub (hasDerivAt_id x)).add ((hasDerivAt_pow 2 x).div_const 2)).congr_deriv29    simp only [id_eq]30    field_simp31    ring32  have hbase : R 0 = 0 := by simp [R]33  refine ⟨nonneg_from_zero hbase hR (fun x hx ↦ by positivity) hu, ?_⟩34  apply sub_nonneg.mp35  apply nonneg_from_zero (f := fun x ↦ x^3/3 - R x) (d := fun x ↦ x^3/(1+x)) (by simp [hbase]) _ _ hu36  · intro x hx37    have hn : 0 < 1+x := by linarith38    apply (((hasDerivAt_pow 3 x).div_const 3).sub (hR x hx)).congr_deriv39    field_simp40    ring41  · intro x hx42    positivity4344/-- For every ancillary dimension K=k+1 and every t≥0 the absolute error in the45quadratic expansion of log L is at most t³/(3K²), including for singular spectra. -/46theorem replicatedFactor_log_remainder {I : Type*} [Fintype I] (w : I → ℝ)47    (hw : ∀ i, 0 ≤ w i) (hs : ∑ i, w i = 1) (k : ℕ) {t : ℝ} (ht : 0 ≤ t) :48    let K : ℝ := (k+1 : ℕ)49    |Real.log (replicatedFactor w k t) + t - t^2*(∑ i, w i^2)/(2*K)| ≤ t^3/(3*K^2) := by50  let K : ℝ := (k+1 : ℕ)51  let a := t/K52  let u := fun i ↦ a*w i53  let R := fun i ↦ Real.log (1+u i) - u i + u i^2/254  have hK : 0 < K := by dsimp [K]; positivity55  have ha : 0 ≤ a := div_nonneg ht hK.le56  have hu i : 0 ≤ u i := mul_nonneg ha (hw i)57  have he i : 0 ≤ R i ∧ R i ≤ u i^3/3 := log_quadratic_error (hu i)58  have hsp : ∑ i, u i = a := by simp [u, ← Finset.mul_sum, hs]59  have hsq : ∑ i, u i^2/2 = a^2*(∑ i, w i^2)/2 := by60    simp only [u, mul_pow, div_eq_mul_inv, ← Finset.sum_mul, ← Finset.mul_sum]61  have hcube : ∑ i, w i^3 ≤ 1 := by62    rw [← hs]63    apply Finset.sum_le_sum64    intro i _65    have hi : w i ≤ 1 := hs ▸ Finset.single_le_sum (fun j _ ↦ hw j) (Finset.mem_univ i)66    calc67      w i^3 = (w i)^2 * w i := by ring68      _ ≤ 1 * w i := mul_le_mul_of_nonneg_right69        (by simpa only [one_pow] using pow_le_pow_left₀ (hw i) hi 2) (hw i)70      _ = _ := one_mul _71  have htotal : ∑ i, R i ≤ a^3/3 := calc72    _ ≤ ∑ i, u i^3/3 := Finset.sum_le_sum (fun i _ ↦ (he i).2)73    _ = a^3 * (∑ i, w i^3)/3 := by simp only [u, mul_pow, div_eq_mul_inv, ← Finset.sum_mul, ← Finset.mul_sum]74    _ ≤ _ := by simpa using div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hcube75      (pow_nonneg ha 3)) (by norm_num : (0 : ℝ) ≤ 3)76  have hf : Real.log (replicatedFactor w k t) = -K * ∑ i, Real.log (1+u i) := by77    have hvec (i) : t * w i / K = u i := by dsimp [u,a]; ring78    change Real.log ((∏ i, (1+t*w i/K))⁻¹ ^ (k+1)) = _79    have hn (i : I) (_ : i ∈ Finset.univ) : 1+u i ≠ 0 := by have := hu i; positivity80    simp only [hvec, Real.log_pow, Real.log_inv, Real.log_prod hn, mul_neg, neg_mul, K]81  have hR : ∑ i, R i = (∑ i, Real.log (1+u i)) - a + a^2*(∑ i, w i^2)/2 := by82    simp only [R, Finset.sum_add_distrib, Finset.sum_sub_distrib, hsp, hsq]83  have hsumpos : 0 ≤ ∑ i, R i := Finset.sum_nonneg (fun i _ ↦ (he i).1)84  change |Real.log (replicatedFactor w k t) + t - t^2*(∑ i, w i^2)/(2*K)| ≤ t^3/(3*K^2)85  rw [hf, show -K*(∑ i, Real.log (1+u i)) + t - t^2*(∑ i, w i^2)/(2*K)86      = -(K*∑ i, R i) by rw [hR]; dsimp [a]; field_simp; ring, abs_neg,87    abs_of_nonneg (mul_nonneg hK.le hsumpos)]88  calc89    _ ≤ K*(a^3/3) := mul_le_mul_of_nonneg_left htotal hK.le90    _ = _ := by dsimp [a]; field_simp9192end SubentropyCertificates.AncillaLimit

Axioms used

Choose a statement to see which axioms its proof uses.