Download data/lean/OAI/Analysis/FiniteFactor/Sampling/Cancellation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.71 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/FiniteFactor/Sampling/Cancellation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/FiniteFactor/Sampling/Cancellation.lean
-
curl -L -o Cancellation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/FiniteFactor/Sampling/Cancellation.lean
5.71 kB
| 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 | |