roseking's picture
Add lean source and binary files (part 128)
7d9f027 verified
Raw History Blame Contribute Delete
4.72 kB
import Mathlib
import OAI.Probability.SKGap.Localization.QuadraticCoeff
namespace OAI
section
noncomputable section
open MeasureTheory ProbabilityTheory InformationTheory Real Set
open scoped NNReal ENNReal
open Filter
open scoped Topology
noncomputable section
open Matrix Real
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
noncomputable section
open Matrix Real
open scoped BigOperators Matrix.Norms.Frobenius NNReal
noncomputable section
open MeasureTheory ProbabilityTheory Real Set Filter
open MeasureTheory.Measure
open scoped ENNReal NNReal MeasureTheory Topology
open MeasureTheory
noncomputable section
noncomputable section
open MeasureTheory Set NormedSpace
open scoped Topology
noncomputable section
open Matrix Real
open scoped BigOperators Matrix.Norms.Frobenius
noncomputable section
open Set Real
open scoped Topology
noncomputable section
open Matrix Set Filter
open scoped Topology Matrix.Norms.Frobenius
noncomputable section
open Matrix NormedSpace ContinuousLinearMap
open scoped Matrix.Norms.Frobenius
noncomputable section
open Matrix
noncomputable section
open MeasureTheory ProbabilityTheory Real Set
open scoped ENNReal NNReal
noncomputable section
open MeasureTheory ProbabilityTheory InformationTheory Real Set
open scoped NNReal ENNReal
noncomputable section
open scoped BigOperators
open MeasureTheory ProbabilityTheory
namespace SKGap
section DiagonalGeometry
variable {ι : Type*} [Fintype ι]
def diagonalSqrt (a : ι → ℝ) (p : EuclideanSpace ℝ ι) : EuclideanSpace ℝ ι :=
WithLp.toLp 2 (fun i => Real.sqrt (a i) * p i)
lemma diagonalSqrt_norm_sq (a : ι → ℝ) (ha : ∀ i, 0 ≤ a i) (p : EuclideanSpace ℝ ι) :
‖diagonalSqrt a p‖^2 = ∑ i, a i * (p i)^2 := by
rw [EuclideanSpace.norm_sq_eq]
apply Finset.sum_congr rfl
intro i _
simp only [diagonalSqrt, WithLp.ofLp_toLp, Real.norm_eq_abs, sq_abs, mul_pow,
Real.sq_sqrt (ha i)]
lemma diagonalSqrt_norm_sq_le {a : ι → ℝ} {A : ℝ}
(ha : ∀ i, 0 ≤ a i) (hA : ∀ i, a i ≤ A) (p : EuclideanSpace ℝ ι) :
‖diagonalSqrt a p‖^2 ≤ A * ‖p‖^2 := by
rw [diagonalSqrt_norm_sq a ha, ← sum_coord_sq, Finset.mul_sum]
exact Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_right (hA i) (sq_nonneg _))
lemma diagonalSqrt_norm_le_sqrt {a : ι → ℝ} {A : ℝ}
(ha : ∀ i, 0 ≤ a i) (hA0 : 0 ≤ A) (hA : ∀ i, a i ≤ A)
{p : EuclideanSpace ℝ ι} (hp : ‖p‖ ≤ 1) :
‖diagonalSqrt a p‖ ≤ Real.sqrt A := by
have h := diagonalSqrt_norm_sq_le ha hA p
have hp2 : ‖p‖^2 ≤ 1 := by nlinarith [norm_nonneg p]
have hh := mul_le_mul_of_nonneg_left hp2 hA0
have hs := Real.sq_sqrt hA0
have hs0 := Real.sqrt_nonneg A
nlinarith [norm_nonneg (diagonalSqrt a p)]
omit [Fintype ι] in
lemma continuous_diagonalSqrt (a : ι → ℝ) : Continuous (diagonalSqrt a) := by
apply (PiLp.continuous_toLp 2 (fun _ : ι => ℝ)).comp
exact continuous_pi (fun i => continuous_const.mul (PiLp.continuous_apply 2 (fun _ => ℝ) i))
lemma diagonal_sum_mul_le_norm (a : ι → ℝ) (p g : EuclideanSpace ℝ ι) :
(∑ i, diagonalSqrt a p i * g i) ≤ ‖p‖ * ‖diagonalSqrt a g‖ := by
have he : (∑ i, diagonalSqrt a p i * g i) = inner ℝ p (diagonalSqrt a g) := by
rw [PiLp.inner_apply]
apply Finset.sum_congr rfl
intro i _
simp only [diagonalSqrt, WithLp.ofLp_toLp, RCLike.inner_apply, conj_trivial]
ring
rw [he]
exact real_inner_le_norm _ _
lemma quadraticCoeff_norm {r : ℝ} (hr : 0 ≤ r) (w : EuclideanSpace ℝ ι) :
‖WithLp.toLp 2 (quadraticCoeff r w)‖ = Real.sqrt (2*r) * ‖w‖^2 := by
have hsum : (∑ k, (quadraticCoeff r w k)^2) = 2*r*‖w‖^4 := by
have h := quadraticCoeff_increment r hr w 0
have h0 : quadraticCoeff r (0 : EuclideanSpace ℝ ι) = 0 := by
funext k
cases k <;> simp [quadraticCoeff]
simpa only [h0, Pi.zero_apply, sub_zero, norm_zero, zero_pow (by norm_num : (4 : ℕ) ≠ 0),
WithLp.ofLp_zero, zero_mul, mul_zero, Finset.sum_const_zero, zero_pow (by norm_num : (2 : ℕ) ≠ 0),
add_zero] using h
have he : ‖WithLp.toLp 2 (quadraticCoeff r w)‖^2 =
(Real.sqrt (2*r) * ‖w‖^2)^2 := by
rw [← sum_coord_sq, hsum, mul_pow, Real.sq_sqrt (by positivity)]
ring
have hnon : 0 ≤ Real.sqrt (2*r) * ‖w‖^2 := by positivity
nlinarith [norm_nonneg (WithLp.toLp 2 (quadraticCoeff r w))]
end DiagonalGeometry
lemma quadratic_margin {d b : ℝ} (_hd : 0 ≤ d) (hdb : d ≤ b) (hb : b ≤ 1) :
2*d-d^2 ≤ 1-(1-b)^2 := by
nlinarith [mul_nonneg (sub_nonneg.mpr hdb) (show 0 ≤ 2-b-d by linarith)]
end SKGap
open Real
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI