-- Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Integral.lean
/-- The continuous functional calculus commutes with integration. -/
lemma cfc_integral [TopologicalSpace X] [OpensMeasurableSpace X] (f : X → 𝕜 → 𝕜)
    (bound : X → ℝ) (a : A) [SecondCountableTopologyEither X C(spectrum 𝕜 a, 𝕜)]
    (hf₁ : ∀ x, ContinuousOn (f x) (spectrum 𝕜 a))
    (hf₂ : Continuous (fun x ↦ (⟨_, hf₁ x |>.restrict⟩ : C(spectrum 𝕜 a, 𝕜))))
    (hbound : ∀ x, ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖)
    (hbound_finite_integral : HasFiniteIntegral bound μ) (ha : p a

Proof state:
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
fc : X → C(↑(spectrum 𝕜 a), 𝕜) := fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
fc_integrable : Integrable fc μ
h_int_fc : ((spectrum 𝕜 a).restrict fun x => ∫ (x_1 : X), f x_1 x ∂μ) = ⇑(∫ (x : X), fc x ∂μ)
⊢ cfc (fun r => ∫ (x : X), f x r ∂μ) a = ∫ (x : X), cfc (f x) a ∂μ

Tactic:
have hcont₂ : ContinuousOn (fun r => ∫ x, f x r ∂μ) (spectrum 𝕜 a) := by
  rw [continuousOn_iff_continuous_restrict]
  convert map_continuous (∫ x, fc x ∂μ)

Result:
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
fc : X → C(↑(spectrum 𝕜 a), 𝕜) := fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
fc_integrable : Integrable fc μ
h_int_fc : ((spectrum 𝕜 a).restrict fun x => ∫ (x_1 : X), f x_1 x ∂μ) = ⇑(∫ (x : X), fc x ∂μ)
hcont₂ : ContinuousOn (fun r => ∫ (x : X), f x r ∂μ) (spectrum 𝕜 a)
⊢ cfc (fun r => ∫ (x : X), f x r ∂μ) a = ∫ (x : X), cfc (f x) a ∂μ

Proof state:
case h
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
fc : X → C(↑(spectrum 𝕜 a), 𝕜) := fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
fc_integrable : Integrable fc μ
x✝ : ↑(spectrum 𝕜 a)
⊢ (spectrum 𝕜 a).restrict (fun x => ∫ (x_1 : X), f x_1 x ∂μ) x✝ = (∫ (x : X), fc x ∂μ) x✝

Tactic:
simp [integral_apply fc_integrable, fc]

Result:
no goals

Proof state:
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
⊢ cfc (fun r => ∫ (x : X), f x r ∂μ) a = ∫ (x : X), cfc (f x) a ∂μ

Tactic:
let fc : X → C(spectrum 𝕜 a, 𝕜) := fun x => ⟨_, (hf₁ x).restrict⟩

Result:
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
fc : X → C(↑(spectrum 𝕜 a), 𝕜) := fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
⊢ cfc (fun r => ∫ (x : X), f x r ∂μ) a = ∫ (x : X), cfc (f x) a ∂μ

Proof state:
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
fc : X → C(↑(spectrum 𝕜 a), 𝕜) := fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
⊢ cfc (fun r => ∫ (x : X), f x r ∂μ) a = ∫ (x : X), cfc (f x) a ∂μ

Tactic:
have fc_integrable : Integrable fc μ := by
  refine ⟨hf₂.aestronglyMeasurable, ?_⟩
  refine hbound_finite_integral.mono <| .of_forall fun x ↦ ?_
  rw [norm_le _ (norm_nonneg (bound x))]
  exact fun z ↦ hbound x z.1 z.2

Result:
X : Type u_1
𝕜 : Type u_2
A : Type u_3
p : A → Prop
inst✝¹⁰ : RCLike 𝕜
inst✝⁹ : MeasurableSpace X
μ : Measure X
inst✝⁸ : NormedRing A
inst✝⁷ : StarRing A
inst✝⁶ : NormedAlgebra 𝕜 A
inst✝⁵ : NormedAlgebra ℝ A
inst✝⁴ : CompleteSpace A
inst✝³ : ContinuousFunctionalCalculus 𝕜 p
inst✝² : TopologicalSpace X
inst✝¹ : OpensMeasurableSpace X
f : X → 𝕜 → 𝕜
bound : X → ℝ
a : A
inst✝ : SecondCountableTopologyEither X C(↑(spectrum 𝕜 a), 𝕜)
hf₁ : ∀ (x : X), ContinuousOn (f x) (spectrum 𝕜 a)
hf₂ : Continuous fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
hbound : ∀ (x : X), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ ‖bound x‖
hbound_finite_integral : HasFiniteIntegral bound μ
ha : autoParam (p a) _auto✝
fc : X → C(↑(spectrum 𝕜 a), 𝕜) := fun x => { toFun := (spectrum 𝕜 a).restrict (f x), continuous_toFun := ⋯ }
fc_integrable : Integrable fc μ
⊢ cfc (fun r => ∫ (x : X), f x r ∂μ) a = ∫ (x : X), cfc (f x) a ∂μ