l3lab/ntp-mathlib huggingface dataset:
/-- A map is proper if and only if it is closed and its fibers are compact. -/
theorem isProperMap_iff_isClosedMap_and_compact_fibers :
    IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ ∀ y, IsCompact (f ⁻¹' {y}) := by
  constructor <;> intro H
  -- Note: In Bourbaki, the direct implication is proved by going through universally closed maps.
  -- We could do the same (using a `TFAE` cycle) but proving it directly from
  -- `IsProperMap.isCompact_preimage` is nice enough already so we don't bother with that.
  · exact ⟨H.continuous, H.isClosedMap, fun y ↦ H.isCompact_preimage isCompact_singleton⟩
  · rw [isProperMap_iff_clusterPt]
  -- Let `ℱ : Filter X` and `y` some cluster point of `map f ℱ`.
    refine ⟨H.1, fun ℱ y hy ↦ ?_⟩
  -- That means that the singleton `pure y` meets the "closure" of `map f ℱ`, by which we mean
  -- `Filter.lift' (map f ℱ) closure`. But `f` is closed, so
  -- `closure (map f ℱ) = map f (closure ℱ)` (see `IsClosedMap.lift'_closure_map_eq`).
  -- Thus `map f (closure ℱ ⊓ 𝓟 (f ⁻¹' {y})) = map f (closure ℱ) ⊓ 𝓟 {y} ≠ ⊥`, hence
  -- `closure ℱ ⊓ 𝓟 (f ⁻¹' {y}) ≠ ⊥`.
    rw [H.2.1.mapClusterPt_iff_lift'_closure H.1] at hy
  -- Now, applying the compactness of `f ⁻¹' {y}` to the nontrivial filter
  -- `closure ℱ ⊓ 𝓟 (f ⁻¹' {y})`, we obtain that it has a cluster point `x ∈ f ⁻¹' {y}`.
    rcases H.2.2 y (f := Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y})) inf_le_right with ⟨x, hxy, hx⟩
    refine ⟨x, hxy, ?_⟩
  -- In particular `x` is a cluster point of `closure ℱ`. Since cluster points of `closure ℱ`
  -- are exactly cluster points of `ℱ` (see `clusterPt_lift'_closure_iff`), this completes
  -- the proof.
    

Proof state:
case mpr.intro.intro
X : Type u_1
Y : Type u_2
Z : Type ?u.35858
W : Type ?u.35861
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace W
f : X → Y
H : Continuous f ∧ IsClosedMap f ∧ ∀ (y : Y), IsCompact (f ⁻¹' {y})
ℱ : Filter X
y : Y
hy : NeBot (Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y}))
x : X
hxy : x ∈ f ⁻¹' {y}
hx : ClusterPt x (Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y}))
⊢ ClusterPt x ℱ

Next tactic:
rw [← clusterPt_lift'_closure_iff]
/-- A map is proper if and only if it is closed and its fibers are compact. -/
theorem isProperMap_iff_isClosedMap_and_compact_fibers :
    IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ ∀ y, IsCompact (f ⁻¹' {y}) := by
  constructor <;> intro H
  -- Note: In Bourbaki, the direct implication is proved by going through universally closed maps.
  -- We could do the same (using a `TFAE` cycle) but proving it directly from
  -- `IsProperMap.isCompact_preimage` is nice enough already so we don't bother with that.
  · exact ⟨H.continuous, H.isClosedMap, fun y ↦ H.isCompact_preimage isCompact_singleton⟩
  · rw [isProperMap_iff_clusterPt]
  -- Let `ℱ : Filter X` and `y` some cluster point of `map f ℱ`.
    refine ⟨H.1, fun ℱ y hy ↦ ?_⟩
  -- That means that the singleton `pure y` meets the "closure" of `map f ℱ`, by which we mean
  -- `Filter.lift' (map f ℱ) closure`. But `f` is closed, so
  -- `closure (map f ℱ) = map f (closure ℱ)` (see `IsClosedMap.lift'_closure_map_eq`).
  -- Thus `map f (closure ℱ ⊓ 𝓟 (f ⁻¹' {y})) = map f (closure ℱ) ⊓ 𝓟 {y} ≠ ⊥`, hence
  -- `closure ℱ ⊓ 𝓟 (f ⁻¹' {y}) ≠ ⊥`.
    rw [H.2.1.mapClusterPt_iff_lift'_closure H.1] at hy
  -- Now, applying the compactness of `f ⁻¹' {y}` to the nontrivial filter
  -- `closure ℱ ⊓ 𝓟 (f ⁻¹' {y})`, we obtain that it has a cluster point `x ∈ f ⁻¹' {y}`.
    rcases H.2.2 y (f := Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y})) inf_le_right with ⟨x, hxy, hx⟩
    refine ⟨x, hxy, ?_⟩
  -- In particular `x` is a cluster point of `closure ℱ`. Since cluster points of `closure ℱ`
  -- are exactly cluster points of `ℱ` (see `clusterPt_lift'_closure_iff`), this completes
  -- the proof.
    rw [← clusterPt_lift'_closure_iff]
    

Proof state:
case mpr.intro.intro
X : Type u_1
Y : Type u_2
Z : Type ?u.35858
W : Type ?u.35861
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace W
f : X → Y
H : Continuous f ∧ IsClosedMap f ∧ ∀ (y : Y), IsCompact (f ⁻¹' {y})
ℱ : Filter X
y : Y
hy : NeBot (Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y}))
x : X
hxy : x ∈ f ⁻¹' {y}
hx : ClusterPt x (Filter.lift' ℱ closure ⊓ 𝓟 (f ⁻¹' {y}))
⊢ ClusterPt x (Filter.lift' ℱ closure)

Next tactic:
exact hx.mono inf_le_left
/-- Version of `isProperMap_iff_isClosedMap_and_compact_fibers` in terms of `cofinite` and
`cocompact`. Only works when the codomain is `T1`. -/
lemma isProperMap_iff_isClosedMap_and_tendsto_cofinite [T1Space Y] :
    IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ Tendsto f (cocompact X) cofinite := by
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.36821
W : Type ?u.36824
inst✝⁴ : TopologicalSpace X
inst✝³ : TopologicalSpace Y
inst✝² : TopologicalSpace Z
inst✝¹ : TopologicalSpace W
f : X → Y
inst✝ : T1Space Y
⊢ IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ Tendsto f (cocompact X) cofinite

Next tactic:
simp_rw [isProperMap_iff_isClosedMap_and_compact_fibers, Tendsto,
    le_cofinite_iff_compl_singleton_mem, mem_map, preimage_compl]
/-- Version of `isProperMap_iff_isClosedMap_and_compact_fibers` in terms of `cofinite` and
`cocompact`. Only works when the codomain is `T1`. -/
lemma isProperMap_iff_isClosedMap_and_tendsto_cofinite [T1Space Y] :
    IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ Tendsto f (cocompact X) cofinite := by
  simp_rw [isProperMap_iff_isClosedMap_and_compact_fibers, Tendsto,
    le_cofinite_iff_compl_singleton_mem, mem_map, preimage_compl]
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.36821
W : Type ?u.36824
inst✝⁴ : TopologicalSpace X
inst✝³ : TopologicalSpace Y
inst✝² : TopologicalSpace Z
inst✝¹ : TopologicalSpace W
f : X → Y
inst✝ : T1Space Y
⊢ (Continuous f ∧ IsClosedMap f ∧ ∀ (y : Y), IsCompact (f ⁻¹' {y})) ↔
    Continuous f ∧ IsClosedMap f ∧ ∀ (x : Y), (f ⁻¹' {x})ᶜ ∈ cocompact X

Next tactic:
refine and_congr_right fun f_cont ↦ and_congr_right fun _ ↦
    ⟨fun H y ↦ (H y).compl_mem_cocompact, fun H y ↦ ?_⟩
/-- Version of `isProperMap_iff_isClosedMap_and_compact_fibers` in terms of `cofinite` and
`cocompact`. Only works when the codomain is `T1`. -/
lemma isProperMap_iff_isClosedMap_and_tendsto_cofinite [T1Space Y] :
    IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ Tendsto f (cocompact X) cofinite := by
  simp_rw [isProperMap_iff_isClosedMap_and_compact_fibers, Tendsto,
    le_cofinite_iff_compl_singleton_mem, mem_map, preimage_compl]
  refine and_congr_right fun f_cont ↦ and_congr_right fun _ ↦
    ⟨fun H y ↦ (H y).compl_mem_cocompact, fun H y ↦ ?_⟩
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.36821
W : Type ?u.36824
inst✝⁴ : TopologicalSpace X
inst✝³ : TopologicalSpace Y
inst✝² : TopologicalSpace Z
inst✝¹ : TopologicalSpace W
f : X → Y
inst✝ : T1Space Y
f_cont : Continuous f
x✝ : IsClosedMap f
H : ∀ (x : Y), (f ⁻¹' {x})ᶜ ∈ cocompact X
y : Y
⊢ IsCompact (f ⁻¹' {y})

Next tactic:
rcases mem_cocompact.mp (H y) with ⟨K, hK, hKy⟩
/-- Version of `isProperMap_iff_isClosedMap_and_compact_fibers` in terms of `cofinite` and
`cocompact`. Only works when the codomain is `T1`. -/
lemma isProperMap_iff_isClosedMap_and_tendsto_cofinite [T1Space Y] :
    IsProperMap f ↔ Continuous f ∧ IsClosedMap f ∧ Tendsto f (cocompact X) cofinite := by
  simp_rw [isProperMap_iff_isClosedMap_and_compact_fibers, Tendsto,
    le_cofinite_iff_compl_singleton_mem, mem_map, preimage_compl]
  refine and_congr_right fun f_cont ↦ and_congr_right fun _ ↦
    ⟨fun H y ↦ (H y).compl_mem_cocompact, fun H y ↦ ?_⟩
  rcases mem_cocompact.mp (H y) with ⟨K, hK, hKy⟩
  

Proof state:
case intro.intro
X : Type u_2
Y : Type u_1
Z : Type ?u.36821
W : Type ?u.36824
inst✝⁴ : TopologicalSpace X
inst✝³ : TopologicalSpace Y
inst✝² : TopologicalSpace Z
inst✝¹ : TopologicalSpace W
f : X → Y
inst✝ : T1Space Y
f_cont : Continuous f
x✝ : IsClosedMap f
H : ∀ (x : Y), (f ⁻¹' {x})ᶜ ∈ cocompact X
y : Y
K : Set X
hK : IsCompact K
hKy : Kᶜ ⊆ (f ⁻¹' {y})ᶜ
⊢ IsCompact (f ⁻¹' {y})

Next tactic:
exact hK.of_isClosed_subset (isClosed_singleton.preimage f_cont)
    (compl_le_compl_iff_le.mp hKy)
/-- A continuous map from a compact space to a T₂ space is a proper map. -/
theorem Continuous.isProperMap [CompactSpace X] [T2Space Y] (hf : Continuous f) : IsProperMap f :=
  isProperMap_iff_isClosedMap_and_tendsto_cofinite.2 ⟨hf, hf.isClosedMap, by 

Proof state:
X : Type u_1
Y : Type u_2
Z : Type ?u.38104
W : Type ?u.38107
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : CompactSpace X
inst✝ : T2Space Y
hf : Continuous f
⊢ Tendsto f (cocompact X) cofinite

Next tactic:
simp
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
⊢ IsProperMap f ↔ Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)

Next tactic:
constructor
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> 

Proof state:
case mp
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
⊢ IsProperMap f → Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)

Next tactic:
intro H
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> 

Proof state:
case mpr
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
⊢ (Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)) → IsProperMap f

Next tactic:
intro H
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · 

Proof state:
case mp
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : IsProperMap f
⊢ Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)

Next tactic:
exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · 

Proof state:
case mpr
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
⊢ IsProperMap f

Next tactic:
rw [isProperMap_iff_ultrafilter_of_t2]
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · rw [isProperMap_iff_ultrafilter_of_t2]
    -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`.
    

Proof state:
case mpr
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
⊢ Continuous f ∧ ∀ ⦃𝒰 : Ultrafilter X⦄ ⦃y : Y⦄, Tendsto f (↑𝒰) (𝓝 y) → ∃ x, ↑𝒰 ≤ 𝓝 x

Next tactic:
refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · rw [isProperMap_iff_ultrafilter_of_t2]
    -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`.
    refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩
    -- Pick `K` some compact neighborhood of `y`, which exists by local compactness.
    

Proof state:
case mpr
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
𝒰 : Ultrafilter X
y : Y
hy : Tendsto f (↑𝒰) (𝓝 y)
⊢ ∃ x, ↑𝒰 ≤ 𝓝 x

Next tactic:
rcases exists_compact_mem_nhds y with ⟨K, hK, hKy⟩
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · rw [isProperMap_iff_ultrafilter_of_t2]
    -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`.
    refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩
    -- Pick `K` some compact neighborhood of `y`, which exists by local compactness.
    rcases exists_compact_mem_nhds y with ⟨K, hK, hKy⟩
    -- Then `map f 𝒰 ≤ 𝓝 y ≤ 𝓟 K`, hence `𝒰 ≤ 𝓟 (f ⁻¹' K)`
    

Proof state:
case mpr.intro.intro
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
𝒰 : Ultrafilter X
y : Y
hy : Tendsto f (↑𝒰) (𝓝 y)
K : Set Y
hK : IsCompact K
hKy : K ∈ 𝓝 y
⊢ ∃ x, ↑𝒰 ≤ 𝓝 x

Next tactic:
have : 𝒰 ≤ 𝓟 (f ⁻¹' K) := by
      simpa only [← comap_principal, ← tendsto_iff_comap] using
        hy.mono_right (le_principal_iff.mpr hKy)
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · rw [isProperMap_iff_ultrafilter_of_t2]
    -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`.
    refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩
    -- Pick `K` some compact neighborhood of `y`, which exists by local compactness.
    rcases exists_compact_mem_nhds y with ⟨K, hK, hKy⟩
    -- Then `map f 𝒰 ≤ 𝓝 y ≤ 𝓟 K`, hence `𝒰 ≤ 𝓟 (f ⁻¹' K)`
    have : 𝒰 ≤ 𝓟 (f ⁻¹' K) := by
      

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
𝒰 : Ultrafilter X
y : Y
hy : Tendsto f (↑𝒰) (𝓝 y)
K : Set Y
hK : IsCompact K
hKy : K ∈ 𝓝 y
⊢ ↑𝒰 ≤ 𝓟 (f ⁻¹' K)

Next tactic:
simpa only [← comap_principal, ← tendsto_iff_comap] using
        hy.mono_right (le_principal_iff.mpr hKy)
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · rw [isProperMap_iff_ultrafilter_of_t2]
    -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`.
    refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩
    -- Pick `K` some compact neighborhood of `y`, which exists by local compactness.
    rcases exists_compact_mem_nhds y with ⟨K, hK, hKy⟩
    -- Then `map f 𝒰 ≤ 𝓝 y ≤ 𝓟 K`, hence `𝒰 ≤ 𝓟 (f ⁻¹' K)`
    have : 𝒰 ≤ 𝓟 (f ⁻¹' K) := by
      simpa only [← comap_principal, ← tendsto_iff_comap] using
        hy.mono_right (le_principal_iff.mpr hKy)
    -- By compactness of `f ⁻¹' K`, `𝒰` converges to some `x ∈ f ⁻¹' K`.
    

Proof state:
case mpr.intro.intro
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
𝒰 : Ultrafilter X
y : Y
hy : Tendsto f (↑𝒰) (𝓝 y)
K : Set Y
hK : IsCompact K
hKy : K ∈ 𝓝 y
this : ↑𝒰 ≤ 𝓟 (f ⁻¹' K)
⊢ ∃ x, ↑𝒰 ≤ 𝓝 x

Next tactic:
rcases (H.2 hK).ultrafilter_le_nhds _ this with ⟨x, -, hx⟩
/-- If `Y` is locally compact and Hausdorff, then proper maps `X → Y` are exactly continuous maps
such that the preimage of any compact set is compact. -/
theorem isProperMap_iff_isCompact_preimage [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ ∀ ⦃K⦄, IsCompact K → IsCompact (f ⁻¹' K) := by
  constructor <;> intro H
  -- The direct implication follows from the previous results
  · exact ⟨H.continuous, fun K hK ↦ H.isCompact_preimage hK⟩
  · rw [isProperMap_iff_ultrafilter_of_t2]
    -- Let `𝒰 : Ultrafilter X`, and assume that `f` tends to some `y` along `𝒰`.
    refine ⟨H.1, fun 𝒰 y hy ↦ ?_⟩
    -- Pick `K` some compact neighborhood of `y`, which exists by local compactness.
    rcases exists_compact_mem_nhds y with ⟨K, hK, hKy⟩
    -- Then `map f 𝒰 ≤ 𝓝 y ≤ 𝓟 K`, hence `𝒰 ≤ 𝓟 (f ⁻¹' K)`
    have : 𝒰 ≤ 𝓟 (f ⁻¹' K) := by
      simpa only [← comap_principal, ← tendsto_iff_comap] using
        hy.mono_right (le_principal_iff.mpr hKy)
    -- By compactness of `f ⁻¹' K`, `𝒰` converges to some `x ∈ f ⁻¹' K`.
    rcases (H.2 hK).ultrafilter_le_nhds _ this with ⟨x, -, hx⟩
    

Proof state:
case mpr.intro.intro.intro.intro
X : Type u_2
Y : Type u_1
Z : Type ?u.38671
W : Type ?u.38674
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
H : Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)
𝒰 : Ultrafilter X
y : Y
hy : Tendsto f (↑𝒰) (𝓝 y)
K : Set Y
hK : IsCompact K
hKy : K ∈ 𝓝 y
this : ↑𝒰 ≤ 𝓟 (f ⁻¹' K)
x : X
hx : ↑𝒰 ≤ 𝓝 x
⊢ ∃ x, ↑𝒰 ≤ 𝓝 x

Next tactic:
exact ⟨x, hx⟩
/-- Version of `isProperMap_iff_isCompact_preimage` in terms of `cocompact`. -/
lemma isProperMap_iff_tendsto_cocompact [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y) := by
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.49273
W : Type ?u.49276
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
⊢ IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y)

Next tactic:
simp_rw [isProperMap_iff_isCompact_preimage, hasBasis_cocompact.tendsto_right_iff,
    ← mem_preimage, eventually_mem_set, preimage_compl]
/-- Version of `isProperMap_iff_isCompact_preimage` in terms of `cocompact`. -/
lemma isProperMap_iff_tendsto_cocompact [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y) := by
  simp_rw [isProperMap_iff_isCompact_preimage, hasBasis_cocompact.tendsto_right_iff,
    ← mem_preimage, eventually_mem_set, preimage_compl]
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.49273
W : Type ?u.49276
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
⊢ (Continuous f ∧ ∀ ⦃K : Set Y⦄, IsCompact K → IsCompact (f ⁻¹' K)) ↔
    Continuous f ∧ ∀ (i : Set Y), IsCompact i → (f ⁻¹' i)ᶜ ∈ cocompact X

Next tactic:
refine and_congr_right fun f_cont ↦
    ⟨fun H K hK ↦ (H hK).compl_mem_cocompact, fun H K hK ↦ ?_⟩
/-- Version of `isProperMap_iff_isCompact_preimage` in terms of `cocompact`. -/
lemma isProperMap_iff_tendsto_cocompact [T2Space Y] [WeaklyLocallyCompactSpace Y] :
    IsProperMap f ↔ Continuous f ∧ Tendsto f (cocompact X) (cocompact Y) := by
  simp_rw [isProperMap_iff_isCompact_preimage, hasBasis_cocompact.tendsto_right_iff,
    ← mem_preimage, eventually_mem_set, preimage_compl]
  refine and_congr_right fun f_cont ↦
    ⟨fun H K hK ↦ (H hK).compl_mem_cocompact, fun H K hK ↦ ?_⟩
  

Proof state:
X : Type u_2
Y : Type u_1
Z : Type ?u.49273
W : Type ?u.49276
inst✝⁵ : TopologicalSpace X
inst✝⁴ : TopologicalSpace Y
inst✝³ : TopologicalSpace Z
inst✝² : TopologicalSpace W
f : X → Y
inst✝¹ : T2Space Y
inst✝ : WeaklyLocallyCompactSpace Y
f_cont : Continuous f
H : ∀ (i : Set Y), IsCompact i → (f ⁻¹' i)ᶜ ∈ cocompact X
K : Set Y
hK : IsCompact K
⊢ IsCompact (f ⁻¹' K)

Next tactic:
rcases mem_cocompact.mp (H K hK) with ⟨K', hK', hK'y⟩