Estimation.OrthogonalMoments.UniformInference
Inference for a scalar cross-fitted estimator that is valid uniformly over a class of data laws which may change with the sample size.
Basic 9 core · 0 supporting This module fixes an arbitrary, possibly sample-size-indexed class of laws, an i.i.d.
Class-indexed scalar cross-fitting data
This module fixes an arbitrary, possibly sample-size-indexed class of laws, an i.i.d. experiment under each law, a fixed finite fold split, and scalar oracle and estimated scores. The estimator averages each observation exactly once. All probabilistic rate assumptions are stated in downstream modules.
A scalar cross-fitting problem consists of a positive number of folds, an index set of data laws with an i.i.d. sample under each law, a fixed-fold partition, a law-specific target value, a law-specific oracle score, a foldwise estimated score evaluated on held-out observations, and a class of admissible laws that may depend on sample size. The structure carries only this data; mean-zero, moment, and rate requirements on the scores are separate assumptions imposed downstream.
Definition (Lean source)
The oracle variance is the population second moment of the oracle score under the indexed law. It equals the variance of that score when the score has mean zero, as the downstream oracle conditions require.
Definition (Lean source)
The oracle normalized empirical score is the sum over the first n observations divided by √n.
The cross-fitted estimator adds the average held-out estimated score to the law-specific target. Each observation belongs to exactly one fold.
The cross-fitted score mean is the average of all held-out estimated scores, in the same weighting used by the estimator.
The empirical cross-fitted score variance is its second moment minus the square of its empirical mean.
Definition (Lean source)
The studentized statistic divides the root-sample-size estimator error by the square root of the feasible cross-fitted score variance.
A sequence of random quantities vanishes uniformly in probability over the sample-size-indexed class when the supremum of its tail probabilities vanishes at every positive threshold.
Uniform Kolmogorov convergence to the standard Gaussian means the largest absolute distribution-function error over the law class and all real thresholds tends to zero.
Definition (Lean source)
FoldMoments 3 core · 2 supporting On a training-measurable good event, each fold's estimated score has a deterministic L² approximation rate and a deterministic mean-drift rate (RateConditions). ★ foldCentered_good_secondMoment
Uniform foldwise score rates and centered fold moments
On a training-measurable good event, each fold's estimated score has a
deterministic L² approximation rate and a deterministic mean-drift rate
(RateConditions). Conditional independence of the evaluation fold then gives the
good-event second moment and zero mean of the foldwise centered process. The tail
bound and asymptotic linearity built on these moments live in FoldRates.
Uniform score rates hold when each fold's estimated-minus-oracle score is jointly and training-measurable, has L² norm at most r n and mean drift at most C * a n * b n on a training-measurable good event, and that event fails with probability at most δ n uniformly over the current law class. The rates r n, √n a n b n, and δ n vanish.
Definition (Lean source)
The foldwise centered empirical process is the held-out sum of the estimated-minus-oracle score after subtracting its training-conditional population mean, scaled by the square root of the full sample size.
Definition (Lean source)
Under the uniform score-rate conditions, the integral over the training-measurable good event of the squared foldwise centered score process is at most the square of its L² rate.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
foldCentered_good_sq_lintegral_letheorem — Under the uniform score-rate conditions, the integral over the training-measurable good event of the squared foldwise centered process is at most the squared L² score rate.hypothesesι :sharedType u_1Ω :sharedType u_2Z :sharedType u_3K :sharedℕr a b :ℕ → ℝC :ℝδ :ℕ → ℝ≥0∞R :RateConditions F r a b C δn :ℕp :ιk :Fin KProof (Lean source)
theorem foldCentered_good_sq_lintegral_le {r a b : ℕ → ℝ} {C : ℝ} {δ : ℕ → ℝ≥0∞} (R : RateConditions F r a b C δ) (n : ℕ) (p : ι) (k : Fin K) : (∫⁻ ω in R.good n p k, ofReal ((F.foldCentered n p k ω) ^ 2) ∂F.sampleLaw p) ≤ ofReal ((r n) ^ 2) := by classical letI : IsProbabilityMeasure (F.sampleLaw p) := (F.sample p).indep.isProbabilityMeasure letI : IsProbabilityMeasure (F.laws p) := by rw [← (F.sample p).law] exact Measure.isProbabilityMeasure_map ((F.sample p).meas 0).aemeasurable have hmA : (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance : MeasurableSpace Ω) ≤ (inferInstance : MeasurableSpace Ω) := by intro s hs rcases hs with ⟨t, ht, rfl⟩ exact (measurable_pi_iff.mpr fun i : (F.split p).trainComplement n k => (F.sample p).meas i) ht have hgood : MeasurableSet (R.good n p k) := hmA _ (R.good_train n p k) let g : Ω → Z → ℝ := fun ω z => if ω ∈ R.good n p k then F.score n p k ω z - F.oracle p z else 0 have hg_train : Measurable[(comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance).prod (inferInstance : MeasurableSpace Z)] (uncurry g) := by exact Measurable.ite (measurable_fst (R.good_train n p k)) (R.diff_train n p k) measurable_const have hg : Measurable (uncurry g) := by exact Measurable.ite (measurable_fst hgood) (R.diff_meas n p k) measurable_const have hmem : ∀ ω, MemLp (g ω) 2 (F.laws p) := by intro ω by_cases hω : ω ∈ R.good n p k · simpa [g, hω] using (R.diff_L2 n p k ω hω).1 · simp [g, hω] have hnorm : ∀ ω, (eLpNorm (g ω) 2 (F.laws p)).toReal ≤ r n := by intro ω by_cases hω : ω ∈ R.good n p k · simpa [g, hω] using (R.diff_L2 n p k ω hω).2 · simp [g, hω, R.r_nonneg n] have hL2 : (∫⁻ ω, ofReal ((eLpNorm (g ω) 2 (F.laws p)).toReal ^ 2) ∂F.sampleLaw p) ≤ ofReal ((r n) ^ 2) := by calc _ ≤ ∫⁻ ω, ofReal ((r n) ^ 2) ∂F.sampleLaw p := by apply lintegral_mono intro ω apply ENNReal.ofReal_le_ofReal have hnn : 0 ≤ (eLpNorm (g ω) 2 (F.laws p)).toReal := ENNReal.toReal_nonneg nlinarith [hnorm ω, hnn, R.r_nonneg n] _ = _ := by simp have hiid : (F.sampleLaw p).map (fun ω (i : (F.split p).fold n k) => (F.sample p).Z i ω) = Measure.pi (fun _ : (F.split p).fold n k => F.laws p) := by have hindep_s : iIndepFun (fun i : (F.split p).fold n k => (F.sample p).Z i) (F.sampleLaw p) := (F.sample p).indep.precomp val_injective have hmap := (ProbabilityTheory.iIndepFun_iff_map_fun_eq_pi_map (fun i : (F.split p).fold n k => ((F.sample p).meas i).aemeasurable)).mp hindep_s calc _ = Measure.pi (fun i : (F.split p).fold n k => (F.sampleLaw p).map ((F.sample p).Z i)) := hmap _ = Measure.pi (fun _ : (F.split p).fold n k => F.laws p) := by simp only [(F.sample p).map_eq] have hsq := iid_centered_sum_sq_lintegral_unscaled_le (s := (F.split p).fold n k) (W := (F.sample p).Z) (fun i _ => (F.sample p).meas i) (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance) hmA ((F.split p).folds_indep n k).symm hiid g hg_train hmem have hcard : ((F.split p).fold n k).card ≤ n := by have hs : (F.split p).fold n k ⊆ range n := by intro i hi rw [← (F.split p).cover n] exact Finset.mem_biUnion.mpr ⟨k, Finset.mem_univ _, hi⟩ simpa using Finset.card_le_card hs by_cases hn : n = 0 · subst n simp [foldCentered] have hnpos : 0 < n := Nat.pos_of_ne_zero hn have hpoint (ω : Ω) : ofReal (((sqrt (n : ℝ))⁻¹ * ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) ^ 2) = (n : ENNReal)⁻¹ * ofReal ((∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) ^ 2) := by let z : ℝ := ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p) have hnR : 0 < (n : ℝ) := Nat.cast_pos.mpr hnpos have heq : ((sqrt (n : ℝ))⁻¹ * z) ^ 2 = ((n : ℝ)⁻¹) * z ^ 2 := by rw [mul_pow, inv_pow, Real.sq_sqrt (le_of_lt hnR)] rw [show ((sqrt (n : ℝ))⁻¹ * ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) ^ 2 = ((n : ℝ)⁻¹) * (∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) ^ 2 by simpa [z] using heq] rw [ENNReal.ofReal_mul (inv_nonneg.mpr (le_of_lt hnR))] rw [ENNReal.ofReal_inv_of_pos hnR] norm_num have hscaled : (∫⁻ ω, ofReal (((sqrt (n : ℝ))⁻¹ * ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) ^ 2) ∂F.sampleLaw p) ≤ ofReal ((r n) ^ 2) := by calc _ = (n : ENNReal)⁻¹ * ∫⁻ ω, ofReal ((∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) ^ 2) ∂F.sampleLaw p := by simp_rw [hpoint] rw [lintegral_const_mul' _ _ (by simp [hn])] _ ≤ (n : ENNReal)⁻¹ * ((↑((F.split p).fold n k).card : ENNReal) * ∫⁻ ω, ofReal ((eLpNorm (g ω) 2 (F.laws p)).toReal ^ 2) ∂F.sampleLaw p) := by gcongr _ ≤ (n : ENNReal)⁻¹ * ((↑((F.split p).fold n k).card : ENNReal) * ofReal ((r n) ^ 2)) := by gcongr _ ≤ (n : ENNReal)⁻¹ * ((n : ENNReal) * ofReal ((r n) ^ 2)) := by gcongr _ = ofReal ((r n) ^ 2) := by rw [← mul_assoc, ENNReal.inv_mul_cancel (by simpa using hn) (by simp), one_mul] let Y : Ω → ℝ := fun ω => (sqrt (n : ℝ))⁻¹ * ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p) have hclip (ω : Ω) : Y ω = if ω ∈ R.good n p k then F.foldCentered n p k ω else 0 := by by_cases hω : ω ∈ R.good n p k · simp [Y, g, hω, foldCentered] · simp [Y, g, hω] have hset : (∫⁻ ω in R.good n p k, ofReal ((F.foldCentered n p k ω) ^ 2) ∂F.sampleLaw p) = ∫⁻ ω, ofReal ((Y ω) ^ 2) ∂F.sampleLaw p := by rw [← lintegral_indicator hgood] apply lintegral_congr intro ω by_cases hω : ω ∈ R.good n p k · simp [indicator, hω, hclip ω] · simp [indicator, hω, hclip ω] simpa only [hset] using hscaled -
foldCentered_good_mean_zerotheorem — On a training-measurable good event, the held-out centered score has zero integrated conditional mean under the law of the full sample.hypothesesι :sharedType u_1Ω :sharedType u_2Z :sharedType u_3K :sharedℕr a b :ℕ → ℝC :ℝδ :ℕ → ℝ≥0∞R :RateConditions F r a b C δn :ℕp :ιk :Fin Kconclusion∫ ω in R.good n p k, F.foldCentered n p k ω ∂F.sampleLaw p = 0Proof (Lean source)
theorem foldCentered_good_mean_zero {r a b : ℕ → ℝ} {C : ℝ} {δ : ℕ → ℝ≥0∞} (R : RateConditions F r a b C δ) (n : ℕ) (p : ι) (k : Fin K) : ∫ ω in R.good n p k, F.foldCentered n p k ω ∂F.sampleLaw p = 0 := by classical letI : IsProbabilityMeasure (F.sampleLaw p) := (F.sample p).indep.isProbabilityMeasure letI : IsProbabilityMeasure (F.laws p) := by rw [← (F.sample p).law] exact Measure.isProbabilityMeasure_map ((F.sample p).meas 0).aemeasurable have hmA : (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance : MeasurableSpace Ω) ≤ (inferInstance : MeasurableSpace Ω) := by intro s hs rcases hs with ⟨t, ht, rfl⟩ exact (measurable_pi_iff.mpr fun i : (F.split p).trainComplement n k => (F.sample p).meas i) ht have hgood : MeasurableSet (R.good n p k) := hmA _ (R.good_train n p k) have hdiffMean : Measurable (fun ω => ∫ z, F.score n p k ω z - F.oracle p z ∂F.laws p) := (R.diff_meas n p k).stronglyMeasurable.integral_prod_right.measurable have hfold : Measurable (F.foldCentered n p k) := by unfold foldCentered apply Measurable.const_mul apply Finset.measurable_sum intro i hi exact ((R.diff_meas n p k).comp (measurable_id.prodMk ((F.sample p).meas i))).sub hdiffMean have hsqInt : Integrable (fun ω => (F.foldCentered n p k ω) ^ 2) ((F.sampleLaw p).restrict (R.good n p k)) := by apply (lintegral_ofReal_ne_top_iff_integrable ((hfold.pow_const 2).aestronglyMeasurable) (Filter.Eventually.of_forall fun ω => sq_nonneg _)).mp exact ne_top_of_le_ne_top (by simp) (F.foldCentered_good_sq_lintegral_le R n p k) have hfoldLp : MemLp (F.foldCentered n p k) 2 ((F.sampleLaw p).restrict (R.good n p k)) := (memLp_two_iff_integrable_sq hfold.aestronglyMeasurable).mpr hsqInt have hfoldInt : IntegrableOn (F.foldCentered n p k) (R.good n p k) (F.sampleLaw p) := hfoldLp.integrable (by norm_num) let g : Ω → Z → ℝ := fun ω z => if ω ∈ R.good n p k then F.score n p k ω z - F.oracle p z else 0 have hg_train : Measurable[(comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance).prod (inferInstance : MeasurableSpace Z)] (uncurry g) := by exact Measurable.ite (measurable_fst (R.good_train n p k)) (R.diff_train n p k) measurable_const have hmem : ∀ ω, MemLp (g ω) 2 (F.laws p) := by intro ω by_cases hω : ω ∈ R.good n p k · simpa [g, hω] using (R.diff_L2 n p k ω hω).1 · simp [g, hω] let Y : Ω → ℝ := fun ω => (sqrt (n : ℝ))⁻¹ * ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p) have hclip (ω : Ω) : Y ω = if ω ∈ R.good n p k then F.foldCentered n p k ω else 0 := by by_cases hω : ω ∈ R.good n p k · simp [Y, g, hω, foldCentered] · simp [Y, g, hω] have hYint : Integrable Y (F.sampleLaw p) := by have h := hfoldInt.integrable_indicator hgood have hEq : Y = (R.good n p k).indicator (F.foldCentered n p k) := by funext ω rw [hclip] by_cases hω : ω ∈ R.good n p k · simp [indicator, hω] · simp [indicator, hω] rw [hEq] exact h let s : Finset ℕ := (F.split p).fold n k let νX : Measure ((i : s) → Z) := Measure.pi (fun _ : s => F.laws p) let J : Ω → Ω × ((i : s) → Z) := fun ω => (ω, fun i : s => (F.sample p).Z i ω) let H : Ω × ((i : s) → Z) → ℝ := fun q => (sqrt (n : ℝ))⁻¹ * ∑ i : s, (g q.1 (q.2 i) - ∫ z, g q.1 z ∂F.laws p) have hZmeas : Measurable (fun ω (i : s) => (F.sample p).Z i ω) := measurable_pi_iff.mpr fun i : s => (F.sample p).meas i have hJmeas : @Measurable Ω (Ω × ((i : s) → Z)) _ ((comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance).prod inferInstance) J := (measurable_id'' hmA).prodMk hZmeas have hiid : (F.sampleLaw p).map (fun ω (i : s) => (F.sample p).Z i ω) = νX := by have hindep_s : iIndepFun (fun i : s => (F.sample p).Z i) (F.sampleLaw p) := (F.sample p).indep.precomp val_injective have hmap := (ProbabilityTheory.iIndepFun_iff_map_fun_eq_pi_map (fun i : s => ((F.sample p).meas i).aemeasurable)).mp hindep_s calc _ = Measure.pi (fun i : s => (F.sampleLaw p).map ((F.sample p).Z i)) := hmap _ = νX := by simp [νX, (F.sample p).map_eq] have hJlaw : @Measure.map Ω (Ω × ((i : s) → Z)) _ ((comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance).prod inferInstance) J (F.sampleLaw p) = @Measure.prod Ω ((i : s) → Z) (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance) inferInstance ((F.sampleLaw p).trim hmA) νX := by have hraw := indep_trim_prod_map_eq (Ω := Ω) (β := ((i : s) → Z)) (μ := F.sampleLaw p) (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance) hmA hZmeas.aemeasurable ((F.split p).folds_indep n k).symm simpa [J, νX, hiid] using hraw have hc_train : @Measurable Ω ℝ (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance) inferInstance (fun ω => ∫ z, g ω z ∂F.laws p) := by letI : MeasurableSpace Ω := comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance exact hg_train.stronglyMeasurable.integral_prod_right.measurable have hHmeas : @Measurable (Ω × ((i : s) → Z)) ℝ ((comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance).prod inferInstance) inferInstance H := by dsimp [H] apply Measurable.const_mul apply Finset.measurable_sum intro i hi have hpair : @Measurable (Ω × ((i : s) → Z)) (Ω × Z) ((comap (fun ω (j : (F.split p).trainComplement n k) => (F.sample p).Z j ω) inferInstance).prod inferInstance) ((comap (fun ω (j : (F.split p).trainComplement n k) => (F.sample p).Z j ω) inferInstance).prod inferInstance) (fun q => (q.1, q.2 i)) := by exact measurable_fst.prodMk ((measurable_pi_apply i).comp measurable_snd) exact (hg_train.comp hpair).sub (hc_train.comp measurable_fst) have hcomp : H ∘ J = Y := by funext ω change (sqrt (n : ℝ))⁻¹ * ∑ i : s, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p) = (sqrt (n : ℝ))⁻¹ * ∑ i ∈ (F.split p).fold n k, (g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p) congr 1 simpa [s] using (Finset.sum_attach ((F.split p).fold n k) (fun i => g ω ((F.sample p).Z i ω) - ∫ z, g ω z ∂F.laws p)) letI : MeasurableSpace (Ω × ((i : s) → Z)) := (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance).prod inferInstance have hHint : Integrable H ((F.sampleLaw p).map J) := by apply (integrable_map_measure hHmeas.aestronglyMeasurable hJmeas.aemeasurable).mpr simpa only [hcomp] using hYint have hinner (ω : Ω) : (∫ v, H (ω, v) ∂νX) = 0 := by have hterm (i : s) : ∫ v : ((i : s) → Z), (g ω (v i) - ∫ z, g ω z ∂F.laws p) ∂νX = 0 := by have hgi : Integrable (g ω) (F.laws p) := (hmem ω).integrable (by norm_num) have hmp := measurePreserving_eval (fun _ : s => F.laws p) i have hcompInt : Integrable (fun v : ((i : s) → Z) => g ω (v i)) νX := (by have hmp' : MeasurePreserving (Function.eval i) νX (F.laws p) := by simpa [νX] using hmp exact (hmp'.integrable_comp hgi.aestronglyMeasurable).2 hgi) have hmap : (∫ v : ((i : s) → Z), g ω (v i) ∂νX) = ∫ z, g ω z ∂F.laws p := by have hgi_map : AEStronglyMeasurable (g ω) (νX.map (Function.eval i)) := by simpa [νX, hmp.map_eq] using hgi.aestronglyMeasurable have h := integral_map hmp.aemeasurable hgi_map rw [hmp.map_eq] at h simpa [νX] using h.symm rw [integral_sub hcompInt (integrable_const _), hmap] simp simp only [H] rw [integral_const_mul] rw [integral_finset_sum] · simp [hterm] · intro i hi have hgi : Integrable (g ω) (F.laws p) := (hmem ω).integrable (by norm_num) have hmp := measurePreserving_eval (fun _ : s => F.laws p) i have hcompInt : Integrable (fun v : ((i : s) → Z) => g ω (v i)) νX := by have hmp' : MeasurePreserving (Function.eval i) νX (F.laws p) := by simpa [νX] using hmp exact (hmp'.integrable_comp hgi.aestronglyMeasurable).2 hgi exact hcompInt.sub (integrable_const _) have hHint' : Integrable H (@Measure.prod Ω ((i : s) → Z) (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance) inferInstance ((F.sampleLaw p).trim hmA) νX) := by simpa only [hJlaw] using hHint have hfull : (∫ ω, Y ω ∂F.sampleLaw p) = 0 := by calc _ = ∫ q, H q ∂((F.sampleLaw p).map J) := by rw [← hcomp] exact (integral_map hJmeas.aemeasurable hHmeas.aestronglyMeasurable).symm _ = ∫ q, H q ∂ (@Measure.prod Ω ((i : s) → Z) (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance) inferInstance ((F.sampleLaw p).trim hmA) νX) := by rw [hJlaw] _ = ∫ ω, ∫ v, H (ω, v) ∂νX ∂((F.sampleLaw p).trim hmA) := by letI : MeasurableSpace Ω := comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance exact integral_prod H hHint' _ = 0 := by simp [hinner] rw [← integral_indicator hgood] have hEq : (R.good n p k).indicator (F.foldCentered n p k) = Y := by funext ω rw [hclip] by_cases hω : ω ∈ R.good n p k · simp [indicator, hω] · simp [indicator, hω] rw [hEq] exact hfull
OracleNormal 3 core · 1 supporting The oracle score has mean zero, a uniform positive variance floor, and a uniform third absolute moment bound. ★ standardizedOracle_uniformGaussian
Uniform Gaussian approximation for bounded oracle scores
The oracle score has mean zero, a uniform positive variance floor, and a uniform third absolute moment bound. A quantitative scalar Berry–Esseen bound gives a normal approximation uniformly over a changing class of laws. The bounded score assumption also supplies the fourth moment needed for variance estimation downstream.
Oracle regularity means that the mean-zero score is measurable and uniformly bounded, its variance stays above vmin > 0, and its third absolute moment stays below M3 over every current law class.
Definition (Lean source)
The standardized oracle sum divides the normalized empirical influence score by its law-specific population standard deviation.
For a cross-fitting family satisfying the oracle-score conditions — a bounded, mean-zero oracle score with a uniform variance floor and third-moment bound, the standardized oracle sum converges to the standard Gaussian in Kolmogorov distance uniformly over the possibly sample-size-dependent law class.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
oracle_berry_esseentheorem — A bounded third absolute moment and positive variance floor give a uniform scalar Berry–Esseen distribution-function bound for each positive sample size. The constant one is a conservative universal constant.hypothesesι :sharedType u_1Ω :sharedType u_2Z :sharedType u_3K :sharedℕB vmin M3 :ℝO :OracleConditions F B vmin M3n :ℕhn :0 < np :ιhp :p ∈ F.lawClass nx :ℝProof (Lean source)
theorem oracle_berry_esseen {B vmin M3 : ℝ} (O : OracleConditions F B vmin M3) (n : ℕ) (hn : 0 < n) (p : ι) (hp : p ∈ F.lawClass n) (x : ℝ) : |(F.sampleLaw p {ω | F.standardizedOracle n p ω ≤ x}).toReal - ((gaussianReal 0 1) (Iic x)).toReal| ≤ M3 / ((sqrt vmin) ^ 3 * sqrt (n : ℝ)) := by let μ : Measure ℝ := (F.laws p).map (F.oracle p) haveI : IsProbabilityMeasure (F.sampleLaw p) := (F.sample p).indep.isProbabilityMeasure haveI : IsProbabilityMeasure (F.laws p) := by rw [← (F.sample p).map_eq 0] exact Measure.isProbabilityMeasure_map ((F.sample p).meas 0).aemeasurable have hm : Measurable (F.oracle p) := O.measurable p haveI : IsProbabilityMeasure μ := Measure.isProbabilityMeasure_map hm.aemeasurable have hv : 0 < F.oracleVar p := lt_of_lt_of_le O.vmin_pos (O.variance_lower n p hp) have hmean_int : Integrable (F.oracle p) (F.laws p) := by apply Integrable.of_bound hm.aestronglyMeasurable B filter_upwards [] with z simpa using O.bounded n p hp z have hvar_int : Integrable (fun z => (F.oracle p z) ^ 2) (F.laws p) := by apply Integrable.of_bound (by fun_prop) (B ^ 2) filter_upwards [] with z have hz := O.bounded n p hp z simpa only [Real.norm_eq_abs, abs_pow, abs_sq] using (pow_le_pow_left₀ (abs_nonneg _) hz 2) have hthird_int : Integrable (fun z => |F.oracle p z| ^ 3) (F.laws p) := by apply Integrable.of_bound (by fun_prop) (B ^ 3) filter_upwards [] with z have hz := O.bounded n p hp z simpa only [Real.norm_eq_abs, abs_pow, abs_abs] using (pow_le_pow_left₀ (abs_nonneg _) hz 3) have hmean_map : Integrable (fun y : ℝ => y) μ := (integrable_map_measure (by fun_prop) hm.aemeasurable).2 (by exact hmean_int) have hvar_map : Integrable (fun y : ℝ => y ^ 2) μ := (integrable_map_measure (by fun_prop) hm.aemeasurable).2 (by exact hvar_int) have hthird_map : Integrable (fun y : ℝ => |y| ^ 3) μ := (integrable_map_measure (by fun_prop) hm.aemeasurable).2 (by exact hthird_int) have hmean : ∫ y : ℝ, y ∂μ = 0 := by rw [show (∫ y : ℝ, y ∂μ) = ∫ z, F.oracle p z ∂F.laws p from integral_map hm.aemeasurable (by fun_prop)] exact O.mean_zero n p hp have hvar : ∫ y : ℝ, y ^ 2 ∂μ = F.oracleVar p := by rw [show (∫ y : ℝ, y ^ 2 ∂μ) = ∫ z, (F.oracle p z) ^ 2 ∂F.laws p from integral_map hm.aemeasurable (by fun_prop)] rfl have hthird : ∫ y : ℝ, |y| ^ 3 ∂μ ≤ M3 := by rw [show (∫ y : ℝ, |y| ^ 3 ∂μ) = ∫ z, |F.oracle p z| ^ 3 ∂F.laws p from integral_map hm.aemeasurable (by fun_prop)] exact O.third_moment n p hp let T : Ω → Fin n → ℝ := fun ω i => F.oracle p ((F.sample p).Z i ω) have hTmeas : Measurable T := by apply measurable_pi_lambda intro i exact hm.comp ((F.sample p).meas i) have hTlaw : (F.sampleLaw p).map T = Measure.pi (fun _ : Fin n => μ) := by calc (F.sampleLaw p).map T = (Measure.pi (fun _ : Fin n => F.laws p)).map (fun v i => F.oracle p (v i)) := by rw [← iidSample_finN_pushforward (F.sample p) n] rw [Measure.map_map (measurable_finCoordinatewise n hm) (iidSample_finN_measurable (F.sample p) n)] rfl _ = Measure.pi (fun _ : Fin n => μ) := map_pi_finCoordinatewise n (F.laws p) hm have hE : MeasurableSet {v : Fin n → ℝ | (∑ i : Fin n, v i) / (sqrt (n : ℝ) * sqrt (F.oracleVar p)) ≤ x} := by exact measurableSet_le (by fun_prop) measurable_const have hevent : F.sampleLaw p {ω | F.standardizedOracle n p ω ≤ x} = (Measure.pi (fun _ : Fin n => μ)) {v : Fin n → ℝ | (∑ i : Fin n, v i) / (sqrt (n : ℝ) * sqrt (F.oracleVar p)) ≤ x} := by rw [← hTlaw, Measure.map_apply hTmeas hE] congr 1 ext ω simp only [Set.mem_ofPred_eq, Set.mem_preimage, T, standardizedOracle, oracleSum] rw [Fin.sum_univ_eq_sum_range (fun j : ℕ => F.oracle p ((F.sample p).Z j ω)) n] simp only [div_eq_mul_inv, mul_inv_rev] ring_nf rw [hevent] calc _ ≤ M3 / ((sqrt (F.oracleVar p)) ^ 3 * sqrt (n : ℝ)) := iid_real_berry_esseen μ (F.oracleVar p) M3 hv hmean_map hmean hvar_map hvar hthird_map hthird n hn x _ ≤ M3 / ((sqrt vmin) ^ 3 * sqrt (n : ℝ)) := by have hnreal : 0 < (n : ℝ) := by exact_mod_cast hn have hden : 0 < (sqrt vmin) ^ 3 * sqrt (n : ℝ) := by exact mul_pos (pow_pos (Real.sqrt_pos.2 O.vmin_pos) _) (Real.sqrt_pos.2 hnreal) apply div_le_div_of_nonneg_left O.M3_nonneg hden gcongr exact O.variance_lower n p hp
EmpiricalScoreMoments 1 core · 1 supporting Bounded oracle scores and foldwise L² approximation control the empirical oracle and feasible score second moments uniformly over the law class. ★ score_secondMoment_approx_uniformOP
Uniform empirical score moments
Bounded oracle scores and foldwise L² approximation control the empirical oracle and feasible score second moments uniformly over the law class.
For a cross-fitting family satisfying the foldwise rate conditions and the oracle-score conditions, the empirical second moment of the held-out estimated scores minus the empirical second moment of the oracle scores vanishes in probability uniformly over the law class.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
oracle_secondMoment_uniformOPtheorem — For uniformly bounded oracle scores, the empirical oracle second moment differs from its population value by a uniformly negligible amount.hypothesesι :sharedType u_1Ω :sharedType u_2Z :sharedType u_3K :sharedℕB vmin M3 :ℝO :OracleConditions F B vmin M3conclusionF.UniformOP (fun n p ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 - F.oracleVar p)Proof (Lean source)
theorem oracle_secondMoment_uniformOP {B vmin M3 : ℝ} (O : OracleConditions F B vmin M3) : F.UniformOP (fun n p ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 - F.oracleVar p) := by intro ε hε let b : ℝ := B ^ 2 + 1 have hb : 0 < b := by dsimp [b]; positivity have hrate : Tendsto (fun n : ℕ => ofReal (2 * exp (-2 * (n : ℝ) * ε ^ 2 / b ^ 2))) atTop (𝓝 0) := by have hc : 0 < 2 * ε ^ 2 / b ^ 2 := by positivity have ht : Tendsto (fun n : ℕ => (n : ℝ) * (2 * ε ^ 2 / b ^ 2)) atTop atTop := (tendsto_natCast_atTop_atTop (R := ℝ)).atTop_mul_const hc have he := (Real.tendsto_exp_neg_atTop_nhds_zero.comp ht).const_mul 2 have hr (n : ℕ) : -2 * (n : ℝ) * ε ^ 2 / b ^ 2 = -((n : ℝ) * (2 * ε ^ 2 / b ^ 2)) := by ring have hreal : Tendsto (fun n : ℕ => 2 * exp (-2 * (n : ℝ) * ε ^ 2 / b ^ 2)) atTop (𝓝 0) := by simpa only [Function.comp_apply, hr, mul_zero] using he simpa only [ENNReal.ofReal_zero] using ENNReal.tendsto_ofReal hreal rw [ENNReal.tendsto_nhds_zero] intro ζ hζ have he := (ENNReal.tendsto_nhds_zero.mp hrate) ζ hζ filter_upwards [eventually_gt_atTop (0 : ℕ), he] with n hn htail apply le_trans _ htail refine iSup_le fun p => iSup_le fun hp => ?_ haveI : IsProbabilityMeasure (F.sampleLaw p) := (F.sample p).indep.isProbabilityMeasure haveI : IsProbabilityMeasure (F.laws p) := by rw [← (F.sample p).law] exact Measure.isProbabilityMeasure_map ((F.sample p).meas 0).aemeasurable let f : Z → ℝ := fun z => (F.oracle p z) ^ 2 have hf : Measurable f := (O.measurable p).pow_const 2 have hbound : ∀ᵐ z ∂F.laws p, f z ∈ Icc 0 b := by filter_upwards with z have hz := O.bounded n p hp z constructor · exact sq_nonneg _ · dsimp [f, b] nlinarith [sq_nonneg (|F.oracle p z| - B), abs_nonneg (F.oracle p z), sq_abs (F.oracle p z)] have hh := hoeffding_abs_ge (F.sample p) hf (a := 0) (b := b) hb hbound n hn hε.le have heq : ∀ ω, (n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 - F.oracleVar p = (F.sample p).sampleMean f n ω - ∫ z, f z ∂F.laws p := by intro ω simp only [IIDSample.sampleMean, f, oracleVar] have htail : (F.sampleLaw p).real {ω | ε ≤ |(n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 - F.oracleVar p|} ≤ 2 * exp (-2 * (n : ℝ) * ε ^ 2 / b ^ 2) := by simpa only [heq, sub_zero, b] using hh have hfinite : F.sampleLaw p {ω | ε ≤ |(n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 - F.oracleVar p|} ≠ ⊤ := by exact ne_top_of_le_ne_top (by simp) (measure_mono (Set.subset_univ _)) exact (ENNReal.ofReal_toReal hfinite).symm ▸ ENNReal.ofReal_le_ofReal htail
FoldRates 1 core · 1 supporting Under the uniform score-rate conditions of FoldMoments, conditional independence of the evaluation fold converts the L² rate into a uniform centered-sum tail bound. ★ uniform_asymptotic_linearity
Uniform foldwise tail bounds and asymptotic linearity
Under the uniform score-rate conditions of FoldMoments, conditional independence of the
evaluation fold converts the L² rate into a uniform centered-sum tail bound. The drift rate then
yields class-indexed root-sample-size asymptotic linearity of the cross-fitted estimator.
If the foldwise rate conditions hold — on training-measurable good events whose failure probability vanishes uniformly over the law class, the L² score error and the root-sample-size-scaled mean drift are bounded by vanishing rates, then the root-sample-size-scaled cross-fitted estimator error equals the oracle empirical score sum up to a remainder that is uniformly negligible in probability.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
foldCentered_tailtheorem — A training-measurable fold with L² score error at most r n has a centered held-out tail of order r n plus its good-event failure probability, uniformly for each law in the class.hypothesesι :sharedType u_1Ω :sharedType u_2Z :sharedType u_3K :sharedℕr a b :ℕ → ℝC :ℝδ :ℕ → ℝ≥0∞R :RateConditions F r a b C δn :ℕp :ιhp :p ∈ F.lawClass nk :Fin Kε :ℝhε :0 < εconclusionF.sampleLaw p {ω | ε ≤ |F.foldCentered n p k ω|}≤ δ n + ofReal ((r n) ^ 2 / ε ^ 2)Proof (Lean source)
theorem foldCentered_tail {r a b : ℕ → ℝ} {C : ℝ} {δ : ℕ → ℝ≥0∞} (R : RateConditions F r a b C δ) (n : ℕ) (p : ι) (hp : p ∈ F.lawClass n) (k : Fin K) (ε : ℝ) (hε : 0 < ε) : F.sampleLaw p {ω | ε ≤ |F.foldCentered n p k ω|} ≤ δ n + ofReal ((r n) ^ 2 / ε ^ 2) := by letI : IsProbabilityMeasure (F.sampleLaw p) := (F.sample p).indep.isProbabilityMeasure letI : IsProbabilityMeasure (F.laws p) := by rw [← (F.sample p).law] exact Measure.isProbabilityMeasure_map ((F.sample p).meas 0).aemeasurable have hmA : (comap (fun ω (i : (F.split p).trainComplement n k) => (F.sample p).Z i ω) inferInstance : MeasurableSpace Ω) ≤ (inferInstance : MeasurableSpace Ω) := by intro s hs rcases hs with ⟨t, ht, rfl⟩ exact (measurable_pi_iff.mpr fun i : (F.split p).trainComplement n k => (F.sample p).meas i) ht have hgood : MeasurableSet (R.good n p k) := hmA _ (R.good_train n p k) have hdiffMean : Measurable (fun ω => ∫ z, F.score n p k ω z - F.oracle p z ∂F.laws p) := (R.diff_meas n p k).stronglyMeasurable.integral_prod_right.measurable have hfold : Measurable (F.foldCentered n p k) := by unfold foldCentered apply Measurable.const_mul apply Finset.measurable_sum intro i hi exact ((R.diff_meas n p k).comp (measurable_id.prodMk ((F.sample p).meas i))).sub hdiffMean have hεsq : 0 < ε ^ 2 := sq_pos_of_pos hε let e : ℝ≥0∞ := ofReal (ε ^ 2) have he0 : e ≠ 0 := ne_of_gt (ENNReal.ofReal_pos.mpr hεsq) have heTop : e ≠ ⊤ := ENNReal.ofReal_ne_top have hmarkov : (F.sampleLaw p) ({ω | ε ≤ |F.foldCentered n p k ω|} ∩ R.good n p k) ≤ ofReal ((r n) ^ 2 / ε ^ 2) := by have hsubset : {ω | ε ≤ |F.foldCentered n p k ω|} ∩ R.good n p k ⊆ {ω | e ≤ ofReal ((F.foldCentered n p k ω) ^ 2)} := by intro ω hω apply ENNReal.ofReal_le_ofReal have hs := pow_le_pow_left₀ (le_of_lt hε) hω.1 2 simpa only [sq_abs] using hs calc (F.sampleLaw p) ({ω | ε ≤ |F.foldCentered n p k ω|} ∩ R.good n p k) ≤ ((F.sampleLaw p).restrict (R.good n p k)) {ω | e ≤ ofReal ((F.foldCentered n p k ω) ^ 2)} := by rw [Measure.restrict_apply' hgood] exact measure_mono (fun ω hω => ⟨hsubset hω, hω.2⟩) _ ≤ (∫⁻ ω in R.good n p k, ofReal ((F.foldCentered n p k ω) ^ 2) ∂F.sampleLaw p) / e := meas_ge_le_lintegral_div ((hfold.pow_const 2).ennreal_ofReal.aemeasurable) he0 heTop _ ≤ ofReal ((r n) ^ 2) / e := by gcongr exact F.foldCentered_good_sq_lintegral_le R n p k _ = ofReal ((r n) ^ 2 / ε ^ 2) := by exact (ENNReal.ofReal_div_of_pos hεsq).symm have hcover : {ω | ε ≤ |F.foldCentered n p k ω|} ⊆ (R.good n p k)ᶜ ∪ ({ω | ε ≤ |F.foldCentered n p k ω|} ∩ R.good n p k) := by intro ω hω by_cases hg : ω ∈ R.good n p k · exact inr ⟨hω, hg⟩ · exact inl hg calc (F.sampleLaw p) {ω | ε ≤ |F.foldCentered n p k ω|} ≤ (F.sampleLaw p) ((R.good n p k)ᶜ ∪ ({ω | ε ≤ |F.foldCentered n p k ω|} ∩ R.good n p k)) := measure_mono hcover _ ≤ (F.sampleLaw p) (R.good n p k)ᶜ + (F.sampleLaw p) ({ω | ε ≤ |F.foldCentered n p k ω|} ∩ R.good n p k) := measure_union_le _ _ _ ≤ δ n + ofReal ((r n) ^ 2 / ε ^ 2) := add_le_add (R.fail n p hp k) hmarkov
FoldSquaredError 1 core · 0 supporting Training measurability and independence of the evaluation fold bound the observed squared score error by its population L² rate, on the fold's good event. ★ foldSquaredError_good_lintegral_le
Held-out squared score error
Training measurability and independence of the evaluation fold bound the observed squared score error by its population L² rate, on the fold's good event. This is the variance-estimation counterpart of the centered fold sum.
For a cross-fitting family satisfying the foldwise rate conditions, at a positive sample size n, a law p and an evaluation fold k, the expected held-out average of the squared estimated-minus-oracle scores, restricted to the training-measurable good event, is at most the squared L² score rate r(n)².
Formal statement
Proof (Lean source)
GaussianTransfer 1 core · 0 supporting This probability inequality transfers class-uniform Gaussian convergence from one statistic to another when their difference vanishes uniformly in probability. ★ uniformGaussian_of_uniformOP_difference
Uniform CDF transfer under a negligible perturbation
This probability inequality transfers class-uniform Gaussian convergence from one statistic to another when their difference vanishes uniformly in probability. It is independent of cross-fitting and variance estimation.
For a cross-fitting family, if a statistic X converges to the standard Gaussian in Kolmogorov distance uniformly over the law class and a second statistic Y differs from X by an amount vanishing in probability uniformly over the law class, then Y also converges to the standard Gaussian in Kolmogorov distance uniformly over the law class.
Formal statement
Proof (Lean source)
Inference 1 core · 0 supporting Uniform studentized Gaussian convergence gives two-sided Wald coverage uniformly over a possibly sample-size-indexed class of data laws. ★ wald_uniform_coverage
Uniform Wald coverage
Uniform studentized Gaussian convergence gives two-sided Wald coverage uniformly over a possibly sample-size-indexed class of data laws.
For a cross-fitting family satisfying the foldwise rate conditions and the oracle-score conditions, and a level α strictly between zero and one, the coverage probability of the two-sided Wald interval — the cross-fitted estimate plus or minus the standard-normal (1 − α/2)-quantile times the square root of the empirical score variance over √n — converges to 1 − α uniformly over the law class.
Formal statement
Proof (Lean source)
ScoreMean 1 core · 0 supporting The mean-zero oracle score and foldwise approximation rates imply that the empirical held-out score mean vanishes uniformly in probability. ★ scoreMean_uniformOP
Uniform cross-fitted score mean
The mean-zero oracle score and foldwise approximation rates imply that the empirical held-out score mean vanishes uniformly in probability.
For a cross-fitting family satisfying the foldwise rate conditions on score approximation and drift and the oracle-score conditions, including a mean-zero oracle score, the empirical mean of the held-out estimated scores vanishes in probability uniformly over the law class.
Formal statement
Proof (Lean source)
Studentization 1 core · 0 supporting Uniform asymptotic linearity, quantitative oracle normal approximation, and feasible variance consistency imply uniform studentized Gaussian convergence. ★ student_uniformGaussian
Uniform studentized Gaussian inference
Uniform asymptotic linearity, quantitative oracle normal approximation, and feasible variance consistency imply uniform studentized Gaussian convergence.
For a cross-fitting family satisfying the foldwise rate conditions and the oracle-score conditions, the studentized cross-fitted estimator converges to the standard Gaussian in Kolmogorov distance uniformly over the law class.
Formal statement
Proof (Lean source)
VarianceConsistency 1 core · 1 supporting Uniform second-moment approximation and a vanishing empirical mean imply consistency of the feasible cross-fitted variance and a positive variance floor. ★ scoreVar_small_uniformly_rare
Uniform feasible score variance
Uniform second-moment approximation and a vanishing empirical mean imply consistency of the feasible cross-fitted variance and a positive variance floor.
For a cross-fitting family satisfying the foldwise rate conditions and the oracle-score conditions with oracle variance floor vmin, the largest probability over the law class that the empirical score variance is at most vmin/2 tends to zero.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
scoreVar_uniform_consistenttheorem — The empirical cross-fitted score variance is uniformly consistent for the law-specific oracle influence-score variance.hypothesesι :sharedType u_1Ω :sharedType u_2Z :sharedType u_3K :sharedℕr a b :ℕ → ℝC :ℝδ :ℕ → ℝ≥0∞B vmin M3 :ℝR :RateConditions F r a b C δO :OracleConditions F B vmin M3conclusionF.UniformOP (fun n p ω => F.scoreVar n p ω - F.oracleVar p)Proof (Lean source)
theorem scoreVar_uniform_consistent {r a b : ℕ → ℝ} {C : ℝ} {δ : ℕ → ℝ≥0∞} {B vmin M3 : ℝ} (R : RateConditions F r a b C δ) (O : OracleConditions F B vmin M3) : F.UniformOP (fun n p ω => F.scoreVar n p ω - F.oracleVar p) := by have h₁ := F.score_secondMoment_approx_uniformOP R O have h₂ := F.oracle_secondMoment_uniformOP O have h₃ := F.scoreMean_uniformOP R O intro ε hε have hε3 : 0 < ε / 3 := by positivity have hsqrt : 0 < sqrt (ε / 3) := Real.sqrt_pos.2 hε3 have hsum : Tendsto (fun n => (⨆ (p : ι) (_hp : p ∈ F.lawClass n), F.sampleLaw p {ω | ε / 3 ≤ |(n : ℝ)⁻¹ * (∑ k : Fin K, ∑ i ∈ (F.split p).fold n k, (F.score n p k ω ((F.sample p).Z i ω)) ^ 2) - (n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2|}) + (⨆ (p : ι) (_hp : p ∈ F.lawClass n), F.sampleLaw p {ω | ε / 3 ≤ |(n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 - F.oracleVar p|}) + (⨆ (p : ι) (_hp : p ∈ F.lawClass n), F.sampleLaw p {ω | sqrt (ε / 3) ≤ |F.scoreMean n p ω|})) atTop (𝓝 0) := by simpa only [zero_add] using ((h₁ (ε / 3) hε3).add (h₂ (ε / 3) hε3)).add (h₃ _ hsqrt) rw [ENNReal.tendsto_nhds_zero] at hsum ⊢ intro ζ hζ filter_upwards [hsum ζ hζ] with n hn apply le_trans _ hn refine iSup_le fun p => iSup_le fun hp => ?_ let T : Ω → ℝ := fun ω => (n : ℝ)⁻¹ * ∑ k : Fin K, ∑ i ∈ (F.split p).fold n k, (F.score n p k ω ((F.sample p).Z i ω)) ^ 2 let U : Ω → ℝ := fun ω => (n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle p ((F.sample p).Z i ω)) ^ 2 have hpoint : {ω | ε ≤ |F.scoreVar n p ω - F.oracleVar p|} ⊆ {ω | ε / 3 ≤ |T ω - U ω|} ∪ {ω | ε / 3 ≤ |U ω - F.oracleVar p|} ∪ {ω | sqrt (ε / 3) ≤ |F.scoreMean n p ω|} := by intro ω hω by_contra hh simp only [Set.mem_union, Set.mem_ofPred_eq, not_or] at hh have hsq : (F.scoreMean n p ω) ^ 2 < ε / 3 := by have h : |F.scoreMean n p ω| < sqrt (ε / 3) := lt_of_not_ge hh.2 have hs := Real.sq_sqrt hε3.le rcases abs_lt.mp h with ⟨hl, hr⟩ simpa only [hs] using (sq_lt_sq' hl hr) have htri := abs_add_le (T ω - U ω) (U ω - F.oracleVar p) have htri2 : |T ω - F.oracleVar p| ≤ |T ω - U ω| + |U ω - F.oracleVar p| := by calc _ = |(T ω - U ω) + (U ω - F.oracleVar p)| := by congr 1; ring _ ≤ _ := htri have htri' : |(T ω - F.oracleVar p) - (F.scoreMean n p ω) ^ 2| ≤ |T ω - F.oracleVar p| + |(F.scoreMean n p ω) ^ 2| := by calc _ = |(T ω - F.oracleVar p) + (-(F.scoreMean n p ω) ^ 2)| := by congr 1 _ ≤ _ := by simpa only [abs_neg] using (abs_add_le (T ω - F.oracleVar p) (-(F.scoreMean n p ω) ^ 2)) have hid : F.scoreVar n p ω - F.oracleVar p = (T ω - F.oracleVar p) - (F.scoreMean n p ω) ^ 2 := by simp only [scoreVar, T]; ring change ε ≤ |F.scoreVar n p ω - F.oracleVar p| at hω rw [hid] at hω have habs : |(F.scoreMean n p ω) ^ 2| = (F.scoreMean n p ω) ^ 2 := abs_of_nonneg (sq_nonneg _) rw [habs] at htri' nlinarith [hh.1.1, hh.1.2] have hfirst : F.sampleLaw p {ω | ε / 3 ≤ |T ω - U ω|} ≤ ⨆ (q : ι) (_hq : q ∈ F.lawClass n), F.sampleLaw q {ω | ε / 3 ≤ |(n : ℝ)⁻¹ * (∑ k : Fin K, ∑ i ∈ (F.split q).fold n k, (F.score n q k ω ((F.sample q).Z i ω)) ^ 2) - (n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle q ((F.sample q).Z i ω)) ^ 2|} := le_iSup_of_le p (le_iSup_of_le hp le_rfl) have hsecond : F.sampleLaw p {ω | ε / 3 ≤ |U ω - F.oracleVar p|} ≤ ⨆ (q : ι) (_hq : q ∈ F.lawClass n), F.sampleLaw q {ω | ε / 3 ≤ |(n : ℝ)⁻¹ * ∑ i ∈ range n, (F.oracle q ((F.sample q).Z i ω)) ^ 2 - F.oracleVar q|} := le_iSup_of_le p (le_iSup_of_le hp le_rfl) have hthird : F.sampleLaw p {ω | sqrt (ε / 3) ≤ |F.scoreMean n p ω|} ≤ ⨆ (q : ι) (_hq : q ∈ F.lawClass n), F.sampleLaw q {ω | sqrt (ε / 3) ≤ |F.scoreMean n q ω|} := le_iSup_of_le p (le_iSup_of_le hp le_rfl) calc _ ≤ F.sampleLaw p ({ω | ε / 3 ≤ |T ω - U ω|} ∪ {ω | ε / 3 ≤ |U ω - F.oracleVar p|} ∪ {ω | sqrt (ε / 3) ≤ |F.scoreMean n p ω|}) := measure_mono hpoint _ ≤ F.sampleLaw p {ω | ε / 3 ≤ |T ω - U ω|} + F.sampleLaw p {ω | ε / 3 ≤ |U ω - F.oracleVar p|} + F.sampleLaw p {ω | sqrt (ε / 3) ≤ |F.scoreMean n p ω|} := by exact le_trans (measure_union_le _ _) (add_le_add_left (measure_union_le _ _) _) _ ≤ _ := add_le_add (add_le_add hfirst hsecond) hthird