cfahlgren1's picture
download
raw
17.9 kB
10
abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d)
11
abbrev UnitSphere (d : ℕ) := Metric.sphere (0 : Vector d) 1
12
abbrev State (M : ℕ) := Fin (2 ^ M)
13
abbrev Samples (d T : ℕ) := Fin T → Vector d
15
def uniformSphere (d : ℕ) : Measure (UnitSphere d) :=
body · 2 lines
  let σ := (volume : Measure (Vector d)).toSphere
  (σ Set.univ)⁻¹ • σ
19
def sampleLaw (d T : ℕ) : Measure (Samples d T) :=
body · 1 line
  Measure.pi fun _ => stdGaussian (Vector d)
22
def observationReference (d : ℕ) : Measure (Vector d × ℝ) :=
body · 1 line
  (stdGaussian (Vector d)).prod volume
25
structure KernelLearner (d M T : ℕ) where
body · 4 lines
  initial : PMF (Bool × State M)
  transition : ℕ → State M → (Vector d × ℝ) → PMF (Bool × State M)
  output : ℕ → State M → Measure (UnitSphere d)
  output_probability : ∀ t q, IsProbabilityMeasure (output t q)
32
abbrev RunStatus (M : ℕ) := Sum (State M) (ℕ × State M)
34
def tagged (M t : ℕ) (a : Bool × State M) : RunStatus M :=
body · 1 line
  if a.1 then .inr (t, a.2) else .inl a.2
37
def run {d M T : ℕ} (L : KernelLearner d M T) (s : UnitSphere d)
    (x : Samples d T) : ℕ → PMF (RunStatus M)
body · 7 lines
  | 0 => L.initial.map (tagged M 0)
  | n + 1 => (L.run s x n).bind fun status =>
      match status with
      | .inr done => PMF.pure (.inr done)
      | .inl q => if hn : n < T then
          (L.transition (n + 1) q (x ⟨n, hn⟩, ⟪x ⟨n, hn⟩, s.val⟫)).map (tagged M (n + 1))
        else PMF.pure (.inl q)
47
def terminal {d M T : ℕ} (L : KernelLearner d M T) (s : UnitSphere d)
    (x : Samples d T) : PMF (ℕ × State M) :=
body · 4 lines
  (L.run s x T).map fun status =>
    match status with
    | .inl q => (T, q)
    | .inr done => done
54
def estimateLaw {d M T : ℕ} (L : KernelLearner d M T) (s : UnitSphere d)
    (x : Samples d T) : Measure (UnitSphere d) :=
body · 1 line
  (L.terminal s x).toMeasure.bind fun a => L.output a.1 a.2
58
def angularError {d : ℕ} (s u : UnitSphere d) : ℝ :=
body · 1 line
  Real.arccos ⟪u.val, s.val⟫
61
def conditionalSuccess {d M T : ℕ} (L : KernelLearner d M T) (ε : ℝ)
    (s : UnitSphere d) (x : Samples d T) : ℝ≥0∞ :=
body · 1 line
  L.estimateLaw s x {u | angularError s u ≤ ε}
65
def CompletedRules {d M T : ℕ} (L : KernelLearner d M T) : Prop :=
body · 1 line
  ∀ t q dest, AEMeasurable (fun obs => L.transition t q obs dest) (observationReference d)
70
structure SeededLearner (d M T : ℕ) (Ω : Type u) where
body · 1 line
  rules : Ω → KernelLearner d M T
75
structure Admissible {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω]
    (L : SeededLearner d M T Ω) (ρ : Measure Ω) : Prop where
body · 8 lines
  completed_rules : ∀ᵐ ω ∂ρ, (L.rules ω).CompletedRules
  fixed_experiment : ∀ s ε, AEMeasurable
    (fun z : Ω × Samples d T => (L.rules z.1).conditionalSuccess ε s z.2)
    (ρ.prod (sampleLaw d T))
  uniform_experiment : ∀ ε, AEMeasurable
    (fun z : UnitSphere d × (Ω × Samples d T) =>
      (L.rules z.2.1).conditionalSuccess ε z.1 z.2.2)
    ((uniformSphere d).prod (ρ.prod (sampleLaw d T)))
86
def success {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω]
    (L : SeededLearner d M T Ω) (ρ : Measure Ω) (ε : ℝ) (s : UnitSphere d) : ℝ≥0∞ :=
body · 2 lines
  ∫⁻ z : Ω × Samples d T, (L.rules z.1).conditionalSuccess ε s z.2
    ∂(ρ.prod (sampleLaw d T))
91
def uniformSuccess {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω]
    (L : SeededLearner d M T Ω) (ρ : Measure Ω) (ε : ℝ) : ℝ≥0∞ :=
body · 3 lines
  ∫⁻ z : UnitSphere d × (Ω × Samples d T),
    (L.rules z.2.1).conditionalSuccess ε z.1 z.2.2
      ∂((uniformSphere d).prod (ρ.prod (sampleLaw d T)))
98
def ExplicitPrecision : Prop :=
body · 9 lines
  ∀ M : ℕ → ℕ,
    Asymptotics.IsLittleO atTop (fun d => (M d : ℝ)) (fun d => (d : ℝ) ^ 2) →
    ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ,
    0 < ε → ε ≤ 1 / 10 →
    ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ →
    ∀ L : SeededLearner d (M d) T Ω, L.Admissible ρ →
    ((2 / 3 : ℝ≥0∞) ≤ L.uniformSuccess ρ ε ∨
      ∀ s, (2 / 3 : ℝ≥0∞) ≤ L.success ρ ε s) →
    (2 : ℝ)⁻¹ ^ 16 * (d : ℝ) * Real.logb 2 (1 / ε) ≤ (T : ℝ)
117
abbrev Vector (d : ℕ) := EuclideanSpace ℝ (Fin d)
118
abbrev Sphere (E : Type*) [NormedAddCommGroup E] := Metric.sphere (0 : E) 1
120
def sphereLaw (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
    [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] : Measure (Sphere E) :=
body · 2 lines
  let σ := (volume : Measure E).toSphere
  (σ Set.univ)⁻¹ • σ
125
structure Test (d n : ℕ) where
body · 7 lines
  space : Submodule ℝ (Vector d)
  dimension : Module.finrank ℝ space = n
  center : Vector d
  perpendicular : center ∈ spaceᗮ
  radius : ℝ
  radius_positive : 0 < radius
  unit : ‖center‖^2 + radius^2 = 1
134
def Test.point {d n : ℕ} (A : Test d n) (s : Sphere A.space) : Vector d :=
body · 1 line
  A.center + A.radius • s.val.val
145
abbrev Vector (d : ℕ) := Affine.Vector d
146
abbrev Sphere (d : ℕ) := Metric.sphere (0 : Vector d) 1
147
abbrev Rows (d k : ℕ) := Fin k → Vector d
148
abbrev Observation (d k : ℕ) := Rows d k × (Fin k → ℝ)
150
def onTest {d n : ℕ} (A : Affine.Test d n) (s : Affine.Sphere A.space) : Sphere d := by
body · 11 lines
  refine ⟨A.point s,mem_sphere_zero_iff_norm.mpr ?_⟩
  have hs : ‖(s.val : Vector d)‖ = 1 := by
    rw [Submodule.norm_coe]
    exact mem_sphere_zero_iff_norm.mp s.property
  have ho : ⟪A.center, (s.val : Vector d)⟫ = 0 :=
    Submodule.inner_left_of_mem_orthogonal s.val.property A.perpendicular
  have hz : ‖A.point s‖^2 = 1 := by
    rw [Affine.Test.point,norm_add_sq_real,real_inner_smul_right,ho,mul_zero,norm_smul,
      Real.norm_eq_abs,abs_of_pos A.radius_positive,hs,mul_one]
    nlinarith [A.unit]
  nlinarith [norm_nonneg (A.point s)]
163
def norm (d n : ℕ) (g : Sphere d → ℝ≥0∞) : ℝ≥0∞ :=
body · 2 lines
  ⨆ A : Affine.Test d n, (ENNReal.ofReal A.radius)^((d : ℝ)/16) *
    ∫⁻ s : Affine.Sphere A.space, g (onTest A s) ∂Affine.sphereLaw A.space
167
def blockInput {d k : ℕ} {V : Type*} [Fintype V]
    (κ : V → Observation d k → ℝ≥0∞) (g : V → Sphere d → ℝ≥0∞)
    (s : Sphere d) : ℝ≥0∞ :=
body · 2 lines
  ∫⁻ X : Rows d k, ∑ v, κ v (X,fun i => ⟪X i,s.val⟫)*g v s
    ∂Measure.pi (fun _ => stdGaussian (Vector d))
173
def terminalInput {d : ℕ} (π : Measure (Sphere d)) (ε : ℝ) (s : Sphere d) : ℝ≥0∞ :=
body · 1 line
  π {u | Real.arccos ⟪u.val,s.val⟫ ≤ ε}
185
def RadiusWeightedFullEstimate : Prop :=
body · 14 lines
  ∃ C : ℝ, 1 ≤ C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d →
    (∀ W : ℝ, 1 ≤ W → ∀ (V : Type v) [Fintype V] [Nonempty V],
      (Fintype.card V : ℝ) ≤ W →
      ∀ κ : V → Observation d (d/16) → ℝ≥0∞,
      (∀ v, Measurable (κ v)) → (∀ obs, ∑ v, κ v obs ≤ 1) →
      ∀ g : V → Sphere d → ℝ≥0∞,
      (∀ v, Measurable (g v)) → (∀ v s, g v s ≤ 1) →
      ∀ n : ℕ, (d : ℝ)/2 ≤ n → n ≤ d →
      norm d n (blockInput κ g) ≤
        (ENNReal.ofReal W)^(1/((d/16 : ℕ) : ℝ))*ENNReal.ofReal (C^d)*(⨆ v, norm d (n-2) (g v))) ∧
    (∀ n : ℕ, (d : ℝ)/2 ≤ n → n ≤ d →
      ∀ π : Measure (Sphere d), IsProbabilityMeasure π →
      ∀ ε : ℝ, 0 < ε →
      norm d n (terminalInput π ε) ≤ ENNReal.ofReal (C^d)*(ENNReal.ofReal ε)^((d : ℝ)/16))
210
def HalfPrecision : Prop :=
body · 8 lines
  ∃ c : ℝ, 0 < c ∧ ∀ M : ℕ → ℕ,
    Asymptotics.IsLittleO atTop (fun d => (M d : ℝ)) (fun d => (d : ℝ)^2) →
    ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ T : ℕ, ∀ ε : ℝ,
    0 < ε → ε ≤ 1/10 →
    ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ →
    ∀ L : SeededLearner d (M d) T Ω, L.Admissible ρ →
    (1/2 : ℝ≥0∞) ≤ L.uniformSuccess ρ ε →
    c * (d : ℝ) * Real.logb 2 (1/ε) ≤ (T : ℝ)
229
abbrev Vector (m : ℕ) := EuclideanSpace ℝ (Fin m)
230
abbrev Sphere (E : Type*) [NormedAddCommGroup E] := Metric.sphere (0 : E) 1
232
def sphereLaw (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
    [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] : Measure (Sphere E) :=
body · 2 lines
  let σ := (volume : Measure E).toSphere
  (σ Set.univ)⁻¹ • σ
237
def rowsLaw (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
    [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (T : ℕ) :
    Measure (Fin T → E) := Measure.pi fun _ => stdGaussian E
241
structure Stream (E J : Type*) [MeasurableSpace E] (T : ℕ) where
body · 4 lines
  initial : PMF J
  transition : ℕ → J → (E × ℝ) → PMF J
  output : J → Measure E
  output_probability : ∀ q, IsProbabilityMeasure (output q)
252
def run (L : Stream E J T) (s : E) (x : Fin T → E) : ℕ → PMF J
body · 4 lines
  | 0 => L.initial
  | n+1 => (L.run s x n).bind fun q => if hn : n < T then
      L.transition (n+1) q (x ⟨n,hn⟩, ⟪x ⟨n,hn⟩,s⟫)
    else PMF.pure q
258
def estimateLaw (L : Stream E J T) (s : E) (x : Fin T → E) : Measure E :=
body · 1 line
  (L.run s x T).toMeasure.bind L.output
261
def euclideanSuccess (L : Stream E J T) (η : ℝ) (s : E) (x : Fin T → E) : ℝ≥0∞ :=
body · 1 line
  L.estimateLaw s x {y | ‖y-s‖ ≤ η}
264
def angularSuccess (L : Stream E J T) (ε : ℝ) (s : E) (x : Fin T → E) : ℝ≥0∞ :=
body · 1 line
  L.estimateLaw s x {y | Real.arccos ⟪y,s⟫ ≤ ε}
267
def BorelRules (L : Stream E J T) : Prop :=
body · 1 line
  ∀ n q a, Measurable (fun obs => L.transition n q obs a)
270
def suffix (L : Stream E J T) (n k : ℕ) (v : J) : Stream E J k where
body · 4 lines
  initial := PMF.pure v
  transition t := L.transition (n+t)
  output := L.output
  output_probability := L.output_probability
278
def DimensionEstimate : Prop :=
body · 13 lines
  ∃ C : ℝ, 2 ≤ C ∧ ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ j m : ℕ,
    (d : ℝ)/2 + 2*j ≤ m → m ≤ d →
    ∀ η : ℝ, 0 < η →
    ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ →
    ∀ L : Ω → Stream (Vector m) (Fin (2^(d^2))) (j*(d/32)),
    (∀ᵐ ω ∂ρ, (L ω).BorelRules) →
    AEMeasurable (fun z : Sphere (Vector m) × (Ω × (Fin (j*(d/32)) → Vector m)) =>
      (L z.2.1).euclideanSuccess η z.1.val z.2.2)
      ((sphereLaw (Vector m)).prod (ρ.prod (rowsLaw (Vector m) (j*(d/32))))) →
    (∫⁻ z : Sphere (Vector m) × (Ω × (Fin (j*(d/32)) → Vector m)),
      (L z.2.1).euclideanSuccess η z.1.val z.2.2
        ∂(sphereLaw (Vector m)).prod (ρ.prod (rowsLaw (Vector m) (j*(d/32)))))
      ≤ ENNReal.ofReal ((C^(j+1)*η)^((d : ℝ)/32))
303
def AllAffineFullEstimate : Prop :=
body · 14 lines
  ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d → ∀ k : ℕ,
    (d+1)/2 + 2*k ≤ d → ∀ W : ℝ, 1 ≤ W →
    ∀ (J : Type v) [Fintype J] [Nonempty J] [MeasurableSpace J] [MeasurableSingletonClass J],
    (Fintype.card J : ℝ) ≤ W → W^(1/((d/8 : ℕ) : ℝ)) ≤ (2 : ℝ)^d →
    ∀ ε : ℝ, 0 < ε → ε ≤ 1/10 →
    ∀ (Ω : Type u) [MeasurableSpace Ω] (ρ : Measure Ω), IsProbabilityMeasure ρ →
    ∀ L : Ω → Fixed.Stream (Vector d) J (k*(d/16)),
    (∀ᵐ ω ∂ρ, (L ω).BorelRules ∧ ∀ q, ∀ᵐ y ∂(L ω).output q, ‖y‖ = 1) →
    ∀ ell : ℕ, ell ≤ k → ∀ v : J, ∀ n : ℕ, (d+1)/2 + 2*ell ≤ n →
    ∀ A : Test d n,
    (∫⁻ z : Sphere A.space × (Ω × (Fin (ell*(d/16)) → Vector d)),
      ((L z.2.1).suffix ((k-ell)*(d/16)) (ell*(d/16)) v).angularSuccess ε (A.point z.1) z.2.2
        ∂(sphereLaw A.space).prod (ρ.prod (Fixed.rowsLaw (Vector d) (ell*(d/16)))))
      ≤ ENNReal.ofReal (((16 * ((1000 : ℝ)^32)^ell * ε)/A.radius)^(2*(d/32)))
330
def sphereLaw : Measure (Metric.sphere (0 : E) 1) :=
body · 2 lines
  let σ := (volume : Measure E).toSphere
  (σ Set.univ)⁻¹ • σ
339
def ambientSphereLaw : Measure E := (sphereLaw (E := E)).map Subtype.val
349
abbrev Orthogonal (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] :=
body · 1 line
  unitary (E →L[ℝ] E)
352
instance orthogonal_compact : CompactSpace (Orthogonal E) := by
body · 7 lines
  apply isCompact_iff_compactSpace.mp
  apply (isCompact_closedBall (0 : E →L[ℝ] E) 1).of_isClosed_subset isClosed_unitary
  intro u hu
  rw [Metric.mem_closedBall,dist_zero_right]
  apply u.opNorm_le_bound (by norm_num)
  intro x
  simp only [u.norm_map_of_mem_unitary hu,one_mul,le_refl]
361
noncomputable def orthogonalLaw : Measure (Orthogonal E) :=
body · 1 line
  Measure.haarMeasure ⟨⟨Set.univ,isCompact_univ⟩,by simp⟩
372
def blockIso (V : Submodule ℝ E) (u : Orthogonal V) (w : Orthogonal Vᗮ) : E ≃ₗᵢ[ℝ] E :=
body · 3 lines
  (V.orthogonalDecomposition.trans
    ((Unitary.linearIsometryEquiv u).withLpProdCongr 2 (Unitary.linearIsometryEquiv w))).trans
      V.orthogonalDecomposition.symm
386
def directionLaw (V N : Submodule ℝ E) : Measure E :=
body · 2 lines
  ((orthogonalLaw (E := Vᗮ)).prod (SubsphereRegression.ambientSphereLaw (E := N))).map
    (fun z => blockIso V 1 z.1 (z.2 : E))
390
def directionJointLaw (V N : Submodule ℝ E) (t : ℕ) : Measure (Fin t → E) :=
body · 3 lines
  ((orthogonalLaw (E := Vᗮ)).prod
    (Measure.pi (fun _ : Fin t => SubsphereRegression.ambientSphereLaw (E := N)))).map
      (fun z i => blockIso V 1 z.1 (z.2 i : E))
395
def latitudeSpace (V : Submodule ℝ E) (e : Metric.sphere (0 : V) 1) : Submodule ℝ E :=
body · 1 line
  (ℝ ∙ (e.val : E))ᗮ
398
def latitudeLaw (V : Submodule ℝ E) (e : Metric.sphere (0 : V) 1) (a delta : ℝ) : Measure E :=
body · 4 lines
  ((betaMeasure a delta).prod ((orthogonalLaw (E := V)).prod
    (SubsphereRegression.ambientSphereLaw (E := latitudeSpace V e)))).map
      (fun z => blockIso V z.2.1 1
        (Real.sqrt (1-z.1) • (e.val : E) + Real.sqrt z.1 • (z.2.2 : E)))
404
def MixtureEstimate (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
    [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] : Prop :=
body · 12 lines
  (∀ (V N : Submodule ℝ E), V ≤ N → 1 ≤ Module.finrank ℝ V →
    Module.finrank ℝ V < Module.finrank ℝ N → Module.finrank ℝ N < Module.finrank ℝ E →
    ∀ e : Metric.sphere (0 : V) 1,
    directionLaw V N ≤ (2 : ℝ≥0∞) ^ Module.finrank ℝ E •
      (SubsphereRegression.ambientSphereLaw + latitudeLaw V e
        (((Module.finrank ℝ N : ℝ)-(Module.finrank ℝ V : ℝ))/2)
        (((Module.finrank ℝ E : ℝ)-(Module.finrank ℝ N : ℝ))/2))) ∧
  (∀ N : Submodule ℝ E, 1 ≤ Module.finrank ℝ N →
    directionLaw ⊥ N = SubsphereRegression.ambientSphereLaw) ∧
  (∀ (V : Submodule ℝ E) (t : ℕ), 1 ≤ Module.finrank ℝ E →
    directionJointLaw V ⊤ t =
      Measure.pi (fun _ : Fin t => SubsphereRegression.ambientSphereLaw))
426
def CurrentMainScope : Prop :=
body · 7 lines
  ExplicitPrecision.{u} ∧
  Weighted.RadiusWeightedFullEstimate.{v} ∧
  HalfPrecision.{u} ∧
  Affine.AllAffineFullEstimate.{u,v} ∧
  Fixed.DimensionEstimate.{u} ∧
  (∀ (E : Type w) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
    [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E], Mixture.MixtureEstimate E)

Xet Storage Details

Size:
17.9 kB
·
Xet hash:
21d30a24f4fb728be9974be6c84a5f5c7c2f0f2aa785916ca90ca9be7c79fd68

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.