l3lab/ntp-mathlib huggingface dataset:
theorem isGδ_singleton (x : X) : IsGδ ({x} : Set X) := by
  rcases (nhds_basis_opens x).exists_antitone_subbasis with ⟨U, hU, h_basis⟩
  rw [← biInter_basis_nhds h_basis.toHasBasis]
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : T1Space X
inst✝ : FirstCountableTopology X
x : X
U : ℕ → Set X
hU : ∀ (i : ℕ), x ∈ U i ∧ IsOpen (U i)
h_basis : HasAntitoneBasis (𝓝 x) fun i => U i
⊢ IsGδ (⋂ i, ⋂ (_ : True), U i)

Next tactic:
exact isGδ_biInter (to_countable _) fun n _ => (hU n).2.isGδ
/-- The set of points where a function is continuous is a Gδ set. -/
theorem isGδ_setOf_continuousAt [UniformSpace Y] [IsCountablyGenerated (uniformity Y)] (f : X → Y) :
    IsGδ { x | ContinuousAt f x } := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : UniformSpace Y
inst✝ : IsCountablyGenerated (uniformity Y)
f : X → Y
⊢ IsGδ {x | ContinuousAt f x}

Next tactic:
obtain ⟨U, _, hU⟩ := (@uniformity_hasBasis_open_symmetric Y _).exists_antitone_subbasis
/-- The set of points where a function is continuous is a Gδ set. -/
theorem isGδ_setOf_continuousAt [UniformSpace Y] [IsCountablyGenerated (uniformity Y)] (f : X → Y) :
    IsGδ { x | ContinuousAt f x } := by
  obtain ⟨U, _, hU⟩ := (@uniformity_hasBasis_open_symmetric Y _).exists_antitone_subbasis
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : UniformSpace Y
inst✝ : IsCountablyGenerated (uniformity Y)
f : X → Y
U : ℕ → Set (Y × Y)
left✝ : ∀ (i : ℕ), U i ∈ uniformity Y ∧ IsOpen (U i) ∧ SymmetricRel (U i)
hU : HasAntitoneBasis (uniformity Y) fun i => id (U i)
⊢ IsGδ {x | ContinuousAt f x}

Next tactic:
simp only [Uniform.continuousAt_iff_prod, nhds_prod_eq]
/-- The set of points where a function is continuous is a Gδ set. -/
theorem isGδ_setOf_continuousAt [UniformSpace Y] [IsCountablyGenerated (uniformity Y)] (f : X → Y) :
    IsGδ { x | ContinuousAt f x } := by
  obtain ⟨U, _, hU⟩ := (@uniformity_hasBasis_open_symmetric Y _).exists_antitone_subbasis
  simp only [Uniform.continuousAt_iff_prod, nhds_prod_eq]
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : UniformSpace Y
inst✝ : IsCountablyGenerated (uniformity Y)
f : X → Y
U : ℕ → Set (Y × Y)
left✝ : ∀ (i : ℕ), U i ∈ uniformity Y ∧ IsOpen (U i) ∧ SymmetricRel (U i)
hU : HasAntitoneBasis (uniformity Y) fun i => id (U i)
⊢ IsGδ {x | Tendsto (fun x => (f x.1, f x.2)) (𝓝 x ×ˢ 𝓝 x) (uniformity Y)}

Next tactic:
simp only [(nhds_basis_opens _).prod_self.tendsto_iff hU.toHasBasis, forall_prop_of_true,
    setOf_forall, id]
/-- The set of points where a function is continuous is a Gδ set. -/
theorem isGδ_setOf_continuousAt [UniformSpace Y] [IsCountablyGenerated (uniformity Y)] (f : X → Y) :
    IsGδ { x | ContinuousAt f x } := by
  obtain ⟨U, _, hU⟩ := (@uniformity_hasBasis_open_symmetric Y _).exists_antitone_subbasis
  simp only [Uniform.continuousAt_iff_prod, nhds_prod_eq]
  simp only [(nhds_basis_opens _).prod_self.tendsto_iff hU.toHasBasis, forall_prop_of_true,
    setOf_forall, id]
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : UniformSpace Y
inst✝ : IsCountablyGenerated (uniformity Y)
f : X → Y
U : ℕ → Set (Y × Y)
left✝ : ∀ (i : ℕ), U i ∈ uniformity Y ∧ IsOpen (U i) ∧ SymmetricRel (U i)
hU : HasAntitoneBasis (uniformity Y) fun i => id (U i)
⊢ IsGδ (⋂ i, {x | ∃ ia, (x ∈ ia ∧ IsOpen ia) ∧ ∀ x ∈ ia ×ˢ ia, (f x.1, f x.2) ∈ U i})

Next tactic:
refine' isGδ_iInter fun k => IsOpen.isGδ <| isOpen_iff_mem_nhds.2 fun x => _
/-- The set of points where a function is continuous is a Gδ set. -/
theorem isGδ_setOf_continuousAt [UniformSpace Y] [IsCountablyGenerated (uniformity Y)] (f : X → Y) :
    IsGδ { x | ContinuousAt f x } := by
  obtain ⟨U, _, hU⟩ := (@uniformity_hasBasis_open_symmetric Y _).exists_antitone_subbasis
  simp only [Uniform.continuousAt_iff_prod, nhds_prod_eq]
  simp only [(nhds_basis_opens _).prod_self.tendsto_iff hU.toHasBasis, forall_prop_of_true,
    setOf_forall, id]
  refine' isGδ_iInter fun k => IsOpen.isGδ <| isOpen_iff_mem_nhds.2 fun x => _
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : UniformSpace Y
inst✝ : IsCountablyGenerated (uniformity Y)
f : X → Y
U : ℕ → Set (Y × Y)
left✝ : ∀ (i : ℕ), U i ∈ uniformity Y ∧ IsOpen (U i) ∧ SymmetricRel (U i)
hU : HasAntitoneBasis (uniformity Y) fun i => id (U i)
k : ℕ
x : X
⊢ x ∈ {x | ∃ ia, (x ∈ ia ∧ IsOpen ia) ∧ ∀ x ∈ ia ×ˢ ia, (f x.1, f x.2) ∈ U k} →
    {x | ∃ ia, (x ∈ ia ∧ IsOpen ia) ∧ ∀ x ∈ ia ×ˢ ia, (f x.1, f x.2) ∈ U k} ∈ 𝓝 x

Next tactic:
rintro ⟨s, ⟨hsx, hso⟩, hsU⟩
/-- The set of points where a function is continuous is a Gδ set. -/
theorem isGδ_setOf_continuousAt [UniformSpace Y] [IsCountablyGenerated (uniformity Y)] (f : X → Y) :
    IsGδ { x | ContinuousAt f x } := by
  obtain ⟨U, _, hU⟩ := (@uniformity_hasBasis_open_symmetric Y _).exists_antitone_subbasis
  simp only [Uniform.continuousAt_iff_prod, nhds_prod_eq]
  simp only [(nhds_basis_opens _).prod_self.tendsto_iff hU.toHasBasis, forall_prop_of_true,
    setOf_forall, id]
  refine' isGδ_iInter fun k => IsOpen.isGδ <| isOpen_iff_mem_nhds.2 fun x => _
  rintro ⟨s, ⟨hsx, hso⟩, hsU⟩
  

Proof state:
case intro.intro.intro.intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : UniformSpace Y
inst✝ : IsCountablyGenerated (uniformity Y)
f : X → Y
U : ℕ → Set (Y × Y)
left✝ : ∀ (i : ℕ), U i ∈ uniformity Y ∧ IsOpen (U i) ∧ SymmetricRel (U i)
hU : HasAntitoneBasis (uniformity Y) fun i => id (U i)
k : ℕ
x : X
s : Set X
hsU : ∀ x ∈ s ×ˢ s, (f x.1, f x.2) ∈ U k
hsx : x ∈ s
hso : IsOpen s
⊢ {x | ∃ ia, (x ∈ ia ∧ IsOpen ia) ∧ ∀ x ∈ ia ×ˢ ia, (f x.1, f x.2) ∈ U k} ∈ 𝓝 x

Next tactic:
filter_upwards [IsOpen.mem_nhds hso hsx] with _ hy using ⟨s, ⟨hy, hso⟩, hsU⟩
instance countableInterFilter_residual : CountableInterFilter (residual X) := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝ : TopologicalSpace X
⊢ CountableInterFilter (residual X)

Next tactic:
rw [residual]
instance countableInterFilter_residual : CountableInterFilter (residual X) := by
  rw [residual]; 

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝ : TopologicalSpace X
⊢ CountableInterFilter (countableGenerate {t | IsOpen t ∧ Dense t})

Next tactic:
infer_instance
/-- Dense Gδ sets are residual. -/
theorem residual_of_dense_Gδ {s : Set X} (ho : IsGδ s) (hd : Dense s) : s ∈ residual X := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝ : TopologicalSpace X
s : Set X
ho : IsGδ s
hd : Dense s
⊢ s ∈ residual X

Next tactic:
rcases ho with ⟨T, To, Tct, rfl⟩
/-- Dense Gδ sets are residual. -/
theorem residual_of_dense_Gδ {s : Set X} (ho : IsGδ s) (hd : Dense s) : s ∈ residual X := by
  rcases ho with ⟨T, To, Tct, rfl⟩
  

Proof state:
case intro.intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝ : TopologicalSpace X
T : Set (Set X)
To : ∀ t ∈ T, IsOpen t
Tct : Set.Countable T
hd : Dense (⋂₀ T)
⊢ ⋂₀ T ∈ residual X

Next tactic:
exact
    (countable_sInter_mem Tct).mpr fun t tT =>
      residual_of_dense_open (To t tT) (hd.mono (sInter_subset_of_mem tT))
/-- A set is residual iff it includes a countable intersection of dense open sets. -/
theorem mem_residual_iff {s : Set X} :
    s ∈ residual X ↔
      ∃ S : Set (Set X), (∀ t ∈ S, IsOpen t) ∧ (∀ t ∈ S, Dense t) ∧ S.Countable ∧ ⋂₀ S ⊆ s :=
  mem_countableGenerate_iff.trans <| by 

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝ : TopologicalSpace X
s : Set X
⊢ (∃ S ⊆ {t | IsOpen t ∧ Dense t}, Set.Countable S ∧ ⋂₀ S ⊆ s) ↔
    ∃ S, (∀ t ∈ S, IsOpen t) ∧ (∀ t ∈ S, Dense t) ∧ Set.Countable S ∧ ⋂₀ S ⊆ s

Next tactic:
simp_rw [subset_def, mem_setOf, forall_and, and_assoc]
/-- The empty set is nowhere dense. -/
@[simp]
lemma isNowhereDense_empty : IsNowhereDense (∅ : Set X) := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
⊢ IsNowhereDense ∅

Next tactic:
rw [IsNowhereDense, closure_empty, interior_empty]
/-- A closed set is nowhere dense iff its interior is empty. -/
lemma IsClosed.isNowhereDense_iff {s : Set X} (hs : IsClosed s) :
    IsNowhereDense s ↔ interior s = ∅ := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
hs : IsClosed s
⊢ IsNowhereDense s ↔ interior s = ∅

Next tactic:
rw [IsNowhereDense, IsClosed.closure_eq hs]
/-- If a set `s` is nowhere dense, so is its closure.-/
protected lemma IsNowhereDense.closure {s : Set X} (hs : IsNowhereDense s) :
    IsNowhereDense (closure s) := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
hs : IsNowhereDense s
⊢ IsNowhereDense (closure s)

Next tactic:
rwa [IsNowhereDense, closure_closure]
/-- A set `s` is closed and nowhere dense iff its complement `sᶜ` is open and dense. -/
lemma isClosed_isNowhereDense_iff_compl {s : Set X} :
    IsClosed s ∧ IsNowhereDense s ↔ IsOpen sᶜ ∧ Dense sᶜ := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
⊢ IsClosed s ∧ IsNowhereDense s ↔ IsOpen sᶜ ∧ Dense sᶜ

Next tactic:
rw [and_congr_right IsClosed.isNowhereDense_iff,
    isOpen_compl_iff, interior_eq_empty_iff_dense_compl]
/-- The empty set is meagre. -/
lemma meagre_empty : IsMeagre (∅ : Set X) := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
⊢ IsMeagre ∅

Next tactic:
rw [IsMeagre, compl_empty]
/-- The empty set is meagre. -/
lemma meagre_empty : IsMeagre (∅ : Set X) := by
  rw [IsMeagre, compl_empty]
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
⊢ univ ∈ residual X

Next tactic:
exact Filter.univ_mem
/-- A countable union of meagre sets is meagre. -/
lemma meagre_iUnion {s : ℕ → Set X} (hs : ∀ n, IsMeagre (s n)) : IsMeagre (⋃ n, s n) := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : ℕ → Set X
hs : ∀ (n : ℕ), IsMeagre (s n)
⊢ IsMeagre (⋃ n, s n)

Next tactic:
rw [IsMeagre, compl_iUnion]
/-- A countable union of meagre sets is meagre. -/
lemma meagre_iUnion {s : ℕ → Set X} (hs : ∀ n, IsMeagre (s n)) : IsMeagre (⋃ n, s n) := by
  rw [IsMeagre, compl_iUnion]
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : ℕ → Set X
hs : ∀ (n : ℕ), IsMeagre (s n)
⊢ ⋂ i, (s i)ᶜ ∈ residual X

Next tactic:
exact countable_iInter_mem.mpr hs
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
⊢ IsMeagre s ↔ ∃ S, (∀ t ∈ S, IsNowhereDense t) ∧ Set.Countable S ∧ s ⊆ ⋃₀ S

Next tactic:
rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
⊢ (∃ x,
      (∀ t ∈ compl '' x, IsOpen t) ∧ (∀ t ∈ compl '' x, Dense t) ∧ Set.Countable (compl '' x) ∧ ⋂₀ (compl '' x) ⊆ sᶜ) ↔
    ∃ S, (∀ t ∈ S, IsNowhereDense t) ∧ Set.Countable S ∧ s ⊆ ⋃₀ S

Next tactic:
simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  

Proof state:
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
⊢ (∃ x, (∀ x_1 ∈ x, IsClosed x_1 ∧ IsNowhereDense x_1) ∧ Set.Countable (compl '' x) ∧ s ⊆ ⋃₀ x) ↔
    ∃ S, (∀ t ∈ S, IsNowhereDense t) ∧ Set.Countable S ∧ s ⊆ ⋃₀ S

Next tactic:
refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
  · 

Proof state:
case refine_1
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
x✝ : ∃ x, (∀ x_1 ∈ x, IsClosed x_1 ∧ IsNowhereDense x_1) ∧ Set.Countable (compl '' x) ∧ s ⊆ ⋃₀ x
S : Set (Set X)
hS : ∀ x ∈ S, IsClosed x ∧ IsNowhereDense x
hc : Set.Countable (compl '' S)
hsub : s ⊆ ⋃₀ S
⊢ Set.Countable S

Next tactic:
rw [← compl_compl_image S]
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
  · rw [← compl_compl_image S]; 

Proof state:
case refine_1
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
x✝ : ∃ x, (∀ x_1 ∈ x, IsClosed x_1 ∧ IsNowhereDense x_1) ∧ Set.Countable (compl '' x) ∧ s ⊆ ⋃₀ x
S : Set (Set X)
hS : ∀ x ∈ S, IsClosed x ∧ IsNowhereDense x
hc : Set.Countable (compl '' S)
hsub : s ⊆ ⋃₀ S
⊢ Set.Countable (compl '' (compl '' S))

Next tactic:
exact hc.image _
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
  · rw [← compl_compl_image S]; exact hc.image _
  · 

Proof state:
case refine_2
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
⊢ (∃ S, (∀ t ∈ S, IsNowhereDense t) ∧ Set.Countable S ∧ s ⊆ ⋃₀ S) →
    ∃ x, (∀ x_1 ∈ x, IsClosed x_1 ∧ IsNowhereDense x_1) ∧ Set.Countable (compl '' x) ∧ s ⊆ ⋃₀ x

Next tactic:
intro ⟨S, hS, hc, hsub⟩
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
  · rw [← compl_compl_image S]; exact hc.image _
  · intro ⟨S, hS, hc, hsub⟩
    

Proof state:
case refine_2
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
S : Set (Set X)
hS : ∀ t ∈ S, IsNowhereDense t
hc : Set.Countable S
hsub : s ⊆ ⋃₀ S
⊢ ∃ x, (∀ x_1 ∈ x, IsClosed x_1 ∧ IsNowhereDense x_1) ∧ Set.Countable (compl '' x) ∧ s ⊆ ⋃₀ x

Next tactic:
use closure '' S
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
  · rw [← compl_compl_image S]; exact hc.image _
  · intro ⟨S, hS, hc, hsub⟩
    use closure '' S
    

Proof state:
case h
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
S : Set (Set X)
hS : ∀ t ∈ S, IsNowhereDense t
hc : Set.Countable S
hsub : s ⊆ ⋃₀ S
⊢ (∀ x ∈ closure '' S, IsClosed x ∧ IsNowhereDense x) ∧ Set.Countable (compl '' (closure '' S)) ∧ s ⊆ ⋃₀ (closure '' S)

Next tactic:
rw [ball_image_iff]
/-- A set is meagre iff it is contained in a countable union of nowhere dense sets. -/
lemma meagre_iff_countable_union_isNowhereDense {s : Set X} : IsMeagre s ↔
    ∃ S : Set (Set X), (∀ t ∈ S, IsNowhereDense t) ∧ S.Countable ∧ s ⊆ ⋃₀ S := by
  rw [IsMeagre, mem_residual_iff, compl_bijective.surjective.image_surjective.exists]
  simp_rw [← and_assoc, ← forall_and, ball_image_iff, ← isClosed_isNowhereDense_iff_compl,
    sInter_image, ← compl_iUnion₂, compl_subset_compl, ← sUnion_eq_biUnion, and_assoc]
  refine ⟨fun ⟨S, hS, hc, hsub⟩ ↦ ⟨S, fun s hs ↦ (hS s hs).2, ?_, hsub⟩, ?_⟩
  · rw [← compl_compl_image S]; exact hc.image _
  · intro ⟨S, hS, hc, hsub⟩
    use closure '' S
    rw [ball_image_iff]
    

Proof state:
case h
X✝ : Type u_1
Y : Type u_2
ι : Type u_3
X : Type u_4
inst✝ : TopologicalSpace X
s : Set X
S : Set (Set X)
hS : ∀ t ∈ S, IsNowhereDense t
hc : Set.Countable S
hsub : s ⊆ ⋃₀ S
⊢ (∀ x ∈ S, IsClosed (closure x) ∧ IsNowhereDense (closure x)) ∧
    Set.Countable (compl '' (closure '' S)) ∧ s ⊆ ⋃₀ (closure '' S)

Next tactic:
exact ⟨fun s hs ↦ ⟨isClosed_closure, (hS s hs).closure⟩,
      (hc.image _).image _, hsub.trans (sUnion_mono_subsets fun s ↦ subset_closure)⟩
theorem exp_diagonal (v : m → 𝔸) : exp 𝕂 (diagonal v) = diagonal (exp 𝕂 v) := by
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝¹¹ : Fintype m
inst✝¹⁰ : DecidableEq m
inst✝⁹ : Fintype n
inst✝⁸ : DecidableEq n
inst✝⁷ : (i : m) → Fintype (n' i)
inst✝⁶ : (i : m) → DecidableEq (n' i)
inst✝⁵ : Field 𝕂
inst✝⁴ : Ring 𝔸
inst✝³ : TopologicalSpace 𝔸
inst✝² : TopologicalRing 𝔸
inst✝¹ : Algebra 𝕂 𝔸
inst✝ : T2Space 𝔸
v : m → 𝔸
⊢ exp 𝕂 (diagonal v) = diagonal (exp 𝕂 v)

Next tactic:
simp_rw [exp_eq_tsum, diagonal_pow, ← diagonal_smul, ← diagonal_tsum]
theorem exp_blockDiagonal (v : m → Matrix n n 𝔸) :
    exp 𝕂 (blockDiagonal v) = blockDiagonal (exp 𝕂 v) := by
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝¹¹ : Fintype m
inst✝¹⁰ : DecidableEq m
inst✝⁹ : Fintype n
inst✝⁸ : DecidableEq n
inst✝⁷ : (i : m) → Fintype (n' i)
inst✝⁶ : (i : m) → DecidableEq (n' i)
inst✝⁵ : Field 𝕂
inst✝⁴ : Ring 𝔸
inst✝³ : TopologicalSpace 𝔸
inst✝² : TopologicalRing 𝔸
inst✝¹ : Algebra 𝕂 𝔸
inst✝ : T2Space 𝔸
v : m → Matrix n n 𝔸
⊢ exp 𝕂 (blockDiagonal v) = blockDiagonal (exp 𝕂 v)

Next tactic:
simp_rw [exp_eq_tsum, ← blockDiagonal_pow, ← blockDiagonal_smul, ← blockDiagonal_tsum]
theorem exp_blockDiagonal' (v : ∀ i, Matrix (n' i) (n' i) 𝔸) :
    exp 𝕂 (blockDiagonal' v) = blockDiagonal' (exp 𝕂 v) := by
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝¹¹ : Fintype m
inst✝¹⁰ : DecidableEq m
inst✝⁹ : Fintype n
inst✝⁸ : DecidableEq n
inst✝⁷ : (i : m) → Fintype (n' i)
inst✝⁶ : (i : m) → DecidableEq (n' i)
inst✝⁵ : Field 𝕂
inst✝⁴ : Ring 𝔸
inst✝³ : TopologicalSpace 𝔸
inst✝² : TopologicalRing 𝔸
inst✝¹ : Algebra 𝕂 𝔸
inst✝ : T2Space 𝔸
v : (i : m) → Matrix (n' i) (n' i) 𝔸
⊢ exp 𝕂 (blockDiagonal' v) = blockDiagonal' (exp 𝕂 v)

Next tactic:
simp_rw [exp_eq_tsum, ← blockDiagonal'_pow, ← blockDiagonal'_smul, ← blockDiagonal'_tsum]
theorem exp_transpose (A : Matrix m m 𝔸) : exp 𝕂 Aᵀ = (exp 𝕂 A)ᵀ := by
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝⁷ : Fintype m
inst✝⁶ : DecidableEq m
inst✝⁵ : Field 𝕂
inst✝⁴ : CommRing 𝔸
inst✝³ : TopologicalSpace 𝔸
inst✝² : TopologicalRing 𝔸
inst✝¹ : Algebra 𝕂 𝔸
inst✝ : T2Space 𝔸
A : Matrix m m 𝔸
⊢ exp 𝕂 Aᵀ = (exp 𝕂 A)ᵀ

Next tactic:
simp_rw [exp_eq_tsum, transpose_tsum, transpose_smul, transpose_pow]
nonrec theorem exp_add_of_commute (A B : Matrix m m 𝔸) (h : Commute A B) :
    exp 𝕂 (A + B) = exp 𝕂 A * exp 𝕂 B := by
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝⁹ : IsROrC 𝕂
inst✝⁸ : Fintype m
inst✝⁷ : DecidableEq m
inst✝⁶ : Fintype n
inst✝⁵ : DecidableEq n
inst✝⁴ : (i : m) → Fintype (n' i)
inst✝³ : (i : m) → DecidableEq (n' i)
inst✝² : NormedRing 𝔸
inst✝¹ : NormedAlgebra 𝕂 𝔸
inst✝ : CompleteSpace 𝔸
A B : Matrix m m 𝔸
h : Commute A B
⊢ exp 𝕂 (A + B) = exp 𝕂 A * exp 𝕂 B

Next tactic:
letI : SeminormedRing (Matrix m m 𝔸) := Matrix.linftyOpSemiNormedRing
nonrec theorem exp_add_of_commute (A B : Matrix m m 𝔸) (h : Commute A B) :
    exp 𝕂 (A + B) = exp 𝕂 A * exp 𝕂 B := by
  letI : SeminormedRing (Matrix m m 𝔸) := Matrix.linftyOpSemiNormedRing
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝⁹ : IsROrC 𝕂
inst✝⁸ : Fintype m
inst✝⁷ : DecidableEq m
inst✝⁶ : Fintype n
inst✝⁵ : DecidableEq n
inst✝⁴ : (i : m) → Fintype (n' i)
inst✝³ : (i : m) → DecidableEq (n' i)
inst✝² : NormedRing 𝔸
inst✝¹ : NormedAlgebra 𝕂 𝔸
inst✝ : CompleteSpace 𝔸
A B : Matrix m m 𝔸
h : Commute A B
this : SeminormedRing (Matrix m m 𝔸) := Matrix.linftyOpSemiNormedRing
⊢ exp 𝕂 (A + B) = exp 𝕂 A * exp 𝕂 B

Next tactic:
letI : NormedRing (Matrix m m 𝔸) := Matrix.linftyOpNormedRing
nonrec theorem exp_add_of_commute (A B : Matrix m m 𝔸) (h : Commute A B) :
    exp 𝕂 (A + B) = exp 𝕂 A * exp 𝕂 B := by
  letI : SeminormedRing (Matrix m m 𝔸) := Matrix.linftyOpSemiNormedRing
  letI : NormedRing (Matrix m m 𝔸) := Matrix.linftyOpNormedRing
  

Proof state:
𝕂 : Type u_1
m : Type u_2
n : Type u_3
p : Type u_4
n' : m → Type u_5
𝔸 : Type u_6
inst✝⁹ : IsROrC 𝕂
inst✝⁸ : Fintype m
inst✝⁷ : DecidableEq m
inst✝⁶ : Fintype n
inst✝⁵ : DecidableEq n
inst✝⁴ : (i : m) → Fintype (n' i)
inst✝³ : (i : m) → DecidableEq (n' i)
inst✝² : NormedRing 𝔸
inst✝¹ : NormedAlgebra 𝕂 𝔸
inst✝ : CompleteSpace 𝔸
A B : Matrix m m 𝔸
h : Commute A B
this✝ : SeminormedRing (Matrix m m 𝔸) := Matrix.linftyOpSemiNormedRing
this : NormedRing (Matrix m m 𝔸) := Matrix.linftyOpNormedRing
⊢ exp 𝕂 (A + B) = exp 𝕂 A * exp 𝕂 B

Next tactic:
letI : NormedAlgebra 𝕂 (Matrix m m 𝔸) := Matrix.linftyOpNormedAlgebra