introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
28.6 kB
import Mathlib
import OAI.Probability.ParisiFinite.Sine
namespace OAI
/-! Field. -/
noncomputable section
open scoped BigOperators ComplexConjugate InnerProductSpace Topology ComplexOrder
open Filter
open scoped BigOperators
open scoped Matrix Matrix.Norms.L2Operator ComplexConjugate
open scoped InnerProductSpace ComplexConjugate
open Filter Topology
open Filter Set Topology
open scoped InnerProductSpace ComplexConjugate Topology
open scoped InnerProductSpace
open scoped BigOperators Topology InnerProductSpace
open scoped BigOperators InnerProductSpace
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory
open scoped RealInnerProductSpace
variable (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
def field (d : E) (g : E) : ℝ := βŸͺd,g⟫
theorem memLp_field (d : E) : MemLp (field E d) 2 (stdGaussian E) := by
exact (innerSL ℝ d).comp_memLp' IsGaussian.memLp_two_id
def vector (d : E) : Lp ℝ 2 (stdGaussian E) := (memLp_field E d).toLp (field E d)
theorem vector_ae (d : E) : (vector E d : E β†’ ℝ)=ᡐ[stdGaussian E] field E d :=
(memLp_field E d).coeFn_toLp
theorem field_covariance (d e : E) :
(∫g, field E d g*field E e g βˆ‚stdGaussian E)=βŸͺd,e⟫ := by
have h := covarianceBilin_apply (ΞΌ := stdGaussian E) IsGaussian.memLp_two_id d e
rw [covarianceBilin_stdGaussian] at h
simpa only [field,id_eq,integral_id_stdGaussian,sub_zero,innerSL_apply_apply ℝ] using h.symm
theorem inner_vector (d e : E) : βŸͺvector E d,vector E e⟫=βŸͺd,e⟫ := by
rw [L2.inner_def,←field_covariance E d e]
apply integral_congr_ae
filter_upwards [vector_ae E d,vector_ae E e] with g hd he
rw [hd,he]
simp only [RCLike.inner_apply',starRingEnd_apply,star_trivial]
def linearMap : E β†’β‚—[ℝ] Lp ℝ 2 (stdGaussian E) where
toFun := vector E
map_add' d e := by
apply Lp.ext
filter_upwards [vector_ae E (d+e),vector_ae E d,vector_ae E e,
Lp.coeFn_add (vector E d) (vector E e)] with g h1 h2 h3 h4
rw [h1,h4]
simp only [Pi.add_apply]
rw [h2,h3]
exact inner_add_left d e g
map_smul' c d := by
apply Lp.ext
filter_upwards [vector_ae E (c β€’ d),vector_ae E d,
Lp.coeFn_smul c (vector E d)] with g h1 h2 h3
simp only [RingHom.id_apply]
rw [h1,h3]
simp only [Pi.smul_apply,smul_eq_mul]
rw [h2]
exact real_inner_smul_left d g c
def aggregate : E β†’β‚—α΅’[ℝ] Lp ℝ 2 (stdGaussian E) :=
LinearMap.isometryOfInner (linearMap E) (inner_vector E)
@[simp] theorem aggregate_apply (d : E) : aggregate E d=vector E d := rfl
@[simp] theorem norm_aggregate_sub (d e : E) :
β€–aggregate E d-aggregate E eβ€–=β€–d-eβ€– := by
rw [←map_sub,(aggregate E).norm_map]
theorem aggregate_centered (d : E) : (∫g, aggregate E d g βˆ‚stdGaussian E)=0 := by
change (∫g, vector E d g βˆ‚stdGaussian E)=0
rw [integral_congr_ae (vector_ae E d)]
exact integral_strongDual_stdGaussian (innerSL ℝ d)
theorem reflection : MeasurePreserving (fun g : E => -g) (stdGaussian E) (stdGaussian E) := by
refine ⟨measurable_neg,?_⟩
exact stdGaussian_map (LinearIsometryEquiv.neg ℝ : E ≃ₗᡒ[ℝ] E)
theorem aggregate_odd (d : E) :
βˆ€α΅ g βˆ‚stdGaussian E, aggregate E d (-g)= -aggregate E d g := by
have ha := (reflection E).quasiMeasurePreserving.ae (vector_ae E d)
filter_upwards [vector_ae E d,ha] with g h1 h2
change vector E d (-g)= -vector E d g
rw [h1,h2]
exact inner_neg_right d g
theorem field_law (d : E) :
(stdGaussian E).map (field E d)=gaussianReal 0 (β€–dβ€–β‚Š^2) := by
change (stdGaussian E).map (innerSL ℝ d)=_
rw [IsGaussian.map_eq_gaussianReal,integral_strongDual_stdGaussian,
variance_dual_stdGaussian]
congr 1
simp only [innerSL_apply_norm]
apply NNReal.coe_injective
simp only [Real.coe_toNNReal' , NNReal.coe_pow,coe_nnnorm,sup_eq_left.mpr (sq_nonneg β€–dβ€–)]
end ClassicalGaussian
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory
open scoped RealInnerProductSpace
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
variable {ΞΊ : Type*} [Fintype ΞΊ] (cols : ΞΊ β†’ V)
abbrev ColumnSpan := Submodule.span ℝ (Set.range cols)
instance span_finiteDimensional : FiniteDimensional ℝ (ColumnSpan cols) :=
FiniteDimensional.span_of_finite ℝ (Set.finite_range cols)
instance span_measurableSpace : MeasurableSpace (ColumnSpan cols) := borel (ColumnSpan cols)
instance span_borelSpace : BorelSpace (ColumnSpan cols) := ⟨rfl⟩
def column (k : κ) : ColumnSpan cols := ⟨cols k, Submodule.subset_span (Set.mem_range_self k)⟩
omit [Fintype ΞΊ] in
@[simp] theorem inner_column (j k : ΞΊ) : βŸͺcolumn cols j,column cols k⟫=βŸͺcols j,cols k⟫ := rfl
omit [Fintype ΞΊ] in
@[simp] theorem norm_column_sub (j k : ΞΊ) : β€–column cols j-column cols kβ€–=β€–cols j-cols kβ€– := rfl
def jointColumn (k : ΞΊ) : Lp ℝ 2 (stdGaussian (ColumnSpan cols)) :=
aggregate (ColumnSpan cols) (column cols k)
theorem jointColumn_covariance (j k : ΞΊ) :
(∫g, jointColumn cols j g*jointColumn cols k g βˆ‚stdGaussian (ColumnSpan cols))=
βŸͺcols j,cols k⟫ := by
rw [←inner_column cols j k,←field_covariance (ColumnSpan cols) (column cols j) (column cols k)]
apply integral_congr_ae
filter_upwards [vector_ae (ColumnSpan cols) (column cols j),
vector_ae (ColumnSpan cols) (column cols k)] with g h1 h2
change vector (ColumnSpan cols) (column cols j) g *
vector (ColumnSpan cols) (column cols k) g = _
rw [h1,h2]
theorem jointColumn_centered (k : ΞΊ) :
(∫g, jointColumn cols k g βˆ‚stdGaussian (ColumnSpan cols))=0 :=
aggregate_centered (ColumnSpan cols) (column cols k)
theorem jointColumn_norm_sub (j k : ΞΊ) :
β€–jointColumn cols j-jointColumn cols kβ€–=β€–cols j-cols kβ€– :=
norm_aggregate_sub (ColumnSpan cols) (column cols j) (column cols k)
theorem jointColumn_odd (k : ΞΊ) :
βˆ€α΅ g βˆ‚stdGaussian (ColumnSpan cols), jointColumn cols k (-g)= -jointColumn cols k g :=
aggregate_odd (ColumnSpan cols) (column cols k)
end ClassicalGaussian
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory
open scoped RealInnerProductSpace
variable {E F : Type*}
[NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
[MeasurableSpace E] [BorelSpace E]
[NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ F]
[MeasurableSpace F] [BorelSpace F]
theorem projection_gaussian (i : E β†’β‚—α΅’[ℝ] F) :
(stdGaussian F).map (ContinuousLinearMap.adjoint i.toContinuousLinearMap)=stdGaussian E := by
apply Measure.ext_of_charFun
funext t
rw [charFun_apply,integral_map (by fun_prop) (by fun_prop)]
simp only [ContinuousLinearMap.adjoint_inner_left]
change charFun (stdGaussian F) (i t)=charFun (stdGaussian E) t
simp only [charFun_stdGaussian,i.norm_map]
theorem projection_preserving (i : E β†’β‚—α΅’[ℝ] F) :
MeasurePreserving (ContinuousLinearMap.adjoint i.toContinuousLinearMap)
(stdGaussian F) (stdGaussian E) :=
⟨by fun_prop,projection_gaussian i⟩
theorem aggregate_pullback (i : E β†’β‚—α΅’[ℝ] F) (d : E) :
Lp.compMeasurePreserving (ContinuousLinearMap.adjoint i.toContinuousLinearMap)
(projection_preserving i) (aggregate E d)=aggregate F (i d) := by
apply Lp.ext
have h1 := (projection_preserving i).quasiMeasurePreserving.ae (vector_ae E d)
filter_upwards [Lp.coeFn_compMeasurePreserving (aggregate E d) (projection_preserving i),
h1,vector_ae F (i d)] with g h2 h3 h4
change _=vector F (i d) g
rw [h2,h4]
change vector E d (ContinuousLinearMap.adjoint i.toContinuousLinearMap g)=_
rw [h3]
exact ContinuousLinearMap.adjoint_inner_right i.toContinuousLinearMap d g
end ClassicalGaussian
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory TrigLp
open scoped Topology
variable (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
variable {ΞΊ : Type*} [Fintype ΞΊ]
theorem exists_robust_gaussian_operation (cols : ΞΊ β†’ E) (Ο† : (ΞΊ β†’ ℝ) β†’ ℝ)
(hφ : MemLp φ 2 (inputLaw (stdGaussian E) (fun k => aggregate E (cols k))))
(ho : βˆ€x, Ο† (-x)= -Ο† x) {Ξ΅ : ℝ} (hΞ΅ : 0<Ξ΅) :
βˆƒs : Finset (ΞΊ β†’ ℝ), βˆƒb : (ΞΊ β†’ ℝ) β†’ ℝ, βˆƒΞ΄ : ℝ, 0<Ξ΄ ∧
βˆ€d : ΞΊ β†’ E, (βˆ€k, β€–d k-cols kβ€–<Ξ΄) β†’
β€–polynomial (stdGaussian E) s b (fun k => aggregate E (d k))-
(hφ.comp_measurePreserving (inputMap_preserving (stdGaussian E)
(fun k => aggregate E (cols k)))).toLp
(Ο† ∘ inputMap (stdGaussian E) (fun k => aggregate E (cols k)))β€–<Ξ΅ := by
obtain ⟨s,b,δ,hδ,hd⟩ := exists_robust_odd_operation (stdGaussian E) (fun g => -g)
(reflection E) (fun k => aggregate E (cols k)) (fun k => aggregate_odd E (cols k))
φ hφ ho hΡ
refine ⟨s,b,δ,hδ,?_⟩
intro d hd'
apply hd
intro k
simpa only [norm_aggregate_sub] using hd' k
theorem exists_robust_gaussian_angle (cols : ΞΊ β†’ E) (Ο† : (ΞΊ β†’ ℝ) β†’ ℝ)
(hφ : MemLp φ 2 (inputLaw (stdGaussian E) (fun k => aggregate E (cols k))))
(ho : βˆ€x, Ο† (-x)= -Ο† x) (hb : βˆ€x, |Ο† x|≀1) {Ξ΅ : ℝ} (hΞ΅ : 0<Ξ΅) :
βˆƒs : Finset (ΞΊ β†’ ℝ), βˆƒb : (ΞΊ β†’ ℝ) β†’ ℝ, βˆƒΞ΄ : ℝ, 0<Ξ΄ ∧
βˆ€d : ΞΊ β†’ E, (βˆ€k, β€–d k-cols kβ€–<Ξ΄) β†’
β€–readout (stdGaussian E) s b (fun k => aggregate E (d k))-
(hφ.comp_measurePreserving (inputMap_preserving (stdGaussian E)
(fun k => aggregate E (cols k)))).toLp
(Ο† ∘ inputMap (stdGaussian E) (fun k => aggregate E (cols k)))β€–<Ξ΅ := by
obtain ⟨s,b,δ,hδ,hd⟩ := exists_robust_odd_readout (stdGaussian E) (fun g => -g)
(reflection E) (fun k => aggregate E (cols k)) (fun k => aggregate_odd E (cols k))
φ hφ ho hb hΡ
refine ⟨s,b,δ,hδ,?_⟩
intro d hd'
apply hd
intro k
simpa only [norm_aggregate_sub] using hd' k
end ClassicalGaussian
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory
open scoped RealInnerProductSpace
variable (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
theorem covariance_field (d e : E) :
cov[field E d,field E e;stdGaussian E]=βŸͺd,e⟫ := by
rw [covariance_eq_sub (memLp_field E d) (memLp_field E e)]
have hd : (∫g,field E d g βˆ‚stdGaussian E)=0 :=
integral_strongDual_stdGaussian (innerSL ℝ d)
have he : (∫g,field E e g βˆ‚stdGaussian E)=0 :=
integral_strongDual_stdGaussian (innerSL ℝ e)
rw [hd,he,mul_zero,sub_zero]
exact field_covariance E d e
theorem joint_gaussian {ΞΊ : Type*} [Fintype ΞΊ] (cols : ΞΊ β†’ E) :
HasGaussianLaw (fun g k => field E (cols k) g) (stdGaussian E) := by
exact HasGaussianLaw.map_of_measurable
(ContinuousLinearMap.pi (fun k => innerSL ℝ (cols k)))
IsGaussian.hasGaussianLaw_id (by fun_prop)
theorem fields_independent {ΞΊ : Type*} [Fintype ΞΊ] (cols : ΞΊ β†’ E)
(h : βˆ€j k, jβ‰ k β†’ βŸͺcols j,cols k⟫=0) :
iIndepFun (fun k => field E (cols k)) (stdGaussian E) := by
apply (joint_gaussian E cols).iIndepFun_of_covariance_eq_zero
intro j k hjk
rw [covariance_field]
exact h j k hjk
theorem orthogonal_families_independent {ΞΊ ΞΉ : Type*} [Fintype ΞΊ] [Fintype ΞΉ]
(d : ΞΊ β†’ E) (e : ΞΉ β†’ E) (h : βˆ€j k, βŸͺd j,e k⟫=0) :
IndepFun (fun g j => field E (d j) g) (fun g k => field E (e k) g)
(stdGaussian E) := by
have hg : HasGaussianLaw (fun g => ((fun j => field E (d j) g),
(fun k => field E (e k) g))) (stdGaussian E) := by
exact HasGaussianLaw.map_of_measurable
((ContinuousLinearMap.pi (fun j => innerSL ℝ (d j))).prod
(ContinuousLinearMap.pi (fun k => innerSL ℝ (e k))))
IsGaussian.hasGaussianLaw_id (by fun_prop)
apply hg.indepFun_of_covariance_eval
intro j k
rw [covariance_field]
exact h j k
end ClassicalGaussian
namespace TrigLp
open MeasureTheory
variable {Ξ© Ξ©' : Type*} [MeasurableSpace Ξ©] [MeasurableSpace Ξ©']
variable (ΞΌ : Measure Ξ©) (Ξ½ : Measure Ξ©') (X : Ξ© β†’ Ξ©')
variable (hX : MeasurePreserving X ΞΌ Ξ½)
variable {ΞΊ : Type*} [Fintype ΞΊ]
omit [Fintype ΞΊ] in
theorem sine_pullback (f : Lp ℝ 2 Ξ½) :
Lp.compMeasurePreservingβ‚— ℝ X hX (sine Ξ½ f)=
sine ΞΌ (Lp.compMeasurePreservingβ‚— ℝ X hX f) := by
apply Lp.ext
have hf := hX.quasiMeasurePreserving.ae (sine_ae Ξ½ f)
filter_upwards [Lp.coeFn_compMeasurePreserving (sine Ξ½ f) hX,hf,
sine_ae ΞΌ (Lp.compMeasurePreservingβ‚— ℝ X hX f),
Lp.coeFn_compMeasurePreserving f hX] with Ο‰ h1 h2 h3 h4
change Lp.compMeasurePreserving X hX (sine Ξ½ f) Ο‰=_
rw [h1,Function.comp_apply,h2,h3]
congr 1
change f (X Ο‰)=Lp.compMeasurePreserving X hX f Ο‰
exact h4.symm
theorem polynomial_pullback (s : Finset (ΞΊ β†’ ℝ)) (b : (ΞΊ β†’ ℝ) β†’ ℝ)
(cols : ΞΊ β†’ Lp ℝ 2 Ξ½) :
Lp.compMeasurePreservingβ‚— ℝ X hX (polynomial Ξ½ s b cols)=
polynomial ΞΌ s b (fun k => Lp.compMeasurePreservingβ‚— ℝ X hX (cols k)) := by
simp only [polynomial,map_sum,map_smul,sine_pullback,linear]
theorem readout_pullback (s : Finset (ΞΊ β†’ ℝ)) (b : (ΞΊ β†’ ℝ) β†’ ℝ)
(cols : ΞΊ β†’ Lp ℝ 2 Ξ½) :
Lp.compMeasurePreservingβ‚— ℝ X hX (readout Ξ½ s b cols)=
readout ΞΌ s b (fun k => Lp.compMeasurePreservingβ‚— ℝ X hX (cols k)) := by
simp only [readout,sine_pullback,map_smul,polynomial_pullback]
def coefficientBound (s : Finset (ΞΊ β†’ ℝ)) (b : (ΞΊ β†’ ℝ) β†’ ℝ) : ℝ :=
βˆ‘a∈s, |b a| * (βˆ‘k, |a k|)
theorem coefficientBound_nonneg (s : Finset (ΞΊ β†’ ℝ)) (b : (ΞΊ β†’ ℝ) β†’ ℝ) :
0≀coefficientBound s b := by
exact Finset.sum_nonneg (fun a ha => mul_nonneg (abs_nonneg _) (Finset.sum_nonneg fun _ _ => abs_nonneg _))
theorem polynomial_norm_sub_uniform (s : Finset (ΞΊ β†’ ℝ)) (b : (ΞΊ β†’ ℝ) β†’ ℝ)
(f g : ΞΊ β†’ Lp ℝ 2 ΞΌ) {Ξ΄ : ℝ} (h : βˆ€k, β€–f k-g k‖≀δ) :
β€–polynomial ΞΌ s b f-polynomial ΞΌ s b g‖≀coefficientBound s b*Ξ΄ := by
calc
_ ≀ βˆ‘a∈s, |b a| *(βˆ‘k, |a k| *β€–f k-g kβ€–) := polynomial_norm_sub_le ΞΌ s b f g
_ ≀ βˆ‘a∈s, |b a| *(βˆ‘k, |a k| *Ξ΄) := by
apply Finset.sum_le_sum
intro a ha
apply mul_le_mul_of_nonneg_left _ (abs_nonneg _)
exact Finset.sum_le_sum (fun k hk => mul_le_mul_of_nonneg_left (h k) (abs_nonneg _))
_ = coefficientBound s b*Ξ΄ := by
simp only [coefficientBound,Finset.sum_mul,Finset.mul_sum,mul_assoc]
end TrigLp
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory TrigLp
universe u v
variable (E : Type u) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
variable {ΞΊ : Type*} [Fintype ΞΊ]
def localValue (cols : ΞΊ β†’ E) (Ο† : (ΞΊ β†’ ℝ) β†’ ℝ)
(hφ : MemLp φ 2 (inputLaw (stdGaussian E) (fun k => aggregate E (cols k)))) :
Lp ℝ 2 (stdGaussian E) :=
(hφ.comp_measurePreserving (inputMap_preserving (stdGaussian E)
(fun k => aggregate E (cols k)))).toLp
(Ο† ∘ inputMap (stdGaussian E) (fun k => aggregate E (cols k)))
theorem exists_ambient_robust_operation (cols : ΞΊ β†’ E) (Ο† : (ΞΊ β†’ ℝ) β†’ ℝ)
(hφ : MemLp φ 2 (inputLaw (stdGaussian E) (fun k => aggregate E (cols k))))
(ho : βˆ€x, Ο† (-x)= -Ο† x) {Ξ΅ : ℝ} (hΞ΅ : 0<Ξ΅) :
βˆƒs : Finset (ΞΊ β†’ ℝ), βˆƒb : (ΞΊ β†’ ℝ) β†’ ℝ, βˆƒΞ΄ : ℝ, 0<Ξ΄ ∧
βˆ€ (F : Type v) [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[FiniteDimensional ℝ F] [MeasurableSpace F] [BorelSpace F]
(i : E β†’β‚—α΅’[ℝ] F) (d : ΞΊ β†’ F), (βˆ€k, β€–d k-i (cols k)β€–<Ξ΄) β†’
β€–polynomial (stdGaussian F) s b (fun k => aggregate F (d k))-
Lp.compMeasurePreservingβ‚— ℝ (ContinuousLinearMap.adjoint i.toContinuousLinearMap)
(projection_preserving i) (localValue E cols φ hφ)‖<Ρ := by
obtain ⟨s,b,Ξ΄β‚€,hΞ΄β‚€,ha⟩ := exists_robust_gaussian_operation E cols Ο† hΟ† ho (half_pos hΞ΅)
have hb := ha cols (fun k => by simpa only [sub_self,norm_zero] using hΞ΄β‚€)
change β€–polynomial (stdGaussian E) s b (fun k => aggregate E (cols k))-
localValue E cols φ hφ‖<Ρ/2 at hb
let K := coefficientBound s b
have hK : 0≀K := coefficientBound_nonneg s b
have hp : 0<2*(K+1) := by positivity
let Ξ΄ := Ξ΅/(2*(K+1))
have hΞ΄ : 0<Ξ΄ := div_pos hΞ΅ hp
have heq : Ξ΄*(2*(K+1))=Ξ΅ := div_mul_cancelβ‚€ Ξ΅ (ne_of_gt hp)
have hKΞ΄ : K*Ξ΄<Ξ΅/2 := by nlinarith
refine ⟨s,b,δ,hδ,?_⟩
intro F inst1 inst2 inst3 inst4 inst5 i d hd
let P : Lp ℝ 2 (stdGaussian E) β†’β‚—[ℝ] Lp ℝ 2 (stdGaussian F) := Lp.compMeasurePreservingβ‚— ℝ
(ContinuousLinearMap.adjoint i.toContinuousLinearMap) (projection_preserving i)
have hid : polynomial (stdGaussian F) s b (fun k => aggregate F (i (cols k)))=
P (polynomial (stdGaussian E) s b (fun k => aggregate E (cols k))) := by
rw [polynomial_pullback]
congr 1
funext k
exact (aggregate_pullback i (cols k)).symm
have herr : β€–polynomial (stdGaussian F) s b (fun k => aggregate F (i (cols k)))-
P (localValue E cols φ hφ)‖<Ρ/2 := by
rw [hid,←map_sub]
change β€–Lp.compMeasurePreserving (ContinuousLinearMap.adjoint i.toContinuousLinearMap)
(projection_preserving i)
(polynomial (stdGaussian E) s b (fun k => aggregate E (cols k))-localValue E cols φ hφ)‖<Ρ/2
rwa [Lp.norm_compMeasurePreserving]
have hpert : β€–polynomial (stdGaussian F) s b (fun k => aggregate F (d k))-
polynomial (stdGaussian F) s b (fun k => aggregate F (i (cols k)))β€–<Ξ΅/2 := by
apply lt_of_le_of_lt (polynomial_norm_sub_uniform (stdGaussian F) s b _ _ ?_) hKΞ΄
intro k
rw [norm_aggregate_sub]
exact (hd k).le
calc
_ ≀ β€–polynomial (stdGaussian F) s b (fun k => aggregate F (d k))-
polynomial (stdGaussian F) s b (fun k => aggregate F (i (cols k)))β€–+
β€–polynomial (stdGaussian F) s b (fun k => aggregate F (i (cols k)))-
P (localValue E cols φ hφ)‖ := norm_sub_le_norm_sub_add_norm_sub _ _ _
_ < Ξ΅/2+Ξ΅/2 := add_lt_add hpert herr
_ = Ξ΅ := add_halves Ξ΅
end ClassicalGaussian
namespace ClassicalGaussian
open MeasureTheory ProbabilityTheory TrigLp
universe u v
variable (E : Type u) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
variable {ΞΊ : Type*} [Fintype ΞΊ]
theorem exists_ambient_robust_angle (cols : ΞΊ β†’ E) (Ο† : (ΞΊ β†’ ℝ) β†’ ℝ)
(hφ : MemLp φ 2 (inputLaw (stdGaussian E) (fun k => aggregate E (cols k))))
(ho : βˆ€x, Ο† (-x)= -Ο† x) (hbound : βˆ€x, |Ο† x|≀1) {Ξ΅ : ℝ} (hΞ΅ : 0<Ξ΅) :
βˆƒs : Finset (ΞΊ β†’ ℝ), βˆƒb : (ΞΊ β†’ ℝ) β†’ ℝ, βˆƒΞ΄ : ℝ, 0<Ξ΄ ∧
βˆ€ (F : Type v) [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[FiniteDimensional ℝ F] [MeasurableSpace F] [BorelSpace F]
(i : E β†’β‚—α΅’[ℝ] F) (d : ΞΊ β†’ F), (βˆ€k, β€–d k-i (cols k)β€–<Ξ΄) β†’
β€–readout (stdGaussian F) s b (fun k => aggregate F (d k))-
Lp.compMeasurePreservingβ‚— ℝ (ContinuousLinearMap.adjoint i.toContinuousLinearMap)
(projection_preserving i) (localValue E cols φ hφ)‖<Ρ := by
obtain ⟨s,b,Ξ΄β‚€,hΞ΄β‚€,ha⟩ := exists_robust_gaussian_angle E cols Ο† hΟ† ho hbound (half_pos hΞ΅)
have hb := ha cols (fun k => by simpa only [sub_self,norm_zero] using hΞ΄β‚€)
change β€–readout (stdGaussian E) s b (fun k => aggregate E (cols k))-
localValue E cols φ hφ‖<Ρ/2 at hb
let K := coefficientBound s b
have hK : 0≀K := coefficientBound_nonneg s b
have hp : 0<4*(K+1) := by positivity
let Ξ΄ := Ξ΅/(4*(K+1))
have hΞ΄ : 0<Ξ΄ := div_pos hΞ΅ hp
have heq : Ξ΄*(4*(K+1))=Ξ΅ := div_mul_cancelβ‚€ Ξ΅ (ne_of_gt hp)
have hKΞ΄ : 2*(K*Ξ΄)<Ξ΅/2 := by nlinarith
refine ⟨s,b,δ,hδ,?_⟩
intro F inst1 inst2 inst3 inst4 inst5 i d hd
let P : Lp ℝ 2 (stdGaussian E) β†’β‚—[ℝ] Lp ℝ 2 (stdGaussian F) := Lp.compMeasurePreservingβ‚— ℝ
(ContinuousLinearMap.adjoint i.toContinuousLinearMap) (projection_preserving i)
have hid : readout (stdGaussian F) s b (fun k => aggregate F (i (cols k)))=
P (readout (stdGaussian E) s b (fun k => aggregate E (cols k))) := by
rw [readout_pullback]
congr 1
funext k
exact (aggregate_pullback i (cols k)).symm
have herr : β€–readout (stdGaussian F) s b (fun k => aggregate F (i (cols k)))-
P (localValue E cols φ hφ)‖<Ρ/2 := by
rw [hid,←map_sub]
change β€–Lp.compMeasurePreserving (ContinuousLinearMap.adjoint i.toContinuousLinearMap)
(projection_preserving i)
(readout (stdGaussian E) s b (fun k => aggregate E (cols k))-localValue E cols φ hφ)‖<Ρ/2
rwa [Lp.norm_compMeasurePreserving]
have hpert : β€–readout (stdGaussian F) s b (fun k => aggregate F (d k))-
readout (stdGaussian F) s b (fun k => aggregate F (i (cols k)))β€–<Ξ΅/2 := by
apply lt_of_le_of_lt (readout_norm_sub_le (stdGaussian F) s b _ _)
apply lt_of_le_of_lt (mul_le_mul_of_nonneg_left
(polynomial_norm_sub_uniform (stdGaussian F) s b _ _ ?_) (by norm_num : (0:ℝ)≀2)) hKΞ΄
intro k
rw [norm_aggregate_sub]
exact (hd k).le
calc
_ ≀ β€–readout (stdGaussian F) s b (fun k => aggregate F (d k))-
readout (stdGaussian F) s b (fun k => aggregate F (i (cols k)))β€–+
β€–readout (stdGaussian F) s b (fun k => aggregate F (i (cols k)))-
P (localValue E cols φ hφ)‖ := norm_sub_le_norm_sub_add_norm_sub _ _ _
_ < Ξ΅/2+Ξ΅/2 := add_lt_add hpert herr
_ = Ξ΅ := add_halves Ξ΅
end ClassicalGaussian
namespace FiniteOccupations
open scoped InnerProductSpace BigOperators
variable {A B : Type*} [Fintype A] [Fintype B] [DecidableEq B]
variable (f : A β†’ B)
def weight (b : B) : β„‚ := (Real.sqrt (Fintype.card {a : A // f a=b} : ℝ) : β„‚)⁻¹
omit [Fintype B] in
theorem card_pos (hf : Function.Surjective f) (b : B) : 0<Fintype.card {a : A // f a=b} := by
obtain ⟨a,ha⟩ := hf b
exact Fintype.card_pos_iff.mpr ⟨⟨a,ha⟩⟩
omit [Fintype B] in
@[simp] theorem star_weight (b : B) : starRingEnd β„‚ (weight f b)=weight f b := by
simp [weight]
omit [Fintype B] in
theorem card_mul_weight_sq (hf : Function.Surjective f) (b : B) :
(Fintype.card {a : A // f a=b} : β„‚)*(weight f b)^2=1 := by
have hsq : (Real.sqrt (Fintype.card {a : A // f a=b} : ℝ) : β„‚)^2=
(Fintype.card {a : A // f a=b} : β„‚) := by
exact_mod_cast Real.sq_sqrt (Nat.cast_nonneg (Fintype.card {a : A // f a=b}))
rw [weight,inv_pow,hsq]
exact mul_inv_cancelβ‚€ (Nat.cast_ne_zero.mpr (Nat.ne_of_gt (card_pos f hf b)))
omit [Fintype B] in
theorem weight_ne_zero (hf : Function.Surjective f) (b : B) : weight f b≠0 := by
intro h
simpa [h] using card_mul_weight_sq f hf b
def liftLinear : EuclideanSpace β„‚ B β†’β‚—[β„‚] EuclideanSpace β„‚ A where
toFun u := WithLp.toLp 2 (fun a => weight f (f a)*u (f a))
map_add' u v := by ext a; simp [mul_add]
map_smul' c u := by ext a; simp [mul_left_comm]
omit [Fintype B] in
@[simp] theorem liftLinear_apply (u : EuclideanSpace β„‚ B) (a : A) :
liftLinear f u a=weight f (f a)*u (f a) := rfl
theorem inner_lift (hf : Function.Surjective f) (u v : EuclideanSpace β„‚ B) :
βŸͺliftLinear f u,liftLinear f v⟫_β„‚=βŸͺu,v⟫_β„‚ := by
classical
simp only [PiLp.inner_apply,RCLike.inner_apply,liftLinear_apply,map_mul,star_weight]
rw [←Fintype.sum_fiberwise f]
apply Finset.sum_congr rfl
intro b hb
have he (a : {a : A // f a=b}) :
weight f (f a)*v (f a)*(weight f (f a)*starRingEnd β„‚ (u (f a)))=
(weight f b)^2*(v b*starRingEnd β„‚ (u b)) := by rw [a.property]; ring
simp_rw [he]
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
rw [←mul_assoc,card_mul_weight_sq f hf,one_mul]
def lift (hf : Function.Surjective f) : EuclideanSpace β„‚ B β†’β‚—α΅’[β„‚] EuclideanSpace β„‚ A :=
LinearMap.isometryOfInner (liftLinear f) (inner_lift f hf)
@[simp] theorem lift_apply (hf : Function.Surjective f) (u : EuclideanSpace β„‚ B) (a : A) :
lift f hf u a=weight f (f a)*u (f a) := rfl
theorem mem_range_iff (hf : Function.Surjective f) (u : EuclideanSpace β„‚ A) :
u∈Set.range (lift f hf) ↔ βˆ€a a', f a=f a' β†’ u a=u a' := by
constructor
· rintro ⟨v,rfl⟩ a a' h
simp only [lift_apply,h]
Β· intro h
let rep : B β†’ A := fun b => (hf b).choose
have hr (b : B) : f (rep b)=b := (hf b).choose_spec
refine ⟨WithLp.toLp 2 (fun b => u (rep b)/weight f b),?_⟩
ext a
change weight f (f a)*(u (rep (f a))/weight f (f a))=u a
rw [mul_div_cancelβ‚€ _ (weight_ne_zero f hf _)]
exact h _ _ (hr (f a))
end FiniteOccupations
namespace FiniteTensorOccupations
open scoped InnerProductSpace
variable {I Ξ± : Type*} [Fintype I] [Fintype Ξ±] [DecidableEq Ξ±]
local instance : DecidableEq I := Classical.decEq _
def counts (w : I β†’ Ξ±) (a : Ξ±) : β„• := Fintype.card {i : I // w i=a}
omit [Fintype Ξ±] in
theorem counts_eq_iff (w z : I β†’ Ξ±) :
counts w=counts z ↔ βˆƒΟƒ : I ≃ I, βˆ€i, z (Οƒ i)=w i := by
classical
constructor
Β· intro h
let e (a : Ξ±) : {i : I // w i=a} ≃ {i : I // z i=a} :=
Fintype.equivOfCardEq (congrFun h a)
exact ⟨Equiv.ofFiberEquiv e,Equiv.ofFiberEquiv_map e⟩
Β· rintro βŸ¨Οƒ,hΟƒβŸ©
funext a
apply Fintype.card_congr
exact {
toFun := fun i => βŸ¨Οƒ i,by rw [hΟƒ,i.property]⟩
invFun := fun j => βŸ¨Οƒ.symm j,by rw [←hΟƒ,Οƒ.apply_symm_apply,j.property]⟩
left_inv := by intro i; ext; simp
right_inv := by intro j; ext; simp }
def occupancySetoid : Setoid (I β†’ Ξ±) where
r w z := counts w=counts z
iseqv := ⟨fun _ => rfl,fun h => h.symm,fun h h' => h.trans h'⟩
abbrev Occupation (I Ξ± : Type*) [Fintype I] [DecidableEq Ξ±] :=
Quotient (occupancySetoid (I := I) (Ξ± := Ξ±))
instance : Fintype (Occupation I Ξ±) := Fintype.ofFinite _
noncomputable instance : DecidableEq (Occupation I Ξ±) := Classical.decEq _
def register (w : I β†’ Ξ±) : Occupation I Ξ± := Quotient.mk _ w
omit [Fintype Ξ±] in
@[simp] theorem register_eq_iff (w z : I β†’ Ξ±) :
register w=register z ↔ counts w=counts z := Quotient.eq
omit [Fintype Ξ±] in
theorem register_surjective : Function.Surjective (register (I := I) (Ξ± := Ξ±)) := by
intro q
exact Quotient.inductionOn q (fun w => ⟨w,rfl⟩)
def embedding : EuclideanSpace β„‚ (Occupation I Ξ±) β†’β‚—α΅’[β„‚] EuclideanSpace β„‚ (I β†’ Ξ±) :=
FiniteOccupations.lift register register_surjective
theorem mem_range_iff_symmetric (u : EuclideanSpace β„‚ (I β†’ Ξ±)) :
u∈Set.range (embedding (I := I) (Ξ± := Ξ±)) ↔
βˆ€w : I β†’ Ξ±, βˆ€Οƒ : I ≃ I, u (w ∘ Οƒ)=u w := by
rw [embedding,FiniteOccupations.mem_range_iff]
constructor
Β· intro h w Οƒ
apply h
apply (register_eq_iff _ _).mpr
exact (counts_eq_iff _ _).mpr βŸ¨Οƒ,fun _ => rfl⟩
Β· intro h w z hwz
obtain βŸ¨Οƒ,hΟƒβŸ© := (counts_eq_iff w z).mp ((register_eq_iff _ _).mp hwz)
have he : z ∘ Οƒ=w := funext hΟƒ
simpa only [he] using h z Οƒ
def symmetricSector : Submodule β„‚ (EuclideanSpace β„‚ (I β†’ Ξ±)) where
carrier := {u | βˆ€w : I β†’ Ξ±, βˆ€Οƒ : I ≃ I, u (w ∘ Οƒ)=u w}
zero_mem' := by intro w Οƒ; rfl
add_mem' := by intro u v hu hv w Οƒ; simp [hu w Οƒ,hv w Οƒ]
smul_mem' := by intro c u hu w Οƒ; simp [hu w Οƒ]
def symmetricEmbedding :
EuclideanSpace β„‚ (Occupation I Ξ±) β†’β‚—α΅’[β„‚] symmetricSector (I := I) (Ξ± := Ξ±) where
toLinearMap := (embedding (I := I) (Ξ± := Ξ±)).toLinearMap.codRestrict symmetricSector
(fun u => (mem_range_iff_symmetric _).mp ⟨u,rfl⟩)
norm_map' u := (embedding (I := I) (Ξ± := Ξ±)).norm_map u
theorem symmetricEmbedding_surjective :
Function.Surjective (symmetricEmbedding (I := I) (Ξ± := Ξ±)) := by
intro y
obtain ⟨u,hu⟩ := (mem_range_iff_symmetric (y : EuclideanSpace β„‚ (I β†’ Ξ±))).mpr y.property
refine ⟨u,?_⟩
apply Subtype.ext
exact hu
def occupationMap : symmetricSector (I := I) (Ξ± := Ξ±) ≃ₗᡒ[β„‚]
EuclideanSpace β„‚ (Occupation I Ξ±) :=
(LinearIsometryEquiv.ofSurjective symmetricEmbedding symmetricEmbedding_surjective).symm
@[simp] theorem occupationMap_symm_apply (u : EuclideanSpace β„‚ (Occupation I Ξ±))
(w : I β†’ Ξ±) :
(occupationMap.symm u : EuclideanSpace β„‚ (I β†’ Ξ±)) w =
FiniteOccupations.weight register (register w)*u (register w) := rfl
end FiniteTensorOccupations
end
end OAI