Download data/lean/OAI/Probability/IsingPerceptron/DeviationRate.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 29 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/DeviationRate.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/IsingPerceptron/DeviationRate.lean
-
curl -L -o DeviationRate.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/DeviationRate.lean
29 kB
| import Mathlib | |
| import OAI.Probability.IsingPerceptron.ActualQuenched | |
| namespace OAI | |
| /-! Deviation Rate. -/ | |
| noncomputable section | |
| namespace IsingPerceptron.Main | |
| open MeasureTheory ProbabilityTheory Real Filter Set | |
| open scoped BigOperators Topology Interval | |
| def sourceDeviationRate (Ξ± C : β) (j N : β) : β := | |
| ((7/2)+4*sqrt (25/12+4*Ξ±*C^2)/(1/2)^(j+1)+20*(1/2)^(j+1))*(N:β)^(-(1:β)/8) | |
| lemma sourceDeviationRate_tendsto (Ξ± C : β) (j : β) : | |
| Tendsto (sourceDeviationRate Ξ± C j) atTop (π 0) := by | |
| have h : Tendsto (fun N : β => (N:β)^(-(1:β)/8)) atTop (π 0) := by | |
| convert (tendsto_rpow_neg_atTop (by norm_num : (0:β)<1/8)).comp tendsto_natCast_atTop_atTop using 1 | |
| funext n | |
| simp only [Function.comp_apply] | |
| congr 1 | |
| ring | |
| unfold sourceDeviationRate | |
| simpa only [mul_zero] using h.const_mul | |
| ((7/2)+4*sqrt (25/12+4*Ξ±*C^2)/(1/2)^(j+1)+20*(1/2)^(j+1)) | |
| lemma source_eta_eventually : βαΆ N : β in atTop,(N:β)^(-(1:β)/8) β€ 1/2 := by | |
| have h : Tendsto (fun N : β => (N:β)^(-(1:β)/8)) atTop (π 0) := by | |
| convert (tendsto_rpow_neg_atTop (by norm_num : (0:β)<1/8)).comp tendsto_natCast_atTop_atTop using 1 | |
| funext n | |
| simp only [Function.comp_apply] | |
| congr 1 | |
| ring | |
| exact h.eventually_le_const (by norm_num) | |
| lemma scale_rate_identity {N : β} (hN : 0<N) : | |
| sqrt (N:β)/((N:β)^(-(1:β)/8)*(perturbationScale N)^2)=(N:β)^(-(1:β)/8) := by | |
| have hn : (0:β)<N := by exact_mod_cast hN | |
| unfold perturbationScale | |
| rw [sqrt_eq_rpow,β rpow_natCast,β rpow_mul hn.le,β rpow_add hn,β rpow_sub hn] | |
| norm_num | |
| lemma source_scale_inverse {N : β} (hN : 0<N) : | |
| (perturbationScale N)β»ΒΉ β€ (N:β)^(-(1:β)/8) := by | |
| have hn : (1:β) β€ N := by exact_mod_cast hN | |
| unfold perturbationScale | |
| rw [β rpow_neg (Nat.cast_nonneg N)] | |
| exact rpow_le_rpow_of_exponent_le hn (by norm_num) | |
| theorem source_rawTensor_deviation_rate {M N : β} (hN : 0<N) {Ξ± C : β} (hΞ± : 0 β€ Ξ±) | |
| (hM : (M:β) β€ Ξ±*N) {f : β β β} (hf : Measurable f) (hC : βz,|f z| β€ C) | |
| (v : β β β) (hv : βj : Fin N,v (j.val+1)βIcc (1/2:β) (5/2)) | |
| (j : Fin N) (hΞ· : (N:β)^(-(1:β)/8) β€ 1/2) : | |
| (β«u in (1:β)..2,β«p,rawTensorDeviation (M:=M) hN f (perturbationScale N) v j u p | |
| βperturbedDisorderLaw M N)/(perturbationScale N) β€ sourceDeviationRate Ξ± C j.val N := by | |
| have hn : (0:β)<N := by exact_mod_cast hN | |
| have hs : 0<perturbationScale N := rpow_pos_of_pos hn _ | |
| have he : 0<(N:β)^(-(1:β)/8) := rpow_pos_of_pos hn _ | |
| have hd : (0:β)<(1/2)^(j.val+1) := by positivity | |
| have h := rawTensor_deviation_integral (M:=M) hN hf hC (perturbationScale N) hs v hv j he hΞ· | |
| have hV : (25/12)*(perturbationScale N)^2+4*M*C^2 β€ (25/12+4*Ξ±*C^2)*N := by | |
| have hrow := mul_le_mul_of_nonneg_right hM (sq_nonneg C) | |
| nlinarith [perturbationScale_sq_le hN] | |
| have hK : (0:β) β€ 25/12+4*Ξ±*C^2 := by positivity | |
| have hsqrt : sqrt ((25/12)*(perturbationScale N)^2+4*M*C^2) β€ sqrt (25/12+4*Ξ±*C^2)*sqrt N := by | |
| simpa only [sqrt_mul hK] using sqrt_le_sqrt hV | |
| apply h.trans | |
| have hfirst : (7/2)/(perturbationScale N) β€ (7/2)*(N:β)^(-(1:β)/8) := by | |
| simpa only [div_eq_mul_inv] using mul_le_mul_of_nonneg_left (source_scale_inverse hN) (by norm_num : (0:β) β€ 7/2) | |
| have hsecond : 4*sqrt ((25/12)*(perturbationScale N)^2+4*M*C^2)/ | |
| ((N:β)^(-(1:β)/8)*(perturbationScale N)^2*(1/2)^(j.val+1)) β€ | |
| (4*sqrt (25/12+4*Ξ±*C^2)/(1/2)^(j.val+1))*(N:β)^(-(1:β)/8) := by | |
| calc _ β€ (4*(sqrt (25/12+4*Ξ±*C^2)*sqrt N))/ | |
| ((N:β)^(-(1:β)/8)*(perturbationScale N)^2*(1/2)^(j.val+1)) := | |
| div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hsqrt (by norm_num)) (by positivity) | |
| _ = (4*sqrt (25/12+4*Ξ±*C^2)/(1/2)^(j.val+1))* | |
| (sqrt N/((N:β)^(-(1:β)/8)*(perturbationScale N)^2)) := by ring | |
| _ = _ := by rw [scale_rate_identity hN] | |
| unfold sourceDeviationRate | |
| nlinarith | |
| lemma parameter_resampling_preserving {X : Type*} [MeasurableSpace X] | |
| (ΞΌ : Measure X) [IsProbabilityMeasure ΞΌ] (j : β) : | |
| MeasurePreserving (fun p : (β β X) Γ X => Function.update p.1 j p.2) | |
| ((Measure.infinitePi (fun _ : β => ΞΌ)).prod ΞΌ) (Measure.infinitePi (fun _ : β => ΞΌ)) := by | |
| classical | |
| have hm : Measurable (fun p : (β β X) Γ X => Function.update p.1 j p.2) := by fun_prop | |
| refine β¨hm,Measure.eq_infinitePi _ ?_β© | |
| intro s t ht | |
| rw [Measure.map_apply hm (MeasurableSet.pi s.countable_toSet (fun i _ => ht i))] | |
| by_cases hj : jβs | |
| Β· have he : (fun p : (β β X) Γ X => Function.update p.1 j p.2)β»ΒΉ' (Set.pi s t)= | |
| (Set.pi (s.erase j) t) ΓΛ’ (t j) := by | |
| ext p | |
| simp only [Set.mem_preimage,Set.mem_pi,Finset.mem_coe,Set.mem_prod,Finset.mem_erase] | |
| constructor | |
| Β· intro h | |
| refine β¨?_,?_β© | |
| Β· intro i hi | |
| simpa only [Function.update_of_ne hi.1] using h i hi.2 | |
| Β· simpa only [Function.update_self] using h j hj | |
| Β· rintro β¨h,huβ© i hi | |
| by_cases hij : i=j | |
| Β· subst i | |
| simpa only [Function.update_self] using hu | |
| Β· simpa only [Function.update_of_ne hij] using h i β¨hij,hiβ© | |
| rw [he,Measure.prod_prod,Measure.infinitePi_pi _ (fun i _ => ht i)] | |
| exact Finset.prod_erase_mul s (fun i => ΞΌ (t i)) hj | |
| Β· have he : (fun p : (β β X) Γ X => Function.update p.1 j p.2)β»ΒΉ' (Set.pi s t)= | |
| (Set.pi s t) ΓΛ’ Set.univ := by | |
| ext p | |
| simp only [Set.mem_preimage,Set.mem_pi,Finset.mem_coe,Set.mem_prod,Set.mem_univ,and_true] | |
| congr! 2 with i | |
| rename_i hi | |
| rw [Function.update_of_ne (by intro he; exact hj (he βΈ hi))] | |
| rw [he,Measure.prod_prod,Measure.infinitePi_pi _ (fun i _ => ht i),measure_univ,mul_one] | |
| def parameterCoordinateLaw : Measure β := volume.restrict (Ioc 1 2) | |
| instance parameterCoordinateLaw_probability : IsProbabilityMeasure parameterCoordinateLaw := by | |
| constructor | |
| norm_num [parameterCoordinateLaw] | |
| def sourceParameterLaw : Measure (β β β) := Measure.infinitePi (fun _ => parameterCoordinateLaw) | |
| instance sourceParameterLaw_probability : IsProbabilityMeasure sourceParameterLaw := by | |
| unfold sourceParameterLaw | |
| infer_instance | |
| lemma parameterCoordinateLaw_mem : βα΅u βparameterCoordinateLaw,uβIcc (1:β) 2 := by | |
| exact (ae_restrict_mem measurableSet_Ioc).mono (fun u hu => β¨hu.1.le,hu.2β©) | |
| lemma sourceParameterLaw_mem : βα΅v βsourceParameterLaw,βj,v jβIcc (1:β) 2 := by | |
| rw [ae_all_iff] | |
| intro j | |
| exact (measurePreserving_eval_infinitePi (fun _ : β => parameterCoordinateLaw) j).quasiMeasurePreserving.ae parameterCoordinateLaw_mem | |
| lemma integral_parameterCoordinateLaw (F : β β β) : | |
| (β«u,F u βparameterCoordinateLaw)=β«u in (1:β)..2,F u := by | |
| rw [intervalIntegral.integral_of_le (by norm_num : (1:β)β€2)] | |
| rfl | |
| instance perturbedDisorderLaw_probability (M N : β) : IsProbabilityMeasure (perturbedDisorderLaw M N) := by | |
| unfold perturbedDisorderLaw | |
| infer_instance | |
| def tensorMeanAt {M N : β} (hN : 0<N) (f : β β β) (s : β) (j : Fin N) | |
| (v : β β β) (p : PerturbedDisorder M N) : β := | |
| rawTensorMean hN f s v j (v (j.val+1)) p | |
| def tensorDeviationAt {M N : β} (hN : 0<N) (f : β β β) (s : β) (j : Fin N) | |
| (v : β β β) (p : PerturbedDisorder M N) : β := | |
| rawTensorDeviation hN f s v j (v (j.val+1)) p | |
| lemma tensorMeanAt_measurable {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) : | |
| Measurable (fun p : (β β β) Γ PerturbedDisorder M N => tensorMeanAt hN f s j p.1 p.2) := by | |
| unfold tensorMeanAt rawTensorMean | |
| simp only [Function.update_eq_self] | |
| unfold fullTensorEnergy fullTensorCoefficient tensorAmplitude patternEnergy rowEvaluation | |
| selectedTensorObservable tensorPerturbation gaussianLinear | |
| apply finiteGibbs_measurable <;> intro x <;> fun_prop | |
| lemma tensorDeviationAt_measurable {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) : | |
| Measurable (fun p : (β β β) Γ PerturbedDisorder M N => tensorDeviationAt hN f s j p.1 p.2) := by | |
| have hm : Measurable (fun v => β«q,tensorMeanAt (M:=M) hN f s j v q βperturbedDisorderLaw M N) := | |
| (tensorMeanAt_measurable hN hf s j).stronglyMeasurable.integral_prod_right.measurable | |
| unfold tensorDeviationAt rawTensorDeviation | |
| change Measurable (fun p : (β β β) Γ PerturbedDisorder M N => | |
| finiteGibbs (fun x => patternEnergy f p.2.2 x+ | |
| fullTensorEnergy hN s (Function.update p.1 (j.val+1) (p.1 (j.val+1))) p.2.1 x) | |
| (fun x => |selectedTensorObservable hN j p.2.1 x- | |
| β«q,tensorMeanAt hN f s j p.1 q βperturbedDisorderLaw M N|)) | |
| simp only [Function.update_eq_self] | |
| apply finiteGibbs_measurable | |
| Β· intro x | |
| unfold patternEnergy rowEvaluation fullTensorEnergy fullTensorCoefficient tensorAmplitude | |
| fun_prop | |
| Β· intro x | |
| apply Measurable.abs | |
| apply Measurable.sub _ (hm.comp measurable_fst) | |
| unfold selectedTensorObservable tensorPerturbation gaussianLinear | |
| fun_prop | |
| def tensorMajorant {N : β} (hN : 0<N) (j : Fin N) | |
| (g : Fin (Fintype.card (FullTensorIndex N)) β β) : β := | |
| βx : Spins N,|selectedTensorObservable hN j g x| | |
| lemma tensorMajorant_memLp {N : β} (hN : 0<N) (j : Fin N) : | |
| MemLp (tensorMajorant hN j) 2 (Measure.pi (fun _ => gaussianReal 0 1)) := by | |
| apply memLp_finsetSum | |
| intro x _ | |
| apply MemLp.abs | |
| unfold selectedTensorObservable tensorPerturbation gaussianLinear | |
| apply memLp_finsetSum | |
| intro i _ | |
| exact ((memLp_id_gaussianReal (ΞΌ:=0) (v:=1) 2).comp_measurePreserving | |
| (measurePreserving_eval (fun _ : Fin (Fintype.card (FullTensorIndex N)) => gaussianReal 0 1) | |
| ((fullTensorEnumeration N).symm β¨j,iβ©))).mul_const _ | |
| lemma tensorMeanAt_bound {M N : β} (hN : 0<N) (f : β β β) (s : β) (j : Fin N) | |
| (v : β β β) (p : PerturbedDisorder M N) : | |
| |tensorMeanAt hN f s j v p| β€ tensorMajorant hN j p.1 := | |
| finiteGibbs_abs _ _ (finiteFunction_bound _) | |
| lemma tensorMeanAt_integrable {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) (v : β β β) : | |
| Integrable (tensorMeanAt hN f s j v) (perturbedDisorderLaw M N) := by | |
| apply (((tensorMajorant_memLp hN j).comp_measurePreserving measurePreserving_fst).integrable | |
| (by norm_num)).mono' | |
| (((tensorMeanAt_measurable hN hf s j).comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable) | |
| exact ae_of_all _ fun p => tensorMeanAt_bound hN f s j v p | |
| lemma tensorDeviationAt_bound {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) (v : β β β) (p : PerturbedDisorder M N) : | |
| |tensorDeviationAt hN f s j v p| β€ tensorMajorant hN j p.1+ | |
| β«q : PerturbedDisorder M N,tensorMajorant hN j q.1 βperturbedDisorderLaw M N := by | |
| apply finiteGibbs_abs | |
| intro x | |
| rw [abs_abs] | |
| apply (abs_sub _ _).trans | |
| apply add_le_add (finiteFunction_bound _ x) | |
| calc | |
| _ β€ β«q,|tensorMeanAt hN f s j v q| βperturbedDisorderLaw M N := by | |
| simpa only [Real.norm_eq_abs,tensorMeanAt] using norm_integral_le_integral_norm (tensorMeanAt hN f s j v) | |
| _ β€ _ := integral_mono (tensorMeanAt_integrable hN hf s j v).abs | |
| (((tensorMajorant_memLp hN j).comp_measurePreserving measurePreserving_fst).integrable (by norm_num)) | |
| (tensorMeanAt_bound hN f s j v) | |
| lemma tensorDeviationAt_integrable {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) (v : β β β) : | |
| Integrable (tensorDeviationAt hN f s j v) (perturbedDisorderLaw M N) := by | |
| apply ((((tensorMajorant_memLp hN j).comp_measurePreserving measurePreserving_fst).integrable | |
| (by norm_num)).add (integrable_const _)).mono' | |
| (((tensorDeviationAt_measurable hN hf s j).comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable) | |
| exact ae_of_all _ fun p => by simpa only [Real.norm_eq_abs,Pi.add_apply,Function.comp_apply,id_eq] using tensorDeviationAt_bound hN hf s j v p | |
| def meanTensorDeviation {M N : β} (hN : 0<N) (f : β β β) (s : β) (j : Fin N) | |
| (v : β β β) : β := β«p,tensorDeviationAt hN f s j v p βperturbedDisorderLaw M N | |
| lemma meanTensorDeviation_measurable {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) : Measurable (meanTensorDeviation (M:=M) hN f s j) := | |
| (tensorDeviationAt_measurable hN hf s j).stronglyMeasurable.integral_prod_right.measurable | |
| lemma meanTensorDeviation_nonneg {M N : β} (hN : 0<N) (f : β β β) (s : β) (j : Fin N) | |
| (v : β β β) : 0 β€ meanTensorDeviation (M:=M) hN f s j v := by | |
| apply integral_nonneg | |
| intro p | |
| apply finiteGibbs_nonneg | |
| intro x | |
| exact abs_nonneg _ | |
| lemma meanTensorDeviation_bound {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) (v : β β β) : | |
| |meanTensorDeviation (M:=M) hN f s j v| β€ | |
| 2*β«q : PerturbedDisorder M N,tensorMajorant hN j q.1 βperturbedDisorderLaw M N := by | |
| have hi : Integrable (fun q : PerturbedDisorder M N => tensorMajorant hN j q.1) (perturbedDisorderLaw M N) := ((tensorMajorant_memLp hN j).comp_measurePreserving measurePreserving_fst).integrable | |
| (by norm_num : (1:ENNReal)β€2) | |
| calc | |
| _ β€ β«p,|tensorDeviationAt hN f s j v p| βperturbedDisorderLaw M N := by | |
| simpa only [Real.norm_eq_abs,meanTensorDeviation] using norm_integral_le_integral_norm (tensorDeviationAt hN f s j v) | |
| _ β€ β«p,tensorMajorant hN j p.1+(β«q : PerturbedDisorder M N,tensorMajorant hN j q.1 | |
| βperturbedDisorderLaw M N) βperturbedDisorderLaw M N := | |
| integral_mono (tensorDeviationAt_integrable hN hf s j v).abs (hi.add (integrable_const _)) | |
| (tensorDeviationAt_bound hN hf s j v) | |
| _ = _ := by rw [integral_add hi (integrable_const _)]; simp only [integral_const,probReal_univ,one_smul]; ring | |
| lemma meanTensorDeviation_integrable {M N : β} (hN : 0<N) {f : β β β} (hf : Measurable f) | |
| (s : β) (j : Fin N) : | |
| Integrable (meanTensorDeviation (M:=M) hN f s j) sourceParameterLaw := | |
| (bounded_memLp sourceParameterLaw (meanTensorDeviation_measurable hN hf s j) | |
| (meanTensorDeviation_bound hN hf s j)).integrable (by norm_num) | |
| lemma integral_resample_parameter {F : (β β β) β β} | |
| (hF : Integrable F sourceParameterLaw) (j : β) : | |
| (β«v,β«u,F (Function.update v j u) βparameterCoordinateLaw βsourceParameterLaw)= | |
| β«v,F v βsourceParameterLaw := by | |
| have hp := parameter_resampling_preserving parameterCoordinateLaw j | |
| have hi := hp.integrable_comp_of_integrable hF | |
| have hi' : Integrable (Function.uncurry (fun v u => F (Function.update v j u))) | |
| (sourceParameterLaw.prod parameterCoordinateLaw) := hi | |
| rw [integral_integral hi'] | |
| have he : Measure.map (fun p : (β β β) Γ β => Function.update p.1 j p.2) | |
| (sourceParameterLaw.prod parameterCoordinateLaw)=sourceParameterLaw := hp.map_eq | |
| rw [β integral_map hp.measurable.aemeasurable] | |
| Β· rw [he] | |
| Β· simpa only [he] using hF.aestronglyMeasurable | |
| lemma meanTensorDeviation_update {M N : β} (hN : 0<N) (f : β β β) (s : β) | |
| (j : Fin N) (v : β β β) (u : β) : | |
| meanTensorDeviation (M:=M) hN f s j (Function.update v (j.val+1) u)= | |
| β«p,rawTensorDeviation hN f s v j u p βperturbedDisorderLaw M N := by | |
| simp only [meanTensorDeviation,tensorDeviationAt,rawTensorDeviation,rawTensorMean, | |
| Function.update_self,Function.update_idem] | |
| theorem source_parameter_deviation_rate {M N : β} (hN : 0<N) {Ξ± C : β} (hΞ± : 0 β€ Ξ±) | |
| (hM : (M:β) β€ Ξ±*N) {f : β β β} (hf : Measurable f) (hC : βz,|f z| β€ C) | |
| (j : Fin N) (hΞ· : (N:β)^(-(1:β)/8) β€ 1/2) : | |
| (β«v,meanTensorDeviation (M:=M) hN f (perturbationScale N) j v βsourceParameterLaw)/ | |
| perturbationScale N β€ sourceDeviationRate Ξ± C j.val N := by | |
| have hn : (0:β)<N := by exact_mod_cast hN | |
| have hs : 0<perturbationScale N := rpow_pos_of_pos hn _ | |
| have hi := meanTensorDeviation_integrable (M:=M) hN hf (perturbationScale N) j | |
| have hp := parameter_resampling_preserving parameterCoordinateLaw (j.val+1) | |
| have hir := hp.integrable_comp_of_integrable hi | |
| rw [β integral_resample_parameter hi (j.val+1),β integral_div] | |
| have hi2 : Integrable (fun v => | |
| (β«u,meanTensorDeviation (M:=M) hN f (perturbationScale N) j (Function.update v (j.val+1) u) | |
| βparameterCoordinateLaw)/perturbationScale N) sourceParameterLaw := | |
| hir.integral_prod_left.div_const _ | |
| have hbound : (β«v, (sourceDeviationRate Ξ± C j.val N : β) βsourceParameterLaw)= | |
| sourceDeviationRate Ξ± C j.val N := by simp | |
| rw [β hbound] | |
| apply integral_mono_ae hi2 (integrable_const _) | |
| filter_upwards [sourceParameterLaw_mem] with v hv | |
| rw [integral_parameterCoordinateLaw] | |
| simp_rw [meanTensorDeviation_update] | |
| apply source_rawTensor_deviation_rate hN hΞ± hM hf hC v _ j hΞ· | |
| intro k | |
| constructor <;> linarith [(hv (k.val+1)).1,(hv (k.val+1)).2] | |
| def sourceDeviation (Ξ± : β) (f : β β β) (j N : β) (v : β β β) : β := | |
| if h : j<N then | |
| meanTensorDeviation (M:=patternCount Ξ± N-2) (Nat.lt_of_le_of_lt (Nat.zero_le j) h) | |
| f (perturbationScale N) β¨j,hβ© v/perturbationScale N | |
| else 0 | |
| lemma sourceDeviation_measurable (Ξ± : β) {f : β β β} (hf : Measurable f) (j N : β) : | |
| Measurable (sourceDeviation Ξ± f j N) := by | |
| unfold sourceDeviation | |
| split_ifs with h | |
| Β· exact (meanTensorDeviation_measurable _ hf _ _).div_const _ | |
| Β· exact measurable_const | |
| lemma sourceDeviation_integrable (Ξ± : β) {f : β β β} (hf : Measurable f) (j N : β) : | |
| Integrable (sourceDeviation Ξ± f j N) sourceParameterLaw := by | |
| unfold sourceDeviation | |
| split_ifs with h | |
| Β· exact (meanTensorDeviation_integrable _ hf _ _).div_const _ | |
| Β· exact integrable_const _ | |
| lemma sourceDeviation_nonneg (Ξ± : β) (f : β β β) (j N : β) (v : β β β) : | |
| 0 β€ sourceDeviation Ξ± f j N v := by | |
| unfold sourceDeviation | |
| split_ifs with h | |
| Β· exact div_nonneg (meanTensorDeviation_nonneg _ _ _ _ _) (rpow_nonneg (Nat.cast_nonneg N) _) | |
| Β· exact le_rfl | |
| theorem source_integrated_deviation_tendsto (Ξ± : β) (hΞ± : 0 β€ Ξ±) {f : β β β} | |
| (hf : Measurable f) {C : β} (hC : βz,|f z| β€ C) (j : β) : | |
| Tendsto (fun N => β«v,sourceDeviation Ξ± f j N v βsourceParameterLaw) atTop (π 0) := by | |
| apply squeeze_zero' (Eventually.of_forall (fun N => integral_nonneg (sourceDeviation_nonneg Ξ± f j N))) | |
| _ (sourceDeviationRate_tendsto Ξ± C j) | |
| filter_upwards [eventually_gt_atTop j,source_eta_eventually] with N hN hΞ· | |
| have hn : (0:β)<N := by exact_mod_cast (Nat.lt_of_le_of_lt (Nat.zero_le j) hN) | |
| have hM : ((patternCount Ξ± N-2:β):β) β€ Ξ±*N := | |
| (Nat.cast_le.mpr (Nat.sub_le _ _)).trans (Nat.floor_le (mul_nonneg hΞ± hn.le)) | |
| simp only [sourceDeviation,dite_eq_left hN,integral_div] | |
| exact source_parameter_deviation_rate _ hΞ± hM hf hC β¨j,hNβ© hΞ· | |
| end IsingPerceptron.Main | |
| namespace IsingPerceptron.Main | |
| open Filter Set | |
| open scoped BigOperators Topology | |
| open Classical | |
| def slowDiagonal (b : β β β β β) (N : β) : β := | |
| Nat.findGreatest (fun k => βm,N β€ m β | |
| βj β Finset.range k,b j m β€ 1/((k:β)+1)) N | |
| lemma slowDiagonal_le (b : β β β β β) (N : β) : slowDiagonal b N β€ N := | |
| Nat.findGreatest_le N | |
| lemma slowDiagonal_mono (b : β β β β β) : Monotone (slowDiagonal b) := by | |
| intro M N hMN | |
| exact Nat.findGreatest_mono (fun k hk m hm => hk m (hMN.trans hm)) hMN | |
| lemma slowDiagonal_bound (b : β β β β β) (N : β) : | |
| βj β Finset.range (slowDiagonal b N),b j N β€ 1/((slowDiagonal b N:β)+1) := by | |
| have h0 : βm,N β€ m β βj β Finset.range 0,b j m β€ 1/((0:β)+1) := by simp | |
| have hs : βm,N β€ m β | |
| βj β Finset.range (slowDiagonal b N),b j m β€ 1/((slowDiagonal b N:β)+1) := | |
| Nat.findGreatest_spec (P:=fun k => βm,N β€ m β | |
| βj β Finset.range k,b j m β€ 1/((k:β)+1)) (Nat.zero_le N) (by simpa only [Nat.cast_zero] using h0) | |
| exact hs N le_rfl | |
| lemma slowDiagonal_tendsto {b : β β β β β} | |
| (hb : βj,Tendsto (b j) atTop (π 0)) : | |
| Tendsto (slowDiagonal b) atTop atTop := by | |
| apply tendsto_atTop.mpr | |
| intro k | |
| have hsum : Tendsto (fun N => βj β Finset.range k,b j N) atTop (π 0) := by | |
| simpa using tendsto_finsetSum (Finset.range k) (fun j _ => hb j) | |
| have hp : (0:β)<1/((k:β)+1) := by positivity | |
| obtain β¨n,hnβ© := eventually_atTop.mp (hsum.eventually (gt_mem_nhds hp)) | |
| filter_upwards [eventually_ge_atTop (max k n)] with N hN | |
| apply Nat.le_findGreatest (le_trans (le_max_left _ _) hN) | |
| intro m hm | |
| exact (hn m ((le_max_right _ _).trans (hN.trans hm))).le | |
| lemma slowDiagonal_sum_tendsto {b : β β β β β} | |
| (hb0 : βj N,0 β€ b j N) (hb : βj,Tendsto (b j) atTop (π 0)) : | |
| Tendsto (fun N => βj β Finset.range (slowDiagonal b N),b j N) atTop (π 0) := by | |
| apply squeeze_zero (fun N => Finset.sum_nonneg (fun j _ => hb0 j N)) | |
| (slowDiagonal_bound b) | |
| exact tendsto_one_div_add_atTop_nhds_zero_nat.comp (slowDiagonal_tendsto hb) | |
| end IsingPerceptron.Main | |
| namespace IsingPerceptron.Main | |
| open MeasureTheory ProbabilityTheory Real Filter Set | |
| open scoped BigOperators Topology | |
| def sourceGoodCutoff (Ξ± : β) (f : β β β) : β β β := | |
| slowDiagonal (fun j N => β«v,sourceDeviation Ξ± f j N v βsourceParameterLaw) | |
| def sourceGoodError (Ξ± : β) (f : β β β) (N : β) : β := | |
| βj β Finset.range (sourceGoodCutoff Ξ± f N), | |
| β«v,sourceDeviation Ξ± f j N v βsourceParameterLaw | |
| def sourceGoodTolerance (Ξ± : β) (f : β β β) (N : β) : β := | |
| sqrt (sourceGoodError Ξ± f N)+1/(N:β) | |
| def sourceGoodParameters (Ξ± : β) (f : β β β) (N : β) : Set (β β β) := | |
| {v | βj,v jβIcc (1:β) 2} β© | |
| {v | βj β Finset.range (sourceGoodCutoff Ξ± f N),sourceDeviation Ξ± f j N v β€ | |
| sourceGoodTolerance Ξ± f N} | |
| lemma sourceGoodCutoff_le (Ξ± : β) (f : β β β) (N : β) : sourceGoodCutoff Ξ± f N β€ N := | |
| slowDiagonal_le _ _ | |
| lemma sourceGoodCutoff_monotone (Ξ± : β) (f : β β β) : Monotone (sourceGoodCutoff Ξ± f) := | |
| slowDiagonal_mono _ | |
| lemma sourceGoodCutoff_tendsto (Ξ± : β) (hΞ± : 0 β€ Ξ±) {f : β β β} | |
| (hf : Measurable f) {C : β} (hC : βz,|f z| β€ C) : | |
| Tendsto (sourceGoodCutoff Ξ± f) atTop atTop := | |
| slowDiagonal_tendsto (source_integrated_deviation_tendsto Ξ± hΞ± hf hC) | |
| lemma sourceGoodError_nonneg (Ξ± : β) (f : β β β) (N : β) : 0 β€ sourceGoodError Ξ± f N := | |
| Finset.sum_nonneg (fun j _ => integral_nonneg (sourceDeviation_nonneg Ξ± f j N)) | |
| lemma sourceGoodError_tendsto (Ξ± : β) (hΞ± : 0 β€ Ξ±) {f : β β β} | |
| (hf : Measurable f) {C : β} (hC : βz,|f z| β€ C) : | |
| Tendsto (sourceGoodError Ξ± f) atTop (π 0) := | |
| slowDiagonal_sum_tendsto (fun j N => integral_nonneg (sourceDeviation_nonneg Ξ± f j N)) | |
| (source_integrated_deviation_tendsto Ξ± hΞ± hf hC) | |
| lemma sourceGoodTolerance_pos (Ξ± : β) (f : β β β) {N : β} (hN : 0<N) : | |
| 0<sourceGoodTolerance Ξ± f N := by | |
| have hn : (0:β)<N := by exact_mod_cast hN | |
| exact add_pos_of_nonneg_of_pos (sqrt_nonneg _) (one_div_pos.mpr hn) | |
| lemma sourceGoodTolerance_tendsto (Ξ± : β) (hΞ± : 0 β€ Ξ±) {f : β β β} | |
| (hf : Measurable f) {C : β} (hC : βz,|f z| β€ C) : | |
| Tendsto (sourceGoodTolerance Ξ± f) atTop (π 0) := by | |
| have he := sourceGoodError_tendsto Ξ± hΞ± hf hC | |
| have hs := continuous_sqrt.continuousAt.tendsto.comp he | |
| change Tendsto (fun N => sqrt (sourceGoodError Ξ± f N)+1/(N:β)) atTop (π 0) | |
| simpa only [Function.comp_def,sqrt_zero,zero_add] using hs.add | |
| (tendsto_one_div_atTop_nhds_zero_nat (π:=β)) | |
| lemma sourceGoodParameters_measurable (Ξ± : β) {f : β β β} (hf : Measurable f) (N : β) : | |
| MeasurableSet (sourceGoodParameters Ξ± f N) := by | |
| apply MeasurableSet.inter | |
| Β· have hm : MeasurableSet (βj : β,(fun v : β β β => v j)β»ΒΉ' Icc (1:β) 2) := | |
| MeasurableSet.iInter (fun j => measurableSet_Icc.preimage (measurable_pi_apply j)) | |
| convert hm using 1 | |
| ext v | |
| simp only [mem_ofPred_eq,mem_iInter,mem_preimage] | |
| Β· exact measurableSet_le (Finset.measurable_sum _ (fun j _ => sourceDeviation_measurable Ξ± hf j N)) | |
| measurable_const | |
| lemma sourceGoodParameters_bad_bound (Ξ± : β) {f : β β β} (hf : Measurable f) | |
| {N : β} (hN : 0<N) : | |
| sourceParameterLaw.real (sourceGoodParameters Ξ± f N)αΆ β€ | |
| sourceGoodError Ξ± f N/sourceGoodTolerance Ξ± f N := by | |
| let A := fun v => βj β Finset.range (sourceGoodCutoff Ξ± f N),sourceDeviation Ξ± f j N v | |
| have hA : Integrable A sourceParameterLaw := | |
| integrable_finsetSum _ (fun j _ => sourceDeviation_integrable Ξ± hf j N) | |
| have hA0 : βv,0 β€ A v := fun v => | |
| Finset.sum_nonneg (fun j _ => sourceDeviation_nonneg Ξ± f j N v) | |
| have he : (β«v,A v βsourceParameterLaw)=sourceGoodError Ξ± f N := by | |
| exact integral_finsetSum _ (fun j _ => sourceDeviation_integrable Ξ± hf j N) | |
| have hmark := mul_meas_ge_le_integral_of_nonneg (Eventually.of_forall hA0) hA | |
| (sourceGoodTolerance Ξ± f N) | |
| rw [he] at hmark | |
| have hset : sourceParameterLaw (sourceGoodParameters Ξ± f N)αΆ= | |
| sourceParameterLaw {v | sourceGoodTolerance Ξ± f N<A v} := by | |
| apply measure_congr | |
| filter_upwards [sourceParameterLaw_mem] with v hv | |
| apply propext | |
| change (Β¬((βj,v jβIcc (1:β) 2) β§ A v β€ sourceGoodTolerance Ξ± f N)) β | |
| sourceGoodTolerance Ξ± f N<A v | |
| simp only [hv,forall_const,true_and,not_le] | |
| have hle : sourceParameterLaw.real (sourceGoodParameters Ξ± f N)αΆ β€ | |
| sourceParameterLaw.real {v | sourceGoodTolerance Ξ± f N β€ A v} := by | |
| rw [measureReal_def,hset] | |
| exact measureReal_mono (show {v | sourceGoodTolerance Ξ± f N<A v} β | |
| {v | sourceGoodTolerance Ξ± f N β€ A v} from | |
| fun v hv => (show sourceGoodTolerance Ξ± f N<A v from hv).le) | |
| exact (le_div_iffβ (sourceGoodTolerance_pos Ξ± f hN)).mpr | |
| ((mul_le_mul_of_nonneg_right hle (sourceGoodTolerance_pos Ξ± f hN).le).trans | |
| (by simpa only [mul_comm] using hmark)) | |
| lemma sourceGoodParameters_bad_sqrt (Ξ± : β) {f : β β β} (hf : Measurable f) | |
| {N : β} (hN : 0<N) : | |
| sourceParameterLaw.real (sourceGoodParameters Ξ± f N)αΆ β€ sqrt (sourceGoodError Ξ± f N) := by | |
| apply (sourceGoodParameters_bad_bound Ξ± hf hN).trans | |
| apply (div_le_iffβ (sourceGoodTolerance_pos Ξ± f hN)).mpr | |
| have hs := sq_sqrt (sourceGoodError_nonneg Ξ± f N) | |
| have hp : 0 β€ sqrt (sourceGoodError Ξ± f N)*(1/(N:β)) := by positivity | |
| dsimp [sourceGoodTolerance] | |
| nlinarith | |
| lemma sourceGoodParameters_probability (Ξ± : β) (hΞ± : 0 β€ Ξ±) {f : β β β} | |
| (hf : Measurable f) {C : β} (hC : βz,|f z| β€ C) : | |
| Tendsto (fun N => sourceParameterLaw.real (sourceGoodParameters Ξ± f N)) atTop (π 1) := by | |
| have hb : Tendsto (fun N => sourceParameterLaw.real (sourceGoodParameters Ξ± f N)αΆ) | |
| atTop (π 0) := by | |
| apply squeeze_zero' (Eventually.of_forall (fun N => ENNReal.toReal_nonneg)) | |
| Β· filter_upwards [eventually_gt_atTop 0] with N hN | |
| exact sourceGoodParameters_bad_sqrt Ξ± hf hN | |
| Β· simpa only [Function.comp_def,sqrt_zero] using | |
| continuous_sqrt.continuousAt.tendsto.comp (sourceGoodError_tendsto Ξ± hΞ± hf hC) | |
| have he (N : β) : sourceParameterLaw.real (sourceGoodParameters Ξ± f N)= | |
| 1-sourceParameterLaw.real (sourceGoodParameters Ξ± f N)αΆ := by | |
| rw [measureReal_compl (sourceGoodParameters_measurable Ξ± hf N)] | |
| simp | |
| simp_rw [he] | |
| simpa using tendsto_const_nhds.sub hb | |
| lemma sourceGoodParameters_uniform {Ξ± : β} {f : β β β} {j N : β} | |
| (hj : j<sourceGoodCutoff Ξ± f N) {v : β β β} (hv : vβsourceGoodParameters Ξ± f N) : | |
| sourceDeviation Ξ± f j N v β€ sourceGoodTolerance Ξ± f N := by | |
| exact (Finset.single_le_sum (fun k _ => sourceDeviation_nonneg Ξ± f k N v) | |
| (Finset.mem_range.mpr hj)).trans hv.2 | |
| theorem source_good_parameters (Ξ± : β) (hΞ± : 0 β€ Ξ±) {f : β β β} | |
| (hf : Measurable f) {C : β} (hC : βz,|f z| β€ C) : | |
| (Monotone (sourceGoodCutoff Ξ± f) β§ Tendsto (sourceGoodCutoff Ξ± f) atTop atTop) β§ | |
| Tendsto (fun N => sourceParameterLaw.real (sourceGoodParameters Ξ± f N)) atTop (π 1) β§ | |
| βv : β β (β β β),(βαΆ N in atTop,v NβsourceGoodParameters Ξ± f N) β | |
| βj,Tendsto (fun N => sourceDeviation Ξ± f j N (v N)) atTop (π 0) := by | |
| refine β¨β¨sourceGoodCutoff_monotone Ξ± f,sourceGoodCutoff_tendsto Ξ± hΞ± hf hCβ©, | |
| sourceGoodParameters_probability Ξ± hΞ± hf hC,?_β© | |
| intro v hv j | |
| apply squeeze_zero' (Eventually.of_forall (fun N => sourceDeviation_nonneg Ξ± f j N (v N))) | |
| _ (sourceGoodTolerance_tendsto Ξ± hΞ± hf hC) | |
| filter_upwards [hv,(sourceGoodCutoff_tendsto Ξ± hΞ± hf hC).eventually (eventually_gt_atTop j)] with N hv hj | |
| exact sourceGoodParameters_uniform hj hv | |
| end IsingPerceptron.Main | |
| end | |
| end OAI | |