-- Mathlib/Topology/Inseparable.lean
theorem IsOpen.continuous_piecewise_of_specializes [DecidablePred (· ∈ s)] (hs : IsOpen s)
    (hf : Continuous f) (hg : Continuous g) (hspec : ∀ x, f x ⤳ g x) :
    Continuous (s.piecewise f g)

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
U : Set Y
hU : IsOpen U
⊢ IsOpen (f ⁻¹' U ∩ s ∪ g ⁻¹' U)

Tactic:
exact hU.preimage hf |>.inter hs |>.union (hU.preimage hg)

Result:
no goals

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
⊢ Continuous (s.piecewise f g)

Tactic:
rw [continuous_def]

Result:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
⊢ ∀ (s_1 : Set Y), IsOpen s_1 → IsOpen (s.piecewise f g ⁻¹' s_1)

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
⊢ ∀ (s_1 : Set Y), IsOpen s_1 → IsOpen (s.piecewise f g ⁻¹' s_1)

Tactic:
intro U hU

Result:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
U : Set Y
hU : IsOpen U
⊢ IsOpen (s.piecewise f g ⁻¹' U)

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
⊢ Continuous (s.piecewise f g)

Tactic:
have : ∀ U, IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U := fun U hU x hx ↦ (hspec x).mem_open hU hx

Result:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
⊢ Continuous (s.piecewise f g)

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
U : Set Y
hU : IsOpen U
⊢ IsOpen (s.piecewise f g ⁻¹' U)

Tactic:
rw [piecewise_preimage, ite_eq_of_subset_right _ (this U hU)]

Result:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s : Set X
f g : X → Y
inst✝ : DecidablePred fun x => x ∈ s
hs : IsOpen s
hf : Continuous f
hg : Continuous g
hspec : ∀ (x : X), f x ⤳ g x
this : ∀ (U : Set Y), IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U
U : Set Y
hU : IsOpen U
⊢ IsOpen (f ⁻¹' U ∩ s ∪ g ⁻¹' U)