Download data/lean/OAI/Probability/SKGap/Matrix/LogDetUniform.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.08 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Matrix/LogDetUniform.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/SKGap/Matrix/LogDetUniform.lean
-
curl -L -o LogDetUniform.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Matrix/LogDetUniform.lean
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 | |