Stat.UStatistic.LocalizedVariance
A variance bound for U-statistics whose kernel is concentrated on a small set, as with kernel smoothing.
Basic 8 core · 1 supporting This module fixes the finite product law, unordered pair set, statistic, and the two localization masses used in a variance bound.
Localized unordered order-two U-statistics
This module fixes the finite product law, unordered pair set, statistic, and the two localization masses used in a variance bound. The row mass squares the conditional weight before integrating; the pair mass integrates the weight once over each variable.
A kernel, localization weight, and nonnegative envelope scale form a localized symmetric kernel when both functions are measurable and symmetric, the weight lies between zero and one, and the kernel is bounded by the scaled weight.
Definition (Lean source)
A probability law and sample size determine the product law of independent observations with that common marginal distribution.
A sample size determines its unordered distinct index pairs, represented by the unique orientation whose first index is smaller.
A sample size, two-observation kernel, and realized sample determine the unordered order-two U-statistic, the average kernel value over distinct unordered pairs of observations (each pair evaluated with the lower-indexed observation first). With fewer than two observations there are no pairs and the value is zero.
Definition (Lean source)
A probability law and localization weight determine the pair mass, the weight's expectation under two independent draws.
Definition (Lean source)
A probability law and localization weight determine the squared row mass, the expectation of the square of its conditional one-draw mass.
Definition (Lean source)
A two-observation kernel, index pair, and sample realization determine the pair's kernel value.
1 supporting declaration (lemmas, instances)
Bounds 1 core · 9 supporting This module bounds the mean, pair variance, and overlapping pair covariance using the two distinct localization scales. ★ covariance_shared_pairs_le_rowMassSq
Localized covariance bounds
This module bounds the mean, pair variance, and overlapping pair covariance using the two distinct localization scales. Symmetry handles every orientation of a shared index.
9 supporting declarations (lemmas, instances)
-
pairValue_memLp_twotheorem — A probability law and localization certificate and sample pair give a pair kernel value with finite second moment under the independent product law.hypothesesX :sharedType u_1H :sharedX → X → ℝW :sharedX → X → ℝM :sharedℝn :ℕProof (Lean source)
theorem pairValue_memLp_two {n : ℕ} (p : Fin n × Fin n) : MemLp (pairValue H p) 2 (iidLaw P n) := by have : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance have hm : Measurable (pairValue H p) := by change Measurable (fun ω : Fin n → X => H (ω p.1) (ω p.2)) have hpair : Measurable (fun ω : Fin n → X => (ω p.1, ω p.2)) := by fun_prop exact h.measurable_kernel.comp hpair apply MemLp.of_bound hm.aestronglyMeasurable M filter_upwards [] with ω rw [Real.norm_eq_abs] exact (h.envelope (ω p.1) (ω p.2)).trans (mul_le_of_le_one_right h.envelope_nonneg (h.weight_le_one _ _)) -
kernel_mean_sq_le_rowMassSqtheorem — A probability law and localized-kernel certificate give a population kernel mean whose square is controlled by the squared row mass.hypothesesX :sharedType u_1H :sharedX → X → ℝW :sharedX → X → ℝM :sharedℝconclusion(∫ x, ∫ y, H x y ∂P ∂P) ^ 2 ≤ M ^ 2 * rowMassSq P WProof (Lean source)
theorem kernel_mean_sq_le_rowMassSq : (∫ x, ∫ y, H x y ∂P ∂P) ^ 2 ≤ M ^ 2 * rowMassSq P W := by have hH (x : X) : Integrable (H x) P := Integrable.of_bound (h.measurable_kernel.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable M (Filter.Eventually.of_forall (fun y => by rw [Real.norm_eq_abs] exact (h.envelope x y).trans (mul_le_of_le_one_right h.envelope_nonneg (h.weight_le_one x y)))) have hW (x : X) : Integrable (W x) P := Integrable.of_bound (h.measurable_weight.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable 1 (Filter.Eventually.of_forall (fun y => by rw [Real.norm_eq_abs, abs_of_nonneg (h.weight_nonneg x y)] exact h.weight_le_one x y)) have hrow (x : X) : |∫ y, H x y ∂P| ≤ M * ∫ y, W x y ∂P := by calc _ ≤ ∫ y, |H x y| ∂P := abs_integral_le_integral_abs _ ≤ ∫ y, M * W x y ∂P := integral_mono (hH x).abs ((hW x).const_mul M) (h.envelope x) _ = _ := by rw [integral_const_mul] have hHprod : Integrable (fun z : X × X => H z.1 z.2) (P.prod P) := Integrable.of_bound h.measurable_kernel.aestronglyMeasurable M (Filter.Eventually.of_forall (fun z => by rw [Real.norm_eq_abs] exact (h.envelope z.1 z.2).trans (mul_le_of_le_one_right h.envelope_nonneg (h.weight_le_one _ _)))) have hWprod : Integrable (fun z : X × X => W z.1 z.2) (P.prod P) := Integrable.of_bound h.measurable_weight.aestronglyMeasurable 1 (Filter.Eventually.of_forall (fun z => by rw [Real.norm_eq_abs, abs_of_nonneg (h.weight_nonneg _ _)] exact h.weight_le_one _ _)) have hHout : Integrable (fun x => ∫ y, H x y ∂P) P := hHprod.integral_prod_left have hWout : Integrable (fun x => ∫ y, W x y ∂P) P := hWprod.integral_prod_left have hWmeas : Measurable (fun x => ∫ y, W x y ∂P) := (h.measurable_weight.stronglyMeasurable.integral_prod_right' (ν := P)).measurable have hWbound (x : X) : |∫ y, W x y ∂P| ≤ 1 := by calc _ ≤ ∫ y, |W x y| ∂P := abs_integral_le_integral_abs _ = ∫ y, W x y ∂P := by congr 1; funext y; rw [abs_of_nonneg (h.weight_nonneg x y)] _ ≤ 1 := by simpa using integral_mono (hW x) (integrable_const (1 : ℝ)) (h.weight_le_one x) have hWsq : Integrable (fun x => (∫ y, W x y ∂P) ^ 2) P := Integrable.of_bound (hWmeas.pow_const 2).aestronglyMeasurable 1 (Filter.Eventually.of_forall (fun x => by rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] nlinarith [mul_nonneg (sub_nonneg.mpr (hWbound x)) (add_nonneg (abs_nonneg (∫ y, W x y ∂P)) (by norm_num : (0 : ℝ) ≤ 1)), sq_abs (∫ y, W x y ∂P)])) have hglobal : |∫ x, ∫ y, H x y ∂P ∂P| ≤ M * ∫ x, ∫ y, W x y ∂P ∂P := by calc _ ≤ ∫ x, |∫ y, H x y ∂P| ∂P := abs_integral_le_integral_abs _ ≤ ∫ x, M * ∫ y, W x y ∂P ∂P := integral_mono hHout.abs (hWout.const_mul M) hrow _ = _ := by rw [integral_const_mul] have hjs : (∫ x, ∫ y, W x y ∂P ∂P) ^ 2 ≤ rowMassSq P W := by have hvar := variance_nonneg (fun x => ∫ y, W x y ∂P) P rw [variance_eq_sub ((memLp_two_iff_integrable_sq hWmeas.aestronglyMeasurable).2 hWsq)] at hvar simp only [Pi.pow_apply] at hvar unfold rowMassSq linarith have hsq : (∫ x, ∫ y, H x y ∂P ∂P) ^ 2 ≤ M ^ 2 * (∫ x, ∫ y, W x y ∂P ∂P) ^ 2 := by have hw : 0 ≤ ∫ x, ∫ y, W x y ∂P ∂P := integral_nonneg (fun x => integral_nonneg (h.weight_nonneg x)) have ha := (sq_le_sq₀ (abs_nonneg (∫ x, ∫ y, H x y ∂P ∂P)) (mul_nonneg h.envelope_nonneg hw)).2 hglobal nlinarith [ha, sq_abs (∫ x, ∫ y, H x y ∂P ∂P)] nlinarith [mul_le_mul_of_nonneg_left hjs (sq_nonneg M)] -
pairValue_second_moment_le_pairMasstheorem — A probability law and localized-kernel certificate and unordered sample pair give a pair-value second moment bounded by the pair mass.hypothesesProof (Lean source)
theorem pairValue_second_moment_le_pairMass {n : ℕ} {p : Fin n × Fin n} (hp : p ∈ pairIndices n) : (∫ ω, (pairValue H p ω) ^ 2 ∂iidLaw P n) ≤ M ^ 2 * pairMass P W := by have hij : p.1 ≠ p.2 := ne_of_lt (Finset.mem_filter.mp hp).2 have hsq (x y : X) : H x y ^ 2 ≤ M ^ 2 * W x y := by have hw0 := h.weight_nonneg x y have hw1 := h.weight_le_one x y have he := h.envelope x y have hm := h.envelope_nonneg have ha : H x y ^ 2 ≤ (M * W x y) ^ 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr he) (add_nonneg (abs_nonneg (H x y)) (mul_nonneg hm hw0)), sq_abs (H x y)] have hb : (W x y) ^ 2 ≤ W x y := by nlinarith [mul_nonneg hw0 (sub_nonneg.mpr hw1)] nlinarith [mul_le_mul_of_nonneg_left hb (sq_nonneg M)] have hmeas : Measurable (fun z : X × X => H z.1 z.2 ^ 2) := h.measurable_kernel.pow_const 2 have hbound (x y : X) : |H x y ^ 2| ≤ M ^ 2 := by rw [abs_of_nonneg (sq_nonneg _)] have := hsq x y exact this.trans (mul_le_of_le_one_right (sq_nonneg M) (h.weight_le_one x y)) have hH (x : X) : Integrable (fun y => H x y ^ 2) P := Integrable.of_bound (hmeas.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable (M ^ 2) (Filter.Eventually.of_forall (fun y => by simpa only [Real.norm_eq_abs] using hbound x y)) have hW (x : X) : Integrable (fun y => M ^ 2 * W x y) P := by have hwm : Measurable (fun y => M ^ 2 * W x y) := (h.measurable_weight.comp (measurable_const.prodMk measurable_id)).const_mul _ exact Integrable.of_bound hwm.aestronglyMeasurable (M ^ 2) (Filter.Eventually.of_forall (fun y => by rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (sq_nonneg _) (h.weight_nonneg _ _))] exact mul_le_of_le_one_right (sq_nonneg _) (h.weight_le_one _ _))) have hinner (x : X) : (∫ y, H x y ^ 2 ∂P) ≤ M ^ 2 * ∫ y, W x y ∂P := by calc _ ≤ ∫ y, M ^ 2 * W x y ∂P := integral_mono (hH x) (hW x) (hsq x) _ = _ := by rw [integral_const_mul] have houtH : Integrable (fun x => ∫ y, H x y ^ 2 ∂P) P := by have hp : Integrable (fun z : X × X => H z.1 z.2 ^ 2) (P.prod P) := Integrable.of_bound hmeas.aestronglyMeasurable (M ^ 2) (Filter.Eventually.of_forall (fun z => by simpa only [Real.norm_eq_abs] using hbound z.1 z.2)) exact hp.integral_prod_left have houtW : Integrable (fun x => M ^ 2 * ∫ y, W x y ∂P) P := by have hw : Integrable (fun z : X × X => W z.1 z.2) (P.prod P) := Integrable.of_bound h.measurable_weight.aestronglyMeasurable 1 (Filter.Eventually.of_forall (fun z => by rw [Real.norm_eq_abs, abs_of_nonneg (h.weight_nonneg _ _)] exact h.weight_le_one _ _)) exact hw.integral_prod_left.const_mul _ calc _ = ∫ x, ∫ y, H x y ^ 2 ∂P ∂P := by change (∫ ω, H (ω p.1) (ω p.2) ^ 2 ∂iidLaw P n) = _ exact integral_two_coordinates P hij (fun x y => H x y ^ 2) hmeas (M ^ 2) hbound _ ≤ ∫ x, M ^ 2 * ∫ y, W x y ∂P ∂P := integral_mono houtH houtW hinner _ = M ^ 2 * pairMass P W := by rw [integral_const_mul]; rfl -
pairValue_integral_eq_kernel_meantheorem — A probability law and localized-kernel certificate and unordered sample pair give the independent-pair population mean.hypothesesconclusion(∫ ω, pairValue H p ω ∂iidLaw P n) = ∫ x, ∫ y, H x y ∂P ∂PProof (Lean source)
theorem pairValue_integral_eq_kernel_mean {n : ℕ} {p : Fin n × Fin n} (hp : p ∈ pairIndices n) : (∫ ω, pairValue H p ω ∂iidLaw P n) = ∫ x, ∫ y, H x y ∂P ∂P := by have hij : p.1 ≠ p.2 := ne_of_lt (Finset.mem_filter.mp hp).2 have hbound (x y : X) : |H x y| ≤ M := (h.envelope x y).trans (mul_le_of_le_one_right h.envelope_nonneg (h.weight_le_one x y)) change (∫ ω, H (ω p.1) (ω p.2) ∂iidLaw P n) = _ exact integral_two_coordinates P hij H h.measurable_kernel M hbound -
covariance_disjoint_pairs_eq_zerotheorem — A probability law and localized-kernel certificate, two unordered sample pairs, and their disjointness give zero covariance under the finite independent product law.hypothesesconclusionProof (Lean source)
theorem covariance_disjoint_pairs_eq_zero {n : ℕ} {p q : Fin n × Fin n} (hpq : ¬ SharesIndex p q) : covariance (pairValue H p) (pairValue H q) (iidLaw P n) = 0 := by -- The two coordinate pairs are independent by `iIndepFun_pi` and the four -- cross-inequalities from `¬ SharesIndex`; apply `IndepFun.covariance_eq_zero`. haveI : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance have hcross : p.1 ≠ q.1 ∧ p.1 ≠ q.2 ∧ p.2 ≠ q.1 ∧ p.2 ≠ q.2 := by simp only [SharesIndex, not_or] at hpq exact hpq have hcoord : iIndepFun (fun i : Fin n => fun ω : Fin n → X => ω i) (iidLaw P n) := by unfold iidLaw simpa using (iIndepFun_pi (μ := fun _ : Fin n => P) (X := fun _ : Fin n => id) (fun _ => aemeasurable_id)) have hind : pairValue H p ⟂ᵢ[iidLaw P n] pairValue H q := by have hpairs := hcoord.indepFun_prodMk_prodMk (fun i => measurable_pi_apply i) p.1 p.2 q.1 q.2 hcross.1 hcross.2.1 hcross.2.2.1 hcross.2.2.2 have hc := hpairs.comp h.measurable_kernel h.measurable_kernel change (fun ω => H (ω p.1) (ω p.2)) ⟂ᵢ[iidLaw P n] (fun ω => H (ω q.1) (ω q.2)) simpa only [Function.comp_def, Function.uncurry_apply_pair] using hc exact hind.covariance_eq_zero (pairValue_memLp_two P h p) (pairValue_memLp_two P h q) -
covariance_identical_pair_le_pairMasstheorem — A probability law and localized-kernel certificate and unordered sample pair give a self-covariance bounded by the scaled pair mass.hypothesesconclusionProof (Lean source)
theorem covariance_identical_pair_le_pairMass {n : ℕ} {p : Fin n × Fin n} (hp : p ∈ pairIndices n) : covariance (pairValue H p) (pairValue H p) (iidLaw P n) ≤ M ^ 2 * pairMass P W := by -- Use `variance_le_expectation_sq` or `covariance_self`, then the localized -- second-moment estimate above. haveI : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance have hm := pairValue_memLp_two P h p calc covariance (pairValue H p) (pairValue H p) (iidLaw P n) = variance (pairValue H p) (iidLaw P n) := covariance_self hm.aemeasurable _ ≤ ∫ ω, (pairValue H p ω) ^ 2 ∂iidLaw P n := variance_le_expectation_sq hm.aestronglyMeasurable _ ≤ M ^ 2 * pairMass P W := pairValue_second_moment_le_pairMass P h hp
Bridge 1 core · 0 supporting The real centered second moment bound for a localized unordered pair average transfers to its extended nonnegative integral. ★ lintegral_centered_second_moment_le
Extended nonnegative localized variance bound
The real centered second moment bound for a localized unordered pair average transfers to its extended nonnegative integral.
Under a probability law and a kernel H localized by a weight W with envelope M, with at least two observations, the expected squared deviation of the unordered order-two U-statistic of H from its mean under n independent draws, computed as an integral of an extended-nonnegative integrand, is at most 16·M²·(R/n + Q/n²), where R is the squared row mass and Q the pair mass of W.
Formal statement
Proof (Lean source)
Coordinates 1 core · 2 supporting These lemmas identify integrals of functions of two, three, and four distinct sample coordinates with their independent iterated integrals. ★ integral_four_coordinates
Integration over distinct product coordinates
These lemmas identify integrals of functions of two, three, and four distinct sample coordinates with their independent iterated integrals. The bounded measurable form is suited to products of bounded localized kernels and weights.
For a probability law, four pairwise distinct coordinates, measurable four-variable function, and uniform bound, the finite-product integral equals the four independent-draw integral.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
integral_two_coordinatestheorem — For a probability law, two distinct coordinates, measurable two-variable function, and uniform bound, the finite-product integral equals the two independent-draw integral.hypothesesX :sharedType u_1n :ℕFin nhij :i ≠ jf :X → X → ℝhf :Measurable fun z : X × X => f z.1 z.2B :ℝhB :∀ x y, |f x y| ≤ Bconclusion∫ ω, f (ω i) (ω j) ∂iidLaw P n = ∫ x, ∫ y, f x y ∂P ∂PProof (Lean source)
theorem integral_two_coordinates {n : ℕ} {i j : Fin n} (hij : i ≠ j) (f : X → X → ℝ) (hf : Measurable fun z : X × X => f z.1 z.2) (B : ℝ) (hB : ∀ x y, |f x y| ≤ B) : ∫ ω, f (ω i) (ω j) ∂iidLaw P n = ∫ x, ∫ y, f x y ∂P ∂P := by -- Use independence of the two coordinate projections under `Measure.pi` to identify -- their joint law with `P.prod P`; bounded measurability supplies integrability. have hcoord : iIndepFun (fun a : Fin n => fun ω : Fin n → X => ω a) (iidLaw P n) := by unfold iidLaw simpa using (iIndepFun_pi (μ := fun _ : Fin n => P) (X := fun _ : Fin n => id) (fun _ => aemeasurable_id)) have hpair : (iidLaw P n).map (fun ω => (ω i, ω j)) = P.prod P := by letI : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance have hind := hcoord.indepFun hij simpa only [(measurePreserving_eval (fun _ : Fin n => P) i).map_eq, (measurePreserving_eval (fun _ : Fin n => P) j).map_eq, iidLaw] using (hind.map_prod_eq_prod_map_map (measurable_pi_apply i).aemeasurable (measurable_pi_apply j).aemeasurable) have hfi : Integrable (fun z : X × X => f z.1 z.2) (P.prod P) := Integrable.of_bound hf.aestronglyMeasurable B (Filter.Eventually.of_forall (by intro z simpa only [Real.norm_eq_abs] using hB z.1 z.2)) calc _ = ∫ z : X × X, f z.1 z.2 ∂(iidLaw P n).map (fun ω => (ω i, ω j)) := by rw [integral_map (by fun_prop) hf.aestronglyMeasurable] _ = ∫ z : X × X, f z.1 z.2 ∂(P.prod P) := by rw [hpair] _ = _ := integral_prod _ hfi -
integral_three_coordinatestheorem — For a probability law, three pairwise distinct coordinates, measurable three-variable function, and uniform bound, the finite-product integral equals the three independent-draw integral.hypothesesX :sharedType u_1n :ℕFin nhij :i ≠ jhik :i ≠ khjk :j ≠ kf :X → X → X → ℝhf :Measurable fun z : (X × X) × X => f z.1.1 z.1.2 z.2B :ℝhB :∀ x y z, |f x y z| ≤ Bconclusion∫ ω, f (ω i) (ω j) (ω k) ∂iidLaw P n = ∫ x, ∫ y, ∫ z, f x y z ∂P ∂P ∂PProof (Lean source)
theorem integral_three_coordinates {n : ℕ} {i j k : Fin n} (hij : i ≠ j) (hik : i ≠ k) (hjk : j ≠ k) (f : X → X → X → ℝ) (hf : Measurable fun z : (X × X) × X => f z.1.1 z.1.2 z.2) (B : ℝ) (hB : ∀ x y z, |f x y z| ≤ B) : ∫ ω, f (ω i) (ω j) (ω k) ∂iidLaw P n = ∫ x, ∫ y, ∫ z, f x y z ∂P ∂P ∂P := by -- Push the product law along the three distinct coordinate projections, then -- apply Fubini twice. A reusable finite-coordinate map theorem may shorten this. letI : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance have hcoord : iIndepFun (fun a : Fin n => fun ω : Fin n → X => ω a) (iidLaw P n) := by unfold iidLaw simpa using (iIndepFun_pi (μ := fun _ : Fin n => P) (X := fun _ : Fin n => id) (fun _ => aemeasurable_id)) have hpair : (iidLaw P n).map (fun ω => (ω i, ω j)) = P.prod P := by have hind := hcoord.indepFun hij simpa only [(measurePreserving_eval (fun _ : Fin n => P) i).map_eq, (measurePreserving_eval (fun _ : Fin n => P) j).map_eq, iidLaw] using (hind.map_prod_eq_prod_map_map (measurable_pi_apply i).aemeasurable (measurable_pi_apply j).aemeasurable) have htriple : (iidLaw P n).map (fun ω => ((ω i, ω j), ω k)) = (P.prod P).prod P := by have hind := hcoord.indepFun_prodMk (fun a => measurable_pi_apply a) i j k hik hjk have h := hind.map_prod_eq_prod_map_map ((measurable_pi_apply i).prodMk (measurable_pi_apply j)).aemeasurable (measurable_pi_apply k).aemeasurable rw [hpair] at h simpa only [(measurePreserving_eval (fun _ : Fin n => P) k).map_eq, iidLaw] using h have hfi : Integrable (fun z : (X × X) × X => f z.1.1 z.1.2 z.2) ((P.prod P).prod P) := Integrable.of_bound hf.aestronglyMeasurable B (Filter.Eventually.of_forall (by intro z simpa only [Real.norm_eq_abs] using hB z.1.1 z.1.2 z.2)) calc _ = ∫ z : (X × X) × X, f z.1.1 z.1.2 z.2 ∂ (iidLaw P n).map (fun ω => ((ω i, ω j), ω k)) := by rw [integral_map (by fun_prop) hf.aestronglyMeasurable] _ = ∫ z : (X × X) × X, f z.1.1 z.1.2 z.2 ∂((P.prod P).prod P) := by rw [htriple] _ = ∫ z : X × X, ∫ w : X, f z.1 z.2 w ∂P ∂(P.prod P) := integral_prod _ hfi _ = _ := by exact integral_prod _ hfi.integral_prod_left
Counting 1 core · 7 supporting This module counts unordered index pairs and the ordered pairs of such pairs that are identical, share exactly one index, or are disjoint. ★ normalized_pair_counts_le
Counting unordered pair overlaps
This module counts unordered index pairs and the ordered pairs of such pairs that are identical, share exactly one index, or are disjoint. The counts are purely finite and independent of the observation space.
For a sample size n of at least two and nonnegative reals a, p and r, with N = n(n − 1)/2 the number of unordered pairs, the quantity N⁻²·(N·a·p + 2N(n − 2)·2a·r) is at most 16·a·(r/n + p/n²). This is the counting step of the U-statistic variance bound: N identical pairs each contribute a·p, and the 2N(n − 2) ordered pairs of pairs sharing exactly one index each contribute 2a·r.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
card_pairIndicestheorem — A sample size has exactly its binomial number of unordered pairs.Proof (Lean source)
theorem card_pairIndices (n : ℕ) : (pairIndices n).card = n.choose 2 := by simpa [pairIndices] using (Finset.card_product_filter_lt (s := (Finset.univ : Finset (Fin n)))) -
card_identical_pair_configurationstheorem — A sample size has one ordered identical-pair configuration for each unordered pair.hypothesesn :ℕconclusion= n.choose 2Proof (Lean source)
theorem card_identical_pair_configurations (n : ℕ) : ((pairIndices n).product (pairIndices n) |>.filter fun pq => pq.1 = pq.2).card = n.choose 2 := by change ((pairIndices n ×ˢ pairIndices n).filter (fun pq => pq.1 = pq.2)).card = _ rw [← Finset.diag_eq_filter, Finset.diag_card, card_pairIndices] -
card_pairs_sharing_fixed_pairtheorem — Given at least two observations and an unordered pair, exactly twice the number of remaining vertices gives a distinct pair sharing an endpoint.hypothesesconclusionProof (Lean source)
theorem card_pairs_sharing_fixed_pair {n : ℕ} (hn : 2 ≤ n) {p : Fin n × Fin n} (hp : p ∈ pairIndices n) : ((pairIndices n).filter fun q => p ≠ q ∧ SharesIndex p q).card = 2 * (n - 2) := by -- Partition the filtered pairs by which endpoint of p they contain. The -- parts are disjoint because q ≠ p; each is indexed by the n - 2 remaining -- vertices. An order-free Finset erase of the two endpoints is convenient. have hcount (a b : Fin n) (hab : a ≠ b) : ((pairIndices n).filter (fun q => q ≠ (if a < b then (a,b) else (b,a)) ∧ (q.1 = a ∨ q.2 = a))).card = n - 2 := by let t := ((Finset.univ : Finset (Fin n)).erase a).erase b let f : Fin n → Fin n × Fin n := fun x => if a < x then (a,x) else (x,a) have heq : (pairIndices n).filter (fun q => q ≠ (if a < b then (a,b) else (b,a)) ∧ (q.1 = a ∨ q.2 = a)) = t.image f := by ext q simp only [mem_filter, pairIndices, Finset.mem_univ, true_and, mem_image] constructor · rintro ⟨hord, hne, hshare⟩ rcases hshare with h | h · refine ⟨q.2, ?_, ?_⟩ · grind · dsimp [f]; split_ifs <;> grind · refine ⟨q.1, ?_, ?_⟩ · grind · dsimp [f]; split_ifs <;> grind · rintro ⟨x, hx, hqx⟩ rw [← hqx] have hxa : x ≠ a := (Finset.mem_erase.mp (Finset.mem_erase.mp hx).2).1 have hxb : x ≠ b := (Finset.mem_erase.mp hx).1 dsimp [f] split_ifs <;> grind have hinj : InjOn f ↑t := by intro x hx y hy h have hxa : x ≠ a := (Finset.mem_erase.mp (Finset.mem_erase.mp hx).2).1 have hya : y ≠ a := (Finset.mem_erase.mp (Finset.mem_erase.mp hy).2).1 dsimp [f] at h split_ifs at h <;> grind rw [heq, Finset.card_image_of_injOn hinj] have hb : b ∈ (Finset.univ : Finset (Fin n)).erase a := by simp [hab.symm] rw [Finset.card_erase_of_mem hb, Finset.card_erase_of_mem (Finset.mem_univ a)] simp only [Finset.card_univ, Fintype.card_fin] omega have hpord : p.1 < p.2 := by simpa [pairIndices] using hp let A := (pairIndices n).filter fun q => q ≠ p ∧ (q.1 = p.1 ∨ q.2 = p.1) let B := (pairIndices n).filter fun q => q ≠ p ∧ (q.1 = p.2 ∨ q.2 = p.2) have hcover : ((pairIndices n).filter fun q => p ≠ q ∧ SharesIndex p q) = A ∪ B := by ext q simp only [mem_filter, mem_union] dsimp [A, B] simp only [mem_filter] unfold SharesIndex grind have hdisj : Disjoint A B := by apply Finset.disjoint_left.mpr intro q hA hB have hqord : q.1 < q.2 := by have hq : q ∈ pairIndices n := (Finset.mem_filter.mp hA).1 simpa [pairIndices] using hq have ha := (Finset.mem_filter.mp hA).2 have hb := (Finset.mem_filter.mp hB).2 grind have hA : A.card = n - 2 := by simpa [A, hpord] using hcount p.1 p.2 (ne_of_lt hpord) have hB : B.card = n - 2 := by have hnot : ¬ p.2 < p.1 := not_lt_of_ge (le_of_lt hpord) simpa [B, hnot] using hcount p.2 p.1 (Ne.symm (ne_of_lt hpord)) rw [hcover, Finset.card_union_of_disjoint hdisj, hA, hB] omega -
card_pairs_disjoint_fixed_pairtheorem — Given an unordered pair, the pairs using neither endpoint have the binomial remaining-vertex count.Proof (Lean source)
theorem card_pairs_disjoint_fixed_pair {n : ℕ} {p : Fin n × Fin n} (hp : p ∈ pairIndices n) : ((pairIndices n).filter fun q => ¬ SharesIndex p q).card = (n - 2).choose 2 := by let s := ((Finset.univ : Finset (Fin n)).erase p.1).erase p.2 have hset : (pairIndices n).filter (fun q => ¬ SharesIndex p q) = (s ×ˢ s).filter (fun q => q.1 < q.2) := by ext q simp [s, pairIndices, SharesIndex, Finset.mem_product, and_comm, and_assoc] grind have hpord : p.1 < p.2 := by simpa [pairIndices] using hp have hp2 : p.2 ∈ (Finset.univ : Finset (Fin n)).erase p.1 := by simp [ne_of_gt hpord] have hs : s.card = n - 2 := by dsimp [s] rw [Finset.card_erase_of_mem hp2, Finset.card_erase_of_mem (Finset.mem_univ p.1)] simp only [Finset.card_univ, Fintype.card_fin] omega rw [hset, Finset.card_product_filter_lt, hs] -
choose_two_mul_choose_sub_twotheorem — A sample size satisfies the pair-then-disjoint-pair counting identity, which counts every four-element subset through its six ordered pairings.hypothesesn :ℕconclusionn.choose 2 * (n - 2).choose 2 = 6 * n.choose 4Proof (Lean source)
theorem choose_two_mul_choose_sub_two (n : ℕ) : n.choose 2 * (n - 2).choose 2 = 6 * n.choose 4 := by have h := Nat.choose_mul (n := n) (k := 4) (s := 2) (by omega) have hchoose : choose 4 2 = 6 := by decide rw [hchoose] at h simpa [Nat.mul_comm] using h.symm -
card_disjoint_pair_configurationstheorem — A sample size has six ordered disjoint-pair configurations per four-element subset.hypothesesn :ℕconclusion((pairIndices n).product (pairIndices n) |>.filter fun (pq : (Fin n × Fin n) × (Fin n × Fin n)) => ¬ SharesIndex pq.1 pq.2).card= 6 * n.choose 4Proof (Lean source)
theorem card_disjoint_pair_configurations (n : ℕ) : ((pairIndices n).product (pairIndices n) |>.filter fun (pq : (Fin n × Fin n) × (Fin n × Fin n)) => ¬ SharesIndex pq.1 pq.2).card = 6 * n.choose 4 := by -- Sum `card_pairs_disjoint_fixed_pair` over first pairs, rewrite with -- `card_pairIndices`, then use `choose_two_mul_choose_sub_two`. classical let s := pairIndices n have hfiber (p : Fin n × Fin n) (hp : p ∈ s) : (((s ×ˢ s).filter (fun pq => ¬ SharesIndex pq.1 pq.2)).filter (fun pq => pq.1 = p)).card = (n - 2).choose 2 := by have heq : ((s ×ˢ s).filter (fun pq => ¬ SharesIndex pq.1 pq.2)).filter (fun pq => pq.1 = p) = {p} ×ˢ (s.filter fun q => ¬ SharesIndex p q) := by ext pq simp only [mem_filter, Finset.mem_product, Finset.mem_singleton] constructor · rintro ⟨⟨⟨hpq, hqq⟩, hdis⟩, hfst⟩ subst p exact ⟨rfl, hqq, hdis⟩ · rintro ⟨hfst, hqq, hdis⟩ subst p exact ⟨⟨⟨hp, hqq⟩, hdis⟩, rfl⟩ rw [heq, Finset.card_product] simpa [s] using card_pairs_disjoint_fixed_pair hp have hsum := Finset.card_eq_sum_card_fiberwise (s := (s ×ˢ s).filter (fun pq => ¬ SharesIndex pq.1 pq.2)) (t := s) (f := fst) (by intro pq hpq exact (Finset.mem_product.mp (Finset.mem_filter.mp hpq).1).1) rw [Finset.sum_const_nat hfiber] at hsum have hcard : ((pairIndices n ×ˢ pairIndices n).filter (fun pq => ¬ SharesIndex pq.1 pq.2)).card = n.choose 2 * (n - 2).choose 2 := by simpa [s, card_pairIndices] using hsum exact hcard.trans (choose_two_mul_choose_sub_two n)
Main 1 core · 1 supporting For a symmetric kernel bounded by a symmetric weight, the centered second moment of the unordered pair average is controlled by both the squared row mass at order 1/n and the pair mass at order 1/n². ★ centered_second_moment_le
Localized variance of an unordered order-two U-statistic
For a symmetric kernel bounded by a symmetric weight, the centered second moment of
the unordered pair average is controlled by both the squared row mass at order 1/n
and the pair mass at order 1/n². The extended nonnegative form is in Bridge.
Under a probability law and a kernel H localized by a weight W with envelope M — both symmetric and measurable, W between zero and one, and |H| at most M·W — with at least two observations, the variance of the unordered order-two U-statistic of H under n independent draws (its expected squared deviation from its mean) is at most 16·M²·(R/n + Q/n²). Here Q, the pair mass, is the mean of W over two independent draws, and R, the squared row mass, is the mean over one draw of the square of W's mean over a second independent draw.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
uStatistic_memLp_twotheorem — A probability law and localized-kernel certificate give an unordered order-two U-statistic with finite second moment.hypothesesX :sharedType u_1H :sharedX → X → ℝW :sharedX → X → ℝM :sharedℝn :ℕconclusionMemLp (uStatistic n H) 2 (iidLaw P n)Proof (Lean source)
theorem uStatistic_memLp_two {n : ℕ} : MemLp (uStatistic n H) 2 (iidLaw P n) := by have hsum : MemLp (∑ p ∈ pairIndices n, pairValue H p) 2 (iidLaw P n) := memLp_finsetSum' (pairIndices n) (fun p _ => pairValue_memLp_two P h p) convert hsum.const_mul (((pairIndices n).card : ℝ)⁻¹) using 1 funext ω simp only [uStatistic, pairValue, Finset.sum_apply]
Mean 1 core · 1 supporting For a measurable integrable symmetric pair kernel, each distinct finite-product coordinate pair has the independent two-draw expectation. ★ integral_uStatistic_eq_pair
Mean of an unordered order-two U-statistic
For a measurable integrable symmetric pair kernel, each distinct finite-product coordinate pair has the independent two-draw expectation. Averaging over unordered pairs preserves that mean. This module is independent of causal models and supplies the integrable finite-product transport.
A probability law, sample size, at least two observations, pair kernel, its measurability, and its integrability under the independent two-draw law give an unordered U-statistic mean equal to its independent two-draw mean.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
integral_two_coordinates_integrabletheorem — A probability law, sample size, two sample coordinates, their distinctness, pair kernel, and measurability of that kernel give a coordinate-pair mean equal to its independent two-draw mean.hypothesesconclusion∫ ω, H (ω i) (ω j) ∂iidLaw P n = ∫ z : X × X, H z.1 z.2 ∂(P.prod P)Proof (Lean source)
theorem integral_two_coordinates_integrable {n : ℕ} {i j : Fin n} (hij : i ≠ j) (H : X → X → ℝ) (hH : Measurable fun z : X × X => H z.1 z.2) : ∫ ω, H (ω i) (ω j) ∂iidLaw P n = ∫ z : X × X, H z.1 z.2 ∂(P.prod P) := by -- Follow `LocalizedVariance.integral_two_coordinates`: the joint coordinate -- map sends `iidLaw P n` to `P.prod P`. Use `integral_map`. letI : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance have hcoord : iIndepFun (fun a : Fin n => fun ω : Fin n → X => ω a) (iidLaw P n) := by unfold iidLaw simpa using (iIndepFun_pi (μ := fun _ : Fin n => P) (X := fun _ : Fin n => id) (fun _ => aemeasurable_id)) have hpair : (iidLaw P n).map (fun ω => (ω i, ω j)) = P.prod P := by have hind := hcoord.indepFun hij simpa only [(measurePreserving_eval (fun _ : Fin n => P) i).map_eq, (measurePreserving_eval (fun _ : Fin n => P) j).map_eq, iidLaw] using (hind.map_prod_eq_prod_map_map (measurable_pi_apply i).aemeasurable (measurable_pi_apply j).aemeasurable) calc _ = ∫ z : X × X, H z.1 z.2 ∂(iidLaw P n).map (fun ω => (ω i, ω j)) := by rw [integral_map (by fun_prop) hH.aestronglyMeasurable] _ = _ := by rw [hpair]
SumBound 1 core · 1 supporting The variance of the unnormalized unordered pair sum is expanded into ordered pair-of-pairs covariances. ★ pair_sum_variance_le_localized_counts
Covariance expansion and localized count bound
The variance of the unnormalized unordered pair sum is expanded into ordered pair-of-pairs covariances. Identical, shared, and disjoint configurations are bounded separately using the pair and squared row masses.
Under a probability law and a kernel H localized by a weight W with envelope M, with at least two observations, the variance, under n independent draws, of the sum of the kernel values over all N = n(n − 1)/2 unordered pairs is at most N·M²·Q + 2N(n − 2)·2M²·R, where Q is the pair mass and R the squared row mass of W.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
pair_sum_variance_eq_covariance_sumtheorem — A probability law and localized-kernel certificate give an unnormalized pair sum variance equal to its ordered covariance expansion.hypothesesX :sharedType u_1H :sharedX → X → ℝW :sharedX → X → ℝM :sharedℝn :ℕconclusionProof (Lean source)
theorem pair_sum_variance_eq_covariance_sum {n : ℕ} : variance (fun ω => ∑ p ∈ pairIndices n, pairValue H p ω) (iidLaw P n) = ∑ p ∈ pairIndices n, ∑ q ∈ pairIndices n, covariance (pairValue H p) (pairValue H q) (iidLaw P n) := by have : IsProbabilityMeasure (iidLaw P n) := by unfold iidLaw; infer_instance exact variance_fun_sum' (fun p _ => pairValue_memLp_two P h p)