math / data /lean /OAI /Probability /SKGap /Matrix /LogDetUniform.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
9.08 kB
import Mathlib
import OAI.Probability.SKGap.Matrix.RankNorm
import OAI.Probability.SKGap.Brownian.LogDetMesh
import OAI.Probability.SKGap.Stability.LogDetUniformMean
namespace OAI
section
noncomputable section
namespace SKGap
open Matrix MeasureTheory ProbabilityTheory Real Set Filter
open scoped BigOperators Matrix.Norms.Frobenius Topology
theorem actual_logdet_uniform {j Ξ΅ : ℝ} (hj : 0 < j) (hj1 : j < 1) (hΞ΅ : 0 < Ξ΅) :
βˆƒ Ξ³β‚€ : ℝ, 0 < Ξ³β‚€ ∧ βˆ€ Ξ³ : ℝ, 0 < Ξ³ β†’ Ξ³ ≀ Ξ³β‚€ β†’ βˆƒ N : β„•, 0 < N ∧
βˆ€ n : β„•, N ≀ n β†’
(Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)).real
{g | βˆƒ a : Fin n β†’ ℝ, (βˆ€ i,0 ≀ a i) ∧ (βˆ€ i,a i ≀ 1) ∧
j*(coordAverage a)^2+Ξ΅ < LogDet.regularizedLogDet Ξ³
(logPath (j*coordAverage a) a (goeMatrix (j/(n:ℝ)) g) 1)} ≀
4*Real.exp (-min 1 (1/(Ο€^2*j))*(n:ℝ)) := by
classical
obtain ⟨B,hB,hmean⟩ := actual_logdet_mean hj hj1
refine ⟨Ρ/(4*(B^2+1)),by positivity,?_⟩
intro Ξ³ hΞ³ hΞ³β‚€
obtain ⟨C,hC,Nβ‚€,hNβ‚€,hm⟩ := hmean Ξ³ hΞ³
have hΞ³B : Ξ³*B^2 ≀ Ξ΅/4 := by
have hh := (le_div_iffβ‚€ (by positivity : 0 < 4*(B^2+1))).mp hΞ³β‚€
nlinarith
let R := 2*sqrt j+1
have hR : 0 ≀ R := by dsimp [R]; positivity
let K := (2*j+R)/sqrt Ξ³+2*j
have hK : 0 ≀ K := by dsimp [K]; positivity
let Ξ΄ := Ξ΅/(4*(K+1))
have hΞ΄ : 0 < Ξ΄ := by dsimp [Ξ΄]; positivity
have hKΞ΄ : K*Ξ΄ ≀ Ξ΅/4 := by
have hh : Ξ΄*(4*(K+1))=Ξ΅ := div_mul_cancelβ‚€ Ξ΅ (ne_of_gt (by positivity : 0 < 4*(K+1)))
nlinarith
obtain ⟨s,hs,hcover⟩ := scalar_cube_net hδ
let q := Ξ³*(Ξ΅/4)^2/(Ο€^2*j)
have hq : 0 < q := by dsimp [q]; positivity
obtain ⟨N₁,hNβ‚βŸ© := exists_nat_ge (4*C/Ξ΅)
obtain ⟨Nβ‚‚,hNβ‚‚βŸ© := exists_nat_ge (((s.card:ℝ)+1)/q)
refine ⟨max Nβ‚€ (max N₁ Nβ‚‚),hNβ‚€.trans_le (le_max_left _ _),?_⟩
intro n hn
have hnβ‚€ := (le_max_left Nβ‚€ (max N₁ Nβ‚‚)).trans hn
have hn₁ := (le_max_left N₁ Nβ‚‚).trans ((le_max_right Nβ‚€ (max N₁ Nβ‚‚)).trans hn)
have hnβ‚‚ := (le_max_right N₁ Nβ‚‚).trans ((le_max_right Nβ‚€ (max N₁ Nβ‚‚)).trans hn)
have hnpos := hNβ‚€.trans_le hnβ‚€
have hnreal : (0:ℝ) < n := Nat.cast_pos.mpr hnpos
let : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hnpos
have hCn : C/(n:ℝ) ≀ Ξ΅/4 := by
have hh := hN₁.trans (Nat.cast_le.mpr hn₁)
have hh' := (div_le_iffβ‚€ hΞ΅).mp hh
apply (div_le_iffβ‚€ hnreal).mpr
nlinarith
let ΞΌ := Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)
let M := fun g : MatrixCoordinates (Fin n) β†’ ℝ => goeMatrix (j/(n:ℝ)) g
let T := {g | βˆƒ v : Fin n β†’ s, j*(coordAverage (fun i => (v i:ℝ)))^2+Ξ΅/2+Ξ΅/4 <
LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage (fun i => (v i:ℝ)))
(fun i => (v i:ℝ)) (M g) 1)}
let U := {g | R < opNorm (M g)}
have hT : ΞΌ.real T ≀ 2*Real.exp (-(n:ℝ)) := by
apply (logdet_mesh_tail hj hΞ³ (by positivity : 0 ≀ Ξ΅/4) hnpos s hs ?_).trans
Β· have hh := product_mesh_absorption hq s.card n (hNβ‚‚.trans (Nat.cast_le.mpr hnβ‚‚))
have he : -Ξ³*(n:ℝ)^2*(Ξ΅/4)^2/(Ο€^2*j)= -q*(n:ℝ)^2 := by dsimp only [q]; ring
simpa only [he] using hh
Β· intro a ha ha1
have hh := hm n hnβ‚€ a ha ha1
have he : (j/(n:ℝ))*βˆ‘ i,a i=j*coordAverage a := by simp only [coordAverage,Fintype.card_fin]; ring
rw [he] at hh
change (∫ g, LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage a) a (M g) 1) βˆ‚ΞΌ) ≀ _
have heavg : (βˆ‘ i,a i)/(n:ℝ)=coordAverage a := by simp only [coordAverage,Fintype.card_fin]
rw [heavg] at hh
linarith
have hU : ΞΌ.real U ≀ 2*Real.exp (-(n:ℝ)/(Ο€^2*j)) := by
change (gaussianCoordinates (MatrixCoordinates (Fin n))).real
{g | 2*sqrt j+1 < β€–matrixOperator (goeMatrix (j/(n:ℝ)) g)β€–} ≀ _
simpa only [one_pow,_root_.neg_one_mul,Fintype.card_fin] using
(goe_norm_tail (ΞΉ := Fin n) hj (by norm_num : (0:ℝ) ≀ 1))
have hsub : {g | βˆƒ a : Fin n β†’ ℝ, (βˆ€ i,0 ≀ a i) ∧ (βˆ€ i,a i ≀ 1) ∧
j*(coordAverage a)^2+Ξ΅ < LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage a) a (M g) 1)} βŠ† T βˆͺ U := by
rintro g ⟨a,ha,ha1,hbad⟩
by_contra hg
have hnot := not_or.mp hg
have hop : opNorm (M g) ≀ R := le_of_not_gt hnot.2
have hnet (v : Fin n β†’ s) : LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage (fun i => (v i:ℝ)))
(fun i => (v i:ℝ)) (M g) 1) ≀ j*(coordAverage (fun i => (v i:ℝ)))^2+(Ξ΅/2+Ξ΅/4) := by
have hh : Β¬ j*(coordAverage (fun i => (v i:ℝ)))^2+Ξ΅/2+Ξ΅/4 <
LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage (fun i => (v i:ℝ)))
(fun i => (v i:ℝ)) (M g) 1) := fun hv => hnot.1 ⟨v,hv⟩
linarith [le_of_not_gt hh]
have hh := logdet_cube_net_transfer hj.le hΞ΄ hR hΞ³ s hs hcover hop hnet ha ha1
change LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage a) a (M g) 1) ≀
j*(coordAverage a)^2+(Ξ΅/2+Ξ΅/4)+K*Ξ΄ at hh
linarith
have hb := (measureReal_mono hsub (measure_ne_top _ _)).trans
((measureReal_union_le T U).trans (add_le_add hT hU))
apply hb.trans
have e₁ : Real.exp (-(n:ℝ)) ≀ Real.exp (-min 1 (1/(Ο€^2*j))*(n:ℝ)) := by
apply Real.exp_le_exp.mpr
nlinarith [mul_nonneg (Nat.cast_nonneg n) (sub_nonneg.mpr (min_le_left 1 (1/(Ο€^2*j))))]
have eβ‚‚ : Real.exp (-(n:ℝ)/(Ο€^2*j)) ≀ Real.exp (-min 1 (1/(Ο€^2*j))*(n:ℝ)) := by
apply Real.exp_le_exp.mpr
have hh := mul_le_mul_of_nonneg_right (min_le_right 1 (1/(Ο€^2*j))) (Nat.cast_nonneg n)
simp only [div_eq_mul_inv,_root_.one_mul] at hh ⊒
nlinarith
linarith
end SKGap
end
end
section
noncomputable section
namespace SKGap
open Matrix MeasureTheory ProbabilityTheory Real Set Filter
open scoped BigOperators Matrix.Norms.Frobenius Topology
theorem actual_simultaneous_logdet {j Ξ΅ : ℝ} (hj : 0 < j) (hj1 : j < 1) (hΞ΅ : 0 < Ξ΅) :
βˆƒ Ξ³β‚€ : ℝ, 0 < Ξ³β‚€ ∧ βˆ€ Ξ³ : ℝ, 0 < Ξ³ β†’ Ξ³ ≀ Ξ³β‚€ β†’ βˆ€ rβ‚€ : β„•, βˆ€ Mβ‚‚ : ℝ,
βˆƒ N : β„•, 0 < N ∧ βˆ€ n : β„•, N ≀ n β†’
(Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)).real
{g | βˆƒ a : Fin n β†’ ℝ, (βˆ€ i,0 ≀ a i) ∧ (βˆ€ i,a i ≀ 1) ∧
βˆƒ E : Matrix (Fin n) (Fin n) ℝ, E.rank ≀ rβ‚€ ∧ opNorm E ≀ Mβ‚‚ ∧
j*(coordAverage a)^2+Ξ΅ < LogDet.regularizedLogDet Ξ³
(1+((j*coordAverage a) β€’ 1-goeMatrix (j/(n:ℝ)) g)*diagonal a+E)} ≀
4*Real.exp (-min 1 (1/(Ο€^2*j))*(n:ℝ)) := by
obtain βŸ¨Ξ³β‚€,hΞ³β‚€,hbound⟩ := actual_logdet_uniform hj hj1 (half_pos hΞ΅)
refine βŸ¨Ξ³β‚€,hΞ³β‚€,?_⟩
intro Ξ³ hΞ³ hΞ³le rβ‚€ Mβ‚‚
obtain ⟨Nβ‚€,hNβ‚€,hb⟩ := hbound Ξ³ hΞ³ hΞ³le
let D := max 0 Mβ‚‚
have hD : 0 ≀ D := le_max_left _ _
obtain ⟨N₁,hNβ‚βŸ© := exists_nat_ge ((2*D*sqrt (rβ‚€:ℝ)/Ξ΅)^2/Ξ³)
refine ⟨max Nβ‚€ N₁,hNβ‚€.trans_le (le_max_left _ _),?_⟩
intro n hn
have hnβ‚€ := (le_max_left Nβ‚€ N₁).trans hn
have hn₁ := (le_max_right Nβ‚€ N₁).trans hn
have hnpos := hNβ‚€.trans_le hnβ‚€
have hnreal : (0:ℝ) < n := Nat.cast_pos.mpr hnpos
let : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hnpos
have hroot : 2*D*sqrt (rβ‚€:ℝ)/Ξ΅ ≀ sqrt ((n:ℝ)*Ξ³) := by
apply (sq_le_sqβ‚€ (by positivity) (sqrt_nonneg _)).mp
rw [sq_sqrt (by positivity)]
have hh := (div_le_iffβ‚€ hΞ³).mp (hN₁.trans (Nat.cast_le.mpr hn₁))
exact hh
have hpert : D*sqrt (rβ‚€:ℝ)/sqrt ((n:ℝ)*Ξ³) ≀ Ξ΅/2 := by
apply (div_le_iffβ‚€ (sqrt_pos.mpr (mul_pos hnreal hΞ³))).mpr
have hh := (div_le_iffβ‚€ hΞ΅).mp hroot
nlinarith
apply (measureReal_mono (sβ‚‚ := {g | βˆƒ a : Fin n β†’ ℝ, (βˆ€ i,0 ≀ a i) ∧ (βˆ€ i,a i ≀ 1) ∧
j*(coordAverage a)^2+Ξ΅/2 < LogDet.regularizedLogDet Ξ³
(logPath (j*coordAverage a) a (goeMatrix (j/(n:ℝ)) g) 1)}) ?_ (measure_ne_top _ _)).trans (hb n hnβ‚€)
rintro g ⟨a,ha,ha1,E,hr,hE,hbad⟩
refine ⟨a,ha,ha1,?_⟩
let W := goeMatrix (j/(n:ℝ)) g
let L := 1+((j*coordAverage a) β€’ 1-W)*diagonal a
have htr : Lα΅€=logPath (j*coordAverage a) a W 1 := by
have hW : Wα΅€=W := goeMatrix_symm (j/(n:ℝ)) g
simp only [L,transpose_add,transpose_one,transpose_mul,transpose_sub,transpose_smul,
diagonal_transpose,hW,logPath,one_pow,one_mul,one_smul,Matrix.mul_sub,Matrix.mul_smul,Matrix.mul_one]
abel
have hf : LogDet.regularizedLogDet Ξ³ (L+E)=
LogDet.regularizedLogDet Ξ³ (logPath (j*coordAverage a) a W 1+Eα΅€) := by
rw [← regularizedLogDet_transpose (ne_of_gt hΞ³) (L+E),transpose_add,htr]
have hh := (abs_le.mp (logdet_rank_perturbation hΞ³ hD
(logPath (j*coordAverage a) a W 1) Eα΅€
(by simpa only [Matrix.rank_transpose] using hr)
(by rw [opNorm_transpose]; exact hE.trans (le_max_right _ _)))).2
simp only [Fintype.card_fin] at hh
change j*(coordAverage a)^2+Ξ΅ < LogDet.regularizedLogDet Ξ³ (L+E) at hbad
rw [hf] at hbad
linarith
end SKGap
end
end
end OAI