-- Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean
theorem comp_attachBound_mem_closure (A : Subalgebra ℝ C(X, ℝ)) (f : A)
    (p : C(Set.Icc (-‖f‖) ‖f‖, ℝ)) : p.comp (attachBound (f : C(X, ℝ))) ∈ A.topologicalClosure

Proof state:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
⊢ p.comp (↑f).attachBound ∈ A.topologicalClosure

Tactic:
have frequently_mem_polynomials := mem_closure_iff_frequently.mp mem_closure

Result:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
⊢ p.comp (↑f).attachBound ∈ A.topologicalClosure

Proof state:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
⊢ ∃ᶠ (x : C(X, ℝ)) in nhds (p.comp (↑f).attachBound), x ∈ ↑A.toSubsemiring

Tactic:
refine
  ((compRightContinuousMap ℝ (attachBound (f : C(X, ℝ)))).continuousAt
          p).tendsto.frequently_map
    _ ?_ frequently_mem_polynomials

Result:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
⊢ ∀ x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring,
    (compRightContinuousMap ℝ (↑f).attachBound) x ∈ ↑A.toSubsemiring

Proof state:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
⊢ p.comp (↑f).attachBound ∈ A.topologicalClosure

Tactic:
have mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure :=
  continuousMap_mem_polynomialFunctions_closure _ _ p

Result:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
⊢ p.comp (↑f).attachBound ∈ A.topologicalClosure

Proof state:
case intro.intro
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
g : ℝ[X]
⊢ (compRightContinuousMap ℝ (↑f).attachBound) (↑(Polynomial.toContinuousMapOnAlgHom (Set.Icc (-‖f‖) ‖f‖)) g) ∈
    ↑A.toSubsemiring

Tactic:
simp only [SetLike.mem_coe, AlgHom.coe_toRingHom, compRightContinuousMap_apply,
  Polynomial.toContinuousMapOnAlgHom_apply]

Result:
case intro.intro
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
g : ℝ[X]
⊢ (g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (↑f).attachBound ∈ A.toSubsemiring

Proof state:
case intro.intro
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
g : ℝ[X]
⊢ (g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (↑f).attachBound ∈ A.toSubsemiring

Tactic:
apply polynomial_comp_attachBound_mem

Result:
no goals

Proof state:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
⊢ ∀ x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring,
    (compRightContinuousMap ℝ (↑f).attachBound) x ∈ ↑A.toSubsemiring

Tactic:
rintro _ ⟨g, ⟨-, rfl⟩⟩

Result:
case intro.intro
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
g : ℝ[X]
⊢ (compRightContinuousMap ℝ (↑f).attachBound) (↑(Polynomial.toContinuousMapOnAlgHom (Set.Icc (-‖f‖) ‖f‖)) g) ∈
    ↑A.toSubsemiring

Proof state:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
⊢ p.comp (↑f).attachBound ∈ A.topologicalClosure

Tactic:
apply mem_closure_iff_frequently.mpr

Result:
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : CompactSpace X
A : Subalgebra ℝ C(X, ℝ)
f : ↥A
p : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)
mem_closure : p ∈ (polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).topologicalClosure
frequently_mem_polynomials :
  ∃ᶠ (x : C(↑(Set.Icc (-‖f‖) ‖f‖), ℝ)) in nhds p, x ∈ ↑(polynomialFunctions (Set.Icc (-‖f‖) ‖f‖)).toSubsemiring
⊢ ∃ᶠ (x : C(X, ℝ)) in nhds (p.comp (↑f).attachBound), x ∈ ↑A.toSubsemiring