import OAI.Analysis.FiniteFactor.Matrix.Integrals import Mathlib.MeasureTheory.Integral.Bochner.SumMeasure namespace OAI namespace FiniteFactor open MeasureTheory Filter open scoped ENNReal ComplexConjugate noncomputable section def sourceFiberInner (f g : SourceHilbert SourceCoordinate) (x : SourceCoordinate → ℝ) : ℂ := ∫ n : ℤ, inner ℂ (f (x,n)) (g (x,n)) ∂Measure.count theorem sourceFiberInner_integrable (f g : SourceHilbert SourceCoordinate) : Integrable (sourceFiberInner f g) sourceBaseMeasure := (L2.integrable_inner (𝕜 := ℂ) f g).integral_prod_left theorem source_inner_fiber (f g : SourceHilbert SourceCoordinate) : inner ℂ f g = ∫ x, sourceFiberInner f g x ∂sourceBaseMeasure := integral_prod _ (L2.integrable_inner (𝕜 := ℂ) f g) theorem sourceScalar_indicator_inner (A : Set (SourceCoordinate → ℝ)) (hA : MeasurableSet A) (f g : SourceHilbert SourceCoordinate) : inner ℂ (sourceScalar (sourceBaseIndicator A hA) f) g = ∫ x in A, sourceFiberInner f g x ∂sourceBaseMeasure := by rw [source_inner_fiber, ← integral_indicator hA] apply integral_congr_ae filter_upwards [source_ae_all_fibers (sourceScalar_apply_ae (sourceBaseIndicator A hA) f)] with x hx unfold sourceFiberInner by_cases ha : x ∈ A · simp only [Set.indicator_of_mem ha] apply integral_congr_ae exact Eventually.of_forall fun n => by dsimp only; rw [hx]; simp [sourceBaseIndicator, ha] · simp only [Set.indicator_of_notMem ha] have he : (fun n : ℤ => inner ℂ ((sourceScalar (sourceBaseIndicator A hA) f) (x,n)) (g (x,n))) = fun _ => (0 : ℂ) := by funext n rw [hx] simp [sourceBaseIndicator, ha] rw [he, integral_zero] /-- The scalar distribution identity determining every output coordinate of H. -/ theorem source_coordinate_action_inner (θ : SourceCoordinate → ℝ) {H : SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate} (hH : H ∈ sourceAlgebra θ) (f : SourceHilbert SourceCoordinate) (k : ℤ) : (fun x => (H f) (x,k)) =ᵐ[sourceBaseMeasure] sourceFiberInner ((star H) (sourceBasis k)) f := by apply Integrable.ae_eq_of_forall_setIntegral_eq _ _ (source_fiber_integrable _ _) (sourceFiberInner_integrable _ _) intro A hA _ rw [← source_fiber_integral, ← L2.inner_indicatorConstLp_one] change inner ℂ (sourceFiberIndicator A hA k) (H f) = _ rw [← ContinuousLinearMap.adjoint_inner_left, ← ContinuousLinearMap.star_eq_adjoint] have he : (star H) (sourceFiberIndicator A hA k) = sourceScalar (sourceBaseIndicator A hA) ((star H) (sourceBasis k)) := by rw [← sourceScalar_indicator_basis] exact (congrArg (fun T : SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate => T (sourceBasis k)) (sourceAlgebra_commutes_scalar θ (star_mem hH) (sourceBaseIndicator A hA))).symm rw [he, sourceScalar_indicator_inner] /-- Actual action on arbitrary L2 input, expressed through the constructed matrix entries. The counting integral is an absolutely convergent series a.e. -/ theorem sourceMatrix_action (θ : SourceCoordinate → ℝ) {H : SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate} (hH : H ∈ sourceAlgebra θ) (f : SourceHilbert SourceCoordinate) (k : ℤ) : (fun x => (H f) (x,k)) =ᵐ[sourceBaseMeasure] fun x => ∫ n : ℤ, sourceMatrixEntry H k n x * f (x,n) ∂Measure.count := by have hs : ∀ᵐ x ∂sourceBaseMeasure, ∀ n : ℤ, sourceMatrixEntry (star H) n k x = star (sourceMatrixEntry H k n x) := by rw [ae_all_iff] intro n exact sourceMatrixEntry_star θ hH n k filter_upwards [source_coordinate_action_inner θ hH f k, hs] with x hx hs rw [hx] unfold sourceFiberInner apply integral_congr_ae exact Eventually.of_forall fun n => by change inner ℂ (sourceMatrixEntry (star H) n k x) (f (x,n)) = _ rw [hs] simp [RCLike.inner_apply, mul_comm] /-- The matrix action is absolutely integrable over the counting measure. -/ theorem sourceMatrix_action_integrable (θ : SourceCoordinate → ℝ) {H : SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate} (hH : H ∈ sourceAlgebra θ) (f : SourceHilbert SourceCoordinate) (k : ℤ) : ∀ᵐ x ∂sourceBaseMeasure, Integrable (fun n : ℤ => sourceMatrixEntry H k n x * f (x,n)) Measure.count := by have hs : ∀ᵐ x ∂sourceBaseMeasure, ∀ n : ℤ, sourceMatrixEntry (star H) n k x = star (sourceMatrixEntry H k n x) := by rw [ae_all_iff] intro n exact sourceMatrixEntry_star θ hH n k filter_upwards [(L2.integrable_inner (𝕜 := ℂ) ((star H) (sourceBasis k)) f).prod_right_ae, hs] with x hi hs apply hi.congr exact Eventually.of_forall fun n => by change inner ℂ (sourceMatrixEntry (star H) n k x) (f (x,n)) = _ rw [hs] simp [RCLike.inner_apply, mul_comm] theorem sourceMatrix_action_tsum (θ : SourceCoordinate → ℝ) {H : SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate} (hH : H ∈ sourceAlgebra θ) (f : SourceHilbert SourceCoordinate) (k : ℤ) : ∀ᵐ x ∂sourceBaseMeasure, (H f) (x,k) = ∑' n : ℤ, sourceMatrixEntry H k n x * f (x,n) := by filter_upwards [sourceMatrix_action θ hH f k, sourceMatrix_action_integrable θ hH f k] with x hx hi rw [hx, integral_countable hi] simp [measureReal_def] /-- Products are given by the matrix product on a single conull base set. -/ theorem sourceMatrix_mul (θ : SourceCoordinate → ℝ) {H B : SourceHilbert SourceCoordinate →L[ℂ] SourceHilbert SourceCoordinate} (hH : H ∈ sourceAlgebra θ) : ∀ᵐ x ∂sourceBaseMeasure, ∀ k n : ℤ, sourceMatrixEntry (H * B) k n x = ∫ r : ℤ, sourceMatrixEntry H k r x * sourceMatrixEntry B r n x ∂Measure.count := by rw [ae_all_iff] intro k rw [ae_all_iff] intro n exact sourceMatrix_action θ hH (B (sourceBasis n)) k end end FiniteFactor end OAI