math / data /lean /OAI /Probability /SKFluctuations /Diagonal.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
34.2 kB
import Mathlib
import OAI.Probability.SKFluctuations.MarkedAttachPreserves
import OAI.Probability.SKFluctuations.ScalarWeightedJet
namespace OAI
/-! Diagonal. -/
noncomputable section
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators Topology
open MeasureTheory Filter Set
open scoped Topology
open MeasureTheory ProbabilityTheory Filter Set
namespace SKFluctuations.GaussianCalculus
open MeasureTheory ProbabilityTheory Filter Set Hierarchy
open scoped Topology NNReal BigOperators
variable {ΞΉ : Type*} [Fintype ΞΉ]
theorem ExpNormBounded.diagonal {f : (ΞΉ β†’ ℝ) β†’ ℝ} (hf : ExpNormBounded f)
(x a : ΞΉ β†’ ℝ) : ExpNormBounded (fun z => f (x+a*z)) := by
obtain ⟨C,c,hC,hc,hb⟩ := hf.2
refine ⟨hf.1.comp (continuous_const.add (continuous_const.mul continuous_id)),
C*Real.exp (c*β€–xβ€–), c*β€–aβ€–, by positivity, by positivity, fun z => ?_⟩
calc
_ ≀ C*Real.exp (c*β€–x+a*zβ€–) := hb _
_ ≀ C*Real.exp (c*(β€–xβ€–+β€–aβ€–*β€–zβ€–)) := by
gcongr
exact (norm_add_le _ _).trans (add_le_add le_rfl (norm_mul_le a z))
_ = _ := by rw [mul_add,Real.exp_add]; ring_nf
theorem ExpNormBounded.diagonal_integrable {f : (ΞΉ β†’ ℝ) β†’ ℝ} (hf : ExpNormBounded f)
{Ξ½ : Measure (ΞΉ β†’ ℝ)} (hΞ½ : ExponentialIncrement Ξ½) (x a : ΞΉ β†’ ℝ) :
Integrable (fun z => f (x+a*z)) Ξ½ := by
simpa only [one_smul,zero_add] using (hf.diagonal x a).affine_integrable hΞ½ 0 1
theorem ExpNormBounded.diagonal_coord_integrable {f : (ΞΉ β†’ ℝ) β†’ ℝ} (hf : ExpNormBounded f)
(q : ΞΉ β†’ ℝβ‰₯0) (x a : ΞΉ β†’ ℝ) (i : ΞΉ) :
Integrable (fun z => z i*f (x+a*z)) (Measure.pi fun i => gaussianReal 0 (q i)) := by
simpa only [one_smul,zero_add] using (hf.diagonal x a).affine_coord_integrable q 0 1 i
theorem standardGaussianVector_diagonal_stein {n : β„•} (i : Fin (n+1))
{f f₁ : (Fin (n+1) β†’ ℝ) β†’ ℝ} (hf : ExpNormBounded f) (hf₁ : ExpNormBounded f₁)
(hd : βˆ€ x t, HasDerivAt (fun s : ℝ => f (x+s β€’ Pi.single i 1))
(f₁ (x+t β€’ Pi.single i 1)) t) (x a : Fin (n+1) β†’ ℝ) :
(∫ z, z i*f (x+a*z) βˆ‚Measure.pi (fun _ : Fin (n+1) => gaussianReal 0 1)) =
a i * ∫ z, f₁ (x+a*z) βˆ‚Measure.pi (fun _ : Fin (n+1) => gaussianReal 0 1) := by
have h := standardGaussianVector_stein i
(f := fun z => f (x+a*z)) (f₁ := fun z => a i*f₁ (x+a*z))
?_ (hf.diagonal_integrable (exponentialIncrement_gaussian (fun _ => 1)) x a)
((hf₁.diagonal_integrable (exponentialIncrement_gaussian (fun _ => 1)) x a).const_mul (a i))
(hf.diagonal_coord_integrable (fun _ => 1) x a i)
Β· simpa only [integral_const_mul] using h
Β· intro y t
have he (s : ℝ) : x+a*i.insertNth s y =
(x+a*i.insertNth 0 y)+(a i*s) β€’ Pi.single i 1 := by
ext j
by_cases hj : j = i
Β· subst j
simp
· obtain ⟨k,rfl⟩ := (Fin.eq_self_or_eq_succAbove i j).resolve_left hj
simp
have hd' := (hd (x+a*i.insertNth 0 y) (a i*t)).comp t
((hasDerivAt_id t).const_mul (a i))
simpa only [Function.comp_def, ← he,mul_one] using hd'.congr_deriv (mul_comm _ _)
end SKFluctuations.GaussianCalculus
namespace SKFluctuations.GaussianCalculus
open MeasureTheory ProbabilityTheory Filter Set Hierarchy
open scoped Topology NNReal BigOperators
theorem hasDerivAt_diagonal_heat_continuation {n : β„•}
{F : (Fin (n+1) β†’ ℝ) β†’ ℝ} {G H : Fin (n+1) β†’ (Fin (n+1) β†’ ℝ) β†’ ℝ} {C : ℝβ‰₯0}
(hF : LipschitzWith C F) (hG : βˆ€ i, BddSmooth 0 (G i)) (hH : βˆ€ i, BddSmooth 0 (H i))
(hd : βˆ€ x v t, HasDerivAt (fun s : ℝ => F (x+s β€’ v))
(βˆ‘ i, v i*G i (x+t β€’ v)) t)
(hd₁ : βˆ€ i x t, HasDerivAt (fun s : ℝ => G i (x+s β€’ Pi.single i 1))
(H i (x+t β€’ Pi.single i 1)) t)
{a a' : ℝ β†’ (Fin (n+1) β†’ ℝ)} {l r A B t m : ℝ} (ht : t ∈ Ioo l r)
(ha : βˆ€ s ∈ Ioo l r, HasDerivAt a (a' s) s)
(hA : βˆ€ s ∈ Ioo l r, β€–a sβ€– ≀ A) (hB : βˆ€ s ∈ Ioo l r, β€–a' sβ€– ≀ B)
(hm : m β‰  0) (x : Fin (n+1) β†’ ℝ) :
HasDerivAt (fun s => Real.log (∫ z, Real.exp (m*F (x+a s*z))
βˆ‚Measure.pi (fun _ : Fin (n+1) => gaussianReal 0 1))/m)
(βˆ‘ i, a t i*a' t i *
(tiltedMean (Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1) m
(fun z => F (x+a t*z)) (fun z => H i (x+a t*z)) + m *
tiltedMean (Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1) m
(fun z => F (x+a t*z)) (fun z => (G i (x+a t*z))^2))) t := by
let P := fun y => Real.exp (m*F y)
let P₁ := fun i y => m*G i y*P y
let Pβ‚‚ := fun i y => (m*H i y + m^2*(G i y)^2)*P y
let Ξ½ := Measure.pi (fun _ : Fin (n+1) => gaussianReal 0 1)
have hΞ½ : ExponentialIncrement Ξ½ := exponentialIncrement_gaussian (fun _ => 1)
have hP : ExpNormBounded P := ExpNormBounded.exp_lipschitz hF m
have hB₁ (i) : BddSmooth 0 (fun y => m*G i y) := (hG i).const_mul m
have hBβ‚‚ (i) : BddSmooth 0 (fun y => m*H i y + m^2*(G i y)^2) := by
simpa only [pow_two] using ((hH i).const_mul m).add (((hG i).mul (hG i)).const_mul (m*m))
have hdP (y v : Fin (n+1) β†’ ℝ) (s : ℝ) :
HasDerivAt (fun r : ℝ => P (y+r β€’ v)) (βˆ‘ i, v i*P₁ i (y+s β€’ v)) s := by
apply (((hd y v s).const_mul m).exp).congr_deriv
dsimp [P₁,P]
rw [Finset.mul_sum, Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
ring
have hdP₁ (i) (y : Fin (n+1) β†’ ℝ) (s : ℝ) :
HasDerivAt (fun r : ℝ => P₁ i (y+r β€’ Pi.single i 1))
(Pβ‚‚ i (y+s β€’ Pi.single i 1)) s := by
have hp := hdP y (Pi.single i 1) s
simp only [Pi.single_apply, ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ite_true] at hp
apply (((hd₁ i y s).const_mul m).mul hp).congr_deriv
dsimp [Pβ‚‚,P₁]
ring
have hs (i) : (∫ z, z i*P₁ i (x+a t*z) βˆ‚Ξ½) =
a t i*∫ z, Pβ‚‚ i (x+a t*z) βˆ‚Ξ½ :=
standardGaussianVector_diagonal_stein i (hP.bdd_mul (hB₁ i))
(hP.bdd_mul (hBβ‚‚ i)) (hdP₁ i) x (a t)
have h := hasDerivAt_integral_exp_scaledSource hΞ½ hF (fun i => (hG i).continuous)
hd ht ha hA hB m x
have hp : 0 < ∫ z, P (x+a t*z) βˆ‚Ξ½ := partition_pos m (hP.diagonal_integrable hΞ½ x _)
have hGs (i) : BddSmooth 0 (fun y => (G i y)^2) := by
simpa only [pow_two] using (hG i).mul (hG i)
have hiH (i) : Integrable (fun z => H i (x+a t*z)*P (x+a t*z)) Ξ½ :=
(hP.bdd_mul (hH i)).diagonal_integrable hΞ½ x _
have hiGs (i) : Integrable (fun z => (G i (x+a t*z))^2*P (x+a t*z)) Ξ½ :=
(hP.bdd_mul (hGs i)).diagonal_integrable hΞ½ x _
have he (i) : (∫ z, Pβ‚‚ i (x+a t*z) βˆ‚Ξ½) =
m*(∫ z, H i (x+a t*z)*P (x+a t*z) βˆ‚Ξ½) +
m^2*(∫ z, (G i (x+a t*z))^2*P (x+a t*z) βˆ‚Ξ½) := by
rw [← integral_const_mul, ← integral_const_mul,
← integral_add ((hiH i).const_mul m) ((hiGs i).const_mul (m^2))]
apply integral_congr_ae
exact Eventually.of_forall fun z => by dsimp [Pβ‚‚]; ring
have he' : (∫ z, m*(βˆ‘ i, (a' t*z) i*G i (x+a t*z))*P (x+a t*z) βˆ‚Ξ½) =
βˆ‘ i, a' t i*(∫ z, z i*P₁ i (x+a t*z) βˆ‚Ξ½) := by
simp_rw [← integral_const_mul]
rw [← integral_finsetSum _ (fun i _ =>
((hP.bdd_mul (hB₁ i)).diagonal_coord_integrable (fun _ => 1) x (a t) i).const_mul (a' t i))]
apply integral_congr_ae
exact Eventually.of_forall fun z => by
dsimp only
rw [Finset.mul_sum,Finset.sum_mul]
apply Finset.sum_congr rfl
intro i _
dsimp [P₁]
ring
apply ((h.log hp.ne').div_const m).congr_deriv
change ((∫ z, m*(βˆ‘ i, (a' t*z) i*G i (x+a t*z))*P (x+a t*z) βˆ‚Ξ½)/
(∫ z, P (x+a t*z) βˆ‚Ξ½))/m = _
rw [he',Finset.sum_div,Finset.sum_div]
apply Finset.sum_congr rfl
intro i _
rw [hs,he]
simp only [tiltedMean]
dsimp [P,Ξ½] at *
field_simp
end SKFluctuations.GaussianCalculus
namespace SKFluctuations.GaussianCalculus
open MeasureTheory ProbabilityTheory Filter Set Hierarchy
open scoped Topology NNReal BigOperators
theorem hasDerivAt_signed_variance_continuation {n : β„•}
{F : (Fin (n+1) β†’ ℝ) β†’ ℝ} {G H : Fin (n+1) β†’ (Fin (n+1) β†’ ℝ) β†’ ℝ} {C : ℝβ‰₯0}
(hF : LipschitzWith C F) (hG : βˆ€ i, BddSmooth 0 (G i)) (hH : βˆ€ i, BddSmooth 0 (H i))
(hd : βˆ€ x v t, HasDerivAt (fun s : ℝ => F (x+s β€’ v))
(βˆ‘ i, v i*G i (x+t β€’ v)) t)
(hd₁ : βˆ€ i x t, HasDerivAt (fun s : ℝ => G i (x+s β€’ Pi.single i 1))
(H i (x+t β€’ Pi.single i 1)) t)
(q d : Fin (n+1) β†’ ℝ) {t m : ℝ} (ht : βˆ€ i, 0 < q i+t*d i) (hm : m β‰  0)
(x : Fin (n+1) β†’ ℝ) :
HasDerivAt (fun s => Real.log (∫ z, Real.exp (m*F (x+(fun i => Real.sqrt (q i+s*d i))*z))
βˆ‚Measure.pi (fun _ : Fin (n+1) => gaussianReal 0 1))/m)
(βˆ‘ i, (d i/2) *
(tiltedMean (Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1) m
(fun z => F (x+(fun i => Real.sqrt (q i+t*d i))*z))
(fun z => H i (x+(fun i => Real.sqrt (q i+t*d i))*z)) + m *
tiltedMean (Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1) m
(fun z => F (x+(fun i => Real.sqrt (q i+t*d i))*z))
(fun z => (G i (x+(fun i => Real.sqrt (q i+t*d i))*z))^2))) t := by
let a := fun s i => Real.sqrt (q i+s*d i)
let a' := fun s i => d i/(2*Real.sqrt (q i+s*d i))
have ha : Continuous a := continuous_pi fun i => (continuous_const.add (continuous_id.mul continuous_const)).sqrt
have ha' : ContinuousAt a' t := continuousAt_pi.mpr fun i =>
continuousAt_const.div (continuousAt_const.mul
(continuousAt_const.add (continuousAt_id.mul continuousAt_const)).sqrt)
(mul_ne_zero (by norm_num) (Real.sqrt_ne_zero'.mpr (ht i)))
have hp : βˆ€αΆ  s in 𝓝 t, βˆ€ i, 0 < q i+s*d i := by
rw [eventually_all]
intro i
exact (continuousAt_const.add (continuousAt_id.mul continuousAt_const)).eventually
(eventually_gt_nhds (ht i))
have hA : βˆ€αΆ  s in 𝓝 t, β€–a sβ€– ≀ β€–a tβ€–+1 :=
(ha.continuousAt.norm.eventually (eventually_lt_nhds (lt_add_one _))).mono fun _ h => h.le
have hB : βˆ€αΆ  s in 𝓝 t, β€–a' sβ€– ≀ β€–a' tβ€–+1 :=
(ha'.norm.eventually (eventually_lt_nhds (lt_add_one _))).mono fun _ h => h.le
obtain ⟨l,r,htr,hlr⟩ := (hp.and (hA.and hB)).exists_Ioo_subset
have haD (s) (hs : s ∈ Ioo l r) : HasDerivAt a (a' s) s := by
apply hasDerivAt_pi.mpr
intro i
simpa only [a, a', id_eq, one_mul] using
(((hasDerivAt_id s).mul_const (d i)).const_add (q i)).sqrt ((hlr hs).1 i).ne'
have hh := hasDerivAt_diagonal_heat_continuation hF hG hH hd hd₁ htr haD
(fun s hs => (hlr hs).2.1) (fun s hs => (hlr hs).2.2) hm x
apply hh.congr_deriv
apply Finset.sum_congr rfl
intro i _
dsimp [a,a']
rw [show Real.sqrt (q i+t*d i)*(d i/(2*Real.sqrt (q i+t*d i))) = d i/2 by
field_simp [Real.sqrt_ne_zero'.mpr (ht i)]]
end SKFluctuations.GaussianCalculus
namespace SKFluctuations.Hierarchy
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal BigOperators
variable {ΞΉ : Type*} [Fintype ΞΉ]
theorem integral_diagonalGaussian (q : ΞΉ β†’ ℝβ‰₯0) {f : (ΞΉ β†’ ℝ) β†’ ℝ} (hf : Continuous f) :
(∫ z, f (fun i => Real.sqrt (q i)*z i) βˆ‚Measure.pi fun _ : ΞΉ => gaussianReal 0 1) =
∫ z, f z βˆ‚Measure.pi fun i => gaussianReal 0 (q i) := by
have hh := integral_map_of_stronglyMeasurable (ΞΌ := Measure.pi fun _ : ΞΉ => gaussianReal 0 1)
(diagonalDriver q).measurable hf.stronglyMeasurable
change (∫ z, f z βˆ‚linearGaussian (diagonalDriver q) 1) = _ at hh
rw [linearGaussian_diagonal] at hh
exact hh.symm
noncomputable def varianceContinuation (m : ℝ) (F : (ΞΉ β†’ ℝ) β†’ ℝ) (q : ΞΉ β†’ ℝ) : (ΞΉ β†’ ℝ) β†’ ℝ :=
shiftedContinuation (Measure.pi fun i => gaussianReal 0 (Real.toNNReal (q i))) m F
noncomputable def varianceTest (m : ℝ) (F A : (ΞΉ β†’ ℝ) β†’ ℝ) (q : ΞΉ β†’ ℝ) : (ΞΉ β†’ ℝ) β†’ ℝ :=
shiftedMean (Measure.pi fun i => gaussianReal 0 (Real.toNNReal (q i))) m F A
theorem varianceContinuation_eq {F : (ΞΉ β†’ ℝ) β†’ ℝ} (hF : Continuous F)
(m : ℝ) {q : ΞΉ β†’ ℝ} (hq : βˆ€ i, 0 ≀ q i) (x : ΞΉ β†’ ℝ) :
varianceContinuation m F q x = Real.log (∫ z, Real.exp (m*F (x+(fun i => Real.sqrt (q i))*z))
βˆ‚Measure.pi fun _ : ΞΉ => gaussianReal 0 1)/m := by
have hi := integral_diagonalGaussian (fun i => Real.toNNReal (q i))
(f := fun z => Real.exp (m*F (x+z))) (by fun_prop)
simp only [Real.coe_toNNReal _ (hq _)] at hi
exact congrArg (fun z => Real.log z/m) hi.symm
theorem varianceTest_eq {F A : (ΞΉ β†’ ℝ) β†’ ℝ} (hF : Continuous F) (hA : Continuous A)
(m : ℝ) {q : ΞΉ β†’ ℝ} (hq : βˆ€ i, 0 ≀ q i) (x : ΞΉ β†’ ℝ) :
varianceTest m F A q x = tiltedMean (Measure.pi fun _ : ΞΉ => gaussianReal 0 1) m
(fun z => F (x+(fun i => Real.sqrt (q i))*z)) (fun z => A (x+(fun i => Real.sqrt (q i))*z)) := by
have hn := integral_diagonalGaussian (fun i => Real.toNNReal (q i))
(f := fun z => A (x+z)*Real.exp (m*F (x+z))) (by fun_prop)
have hd := integral_diagonalGaussian (fun i => Real.toNNReal (q i))
(f := fun z => Real.exp (m*F (x+z))) (by fun_prop)
simp only [Real.coe_toNNReal _ (hq _)] at hn hd
exact congrArgβ‚‚ (Β· / Β·) hn.symm hd.symm
end SKFluctuations.Hierarchy
namespace SKFluctuations.Hierarchy
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal BigOperators
variable {ΞΉ : Type*} [Fintype ΞΉ]
noncomputable def signedVarianceDerivative (m : ℝ) (F : (ΞΉ β†’ ℝ) β†’ ℝ)
(G H : ΞΉ β†’ (ΞΉ β†’ ℝ) β†’ ℝ) (d q : ΞΉ β†’ ℝ) (x : ΞΉ β†’ ℝ) : ℝ :=
βˆ‘ i, (d i/2)*(varianceTest m F (H i) q x + m*varianceTest m F (fun y => (G i y)^2) q x)
theorem parametric_signed_variance {n : β„•}
{F : (Fin (n+1) β†’ ℝ) β†’ ℝ} {G H : Fin (n+1) β†’ (Fin (n+1) β†’ ℝ) β†’ ℝ} {C : ℝβ‰₯0}
(hF : LipschitzWith C F) (hG : βˆ€ i, BddSmooth 0 (G i)) (hH : βˆ€ i, BddSmooth 0 (H i))
(hd : βˆ€ x v t, HasDerivAt (fun s : ℝ => F (x+s β€’ v))
(βˆ‘ i, v i*G i (x+t β€’ v)) t)
(hd₁ : βˆ€ i x t, HasDerivAt (fun s : ℝ => G i (x+s β€’ Pi.single i 1))
(H i (x+t β€’ Pi.single i 1)) t)
(q d : Fin (n+1) β†’ ℝ) {m : ℝ} (hm : 0 < m) :
βˆƒ K, βˆ€ l r, (βˆ€ t ∈ Ioo l r, βˆ€ i, 0 < q i+t*d i) β†’
ParametricRegular l r K
(fun t => varianceContinuation m F (fun i => q i+t*d i))
(fun t => signedVarianceDerivative m F G H d (fun i => q i+t*d i)) := by
have hGs (i) : BddSmooth 0 (fun y => (G i y)^2) := by
simpa only [pow_two] using (hG i).mul (hG i)
choose BH hBH bH using fun i => (hH i).bound
choose BG hBG bG using fun i => (hGs i).bound
let K : ℝ := βˆ‘ i, (|d i|/2)*(BH i+m*BG i)
have hK : 0 ≀ K := Finset.sum_nonneg fun i _ =>
mul_nonneg (div_nonneg (abs_nonneg _) (by norm_num))
(add_nonneg (hBH i) (mul_nonneg hm.le (hBG i)))
have hi (t : ℝ) (x : Fin (n+1) β†’ ℝ) :
Integrable (fun z => Real.exp (m*F (x+z)))
(Measure.pi fun i => gaussianReal 0 (Real.toNNReal (q i+t*d i))) :=
(exponentialIncrement_gaussian _).integrable_shift hF m x
refine ⟨K, fun l r hq => ⟨hK, ?_, ?_, ?_, ?_⟩⟩
Β· intro t _
exact ⟨C,lipschitzWith_shiftedContinuation hF hm (hi t)⟩
Β· intro t _
exact continuous_finsetSum _ fun i _ =>
((continuous_shiftedMean hF (hH i).continuous (hBH i) (bH i) (hi t)).add
((continuous_shiftedMean hF (hGs i).continuous (hBG i) (bG i) (hi t)).const_mul m)).const_mul (d i/2)
Β· intro t _ x
have hBH' (i) : |varianceTest m F (H i) (fun i => q i+t*d i) x| ≀ BH i :=
abs_tiltedMean_le ((hH i).continuous.comp (continuous_const.add continuous_id)).measurable
(hi t x) (fun z => bH i (x+z))
have hBG' (i) : |varianceTest m F (fun y => (G i y)^2) (fun i => q i+t*d i) x| ≀ BG i :=
abs_tiltedMean_le ((hGs i).continuous.comp (continuous_const.add continuous_id)).measurable
(hi t x) (fun z => bG i (x+z))
apply (Finset.abs_sum_le_sum_abs _ _).trans
apply Finset.sum_le_sum
intro i _
rw [abs_mul,abs_div,abs_of_pos (by norm_num : (0:ℝ) < 2)]
apply mul_le_mul_of_nonneg_left _ (by positivity)
apply (abs_add_le _ _).trans
rw [abs_mul,abs_of_pos hm]
exact add_le_add (hBH' i) (mul_le_mul_of_nonneg_left (hBG' i) hm.le)
Β· intro t ht x
have hh := GaussianCalculus.hasDerivAt_signed_variance_continuation hF hG hH hd hd₁ q d
(hq t ht) hm.ne' x
have he : (fun s => varianceContinuation m F (fun i => q i+s*d i) x) =αΆ [𝓝 t]
(fun s => Real.log (∫ z, Real.exp (m*F (x+(fun i => Real.sqrt (q i+s*d i))*z))
βˆ‚Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1)/m) := by
filter_upwards [Ioo_mem_nhds ht.1 ht.2] with s hs
exact varianceContinuation_eq hF.continuous m (fun i => (hq s hs i).le) x
have hde : signedVarianceDerivative m F G H d (fun i => q i+t*d i) x =
(βˆ‘ i, (d i/2)*(tiltedMean (Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1) m
(fun z => F (x+(fun i => Real.sqrt (q i+t*d i))*z))
(fun z => H i (x+(fun i => Real.sqrt (q i+t*d i))*z)) + m*
tiltedMean (Measure.pi fun _ : Fin (n+1) => gaussianReal 0 1) m
(fun z => F (x+(fun i => Real.sqrt (q i+t*d i))*z))
(fun z => (G i (x+(fun i => Real.sqrt (q i+t*d i))*z))^2))) := by
simp only [signedVarianceDerivative,varianceTest_eq hF.continuous (hH _).continuous m
(fun i => (hq t ht i).le),varianceTest_eq hF.continuous (hGs _).continuous m
(fun i => (hq t ht i).le)]
rw [hde]
exact hh.congr_of_eventuallyEq he
end SKFluctuations.Hierarchy
namespace SKFluctuations.Hierarchy
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal BigOperators
variable {ΞΉ S : Type*} [Fintype ΞΉ] [Fintype S] [Nonempty S]
noncomputable def hierarchyAtom (w : S β†’ ℝ) (Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ)
(steps : List (GaussianStep ΞΉ)) (Οƒ : S) (x : ΞΉ β†’ ℝ) : ℝ := by
classical
exact gaussianHierarchyMean w Ο† (fun Ο„ => if Ο„ = Οƒ then 1 else 0) steps x
theorem hierarchyAtom_nonneg {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (Οƒ : S) (x : ΞΉ β†’ ℝ) :
0 ≀ hierarchyAtom w Ο† steps Οƒ x := by
classical
exact gaussianHierarchyMean_nonneg hw Ο† (fun Ο„ => by split_ifs <;> norm_num) steps ha x
theorem hierarchyAtom_smooth {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (Οƒ : S) (r : β„•) :
BddSmooth r (hierarchyAtom w Ο† steps Οƒ) :=
gaussianHierarchyMean_smooth hw Ο† _ steps ha r
theorem gaussianHierarchyMean_atoms {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (A : S β†’ ℝ) (x : ΞΉ β†’ ℝ) :
gaussianHierarchyMean w Ο† A steps x = βˆ‘ Οƒ, A Οƒ*hierarchyAtom w Ο† steps Οƒ x := by
classical
have he : A = fun Ο„ => βˆ‘ Οƒ, A Οƒ*(if Ο„ = Οƒ then 1 else 0) := by
funext Ο„
simp
conv_lhs => rw [he]
rw [gaussianHierarchyMean_sum hw Ο† steps ha]
apply Finset.sum_congr rfl
intro Οƒ _
exact congrFun (gaussianHierarchyMean_const_mul_ordered hw Ο† _ steps ha (A Οƒ)) x
theorem hierarchyAtom_sum {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
βˆ‘ Οƒ, hierarchyAtom w Ο† steps Οƒ x = 1 := by
have h := gaussianHierarchyMean_atoms hw Ο† steps ha (fun _ => 1) x
rw [gaussianHierarchyMean_const hw Ο† steps ha] at h
simpa only [one_mul] using h.symm
noncomputable def hierarchyPairMean (w : S β†’ ℝ) (Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ)
(K : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ)) (x : ΞΉ β†’ ℝ) : ℝ :=
βˆ‘ Οƒ, βˆ‘ Ο„, (hierarchyAtom w Ο† steps Οƒ x*hierarchyAtom w Ο† steps Ο„ x)*K Οƒ Ο„
theorem hierarchyPairMean_smooth {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (K : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (r : β„•) :
BddSmooth r (hierarchyPairMean w Ο† K steps) := by
apply BddSmooth.sum Finset.univ
intro Οƒ _
apply BddSmooth.sum Finset.univ
intro Ο„ _
simpa only [mul_comm (K Οƒ Ο„)] using
((hierarchyAtom_smooth hw Ο† steps ha Οƒ r).mul
(hierarchyAtom_smooth hw Ο† steps ha Ο„ r)).const_mul (K Οƒ Ο„)
theorem hierarchyPairMean_const {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (c : ℝ) (x : ΞΉ β†’ ℝ) :
hierarchyPairMean w Ο† (fun _ _ => c) steps x = c := by
unfold hierarchyPairMean
simp_rw [← Finset.sum_mul,← Finset.mul_sum,hierarchyAtom_sum hw Ο† steps ha]
simp only [mul_one,hierarchyAtom_sum hw Ο† steps ha]
ring
theorem hierarchyPairMean_mono {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) {K L : S β†’ S β†’ ℝ} (hKL : βˆ€ Οƒ Ο„, K Οƒ Ο„ ≀ L Οƒ Ο„)
(steps : List (GaussianStep ΞΉ)) {a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
hierarchyPairMean w Ο† K steps x ≀ hierarchyPairMean w Ο† L steps x := by
apply Finset.sum_le_sum
intro Οƒ _
apply Finset.sum_le_sum
intro Ο„ _
exact mul_le_mul_of_nonneg_left (hKL Οƒ Ο„) (mul_nonneg
(hierarchyAtom_nonneg hw Ο† steps ha Οƒ x) (hierarchyAtom_nonneg hw Ο† steps ha Ο„ x))
omit [Nonempty S] in
theorem hierarchyPairMean_linear (w : S β†’ ℝ) (Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ)
(K L : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ)) (c d : ℝ) (x : ΞΉ β†’ ℝ) :
hierarchyPairMean w Ο† (fun Οƒ Ο„ => c*K Οƒ Ο„+d*L Οƒ Ο„) steps x =
c*hierarchyPairMean w Ο† K steps x+d*hierarchyPairMean w Ο† L steps x := by
unfold hierarchyPairMean
simp_rw [mul_add,Finset.sum_add_distrib,← mul_assoc]
simp_rw [mul_comm _ c,mul_comm _ d,mul_assoc,← Finset.mul_sum]
theorem hierarchyPairMean_product {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (A B : S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
hierarchyPairMean w Ο† (fun Οƒ Ο„ => A Οƒ*B Ο„) steps x =
gaussianHierarchyMean w Ο† A steps x*gaussianHierarchyMean w Ο† B steps x := by
rw [gaussianHierarchyMean_atoms hw Ο† steps ha,gaussianHierarchyMean_atoms hw Ο† steps ha,
Finset.sum_mul]
simp_rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro Οƒ _
apply Finset.sum_congr rfl
intro Ο„ _
ring
noncomputable def kernelPenalty (w : S β†’ ℝ) (Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ)
(K : S β†’ S β†’ ℝ) : ℝ β†’ List (GaussianStep ΞΉ) β†’ (ΞΉ β†’ ℝ) β†’ ℝ
| a, [] => fun x => (1-a)*hierarchyPairMean w Ο† K [] x
| a, (m,q)::tail => fun x => (m-a)*hierarchyPairMean w Ο† K ((m,q)::tail) x+
shiftedMean (Measure.pi fun i => gaussianReal 0 (q i)) m (gaussianHierarchy w Ο† tail)
(kernelPenalty w Ο† K m tail) x
theorem kernelPenalty_smooth {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (K : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (r : β„•) :
BddSmooth r (kernelPenalty w Ο† K a steps) := by
induction steps generalizing a with
| nil => exact (hierarchyPairMean_smooth hw Ο† K [] ha r).const_mul (1-a)
| cons st tail ih =>
rcases st with ⟨m,q⟩
exact ((hierarchyPairMean_smooth hw Ο† K ((m,q)::tail) ha r).const_mul (m-a)).add
((ih ha.2.2.2).shiftedMean (gaussianHierarchy_regular hw Ο† tail ha.2.2.2 r)
(gaussianHierarchy_integrable hw Ο† tail ha.2.2.2 m q))
theorem kernelPenalty_const {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (c : ℝ) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† (fun _ _ => c) a steps x = (1-a)*c := by
induction steps generalizing a x with
| nil => simp only [kernelPenalty,hierarchyPairMean_const hw Ο† [] ha]
| cons st tail ih =>
rcases st with ⟨m,q⟩
simp only [kernelPenalty,hierarchyPairMean_const hw Ο† ((m,q)::tail) ha]
rw [funext (ih ha.2.2.2)]
rw [shiftedMean_const _ (gaussianHierarchy_integrable hw Ο† tail ha.2.2.2 m q x)]
ring
theorem kernelPenalty_mono {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) {K L : S β†’ S β†’ ℝ} (hKL : βˆ€ Οƒ Ο„, K Οƒ Ο„ ≀ L Οƒ Ο„)
(steps : List (GaussianStep ΞΉ)) {a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† K a steps x ≀ kernelPenalty w Ο† L a steps x := by
induction steps generalizing a x with
| nil =>
exact mul_le_mul_of_nonneg_left (hierarchyPairMean_mono hw Ο† hKL [] ha x)
(sub_nonneg.mpr ha.2)
| cons st tail ih =>
rcases st with ⟨m,q⟩
exact add_le_add (mul_le_mul_of_nonneg_left (hierarchyPairMean_mono hw Ο† hKL _ ha x)
(sub_nonneg.mpr ha.2.1))
(shiftedMean_mono (kernelPenalty_smooth hw Ο† K tail ha.2.2.2 0)
(kernelPenalty_smooth hw Ο† L tail ha.2.2.2 0) (fun y => ih ha.2.2.2 y)
(gaussianHierarchy_integrable hw Ο† tail ha.2.2.2 m q x))
theorem kernelPenalty_linear {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (K L : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (c d : ℝ) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† (fun Οƒ Ο„ => c*K Οƒ Ο„+d*L Οƒ Ο„) a steps x =
c*kernelPenalty w Ο† K a steps x+d*kernelPenalty w Ο† L a steps x := by
induction steps generalizing a x with
| nil => simp only [kernelPenalty,hierarchyPairMean_linear]; ring
| cons st tail ih =>
rcases st with ⟨m,q⟩
simp only [kernelPenalty,hierarchyPairMean_linear]
rw [funext (ih ha.2.2.2)]
rw [shiftedMean_add ((kernelPenalty_smooth hw Ο† K tail ha.2.2.2 0).const_mul c)
((kernelPenalty_smooth hw Ο† L tail ha.2.2.2 0).const_mul d)
(gaussianHierarchy_integrable hw Ο† tail ha.2.2.2 m q x),shiftedMean_const_mul,
shiftedMean_const_mul]
ring
theorem kernelPenalty_rankOne {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (v : ΞΉ β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† (fun Οƒ Ο„ => Ο† Οƒ v*Ο† Ο„ v) a steps x = hierarchyPenalty w Ο† v a steps x := by
induction steps generalizing a x with
| nil => simp only [kernelPenalty,hierarchyPenalty,hierarchyPairMean_product hw Ο† _ _ [] ha,pow_two]
| cons st tail ih =>
rcases st with ⟨m,q⟩
simp only [kernelPenalty,hierarchyPenalty,hierarchyPairMean_product hw Ο† _ _ _ ha,pow_two]
rw [funext (ih ha.2.2.2)]
end SKFluctuations.Hierarchy
namespace SKFluctuations.Hierarchy
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal BigOperators
variable {ΞΉ S : Type*} [Fintype ΞΉ] [Fintype S] [Nonempty S]
theorem kernelPenalty_const_mul {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (K : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a : ℝ} (ha : OrderedSteps a steps) (c : ℝ) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† (fun Οƒ Ο„ => c*K Οƒ Ο„) a steps x = c*kernelPenalty w Ο† K a steps x := by
simpa only [zero_mul,add_zero] using kernelPenalty_linear hw Ο† K (fun _ _ => 0) steps ha c 0 x
theorem kernelPenalty_sum {ΞΊ : Type*} {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (K : ΞΊ β†’ S β†’ S β†’ ℝ) (is : Finset ΞΊ)
(steps : List (GaussianStep ΞΉ)) {a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† (fun Οƒ Ο„ => βˆ‘ i ∈ is, K i Οƒ Ο„) a steps x =
βˆ‘ i ∈ is, kernelPenalty w Ο† (K i) a steps x := by
classical
induction is using Finset.induction_on with
| empty => simp only [Finset.sum_empty,kernelPenalty_const hw Ο† steps ha,mul_zero]
| @insert i is hi ih =>
simp only [Finset.sum_insert hi]
have he := kernelPenalty_linear hw Ο† (K i) (fun Οƒ Ο„ => βˆ‘ j ∈ is, K j Οƒ Ο„) steps ha 1 1 x
simp only [one_mul] at he
rw [he,ih]
theorem kernelPenalty_weighted_features {ΞΊ : Type*} [Fintype ΞΊ] {w : S β†’ ℝ}
(hw : βˆ€ Οƒ, 0 < w Οƒ) (Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (v : ΞΊ β†’ ΞΉ β†’ ℝ)
(d : ΞΊ β†’ ℝ) (steps : List (GaussianStep ΞΉ)) {a : ℝ} (ha : OrderedSteps a steps) (x : ΞΉ β†’ ℝ) :
kernelPenalty w Ο† (fun Οƒ Ο„ => βˆ‘ i, d i*Ο† Οƒ (v i)*Ο† Ο„ (v i)) a steps x =
βˆ‘ i, d i*hierarchyPenalty w Ο† (v i) a steps x := by
have he : (fun Οƒ Ο„ => βˆ‘ i, d i*Ο† Οƒ (v i)*Ο† Ο„ (v i)) =
fun Οƒ Ο„ => βˆ‘ i, d i*(Ο† Οƒ (v i)*Ο† Ο„ (v i)) := by
funext Οƒ Ο„
simp only [mul_assoc]
rw [he,kernelPenalty_sum hw Ο† _ Finset.univ steps ha]
apply Finset.sum_congr rfl
intro i _
rw [kernelPenalty_const_mul hw Ο† _ steps ha,kernelPenalty_rankOne hw Ο† _ steps ha]
theorem kernelPenalty_lower_bound {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (K : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{a C : ℝ} (ha : OrderedSteps a steps) (hK : βˆ€ Οƒ Ο„, -C ≀ K Οƒ Ο„) (x : ΞΉ β†’ ℝ) :
-(1/2:ℝ)*kernelPenalty w Ο† K a steps x ≀ (1-a)*C/2 := by
have hh := kernelPenalty_mono hw Ο† hK steps ha x
rw [kernelPenalty_const hw Ο† steps ha] at hh
linarith
theorem kernelPenalty_chord {w : S β†’ ℝ} (hw : βˆ€ Οƒ, 0 < w Οƒ)
(Ο† : S β†’ (ΞΉ β†’ ℝ) β†’L[ℝ] ℝ) (R : S β†’ S β†’ ℝ) (steps : List (GaussianStep ΞΉ))
{m a : ℝ} (hm : OrderedSteps m steps) (ha : 0 < a) (c : ℝ) (x : ΞΉ β†’ ℝ) :
-(1/2:ℝ)*kernelPenalty w Ο† (fun Οƒ Ο„ => a/2*(R Οƒ Ο„)^2-c*R Οƒ Ο„) m steps x ≀
(1-m)*c^2/(4*a) := by
have hK (Οƒ Ο„) : -(c^2/(2*a)) ≀ a/2*(R Οƒ Ο„)^2-c*R Οƒ Ο„ := by
rw [← neg_div,div_le_iffβ‚€ (show 0 < 2*a by positivity)]
nlinarith [sq_nonneg (a*R Οƒ Ο„-c)]
have hh := kernelPenalty_lower_bound hw Ο† _ steps hm hK x
convert hh using 1; ring
theorem prefixTest_le_const {F A : (ΞΉ β†’ ℝ) β†’ ℝ} {C : ℝβ‰₯0}
(hF : LipschitzWith C F) (hA : BddSmooth 0 A) (front : List (GaussianStep ΞΉ))
(ho : βˆ€ st ∈ front, 0 < st.1) {B : ℝ} (hb : βˆ€ y, A y ≀ B) (x : ΞΉ β†’ ℝ) :
prefixTest front F A x ≀ B := by
have hn : βˆ€ y, 0 ≀ B+(-1)*A y := fun y => by linarith [hb y]
have hh := prefixTest_nonneg hF hn front ho x
rw [prefixTest_affine hF hA front ho B (-1) x] at hh
linarith
theorem rootedPrefixTest_le_const {F A : (ΞΉ β†’ ℝ) β†’ ℝ} {C : ℝβ‰₯0}
(hF : LipschitzWith C F) (hA : BddSmooth 0 A) (front : List (GaussianStep ΞΉ))
(ho : βˆ€ st ∈ front, 0 < st.1) {B : ℝ} (hb : βˆ€ y, A y ≀ B)
(qβ‚€ : ΞΉ β†’ ℝβ‰₯0) (x : ΞΉ β†’ ℝ) :
zeroContinuation (Measure.pi fun i => gaussianReal 0 (qβ‚€ i)) (prefixTest front F A) x ≀ B := by
have hP := prefixTest_smooth0 hF hA front ho
have hi : Integrable (fun z => prefixTest front F A (x+z))
(Measure.pi fun i => gaussianReal 0 (qβ‚€ i)) := by
obtain ⟨D,hD,hbD⟩ := hP.bound
exact Integrable.of_bound (hP.continuous.comp (continuous_const.add continuous_id)).aestronglyMeasurable
D (Filter.Eventually.of_forall fun z => by simpa only [Real.norm_eq_abs] using hbD (x+z))
have hh := integral_mono hi (integrable_const B) (fun z => prefixTest_le_const hF hA front ho hb (x+z))
simpa [zeroContinuation] using hh
end SKFluctuations.Hierarchy
namespace SKFluctuations
open MeasureTheory ProbabilityTheory Hierarchy
open scoped Topology NNReal BigOperators
theorem orderedSK_kernel_chord (n : β„•) (hn : 0 < n) {w : Spin n β†’ ℝ}
(hw : βˆ€ Οƒ, 0 < w Οƒ) (steps : List (GaussianStep (OrderedFeatureIndex n)))
{m a : ℝ} (hm : OrderedSteps m steps) (ha : 0 < a) (c : ℝ) (x : OrderedFeatureIndex n β†’ ℝ) :
-(1/2:ℝ)*(βˆ‘ i : OrderedFeatureIndex n, Sum.elim (fun _ => -c) (fun _ => a) i*
hierarchyPenalty w (orderedFeature n) (Pi.single i 1) m steps x) ≀
(n:ℝ)*(1-m)*c^2/(4*a) := by
have he : (fun Οƒ Ο„ => βˆ‘ i : OrderedFeatureIndex n, Sum.elim (fun _ => -c) (fun _ => a) i*
orderedFeature n Οƒ (Pi.single i 1)*orderedFeature n Ο„ (Pi.single i 1)) =
fun Οƒ Ο„ => (n:ℝ)*(a/2*(orderedOverlap n Οƒ Ο„)^2-c*orderedOverlap n Οƒ Ο„) := by
funext Οƒ Ο„
simp only [orderedFeature_single]
rw [orderedCovariance n hn]
ring
rw [← kernelPenalty_weighted_features hw (orderedFeature n) (fun i => Pi.single i 1) _ steps hm,he,
kernelPenalty_const_mul hw (orderedFeature n) _ steps hm]
have hh := mul_le_mul_of_nonneg_left (kernelPenalty_chord hw (orderedFeature n)
(orderedOverlap n) steps hm ha c x) (Nat.cast_nonneg n)
convert hh using 1 <;> first | rfl | ring
end SKFluctuations
namespace SKFluctuations
open MeasureTheory ProbabilityTheory Hierarchy
open scoped Topology NNReal BigOperators
theorem orderedSK_kernel_chord_observed (n : β„•) (hn : 0 < n) {w : Spin n β†’ ℝ}
(hw : βˆ€ Οƒ, 0 < w Οƒ) (steps front : List (GaussianStep (OrderedFeatureIndex n)))
{m a : ℝ} (hm : OrderedSteps m steps) (ha : 0 < a) (c : ℝ)
(hf : βˆ€ st ∈ front, 0 < st.1) (qβ‚€ : OrderedFeatureIndex n β†’ ℝβ‰₯0)
(x : OrderedFeatureIndex n β†’ ℝ) :
zeroContinuation (Measure.pi fun i => gaussianReal 0 (qβ‚€ i))
(prefixTest front (gaussianHierarchy w (orderedFeature n) steps)
(fun y => -(1/2:ℝ)*(βˆ‘ i : OrderedFeatureIndex n,
Sum.elim (fun _ => -c) (fun _ => a) i*
hierarchyPenalty w (orderedFeature n) (Pi.single i 1) m steps y))) x ≀
(n:ℝ)*(1-m)*c^2/(4*a) := by
apply rootedPrefixTest_le_const (gaussianHierarchy_regular hw (orderedFeature n) steps hm 0).1.choose_spec
((BddSmooth.sum Finset.univ (fun i _ =>
(hierarchyPenalty_smooth hw (orderedFeature n) (Pi.single i 1) steps hm 0).const_mul
(Sum.elim (fun _ => -c) (fun _ => a) i))).const_mul (-(1/2:ℝ))) front hf
exact fun y => orderedSK_kernel_chord n hn hw steps hm ha c y
end SKFluctuations
end
end OAI