-- Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Restrict.lean
theorem cfc (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) (h0 : p 0)
    (h : ∀ a, p a ↔ q a ∧ SpectrumRestricts a f) :
    ContinuousFunctionalCalculus R p where
  predicate_zero := h0
  spectrum_nonempty a ha := ((h a).mp ha).2.image ▸
    (ContinuousFunctionalCalculus.spectrum_nonempty a ((h a).mp ha).1 |>.image f)
  compactSpace_spectrum a

Proof state:
R : Type u_1
S : Type u_2
A : Type u_3
p q : A → Prop
inst✝²⁰ : Semifield R
inst✝¹⁹ : StarRing R
inst✝¹⁸ : MetricSpace R
inst✝¹⁷ : IsTopologicalSemiring R
inst✝¹⁶ : ContinuousStar R
inst✝¹⁵ : Semifield S
inst✝¹⁴ : StarRing S
inst✝¹³ : MetricSpace S
inst✝¹² : IsTopologicalSemiring S
inst✝¹¹ : ContinuousStar S
inst✝¹⁰ : Ring A
inst✝⁹ : StarRing A
inst✝⁸ : Algebra S A
inst✝⁷ : Algebra R S
inst✝⁶ : Algebra R A
inst✝⁵ : IsScalarTower R S A
inst✝⁴ : StarModule R S
inst✝³ : ContinuousSMul R S
inst✝² : TopologicalSpace A
inst✝¹ : ContinuousFunctionalCalculus S q
inst✝ : CompleteSpace R
f : C(S, R)
halg : IsUniformEmbedding ⇑(algebraMap R S)
h0 : p 0
h : ∀ (a : A), p a ↔ q a ∧ SpectrumRestricts a ⇑f
a : A
ha : p a
g : C(↑(spectrum R a), R)
⊢ ⇑(algebraMap R S) ⁻¹'
      range
        ⇑({ toFun := ⇑(StarAlgHom.ofId R S), continuous_toFun := ⋯ }.comp
            (g.comp { toFun := Subtype.map ⇑f ⋯, continuous_toFun := ⋯ })) =
    range ⇑g

Tactic:
ext x

Result:
case h
R : Type u_1
S : Type u_2
A : Type u_3
p q : A → Prop
inst✝²⁰ : Semifield R
inst✝¹⁹ : StarRing R
inst✝¹⁸ : MetricSpace R
inst✝¹⁷ : IsTopologicalSemiring R
inst✝¹⁶ : ContinuousStar R
inst✝¹⁵ : Semifield S
inst✝¹⁴ : StarRing S
inst✝¹³ : MetricSpace S
inst✝¹² : IsTopologicalSemiring S
inst✝¹¹ : ContinuousStar S
inst✝¹⁰ : Ring A
inst✝⁹ : StarRing A
inst✝⁸ : Algebra S A
inst✝⁷ : Algebra R S
inst✝⁶ : Algebra R A
inst✝⁵ : IsScalarTower R S A
inst✝⁴ : StarModule R S
inst✝³ : ContinuousSMul R S
inst✝² : TopologicalSpace A
inst✝¹ : ContinuousFunctionalCalculus S q
inst✝ : CompleteSpace R
f : C(S, R)
halg : IsUniformEmbedding ⇑(algebraMap R S)
h0 : p 0
h : ∀ (a : A), p a ↔ q a ∧ SpectrumRestricts a ⇑f
a : A
ha : p a
g : C(↑(spectrum R a), R)
x : R
⊢ x ∈
      ⇑(algebraMap R S) ⁻¹'
        range
          ⇑({ toFun := ⇑(StarAlgHom.ofId R S), continuous_toFun := ⋯ }.comp
              (g.comp { toFun := Subtype.map ⇑f ⋯, continuous_toFun := ⋯ })) ↔
    x ∈ range ⇑g

Proof state:
case h.mp.intro
R : Type u_1
S : Type u_2
A : Type u_3
p q : A → Prop
inst✝²⁰ : Semifield R
inst✝¹⁹ : StarRing R
inst✝¹⁸ : MetricSpace R
inst✝¹⁷ : IsTopologicalSemiring R
inst✝¹⁶ : ContinuousStar R
inst✝¹⁵ : Semifield S
inst✝¹⁴ : StarRing S
inst✝¹³ : MetricSpace S
inst✝¹² : IsTopologicalSemiring S
inst✝¹¹ : ContinuousStar S
inst✝¹⁰ : Ring A
inst✝⁹ : StarRing A
inst✝⁸ : Algebra S A
inst✝⁷ : Algebra R S
inst✝⁶ : Algebra R A
inst✝⁵ : IsScalarTower R S A
inst✝⁴ : StarModule R S
inst✝³ : ContinuousSMul R S
inst✝² : TopologicalSpace A
inst✝¹ : ContinuousFunctionalCalculus S q
inst✝ : CompleteSpace R
f : C(S, R)
halg : IsUniformEmbedding ⇑(algebraMap R S)
h0 : p 0
h : ∀ (a : A), p a ↔ q a ∧ SpectrumRestricts a ⇑f
a : A
ha : p a
g : C(↑(spectrum R a), R)
x : R
y : ↑(spectrum S a)
hy :
  ({ toFun := ⇑(StarAlgHom.ofId R S), continuous_toFun := ⋯ }.comp
        (g.comp { toFun := Subtype.map ⇑f ⋯, continuous_toFun := ⋯ }))
      y =
    (algebraMap R S) x
this : g (Subtype.map ⇑f ⋯ y) = x
⊢ x ∈ range ⇑g

Tactic:
exact ⟨_, this⟩

Result:
no goals

Proof state:
R : Type u_1
S : Type u_2
A : Type u_3
p q : A → Prop
inst✝²⁰ : Semifield R
inst✝¹⁹ : StarRing R
inst✝¹⁸ : MetricSpace R
inst✝¹⁷ : IsTopologicalSemiring R
inst✝¹⁶ : ContinuousStar R
inst✝¹⁵ : Semifield S
inst✝¹⁴ : StarRing S
inst✝¹³ : MetricSpace S
inst✝¹² : IsTopologicalSemiring S
inst✝¹¹ : ContinuousStar S
inst✝¹⁰ : Ring A
inst✝⁹ : StarRing A
inst✝⁸ : Algebra S A
inst✝⁷ : Algebra R S
inst✝⁶ : Algebra R A
inst✝⁵ : IsScalarTower R S A
inst✝⁴ : StarModule R S
inst✝³ : ContinuousSMul R S
inst✝² : TopologicalSpace A
inst✝¹ : ContinuousFunctionalCalculus S q
inst✝ : CompleteSpace R
f : C(S, R)
halg : IsUniformEmbedding ⇑(algebraMap R S)
h0 : p 0
h : ∀ (a : A), p a ↔ q a ∧ SpectrumRestricts a ⇑f
a : A
ha : p a
g : C(↑(spectrum R a), R)
⊢ SpectrumRestricts ((starAlgHom (cfcHom ⋯) ⋯) g) ⇑f

Tactic:
refine .of_rightInvOn (((h a).mp ha).2.left_inv) fun s hs ↦ ?_

Result:
R : Type u_1
S : Type u_2
A : Type u_3
p q : A → Prop
inst✝²⁰ : Semifield R
inst✝¹⁹ : StarRing R
inst✝¹⁸ : MetricSpace R
inst✝¹⁷ : IsTopologicalSemiring R
inst✝¹⁶ : ContinuousStar R
inst✝¹⁵ : Semifield S
inst✝¹⁴ : StarRing S
inst✝¹³ : MetricSpace S
inst✝¹² : IsTopologicalSemiring S
inst✝¹¹ : ContinuousStar S
inst✝¹⁰ : Ring A
inst✝⁹ : StarRing A
inst✝⁸ : Algebra S A
inst✝⁷ : Algebra R S
inst✝⁶ : Algebra R A
inst✝⁵ : IsScalarTower R S A
inst✝⁴ : StarModule R S
inst✝³ : ContinuousSMul R S
inst✝² : TopologicalSpace A
inst✝¹ : ContinuousFunctionalCalculus S q
inst✝ : CompleteSpace R
f : C(S, R)
halg : IsUniformEmbedding ⇑(algebraMap R S)
h0 : p 0
h : ∀ (a : A), p a ↔ q a ∧ SpectrumRestricts a ⇑f
a : A
ha : p a
g : C(↑(spectrum R a), R)
s : S
hs : s ∈ spectrum S ((starAlgHom (cfcHom ⋯) ⋯) g)
⊢ (algebraMap R S) (f s) = s