Download data/lean/OAI/Probability/LogConcave/Numerics/NodeLp.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.17 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Numerics/NodeLp.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Numerics/NodeLp.lean
-
curl -L -o NodeLp.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Numerics/NodeLp.lean
8.17 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.Numerics.Correction | |
| namespace OAI | |
| section | |
| section | |
| noncomputable section | |
| namespace LogConcaveSampling.FinitePicard | |
| open MeasureTheory | |
| open scoped BigOperators NNReal RealInnerProductSpace | |
| variable {Ξ© E I : Type*} [MeasurableSpace Ξ©] {Ξ½ : Measure Ξ©} [IsFiniteMeasure Ξ½] | |
| [NormedAddCommGroup E] | |
| lemma lipschitz_zero_shift {K : ββ₯0} {Ο : E β E} (hΟ : LipschitzWith K Ο) : | |
| LipschitzWith K (fun x => Ο x-Ο 0) := by | |
| apply LipschitzWith.of_dist_le_mul | |
| intro x y | |
| simpa only [dist_sub_right] using hΟ.dist_le_mul x y | |
| def nodeLp {K : ββ₯0} {Ο : E β E} (hΟ : LipschitzWith K Ο) (f : Lp E 2 Ξ½) : Lp E 2 Ξ½ := | |
| (lipschitz_zero_shift hΟ).compLp (by simp) f + Lp.const 2 Ξ½ (Ο 0) | |
| lemma nodeLp_ae {K : ββ₯0} {Ο : E β E} (hΟ : LipschitzWith K Ο) (f : Lp E 2 Ξ½) : | |
| (nodeLp hΟ f : Ξ© β E)=α΅[Ξ½] fun z => Ο (f z) := by | |
| filter_upwards [Lp.coeFn_add ((lipschitz_zero_shift hΟ).compLp (by simp) f) | |
| (Lp.const 2 Ξ½ (Ο 0)), | |
| (lipschitz_zero_shift hΟ).coeFn_compLp (by simp) f, | |
| Lp.coeFn_const 2 Ξ½ (Ο 0)] with z hz hΟz hc | |
| simp only [nodeLp,hz,Pi.add_apply,hΟz,Function.comp_apply,hc,Function.const_apply,sub_add_cancel] | |
| lemma nodeLp_lipschitz {K : ββ₯0} {Ο : E β E} (hΟ : LipschitzWith K Ο) : | |
| LipschitzWith K (nodeLp (Ξ½:=Ξ½) hΟ) := by | |
| apply LipschitzWith.of_dist_le_mul | |
| intro f g | |
| simpa only [nodeLp,dist_add_right] using | |
| ((lipschitz_zero_shift hΟ).lipschitzWith_compLp (by simp)).dist_le_mul f g | |
| variable [NormedSpace β E] [Fintype I] | |
| def stepLp (w : I β I β β) (Ο : I β E β E) {K : ββ₯0} | |
| (hΟ : βi,LipschitzWith K (Ο i)) (a z : I β Lp E 2 Ξ½) : I β Lp E 2 Ξ½ := | |
| step w (fun j => nodeLp (hΟ j)) a z | |
| lemma stepLp_lipschitz (w : I β I β β) (Ο : I β E β E) {A K : ββ₯0} | |
| (hΟ : βi,LipschitzWith K (Ο i)) (a : I β Lp E 2 Ξ½) | |
| (hw : βi,βj,|w i j|β€A) : LipschitzWith (A*K) (stepLp w Ο hΟ a) := | |
| step_lipschitz w _ a hw (fun j => nodeLp_lipschitz (hΟ j)) | |
| lemma stepLp_ae (w : I β I β β) (Ο : I β E β E) {K : ββ₯0} | |
| (hΟ : βi,LipschitzWith K (Ο i)) (a z : I β Lp E 2 Ξ½) (i : I) : | |
| (stepLp w Ο hΟ a z i : Ξ© β E)=α΅[Ξ½] | |
| fun Ο => step w Ο (fun j => a j Ο) (fun j => z j Ο) i := by | |
| classical | |
| have ha := Lp.coeFn_add (a i) (βj,w i j β’ nodeLp (hΟ j) (z j)) | |
| have hs := Lp.coeFn_fun_finsetSum Finset.univ (fun j => w i j β’ nodeLp (hΟ j) (z j)) | |
| have hm : βα΅Ο βΞ½,βj,(w i j β’ nodeLp (hΟ j) (z j) : Lp E 2 Ξ½) Ο= | |
| w i j β’ Ο j (z j Ο) := by | |
| rw [ae_all_iff] | |
| intro j | |
| filter_upwards [Lp.coeFn_smul (w i j) (nodeLp (hΟ j) (z j)),nodeLp_ae (hΟ j) (z j)] with Ο h1 h2 | |
| simp only [h1,Pi.smul_apply,h2] | |
| filter_upwards [ha,hs,hm] with Ο h1 h2 h3 | |
| simp only [stepLp,step,correction,Pi.add_apply,h1,h2,h3] | |
| theorem rms_picard_defect (w : I β I β β) (Ο : I β E β E) {A K : ββ₯0} | |
| (hΟ : βi,LipschitzWith K (Ο i)) (a e : I β Lp E 2 Ξ½) | |
| (hw : βi,βj,|w i j|β€A) (hq : (A*K:ββ₯0)β€1/2) | |
| {D : β} (hD : 0β€D) (he : βi,dist (stepLp w Ο hΟ a e i) (e i)β€D) (n : β) : | |
| dist ((stepLp w Ο hΟ a)^[n] a) eβ€2*D+(A*K:ββ₯0)^n*dist a e := by | |
| apply iterate_defect (stepLp_lipschitz w Ο hΟ a hw) (by exact_mod_cast hq) a e hD | |
| ((dist_pi_le_iff hD).mpr he) n | |
| section Inner | |
| omit [NormedSpace β E] [IsFiniteMeasure Ξ½] | |
| variable [InnerProductSpace β E] | |
| lemma lp_norm_sq_integral (f : Lp E 2 Ξ½) : βfβ^2=β«Ο,βf Οβ^2 βΞ½ := by | |
| rw [βreal_inner_self_eq_norm_sq,L2.inner_def] | |
| simp only [real_inner_self_eq_norm_sq] | |
| lemma nodewise_rms_le {f g : Lp E 2 Ξ½} {B : β} (hB : 0β€B) | |
| (h : (β«Ο,βf Ο-g Οβ^2 βΞ½)β€B^2) : dist f gβ€B := by | |
| rw [dist_eq_norm] | |
| have he : βf-gβ^2=β«Ο,βf Ο-g Οβ^2 βΞ½ := by | |
| rw [lp_norm_sq_integral] | |
| apply integral_congr_ae | |
| filter_upwards [Lp.coeFn_sub f g] with Ο hΟ | |
| simp only [hΟ,Pi.sub_apply] | |
| nlinarith [norm_nonneg (f-g)] | |
| end Inner | |
| end LogConcaveSampling.FinitePicard | |
| end | |
| end | |
| section | |
| noncomputable section | |
| namespace LogConcaveSampling.FinitePicard | |
| open MeasureTheory | |
| open scoped BigOperators NNReal RealInnerProductSpace | |
| variable {Ξ© E I : Type*} [MeasurableSpace Ξ©] {Ξ½ : Measure Ξ©} [IsFiniteMeasure Ξ½] | |
| [NormedAddCommGroup E] [InnerProductSpace β E] [Fintype I] | |
| omit [IsFiniteMeasure Ξ½] in | |
| lemma lp_rms_eq (f g : Lp E 2 Ξ½) {u v : Ξ© β E} | |
| (hf : (f : Ξ© β E)=α΅[Ξ½] u) (hg : (g : Ξ© β E)=α΅[Ξ½] v) : | |
| Integrable (fun Ο => βu Ο-v Οβ^2) Ξ½ β§ | |
| (β«Ο,βu Ο-v Οβ^2 βΞ½)=dist f g^2 := by | |
| have he : (fun Ο => (f-g : Lp E 2 Ξ½) Ο)=α΅[Ξ½] fun Ο => u Ο-v Ο := by | |
| filter_upwards [Lp.coeFn_sub f g,hf,hg] with Ο h1 h2 h3 | |
| simp only [h1,Pi.sub_apply,h2,h3] | |
| have hi := (Lp.memLp (f-g)).integrable_norm_pow (by norm_num : (2:β)β 0) | |
| have hn : (fun Ο => β(f-g : Lp E 2 Ξ½) Οβ^2)=α΅[Ξ½] fun Ο => βu Ο-v Οβ^2 := | |
| he.fun_comp (fun z => βzβ^2) | |
| refine β¨hi.congr hn,?_β© | |
| rw [dist_eq_norm,lp_norm_sq_integral] | |
| exact integral_congr_ae hn.symm | |
| lemma iterateLp_nodes_ae (w : I β I β β) (Ο : I β E β E) {K : ββ₯0} | |
| (hΟ : βi,LipschitzWith K (Ο i)) (a : I β Ξ© β E) (aLp : I β Lp E 2 Ξ½) | |
| (ha : βi,(aLp i : Ξ© β E)=α΅[Ξ½] a i) (N : β) (i : I) : | |
| ((stepLp w Ο hΟ aLp)^[N] aLp i : Ξ© β E)=α΅[Ξ½] | |
| fun Ο => nodes w Ο (fun Ο j => a j Ο) N Ο i := by | |
| induction N generalizing i with | |
| | zero => simpa only [Function.iterate_zero_apply,nodes] using ha i | |
| | succ N ih => | |
| rw [Function.iterate_succ_apply'] | |
| have hia : βα΅Ο βΞ½,βj,aLp j Ο=a j Ο := ae_all_iff.mpr ha | |
| have hii : βα΅Ο βΞ½,βj,((stepLp w Ο hΟ aLp)^[N] aLp j : Ξ© β E) Ο= | |
| nodes w Ο (fun Ο j => a j Ο) N Ο j := ae_all_iff.mpr ih | |
| filter_upwards [stepLp_ae w Ο hΟ aLp ((stepLp w Ο hΟ aLp)^[N] aLp) i,hia,hii] with Ο h1 h2 h3 | |
| simp only [h1,nodes,step,correction,Pi.add_apply,h2,h3] | |
| theorem nodes_rms (w : I β I β β) (Ο : I β E β E) {A K : ββ₯0} | |
| (hΟ : βi,LipschitzWith K (Ο i)) (a e : I β Ξ© β E) | |
| (ha : βi,MemLp (a i) 2 Ξ½) (he : βi,MemLp (e i) 2 Ξ½) | |
| (hw : βi,βj,|w i j|β€A) (hq : (A*K:ββ₯0)β€1/2) | |
| {D H : β} (hD : 0β€D) (hH : 0β€H) | |
| (hdef : βi,(β«Ο,βstep w Ο (fun j => a j Ο) (fun j => e j Ο) i-e i Οβ^2 βΞ½)β€D^2) | |
| (hinit : βi,(β«Ο,βa i Ο-e i Οβ^2 βΞ½)β€H^2) (N : β) (i : I) : | |
| Integrable (fun Ο => βnodes w Ο (fun Ο j => a j Ο) N Ο i-e i Οβ^2) Ξ½ β§ | |
| (β«Ο,βnodes w Ο (fun Ο j => a j Ο) N Ο i-e i Οβ^2 βΞ½)β€ | |
| (2*D+(A*K:ββ₯0)^N*H)^2 := by | |
| let aLp : I β Lp E 2 Ξ½ := fun j => (ha j).toLp (a j) | |
| let eLp : I β Lp E 2 Ξ½ := fun j => (he j).toLp (e j) | |
| have ha' (j : I) : (aLp j : Ξ© β E)=α΅[Ξ½] a j := (ha j).coeFn_toLp | |
| have he' (j : I) : (eLp j : Ξ© β E)=α΅[Ξ½] e j := (he j).coeFn_toLp | |
| have hstep (j : I) : (stepLp w Ο hΟ aLp eLp j : Ξ© β E)=α΅[Ξ½] | |
| fun Ο => step w Ο (fun i => a i Ο) (fun i => e i Ο) j := by | |
| filter_upwards [stepLp_ae w Ο hΟ aLp eLp j,ae_all_iff.mpr ha',ae_all_iff.mpr he'] with Ο h1 h2 h3 | |
| simpa only [h2,h3] using h1 | |
| have hdef' (j : I) : dist (stepLp w Ο hΟ aLp eLp j) (eLp j)β€D := by | |
| have hh := (lp_rms_eq _ _ (hstep j) (he' j)).2 | |
| have hb := hdef j | |
| rw [hh] at hb | |
| nlinarith [dist_nonneg (x:=stepLp w Ο hΟ aLp eLp j) (y:=eLp j)] | |
| have hinit' : dist aLp eLpβ€H := by | |
| apply (dist_pi_le_iff hH).mpr | |
| intro j | |
| have hh := (lp_rms_eq _ _ (ha' j) (he' j)).2 | |
| have hb := hinit j | |
| rw [hh] at hb | |
| nlinarith [dist_nonneg (x:=aLp j) (y:=eLp j)] | |
| have hb := rms_picard_defect w Ο hΟ aLp eLp hw hq hD hdef' N | |
| have hrms := lp_rms_eq _ _ (iterateLp_nodes_ae w Ο hΟ a aLp ha' N i) (he' i) | |
| refine β¨hrms.1,?_β© | |
| rw [hrms.2] | |
| apply pow_le_pow_leftβ dist_nonneg _ 2 | |
| exact (dist_le_pi_dist _ _ i).trans (hb.trans | |
| (add_le_add le_rfl (mul_le_mul_of_nonneg_left hinit' (show 0β€((A*K:ββ₯0):β)^N from by positivity)))) | |
| end LogConcaveSampling.FinitePicard | |
| end | |
| end | |
| end | |
| end OAI | |