Download data/lean/OAI/Probability/Perceptron/Variational/CompactEnvelope.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.76 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Variational/CompactEnvelope.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Perceptron/Variational/CompactEnvelope.lean
-
curl -L -o CompactEnvelope.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Variational/CompactEnvelope.lean
5.76 kB
| import Mathlib | |
| import OAI.Probability.Perceptron.Pressure.FiniteTerminal | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped Topology BigOperators BoundedContinuousFunction ContDiff | |
| namespace SphericalPerceptronFreeEnergy | |
| def Jet3.addConstant (g : Jet3) (c : β) : Jet3 where | |
| f:=g.f+BoundedContinuousFunction.const β c | |
| d1:=g.d1 | |
| d2:=g.d2 | |
| d3:=g.d3 | |
| has1 x:=by | |
| change HasDerivAt (fun y => g.f y + c) (g.d1 x) x | |
| exact (g.has1 x).add_const c | |
| has2:=g.has2 | |
| has3:=g.has3 | |
| def Jet3.negative (g : Jet3) : Jet3 where | |
| f:=-g.f | |
| d1:=-g.d1 | |
| d2:=-g.d2 | |
| d3:=-g.d3 | |
| has1 x:=by simpa using (g.has1 x).neg | |
| has2 x:=by simpa using (g.has2 x).neg | |
| has3 x:=by simpa using (g.has3 x).neg | |
| lemma exists_smooth_lower_envelope (f : ββα΅β) {R Ξ΅ : β} (hR : 0<R) (hΞ΅ : 0<Ξ΅) : | |
| β g : Jet3, | |
| HasCompactSupport (g.d1 : βββ) β§ HasCompactSupport (g.d2 : βββ) β§ | |
| HasCompactSupport (g.d3 : βββ) β§ βg.fββ€βfβ+2*Ξ΅ β§ | |
| (β x : β,g.f xβ€f x) β§ (β x : β,|x|β€Rβ|g.f x-f x|β€2*Ξ΅) := by | |
| let K:=βfβ | |
| let Ο : ContDiffBump (0:β):=β¨R,R+1,hR,by linarithβ© | |
| let F : βββ:=fun x=>Ο x*(f x+K) | |
| have hF : Continuous F:=Ο.continuous.mul (f.continuous.add continuous_const) | |
| have hFs : HasCompactSupport F:=Ο.hasCompactSupport.mul_right | |
| obtain β¨g,hg,hgf,hgsβ©:=hF.exists_contDiff_approx (β€:ββ) | |
| (Ξ΅:=fun _=>Ξ΅) continuous_const (fun _=>hΞ΅) | |
| have hg' : ContDiff β β g:=hg | |
| have hs : HasCompactSupport g:=hFs.mono hgs | |
| let J:=(Jet3.ofCompactSmooth g hg' hs).addConstant (-K-Ξ΅) | |
| have hJ (x : β) : J.f x=g x-K-Ξ΅ := by simp [J,Jet3.addConstant]; ring | |
| have hzero (x : β) : 0β€F x := by | |
| have hf:= (abs_le.mp (f.norm_coe_le_norm x)).1 | |
| dsimp [F,K] | |
| exact mul_nonneg Ο.nonneg (by linarith) | |
| have hle (x : β) : F xβ€f x+K := | |
| mul_le_of_le_one_left (by have hf:=(abs_le.mp (f.norm_coe_le_norm x)).1; dsimp [K]; linarith) Ο.le_one | |
| have herr (x : β) : |g x-F x|<Ξ΅ := by simpa only [Real.dist_eq] using hgf x | |
| have hlower (x : β) : J.f xβ€f x := by | |
| rw [hJ] | |
| have hh:=(abs_lt.mp (herr x)).2 | |
| linarith [hle x] | |
| refine β¨J,?_,?_,?_,?_,hlower,?_β© | |
| Β· change HasCompactSupport (deriv g) | |
| exact hs.deriv | |
| Β· change HasCompactSupport (deriv (deriv g)) | |
| exact hs.deriv.deriv | |
| Β· change HasCompactSupport (deriv (deriv (deriv g))) | |
| exact hs.deriv.deriv.deriv | |
| Β· apply (BoundedContinuousFunction.norm_le (by positivity : 0β€βfβ+2*Ξ΅)).mpr | |
| intro x | |
| rw [Real.norm_eq_abs] | |
| apply abs_le.mpr | |
| constructor | |
| Β· rw [hJ] | |
| have hh:=(abs_lt.mp (herr x)).1 | |
| dsimp [K] at * | |
| linarith [hzero x] | |
| Β· have hh:=(abs_le.mp (f.norm_coe_le_norm x)).2 | |
| linarith [hlower x] | |
| Β· intro x hx | |
| have hΟ : Ο x=1:=Ο.one_of_mem_closedBall (by simpa only [Metric.mem_closedBall,Real.dist_eq,sub_zero] using hx) | |
| have he : F x=f x+K:=by simp [F,hΟ] | |
| rw [hJ] | |
| have hh:=herr x | |
| rw [he] at hh | |
| exact abs_le.mpr β¨by linarith [(abs_lt.mp hh).1],by linarith [(abs_lt.mp hh).2]β© | |
| lemma exists_smooth_lower_sequence (f : ββα΅β) : | |
| β g : ββJet3, | |
| (β n,HasCompactSupport ((g n).d1 : βββ) β§ HasCompactSupport ((g n).d2 : βββ) β§ | |
| HasCompactSupport ((g n).d3 : βββ)) β§ | |
| (β n,β(g n).fββ€βfβ+1) β§ (β n x,(g n).f xβ€f x) β§ | |
| β R : β,0<Rββ Ξ΅ : β,0<Ξ΅ββ N : β,β nβ₯N,β x : β,|x|β€Rβ|(g n).f x-f x|β€Ξ΅ := by | |
| have hx (n : β):=exists_smooth_lower_envelope f | |
| (by positivity : 0<(n:β)+1) (by positivity : 0<(1:β)/(2*((n:β)+1))) | |
| choose g h1 h2 h3 hn hlo he using hx | |
| refine β¨g,(fun n=>β¨h1 n,h2 n,h3 nβ©),?_,hlo,?_β© | |
| Β· intro n | |
| have hh : 2*((1:β)/(2*((n:β)+1)))=1/((n:β)+1) := by field_simp | |
| have hle : (1:β)/((n:β)+1)β€1 := (div_le_one (by positivity)).mpr (by linarith [Nat.cast_nonneg (Ξ±:=β) n]) | |
| have hi:=hn n | |
| rw [hh] at hi | |
| exact hi.trans (by linarith) | |
| Β· intro R hR Ξ΅ hΞ΅ | |
| obtain β¨N1,hN1β©:=exists_nat_ge R | |
| obtain β¨N2,hN2β©:=exists_nat_one_div_lt hΞ΅ | |
| refine β¨max N1 N2,fun n hn x hx=>?_β© | |
| have hN1' : N1β€n:=(le_max_left _ _).trans hn | |
| have hN2' : N2β€n:=(le_max_right _ _).trans hn | |
| have hx' : |x|β€(n:β)+1 := by | |
| have hc : (N1:β)β€n:=by exact_mod_cast hN1' | |
| linarith | |
| have hh:=he n x hx' | |
| have heq : 2*((1:β)/(2*((n:β)+1)))=1/((n:β)+1) := by field_simp | |
| rw [heq] at hh | |
| exact hh.trans ((one_div_le_one_div_of_le (by positivity) (by exact_mod_cast Nat.add_le_add_right hN2' 1)).trans hN2.le) | |
| lemma exists_smooth_upper_sequence (f : ββα΅β) : | |
| β g : ββJet3, | |
| (β n,HasCompactSupport ((g n).d1 : βββ) β§ HasCompactSupport ((g n).d2 : βββ) β§ | |
| HasCompactSupport ((g n).d3 : βββ)) β§ | |
| (β n,β(g n).fββ€βfβ+1) β§ (β n x,f xβ€(g n).f x) β§ | |
| β R : β,0<Rββ Ξ΅ : β,0<Ξ΅ββ N : β,β nβ₯N,β x : β,|x|β€Rβ|(g n).f x-f x|β€Ξ΅ := by | |
| obtain β¨g,hs,hn,hlo,heβ©:=exists_smooth_lower_sequence (-f) | |
| refine β¨fun n=>(g n).negative,fun n=>β¨(hs n).1.neg,(hs n).2.1.neg,(hs n).2.2.negβ©,?_,?_,?_β© | |
| Β· intro n | |
| simpa only [Jet3.negative,norm_neg] using hn n | |
| Β· intro n x | |
| have h:=hlo n x | |
| change f xβ€-(g n).f x | |
| change (g n).f xβ€-f x at h | |
| linarith | |
| Β· intro R hR Ξ΅ hΞ΅ | |
| obtain β¨N,hNβ©:=he R hR Ξ΅ hΞ΅ | |
| refine β¨N,fun n hn x hx=>?_β© | |
| have h:=hN n hn x hx | |
| change |-(g n).f x-f x|β€Ξ΅ | |
| change |(g n).f x- -f x|β€Ξ΅ at h | |
| rw [show -(g n).f x-f x = -((g n).f x+f x) by ring,abs_neg] | |
| simpa only [sub_neg_eq_add] using h | |
| end SphericalPerceptronFreeEnergy | |
| end | |
| end OAI | |