File size: 4,788 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | import Mathlib
import OAI.Probability.SKRatio.Calculus.PlusSpin
import OAI.Probability.SKRatio.Variational.ScalarKernel
namespace OAI
section
noncomputable section
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Filter Set Real
namespace SKRatio.Planted
open Scalar Calculus
abbrev FieldWeight := Set.Icc (0:β) 2
instance : CompactSpace FieldWeight := inferInstanceAs (CompactSpace (Set.Icc (0:β) 2))
def compactWeight (h : β) : FieldWeight :=
β¨w h, (w_pos h).le, by unfold w; linarith [(m_bounds h).1]β©
lemma compactWeight_lipschitz : LipschitzWith 1 compactWeight := by
apply LipschitzWith.of_dist_le_mul
intro h t
change |w h-w t| β€ (1:β)*|h-t|
simpa only [w,m,sub_sub_sub_cancel_left,abs_sub_comm,one_mul] using tanh_lipschitz_abs h t
@[simp] lemma compactWeight_coe (h : β) : (compactWeight h : β) = w h := rfl
def compactV (a : FieldWeight) : β := (a:β)*(2-a)
def compactF (p : FieldWeight Γ FieldWeight) : β :=
(p.2:β)^2*(2-p.2)^2/((p.1:β)+p.2)
def compactK (p : FieldWeight Γ FieldWeight) : β :=
compactV p.1*compactV p.2/((p.1:β)+p.2)
lemma compactV_nonneg (a : FieldWeight) : 0β€compactV a :=
mul_nonneg a.2.1 (sub_nonneg.mpr a.2.2)
lemma compactV_le_one (a : FieldWeight) : compactV aβ€1 := by
dsimp [compactV]
nlinarith [sq_nonneg ((a:β)-1)]
lemma compactV_le (a : FieldWeight) : compactV aβ€2*a := by
dsimp [compactV]
nlinarith [sq_nonneg (a:β)]
lemma compactF_nonneg (p : FieldWeight Γ FieldWeight) : 0β€compactF p := by
unfold compactF
exact div_nonneg (mul_nonneg (sq_nonneg _) (sq_nonneg _)) (add_nonneg p.1.2.1 p.2.2.1)
lemma compactK_nonneg (p : FieldWeight Γ FieldWeight) : 0β€compactK p := by
unfold compactK
exact div_nonneg (mul_nonneg (compactV_nonneg _) (compactV_nonneg _)) (add_nonneg p.1.2.1 p.2.2.1)
lemma compactF_bound (p : FieldWeight Γ FieldWeight) : compactF p β€ 4*(p.2:β) := by
by_cases hz : (p.1:β)+(p.2:β)=0
Β· simp only [compactF,hz,div_zero]
exact mul_nonneg (by norm_num) p.2.2.1
have hd : 0<(p.1:β)+(p.2:β) := lt_of_le_of_ne (add_nonneg p.1.2.1 p.2.2.1) (Ne.symm hz)
apply (div_le_iffβ hd).mpr
have hs : (2-(p.2:β))^2β€4 := by nlinarith [p.2.2.1,p.2.2.2]
have hm := mul_le_mul_of_nonneg_left hs (sq_nonneg (p.2:β))
nlinarith only [hm,mul_nonneg p.1.2.1 p.2.2.1]
lemma compactK_bound (p : FieldWeight Γ FieldWeight) : compactK p β€ 4*(p.2:β) := by
by_cases hz : (p.1:β)+(p.2:β)=0
Β· simp only [compactK,hz,div_zero]
exact mul_nonneg (by norm_num) p.2.2.1
have hd : 0<(p.1:β)+(p.2:β) := lt_of_le_of_ne (add_nonneg p.1.2.1 p.2.2.1) (Ne.symm hz)
apply (div_le_iffβ hd).mpr
have hm := mul_le_mul (compactV_le p.1) (compactV_le p.2)
(compactV_nonneg p.2) (mul_nonneg (by norm_num : (0:β)β€2) p.1.2.1)
nlinarith only [hm,sq_nonneg (p.2:β)]
lemma continuous_compactV : Continuous compactV := by unfold compactV; fun_prop
lemma continuous_compact_div {f : FieldWeight Γ FieldWeight β β}
(hnonneg : β p, 0β€f p) (hbound : β p, f pβ€4*(p.2:β))
(hoff : β p, (p.1:β)+(p.2:β)β 0 β ContinuousAt f p) : Continuous f := by
apply continuous_iff_continuousAt.mpr
intro p
by_cases hz : (p.1:β)+(p.2:β)=0
Β· have h2 : (p.2:β)=0 := by linarith [p.1.2.1,p.2.2.1]
have hp : f p=0 := le_antisymm (by simpa [h2] using hbound p) (hnonneg p)
rw [ContinuousAt,hp]
apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds
(h := fun q : FieldWeight Γ FieldWeight => 4*(q.2:β))
(by simpa only [ContinuousAt,h2,mul_zero] using
(show Continuous (fun q : FieldWeight Γ FieldWeight => 4*(q.2:β)) by fun_prop).continuousAt (x := p))
hnonneg hbound
Β· exact hoff p hz
lemma continuous_compactF : Continuous compactF := by
apply continuous_compact_div compactF_nonneg compactF_bound
intro p hp
exact ContinuousAt.div (by fun_prop) (by fun_prop) hp
lemma continuous_compactK : Continuous compactK := by
apply continuous_compact_div compactK_nonneg compactK_bound
intro p hp
exact ContinuousAt.div
((continuous_compactV.comp continuous_fst).mul (continuous_compactV.comp continuous_snd)).continuousAt
(by fun_prop) hp
lemma compactV_weight (h : β) : compactV (compactWeight h) = v h := by
unfold compactV compactWeight w v
dsimp
ring
lemma compactF_weight (h t : β) : compactF (compactWeight h,compactWeight t) =
v t^2/(w h+w t) := by
unfold compactF
simp only [compactWeight_coe,βmul_pow]
rw [show w t*(2-w t)=v t from compactV_weight t]
lemma compactK_weight (h t : β) : compactK (compactWeight h,compactWeight t) =
kernel h t := by
unfold compactK kernel
rw [compactV_weight,compactV_weight]
rfl
end SKRatio.Planted
end
end
end OAI
|