l3lab/ntp-mathlib huggingface dataset:
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_iUnion [Countable ι] (s : ι → Set X)
    (hcomp : ∀ i, IsSigmaCompact (s i)) : IsSigmaCompact (⋃ i, s i) := by
  -- Choose a decomposition s_i = ⋃ K_i,j for each i.
  choose K hcomp hcov using fun i ↦ hcomp i
  -- Then, we have a countable union of countable unions of compact sets, i.e. countably many.
  have := calc
    ⋃ i, s i
    _ = ⋃ i, ⋃ n, (K i n) := by simp_rw [hcov]
    _ = ⋃ (i) (n : ℕ), (K.uncurry ⟨i, n⟩) := by 

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s✝ t : Set X
inst✝ : Countable ι
s : ι → Set X
hcomp✝ : ∀ (i : ι), IsSigmaCompact (s i)
K : ι → ℕ → Set X
hcomp : ∀ (i : ι) (n : ℕ), IsCompact (K i n)
hcov : ∀ (i : ι), ⋃ n, K i n = s i
⊢ ⋃ i, ⋃ n, K i n = ⋃ i, ⋃ n, Function.uncurry K (i, n)

Next tactic:
rw [Function.uncurry_def]
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_iUnion [Countable ι] (s : ι → Set X)
    (hcomp : ∀ i, IsSigmaCompact (s i)) : IsSigmaCompact (⋃ i, s i) := by
  -- Choose a decomposition s_i = ⋃ K_i,j for each i.
  choose K hcomp hcov using fun i ↦ hcomp i
  -- Then, we have a countable union of countable unions of compact sets, i.e. countably many.
  have := calc
    ⋃ i, s i
    _ = ⋃ i, ⋃ n, (K i n) := by simp_rw [hcov]
    _ = ⋃ (i) (n : ℕ), (K.uncurry ⟨i, n⟩) := by rw [Function.uncurry_def]
    _ = ⋃ x, K.uncurry x := by 

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s✝ t : Set X
inst✝ : Countable ι
s : ι → Set X
hcomp✝ : ∀ (i : ι), IsSigmaCompact (s i)
K : ι → ℕ → Set X
hcomp : ∀ (i : ι) (n : ℕ), IsCompact (K i n)
hcov : ∀ (i : ι), ⋃ n, K i n = s i
⊢ ⋃ i, ⋃ n, Function.uncurry K (i, n) = ⋃ x, Function.uncurry K x

Next tactic:
rw [← iUnion_prod']
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_iUnion [Countable ι] (s : ι → Set X)
    (hcomp : ∀ i, IsSigmaCompact (s i)) : IsSigmaCompact (⋃ i, s i) := by
  -- Choose a decomposition s_i = ⋃ K_i,j for each i.
  choose K hcomp hcov using fun i ↦ hcomp i
  -- Then, we have a countable union of countable unions of compact sets, i.e. countably many.
  have := calc
    ⋃ i, s i
    _ = ⋃ i, ⋃ n, (K i n) := by simp_rw [hcov]
    _ = ⋃ (i) (n : ℕ), (K.uncurry ⟨i, n⟩) := by rw [Function.uncurry_def]
    _ = ⋃ x, K.uncurry x := by rw [← iUnion_prod']
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s✝ t : Set X
inst✝ : Countable ι
s : ι → Set X
hcomp✝ : ∀ (i : ι), IsSigmaCompact (s i)
K : ι → ℕ → Set X
hcomp : ∀ (i : ι) (n : ℕ), IsCompact (K i n)
hcov : ∀ (i : ι), ⋃ n, K i n = s i
this : ⋃ i, s i = ⋃ x, Function.uncurry K x
⊢ IsSigmaCompact (⋃ i, s i)

Next tactic:
rw [this]
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_iUnion [Countable ι] (s : ι → Set X)
    (hcomp : ∀ i, IsSigmaCompact (s i)) : IsSigmaCompact (⋃ i, s i) := by
  -- Choose a decomposition s_i = ⋃ K_i,j for each i.
  choose K hcomp hcov using fun i ↦ hcomp i
  -- Then, we have a countable union of countable unions of compact sets, i.e. countably many.
  have := calc
    ⋃ i, s i
    _ = ⋃ i, ⋃ n, (K i n) := by simp_rw [hcov]
    _ = ⋃ (i) (n : ℕ), (K.uncurry ⟨i, n⟩) := by rw [Function.uncurry_def]
    _ = ⋃ x, K.uncurry x := by rw [← iUnion_prod']
  rw [this]
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝² : TopologicalSpace X
inst✝¹ : TopologicalSpace Y
s✝ t : Set X
inst✝ : Countable ι
s : ι → Set X
hcomp✝ : ∀ (i : ι), IsSigmaCompact (s i)
K : ι → ℕ → Set X
hcomp : ∀ (i : ι) (n : ℕ), IsCompact (K i n)
hcov : ∀ (i : ι), ⋃ n, K i n = s i
this : ⋃ i, s i = ⋃ x, Function.uncurry K x
⊢ IsSigmaCompact (⋃ x, Function.uncurry K x)

Next tactic:
exact isSigmaCompact_iUnion_of_isCompact K.uncurry fun x ↦ (hcomp x.1 x.2)
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_sUnion (S : Set (Set X)) (hc : Set.Countable S)
    (hcomp : ∀ s : S, IsSigmaCompact s (X := X)) : IsSigmaCompact (⋃₀ S) := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s t : Set X
S : Set (Set X)
hc : Set.Countable S
hcomp : ∀ (s : ↑S), IsSigmaCompact ↑s
⊢ IsSigmaCompact (⋃₀ S)

Next tactic:
have : Countable S := countable_coe_iff.mpr hc
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_sUnion (S : Set (Set X)) (hc : Set.Countable S)
    (hcomp : ∀ s : S, IsSigmaCompact s (X := X)) : IsSigmaCompact (⋃₀ S) := by
  have : Countable S := countable_coe_iff.mpr hc
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s t : Set X
S : Set (Set X)
hc : Set.Countable S
hcomp : ∀ (s : ↑S), IsSigmaCompact ↑s
this : Countable ↑S
⊢ IsSigmaCompact (⋃₀ S)

Next tactic:
apply sUnion_eq_iUnion.symm ▸ isSigmaCompact_iUnion _ hcomp
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_biUnion {s : Set ι} {S : ι → Set X} (hc : Set.Countable s)
    (hcomp : ∀ (i : ι), i ∈ s → IsSigmaCompact (S i)) :
    IsSigmaCompact (⋃ (i : ι) (_ : i ∈ s), S i) := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
s : Set ι
S : ι → Set X
hc : Set.Countable s
hcomp : ∀ i ∈ s, IsSigmaCompact (S i)
⊢ IsSigmaCompact (⋃ i ∈ s, S i)

Next tactic:
have : Countable ↑s := countable_coe_iff.mpr hc
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_biUnion {s : Set ι} {S : ι → Set X} (hc : Set.Countable s)
    (hcomp : ∀ (i : ι), i ∈ s → IsSigmaCompact (S i)) :
    IsSigmaCompact (⋃ (i : ι) (_ : i ∈ s), S i) := by
  have : Countable ↑s := countable_coe_iff.mpr hc
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
s : Set ι
S : ι → Set X
hc : Set.Countable s
hcomp : ∀ i ∈ s, IsSigmaCompact (S i)
this : Countable ↑s
⊢ IsSigmaCompact (⋃ i ∈ s, S i)

Next tactic:
rw [biUnion_eq_iUnion]
/-- Countable unions of σ-compact sets are σ-compact. -/
lemma isSigmaCompact_biUnion {s : Set ι} {S : ι → Set X} (hc : Set.Countable s)
    (hcomp : ∀ (i : ι), i ∈ s → IsSigmaCompact (S i)) :
    IsSigmaCompact (⋃ (i : ι) (_ : i ∈ s), S i) := by
  have : Countable ↑s := countable_coe_iff.mpr hc
  rw [biUnion_eq_iUnion]
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
s : Set ι
S : ι → Set X
hc : Set.Countable s
hcomp : ∀ i ∈ s, IsSigmaCompact (S i)
this : Countable ↑s
⊢ IsSigmaCompact (⋃ x, S ↑x)

Next tactic:
exact isSigmaCompact_iUnion _ (fun ⟨i', hi'⟩ ↦ hcomp i' hi')
/-- A closed subset of a σ-compact set is σ-compact. -/
lemma IsSigmaCompact.of_isClosed_subset {s t : Set X} (ht : IsSigmaCompact t)
    (hs : IsClosed s) (h : s ⊆ t) : IsSigmaCompact s := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t✝ s t : Set X
ht : IsSigmaCompact t
hs : IsClosed s
h : s ⊆ t
⊢ IsSigmaCompact s

Next tactic:
rcases ht with ⟨K, hcompact, hcov⟩
/-- A closed subset of a σ-compact set is σ-compact. -/
lemma IsSigmaCompact.of_isClosed_subset {s t : Set X} (ht : IsSigmaCompact t)
    (hs : IsClosed s) (h : s ⊆ t) : IsSigmaCompact s := by
  rcases ht with ⟨K, hcompact, hcov⟩
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t✝ s t : Set X
hs : IsClosed s
h : s ⊆ t
K : ℕ → Set X
hcompact : ∀ (n : ℕ), IsCompact (K n)
hcov : ⋃ n, K n = t
⊢ IsSigmaCompact s

Next tactic:
refine ⟨(fun n ↦ s ∩ (K n)), fun n ↦ (hcompact n).inter_left hs, ?_⟩
/-- A closed subset of a σ-compact set is σ-compact. -/
lemma IsSigmaCompact.of_isClosed_subset {s t : Set X} (ht : IsSigmaCompact t)
    (hs : IsClosed s) (h : s ⊆ t) : IsSigmaCompact s := by
  rcases ht with ⟨K, hcompact, hcov⟩
  refine ⟨(fun n ↦ s ∩ (K n)), fun n ↦ (hcompact n).inter_left hs, ?_⟩
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t✝ s t : Set X
hs : IsClosed s
h : s ⊆ t
K : ℕ → Set X
hcompact : ∀ (n : ℕ), IsCompact (K n)
hcov : ⋃ n, K n = t
⊢ ⋃ n, (fun n => s ∩ K n) n = s

Next tactic:
rw [← inter_iUnion, hcov]
/-- A closed subset of a σ-compact set is σ-compact. -/
lemma IsSigmaCompact.of_isClosed_subset {s t : Set X} (ht : IsSigmaCompact t)
    (hs : IsClosed s) (h : s ⊆ t) : IsSigmaCompact s := by
  rcases ht with ⟨K, hcompact, hcov⟩
  refine ⟨(fun n ↦ s ∩ (K n)), fun n ↦ (hcompact n).inter_left hs, ?_⟩
  rw [← inter_iUnion, hcov]
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t✝ s t : Set X
hs : IsClosed s
h : s ⊆ t
K : ℕ → Set X
hcompact : ∀ (n : ℕ), IsCompact (K n)
hcov : ⋃ n, K n = t
⊢ s ∩ t = s

Next tactic:
exact inter_eq_left.mpr h
/-- If `s` is σ-compact and `f` is continuous on `s`, `f(s)` is σ-compact.-/
lemma IsSigmaCompact.image_of_continuousOn {f : X → Y} {s : Set X} (hs : IsSigmaCompact s)
    (hf : ContinuousOn f s) : IsSigmaCompact (f '' s) := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hs : IsSigmaCompact s
hf : ContinuousOn f s
⊢ IsSigmaCompact (f '' s)

Next tactic:
rcases hs with ⟨K, hcompact, hcov⟩
/-- If `s` is σ-compact and `f` is continuous on `s`, `f(s)` is σ-compact.-/
lemma IsSigmaCompact.image_of_continuousOn {f : X → Y} {s : Set X} (hs : IsSigmaCompact s)
    (hf : ContinuousOn f s) : IsSigmaCompact (f '' s) := by
  rcases hs with ⟨K, hcompact, hcov⟩
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : ContinuousOn f s
K : ℕ → Set X
hcompact : ∀ (n : ℕ), IsCompact (K n)
hcov : ⋃ n, K n = s
⊢ IsSigmaCompact (f '' s)

Next tactic:
refine ⟨fun n ↦ f '' K n, ?_, hcov.symm ▸ image_iUnion.symm⟩
/-- If `s` is σ-compact and `f` is continuous on `s`, `f(s)` is σ-compact.-/
lemma IsSigmaCompact.image_of_continuousOn {f : X → Y} {s : Set X} (hs : IsSigmaCompact s)
    (hf : ContinuousOn f s) : IsSigmaCompact (f '' s) := by
  rcases hs with ⟨K, hcompact, hcov⟩
  refine ⟨fun n ↦ f '' K n, ?_, hcov.symm ▸ image_iUnion.symm⟩
  

Proof state:
case intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : ContinuousOn f s
K : ℕ → Set X
hcompact : ∀ (n : ℕ), IsCompact (K n)
hcov : ⋃ n, K n = s
⊢ ∀ (n : ℕ), IsCompact ((fun n => f '' K n) n)

Next tactic:
exact fun n ↦ (hcompact n).image_of_continuousOn (hf.mono (hcov.symm ▸ subset_iUnion K n))
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
⊢ IsSigmaCompact s ↔ IsSigmaCompact (f '' s)

Next tactic:
constructor
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · 

Proof state:
case mp
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
⊢ IsSigmaCompact s → IsSigmaCompact (f '' s)

Next tactic:
exact fun h ↦ h.image hf.continuous
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · 

Proof state:
case mpr
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
⊢ IsSigmaCompact (f '' s) → IsSigmaCompact s

Next tactic:
rintro ⟨L, hcomp, hcov⟩
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    

Proof state:
case mpr.intro.intro
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
⊢ IsSigmaCompact s

Next tactic:
refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · 

Proof state:
case mpr.intro.intro.refine_1
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
⊢ ∀ (n : ℕ), IsCompact ((fun n => f ⁻¹' L n ∩ s) n)

Next tactic:
intro n
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      

Proof state:
case mpr.intro.intro.refine_1
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
n : ℕ
⊢ IsCompact ((fun n => f ⁻¹' L n ∩ s) n)

Next tactic:
have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        rw [image_preimage_inter, inter_eq_left.mpr]
        exact (subset_iUnion _ n).trans hcov.le
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
n : ℕ
⊢ f '' (f ⁻¹' L n ∩ s) = L n

Next tactic:
rw [image_preimage_inter, inter_eq_left.mpr]
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        rw [image_preimage_inter, inter_eq_left.mpr]
        

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
n : ℕ
⊢ L n ⊆ f '' s

Next tactic:
exact (subset_iUnion _ n).trans hcov.le
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        rw [image_preimage_inter, inter_eq_left.mpr]
        exact (subset_iUnion _ n).trans hcov.le
      

Proof state:
case mpr.intro.intro.refine_1
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
n : ℕ
this : f '' (f ⁻¹' L n ∩ s) = L n
⊢ IsCompact ((fun n => f ⁻¹' L n ∩ s) n)

Next tactic:
apply hf.isCompact_iff.mpr (this.symm ▸ (hcomp n))
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        rw [image_preimage_inter, inter_eq_left.mpr]
        exact (subset_iUnion _ n).trans hcov.le
      apply hf.isCompact_iff.mpr (this.symm ▸ (hcomp n))
    · 

Proof state:
case mpr.intro.intro.refine_2
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
⊢ ⋃ n, (fun n => f ⁻¹' L n ∩ s) n = s

Next tactic:
calc ⋃ n, f ⁻¹' L n ∩ s
        _ = f ⁻¹' (⋃ n, L n) ∩ s  := by rw [preimage_iUnion, iUnion_inter]
        _ = f ⁻¹' (f '' s) ∩ s := by rw [hcov]
        _ = s := inter_eq_right.mpr (subset_preimage_image _ _)
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        rw [image_preimage_inter, inter_eq_left.mpr]
        exact (subset_iUnion _ n).trans hcov.le
      apply hf.isCompact_iff.mpr (this.symm ▸ (hcomp n))
    · calc ⋃ n, f ⁻¹' L n ∩ s
        _ = f ⁻¹' (⋃ n, L n) ∩ s  := by 

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
⊢ ⋃ n, f ⁻¹' L n ∩ s = (f ⁻¹' ⋃ n, L n) ∩ s

Next tactic:
rw [preimage_iUnion, iUnion_inter]
/-- If `f : X → Y` is `Inducing`, the image `f '' s` of a set `s` is σ-compact
  if and only `s` is σ-compact. -/
lemma Inducing.isSigmaCompact_iff {f : X → Y} {s : Set X}
    (hf : Inducing f) : IsSigmaCompact s ↔ IsSigmaCompact (f '' s) := by
  constructor
  · exact fun h ↦ h.image hf.continuous
  · rintro ⟨L, hcomp, hcov⟩
    -- Suppose f(s) is σ-compact; we want to show s is σ-compact.
    -- Write f(s) as a union of compact sets L n, so s = ⋃ K n with K n := f⁻¹(L n) ∩ s.
    -- Since f is inducing, each K n is compact iff L n is.
    refine ⟨fun n ↦ f ⁻¹' (L n) ∩ s, ?_, ?_⟩
    · intro n
      have : f '' (f ⁻¹' (L n) ∩ s) = L n := by
        rw [image_preimage_inter, inter_eq_left.mpr]
        exact (subset_iUnion _ n).trans hcov.le
      apply hf.isCompact_iff.mpr (this.symm ▸ (hcomp n))
    · calc ⋃ n, f ⁻¹' L n ∩ s
        _ = f ⁻¹' (⋃ n, L n) ∩ s  := by rw [preimage_iUnion, iUnion_inter]
        _ = f ⁻¹' (f '' s) ∩ s := by 

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t : Set X
f : X → Y
s : Set X
hf : Inducing f
L : ℕ → Set Y
hcomp : ∀ (n : ℕ), IsCompact (L n)
hcov : ⋃ n, L n = f '' s
⊢ (f ⁻¹' ⋃ n, L n) ∩ s = f ⁻¹' (f '' s) ∩ s

Next tactic:
rw [hcov]
/-- A topological space is σ-compact iff there exists a countable collection of compact
subspaces that cover the entire space. -/
lemma SigmaCompactSpace_iff_exists_compact_covering :
    SigmaCompactSpace X ↔ ∃ K : ℕ → Set X, (∀ n, IsCompact (K n)) ∧ ⋃ n, K n = univ := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s t : Set X
⊢ SigmaCompactSpace X ↔ ∃ K, (∀ (n : ℕ), IsCompact (K n)) ∧ ⋃ n, K n = univ

Next tactic:
rw [← isSigmaCompact_univ_iff, IsSigmaCompact]
/-- A subset `s` is σ-compact iff `s` (with the subspace topology) is a σ-compact space. -/
lemma isSigmaCompact_iff_isSigmaCompact_univ {s : Set X} :
    IsSigmaCompact s ↔ IsSigmaCompact (univ : Set s) := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝¹ : TopologicalSpace X
inst✝ : TopologicalSpace Y
s✝ t s : Set X
⊢ IsSigmaCompact s ↔ IsSigmaCompact univ

Next tactic:
rw [Subtype.isSigmaCompact_iff, image_univ, Subtype.range_coe]
instance (priority := 100) sigmaCompactSpace_of_locally_compact_second_countable
    [LocallyCompactSpace X] [SecondCountableTopology X] : SigmaCompactSpace X := by
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
s t : Set X
inst✝¹ : LocallyCompactSpace X
inst✝ : SecondCountableTopology X
⊢ SigmaCompactSpace X

Next tactic:
choose K hKc hxK using fun x : X => exists_compact_mem_nhds x
instance (priority := 100) sigmaCompactSpace_of_locally_compact_second_countable
    [LocallyCompactSpace X] [SecondCountableTopology X] : SigmaCompactSpace X := by
  choose K hKc hxK using fun x : X => exists_compact_mem_nhds x
  

Proof state:
X : Type u_1
Y : Type u_2
ι : Type u_3
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
s t : Set X
inst✝¹ : LocallyCompactSpace X
inst✝ : SecondCountableTopology X
K : X → Set X
hKc : ∀ (x : X), IsCompact (K x)
hxK : ∀ (x : X), K x ∈ 𝓝 x
⊢ SigmaCompactSpace X

Next tactic:
rcases countable_cover_nhds hxK with ⟨s, hsc, hsU⟩