import OAI.Analysis.FiniteFactor.Coupling.FiniteLaw import OAI.Analysis.FiniteFactor.ProductDensityLimit namespace OAI namespace FiniteFactor open MeasureTheory Filter Finset open scoped Topology ENNReal noncomputable section /-- Finite-coordinate factorization under the actual infinite product measure. -/ theorem integral_infinitePi_finset_prod {ι : Type*} {X : ι → Type*} [∀ i, MeasurableSpace (X i)] (μ : ∀ i, Measure (X i)) [∀ i, IsProbabilityMeasure (μ i)] (I : Finset ι) (f : ∀ i, X i → ℝ) (hf : ∀ i, Measurable (f i)) : (∫ x, ∏ i ∈ I, f i (x i) ∂Measure.infinitePi μ) = ∏ i ∈ I, ∫ t, f i t ∂μ i := by classical have he (x : ∀ i, X i) : (∏ i ∈ I, f i (x i)) = ∏ i : I, f i (x i) := (Finset.prod_coe_sort I (fun i => f i (x i))).symm simp_rw [he] change (∫ x, (∏ i : I, f i (I.restrict x i)) ∂Measure.infinitePi μ) = _ rw [integral_restrict_infinitePi μ (f := fun x : ∀ i : I, X i => ∏ i : I, f i (x i)) ((Finset.measurable_prod _ fun (i : I) _ => (hf i).comp (measurable_pi_apply i)).aestronglyMeasurable)] rw [integral_fintype_prod_eq_prod] exact Finset.prod_coe_sort I (fun i => ∫ t, f i t ∂μ i) namespace CouplingParameters variable {ι : Type*} def prefixDensity (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) (x : ι → ℝ) : ℝ := ∏ i ∈ I, (p i).endpointDensity (right i) (x i) theorem prefixDensity_measurable (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) : Measurable (prefixDensity p right I) := Finset.measurable_prod _ fun i _ => ((p i).endpointDensity_measurable (right i)).comp (measurable_pi_apply i) theorem prefixDensity_nonneg (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) (x : ι → ℝ) : 0 ≤ prefixDensity p right I x := Finset.prod_nonneg fun i _ => ((p i).diagonalMass_pos.trans_le ((p i).endpointDensity_lower (right i) (x i))).le theorem prefixDensity_memLp (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) : MemLp (prefixDensity p right I) 2 (Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) := by apply MemLp.of_bound (prefixDensity_measurable p right I).aestronglyMeasurable (10 ^ I.card) apply Eventually.of_forall intro x rw [Real.norm_of_nonneg (prefixDensity_nonneg p right I x)] calc _ ≤ ∏ i ∈ I, (10 : ℝ) := Finset.prod_le_prod₀ (fun i _ => ((p i).diagonalMass_pos.trans_le ((p i).endpointDensity_lower (right i) (x i))).le) (fun i _ => ((p i).endpointDensity_lt_ten (right i) (x i)).le) _ = _ := by simp theorem prefixDensity_integral (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) : (∫ x, prefixDensity p right I x ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) = 1 := by unfold prefixDensity rw [integral_infinitePi_finset_prod _ _ _ (fun i => (p i).endpointDensity_measurable (right i))] simp [endpointDensity_integral] theorem prefixDensity_sq_integral (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) : (∫ x, prefixDensity p right I x ^ 2 ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) = ∏ i ∈ I, ∫ t, (p i).endpointDensity (right i) t ^ 2 ∂unitIntervalMeasure := by simp only [prefixDensity, ← Finset.prod_pow] exact integral_infinitePi_finset_prod _ _ _ (fun i => ((p i).endpointDensity_measurable (right i)).pow_const 2) theorem prefixDensity_energy (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) : (∫ x, prefixDensity p right I x ^ 2 ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) ≤ Real.exp (∑ i ∈ I, 20*(2*(p i).kappa^2/(p i).m + (p i).tagMass)) := by classical rw [prefixDensity_sq_integral, ← Finset.prod_coe_sort I, ← Finset.sum_coe_sort I] exact product_energy_le_exp _ _ (fun i => integral_nonneg (fun _ => sq_nonneg _)) (fun i => (p i).endpointDensity_source_energy (right i)) /-- Exact orthogonality identity for nested finite product densities. -/ theorem prefixDensity_inner (p : ι → CouplingParameters) (right : ι → Bool) {I J : Finset ι} (hIJ : I ⊆ J) : (∫ x, prefixDensity p right I x * prefixDensity p right J x ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) = ∫ x, prefixDensity p right I x ^ 2 ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure) := by classical have he (x : ι → ℝ) : prefixDensity p right I x * prefixDensity p right J x = ∏ i ∈ J, if i ∈ I then (p i).endpointDensity (right i) (x i)^2 else (p i).endpointDensity (right i) (x i) := by have hi : prefixDensity p right I x = ∏ i ∈ J, if i ∈ I then (p i).endpointDensity (right i) (x i) else 1 := by rw [← Finset.prod_subset hIJ] · apply Finset.prod_congr rfl intro i hi simp [hi] · intro i _ hi simp [hi] rw [hi, prefixDensity, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro i _ split <;> simp_all [sq] simp_rw [he] rw [integral_infinitePi_finset_prod (fun _ : ι => unitIntervalMeasure) J (fun i t => if i ∈ I then (p i).endpointDensity (right i) t ^ 2 else (p i).endpointDensity (right i) t) (fun i => by split · exact ((p i).endpointDensity_measurable (right i)).pow_const 2 · exact (p i).endpointDensity_measurable (right i)), prefixDensity_sq_integral] calc _ = ∏ i ∈ I, ∫ t, (if i ∈ I then (p i).endpointDensity (right i) t ^ 2 else (p i).endpointDensity (right i) t) ∂unitIntervalMeasure := by symm apply Finset.prod_subset hIJ intro i _ hi simp [hi, endpointDensity_integral] _ = _ := by apply Finset.prod_congr rfl intro i hi simp [hi] /-- The lifted prefix density has exactly the finite endpoint law on every Borel cylinder at that prefix. -/ theorem prefixDensity_cylinder (p : ι → CouplingParameters) (right : ι → Bool) (I : Finset ι) {S : Set (I → ℝ)} (hS : MeasurableSet S) : ENNReal.ofReal (∫ x in (I.restrict (π := fun _ : ι => ℝ)) ⁻¹' S, prefixDensity p right I x ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) = Measure.pi (fun i : I => (p i).selectedLaw true (right i)) S := by classical rw [finiteProductLaw_density, withDensity_apply _ hS] rw [← Measure.infinitePi_map_restrict (fun _ : ι => unitIntervalMeasure), setLIntegral_map hS (finiteProductDensity_measurable (fun i : I => p i) (fun _ => true) (fun i => right i)).ennreal_ofReal (measurable_restrict I)] have he (x : ι → ℝ) : finiteProductDensity (fun i : I => p i) (fun _ => true) (fun i => right i) ((I.restrict (π := fun _ : ι => ℝ)) x) = prefixDensity p right I x := by exact Finset.prod_coe_sort I (fun i => (p i).endpointDensity (right i) (x i)) simp_rw [he] exact ofReal_integral_eq_lintegral_ofReal ((prefixDensity_memLp p right I).integrable (by norm_num)).restrict (Eventually.of_forall (prefixDensity_nonneg p right I)) /-- Enlarging the prefix does not change any earlier cylinder law. -/ theorem prefixDensity_cylinder_of_subset (p : ι → CouplingParameters) (right : ι → Bool) {J I : Finset ι} (hJI : J ⊆ I) {S : Set (J → ℝ)} (hS : MeasurableSet S) : ENNReal.ofReal (∫ x in (J.restrict (π := fun _ : ι => ℝ)) ⁻¹' S, prefixDensity p right I x ∂Measure.infinitePi (fun _ : ι => unitIntervalMeasure)) = Measure.pi (fun i : J => (p i).selectedLaw true (right i)) S := by have he : (J.restrict (π := fun _ : ι => ℝ)) ⁻¹' S = (I.restrict (π := fun _ : ι => ℝ)) ⁻¹' ((Finset.restrict₂ (π := fun _ : ι => ℝ) hJI : (I → ℝ) → (J → ℝ)) ⁻¹' S) := by rw [← Set.preimage_comp, Finset.restrict₂_comp_restrict hJI] rw [he, prefixDensity_cylinder p right I (hS.preimage (measurable_restrict₂ hJI))] have hh := congrArg (fun ν : Measure (J → ℝ) => ν S) (isProjectiveMeasureFamily_pi (fun i => (p i).selectedLaw true (right i)) I J hJI) rw [Measure.map_apply (show Measurable (Finset.restrict₂ (π := fun _ : ι => ℝ) hJI) from measurable_restrict₂ hJI) hS] at hh exact hh.symm end CouplingParameters end end FiniteFactor end OAI