introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
5.93 kB
import OAI.Probability.GaussianRegression.Success
namespace OAI
/-!
Real-valued success bounds and accuracy-uniform precision tradeoffs.
-/
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace Topology
open InnerProductSpace
open scoped Pointwise
noncomputable section
universe u
namespace NoiselessRegression
namespace Learner
lemma streaming_success_bound_real {d M T : β„•} {Ξ© : Type u} [MeasurableSpace Ξ©]
(L : Learner d M T Ω) (ρ : Measure Ω) [IsProbabilityMeasure ρ]
(hL : L.Admissible ρ) (hd : 3 ≀ d) {Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅)
{a q : β„•} (ha : 2*a ≀ d-1) (hq : 2 ≀ q) (hqa : 2*q ≀ a)
(hs : (2/3 : ℝβ‰₯0∞) ≀ L.uniformSuccess ρ Ξ΅) :
(2/3 : ℝ) ≀ ((T : ℝ)+1) * ((3 : ℝ)*4^d * Ξ΅^a) *
((32768 : ℝ)^d * ((2 : ℝ)^M)^(1/(q : ℝ)))^(T/q+1) := by
have hb := hs.trans (L.streaming_success_bound ρ hL hd hΡ ha hq hqa)
have ht : (T+1 : ℝβ‰₯0∞) *
(ENNReal.ofReal ((3 : ℝ)*4^d) * ENNReal.ofReal (Ξ΅^a)) *
streamFactor (E := Vector d) (J := State M) q ^ (T/q+1) β‰  ∞ := by
apply ENNReal.mul_ne_top
Β· apply ENNReal.mul_ne_top (by simp)
exact ENNReal.mul_ne_top ENNReal.ofReal_ne_top ENNReal.ofReal_ne_top
Β· exact ENNReal.pow_ne_top (streamFactor_ne_top q)
have hr := ENNReal.toReal_mono ht hb
simpa [ENNReal.toReal_div, ENNReal.toReal_ofNat, ENNReal.toReal_mul,
ENNReal.toReal_add, ENNReal.toReal_natCast, ENNReal.toReal_one,
ENNReal.toReal_ofReal (by positivity : (0 : ℝ) ≀ 3*4^d),
ENNReal.toReal_ofReal (by positivity : 0 ≀ Ξ΅^a), streamFactor,
ENNReal.toReal_pow, ← ENNReal.toReal_rpow, finrank_euclideanSpace_fin,
Fintype.card_fin, State, Nat.cast_pow, Nat.cast_ofNat, Vector] using hr
end Learner
lemma precision_from_stream_bound {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*(400000+100*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 : ℝ) ≀ 32768 := Real.log_le_self (by norm_num)
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 ≀
(32768+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*(32768+8*A) := by
calc
_ ≀ ((T/q+1 : β„•) : ℝ) * ((32768+8*A)*d) :=
mul_le_mul_of_nonneg_left hinside (Nat.cast_nonneg _)
_ = (32768+8*A)*(((T/q+1 : β„•) : ℝ)*d) := by ring
_ ≀ (32768+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/Ξ΅) ≀ (400000+100*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*(400000+100*A)*T := by
have ham := mul_le_mul_of_nonneg_right hap hlogΞ΅0
linarith
have hden : (0 : ℝ) < 4*(400000+100*A) := by positivity
calc
_ = ((d : ℝ)*Real.log (1/Ξ΅))/(4*(400000+100*A)) := by ring
_ ≀ T := (div_le_iffβ‚€ hden).2 (by nlinarith [hmain])
end NoiselessRegression
end
end OAI