roseking's picture
Add lean source and binary files (part 122)
b317718 verified
Raw History Blame Contribute Delete
6.09 kB
import OAI.Probability.GaussianRegression.Sphere
namespace OAI
/-!
Fubini bounds and rotational lower bounds for sequential estimation.
-/
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace Topology
open InnerProductSpace
open scoped Pointwise
noncomputable section
universe u
namespace NoiselessRegression
section FubiniAux
variable {X Y Z : Type*} [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
{μ : Measure X} {ν : Measure Y} [SFinite μ] [SFinite ν]
lemma ae_fiber_aemeasurable {f : X × Y → Z} (hf : AEMeasurable f (μ.prod ν)) :
∀ᵐ y ∂ν, AEMeasurable (fun x => f (x,y)) μ := by
have he := Measure.ae_ae_of_ae_prod hf.prod_swap.ae_eq_mk
filter_upwards [he] with y hy
have hm : Measurable (fun x => hf.prod_swap.mk _ (y,x)) :=
hf.prod_swap.measurable_mk.comp (measurable_const.prodMk measurable_id)
exact hm.aemeasurable.congr (Filter.EventuallyEq.symm hy)
lemma prod_null_set_bound {S : Set (X × Y)} (hS : NullMeasurableSet S (μ.prod ν))
{c : ℝ≥0∞} (h : ∀ᵐ y ∂ν, μ {x | (x,y) ∈ S} ≤ c) :
(μ.prod ν) S ≤ c * ν univ := by
have hm : AEMeasurable (S.indicator (fun _ => (1 : ℝ≥0∞))) (μ.prod ν) :=
aemeasurable_const.indicator₀ hS
rw [← one_mul ((μ.prod ν) S), ← lintegral_indicator_const₀ hS 1, lintegral_prod_symm _ hm]
apply (lintegral_mono_ae ?_).trans_eq (lintegral_const c)
filter_upwards [h, ae_fiber_aemeasurable hm] with y hy hmy
have hs : NullMeasurableSet {x | (x,y) ∈ S} μ := by
have heq : {x | (x,y) ∈ S} = {x | S.indicator (fun _ => (1 : ℝ≥0∞)) (x,y) = 1} := by
ext x
by_cases hx : (x,y) ∈ S <;> simp [hx]
rw [heq]
exact nullMeasurableSet_eq_fun hmy aemeasurable_const
change (∫⁻ x, ({x | (x,y) ∈ S}).indicator (fun _ => (1 : ℝ≥0∞)) x ∂μ) ≤ c
simpa [lintegral_indicator_const₀ hs] using hy
end FubiniAux
instance sampleLaw_probability (d T : ℕ) : IsProbabilityMeasure (sampleLaw d T) := by
unfold sampleLaw
infer_instance
instance uniformSphere_probability (d : ℕ) [NeZero d] : IsProbabilityMeasure (uniformSphere d) := by
change IsProbabilityMeasure (sphereLaw (E := Vector d))
infer_instance
namespace Learner
lemma run_congr_labels {d M T : ℕ} {Ω : Type u} (L : Learner d M T Ω)
(s t : UnitSphere d) (ω : Ω) (x : Samples d T)
(h : ∀ i, ⟪x i,s.val⟫ = ⟪x i,t.val⟫) (n : ℕ) :
L.run s ω x n = L.run t ω x n := by
induction n with
| zero => rfl
| succ n ih =>
simp only [run, ih]
split
· rfl
· split
· rw [h]
· rfl
lemma estimate_congr_labels {d M T : ℕ} {Ω : Type u} (L : Learner d M T Ω)
(s t : UnitSphere d) (ω : Ω) (x : Samples d T)
(h : ∀ i, ⟪x i,s.val⟫ = ⟪x i,t.val⟫) : L.estimate s ω x = L.estimate t ω x := by
simp only [estimate, terminal, run_congr_labels L s t ω x h]
lemma angularSuccess_nullMeasurable {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω]
(L : Learner d M T Ω) (ρ : Measure Ω) (ε : ℝ) (hL : L.Admissible ρ) :
NullMeasurableSet {z : UnitSphere d × (Ω × Samples d T) |
angularError z.1 (L.estimate z.1 z.2.1 z.2.2) ≤ ε}
((uniformSphere d).prod (ρ.prod (sampleLaw d T))) := by
apply nullMeasurableSet_le _ aemeasurable_const
exact Real.continuous_arccos.measurable.comp_aemeasurable
((measurable_subtype_coe.comp_aemeasurable hL.uniform_experiment).inner
(measurable_subtype_coe.comp measurable_fst).aemeasurable)
lemma linear_success_bound {d M T : ℕ} {Ω : Type u} [MeasurableSpace Ω]
(L : Learner d M T Ω) (ρ : Measure Ω) [IsProbabilityMeasure ρ]
(hd : 0 < d) (hT : 4*T ≤ d) {ε : ℝ} (hε : ε ≤ 1/10) (hL : L.Admissible ρ) :
L.uniformSuccess ρ ε ≤ ENNReal.ofReal (21/32 : ℝ) := by
classical
let : NeZero d := ⟨hd.ne'⟩
have hmeas := ae_fiber_aemeasurable hL.uniform_experiment
unfold uniformSuccess
refine (prod_null_set_bound (L.angularSuccess_nullMeasurable ρ ε hL)
(c := ENNReal.ofReal (21/32 : ℝ)) ?_).trans_eq (by simp)
filter_upwards [hmeas] with z hz
let U : Submodule ℝ (Vector d) := Submodule.span ℝ (Set.range z.2)
have hdim : Module.finrank ℝ U ≤ T := by
have h := finrank_span_le_card (R := ℝ) (Set.range z.2)
apply h.trans
rw [Set.toFinset_range]
exact (Finset.card_image_le).trans_eq (by simp)
have hU : 4 * Module.finrank ℝ U ≤ Module.finrank ℝ (Vector d) := by
simpa only [Vector, finrank_euclideanSpace_fin] using (Nat.mul_le_mul_left 4 hdim).trans hT
change sphereLaw {s : UnitSphere d | angularError s (L.estimate s z.1 z.2) ≤ ε} ≤ _
apply sphere_reflection_success_bound U hU
· exact nullMeasurableSet_le
(Real.continuous_arccos.measurable.comp_aemeasurable
((measurable_subtype_coe.comp_aemeasurable hz).inner measurable_subtype_coe.aemeasurable))
aemeasurable_const
· intro s hs ht
let t := sphereIsometry U.reflection s
have he : L.estimate s z.1 z.2 = L.estimate t z.1 z.2 := by
apply L.estimate_congr_labels
intro i
have hi : z.2 i ∈ U := Submodule.subset_span (Set.mem_range_self i)
have he := U.reflection.inner_map_map (z.2 i) s.val
rw [(Submodule.reflection_eq_self_iff (z.2 i)).2 hi] at he
exact he.symm
have hs' : dist s.val (L.estimate s z.1 z.2).val ≤ ε := by
apply (chord_le_arccos s (L.estimate s z.1 z.2)).trans
simpa only [Set.mem_ofPred_eq, angularError, real_inner_comm] using hs
have ht' : dist t.val (L.estimate t z.1 z.2).val ≤ ε := by
apply (chord_le_arccos t (L.estimate t z.1 z.2)).trans
simpa only [Set.mem_ofPred_eq, angularError, real_inner_comm] using ht
calc
_ = dist s.val t.val := rfl
_ ≤ dist s.val (L.estimate s z.1 z.2).val + dist (L.estimate s z.1 z.2).val t.val := dist_triangle _ _ _
_ ≤ ε + ε := by rw [he, dist_comm (L.estimate t z.1 z.2).val t.val] at *; exact add_le_add hs' ht'
_ ≤ 1/5 := by linarith
end Learner
end NoiselessRegression
end
end OAI