cfahlgren1's picture
download
raw
7.31 kB
import Mathlib
import OAI.Probability.Subsphere.Regression.Precision
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace
noncomputable section
universe u
namespace SubsphereRegression
lemma precision_from_stream_bound_explicit_aux {d M T a q : ℕ} {ε A : ℝ}
(hd : 32 ≤ d) (hT : d ≤ 4*T) (hq : 0 < q) (hdq : d ≤ 8*q)
(ha : d ≤ 4*a) (hM : (M : ℝ) ≤ A * (d : ℝ)^2) (hA : 0 < A)
(hε : 0 < ε) (hε1 : ε ≤ 1)
(hbound : (2/3 : ℝ) ≤ ((T : ℝ)+1) * ((3 : ℝ)*4^d * ε^a) *
((32768 : ℝ)^d * ((2 : ℝ)^M)^(1/(q : ℝ)))^(T/q+1)) :
(1 / (4*(256+128*A))) * (d : ℝ) * Real.log (1/ε) ≤ (T : ℝ) := by
have hd0 : (0 : ℝ) < d := by exact_mod_cast (by omega : 0 < d)
have hq0 : (0 : ℝ) < q := by exact_mod_cast hq
have hT0 : (0 : ℝ) ≤ T := Nat.cast_nonneg T
have hdp : (d : ℝ) ≤ 4*T := by exact_mod_cast hT
have hdqp : (d : ℝ) ≤ 8*q := by exact_mod_cast hdq
have hap : (d : ℝ) ≤ 4*a := by exact_mod_cast ha
have hB : ((T/q+1 : ℕ) : ℝ) * d ≤ 12*T := by
have hbd : (T/q+1)*d ≤ 12*T := by
have hmul := Nat.div_mul_le_self T q
calc
(T/q+1)*d = (T/q)*d+d := by ring
_ ≤ (T/q)*(8*q)+d := Nat.add_le_add_right (Nat.mul_le_mul_left _ hdq) _
_ = 8*((T/q)*q)+d := by ring
_ ≤ 8*T+d := Nat.add_le_add_right (Nat.mul_le_mul_left 8 hmul) _
_ ≤ 12*T := by omega
exact_mod_cast hbd
have hMq : (M : ℝ) / q ≤ 8*A*d := by
apply (div_le_iff₀ hq0).2
calc
(M : ℝ) ≤ A*d^2 := hM
_ ≤ A*d*(8*q) := by nlinarith [mul_le_mul_of_nonneg_left hdqp (by positivity : 0 ≤ A*d)]
_ = 8*A*d*q := by ring
have hlog := Real.log_le_log (by norm_num : (0 : ℝ) < 2/3) hbound
rw [Real.log_mul (by positivity) (by positivity),
Real.log_mul (by positivity) (by positivity),
Real.log_mul (by positivity) (by positivity),
Real.log_mul (by positivity) (by positivity),
Real.log_pow, Real.log_pow, Real.log_pow,
Real.log_mul (by positivity) (by positivity), Real.log_pow,
Real.log_rpow (by positivity), Real.log_pow] at hlog
have hlogε : Real.log (1/ε) = -Real.log ε := by simp
have hlogε0 : 0 ≤ Real.log (1/ε) := Real.log_nonneg ((le_div_iff₀ hε).2 (by simpa using hε1))
have heq : (1/(q : ℝ)) * ((M : ℝ)*Real.log 2) = ((M : ℝ)/q)*Real.log 2 := by ring
rw [heq] at hlog
have hlT : Real.log ((T : ℝ)+1) ≤ T := by
simpa using Real.log_le_sub_one_of_pos (by positivity : (0 : ℝ) < T+1)
have hl3 : Real.log (3 : ℝ) ≤ 3 := Real.log_le_self (by norm_num)
have hl4 : Real.log (4 : ℝ) ≤ 4 := Real.log_le_self (by norm_num)
have hl32 : Real.log (32768 : ℝ) ≤ 15 := by
have hpow : (32768 : ℝ) = 2 ^ (15 : ℕ) := by norm_num
rw [hpow, Real.log_pow]
have h2 := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)
norm_num at h2 ⊢
linarith
have hl2 : Real.log (2 : ℝ) ≤ 1 := by
convert Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) using 1; norm_num
have hl23 : -(1 : ℝ) ≤ Real.log (2/3 : ℝ) := by
have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2/3)
norm_num at h
linarith
have hinside : (d : ℝ)*Real.log 32768 + ((M : ℝ)/q)*Real.log 2 ≤
(15+8*A)*d := by
have hm0 : (0 : ℝ) ≤ (M : ℝ)/q := by positivity
have h1 := mul_le_mul_of_nonneg_left hl32 hd0.le
have h2 := mul_le_mul_of_nonneg_left hl2 hm0
nlinarith
have hfull : ((T/q+1 : ℕ) : ℝ) *
((d : ℝ)*Real.log 32768 + ((M : ℝ)/q)*Real.log 2) ≤
12*T*(15+8*A) := by
calc
_ ≤ ((T/q+1 : ℕ) : ℝ) * ((15+8*A)*d) :=
mul_le_mul_of_nonneg_left hinside (Nat.cast_nonneg _)
_ = (15+8*A)*(((T/q+1 : ℕ) : ℝ)*d) := by ring
_ ≤ (15+8*A)*(12*T) := mul_le_mul_of_nonneg_left hB (by positivity)
_ = _ := by ring
have hd4 : (4 : ℝ) ≤ d := by exact_mod_cast (by omega : 4 ≤ d)
have hlogbound : (a : ℝ)*Real.log (1/ε) ≤ (256+128*A)*T := by
have h4 := mul_le_mul_of_nonneg_left hl4 hd0.le
rw [hlogε]
nlinarith [mul_nonneg hA.le hT0]
have hmain : (d : ℝ)*Real.log (1/ε) ≤ 4*(256+128*A)*T := by
have ham := mul_le_mul_of_nonneg_right hap hlogε0
linarith
have hden : (0 : ℝ) < 4*(256+128*A) := by positivity
calc
_ = ((d : ℝ)*Real.log (1/ε))/(4*(256+128*A)) := by ring
_ ≤ T := (div_le_iff₀ hden).2 (by nlinarith [hmain])
lemma desired_coefficient_le : (2 : ℝ)⁻¹ ^ 16 / Real.log 2 ≤ 1 / (4 * (256 + 128)) := by
have hlog : (1 / 2 : ℝ) ≤ Real.log 2 := by
have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2)
norm_num at h
exact h
have hpos : 0 < Real.log (2 : ℝ) := Real.log_pos (by norm_num)
apply (div_le_iff₀ hpos).2
norm_num
nlinarith
theorem explicit_precision_old_model :
∀ 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 : Learner 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 : ℝ) := by
intro M hM
obtain ⟨d₂, hd₂⟩ := eventually_atTop.1 hM.eventuallyLE
refine ⟨max 32 d₂, ?_⟩
intro d hd T ε hε hε10 Ω _ ρ hρ L hL hs
let : IsProbabilityMeasure ρ := hρ
have hd32 : 32 ≤ d := by omega
have hmem : (M d : ℝ) ≤ 1 * (d : ℝ)^2 := by
have hm := hd₂ d (by omega)
simpa only [Real.norm_eq_abs, abs_of_nonneg (Nat.cast_nonneg (M d) : (0 : ℝ) ≤ M d),
abs_of_nonneg (sq_nonneg (d : ℝ)), one_mul] using hm
have hs' : (2 / 3 : ℝ≥0∞) ≤ L.uniformSuccess ρ ε := by
rcases hs with hs | hs
· exact hs
· exact L.uniformSuccess_of_pointwise ρ hL (by omega) ε hs
have hT : d ≤ 4*T := by
by_contra h
have hb := hs'.trans (L.linear_success_bound ρ (by omega) (by omega) hε10 hL)
have hr := ENNReal.toReal_mono ENNReal.ofReal_ne_top hb
norm_num [ENNReal.toReal_div] at hr
let q := (d-1)/4
let a := 2*q
have hq : 2 ≤ q := by dsimp [q]; omega
have hqa : 2*q ≤ a := le_rfl
have ha : 2*a ≤ d-1 := by dsimp [a, q]; omega
have hdq : d ≤ 8*q := by dsimp [q]; omega
have hda : d ≤ 4*a := by dsimp [a]; omega
have hp := precision_from_stream_bound_explicit_aux hd32 hT (by omega) hdq hda hmem
(by norm_num : (0 : ℝ) < 1) hε (by linarith : ε ≤ 1)
(L.streaming_success_bound_real ρ hL (by omega) hε ha hq hqa hs')
have hlogε : 0 ≤ Real.log (1 / ε) := Real.log_nonneg
((le_div_iff₀ hε).2 (by linarith))
calc
_ = ((2 : ℝ)⁻¹ ^ 16 / Real.log 2) * ((d : ℝ) * Real.log (1 / ε)) := by
rw [Real.logb]
ring
_ ≤ (1 / (4 * (256 + 128))) * ((d : ℝ) * Real.log (1 / ε)) :=
mul_le_mul_of_nonneg_right desired_coefficient_le (mul_nonneg (Nat.cast_nonneg _) hlogε)
_ ≤ T := by simpa only [mul_one, mul_assoc] using hp
end SubsphereRegression
end
end
end OAI

Xet Storage Details

Size:
7.31 kB
·
Xet hash:
f33bed4e245b909692297aa297db6cab314932f84114252a940fac662ceb0b96

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