l3lab/ntp-mathlib huggingface dataset:
theorem isPreconnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)}
    (hs : ∀ i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by
  rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩
  rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩
  induction' I using Finset.induction_on with i I _ ihI
  · refine' ⟨g, hgs, ⟨_, hgv⟩⟩
    simpa using hI
  · rw [Finset.piecewise_insert] at hI
    have := I.piecewise_mem_set_pi hfs hgs
    refine' (hsuv this).elim ihI fun h => _
    set S := update (I.piecewise f g) i '' s i
    have hsub : S ⊆ pi univ s := by
      refine' image_subset_iff.2 fun z hz => _
      rwa [update_preimage_univ_pi]
      exact fun j _ => this j trivial
    have hconn : IsPreconnected S :=
      (hs i).image _ (continuous_const.update i continuous_id).continuousOn
    have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩
    have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩
    refine' (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono _
    

Proof state:
case intro.intro.intro.intro.intro.insert
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u✝ v✝ : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : (i : ι) → Set (π i)
hs : ∀ (i : ι), IsPreconnected (s i)
u v : Set ((i : ι) → π i)
uo : IsOpen u
vo : IsOpen v
hsuv : pi univ s ⊆ u ∪ v
f : (i : ι) → π i
hfs : f ∈ pi univ s
hfu : f ∈ u
g : (i : ι) → π i
hgs : g ∈ pi univ s
hgv : g ∈ v
i : ι
I : Finset ι
a✝ : i ∉ I
ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v))
hI : update (Finset.piecewise I f g) i (f i) ∈ u
this : Finset.piecewise I f g ∈ pi univ s
h : Finset.piecewise I f g ∈ v
S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i
hsub : S ⊆ pi univ s
hconn : IsPreconnected S
hSu : Set.Nonempty (S ∩ u)
hSv : Set.Nonempty (S ∩ v)
⊢ S ∩ (u ∩ v) ⊆ pi univ s ∩ (u ∩ v)

Next tactic:
exact inter_subset_inter_left _ hsub
@[simp]
theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} :
    IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : (i : ι) → Set (π i)
⊢ IsConnected (pi univ s) ↔ ∀ (i : ι), IsConnected (s i)

Next tactic:
simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff]
@[simp]
theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} :
    IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by
  simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff]
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : (i : ι) → Set (π i)
⊢ Set.Nonempty (pi univ s) → (IsPreconnected (pi univ s) ↔ ∀ (x : ι), IsPreconnected (s x))

Next tactic:
refine' fun hne => ⟨fun hc i => _, isPreconnected_univ_pi⟩
@[simp]
theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} :
    IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by
  simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff]
  refine' fun hne => ⟨fun hc i => _, isPreconnected_univ_pi⟩
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : (i : ι) → Set (π i)
hne : Set.Nonempty (pi univ s)
hc : IsPreconnected (pi univ s)
i : ι
⊢ IsPreconnected (s i)

Next tactic:
rw [← eval_image_univ_pi hne]
@[simp]
theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} :
    IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by
  simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff]
  refine' fun hne => ⟨fun hc i => _, isPreconnected_univ_pi⟩
  rw [← eval_image_univ_pi hne]
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : (i : ι) → Set (π i)
hne : Set.Nonempty (pi univ s)
hc : IsPreconnected (pi univ s)
i : ι
⊢ IsPreconnected ((fun f => f i) '' pi univ s)

Next tactic:
exact hc.image _ (continuous_apply _).continuousOn
theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :
    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
⊢ IsConnected s ↔ ∃ i t, IsConnected t ∧ s = mk i '' t

Next tactic:
refine' ⟨fun hs => _, _⟩
theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :
    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · 

Proof state:
case refine'_1
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
hs : IsConnected s
⊢ ∃ i t, IsConnected t ∧ s = mk i '' t

Next tactic:
obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty
theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :
    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty
    

Proof state:
case refine'_1.intro.mk
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
hs : IsConnected s
i : ι
x : π i
hx : { fst := i, snd := x } ∈ s
⊢ ∃ i t, IsConnected t ∧ s = mk i '' t

Next tactic:
have : s ⊆ range (Sigma.mk i) :=
      hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩
theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :
    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty
    have : s ⊆ range (Sigma.mk i) :=
      hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩
    

Proof state:
case refine'_1.intro.mk
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
hs : IsConnected s
i : ι
x : π i
hx : { fst := i, snd := x } ∈ s
this : s ⊆ range (mk i)
⊢ ∃ i t, IsConnected t ∧ s = mk i '' t

Next tactic:
exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this,
      (Set.image_preimage_eq_of_subset this).symm⟩
theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :
    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty
    have : s ⊆ range (Sigma.mk i) :=
      hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩
    exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this,
      (Set.image_preimage_eq_of_subset this).symm⟩
  · 

Proof state:
case refine'_2
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
⊢ (∃ i t, IsConnected t ∧ s = mk i '' t) → IsConnected s

Next tactic:
rintro ⟨i, t, ht, rfl⟩
theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :
    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty
    have : s ⊆ range (Sigma.mk i) :=
      hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩
    exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this,
      (Set.image_preimage_eq_of_subset this).symm⟩
  · rintro ⟨i, t, ht, rfl⟩
    

Proof state:
case refine'_2.intro.intro.intro
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s t✝ u v : Set α
inst✝ : (i : ι) → TopologicalSpace (π i)
i : ι
t : Set (π i)
ht : IsConnected t
⊢ IsConnected (mk i '' t)

Next tactic:
exact ht.image _ continuous_sigmaMk.continuousOn
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
⊢ IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = mk i '' t

Next tactic:
refine' ⟨fun hs => _, _⟩
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · 

Proof state:
case refine'_1
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
hs : IsPreconnected s
⊢ ∃ i t, IsPreconnected t ∧ s = mk i '' t

Next tactic:
obtain rfl | h := s.eq_empty_or_nonempty
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain rfl | h := s.eq_empty_or_nonempty
    · 

Proof state:
case refine'_1.inl
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s t u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
hs : IsPreconnected ∅
⊢ ∃ i t, IsPreconnected t ∧ ∅ = mk i '' t

Next tactic:
exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain rfl | h := s.eq_empty_or_nonempty
    · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩
    · 

Proof state:
case refine'_1.inr
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
hs : IsPreconnected s
h : Set.Nonempty s
⊢ ∃ i t, IsPreconnected t ∧ s = mk i '' t

Next tactic:
obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain rfl | h := s.eq_empty_or_nonempty
    · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩
    · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩
      

Proof state:
case refine'_1.inr.intro.intro.intro
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s t✝ u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
a : ι
t : Set (π a)
ht : IsConnected t
hs : IsPreconnected (mk a '' t)
h : Set.Nonempty (mk a '' t)
⊢ ∃ i t_1, IsPreconnected t_1 ∧ mk a '' t = mk i '' t_1

Next tactic:
refine' ⟨a, t, ht.isPreconnected, rfl⟩
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain rfl | h := s.eq_empty_or_nonempty
    · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩
    · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩
      refine' ⟨a, t, ht.isPreconnected, rfl⟩
  · 

Proof state:
case refine'_2
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
s : Set ((i : ι) × π i)
⊢ (∃ i t, IsPreconnected t ∧ s = mk i '' t) → IsPreconnected s

Next tactic:
rintro ⟨a, t, ht, rfl⟩
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]
    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain rfl | h := s.eq_empty_or_nonempty
    · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩
    · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩
      refine' ⟨a, t, ht.isPreconnected, rfl⟩
  · rintro ⟨a, t, ht, rfl⟩
    

Proof state:
case refine'_2.intro.intro.intro
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s t✝ u v : Set α
hι : Nonempty ι
inst✝ : (i : ι) → TopologicalSpace (π i)
a : ι
t : Set (π a)
ht : IsPreconnected t
⊢ IsPreconnected (mk a '' t)

Next tactic:
exact ht.image _ continuous_sigmaMk.continuousOn
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  

Proof state:
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
⊢ IsConnected s ↔ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t

Next tactic:
refine' ⟨fun hs => _, _⟩
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · 

Proof state:
case refine'_1
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t

Next tactic:
obtain ⟨x | x, hx⟩ := hs.nonempty
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · 

Proof state:
case refine'_1.intro.inl
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : α
hx : inl x ∈ s
⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t

Next tactic:
have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      

Proof state:
case refine'_1.intro.inl
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : α
hx : inl x ∈ s
h : s ⊆ range inl
⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t

Next tactic:
refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · 

Proof state:
case refine'_1.intro.inl.refine'_1
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : α
hx : inl x ∈ s
h : s ⊆ range inl
⊢ IsConnected (inl ⁻¹' s)

Next tactic:
exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · 

Proof state:
case refine'_1.intro.inl.refine'_2
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : α
hx : inl x ∈ s
h : s ⊆ range inl
⊢ s = inl '' (inl ⁻¹' s)

Next tactic:
exact (image_preimage_eq_of_subset h).symm
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · exact (image_preimage_eq_of_subset h).symm
    · 

Proof state:
case refine'_1.intro.inr
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : β
hx : inr x ∈ s
⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t

Next tactic:
have h : s ⊆ range Sum.inr :=
        hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · exact (image_preimage_eq_of_subset h).symm
    · have h : s ⊆ range Sum.inr :=
        hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩
      

Proof state:
case refine'_1.intro.inr
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : β
hx : inr x ∈ s
h : s ⊆ range inr
⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t

Next tactic:
refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · exact (image_preimage_eq_of_subset h).symm
    · have h : s ⊆ range Sum.inr :=
        hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩
      refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩
      · 

Proof state:
case refine'_1.intro.inr.refine'_1
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : β
hx : inr x ∈ s
h : s ⊆ range inr
⊢ IsConnected (inr ⁻¹' s)

Next tactic:
exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · exact (image_preimage_eq_of_subset h).symm
    · have h : s ⊆ range Sum.inr :=
        hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩
      refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h
      · 

Proof state:
case refine'_1.intro.inr.refine'_2
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
hs : IsConnected s
x : β
hx : inr x ∈ s
h : s ⊆ range inr
⊢ s = inr '' (inr ⁻¹' s)

Next tactic:
exact (image_preimage_eq_of_subset h).symm
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · exact (image_preimage_eq_of_subset h).symm
    · have h : s ⊆ range Sum.inr :=
        hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩
      refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h
      · exact (image_preimage_eq_of_subset h).symm
  · 

Proof state:
case refine'_2
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s✝ t u v : Set α
inst✝ : TopologicalSpace β
s : Set (α ⊕ β)
⊢ ((∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t) → IsConnected s

Next tactic:
rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩)
theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :
    IsConnected s ↔
      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by
  refine' ⟨fun hs => _, _⟩
  · obtain ⟨x | x, hx⟩ := hs.nonempty
    · have h : s ⊆ range Sum.inl :=
        hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩
      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h
      · exact (image_preimage_eq_of_subset h).symm
    · have h : s ⊆ range Sum.inr :=
        hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩
      refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩
      · exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h
      · exact (image_preimage_eq_of_subset h).symm
  · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩)
    · 

Proof state:
case refine'_2.inl.intro.intro
α : Type u
β : Type v
ι : Type u_1
π : ι → Type u_2
inst✝¹ : TopologicalSpace α
s t✝ u v : Set α
inst✝ : TopologicalSpace β
t : Set α
ht : IsConnected t
⊢ IsConnected (inl '' t)

Next tactic:
exact ht.image _ continuous_inl.continuousOn