Add lean source and binary files (part 18)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/CompactTorus.lean +52 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/CrossProducts.lean +98 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Cube.lean +84 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/CutoffMass.lean +92 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/CylinderBasis.lean +63 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/CylinderSystem.lean +75 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalContribution.lean +69 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalEvent.lean +65 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalIntegral.lean +59 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalLimit.lean +94 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Discrepancy.lean +111 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/EmpiricalL2.lean +89 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Error.lean +120 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/ErrorEvent.lean +80 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/FirstCorrelation.lean +74 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/FirstMarginal.lean +67 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Fourier.lean +92 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/IdealProduct.lean +120 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/IdealRectangleLimit.lean +105 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/LambdaMarginals.lean +69 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/LambdaMass.lean +53 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/LambdaRectangles.lean +122 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/LimitMeasure.lean +98 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Measures.lean +79 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Moments.lean +50 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/OrbitSupport.lean +48 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/OrderedRestriction.lean +100 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/PairMoments.lean +78 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/PhaseSelfMoment.lean +61 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Powers.lean +153 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/ProductError.lean +114 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/ProductMoments.lean +116 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/RationalTests.lean +108 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/RectangleApproximation.lean +38 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/RectangleError.lean +91 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/RotationTransport.lean +61 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/SecondCorrelation.lean +73 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/SecondMarginal.lean +80 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/SelfMoment.lean +74 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/SelfSummability.lean +96 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/SingleCorrelation.lean +96 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/Tail.lean +86 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TestedMarginals.lean +94 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TestedTransport.lean +92 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TorusLimitMarginals.lean +69 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TorusMarginals.lean +58 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TorusSupport.lean +107 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TriangleLaw.lean +79 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TrimmedMarginals.lean +42 -0
- lean/OAI/Analysis/FiniteFactor/OrbitSampling/TrimmedWeak.lean +88 -0
lean/OAI/Analysis/FiniteFactor/OrbitSampling/CompactTorus.lean
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.WeakLimit
|
| 2 |
+
import Mathlib.MeasureTheory.Constructions.Polish.Basic
|
| 3 |
+
import Mathlib.Topology.Instances.AddCircle.Real
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Filter Finset
|
| 9 |
+
open scoped Classical ENNReal Topology
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
abbrev SourceSamplingTorus := (SourceCoordinate → UnitAddCircle) × (SourceCoordinate → UnitAddCircle)
|
| 13 |
+
|
| 14 |
+
instance sourceSamplingTorus_compact : CompactSpace SourceSamplingTorus := inferInstance
|
| 15 |
+
|
| 16 |
+
instance sourceSamplingTorus_borel : BorelSpace SourceSamplingTorus := Prod.borelSpace
|
| 17 |
+
|
| 18 |
+
def sourceSamplingTorusMap (p : SourceSamplingPair) : SourceSamplingTorus :=
|
| 19 |
+
(fun i => (p.1 i : UnitAddCircle),fun i => (p.2 i : UnitAddCircle))
|
| 20 |
+
|
| 21 |
+
theorem sourceSamplingTorusMap_continuous : Continuous sourceSamplingTorusMap := by
|
| 22 |
+
exact (continuous_pi (fun i => (AddCircle.continuous_mk' (1 : ℝ)).comp
|
| 23 |
+
((continuous_apply i).comp continuous_fst))).prodMk
|
| 24 |
+
(continuous_pi (fun i => (AddCircle.continuous_mk' (1 : ℝ)).comp
|
| 25 |
+
((continuous_apply i).comp continuous_snd)))
|
| 26 |
+
|
| 27 |
+
def sourceSamplingUntrimmedTorus (I : Finset SourceCoordinate) (s : ℕ)
|
| 28 |
+
(θ : SourceCoordinate → ℝ) : FiniteMeasure SourceSamplingTorus :=
|
| 29 |
+
(sourceSamplingUntrimmedFinite I s θ).map sourceSamplingTorusMap
|
| 30 |
+
|
| 31 |
+
def sourceSamplingLambdaTorus (I : Finset SourceCoordinate) : FiniteMeasure SourceSamplingTorus :=
|
| 32 |
+
(sourceSamplingLambdaFinite I).map sourceSamplingTorusMap
|
| 33 |
+
|
| 34 |
+
theorem sourceSamplingUntrimmed_torus_event : ∀ᵐ θ ∂sourceAngleLaw,
|
| 35 |
+
∀ I : Finset SourceCoordinate,
|
| 36 |
+
Tendsto (fun s => sourceSamplingUntrimmedTorus I s θ) atTop
|
| 37 |
+
(𝓝 (sourceSamplingLambdaTorus I)) ∧
|
| 38 |
+
∀ f : C(SourceSamplingTorus,ℝ),
|
| 39 |
+
Tendsto (fun s => ∫ p, f p ∂(sourceSamplingUntrimmedTorus I s θ : Measure SourceSamplingTorus))
|
| 40 |
+
atTop (𝓝 (∫ p, f p ∂(sourceSamplingLambdaTorus I : Measure SourceSamplingTorus))) := by
|
| 41 |
+
filter_upwards [sourceSamplingUntrimmed_weak_event] with θ hθ
|
| 42 |
+
intro I
|
| 43 |
+
have h := FiniteMeasure.tendsto_map_of_tendsto_of_continuous _ _ (hθ I)
|
| 44 |
+
sourceSamplingTorusMap_continuous
|
| 45 |
+
refine ⟨h,fun f => ?_⟩
|
| 46 |
+
exact (FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp h)
|
| 47 |
+
(BoundedContinuousFunction.mkOfCompact f)
|
| 48 |
+
|
| 49 |
+
end
|
| 50 |
+
end FiniteFactor
|
| 51 |
+
|
| 52 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/CrossProducts.lean
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.ProductMoments
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.SingleCorrelation
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- A global bound used only to justify finite-stage integrations. -/
|
| 11 |
+
theorem sourceSamplingIdealDensity_bounds (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 12 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 13 |
+
(x : SourceCoordinate → ℝ) :
|
| 14 |
+
0 ≤ sourceSamplingIdealDensity stage r b E G x ∧
|
| 15 |
+
sourceSamplingIdealDensity stage r b E G x ≤
|
| 16 |
+
(max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card := by
|
| 17 |
+
have hp := sourceSampling_parameters stage
|
| 18 |
+
have hb (i : SourceCoordinate) := (sampling_kernel_mean unitIntervalMeasure
|
| 19 |
+
(samplingOrientedWeight r (b i) _ _ (E i) (G i))
|
| 20 |
+
(samplingOrientedWeight_measurable r (b i) _ _ (E i) (G i) (hE i) (hG i))
|
| 21 |
+
(max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))
|
| 22 |
+
(samplingOrientedWeight_bounds r (b i) _ _ (E i) (G i) hp.1 hp.2.2)).2
|
| 23 |
+
refine ⟨prod_nonneg (fun i _ => (hb i (x i)).1),?_⟩
|
| 24 |
+
calc
|
| 25 |
+
_ ≤ ∏ _i ∈ sourceSamplingPrefix stage, max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)) :=
|
| 26 |
+
prod_le_prod₀ (fun i _ => (hb i (x i)).1) (fun i _ => (hb i (x i)).2)
|
| 27 |
+
_ = _ := by simp
|
| 28 |
+
|
| 29 |
+
/-- Exact mixed factorization for q_n and the actual ideal density on the
|
| 30 |
+
full countable Haar space. -/
|
| 31 |
+
theorem sourceSamplingProduct_mixed_factorization (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 32 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) (n : ℤ) :
|
| 33 |
+
(∫ x, ∫ θ, sourceSamplingProduct stage r b E G n θ x * sourceSamplingIdealDensity stage r b E G x
|
| 34 |
+
∂sourceAngleLaw ∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) =
|
| 35 |
+
∏ i ∈ sourceSamplingPrefix stage,
|
| 36 |
+
∫ s, samplingOrientedDensity r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s *
|
| 37 |
+
(∫ θ, samplingOrientedWeight r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 38 |
+
(E i) (G i) s (Int.fract ((n : ℝ)*θ i)) ∂sourceAngleLaw) ∂unitIntervalMeasure := by
|
| 39 |
+
let u (i : SourceCoordinate) := samplingOrientedWeight r (b i) (sourceSamplingWidth stage)
|
| 40 |
+
(sourceSamplingCutoff stage) (E i) (G i)
|
| 41 |
+
let a (i : SourceCoordinate) := samplingOrientedDensity r (b i) (sourceSamplingWidth stage)
|
| 42 |
+
(sourceSamplingCutoff stage) (E i) (G i)
|
| 43 |
+
let F (i : SourceCoordinate) (s t : ℝ) := u i s (Int.fract ((n : ℝ)*t))*a i s
|
| 44 |
+
have hF (i : SourceCoordinate) : Measurable (fun p : ℝ × ℝ => F i p.1 p.2) := by
|
| 45 |
+
have hu := samplingOrientedWeight_measurable r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 46 |
+
(E i) (G i) (hE i) (hG i)
|
| 47 |
+
have ha := samplingOrientedDensity_measurable r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 48 |
+
(E i) (G i) (hE i) (hG i)
|
| 49 |
+
exact (hu.comp (measurable_fst.prodMk (sourceFract_measurable.comp (measurable_const.mul measurable_snd)))).mul
|
| 50 |
+
(ha.comp measurable_fst)
|
| 51 |
+
calc
|
| 52 |
+
_ = ∫ x, ∏ i ∈ sourceSamplingPrefix stage, ∫ t, F i (x i) t ∂sourceAngleMarginal i
|
| 53 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) := by
|
| 54 |
+
apply integral_congr_ae
|
| 55 |
+
filter_upwards [] with x
|
| 56 |
+
simp only [sourceSamplingProduct,sourceSamplingIdealDensity,← Finset.prod_mul_distrib]
|
| 57 |
+
exact integral_infinitePi_finset_prod _ _ _
|
| 58 |
+
(fun i => (hF i).comp (measurable_const.prodMk measurable_id))
|
| 59 |
+
_ = ∏ i ∈ sourceSamplingPrefix stage, ∫ s, ∫ t, F i s t ∂sourceAngleMarginal i ∂unitIntervalMeasure :=
|
| 60 |
+
integral_infinitePi_finset_prod _ _ _
|
| 61 |
+
(fun i => (hF i).stronglyMeasurable.integral_prod_right.measurable)
|
| 62 |
+
_ = _ := by
|
| 63 |
+
apply Finset.prod_congr rfl
|
| 64 |
+
intro i _
|
| 65 |
+
apply integral_congr_ae
|
| 66 |
+
filter_upwards [] with s
|
| 67 |
+
have hm : Measurable (fun t => F i s t) := (hF i).comp (measurable_const.prodMk measurable_id)
|
| 68 |
+
rw [← sourceAngleLaw_coordinate i,integral_map (measurable_pi_apply i).aemeasurable hm.aestronglyMeasurable]
|
| 69 |
+
dsimp [F,u,a]
|
| 70 |
+
rw [integral_mul_const,mul_comm]
|
| 71 |
+
|
| 72 |
+
/-- Fubini is justified for every finite-stage pair of actual summands. -/
|
| 73 |
+
theorem sourceSamplingProduct_pair_integrable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 74 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) (n k : ℤ) :
|
| 75 |
+
Integrable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) =>
|
| 76 |
+
sourceSamplingProduct stage r b E G n p.1 p.2*sourceSamplingProduct stage r b E G k p.1 p.2)
|
| 77 |
+
(sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))) :=
|
| 78 |
+
sampling_bounded_product_integrable _ _ _
|
| 79 |
+
(sourceSamplingProduct_measurable stage r b E G hE hG n)
|
| 80 |
+
(sourceSamplingProduct_measurable stage r b E G hE hG k) _
|
| 81 |
+
(fun p => sourceSamplingProduct_bounds stage r b E G n p.1 p.2)
|
| 82 |
+
(fun p => sourceSamplingProduct_bounds stage r b E G k p.1 p.2)
|
| 83 |
+
|
| 84 |
+
theorem sourceSamplingProduct_mixed_integrable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 85 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) (n : ℤ) :
|
| 86 |
+
Integrable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) =>
|
| 87 |
+
sourceSamplingProduct stage r b E G n p.1 p.2*sourceSamplingIdealDensity stage r b E G p.2)
|
| 88 |
+
(sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))) :=
|
| 89 |
+
sampling_bounded_product_integrable _ _ _
|
| 90 |
+
(sourceSamplingProduct_measurable stage r b E G hE hG n)
|
| 91 |
+
((sourceSamplingIdealDensity_measurable stage r b E G hE hG).comp measurable_snd) _
|
| 92 |
+
(fun p => sourceSamplingProduct_bounds stage r b E G n p.1 p.2)
|
| 93 |
+
(fun p => sourceSamplingIdealDensity_bounds stage r b E G hE hG p.2)
|
| 94 |
+
|
| 95 |
+
end
|
| 96 |
+
end FiniteFactor
|
| 97 |
+
|
| 98 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Cube.lean
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.LambdaRectangles
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
abbrev SourceSamplingPair := (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)
|
| 11 |
+
|
| 12 |
+
def sourceSamplingCube : Set SourceSamplingPair :=
|
| 13 |
+
{p | ∀ i, p.1 i ∈ Set.Icc (0 : ℝ) 1 ∧ p.2 i ∈ Set.Icc (0 : ℝ) 1}
|
| 14 |
+
|
| 15 |
+
theorem sourceSamplingCube_measurable : MeasurableSet sourceSamplingCube := by
|
| 16 |
+
exact sourceSamplingRectangle_measurable _ _ (fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)
|
| 17 |
+
|
| 18 |
+
instance sourceSamplingUntrimmed_finite (I : Finset SourceCoordinate) (s : ℕ)
|
| 19 |
+
(θ : SourceCoordinate → ℝ) : IsFiniteMeasure (sourceSamplingUntrimmed I s θ) := by
|
| 20 |
+
constructor
|
| 21 |
+
unfold sourceSamplingUntrimmed
|
| 22 |
+
rw [Measure.smul_apply, smul_eq_mul]
|
| 23 |
+
exact ENNReal.mul_lt_top ENNReal.ofReal_lt_top (measure_lt_top _ _)
|
| 24 |
+
|
| 25 |
+
theorem sourceSamplingSummand_cube (I : Finset SourceCoordinate) (s : ℕ)
|
| 26 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 27 |
+
∀ᵐ p ∂sourceSamplingSummand I s θ n, p ∈ sourceSamplingCube := by
|
| 28 |
+
apply (ae_map_iff (measurable_id.prodMk (coordinateRotate_preserving θ n).measurable).aemeasurable
|
| 29 |
+
sourceSamplingCube_measurable).mpr
|
| 30 |
+
have hh : ∀ᵐ x ∂sourceSamplingWeightedMeasure I s θ n, ∀ i, x i ∈ Set.Ico (0 : ℝ) 1 :=
|
| 31 |
+
ae_iff.mpr (withDensity_absolutelyContinuous _ _ (ae_iff.mp sourceSamplingHaar_cube))
|
| 32 |
+
filter_upwards [hh] with x hx
|
| 33 |
+
intro i
|
| 34 |
+
exact ⟨⟨(hx i).1,(hx i).2.le⟩,Int.fract_nonneg _,(Int.fract_lt_one _).le⟩
|
| 35 |
+
|
| 36 |
+
theorem sourceSamplingUntrimmed_cube (I : Finset SourceCoordinate) (s : ℕ)
|
| 37 |
+
(θ : SourceCoordinate → ℝ) :
|
| 38 |
+
∀ᵐ p ∂sourceSamplingUntrimmed I s θ, p ∈ sourceSamplingCube := by
|
| 39 |
+
apply Measure.ae_smul_measure
|
| 40 |
+
rw [ae_iff, Measure.finsetSum_apply]
|
| 41 |
+
apply Finset.sum_eq_zero
|
| 42 |
+
intro n hn
|
| 43 |
+
exact ae_iff.mp (sourceSamplingSummand_cube I s θ n)
|
| 44 |
+
|
| 45 |
+
theorem sourceSamplingLambda_cube (I : Finset SourceCoordinate) :
|
| 46 |
+
∀ᵐ p ∂sourceSamplingLambda I, p ∈ sourceSamplingCube := by
|
| 47 |
+
apply (ae_map_iff (sourceSamplingLimitMap_measurable I).aemeasurable
|
| 48 |
+
sourceSamplingCube_measurable).mpr
|
| 49 |
+
filter_upwards [ae_restrict_of_ae sourceSamplingPairHaar_cube] with p hp
|
| 50 |
+
intro i
|
| 51 |
+
refine ⟨⟨(hp i).1.1,(hp i).1.2.le⟩,?_⟩
|
| 52 |
+
by_cases hi : i ∈ I
|
| 53 |
+
· simpa [sourceSamplingLimitMap,hi] using And.intro (hp i).2.1 (hp i).2.2.le
|
| 54 |
+
· simpa [sourceSamplingLimitMap,hi] using And.intro (hp i).1.1 (hp i).1.2.le
|
| 55 |
+
|
| 56 |
+
def sourceSamplingEmptyTest : SourceSamplingRationalTest := ⟨∅,fun _ => ((0,1),(0,1))⟩
|
| 57 |
+
|
| 58 |
+
theorem sourceSamplingEmptyTest_rectangle :
|
| 59 |
+
sourceSamplingRectangle (sourceSamplingRationalX sourceSamplingEmptyTest)
|
| 60 |
+
(sourceSamplingRationalY sourceSamplingEmptyTest) = sourceSamplingCube := by
|
| 61 |
+
ext p
|
| 62 |
+
simp [sourceSamplingRectangle,sourceSamplingRationalX,sourceSamplingRationalY,
|
| 63 |
+
sourceSamplingRationalEndpoints,sourceSamplingEmptyTest,sourceSamplingCube]
|
| 64 |
+
|
| 65 |
+
/-- The empty rational test gives actual total-mass convergence. -/
|
| 66 |
+
theorem sourceSampling_mass_limit_event : ∀ᵐ θ ∂sourceAngleLaw,
|
| 67 |
+
∀ I : Finset SourceCoordinate,
|
| 68 |
+
Tendsto (fun s => ((sourceSamplingUntrimmed I s θ) Set.univ).toReal)
|
| 69 |
+
atTop (𝓝 (((sourceSamplingLambda I) Set.univ).toReal)) := by
|
| 70 |
+
filter_upwards [sourceSamplingLambda_rectangle_limit_event] with θ hθ
|
| 71 |
+
intro I
|
| 72 |
+
have h := hθ I sourceSamplingEmptyTest
|
| 73 |
+
rw [sourceSamplingEmptyTest_rectangle] at h
|
| 74 |
+
have hu (s : ℕ) : sourceSamplingUntrimmed I s θ sourceSamplingCube =
|
| 75 |
+
sourceSamplingUntrimmed I s θ Set.univ :=
|
| 76 |
+
measure_congr (by filter_upwards [sourceSamplingUntrimmed_cube I s θ] with p hp; exact propext (iff_true_intro hp))
|
| 77 |
+
have hl : sourceSamplingLambda I sourceSamplingCube = sourceSamplingLambda I Set.univ :=
|
| 78 |
+
measure_congr (by filter_upwards [sourceSamplingLambda_cube I] with p hp; exact propext (iff_true_intro hp))
|
| 79 |
+
simpa only [hu,hl] using h
|
| 80 |
+
|
| 81 |
+
end
|
| 82 |
+
end FiniteFactor
|
| 83 |
+
|
| 84 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/CutoffMass.lean
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.DiagonalIntegral
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- Exact whole-circle first density, including the retained cutoff. -/
|
| 11 |
+
theorem samplingTestedFirstDensity_whole (b : Bool) (h α s : ℝ)
|
| 12 |
+
(hh : 0 < h) (hh1 : h < 1) (hα : 0 < α) (hs : s ∈ Set.Ico (0 : ℝ) 1) :
|
| 13 |
+
samplingTestedFirstDensity b h α (Set.Icc 0 1) (Set.Icc 0 1) s =
|
| 14 |
+
if b then 1-s else if α ≤ samplingDistance s then 1 else 0 := by
|
| 15 |
+
have he : samplingTestedFirstDensity b h α (Set.Icc 0 1) (Set.Icc 0 1) s =
|
| 16 |
+
∫ t, samplingWeight b h α s t ∂unitIntervalMeasure := by
|
| 17 |
+
apply integral_congr_ae
|
| 18 |
+
filter_upwards [] with t
|
| 19 |
+
have hs' : s ∈ Set.Icc (0 : ℝ) 1 := ⟨hs.1,hs.2.le⟩
|
| 20 |
+
have ht' : Int.fract (s+t) ∈ Set.Icc (0 : ℝ) 1 := ⟨Int.fract_nonneg _,(Int.fract_lt_one _).le⟩
|
| 21 |
+
simp only [samplingTestedFirstWeight,hs',ht',and_self,ite_true]
|
| 22 |
+
exact he.trans (samplingWeight_first_integral b h α s hh hh1 hα hs)
|
| 23 |
+
|
| 24 |
+
/-- The exact lost mass of one untested diagonal coordinate is 2α. -/
|
| 25 |
+
theorem sampling_diagonal_whole_mass (h α : ℝ)
|
| 26 |
+
(hh : 0 < h) (hh1 : h < 1) (hα : 0 < α) (hα1 : α ≤ 1/2) :
|
| 27 |
+
(∫ s, samplingTestedFirstDensity false h α (Set.Icc 0 1) (Set.Icc 0 1) s ∂unitIntervalMeasure) = 1-2*α := by
|
| 28 |
+
have he : samplingTestedFirstDensity false h α (Set.Icc 0 1) (Set.Icc 0 1) =ᵐ[unitIntervalMeasure]
|
| 29 |
+
(Set.Icc α (1-α)).indicator (fun _ => (1 : ℝ)) := by
|
| 30 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with s hs
|
| 31 |
+
rw [samplingTestedFirstDensity_whole false h α s hh hh1 hα hs]
|
| 32 |
+
have hc : α ≤ samplingDistance s ↔ s ∈ Set.Icc α (1-α) := by
|
| 33 |
+
simp only [samplingDistance,le_min_iff,Set.mem_Icc]
|
| 34 |
+
constructor <;> intro h <;> constructor <;> linarith [h.1,h.2]
|
| 35 |
+
simp only [Bool.false_eq_true,ite_false,hc,Set.indicator_apply]
|
| 36 |
+
rw [integral_congr_ae he,integral_indicator measurableSet_Icc,integral_const]
|
| 37 |
+
have hsub : Set.Icc α (1-α) ⊆ Set.Ico (0 : ℝ) 1 := by
|
| 38 |
+
intro s hs
|
| 39 |
+
exact ⟨hα.le.trans hs.1,hs.2.trans_lt (by linarith)⟩
|
| 40 |
+
simp only [measureReal_def,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,
|
| 41 |
+
smul_eq_mul,mul_one]
|
| 42 |
+
unfold unitIntervalMeasure
|
| 43 |
+
rw [Measure.restrict_apply measurableSet_Icc,Set.inter_eq_left.mpr hsub,Real.volume_Icc,
|
| 44 |
+
ENNReal.toReal_ofReal (by linarith)]
|
| 45 |
+
ring
|
| 46 |
+
|
| 47 |
+
/-- The total cutoff budget tends to zero despite the growing dimension. -/
|
| 48 |
+
theorem sourceSampling_cutoff_budget_tendsto :
|
| 49 |
+
Tendsto (fun stage => 2*((sourceSamplingPrefix stage).card : ℝ)*sourceSamplingCutoff stage)
|
| 50 |
+
atTop (𝓝 0) := by
|
| 51 |
+
have ht : Tendsto (fun stage => (101/50 : ℝ)*(sourceBlockSize stage : ℝ)⁻¹) atTop (𝓝 0) := by
|
| 52 |
+
simpa using (tendsto_inv_atTop_zero.comp
|
| 53 |
+
(tendsto_natCast_atTop_atTop.comp sourceBlockSize_tendsto)).const_mul (101/50 : ℝ)
|
| 54 |
+
apply squeeze_zero (fun stage => by have := (sourceSampling_parameters stage).2.2; positivity) _ ht
|
| 55 |
+
intro stage
|
| 56 |
+
have hm := sourceBlockSize_pos stage
|
| 57 |
+
calc
|
| 58 |
+
_ ≤ 2*((101/100 : ℝ)*sourceBlockSize stage)*sourceSamplingCutoff stage := by
|
| 59 |
+
exact mul_le_mul_of_nonneg_right
|
| 60 |
+
(mul_le_mul_of_nonneg_left (sourceSamplingPrefix_card_bound stage) (by norm_num))
|
| 61 |
+
(sourceSampling_parameters stage).2.2.le
|
| 62 |
+
_ = (101/50 : ℝ)*(sourceBlockSize stage : ℝ)⁻¹ := by
|
| 63 |
+
simp only [sourceSamplingCutoff,Real.rpow_neg hm.le,Real.rpow_two]
|
| 64 |
+
field_simp
|
| 65 |
+
ring
|
| 66 |
+
|
| 67 |
+
/-- Any subset of untested coordinates retains asymptotically all its mass.
|
| 68 |
+
The estimate uses its actual varying cardinality, bounded by the prefix. -/
|
| 69 |
+
theorem sourceSampling_untested_mass_tendsto (k : ℕ → ℕ)
|
| 70 |
+
(hk : ∀ stage, k stage ≤ (sourceSamplingPrefix stage).card) :
|
| 71 |
+
Tendsto (fun stage => (1-2*sourceSamplingCutoff stage)^(k stage)) atTop (𝓝 1) := by
|
| 72 |
+
have he : ∀ stage, |(1-2*sourceSamplingCutoff stage)^(k stage)-1| ≤
|
| 73 |
+
2*((sourceSamplingPrefix stage).card : ℝ)*sourceSamplingCutoff stage := by
|
| 74 |
+
intro stage
|
| 75 |
+
have hα := (sourceSampling_parameters stage).2.2
|
| 76 |
+
have hα1 := sourceSamplingCutoff_le_half stage
|
| 77 |
+
have hlo : 0 ≤ 1-2*sourceSamplingCutoff stage := by linarith
|
| 78 |
+
have hup : (1-2*sourceSamplingCutoff stage)^(k stage) ≤ 1 := pow_le_one₀ hlo (by linarith)
|
| 79 |
+
have hb := one_add_mul_le_pow (show (-2 : ℝ) ≤ -(2*sourceSamplingCutoff stage) by linarith) (k stage)
|
| 80 |
+
have hk' : (k stage : ℝ) ≤ (sourceSamplingPrefix stage).card := by exact_mod_cast hk stage
|
| 81 |
+
rw [abs_of_nonpos (by linarith)]
|
| 82 |
+
have hm := mul_le_mul_of_nonneg_right hk' (show 0 ≤ 2*sourceSamplingCutoff stage by positivity)
|
| 83 |
+
simp only [mul_neg,← sub_eq_add_neg] at hb
|
| 84 |
+
nlinarith
|
| 85 |
+
apply tendsto_iff_norm_sub_tendsto_zero.mpr
|
| 86 |
+
simp only [Real.norm_eq_abs]
|
| 87 |
+
exact squeeze_zero (fun stage => abs_nonneg _) he sourceSampling_cutoff_budget_tendsto
|
| 88 |
+
|
| 89 |
+
end
|
| 90 |
+
end FiniteFactor
|
| 91 |
+
|
| 92 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/CylinderBasis.lean
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.CylinderSystem
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem rational_Icc_nhds {x : ℝ} {u : Set ℝ} (hu : u ∈ 𝓝 x) :
|
| 11 |
+
∃ a b : ℚ, Set.Icc (a : ℝ) b ∈ 𝓝 x ∧ Set.Icc (a : ℝ) b ⊆ u := by
|
| 12 |
+
obtain ⟨l,r,hlr,hsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hu
|
| 13 |
+
obtain ⟨a,hla,hax⟩ := exists_rat_btwn hlr.1
|
| 14 |
+
obtain ⟨b,hxb,hbr⟩ := exists_rat_btwn hlr.2
|
| 15 |
+
exact ⟨a,b,Icc_mem_nhds hax hxb,fun y hy => hsub ⟨hla.trans_le hy.1,hy.2.trans_lt hbr⟩⟩
|
| 16 |
+
|
| 17 |
+
/-- The finite rational cylinders contain arbitrarily small neighborhoods
|
| 18 |
+
in the full real product, including points outside the unit cube. -/
|
| 19 |
+
theorem sourceSamplingCylinder_basis (u : Set SourceSamplingPair) (hu : IsOpen u)
|
| 20 |
+
(p : SourceSamplingPair) (hp : p ∈ u) :
|
| 21 |
+
∃ s ∈ Set.range sourceSamplingCylinder, s ∈ 𝓝 p ∧ s ⊆ u := by
|
| 22 |
+
obtain ⟨ux,hux,uy,huy,hxy⟩ := mem_nhds_prod_iff.mp (hu.mem_nhds hp)
|
| 23 |
+
rw [nhds_pi,Filter.mem_pi'] at hux huy
|
| 24 |
+
obtain ⟨Kx,tx,htx,hsubx⟩ := hux
|
| 25 |
+
obtain ⟨Ky,ty,hty,hsuby⟩ := huy
|
| 26 |
+
choose ax bx hnx hsx using fun i => rational_Icc_nhds (htx i)
|
| 27 |
+
choose ay by' hny hsy using fun i => rational_Icc_nhds (hty i)
|
| 28 |
+
let T : SourceSamplingRationalTest := ⟨Kx ∪ Ky,fun i => ((ax i,bx i),(ay i,by' i))⟩
|
| 29 |
+
have hTx (i : SourceCoordinate) (hi : i ∈ T.1) :
|
| 30 |
+
sourceSamplingRationalX T i = Set.Icc (ax i : ℝ) (bx i) := by
|
| 31 |
+
simp [sourceSamplingRationalX,sourceSamplingRationalEndpoints,hi,T]
|
| 32 |
+
have hTy (i : SourceCoordinate) (hi : i ∈ T.1) :
|
| 33 |
+
sourceSamplingRationalY T i = Set.Icc (ay i : ℝ) (by' i) := by
|
| 34 |
+
simp [sourceSamplingRationalY,sourceSamplingRationalEndpoints,hi,T]
|
| 35 |
+
refine ⟨sourceSamplingCylinder T,⟨T,rfl⟩,?_,?_⟩
|
| 36 |
+
· have he : sourceSamplingCylinder T = ⋂ i ∈ T.1,
|
| 37 |
+
{q : SourceSamplingPair | q.1 i ∈ sourceSamplingRationalX T i ∧
|
| 38 |
+
q.2 i ∈ sourceSamplingRationalY T i} := by ext q; simp [sourceSamplingCylinder]
|
| 39 |
+
rw [he]
|
| 40 |
+
apply (Filter.biInter_mem (Set.toFinite (T.1 : Set SourceCoordinate))).mpr
|
| 41 |
+
intro i hi
|
| 42 |
+
have hx := ((continuous_apply i).comp continuous_fst).continuousAt (hnx i)
|
| 43 |
+
have hy := ((continuous_apply i).comp continuous_snd).continuousAt (hny i)
|
| 44 |
+
change {q : SourceSamplingPair | q.1 i ∈ Set.Icc (ax i : ℝ) (bx i)} ∈ 𝓝 p at hx
|
| 45 |
+
change {q : SourceSamplingPair | q.2 i ∈ Set.Icc (ay i : ℝ) (by' i)} ∈ 𝓝 p at hy
|
| 46 |
+
filter_upwards [hx,hy] with q hq1 hq2
|
| 47 |
+
exact ⟨by simpa only [hTx i hi] using hq1,by simpa only [hTy i hi] using hq2⟩
|
| 48 |
+
· intro q hq
|
| 49 |
+
apply hxy
|
| 50 |
+
constructor
|
| 51 |
+
· apply hsubx
|
| 52 |
+
intro i hi
|
| 53 |
+
have hmem : i ∈ T.1 := Finset.mem_union_left _ hi
|
| 54 |
+
exact hsx i (by simpa only [hTx i hmem] using (hq i hmem).1)
|
| 55 |
+
· apply hsuby
|
| 56 |
+
intro i hi
|
| 57 |
+
have hmem : i ∈ T.1 := Finset.mem_union_right _ hi
|
| 58 |
+
exact hsy i (by simpa only [hTy i hmem] using (hq i hmem).2)
|
| 59 |
+
|
| 60 |
+
end
|
| 61 |
+
end FiniteFactor
|
| 62 |
+
|
| 63 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/CylinderSystem.lean
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Cube
|
| 2 |
+
import Mathlib.Topology.Instances.Rat
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- Finite cylinders in the full real product: coordinates outside the
|
| 12 |
+
finite support are unrestricted. On the conull cube these are the original
|
| 13 |
+
rational tests. The ambient real product is not asserted to be compact. -/
|
| 14 |
+
def sourceSamplingCylinder (T : SourceSamplingRationalTest) : Set SourceSamplingPair :=
|
| 15 |
+
{p | ∀ i ∈ T.1, p.1 i ∈ sourceSamplingRationalX T i ∧ p.2 i ∈ sourceSamplingRationalY T i}
|
| 16 |
+
|
| 17 |
+
theorem sourceSamplingCylinder_measurable (T : SourceSamplingRationalTest) :
|
| 18 |
+
MeasurableSet (sourceSamplingCylinder T) := by
|
| 19 |
+
simp only [sourceSamplingCylinder,Set.ofPred_forall]
|
| 20 |
+
exact MeasurableSet.iInter (fun i => MeasurableSet.iInter (fun _ =>
|
| 21 |
+
(measurableSet_Icc.preimage ((measurable_pi_apply i).comp measurable_fst)).inter
|
| 22 |
+
(measurableSet_Icc.preimage ((measurable_pi_apply i).comp measurable_snd))))
|
| 23 |
+
|
| 24 |
+
theorem sourceSamplingCylinder_on_cube (T : SourceSamplingRationalTest) (p : SourceSamplingPair)
|
| 25 |
+
(hp : p ∈ sourceSamplingCube) :
|
| 26 |
+
p ∈ sourceSamplingCylinder T ↔
|
| 27 |
+
p ∈ sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T) := by
|
| 28 |
+
constructor
|
| 29 |
+
· intro h i
|
| 30 |
+
by_cases hi : i ∈ T.1
|
| 31 |
+
· exact h i hi
|
| 32 |
+
· simpa [sourceSamplingRationalX,sourceSamplingRationalY,sourceSamplingRationalEndpoints,hi]
|
| 33 |
+
using hp i
|
| 34 |
+
· intro h i _
|
| 35 |
+
exact h i
|
| 36 |
+
|
| 37 |
+
def sourceSamplingTestMeet (T U : SourceSamplingRationalTest) : SourceSamplingRationalTest :=
|
| 38 |
+
⟨T.1 ∪ U.1,fun i =>
|
| 39 |
+
if i.1 ∈ T.1 then
|
| 40 |
+
if i.1 ∈ U.1 then
|
| 41 |
+
((max (sourceSamplingRationalEndpoints T i).1.1 (sourceSamplingRationalEndpoints U i).1.1,
|
| 42 |
+
min (sourceSamplingRationalEndpoints T i).1.2 (sourceSamplingRationalEndpoints U i).1.2),
|
| 43 |
+
(max (sourceSamplingRationalEndpoints T i).2.1 (sourceSamplingRationalEndpoints U i).2.1,
|
| 44 |
+
min (sourceSamplingRationalEndpoints T i).2.2 (sourceSamplingRationalEndpoints U i).2.2))
|
| 45 |
+
else sourceSamplingRationalEndpoints T i
|
| 46 |
+
else sourceSamplingRationalEndpoints U i⟩
|
| 47 |
+
|
| 48 |
+
theorem sourceSamplingCylinder_inter (T U : SourceSamplingRationalTest) :
|
| 49 |
+
sourceSamplingCylinder (sourceSamplingTestMeet T U) =
|
| 50 |
+
sourceSamplingCylinder T ∩ sourceSamplingCylinder U := by
|
| 51 |
+
have hcoord (p : SourceSamplingPair) (i : SourceCoordinate) :
|
| 52 |
+
(i ∈ T.1 ∪ U.1 → p.1 i ∈ sourceSamplingRationalX (sourceSamplingTestMeet T U) i ∧
|
| 53 |
+
p.2 i ∈ sourceSamplingRationalY (sourceSamplingTestMeet T U) i) ↔
|
| 54 |
+
(i ∈ T.1 → p.1 i ∈ sourceSamplingRationalX T i ∧ p.2 i ∈ sourceSamplingRationalY T i) ∧
|
| 55 |
+
(i ∈ U.1 → p.1 i ∈ sourceSamplingRationalX U i ∧ p.2 i ∈ sourceSamplingRationalY U i) := by
|
| 56 |
+
by_cases ht : i ∈ T.1 <;> by_cases hu : i ∈ U.1 <;>
|
| 57 |
+
simp [sourceSamplingRationalX,sourceSamplingRationalY,sourceSamplingRationalEndpoints,
|
| 58 |
+
sourceSamplingTestMeet,ht,hu,Set.mem_Icc]
|
| 59 |
+
tauto
|
| 60 |
+
ext p
|
| 61 |
+
change (∀ i, i ∈ T.1 ∪ U.1 → _) ↔ (∀ i, i ∈ T.1 → _) ∧ (∀ i, i ∈ U.1 → _)
|
| 62 |
+
constructor
|
| 63 |
+
· intro h
|
| 64 |
+
exact ⟨fun i => ((hcoord p i).mp (h i)).1,fun i => ((hcoord p i).mp (h i)).2⟩
|
| 65 |
+
· rintro ⟨hT,hU⟩ i
|
| 66 |
+
exact (hcoord p i).mpr ⟨hT i,hU i⟩
|
| 67 |
+
|
| 68 |
+
theorem sourceSamplingCylinder_piSystem : IsPiSystem (Set.range sourceSamplingCylinder) := by
|
| 69 |
+
rintro _ ⟨T,rfl⟩ _ ⟨U,rfl⟩ _
|
| 70 |
+
exact ⟨sourceSamplingTestMeet T U,sourceSamplingCylinder_inter T U⟩
|
| 71 |
+
|
| 72 |
+
end
|
| 73 |
+
end FiniteFactor
|
| 74 |
+
|
| 75 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalContribution.lean
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.SelfSummability
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
noncomputable section
|
| 8 |
+
|
| 9 |
+
/-- The self-pair part of the empirical squared norm, with its actual P^-2 weight. -/
|
| 10 |
+
def sourceSamplingDiagonalContribution (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 11 |
+
(E G : SourceCoordinate → Set ℝ) (θ : SourceCoordinate → ℝ) : ℝ :=
|
| 12 |
+
(∑ n ∈ sourceSamplingPowers stage,
|
| 13 |
+
∫ x, sourceSamplingProduct stage r b E G n θ x ^ 2
|
| 14 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) / ((sourceSamplingPowers stage).card : ℝ)^2
|
| 15 |
+
|
| 16 |
+
theorem sourceSamplingDiagonalContribution_nonneg (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 17 |
+
(E G : SourceCoordinate → Set ℝ) (θ : SourceCoordinate → ℝ) :
|
| 18 |
+
0 ≤ sourceSamplingDiagonalContribution stage r b E G θ :=
|
| 19 |
+
div_nonneg (sum_nonneg (fun _ _ => integral_nonneg (fun _ => sq_nonneg _))) (sq_nonneg _)
|
| 20 |
+
|
| 21 |
+
theorem sourceSamplingProduct_square_integrable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 22 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) (n : ℤ) :
|
| 23 |
+
Integrable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) =>
|
| 24 |
+
sourceSamplingProduct stage r b E G n p.1 p.2 ^ 2)
|
| 25 |
+
(sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))) :=
|
| 26 |
+
sampling_square_integrable _ _
|
| 27 |
+
((max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card)
|
| 28 |
+
(sourceSamplingProduct_measurable stage r b E G hE hG n)
|
| 29 |
+
(fun p => sourceSamplingProduct_bounds stage r b E G n p.1 p.2)
|
| 30 |
+
|
| 31 |
+
theorem sourceSamplingDiagonalContribution_integrable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 32 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 33 |
+
Integrable (sourceSamplingDiagonalContribution stage r b E G) sourceAngleLaw := by
|
| 34 |
+
apply Integrable.div_const
|
| 35 |
+
exact integrable_finsetSum _ (fun n _ =>
|
| 36 |
+
(sourceSamplingProduct_square_integrable stage r b E G hE hG n).integral_prod_left)
|
| 37 |
+
|
| 38 |
+
/-- The diagonal contribution's expectation is bounded by the proved
|
| 39 |
+
summable budget; the finite set is the actual deterministic sample set. -/
|
| 40 |
+
theorem sourceSamplingDiagonalContribution_expectation (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 41 |
+
(r : Bool) (b : SourceCoordinate → Bool) (E G : SourceCoordinate → Set ℝ)
|
| 42 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 43 |
+
(∫ θ, sourceSamplingDiagonalContribution stage r b E G θ ∂sourceAngleLaw) ≤ sourceSamplingSelfBudget stage := by
|
| 44 |
+
have hP : (0 : ℝ) < (sourceSamplingPowers stage).card :=
|
| 45 |
+
(Real.rpow_pos_of_pos (sourceBlockSize_pos stage) _).trans_le (sourceSamplingPowers_spec stage hs).2.1
|
| 46 |
+
unfold sourceSamplingDiagonalContribution
|
| 47 |
+
rw [integral_div,integral_finsetSum _ (fun n _ =>
|
| 48 |
+
(sourceSamplingProduct_square_integrable stage r b E G hE hG n).integral_prod_left)]
|
| 49 |
+
have hsum := Finset.sum_le_sum (fun n hn => sourceSamplingProduct_self_moment stage hs r b E G hE hG n hn)
|
| 50 |
+
simp only [Finset.sum_const,nsmul_eq_mul] at hsum
|
| 51 |
+
calc
|
| 52 |
+
_ ≤ ((sourceSamplingPowers stage).card : ℝ)*
|
| 53 |
+
(2+8*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ))^(sourceSamplingPrefix stage).card /
|
| 54 |
+
((sourceSamplingPowers stage).card : ℝ)^2 := div_le_div_of_nonneg_right hsum (sq_nonneg _)
|
| 55 |
+
_ = _ := by unfold sourceSamplingSelfBudget; field_simp
|
| 56 |
+
|
| 57 |
+
/-- Actual self-pair expectations are summable across the constructed stages. -/
|
| 58 |
+
theorem sourceSamplingDiagonalContribution_summable_integral (r : Bool) (b : SourceCoordinate → Bool)
|
| 59 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 60 |
+
Summable (fun stage => ∫ θ, sourceSamplingDiagonalContribution stage r b E G θ ∂sourceAngleLaw) := by
|
| 61 |
+
apply sourceSamplingSelfBudget_summable.of_norm_bounded_eventually_nat
|
| 62 |
+
filter_upwards [sourceBlockSize_tendsto.eventually (eventually_ge_atTop 200000)] with stage hs
|
| 63 |
+
rw [Real.norm_eq_abs,abs_of_nonneg (integral_nonneg (sourceSamplingDiagonalContribution_nonneg stage r b E G))]
|
| 64 |
+
exact sourceSamplingDiagonalContribution_expectation stage hs r b E G hE hG
|
| 65 |
+
|
| 66 |
+
end
|
| 67 |
+
end FiniteFactor
|
| 68 |
+
|
| 69 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalEvent.lean
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.DiagonalContribution
|
| 2 |
+
import Mathlib.MeasureTheory.Integral.Lebesgue.Markov
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter
|
| 8 |
+
open scoped ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- Tonelli converts summable expectations of nonnegative functions into
|
| 12 |
+
pointwise summability on a conull event. -/
|
| 13 |
+
theorem sampling_ae_summable_of_integrals {Ω : Type*} [MeasurableSpace Ω]
|
| 14 |
+
(μ : Measure Ω) (f : ℕ → Ω → ℝ) (hm : ∀ n, Measurable (f n))
|
| 15 |
+
(hi : ∀ n, Integrable (f n) μ) (hn : ∀ n x, 0 ≤ f n x)
|
| 16 |
+
(hs : Summable (fun n => ∫ x, f n x ∂μ)) :
|
| 17 |
+
∀ᵐ x ∂μ, Summable (fun n => f n x) := by
|
| 18 |
+
have he (n : ℕ) : (∫⁻ x, ENNReal.ofReal (f n x) ∂μ) = ENNReal.ofReal (∫ x, f n x ∂μ) :=
|
| 19 |
+
(ofReal_integral_eq_lintegral_ofReal (hi n) (Eventually.of_forall (hn n))).symm
|
| 20 |
+
have hfin : (∫⁻ x, ∑' n, ENNReal.ofReal (f n x) ∂μ) ≠ ∞ := by
|
| 21 |
+
rw [lintegral_tsum (fun n => (hm n).ennreal_ofReal.aemeasurable)]
|
| 22 |
+
simp_rw [he]
|
| 23 |
+
exact hs.tsum_ofReal_ne_top
|
| 24 |
+
have hm' : Measurable (fun x => ∑' n, ENNReal.ofReal (f n x)) :=
|
| 25 |
+
Measurable.tsum (fun n => (hm n).ennreal_ofReal)
|
| 26 |
+
filter_upwards [ae_lt_top hm' hfin] with x hx
|
| 27 |
+
exact (ENNReal.summable_toReal hx.ne).congr (fun n => ENNReal.toReal_ofReal (hn n x))
|
| 28 |
+
|
| 29 |
+
theorem sourceSamplingDiagonalContribution_measurable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 30 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 31 |
+
Measurable (sourceSamplingDiagonalContribution stage r b E G) := by
|
| 32 |
+
apply Measurable.div_const
|
| 33 |
+
apply Finset.measurable_sum
|
| 34 |
+
intro n _
|
| 35 |
+
exact ((sourceSamplingProduct_measurable stage r b E G hE hG n).pow_const 2).stronglyMeasurable.integral_prod_right.measurable
|
| 36 |
+
|
| 37 |
+
/-- A genuine conull conclusion for the actual diagonal contribution.
|
| 38 |
+
This does not assert convergence of the full empirical sampling error. -/
|
| 39 |
+
theorem sourceSamplingDiagonalContribution_ae (r : Bool) (b : SourceCoordinate → Bool)
|
| 40 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 41 |
+
∀ᵐ θ ∂sourceAngleLaw,
|
| 42 |
+
Summable (fun stage => sourceSamplingDiagonalContribution stage r b E G θ) ∧
|
| 43 |
+
Tendsto (fun stage => sourceSamplingDiagonalContribution stage r b E G θ) atTop (𝓝 0) := by
|
| 44 |
+
have ha := sampling_ae_summable_of_integrals sourceAngleLaw
|
| 45 |
+
(fun stage θ => sourceSamplingDiagonalContribution stage r b E G θ)
|
| 46 |
+
(fun stage => sourceSamplingDiagonalContribution_measurable stage r b E G hE hG)
|
| 47 |
+
(fun stage => sourceSamplingDiagonalContribution_integrable stage r b E G hE hG)
|
| 48 |
+
(fun stage θ => sourceSamplingDiagonalContribution_nonneg stage r b E G θ)
|
| 49 |
+
(sourceSamplingDiagonalContribution_summable_integral r b E G hE hG)
|
| 50 |
+
exact ha.mono (fun θ hθ => ⟨hθ,hθ.tendsto_atTop_zero⟩)
|
| 51 |
+
|
| 52 |
+
/-- One conull event handles every member of any countable family of source
|
| 53 |
+
tests, orientations and triangular-coordinate choices for the diagonal term. -/
|
| 54 |
+
theorem sourceSamplingDiagonalContribution_countable_event {ι : Type*} [Countable ι]
|
| 55 |
+
(r : ι → Bool) (b : ι → SourceCoordinate → Bool) (E G : ι → SourceCoordinate → Set ℝ)
|
| 56 |
+
(hE : ∀ j i, MeasurableSet (E j i)) (hG : ∀ j i, MeasurableSet (G j i)) :
|
| 57 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ j,
|
| 58 |
+
Summable (fun stage => sourceSamplingDiagonalContribution stage (r j) (b j) (E j) (G j) θ) ∧
|
| 59 |
+
Tendsto (fun stage => sourceSamplingDiagonalContribution stage (r j) (b j) (E j) (G j) θ) atTop (𝓝 0) :=
|
| 60 |
+
(ae_all_iff).mpr (fun j => sourceSamplingDiagonalContribution_ae (r j) (b j) (E j) (G j) (hE j) (hG j))
|
| 61 |
+
|
| 62 |
+
end
|
| 63 |
+
end FiniteFactor
|
| 64 |
+
|
| 65 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalIntegral.lean
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.DiagonalLimit
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- The actual one-coordinate diagonal model converges to uniform diagonal
|
| 11 |
+
mass on every measurable first test and closed-interval second test. -/
|
| 12 |
+
theorem sourceSampling_diagonal_integral_tendsto (E : Set ℝ) (hE : MeasurableSet E) (a c : ℝ) :
|
| 13 |
+
Tendsto (fun stage => ∫ s,
|
| 14 |
+
samplingTestedFirstDensity false (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 15 |
+
E (Set.Icc a c) s ∂unitIntervalMeasure)
|
| 16 |
+
atTop (𝓝 ((unitIntervalMeasure (E ∩ Set.Icc a c)).toReal)) := by
|
| 17 |
+
have : NullSingletonClass unitIntervalMeasure := by unfold unitIntervalMeasure; infer_instance
|
| 18 |
+
let f : ℝ → ℝ := (E ∩ Set.Icc a c).indicator (fun _ => 1)
|
| 19 |
+
have hlim : ∀ᵐ s ∂unitIntervalMeasure,
|
| 20 |
+
Tendsto (fun stage => samplingTestedFirstDensity false
|
| 21 |
+
(sourceSamplingWidth stage) (sourceSamplingCutoff stage) E (Set.Icc a c) s)
|
| 22 |
+
atTop (𝓝 (f s)) := by
|
| 23 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico,unitIntervalMeasure.ae_ne 0,
|
| 24 |
+
unitIntervalMeasure.ae_ne a,unitIntervalMeasure.ae_ne c] with s hs hs0 hsa hsc
|
| 25 |
+
have hh := sourceSampling_diagonal_eventually s a c E ⟨lt_of_le_of_ne hs.1 (Ne.symm hs0),hs.2⟩ hsa hsc
|
| 26 |
+
have he : (fun stage => samplingTestedFirstDensity false (sourceSamplingWidth stage)
|
| 27 |
+
(sourceSamplingCutoff stage) E (Set.Icc a c) s) =ᶠ[atTop] (fun _ => f s) := by
|
| 28 |
+
filter_upwards [hh] with stage hstage
|
| 29 |
+
simpa only [f,Set.indicator_apply,Set.mem_inter_iff] using hstage
|
| 30 |
+
exact tendsto_const_nhds.congr' he.symm
|
| 31 |
+
have hm (stage : ℕ) : AEStronglyMeasurable
|
| 32 |
+
(samplingTestedFirstDensity false (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 33 |
+
E (Set.Icc a c)) unitIntervalMeasure := (samplingTestedFirstDensity_measurable false
|
| 34 |
+
(sourceSamplingWidth stage) (sourceSamplingCutoff stage) E (Set.Icc a c) hE measurableSet_Icc).aestronglyMeasurable
|
| 35 |
+
have hb (stage : ℕ) : ∀ᵐ s ∂unitIntervalMeasure,
|
| 36 |
+
‖samplingTestedFirstDensity false (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 37 |
+
E (Set.Icc a c) s‖ ≤ (1 : ℝ) := by
|
| 38 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with s hs
|
| 39 |
+
have hp := sourceSampling_parameters stage
|
| 40 |
+
have h := samplingTestedFirstDensity_bounds false _ _ E (Set.Icc a c)
|
| 41 |
+
hp.1 hp.2.1 hp.2.2 hE measurableSet_Icc s hs
|
| 42 |
+
rw [Real.norm_eq_abs,abs_of_nonneg h.1]
|
| 43 |
+
exact h.2
|
| 44 |
+
have ht := tendsto_integral_of_dominated_convergence (fun _ : ℝ => (1 : ℝ)) hm (integrable_const 1) hb hlim
|
| 45 |
+
have hf : (∫ s, f s ∂unitIntervalMeasure) = (unitIntervalMeasure (E ∩ Set.Icc a c)).toReal := by
|
| 46 |
+
rw [integral_indicator (hE.inter measurableSet_Icc)]
|
| 47 |
+
simp [measureReal_def]
|
| 48 |
+
rwa [hf] at ht
|
| 49 |
+
|
| 50 |
+
/-- Triangular tested factors are independent of the sampling width and cutoff. -/
|
| 51 |
+
theorem samplingTestedFirstDensity_triangular_parameters (h α h' α' s : ℝ) (E G : Set ℝ) :
|
| 52 |
+
samplingTestedFirstDensity true h α E G s = samplingTestedFirstDensity true h' α' E G s := by
|
| 53 |
+
unfold samplingTestedFirstDensity samplingTestedFirstWeight samplingWeight
|
| 54 |
+
simp only [ite_true]
|
| 55 |
+
|
| 56 |
+
end
|
| 57 |
+
end FiniteFactor
|
| 58 |
+
|
| 59 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/DiagonalLimit.lean
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.RationalTests
|
| 2 |
+
import Mathlib.MeasureTheory.Integral.DominatedConvergence
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
theorem sourceSamplingWidth_tendsto : Tendsto sourceSamplingWidth atTop (𝓝 0) := by
|
| 12 |
+
have hh := (tendsto_rpow_neg_atTop (by norm_num : (0 : ℝ) < 3/5)).comp
|
| 13 |
+
(tendsto_natCast_atTop_atTop.comp sourceBlockSize_tendsto)
|
| 14 |
+
convert hh using 1
|
| 15 |
+
funext stage
|
| 16 |
+
simp only [sourceSamplingWidth,Function.comp_apply]
|
| 17 |
+
congr 1; norm_num
|
| 18 |
+
|
| 19 |
+
theorem sourceSamplingCutoff_tendsto : Tendsto sourceSamplingCutoff atTop (𝓝 0) := by
|
| 20 |
+
have hh := (tendsto_rpow_neg_atTop (by norm_num : (0 : ℝ) < 2)).comp
|
| 21 |
+
(tendsto_natCast_atTop_atTop.comp sourceBlockSize_tendsto)
|
| 22 |
+
exact hh
|
| 23 |
+
|
| 24 |
+
theorem sampling_interval_small_displacement (s a c t : ℝ)
|
| 25 |
+
(_ha : s ≠ a) (hc : s ≠ c) (ht : 0 ≤ t)
|
| 26 |
+
(hta : t < |s-a|) (htc : t < |s-c|) :
|
| 27 |
+
s+t ∈ Set.Icc a c ↔ s ∈ Set.Icc a c := by
|
| 28 |
+
have hleft : a ≤ s+t ↔ a ≤ s := by
|
| 29 |
+
by_cases h : a ≤ s
|
| 30 |
+
· constructor
|
| 31 |
+
· exact fun _ => h
|
| 32 |
+
· intro _; linarith
|
| 33 |
+
· rw [abs_of_neg (by linarith : s-a < 0)] at hta
|
| 34 |
+
constructor <;> intro hh <;> linarith
|
| 35 |
+
have hright : s+t ≤ c ↔ s ≤ c := by
|
| 36 |
+
by_cases h : s ≤ c
|
| 37 |
+
· have hsc : s < c := lt_of_le_of_ne h hc
|
| 38 |
+
rw [abs_of_neg (by linarith : s-c < 0)] at htc
|
| 39 |
+
constructor <;> intro hh <;> linarith
|
| 40 |
+
· constructor <;> intro hh <;> linarith
|
| 41 |
+
exact and_congr hleft hright
|
| 42 |
+
|
| 43 |
+
/-- Away from the interval endpoints, a sufficiently short retained diagonal
|
| 44 |
+
step has exactly the same interval test as its starting coordinate. -/
|
| 45 |
+
theorem samplingTestedFirstDensity_diagonal_exact (h α s a c : ℝ) (E : Set ℝ)
|
| 46 |
+
(hh : 0 < h) (hh1 : h < 1) (hα : 0 < α)
|
| 47 |
+
(hs : s ∈ Set.Ico (0 : ℝ) 1) (hcut : α ≤ samplingDistance s)
|
| 48 |
+
(ha : s ≠ a) (hc : s ≠ c) (hha : h < |s-a|) (hhc : h < |s-c|) :
|
| 49 |
+
samplingTestedFirstDensity false h α E (Set.Icc a c) s =
|
| 50 |
+
if s ∈ E ∧ s ∈ Set.Icc a c then 1 else 0 := by
|
| 51 |
+
have he (t : ℝ) : samplingTestedFirstWeight false h α E (Set.Icc a c) s t =
|
| 52 |
+
if s ∈ E ∧ s ∈ Set.Icc a c then samplingWeight false h α s t else 0 := by
|
| 53 |
+
by_cases hw : samplingWeight false h α s t = 0
|
| 54 |
+
· simp [samplingTestedFirstWeight,hw]
|
| 55 |
+
· have ho := samplingWeight_orders false h α s t hh hh1 hα hs hw
|
| 56 |
+
have hsp : 0 < t ∧ t < h*samplingDistance s := by
|
| 57 |
+
unfold samplingWeight at hw
|
| 58 |
+
simp only [Bool.false_eq_true,ite_false] at hw
|
| 59 |
+
split_ifs at hw with hcond
|
| 60 |
+
· exact hcond.2
|
| 61 |
+
· exact False.elim (hw rfl)
|
| 62 |
+
have hd : samplingDistance s ≤ 1 := (min_le_right s (1-s)).trans (by linarith [hs.1])
|
| 63 |
+
have hth : t < h := hsp.2.trans_le (by nlinarith)
|
| 64 |
+
have hmem := sampling_interval_small_displacement s a c t ha hc hsp.1.le
|
| 65 |
+
(hth.trans hha) (hth.trans hhc)
|
| 66 |
+
simp only [samplingTestedFirstWeight,ho.1,hmem]
|
| 67 |
+
unfold samplingTestedFirstDensity
|
| 68 |
+
simp_rw [he]
|
| 69 |
+
by_cases htest : s ∈ E ∧ s ∈ Set.Icc a c
|
| 70 |
+
· simp only [ite_eq_left htest]
|
| 71 |
+
simpa only [Bool.false_eq_true,ite_false,ite_eq_left hcut] using
|
| 72 |
+
samplingWeight_first_integral false h α s hh hh1 hα hs
|
| 73 |
+
· simp only [ite_eq_right htest,integral_zero]
|
| 74 |
+
|
| 75 |
+
/-- At each interior starting point away from the two tested endpoints, the
|
| 76 |
+
actual diagonal density eventually equals the uniform diagonal test. -/
|
| 77 |
+
theorem sourceSampling_diagonal_eventually (s a c : ℝ) (E : Set ℝ)
|
| 78 |
+
(hs : s ∈ Set.Ioo (0 : ℝ) 1) (ha : s ≠ a) (hc : s ≠ c) :
|
| 79 |
+
∀ᶠ stage in atTop,
|
| 80 |
+
samplingTestedFirstDensity false (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 81 |
+
E (Set.Icc a c) s = if s ∈ E ∧ s ∈ Set.Icc a c then 1 else 0 := by
|
| 82 |
+
have hd : 0 < samplingDistance s := lt_min hs.1 (by linarith [hs.2])
|
| 83 |
+
have hcut := sourceSamplingCutoff_tendsto.eventually (gt_mem_nhds hd)
|
| 84 |
+
have hwa := sourceSamplingWidth_tendsto.eventually (gt_mem_nhds (abs_pos.mpr (sub_ne_zero.mpr ha)))
|
| 85 |
+
have hwc := sourceSamplingWidth_tendsto.eventually (gt_mem_nhds (abs_pos.mpr (sub_ne_zero.mpr hc)))
|
| 86 |
+
filter_upwards [hcut,hwa,hwc] with stage hcut hwa hwc
|
| 87 |
+
have hp := sourceSampling_parameters stage
|
| 88 |
+
exact samplingTestedFirstDensity_diagonal_exact _ _ s a c E hp.1 hp.2.1 hp.2.2
|
| 89 |
+
⟨hs.1.le,hs.2⟩ hcut.le ha hc hwa hwc
|
| 90 |
+
|
| 91 |
+
end
|
| 92 |
+
end FiniteFactor
|
| 93 |
+
|
| 94 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Discrepancy.lean
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.Rectangle
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Fourier
|
| 3 |
+
import OAI.Analysis.FiniteFactor.Sampling.Periodization
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Finset Filter
|
| 9 |
+
open scoped ENNReal Topology
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
/-- Every constructed power is long enough for density at most two on
|
| 13 |
+
every coordinate in the sampling prefix. -/
|
| 14 |
+
theorem sourceSampling_phase_length (s : ℕ) (hs : 200000 ≤ sourceBlockSize s)
|
| 15 |
+
(i : SourceCoordinate) (hi : i.1 ≤ s) (n : ℤ) (hn : n ∈ sourceSamplingPowers s) :
|
| 16 |
+
1 ≤ (n : ℝ)*sourceAngleUnit i := by
|
| 17 |
+
have hm : (200000 : ℝ) ≤ sourceBlockSize s := by exact_mod_cast hs
|
| 18 |
+
have hm0 := sourceBlockSize_pos s
|
| 19 |
+
have hspec := (sourceSamplingPowers_spec s hs).1 n hn
|
| 20 |
+
have hQ : (sourceBlockSize s : ℝ)^3 ≤ samplingQ (sourceBlockSize s) := by
|
| 21 |
+
unfold samplingQ
|
| 22 |
+
rw [← Real.rpow_natCast]
|
| 23 |
+
exact Real.rpow_le_rpow_of_exponent_le (by linarith) (by norm_num; linarith)
|
| 24 |
+
have hN : (sourceBlockSize i.1 : ℝ)*(sourceStageState i.1).K ≤ (sourceBlockSize s : ℝ)^2 := by
|
| 25 |
+
have hh : (sourceBlockSize i.1 : ℝ)*(sourceStageState i.1).K ≤
|
| 26 |
+
(sourceBlockSize s : ℝ)*(sourceStageState s).K := by exact_mod_cast sourceFrequencyScale_monotone hi
|
| 27 |
+
have hK : ((sourceStageState s).K : ℝ) ≤ sourceBlockSize s := by exact_mod_cast (sourceStage s).m_ge_K
|
| 28 |
+
nlinarith
|
| 29 |
+
have hnp : (sourceBlockSize i.1 : ℝ)*(sourceStageState i.1).K ≤ (n : ℝ) := by
|
| 30 |
+
nlinarith [hspec.1,sq_nonneg (sourceBlockSize s : ℝ)]
|
| 31 |
+
unfold sourceAngleUnit
|
| 32 |
+
rw [mul_one_div,le_div_iff₀ (mul_pos (sourceBlockSize_pos i.1) (sourceCutoff_pos i.1)),one_mul]
|
| 33 |
+
exact hnp
|
| 34 |
+
|
| 35 |
+
theorem sourceSampling_phase_domination (s : ℕ) (hs : 200000 ≤ sourceBlockSize s)
|
| 36 |
+
(i : SourceCoordinate) (hi : i.1 ≤ s) (n : ℤ) (hn : n ∈ sourceSamplingPowers s) :
|
| 37 |
+
sourceAngleLaw.map (fun θ => Int.fract ((n : ℝ)*θ i)) ≤
|
| 38 |
+
(2 : ℝ≥0∞) • unitIntervalMeasure := by
|
| 39 |
+
have hp : Measurable (fun t : ℝ => Int.fract ((n : ℝ)*t)) :=
|
| 40 |
+
sourceFract_measurable.comp (measurable_const.mul measurable_id)
|
| 41 |
+
have he : sourceAngleLaw.map (fun θ => Int.fract ((n : ℝ)*θ i)) =
|
| 42 |
+
(sourceAngleMarginal i).map (fun t => Int.fract ((n : ℝ)*t)) := by
|
| 43 |
+
rw [← sourceAngleLaw_coordinate i,Measure.map_map hp (measurable_pi_apply i)]
|
| 44 |
+
rfl
|
| 45 |
+
rw [he]
|
| 46 |
+
have hnp : (0 : ℝ) < n := by exact_mod_cast ((sourceSamplingPowers_spec s hs).1 n hn).2.2
|
| 47 |
+
have hh := (sourceAngle_phase_sandwich i (n : ℝ) hnp).2
|
| 48 |
+
apply hh.trans
|
| 49 |
+
have hlen := sourceSampling_phase_length s hs i hi n hn
|
| 50 |
+
have hiR : 1/(n*sourceAngleUnit i) ≤ (1 : ℝ) := by
|
| 51 |
+
simpa using one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) hlen
|
| 52 |
+
have heps : ENNReal.ofReal (1+1/(n*sourceAngleUnit i)) ≤ (2 : ℝ≥0∞) := by
|
| 53 |
+
exact_mod_cast ENNReal.ofReal_le_ofReal (show 1+1/(n*sourceAngleUnit i) ≤ (2 : ℝ) by linarith)
|
| 54 |
+
gcongr
|
| 55 |
+
|
| 56 |
+
theorem samplingCharacter_pair_expression (v w : ℤ) (a b : ℝ) :
|
| 57 |
+
samplingCharacter v a*samplingCharacter w b =
|
| 58 |
+
Complex.exp (2*Real.pi*Complex.I*((v : ℂ)*(a : ℂ)+(w : ℂ)*(b : ℂ))) := by
|
| 59 |
+
unfold samplingCharacter
|
| 60 |
+
rw [← Complex.exp_add]
|
| 61 |
+
congr 1
|
| 62 |
+
ring
|
| 63 |
+
|
| 64 |
+
/-- Rectangle discrepancy for the actual pair law of the deterministic
|
| 65 |
+
selected powers, with every probabilistic hypothesis discharged. -/
|
| 66 |
+
theorem sourceSampling_rectangle_bound (s : ℕ) (hs : 200000 ≤ sourceBlockSize s)
|
| 67 |
+
(i : SourceCoordinate) (hi : i.1 ≤ s) (n n' : ℤ)
|
| 68 |
+
(hn : n ∈ sourceSamplingPowers s) (hn' : n' ∈ sourceSamplingPowers s) (hne : n ≠ n')
|
| 69 |
+
(a b a' b' : ℝ) :
|
| 70 |
+
|(sourceAngleLaw {θ | Int.fract ((n : ℝ)*θ i) ∈ Set.Icc a b ∧
|
| 71 |
+
Int.fract ((n' : ℝ)*θ i) ∈ Set.Icc a' b'}).toReal -
|
| 72 |
+
(unitIntervalMeasure (Set.Icc a b)).toReal*(unitIntervalMeasure (Set.Icc a' b')).toReal| ≤
|
| 73 |
+
26*(sourceBlockSize s : ℝ)^(-80 : ℝ) := by
|
| 74 |
+
let m := sourceBlockSize s
|
| 75 |
+
have hm0 : (0 : ℝ) < m := sourceBlockSize_pos s
|
| 76 |
+
have hm1 : (1 : ℝ) ≤ m := by
|
| 77 |
+
have hm : (200000 : ℝ) ≤ m := by exact_mod_cast hs
|
| 78 |
+
linarith
|
| 79 |
+
let δ : ℝ := (m : ℝ)^(-80 : ℝ)
|
| 80 |
+
let ε : ℝ := Real.pi⁻¹*(m : ℝ)^(-1000 : ℝ)
|
| 81 |
+
have hH : 0 < samplingH m := pow_pos (by exact_mod_cast hm0) 300
|
| 82 |
+
have hphase (n : ℤ) : Measurable (fun θ : SourceCoordinate → ℝ => Int.fract ((n : ℝ)*θ i)) :=
|
| 83 |
+
sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i))
|
| 84 |
+
have hh := sampling_rectangle_discrepancy sourceAngleLaw _ _ (hphase n) (hphase n')
|
| 85 |
+
(sourceSampling_phase_domination s hs i hi n hn) (sourceSampling_phase_domination s hs i hi n' hn')
|
| 86 |
+
(samplingH m) hH a b a' b' δ ε (by dsimp [δ]; positivity) (by dsimp [ε]; positivity)
|
| 87 |
+
(fun v w hv hw hne' => by
|
| 88 |
+
simp_rw [samplingCharacter_pair_expression]
|
| 89 |
+
exact sourceSampling_pair_fourier_bound s hs i hi n n' hn hn' hne v w hv.le hw.le hne')
|
| 90 |
+
apply hh.trans
|
| 91 |
+
have htail : 1/(2*(samplingH m : ℝ)*δ^2) = (1/2 : ℝ)*(m : ℝ)^(-140 : ℝ) := by
|
| 92 |
+
dsimp [samplingH,δ]
|
| 93 |
+
norm_num [Real.rpow_neg,Real.rpow_ofNat,hm0.le]
|
| 94 |
+
field_simp
|
| 95 |
+
have hfour : (samplingH m : ℝ)^2*ε = Real.pi⁻¹*(m : ℝ)^(-400 : ℝ) := by
|
| 96 |
+
dsimp [samplingH,ε]
|
| 97 |
+
norm_num [Real.rpow_neg,Real.rpow_ofNat,hm0.le]
|
| 98 |
+
field_simp
|
| 99 |
+
rw [htail,hfour]
|
| 100 |
+
have h140 : (m : ℝ)^(-140 : ℝ) ≤ δ := Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num)
|
| 101 |
+
have h400 : (m : ℝ)^(-400 : ℝ) ≤ δ := Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num)
|
| 102 |
+
have hpi : Real.pi⁻¹ ≤ 1 := by simpa using one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) (show 1 ≤ Real.pi by linarith [Real.two_le_pi])
|
| 103 |
+
have hδ : 0 ≤ δ := by dsimp [δ]; positivity
|
| 104 |
+
have hp0 : 0 ≤ (m : ℝ)^(-400 : ℝ) := by positivity
|
| 105 |
+
change 24*δ+1/2*(m : ℝ)^(-140 : ℝ)+Real.pi⁻¹*(m : ℝ)^(-400 : ℝ) ≤ 26*δ
|
| 106 |
+
nlinarith
|
| 107 |
+
|
| 108 |
+
end
|
| 109 |
+
end FiniteFactor
|
| 110 |
+
|
| 111 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/EmpiricalL2.lean
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.ErrorEvent
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem sourceSamplingEmpiricalDensity_measurable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 11 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 12 |
+
(θ : SourceCoordinate → ℝ) : Measurable (sourceSamplingEmpiricalDensity stage r b E G θ) :=
|
| 13 |
+
(Finset.measurable_sum _ (fun n _ => (sourceSamplingProduct_measurable stage r b E G hE hG n).comp
|
| 14 |
+
(measurable_const.prodMk measurable_id))).div_const _
|
| 15 |
+
|
| 16 |
+
/-- Every empirical density is bounded at its finite stage, including stages
|
| 17 |
+
whose selected set is empty. No asymptotic assumption is used here. -/
|
| 18 |
+
theorem sourceSamplingEmpiricalDensity_bounds (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 19 |
+
(E G : SourceCoordinate → Set ℝ) (θ x : SourceCoordinate → ℝ) :
|
| 20 |
+
0 ≤ sourceSamplingEmpiricalDensity stage r b E G θ x ∧
|
| 21 |
+
sourceSamplingEmpiricalDensity stage r b E G θ x ≤
|
| 22 |
+
(max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card := by
|
| 23 |
+
let C := (max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card
|
| 24 |
+
have hC : 0 ≤ C := pow_nonneg ((by norm_num : (0 : ℝ) ≤ 1).trans (le_max_left _ _)) _
|
| 25 |
+
have hb := sourceSamplingProduct_bounds stage r b E G
|
| 26 |
+
have hn : 0 ≤ sourceSamplingEmpiricalDensity stage r b E G θ x :=
|
| 27 |
+
div_nonneg (sum_nonneg (fun n _ => (hb n θ x).1)) (by positivity)
|
| 28 |
+
refine ⟨hn,?_⟩
|
| 29 |
+
by_cases hS : (sourceSamplingPowers stage).Nonempty
|
| 30 |
+
· have hP : (0 : ℝ) < (sourceSamplingPowers stage).card := by exact_mod_cast hS.card_pos
|
| 31 |
+
apply (div_le_iff₀ hP).mpr
|
| 32 |
+
calc
|
| 33 |
+
_ ≤ ∑ _n ∈ sourceSamplingPowers stage, C := sum_le_sum (fun n _ => (hb n θ x).2)
|
| 34 |
+
_ = _ := by simp [C]; ring
|
| 35 |
+
· have he : sourceSamplingPowers stage = ∅ := Finset.not_nonempty_iff_eq_empty.mp hS
|
| 36 |
+
simp [sourceSamplingEmpiricalDensity,he]
|
| 37 |
+
|
| 38 |
+
/-- The empirical densities, not only the ideal products, belong to L2. -/
|
| 39 |
+
theorem sourceSamplingEmpiricalDensity_memLp (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 40 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 41 |
+
(θ : SourceCoordinate → ℝ) :
|
| 42 |
+
MemLp (sourceSamplingEmpiricalDensity stage r b E G θ) 2
|
| 43 |
+
(Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) := by
|
| 44 |
+
apply MemLp.of_bound (sourceSamplingEmpiricalDensity_measurable stage r b E G hE hG θ).aestronglyMeasurable
|
| 45 |
+
((max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card)
|
| 46 |
+
apply Eventually.of_forall
|
| 47 |
+
intro x
|
| 48 |
+
rw [Real.norm_eq_abs,abs_of_nonneg (sourceSamplingEmpiricalDensity_bounds stage r b E G θ x).1]
|
| 49 |
+
exact (sourceSamplingEmpiricalDensity_bounds stage r b E G θ x).2
|
| 50 |
+
|
| 51 |
+
/-- The full error and the ideal L2 bound control the actual empirical square. -/
|
| 52 |
+
theorem sourceSamplingEmpiricalDensity_square_le (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 53 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 54 |
+
(θ : SourceCoordinate → ℝ) :
|
| 55 |
+
(∫ x, sourceSamplingEmpiricalDensity stage r b E G θ x^2
|
| 56 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) ≤
|
| 57 |
+
2*sourceSamplingSquaredError stage r b E G θ+2*Real.exp 5 := by
|
| 58 |
+
let μ := Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)
|
| 59 |
+
let z := sourceSamplingEmpiricalDensity stage r b E G θ
|
| 60 |
+
let g := sourceSamplingIdealDensity stage r b E G
|
| 61 |
+
let C := (max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card
|
| 62 |
+
have hz := sourceSamplingEmpiricalDensity_measurable stage r b E G hE hG θ
|
| 63 |
+
have hg := sourceSamplingIdealDensity_measurable stage r b E G hE hG
|
| 64 |
+
have hzb := sourceSamplingEmpiricalDensity_bounds stage r b E G θ
|
| 65 |
+
have hgb := sourceSamplingIdealDensity_bounds stage r b E G hE hG
|
| 66 |
+
have hzi : Integrable (fun x => z x^2) μ := sampling_square_integrable μ z C hz hzb
|
| 67 |
+
have hgi : Integrable (fun x => g x^2) μ := sampling_square_integrable μ g C hg hgb
|
| 68 |
+
have hei : Integrable (fun x => (z x-g x)^2) μ := by
|
| 69 |
+
apply sampling_integrable_bounded μ _ ((hz.sub hg).pow_const 2) (C^2)
|
| 70 |
+
intro x
|
| 71 |
+
rw [abs_of_nonneg (sq_nonneg _)]
|
| 72 |
+
have hz' : 0 ≤ z x ∧ z x ≤ C := hzb x
|
| 73 |
+
have hg' : 0 ≤ g x ∧ g x ≤ C := hgb x
|
| 74 |
+
change (z x-g x)^2 ≤ C^2
|
| 75 |
+
nlinarith [mul_nonneg (show 0 ≤ C-(z x-g x) by linarith) (show 0 ≤ C+(z x-g x) by linarith)]
|
| 76 |
+
have hi := integral_mono_ae hzi ((hei.const_mul 2).add (hgi.const_mul 2))
|
| 77 |
+
(Eventually.of_forall (fun x => show z x^2 ≤ 2*(z x-g x)^2+2*g x^2 by nlinarith [sq_nonneg (z x-2*g x)]))
|
| 78 |
+
simp only [Pi.add_apply] at hi
|
| 79 |
+
rw [integral_add (hei.const_mul 2) (hgi.const_mul 2),integral_const_mul,integral_const_mul] at hi
|
| 80 |
+
exact hi.trans (by
|
| 81 |
+
have hb := sourceSamplingIdealDensity_uniform_square stage r b E G hE hG
|
| 82 |
+
change (∫ x, g x^2 ∂μ) ≤ Real.exp 5 at hb
|
| 83 |
+
change _ ≤ 2*(∫ x, (z x-g x)^2 ∂μ)+2*Real.exp 5
|
| 84 |
+
linarith)
|
| 85 |
+
|
| 86 |
+
end
|
| 87 |
+
end FiniteFactor
|
| 88 |
+
|
| 89 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Error.lean
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.ProductError
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.DiagonalEvent
|
| 3 |
+
import OAI.Analysis.FiniteFactor.Sampling.Cancellation
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Filter Finset
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
def sourceSamplingEmpiricalDensity (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 12 |
+
(E G : SourceCoordinate → Set ℝ) (θ x : SourceCoordinate → ℝ) : ℝ :=
|
| 13 |
+
(∑ n ∈ sourceSamplingPowers stage, sourceSamplingProduct stage r b E G n θ x)/
|
| 14 |
+
((sourceSamplingPowers stage).card : ℝ)
|
| 15 |
+
|
| 16 |
+
/-- The full sampling error, including every distinct-pair and mixed term. -/
|
| 17 |
+
def sourceSamplingSquaredError (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 18 |
+
(E G : SourceCoordinate → Set ℝ) (θ : SourceCoordinate → ℝ) : ℝ :=
|
| 19 |
+
∫ x, (sourceSamplingEmpiricalDensity stage r b E G θ x-sourceSamplingIdealDensity stage r b E G x)^2
|
| 20 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)
|
| 21 |
+
|
| 22 |
+
theorem sourceSampling_error_joint_integrable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 23 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 24 |
+
Integrable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) =>
|
| 25 |
+
(sourceSamplingEmpiricalDensity stage r b E G p.1 p.2-sourceSamplingIdealDensity stage r b E G p.2)^2)
|
| 26 |
+
(sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))) := by
|
| 27 |
+
apply sampling_average_square_integrable
|
| 28 |
+
· intro n _ k _
|
| 29 |
+
exact sourceSamplingProduct_pair_integrable stage r b E G hE hG n k
|
| 30 |
+
· intro n _
|
| 31 |
+
exact sourceSamplingProduct_mixed_integrable stage r b E G hE hG n
|
| 32 |
+
· have hm : Measurable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) => sourceSamplingIdealDensity stage r b E G p.2) :=
|
| 33 |
+
(sourceSamplingIdealDensity_measurable stage r b E G hE hG).comp measurable_snd
|
| 34 |
+
have hi := sampling_bounded_product_integrable
|
| 35 |
+
(sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)))
|
| 36 |
+
(fun p => sourceSamplingIdealDensity stage r b E G p.2) (fun p => sourceSamplingIdealDensity stage r b E G p.2)
|
| 37 |
+
hm hm _ (fun p => sourceSamplingIdealDensity_bounds stage r b E G hE hG p.2)
|
| 38 |
+
(fun p => sourceSamplingIdealDensity_bounds stage r b E G hE hG p.2)
|
| 39 |
+
simpa only [pow_two] using hi
|
| 40 |
+
|
| 41 |
+
theorem sourceSamplingSquaredError_integrable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 42 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 43 |
+
Integrable (sourceSamplingSquaredError stage r b E G) sourceAngleLaw :=
|
| 44 |
+
(sourceSampling_error_joint_integrable stage r b E G hE hG).integral_prod_left
|
| 45 |
+
|
| 46 |
+
theorem sourceSamplingSquaredError_measurable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 47 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 48 |
+
Measurable (sourceSamplingSquaredError stage r b E G) := by
|
| 49 |
+
have hm : Measurable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) =>
|
| 50 |
+
sourceSamplingEmpiricalDensity stage r b E G p.1 p.2) :=
|
| 51 |
+
(Finset.measurable_sum _ (fun n _ => sourceSamplingProduct_measurable stage r b E G hE hG n)).div_const _
|
| 52 |
+
exact ((hm.sub ((sourceSamplingIdealDensity_measurable stage r b E G hE hG).comp measurable_snd)).pow_const 2).stronglyMeasurable.integral_prod_right.measurable
|
| 53 |
+
|
| 54 |
+
theorem sourceSamplingSquaredError_nonneg (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 55 |
+
(E G : SourceCoordinate → Set ℝ) (θ : SourceCoordinate → ℝ) :
|
| 56 |
+
0 ≤ sourceSamplingSquaredError stage r b E G θ := integral_nonneg (fun _ => sq_nonneg _)
|
| 57 |
+
|
| 58 |
+
/-- Full expected squared sampling error with the source's actual sample set,
|
| 59 |
+
weights and ideal density. All distinct-pair and mixed assumptions are proved. -/
|
| 60 |
+
theorem sourceSamplingSquaredError_expectation (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 61 |
+
(r : Bool) (b : SourceCoordinate → Bool) (a c a' c' : SourceCoordinate → ℝ) :
|
| 62 |
+
(∫ θ, sourceSamplingSquaredError stage r b (fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) θ ∂sourceAngleLaw) ≤
|
| 63 |
+
(∫ θ, sourceSamplingDiagonalContribution stage r b (fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) θ ∂sourceAngleLaw)+
|
| 64 |
+
3*sourceSamplingCorrelationBudget stage := by
|
| 65 |
+
let E := fun i => Set.Icc (a i) (c i)
|
| 66 |
+
let G := fun i => Set.Icc (a' i) (c' i)
|
| 67 |
+
have hE : ∀ i, MeasurableSet (E i) := fun _ => measurableSet_Icc
|
| 68 |
+
have hG : ∀ i, MeasurableSet (G i) := fun _ => measurableSet_Icc
|
| 69 |
+
let μ := sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))
|
| 70 |
+
let S := sourceSamplingPowers stage
|
| 71 |
+
let f (n : ℤ) (p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)) := sourceSamplingProduct stage r b E G n p.1 p.2
|
| 72 |
+
let g (p : (SourceCoordinate → ℝ) × (SourceCoordinate → ��)) := sourceSamplingIdealDensity stage r b E G p.2
|
| 73 |
+
have hpair (n k : ℤ) : Integrable (fun p => f n p*f k p) μ :=
|
| 74 |
+
sourceSamplingProduct_pair_integrable stage r b E G hE hG n k
|
| 75 |
+
have hmix (n : ℤ) : Integrable (fun p => f n p*g p) μ :=
|
| 76 |
+
sourceSamplingProduct_mixed_integrable stage r b E G hE hG n
|
| 77 |
+
have hg : Integrable (fun p => g p^2) μ := by
|
| 78 |
+
have hm : Measurable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) => sourceSamplingIdealDensity stage r b E G p.2) :=
|
| 79 |
+
(sourceSamplingIdealDensity_measurable stage r b E G hE hG).comp measurable_snd
|
| 80 |
+
simpa only [pow_two] using sampling_bounded_product_integrable μ g g hm hm _
|
| 81 |
+
(fun p => sourceSamplingIdealDensity_bounds stage r b E G hE hG p.2)
|
| 82 |
+
(fun p => sourceSamplingIdealDensity_bounds stage r b E G hE hG p.2)
|
| 83 |
+
have hA : (∫ p, g p^2 ∂μ) = ∫ x, sourceSamplingIdealDensity stage r b E G x^2
|
| 84 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) := by
|
| 85 |
+
rw [integral_prod _ hg]
|
| 86 |
+
simp [g]
|
| 87 |
+
have hB (n k : ℤ) : (∫ p, f n p*f k p ∂μ) =
|
| 88 |
+
∫ θ, ∫ x, sourceSamplingProduct stage r b E G n θ x*sourceSamplingProduct stage r b E G k θ x
|
| 89 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) ∂sourceAngleLaw := integral_prod _ (hpair n k)
|
| 90 |
+
have hM (n : ℤ) : (∫ p, f n p*g p ∂μ) =
|
| 91 |
+
∫ θ, ∫ x, sourceSamplingProduct stage r b E G n θ x*sourceSamplingIdealDensity stage r b E G x
|
| 92 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) ∂sourceAngleLaw := integral_prod _ (hmix n)
|
| 93 |
+
have hS : S.Nonempty := by
|
| 94 |
+
have hP : (0 : ℝ) < (sourceSamplingPowers stage).card :=
|
| 95 |
+
(Real.rpow_pos_of_pos (sourceBlockSize_pos stage) _).trans_le (sourceSamplingPowers_spec stage hs).2.1
|
| 96 |
+
exact Finset.card_pos.mp (by exact_mod_cast hP)
|
| 97 |
+
have hc := sampling_finite_cancellation S hS
|
| 98 |
+
(fun n k => ∫ p, f n p*f k p ∂μ) (fun n => ∫ p, f n p*g p ∂μ)
|
| 99 |
+
(∫ p, g p^2 ∂μ) (sourceSamplingCorrelationBudget stage)
|
| 100 |
+
(integral_nonneg (fun _ => sq_nonneg _)) (by unfold sourceSamplingCorrelationBudget; positivity)
|
| 101 |
+
(fun n hn k hk hne => by rw [hB,hA]; exact sourceSamplingProduct_pair_error stage hs r b a c a' c' n k hn hk hne)
|
| 102 |
+
(fun n hn => by rw [hM,hA]; exact sourceSamplingProduct_mixed_error stage hs r b E G hE hG n hn)
|
| 103 |
+
have hex := sampling_average_square_expansion μ S f g (fun n _ k _ => hpair n k) (fun n _ => hmix n) hg
|
| 104 |
+
rw [← hex] at hc
|
| 105 |
+
have hErr : (∫ p, ((∑ n ∈ S, f n p)/(S.card : ℝ)-g p)^2 ∂μ) =
|
| 106 |
+
∫ θ, sourceSamplingSquaredError stage r b E G θ ∂sourceAngleLaw :=
|
| 107 |
+
integral_prod _ (sourceSampling_error_joint_integrable stage r b E G hE hG)
|
| 108 |
+
have hDiag : (∑ n ∈ S, ∫ p, f n p*f n p ∂μ)/(S.card : ℝ)^2 =
|
| 109 |
+
∫ θ, sourceSamplingDiagonalContribution stage r b E G θ ∂sourceAngleLaw := by
|
| 110 |
+
unfold sourceSamplingDiagonalContribution
|
| 111 |
+
rw [integral_div,integral_finsetSum _ (fun n _ =>
|
| 112 |
+
(sourceSamplingProduct_square_integrable stage r b E G hE hG n).integral_prod_left)]
|
| 113 |
+
simp only [hB,pow_two,f,S]
|
| 114 |
+
rw [hErr,hDiag] at hc
|
| 115 |
+
exact hc
|
| 116 |
+
|
| 117 |
+
end
|
| 118 |
+
end FiniteFactor
|
| 119 |
+
|
| 120 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/ErrorEvent.lean
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Error
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter
|
| 7 |
+
open scoped Classical Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- The distinct and mixed error budget is summable along the actual stages. -/
|
| 11 |
+
theorem sourceSamplingCorrelationBudget_summable : Summable sourceSamplingCorrelationBudget := by
|
| 12 |
+
apply (sourceSampling_inverse_square_summable.mul_left (208*Real.exp 135)).of_nonneg_of_le
|
| 13 |
+
· intro stage; unfold sourceSamplingCorrelationBudget; positivity
|
| 14 |
+
intro stage
|
| 15 |
+
let m : ℝ := sourceBlockSize stage
|
| 16 |
+
have hm : 0 < m := sourceBlockSize_pos stage
|
| 17 |
+
have hm1 : 1 ≤ m := by
|
| 18 |
+
have hh : 100 ≤ sourceBlockSize stage := (sourceStage stage).m_ge_100
|
| 19 |
+
dsimp [m]
|
| 20 |
+
exact_mod_cast (show 1 ≤ sourceBlockSize stage by omega)
|
| 21 |
+
have hd : ((sourceSamplingPrefix stage).card : ℝ) ≤ 2*m :=
|
| 22 |
+
(sourceSamplingPrefix_card_bound stage).trans (by dsimp [m]; nlinarith)
|
| 23 |
+
have he : m*m^(-74 : ℝ) = m^(-73 : ℝ) := by
|
| 24 |
+
conv_lhs => lhs; rw [← Real.rpow_one m]
|
| 25 |
+
rw [← Real.rpow_add hm]; norm_num
|
| 26 |
+
calc
|
| 27 |
+
sourceSamplingCorrelationBudget stage ≤ (2*m)*(104*m^(-74 : ℝ))*Real.exp 135 := by
|
| 28 |
+
unfold sourceSamplingCorrelationBudget
|
| 29 |
+
exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hd (by positivity)) (by positivity)
|
| 30 |
+
_ = (208*Real.exp 135)*m^(-73 : ℝ) := by rw [← he]; ring
|
| 31 |
+
_ ≤ (208*Real.exp 135)*m^(-2 : ℝ) := mul_le_mul_of_nonneg_left
|
| 32 |
+
(Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num)) (by positivity)
|
| 33 |
+
|
| 34 |
+
/-- Summable expectations for the full empirical sampling error. -/
|
| 35 |
+
theorem sourceSamplingSquaredError_summable_integral (r : Bool) (b : SourceCoordinate → Bool)
|
| 36 |
+
(a c a' c' : SourceCoordinate → ℝ) :
|
| 37 |
+
Summable (fun stage => ∫ θ, sourceSamplingSquaredError stage r b
|
| 38 |
+
(fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) θ ∂sourceAngleLaw) := by
|
| 39 |
+
have hd := sourceSamplingDiagonalContribution_summable_integral r b
|
| 40 |
+
(fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i))
|
| 41 |
+
(fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)
|
| 42 |
+
have hb := hd.add (sourceSamplingCorrelationBudget_summable.mul_left 3)
|
| 43 |
+
apply hb.of_norm_bounded_eventually_nat
|
| 44 |
+
filter_upwards [sourceBlockSize_tendsto.eventually (eventually_ge_atTop 200000)] with stage hs
|
| 45 |
+
rw [Real.norm_eq_abs,abs_of_nonneg (integral_nonneg (sourceSamplingSquaredError_nonneg stage r b _ _))]
|
| 46 |
+
exact sourceSamplingSquaredError_expectation stage hs r b a c a' c'
|
| 47 |
+
|
| 48 |
+
/-- The full squared sampling error is summable and converges to zero on a
|
| 49 |
+
conull set of actual source angles. This is not just the self-pair event. -/
|
| 50 |
+
theorem sourceSamplingSquaredError_ae (r : Bool) (b : SourceCoordinate → Bool)
|
| 51 |
+
(a c a' c' : SourceCoordinate → ℝ) :
|
| 52 |
+
∀ᵐ θ ∂sourceAngleLaw,
|
| 53 |
+
Summable (fun stage => sourceSamplingSquaredError stage r b
|
| 54 |
+
(fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) θ) ∧
|
| 55 |
+
Tendsto (fun stage => sourceSamplingSquaredError stage r b
|
| 56 |
+
(fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) θ) atTop (𝓝 0) := by
|
| 57 |
+
have he := sampling_ae_summable_of_integrals sourceAngleLaw
|
| 58 |
+
(fun stage θ => sourceSamplingSquaredError stage r b (fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) θ)
|
| 59 |
+
(fun stage => sourceSamplingSquaredError_measurable stage r b _ _ (fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc))
|
| 60 |
+
(fun stage => sourceSamplingSquaredError_integrable stage r b _ _ (fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc))
|
| 61 |
+
(fun stage θ => sourceSamplingSquaredError_nonneg stage r b _ _ θ)
|
| 62 |
+
(sourceSamplingSquaredError_summable_integral r b a c a' c')
|
| 63 |
+
exact he.mono (fun θ hθ => ⟨hθ,hθ.tendsto_atTop_zero⟩)
|
| 64 |
+
|
| 65 |
+
/-- One source-angle event handles any countable family of interval tests,
|
| 66 |
+
orientations and triangular-coordinate choices for the full error. -/
|
| 67 |
+
theorem sourceSamplingSquaredError_countable_event {ι : Type*} [Countable ι]
|
| 68 |
+
(r : ι → Bool) (b : ι → SourceCoordinate → Bool)
|
| 69 |
+
(a c a' c' : ι → SourceCoordinate → ℝ) :
|
| 70 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ j,
|
| 71 |
+
Summable (fun stage => sourceSamplingSquaredError stage (r j) (b j)
|
| 72 |
+
(fun i => Set.Icc (a j i) (c j i)) (fun i => Set.Icc (a' j i) (c' j i)) θ) ∧
|
| 73 |
+
Tendsto (fun stage => sourceSamplingSquaredError stage (r j) (b j)
|
| 74 |
+
(fun i => Set.Icc (a j i) (c j i)) (fun i => Set.Icc (a' j i) (c' j i)) θ) atTop (𝓝 0) :=
|
| 75 |
+
ae_all_iff.mpr (fun j => sourceSamplingSquaredError_ae (r j) (b j) (a j) (c j) (a' j) (c' j))
|
| 76 |
+
|
| 77 |
+
end
|
| 78 |
+
end FiniteFactor
|
| 79 |
+
|
| 80 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/FirstCorrelation.lean
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.FirstDiscrepancy
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter
|
| 7 |
+
open scoped Classical
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem sourceSampling_first_height_bound (stage : ℕ) (b : Bool) (s : ℝ) :
|
| 11 |
+
0 ≤ samplingFirstHeight b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) s ∧
|
| 12 |
+
samplingFirstHeight b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) s ≤
|
| 13 |
+
(sourceBlockSize stage : ℝ)^(13/5 : ℝ) := by
|
| 14 |
+
have hp := sourceSampling_parameters stage
|
| 15 |
+
have hm := sourceBlockSize_pos stage
|
| 16 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by
|
| 17 |
+
have hh : (100 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_100
|
| 18 |
+
linarith
|
| 19 |
+
cases b
|
| 20 |
+
· unfold samplingFirstHeight
|
| 21 |
+
simp only [Bool.false_eq_true,ite_false]
|
| 22 |
+
split_ifs with hc
|
| 23 |
+
· have hd : 0 < samplingDistance s := hp.2.2.trans_le hc
|
| 24 |
+
refine ⟨one_div_nonneg.mpr (mul_nonneg hp.1.le hd.le),?_⟩
|
| 25 |
+
calc
|
| 26 |
+
_ ≤ 1/(sourceSamplingWidth stage*sourceSamplingCutoff stage) :=
|
| 27 |
+
one_div_le_one_div_of_le (mul_pos hp.1 hp.2.2) (mul_le_mul_of_nonneg_left hc hp.1.le)
|
| 28 |
+
_ = _ := by
|
| 29 |
+
unfold sourceSamplingWidth sourceSamplingCutoff
|
| 30 |
+
rw [← Real.rpow_add hm]
|
| 31 |
+
norm_num
|
| 32 |
+
rw [Real.rpow_neg hm.le,inv_inv]
|
| 33 |
+
· exact ⟨le_rfl,by positivity⟩
|
| 34 |
+
· exact ⟨by norm_num [samplingFirstHeight],Real.one_le_rpow hm1 (by norm_num)⟩
|
| 35 |
+
|
| 36 |
+
/-- Explicit first-oriented pair correlation error for every prefix coordinate,
|
| 37 |
+
every rectangle endpoint and both source coordinate types. -/
|
| 38 |
+
theorem sourceSampling_first_pair_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 39 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n n' : ℤ)
|
| 40 |
+
(hn : n ∈ sourceSamplingPowers stage) (hn' : n' ∈ sourceSamplingPowers stage) (hne : n ≠ n')
|
| 41 |
+
(b : Bool) (E : Set ℝ) (a c s : ℝ) (hsx : s ∈ Set.Ico (0 : ℝ) 1) :
|
| 42 |
+
|(∫ θ, samplingTestedFirstWeight b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 43 |
+
E (Set.Icc a c) s (Int.fract ((n : ℝ)*θ i)) *
|
| 44 |
+
samplingTestedFirstWeight b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 45 |
+
E (Set.Icc a c) s (Int.fract ((n' : ℝ)*θ i)) ∂sourceAngleLaw) -
|
| 46 |
+
samplingTestedFirstDensity b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E (Set.Icc a c) s ^ 2| ≤
|
| 47 |
+
26*(sourceBlockSize stage : ℝ)^(-74 : ℝ) := by
|
| 48 |
+
let m : ℝ := sourceBlockSize stage
|
| 49 |
+
let C := if s ∈ E then samplingFirstHeight b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) s else 0
|
| 50 |
+
have hm : 0 < m := sourceBlockSize_pos stage
|
| 51 |
+
have hm1 : 1 ≤ m := by
|
| 52 |
+
have hh : (200000 : ℝ) ≤ (sourceBlockSize stage : ℝ) := by exact_mod_cast hs
|
| 53 |
+
dsimp [m]
|
| 54 |
+
linarith
|
| 55 |
+
have hheight := sourceSampling_first_height_bound stage b s
|
| 56 |
+
have hC : 0 ≤ C ∧ C ≤ m^(3 : ℝ) := by
|
| 57 |
+
dsimp [C]
|
| 58 |
+
split_ifs
|
| 59 |
+
· exact ⟨hheight.1,hheight.2.trans (Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num))⟩
|
| 60 |
+
· exact ⟨le_rfl,by positivity⟩
|
| 61 |
+
have hC2 : C^2 ≤ m^(6 : ℝ) := by
|
| 62 |
+
calc
|
| 63 |
+
C^2 ≤ (m^(3 : ℝ))^2 := by nlinarith [hC.1,hC.2,Real.rpow_nonneg hm.le (3 : ℝ)]
|
| 64 |
+
_ = _ := by rw [← Real.rpow_natCast,← Real.rpow_mul hm.le]; norm_num
|
| 65 |
+
apply (sourceSampling_first_pair_bound stage hs i hi n n' hn hn' hne b E a c s hsx).trans
|
| 66 |
+
change (26*m^(-80 : ℝ))*C^2 ≤ 26*m^(-74 : ℝ)
|
| 67 |
+
calc
|
| 68 |
+
_ ≤ (26*m^(-80 : ℝ))*m^(6 : ℝ) := mul_le_mul_of_nonneg_left hC2 (by positivity)
|
| 69 |
+
_ = _ := by rw [mul_assoc,← Real.rpow_add hm]; norm_num
|
| 70 |
+
|
| 71 |
+
end
|
| 72 |
+
end FiniteFactor
|
| 73 |
+
|
| 74 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/FirstMarginal.lean
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.UniformEvent
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Measures
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- The actual first marginal is the verified empirical interval-test density.
|
| 12 |
+
The whole-circle tests [0,1] are valid on the Haar cube. -/
|
| 13 |
+
theorem sourceSamplingUntrimmed_first_density (I : Finset SourceCoordinate) (stage : ℕ)
|
| 14 |
+
(θ : SourceCoordinate → ℝ) :
|
| 15 |
+
(sourceSamplingUntrimmed I stage θ).map Prod.fst =
|
| 16 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 17 |
+
(sourceSamplingEmpiricalDensity stage false (fun i => decide (i ∈ I))
|
| 18 |
+
(fun _ => Set.Icc 0 1) (fun _ => Set.Icc 0 1) θ x)) := by
|
| 19 |
+
let S := sourceSamplingPowers stage
|
| 20 |
+
let c : ℝ≥0∞ := ENNReal.ofReal (1/((sourceSamplingPowers stage).card : ℝ))
|
| 21 |
+
let w (n : ℤ) := sourceSamplingWeight I stage θ n
|
| 22 |
+
have hrep : (fun x => ENNReal.ofReal (sourceSamplingEmpiricalDensity stage false (fun i => decide (i ∈ I))
|
| 23 |
+
(fun _ => Set.Icc 0 1) (fun _ => Set.Icc 0 1) θ x)) =ᵐ[sourceSamplingHaar]
|
| 24 |
+
(fun x => c*(∑ n ∈ S, ENNReal.ofReal (w n x))) := by
|
| 25 |
+
filter_upwards [sourceSamplingHaar_cube] with x hx
|
| 26 |
+
have hw (n : ℤ) : sourceSamplingProduct stage false (fun i => decide (i ∈ I))
|
| 27 |
+
(fun _ => Set.Icc 0 1) (fun _ => Set.Icc 0 1) n θ x = w n x := by
|
| 28 |
+
apply Finset.prod_congr rfl
|
| 29 |
+
intro i _
|
| 30 |
+
have hx' : x i ∈ Set.Icc (0 : ℝ) 1 := ⟨(hx i).1,(hx i).2.le⟩
|
| 31 |
+
have hy : Int.fract (x i+Int.fract ((n : ℝ)*θ i)) ∈ Set.Icc (0 : ℝ) 1 :=
|
| 32 |
+
⟨Int.fract_nonneg _,(Int.fract_lt_one _).le⟩
|
| 33 |
+
simp only [samplingOrientedWeight, Bool.false_eq_true, ite_false, samplingTestedFirstWeight,
|
| 34 |
+
hx', hy, and_self, ite_true]
|
| 35 |
+
simp only [sourceSamplingEmpiricalDensity,hw]
|
| 36 |
+
rw [div_eq_mul_inv,mul_comm,← one_div,
|
| 37 |
+
ENNReal.ofReal_mul (by positivity),ENNReal.ofReal_sum_of_nonneg (fun n _ => (sourceSamplingWeight_bounds I stage θ n x).1)]
|
| 38 |
+
rw [withDensity_congr_ae hrep]
|
| 39 |
+
ext A hA
|
| 40 |
+
rw [Measure.map_apply measurable_fst hA]
|
| 41 |
+
unfold sourceSamplingUntrimmed
|
| 42 |
+
rw [Measure.smul_apply,Measure.finsetSum_apply,withDensity_apply _ hA]
|
| 43 |
+
have hterm (n : ℤ) : sourceSamplingSummand I stage θ n (Prod.fst ⁻¹' A) =
|
| 44 |
+
∫⁻ x in A, ENNReal.ofReal (w n x) ∂sourceSamplingHaar := by
|
| 45 |
+
rw [← Measure.map_apply measurable_fst hA,sourceSamplingSummand_first_marginal]
|
| 46 |
+
exact withDensity_apply _ hA
|
| 47 |
+
simp only [hterm,smul_eq_mul]
|
| 48 |
+
rw [lintegral_const_mul' c _ ENNReal.ofReal_ne_top]
|
| 49 |
+
congr 1
|
| 50 |
+
exact (lintegral_finsetSum S (fun n _ =>
|
| 51 |
+
(sourceSamplingWeight_measurable I stage θ n).ennreal_ofReal)).symm
|
| 52 |
+
|
| 53 |
+
/-- Uniform L2 densities for the actual untrimmed first marginals. -/
|
| 54 |
+
theorem sourceSamplingUntrimmed_first_L2 (I : Finset SourceCoordinate) :
|
| 55 |
+
∀ᵐ θ ∂sourceAngleLaw, ∃ C : ℝ, ∀ stage,
|
| 56 |
+
∃ f : (SourceCoordinate → ℝ) → ℝ,
|
| 57 |
+
(sourceSamplingUntrimmed I stage θ).map Prod.fst = sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (f x)) ∧
|
| 58 |
+
MemLp f 2 sourceSamplingHaar ∧ (∫ x, f x^2 ∂sourceSamplingHaar) ≤ C := by
|
| 59 |
+
filter_upwards [sourceSamplingEmpiricalDensity_uniform false (fun i => decide (i ∈ I))
|
| 60 |
+
(fun _ => 0) (fun _ => 1) (fun _ => 0) (fun _ => 1)] with θ hθ
|
| 61 |
+
obtain ⟨C,hC⟩ := hθ
|
| 62 |
+
refine ⟨C,fun stage => ⟨_,sourceSamplingUntrimmed_first_density I stage θ,(hC stage).1,(hC stage).2⟩⟩
|
| 63 |
+
|
| 64 |
+
end
|
| 65 |
+
end FiniteFactor
|
| 66 |
+
|
| 67 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Fourier.lean
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.Fourier
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Powers
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem sourceBlockSize_monotone : Monotone sourceBlockSize := by
|
| 11 |
+
apply monotone_nat_of_le_succ
|
| 12 |
+
intro s
|
| 13 |
+
have hp := (sourceStage (s+1)).previous_size
|
| 14 |
+
have hd : (sourceBlockSize s : ℝ) ≤ (sourceStageState (s+1)).d := by
|
| 15 |
+
change (sourceBlockSize s : ℝ) ≤ ((sourceStageState s).d+(sourceStage s).m : ℕ)
|
| 16 |
+
change ((sourceStage s).m : ℝ) ≤ ((sourceStageState s).d+(sourceStage s).m : ℕ)
|
| 17 |
+
push_cast
|
| 18 |
+
exact le_add_of_nonneg_left (Nat.cast_nonneg _)
|
| 19 |
+
have hm : (sourceBlockSize s : ℝ) ≤ sourceBlockSize (s+1) := by
|
| 20 |
+
change ((sourceStageState (s+1)).d : ℝ) ≤ (sourceBlockSize (s+1) : ℝ)/100 at hp
|
| 21 |
+
have := Nat.cast_nonneg (α := ℝ) (sourceBlockSize (s+1))
|
| 22 |
+
linarith
|
| 23 |
+
exact_mod_cast hm
|
| 24 |
+
|
| 25 |
+
theorem sourceFrequencyScale_monotone :
|
| 26 |
+
Monotone (fun s => sourceBlockSize s * (sourceStageState s).K) := by
|
| 27 |
+
have hK : Monotone (fun s => (sourceStageState s).K) := by
|
| 28 |
+
apply monotone_nat_of_le_succ
|
| 29 |
+
intro s
|
| 30 |
+
have := sourceStage_cutoff_growth s
|
| 31 |
+
omega
|
| 32 |
+
intro s t hst
|
| 33 |
+
exact Nat.mul_le_mul (sourceBlockSize_monotone hst) (hK hst)
|
| 34 |
+
|
| 35 |
+
/-- The full infinite-product angle expectation has the same coordinate
|
| 36 |
+
Fourier estimate; no independence between two phases is asserted. -/
|
| 37 |
+
theorem sourceAngleLaw_pair_fourier_le (i : SourceCoordinate) (v v' : ℤ) (n n' : ℝ)
|
| 38 |
+
(hw : (v : ℝ)*n+(v' : ℝ)*n' ≠ 0) :
|
| 39 |
+
‖∫ θ, Complex.exp (2 * Real.pi * Complex.I *
|
| 40 |
+
((v : ℂ) * (Int.fract (n*θ i) : ℝ) + (v' : ℂ) * (Int.fract (n'*θ i) : ℝ)))
|
| 41 |
+
∂sourceAngleLaw‖ ≤
|
| 42 |
+
1/(Real.pi*sourceAngleUnit i*|(v : ℝ)*n+(v' : ℝ)*n'|) := by
|
| 43 |
+
have hh := sourceAngle_pair_fourier_le i v v' n n' hw
|
| 44 |
+
simp_rw [pair_fourier_fract] at hh ⊢
|
| 45 |
+
rw [← sourceAngleLaw_coordinate i,
|
| 46 |
+
integral_map (measurable_pi_apply i).aemeasurable (by fun_prop)] at hh
|
| 47 |
+
exact hh
|
| 48 |
+
|
| 49 |
+
theorem sourceSampling_pair_fourier_bound (s : ℕ) (hs : 200000 ≤ sourceBlockSize s)
|
| 50 |
+
(i : SourceCoordinate) (hi : i.1 ≤ s) (n n' : ℤ)
|
| 51 |
+
(hn : n ∈ sourceSamplingPowers s) (hn' : n' ∈ sourceSamplingPowers s) (hne : n ≠ n')
|
| 52 |
+
(v v' : ℤ) (hv : |v| ≤ (samplingH (sourceBlockSize s) : ℤ))
|
| 53 |
+
(hv' : |v'| ≤ (samplingH (sourceBlockSize s) : ℤ)) (hvv' : v ≠ 0 ∨ v' ≠ 0) :
|
| 54 |
+
‖∫ θ, Complex.exp (2 * Real.pi * Complex.I *
|
| 55 |
+
((v : ℂ) * (Int.fract ((n : ℝ)*θ i) : ℝ) +
|
| 56 |
+
(v' : ℂ) * (Int.fract ((n' : ℝ)*θ i) : ℝ))) ∂sourceAngleLaw‖ ≤
|
| 57 |
+
Real.pi⁻¹*(sourceBlockSize s : ℝ)^(-1000 : ℝ) := by
|
| 58 |
+
have hsep := (sourceSamplingPowers_spec s hs).2.2 hn hn' hne
|
| 59 |
+
have hfreq : (samplingR (sourceBlockSize s) (sourceStageState s).K : ℤ) < |v*n+v'*n'| := by
|
| 60 |
+
by_contra hh
|
| 61 |
+
exact hsep ⟨v,mem_Icc.mpr (abs_le.mp hv),v',mem_Icc.mpr (abs_le.mp hv'),hvv',le_of_not_gt hh⟩
|
| 62 |
+
let w : ℝ := (v : ℝ)*(n : ℝ)+(v' : ℝ)*(n' : ℝ)
|
| 63 |
+
have hwR : (samplingR (sourceBlockSize s) (sourceStageState s).K : ℝ) < |w| := by
|
| 64 |
+
dsimp [w]
|
| 65 |
+
exact_mod_cast hfreq
|
| 66 |
+
have hwpos : 0 < |w| := lt_of_le_of_lt (Nat.cast_nonneg _) hwR
|
| 67 |
+
have hw : w ≠ 0 := abs_pos.mp hwpos
|
| 68 |
+
apply (sourceAngleLaw_pair_fourier_le i v v' (n : ℝ) (n' : ℝ) hw).trans
|
| 69 |
+
have hN : (sourceBlockSize i.1 : ℝ)*(sourceStageState i.1).K ≤
|
| 70 |
+
(sourceBlockSize s : ℝ)*(sourceStageState s).K := by
|
| 71 |
+
exact_mod_cast sourceFrequencyScale_monotone hi
|
| 72 |
+
have hmpos := sourceBlockSize_pos s
|
| 73 |
+
have hNpos := mul_pos (sourceBlockSize_pos i.1) (sourceCutoff_pos i.1)
|
| 74 |
+
have hscale : (sourceBlockSize s : ℝ)^1000 ≤ sourceAngleUnit i * |w| := by
|
| 75 |
+
unfold samplingR at hwR
|
| 76 |
+
push_cast at hwR
|
| 77 |
+
unfold sourceAngleUnit
|
| 78 |
+
rw [one_div, inv_mul_eq_div, le_div_iff₀ hNpos]
|
| 79 |
+
have hh := mul_le_mul_of_nonneg_right hN (pow_nonneg hmpos.le 1000)
|
| 80 |
+
nlinarith
|
| 81 |
+
change 1/(Real.pi*sourceAngleUnit i*|w|) ≤ _
|
| 82 |
+
calc
|
| 83 |
+
_ = Real.pi⁻¹*(1/(sourceAngleUnit i*|w|)) := by ring
|
| 84 |
+
_ ≤ Real.pi⁻¹*(1/(sourceBlockSize s : ℝ)^1000) := by
|
| 85 |
+
exact mul_le_mul_of_nonneg_left
|
| 86 |
+
(one_div_le_one_div_of_le (pow_pos hmpos 1000) hscale) (inv_nonneg.mpr Real.pi_pos.le)
|
| 87 |
+
_ = _ := by rw [Real.rpow_neg, Real.rpow_ofNat, one_div]; positivity
|
| 88 |
+
|
| 89 |
+
end
|
| 90 |
+
end FiniteFactor
|
| 91 |
+
|
| 92 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/IdealProduct.lean
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.OrientedMoments
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
noncomputable section
|
| 8 |
+
|
| 9 |
+
/-- The actual source prefix dimension, including the current block. -/
|
| 10 |
+
theorem sourceSamplingPrefix_card (stage : ℕ) :
|
| 11 |
+
(sourceSamplingPrefix stage).card = (sourceStageState stage).d+sourceBlockSize stage := by
|
| 12 |
+
unfold sourceSamplingPrefix CouplingParameters.blockPrefix
|
| 13 |
+
simp only [Finset.card_sigma,Finset.card_univ,Fintype.card_fin]
|
| 14 |
+
change (∑ i ∈ range (stage+1), (sourceStage i).m) = _
|
| 15 |
+
rw [sum_range_succ,← sourceStage_previous_size]
|
| 16 |
+
rfl
|
| 17 |
+
|
| 18 |
+
theorem sourceSamplingPrefix_card_bound (stage : ℕ) :
|
| 19 |
+
((sourceSamplingPrefix stage).card : ℝ) ≤ (101/100 : ℝ)*sourceBlockSize stage := by
|
| 20 |
+
rw [sourceSamplingPrefix_card,Nat.cast_add]
|
| 21 |
+
have hp := (sourceStage stage).previous_size
|
| 22 |
+
change ((sourceStageState stage).d : ℝ) ≤ (sourceBlockSize stage : ℝ)/100 at hp
|
| 23 |
+
linarith
|
| 24 |
+
|
| 25 |
+
/-- The small quadratic coordinate errors stay bounded in the growing prefix. -/
|
| 26 |
+
theorem sourceSampling_prefix_quadratic_budget (stage : ℕ) :
|
| 27 |
+
((sourceSamplingPrefix stage).card : ℝ)*(4*(sourceBlockSize stage : ℝ)^(-6/5 : ℝ)) ≤ 5 := by
|
| 28 |
+
have hm := sourceBlockSize_pos stage
|
| 29 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by
|
| 30 |
+
have hh : (100 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_100
|
| 31 |
+
linarith
|
| 32 |
+
have he : (sourceBlockSize stage : ℝ)*(sourceBlockSize stage : ℝ)^(-6/5 : ℝ) =
|
| 33 |
+
(sourceBlockSize stage : ℝ)^(-1/5 : ℝ) := by
|
| 34 |
+
conv_lhs => lhs; rw [← Real.rpow_one (sourceBlockSize stage : ℝ)]
|
| 35 |
+
rw [← Real.rpow_add hm]
|
| 36 |
+
norm_num
|
| 37 |
+
have hp : (sourceBlockSize stage : ℝ)^(-1/5 : ℝ) ≤ 1 :=
|
| 38 |
+
Real.rpow_le_one_of_one_le_of_nonpos hm1 (by norm_num)
|
| 39 |
+
calc
|
| 40 |
+
_ ≤ ((101/100 : ℝ)*sourceBlockSize stage)*(4*(sourceBlockSize stage : ℝ)^(-6/5 : ℝ)) :=
|
| 41 |
+
mul_le_mul_of_nonneg_right (sourceSamplingPrefix_card_bound stage) (by positivity)
|
| 42 |
+
_ = (101/25 : ℝ)*(sourceBlockSize stage : ℝ)^(-1/5 : ℝ) := by rw [← he]; ring
|
| 43 |
+
_ ≤ 5 := by linarith
|
| 44 |
+
|
| 45 |
+
def sourceSamplingIdealDensity (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 46 |
+
(E G : SourceCoordinate → Set ℝ) (x : SourceCoordinate → ℝ) : ℝ :=
|
| 47 |
+
∏ i ∈ sourceSamplingPrefix stage,
|
| 48 |
+
samplingOrientedDensity r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) (x i)
|
| 49 |
+
|
| 50 |
+
theorem sourceSamplingIdealDensity_measurable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 51 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 52 |
+
Measurable (sourceSamplingIdealDensity stage r b E G) :=
|
| 53 |
+
Finset.measurable_prod _ (fun i _ =>
|
| 54 |
+
(samplingOrientedDensity_measurable r (b i) _ _ (E i) (G i) (hE i) (hG i)).comp (measurable_pi_apply i))
|
| 55 |
+
|
| 56 |
+
/-- Exact product factorization of the ideal marginal's quadratic moment. -/
|
| 57 |
+
theorem sourceSamplingIdealDensity_square (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 58 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 59 |
+
(∫ x, sourceSamplingIdealDensity stage r b E G x ^ 2
|
| 60 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) =
|
| 61 |
+
∏ i ∈ sourceSamplingPrefix stage,
|
| 62 |
+
∫ s, samplingOrientedDensity r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s ^ 2
|
| 63 |
+
∂unitIntervalMeasure := by
|
| 64 |
+
simp only [sourceSamplingIdealDensity,← Finset.prod_pow]
|
| 65 |
+
exact integral_infinitePi_finset_prod _ _ _ (fun i =>
|
| 66 |
+
(samplingOrientedDensity_measurable r (b i) _ _ (E i) (G i) (hE i) (hG i)).pow_const 2)
|
| 67 |
+
|
| 68 |
+
/-- Uniform-in-stage ideal marginal bound. The second orientation uses the
|
| 69 |
+
quadratic cancellation established for the actual cutoff diagonal density. -/
|
| 70 |
+
theorem sourceSamplingIdealDensity_uniform_square (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 71 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 72 |
+
(∫ x, sourceSamplingIdealDensity stage r b E G x ^ 2
|
| 73 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) ≤ Real.exp 5 := by
|
| 74 |
+
rw [sourceSamplingIdealDensity_square stage r b E G hE hG,← Finset.prod_coe_sort]
|
| 75 |
+
have he := product_energy_le_exp
|
| 76 |
+
(fun i : sourceSamplingPrefix stage => ∫ s, samplingOrientedDensity r (b i)
|
| 77 |
+
(sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s ^ 2 ∂unitIntervalMeasure)
|
| 78 |
+
(fun _ : sourceSamplingPrefix stage => 4*(sourceBlockSize stage : ℝ)^(-6/5 : ℝ))
|
| 79 |
+
(fun i => integral_nonneg (fun _ => sq_nonneg _))
|
| 80 |
+
(fun i => (sourceSampling_oriented_moment stage r (b i) (E i) (G i) (hE i) (hG i)).2)
|
| 81 |
+
apply he.trans
|
| 82 |
+
apply Real.exp_le_exp.mpr
|
| 83 |
+
simpa using sourceSampling_prefix_quadratic_budget stage
|
| 84 |
+
|
| 85 |
+
/-- Each ideal marginal is genuinely in L2; the preceding integral bound is
|
| 86 |
+
therefore a norm bound, not an integral of a nonintegrable function. -/
|
| 87 |
+
theorem sourceSamplingIdealDensity_memLp (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 88 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 89 |
+
MemLp (sourceSamplingIdealDensity stage r b E G) 2
|
| 90 |
+
(Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) := by
|
| 91 |
+
let C := max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage))
|
| 92 |
+
have hp := sourceSampling_parameters stage
|
| 93 |
+
have hb (i : SourceCoordinate) (s : ℝ) :
|
| 94 |
+
0 ≤ samplingOrientedDensity r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s ∧
|
| 95 |
+
samplingOrientedDensity r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s ≤ C := by
|
| 96 |
+
have hm : Measurable (samplingOrientedWeight r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s) :=
|
| 97 |
+
(samplingOrientedWeight_measurable r (b i) _ _ (E i) (G i) (hE i) (hG i)).comp
|
| 98 |
+
(measurable_const.prodMk measurable_id)
|
| 99 |
+
have hw := samplingOrientedWeight_bounds r (b i) _ _ (E i) (G i) hp.1 hp.2.2 s
|
| 100 |
+
have hi : Integrable (samplingOrientedWeight r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (E i) (G i) s)
|
| 101 |
+
unitIntervalMeasure := (integrable_const C).mono' hm.aestronglyMeasurable
|
| 102 |
+
(Eventually.of_forall (fun t => by rw [Real.norm_eq_abs,abs_of_nonneg (hw t).1]; exact (hw t).2))
|
| 103 |
+
refine ⟨integral_nonneg (fun t => (hw t).1),?_⟩
|
| 104 |
+
simpa [samplingOrientedDensity] using integral_mono_ae hi (integrable_const C)
|
| 105 |
+
(Eventually.of_forall (fun t => (hw t).2))
|
| 106 |
+
apply MemLp.of_bound (sourceSamplingIdealDensity_measurable stage r b E G hE hG).aestronglyMeasurable
|
| 107 |
+
(C^(sourceSamplingPrefix stage).card)
|
| 108 |
+
apply Eventually.of_forall
|
| 109 |
+
intro x
|
| 110 |
+
have hnon : 0 ≤ sourceSamplingIdealDensity stage r b E G x := prod_nonneg (fun i _ => (hb i (x i)).1)
|
| 111 |
+
rw [Real.norm_eq_abs,abs_of_nonneg hnon]
|
| 112 |
+
calc
|
| 113 |
+
_ ≤ ∏ _i ∈ sourceSamplingPrefix stage, C :=
|
| 114 |
+
prod_le_prod₀ (fun i _ => (hb i (x i)).1) (fun i _ => (hb i (x i)).2)
|
| 115 |
+
_ = _ := by simp
|
| 116 |
+
|
| 117 |
+
end
|
| 118 |
+
end FiniteFactor
|
| 119 |
+
|
| 120 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/IdealRectangleLimit.lean
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.CutoffMass
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.RectangleApproximation
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- Explicit finite-coordinate rectangle mass of the triangular/diagonal
|
| 12 |
+
model. The triangular term retains the actual source weight integral. -/
|
| 13 |
+
def sourceSamplingLimitRectangleMass (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest) : ℝ :=
|
| 14 |
+
∏ i ∈ I ∪ T.1,
|
| 15 |
+
if i ∈ I then
|
| 16 |
+
∫ s, samplingTestedFirstDensity true (sourceSamplingWidth 0) (sourceSamplingCutoff 0)
|
| 17 |
+
(sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure
|
| 18 |
+
else (unitIntervalMeasure (sourceSamplingRationalX T i ∩ sourceSamplingRationalY T i)).toReal
|
| 19 |
+
|
| 20 |
+
/-- Exact finite-coordinate factorization of the first ideal integral. -/
|
| 21 |
+
theorem sourceSamplingIdealDensity_integral (I : Finset SourceCoordinate) (stage : ℕ)
|
| 22 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 23 |
+
(∫ x, sourceSamplingIdealDensity stage false (fun i => decide (i ∈ I)) E G x ∂sourceSamplingHaar) =
|
| 24 |
+
∏ i ∈ sourceSamplingPrefix stage, ∫ s,
|
| 25 |
+
samplingTestedFirstDensity (decide (i ∈ I)) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 26 |
+
(E i) (G i) s ∂unitIntervalMeasure := by
|
| 27 |
+
exact integral_infinitePi_finset_prod _ _ _ (fun i =>
|
| 28 |
+
samplingTestedFirstDensity_measurable (decide (i ∈ I)) _ _ (E i) (G i) (hE i) (hG i))
|
| 29 |
+
|
| 30 |
+
/-- Tests and triangular coordinates occupy a fixed finite set. Every other
|
| 31 |
+
prefix coordinate contributes its exact retained mass, 1-2α. -/
|
| 32 |
+
theorem sourceSamplingIdeal_rectangle_split (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest)
|
| 33 |
+
(stage : ℕ) (hK : I ∪ T.1 ⊆ sourceSamplingPrefix stage) :
|
| 34 |
+
(∫ x, sourceSamplingIdealDensity stage false (fun i => decide (i ∈ I))
|
| 35 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) x ∂sourceSamplingHaar) =
|
| 36 |
+
(∏ i ∈ I ∪ T.1, ∫ s,
|
| 37 |
+
samplingTestedFirstDensity (decide (i ∈ I)) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 38 |
+
(sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure) *
|
| 39 |
+
(1-2*sourceSamplingCutoff stage)^((sourceSamplingPrefix stage \ (I ∪ T.1)).card) := by
|
| 40 |
+
rw [sourceSamplingIdealDensity_integral I stage (sourceSamplingRationalX T) (sourceSamplingRationalY T) (fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)]
|
| 41 |
+
let F := fun i => ∫ s, samplingTestedFirstDensity (decide (i ∈ I)) (sourceSamplingWidth stage)
|
| 42 |
+
(sourceSamplingCutoff stage) (sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure
|
| 43 |
+
have hf (i : SourceCoordinate) (hi : i ∈ sourceSamplingPrefix stage \ (I ∪ T.1)) :
|
| 44 |
+
F i = 1-2*sourceSamplingCutoff stage := by
|
| 45 |
+
have hnot := (Finset.mem_sdiff.mp hi).2
|
| 46 |
+
have hI : i ∉ I := fun h => hnot (Finset.mem_union_left _ h)
|
| 47 |
+
have hT : i ∉ T.1 := fun h => hnot (Finset.mem_union_right _ h)
|
| 48 |
+
simp only [F,decide_eq_false hI,sourceSamplingRationalX,sourceSamplingRationalY,
|
| 49 |
+
sourceSamplingRationalEndpoints,dite_eq_right hT,Rat.cast_zero,Rat.cast_one]
|
| 50 |
+
have hp := sourceSampling_parameters stage
|
| 51 |
+
exact sampling_diagonal_whole_mass _ _ hp.1 hp.2.1 hp.2.2 (sourceSamplingCutoff_le_half stage)
|
| 52 |
+
have hp := Finset.prod_sdiff hK (f := F)
|
| 53 |
+
rw [Finset.prod_congr rfl hf,Finset.prod_const] at hp
|
| 54 |
+
simpa only [mul_comm] using hp.symm
|
| 55 |
+
|
| 56 |
+
/-- The deterministic ideal product limit includes all growing-prefix cutoff
|
| 57 |
+
losses and has exactly the tested diagonal-coordinate limits. -/
|
| 58 |
+
theorem sourceSamplingIdeal_rectangle_tendsto (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest) :
|
| 59 |
+
Tendsto (fun stage => ∫ x, sourceSamplingIdealDensity stage false (fun i => decide (i ∈ I))
|
| 60 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) x ∂sourceSamplingHaar)
|
| 61 |
+
atTop (𝓝 (sourceSamplingLimitRectangleMass I T)) := by
|
| 62 |
+
let F := fun stage i => ∫ s, samplingTestedFirstDensity (decide (i ∈ I)) (sourceSamplingWidth stage)
|
| 63 |
+
(sourceSamplingCutoff stage) (sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure
|
| 64 |
+
have hcoord (i : SourceCoordinate) : Tendsto (fun stage => F stage i) atTop
|
| 65 |
+
(𝓝 (if i ∈ I then ∫ s, samplingTestedFirstDensity true (sourceSamplingWidth 0) (sourceSamplingCutoff 0)
|
| 66 |
+
(sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure
|
| 67 |
+
else (unitIntervalMeasure (sourceSamplingRationalX T i ∩ sourceSamplingRationalY T i)).toReal)) := by
|
| 68 |
+
by_cases hi : i ∈ I
|
| 69 |
+
· simp only [ite_eq_left hi,F,decide_eq_true hi]
|
| 70 |
+
have he (stage : ℕ) : (∫ s, samplingTestedFirstDensity true (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 71 |
+
(sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure) =
|
| 72 |
+
∫ s, samplingTestedFirstDensity true (sourceSamplingWidth 0) (sourceSamplingCutoff 0)
|
| 73 |
+
(sourceSamplingRationalX T i) (sourceSamplingRationalY T i) s ∂unitIntervalMeasure := by
|
| 74 |
+
apply integral_congr_ae
|
| 75 |
+
exact Eventually.of_forall (fun s => samplingTestedFirstDensity_triangular_parameters _ _ _ _ _ _ _)
|
| 76 |
+
simp_rw [he]
|
| 77 |
+
exact tendsto_const_nhds
|
| 78 |
+
· simp only [ite_eq_right hi,F,decide_eq_false hi]
|
| 79 |
+
exact sourceSampling_diagonal_integral_tendsto _ measurableSet_Icc _ _
|
| 80 |
+
have hfixed := tendsto_finsetProd (I ∪ T.1) (fun i _ => hcoord i)
|
| 81 |
+
have htail := sourceSampling_untested_mass_tendsto
|
| 82 |
+
(fun stage => (sourceSamplingPrefix stage \ (I ∪ T.1)).card)
|
| 83 |
+
(fun stage => Finset.card_le_card Finset.sdiff_subset)
|
| 84 |
+
have hall := hfixed.mul htail
|
| 85 |
+
simp only [mul_one] at hall
|
| 86 |
+
apply hall.congr'
|
| 87 |
+
filter_upwards [sourceSamplingPrefix_eventually_covers (I ∪ T.1)] with stage hstage
|
| 88 |
+
exact (sourceSamplingIdeal_rectangle_split I T stage hstage).symm
|
| 89 |
+
|
| 90 |
+
/-- Actual untrimmed rational rectangle masses converge to the explicit
|
| 91 |
+
triangular/diagonal product value on one conull event for all I and tests. -/
|
| 92 |
+
theorem sourceSampling_rectangle_limit_event :
|
| 93 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest),
|
| 94 |
+
Tendsto (fun stage => ((sourceSamplingUntrimmed I stage θ)
|
| 95 |
+
(sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T))).toReal)
|
| 96 |
+
atTop (𝓝 (sourceSamplingLimitRectangleMass I T)) := by
|
| 97 |
+
filter_upwards [sourceSampling_rectangle_approximation_event] with θ hθ
|
| 98 |
+
intro I T
|
| 99 |
+
have hh := (hθ I T).add (sourceSamplingIdeal_rectangle_tendsto I T)
|
| 100 |
+
simpa only [sub_add_cancel,zero_add] using hh
|
| 101 |
+
|
| 102 |
+
end
|
| 103 |
+
end FiniteFactor
|
| 104 |
+
|
| 105 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/LambdaMarginals.lean
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Cube
|
| 2 |
+
import OAI.Analysis.FiniteFactor.SubmeasureL2Density
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
def sourceSamplingLimitCoordinate (I : Finset SourceCoordinate) (r : Bool)
|
| 12 |
+
(i : SourceCoordinate) (z : ℝ × ℝ) : ℝ := if r = true ∧ i ∈ I then z.2 else z.1
|
| 13 |
+
|
| 14 |
+
theorem sourceSamplingLimitCoordinate_preserving (I : Finset SourceCoordinate) (r : Bool)
|
| 15 |
+
(i : SourceCoordinate) : MeasurePreserving (sourceSamplingLimitCoordinate I r i)
|
| 16 |
+
(unitIntervalMeasure.prod unitIntervalMeasure) unitIntervalMeasure := by
|
| 17 |
+
by_cases h : r = true ∧ i ∈ I
|
| 18 |
+
· have he : sourceSamplingLimitCoordinate I r i = Prod.snd := by funext z; simp [sourceSamplingLimitCoordinate,h]
|
| 19 |
+
rw [he]
|
| 20 |
+
exact measurePreserving_snd
|
| 21 |
+
· have he : sourceSamplingLimitCoordinate I r i = Prod.fst := by funext z; simp [sourceSamplingLimitCoordinate,h]
|
| 22 |
+
rw [he]
|
| 23 |
+
exact measurePreserving_fst
|
| 24 |
+
|
| 25 |
+
theorem sourceSamplingLimitEndpoint_eq (I : Finset SourceCoordinate) (r : Bool) :
|
| 26 |
+
sourceSamplingEndpoint r ∘ sourceSamplingLimitMap I =
|
| 27 |
+
(fun p i => sourceSamplingLimitCoordinate I r i (p i)) := by
|
| 28 |
+
funext p i
|
| 29 |
+
cases r <;> simp [sourceSamplingEndpoint,sourceSamplingLimitMap,sourceSamplingLimitCoordinate]
|
| 30 |
+
|
| 31 |
+
/-- Before the triangular restriction, either selected endpoint is exactly
|
| 32 |
+
product Haar, including the mixed first/second selection in the second endpoint. -/
|
| 33 |
+
theorem sourceSamplingLimitEndpoint_preserving (I : Finset SourceCoordinate) (r : Bool) :
|
| 34 |
+
MeasurePreserving (sourceSamplingEndpoint r ∘ sourceSamplingLimitMap I)
|
| 35 |
+
sourceSamplingPairHaar sourceSamplingHaar := by
|
| 36 |
+
rw [sourceSamplingLimitEndpoint_eq]
|
| 37 |
+
refine ⟨Measurable.of_eval (fun i => (sourceSamplingLimitCoordinate_preserving I r i).measurable.comp
|
| 38 |
+
(measurable_pi_apply i)),?_⟩
|
| 39 |
+
rw [Measure.infinitePi_map_pi _ (fun i => (sourceSamplingLimitCoordinate_preserving I r i).measurable)]
|
| 40 |
+
simp only [(sourceSamplingLimitCoordinate_preserving I r _).map_eq]
|
| 41 |
+
|
| 42 |
+
/-- Both actual limiting marginals are submeasures of Haar. This proves the
|
| 43 |
+
absolute continuity needed for the later Lusin transfer without assuming a marginal law. -/
|
| 44 |
+
theorem sourceSamplingLambda_marginal_le (I : Finset SourceCoordinate) (r : Bool) :
|
| 45 |
+
(sourceSamplingLambda I).map (sourceSamplingEndpoint r) ≤ sourceSamplingHaar := by
|
| 46 |
+
rw [sourceSamplingLambda,Measure.map_map (sourceSamplingEndpoint_measurable r)
|
| 47 |
+
(sourceSamplingLimitMap_measurable I)]
|
| 48 |
+
have h := Measure.map_mono (μ := sourceSamplingPairHaar.restrict (sourceSamplingTriangleSet I))
|
| 49 |
+
(ν := sourceSamplingPairHaar) Measure.restrict_le_self (sourceSamplingLimitEndpoint_preserving I r).measurable
|
| 50 |
+
rwa [(sourceSamplingLimitEndpoint_preserving I r).map_eq] at h
|
| 51 |
+
|
| 52 |
+
theorem sourceSamplingLambda_marginal_density (I : Finset SourceCoordinate) (r : Bool) :
|
| 53 |
+
∃ g : (SourceCoordinate → ℝ) → ℝ,
|
| 54 |
+
Measurable g ∧ (∀ x, 0 ≤ g x) ∧
|
| 55 |
+
(sourceSamplingLambda I).map (sourceSamplingEndpoint r) =
|
| 56 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (g x)) ∧
|
| 57 |
+
(∀ᵐ x ∂sourceSamplingHaar, g x ≤ 1) ∧ MemLp g 2 sourceSamplingHaar ∧
|
| 58 |
+
(∫ x, g x^2 ∂sourceSamplingHaar) ≤ 1 := by
|
| 59 |
+
have h := sourceSamplingLambda_marginal_le I r
|
| 60 |
+
have h' : (sourceSamplingLambda I).map (sourceSamplingEndpoint r) ≤
|
| 61 |
+
sourceSamplingHaar.withDensity (fun _ => ENNReal.ofReal (1 : ℝ)) := by simpa using h
|
| 62 |
+
obtain ⟨g,hg,hg0,hgm,hgle,hglp,hgint⟩ := submeasure_L2_density sourceSamplingHaar
|
| 63 |
+
((sourceSamplingLambda I).map (sourceSamplingEndpoint r)) (fun _ => 1) (memLp_const (1 : ℝ)) h'
|
| 64 |
+
exact ⟨g,hg,hg0,hgm,by simpa using hgle,hglp,by simpa using hgint⟩
|
| 65 |
+
|
| 66 |
+
end
|
| 67 |
+
end FiniteFactor
|
| 68 |
+
|
| 69 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/LambdaMass.lean
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Cube
|
| 2 |
+
import Mathlib.Analysis.SpecialFunctions.Integrals.Basic
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
theorem sourceSampling_triangle_mass :
|
| 12 |
+
((unitIntervalMeasure.prod unitIntervalMeasure)
|
| 13 |
+
{p : ℝ × ℝ | p.1 ∈ Set.Icc (0 : ℝ) 1 ∧ p.2 ∈ Set.Icc (0 : ℝ) 1 ∧ p.1 < p.2}).toReal = 1/2 := by
|
| 14 |
+
rw [← samplingTestedFirstDensity_triangular_mass (1/2) 1 _ _ measurableSet_Icc measurableSet_Icc]
|
| 15 |
+
have he : samplingTestedFirstDensity true (1/2) 1 (Set.Icc 0 1) (Set.Icc 0 1) =ᵐ[unitIntervalMeasure]
|
| 16 |
+
(fun s => 1-s) := by
|
| 17 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with s hs
|
| 18 |
+
simpa only [ite_true] using samplingTestedFirstDensity_whole true (1/2) 1 s
|
| 19 |
+
(by norm_num) (by norm_num) (by norm_num) hs
|
| 20 |
+
rw [integral_congr_ae he,unitIntervalMeasure,restrict_Ico_eq_restrict_Ioc,
|
| 21 |
+
← intervalIntegral.integral_of_le (show (0 : ℝ) ≤ 1 by norm_num)]
|
| 22 |
+
rw [intervalIntegral.integral_sub (f := fun _ : ℝ => (1 : ℝ)) (g := fun x : ℝ => x)
|
| 23 |
+
intervalIntegrable_const (continuous_id.intervalIntegrable _ _)]
|
| 24 |
+
norm_num [intervalIntegral.integral_const]
|
| 25 |
+
|
| 26 |
+
theorem sourceSamplingLambda_mass (I : Finset SourceCoordinate) :
|
| 27 |
+
((sourceSamplingLambda I) Set.univ).toReal = (1/2 : ℝ)^I.card := by
|
| 28 |
+
have he : sourceSamplingLambda I sourceSamplingCube = sourceSamplingLambda I Set.univ :=
|
| 29 |
+
measure_congr (by filter_upwards [sourceSamplingLambda_cube I] with p hp; exact propext (iff_true_intro hp))
|
| 30 |
+
rw [← he,← sourceSamplingEmptyTest_rectangle,sourceSamplingLambda_rectangle,
|
| 31 |
+
sourceSamplingLimitRectangleMass_formula]
|
| 32 |
+
have hE (i : SourceCoordinate) : sourceSamplingRationalX sourceSamplingEmptyTest i = Set.Icc (0 : ℝ) 1 ∧
|
| 33 |
+
sourceSamplingRationalY sourceSamplingEmptyTest i = Set.Icc (0 : ℝ) 1 := by
|
| 34 |
+
simp [sourceSamplingRationalX,sourceSamplingRationalY,sourceSamplingRationalEndpoints,sourceSamplingEmptyTest]
|
| 35 |
+
change (∏ i ∈ I ∪ ∅, _) = _
|
| 36 |
+
rw [Finset.union_empty]
|
| 37 |
+
calc
|
| 38 |
+
_ = ∏ _i ∈ I, (1/2 : ℝ) := by
|
| 39 |
+
apply Finset.prod_congr rfl
|
| 40 |
+
intro i hi
|
| 41 |
+
rw [ite_eq_left hi,(hE i).1,(hE i).2]
|
| 42 |
+
exact sourceSampling_triangle_mass
|
| 43 |
+
_ = _ := by simp
|
| 44 |
+
|
| 45 |
+
theorem sourceSamplingLambda_mass_pos (I : Finset SourceCoordinate) :
|
| 46 |
+
0 < ((sourceSamplingLambda I) Set.univ).toReal := by
|
| 47 |
+
rw [sourceSamplingLambda_mass]
|
| 48 |
+
positivity
|
| 49 |
+
|
| 50 |
+
end
|
| 51 |
+
end FiniteFactor
|
| 52 |
+
|
| 53 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/LambdaRectangles.lean
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.LimitMeasure
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingLambdaTest (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest)
|
| 11 |
+
(i : SourceCoordinate) (p : ℝ × ℝ) : Prop :=
|
| 12 |
+
if i ∈ I then p.1 ∈ sourceSamplingRationalX T i ∧ p.2 ∈ sourceSamplingRationalY T i ∧ p.1 < p.2
|
| 13 |
+
else p.1 ∈ sourceSamplingRationalX T i ∧ p.1 ∈ sourceSamplingRationalY T i
|
| 14 |
+
|
| 15 |
+
theorem sourceSamplingLambdaTest_measurable (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest)
|
| 16 |
+
(i : SourceCoordinate) : MeasurableSet {p | sourceSamplingLambdaTest I T i p} := by
|
| 17 |
+
by_cases hi : i ∈ I
|
| 18 |
+
· simp only [sourceSamplingLambdaTest,ite_eq_left hi]
|
| 19 |
+
exact (measurableSet_Icc.preimage measurable_fst).inter
|
| 20 |
+
((measurableSet_Icc.preimage measurable_snd).inter (measurableSet_lt measurable_fst measurable_snd))
|
| 21 |
+
· simp only [sourceSamplingLambdaTest,ite_eq_right hi]
|
| 22 |
+
exact (measurableSet_Icc.preimage measurable_fst).inter (measurableSet_Icc.preimage measurable_fst)
|
| 23 |
+
|
| 24 |
+
/-- The finite coordinate conditions are equivalent to restriction by the
|
| 25 |
+
triangle and the full cylinder rectangle on the conull Haar cube. -/
|
| 26 |
+
theorem sourceSamplingLambdaTest_iff (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest)
|
| 27 |
+
(p : SourceCoordinate → ℝ × ℝ)
|
| 28 |
+
(hp : ∀ i, (p i).1 ∈ Set.Ico (0 : ℝ) 1 ∧ (p i).2 ∈ Set.Ico (0 : ℝ) 1) :
|
| 29 |
+
(∀ i ∈ I ∪ T.1, sourceSamplingLambdaTest I T i (p i)) ↔
|
| 30 |
+
sourceSamplingLimitMap I p ∈ sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T) ∧
|
| 31 |
+
p ∈ sourceSamplingTriangleSet I := by
|
| 32 |
+
constructor
|
| 33 |
+
· intro h
|
| 34 |
+
constructor
|
| 35 |
+
· intro i
|
| 36 |
+
by_cases hi : i ∈ I
|
| 37 |
+
· have hh := h i (Finset.mem_union_left _ hi)
|
| 38 |
+
simp only [sourceSamplingLambdaTest,ite_eq_left hi] at hh
|
| 39 |
+
exact ⟨hh.1,by simpa only [sourceSamplingLimitMap,ite_eq_left hi] using hh.2.1⟩
|
| 40 |
+
· by_cases ht : i ∈ T.1
|
| 41 |
+
· have hh := h i (Finset.mem_union_right _ ht)
|
| 42 |
+
simpa only [sourceSamplingLambdaTest,sourceSamplingLimitMap,ite_eq_right hi] using hh
|
| 43 |
+
· have hx : (p i).1 ∈ Set.Icc (0 : ℝ) 1 := ⟨(hp i).1.1,(hp i).1.2.le⟩
|
| 44 |
+
simpa only [sourceSamplingLimitMap,ite_eq_right hi,sourceSamplingRationalX,sourceSamplingRationalY,
|
| 45 |
+
sourceSamplingRationalEndpoints,dite_eq_right ht,Rat.cast_zero,Rat.cast_one] using And.intro hx hx
|
| 46 |
+
· intro i hi
|
| 47 |
+
have hh := h i (Finset.mem_union_left _ hi)
|
| 48 |
+
simp only [sourceSamplingLambdaTest,ite_eq_left hi] at hh
|
| 49 |
+
exact hh.2.2
|
| 50 |
+
· rintro ⟨hrect,htri⟩ i _
|
| 51 |
+
have hh := hrect i
|
| 52 |
+
by_cases hi : i ∈ I
|
| 53 |
+
· simp only [sourceSamplingLambdaTest,ite_eq_left hi]
|
| 54 |
+
exact ⟨hh.1,by simpa only [sourceSamplingLimitMap,ite_eq_left hi] using hh.2,htri i hi⟩
|
| 55 |
+
· simpa only [sourceSamplingLambdaTest,sourceSamplingLimitMap,ite_eq_right hi] using hh
|
| 56 |
+
|
| 57 |
+
/-- The constructed infinite-coordinate measure has exactly the rectangle
|
| 58 |
+
values previously obtained as sampling limits. -/
|
| 59 |
+
theorem sourceSamplingLambda_rectangle (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest) :
|
| 60 |
+
((sourceSamplingLambda I)
|
| 61 |
+
(sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T))).toReal =
|
| 62 |
+
sourceSamplingLimitRectangleMass I T := by
|
| 63 |
+
let R := sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T)
|
| 64 |
+
let C := sourceSamplingLimitMap I ⁻¹' R ∩ sourceSamplingTriangleSet I
|
| 65 |
+
have hR : MeasurableSet R := sourceSamplingRectangle_measurable _ _
|
| 66 |
+
(fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)
|
| 67 |
+
have hmap := sourceSamplingLimitMap_measurable I
|
| 68 |
+
have hC : MeasurableSet C := (hmap hR).inter (sourceSamplingTriangleSet_measurable I)
|
| 69 |
+
have he : C.indicator (fun _ => (1 : ℝ)) =ᵐ[sourceSamplingPairHaar]
|
| 70 |
+
(fun p => ∏ i ∈ I ∪ T.1, if sourceSamplingLambdaTest I T i (p i) then (1 : ℝ) else 0) := by
|
| 71 |
+
filter_upwards [sourceSamplingPairHaar_cube] with p hp
|
| 72 |
+
simp only [Finset.prod_ite_zero,Finset.prod_const_one,
|
| 73 |
+
sourceSamplingLambdaTest_iff I T p hp,Set.indicator_apply]
|
| 74 |
+
rfl
|
| 75 |
+
rw [sourceSamplingLambda,Measure.map_apply hmap hR,Measure.restrict_apply (hmap hR)]
|
| 76 |
+
change (sourceSamplingPairHaar C).toReal = _
|
| 77 |
+
calc
|
| 78 |
+
_ = ∫ p, C.indicator (fun _ => (1 : ℝ)) p ∂sourceSamplingPairHaar := by
|
| 79 |
+
rw [integral_indicator hC]; simp [measureReal_def]
|
| 80 |
+
_ = ∫ p, ∏ i ∈ I ∪ T.1, if sourceSamplingLambdaTest I T i (p i) then (1 : ℝ) else 0
|
| 81 |
+
∂sourceSamplingPairHaar := integral_congr_ae he
|
| 82 |
+
_ = ∏ i ∈ I ∪ T.1, ∫ z, (if sourceSamplingLambdaTest I T i z then (1 : ℝ) else 0)
|
| 83 |
+
∂unitIntervalMeasure.prod unitIntervalMeasure :=
|
| 84 |
+
integral_infinitePi_finset_prod _ _ _ (fun i =>
|
| 85 |
+
Measurable.ite (sourceSamplingLambdaTest_measurable I T i) measurable_const measurable_const)
|
| 86 |
+
_ = _ := by
|
| 87 |
+
rw [sourceSamplingLimitRectangleMass_formula]
|
| 88 |
+
apply Finset.prod_congr rfl
|
| 89 |
+
intro i _
|
| 90 |
+
have hA := sourceSamplingLambdaTest_measurable I T i
|
| 91 |
+
have hh : (∫ z, (if sourceSamplingLambdaTest I T i z then (1 : ℝ) else 0)
|
| 92 |
+
∂unitIntervalMeasure.prod unitIntervalMeasure) =
|
| 93 |
+
((unitIntervalMeasure.prod unitIntervalMeasure) {z | sourceSamplingLambdaTest I T i z}).toReal := by
|
| 94 |
+
change (∫ z, {z | sourceSamplingLambdaTest I T i z}.indicator (fun _ => (1 : ℝ)) z
|
| 95 |
+
∂unitIntervalMeasure.prod unitIntervalMeasure) = _
|
| 96 |
+
rw [integral_indicator hA]; simp [measureReal_def]
|
| 97 |
+
rw [hh]
|
| 98 |
+
by_cases hi : i ∈ I
|
| 99 |
+
· simp only [sourceSamplingLambdaTest,ite_eq_left hi]
|
| 100 |
+
· simp only [sourceSamplingLambdaTest,ite_eq_right hi]
|
| 101 |
+
have heq : {z : ℝ × ℝ | z.1 ∈ sourceSamplingRationalX T i ∧ z.1 ∈ sourceSamplingRationalY T i} =
|
| 102 |
+
(sourceSamplingRationalX T i ∩ sourceSamplingRationalY T i) ×ˢ Set.univ := by ext z; simp
|
| 103 |
+
rw [heq,Measure.prod_prod]
|
| 104 |
+
simp
|
| 105 |
+
|
| 106 |
+
/-- Actual untrimmed measures converge to the actual source limiting measure
|
| 107 |
+
on every rational cylinder rectangle, on a single conull event. -/
|
| 108 |
+
theorem sourceSamplingLambda_rectangle_limit_event :
|
| 109 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest),
|
| 110 |
+
Tendsto (fun stage => ((sourceSamplingUntrimmed I stage θ)
|
| 111 |
+
(sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T))).toReal)
|
| 112 |
+
atTop (𝓝 (((sourceSamplingLambda I)
|
| 113 |
+
(sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T))).toReal)) := by
|
| 114 |
+
filter_upwards [sourceSampling_rectangle_limit_event] with θ hθ
|
| 115 |
+
intro I T
|
| 116 |
+
rw [sourceSamplingLambda_rectangle]
|
| 117 |
+
exact hθ I T
|
| 118 |
+
|
| 119 |
+
end
|
| 120 |
+
end FiniteFactor
|
| 121 |
+
|
| 122 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/LimitMeasure.lean
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TriangleLaw
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.IdealRectangleLimit
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
abbrev sourceSamplingPairHaar : Measure (SourceCoordinate → ℝ × ℝ) :=
|
| 12 |
+
Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure.prod unitIntervalMeasure)
|
| 13 |
+
|
| 14 |
+
def sourceSamplingTriangleSet (I : Finset SourceCoordinate) : Set (SourceCoordinate → ℝ × ℝ) :=
|
| 15 |
+
{p | ∀ i ∈ I, (p i).1 < (p i).2}
|
| 16 |
+
|
| 17 |
+
def sourceSamplingLimitMap (I : Finset SourceCoordinate) (p : SourceCoordinate → ℝ × ℝ) :
|
| 18 |
+
(SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) :=
|
| 19 |
+
(fun i => (p i).1,fun i => if i ∈ I then (p i).2 else (p i).1)
|
| 20 |
+
|
| 21 |
+
def sourceSamplingLambda (I : Finset SourceCoordinate) :
|
| 22 |
+
Measure ((SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)) :=
|
| 23 |
+
(sourceSamplingPairHaar.restrict (sourceSamplingTriangleSet I)).map (sourceSamplingLimitMap I)
|
| 24 |
+
|
| 25 |
+
theorem sourceSamplingTriangleSet_measurable (I : Finset SourceCoordinate) :
|
| 26 |
+
MeasurableSet (sourceSamplingTriangleSet I) := by
|
| 27 |
+
simp only [sourceSamplingTriangleSet,Set.ofPred_forall]
|
| 28 |
+
apply MeasurableSet.iInter
|
| 29 |
+
intro i
|
| 30 |
+
apply MeasurableSet.iInter
|
| 31 |
+
intro _
|
| 32 |
+
exact measurableSet_lt (measurable_fst.comp (measurable_pi_apply i))
|
| 33 |
+
(measurable_snd.comp (measurable_pi_apply i))
|
| 34 |
+
|
| 35 |
+
theorem sourceSamplingLimitMap_measurable (I : Finset SourceCoordinate) :
|
| 36 |
+
Measurable (sourceSamplingLimitMap I) := by
|
| 37 |
+
apply Measurable.prodMk
|
| 38 |
+
· exact Measurable.of_eval (fun i => measurable_fst.comp (measurable_pi_apply i))
|
| 39 |
+
· apply Measurable.of_eval
|
| 40 |
+
intro i
|
| 41 |
+
by_cases hi : i ∈ I
|
| 42 |
+
· simpa only [hi,ite_true,Function.comp_def] using measurable_snd.comp (measurable_pi_apply i)
|
| 43 |
+
· simpa only [hi,ite_false,Function.comp_def] using measurable_fst.comp (measurable_pi_apply i)
|
| 44 |
+
|
| 45 |
+
instance sourceSamplingLambda_finite (I : Finset SourceCoordinate) : IsFiniteMeasure (sourceSamplingLambda I) := by
|
| 46 |
+
unfold sourceSamplingLambda
|
| 47 |
+
infer_instance
|
| 48 |
+
|
| 49 |
+
theorem sourceSamplingPairHaar_cube : ∀ᵐ p ∂sourceSamplingPairHaar,
|
| 50 |
+
∀ i, (p i).1 ∈ Set.Ico (0 : ℝ) 1 ∧ (p i).2 ∈ Set.Ico (0 : ℝ) 1 := by
|
| 51 |
+
apply ae_all_iff.mpr
|
| 52 |
+
intro i
|
| 53 |
+
have hp : ∀ᵐ z ∂unitIntervalMeasure.prod unitIntervalMeasure,
|
| 54 |
+
z.1 ∈ Set.Ico (0 : ℝ) 1 ∧ z.2 ∈ Set.Ico (0 : ℝ) 1 := by
|
| 55 |
+
apply (Measure.ae_prod_iff_ae_ae (measurableSet_Ico.prod measurableSet_Ico)).mpr
|
| 56 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with x hx
|
| 57 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with y hy
|
| 58 |
+
exact ⟨hx,hy⟩
|
| 59 |
+
have hh : ∀ᵐ z ∂sourceSamplingPairHaar.map (fun p => p i),
|
| 60 |
+
z.1 ∈ Set.Ico (0 : ℝ) 1 ∧ z.2 ∈ Set.Ico (0 : ℝ) 1 := by
|
| 61 |
+
rw [Measure.infinitePi_map_eval]
|
| 62 |
+
exact hp
|
| 63 |
+
exact ae_of_ae_map (measurable_pi_apply i).aemeasurable hh
|
| 64 |
+
|
| 65 |
+
/-- The actual limiting measure is carried by ordered pairs. -/
|
| 66 |
+
theorem sourceSamplingLambda_ordered (I : Finset SourceCoordinate) :
|
| 67 |
+
∀ᵐ p ∂sourceSamplingLambda I, ∀ i, p.1 i ≤ p.2 i := by
|
| 68 |
+
have horder : MeasurableSet {p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) |
|
| 69 |
+
∀ i, p.1 i ≤ p.2 i} := by
|
| 70 |
+
simp only [Set.ofPred_forall]
|
| 71 |
+
exact MeasurableSet.iInter (fun i => measurableSet_le
|
| 72 |
+
((measurable_pi_apply i).comp measurable_fst) ((measurable_pi_apply i).comp measurable_snd))
|
| 73 |
+
apply (ae_map_iff (sourceSamplingLimitMap_measurable I).aemeasurable horder).mpr
|
| 74 |
+
filter_upwards [ae_restrict_mem (sourceSamplingTriangleSet_measurable I)] with p hp
|
| 75 |
+
intro i
|
| 76 |
+
by_cases hi : i ∈ I
|
| 77 |
+
· simpa only [sourceSamplingLimitMap,ite_eq_left hi] using (hp i hi).le
|
| 78 |
+
· simp [sourceSamplingLimitMap,hi]
|
| 79 |
+
|
| 80 |
+
/-- The finite rectangle formula for the source limit, written using actual
|
| 81 |
+
Lebesgue triangular and diagonal masses. -/
|
| 82 |
+
theorem sourceSamplingLimitRectangleMass_formula (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest) :
|
| 83 |
+
sourceSamplingLimitRectangleMass I T = ∏ i ∈ I ∪ T.1,
|
| 84 |
+
if i ∈ I then ((unitIntervalMeasure.prod unitIntervalMeasure)
|
| 85 |
+
{p : ℝ × ℝ | p.1 ∈ sourceSamplingRationalX T i ∧
|
| 86 |
+
p.2 ∈ sourceSamplingRationalY T i ∧ p.1 < p.2}).toReal
|
| 87 |
+
else (unitIntervalMeasure (sourceSamplingRationalX T i ∩ sourceSamplingRationalY T i)).toReal := by
|
| 88 |
+
apply Finset.prod_congr rfl
|
| 89 |
+
intro i _
|
| 90 |
+
by_cases hi : i ∈ I
|
| 91 |
+
· simp only [ite_eq_left hi]
|
| 92 |
+
exact samplingTestedFirstDensity_triangular_mass _ _ _ _ measurableSet_Icc measurableSet_Icc
|
| 93 |
+
· simp only [ite_eq_right hi]
|
| 94 |
+
|
| 95 |
+
end
|
| 96 |
+
end FiniteFactor
|
| 97 |
+
|
| 98 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Measures.lean
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Weights
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Finset Filter
|
| 7 |
+
open scoped ENNReal
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
abbrev sourceSamplingHaar : Measure (SourceCoordinate → ℝ) :=
|
| 11 |
+
Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)
|
| 12 |
+
|
| 13 |
+
def sourceSamplingWeightedMeasure (I : Finset SourceCoordinate) (s : ℕ)
|
| 14 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) : Measure (SourceCoordinate → ℝ) :=
|
| 15 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (sourceSamplingWeight I s θ n x))
|
| 16 |
+
|
| 17 |
+
instance sourceSamplingWeightedMeasure_finite (I : Finset SourceCoordinate) (s : ℕ)
|
| 18 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) : IsFiniteMeasure (sourceSamplingWeightedMeasure I s θ n) := by
|
| 19 |
+
apply isFiniteMeasure_withDensity
|
| 20 |
+
let C := ((sourceBlockSize s : ℝ)^(13/5 : ℝ))^(sourceSamplingPrefix s).card
|
| 21 |
+
have hh : (∫⁻ x, ENNReal.ofReal (sourceSamplingWeight I s θ n x) ∂sourceSamplingHaar) ≤ ENNReal.ofReal C := by
|
| 22 |
+
calc
|
| 23 |
+
_ ≤ ∫⁻ _x, ENNReal.ofReal C ∂sourceSamplingHaar :=
|
| 24 |
+
lintegral_mono (fun x => ENNReal.ofReal_le_ofReal (sourceSamplingWeight_bounds I s θ n x).2)
|
| 25 |
+
_ = _ := by simp
|
| 26 |
+
exact ne_top_of_le_ne_top ENNReal.ofReal_ne_top hh
|
| 27 |
+
|
| 28 |
+
def sourceSamplingSummand (I : Finset SourceCoordinate) (s : ℕ)
|
| 29 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 30 |
+
Measure ((SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)) :=
|
| 31 |
+
(sourceSamplingWeightedMeasure I s θ n).map (fun x => (x,coordinateRotate θ n x))
|
| 32 |
+
|
| 33 |
+
instance sourceSamplingSummand_finite (I : Finset SourceCoordinate) (s : ℕ)
|
| 34 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) : IsFiniteMeasure (sourceSamplingSummand I s θ n) := by
|
| 35 |
+
unfold sourceSamplingSummand
|
| 36 |
+
infer_instance
|
| 37 |
+
|
| 38 |
+
theorem sourceSamplingSummand_first_marginal (I : Finset SourceCoordinate) (s : ℕ)
|
| 39 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 40 |
+
(sourceSamplingSummand I s θ n).map Prod.fst = sourceSamplingWeightedMeasure I s θ n := by
|
| 41 |
+
unfold sourceSamplingSummand
|
| 42 |
+
have hp : Measurable (fun x : SourceCoordinate → ℝ => (x,coordinateRotate θ n x)) :=
|
| 43 |
+
measurable_id.prodMk (coordinateRotate_preserving θ n).measurable
|
| 44 |
+
rw [Measure.map_map measurable_fst hp]
|
| 45 |
+
exact Measure.map_id
|
| 46 |
+
|
| 47 |
+
/-- Finite positive untrimmed measures averaged over the constructed powers.
|
| 48 |
+
No weak limit or uniform marginal bound is asserted by this definition. -/
|
| 49 |
+
def sourceSamplingUntrimmed (I : Finset SourceCoordinate) (s : ℕ) (θ : SourceCoordinate → ℝ) :
|
| 50 |
+
Measure ((SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)) :=
|
| 51 |
+
ENNReal.ofReal (1/((sourceSamplingPowers s).card : ℝ)) •
|
| 52 |
+
∑ n ∈ sourceSamplingPowers s, sourceSamplingSummand I s θ n
|
| 53 |
+
|
| 54 |
+
theorem sourceSamplingHaar_cube : ∀ᵐ x ∂sourceSamplingHaar,
|
| 55 |
+
∀ i : SourceCoordinate, x i ∈ Set.Ico (0 : ℝ) 1 := by
|
| 56 |
+
rw [ae_all_iff]
|
| 57 |
+
intro i
|
| 58 |
+
have hh : ∀ᵐ t ∂sourceSamplingHaar.map (fun x => x i), t ∈ Set.Ico (0 : ℝ) 1 := by
|
| 59 |
+
rw [Measure.infinitePi_map_eval]
|
| 60 |
+
exact ae_restrict_mem measurableSet_Ico
|
| 61 |
+
exact (ae_map_iff (measurable_pi_apply i).aemeasurable measurableSet_Ico).mp hh
|
| 62 |
+
|
| 63 |
+
/-- The weighted source law already orders every coordinate in its prefix. -/
|
| 64 |
+
theorem sourceSamplingWeightedMeasure_orders (I : Finset SourceCoordinate) (s : ℕ)
|
| 65 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 66 |
+
∀ᵐ x ∂sourceSamplingWeightedMeasure I s θ n,
|
| 67 |
+
∀ i ∈ sourceSamplingPrefix s, x i < coordinateRotate θ n x i := by
|
| 68 |
+
rw [sourceSamplingWeightedMeasure,ae_withDensity_iff
|
| 69 |
+
((sourceSamplingWeight_measurable I s θ n).ennreal_ofReal)]
|
| 70 |
+
filter_upwards [sourceSamplingHaar_cube] with x hx hw
|
| 71 |
+
have hw' : sourceSamplingWeight I s θ n x ≠ 0 := by
|
| 72 |
+
intro he
|
| 73 |
+
exact hw (by rw [he]; simp)
|
| 74 |
+
exact sourceSamplingWeight_orders_prefix I s θ n x hx hw'
|
| 75 |
+
|
| 76 |
+
end
|
| 77 |
+
end FiniteFactor
|
| 78 |
+
|
| 79 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Moments.lean
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.TestedSecondMoment
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Weights
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem sourceSamplingWidth_le_half (s : ℕ) : sourceSamplingWidth s ≤ 1/2 := by
|
| 11 |
+
have hm : (100 : ℝ) ≤ sourceBlockSize s := by exact_mod_cast (sourceStage s).m_ge_100
|
| 12 |
+
have hm0 : 0 ≤ (sourceBlockSize s : ℝ) := by positivity
|
| 13 |
+
have he : sourceSamplingWidth s ≤ (sourceBlockSize s : ℝ)^(-1/2 : ℝ) :=
|
| 14 |
+
Real.rpow_le_rpow_of_exponent_le (by linarith) (by norm_num)
|
| 15 |
+
have hs : 2 ≤ Real.sqrt (sourceBlockSize s : ℝ) := by
|
| 16 |
+
nlinarith [Real.sq_sqrt hm0,Real.sqrt_nonneg (sourceBlockSize s : ℝ)]
|
| 17 |
+
apply he.trans
|
| 18 |
+
rw [show (-1/2 : ℝ) = -(1/2) by ring,Real.rpow_neg hm0,← Real.sqrt_eq_rpow]
|
| 19 |
+
simpa only [one_div] using (one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 2) hs)
|
| 20 |
+
|
| 21 |
+
/-- Exact stage parameters discharge all cutoff/width assumptions in the
|
| 22 |
+
source's tested second-diagonal one-coordinate moment bound. -/
|
| 23 |
+
theorem sourceSampling_tested_second_moment (s : ℕ) (E G : Set ℝ)
|
| 24 |
+
(hE : MeasurableSet E) (hG : MeasurableSet G) :
|
| 25 |
+
(∀ᵐ x ∂unitIntervalMeasure,
|
| 26 |
+
0 ≤ samplingTestedSecondDensity (sourceSamplingWidth s) (sourceSamplingCutoff s) E G x ∧
|
| 27 |
+
samplingTestedSecondDensity (sourceSamplingWidth s) (sourceSamplingCutoff s) E G x ≤ 2) ∧
|
| 28 |
+
(∫ x, samplingTestedSecondDensity (sourceSamplingWidth s) (sourceSamplingCutoff s) E G x^2
|
| 29 |
+
∂unitIntervalMeasure) ≤ 1+4*(sourceBlockSize s : ℝ)^(-6/5 : ℝ) := by
|
| 30 |
+
have hp := sourceSampling_parameters s
|
| 31 |
+
have hhalf := sourceSamplingWidth_le_half s
|
| 32 |
+
have hden : 0 < 1-sourceSamplingWidth s := by linarith [hp.2.1]
|
| 33 |
+
have hb := samplingTestedSecondDensity_square (sourceSamplingWidth s) (sourceSamplingCutoff s)
|
| 34 |
+
E G hp.1 hp.2.1 hp.2.2 hE hG
|
| 35 |
+
have hi : 1/(1-sourceSamplingWidth s) ≤ 2 := (div_le_iff₀ hden).mpr (by linarith)
|
| 36 |
+
have herror : (sourceSamplingWidth s)^2/(1-sourceSamplingWidth s)^2 ≤ 4*(sourceSamplingWidth s)^2 := by
|
| 37 |
+
apply (div_le_iff₀ (sq_pos_of_pos hden)).mpr
|
| 38 |
+
have hsq : (1/4 : ℝ) ≤ (1-sourceSamplingWidth s)^2 := by nlinarith
|
| 39 |
+
nlinarith [sq_nonneg (sourceSamplingWidth s),mul_nonneg (sq_nonneg (sourceSamplingWidth s))
|
| 40 |
+
(show 0 ≤ (1-sourceSamplingWidth s)^2-1/4 by linarith)]
|
| 41 |
+
have he : (sourceSamplingWidth s)^2 = (sourceBlockSize s : ℝ)^(-6/5 : ℝ) := by
|
| 42 |
+
unfold sourceSamplingWidth
|
| 43 |
+
rw [← Real.rpow_natCast,← Real.rpow_mul (sourceBlockSize_pos s).le]
|
| 44 |
+
norm_num
|
| 45 |
+
exact ⟨hb.1.mono (fun x hx => ⟨hx.1,hx.2.trans hi⟩),hb.2.trans (by rw [← he]; linarith)⟩
|
| 46 |
+
|
| 47 |
+
end
|
| 48 |
+
end FiniteFactor
|
| 49 |
+
|
| 50 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/OrbitSupport.lean
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.OrderedRestriction
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingPositiveOrbits (s : ℕ) (θ : SourceCoordinate → ℝ) : Set SourceSamplingPair :=
|
| 11 |
+
{p | ∃ n ∈ sourceSamplingPowers s, 0 < n ∧ p.2 = coordinateRotate θ n p.1}
|
| 12 |
+
|
| 13 |
+
theorem sourceSamplingPositiveOrbits_measurable (s : ℕ) (θ : SourceCoordinate → ℝ) :
|
| 14 |
+
MeasurableSet (sourceSamplingPositiveOrbits s θ) := by
|
| 15 |
+
simp only [sourceSamplingPositiveOrbits,Set.ofPred_exists]
|
| 16 |
+
apply MeasurableSet.iUnion
|
| 17 |
+
intro n
|
| 18 |
+
by_cases hn : n ∈ sourceSamplingPowers s
|
| 19 |
+
· simp only [hn,true_and]
|
| 20 |
+
by_cases hp : 0 < n
|
| 21 |
+
· simp only [hp,true_and]
|
| 22 |
+
exact measurableSet_eq_fun measurable_snd ((coordinateRotate_preserving θ n).measurable.comp measurable_fst)
|
| 23 |
+
· simp [hp]
|
| 24 |
+
· simp [hn]
|
| 25 |
+
|
| 26 |
+
theorem sourceSamplingSummand_positive_orbit (I : Finset SourceCoordinate) (s : ℕ)
|
| 27 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) (hn : n ∈ sourceSamplingPowers s) :
|
| 28 |
+
∀ᵐ p ∂sourceSamplingSummand I s θ n, p ∈ sourceSamplingPositiveOrbits s θ := by
|
| 29 |
+
apply (ae_map_iff (measurable_id.prodMk (coordinateRotate_preserving θ n).measurable).aemeasurable
|
| 30 |
+
(sourceSamplingPositiveOrbits_measurable s θ)).mpr
|
| 31 |
+
exact Eventually.of_forall (fun x => ⟨n,hn,(sourceSamplingPowers_positive s n hn).1,rfl⟩)
|
| 32 |
+
|
| 33 |
+
/-- Trimming preserves the constructed finite set of strictly positive
|
| 34 |
+
orbit powers while imposing coordinatewise order everywhere. -/
|
| 35 |
+
theorem sourceSamplingTrimmed_orbits (I : Finset SourceCoordinate) (s : ℕ)
|
| 36 |
+
(θ : SourceCoordinate → ℝ) : ∀ᵐ p ∂sourceSamplingTrimmed I s θ,
|
| 37 |
+
(∀ i, p.1 i ≤ p.2 i) ∧ ∃ n ∈ sourceSamplingPowers s, 0 < n ∧ p.2 = coordinateRotate θ n p.1 := by
|
| 38 |
+
have hu : ∀ᵐ p ∂sourceSamplingUntrimmed I s θ, p ∈ sourceSamplingPositiveOrbits s θ := by
|
| 39 |
+
apply Measure.ae_smul_measure
|
| 40 |
+
rw [ae_iff,Measure.finsetSum_apply]
|
| 41 |
+
exact Finset.sum_eq_zero (fun n hn => ae_iff.mp (sourceSamplingSummand_positive_orbit I s θ n hn))
|
| 42 |
+
filter_upwards [sourceSamplingTrimmed_ordered I s θ,ae_restrict_of_ae hu] with p ho hp
|
| 43 |
+
exact ⟨ho,hp⟩
|
| 44 |
+
|
| 45 |
+
end
|
| 46 |
+
end FiniteFactor
|
| 47 |
+
|
| 48 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/OrderedRestriction.lean
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Cube
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.WeightedTail
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
def sourceSamplingOrdered : Set SourceSamplingPair := {p | ∀ i, p.1 i ≤ p.2 i}
|
| 12 |
+
|
| 13 |
+
theorem sourceSamplingOrdered_measurable : MeasurableSet sourceSamplingOrdered := by
|
| 14 |
+
simp only [sourceSamplingOrdered,Set.ofPred_forall]
|
| 15 |
+
exact MeasurableSet.iInter (fun i => measurableSet_le
|
| 16 |
+
((measurable_pi_apply i).comp measurable_fst) ((measurable_pi_apply i).comp measurable_snd))
|
| 17 |
+
|
| 18 |
+
/-- The actual ordered restriction of the already constructed average. -/
|
| 19 |
+
def sourceSamplingTrimmed (I : Finset SourceCoordinate) (s : ℕ) (θ : SourceCoordinate → ℝ) :
|
| 20 |
+
Measure SourceSamplingPair := (sourceSamplingUntrimmed I s θ).restrict sourceSamplingOrdered
|
| 21 |
+
|
| 22 |
+
instance sourceSamplingTrimmed_finite (I : Finset SourceCoordinate) (s : ℕ)
|
| 23 |
+
(θ : SourceCoordinate → ℝ) : IsFiniteMeasure (sourceSamplingTrimmed I s θ) := by
|
| 24 |
+
unfold sourceSamplingTrimmed
|
| 25 |
+
infer_instance
|
| 26 |
+
|
| 27 |
+
theorem sourceSamplingTrimmed_ordered (I : Finset SourceCoordinate) (s : ℕ)
|
| 28 |
+
(θ : SourceCoordinate → ℝ) : ∀ᵐ p ∂sourceSamplingTrimmed I s θ, ∀ i, p.1 i ≤ p.2 i :=
|
| 29 |
+
ae_restrict_mem sourceSamplingOrdered_measurable
|
| 30 |
+
|
| 31 |
+
theorem sourceSamplingTrimmed_le (I : Finset SourceCoordinate) (s : ℕ)
|
| 32 |
+
(θ : SourceCoordinate → ℝ) : sourceSamplingTrimmed I s θ ≤ sourceSamplingUntrimmed I s θ :=
|
| 33 |
+
Measure.restrict_le_self
|
| 34 |
+
|
| 35 |
+
theorem sourceSamplingPowers_positive (s : ℕ) (n : ℤ) (hn : n ∈ sourceSamplingPowers s) :
|
| 36 |
+
0 < n ∧ (n : ℝ) ≤ samplingQ (sourceBlockSize s) := by
|
| 37 |
+
by_cases hs : 200000 ≤ sourceBlockSize s
|
| 38 |
+
· exact ⟨((sourceSamplingPowers_spec s hs).1 n hn).2.2,
|
| 39 |
+
((sourceSamplingPowers_spec s hs).1 n hn).2.1⟩
|
| 40 |
+
· simp [sourceSamplingPowers,hs] at hn
|
| 41 |
+
|
| 42 |
+
/-- Outside the finite prefix, every failure of global order is an actual
|
| 43 |
+
member of the source's countable tail-failure event. -/
|
| 44 |
+
theorem sourceSampling_order_failure_tail (s n : ℕ) (θ x : SourceCoordinate → ℝ)
|
| 45 |
+
(hprefix : ∀ i ∈ sourceSamplingPrefix s, x i < coordinateRotate θ (n : ℤ) x i)
|
| 46 |
+
(hbad : (x,coordinateRotate θ (n : ℤ) x) ∉ sourceSamplingOrdered) :
|
| 47 |
+
x ∈ sourceTailOrderFailure θ (s+1) n := by
|
| 48 |
+
have hb : ∃ i, coordinateRotate θ (n : ℤ) x i < x i := by
|
| 49 |
+
simpa only [sourceSamplingOrdered,Set.mem_ofPred_eq,not_forall,not_le] using hbad
|
| 50 |
+
obtain ⟨i,hi⟩ := hb
|
| 51 |
+
have hout : i ∉ sourceSamplingPrefix s := fun hh => (hprefix i hh).asymm hi
|
| 52 |
+
have hk : s+1 ≤ i.1 := by
|
| 53 |
+
have hh := (CouplingParameters.mem_blockPrefix sourceBlockSize (s+1) i)
|
| 54 |
+
change i ∉ CouplingParameters.blockPrefix sourceBlockSize (s+1) at hout
|
| 55 |
+
have hnot : ¬ i.1 < s+1 := fun hi => hout (hh.mpr hi)
|
| 56 |
+
omega
|
| 57 |
+
rcases i with ⟨k,j⟩
|
| 58 |
+
obtain ⟨r,rfl⟩ := Nat.exists_eq_add_of_le hk
|
| 59 |
+
apply Set.mem_iUnion.mpr ⟨r,?_⟩
|
| 60 |
+
apply Set.mem_iUnion.mpr ⟨j,?_⟩
|
| 61 |
+
simpa only [coordinateRotate,Int.cast_natCast,Set.mem_ofPred_eq] using hi
|
| 62 |
+
|
| 63 |
+
/-- Discarded mass of each real summand obeys the preserved relative
|
| 64 |
+
weighted-tail estimate. This includes summands of mass zero. -/
|
| 65 |
+
theorem sourceSamplingSummand_discarded_le (I : Finset SourceCoordinate) (s : ℕ)
|
| 66 |
+
(θ : SourceCoordinate → ℝ) (hθ : SourceAngles θ) (n : ℤ)
|
| 67 |
+
(hn : n ∈ sourceSamplingPowers s) :
|
| 68 |
+
sourceSamplingSummand I s θ n sourceSamplingOrderedᶜ ≤
|
| 69 |
+
sourceSamplingSummand I s θ n Set.univ *
|
| 70 |
+
ENNReal.ofReal (4*(sourceBlockSize s : ℝ)^(-(sourceBlockSize s : ℝ)/20)) := by
|
| 71 |
+
have hp := sourceSamplingPowers_positive s n hn
|
| 72 |
+
have he : (n.toNat : ℤ) = n := Int.toNat_of_nonneg hp.1.le
|
| 73 |
+
have hm : Measurable (fun x => (x,coordinateRotate θ n x)) :=
|
| 74 |
+
measurable_id.prodMk (coordinateRotate_preserving θ n).measurable
|
| 75 |
+
rw [sourceSamplingSummand,Measure.map_apply hm sourceSamplingOrdered_measurable.compl,
|
| 76 |
+
Measure.map_apply hm MeasurableSet.univ,Set.preimage_univ]
|
| 77 |
+
have hc : (n.toNat : ℝ) = (n : ℝ) := by exact_mod_cast he
|
| 78 |
+
have hb := sourceSampling_weighted_tail_small I s θ hθ n.toNat (by rw [hc]; exact hp.2)
|
| 79 |
+
rw [he] at hb
|
| 80 |
+
apply le_trans _ hb
|
| 81 |
+
apply measure_mono_ae
|
| 82 |
+
filter_upwards [sourceSamplingWeightedMeasure_orders I s θ n] with x hx
|
| 83 |
+
intro hb
|
| 84 |
+
change (x,coordinateRotate θ n x) ∉ sourceSamplingOrdered at hb
|
| 85 |
+
exact sourceSampling_order_failure_tail s n.toNat θ x (by simpa [he] using hx) (by simpa [he] using hb)
|
| 86 |
+
|
| 87 |
+
/-- The average loses at most the same relative error as each summand. -/
|
| 88 |
+
theorem sourceSamplingUntrimmed_discarded_le (I : Finset SourceCoordinate) (s : ℕ)
|
| 89 |
+
(θ : SourceCoordinate → ℝ) (hθ : SourceAngles θ) :
|
| 90 |
+
sourceSamplingUntrimmed I s θ sourceSamplingOrderedᶜ ≤
|
| 91 |
+
sourceSamplingUntrimmed I s θ Set.univ *
|
| 92 |
+
ENNReal.ofReal (4*(sourceBlockSize s : ℝ)^(-(sourceBlockSize s : ℝ)/20)) := by
|
| 93 |
+
simp only [sourceSamplingUntrimmed,Measure.smul_apply,smul_eq_mul,Measure.finsetSum_apply]
|
| 94 |
+
rw [mul_assoc,Finset.sum_mul]
|
| 95 |
+
exact mul_le_mul' le_rfl (Finset.sum_le_sum (fun n hn => sourceSamplingSummand_discarded_le I s θ hθ n hn))
|
| 96 |
+
|
| 97 |
+
end
|
| 98 |
+
end FiniteFactor
|
| 99 |
+
|
| 100 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/PairMoments.lean
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.SecondCorrelation
|
| 2 |
+
import OAI.Analysis.FiniteFactor.Sampling.SecondTriangular
|
| 3 |
+
import OAI.Analysis.FiniteFactor.Sampling.IntegratedCorrelation
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Filter
|
| 9 |
+
open scoped Classical
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
/-- All four actual tested coordinate cases have the same pair-error budget. -/
|
| 13 |
+
theorem sourceSampling_oriented_pair_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 14 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n n' : ℤ)
|
| 15 |
+
(hn : n ∈ sourceSamplingPowers stage) (hn' : n' ∈ sourceSamplingPowers stage) (hne : n ≠ n')
|
| 16 |
+
(r b : Bool) (a c a' c' s : ℝ) (hsx : s ∈ Set.Ioo (0 : ℝ) 1) :
|
| 17 |
+
|(∫ θ, samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 18 |
+
(Set.Icc a c) (Set.Icc a' c') s (Int.fract ((n : ℝ)*θ i)) *
|
| 19 |
+
samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 20 |
+
(Set.Icc a c) (Set.Icc a' c') s (Int.fract ((n' : ℝ)*θ i)) ∂sourceAngleLaw) -
|
| 21 |
+
samplingOrientedDensity r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 22 |
+
(Set.Icc a c) (Set.Icc a' c') s ^ 2| ≤
|
| 23 |
+
104*(sourceBlockSize stage : ℝ)^(-74 : ℝ) := by
|
| 24 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by
|
| 25 |
+
have h := (sourceStage stage).m_ge_100
|
| 26 |
+
exact_mod_cast (by omega : 1 ≤ sourceBlockSize stage)
|
| 27 |
+
cases r
|
| 28 |
+
· have hb := sourceSampling_first_pair_error stage hs i hi n n' hn hn' hne b
|
| 29 |
+
(Set.Icc a c) a' c' s ⟨hsx.1.le,hsx.2⟩
|
| 30 |
+
exact hb.trans (by nlinarith [Real.rpow_nonneg (sourceBlockSize_pos stage).le (-74 : ℝ)])
|
| 31 |
+
· cases b
|
| 32 |
+
· exact sourceSampling_second_pair_error stage hs i hi n n' hn hn' hne
|
| 33 |
+
(Set.Icc a' c') measurableSet_Icc a c s ⟨hsx.1.le,hsx.2⟩
|
| 34 |
+
· have := sourceSampling_phase_null_singletons stage hs i hi n hn
|
| 35 |
+
have := sourceSampling_phase_null_singletons stage hs i hi n' hn'
|
| 36 |
+
have hm (k : ℤ) : Measurable (fun θ : SourceCoordinate → ℝ => Int.fract ((k : ℝ)*θ i)) :=
|
| 37 |
+
sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i))
|
| 38 |
+
have hp := sourceSampling_parameters stage
|
| 39 |
+
have hb := samplingSecondTriangular_pair_bound sourceAngleLaw
|
| 40 |
+
(fun θ => Int.fract ((n : ℝ)*θ i)) (fun θ => Int.fract ((n' : ℝ)*θ i)) (hm n) (hm n')
|
| 41 |
+
(Eventually.of_forall (fun θ => ⟨Int.fract_nonneg _,Int.fract_lt_one _⟩))
|
| 42 |
+
(Eventually.of_forall (fun θ => ⟨Int.fract_nonneg _,Int.fract_lt_one _⟩))
|
| 43 |
+
_ (by positivity) (sourceSampling_rectangle_bound stage hs i hi n n' hn hn' hne)
|
| 44 |
+
_ _ (Set.Icc a' c') a c s hp.1 hp.2.1 hp.2.2 hsx
|
| 45 |
+
apply hb.trans
|
| 46 |
+
have he := Real.rpow_le_rpow_of_exponent_le hm1 (show (-80 : ℝ) ≤ -74 by norm_num)
|
| 47 |
+
nlinarith [Real.rpow_nonneg (sourceBlockSize_pos stage).le (-74 : ℝ)]
|
| 48 |
+
|
| 49 |
+
theorem sourceSampling_coordinate_pair_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 50 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n n' : ℤ)
|
| 51 |
+
(hn : n ∈ sourceSamplingPowers stage) (hn' : n' ∈ sourceSamplingPowers stage) (hne : n ≠ n')
|
| 52 |
+
(r b : Bool) (a c a' c' : ℝ) :
|
| 53 |
+
|(∫ s, ∫ θ, samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 54 |
+
(Set.Icc a c) (Set.Icc a' c') s (Int.fract ((n : ℝ)*θ i)) *
|
| 55 |
+
samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 56 |
+
(Set.Icc a c) (Set.Icc a' c') s (Int.fract ((n' : ℝ)*θ i)) ∂sourceAngleLaw ∂unitIntervalMeasure) -
|
| 57 |
+
(∫ s, samplingOrientedDensity r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 58 |
+
(Set.Icc a c) (Set.Icc a' c') s ^ 2 ∂unitIntervalMeasure)| ≤
|
| 59 |
+
104*(sourceBlockSize stage : ℝ)^(-74 : ℝ) := by
|
| 60 |
+
have hp := sourceSampling_parameters stage
|
| 61 |
+
apply sampling_integrated_pair_error sourceAngleLaw
|
| 62 |
+
(fun θ => Int.fract ((n : ℝ)*θ i)) (fun θ => Int.fract ((n' : ℝ)*θ i))
|
| 63 |
+
(sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i)))
|
| 64 |
+
(sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i)))
|
| 65 |
+
(samplingOrientedWeight r b _ _ (Set.Icc a c) (Set.Icc a' c'))
|
| 66 |
+
(samplingOrientedWeight_measurable r b _ _ _ _ measurableSet_Icc measurableSet_Icc)
|
| 67 |
+
(max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage))) _
|
| 68 |
+
(samplingOrientedWeight_bounds r b _ _ _ _ hp.1 hp.2.2)
|
| 69 |
+
have : NullSingletonClass unitIntervalMeasure := by unfold unitIntervalMeasure; infer_instance
|
| 70 |
+
filter_upwards [self_mem_ae_restrict measurableSet_Ico,
|
| 71 |
+
ae_iff.mpr (show unitIntervalMeasure {s | ¬s ≠ 0} = 0 by simp)] with s hsx hs0
|
| 72 |
+
exact sourceSampling_oriented_pair_error stage hs i hi n n' hn hn' hne r b a c a' c' s
|
| 73 |
+
⟨lt_of_le_of_ne hsx.1 (Ne.symm hs0),hsx.2⟩
|
| 74 |
+
|
| 75 |
+
end
|
| 76 |
+
end FiniteFactor
|
| 77 |
+
|
| 78 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/PhaseSelfMoment.lean
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.SelfMoment
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter
|
| 7 |
+
open scoped ENNReal
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- Marginal phase domination controls the joint self-pair integral.
|
| 11 |
+
This is the source's one-phase step before taking coordinate products. -/
|
| 12 |
+
theorem sampling_phase_square_bound {Ω : Type*} [MeasurableSpace Ω]
|
| 13 |
+
(μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) (hX : Measurable X)
|
| 14 |
+
(hdom : μ.map X ≤ (2 : ℝ≥0∞) • unitIntervalMeasure)
|
| 15 |
+
(u : ℝ → ℝ → ℝ) (C : ℝ) (hu : Measurable (fun p : ℝ × ℝ => u p.1 p.2))
|
| 16 |
+
(hb : ∀ s t, 0 ≤ u s t ∧ u s t ≤ C) :
|
| 17 |
+
(∫ s, ∫ ω, u s (X ω)^2 ∂μ ∂unitIntervalMeasure) ≤
|
| 18 |
+
2*(∫ s, ∫ t, u s t^2 ∂unitIntervalMeasure ∂unitIntervalMeasure) := by
|
| 19 |
+
have hΩ : Measurable (fun p : ℝ × Ω => u p.1 (X p.2)) :=
|
| 20 |
+
hu.comp (measurable_fst.prodMk (hX.comp measurable_snd))
|
| 21 |
+
have hiΩ := sampling_square_integrable (unitIntervalMeasure.prod μ) _ C hΩ
|
| 22 |
+
(fun p => hb p.1 (X p.2))
|
| 23 |
+
have hiU := sampling_square_integrable (unitIntervalMeasure.prod unitIntervalMeasure) _ C hu
|
| 24 |
+
(fun p => hb p.1 p.2)
|
| 25 |
+
have hpoint (s : ℝ) : (∫ ω, u s (X ω)^2 ∂μ) ≤ 2*(∫ t, u s t^2 ∂unitIntervalMeasure) := by
|
| 26 |
+
have hm : Measurable (fun t => u s t) := hu.comp (measurable_const.prodMk measurable_id)
|
| 27 |
+
have hi := sampling_square_integrable unitIntervalMeasure _ C hm (hb s)
|
| 28 |
+
have hbig := hi.smul_measure (c := (2 : ℝ≥0∞)) (by norm_num)
|
| 29 |
+
have hle := integral_mono_measure hdom (Eventually.of_forall (fun t => sq_nonneg (u s t))) hbig
|
| 30 |
+
rw [integral_map hX.aemeasurable (hm.pow_const 2).aestronglyMeasurable,
|
| 31 |
+
integral_smul_measure] at hle
|
| 32 |
+
simpa using hle
|
| 33 |
+
calc
|
| 34 |
+
_ ≤ ∫ s, 2*(∫ t, u s t^2 ∂unitIntervalMeasure) ∂unitIntervalMeasure :=
|
| 35 |
+
integral_mono_ae hiΩ.integral_prod_left (hiU.integral_prod_left.const_mul 2)
|
| 36 |
+
(Eventually.of_forall hpoint)
|
| 37 |
+
_ = _ := integral_const_mul _ _
|
| 38 |
+
|
| 39 |
+
/-- Actual angle expectation of the tested self-pair, at every admissible
|
| 40 |
+
selected power, for all source orientations and coordinate types. -/
|
| 41 |
+
theorem sourceSampling_phase_self_moment (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 42 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n : ℤ) (hn : n ∈ sourceSamplingPowers stage)
|
| 43 |
+
(r b : Bool) (E G : Set ℝ) (hE : MeasurableSet E) (hG : MeasurableSet G) :
|
| 44 |
+
(∫ s, ∫ θ, samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 45 |
+
E G s (Int.fract ((n : ℝ)*θ i)) ^ 2 ∂sourceAngleLaw ∂unitIntervalMeasure) ≤
|
| 46 |
+
2+8*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ) := by
|
| 47 |
+
have hp := sourceSampling_parameters stage
|
| 48 |
+
have hbound := sampling_phase_square_bound sourceAngleLaw (fun θ => Int.fract ((n : ℝ)*θ i))
|
| 49 |
+
(sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i)))
|
| 50 |
+
(sourceSampling_phase_domination stage hs i hi n hn)
|
| 51 |
+
(samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E G)
|
| 52 |
+
(max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))
|
| 53 |
+
(samplingOrientedWeight_measurable r b _ _ E G hE hG)
|
| 54 |
+
(samplingOrientedWeight_bounds r b _ _ E G hp.1 hp.2.2)
|
| 55 |
+
have hself := sourceSampling_oriented_self_moment stage r b E G hE hG
|
| 56 |
+
exact hbound.trans (by nlinarith)
|
| 57 |
+
|
| 58 |
+
end
|
| 59 |
+
end FiniteFactor
|
| 60 |
+
|
| 61 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Powers.lean
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.Selection
|
| 2 |
+
import OAI.Analysis.FiniteFactor.CrossedProduct.PhaseDecay
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open Finset Filter
|
| 8 |
+
open scoped Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
def samplingQ (m : ℕ) : ℝ := (m : ℝ)^((7/10 : ℝ)*(m : ℝ))
|
| 12 |
+
def samplingH (m : ℕ) : ℕ := m^300
|
| 13 |
+
def samplingR (m K : ℕ) : ℕ := m*K*m^1000
|
| 14 |
+
|
| 15 |
+
theorem sampling_integer_candidates (Q : ℝ) (hQ : 4 ≤ Q) :
|
| 16 |
+
Q/4 ≤ ((Finset.Icc ⌈Q/2⌉ ⌊Q⌋).card : ℝ) := by
|
| 17 |
+
have hf := Int.sub_one_lt_floor Q
|
| 18 |
+
have hc := Int.ceil_lt_add_one (Q/2)
|
| 19 |
+
have horder : ⌈Q/2⌉ ≤ ⌊Q⌋ := by
|
| 20 |
+
have : (⌈Q/2⌉ : ℝ) < (⌊Q⌋ : ℝ)+1 := by linarith
|
| 21 |
+
have ht : ⌈Q/2⌉ < ⌊Q⌋+1 := by exact_mod_cast this
|
| 22 |
+
omega
|
| 23 |
+
rw [Int.card_Icc]
|
| 24 |
+
have hcast : ((⌊Q⌋+1-⌈Q/2⌉).toNat : ℝ) = (⌊Q⌋ : ℝ)+1-(⌈Q/2⌉ : ℝ) := by
|
| 25 |
+
exact_mod_cast Int.toNat_of_nonneg (by omega : 0 ≤ ⌊Q⌋+1-⌈Q/2⌉)
|
| 26 |
+
rw [hcast]
|
| 27 |
+
linarith
|
| 28 |
+
|
| 29 |
+
theorem sampling_forbidden_budget (m K : ℕ) (hm : 4 ≤ m) (hK : K ≤ m) :
|
| 30 |
+
(((2*samplingH m+1)^2*(2*samplingR m K+1) : ℕ) : ℝ) ≤ (m : ℝ)^1605 := by
|
| 31 |
+
have hm1 : 1 ≤ m := by omega
|
| 32 |
+
have hh : 1 ≤ samplingH m := one_le_pow₀ hm1
|
| 33 |
+
have hr : samplingR m K ≤ m^1002 := by
|
| 34 |
+
unfold samplingR
|
| 35 |
+
calc
|
| 36 |
+
m*K*m^1000 ≤ m*m*m^1000 := by gcongr
|
| 37 |
+
_ = m^1002 := by ring
|
| 38 |
+
have hp : 1 ≤ m^1002 := one_le_pow₀ hm1
|
| 39 |
+
have hD : (2*samplingH m+1)^2*(2*samplingR m K+1) ≤ 27*m^1602 := by
|
| 40 |
+
calc
|
| 41 |
+
_ ≤ (3*samplingH m)^2*(3*m^1002) := by gcongr <;> omega
|
| 42 |
+
_ = _ := by unfold samplingH; ring
|
| 43 |
+
have h27 : 27 ≤ m^3 := (by norm_num : 27 ≤ (4 : ℕ)^3).trans (Nat.pow_le_pow_left hm 3)
|
| 44 |
+
have hhD : (2*samplingH m+1)^2*(2*samplingR m K+1) ≤ m^1605 := by
|
| 45 |
+
calc
|
| 46 |
+
_ ≤ 27*m^1602 := hD
|
| 47 |
+
_ ≤ m^3*m^1602 := Nat.mul_le_mul_right _ h27
|
| 48 |
+
_ = _ := by ring
|
| 49 |
+
exact_mod_cast hhD
|
| 50 |
+
|
| 51 |
+
/-- An explicit sufficiently-large threshold discharges the source's greedy
|
| 52 |
+
asymptotics, retaining Q, H, R and the exponent 0.69m exactly. -/
|
| 53 |
+
theorem exists_source_sampling_powers (m K : ℕ) (hm : 200000 ≤ m) (hK : K ≤ m) :
|
| 54 |
+
∃ N : Finset ℤ,
|
| 55 |
+
(∀ n ∈ N, samplingQ m/2 ≤ (n : ℝ) ∧ (n : ℝ) ≤ samplingQ m ∧ 0 < n) ∧
|
| 56 |
+
(m : ℝ)^((69/100 : ℝ)*(m : ℝ)) ≤ (N.card : ℝ) ∧
|
| 57 |
+
(N : Set ℤ).Pairwise (fun n n' => ¬SamplingConflict (samplingH m) (samplingR m K) n n') := by
|
| 58 |
+
have hmR : (200000 : ℝ) ≤ m := by exact_mod_cast hm
|
| 59 |
+
have hm0 : (0 : ℝ) < m := by linarith
|
| 60 |
+
have hm1 : (1 : ℝ) ≤ m := by linarith
|
| 61 |
+
have hQ : (m : ℝ)^1606 ≤ samplingQ m := by
|
| 62 |
+
unfold samplingQ
|
| 63 |
+
rw [← Real.rpow_natCast]
|
| 64 |
+
apply Real.rpow_le_rpow_of_exponent_le hm1
|
| 65 |
+
norm_num
|
| 66 |
+
linarith
|
| 67 |
+
have hmQ : (m : ℝ) ≤ samplingQ m := by
|
| 68 |
+
calc
|
| 69 |
+
_ ≤ (m : ℝ)^1606 := le_self_pow₀ hm1 (by norm_num)
|
| 70 |
+
_ ≤ _ := hQ
|
| 71 |
+
have hQ4 : 4 ≤ samplingQ m := by linarith
|
| 72 |
+
have hR : (samplingR m K : ℝ) < samplingQ m/2 := by
|
| 73 |
+
have hr : samplingR m K ≤ m^1002 := by
|
| 74 |
+
unfold samplingR
|
| 75 |
+
calc
|
| 76 |
+
m*K*m^1000 ≤ m*m*m^1000 := by gcongr
|
| 77 |
+
_ = _ := by ring
|
| 78 |
+
have hsmall : (m : ℝ)^1002 * (m : ℝ) ≤ (m : ℝ)^1606 := by
|
| 79 |
+
rw [← pow_succ]
|
| 80 |
+
exact pow_le_pow_right₀ hm1 (by norm_num)
|
| 81 |
+
have hrR : (samplingR m K : ℝ) ≤ (m : ℝ)^1002 := by exact_mod_cast hr
|
| 82 |
+
have hpos : 0 < (m : ℝ)^1002 := by positivity
|
| 83 |
+
nlinarith
|
| 84 |
+
let S := Finset.Icc ⌈samplingQ m/2⌉ ⌊samplingQ m⌋
|
| 85 |
+
have hS (n : ℤ) (hn : n ∈ S) :
|
| 86 |
+
samplingQ m/2 ≤ (n : ℝ) ∧ (n : ℝ) ≤ samplingQ m := by
|
| 87 |
+
have hh := mem_Icc.mp hn
|
| 88 |
+
constructor
|
| 89 |
+
· exact (Int.le_ceil _).trans (by exact_mod_cast hh.1)
|
| 90 |
+
· exact (show (n : ℝ) ≤ (⌊samplingQ m⌋ : ℝ) by exact_mod_cast hh.2).trans (Int.floor_le _)
|
| 91 |
+
obtain ⟨N,hNS,hpair,hcard⟩ := exists_sampling_separated (samplingH m) (samplingR m K)
|
| 92 |
+
(one_le_pow₀ (by omega)) S (fun n hn => by exact_mod_cast hR.trans_le (hS n hn).1)
|
| 93 |
+
refine ⟨N, fun n hn => ⟨(hS n (hNS hn)).1, (hS n (hNS hn)).2, ?_⟩, ?_, hpair⟩
|
| 94 |
+
· have hh := (hS n (hNS hn)).1
|
| 95 |
+
have : (0 : ℝ) < n := by linarith
|
| 96 |
+
exact_mod_cast this
|
| 97 |
+
· have hcount : samplingQ m/4 ≤
|
| 98 |
+
(((2*samplingH m+1)^2*(2*samplingR m K+1) : ℕ) : ℝ)*(N.card : ℝ) :=
|
| 99 |
+
(sampling_integer_candidates _ hQ4).trans (by exact_mod_cast hcard)
|
| 100 |
+
have hDb := sampling_forbidden_budget m K (by omega) hK
|
| 101 |
+
have hcount' : samplingQ m/4 ≤ (m : ℝ)^1605*(N.card : ℝ) :=
|
| 102 |
+
hcount.trans (mul_le_mul_of_nonneg_right hDb (Nat.cast_nonneg _))
|
| 103 |
+
have hexp : (m : ℝ)^1605*(m : ℝ)^((69/100 : ℝ)*(m : ℝ))*(m : ℝ) ≤ samplingQ m := by
|
| 104 |
+
unfold samplingQ
|
| 105 |
+
calc
|
| 106 |
+
_ = (m : ℝ)^(1605+(69/100 : ℝ)*(m : ℝ)+1) := by
|
| 107 |
+
rw [Real.rpow_add hm0, Real.rpow_one, Real.rpow_add hm0]
|
| 108 |
+
norm_num [Real.rpow_ofNat]
|
| 109 |
+
_ ≤ _ := by
|
| 110 |
+
apply Real.rpow_le_rpow_of_exponent_le hm1
|
| 111 |
+
norm_num
|
| 112 |
+
linarith
|
| 113 |
+
have hprod : 0 < (m : ℝ)^1605 := by positivity
|
| 114 |
+
have htarget : 0 ≤ (m : ℝ)^((69/100 : ℝ)*(m : ℝ)) := by positivity
|
| 115 |
+
apply (mul_le_mul_iff_right₀ hprod).mp
|
| 116 |
+
nlinarith
|
| 117 |
+
|
| 118 |
+
/-- A deterministic finite set fixed from the numerical stages alone. -/
|
| 119 |
+
def sourceSamplingPowers (s : ℕ) : Finset ℤ :=
|
| 120 |
+
if h : 200000 ≤ sourceBlockSize s then
|
| 121 |
+
Classical.choose (exists_source_sampling_powers (sourceBlockSize s)
|
| 122 |
+
(sourceStageState s).K h (sourceStage s).m_ge_K)
|
| 123 |
+
else ∅
|
| 124 |
+
|
| 125 |
+
theorem sourceSamplingPowers_spec (s : ℕ) (hs : 200000 ≤ sourceBlockSize s) :
|
| 126 |
+
(∀ n ∈ sourceSamplingPowers s,
|
| 127 |
+
samplingQ (sourceBlockSize s)/2 ≤ (n : ℝ) ∧
|
| 128 |
+
(n : ℝ) ≤ samplingQ (sourceBlockSize s) ∧ 0 < n) ∧
|
| 129 |
+
(sourceBlockSize s : ℝ)^((69/100 : ℝ)*(sourceBlockSize s : ℝ)) ≤
|
| 130 |
+
((sourceSamplingPowers s).card : ℝ) ∧
|
| 131 |
+
((sourceSamplingPowers s : Finset ℤ) : Set ℤ).Pairwise (fun n n' =>
|
| 132 |
+
¬SamplingConflict (samplingH (sourceBlockSize s))
|
| 133 |
+
(samplingR (sourceBlockSize s) (sourceStageState s).K) n n') := by
|
| 134 |
+
unfold sourceSamplingPowers
|
| 135 |
+
rw [dite_eq_left hs]
|
| 136 |
+
exact Classical.choose_spec (exists_source_sampling_powers _ _ hs (sourceStage s).m_ge_K)
|
| 137 |
+
|
| 138 |
+
theorem sourceSamplingPowers_eventually : ∀ᶠ s in atTop,
|
| 139 |
+
(∀ n ∈ sourceSamplingPowers s,
|
| 140 |
+
samplingQ (sourceBlockSize s)/2 ≤ (n : ℝ) ∧
|
| 141 |
+
(n : ℝ) ≤ samplingQ (sourceBlockSize s) ∧ 0 < n) ∧
|
| 142 |
+
(sourceBlockSize s : ℝ)^((69/100 : ℝ)*(sourceBlockSize s : ℝ)) ≤
|
| 143 |
+
((sourceSamplingPowers s).card : ℝ) ∧
|
| 144 |
+
((sourceSamplingPowers s : Finset ℤ) : Set ℤ).Pairwise (fun n n' =>
|
| 145 |
+
¬SamplingConflict (samplingH (sourceBlockSize s))
|
| 146 |
+
(samplingR (sourceBlockSize s) (sourceStageState s).K) n n') := by
|
| 147 |
+
filter_upwards [sourceBlockSize_tendsto.eventually (eventually_ge_atTop 200000)] with s hs
|
| 148 |
+
exact sourceSamplingPowers_spec s hs
|
| 149 |
+
|
| 150 |
+
end
|
| 151 |
+
end FiniteFactor
|
| 152 |
+
|
| 153 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/ProductError.lean
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.CrossProducts
|
| 2 |
+
import OAI.Analysis.FiniteFactor.Sampling.ProductError
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingCorrelationBudget (stage : ℕ) : ℝ :=
|
| 11 |
+
((sourceSamplingPrefix stage).card : ℝ)*(104*(sourceBlockSize stage : ℝ)^(-74 : ℝ))*Real.exp 135
|
| 12 |
+
|
| 13 |
+
/-- Uniform telescoping budget from the actual ideal coordinate moments. -/
|
| 14 |
+
theorem sourceSampling_coordinate_product_error (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 15 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 16 |
+
(f : SourceCoordinate → ℝ) (hf : ∀ i ∈ sourceSamplingPrefix stage, 0 ≤ f i)
|
| 17 |
+
(he : ∀ i ∈ sourceSamplingPrefix stage,
|
| 18 |
+
|f i-(∫ s, samplingOrientedDensity r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 19 |
+
(E i) (G i) s^2 ∂unitIntervalMeasure)| ≤ 104*(sourceBlockSize stage : ℝ)^(-74 : ℝ)) :
|
| 20 |
+
|(∏ i ∈ sourceSamplingPrefix stage, f i)-
|
| 21 |
+
(∫ x, sourceSamplingIdealDensity stage r b E G x^2
|
| 22 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))| ≤ sourceSamplingCorrelationBudget stage := by
|
| 23 |
+
let A (i : SourceCoordinate) := ∫ s, samplingOrientedDensity r (b i) (sourceSamplingWidth stage)
|
| 24 |
+
(sourceSamplingCutoff stage) (E i) (G i) s^2 ∂unitIntervalMeasure
|
| 25 |
+
let x := (sourceBlockSize stage : ℝ)^(-6/5 : ℝ)
|
| 26 |
+
let ε := 104*(sourceBlockSize stage : ℝ)^(-74 : ℝ)
|
| 27 |
+
let M := 1+108*x
|
| 28 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by
|
| 29 |
+
have h : 100 ≤ sourceBlockSize stage := (sourceStage stage).m_ge_100
|
| 30 |
+
exact_mod_cast (show 1 ≤ sourceBlockSize stage by omega)
|
| 31 |
+
have hx : 0 ≤ x := by dsimp [x]; positivity
|
| 32 |
+
have hε : 0 ≤ ε := by dsimp [ε]; positivity
|
| 33 |
+
have hεx : ε ≤ 104*x := mul_le_mul_of_nonneg_left
|
| 34 |
+
(Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num : (-74 : ℝ) ≤ -6/5)) (by norm_num)
|
| 35 |
+
have hA (i : SourceCoordinate) : 0 ≤ A i ∧ A i ≤ 1+4*x :=
|
| 36 |
+
⟨integral_nonneg (fun _ => sq_nonneg _),(sourceSampling_oriented_moment stage r (b i) (E i) (G i) (hE i) (hG i)).2⟩
|
| 37 |
+
have hfb (i : SourceCoordinate) (hi : i ∈ sourceSamplingPrefix stage) : 0 ≤ f i ∧ f i ≤ M := by
|
| 38 |
+
refine ⟨hf i hi,?_⟩
|
| 39 |
+
have hh := (abs_le.mp (he i hi)).2
|
| 40 |
+
have ha := (hA i).2
|
| 41 |
+
dsimp [M]
|
| 42 |
+
change f i-A i ≤ ε at hh
|
| 43 |
+
linarith
|
| 44 |
+
have hAb (i : SourceCoordinate) (_hi : i ∈ sourceSamplingPrefix stage) : 0 ≤ A i ∧ A i ≤ M :=
|
| 45 |
+
⟨(hA i).1,(hA i).2.trans (by dsimp [M]; linarith)⟩
|
| 46 |
+
have hpow : M^(sourceSamplingPrefix stage).card ≤ Real.exp 135 := by
|
| 47 |
+
have hp := product_energy_le_exp (fun _i : sourceSamplingPrefix stage => M)
|
| 48 |
+
(fun _i : sourceSamplingPrefix stage => 108*x)
|
| 49 |
+
(fun _ => by dsimp [M]; positivity) (fun _ => le_rfl)
|
| 50 |
+
have hbudget : ((sourceSamplingPrefix stage).card : ℝ)*(108*x) ≤ 135 := by
|
| 51 |
+
have hh := sourceSampling_prefix_quadratic_budget stage
|
| 52 |
+
change ((sourceSamplingPrefix stage).card : ℝ)*(4*x) ≤ 5 at hh
|
| 53 |
+
nlinarith
|
| 54 |
+
have hp' : M^(sourceSamplingPrefix stage).card ≤
|
| 55 |
+
Real.exp (((sourceSamplingPrefix stage).card : ℝ)*(108*x)) := by simpa using hp
|
| 56 |
+
exact hp'.trans (Real.exp_le_exp.mpr hbudget)
|
| 57 |
+
rw [sourceSamplingIdealDensity_square stage r b E G hE hG]
|
| 58 |
+
apply (sampling_product_error (sourceSamplingPrefix stage) f A M ε (by dsimp [M]; linarith) hε hfb hAb he).trans
|
| 59 |
+
exact mul_le_mul_of_nonneg_left hpow (by positivity)
|
| 60 |
+
|
| 61 |
+
/-- Distinct products under the actual angle and Haar laws. -/
|
| 62 |
+
theorem sourceSamplingProduct_pair_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 63 |
+
(r : Bool) (b : SourceCoordinate → Bool) (a c a' c' : SourceCoordinate → ℝ)
|
| 64 |
+
(n k : ℤ) (hn : n ∈ sourceSamplingPowers stage) (hk : k ∈ sourceSamplingPowers stage) (hne : n ≠ k) :
|
| 65 |
+
|(∫ θ, ∫ x, sourceSamplingProduct stage r b (fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) n θ x *
|
| 66 |
+
sourceSamplingProduct stage r b (fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) k θ x
|
| 67 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) ∂sourceAngleLaw)-
|
| 68 |
+
(∫ x, sourceSamplingIdealDensity stage r b (fun i => Set.Icc (a i) (c i)) (fun i => Set.Icc (a' i) (c' i)) x^2
|
| 69 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))| ≤ sourceSamplingCorrelationBudget stage := by
|
| 70 |
+
rw [integral_integral_swap (sourceSamplingProduct_pair_integrable stage r b _ _
|
| 71 |
+
(fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc) n k),
|
| 72 |
+
sourceSamplingProduct_inner_factorization stage r b _ _ (fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc) n k]
|
| 73 |
+
apply sourceSampling_coordinate_product_error stage r b _ _ (fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)
|
| 74 |
+
· intro i _
|
| 75 |
+
have hp := sourceSampling_parameters stage
|
| 76 |
+
exact integral_nonneg (fun s => integral_nonneg (fun θ => mul_nonneg
|
| 77 |
+
(samplingOrientedWeight_bounds r (b i) _ _ _ _ hp.1 hp.2.2 s _).1
|
| 78 |
+
(samplingOrientedWeight_bounds r (b i) _ _ _ _ hp.1 hp.2.2 s _).1))
|
| 79 |
+
· intro i hi
|
| 80 |
+
have hip : i.1 ≤ stage := by
|
| 81 |
+
have hh := (CouplingParameters.mem_blockPrefix sourceBlockSize (stage+1) i).mp hi
|
| 82 |
+
omega
|
| 83 |
+
exact sourceSampling_coordinate_pair_error stage hs i hip n k hn hk hne r (b i) (a i) (c i) (a' i) (c' i)
|
| 84 |
+
|
| 85 |
+
/-- Actual mixed products have the same uniform error budget. -/
|
| 86 |
+
theorem sourceSamplingProduct_mixed_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 87 |
+
(r : Bool) (b : SourceCoordinate → Bool) (E G : SourceCoordinate → Set ℝ)
|
| 88 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 89 |
+
(n : ℤ) (hn : n ∈ sourceSamplingPowers stage) :
|
| 90 |
+
|(∫ θ, ∫ x, sourceSamplingProduct stage r b E G n θ x*sourceSamplingIdealDensity stage r b E G x
|
| 91 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) ∂sourceAngleLaw)-
|
| 92 |
+
(∫ x, sourceSamplingIdealDensity stage r b E G x^2
|
| 93 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure))| ≤ sourceSamplingCorrelationBudget stage := by
|
| 94 |
+
rw [integral_integral_swap (sourceSamplingProduct_mixed_integrable stage r b E G hE hG n),
|
| 95 |
+
sourceSamplingProduct_mixed_factorization stage r b E G hE hG n]
|
| 96 |
+
apply sourceSampling_coordinate_product_error stage r b E G hE hG
|
| 97 |
+
· intro i _
|
| 98 |
+
have hp := sourceSampling_parameters stage
|
| 99 |
+
exact integral_nonneg (fun s => mul_nonneg
|
| 100 |
+
(integral_nonneg (fun t => (samplingOrientedWeight_bounds r (b i) _ _ _ _ hp.1 hp.2.2 s t).1))
|
| 101 |
+
(integral_nonneg (fun θ => (samplingOrientedWeight_bounds r (b i) _ _ _ _ hp.1 hp.2.2 s _).1)))
|
| 102 |
+
· intro i hi
|
| 103 |
+
have hip : i.1 ≤ stage := by
|
| 104 |
+
have hh := (CouplingParameters.mem_blockPrefix sourceBlockSize (stage+1) i).mp hi
|
| 105 |
+
omega
|
| 106 |
+
apply (sourceSampling_coordinate_mixed_error stage hs i hip n hn r (b i) (E i) (G i) (hE i) (hG i)).trans
|
| 107 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (show 1 ≤ sourceBlockSize stage by omega)
|
| 108 |
+
have he := Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num : (-80 : ℝ) ≤ -74)
|
| 109 |
+
nlinarith [Real.rpow_nonneg (sourceBlockSize_pos stage).le (-74 : ℝ)]
|
| 110 |
+
|
| 111 |
+
end
|
| 112 |
+
end FiniteFactor
|
| 113 |
+
|
| 114 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/ProductMoments.lean
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.PhaseSelfMoment
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.IdealProduct
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingProduct (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 11 |
+
(E G : SourceCoordinate → Set ℝ) (n : ℤ) (θ x : SourceCoordinate → ℝ) : ℝ :=
|
| 12 |
+
∏ i ∈ sourceSamplingPrefix stage,
|
| 13 |
+
samplingOrientedWeight r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 14 |
+
(E i) (G i) (x i) (Int.fract ((n : ℝ)*θ i))
|
| 15 |
+
|
| 16 |
+
theorem sourceSamplingProduct_measurable (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 17 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) (n : ℤ) :
|
| 18 |
+
Measurable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) => sourceSamplingProduct stage r b E G n p.1 p.2) := by
|
| 19 |
+
unfold sourceSamplingProduct
|
| 20 |
+
apply Finset.measurable_prod
|
| 21 |
+
intro i _
|
| 22 |
+
have hm : Measurable (fun p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ) =>
|
| 23 |
+
(p.2 i,Int.fract ((n : ℝ)*p.1 i))) :=
|
| 24 |
+
((measurable_pi_apply i).comp measurable_snd).prodMk
|
| 25 |
+
(sourceFract_measurable.comp (measurable_const.mul ((measurable_pi_apply i).comp measurable_fst)))
|
| 26 |
+
exact (samplingOrientedWeight_measurable r (b i) (sourceSamplingWidth stage)
|
| 27 |
+
(sourceSamplingCutoff stage) (E i) (G i) (hE i) (hG i)).comp hm
|
| 28 |
+
|
| 29 |
+
theorem sourceSamplingProduct_bounds (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 30 |
+
(E G : SourceCoordinate → Set ℝ) (n : ℤ) (θ x : SourceCoordinate → ℝ) :
|
| 31 |
+
0 ≤ sourceSamplingProduct stage r b E G n θ x ∧
|
| 32 |
+
sourceSamplingProduct stage r b E G n θ x ≤
|
| 33 |
+
(max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card := by
|
| 34 |
+
have hp := sourceSampling_parameters stage
|
| 35 |
+
have hb (i : SourceCoordinate) := samplingOrientedWeight_bounds r (b i) _ _ (E i) (G i) hp.1 hp.2.2
|
| 36 |
+
(x i) (Int.fract ((n : ℝ)*θ i))
|
| 37 |
+
refine ⟨prod_nonneg (fun i _ => (hb i).1),?_⟩
|
| 38 |
+
calc
|
| 39 |
+
_ ≤ ∏ _i ∈ sourceSamplingPrefix stage, max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)) :=
|
| 40 |
+
prod_le_prod₀ (fun i _ => (hb i).1) (fun i _ => (hb i).2)
|
| 41 |
+
_ = _ := by simp
|
| 42 |
+
|
| 43 |
+
/-- Exact coordinate factorization under the two actual infinite product laws.
|
| 44 |
+
Dependence of the two phases within one coordinate is retained in each factor. -/
|
| 45 |
+
theorem sourceSamplingProduct_inner_factorization (stage : ℕ) (r : Bool) (b : SourceCoordinate → Bool)
|
| 46 |
+
(E G : SourceCoordinate → Set ℝ) (hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) (n k : ℤ) :
|
| 47 |
+
(∫ x, ∫ θ, sourceSamplingProduct stage r b E G n θ x * sourceSamplingProduct stage r b E G k θ x
|
| 48 |
+
∂sourceAngleLaw ∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)) =
|
| 49 |
+
∏ i ∈ sourceSamplingPrefix stage,
|
| 50 |
+
∫ s, ∫ θ, samplingOrientedWeight r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 51 |
+
(E i) (G i) s (Int.fract ((n : ℝ)*θ i)) *
|
| 52 |
+
samplingOrientedWeight r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 53 |
+
(E i) (G i) s (Int.fract ((k : ℝ)*θ i)) ∂sourceAngleLaw ∂unitIntervalMeasure := by
|
| 54 |
+
let u (i : SourceCoordinate) := samplingOrientedWeight r (b i) (sourceSamplingWidth stage)
|
| 55 |
+
(sourceSamplingCutoff stage) (E i) (G i)
|
| 56 |
+
let F (i : SourceCoordinate) (s a : ℝ) := u i s (Int.fract ((n : ℝ)*a))*u i s (Int.fract ((k : ℝ)*a))
|
| 57 |
+
have hF (i : SourceCoordinate) : Measurable (fun p : ℝ × ℝ => F i p.1 p.2) := by
|
| 58 |
+
have hu := samplingOrientedWeight_measurable r (b i) (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 59 |
+
(E i) (G i) (hE i) (hG i)
|
| 60 |
+
exact (hu.comp (measurable_fst.prodMk (sourceFract_measurable.comp (measurable_const.mul measurable_snd)))).mul
|
| 61 |
+
(hu.comp (measurable_fst.prodMk (sourceFract_measurable.comp (measurable_const.mul measurable_snd))))
|
| 62 |
+
calc
|
| 63 |
+
_ = ∫ x, ∏ i ∈ sourceSamplingPrefix stage, ∫ a, F i (x i) a ∂sourceAngleMarginal i
|
| 64 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) := by
|
| 65 |
+
apply integral_congr_ae
|
| 66 |
+
filter_upwards [] with x
|
| 67 |
+
simp only [sourceSamplingProduct,← Finset.prod_mul_distrib]
|
| 68 |
+
exact integral_infinitePi_finset_prod _ _ _
|
| 69 |
+
(fun i => (hF i).comp (measurable_const.prodMk measurable_id))
|
| 70 |
+
_ = ∏ i ∈ sourceSamplingPrefix stage, ∫ s, ∫ a, F i s a ∂sourceAngleMarginal i ∂unitIntervalMeasure :=
|
| 71 |
+
integral_infinitePi_finset_prod _ _ _
|
| 72 |
+
(fun i => (hF i).stronglyMeasurable.integral_prod_right.measurable)
|
| 73 |
+
_ = _ := by
|
| 74 |
+
apply Finset.prod_congr rfl
|
| 75 |
+
intro i _
|
| 76 |
+
apply integral_congr_ae
|
| 77 |
+
filter_upwards [] with s
|
| 78 |
+
have hm : Measurable (fun a => F i s a) := (hF i).comp (measurable_const.prodMk measurable_id)
|
| 79 |
+
rw [← sourceAngleLaw_coordinate i,integral_map (measurable_pi_apply i).aemeasurable hm.aestronglyMeasurable]
|
| 80 |
+
|
| 81 |
+
/-- The actual full-prefix self-pair estimate, with the source's angle
|
| 82 |
+
expectation outside the L2 square integral. -/
|
| 83 |
+
theorem sourceSamplingProduct_self_moment (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 84 |
+
(r : Bool) (b : SourceCoordinate → Bool) (E G : SourceCoordinate → Set ℝ)
|
| 85 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 86 |
+
(n : ℤ) (hn : n ∈ sourceSamplingPowers stage) :
|
| 87 |
+
(∫ θ, ∫ x, sourceSamplingProduct stage r b E G n θ x ^ 2
|
| 88 |
+
∂Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure) ∂sourceAngleLaw) ≤
|
| 89 |
+
(2+8*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ))^(sourceSamplingPrefix stage).card := by
|
| 90 |
+
have hint := sampling_square_integrable
|
| 91 |
+
(sourceAngleLaw.prod (Measure.infinitePi (fun _ : SourceCoordinate => unitIntervalMeasure)))
|
| 92 |
+
(fun p => sourceSamplingProduct stage r b E G n p.1 p.2)
|
| 93 |
+
((max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card)
|
| 94 |
+
(sourceSamplingProduct_measurable stage r b E G hE hG n)
|
| 95 |
+
(fun p => sourceSamplingProduct_bounds stage r b E G n p.1 p.2)
|
| 96 |
+
rw [integral_integral_swap hint]
|
| 97 |
+
simp only [pow_two]
|
| 98 |
+
rw [sourceSamplingProduct_inner_factorization stage r b E G hE hG n n]
|
| 99 |
+
calc
|
| 100 |
+
_ ≤ ∏ _i ∈ sourceSamplingPrefix stage,
|
| 101 |
+
(2+8*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ)) := by
|
| 102 |
+
apply Finset.prod_le_prod₀
|
| 103 |
+
· intro i _
|
| 104 |
+
exact integral_nonneg (fun s => integral_nonneg (fun θ => mul_self_nonneg _))
|
| 105 |
+
· intro i hi
|
| 106 |
+
have hip : i.1 ≤ stage := by
|
| 107 |
+
have ht := (CouplingParameters.mem_blockPrefix sourceBlockSize (stage+1) i).mp hi
|
| 108 |
+
omega
|
| 109 |
+
simpa only [pow_two] using sourceSampling_phase_self_moment stage hs i hip n hn r (b i)
|
| 110 |
+
(E i) (G i) (hE i) (hG i)
|
| 111 |
+
_ = _ := by simp
|
| 112 |
+
|
| 113 |
+
end
|
| 114 |
+
end FiniteFactor
|
| 115 |
+
|
| 116 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/RationalTests.lean
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TestedMarginals
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.FirstMarginal
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- A finite rational cylinder test, with two closed intervals per tested
|
| 12 |
+
coordinate. Whole-circle tests fill the remaining coordinates. -/
|
| 13 |
+
abbrev SourceSamplingRationalTest :=
|
| 14 |
+
Σ K : Finset SourceCoordinate, K → (ℚ × ℚ) × (ℚ × ℚ)
|
| 15 |
+
|
| 16 |
+
instance : Countable SourceSamplingRationalTest := inferInstance
|
| 17 |
+
|
| 18 |
+
def sourceSamplingRationalEndpoints (T : SourceSamplingRationalTest) (i : SourceCoordinate) :
|
| 19 |
+
(ℚ × ℚ) × (ℚ × ℚ) :=
|
| 20 |
+
if hi : i ∈ T.1 then T.2 ⟨i,hi⟩ else ((0,1),(0,1))
|
| 21 |
+
|
| 22 |
+
def sourceSamplingRationalX (T : SourceSamplingRationalTest) (i : SourceCoordinate) : Set ℝ :=
|
| 23 |
+
Set.Icc (sourceSamplingRationalEndpoints T i).1.1 (sourceSamplingRationalEndpoints T i).1.2
|
| 24 |
+
|
| 25 |
+
def sourceSamplingRationalY (T : SourceSamplingRationalTest) (i : SourceCoordinate) : Set ℝ :=
|
| 26 |
+
Set.Icc (sourceSamplingRationalEndpoints T i).2.1 (sourceSamplingRationalEndpoints T i).2.2
|
| 27 |
+
|
| 28 |
+
theorem sourceSamplingRationalTests_outside (T : SourceSamplingRationalTest) (stage : ℕ)
|
| 29 |
+
(hK : T.1 ⊆ sourceSamplingPrefix stage) :
|
| 30 |
+
∀ i ∉ sourceSamplingPrefix stage,
|
| 31 |
+
Set.Ico (0 : ℝ) 1 ⊆ sourceSamplingRationalX T i ∧
|
| 32 |
+
Set.Ico (0 : ℝ) 1 ⊆ sourceSamplingRationalY T i := by
|
| 33 |
+
intro i hi
|
| 34 |
+
have hnot : i ∉ T.1 := fun h => hi (hK h)
|
| 35 |
+
simp only [sourceSamplingRationalX,sourceSamplingRationalY,sourceSamplingRationalEndpoints,
|
| 36 |
+
dite_eq_right hnot,Rat.cast_zero,Rat.cast_one]
|
| 37 |
+
exact ⟨Set.Ico_subset_Icc_self,Set.Ico_subset_Icc_self⟩
|
| 38 |
+
|
| 39 |
+
theorem sourceSamplingPrefix_eventually_covers (K : Finset SourceCoordinate) :
|
| 40 |
+
∀ᶠ stage : ℕ in atTop, K ⊆ sourceSamplingPrefix stage := by
|
| 41 |
+
filter_upwards [eventually_ge_atTop (K.sup (fun i => i.1))] with stage hstage
|
| 42 |
+
intro i hi
|
| 43 |
+
apply (CouplingParameters.mem_blockPrefix sourceBlockSize (stage+1) i).mpr
|
| 44 |
+
exact Nat.lt_succ_of_le ((Finset.le_sup (f := fun i => i.1) hi).trans hstage)
|
| 45 |
+
|
| 46 |
+
/-- A concrete single conull event for every finite I, both orientations, and
|
| 47 |
+
all rational cylinder tests. It includes the actual tested measure identity
|
| 48 |
+
at every admissible stage, as well as the full-error convergence and L2 bound. -/
|
| 49 |
+
theorem sourceSampling_rational_event :
|
| 50 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ (I : Finset SourceCoordinate) (r : Bool)
|
| 51 |
+
(T : SourceSamplingRationalTest),
|
| 52 |
+
Tendsto (fun stage => sourceSamplingSquaredError stage r (fun i => decide (i ∈ I))
|
| 53 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) θ) atTop (𝓝 0) ∧
|
| 54 |
+
∃ C : ℝ, ∀ stage,
|
| 55 |
+
MemLp (sourceSamplingEmpiricalDensity stage r (fun i => decide (i ∈ I))
|
| 56 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) θ) 2 sourceSamplingHaar ∧
|
| 57 |
+
(∫ x, sourceSamplingEmpiricalDensity stage r (fun i => decide (i ∈ I))
|
| 58 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) θ x ^ 2 ∂sourceSamplingHaar) ≤ C ∧
|
| 59 |
+
(T.1 ⊆ sourceSamplingPrefix stage →
|
| 60 |
+
((sourceSamplingUntrimmed I stage θ).restrict
|
| 61 |
+
(sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T))).map
|
| 62 |
+
(sourceSamplingEndpoint r) =
|
| 63 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 64 |
+
(sourceSamplingEmpiricalDensity stage r (fun i => decide (i ∈ I))
|
| 65 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) θ x))) := by
|
| 66 |
+
apply ae_all_iff.mpr
|
| 67 |
+
intro I
|
| 68 |
+
apply ae_all_iff.mpr
|
| 69 |
+
intro r
|
| 70 |
+
apply ae_all_iff.mpr
|
| 71 |
+
intro T
|
| 72 |
+
filter_upwards [sourceSamplingSquaredError_ae r (fun i => decide (i ∈ I))
|
| 73 |
+
(fun i => (sourceSamplingRationalEndpoints T i).1.1)
|
| 74 |
+
(fun i => (sourceSamplingRationalEndpoints T i).1.2)
|
| 75 |
+
(fun i => (sourceSamplingRationalEndpoints T i).2.1)
|
| 76 |
+
(fun i => (sourceSamplingRationalEndpoints T i).2.2),
|
| 77 |
+
sourceSamplingEmpiricalDensity_uniform r (fun i => decide (i ∈ I))
|
| 78 |
+
(fun i => (sourceSamplingRationalEndpoints T i).1.1)
|
| 79 |
+
(fun i => (sourceSamplingRationalEndpoints T i).1.2)
|
| 80 |
+
(fun i => (sourceSamplingRationalEndpoints T i).2.1)
|
| 81 |
+
(fun i => (sourceSamplingRationalEndpoints T i).2.2)] with θ he hu
|
| 82 |
+
obtain ⟨C,hC⟩ := hu
|
| 83 |
+
refine ⟨he.2,C,fun stage => ⟨(hC stage).1,(hC stage).2,?_⟩⟩
|
| 84 |
+
intro hK
|
| 85 |
+
exact sourceSamplingUntrimmed_tested_marginal I stage r _ _
|
| 86 |
+
(fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)
|
| 87 |
+
(sourceSamplingRationalTests_outside T stage hK) θ
|
| 88 |
+
|
| 89 |
+
/-- Both actual untested marginal densities are uniformly L2 bounded on one
|
| 90 |
+
conull event, simultaneously for all finite I. -/
|
| 91 |
+
theorem sourceSampling_both_marginals_event :
|
| 92 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ (I : Finset SourceCoordinate) (r : Bool),
|
| 93 |
+
∃ C : ℝ, ∀ stage, ∃ f : (SourceCoordinate → ℝ) → ℝ,
|
| 94 |
+
(sourceSamplingUntrimmed I stage θ).map (sourceSamplingEndpoint r) =
|
| 95 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (f x)) ∧
|
| 96 |
+
MemLp f 2 sourceSamplingHaar ∧ (∫ x, f x^2 ∂sourceSamplingHaar) ≤ C := by
|
| 97 |
+
apply ae_all_iff.mpr
|
| 98 |
+
intro I
|
| 99 |
+
apply ae_all_iff.mpr
|
| 100 |
+
intro r
|
| 101 |
+
cases r
|
| 102 |
+
· exact sourceSamplingUntrimmed_first_L2 I
|
| 103 |
+
· exact sourceSamplingUntrimmed_second_L2 I
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
end FiniteFactor
|
| 107 |
+
|
| 108 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/RectangleApproximation.lean
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.RectangleError
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- Actual rational rectangle masses approach their ideal product integrals
|
| 11 |
+
on a single conull event. This is the stochastic approximation step; the
|
| 12 |
+
identification of the ideal limiting law is a separate obligation. -/
|
| 13 |
+
theorem sourceSampling_rectangle_approximation_event :
|
| 14 |
+
∀ᵐ θ ∂sourceAngleLaw, ∀ (I : Finset SourceCoordinate) (T : SourceSamplingRationalTest),
|
| 15 |
+
Tendsto (fun stage =>
|
| 16 |
+
((sourceSamplingUntrimmed I stage θ)
|
| 17 |
+
(sourceSamplingRectangle (sourceSamplingRationalX T) (sourceSamplingRationalY T))).toReal -
|
| 18 |
+
∫ x, sourceSamplingIdealDensity stage false (fun i => decide (i ∈ I))
|
| 19 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T) x ∂sourceSamplingHaar)
|
| 20 |
+
atTop (𝓝 0) := by
|
| 21 |
+
filter_upwards [sourceSampling_rational_event] with θ hθ
|
| 22 |
+
intro I T
|
| 23 |
+
have he := (hθ I false T).1
|
| 24 |
+
have hs := Real.continuous_sqrt.continuousAt.tendsto.comp he
|
| 25 |
+
simp only [Real.sqrt_zero] at hs
|
| 26 |
+
apply tendsto_zero_iff_norm_tendsto_zero.mpr
|
| 27 |
+
simp only [Real.norm_eq_abs]
|
| 28 |
+
apply squeeze_zero' (Eventually.of_forall (fun stage => abs_nonneg _)) _ hs
|
| 29 |
+
filter_upwards [sourceSamplingPrefix_eventually_covers T.1] with stage hstage
|
| 30 |
+
exact Real.abs_le_sqrt (sourceSamplingUntrimmed_rectangle_error I stage
|
| 31 |
+
(sourceSamplingRationalX T) (sourceSamplingRationalY T)
|
| 32 |
+
(fun _ => measurableSet_Icc) (fun _ => measurableSet_Icc)
|
| 33 |
+
(sourceSamplingRationalTests_outside T stage hstage) θ)
|
| 34 |
+
|
| 35 |
+
end
|
| 36 |
+
end FiniteFactor
|
| 37 |
+
|
| 38 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/RectangleError.lean
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.RationalTests
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- The elementary probability-space Cauchy--Schwarz bound, proved by
|
| 11 |
+
integrating the nonnegative square centered at the mean. -/
|
| 12 |
+
theorem sampling_integral_square_le {Ω : Type*} [MeasurableSpace Ω]
|
| 13 |
+
(μ : Measure Ω) [IsProbabilityMeasure μ] (f : Ω → ℝ)
|
| 14 |
+
(hf : Integrable f μ) (hf2 : Integrable (fun x => f x^2) μ) :
|
| 15 |
+
(∫ x, f x ∂μ)^2 ≤ ∫ x, f x^2 ∂μ := by
|
| 16 |
+
let c := ∫ x, f x ∂μ
|
| 17 |
+
have he : (fun x => (f x-c)^2) = (fun x => f x^2-2*c*f x+c^2) := by funext x; ring
|
| 18 |
+
have hh : 0 ≤ ∫ x, (f x-c)^2 ∂μ := integral_nonneg (fun x => sq_nonneg _)
|
| 19 |
+
have hi : Integrable (fun x => f x^2-2*c*f x) μ := hf2.sub (hf.const_mul (2*c))
|
| 20 |
+
have hc : Integrable (fun _x : Ω => c^2) μ := integrable_const _
|
| 21 |
+
rw [he,integral_add hi hc,integral_sub hf2 (hf.const_mul (2*c)),integral_const_mul] at hh
|
| 22 |
+
simp only [integral_const,measureReal_def,measure_univ,ENNReal.toReal_one,smul_eq_mul,one_mul] at hh
|
| 23 |
+
change c^2 ≤ _
|
| 24 |
+
change 0 ≤ (∫ x, f x^2 ∂μ)-2*c*c+c^2 at hh
|
| 25 |
+
nlinarith
|
| 26 |
+
|
| 27 |
+
/-- Actual rectangle mass equals the integral of the first tested empirical
|
| 28 |
+
density at every admissible stage. -/
|
| 29 |
+
theorem sourceSamplingUntrimmed_rectangle_mass (I : Finset SourceCoordinate) (stage : ℕ)
|
| 30 |
+
(E G : SourceCoordinate → Set ℝ)
|
| 31 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 32 |
+
(houtside : ∀ i ∉ sourceSamplingPrefix stage,
|
| 33 |
+
Set.Ico (0 : ℝ) 1 ⊆ E i ∧ Set.Ico (0 : ℝ) 1 ⊆ G i)
|
| 34 |
+
(θ : SourceCoordinate → ℝ) :
|
| 35 |
+
((sourceSamplingUntrimmed I stage θ) (sourceSamplingRectangle E G)).toReal =
|
| 36 |
+
∫ x, sourceSamplingEmpiricalDensity stage false (fun i => decide (i ∈ I)) E G θ x
|
| 37 |
+
∂sourceSamplingHaar := by
|
| 38 |
+
let z := sourceSamplingEmpiricalDensity stage false (fun i => decide (i ∈ I)) E G θ
|
| 39 |
+
have hm := sourceSamplingEmpiricalDensity_measurable stage false (fun i => decide (i ∈ I)) E G hE hG θ
|
| 40 |
+
have hb := sourceSamplingEmpiricalDensity_bounds stage false (fun i => decide (i ∈ I)) E G θ
|
| 41 |
+
have hi : Integrable z sourceSamplingHaar :=
|
| 42 |
+
sampling_integrable_bounded sourceSamplingHaar z hm _ (fun x => by
|
| 43 |
+
rw [abs_of_nonneg (hb x).1]; exact (hb x).2)
|
| 44 |
+
have hh := congrArg (fun ν : Measure (SourceCoordinate → ℝ) => ν Set.univ)
|
| 45 |
+
(sourceSamplingUntrimmed_tested_marginal I stage false E G hE hG houtside θ)
|
| 46 |
+
rw [Measure.map_apply (sourceSamplingEndpoint_measurable false) MeasurableSet.univ,
|
| 47 |
+
Set.preimage_univ,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,
|
| 48 |
+
withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ] at hh
|
| 49 |
+
rw [hh,← ofReal_integral_eq_lintegral_ofReal hi (Eventually.of_forall (fun x => (hb x).1)),
|
| 50 |
+
ENNReal.toReal_ofReal (integral_nonneg (fun x => (hb x).1))]
|
| 51 |
+
|
| 52 |
+
/-- Full squared sampling error bounds the squared discrepancy of the actual
|
| 53 |
+
rectangle mass and the ideal product integral. -/
|
| 54 |
+
theorem sourceSamplingUntrimmed_rectangle_error (I : Finset SourceCoordinate) (stage : ℕ)
|
| 55 |
+
(E G : SourceCoordinate → Set ℝ)
|
| 56 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 57 |
+
(houtside : ∀ i ∉ sourceSamplingPrefix stage,
|
| 58 |
+
Set.Ico (0 : ℝ) 1 ⊆ E i ∧ Set.Ico (0 : ℝ) 1 ⊆ G i)
|
| 59 |
+
(θ : SourceCoordinate → ℝ) :
|
| 60 |
+
(((sourceSamplingUntrimmed I stage θ) (sourceSamplingRectangle E G)).toReal -
|
| 61 |
+
∫ x, sourceSamplingIdealDensity stage false (fun i => decide (i ∈ I)) E G x ∂sourceSamplingHaar)^2 ≤
|
| 62 |
+
sourceSamplingSquaredError stage false (fun i => decide (i ∈ I)) E G θ := by
|
| 63 |
+
rw [sourceSamplingUntrimmed_rectangle_mass I stage E G hE hG houtside θ]
|
| 64 |
+
let z := sourceSamplingEmpiricalDensity stage false (fun i => decide (i ∈ I)) E G θ
|
| 65 |
+
let g := sourceSamplingIdealDensity stage false (fun i => decide (i ∈ I)) E G
|
| 66 |
+
let C := (max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)))^(sourceSamplingPrefix stage).card
|
| 67 |
+
have hzm := sourceSamplingEmpiricalDensity_measurable stage false (fun i => decide (i ∈ I)) E G hE hG θ
|
| 68 |
+
have hgm := sourceSamplingIdealDensity_measurable stage false (fun i => decide (i ∈ I)) E G hE hG
|
| 69 |
+
have hzb := sourceSamplingEmpiricalDensity_bounds stage false (fun i => decide (i ∈ I)) E G θ
|
| 70 |
+
have hgb := sourceSamplingIdealDensity_bounds stage false (fun i => decide (i ∈ I)) E G hE hG
|
| 71 |
+
have hzi : Integrable z sourceSamplingHaar := sampling_integrable_bounded sourceSamplingHaar z hzm C
|
| 72 |
+
(fun x => by rw [abs_of_nonneg (hzb x).1]; exact (hzb x).2)
|
| 73 |
+
have hgi : Integrable g sourceSamplingHaar := sampling_integrable_bounded sourceSamplingHaar g hgm C
|
| 74 |
+
(fun x => by rw [abs_of_nonneg (hgb x).1]; exact (hgb x).2)
|
| 75 |
+
have hei : Integrable (fun x => (z x-g x)^2) sourceSamplingHaar := by
|
| 76 |
+
apply sampling_integrable_bounded sourceSamplingHaar _ ((hzm.sub hgm).pow_const 2) (C^2)
|
| 77 |
+
intro x
|
| 78 |
+
rw [abs_of_nonneg (sq_nonneg _)]
|
| 79 |
+
have hz' : 0 ≤ z x ∧ z x ≤ C := hzb x
|
| 80 |
+
have hg' : 0 ≤ g x ∧ g x ≤ C := hgb x
|
| 81 |
+
change (z x-g x)^2 ≤ C^2
|
| 82 |
+
nlinarith [sq_nonneg (z x+g x),mul_nonneg (show 0 ≤ C-(z x-g x) by linarith)
|
| 83 |
+
(show 0 ≤ C+(z x-g x) by linarith)]
|
| 84 |
+
have hh := sampling_integral_square_le sourceSamplingHaar (fun x => z x-g x) (hzi.sub hgi) hei
|
| 85 |
+
rw [integral_sub hzi hgi] at hh
|
| 86 |
+
exact hh
|
| 87 |
+
|
| 88 |
+
end
|
| 89 |
+
end FiniteFactor
|
| 90 |
+
|
| 91 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/RotationTransport.lean
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.Measures
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter
|
| 7 |
+
open scoped Classical ENNReal
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem coordinateRotate_neg_cube (θ x : SourceCoordinate → ℝ) (n : ℤ)
|
| 11 |
+
(hx : ∀ i, x i ∈ Set.Ico (0 : ℝ) 1) :
|
| 12 |
+
coordinateRotate θ (-n) (coordinateRotate θ n x) = x := by
|
| 13 |
+
funext i
|
| 14 |
+
unfold coordinateRotate
|
| 15 |
+
rw [Int.cast_neg,neg_mul]
|
| 16 |
+
have he : Int.fract (x i+(n : ℝ)*θ i) + -((n : ℝ)*θ i) =
|
| 17 |
+
x i - (⌊x i+(n : ℝ)*θ i⌋ : ℝ) := by
|
| 18 |
+
linarith [Int.fract_add_floor (x i+(n : ℝ)*θ i)]
|
| 19 |
+
rw [he,Int.fract_sub_intCast,Int.fract_eq_self.mpr (hx i)]
|
| 20 |
+
|
| 21 |
+
theorem coordinateRotate_phase (θ x : SourceCoordinate → ℝ) (n : ℤ) (i : SourceCoordinate) :
|
| 22 |
+
coordinateRotate θ n x i = Int.fract (x i+Int.fract ((n : ℝ)*θ i)) := by
|
| 23 |
+
unfold coordinateRotate
|
| 24 |
+
have he : x i+(n : ℝ)*θ i = (x i+Int.fract ((n : ℝ)*θ i)) + (⌊(n : ℝ)*θ i⌋ : ℝ) := by
|
| 25 |
+
linarith [Int.fract_add_floor ((n : ℝ)*θ i)]
|
| 26 |
+
rw [he,Int.fract_add_intCast]
|
| 27 |
+
|
| 28 |
+
theorem coordinateRotate_neg_phase (θ x : SourceCoordinate → ℝ) (n : ℤ) (i : SourceCoordinate) :
|
| 29 |
+
coordinateRotate θ (-n) x i = Int.fract (x i-Int.fract ((n : ℝ)*θ i)) := by
|
| 30 |
+
unfold coordinateRotate
|
| 31 |
+
rw [Int.cast_neg,neg_mul]
|
| 32 |
+
have he : x i + -((n : ℝ)*θ i) = (x i-Int.fract ((n : ℝ)*θ i)) - (⌊(n : ℝ)*θ i⌋ : ℝ) := by
|
| 33 |
+
linarith [Int.fract_add_floor ((n : ℝ)*θ i)]
|
| 34 |
+
rw [he,Int.fract_sub_intCast]
|
| 35 |
+
|
| 36 |
+
/-- Change of variables for an actual weighted Haar law. The inverse identity
|
| 37 |
+
is needed only on the conull cube of representatives. -/
|
| 38 |
+
theorem sourceSamplingHaar_rotate_withDensity (θ : SourceCoordinate → ℝ) (n : ℤ)
|
| 39 |
+
(w : (SourceCoordinate → ℝ) → ℝ≥0∞) (hw : Measurable w) :
|
| 40 |
+
(sourceSamplingHaar.withDensity w).map (coordinateRotate θ n) =
|
| 41 |
+
sourceSamplingHaar.withDensity (fun y => w (coordinateRotate θ (-n) y)) := by
|
| 42 |
+
let R := coordinateRotate θ n
|
| 43 |
+
let R' := coordinateRotate θ (-n)
|
| 44 |
+
have hR := coordinateRotate_preserving θ n
|
| 45 |
+
have hR' := coordinateRotate_preserving θ (-n)
|
| 46 |
+
ext A hA
|
| 47 |
+
rw [Measure.map_apply hR.measurable hA,withDensity_apply _ (hR.measurable hA),withDensity_apply _ hA]
|
| 48 |
+
rw [← lintegral_indicator (hR.measurable hA),← lintegral_indicator hA]
|
| 49 |
+
have hm : Measurable (A.indicator (fun y => w (R' y))) := (hw.comp hR'.measurable).indicator hA
|
| 50 |
+
calc
|
| 51 |
+
_ = ∫⁻ x, A.indicator (fun y => w (R' y)) (R x) ∂sourceSamplingHaar := by
|
| 52 |
+
apply lintegral_congr_ae
|
| 53 |
+
filter_upwards [sourceSamplingHaar_cube] with x hx
|
| 54 |
+
change (if R x ∈ A then w x else 0) = (if R x ∈ A then w (R' (R x)) else 0)
|
| 55 |
+
rw [show R' (R x) = x from coordinateRotate_neg_cube θ x n hx]
|
| 56 |
+
_ = _ := hR.lintegral_comp hm
|
| 57 |
+
|
| 58 |
+
end
|
| 59 |
+
end FiniteFactor
|
| 60 |
+
|
| 61 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/SecondCorrelation.lean
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.SecondDiscrepancy
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.FirstCorrelation
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter
|
| 8 |
+
open scoped Classical
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- Uniform source height bound, for either marginal orientation. -/
|
| 12 |
+
theorem sourceSampling_max_height (stage : ℕ) :
|
| 13 |
+
max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage)) ≤
|
| 14 |
+
(sourceBlockSize stage : ℝ)^(3 : ℝ) := by
|
| 15 |
+
have hm := sourceBlockSize_pos stage
|
| 16 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by
|
| 17 |
+
have hh : (100 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_100
|
| 18 |
+
linarith
|
| 19 |
+
apply max_le
|
| 20 |
+
· exact Real.one_le_rpow hm1 (by norm_num)
|
| 21 |
+
· have he : 1/(sourceSamplingWidth stage*sourceSamplingCutoff stage) =
|
| 22 |
+
(sourceBlockSize stage : ℝ)^(13/5 : ℝ) := by
|
| 23 |
+
unfold sourceSamplingWidth sourceSamplingCutoff
|
| 24 |
+
rw [← Real.rpow_add hm]
|
| 25 |
+
norm_num
|
| 26 |
+
rw [Real.rpow_neg hm.le,inv_inv]
|
| 27 |
+
rw [he]
|
| 28 |
+
exact Real.rpow_le_rpow_of_exponent_le hm1 (by norm_num)
|
| 29 |
+
|
| 30 |
+
/-- Actual second-diagonal pair error for the selected source powers.
|
| 31 |
+
All phase support, atomlessness and discrepancy hypotheses are discharged. -/
|
| 32 |
+
theorem sourceSampling_second_pair_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 33 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n n' : ℤ)
|
| 34 |
+
(hn : n ∈ sourceSamplingPowers stage) (hn' : n' ∈ sourceSamplingPowers stage) (hne : n ≠ n')
|
| 35 |
+
(G : Set ℝ) (hG : MeasurableSet G) (a c s : ℝ) (hsx : s ∈ Set.Ico (0 : ℝ) 1) :
|
| 36 |
+
|(∫ θ, samplingTestedSecondWeight (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 37 |
+
(Set.Icc a c) G s (Int.fract ((n : ℝ)*θ i)) *
|
| 38 |
+
samplingTestedSecondWeight (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 39 |
+
(Set.Icc a c) G s (Int.fract ((n' : ℝ)*θ i)) ∂sourceAngleLaw) -
|
| 40 |
+
samplingTestedSecondDensity (sourceSamplingWidth stage) (sourceSamplingCutoff stage) (Set.Icc a c) G s ^ 2| ≤
|
| 41 |
+
104*(sourceBlockSize stage : ℝ)^(-74 : ℝ) := by
|
| 42 |
+
have := sourceSampling_phase_null_singletons stage hs i hi n hn
|
| 43 |
+
have := sourceSampling_phase_null_singletons stage hs i hi n' hn'
|
| 44 |
+
have hm (k : ℤ) : Measurable (fun θ : SourceCoordinate → ℝ => Int.fract ((k : ℝ)*θ i)) :=
|
| 45 |
+
sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i))
|
| 46 |
+
have hsupport (k : ℤ) : ∀ᵐ t ∂sourceAngleLaw.map (fun θ => Int.fract ((k : ℝ)*θ i)),
|
| 47 |
+
t ∈ Set.Ico (0 : ℝ) 1 := by
|
| 48 |
+
apply (ae_map_iff (hm k).aemeasurable
|
| 49 |
+
(show MeasurableSet {t : ℝ | t ∈ Set.Ico (0 : ℝ) 1} from measurableSet_Ico)).mpr
|
| 50 |
+
exact Eventually.of_forall (fun θ => ⟨Int.fract_nonneg _,Int.fract_lt_one _⟩)
|
| 51 |
+
have hp := sourceSampling_parameters stage
|
| 52 |
+
have hb := samplingTestedSecond_pair_bound sourceAngleLaw
|
| 53 |
+
(fun θ => Int.fract ((n : ℝ)*θ i)) (fun θ => Int.fract ((n' : ℝ)*θ i))
|
| 54 |
+
(hm n) (hm n') (hsupport n) (hsupport n') _
|
| 55 |
+
(sourceSampling_rectangle_bound stage hs i hi n n' hn hn' hne)
|
| 56 |
+
_ _ G a c s hp.1 hp.2.1 hp.2.2 hG hsx
|
| 57 |
+
let m : ℝ := sourceBlockSize stage
|
| 58 |
+
let C := max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage))
|
| 59 |
+
have hC : 0 ≤ C := (by norm_num : (0 : ℝ) ≤ 1).trans (le_max_left _ _)
|
| 60 |
+
have hC2 : C^2 ≤ m^(6 : ℝ) := by
|
| 61 |
+
calc
|
| 62 |
+
_ ≤ (m^(3 : ℝ))^2 := by nlinarith [sourceSampling_max_height stage,Real.rpow_nonneg (sourceBlockSize_pos stage).le (3 : ℝ)]
|
| 63 |
+
_ = _ := by dsimp [m]; rw [← Real.rpow_natCast,← Real.rpow_mul (sourceBlockSize_pos stage).le]; norm_num
|
| 64 |
+
apply hb.trans
|
| 65 |
+
change (4*(26*m^(-80 : ℝ)))*C^2 ≤ 104*m^(-74 : ℝ)
|
| 66 |
+
calc
|
| 67 |
+
_ ≤ (4*(26*m^(-80 : ℝ)))*m^(6 : ℝ) := mul_le_mul_of_nonneg_left hC2 (by positivity)
|
| 68 |
+
_ = _ := by rw [mul_assoc, mul_assoc,← Real.rpow_add (sourceBlockSize_pos stage)]; norm_num; ring
|
| 69 |
+
|
| 70 |
+
end
|
| 71 |
+
end FiniteFactor
|
| 72 |
+
|
| 73 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/SecondMarginal.lean
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.UniformEvent
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.RotationTransport
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- The actual second marginal of one orbit summand, obtained by weighted
|
| 12 |
+
Haar transport and not supplied as an assumption. -/
|
| 13 |
+
theorem sourceSamplingSummand_second_density (I : Finset SourceCoordinate) (stage : ℕ)
|
| 14 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 15 |
+
(sourceSamplingSummand I stage θ n).map Prod.snd =
|
| 16 |
+
sourceSamplingHaar.withDensity (fun y => ENNReal.ofReal
|
| 17 |
+
(sourceSamplingWeight I stage θ n (coordinateRotate θ (-n) y))) := by
|
| 18 |
+
unfold sourceSamplingSummand
|
| 19 |
+
have hp : Measurable (fun x : SourceCoordinate → ℝ => (x,coordinateRotate θ n x)) :=
|
| 20 |
+
measurable_id.prodMk (coordinateRotate_preserving θ n).measurable
|
| 21 |
+
rw [Measure.map_map measurable_snd hp]
|
| 22 |
+
exact sourceSamplingHaar_rotate_withDensity θ n _
|
| 23 |
+
(sourceSamplingWeight_measurable I stage θ n).ennreal_ofReal
|
| 24 |
+
|
| 25 |
+
/-- The actual second marginal is the second-oriented empirical density. -/
|
| 26 |
+
theorem sourceSamplingUntrimmed_second_density (I : Finset SourceCoordinate) (stage : ℕ)
|
| 27 |
+
(θ : SourceCoordinate → ℝ) :
|
| 28 |
+
(sourceSamplingUntrimmed I stage θ).map Prod.snd =
|
| 29 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 30 |
+
(sourceSamplingEmpiricalDensity stage true (fun i => decide (i ∈ I))
|
| 31 |
+
(fun _ => Set.Icc 0 1) (fun _ => Set.Icc 0 1) θ x)) := by
|
| 32 |
+
let S := sourceSamplingPowers stage
|
| 33 |
+
let c : ℝ≥0∞ := ENNReal.ofReal (1/((sourceSamplingPowers stage).card : ℝ))
|
| 34 |
+
let w (n : ℤ) := fun x => sourceSamplingWeight I stage θ n (coordinateRotate θ (-n) x)
|
| 35 |
+
have hrep : (fun x => ENNReal.ofReal (sourceSamplingEmpiricalDensity stage true (fun i => decide (i ∈ I))
|
| 36 |
+
(fun _ => Set.Icc 0 1) (fun _ => Set.Icc 0 1) θ x)) =ᵐ[sourceSamplingHaar]
|
| 37 |
+
(fun x => c*(∑ n ∈ S, ENNReal.ofReal (w n x))) := by
|
| 38 |
+
filter_upwards [sourceSamplingHaar_cube] with x hx
|
| 39 |
+
have hw (n : ℤ) : sourceSamplingProduct stage true (fun i => decide (i ∈ I))
|
| 40 |
+
(fun _ => Set.Icc 0 1) (fun _ => Set.Icc 0 1) n θ x = w n x := by
|
| 41 |
+
apply Finset.prod_congr rfl
|
| 42 |
+
intro i _
|
| 43 |
+
have hx' : x i ∈ Set.Icc (0 : ℝ) 1 := ⟨(hx i).1,(hx i).2.le⟩
|
| 44 |
+
have hz : Int.fract (x i-Int.fract ((n : ℝ)*θ i)) ∈ Set.Icc (0 : ℝ) 1 :=
|
| 45 |
+
⟨Int.fract_nonneg _,(Int.fract_lt_one _).le⟩
|
| 46 |
+
simp only [samplingOrientedWeight,ite_true,hz,hx',and_self]
|
| 47 |
+
rw [coordinateRotate_neg_phase]
|
| 48 |
+
simp only [sourceSamplingEmpiricalDensity,hw]
|
| 49 |
+
rw [div_eq_mul_inv,mul_comm,← one_div,
|
| 50 |
+
ENNReal.ofReal_mul (by positivity),ENNReal.ofReal_sum_of_nonneg (fun n _ => (sourceSamplingWeight_bounds I stage θ n (coordinateRotate θ (-n) x)).1)]
|
| 51 |
+
rw [withDensity_congr_ae hrep]
|
| 52 |
+
ext A hA
|
| 53 |
+
rw [Measure.map_apply measurable_snd hA]
|
| 54 |
+
unfold sourceSamplingUntrimmed
|
| 55 |
+
rw [Measure.smul_apply,Measure.finsetSum_apply,withDensity_apply _ hA]
|
| 56 |
+
have hterm (n : ℤ) : sourceSamplingSummand I stage θ n (Prod.snd ⁻¹' A) =
|
| 57 |
+
∫⁻ x in A, ENNReal.ofReal (w n x) ∂sourceSamplingHaar := by
|
| 58 |
+
rw [← Measure.map_apply measurable_snd hA,sourceSamplingSummand_second_density]
|
| 59 |
+
exact withDensity_apply _ hA
|
| 60 |
+
simp only [hterm,smul_eq_mul]
|
| 61 |
+
rw [lintegral_const_mul' c _ ENNReal.ofReal_ne_top]
|
| 62 |
+
congr 1
|
| 63 |
+
exact (lintegral_finsetSum S (fun n _ =>
|
| 64 |
+
((sourceSamplingWeight_measurable I stage θ n).comp (coordinateRotate_preserving θ (-n)).measurable).ennreal_ofReal)).symm
|
| 65 |
+
|
| 66 |
+
/-- Uniform L2 densities for the actual untrimmed second marginals. -/
|
| 67 |
+
theorem sourceSamplingUntrimmed_second_L2 (I : Finset SourceCoordinate) :
|
| 68 |
+
∀ᵐ θ ∂sourceAngleLaw, ∃ C : ℝ, ∀ stage,
|
| 69 |
+
∃ f : (SourceCoordinate → ℝ) → ℝ,
|
| 70 |
+
(sourceSamplingUntrimmed I stage θ).map Prod.snd = sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (f x)) ∧
|
| 71 |
+
MemLp f 2 sourceSamplingHaar ∧ (∫ x, f x^2 ∂sourceSamplingHaar) ≤ C := by
|
| 72 |
+
filter_upwards [sourceSamplingEmpiricalDensity_uniform true (fun i => decide (i ∈ I))
|
| 73 |
+
(fun _ => 0) (fun _ => 1) (fun _ => 0) (fun _ => 1)] with θ hθ
|
| 74 |
+
obtain ⟨C,hC⟩ := hθ
|
| 75 |
+
refine ⟨C,fun stage => ⟨_,sourceSamplingUntrimmed_second_density I stage θ,(hC stage).1,(hC stage).2⟩⟩
|
| 76 |
+
|
| 77 |
+
end
|
| 78 |
+
end FiniteFactor
|
| 79 |
+
|
| 80 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/SelfMoment.lean
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.Sampling.OrientedMoments
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter
|
| 7 |
+
noncomputable section
|
| 8 |
+
|
| 9 |
+
theorem sourceSamplingCutoff_le_half (s : ℕ) : sourceSamplingCutoff s ≤ 1/2 := by
|
| 10 |
+
have hm : (100 : ℝ) ≤ sourceBlockSize s := by exact_mod_cast (sourceStage s).m_ge_100
|
| 11 |
+
have hp := sourceBlockSize_pos s
|
| 12 |
+
calc
|
| 13 |
+
sourceSamplingCutoff s ≤ (sourceBlockSize s : ℝ)^(-1 : ℝ) :=
|
| 14 |
+
Real.rpow_le_rpow_of_exponent_le (by linarith) (by norm_num)
|
| 15 |
+
_ = 1/(sourceBlockSize s : ℝ) := by rw [Real.rpow_neg_one,one_div]
|
| 16 |
+
_ ≤ 1/2 := one_div_le_one_div_of_le (by norm_num) (by linarith)
|
| 17 |
+
|
| 18 |
+
theorem sourceSampling_log_self_bound (s : ℕ) :
|
| 19 |
+
(2/sourceSamplingWidth s)*Real.log (1/(2*sourceSamplingCutoff s)) ≤
|
| 20 |
+
4*(sourceBlockSize s : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize s : ℝ) := by
|
| 21 |
+
have hp := sourceSampling_parameters s
|
| 22 |
+
have hm := sourceBlockSize_pos s
|
| 23 |
+
have hl : Real.log (1/(2*sourceSamplingCutoff s)) ≤ Real.log (1/sourceSamplingCutoff s) :=
|
| 24 |
+
Real.log_le_log (one_div_pos.mpr (mul_pos (by norm_num) hp.2.2)) (one_div_le_one_div_of_le hp.2.2 (by linarith [hp.2.2]))
|
| 25 |
+
have he : Real.log (1/sourceSamplingCutoff s) = 2*Real.log (sourceBlockSize s : ℝ) := by
|
| 26 |
+
unfold sourceSamplingCutoff
|
| 27 |
+
rw [one_div,Real.log_inv,Real.log_rpow hm]
|
| 28 |
+
ring
|
| 29 |
+
have hw : (sourceSamplingWidth s)⁻¹ = (sourceBlockSize s : ℝ)^(3/5 : ℝ) := by
|
| 30 |
+
unfold sourceSamplingWidth
|
| 31 |
+
rw [show (-3/5 : ℝ) = -(3/5) by ring,Real.rpow_neg hm.le,inv_inv]
|
| 32 |
+
calc
|
| 33 |
+
_ ≤ (2/sourceSamplingWidth s)*(2*Real.log (sourceBlockSize s : ℝ)) :=
|
| 34 |
+
mul_le_mul_of_nonneg_left (hl.trans_eq he) (div_nonneg (by norm_num) hp.1.le)
|
| 35 |
+
_ = _ := by rw [div_eq_mul_inv,hw]; ring
|
| 36 |
+
|
| 37 |
+
/-- All tested source weights have the logarithmic self-pair bound in both
|
| 38 |
+
orientations. The harmless extra 1 includes triangular coordinates. -/
|
| 39 |
+
theorem sourceSampling_oriented_self_moment (stage : ℕ) (r b : Bool) (E G : Set ℝ)
|
| 40 |
+
(hE : MeasurableSet E) (hG : MeasurableSet G) :
|
| 41 |
+
(∫ s, ∫ t, samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E G s t ^ 2
|
| 42 |
+
∂unitIntervalMeasure ∂unitIntervalMeasure) ≤
|
| 43 |
+
1+4*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ) := by
|
| 44 |
+
have hp := sourceSampling_parameters stage
|
| 45 |
+
have hc := sourceSamplingCutoff_le_half stage
|
| 46 |
+
have hlog : 0 ≤ Real.log (sourceBlockSize stage : ℝ) := Real.log_nonneg (by
|
| 47 |
+
have hm : (100 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_100
|
| 48 |
+
linarith)
|
| 49 |
+
have herr : (0 : ℝ) ≤ 4*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ) := by positivity
|
| 50 |
+
cases b
|
| 51 |
+
· have hb : (∫ s, ∫ t, samplingOrientedWeight r false (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E G s t ^ 2
|
| 52 |
+
∂unitIntervalMeasure ∂unitIntervalMeasure) ≤
|
| 53 |
+
(2/sourceSamplingWidth stage)*Real.log (1/(2*sourceSamplingCutoff stage)) := by
|
| 54 |
+
cases r
|
| 55 |
+
· exact samplingTestedFirstWeight_square_integral _ _ E G hp.1 hp.2.1 hp.2.2 hc hE hG
|
| 56 |
+
· exact samplingTestedSecondWeight_square_integral _ _ E G hp.1 hp.2.1 hp.2.2 hc hE hG
|
| 57 |
+
exact (hb.trans (sourceSampling_log_self_bound stage)).trans (by linarith)
|
| 58 |
+
· have hm := samplingOrientedWeight_measurable r true (sourceSamplingWidth stage)
|
| 59 |
+
(sourceSamplingCutoff stage) E G hE hG
|
| 60 |
+
have hb := samplingOrientedWeight_triangular_bounds r (sourceSamplingWidth stage)
|
| 61 |
+
(sourceSamplingCutoff stage) E G
|
| 62 |
+
have hi := sampling_square_integrable (unitIntervalMeasure.prod unitIntervalMeasure) _ 1 hm
|
| 63 |
+
(fun p => hb p.1 p.2)
|
| 64 |
+
rw [← integral_prod _ hi]
|
| 65 |
+
have hle : (∫ p : ℝ × ℝ, samplingOrientedWeight r true (sourceSamplingWidth stage)
|
| 66 |
+
(sourceSamplingCutoff stage) E G p.1 p.2 ^ 2 ∂unitIntervalMeasure.prod unitIntervalMeasure) ≤ 1 := by
|
| 67 |
+
simpa using integral_mono_ae hi (integrable_const (1 : ℝ))
|
| 68 |
+
(Eventually.of_forall (fun p => by nlinarith [(hb p.1 p.2).1,(hb p.1 p.2).2]))
|
| 69 |
+
exact hle.trans (by linarith)
|
| 70 |
+
|
| 71 |
+
end
|
| 72 |
+
end FiniteFactor
|
| 73 |
+
|
| 74 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/SelfSummability.lean
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.ProductMoments
|
| 2 |
+
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingSelfBudget (stage : ℕ) : ℝ :=
|
| 11 |
+
(2+8*(sourceBlockSize stage : ℝ)^(3/5 : ℝ)*Real.log (sourceBlockSize stage : ℝ))^(sourceSamplingPrefix stage).card /
|
| 12 |
+
((sourceSamplingPowers stage).card : ℝ)
|
| 13 |
+
|
| 14 |
+
/-- A concrete logarithmic estimate sufficient for the source exponent gap. -/
|
| 15 |
+
theorem sampling_self_base_bound (m : ℝ) (hm1 : 1 ≤ m) (hlarge : 802 ≤ m^(1/50 : ℝ)) :
|
| 16 |
+
2+8*m^(3/5 : ℝ)*Real.log m ≤ m^(63/100 : ℝ) := by
|
| 17 |
+
have hm : 0 < m := lt_of_lt_of_le zero_lt_one hm1
|
| 18 |
+
have hl := Real.log_le_rpow_div hm.le (by norm_num : (0 : ℝ) < 1/100)
|
| 19 |
+
have he : m^(3/5 : ℝ)*m^(1/100 : ℝ) = m^(61/100 : ℝ) := by
|
| 20 |
+
rw [← Real.rpow_add hm]; norm_num
|
| 21 |
+
have hpow : 1 ≤ m^(61/100 : ℝ) := Real.one_le_rpow hm1 (by norm_num)
|
| 22 |
+
have hmul : m^(3/5 : ℝ)*Real.log m ≤ 100*m^(61/100 : ℝ) := by
|
| 23 |
+
have hh := mul_le_mul_of_nonneg_left hl (Real.rpow_nonneg hm.le (3/5 : ℝ))
|
| 24 |
+
rw [← mul_div_assoc,he] at hh
|
| 25 |
+
linarith
|
| 26 |
+
calc
|
| 27 |
+
_ ≤ 802*m^(61/100 : ℝ) := by linarith
|
| 28 |
+
_ ≤ m^(1/50 : ℝ)*m^(61/100 : ℝ) := mul_le_mul_of_nonneg_right hlarge (by positivity)
|
| 29 |
+
_ = _ := by rw [← Real.rpow_add hm]; norm_num
|
| 30 |
+
|
| 31 |
+
theorem sourceSamplingSelfBudget_eventually : ∀ᶠ stage in atTop,
|
| 32 |
+
sourceSamplingSelfBudget stage ≤ (sourceBlockSize stage : ℝ)^(-(1/25 : ℝ)*(sourceBlockSize stage : ℝ)) := by
|
| 33 |
+
have ht : Tendsto (fun stage => (sourceBlockSize stage : ℝ)^(1/50 : ℝ)) atTop atTop :=
|
| 34 |
+
(tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 1/50)).comp
|
| 35 |
+
(tendsto_natCast_atTop_atTop.comp sourceBlockSize_tendsto)
|
| 36 |
+
filter_upwards [ht.eventually (eventually_ge_atTop 802),sourceSamplingPowers_eventually] with stage hlarge hspec
|
| 37 |
+
let m : ℝ := sourceBlockSize stage
|
| 38 |
+
let B := 2+8*m^(3/5 : ℝ)*Real.log m
|
| 39 |
+
let P : ℝ := (sourceSamplingPowers stage).card
|
| 40 |
+
have hm : 0 < m := sourceBlockSize_pos stage
|
| 41 |
+
have hm1 : 1 ≤ m := by
|
| 42 |
+
have hh : (100 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_100
|
| 43 |
+
dsimp [m]; linarith
|
| 44 |
+
have hB0 : 0 ≤ B := by dsimp [B]; positivity [Real.log_nonneg hm1]
|
| 45 |
+
have hB : B ≤ m^(63/100 : ℝ) := sampling_self_base_bound m hm1 hlarge
|
| 46 |
+
have hnum : B^(sourceSamplingPrefix stage).card ≤ m^((65/100 : ℝ)*m) := by
|
| 47 |
+
calc
|
| 48 |
+
_ ≤ (m^(63/100 : ℝ))^(sourceSamplingPrefix stage).card := pow_le_pow_left₀ hB0 hB _
|
| 49 |
+
_ = m^((63/100 : ℝ)*((sourceSamplingPrefix stage).card : ℝ)) := by
|
| 50 |
+
rw [← Real.rpow_natCast,← Real.rpow_mul hm.le]
|
| 51 |
+
_ ≤ _ := Real.rpow_le_rpow_of_exponent_le hm1 (by
|
| 52 |
+
have hd := sourceSamplingPrefix_card_bound stage
|
| 53 |
+
change ((sourceSamplingPrefix stage).card : ℝ) ≤ (101/100 : ℝ)*m at hd
|
| 54 |
+
nlinarith)
|
| 55 |
+
have hP : m^((69/100 : ℝ)*m) ≤ P := hspec.2.1
|
| 56 |
+
have hPpos : 0 < P := (Real.rpow_pos_of_pos hm _).trans_le hP
|
| 57 |
+
change B^(sourceSamplingPrefix stage).card/P ≤ m^(-(1/25 : ℝ)*m)
|
| 58 |
+
calc
|
| 59 |
+
_ ≤ m^((65/100 : ℝ)*m)/P := div_le_div_of_nonneg_right hnum hPpos.le
|
| 60 |
+
_ ≤ m^((65/100 : ℝ)*m)/m^((69/100 : ℝ)*m) :=
|
| 61 |
+
div_le_div_of_nonneg_left (by positivity) (by positivity) hP
|
| 62 |
+
_ = _ := by rw [← Real.rpow_sub hm]; congr 1; ring
|
| 63 |
+
|
| 64 |
+
/-- The actual block growth makes the inverse-square stage sequence summable. -/
|
| 65 |
+
theorem sourceSampling_inverse_square_summable : Summable (fun stage => (sourceBlockSize stage : ℝ)^(-2 : ℝ)) := by
|
| 66 |
+
have hg : Summable (fun stage : ℕ => (1/4 : ℝ)^stage) :=
|
| 67 |
+
summable_geometric_of_lt_one (by norm_num) (by norm_num)
|
| 68 |
+
apply hg.of_nonneg_of_le (fun _ => by positivity)
|
| 69 |
+
intro stage
|
| 70 |
+
have hp : (2 : ℝ)^stage ≤ sourceBlockSize stage := by
|
| 71 |
+
have hh := (sourceStage stage).m_ge_pow
|
| 72 |
+
have hle : 2^stage ≤ 2^(stage+1) := Nat.pow_le_pow_right (by norm_num) (by omega)
|
| 73 |
+
exact_mod_cast hle.trans hh
|
| 74 |
+
calc
|
| 75 |
+
_ ≤ ((2 : ℝ)^stage)^(-2 : ℝ) := Real.rpow_le_rpow_of_nonpos (by positivity) hp (by norm_num)
|
| 76 |
+
_ = _ := by
|
| 77 |
+
rw [Real.rpow_neg (by positivity),Real.rpow_two]
|
| 78 |
+
rw [← pow_mul, Nat.mul_comm stage 2, pow_mul, ← inv_pow]
|
| 79 |
+
norm_num
|
| 80 |
+
|
| 81 |
+
/-- Summability of the actual full-product self-pair budget. -/
|
| 82 |
+
theorem sourceSamplingSelfBudget_summable : Summable sourceSamplingSelfBudget := by
|
| 83 |
+
apply sourceSampling_inverse_square_summable.of_norm_bounded_eventually_nat
|
| 84 |
+
filter_upwards [sourceSamplingSelfBudget_eventually] with stage hb
|
| 85 |
+
have hm : (100 : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_100
|
| 86 |
+
have hn : 0 ≤ sourceSamplingSelfBudget stage := by
|
| 87 |
+
unfold sourceSamplingSelfBudget
|
| 88 |
+
have hl := Real.log_nonneg (show (1 : ℝ) ≤ sourceBlockSize stage by linarith)
|
| 89 |
+
positivity
|
| 90 |
+
rw [Real.norm_eq_abs,abs_of_nonneg hn]
|
| 91 |
+
exact hb.trans (Real.rpow_le_rpow_of_exponent_le (by linarith) (by nlinarith))
|
| 92 |
+
|
| 93 |
+
end
|
| 94 |
+
end FiniteFactor
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/SingleCorrelation.lean
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.PairMoments
|
| 2 |
+
import OAI.Analysis.FiniteFactor.Sampling.MixedCorrelation
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter
|
| 8 |
+
open scoped Classical
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- The source powers make the single-phase relative error at most m^-80. -/
|
| 12 |
+
theorem sourceSampling_single_phase_budget (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 13 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n : ℤ) (hn : n ∈ sourceSamplingPowers stage) :
|
| 14 |
+
1/((n : ℝ)*sourceAngleUnit i) ≤ (sourceBlockSize stage : ℝ)^(-80 : ℝ) := by
|
| 15 |
+
let m : ℝ := sourceBlockSize stage
|
| 16 |
+
have hm : 0 < m := sourceBlockSize_pos stage
|
| 17 |
+
have hm2 : 2 ≤ m := by dsimp [m]; exact_mod_cast (show 2 ≤ sourceBlockSize stage by omega)
|
| 18 |
+
have hspec := (sourceSamplingPowers_spec stage hs).1 n hn
|
| 19 |
+
have hQ : m^(83 : ℝ) ≤ samplingQ (sourceBlockSize stage) := by
|
| 20 |
+
unfold samplingQ
|
| 21 |
+
change m^(83 : ℝ) ≤ m^((7/10 : ℝ)*m)
|
| 22 |
+
exact Real.rpow_le_rpow_of_exponent_le (by linarith) (by
|
| 23 |
+
have hh : (200000 : ℝ) ≤ m := by dsimp [m]; exact_mod_cast hs
|
| 24 |
+
linarith)
|
| 25 |
+
have hN : (sourceBlockSize i.1 : ℝ)*(sourceStageState i.1).K ≤ m^2 := by
|
| 26 |
+
have hh : (sourceBlockSize i.1 : ℝ)*(sourceStageState i.1).K ≤
|
| 27 |
+
(sourceBlockSize stage : ℝ)*(sourceStageState stage).K := by exact_mod_cast sourceFrequencyScale_monotone hi
|
| 28 |
+
have hK : ((sourceStageState stage).K : ℝ) ≤ sourceBlockSize stage := by exact_mod_cast (sourceStage stage).m_ge_K
|
| 29 |
+
dsimp [m]
|
| 30 |
+
nlinarith
|
| 31 |
+
have hp : 0 < (n : ℝ) := by exact_mod_cast hspec.2.2
|
| 32 |
+
have h82 : m^(82 : ℝ) ≤ (n : ℝ) := by
|
| 33 |
+
have he : m^(83 : ℝ) = m^(82 : ℝ)*m := by
|
| 34 |
+
rw [show (83 : ℝ) = 82+1 by norm_num,Real.rpow_add hm,Real.rpow_one]
|
| 35 |
+
have hh : 2*m^(82 : ℝ) ≤ m^(83 : ℝ) := by rw [he]; nlinarith [Real.rpow_pos_of_pos hm (82 : ℝ)]
|
| 36 |
+
nlinarith [hspec.1]
|
| 37 |
+
have hlen : m^(80 : ℝ) ≤ (n : ℝ)*sourceAngleUnit i := by
|
| 38 |
+
unfold sourceAngleUnit
|
| 39 |
+
rw [mul_one_div,le_div_iff₀ (mul_pos (sourceBlockSize_pos i.1) (sourceCutoff_pos i.1))]
|
| 40 |
+
calc
|
| 41 |
+
_ ≤ m^(80 : ℝ)*m^2 := mul_le_mul_of_nonneg_left hN (by positivity)
|
| 42 |
+
_ = m^(82 : ℝ) := by rw [← Real.rpow_natCast,← Real.rpow_add hm]; norm_num
|
| 43 |
+
_ ≤ _ := h82
|
| 44 |
+
have he := one_div_le_one_div_of_le (Real.rpow_pos_of_pos hm (80 : ℝ)) hlen
|
| 45 |
+
simpa only [m,one_div,Real.rpow_neg (sourceBlockSize_pos stage).le] using he
|
| 46 |
+
|
| 47 |
+
/-- Actual full-angle single-phase test, with all source sampling hypotheses. -/
|
| 48 |
+
theorem sourceSampling_single_phase_relative (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 49 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n : ℤ) (hn : n ∈ sourceSamplingPowers stage)
|
| 50 |
+
(g : ℝ → ℝ) (hg : ∀ t, 0 ≤ g t) (hgm : Measurable g) (hgi : Integrable g unitIntervalMeasure) :
|
| 51 |
+
|(∫ θ, g (Int.fract ((n : ℝ)*θ i)) ∂sourceAngleLaw)-(∫ t, g t ∂unitIntervalMeasure)| ≤
|
| 52 |
+
(sourceBlockSize stage : ℝ)^(-80 : ℝ)*(∫ t, g t ∂unitIntervalMeasure) := by
|
| 53 |
+
have hnp : (0 : ℝ) < n := by exact_mod_cast ((sourceSamplingPowers_spec stage hs).1 n hn).2.2
|
| 54 |
+
have hh := sourceAngle_single_phase_test i (n : ℝ) hnp (sourceSampling_phase_length stage hs i hi n hn) g hg hgm hgi
|
| 55 |
+
have hm : Measurable (fun t : ℝ => g (Int.fract ((n : ℝ)*t))) :=
|
| 56 |
+
hgm.comp (sourceFract_measurable.comp (measurable_const.mul measurable_id))
|
| 57 |
+
rw [← sourceAngleLaw_coordinate i,integral_map (measurable_pi_apply i).aemeasurable hm.aestronglyMeasurable] at hh
|
| 58 |
+
exact hh.trans (mul_le_mul_of_nonneg_right (sourceSampling_single_phase_budget stage hs i hi n hn) (integral_nonneg hg))
|
| 59 |
+
|
| 60 |
+
/-- The actual mixed q_n/Z_l^0 coordinate factor, for every orientation and
|
| 61 |
+
all measurable tests, has error at most 5*m^-80. -/
|
| 62 |
+
theorem sourceSampling_coordinate_mixed_error (stage : ℕ) (hs : 200000 ≤ sourceBlockSize stage)
|
| 63 |
+
(i : SourceCoordinate) (hi : i.1 ≤ stage) (n : ℤ) (hn : n ∈ sourceSamplingPowers stage)
|
| 64 |
+
(r b : Bool) (E G : Set ℝ) (hE : MeasurableSet E) (hG : MeasurableSet G) :
|
| 65 |
+
|(∫ s, samplingOrientedDensity r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E G s *
|
| 66 |
+
(∫ θ, samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage)
|
| 67 |
+
E G s (Int.fract ((n : ℝ)*θ i)) ∂sourceAngleLaw) ∂unitIntervalMeasure)-
|
| 68 |
+
(∫ s, samplingOrientedDensity r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E G s^2 ∂unitIntervalMeasure)| ≤
|
| 69 |
+
5*(sourceBlockSize stage : ℝ)^(-80 : ℝ) := by
|
| 70 |
+
let u := samplingOrientedWeight r b (sourceSamplingWidth stage) (sourceSamplingCutoff stage) E G
|
| 71 |
+
let C := max 1 (1/(sourceSamplingWidth stage*sourceSamplingCutoff stage))
|
| 72 |
+
have hp := sourceSampling_parameters stage
|
| 73 |
+
have hu : Measurable (fun p : ℝ × ℝ => u p.1 p.2) := samplingOrientedWeight_measurable r b _ _ E G hE hG
|
| 74 |
+
have hb : ∀ s t, 0 ≤ u s t ∧ u s t ≤ C := samplingOrientedWeight_bounds r b _ _ E G hp.1 hp.2.2
|
| 75 |
+
have he := sampling_integrated_mixed_error sourceAngleLaw (fun θ => Int.fract ((n : ℝ)*θ i))
|
| 76 |
+
(sourceFract_measurable.comp (measurable_const.mul (measurable_pi_apply i)))
|
| 77 |
+
u hu C ((sourceBlockSize stage : ℝ)^(-80 : ℝ)) hb (fun s =>
|
| 78 |
+
sourceSampling_single_phase_relative stage hs i hi n hn (u s) (fun t => (hb s t).1)
|
| 79 |
+
(hu.comp (measurable_const.prodMk measurable_id))
|
| 80 |
+
(sampling_integrable_bounded unitIntervalMeasure (u s)
|
| 81 |
+
(hu.comp (measurable_const.prodMk measurable_id)) C (fun t => by
|
| 82 |
+
rw [abs_of_nonneg (hb s t).1]; exact (hb s t).2)))
|
| 83 |
+
apply he.trans
|
| 84 |
+
have hA := (sourceSampling_oriented_moment stage r b E G hE hG).2
|
| 85 |
+
have hm1 : (1 : ℝ) ≤ sourceBlockSize stage := by
|
| 86 |
+
have h := (sourceStage stage).m_ge_100
|
| 87 |
+
exact_mod_cast (show 1 ≤ sourceBlockSize stage by omega)
|
| 88 |
+
have hpow : (sourceBlockSize stage : ℝ)^(-6/5 : ℝ) ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hm1 (by norm_num)
|
| 89 |
+
have hA5 : (∫ s, (∫ t, u s t ∂unitIntervalMeasure)^2 ∂unitIntervalMeasure) ≤ 5 := by
|
| 90 |
+
exact hA.trans (by linarith)
|
| 91 |
+
nlinarith [Real.rpow_nonneg (sourceBlockSize_pos stage).le (-80 : ℝ)]
|
| 92 |
+
|
| 93 |
+
end
|
| 94 |
+
end FiniteFactor
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/Tail.lean
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.CrossedProduct.StageOperator
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
theorem sourceCutoff_ge_shift (s n : ℕ) :
|
| 11 |
+
2^n * (sourceStageState s).K ≤ (sourceStageState (s+n)).K := by
|
| 12 |
+
induction n with
|
| 13 |
+
| zero => simp
|
| 14 |
+
| succ n ih =>
|
| 15 |
+
have hh := sourceStage_cutoff_growth (s+n)
|
| 16 |
+
rw [pow_succ, Nat.add_succ]
|
| 17 |
+
nlinarith
|
| 18 |
+
|
| 19 |
+
/-- The exact geometric tail estimate used in scales and tail trimming. -/
|
| 20 |
+
theorem sourceCutoff_tail_bound (s : ℕ) :
|
| 21 |
+
(∑' n : ℕ, 1 / ((sourceStageState (s+n)).K : ℝ)) ≤
|
| 22 |
+
2 / ((sourceStageState s).K : ℝ) := by
|
| 23 |
+
let b (n : ℕ) : ℝ := (1 / ((sourceStageState s).K : ℝ)) * (1/2 : ℝ)^n
|
| 24 |
+
have hb : Summable b := (summable_geometric_of_lt_one (by norm_num : (0 : ℝ) ≤ 1/2)
|
| 25 |
+
(by norm_num : (1/2 : ℝ) < 1)).mul_left _
|
| 26 |
+
have hle (n : ℕ) : 1 / ((sourceStageState (s+n)).K : ℝ) ≤ b n := by
|
| 27 |
+
have hh : (2 : ℝ)^n * (sourceStageState s).K ≤ (sourceStageState (s+n)).K :=
|
| 28 |
+
by exact_mod_cast sourceCutoff_ge_shift s n
|
| 29 |
+
have hp : (0 : ℝ) < 2^n * (sourceStageState s).K := mul_pos (by positivity) (sourceCutoff_pos s)
|
| 30 |
+
have ht := one_div_le_one_div_of_le hp hh
|
| 31 |
+
simpa [b, one_div_pow, mul_comm, mul_left_comm] using ht
|
| 32 |
+
calc
|
| 33 |
+
_ ≤ ∑' n, b n := (hb.of_nonneg_of_le (fun _ => by positivity) hle).tsum_le_tsum hle hb
|
| 34 |
+
_ = 2 / ((sourceStageState s).K : ℝ) := by
|
| 35 |
+
rw [tsum_mul_left, tsum_geometric_of_lt_one (by norm_num : (0 : ℝ) ≤ 1/2) (by norm_num)]
|
| 36 |
+
ring
|
| 37 |
+
|
| 38 |
+
def sourceTailAngleSum (θ : SourceCoordinate → ℝ) (s : ℕ) : ℝ :=
|
| 39 |
+
∑' n : ℕ, ∑ i : Fin (sourceBlockSize (s+n)), θ ⟨s+n,i⟩
|
| 40 |
+
|
| 41 |
+
theorem SourceAngles.tail_sum_bound {θ : SourceCoordinate → ℝ} (hθ : SourceAngles θ) (s : ℕ) :
|
| 42 |
+
sourceTailAngleSum θ s ≤ 4 / ((sourceStageState s).K : ℝ) := by
|
| 43 |
+
have hb (n : ℕ) :
|
| 44 |
+
(∑ i : Fin (sourceBlockSize (s+n)), θ ⟨s+n,i⟩) ≤ 2 / ((sourceStageState (s+n)).K : ℝ) := by
|
| 45 |
+
have hh := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => (hθ ⟨s+n,i⟩).2)
|
| 46 |
+
have he : (∑ _i : Fin (sourceBlockSize (s+n)),
|
| 47 |
+
2 / ((sourceBlockSize (s+n) : ℝ)*(sourceStageState (s+n)).K)) =
|
| 48 |
+
2 / ((sourceStageState (s+n)).K : ℝ) := by
|
| 49 |
+
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]
|
| 50 |
+
field_simp [(sourceBlockSize_pos (s+n)).ne', (sourceCutoff_pos (s+n)).ne']
|
| 51 |
+
exact hh.trans_eq he
|
| 52 |
+
have hs : Summable (fun n => 2 / ((sourceStageState (s+n)).K : ℝ)) := by
|
| 53 |
+
have hh := sourceCutoff_reciprocal_summable.comp_injective (add_right_injective s)
|
| 54 |
+
simpa [div_eq_mul_inv] using hh.mul_left 2
|
| 55 |
+
calc
|
| 56 |
+
sourceTailAngleSum θ s ≤ ∑' n, 2 / ((sourceStageState (s+n)).K : ℝ) :=
|
| 57 |
+
(hs.of_nonneg_of_le (fun n => Finset.sum_nonneg (fun i _ => hθ.nonneg _)) hb).tsum_le_tsum hb hs
|
| 58 |
+
_ = 2 * ∑' n, 1 / ((sourceStageState (s+n)).K : ℝ) := by
|
| 59 |
+
rw [← tsum_mul_left]; congr; funext n; ring
|
| 60 |
+
_ ≤ 2 * (2 / ((sourceStageState s).K : ℝ)) :=
|
| 61 |
+
mul_le_mul_of_nonneg_left (sourceCutoff_tail_bound s) (by norm_num)
|
| 62 |
+
_ = 4 / ((sourceStageState s).K : ℝ) := by ring
|
| 63 |
+
|
| 64 |
+
/-- The largest proposed sampling power divided by the next cutoff has the
|
| 65 |
+
source exponent gap 7/10 - 3/4 = -1/20. -/
|
| 66 |
+
theorem sourceSampling_tail_ratio (s : ℕ) :
|
| 67 |
+
4 * (sourceBlockSize s : ℝ)^((7/10 : ℝ)*(sourceBlockSize s : ℝ)) /
|
| 68 |
+
((sourceStageState (s+1)).K : ℝ) ≤
|
| 69 |
+
4 * (sourceBlockSize s : ℝ)^(-(sourceBlockSize s : ℝ)/20) := by
|
| 70 |
+
have hm := sourceBlockSize_pos s
|
| 71 |
+
have hK := sourceCutoff_pos (s+1)
|
| 72 |
+
have hc : (sourceBlockSize s : ℝ)^((3/4 : ℝ)*(sourceBlockSize s : ℝ)) ≤
|
| 73 |
+
(sourceStageState (s+1)).K := Nat.le_ceil _
|
| 74 |
+
apply (div_le_iff₀ hK).mpr
|
| 75 |
+
calc
|
| 76 |
+
_ = (4 * (sourceBlockSize s : ℝ)^(-(sourceBlockSize s : ℝ)/20)) *
|
| 77 |
+
(sourceBlockSize s : ℝ)^((3/4 : ℝ)*(sourceBlockSize s : ℝ)) := by
|
| 78 |
+
rw [mul_assoc, ← Real.rpow_add hm]
|
| 79 |
+
congr 2
|
| 80 |
+
ring
|
| 81 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left hc (by positivity)
|
| 82 |
+
|
| 83 |
+
end
|
| 84 |
+
end FiniteFactor
|
| 85 |
+
|
| 86 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TestedMarginals.lean
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TestedTransport
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingEndpoint (r : Bool)
|
| 11 |
+
(p : (SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)) : SourceCoordinate → ℝ :=
|
| 12 |
+
if r then p.2 else p.1
|
| 13 |
+
|
| 14 |
+
theorem sourceSamplingEndpoint_measurable (r : Bool) : Measurable (sourceSamplingEndpoint r) := by
|
| 15 |
+
cases r
|
| 16 |
+
· exact measurable_fst
|
| 17 |
+
· exact measurable_snd
|
| 18 |
+
|
| 19 |
+
/-- Both actual rectangle-restricted marginal measures for a single power. -/
|
| 20 |
+
theorem sourceSamplingSummand_tested_marginal (I : Finset SourceCoordinate) (stage : ℕ)
|
| 21 |
+
(r : Bool) (E G : SourceCoordinate → Set ℝ)
|
| 22 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 23 |
+
(houtside : ∀ i ∉ sourceSamplingPrefix stage,
|
| 24 |
+
Set.Ico (0 : ℝ) 1 ⊆ E i ∧ Set.Ico (0 : ℝ) 1 ⊆ G i)
|
| 25 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 26 |
+
((sourceSamplingSummand I stage θ n).restrict (sourceSamplingRectangle E G)).map
|
| 27 |
+
(sourceSamplingEndpoint r) =
|
| 28 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 29 |
+
(sourceSamplingProduct stage r (fun i => decide (i ∈ I)) E G n θ x)) := by
|
| 30 |
+
rw [sourceSamplingSummand_restrict_rectangle I stage E G hE hG houtside θ n]
|
| 31 |
+
have hp : Measurable (fun x : SourceCoordinate → ℝ => (x,coordinateRotate θ n x)) :=
|
| 32 |
+
measurable_id.prodMk (coordinateRotate_preserving θ n).measurable
|
| 33 |
+
rw [Measure.map_map (sourceSamplingEndpoint_measurable r) hp]
|
| 34 |
+
cases r
|
| 35 |
+
· exact Measure.map_id
|
| 36 |
+
· change (sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 37 |
+
(sourceSamplingProduct stage false (fun i => decide (i ∈ I)) E G n θ x))).map
|
| 38 |
+
(coordinateRotate θ n) = _
|
| 39 |
+
have hw : Measurable (fun x => ENNReal.ofReal
|
| 40 |
+
(sourceSamplingProduct stage false (fun i => decide (i ∈ I)) E G n θ x)) :=
|
| 41 |
+
(((sourceSamplingProduct_measurable stage false (fun i => decide (i ∈ I)) E G hE hG n).comp
|
| 42 |
+
(measurable_const.prodMk measurable_id)).ennreal_ofReal)
|
| 43 |
+
rw [sourceSamplingHaar_rotate_withDensity θ n _ hw]
|
| 44 |
+
apply withDensity_congr_ae
|
| 45 |
+
filter_upwards [sourceSamplingHaar_cube] with y hy
|
| 46 |
+
rw [sourceSamplingProduct_second_inverse I stage E G θ y n hy]
|
| 47 |
+
|
| 48 |
+
/-- Averaging commutes with rectangle restriction and either endpoint map.
|
| 49 |
+
The density is the previously estimated empirical function, exactly. -/
|
| 50 |
+
theorem sourceSamplingUntrimmed_tested_marginal (I : Finset SourceCoordinate) (stage : ℕ)
|
| 51 |
+
(r : Bool) (E G : SourceCoordinate → Set ℝ)
|
| 52 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 53 |
+
(houtside : ∀ i ∉ sourceSamplingPrefix stage,
|
| 54 |
+
Set.Ico (0 : ℝ) 1 ⊆ E i ∧ Set.Ico (0 : ℝ) 1 ⊆ G i)
|
| 55 |
+
(θ : SourceCoordinate → ℝ) :
|
| 56 |
+
((sourceSamplingUntrimmed I stage θ).restrict (sourceSamplingRectangle E G)).map
|
| 57 |
+
(sourceSamplingEndpoint r) =
|
| 58 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 59 |
+
(sourceSamplingEmpiricalDensity stage r (fun i => decide (i ∈ I)) E G θ x)) := by
|
| 60 |
+
let S := sourceSamplingPowers stage
|
| 61 |
+
let c : ℝ≥0∞ := ENNReal.ofReal (1/((sourceSamplingPowers stage).card : ℝ))
|
| 62 |
+
let w := fun n => sourceSamplingProduct stage r (fun i => decide (i ∈ I)) E G n θ
|
| 63 |
+
have hrep : (fun x => ENNReal.ofReal (sourceSamplingEmpiricalDensity stage r
|
| 64 |
+
(fun i => decide (i ∈ I)) E G θ x)) =
|
| 65 |
+
(fun x => c*∑ n ∈ S, ENNReal.ofReal (w n x)) := by
|
| 66 |
+
funext x
|
| 67 |
+
simp only [sourceSamplingEmpiricalDensity]
|
| 68 |
+
rw [div_eq_mul_inv,mul_comm,← one_div,ENNReal.ofReal_mul (by positivity),
|
| 69 |
+
ENNReal.ofReal_sum_of_nonneg (fun n _ => (sourceSamplingProduct_bounds stage r
|
| 70 |
+
(fun i => decide (i ∈ I)) E G n θ x).1)]
|
| 71 |
+
rw [hrep]
|
| 72 |
+
have hf := sourceSamplingEndpoint_measurable r
|
| 73 |
+
have hR := sourceSamplingRectangle_measurable E G hE hG
|
| 74 |
+
ext A hA
|
| 75 |
+
rw [Measure.map_apply hf hA,Measure.restrict_apply (hf hA)]
|
| 76 |
+
unfold sourceSamplingUntrimmed
|
| 77 |
+
rw [Measure.smul_apply,Measure.finsetSum_apply,withDensity_apply _ hA]
|
| 78 |
+
have hterm (n : ℤ) : sourceSamplingSummand I stage θ n
|
| 79 |
+
(sourceSamplingEndpoint r ⁻¹' A ∩ sourceSamplingRectangle E G) =
|
| 80 |
+
∫⁻ x in A, ENNReal.ofReal (w n x) ∂sourceSamplingHaar := by
|
| 81 |
+
rw [← Measure.restrict_apply (hf hA),← Measure.map_apply hf hA,
|
| 82 |
+
sourceSamplingSummand_tested_marginal I stage r E G hE hG houtside θ n]
|
| 83 |
+
exact withDensity_apply _ hA
|
| 84 |
+
simp only [hterm,smul_eq_mul]
|
| 85 |
+
rw [lintegral_const_mul' c _ ENNReal.ofReal_ne_top]
|
| 86 |
+
congr 1
|
| 87 |
+
exact (lintegral_finsetSum S (fun n _ =>
|
| 88 |
+
(((sourceSamplingProduct_measurable stage r (fun i => decide (i ∈ I)) E G hE hG n).comp
|
| 89 |
+
(measurable_const.prodMk measurable_id)).ennreal_ofReal))).symm
|
| 90 |
+
|
| 91 |
+
end
|
| 92 |
+
end FiniteFactor
|
| 93 |
+
|
| 94 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TestedTransport.lean
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.SecondMarginal
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter Finset
|
| 7 |
+
open scoped Classical ENNReal
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
def sourceSamplingRectangle (E G : SourceCoordinate → Set ℝ) :
|
| 11 |
+
Set ((SourceCoordinate → ℝ) × (SourceCoordinate → ℝ)) :=
|
| 12 |
+
{p | ∀ i, p.1 i ∈ E i ∧ p.2 i ∈ G i}
|
| 13 |
+
|
| 14 |
+
theorem sourceSamplingRectangle_measurable (E G : SourceCoordinate → Set ℝ)
|
| 15 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i)) :
|
| 16 |
+
MeasurableSet (sourceSamplingRectangle E G) := by
|
| 17 |
+
simp only [sourceSamplingRectangle,Set.ofPred_forall]
|
| 18 |
+
apply MeasurableSet.iInter
|
| 19 |
+
intro i
|
| 20 |
+
exact ((hE i).preimage ((measurable_pi_apply i).comp measurable_fst)).inter
|
| 21 |
+
((hG i).preimage ((measurable_pi_apply i).comp measurable_snd))
|
| 22 |
+
|
| 23 |
+
theorem sourceSamplingProduct_first_indicator (I : Finset SourceCoordinate) (stage : ℕ)
|
| 24 |
+
(E G : SourceCoordinate → Set ℝ)
|
| 25 |
+
(houtside : ∀ i ∉ sourceSamplingPrefix stage,
|
| 26 |
+
Set.Ico (0 : ℝ) 1 ⊆ E i ∧ Set.Ico (0 : ℝ) 1 ⊆ G i)
|
| 27 |
+
(θ x : SourceCoordinate → ℝ) (n : ℤ)
|
| 28 |
+
(hx : ∀ i, x i ∈ Set.Ico (0 : ℝ) 1) :
|
| 29 |
+
sourceSamplingProduct stage false (fun i => decide (i ∈ I)) E G n θ x =
|
| 30 |
+
if (x,coordinateRotate θ n x) ∈ sourceSamplingRectangle E G
|
| 31 |
+
then sourceSamplingWeight I stage θ n x else 0 := by
|
| 32 |
+
have hy (i) : coordinateRotate θ n x i ∈ Set.Ico (0 : ℝ) 1 :=
|
| 33 |
+
⟨Int.fract_nonneg _,Int.fract_lt_one _⟩
|
| 34 |
+
have he : (∀ i ∈ sourceSamplingPrefix stage, x i ∈ E i ∧ coordinateRotate θ n x i ∈ G i) ↔
|
| 35 |
+
(x,coordinateRotate θ n x) ∈ sourceSamplingRectangle E G := by
|
| 36 |
+
constructor
|
| 37 |
+
· intro h i
|
| 38 |
+
by_cases hi : i ∈ sourceSamplingPrefix stage
|
| 39 |
+
· exact h i hi
|
| 40 |
+
· exact ⟨(houtside i hi).1 (hx i),(houtside i hi).2 (hy i)⟩
|
| 41 |
+
· intro h i _
|
| 42 |
+
exact h i
|
| 43 |
+
unfold sourceSamplingProduct samplingOrientedWeight samplingTestedFirstWeight
|
| 44 |
+
simp only [Bool.false_eq_true,ite_false,← coordinateRotate_phase]
|
| 45 |
+
simp only [Finset.prod_ite_zero,he]
|
| 46 |
+
rfl
|
| 47 |
+
|
| 48 |
+
/-- Inverse rotation exchanges the two actual tested product orientations. -/
|
| 49 |
+
theorem sourceSamplingProduct_second_inverse (I : Finset SourceCoordinate) (stage : ℕ)
|
| 50 |
+
(E G : SourceCoordinate → Set ℝ) (θ y : SourceCoordinate → ℝ) (n : ℤ)
|
| 51 |
+
(hy : ∀ i, y i ∈ Set.Ico (0 : ℝ) 1) :
|
| 52 |
+
sourceSamplingProduct stage false (fun i => decide (i ∈ I)) E G n θ
|
| 53 |
+
(coordinateRotate θ (-n) y) =
|
| 54 |
+
sourceSamplingProduct stage true (fun i => decide (i ∈ I)) E G n θ y := by
|
| 55 |
+
have hinv : coordinateRotate θ n (coordinateRotate θ (-n) y) = y := by
|
| 56 |
+
simpa only [neg_neg] using coordinateRotate_neg_cube θ y (-n) hy
|
| 57 |
+
apply Finset.prod_congr rfl
|
| 58 |
+
intro i _
|
| 59 |
+
have hi := congrFun hinv i
|
| 60 |
+
rw [coordinateRotate_phase] at hi
|
| 61 |
+
simp only [samplingOrientedWeight,Bool.false_eq_true,ite_false,ite_true,samplingTestedFirstWeight,hi]
|
| 62 |
+
rw [coordinateRotate_neg_phase]
|
| 63 |
+
|
| 64 |
+
/-- The restricted orbit-pair summand is exactly the pushforward of its
|
| 65 |
+
first tested product, with no assumed marginal law. -/
|
| 66 |
+
theorem sourceSamplingSummand_restrict_rectangle (I : Finset SourceCoordinate) (stage : ℕ)
|
| 67 |
+
(E G : SourceCoordinate → Set ℝ)
|
| 68 |
+
(hE : ∀ i, MeasurableSet (E i)) (hG : ∀ i, MeasurableSet (G i))
|
| 69 |
+
(houtside : ∀ i ∉ sourceSamplingPrefix stage,
|
| 70 |
+
Set.Ico (0 : ℝ) 1 ⊆ E i ∧ Set.Ico (0 : ℝ) 1 ⊆ G i)
|
| 71 |
+
(θ : SourceCoordinate → ℝ) (n : ℤ) :
|
| 72 |
+
(sourceSamplingSummand I stage θ n).restrict (sourceSamplingRectangle E G) =
|
| 73 |
+
(sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal
|
| 74 |
+
(sourceSamplingProduct stage false (fun i => decide (i ∈ I)) E G n θ x))).map
|
| 75 |
+
(fun x => (x,coordinateRotate θ n x)) := by
|
| 76 |
+
have hp : Measurable (fun x : SourceCoordinate → ℝ => (x,coordinateRotate θ n x)) :=
|
| 77 |
+
measurable_id.prodMk (coordinateRotate_preserving θ n).measurable
|
| 78 |
+
have hR := sourceSamplingRectangle_measurable E G hE hG
|
| 79 |
+
unfold sourceSamplingSummand sourceSamplingWeightedMeasure
|
| 80 |
+
rw [Measure.restrict_map hp hR,restrict_withDensity (hp hR),← withDensity_indicator (hp hR)]
|
| 81 |
+
congr 1
|
| 82 |
+
apply withDensity_congr_ae
|
| 83 |
+
filter_upwards [sourceSamplingHaar_cube] with x hx
|
| 84 |
+
rw [sourceSamplingProduct_first_indicator I stage E G houtside θ x n hx]
|
| 85 |
+
change (if (x,coordinateRotate θ n x) ∈ sourceSamplingRectangle E G
|
| 86 |
+
then ENNReal.ofReal (sourceSamplingWeight I stage θ n x) else 0) = _
|
| 87 |
+
split_ifs <;> simp
|
| 88 |
+
|
| 89 |
+
end
|
| 90 |
+
end FiniteFactor
|
| 91 |
+
|
| 92 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TorusLimitMarginals.lean
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TorusMarginals
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.LambdaMarginals
|
| 3 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TorusSupport
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Filter
|
| 9 |
+
open scoped ENNReal
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
/-- The actual compact-torus limiting marginals are dominated by product
|
| 13 |
+
Haar, the exact absolute continuity premise needed in the Lusin transfer. -/
|
| 14 |
+
theorem sourceSamplingLambdaTorus_marginal_le (I : Finset SourceCoordinate) (r : Bool) :
|
| 15 |
+
(sourceSamplingLambdaTorus I : Measure SourceSamplingTorus).map (sourceTorusEndpoint r) ≤ sourceTorusHaar := by
|
| 16 |
+
have he : sourceTorusEndpoint r ∘ sourceSamplingTorusMap = sourceTorusQuotient ∘ sourceSamplingEndpoint r := by
|
| 17 |
+
funext p
|
| 18 |
+
cases r <;> rfl
|
| 19 |
+
change ((sourceSamplingLambda I).map sourceSamplingTorusMap).map (sourceTorusEndpoint r) ≤ _
|
| 20 |
+
rw [Measure.map_map (sourceTorusEndpoint_measurable r) sourceSamplingTorusMap_continuous.measurable,he,
|
| 21 |
+
← Measure.map_map sourceTorusQuotient_preserving.measurable (sourceSamplingEndpoint_measurable r)]
|
| 22 |
+
have h := Measure.map_mono (sourceSamplingLambda_marginal_le I r) sourceTorusQuotient_preserving.measurable
|
| 23 |
+
rwa [sourceTorusQuotient_preserving.map_eq] at h
|
| 24 |
+
|
| 25 |
+
theorem sourceSamplingLambdaTorus_marginal_ac (I : Finset SourceCoordinate) (r : Bool) :
|
| 26 |
+
(sourceSamplingLambdaTorus I : Measure SourceSamplingTorus).map (sourceTorusEndpoint r) ≪ sourceTorusHaar :=
|
| 27 |
+
Measure.absolutelyContinuous_of_le (sourceSamplingLambdaTorus_marginal_le I r)
|
| 28 |
+
|
| 29 |
+
theorem sourceSamplingLambda_representatives (I : Finset SourceCoordinate) :
|
| 30 |
+
∀ᵐ p ∂sourceSamplingLambda I, sourceSamplingPairRepresentative (sourceSamplingTorusMap p) = p := by
|
| 31 |
+
have hmeas : MeasurableSet {p : SourceSamplingPair |
|
| 32 |
+
sourceSamplingPairRepresentative (sourceSamplingTorusMap p) = p} :=
|
| 33 |
+
measurableSet_eq_fun (sourceSamplingPairRepresentative_measurable.comp sourceSamplingTorusMap_continuous.measurable)
|
| 34 |
+
measurable_id
|
| 35 |
+
apply (ae_map_iff (sourceSamplingLimitMap_measurable I).aemeasurable hmeas).mpr
|
| 36 |
+
filter_upwards [ae_restrict_of_ae sourceSamplingPairHaar_cube] with p hp
|
| 37 |
+
apply Prod.ext
|
| 38 |
+
· exact sourceTorusRepresentative_quotient _ (fun i => (hp i).1)
|
| 39 |
+
· apply sourceTorusRepresentative_quotient
|
| 40 |
+
intro i
|
| 41 |
+
by_cases hi : i ∈ I
|
| 42 |
+
· simpa only [sourceSamplingLimitMap,ite_eq_left hi] using (hp i).2
|
| 43 |
+
· simpa only [sourceSamplingLimitMap,ite_eq_right hi] using (hp i).1
|
| 44 |
+
|
| 45 |
+
/-- The actual limiting torus measure has the same representative order
|
| 46 |
+
as the trimmed measures. No closure of the order set in torus topology is assumed. -/
|
| 47 |
+
theorem sourceSamplingLambdaTorus_ordered (I : Finset SourceCoordinate) :
|
| 48 |
+
∀ᵐ p ∂(sourceSamplingLambdaTorus I : Measure SourceSamplingTorus),
|
| 49 |
+
∀ i, sourceTorusRepresentative p.1 i ≤ sourceTorusRepresentative p.2 i := by
|
| 50 |
+
have hmeas : MeasurableSet {p : SourceSamplingTorus |
|
| 51 |
+
∀ i, sourceTorusRepresentative p.1 i ≤ sourceTorusRepresentative p.2 i} := by
|
| 52 |
+
simp only [Set.ofPred_forall]
|
| 53 |
+
exact MeasurableSet.iInter (fun i => measurableSet_le
|
| 54 |
+
((measurable_pi_apply i).comp (sourceTorusRepresentative_preserving.measurable.comp measurable_fst))
|
| 55 |
+
((measurable_pi_apply i).comp (sourceTorusRepresentative_preserving.measurable.comp measurable_snd)))
|
| 56 |
+
apply (ae_map_iff sourceSamplingTorusMap_continuous.measurable.aemeasurable hmeas).mpr
|
| 57 |
+
filter_upwards [sourceSamplingLambda_ordered I,sourceSamplingLambda_representatives I] with p hp he
|
| 58 |
+
have h1 := congrArg Prod.fst he
|
| 59 |
+
have h2 := congrArg Prod.snd he
|
| 60 |
+
change sourceTorusRepresentative (sourceTorusQuotient p.1) = p.1 at h1
|
| 61 |
+
change sourceTorusRepresentative (sourceTorusQuotient p.2) = p.2 at h2
|
| 62 |
+
change ∀ i, sourceTorusRepresentative (sourceTorusQuotient p.1) i ≤ sourceTorusRepresentative (sourceTorusQuotient p.2) i
|
| 63 |
+
rw [h1,h2]
|
| 64 |
+
exact hp
|
| 65 |
+
|
| 66 |
+
end
|
| 67 |
+
end FiniteFactor
|
| 68 |
+
|
| 69 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TorusMarginals.lean
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.CrossedProduct.TorusModel
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TrimmedMarginals
|
| 3 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TrimmedWeak
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Filter
|
| 9 |
+
open scoped ENNReal
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
def sourceTorusEndpoint (r : Bool) (p : SourceSamplingTorus) : SourceTorus := if r then p.2 else p.1
|
| 13 |
+
|
| 14 |
+
theorem sourceTorusEndpoint_measurable (r : Bool) : Measurable (sourceTorusEndpoint r) := by
|
| 15 |
+
cases r
|
| 16 |
+
· exact measurable_fst
|
| 17 |
+
· exact measurable_snd
|
| 18 |
+
|
| 19 |
+
theorem sourceSamplingTorus_marginal_transport (μ : Measure SourceSamplingPair) (r : Bool)
|
| 20 |
+
(g : (SourceCoordinate → ℝ) → ℝ) (hg : Measurable g)
|
| 21 |
+
(hm : μ.map (sourceSamplingEndpoint r) = sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (g x))) :
|
| 22 |
+
(μ.map sourceSamplingTorusMap).map (sourceTorusEndpoint r) =
|
| 23 |
+
sourceTorusHaar.withDensity (fun z => ENNReal.ofReal (g (sourceTorusRepresentative z))) := by
|
| 24 |
+
have he : sourceTorusEndpoint r ∘ sourceSamplingTorusMap = sourceTorusQuotient ∘ sourceSamplingEndpoint r := by
|
| 25 |
+
funext p
|
| 26 |
+
cases r <;> rfl
|
| 27 |
+
rw [Measure.map_map (sourceTorusEndpoint_measurable r) sourceSamplingTorusMap_continuous.measurable,he,
|
| 28 |
+
← Measure.map_map sourceTorusQuotient_preserving.measurable (sourceSamplingEndpoint_measurable r),hm]
|
| 29 |
+
exact sourceTorusQuotient_withDensity _ hg.ennreal_ofReal
|
| 30 |
+
|
| 31 |
+
/-- The actual torus marginals, rather than only the representative-space
|
| 32 |
+
marginals, have uniformly bounded L2 densities with respect to product Haar. -/
|
| 33 |
+
theorem sourceSamplingTrimmed_torus_marginals_event : ∀ᵐ θ ∂sourceAngleLaw,
|
| 34 |
+
∀ (I : Finset SourceCoordinate) (r : Bool), ∃ C : ℝ, ∀ s,
|
| 35 |
+
∃ g : SourceTorus → ℝ,
|
| 36 |
+
Measurable g ∧ (∀ z, 0 ≤ g z) ∧
|
| 37 |
+
(sourceSamplingTrimmedTorus I s θ : Measure SourceSamplingTorus).map (sourceTorusEndpoint r) =
|
| 38 |
+
sourceTorusHaar.withDensity (fun z => ENNReal.ofReal (g z)) ∧
|
| 39 |
+
MemLp g 2 sourceTorusHaar ∧ (∫ z, g z^2 ∂sourceTorusHaar) ≤ C := by
|
| 40 |
+
filter_upwards [sourceSamplingTrimmed_marginals_event] with θ hθ
|
| 41 |
+
intro I r
|
| 42 |
+
obtain ⟨C,hC⟩ := hθ I r
|
| 43 |
+
refine ⟨C,fun s => ?_⟩
|
| 44 |
+
obtain ⟨g,hg,hg0,hgm,hglp,hgint⟩ := hC s
|
| 45 |
+
refine ⟨g ∘ sourceTorusRepresentative,hg.comp sourceTorusRepresentative_preserving.measurable,
|
| 46 |
+
fun z => hg0 _,sourceSamplingTorus_marginal_transport _ r g hg hgm,?_,?_⟩
|
| 47 |
+
· exact hglp.comp_measurePreserving sourceTorusRepresentative_preserving
|
| 48 |
+
· have he : (∫ z, (g (sourceTorusRepresentative z))^2 ∂sourceTorusHaar) =
|
| 49 |
+
∫ x, g x^2 ∂sourceSamplingHaar := by
|
| 50 |
+
rw [← sourceTorusRepresentative_preserving.map_eq]
|
| 51 |
+
exact (integral_map sourceTorusRepresentative_preserving.measurable.aemeasurable
|
| 52 |
+
(hg.pow_const 2).aestronglyMeasurable).symm
|
| 53 |
+
exact he.trans_le hgint
|
| 54 |
+
|
| 55 |
+
end
|
| 56 |
+
end FiniteFactor
|
| 57 |
+
|
| 58 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TorusSupport.lean
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.CrossedProduct.TorusModel
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.OrbitSupport
|
| 3 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.TrimmedWeak
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
namespace FiniteFactor
|
| 8 |
+
open MeasureTheory Filter
|
| 9 |
+
open scoped ENNReal Classical
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
def sourceSamplingPairRepresentative (z : SourceSamplingTorus) : SourceSamplingPair :=
|
| 13 |
+
(sourceTorusRepresentative z.1,sourceTorusRepresentative z.2)
|
| 14 |
+
|
| 15 |
+
theorem sourceSamplingPairRepresentative_measurable : Measurable sourceSamplingPairRepresentative :=
|
| 16 |
+
(sourceTorusRepresentative_preserving.measurable.comp measurable_fst).prodMk
|
| 17 |
+
(sourceTorusRepresentative_preserving.measurable.comp measurable_snd)
|
| 18 |
+
|
| 19 |
+
def sourceTorusRotate (θ : SourceCoordinate → ℝ) (n : ℤ) (z : SourceTorus) : SourceTorus :=
|
| 20 |
+
fun i => z i + n • (θ i : UnitAddCircle)
|
| 21 |
+
|
| 22 |
+
theorem sourceTorusRotate_continuous (θ : SourceCoordinate → ℝ) (n : ℤ) : Continuous (sourceTorusRotate θ n) :=
|
| 23 |
+
continuous_pi (fun i => (continuous_apply i).add continuous_const)
|
| 24 |
+
|
| 25 |
+
theorem sourceTorusQuotient_rotate (θ x : SourceCoordinate → ℝ) (n : ℤ) :
|
| 26 |
+
sourceTorusQuotient (coordinateRotate θ n x) = sourceTorusRotate θ n (sourceTorusQuotient x) := by
|
| 27 |
+
funext i
|
| 28 |
+
simp only [sourceTorusQuotient,coordinateRotate,sourceTorusRotate,AddCircle.coe_fract,
|
| 29 |
+
AddCircle.coe_add,← zsmul_eq_mul,AddCircle.coe_zsmul]
|
| 30 |
+
|
| 31 |
+
/-- The chosen real representatives recover the actual orbit measures;
|
| 32 |
+
closed-cube endpoints are not silently identified with distinct real points. -/
|
| 33 |
+
theorem sourceSamplingTrimmed_representatives (I : Finset SourceCoordinate) (s : ℕ)
|
| 34 |
+
(θ : SourceCoordinate → ℝ) : ∀ᵐ p ∂sourceSamplingTrimmed I s θ,
|
| 35 |
+
sourceSamplingPairRepresentative (sourceSamplingTorusMap p) = p := by
|
| 36 |
+
have hmeas : MeasurableSet {p : SourceSamplingPair |
|
| 37 |
+
sourceSamplingPairRepresentative (sourceSamplingTorusMap p) = p} :=
|
| 38 |
+
measurableSet_eq_fun (sourceSamplingPairRepresentative_measurable.comp sourceSamplingTorusMap_continuous.measurable)
|
| 39 |
+
measurable_id
|
| 40 |
+
have hu : ∀ᵐ p ∂sourceSamplingUntrimmed I s θ,
|
| 41 |
+
sourceSamplingPairRepresentative (sourceSamplingTorusMap p) = p := by
|
| 42 |
+
apply Measure.ae_smul_measure
|
| 43 |
+
rw [ae_iff,Measure.finsetSum_apply]
|
| 44 |
+
apply Finset.sum_eq_zero
|
| 45 |
+
intro n hn
|
| 46 |
+
apply ae_iff.mp
|
| 47 |
+
apply (ae_map_iff (measurable_id.prodMk (coordinateRotate_preserving θ n).measurable).aemeasurable hmeas).mpr
|
| 48 |
+
have hh : ∀ᵐ x ∂sourceSamplingWeightedMeasure I s θ n, ∀ i, x i ∈ Set.Ico (0 : ℝ) 1 :=
|
| 49 |
+
ae_iff.mpr (withDensity_absolutelyContinuous _ _ (ae_iff.mp sourceSamplingHaar_cube))
|
| 50 |
+
filter_upwards [hh] with x hx
|
| 51 |
+
apply Prod.ext
|
| 52 |
+
· exact sourceTorusRepresentative_quotient x hx
|
| 53 |
+
· exact sourceTorusRepresentative_quotient _ (fun i => ⟨Int.fract_nonneg _,Int.fract_lt_one _⟩)
|
| 54 |
+
exact ae_restrict_of_ae hu
|
| 55 |
+
|
| 56 |
+
def sourceSamplingTorusOrderedOrbits (s : ℕ) (θ : SourceCoordinate → ℝ) : Set SourceSamplingTorus :=
|
| 57 |
+
{p | (∀ i, sourceTorusRepresentative p.1 i ≤ sourceTorusRepresentative p.2 i) ∧
|
| 58 |
+
∃ n ∈ sourceSamplingPowers s, 0 < n ∧ p.2 = sourceTorusRotate θ n p.1}
|
| 59 |
+
|
| 60 |
+
theorem sourceSamplingTorusOrderedOrbits_measurable (s : ℕ) (θ : SourceCoordinate → ℝ) :
|
| 61 |
+
MeasurableSet (sourceSamplingTorusOrderedOrbits s θ) := by
|
| 62 |
+
change MeasurableSet ({p : SourceSamplingTorus | ∀ i, sourceTorusRepresentative p.1 i ≤ sourceTorusRepresentative p.2 i} ∩
|
| 63 |
+
{p : SourceSamplingTorus | ∃ n ∈ sourceSamplingPowers s, 0 < n ∧ p.2 = sourceTorusRotate θ n p.1})
|
| 64 |
+
apply MeasurableSet.inter
|
| 65 |
+
· simp only [Set.ofPred_forall]
|
| 66 |
+
exact MeasurableSet.iInter (fun i => measurableSet_le
|
| 67 |
+
((measurable_pi_apply i).comp (sourceTorusRepresentative_preserving.measurable.comp measurable_fst))
|
| 68 |
+
((measurable_pi_apply i).comp (sourceTorusRepresentative_preserving.measurable.comp measurable_snd)))
|
| 69 |
+
· simp only [Set.ofPred_exists]
|
| 70 |
+
apply MeasurableSet.iUnion
|
| 71 |
+
intro n
|
| 72 |
+
by_cases hn : n ∈ sourceSamplingPowers s ∧ 0 < n
|
| 73 |
+
· simp only [hn.1,hn.2,true_and]
|
| 74 |
+
exact measurableSet_eq_fun measurable_snd ((sourceTorusRotate_continuous θ n).measurable.comp measurable_fst)
|
| 75 |
+
· have he : {p : SourceSamplingTorus | n ∈ sourceSamplingPowers s ∧ 0 < n ∧ p.2 = sourceTorusRotate θ n p.1} = ∅ := by
|
| 76 |
+
ext p; simp only [Set.mem_ofPred_eq,Set.mem_empty_iff_false,iff_false]; tauto
|
| 77 |
+
rw [he]
|
| 78 |
+
exact MeasurableSet.empty
|
| 79 |
+
|
| 80 |
+
/-- Actual compact-torus support: representatives are ordered, and each pair
|
| 81 |
+
lies on one of the constructed finitely many strictly positive rotation graphs. -/
|
| 82 |
+
theorem sourceSamplingTrimmed_torus_orbits (I : Finset SourceCoordinate) (s : ℕ)
|
| 83 |
+
(θ : SourceCoordinate → ℝ) :
|
| 84 |
+
∀ᵐ p ∂(sourceSamplingTrimmedTorus I s θ : Measure SourceSamplingTorus),
|
| 85 |
+
(∀ i, sourceTorusRepresentative p.1 i ≤ sourceTorusRepresentative p.2 i) ∧
|
| 86 |
+
∃ n ∈ sourceSamplingPowers s, 0 < n ∧ p.2 = sourceTorusRotate θ n p.1 := by
|
| 87 |
+
apply (ae_map_iff sourceSamplingTorusMap_continuous.measurable.aemeasurable
|
| 88 |
+
(sourceSamplingTorusOrderedOrbits_measurable s θ)).mpr
|
| 89 |
+
filter_upwards [sourceSamplingTrimmed_orbits I s θ,sourceSamplingTrimmed_representatives I s θ] with p hp he
|
| 90 |
+
refine ⟨?_,?_⟩
|
| 91 |
+
· have h1 := congrArg Prod.fst he
|
| 92 |
+
have h2 := congrArg Prod.snd he
|
| 93 |
+
change sourceTorusRepresentative (sourceTorusQuotient p.1) = p.1 at h1
|
| 94 |
+
change sourceTorusRepresentative (sourceTorusQuotient p.2) = p.2 at h2
|
| 95 |
+
change ∀ i, sourceTorusRepresentative (sourceTorusQuotient p.1) i ≤ sourceTorusRepresentative (sourceTorusQuotient p.2) i
|
| 96 |
+
rw [h1,h2]
|
| 97 |
+
exact hp.1
|
| 98 |
+
· obtain ⟨n,hn,hpos,hrot⟩ := hp.2
|
| 99 |
+
refine ⟨n,hn,hpos,?_⟩
|
| 100 |
+
change sourceTorusQuotient p.2 = sourceTorusRotate θ n (sourceTorusQuotient p.1)
|
| 101 |
+
rw [hrot]
|
| 102 |
+
exact sourceTorusQuotient_rotate θ p.1 n
|
| 103 |
+
|
| 104 |
+
end
|
| 105 |
+
end FiniteFactor
|
| 106 |
+
|
| 107 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TriangleLaw.lean
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.CutoffMass
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace FiniteFactor
|
| 6 |
+
open MeasureTheory Filter
|
| 7 |
+
open scoped Classical ENNReal Topology
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
/-- The actual triangular phase weight is precisely the order indicator
|
| 11 |
+
of the rotated endpoint, on the Haar representatives. -/
|
| 12 |
+
theorem samplingWeight_triangular_order (h α s t : ℝ)
|
| 13 |
+
(hs : s ∈ Set.Ico (0 : ℝ) 1) (ht : t ∈ Set.Ico (0 : ℝ) 1) :
|
| 14 |
+
samplingWeight true h α s t = if s < Int.fract (s+t) then 1 else 0 := by
|
| 15 |
+
by_cases hst : s+t < 1
|
| 16 |
+
· have hf : Int.fract (s+t) = s+t := Int.fract_eq_self.mpr ⟨by linarith [hs.1,ht.1],hst⟩
|
| 17 |
+
simp only [samplingWeight,ite_true,hf]
|
| 18 |
+
have he : (0 < t ∧ t < 1-s) ↔ s < s+t := by
|
| 19 |
+
constructor
|
| 20 |
+
· intro h; linarith [h.1]
|
| 21 |
+
· intro h; constructor <;> linarith
|
| 22 |
+
simp only [he]
|
| 23 |
+
· have hf : ⌊s+t⌋ = (1 : ℤ) := Int.floor_eq_iff.mpr ⟨by norm_num; linarith,by norm_num; linarith [hs.2,ht.2]⟩
|
| 24 |
+
have hn : ¬ (0 < t ∧ t < 1-s) := by intro h; linarith [h.2]
|
| 25 |
+
have ho : ¬ s < Int.fract (s+t) := by rw [Int.fract,hf]; norm_num; linarith [ht.2]
|
| 26 |
+
simp only [samplingWeight,ite_true,ite_eq_right hn,ite_eq_right ho]
|
| 27 |
+
|
| 28 |
+
/-- The first tested triangular density is its actual vertical section of
|
| 29 |
+
Lebesgue measure on 0≤x<y<1. No triangular marginal identity is assumed. -/
|
| 30 |
+
theorem samplingTestedFirstDensity_triangular_section (h α s : ℝ) (E G : Set ℝ)
|
| 31 |
+
(hG : MeasurableSet G) (hs : s ∈ Set.Ico (0 : ℝ) 1) :
|
| 32 |
+
samplingTestedFirstDensity true h α E G s =
|
| 33 |
+
∫ y, (if s ∈ E ∧ y ∈ G ∧ s < y then (1 : ℝ) else 0) ∂unitIntervalMeasure := by
|
| 34 |
+
let F := fun y : ℝ => if s ∈ E ∧ y ∈ G ∧ s < y then (1 : ℝ) else 0
|
| 35 |
+
have hm : Measurable F := by
|
| 36 |
+
apply Measurable.ite _ measurable_const measurable_const
|
| 37 |
+
by_cases htest : s ∈ E
|
| 38 |
+
· simp only [htest,true_and]
|
| 39 |
+
change MeasurableSet (G ∩ {y : ℝ | s < y})
|
| 40 |
+
exact hG.inter (measurableSet_lt measurable_const measurable_id)
|
| 41 |
+
· simp [htest]
|
| 42 |
+
have hp : MeasurePreserving (fun t : ℝ => Int.fract (s+t)) unitIntervalMeasure unitIntervalMeasure := by
|
| 43 |
+
simpa only [add_comm] using unitInterval_rotate_preserving s
|
| 44 |
+
have he : samplingTestedFirstWeight true h α E G s =ᵐ[unitIntervalMeasure]
|
| 45 |
+
(fun t => F (Int.fract (s+t))) := by
|
| 46 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with t ht
|
| 47 |
+
rw [samplingTestedFirstWeight,samplingWeight_triangular_order h α s t hs ht]
|
| 48 |
+
simp only [F]
|
| 49 |
+
split_ifs <;> simp_all
|
| 50 |
+
rw [samplingTestedFirstDensity,integral_congr_ae he]
|
| 51 |
+
rw [← integral_map hp.measurable.aemeasurable hm.aestronglyMeasurable,hp.map_eq]
|
| 52 |
+
|
| 53 |
+
/-- The two-dimensional tested source integral equals the genuine triangular
|
| 54 |
+
restriction of product Lebesgue measure. -/
|
| 55 |
+
theorem samplingTestedFirstDensity_triangular_mass (h α : ℝ) (E G : Set ℝ)
|
| 56 |
+
(hE : MeasurableSet E) (hG : MeasurableSet G) :
|
| 57 |
+
(∫ s, samplingTestedFirstDensity true h α E G s ∂unitIntervalMeasure) =
|
| 58 |
+
((unitIntervalMeasure.prod unitIntervalMeasure)
|
| 59 |
+
{p : ℝ × ℝ | p.1 ∈ E ∧ p.2 ∈ G ∧ p.1 < p.2}).toReal := by
|
| 60 |
+
let A := {p : ℝ × ℝ | p.1 ∈ E ∧ p.2 ∈ G ∧ p.1 < p.2}
|
| 61 |
+
have hA : MeasurableSet A := (hE.preimage measurable_fst).inter
|
| 62 |
+
((hG.preimage measurable_snd).inter (measurableSet_lt measurable_fst measurable_snd))
|
| 63 |
+
have hm : Measurable (A.indicator (fun _ => (1 : ℝ))) := measurable_const.indicator hA
|
| 64 |
+
have hi : Integrable (A.indicator (fun _ => (1 : ℝ))) (unitIntervalMeasure.prod unitIntervalMeasure) :=
|
| 65 |
+
(integrable_const (1 : ℝ)).indicator hA
|
| 66 |
+
calc
|
| 67 |
+
_ = ∫ s, ∫ y, A.indicator (fun _ => (1 : ℝ)) (s,y) ∂unitIntervalMeasure ∂unitIntervalMeasure := by
|
| 68 |
+
apply integral_congr_ae
|
| 69 |
+
filter_upwards [ae_restrict_mem measurableSet_Ico] with s hs
|
| 70 |
+
simpa only [A,Set.indicator_apply,Set.mem_ofPred_eq] using
|
| 71 |
+
samplingTestedFirstDensity_triangular_section h α s E G hG hs
|
| 72 |
+
_ = ∫ p, A.indicator (fun _ => (1 : ℝ)) p ∂unitIntervalMeasure.prod unitIntervalMeasure :=
|
| 73 |
+
(integral_prod _ hi).symm
|
| 74 |
+
_ = _ := by rw [integral_indicator hA]; simp [measureReal_def,A]
|
| 75 |
+
|
| 76 |
+
end
|
| 77 |
+
end FiniteFactor
|
| 78 |
+
|
| 79 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TrimmedMarginals.lean
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.OrderedRestriction
|
| 2 |
+
import OAI.Analysis.FiniteFactor.SubmeasureL2Density
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
/-- Each actual trimmed marginal is dominated by the actual untrimmed
|
| 12 |
+
marginal, for both orientations. -/
|
| 13 |
+
theorem sourceSamplingTrimmed_marginal_le (I : Finset SourceCoordinate) (s : ℕ)
|
| 14 |
+
(θ : SourceCoordinate → ℝ) (r : Bool) :
|
| 15 |
+
(sourceSamplingTrimmed I s θ).map (sourceSamplingEndpoint r) ≤
|
| 16 |
+
(sourceSamplingUntrimmed I s θ).map (sourceSamplingEndpoint r) :=
|
| 17 |
+
Measure.map_mono (sourceSamplingTrimmed_le I s θ) (sourceSamplingEndpoint_measurable r)
|
| 18 |
+
|
| 19 |
+
/-- The actual Radon--Nikodym densities after trimming have the same uniform
|
| 20 |
+
squared L2 bound, on a single event for every finite I and both endpoints. -/
|
| 21 |
+
theorem sourceSamplingTrimmed_marginals_event : ∀ᵐ θ ∂sourceAngleLaw,
|
| 22 |
+
∀ (I : Finset SourceCoordinate) (r : Bool), ∃ C : ℝ, ∀ s : ℕ,
|
| 23 |
+
∃ g : (SourceCoordinate → ℝ) → ℝ,
|
| 24 |
+
Measurable g ∧ (∀ x, 0 ≤ g x) ∧
|
| 25 |
+
(sourceSamplingTrimmed I s θ).map (sourceSamplingEndpoint r) =
|
| 26 |
+
sourceSamplingHaar.withDensity (fun x => ENNReal.ofReal (g x)) ∧
|
| 27 |
+
MemLp g 2 sourceSamplingHaar ∧ (∫ x, g x^2 ∂sourceSamplingHaar) ≤ C := by
|
| 28 |
+
filter_upwards [sourceSampling_both_marginals_event] with θ hθ
|
| 29 |
+
intro I r
|
| 30 |
+
obtain ⟨C,hC⟩ := hθ I r
|
| 31 |
+
refine ⟨C,fun s => ?_⟩
|
| 32 |
+
obtain ⟨f,hf,hLp,hbound⟩ := hC s
|
| 33 |
+
have hsub := sourceSamplingTrimmed_marginal_le I s θ r
|
| 34 |
+
rw [hf] at hsub
|
| 35 |
+
obtain ⟨g,hg,hg0,hgμ,hle,hgLp,hgint⟩ := submeasure_L2_density sourceSamplingHaar
|
| 36 |
+
((sourceSamplingTrimmed I s θ).map (sourceSamplingEndpoint r)) f hLp hsub
|
| 37 |
+
exact ⟨g,hg,hg0,hgμ,hgLp,hgint.trans hbound⟩
|
| 38 |
+
|
| 39 |
+
end
|
| 40 |
+
end FiniteFactor
|
| 41 |
+
|
| 42 |
+
end OAI
|
lean/OAI/Analysis/FiniteFactor/OrbitSampling/TrimmedWeak.lean
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.OrderedRestriction
|
| 2 |
+
import OAI.Analysis.FiniteFactor.OrbitSampling.CompactTorus
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace FiniteFactor
|
| 7 |
+
open MeasureTheory Filter Finset
|
| 8 |
+
open scoped Classical ENNReal Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
def sourceSamplingTrimmedFinite (I : Finset SourceCoordinate) (s : ℕ)
|
| 12 |
+
(θ : SourceCoordinate → ℝ) : FiniteMeasure SourceSamplingPair :=
|
| 13 |
+
⟨sourceSamplingTrimmed I s θ,inferInstance⟩
|
| 14 |
+
|
| 15 |
+
def sourceSamplingTrimmedTorus (I : Finset SourceCoordinate) (s : ℕ)
|
| 16 |
+
(θ : SourceCoordinate → ℝ) : FiniteMeasure SourceSamplingTorus :=
|
| 17 |
+
(sourceSamplingTrimmedFinite I s θ).map sourceSamplingTorusMap
|
| 18 |
+
|
| 19 |
+
theorem sourceSampling_discarded_tendsto (I : Finset SourceCoordinate)
|
| 20 |
+
(θ : SourceCoordinate → ℝ) (hθ : SourceAngles θ)
|
| 21 |
+
(hmass : Tendsto (fun s => ((sourceSamplingUntrimmed I s θ) Set.univ).toReal)
|
| 22 |
+
atTop (𝓝 (((sourceSamplingLambda I) Set.univ).toReal))) :
|
| 23 |
+
Tendsto (fun s => ((sourceSamplingUntrimmed I s θ) sourceSamplingOrderedᶜ).toReal)
|
| 24 |
+
atTop (𝓝 0) := by
|
| 25 |
+
have hlim := hmass.mul sourceSampling_tail_error_tendsto
|
| 26 |
+
rw [mul_zero] at hlim
|
| 27 |
+
apply squeeze_zero (fun s => ENNReal.toReal_nonneg) _ hlim
|
| 28 |
+
intro s
|
| 29 |
+
have h := ENNReal.toReal_mono (by finiteness)
|
| 30 |
+
(sourceSamplingUntrimmed_discarded_le I s θ hθ)
|
| 31 |
+
simpa only [ENNReal.toReal_mul,ENNReal.toReal_ofReal (by positivity :
|
| 32 |
+
0 ≤ 4*(sourceBlockSize s : ℝ)^(-(sourceBlockSize s : ℝ)/20))] using h
|
| 33 |
+
|
| 34 |
+
def finiteMeasureRestrict {Ω : Type*} [MeasurableSpace Ω]
|
| 35 |
+
(μ : FiniteMeasure Ω) (A : Set Ω) : FiniteMeasure Ω :=
|
| 36 |
+
⟨(μ : Measure Ω).restrict A,inferInstance⟩
|
| 37 |
+
|
| 38 |
+
/-- A restriction whose discarded mass tends to zero has the same finite
|
| 39 |
+
weak limit. The norm bound gives the actual error for every test function. -/
|
| 40 |
+
theorem finiteMeasure_restrict_tendsto {Ω : Type*} [MeasurableSpace Ω]
|
| 41 |
+
[TopologicalSpace Ω] [OpensMeasurableSpace Ω]
|
| 42 |
+
(μ : ℕ → FiniteMeasure Ω) (ν : FiniteMeasure Ω) (A : Set Ω) (hA : MeasurableSet A)
|
| 43 |
+
(hμ : Tendsto μ atTop (𝓝 ν))
|
| 44 |
+
(hloss : Tendsto (fun n => ((μ n : Measure Ω) Aᶜ).toReal) atTop (𝓝 0)) :
|
| 45 |
+
Tendsto (fun n => finiteMeasureRestrict (μ n) A)
|
| 46 |
+
atTop (𝓝 ν) := by
|
| 47 |
+
apply FiniteMeasure.tendsto_of_forall_integral_tendsto
|
| 48 |
+
intro f
|
| 49 |
+
have hf := FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp hμ f
|
| 50 |
+
have he : Tendsto (fun n => ∫ x in Aᶜ, f x ∂(μ n : Measure Ω)) atTop (𝓝 0) := by
|
| 51 |
+
apply tendsto_zero_iff_norm_tendsto_zero.mpr
|
| 52 |
+
have hb := hloss.const_mul ‖f‖
|
| 53 |
+
rw [mul_zero] at hb
|
| 54 |
+
apply squeeze_zero (fun n => norm_nonneg _) _ hb
|
| 55 |
+
intro n
|
| 56 |
+
have hh := norm_integral_le_of_norm_le_const
|
| 57 |
+
(μ := (μ n : Measure Ω).restrict Aᶜ)
|
| 58 |
+
(Eventually.of_forall (fun x => f.norm_coe_le_norm x))
|
| 59 |
+
simpa only [measureReal_def,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] using hh
|
| 60 |
+
have hsub := hf.sub he
|
| 61 |
+
rw [sub_zero] at hsub
|
| 62 |
+
convert hsub using 1
|
| 63 |
+
funext n
|
| 64 |
+
exact (eq_sub_iff_add_eq.mpr (integral_add_compl (μ := (μ n : Measure Ω)) hA (f.integrable (μ := (μ n : Measure Ω)))))
|
| 65 |
+
|
| 66 |
+
/-- Actual ordered measures have the same compact-torus weak limit, for
|
| 67 |
+
all continuous tests, on one probability-one angle event. -/
|
| 68 |
+
theorem sourceSamplingTrimmed_weak_event : ∀ᵐ θ ∂sourceAngleLaw,
|
| 69 |
+
∀ I : Finset SourceCoordinate,
|
| 70 |
+
Tendsto (fun s => sourceSamplingTrimmedFinite I s θ) atTop (𝓝 (sourceSamplingLambdaFinite I)) ∧
|
| 71 |
+
Tendsto (fun s => sourceSamplingTrimmedTorus I s θ) atTop (𝓝 (sourceSamplingLambdaTorus I)) ∧
|
| 72 |
+
∀ f : C(SourceSamplingTorus,ℝ),
|
| 73 |
+
Tendsto (fun s => ∫ p, f p ∂(sourceSamplingTrimmedTorus I s θ : Measure SourceSamplingTorus))
|
| 74 |
+
atTop (𝓝 (∫ p, f p ∂(sourceSamplingLambdaTorus I : Measure SourceSamplingTorus))) := by
|
| 75 |
+
filter_upwards [sourceSamplingUntrimmed_weak_event,sourceSampling_mass_limit_event,sourceAngleLaw_admissible]
|
| 76 |
+
with θ hw hm ha
|
| 77 |
+
intro I
|
| 78 |
+
have h := finiteMeasure_restrict_tendsto (fun s => sourceSamplingUntrimmedFinite I s θ)
|
| 79 |
+
(sourceSamplingLambdaFinite I) sourceSamplingOrdered sourceSamplingOrdered_measurable
|
| 80 |
+
(hw I) (sourceSampling_discarded_tendsto I θ ha (hm I))
|
| 81 |
+
have ht := FiniteMeasure.tendsto_map_of_tendsto_of_continuous _ _ h sourceSamplingTorusMap_continuous
|
| 82 |
+
refine ⟨h,ht,fun f => ?_⟩
|
| 83 |
+
exact (FiniteMeasure.tendsto_iff_forall_integral_tendsto.mp ht) (BoundedContinuousFunction.mkOfCompact f)
|
| 84 |
+
|
| 85 |
+
end
|
| 86 |
+
end FiniteFactor
|
| 87 |
+
|
| 88 |
+
end OAI
|