File size: 5,708 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | import OAI.Analysis.FiniteFactor.Sampling.IntegratedCorrelation
namespace OAI
namespace FiniteFactor
open MeasureTheory Filter Finset
open scoped Classical
noncomputable section
/-- Exact finite-average expansion, before bounding or discarding any term. -/
theorem sampling_average_square_expansion {ΞΉ Ξ© : Type*} [MeasurableSpace Ξ©]
(ΞΌ : Measure Ξ©) (S : Finset ΞΉ) (f : ΞΉ β Ξ© β β) (g : Ξ© β β)
(hpair : β n β S, β k β S, Integrable (fun x => f n x*f k x) ΞΌ)
(hmix : β n β S, Integrable (fun x => f n x*g x) ΞΌ)
(hg : Integrable (fun x => g x^2) ΞΌ) :
(β« x, ((β n β S, f n x)/(S.card : β)-g x)^2 βΞΌ) =
(β n β S, β k β S, β« x, f n x*f k x βΞΌ)/(S.card : β)^2 -
2*(β n β S, β« x, f n x*g x βΞΌ)/(S.card : β)+(β« x, g x^2 βΞΌ) := by
have he (x : Ξ©) : ((β n β S, f n x)/(S.card : β)-g x)^2 =
(β n β S, β k β S, f n x*f k x)/(S.card : β)^2 -
2*(β n β S, f n x*g x)/(S.card : β)+g x^2 := by
have hsq : (β n β S, β k β S, f n x*f k x) = (β n β S, f n x)^2 := by
rw [pow_two]; simp_rw [Finset.sum_mul,Finset.mul_sum]
rw [hsq,β Finset.sum_mul]
ring
have hpi := integrable_finsetSum S (fun n hn => integrable_finsetSum S (fun k hk => hpair n hn k hk))
have hmi := integrable_finsetSum S (fun n hn => hmix n hn)
have hiP : Integrable (fun x => (β n β S, β k β S, f n x*f k x)/(S.card : β)^2) ΞΌ := hpi.div_const _
have hiM : Integrable (fun x => 2*(β n β S, f n x*g x)/(S.card : β)) ΞΌ := (hmi.const_mul 2).div_const _
have hiSub : Integrable (fun x => (β n β S, β k β S, f n x*f k x)/(S.card : β)^2 -
2*(β n β S, f n x*g x)/(S.card : β)) ΞΌ := hiP.sub hiM
have hpis : (β« x, β n β S, β k β S, f n x*f k x βΞΌ) =
β n β S, β k β S, β« x, f n x*f k x βΞΌ := by
rw [integral_finsetSum S (fun n hn => integrable_finsetSum S (fun k hk => hpair n hn k hk))]
apply sum_congr rfl
intro n hn
exact integral_finsetSum S (fun k hk => hpair n hn k hk)
simp_rw [he]
rw [integral_add hiSub hg,integral_sub hiP hiM,integral_div,integral_div,integral_const_mul,
hpis,integral_finsetSum S (fun n hn => hmix n hn)]
/-- Integrability of the full error follows from the same finite expansion. -/
theorem sampling_average_square_integrable {ΞΉ Ξ© : Type*} [MeasurableSpace Ξ©]
(ΞΌ : Measure Ξ©) (S : Finset ΞΉ) (f : ΞΉ β Ξ© β β) (g : Ξ© β β)
(hpair : β n β S, β k β S, Integrable (fun x => f n x*f k x) ΞΌ)
(hmix : β n β S, Integrable (fun x => f n x*g x) ΞΌ)
(hg : Integrable (fun x => g x^2) ΞΌ) :
Integrable (fun x => ((β n β S, f n x)/(S.card : β)-g x)^2) ΞΌ := by
have hpi := integrable_finsetSum S (fun n hn => integrable_finsetSum S (fun k hk => hpair n hn k hk))
have hmi := integrable_finsetSum S (fun n hn => hmix n hn)
have h : Integrable (fun x => (β n β S, β k β S, f n x*f k x)/(S.card : β)^2 -
2*(β n β S, f n x*g x)/(S.card : β)+g x^2) ΞΌ :=
((hpi.div_const _).sub ((hmi.const_mul 2).div_const _)).add hg
apply h.congr
apply Eventually.of_forall
intro x
have hsq : (β n β S, β k β S, f n x*f k x) = (β n β S, f n x)^2 := by
rw [pow_two]; simp_rw [Finset.sum_mul,Finset.mul_sum]
dsimp only
rw [hsq,β Finset.sum_mul]
ring
/-- The distinct-pair and mixed main terms cancel to -A/P. Since A is
nonnegative, the surviving upper bound is the actual diagonal term plus 3Ξ΅. -/
theorem sampling_finite_cancellation {ΞΉ : Type*} (S : Finset ΞΉ) (hS : S.Nonempty)
(B : ΞΉ β ΞΉ β β) (M : ΞΉ β β) (A Ξ΅ : β) (hA : 0 β€ A) (hΞ΅ : 0 β€ Ξ΅)
(hpair : β n β S, β k β S, n β k β |B n k-A| β€ Ξ΅)
(hmix : β n β S, |M n-A| β€ Ξ΅) :
(β n β S, β k β S, B n k)/(S.card : β)^2 -
2*(β n β S, M n)/(S.card : β)+A β€
(β n β S, B n n)/(S.card : β)^2+3*Ξ΅ := by
let N : β := S.card
have hN : 0 < N := by dsimp [N]; exact_mod_cast hS.card_pos
have hN1 : 1 β€ N := by dsimp [N]; exact_mod_cast (show 1 β€ S.card from hS.card_pos)
have hp (n : ΞΉ) (hn : n β S) :
(β k β S, B n k) β€ B n n+(N-1)*(A+Ξ΅) := by
have hoff : (β k β S.erase n, B n k) β€ ((S.erase n).card : β)*(A+Ξ΅) := by
calc
_ β€ β _k β S.erase n, (A+Ξ΅) := sum_le_sum (fun k hk => by
have hmem := mem_erase.mp hk
have hb := (abs_le.mp (hpair n hn k hmem.2 (Ne.symm hmem.1))).2
linarith)
_ = _ := by simp; ring
have hc : ((S.erase n).card : β) = N-1 := by
rw [card_erase_of_mem hn,Nat.cast_sub (by exact hS.card_pos),Nat.cast_one]
rw [hc] at hoff
have he := sum_erase_add S (fun k => B n k) hn
linarith
have hpall : (β n β S, β k β S, B n k) β€
(β n β S, B n n)+N*(N-1)*(A+Ξ΅) := by
calc
_ β€ β n β S, (B n n+(N-1)*(A+Ξ΅)) := sum_le_sum hp
_ = _ := by rw [sum_add_distrib]; simp [N]; ring
have hmall : N*(A-Ξ΅) β€ β n β S, M n := by
calc
_ = β _n β S, (A-Ξ΅) := by simp [N]; ring
_ β€ _ := sum_le_sum (fun n hn => by have hh := (abs_le.mp (hmix n hn)).1; linarith)
change _/N^2-2*_/N+A β€ _/N^2+3*Ξ΅
have hpdiv := div_le_div_of_nonneg_right hpall (sq_nonneg N)
have hmdiv := div_le_div_of_nonneg_right hmall hN.le
have hcancel : ((β n β S, B n n)+N*(N-1)*(A+Ξ΅))/N^2-
2*(N*(A-Ξ΅))/N+A =
(β n β S, B n n)/N^2+3*Ξ΅-(A+Ξ΅)/N := by field_simp; ring
have hnneg : 0 β€ (A+Ξ΅)/N := div_nonneg (add_nonneg hA hΞ΅) hN.le
simp only [mul_div_assoc] at hmdiv hcancel β’
nlinarith
end
end FiniteFactor
end OAI
|