cfahlgren1's picture
download
raw
25.5 kB
11
abbrev Time := unitInterval
13
abbrev Spin (N : ℕ) := EuclideanSpace ℝ (Fin N)
15
def unitSphereLaw (N : ℕ) : Measure (Metric.sphere (0 : Spin N) 1) :=
body · 2 lines
  let s := (volume : Measure (Spin N)).toSphere
  (s Set.univ)⁻¹ • s
19
structure Trial where
body · 5 lines
  toFun : Time → ℝ
  monotone : Monotone toFun
  measurable : Measurable toFun
  nonneg : ∀ t, 0 ≤ toFun t
  le_one : ∀ t, toFun t ≤ 1
26
instance : CoeFun Trial (fun _ => Time → ℝ) := ⟨Trial.toFun⟩
28
def timeLaw : Measure Time := Measure.comap Subtype.val volume
30
def tailIntegral (m : Trial) (t : Time) : ℝ :=
body · 1 line
  ∫ s in Set.Ici t, m s ∂timeLaw
33
def entropy (m : Trial) : ℝ≥0∞ :=
body · 2 lines
  (∫⁻ t, (ENNReal.ofReal (tailIntegral m t))⁻¹ -
    (ENNReal.ofReal (1 - (t : ℝ)))⁻¹ ∂timeLaw) / 2
37
@[simp] theorem timeLaw_eq_volume : timeLaw = (volume : Measure Time) := rfl
39
instance : IsProbabilityMeasure timeLaw := by
body · 2 lines
  rw [timeLaw_eq_volume]
  infer_instance
43
def finitePointMeasure {S : Type*} [MeasurableSpace S] (n : ℕ) (x : Fin n → S) : Measure S :=
body · 1 line
  ∑ i : Fin n, Measure.dirac (x i)
46
@[fun_prop] lemma finitePointMeasure_measurable {S : Type*} [MeasurableSpace S] (n : ℕ) :
    Measurable (finitePointMeasure (S := S) n) := by
proof · 2 lines
  unfold finitePointMeasure
  fun_prop
51
def finitePoissonLaw {S : Type*} [MeasurableSpace S] (r : ℝ≥0) (ν : Measure S) :
    Measure (Measure S) :=
body · 2 lines
  Measure.sum fun n : ℕ =>
    poissonMeasure r {n} • (Measure.pi fun _ : Fin n => ν).map (finitePointMeasure n)
56
instance finitePoissonLaw_probability {S : Type*} [MeasurableSpace S]
    (r : ℝ≥0) (ν : Measure S) [IsProbabilityMeasure ν] :
    IsProbabilityMeasure (finitePoissonLaw r ν) := by
body · 10 lines
  constructor
  rw [finitePoissonLaw,Measure.sum_apply _ MeasurableSet.univ]
  have hmass (n : ℕ) : ((Measure.pi fun _ : Fin n => ν).map (finitePointMeasure n)) univ = 1 := by
    rw [Measure.map_apply (finitePointMeasure_measurable n) MeasurableSet.univ,
      preimage_univ,measure_univ]
  simp only [Measure.smul_apply,hmass,smul_eq_mul,mul_one]
  have hh := hasSum_one_poissonMeasure r
  simp_rw [poissonMeasure_singleton]
  rw [← ENNReal.ofReal_tsum_of_nonneg (fun _ => by positivity) hh.summable,hh.tsum_eq]
  norm_num
70
lemma measureSum_measurable {S : Type*} [MeasurableSpace S] :
    Measurable (fun η : ℕ → Measure S => Measure.sum η) := by
proof · 4 lines
  apply Measure.measurable_of_measurable_coe
  intro s hs
  simp only [Measure.sum_apply _ hs]
  exact Measurable.tsum fun i => (Measure.measurable_coe hs).comp (measurable_pi_apply i)
77
def countablePoissonLaw {S : Type*} [MeasurableSpace S]
    (r : ℕ → ℝ≥0) (ν : ℕ → Measure S) : Measure (Measure S) :=
body · 1 line
  (Measure.infinitePi fun i => finitePoissonLaw (r i) (ν i)).map Measure.sum
81
instance countablePoissonLaw_probability {S : Type*} [MeasurableSpace S]
    (r : ℕ → ℝ≥0) (ν : ℕ → Measure S) [∀ i, IsProbabilityMeasure (ν i)] :
    IsProbabilityMeasure (countablePoissonLaw r ν) := by
body · 2 lines
  unfold countablePoissonLaw
  infer_instance
87
def finiteIntensityMarks {S : Type*} [MeasurableSpace S] [Nonempty S] (κ : Measure S) : Measure S :=
body · 1 line
  if κ univ = 0 then Measure.dirac (Classical.choice ‹Nonempty S›) else (κ univ)⁻¹ • κ
90
instance finiteIntensityMarks_probability {S : Type*} [MeasurableSpace S] [Nonempty S]
    (κ : Measure S) [IsFiniteMeasure κ] : IsProbabilityMeasure (finiteIntensityMarks κ) := by
body · 5 lines
  by_cases hκ : κ univ = 0
  · simp only [finiteIntensityMarks,ite_eq_left hκ]
    infer_instance
  · constructor
    simp [finiteIntensityMarks,hκ,ENNReal.inv_mul_cancel hκ (measure_ne_top _ _)]
98
def poissonRandomMeasureLaw {S : Type*} [MeasurableSpace S] [Nonempty S]
    (κ : Measure S) [SFinite κ] : Measure (Measure S) :=
body · 2 lines
  countablePoissonLaw (fun i => ((sfiniteSeq κ i) univ).toNNReal)
    (fun i => finiteIntensityMarks (sfiniteSeq κ i))
103
instance poissonRandomMeasureLaw_probability {S : Type*} [MeasurableSpace S] [Nonempty S]
    (κ : Measure S) [SFinite κ] : IsProbabilityMeasure (poissonRandomMeasureLaw κ) := by
body · 2 lines
  unfold poissonRandomMeasureLaw
  infer_instance
108
def stableLogIntensity (b : ℝ) : Measure ℝ :=
body · 1 line
  volume.withDensity (fun x => ENNReal.ofReal (b * Real.exp (-b*x)))
111
instance stableLogIntensity_sigmaFinite (b : ℝ) : SigmaFinite (stableLogIntensity b) := by
body · 2 lines
  unfold stableLogIntensity
  infer_instance
115
def normalizedMeasure {S : Type*} [MeasurableSpace S] (μ : Measure S) : Measure S :=
body · 1 line
  (μ univ)⁻¹ • μ
118
lemma measurable_measure_withDensity_fixed {S : Type*} [MeasurableSpace S]
    {f : S → ℝ≥0∞} (hf : Measurable f) : Measurable (fun μ : Measure S => μ.withDensity f) := by
proof · 3 lines
  refine Measure.measurable_of_measurable_coe _ fun s hs => ?_
  simp only [withDensity_apply _ hs,← lintegral_indicator hs]
  exact Measure.measurable_lintegral (hf.indicator hs)
124
lemma normalizedMeasure_measurable {S : Type*} [MeasurableSpace S] :
    Measurable (normalizedMeasure (S := S)) := by
proof · 3 lines
  refine Measure.measurable_of_measurable_coe _ fun s hs => ?_
  change Measurable (fun μ : Measure S => (μ univ)⁻¹ * μ s)
  exact (Measure.measurable_coe MeasurableSet.univ).inv.mul (Measure.measurable_coe hs)
133
def markedStableTotalE (η : Measure (ℝ × S)) : ℝ≥0∞ :=
body · 1 line
  ∫⁻ p, ENNReal.ofReal (Real.exp p.1) ∂η
136
@[fun_prop] lemma markedStableTotalE_measurable : Measurable (markedStableTotalE (S := S)) :=
proof · 1 line
  Measure.measurable_lintegral (by fun_prop)
139
def markedStableTotal (η : Measure (ℝ × S)) : ℝ := (markedStableTotalE η).toReal
141
@[fun_prop] lemma markedStableTotal_measurable : Measurable (markedStableTotal (S := S)) :=
proof · 1 line
  markedStableTotalE_measurable.ennreal_toReal
144
def markedStableMassKernel : Kernel (Measure (ℝ × S)) (ℝ × S) where
body · 2 lines
  toFun η := normalizedMeasure (η.withDensity (fun p => ENNReal.ofReal (Real.exp p.1)))
  measurable' := normalizedMeasure_measurable.comp (measurable_measure_withDensity_fixed (by fun_prop))
148
instance markedStableMassKernel_finite : IsFiniteKernel (markedStableMassKernel (S := S)) := by
body · 5 lines
  refine ⟨1, by simp, ?_⟩
  intro η
  change (η.withDensity (fun p => ENNReal.ofReal (Real.exp p.1)) univ)⁻¹ *
    (η.withDensity (fun p => ENNReal.ofReal (Real.exp p.1)) univ) ≤ 1
  exact ENNReal.inv_mul_le_one _
155
def markedStableCountKernel : Kernel (Measure (ℝ × S)) (ℝ × S) :=
body · 1 line
  markedStableMassKernel.withDensity (fun η p => ENNReal.ofReal (markedStableTotal η*Real.exp (-p.1)))
160
@[reducible] def DecoratedCascade (S : Type) [MeasurableSpace S] : ℕ → MeasCat
body · 2 lines
  | 0 => MeasCat.of Unit
  | n+1 => MeasCat.of (Measure (ℝ×(S×DecoratedCascade S n)))
164
instance decoratedCascadeNonempty (S : Type) [MeasurableSpace S] (n : ℕ) :
    Nonempty (DecoratedCascade S n) := by
body · 3 lines
  cases n with
  | zero => exact ⟨()⟩
  | succ n => exact ⟨(0 : Measure (ℝ×(S×DecoratedCascade S n)))⟩
170
def decoratedCascadeLaw {S : Type} [MeasurableSpace S] [Nonempty S]
    (ν : ProbabilityMeasure S) : (n : ℕ) → (Fin n → ℝ) → ProbabilityMeasure (DecoratedCascade S n)
body · 4 lines
  | 0, _ => ⟨Measure.dirac (),by exact Measure.dirac.isProbabilityMeasure⟩
  | n+1, z => ⟨poissonRandomMeasureLaw ((stableLogIntensity (z 0)).prod
      ((ν : Measure S).prod (decoratedCascadeLaw ν n (fun i => z i.succ)))),
        by exact poissonRandomMeasureLaw_probability _⟩
177
def decoratedTerminalTotalE {X S : Type} [MeasurableSpace X] [MeasurableSpace S]
    (step : X×S → X) (H : X → ℝ) : (n : ℕ) → X×DecoratedCascade S n → ℝ≥0∞
body · 3 lines
  | 0, p => ENNReal.ofReal (Real.exp (H p.1))
  | n+1, p => ∫⁻ q : ℝ×(S×DecoratedCascade S n), ENNReal.ofReal (Real.exp q.1) *
      decoratedTerminalTotalE step H n (step (p.1,q.2.1),q.2.2) ∂markedStableCountKernel p.2
183
def decoratedTerminalTotal {X S : Type} [MeasurableSpace X] [MeasurableSpace S]
    (step : X×S → X) (H : X → ℝ) (n : ℕ) (p : X×DecoratedCascade S n) : ℝ :=
body · 1 line
  (decoratedTerminalTotalE step H n p).toReal
187
def gaussianShiftStep (σ : ℕ → ℝ) (p : (ℕ → ℝ) × ℝ) : ℕ → ℝ :=
body · 1 line
  fun i => p.1 (i+1)+σ i*p.2
190
def standardGaussianMark : ProbabilityMeasure ℝ := ⟨gaussianReal 0 1,inferInstance⟩
192
def piMarkLaw {ι S : Type} [Fintype ι] [MeasurableSpace S]
    (ν : ι → ProbabilityMeasure S) : ProbabilityMeasure (ι → S) :=
body · 1 line
  ⟨Measure.pi (fun i => (ν i : Measure S)),inferInstance⟩
196
def canonicalCoordinateStep (d : ℕ) (σ : ℕ → ℝ) :
    (Fin d → ℕ → ℝ)×(Fin d → ℝ) → (Fin d → ℕ → ℝ) :=
body · 1 line
  fun p i => gaussianShiftStep σ (p.1 i,p.2 i)
200
def decoratedLeafIntegral {X S : Type} [MeasurableSpace X] [MeasurableSpace S]
    (step : X × S → X) (F : X → ℝ≥0∞) :
    (n : ℕ) → X × DecoratedCascade S n → ℝ≥0∞
body · 5 lines
  | 0, p => F p.1
  | n+1, p => ∫⁻ q : ℝ × (S × DecoratedCascade S n),
      ENNReal.ofReal (Real.exp q.1) *
        decoratedLeafIntegral step F n (step (p.1,q.2.1),q.2.2)
          ∂markedStableCountKernel p.2
209
def decoratedFieldFactor {X S : Type} [MeasurableSpace X] [MeasurableSpace S]
    (d : ℕ) (step : X × S → X) (field : X → Spin d) (k : ℕ)
    (p : X × DecoratedCascade S k) (x : Spin d) : ℝ≥0∞ :=
body · 1 line
  decoratedLeafIntegral step (fun y => ENNReal.ofReal (Real.exp (inner ℝ (field y) x))) k p
214
def decoratedAngularFactor {X S : Type} [MeasurableSpace X] [MeasurableSpace S]
    (n : ℕ) (step : X × S → X) (field : X → Spin (n+1)) (k : ℕ)
    (p : X × DecoratedCascade S k) (r : ℝ) : ℝ≥0∞ :=
body · 2 lines
  ∫⁻ u : Metric.sphere (0:Spin (n+1)) 1,
    decoratedFieldFactor (n+1) step field k p (r • (u:Spin (n+1))) ∂unitSphereLaw (n+1)
220
def coordinateLeafField (d : ℕ) (x : Fin d → ℕ → ℝ) : Spin d :=
body · 1 line
  WithLp.toLp 2 (fun i => x i 0)
223
def coordinateCascadeLaw (d k : ℕ) (z : Fin k → ℝ) (r : ℝ≥0) :
    Measure ((Fin d → ℝ) × DecoratedCascade (Fin d → ℝ) k) :=
body · 2 lines
  (Measure.pi (fun _ : Fin d => gaussianReal 0 r)).prod
    (decoratedCascadeLaw (piMarkLaw (fun _ : Fin d => standardGaussianMark)) k z)
228
def coordinateAngularLog (n k : ℕ) (σ : ℕ → ℝ) (R : ℝ)
    (p : (Fin (n+1) → ℕ → ℝ) × DecoratedCascade (Fin (n+1) → ℝ) k) : ℝ :=
body · 3 lines
  Real.log ((decoratedAngularFactor n (canonicalCoordinateStep (n+1) σ)
    (coordinateLeafField (n+1)) k p R).toReal /
      decoratedTerminalTotal (canonicalCoordinateStep (n+1) σ) (fun _ => 0) k p)
234
def normalizedCoordinateSphereLog (n k : ℕ) (σ : ℕ → ℝ)
    (p : (Fin (n+1) → ℝ) × DecoratedCascade (Fin (n+1) → ℝ) k) : ℝ :=
body · 1 line
  coordinateAngularLog n k σ (Real.sqrt (n+1:ℕ)) ((fun i _ => p.1 i),p.2) / ((n+1:ℕ):ℝ)
238
def expectedCoordinateSphereLog (n k : ℕ) (σ : ℕ → ℝ) (z : Fin k → ℝ) (r : ℝ≥0) : ℝ :=
body · 1 line
  ∫ p, normalizedCoordinateSphereLog n k σ p ∂coordinateCascadeLaw (n+1) k z r
241
def weightedStepTrial {I : Type*} [Fintype I] (w : I → ℝ) (q : I → Time)
    (hw : ∀ i, 0 ≤ w i) (hw1 : ∑ i, w i = 1) : Trial where
body · 24 lines
  toFun := fun t => ∑ i, if q i ≤ t then w i else 0
  monotone := by
    intro s t hst
    apply Finset.sum_le_sum
    intro i _
    by_cases hi : q i ≤ s
    · simp only [ite_eq_left hi,ite_eq_left (hi.trans hst),le_refl]
    · rw [ite_eq_right hi]
      split_ifs <;> first | exact hw i | rfl
  measurable := by
    apply Finset.measurable_sum
    intro i _
    exact measurable_const.ite (measurableSet_le measurable_const measurable_id) measurable_const
  nonneg := by
    intro t
    apply Finset.sum_nonneg
    intro i _
    split_ifs <;> first | exact hw i | rfl
  le_one := by
    intro t
    rw [← hw1]
    apply Finset.sum_le_sum
    intro i _
    split_ifs <;> first | rfl | exact hw i
268
def stepCumulative {k : ℕ} (w : Fin (k+1) → ℝ) (i : Fin k) : ℝ :=
body · 1 line
  ∑ j : Fin (k+1), if j ≤ i.castSucc then w j else 0
271
def stepFieldIncrement (k : ℕ) (h : Fin (k+1) → ℝ) (j : ℕ) : ℝ :=
body · 2 lines
  if hj : j < k then
    Real.sqrt (2*(h (Fin.rev ⟨j,hj⟩).succ-h (Fin.rev ⟨j,hj⟩).castSucc)) else 0
275
def finiteSphericalFieldValue (n k : ℕ) (w h : Fin (k+1) → ℝ) : ℝ :=
body · 2 lines
  expectedCoordinateSphereLog n k (stepFieldIncrement k h) (stepCumulative w)
    (Real.toNNReal (2*h 0))-h (Fin.last k)
279
def finiteSphericalDualObjective {k : ℕ} (w h : Fin (k+1) → ℝ)
    (hw : ∀ i, 0 ≤ w i) (hw1 : ∑ i, w i=1) (q : Fin (k+1) → Time) : ℝ :=
body · 1 line
  (entropy (weightedStepTrial w q hw hw1)).toReal-∑ i, w i*h i*(q i:ℝ)
283
def finiteSphericalDualValues {k : ℕ} (w h : Fin (k+1) → ℝ)
    (hw : ∀ i, 0 ≤ w i) (hw1 : ∑ i, w i=1) : Set ℝ :=
body · 2 lines
  finiteSphericalDualObjective w h hw hw1 ''
    {q : Fin (k+1) → Time | Monotone q ∧ (q (Fin.last k):ℝ) < 1}
288
structure FiniteFieldModel (f : Time → ℝ) where
body · 7 lines
  depth : ℕ
  value : Fin (depth+1) → ℝ
  label : Time → Fin (depth+1)
  measurable_label : Measurable label
  positive : ∀ i, 0 < timeLaw.real (label ⁻¹' {i})
  monotone_value : Monotone value
  agrees : (fun u => value (label u)) =ᵐ[timeLaw] f
297
def FiniteFieldModel.weight {f : Time → ℝ} (M : FiniteFieldModel f) (i : Fin (M.depth+1)) : ℝ :=
body · 1 line
  timeLaw.real (M.label ⁻¹' {i})
300
def FiniteFieldModel.pressure {f : Time → ℝ} (M : FiniteFieldModel f) (n : ℕ) : ℝ :=
body · 1 line
  finiteSphericalFieldValue n M.depth M.weight M.value
303
theorem exists_finiteFieldModel (f : Time → ℝ) (hf : Measurable f)
    (hfin : (Set.range f).Finite) : Nonempty (FiniteFieldModel f) := by
proof · 48 lines
  classical
  let S := hfin.toFinset
  let T := S.filter (fun r => 0 < timeLaw.real (f ⁻¹' {r}))
  have hae : ∀ᵐ u ∂timeLaw, f u ∈ T := by
    have hnull : ∀ r ∈ S, ∀ᵐ u ∂timeLaw, f u=r → 0 < timeLaw.real (f ⁻¹' {r}) := by
      intro r hr
      by_cases hp : 0 < timeLaw.real (f ⁻¹' {r})
      · exact ae_of_all _ (fun _ _ => hp)
      · have hz : timeLaw (f ⁻¹' {r})=0 := by
          have hz : (timeLaw (f ⁻¹' {r})).toReal=0 := le_antisymm (le_of_not_gt hp) ENNReal.toReal_nonneg
          have hp := (ENNReal.toReal_eq_zero_iff _).mp hz
          rcases hp with hp | hp
          · exact hp
          · exact (measure_ne_top _ _ hp).elim
        have hnot : ∀ᵐ u ∂timeLaw, f u ≠ r := by
          apply ae_iff.mpr
          simpa only [Set.preimage,Set.mem_singleton_iff,not_not] using hz
        filter_upwards [hnot] with u hu
        exact fun h => (hu h).elim
    have hall := (S.eventually_all).mpr hnull
    filter_upwards [hall] with u hu
    have hmem : f u ∈ S := hfin.mem_toFinset.mpr (mem_range_self u)
    exact Finset.mem_filter.mpr ⟨hmem,hu (f u) hmem rfl⟩
  have hT : T.Nonempty := by
    obtain ⟨u,hu⟩ := hae.exists
    exact ⟨f u,hu⟩
  obtain ⟨d,hd⟩ := Nat.exists_eq_succ_of_ne_zero (Finset.card_ne_zero.mpr hT)
  let e := T.orderIsoOfFin hd
  let v : Fin (d+1) → ℝ := fun i => e i
  have hv : StrictMono v := fun i j hij => e.strictMono hij
  have hve : MeasurableEmbedding v := ⟨hv.injective,measurable_of_finite _,fun _ _ => (Set.toFinite _).measurableSet⟩
  let a : Time → Fin (d+1) := fun u => hve.invFun (f u)
  have hag : (fun u => v (a u)) =ᵐ[timeLaw] f := by
    filter_upwards [hae] with u hu
    have hx : f u=v (e.symm ⟨f u,hu⟩) := congrArg Subtype.val (e.apply_symm_apply ⟨f u,hu⟩) |>.symm
    dsimp only [a]
    rw [hx,hve.leftInverse_invFun]
  refine ⟨⟨d,v,a,hve.measurable_invFun.comp hf,?_,hv.monotone,hag⟩⟩
  intro i
  have he : a ⁻¹' {i}=ᵐ[timeLaw] f ⁻¹' {v i} := by
    filter_upwards [hag] with u hu
    apply propext
    change (a u=i) ↔ f u=v i
    rw [← hu]
    exact hv.injective.eq_iff.symm
  change 0 < (timeLaw (a ⁻¹' {i})).toReal
  rw [measure_congr he]
  exact (Finset.mem_filter.mp (e i).2).2
354
structure BoundedField (H : ℝ) where
body · 4 lines
  toFun : Time → ℝ
  monotone : Monotone toFun
  nonneg : ∀ u, 0 ≤ toFun u
  le_bound : ∀ u, toFun u ≤ H
360
instance {H : ℝ} : CoeFun (BoundedField H) (fun _ => Time → ℝ) := ⟨BoundedField.toFun⟩
362
lemma BoundedField.measurable {H : ℝ} (f : BoundedField H) : Measurable f := f.monotone.measurable
364
def roundLower (N : ℕ) (x : ℝ) : ℝ := (⌊(N+1:ℕ)*x⌋₊:ℝ)/(N+1:ℕ)
366
lemma roundLower_nonneg (N : ℕ) (x : ℝ) : 0 ≤ roundLower N x := by unfold roundLower; positivity
368
lemma roundLower_monotone (N : ℕ) : Monotone (roundLower N) := by
proof · 3 lines
  intro x y hxy
  apply div_le_div_of_nonneg_right _ (by positivity)
  exact_mod_cast Nat.floor_mono (mul_le_mul_of_nonneg_left hxy (by positivity))
373
lemma roundLower_le (N : ℕ) {x : ℝ} (hx : 0 ≤ x) : roundLower N x ≤ x := by
proof · 3 lines
  unfold roundLower
  rw [div_le_iff₀ (by positivity : (0:ℝ)<(N+1:ℕ))]
  simpa only [mul_comm] using Nat.floor_le (mul_nonneg (by positivity) hx)
378
def BoundedField.round {H : ℝ} (f : BoundedField H) (N : ℕ) : BoundedField H where
body · 4 lines
  toFun := fun u => roundLower N (f u)
  monotone := (roundLower_monotone N).comp f.monotone
  nonneg := fun u => roundLower_nonneg N (f u)
  le_bound := fun u => (roundLower_le N (f.nonneg u)).trans (f.le_bound u)
384
lemma BoundedField.round_finite {H : ℝ} (f : BoundedField H) (N : ℕ) :
    (Set.range (f.round N)).Finite := by
proof · 7 lines
  let T := (Finset.range (⌊(N+1:ℕ)*H⌋₊+1)).image (fun k : ℕ => (k:ℝ)/(N+1:ℕ))
  apply T.finite_toSet.subset
  rintro x ⟨u,rfl⟩
  apply Finset.mem_image.mpr
  refine ⟨⌊(N+1:ℕ)*f u⌋₊,?_,rfl⟩
  apply Finset.mem_range.mpr
  exact Nat.lt_succ_of_le (Nat.floor_mono (mul_le_mul_of_nonneg_left (f.le_bound u) (by positivity)))
394
def BoundedField.roundModel {H : ℝ} (f : BoundedField H) (N : ℕ) : FiniteFieldModel (f.round N) :=
body · 1 line
  Classical.choice (exists_finiteFieldModel _ (f.round N).measurable (f.round_finite N))
397
def quantileTrial (q : Time → Time) : Trial where
body · 12 lines
  toFun := fun t => timeLaw.real {u | q u ≤ t}
  monotone := by
    intro s t hst
    exact measureReal_mono (fun u hu => hu.trans hst)
  measurable := by
    apply Monotone.measurable
    intro s t hst
    exact measureReal_mono (fun u hu => hu.trans hst)
  nonneg := fun _ => measureReal_nonneg
  le_one := by
    intro t
    exact measureReal_le_one
411
def quantileTail (q : Time → Time) (t : ℝ) : ℝ :=
body · 1 line
  ∫ u, 1-max (q u:ℝ) t ∂timeLaw
414
lemma quantileTail_integrable (q : Time → Time) (hq : Measurable q) (t : ℝ) :
    Integrable (fun u => 1-max (q u:ℝ) t) timeLaw := by
proof · 14 lines
  have hm : Measurable (fun u => 1-max (q u:ℝ) t) :=
    measurable_const.sub ((measurable_subtype_coe.comp hq).max measurable_const)
  apply Integrable.mono' (integrable_const (2+|t|)) hm.aestronglyMeasurable
  exact ae_of_all _ fun u => by
    rw [Real.norm_eq_abs]
    have hq0 := (q u).2.1
    have hq1 := (q u).2.2
    have ha : |max (q u:ℝ) t| ≤ 1+|t| := by
      rcases le_total (q u:ℝ) t with h | h
      · rw [max_eq_right h]; linarith
      · rw [max_eq_left h,abs_of_nonneg hq0]; nlinarith [abs_nonneg t]
    have hb := abs_sub 1 (max (q u:ℝ) t)
    norm_num at hb
    linarith
431
lemma quantileTail_lower (q : Time → Time) (hq : Measurable q) {B t : ℝ}
    (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) (ht : t ≤ B) :
    1-B ≤ quantileTail q t := by
proof · 3 lines
  have h := integral_mono_ae (integrable_const (1-B)) (quantileTail_integrable q hq t)
    (hb.mono fun u hu => sub_le_sub_left (max_le hu ht) 1)
  simpa [quantileTail] using h
438
lemma quantileTail_lipschitz (q : Time → Time) (hq : Measurable q) :
    LipschitzWith 1 (quantileTail q) := by
proof · 16 lines
  apply LipschitzWith.of_dist_le_mul
  intro s t
  rw [Real.dist_eq,Real.dist_eq,NNReal.coe_one,one_mul]
  unfold quantileTail
  rw [← integral_sub (quantileTail_integrable q hq s) (quantileTail_integrable q hq t)]
  calc
    _ ≤ ∫ u, |(1-max (q u:ℝ) s)-(1-max (q u:ℝ) t)| ∂timeLaw := abs_integral_le_integral_abs
    _ ≤ ∫ _ : Time, |s-t| ∂timeLaw := by
      apply integral_mono ((quantileTail_integrable q hq s).sub (quantileTail_integrable q hq t)).abs (integrable_const _)
      intro u
      have h := (LipschitzWith.id.const_max (q u:ℝ)).dist_le_mul s t
      simp only [Real.dist_eq,NNReal.coe_one,one_mul] at h
      change |(1-max (q u:ℝ) s)-(1-max (q u:ℝ) t)| ≤ _
      rw [show (1-max (q u:ℝ) s)-(1-max (q u:ℝ) t)=max (q u:ℝ) t-max (q u:ℝ) s by ring,abs_sub_comm]
      exact h
    _ = _ := by simp
457
def boundedSphericalFieldValue {H : ℝ} (f : BoundedField H) (n : ℕ) : ℝ :=
body · 1 line
  limUnder atTop (fun N => (f.roundModel N).pressure n)
460
def BoundedField.toQuantile {B : ℝ} (q : BoundedField B) (hB : B ≤ 1) : Time → Time :=
body · 1 line
  fun u => ⟨q u,q.nonneg u,(q.le_bound u).trans hB⟩
463
lemma BoundedField.toQuantile_measurable {B : ℝ} (q : BoundedField B) (hB : B ≤ 1) :
    Measurable (q.toQuantile hB) := q.measurable.subtype_mk
466
def quantileA (q : Time → Time) (r : ℝ) : ℝ :=
body · 1 line
  ∫ t in (0:ℝ)..r, 1/(quantileTail q t)^2
469
lemma quantileA_integrand_continuous {B : ℝ} (q : Time → Time) (hq : Measurable q)
    (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) :
    ContinuousOn (fun t => 1/(quantileTail q t)^2) (Icc 0 B) := by
proof · 3 lines
  apply continuousOn_const.div ((quantileTail_lipschitz q hq).continuous.continuousOn.pow 2)
  intro t ht
  exact pow_ne_zero _ (ne_of_gt ((sub_pos.mpr hB).trans_le (quantileTail_lower q hq hb ht.2)))
476
lemma quantileA_integrand_bound {B t : ℝ} (q : Time → Time) (hq : Measurable q)
    (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) (ht : t ≤ B) :
    1/(quantileTail q t)^2 ≤ 1/(1-B)^2 := by
proof · 3 lines
  have hd := quantileTail_lower q hq hb ht
  exact one_div_le_one_div_of_le (sq_pos_of_pos (sub_pos.mpr hB))
    (pow_le_pow_left₀ (sub_nonneg.mpr hB.le) hd 2)
483
lemma quantileA_nonneg (q : Time → Time) {r : ℝ} (hr : 0 ≤ r) : 0 ≤ quantileA q r :=
proof · 1 line
  intervalIntegral.integral_nonneg hr (fun _ _ => by positivity)
486
lemma quantileA_mono {B : ℝ} (q : Time → Time) (hq : Measurable q)
    (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) :
    MonotoneOn (quantileA q) (Icc 0 B) := by
proof · 4 lines
  intro r hr s hs hrs
  exact intervalIntegral.integral_mono_interval le_rfl hr.1 hrs
    (ae_of_all _ fun _ => by positivity)
    (((quantileA_integrand_continuous q hq hB hb).mono (Icc_subset_Icc le_rfl hs.2)).intervalIntegrable_of_Icc hs.1)
494
lemma quantileA_bound {B r : ℝ} (q : Time → Time) (hq : Measurable q)
    (hB : B < 1) (hb : ∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) (hr : r ∈ Icc 0 B) :
    quantileA q r ≤ B/(1-B)^2 := by
proof · 7 lines
  have h := intervalIntegral.integral_mono_on hr.1
    (((quantileA_integrand_continuous q hq hB hb).mono (Icc_subset_Icc le_rfl hr.2)).intervalIntegrable_of_Icc hr.1)
    (intervalIntegrable_const (μ := volume) (c := 1/(1-B)^2))
    (fun t ht => quantileA_integrand_bound q hq hB hb (ht.2.trans hr.2))
  have he : (∫ _t in (0:ℝ)..r, 1/(1-B)^2)=r/(1-B)^2 := by simp [div_eq_mul_inv]
  rw [he] at h
  exact h.trans (div_le_div_of_nonneg_right hr.2 (sq_nonneg _))
505
def BoundedField.stationary {B : ℝ} (q : BoundedField B) (hB : B < 1) :
    BoundedField (B/(2*(1-B)^2)) where
body · 12 lines
  toFun := fun u => quantileA (q.toQuantile hB.le) (q u)/2
  monotone := fun u v huv => div_le_div_of_nonneg_right
    (quantileA_mono _ (q.toQuantile_measurable hB.le) hB (ae_of_all _ q.le_bound)
      ⟨q.nonneg u,q.le_bound u⟩ ⟨q.nonneg v,q.le_bound v⟩ (q.monotone huv)) (by norm_num)
  nonneg := fun u => div_nonneg (quantileA_nonneg _ (q.nonneg u)) (by norm_num)
  le_bound := by
    intro u
    have h := (quantileA_bound _ (q.toQuantile_measurable hB.le) hB (ae_of_all _ q.le_bound)
      ⟨q.nonneg u,q.le_bound u⟩)
    calc
      _ ≤ (B/(1-B)^2)/2 := div_le_div_of_nonneg_right h (by norm_num)
      _ = _ := by rw [div_div,mul_comm]
520
def clippedQuantile (q : Time → Time) (hq : Monotone q) (B : ℝ) (hB0 : 0 ≤ B) : BoundedField B where
body · 4 lines
  toFun := fun u => min (q u:ℝ) B
  monotone := fun _ _ huv => min_le_min (hq huv) le_rfl
  nonneg := fun u => le_min (q u).2.1 hB0
  le_bound := fun _ => min_le_right _ _
526
def stationaryQuantileField (q : Time → Time) (hq : Monotone q) (B : ℝ) (hB0 : 0 ≤ B) (hB1 : B < 1) :
    BoundedField (B/(2*(1-B)^2)) := (clippedQuantile q hq B hB0).stationary hB1
529
def SphericalLinearFieldFormula : Prop :=
body · 17 lines
  (∀ (k : ℕ) (w : Fin (k+1) → ℝ) (hw : ∀ i, 0 < w i) (hw1 : ∑ i, w i=1),
    (∀ h : Fin (k+1) → ℝ, Monotone h → 0 ≤ h 0 →
      ∃ q : Fin (k+1) → Time, Monotone q ∧ (q (Fin.last k):ℝ) < 1 ∧
        IsLeast (finiteSphericalDualValues w h (fun i => (hw i).le) hw1)
          (finiteSphericalDualObjective w h (fun i => (hw i).le) hw1 q)) ∧
    (∀ K : Set (Fin (k+1) → ℝ), IsCompact K →
      (∀ h ∈ K, Monotone h ∧ 0 ≤ h 0) →
      TendstoUniformlyOn (fun n h => finiteSphericalFieldValue n k w h)
        (fun h => sInf (finiteSphericalDualValues w h (fun i => (hw i).le) hw1)) atTop K)) ∧
  (∀ (B : ℝ) (hB0 : 0 ≤ B) (hB1 : B < 1) (ε : ℝ), 0 < ε →
    ∀ᶠ n : ℕ in atTop, ∀ (q : Time → Time) (hq : Monotone q),
      (∀ᵐ u ∂timeLaw, (q u:ℝ) ≤ B) →
      entropy (quantileTrial q) < ∞ ∧
      (∀ᵐ u ∂timeLaw, 2*stationaryQuantileField q hq B hB0 hB1 u=quantileA q (q u)) ∧
      |boundedSphericalFieldValue (stationaryQuantileField q hq B hB0 hB1) n-
        ((entropy (quantileTrial q)).toReal-
          ∫ u, stationaryQuantileField q hq B hB0 hB1 u*(q u:ℝ) ∂timeLaw)| < ε)

Xet Storage Details

Size:
25.5 kB
·
Xet hash:
b56498143bff54f995a66220ba1a85ef52d05c67ef6997b40f39619cacb768f1

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