l3lab/ntp-mathlib huggingface dataset:
/-- The second theorem states that locally compact spaces are Baire. -/
instance (priority := 100) BaireSpace.of_t2Space_locallyCompactSpace
    [TopologicalSpace α] [T2Space α] [LocallyCompactSpace α] : BaireSpace α := by
  constructor
  intro f ho hd
  /- To prove that an intersection of open dense subsets is dense, prove that its intersection
    with any open neighbourhood `U` is dense. Define recursively a decreasing sequence `K` of
    compact neighbourhoods: start with some compact neighbourhood inside `U`, then at each step,
    take its interior, intersect with `f n`, then choose a compact neighbourhood inside the
    intersection. -/
  apply dense_iff_inter_open.2
  intro U U_open U_nonempty
  rcases exists_positiveCompacts_subset U_open U_nonempty with ⟨K₀, hK₀⟩
  have : ∀ (n) (K : PositiveCompacts α), ∃ K' : PositiveCompacts α, ↑K' ⊆ f n ∩ interior K := by
    refine' fun n K => exists_positiveCompacts_subset ((ho n).inter isOpen_interior) _
    rw [inter_comm]
    exact (hd n).inter_open_nonempty _ isOpen_interior K.interior_nonempty
  choose K_next hK_next using this
  let K : ℕ → PositiveCompacts α := fun n => Nat.recOn n K₀ K_next
  -- This is a decreasing sequence of positive compacts contained in suitable open sets `f n`.
  have hK_decreasing : ∀ n : ℕ, ((K (n + 1)).carrier) ⊆ (f n ∩ (K n).carrier) :=
    fun n => (hK_next n (K n)).trans <| inter_subset_inter_right _ interior_subset
  -- Prove that ̀`⋂ n : ℕ, K n` is inside `U ∩ ⋂ n : ℕ, f n`.
  have hK_subset : (⋂ n, (K n).carrier : Set α) ⊆ U ∩ ⋂ n, f n := by
    intro x hx
    simp only [mem_iInter] at hx
    simp only [mem_inter_iff, mem_inter] at hx ⊢
    refine' ⟨hK₀ <| hx 0, _⟩
    simp only [mem_iInter]
    exact fun n => (hK_decreasing n (hx (n + 1))).1
  /- Prove that `⋂ n : ℕ, K n` is not empty, as an intersection of a decreasing sequence
    of nonempty compact subsets. -/
  have hK_nonempty : (⋂ n, (K n).carrier : Set α).Nonempty :=
    IsCompact.nonempty_iInter_of_sequence_nonempty_compact_closed _
      (fun n => (hK_decreasing n).trans (inter_subset_right _ _)) (fun n => (K n).nonempty)
      (K 0).isCompact fun n => (K n).isCompact.isClosed
  

Proof state:
case baire_property.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : T2Space α
inst✝ : LocallyCompactSpace α
f : ℕ → Set α
ho : ∀ (n : ℕ), IsOpen (f n)
hd : ∀ (n : ℕ), Dense (f n)
U : Set α
U_open : IsOpen U
U_nonempty : Set.Nonempty U
K₀ : PositiveCompacts α
hK₀ : ↑K₀ ⊆ U
K_next : ℕ → PositiveCompacts α → PositiveCompacts α
hK_next : ∀ (n : ℕ) (K : PositiveCompacts α), ↑(K_next n K) ⊆ f n ∩ interior ↑K
K : ℕ → PositiveCompacts α := fun n => Nat.recOn n K₀ K_next
hK_decreasing : ∀ (n : ℕ), (K (n + 1)).carrier ⊆ f n ∩ (K n).carrier
hK_subset : ⋂ n, (K n).carrier ⊆ U ∩ ⋂ n, f n
hK_nonempty : Set.Nonempty (⋂ n, (K n).carrier)
⊢ Set.Nonempty (U ∩ ⋂ n, f n)

Next tactic:
exact hK_nonempty.mono hK_subset
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
⊢ Dense (⋂₀ S)

Next tactic:
rcases S.eq_empty_or_nonempty with h | h
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : S = ∅
⊢ Dense (⋂₀ S)

Next tactic:
simp [h]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · simp [h]
  · 

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : Set.Nonempty S
⊢ Dense (⋂₀ S)

Next tactic:
rcases hS.exists_eq_range h with ⟨f, hf⟩
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · simp [h]
  · rcases hS.exists_eq_range h with ⟨f, hf⟩
    

Proof state:
case inr.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : Set.Nonempty S
f : ℕ → Set α
hf : S = range f
⊢ Dense (⋂₀ S)

Next tactic:
have F : ∀ n, f n ∈ S := fun n => by rw [hf]; exact mem_range_self _
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · simp [h]
  · rcases hS.exists_eq_range h with ⟨f, hf⟩
    have F : ∀ n, f n ∈ S := fun n => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : Set.Nonempty S
f : ℕ → Set α
hf : S = range f
n : ℕ
⊢ f n ∈ S

Next tactic:
rw [hf]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · simp [h]
  · rcases hS.exists_eq_range h with ⟨f, hf⟩
    have F : ∀ n, f n ∈ S := fun n => by rw [hf]; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : Set.Nonempty S
f : ℕ → Set α
hf : S = range f
n : ℕ
⊢ f n ∈ range f

Next tactic:
exact mem_range_self _
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · simp [h]
  · rcases hS.exists_eq_range h with ⟨f, hf⟩
    have F : ∀ n, f n ∈ S := fun n => by rw [hf]; exact mem_range_self _
    

Proof state:
case inr.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : Set.Nonempty S
f : ℕ → Set α
hf : S = range f
F : ∀ (n : ℕ), f n ∈ S
⊢ Dense (⋂₀ S)

Next tactic:
rw [hf, sInter_range]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with ⋂₀. -/
theorem dense_sInter_of_isOpen {S : Set (Set α)} (ho : ∀ s ∈ S, IsOpen s) (hS : S.Countable)
    (hd : ∀ s ∈ S, Dense s) : Dense (⋂₀ S) := by
  rcases S.eq_empty_or_nonempty with h | h
  · simp [h]
  · rcases hS.exists_eq_range h with ⟨f, hf⟩
    have F : ∀ n, f n ∈ S := fun n => by rw [hf]; exact mem_range_self _
    rw [hf, sInter_range]
    

Proof state:
case inr.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set (Set α)
ho : ∀ s ∈ S, IsOpen s
hS : Set.Countable S
hd : ∀ s ∈ S, Dense s
h : Set.Nonempty S
f : ℕ → Set α
hf : S = range f
F : ∀ (n : ℕ), f n ∈ S
⊢ Dense (⋂ x, f x)

Next tactic:
exact dense_iInter_of_isOpen_nat (fun n => ho _ (F n)) fun n => hd _ (F n)
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_isOpen {S : Set β} {f : β → Set α} (ho : ∀ s ∈ S, IsOpen (f s))
    (hS : S.Countable) (hd : ∀ s ∈ S, Dense (f s)) : Dense (⋂ s ∈ S, f s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : β → Set α
ho : ∀ s ∈ S, IsOpen (f s)
hS : Set.Countable S
hd : ∀ s ∈ S, Dense (f s)
⊢ Dense (⋂ s ∈ S, f s)

Next tactic:
rw [← sInter_image]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_isOpen {S : Set β} {f : β → Set α} (ho : ∀ s ∈ S, IsOpen (f s))
    (hS : S.Countable) (hd : ∀ s ∈ S, Dense (f s)) : Dense (⋂ s ∈ S, f s) := by
  rw [← sInter_image]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : β → Set α
ho : ∀ s ∈ S, IsOpen (f s)
hS : Set.Countable S
hd : ∀ s ∈ S, Dense (f s)
⊢ Dense (⋂₀ ((fun s => f s) '' S))

Next tactic:
apply dense_sInter_of_isOpen
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_isOpen {S : Set β} {f : β → Set α} (ho : ∀ s ∈ S, IsOpen (f s))
    (hS : S.Countable) (hd : ∀ s ∈ S, Dense (f s)) : Dense (⋂ s ∈ S, f s) := by
  rw [← sInter_image]
  apply dense_sInter_of_isOpen
  · 

Proof state:
case ho
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : β → Set α
ho : ∀ s ∈ S, IsOpen (f s)
hS : Set.Countable S
hd : ∀ s ∈ S, Dense (f s)
⊢ ∀ s ∈ (fun s => f s) '' S, IsOpen s

Next tactic:
rwa [ball_image_iff]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_isOpen {S : Set β} {f : β → Set α} (ho : ∀ s ∈ S, IsOpen (f s))
    (hS : S.Countable) (hd : ∀ s ∈ S, Dense (f s)) : Dense (⋂ s ∈ S, f s) := by
  rw [← sInter_image]
  apply dense_sInter_of_isOpen
  · rwa [ball_image_iff]
  · 

Proof state:
case hS
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : β → Set α
ho : ∀ s ∈ S, IsOpen (f s)
hS : Set.Countable S
hd : ∀ s ∈ S, Dense (f s)
⊢ Set.Countable ((fun s => f s) '' S)

Next tactic:
exact hS.image _
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_isOpen {S : Set β} {f : β → Set α} (ho : ∀ s ∈ S, IsOpen (f s))
    (hS : S.Countable) (hd : ∀ s ∈ S, Dense (f s)) : Dense (⋂ s ∈ S, f s) := by
  rw [← sInter_image]
  apply dense_sInter_of_isOpen
  · rwa [ball_image_iff]
  · exact hS.image _
  · 

Proof state:
case hd
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : β → Set α
ho : ∀ s ∈ S, IsOpen (f s)
hS : Set.Countable S
hd : ∀ s ∈ S, Dense (f s)
⊢ ∀ s ∈ (fun s => f s) '' S, Dense s

Next tactic:
rwa [ball_image_iff]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_isOpen [Encodable β] {f : β → Set α} (ho : ∀ s, IsOpen (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsOpen (f s)
hd : ∀ (s : β), Dense (f s)
⊢ Dense (⋂ s, f s)

Next tactic:
rw [← sInter_range]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_isOpen [Encodable β] {f : β → Set α} (ho : ∀ s, IsOpen (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  rw [← sInter_range]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsOpen (f s)
hd : ∀ (s : β), Dense (f s)
⊢ Dense (⋂₀ range fun s => f s)

Next tactic:
apply dense_sInter_of_isOpen
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_isOpen [Encodable β] {f : β → Set α} (ho : ∀ s, IsOpen (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  rw [← sInter_range]
  apply dense_sInter_of_isOpen
  · 

Proof state:
case ho
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsOpen (f s)
hd : ∀ (s : β), Dense (f s)
⊢ ∀ s ∈ range fun s => f s, IsOpen s

Next tactic:
rwa [forall_range_iff]
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_isOpen [Encodable β] {f : β → Set α} (ho : ∀ s, IsOpen (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  rw [← sInter_range]
  apply dense_sInter_of_isOpen
  · rwa [forall_range_iff]
  · 

Proof state:
case hS
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsOpen (f s)
hd : ∀ (s : β), Dense (f s)
⊢ Set.Countable (range fun s => f s)

Next tactic:
exact countable_range _
/-- Baire theorem: a countable intersection of dense open sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_isOpen [Encodable β] {f : β → Set α} (ho : ∀ s, IsOpen (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  rw [← sInter_range]
  apply dense_sInter_of_isOpen
  · rwa [forall_range_iff]
  · exact countable_range _
  · 

Proof state:
case hd
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsOpen (f s)
hd : ∀ (s : β), Dense (f s)
⊢ ∀ s ∈ range fun s => f s, Dense s

Next tactic:
rwa [forall_range_iff]
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s : Set α
⊢ s ∈ residual α ↔ ∃ t, ∃ (_ : t ⊆ s), IsGδ t ∧ Dense t

Next tactic:
constructor
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s : Set α
⊢ s ∈ residual α → ∃ t, ∃ (_ : t ⊆ s), IsGδ t ∧ Dense t

Next tactic:
rw [mem_residual_iff]
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  constructor
  · rw [mem_residual_iff]
    

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s : Set α
⊢ (∃ S, (∀ t ∈ S, IsOpen t) ∧ (∀ t ∈ S, Dense t) ∧ Set.Countable S ∧ ⋂₀ S ⊆ s) → ∃ t, ∃ (_ : t ⊆ s), IsGδ t ∧ Dense t

Next tactic:
rintro ⟨S, hSo, hSd, Sct, Ss⟩
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  constructor
  · rw [mem_residual_iff]
    rintro ⟨S, hSo, hSd, Sct, Ss⟩
    

Proof state:
case mp.intro.intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s : Set α
S : Set (Set α)
hSo : ∀ t ∈ S, IsOpen t
hSd : ∀ t ∈ S, Dense t
Sct : Set.Countable S
Ss : ⋂₀ S ⊆ s
⊢ ∃ t, ∃ (_ : t ⊆ s), IsGδ t ∧ Dense t

Next tactic:
refine' ⟨_, Ss, ⟨_, fun t ht => hSo _ ht, Sct, rfl⟩, _⟩
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  constructor
  · rw [mem_residual_iff]
    rintro ⟨S, hSo, hSd, Sct, Ss⟩
    refine' ⟨_, Ss, ⟨_, fun t ht => hSo _ ht, Sct, rfl⟩, _⟩
    

Proof state:
case mp.intro.intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s : Set α
S : Set (Set α)
hSo : ∀ t ∈ S, IsOpen t
hSd : ∀ t ∈ S, Dense t
Sct : Set.Countable S
Ss : ⋂₀ S ⊆ s
⊢ Dense (⋂₀ S)

Next tactic:
exact dense_sInter_of_isOpen hSo Sct hSd
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  constructor
  · rw [mem_residual_iff]
    rintro ⟨S, hSo, hSd, Sct, Ss⟩
    refine' ⟨_, Ss, ⟨_, fun t ht => hSo _ ht, Sct, rfl⟩, _⟩
    exact dense_sInter_of_isOpen hSo Sct hSd
  

Proof state:
case mpr
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s : Set α
⊢ (∃ t, ∃ (_ : t ⊆ s), IsGδ t ∧ Dense t) → s ∈ residual α

Next tactic:
rintro ⟨t, ts, ho, hd⟩
/-- A set is residual (comeagre) if and only if it includes a dense `Gδ` set. -/
theorem mem_residual {s : Set α} : s ∈ residual α ↔ ∃ (t : _) (_ : t ⊆ s), IsGδ t ∧ Dense t := by
  constructor
  · rw [mem_residual_iff]
    rintro ⟨S, hSo, hSd, Sct, Ss⟩
    refine' ⟨_, Ss, ⟨_, fun t ht => hSo _ ht, Sct, rfl⟩, _⟩
    exact dense_sInter_of_isOpen hSo Sct hSd
  rintro ⟨t, ts, ho, hd⟩
  

Proof state:
case mpr.intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s t : Set α
ts : t ⊆ s
ho : IsGδ t
hd : Dense t
⊢ s ∈ residual α

Next tactic:
exact mem_of_superset (residual_of_dense_Gδ ho hd) ts
/-- A property holds on a residual (comeagre) set if and only if it holds on some dense `Gδ` set. -/
theorem eventually_residual {p : α → Prop} :
    (∀ᶠ x in residual α, p x) ↔ ∃ t : Set α, IsGδ t ∧ Dense t ∧ ∀ x : α, x ∈ t → p x := by
  -- this can probably be improved...
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
p : α → Prop
⊢ (∀ᶠ (x : α) in residual α, p x) ↔ ∃ t, IsGδ t ∧ Dense t ∧ ∀ x ∈ t, p x

Next tactic:
convert@mem_residual _ _ _ p
/-- A property holds on a residual (comeagre) set if and only if it holds on some dense `Gδ` set. -/
theorem eventually_residual {p : α → Prop} :
    (∀ᶠ x in residual α, p x) ↔ ∃ t : Set α, IsGδ t ∧ Dense t ∧ ∀ x : α, x ∈ t → p x := by
  -- this can probably be improved...
  convert@mem_residual _ _ _ p
  

Proof state:
case h.e'_2.h.e'_2.h.a
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
p : α → Prop
x✝ : Set α
⊢ (IsGδ x✝ ∧ Dense x✝ ∧ ∀ x ∈ x✝, p x) ↔ ∃ (_ : x✝ ⊆ p), IsGδ x✝ ∧ Dense x✝

Next tactic:
simp_rw [exists_prop, @and_comm ((_ : Set α) ⊆ p), and_assoc]
/-- A property holds on a residual (comeagre) set if and only if it holds on some dense `Gδ` set. -/
theorem eventually_residual {p : α → Prop} :
    (∀ᶠ x in residual α, p x) ↔ ∃ t : Set α, IsGδ t ∧ Dense t ∧ ∀ x : α, x ∈ t → p x := by
  -- this can probably be improved...
  convert@mem_residual _ _ _ p
  simp_rw [exists_prop, @and_comm ((_ : Set α) ⊆ p), and_assoc]
  

Proof state:
case h.e'_2.h.e'_2.h.a
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
p : α → Prop
x✝ : Set α
⊢ (IsGδ x✝ ∧ Dense x✝ ∧ ∀ x ∈ x✝, p x) ↔ IsGδ x✝ ∧ Dense x✝ ∧ x✝ ⊆ p

Next tactic:
rfl
/-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_Gδ [Encodable β] {f : β → Set α} (ho : ∀ s, IsGδ (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsGδ (f s)
hd : ∀ (s : β), Dense (f s)
⊢ Dense (⋂ s, f s)

Next tactic:
rw [← sInter_range]
/-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with
an index set which is an encodable type. -/
theorem dense_iInter_of_Gδ [Encodable β] {f : β → Set α} (ho : ∀ s, IsGδ (f s))
    (hd : ∀ s, Dense (f s)) : Dense (⋂ s, f s) := by
  rw [← sInter_range]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝² : TopologicalSpace α
inst✝¹ : BaireSpace α
inst✝ : Encodable β
f : β → Set α
ho : ∀ (s : β), IsGδ (f s)
hd : ∀ (s : β), Dense (f s)
⊢ Dense (⋂₀ range fun s => f s)

Next tactic:
exact dense_sInter_of_Gδ (forall_range_iff.2 ‹_›) (countable_range _) (forall_range_iff.2 ‹_›)
/-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_Gδ {S : Set β} {f : ∀ x ∈ S, Set α} (ho : ∀ s (H : s ∈ S), IsGδ (f s H))
    (hS : S.Countable) (hd : ∀ s (H : s ∈ S), Dense (f s H)) : Dense (⋂ s ∈ S, f s ‹_›) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : (x : β) → x ∈ S → Set α
ho : ∀ (s : β) (H : s ∈ S), IsGδ (f s H)
hS : Set.Countable S
hd : ∀ (s : β) (H : s ∈ S), Dense (f s H)
⊢ Dense (⋂ s, ⋂ (h : s ∈ S), f s h)

Next tactic:
rw [biInter_eq_iInter]
/-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_Gδ {S : Set β} {f : ∀ x ∈ S, Set α} (ho : ∀ s (H : s ∈ S), IsGδ (f s H))
    (hS : S.Countable) (hd : ∀ s (H : s ∈ S), Dense (f s H)) : Dense (⋂ s ∈ S, f s ‹_›) := by
  rw [biInter_eq_iInter]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : (x : β) → x ∈ S → Set α
ho : ∀ (s : β) (H : s ∈ S), IsGδ (f s H)
hS : Set.Countable S
hd : ∀ (s : β) (H : s ∈ S), Dense (f s H)
⊢ Dense (⋂ x, f ↑x (_ : ↑x ∈ S))

Next tactic:
haveI := hS.toEncodable
/-- Baire theorem: a countable intersection of dense Gδ sets is dense. Formulated here with
an index set which is a countable set in any type. -/
theorem dense_biInter_of_Gδ {S : Set β} {f : ∀ x ∈ S, Set α} (ho : ∀ s (H : s ∈ S), IsGδ (f s H))
    (hS : S.Countable) (hd : ∀ s (H : s ∈ S), Dense (f s H)) : Dense (⋂ s ∈ S, f s ‹_›) := by
  rw [biInter_eq_iInter]
  haveI := hS.toEncodable
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
S : Set β
f : (x : β) → x ∈ S → Set α
ho : ∀ (s : β) (H : s ∈ S), IsGδ (f s H)
hS : Set.Countable S
hd : ∀ (s : β) (H : s ∈ S), Dense (f s H)
this : Encodable ↑S
⊢ Dense (⋂ x, f ↑x (_ : ↑x ∈ S))

Next tactic:
exact dense_iInter_of_Gδ (fun s => ho s s.2) fun s => hd s s.2
/-- Baire theorem: the intersection of two dense Gδ sets is dense. -/
theorem Dense.inter_of_Gδ {s t : Set α} (hs : IsGδ s) (ht : IsGδ t) (hsc : Dense s)
    (htc : Dense t) : Dense (s ∩ t) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s t : Set α
hs : IsGδ s
ht : IsGδ t
hsc : Dense s
htc : Dense t
⊢ Dense (s ∩ t)

Next tactic:
rw [inter_eq_iInter]
/-- Baire theorem: the intersection of two dense Gδ sets is dense. -/
theorem Dense.inter_of_Gδ {s t : Set α} (hs : IsGδ s) (ht : IsGδ t) (hsc : Dense s)
    (htc : Dense t) : Dense (s ∩ t) := by
  rw [inter_eq_iInter]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
inst✝¹ : TopologicalSpace α
inst✝ : BaireSpace α
s t : Set α
hs : IsGδ s
ht : IsGδ t
hsc : Dense s
htc : Dense t
⊢ Dense (⋂ b, bif b then s else t)

Next tactic:
apply dense_iInter_of_Gδ