[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.Category.Profinite.Nobeling.Successor).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
def Linear_CC'₀ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C0 (L95-L97)
def C0 := C ∩ {f | f (term I ho) = false}
/-- The subset of `C` consisting of those elements whose `o`-th entry is `true`. -/
```

-- snippet 2
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C1 (L98-L100)
def C1 := C ∩ {f | f (term I ho) = true}
include hC in
```

-- snippet 3
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.isClosed_C0 (L101-L106)
theorem isClosed_C0 : IsClosed (C0 C ho) := by
refine hC.inter ?_
  have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho)
  exact IsClosed.preimage h (t := {false}) (isClosed_discrete _)

include hC in
```

-- snippet 4
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.isClosed_C1 (L107-L111)
theorem isClosed_C1 : IsClosed (C1 C ho) := by
refine hC.inter ?_
  have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho)
  exact IsClosed.preimage h (t := {true}) (isClosed_discrete _)
```

-- snippet 5
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.contained_C1 (L112-L114)
theorem contained_C1 : contained (π (C1 C ho) (ord I · < o)) o :=
contained_proj _ _
```

-- snippet 6
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.union_C0C1_eq (L115-L123)
theorem union_C0C1_eq : (C0 C ho) ∪ (C1 C ho) = C := by
ext x
  simp only [C0, C1, Set.mem_union, Set.mem_inter_iff, Set.mem_setOf_eq,
    ← and_or_left, and_iff_left_iff_imp, Bool.dichotomy (x (term I ho)), implies_true]

/--
The intersection of `C0` and the projection of `C1`. We will apply the inductive hypothesis to
this set.
-/
```

-- snippet 7
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C' (L124-L126)
def C' := C0 C ho ∩ π (C1 C ho) (ord I · < o)
include hC in
```

-- snippet 8
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.isClosed_C' (L127-L129)
theorem isClosed_C' : IsClosed (C' C ho) :=
IsClosed.inter (isClosed_C0 _ hC _) (isClosed_proj _ _ (isClosed_C1 _ hC _))
```

-- snippet 9
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.contained_C' (L130-L135)
theorem contained_C' : contained (C' C ho) o := fun f hf i hi ↦ contained_C1 C ho f hf.2 i hi
variable (o)

/-- Swapping the `o`-th coordinate to `true`. -/
noncomputable
```

-- snippet 10
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.SwapTrue (L136-L138)
def SwapTrue : (I → Bool) → I → Bool :=
fun f i ↦ if ord I i = o then true else f i
```

-- snippet 11
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.continuous_swapTrue (L139-L149)
theorem continuous_swapTrue : Continuous (SwapTrue o : (I → Bool) → I → Bool) := by
dsimp +unfoldPartialApp [SwapTrue]
  apply continuous_pi
  intro i
  apply Continuous.comp'
  · apply continuous_bot
  · apply continuous_apply

variable {o}

include hsC in
```

-- snippet 12
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.swapTrue_mem_C1 (L150-L165)
theorem swapTrue_mem_C1 (f : π (C1 C ho) (ord I · < o)) :
    SwapTrue o f.val ∈ C1 C ho := by
obtain ⟨f, g, hg, rfl⟩ := f
  convert hg
  dsimp +unfoldPartialApp [SwapTrue]
  ext i
  split_ifs with h
  · rw [ord_term ho] at h
    simpa only [← h] using hg.2.symm
  · simp only [Proj, ite_eq_left_iff, not_lt, @eq_comm _ false, ← Bool.not_eq_true]
    specialize hsC g hg.1 i
    intro h'
    contrapose! hsC
    exact ⟨hsC, Order.succ_le_of_lt (h'.lt_of_ne' h)⟩

/-- The first way to map `C'` into `C`. -/
```

-- snippet 13
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC'₀ (L166-L169)
def CC'₀ : C' C ho → C := fun g ↦ ⟨g.val,g.prop.1.1⟩
/-- The second way to map `C'` into `C`. -/
noncomputable
```

-- snippet 14
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC'₁ (L170-L172)
def CC'₁ : C' C ho → C :=
fun g ↦ ⟨SwapTrue o g.val, (swapTrue_mem_C1 C hsC ho ⟨g.val,g.prop.2⟩).1⟩
```

-- snippet 15
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.continuous_CC'₀ (L173-L174)
theorem continuous_CC'₀ : Continuous (CC'₀ C ho) := Continuous.subtype_mk continuous_subtype_val _
```

-- snippet 16
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.continuous_CC'₁ (L175-L179)
theorem continuous_CC'₁ : Continuous (CC'₁ C hsC ho) :=
Continuous.subtype_mk (Continuous.comp (continuous_swapTrue o) continuous_subtype_val) _

/-- The `ℤ`-linear map induced by precomposing with `CC'₀` -/
noncomputable
```

-- snippet 17
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.Linear_CC'₁ (L185-L189)
def Linear_CC'₁ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ :=
LocallyConstant.comapₗ ℤ ⟨(CC'₁ C hsC ho), (continuous_CC'₁ C hsC ho)⟩

/-- The difference between `Linear_CC'₁` and `Linear_CC'₀`. -/
noncomputable
```

-- snippet 18
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.Linear_CC' (L190-L192)
def Linear_CC' : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ :=
Linear_CC'₁ C hsC ho - Linear_CC'₀ C ho
```

-- snippet 19
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC_comp_zero (L193-L206)
theorem CC_comp_zero : ∀ y, (Linear_CC' C hsC ho) ((πs C o) y) = 0 := by
intro y
  ext x
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁, LocallyConstant.sub_apply]
  simp only [sub_eq_zero]
  congr 1
  ext i
  dsimp [CC'₀, CC'₁, ProjRestrict, Proj]
  apply if_ctx_congr Iff.rfl _ (fun _ ↦ rfl)
  simp only [SwapTrue, ite_eq_right_iff]
  intro h₁ h₂
  exact (h₁.ne h₂).elim

include hsC in
```

-- snippet 20
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C0_projOrd (L207-L220)
theorem C0_projOrd {x : I → Bool} (hx : x ∈ C0 C ho) : Proj (ord I · < o) x = x := by
ext i
  simp only [Proj, ite_eq_left_iff, not_lt]
  intro hi
  rcases hi.lt_or_eq with hi | hi
  · specialize hsC x hx.1 i
    rw [← not_imp_not] at hsC
    simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC
    exact (hsC hi).symm
  · simp only [C0, Set.mem_inter_iff, Set.mem_setOf_eq] at hx
    rw [eq_comm, ord_term ho] at hi
    rw [← hx.2, hi]

include hsC in
```

-- snippet 21
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C1_projOrd (L221-L236)
theorem C1_projOrd {x : I → Bool} (hx : x ∈ C1 C ho) : SwapTrue o (Proj (ord I · < o) x) = x := by
ext i
  dsimp [SwapTrue, Proj]
  split_ifs with hi h
  · rw [ord_term ho] at hi
    rw [← hx.2, hi]
  · rfl
  · simp only [not_lt] at h
    have h' : o < ord I i := lt_of_le_of_ne h (Ne.symm hi)
    specialize hsC x hx.1 i
    rw [← not_imp_not] at hsC
    simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC
    exact (hsC h').symm

include hC in
open scoped Classical in
```

-- snippet 22
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC_exact (L237-L271)
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap ⟨C₀C, h₀⟩) (f.comap ⟨C₁C, h₁⟩) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
  · ext ⟨x, hx⟩
    rw [← union_C0C1_eq C ho] at hx
    rcases hx with hx₀ | hx₁
    · have hx₀' : ProjRestrict C (ord I · < o) ⟨x, hx⟩ = x := by
        simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using C0_projOrd C hsC ho hx₀
      simp only [C₀C, πs_apply_apply, hx₀', hx₀, LocallyConstant.piecewise'_apply_left,
        LocallyConstant.coe_comap, ContinuousMap.coe_mk, Function.comp_apply]
    · have hx₁' : (ProjRestrict C (ord I · < o) ⟨x, hx⟩).val ∈ π (C1 C ho) (ord I · < o) := by
        simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using ⟨x, hx₁, rfl⟩
      simp only [C₁C, πs_apply_apply, LocallyConstant.coe_comap,
        Function.comp_apply, hx₁', LocallyConstant.piecewise'_apply_right]
      congr
      simp only [ContinuousMap.coe_mk, Subtype.mk.injEq]
      exact C1_projOrd C hsC ho hx₁

variable (o) in
```

-- snippet 23
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.succ_mono (L272-L276)
theorem succ_mono : CategoryTheory.Mono (ModuleCat.ofHom (πs C o)) := by
rw [ModuleCat.mono_iff_injective]
  exact injective_πs _ _

include hC in
```

-- snippet 24
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.succ_exact (L277-L291)
theorem succ_exact :
    (ShortComplex.mk (ModuleCat.ofHom (πs C o)) (ModuleCat.ofHom (Linear_CC' C hsC ho))
    (by ext : 2; apply CC_comp_zero)).Exact := by
rw [ShortComplex.moduleCat_exact_iff]
  intro f
  exact CC_exact C hC hsC ho

end ExactSequence

namespace GoodProducts

/--
The `GoodProducts` in `C` that contain `o` (they necessarily start with `o`, see
`GoodProducts.head!_eq_o_of_maxProducts`)
-/
```

-- snippet 25
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.MaxProducts (L292-L294)
def MaxProducts : Set (Products I) := {l | l.isGood C ∧ term I ho ∈ l.val}
include hsC in
```

-- snippet 26
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isClosedMap (L221-L224)
theorem isClosedMap {X Y : CompHausLike.{u} P} (f : X ⟶ Y) : IsClosedMap f := fun _ hC =>
(hC.isCompact.image f.hom.hom.continuous).isClosed

/-- Any continuous bijection of compact Hausdorff spaces is an isomorphism. -/
```

-- snippet 27
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.Sigma (L161-L170)
lemma Sigma.isOpenEmbedding_ι (a : α) :
    IsOpenEmbedding (Sigma.ι X a) := by
refine IsOpenEmbedding.of_comp _ (homeoOfIso ((colimit.isColimit _).coconePointUniqueUpToIso
    (finiteCoproduct.isColimit X))).isOpenEmbedding ?_
  convert finiteCoproduct.isOpenEmbedding_ι X a
  ext x
  change (Sigma.ι X a ≫ _) x = _
  simp

/-- The functor to `TopCat` preserves finite coproducts if they exist. -/
```

-- snippet 28
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.homeoOfIso (L256-L260)
def homeoOfIso {X Y : CompHausLike.{u} P} (f : X ≅ Y) : X ≃ₜ Y :=
TopCat.homeoOfIso <| (compHausLikeToTop P).mapIso f

/-- The equivalence between isomorphisms in `CompHaus` and homeomorphisms
of topological spaces. -/
```

-- snippet 29
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.ofHom (L67-L68)
abbrev ofHom (f : C(X, Y)) : of X ⟶ of Y := ConcreteCategory.ofHom f
```

-- snippet 30
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.coe_id (L123-L125)
theorem coe_id (X : CompHausLike P) : (𝟙 X : X → X) = id :=
rfl
```

-- snippet 31
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.of (L114-L119)
abbrev of : CompHausLike P where
  toTop := TopCat.of X
is_compact := ‹_›
  is_hausdorff := ‹_›
  prop := HasProp.hasProp
```

-- snippet 32
```lean
-- Mathlib.Topology.Category.Compactum.incl (L132-L134)
def incl (X : Compactum) : X → Ultrafilter X :=
(β).η.app _
```

-- snippet 33
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.hasPullbacksOfInclusions (L335-L350)
theorem hasPullbacksOfInclusions
    (hP' : ∀ ⦃X Y B : CompHausLike.{u} P⦄ (f : X ⟶ B) (g : Y ⟶ B)
      (_ : IsOpenEmbedding f), HasExplicitPullback f g) :
    HasExplicitPullbacksOfInclusions P :=
{ hasProp := by
      intro _ _ _ f
      apply hP'
      exact Sigma.isOpenEmbedding_ι _ _ }

/-- The functor to `TopCat` preserves pullbacks of inclusions if they exist. -/
noncomputable instance [HasExplicitPullbacksOfInclusions P] :
    PreservesPullbacksOfInclusions (compHausLikeToTop P) :=
  { preservesPullbackInl := by
      intro X Y Z f
      infer_instance }
```

-- snippet 34
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.isoOfHomeo (L86-L96)
def isoOfHomeo {X Y : CompactlyGenerated.{u, w}} (f : X ≃ₜ Y) : X ≅ Y where
  hom := ofHom ⟨f, f.continuous⟩
inv := ofHom ⟨f.symm, f.symm.continuous⟩
  hom_inv_id := by
    ext x
    exact f.symm_apply_apply x
  inv_hom_id := by
    ext x
    exact f.apply_symm_apply x

/-- Construct a homeomorphism from an isomorphism. -/
```

-- snippet 35
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.toCompHausLike (L152-L158)
def toCompHausLike {P P' : TopCat → Prop} (h : ∀ (X : CompHausLike P), P X.toTop → P' X.toTop) :
    CompHausLike P ⥤ CompHausLike P' where
  obj X :=
haveI : HasProp P' X := ⟨(h _ X.prop)⟩
    CompHausLike.of _ X
  map {X Y} f := ConcreteCategory.ofHom f.hom.hom
```

-- snippet 36
```lean
-- Mathlib.Topology.Category.Compactum.str_hom_commute (L142-L147)
theorem str_hom_commute (X Y : Compactum) (f : X ⟶ Y) (xs : Ultrafilter X) :
    f (X.str xs) = Y.str (map f xs) := by
change (X.a ≫ f.f) _ = _
  rw [← f.h]
  rfl
```

-- snippet 37
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.compHausLikeToCompHaus (L217-L218)
abbrev compHausLikeToCompHaus (P : TopCat → Prop) : CompHausLike P ⥤ CompHaus :=
CompHausLike.toCompHausLike (by simp only [implies_true])
```

-- snippet 38
```lean
-- Mathlib.Topology.Category.Compactum.free (L101-L104)
def free : Type* ⥤ Compactum :=
Monad.free _

/-- The adjunction between `free` and `forget`. -/
```

-- snippet 39
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.homeoOfIso (L98-L107)
def homeoOfIso {X Y : CompactlyGenerated.{u, w}} (f : X ≅ Y) : X ≃ₜ Y where
  toFun := f.hom
invFun := f.inv
  left_inv := f.hom_inv_id_apply
  right_inv := f.inv_hom_id_apply
  continuous_toFun := f.hom.hom.hom.continuous
  continuous_invFun := f.inv.hom.hom.continuous

/-- The equivalence between isomorphisms in `CompactlyGenerated` and homeomorphisms
of topological spaces. -/
```

-- snippet 40
```lean
-- Mathlib.Topology.Category.CompHausLike.EffectiveEpi.effectiveEpiStruct (L36-L63)
def effectiveEpiStruct {B X : CompHausLike P} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h :=
ofHom _ ((IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).lift e.hom.hom
      fun a b hab ↦
        CategoryTheory.congr_fun (h
          (ofHom _ ⟨fun _ ↦ a, continuous_const⟩)
          (ofHom _ ⟨fun _ ↦ b, continuous_const⟩)
        (by ext; exact hab)) a)
  fac e h :=
    InducedCategory.hom_ext (TopCat.hom_ext
      ((IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).lift_comp _ _))
  uniq e h g hm := by
    suffices g = ofHom _
        ((IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).liftEquiv ⟨e.hom.hom,
      fun a b hab ↦ CategoryTheory.congr_fun
        (h
          (ofHom _ ⟨fun _ ↦ a, continuous_const⟩)
          (ofHom _ ⟨fun _ ↦ b, continuous_const⟩)
          (by ext; exact hab))
        a⟩) by assumption
    apply ConcreteCategory.ext
    rw [hom_ofHom, ← Equiv.symm_apply_eq
      (IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).liftEquiv]
    ext
    simp only [IsQuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm]
    rfl
```

-- snippet 41
```lean
-- Mathlib.Topology.Category.Compactum.str_eq_of_le_nhds (L272-L341)
theorem str_eq_of_le_nhds {X : Compactum} (F : Ultrafilter X) (x : X) : ↑F ≤ 𝓝 x → X.str F = x := by
-- Notation to be used in this proof.
  let fsu := Finset (Set (Ultrafilter X))
  let ssu := Set (Set (Ultrafilter X))
  let ι : fsu → ssu := fun x ↦ ↑x
  let T0 : ssu := { S | ∃ A ∈ F, S = basic A }
  let AA := X.str ⁻¹' {x}
  let T1 := insert AA T0
  let T2 := finiteInterClosure T1
  intro cond
  -- If F contains a closed set A, then x is contained in A.
  have claim1 : ∀ A : Set X, IsClosed A → A ∈ F → x ∈ A := by
    intro A hA h
    by_contra H
    rw [le_nhds_iff] at cond
    specialize cond Aᶜ H hA.isOpen_compl
    rw [Ultrafilter.mem_coe, Ultrafilter.compl_mem_iff_notMem] at cond
    contradiction
  -- If A ∈ F, then x ∈ cl A.
  have claim2 : ∀ A : Set X, A ∈ F → x ∈ cl A := by
    intro A hA
    exact claim1 (cl A) (isClosed_cl A) (mem_of_superset hA (subset_cl A))
  -- T0 is closed under intersections.
  have claim3 : ∀ (S1) (_ : S1 ∈ T0) (S2) (_ : S2 ∈ T0), S1 ∩ S2 ∈ T0 := by
    rintro S1 ⟨S1, hS1, rfl⟩ S2 ⟨S2, hS2, rfl⟩
    exact ⟨S1 ∩ S2, inter_mem hS1 hS2, by simp [basic_inter]⟩
  -- For every S ∈ T0, the intersection AA ∩ S is nonempty.
  have claim4 : ∀ S ∈ T0, (AA ∩ S).Nonempty := by
    rintro S ⟨S, hS, rfl⟩
    rcases claim2 _ hS with ⟨G, hG, hG2⟩
    exact ⟨G, hG2, hG⟩
  -- Every element of T0 is nonempty.
  have claim5 : ∀ S ∈ T0, Set.Nonempty S := by
    rintro S ⟨S, hS, rfl⟩
    exact ⟨F, hS⟩
  -- Every element of T2 is nonempty.
  have claim6 : ∀ S ∈ T2, Set.Nonempty S := by
    suffices ∀ S ∈ T2, S ∈ T0 ∨ ∃ Q ∈ T0, S = AA ∩ Q by
      intro S hS
      rcases this _ hS with h | h
      · exact claim5 S h
      · rcases h with ⟨Q, hQ, rfl⟩
        exact claim4 Q hQ
    intro S hS
    apply finiteInterClosure_insert
    · constructor
      · use Set.univ
        refine ⟨Filter.univ_sets _, ?_⟩
        ext
        refine ⟨?_, by tauto⟩
        · intro
          apply Filter.univ_sets
      · exact claim3
    · exact hS
  -- It suffices to show that the intersection of any finite subset of T1 is nonempty.
  suffices ∀ F : fsu, ↑F ⊆ T1 → (⋂₀ ι F).Nonempty by
    obtain ⟨G, h1⟩ := Ultrafilter.exists_ultrafilter_of_finite_inter_nonempty _ this
    have c1 : X.join G = F := Ultrafilter.coe_le_coe.1 fun P hP => h1 (Or.inr ⟨P, hP, rfl⟩)
    have c2 : G.map X.str = X.incl x := by
      refine Ultrafilter.coe_le_coe.1 fun P hP => ?_
      apply mem_of_superset (h1 (Or.inl rfl))
      rintro x ⟨rfl⟩
      exact hP
    simp [← c1, c2]
  -- Finish...
  intro T hT
  refine claim6 _ (finiteInter_mem (.finiteInterClosure_finiteInter _) _ ?_)
  intro t ht
  exact finiteInterClosure.basic (@hT t ht)
```

-- snippet 42
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.productCone (L40-L47)
def productCone : BinaryFan X Y :=
BinaryFan.mk (P := CompHausLike.of P (X × Y))
    (ofHom _ { toFun := Prod.fst }) (ofHom _ { toFun := Prod.snd })

/--
When the predicate `P` is preserved under taking type-theoretic products, that product is a
category-theoretic product in `CompHausLike P`.
-/
```

-- snippet 43
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isoOfHomeo (L251-L254)
def isoOfHomeo {X Y : CompHausLike.{u} P} (f : X ≃ₜ Y) : X ≅ Y :=
(fullyFaithfulCompHausLikeToTop P).preimageIso (TopCat.isoOfHomeo f)

/-- Construct a homeomorphism from an isomorphism. -/
```

-- snippet 44
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isoEquivHomeo (L262-L266)
def isoEquivHomeo {X Y : CompHausLike.{u} P} : (X ≅ Y) ≃ (X ≃ₜ Y) where
  toFun := homeoOfIso
invFun := isoOfHomeo

/-- A constant map as a morphism in `CompHausLike` -/
```

-- snippet 45
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.fullyFaithfulCompHausLikeToTop (L187-L189)
def fullyFaithfulCompHausLikeToTop : (compHausLikeToTop P).FullyFaithful :=
fullyFaithfulInducedFunctor _
```

-- snippet 46
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.ofHom (L137-L138)
abbrev ofHom (f : C(X, Y)) : of P X ⟶ of P Y := ConcreteCategory.ofHom f
```

-- snippet 47
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isIso_of_bijective (L225-L238)
theorem isIso_of_bijective {X Y : CompHausLike.{u} P} (f : X ⟶ Y) (bij : Function.Bijective f) :
    IsIso f := by
let E := Equiv.ofBijective _ bij
  have hE : Continuous E.symm := by
    rw [continuous_iff_isClosed]
    intro S hS
    rw [← E.image_eq_preimage_symm]
    exact isClosedMap f S hS
  refine ⟨⟨ofHom _ ⟨E.symm, hE⟩, ?_, ?_⟩⟩
  · ext x
    apply E.symm_apply_apply
  · ext x
    apply E.apply_symm_apply
```

-- snippet 48
```lean
-- Mathlib.Topology.Category.Compactum.le_nhds_of_str_eq (L342-L345)
theorem le_nhds_of_str_eq {X : Compactum} (F : Ultrafilter X) (x : X) : X.str F = x → ↑F ≤ 𝓝 x :=
fun h => le_nhds_iff.mpr fun s hx hs => hs _ <| by rwa [h]

-- All the hard work above boils down to this `T2Space` instance.
```

-- snippet 49
```lean
-- Mathlib.Topology.Category.CompHausLike.EffectiveEpi.preregular (L64-L74)
theorem preregular [HasExplicitPullbacks P]
    (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) :
    Preregular (CompHausLike P) where
  exists_fac := by
intro X Y Z f π hπ
    refine ⟨pullback f π, pullback.fst f π, ⟨⟨effectiveEpiStruct _ ?_⟩⟩, pullback.snd f π,
      (pullback.condition _ _).symm⟩
    intro y
    obtain ⟨z, hz⟩ := hs π hπ (f y)
    exact ⟨⟨(y, z), hz.symm⟩, rfl⟩
```

-- snippet 50
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.finiteCoproduct (L63-L67)
def finiteCoproduct : CompHausLike P := CompHausLike.of P (Σ (a : α), X a)
/--
The inclusion of one of the factors into the explicit finite coproduct.
-/
```

-- snippet 51
```lean
-- Mathlib.Topology.Category.CompHausLike.SigmaComparison.sigmaComparison (L43-L46)
def sigmaComparison : X.obj ⟨(of P ((a : α) × σ a))⟩ ⟶ ((a : α) → X.obj ⟨of P (σ a)⟩) :=
fun x a ↦ X.map (ofHom _ ⟨Sigma.mk a, continuous_sigmaMk⟩).op x

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 52
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.HasExplicitPullback (L196-L203)
abbrev HasExplicitPullback := HasProp P { xy : X × Y | f xy.fst = g xy.snd }
variable [HasExplicitPullback f g] -- (hP : P (TopCat.of { xy : X × Y | f xy.fst = g xy.snd }))

/--
The pullback of two morphisms `f,g` in `CompHaus`, constructed explicitly as the set of
pairs `(x,y)` such that `f x = g y`, with the topology induced by the product.
-/
```

-- snippet 53
```lean
-- Mathlib.Topology.Category.CompHausLike.EffectiveEpi.precoherent (L75-L81)
theorem precoherent [HasExplicitPullbacks P] [HasExplicitFiniteCoproducts.{0} P]
    (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) :
    Precoherent (CompHausLike P) := by
have : Preregular (CompHausLike P) := preregular hs
  infer_instance

end CompHausLike
```

-- snippet 54
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.finitaryExtensive (L354-L366)
theorem finitaryExtensive (hP' : ∀ ⦃X Y B : CompHausLike.{u} P⦄ (f : X ⟶ B) (g : Y ⟶ B)
    (_ : IsOpenEmbedding f), HasExplicitPullback f g) :
      FinitaryExtensive (CompHausLike P) :=
have := hasPullbacksOfInclusions hP'
  finitaryExtensive_of_preserves_and_reflects (compHausLikeToTop P)

end FiniteCoproducts

section Terminal

variable {P : TopCat.{u} → Prop}

/-- A one-element space is terminal in `CompHaus` -/
```

-- snippet 55
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.stoneCechObj (L79-L112)
def stoneCechObj (X : TopCat) : CompHaus :=
CompHaus.of (StoneCech X)

set_option backward.isDefEq.respectTransparency false in
/-- (Implementation) The bijection of homsets to establish the reflective adjunction of compact
Hausdorff spaces in topological spaces.
-/
noncomputable def stoneCechEquivalence (X : TopCat.{u}) (Y : CompHaus.{u}) :
    (stoneCechObj X ⟶ Y) ≃ (X ⟶ compHausToTop.obj Y) where
  toFun f := TopCat.ofHom
    { toFun := f ∘ stoneCechUnit
      continuous_toFun := f.hom.hom.2.comp (@continuous_stoneCechUnit X _) }
  invFun f := CompHausLike.ofHom _
    { toFun := stoneCechExtend f.hom.2
      continuous_toFun := continuous_stoneCechExtend f.hom.2 }
  left_inv := by
    rintro ⟨f : StoneCech X ⟶ Y, hf : Continuous f⟩
    ext x
    refine congr_fun ?_ x
    apply Continuous.ext_on denseRange_stoneCechUnit (continuous_stoneCechExtend _) hf
    · rintro _ ⟨y, rfl⟩
      apply congr_fun (stoneCechExtend_extends (hf.comp _)) y
      apply continuous_stoneCechUnit
  right_inv := by
    rintro ⟨f : (X : Type _) ⟶ Y, hf : Continuous f⟩
    ext
    exact congr_fun (stoneCechExtend_extends hf) _

/-- The Stone-Cech compactification functor from topological spaces to compact Hausdorff spaces,
left adjoint to the inclusion functor.
-/
noncomputable def topToCompHaus : TopCat.{u} ⥤ CompHaus.{u} :=
  Adjunction.leftAdjointOfEquiv stoneCechEquivalence.{u} fun _ _ _ _ _ => rfl
```

-- snippet 56
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.coe_comp (L127-L130)
theorem coe_comp {X Y Z : CompHausLike P} (f : X ⟶ Y) (g : Y ⟶ Z) :
    (f ≫ g : X → Z) = g ∘ f :=
rfl
```

-- snippet 57
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.fullyFaithfulCompactlyGeneratedToTop (L77-L79)
def fullyFaithfulCompactlyGeneratedToTop : compactlyGeneratedToTop.{u, w}.FullyFaithful :=
fullyFaithfulInducedFunctor _
```

-- snippet 58
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.epi_iff_surjective (L181-L216)
theorem epi_iff_surjective {X Y : CompHaus.{u}} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by
constructor
  · dsimp [Function.Surjective]
    contrapose!
    rintro ⟨y, hy⟩ hf
    let C := Set.range f
    have hC : IsClosed C := (isCompact_range f.hom.hom.continuous).isClosed
    let D := ({y} : Set Y)
    have hD : IsClosed D := isClosed_singleton
    have hCD : Disjoint C D := by
      rw [Set.disjoint_singleton_right]
      rintro ⟨y', hy'⟩
      exact hy y' hy'
    obtain ⟨φ, hφ0, hφ1, hφ01⟩ := exists_continuous_zero_one_of_isClosed hC hD hCD
    haveI : CompactSpace (ULift.{u} <| Set.Icc (0 : ℝ) 1) := Homeomorph.ulift.symm.compactSpace
    haveI : T2Space (ULift.{u} <| Set.Icc (0 : ℝ) 1) := Homeomorph.ulift.symm.t2Space
    let Z := of (ULift.{u} <| Set.Icc (0 : ℝ) 1)
    let g : Y ⟶ Z := ofHom _
      ⟨fun y' => ⟨⟨φ y', hφ01 y'⟩⟩,
        continuous_uliftUp.comp (φ.continuous.subtype_mk fun y' => hφ01 y')⟩
    let h : Y ⟶ Z := ofHom _
      ⟨fun _ => ⟨⟨0, Set.left_mem_Icc.mpr zero_le_one⟩⟩, continuous_const⟩
    have H : h = g := by
      rw [← cancel_epi f]
      ext x : 4
      simp [g, h, Z, hφ0 (Set.mem_range_self x)]
    apply_fun fun e => (e y).down.1 at H
    dsimp [g, h, Z] at H
    simp only [hφ1 (Set.mem_singleton y), Pi.one_apply] at H
    exact zero_ne_one H
  · rw [← CategoryTheory.epi_iff_surjective]
    apply (forget CompHaus).epi_of_epi_map

end CompHaus

/-- Every `CompHausLike` admits a functor to `CompHaus`. -/
```

-- snippet 59
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.coproductIsColimit (L86-L94)
def coproductIsColimit : IsColimit (coproductCocone X Y) := by
refine BinaryCofan.isColimitMk (fun s ↦ ofHom _ { toFun := Sum.elim s.inl s.inr })
    (by rfl_cat) (by rfl_cat) fun _ _ h₁ h₂ ↦ ?_
  ext ⟨⟩
  exacts [ConcreteCategory.congr_hom h₁ _, ConcreteCategory.congr_hom h₂ _]

end Coproduct

end CompHausLike
```

-- snippet 60
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.HasExplicitFiniteCoproduct (L55-L62)
abbrev HasExplicitFiniteCoproduct := HasProp P (Σ (a : α), X a)
variable [HasExplicitFiniteCoproduct X]

/--
The coproduct of a finite family of objects in `CompHaus`, constructed as the disjoint
union with its usual topology.
-/
```

-- snippet 61
```lean
-- Mathlib.Topology.Category.CompHaus.Projective.projective_ultrafilter (L41-L57)
instance projective_ultrafilter (X : Type*) : Projective (of <| Ultrafilter X) where
  factors {Y Z} f g hg := by
rw [epi_iff_surjective] at hg
    obtain ⟨g', hg'⟩ := hg.hasRightInverse
    let t : X → Y := g' ∘ f ∘ (pure : X → Ultrafilter X)
    let h : Ultrafilter X → Y := Ultrafilter.extend t
    have hh : Continuous h := continuous_ultrafilter_extend _
    use CompHausLike.ofHom _ ⟨h, hh⟩
    apply ConcreteCategory.coe_ext
    have : g.hom ∘ g' = id := hg'.comp_eq_id
    convert denseRange_pure.equalizer (g.hom.hom.continuous.comp hh) f.hom.hom.continuous _
    -- This used to be `rw`, but we need `rw; rfl` after https://github.com/leanprover/lean4/pull/2644
    rw [comp_assoc, ultrafilter_extend_extends, ← comp_assoc, this, id_comp]
    rfl

/-- For any compact Hausdorff space `X`,
  the natural map `Ultrafilter X → X` is a projective presentation. -/
```

-- snippet 62
```lean
-- Mathlib.Topology.Category.Compactum.str (L124-L127)
def str (X : Compactum) : Ultrafilter X → X :=
X.a

/-- The monadic join. -/
```

-- snippet 63
```lean
-- Mathlib.Topology.Category.CompHausLike.SigmaComparison.isIsoSigmaComparison (L69-L73)
instance isIsoSigmaComparison : IsIso <| sigmaComparison X σ := by
rw [sigmaComparison_eq_comp_isos]
  infer_instance

end CompHausLike
```

-- snippet 64
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.category (L92-L94)
instance category : Category (CompHausLike P) :=
inferInstanceAs (Category (InducedCategory _ toTop))
```

-- snippet 65
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.compHausLikeToTop (L178-L182)
def compHausLikeToTop : CompHausLike.{u} P ⥤ TopCat.{u} :=
inducedFunctor _
-- The `Full, Faithful` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
```

-- snippet 66
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.topToCompHaus_obj (L113-L124)
theorem topToCompHaus_obj (X : TopCat) : ↥(topToCompHaus.obj X) = StoneCech X :=
rfl

/-- The category of compact Hausdorff spaces is reflective in the category of topological spaces.
-/
noncomputable instance compHausToTop.reflective : Reflective compHausToTop where
  L := topToCompHaus
  adj := Adjunction.adjunctionOfEquivLeft _ _

noncomputable instance compHausToTop.createsLimits : CreatesLimits compHausToTop :=
  monadicCreatesLimits _
```

-- snippet 67
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.coproductCocone (L79-L85)
def coproductCocone : BinaryCofan X Y := BinaryCofan.mk (P := CompHausLike.of P (X ⊕ Y))
(ofHom _ { toFun := Sum.inl }) (ofHom _ { toFun := Sum.inr })

/--
When the predicate `P` is preserved under taking type-theoretic sums, that sum is a
category-theoretic coproduct in `CompHausLike P`.
-/
```

-- snippet 68
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.const_comp (L271-L275)
lemma const_comp {P : TopCat.{u} → Prop} {S T U : CompHausLike.{u} P}
    (s : S) (g : S ⟶ U) : T.const s ≫ g = T.const (g s) :=
rfl

end CompHausLike
```

-- snippet 69
```lean
-- Mathlib.Topology.Category.Compactum.forget (L91-L93)
def forget : Compactum ⥤ Type* :=
Monad.forget _
```

-- snippet 70
```lean
-- Mathlib.Topology.Category.Compactum.adj (L105-L107)
def adj : free ⊣ forget :=
Monad.adj _
```

-- snippet 71
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.of (L58-L61)
abbrev of : CompactlyGenerated.{u, w} where
  toTop := TopCat.of X
is_compactly_generated := ‹_›
```

-- snippet 72
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.limitConeIsLimit (L171-L180)
def limitConeIsLimit {J : Type v} [SmallCategory J] (F : J ⥤ CompHaus.{max v u}) :
    Limits.IsLimit.{v} (limitCone.{v, u} F) :=
letI FF : J ⥤ TopCat := F ⋙ compHausToTop
  { lift := fun S => InducedCategory.homMk
      ((TopCat.limitConeIsLimit FF).lift (compHausToTop.mapCone S))
    uniq := fun S m hm => InducedCategory.hom_ext
      ((TopCat.limitConeIsLimit FF).uniq (compHausToTop.mapCone S) _ (fun j ↦ by
        simp [← hm]
        rfl)) }
```

-- snippet 73
```lean
-- Mathlib.Topology.Category.Compactum.isClosed_iff (L162-L175)
theorem isClosed_iff {X : Compactum} (S : Set X) :
    IsClosed S ↔ ∀ F : Ultrafilter X, S ∈ F → X.str F ∈ S := by
rw [← isOpen_compl_iff]
  constructor
  · intro cond F h
    by_contra c
    specialize cond F c
    rw [compl_mem_iff_notMem] at cond
    contradiction
  · intro h1 F h2
    specialize h1 F
    rcases F.mem_or_compl_mem S with h | h
    exacts [absurd (h1 h) h2, h]
```

-- snippet 74
```lean
-- Mathlib.Topology.Category.Compactum.str_incl (L136-L140)
theorem str_incl (X : Compactum) (x : X) : X.str (X.incl x) = x := by
change ((β).η.app _ ≫ X.a) _ = _
  rw [Monad.Algebra.unit]
  rfl
```

-- snippet 75
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.forget_reflectsIsomorphisms (L239-L249)
instance forget_reflectsIsomorphisms :
    (forget (CompHausLike.{u} P)).ReflectsIsomorphisms :=
⟨by intro A B f hf; rw [isIso_iff_bijective] at hf; exact isIso_of_bijective _ hf⟩

/-- Any continuous bijection of compact Hausdorff spaces induces an isomorphism. -/
noncomputable def isoOfBijective {X Y : CompHausLike.{u} P} (f : X ⟶ Y)
    (bij : Function.Bijective f) : X ≅ Y :=
  letI := isIso_of_bijective _ bij
  asIso f

/-- Construct an isomorphism from a homeomorphism. -/
```

-- snippet 76
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.limitCone (L135-L170)
def limitCone {J : Type v} [SmallCategory J] (F : J ⥤ CompHaus.{max v u}) : Limits.Cone F :=
letI FF : J ⥤ TopCat := F ⋙ compHausToTop
  { pt := {
      toTop := (TopCat.limitCone FF).pt
      is_compact := by
        change CompactSpace { u : ∀ j, F.obj j | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j }
        rw [← isCompact_iff_compactSpace]
        apply IsClosed.isCompact
        have :
          { u : ∀ j, F.obj j | ∀ {i j : J} (f : i ⟶ j), F.map f (u i) = u j } =
            ⋂ (i : J) (j : J) (f : i ⟶ j), { u | F.map f (u i) = u j } := by
          ext1
          simp only [Set.mem_iInter, Set.mem_setOf_eq]
        rw [this]
        apply isClosed_iInter
        intro i
        apply isClosed_iInter
        intro j
        apply isClosed_iInter
        intro f
        apply isClosed_eq
        · exact ((F.map f).hom.hom.continuous).comp (continuous_apply i)
        · exact continuous_apply j
      is_hausdorff :=
        show T2Space { u : ∀ j, F.obj j | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j } from
          inferInstance
      prop := trivial }
    π := {
      app := fun j => InducedCategory.homMk ((TopCat.limitCone FF).π.app j)
      naturality := by
        intro _ _ f
        ext ⟨x, hx⟩
        simp only [Functor.const_obj_map]
        exact (hx f).symm } }

/-- The limit cone `CompHaus.limitCone F` is indeed a limit cone. -/
```

-- snippet 77
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.productIsLimit (L48-L61)
def productIsLimit : IsLimit (productCone X Y) := by
refine BinaryFan.isLimitMk (fun s ↦ ofHom _ { toFun x := (s.fst x, s.snd x) })
    (by rfl_cat) (by rfl_cat) fun _ _ h₁ h₂ ↦ ?_
  ext x
  exacts [ConcreteCategory.congr_hom h₁ _, ConcreteCategory.congr_hom h₂ _]

/--
When the predicate `P` is preserved under taking type-theoretic products and `PUnit` satisfies it,
then `CompHausLike P` is a cartesian monoidal category.

This could be an instance but that causes some slowness issues with typeclass search, therefore we
keep it as a def and turn it on as an instance for the explicit examples of `CompHausLike` as
needed.
-/
```

-- snippet 78
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.concreteCategory (L95-L97)
instance concreteCategory : ConcreteCategory (CompHausLike P) (C(·, ·)) :=
InducedCategory.concreteCategory toTop
```

-- snippet 79
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.mono_iff_injective (L209-L220)
theorem mono_iff_injective {X Y : CompHausLike.{u} P} (f : X ⟶ Y) :
    Mono f ↔ Function.Injective f := by
constructor
  · intro hf x₁ x₂ h
    let g₁ : X ⟶ X := ofHom _ ⟨fun _ => x₁, continuous_const⟩
    let g₂ : X ⟶ X := ofHom _ ⟨fun _ => x₂, continuous_const⟩
    have : g₁ ≫ f = g₂ ≫ f := by ext; exact h
    exact CategoryTheory.congr_fun ((cancel_mono _).mp this) x₁
  · rw [← CategoryTheory.mono_iff_injective]
    apply (forget (CompHausLike P)).mono_of_mono_map

/-- Any continuous function on compact Hausdorff spaces is a closed map. -/
```

-- snippet 80
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.isoEquivHomeo (L109-L113)
def isoEquivHomeo {X Y : CompactlyGenerated.{u, w}} : (X ≅ Y) ≃ (X ≃ₜ Y) where
  toFun := homeoOfIso
invFun := isoOfHomeo

end CompactlyGenerated
```

-- snippet 81
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.pullback (L204-L213)
def pullback : CompHausLike P :=
letI set := { xy : X × Y | f xy.fst = g xy.snd }
  haveI : CompactSpace set :=
    isCompact_iff_compactSpace.mp (isClosed_eq (f.hom.hom.continuous.comp continuous_fst)
      (g.hom.hom.continuous.comp continuous_snd)).isCompact
  CompHausLike.of P set

/--
The projection from the pullback to the first component.
-/
```

-- snippet 82
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.cartesianMonoidalCategory (L63-L78)
def cartesianMonoidalCategory [∀ (X Y : CompHausLike.{u} P), HasProp P (X × Y)]
    [HasProp P PUnit.{u + 1}] : CartesianMonoidalCategory (CompHausLike.{u} P) :=
.ofChosenFiniteProducts
    ⟨_, CompHausLike.isTerminalPUnit⟩
    (fun X Y ↦ ⟨productCone X Y, productIsLimit X Y⟩)

end Product

section Coproduct

variable [HasProp P (X ⊕ Y)]

/--
Explicit binary cofan in `CompHausLike P`, given that the predicate `P` is preserved under taking
type-theoretic sums.
-/
```

-- snippet 83
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.of (L67-L71)
abbrev of : CompHaus := CompHausLike.of _ X
end CompHaus

/-- The fully faithful embedding of `CompHaus` in `TopCat`. -/
```

-- snippet 84
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.CompHaus (L44-L47)
abbrev CompHaus := CompHausLike (fun _ ↦ True)
namespace CompHaus
```

-- snippet 85
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.compactlyGeneratedToTop (L73-L76)
def compactlyGeneratedToTop : CompactlyGenerated.{u, w} ⥤ TopCat.{w} :=
inducedFunctor _

/-- `compactlyGeneratedToTop` is fully faithful. -/
```

-- snippet 86
```lean
-- Mathlib.Topology.Category.CompHaus.EffectiveEpi.effectiveEpi_tfae (L39-L50)
theorem effectiveEpi_tfae
    {B X : CompHaus.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
tfae_have 1 → 2 := fun _ ↦ inferInstance
  tfae_have 2 ↔ 3 := epi_iff_surjective π
  tfae_have 3 → 1 := fun hπ ↦ ⟨⟨effectiveEpiStruct π hπ⟩⟩
  tfae_finish
```

-- snippet 87
```lean
-- Mathlib.Topology.Category.Compactum.isClosed_cl (L267-L271)
theorem isClosed_cl {X : Compactum} (A : Set X) : IsClosed (cl A) := by
rw [isClosed_iff]
  intro F hF
  exact cl_cl _ ⟨F, hF, rfl⟩
```

-- snippet 88
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.const (L267-L270)
def const {P : TopCat.{u} → Prop}
    (T : CompHausLike.{u} P) {S : CompHausLike.{u} P} (s : S) : T ⟶ S :=
ofHom _ (ContinuousMap.const _ s)
```

-- snippet 89
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.epi_of_surjective (L204-L208)
theorem epi_of_surjective {X Y : CompHausLike.{u} P} (f : X ⟶ Y) (hf : Function.Surjective f) :
    Epi f := by
rw [← CategoryTheory.epi_iff_surjective] at hf
  exact (forget (CompHausLike P)).epi_of_epi_map hf
```

-- snippet 90
```lean
-- Mathlib.Topology.Category.Compactum.Compactum (L85-L90)
def Compactum :=
Monad.Algebra β deriving Category, Inhabited

namespace Compactum

/-- The forgetful functor to Type* -/
```

-- snippet 91
```lean
-- Mathlib.Topology.Category.CompHausLike.SigmaComparison.sigmaComparison_eq_comp_isos (L47-L68)
theorem sigmaComparison_eq_comp_isos : sigmaComparison X σ =
    (X.mapIso (opCoproductIsoProduct'
      (finiteCoproduct.isColimit.{u, u} (fun a ↦ of P (σ a)))
      (productIsProduct fun x ↦ Opposite.op (of P (σ x))))).hom ≫
    (PreservesProduct.iso X fun a ↦ ⟨of P (σ a)⟩).hom ≫
    (Types.productIso.{u, max u w} fun a ↦ X.obj ⟨of P (σ a)⟩).hom := by
ext x a
  simp only [Cofan.mk_pt, Fan.mk_pt, Functor.mapIso_hom,
    PreservesProduct.iso_hom, types_comp_apply, Types.productIso_hom_comp_eval_apply]
  have := congrFun (piComparison_comp_π X (fun a ↦ ⟨of P (σ a)⟩) a)
  simp only [types_comp_apply] at this
  rw [this, ← FunctorToTypes.map_comp_apply]
  simp only [sigmaComparison]
  apply congrFun
  congr 2
  rw [← opCoproductIsoProduct_inv_comp_ι]
  simp only [Opposite.unop_op, unop_comp, Quiver.Hom.unop_op, Category.assoc]
  simp only [opCoproductIsoProduct, ← unop_comp, opCoproductIsoProduct'_comp_self]
  erw [IsColimit.fac]
  rfl

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 92
```lean
-- Mathlib.Topology.Category.CompHaus.EffectiveEpi.effectiveEpiFamily_of_jointly_surjective (L102-L109)
theorem effectiveEpiFamily_of_jointly_surjective
    {α : Type} [Finite α] {B : CompHaus.{u}}
    (X : α → CompHaus.{u}) (π : (a : α) → (X a ⟶ B))
    (surj : ∀ b : B, ∃ (a : α) (x : X a), π a x = b) :
    EffectiveEpiFamily X π :=
((effectiveEpiFamily_tfae X π).out 2 0).mp surj

end CompHaus
```

-- snippet 93
```lean
-- Mathlib.Topology.Category.Compactum.join (L128-L131)
def join (X : Compactum) : Ultrafilter (Ultrafilter X) → Ultrafilter X :=
(β).μ.app _

/-- The inclusion of `X` into `Ultrafilter X`. -/
```

-- snippet 94
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.hasForget₂ (L98-L106)
instance hasForget₂ : HasForget₂ (CompHausLike P) TopCat :=
InducedCategory.hasForget₂ _

variable (X : Type u) [TopologicalSpace X] [CompactSpace X] [T2Space X]

/-- This wraps the predicate `P : TopCat → Prop` in a typeclass. -/
class HasProp : Prop where
  hasProp : P (TopCat.of X)
```

-- snippet 95
```lean
-- Mathlib.Topology.Category.CompHaus.Limits.isTerminalPUnit (L35-L43)
abbrev isTerminalPUnit : IsTerminal (CompHaus.of PUnit.{u + 1}) := CompHausLike.isTerminalPUnit
/-- The isomorphism from an arbitrary terminal object of `CompHaus` to a one-element space. -/
noncomputable def terminalIsoPUnit : ⊤_ CompHaus.{u} ≅ CompHaus.of PUnit :=
  terminalIsTerminal.uniqueUpToIso CompHaus.isTerminalPUnit

noncomputable example : PreservesFiniteCoproducts compHausToTop := inferInstance

end CompHaus
```

-- snippet 96
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.coe_of (L120-L121)
theorem coe_of : (CompHausLike.of P X : Type _) = X := rfl
```

-- snippet 97
```lean
-- Mathlib.Topology.Category.CompHaus.Frm.topCatOpToFrm (L22-L26)
def topCatOpToFrm : TopCatᵒᵖ ⥤ Frm where
  obj X := Frm.of (Opens (unop X : TopCat))
map f := Frm.ofHom <| Opens.comap <| (Quiver.Hom.unop f).hom

-- Note, `CompHaus` is too strong. We only need `T0Space`.
```

-- snippet 98
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.isTerminalPUnit (L367-L375)
def isTerminalPUnit [HasProp P PUnit.{u + 1}] :
    IsTerminal (CompHausLike.of P PUnit.{u + 1}) :=
haveI : ∀ X, Unique (X ⟶ CompHausLike.of P PUnit.{u + 1}) := fun _ ↦
    ⟨⟨ofHom _ ⟨fun _ ↦ PUnit.unit, continuous_const⟩⟩, fun _ ↦ rfl⟩
  Limits.IsTerminal.ofUnique _

end Terminal

end CompHausLike
```

-- snippet 99
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.compHausToTop (L72-L77)
abbrev compHausToTop : CompHaus.{u} ⥤ TopCat.{u} :=
CompHausLike.compHausLikeToTop _

/-- (Implementation) The object part of the compactification functor from topological spaces to
compact Hausdorff spaces.
-/
```

-- snippet 100
```lean
-- Mathlib.Topology.Category.Compactum.join_distrib (L149-L154)
theorem join_distrib (X : Compactum) (uux : Ultrafilter (Ultrafilter X)) :
    X.str (X.join uux) = X.str (map X.str uux) := by
change ((β).μ.app _ ≫ X.a) _ = _
  rw [Monad.Algebra.assoc]
  rfl
```

-- snippet 101
```lean
-- Mathlib.Topology.Category.CompHaus.EffectiveEpi.effectiveEpiFamily_tfae (L59-L101)
theorem effectiveEpiFamily_tfae
    {α : Type} [Finite α] {B : CompHaus.{u}}
    (X : α → CompHaus.{u}) (π : (a : α) → (X a ⟶ B)) :
    TFAE
    [ EffectiveEpiFamily X π
    , Epi (Sigma.desc π)
    , ∀ b : B, ∃ (a : α) (x : X a), π a x = b
    ] := by
tfae_have 2 → 1
  | _ => by
    simpa [← effectiveEpi_desc_iff_effectiveEpiFamily, (effectiveEpi_tfae (Sigma.desc π)).out 0 1]
  tfae_have 1 → 2
  | _ => inferInstance
  tfae_have 3 → 2
  | e => by
    rw [epi_iff_surjective]
    intro b
    obtain ⟨t, x, h⟩ := e b
    refine ⟨Sigma.ι X t x, ?_⟩
    change (Sigma.ι X t ≫ Sigma.desc π) x = _
    simpa using h
  tfae_have 2 → 3
  | e => by
    rw [epi_iff_surjective] at e
    let i : ∐ X ≅ finiteCoproduct X :=
      (colimit.isColimit _).coconePointUniqueUpToIso (finiteCoproduct.isColimit _)
    intro b
    obtain ⟨t, rfl⟩ := e b
    let q := i.hom t
    refine ⟨q.1,q.2,?_⟩
    have : t = i.inv (i.hom t) := show t = (i.hom ≫ i.inv) t by simp only [i.hom_inv_id]; rfl
    rw [this]
    change _ = (i.inv ≫ Sigma.desc π) (i.hom t)
    suffices i.inv ≫ Sigma.desc π = finiteCoproduct.desc X π by
      rw [this]; rfl
    rw [Iso.inv_comp_eq]
    apply colimit.hom_ext
    rintro ⟨a⟩
    simp only [i, Discrete.functor_obj, colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app,
      colimit.comp_coconePointUniqueUpToIso_hom_assoc]
    ext; rfl
  tfae_finish
```

-- snippet 102
```lean
-- Mathlib.Topology.Category.Compactum.lim_eq_str (L352-L357)
theorem lim_eq_str {X : Compactum} (F : Ultrafilter X) : F.lim = X.str F := by
rw [Ultrafilter.lim_eq_iff_le_nhds, le_nhds_iff]
  tauto

set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
```

-- snippet 103
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.fullyFaithfulToCompHausLike (L165-L167)
def fullyFaithfulToCompHausLike : (toCompHausLike h).FullyFaithful where
  preimage f := ConcreteCategory.ofHom f.hom.hom
```

-- snippet 104
```lean
-- Mathlib.Topology.Category.CompHaus.Projective.projectivePresentation (L58-L65)
def projectivePresentation (X : CompHaus) : ProjectivePresentation X where
  p := of <| Ultrafilter X
f := CompHausLike.ofHom _ ⟨_, continuous_ultrafilter_extend id⟩
  projective := CompHaus.projective_ultrafilter X
  epi :=
    ConcreteCategory.epi_of_surjective _ fun x =>
      ⟨(pure x : Ultrafilter X), congr_fun (ultrafilter_extend_extends (𝟙 X)) x⟩
```

-- snippet 105
```lean
-- Mathlib.Topology.Category.CompHaus.Frm.CompHausOpToFrame (L27-L30)
instance CompHausOpToFrame.faithful : (compHausToTop.op ⋙ topCatOpToFrm.{u}).Faithful :=
⟨fun {X _ _ _} h =>  Quiver.Hom.unop_inj <| ConcreteCategory.ext <|
    Opens.comap_injective (β := (unop X).toTop) <| FrameHom.ext <|
      CategoryTheory.congr_fun h⟩
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.Category.Profinite.Nobeling.Successor).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
def Linear_CC'₀ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C0 (L95-L97)
def C0 := C ∩ {f | f (term I ho) = false}
/-- The subset of `C` consisting of those elements whose `o`-th entry is `true`. -/
```

-- snippet 2
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C1 (L98-L100)
def C1 := C ∩ {f | f (term I ho) = true}
include hC in
```

-- snippet 3
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.isClosed_C0 (L101-L106)
theorem isClosed_C0 : IsClosed (C0 C ho) := by
refine hC.inter ?_
  have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho)
  exact IsClosed.preimage h (t := {false}) (isClosed_discrete _)

include hC in
```

-- snippet 4
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.isClosed_C1 (L107-L111)
theorem isClosed_C1 : IsClosed (C1 C ho) := by
refine hC.inter ?_
  have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho)
  exact IsClosed.preimage h (t := {true}) (isClosed_discrete _)
```

-- snippet 5
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.contained_C1 (L112-L114)
theorem contained_C1 : contained (π (C1 C ho) (ord I · < o)) o :=
contained_proj _ _
```

-- snippet 6
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.union_C0C1_eq (L115-L123)
theorem union_C0C1_eq : (C0 C ho) ∪ (C1 C ho) = C := by
ext x
  simp only [C0, C1, Set.mem_union, Set.mem_inter_iff, Set.mem_setOf_eq,
    ← and_or_left, and_iff_left_iff_imp, Bool.dichotomy (x (term I ho)), implies_true]

/--
The intersection of `C0` and the projection of `C1`. We will apply the inductive hypothesis to
this set.
-/
```

-- snippet 7
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C' (L124-L126)
def C' := C0 C ho ∩ π (C1 C ho) (ord I · < o)
include hC in
```

-- snippet 8
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.isClosed_C' (L127-L129)
theorem isClosed_C' : IsClosed (C' C ho) :=
IsClosed.inter (isClosed_C0 _ hC _) (isClosed_proj _ _ (isClosed_C1 _ hC _))
```

-- snippet 9
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.contained_C' (L130-L135)
theorem contained_C' : contained (C' C ho) o := fun f hf i hi ↦ contained_C1 C ho f hf.2 i hi
variable (o)

/-- Swapping the `o`-th coordinate to `true`. -/
noncomputable
```

-- snippet 10
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.SwapTrue (L136-L138)
def SwapTrue : (I → Bool) → I → Bool :=
fun f i ↦ if ord I i = o then true else f i
```

-- snippet 11
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.continuous_swapTrue (L139-L149)
theorem continuous_swapTrue : Continuous (SwapTrue o : (I → Bool) → I → Bool) := by
dsimp +unfoldPartialApp [SwapTrue]
  apply continuous_pi
  intro i
  apply Continuous.comp'
  · apply continuous_bot
  · apply continuous_apply

variable {o}

include hsC in
```

-- snippet 12
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.swapTrue_mem_C1 (L150-L165)
theorem swapTrue_mem_C1 (f : π (C1 C ho) (ord I · < o)) :
    SwapTrue o f.val ∈ C1 C ho := by
obtain ⟨f, g, hg, rfl⟩ := f
  convert hg
  dsimp +unfoldPartialApp [SwapTrue]
  ext i
  split_ifs with h
  · rw [ord_term ho] at h
    simpa only [← h] using hg.2.symm
  · simp only [Proj, ite_eq_left_iff, not_lt, @eq_comm _ false, ← Bool.not_eq_true]
    specialize hsC g hg.1 i
    intro h'
    contrapose! hsC
    exact ⟨hsC, Order.succ_le_of_lt (h'.lt_of_ne' h)⟩

/-- The first way to map `C'` into `C`. -/
```

-- snippet 13
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC'₀ (L166-L169)
def CC'₀ : C' C ho → C := fun g ↦ ⟨g.val,g.prop.1.1⟩
/-- The second way to map `C'` into `C`. -/
noncomputable
```

-- snippet 14
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC'₁ (L170-L172)
def CC'₁ : C' C ho → C :=
fun g ↦ ⟨SwapTrue o g.val, (swapTrue_mem_C1 C hsC ho ⟨g.val,g.prop.2⟩).1⟩
```

-- snippet 15
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.continuous_CC'₀ (L173-L174)
theorem continuous_CC'₀ : Continuous (CC'₀ C ho) := Continuous.subtype_mk continuous_subtype_val _
```

-- snippet 16
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.continuous_CC'₁ (L175-L179)
theorem continuous_CC'₁ : Continuous (CC'₁ C hsC ho) :=
Continuous.subtype_mk (Continuous.comp (continuous_swapTrue o) continuous_subtype_val) _

/-- The `ℤ`-linear map induced by precomposing with `CC'₀` -/
noncomputable
```

-- snippet 17
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.Linear_CC'₁ (L185-L189)
def Linear_CC'₁ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ :=
LocallyConstant.comapₗ ℤ ⟨(CC'₁ C hsC ho), (continuous_CC'₁ C hsC ho)⟩

/-- The difference between `Linear_CC'₁` and `Linear_CC'₀`. -/
noncomputable
```

-- snippet 18
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.Linear_CC' (L190-L192)
def Linear_CC' : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ :=
Linear_CC'₁ C hsC ho - Linear_CC'₀ C ho
```

-- snippet 19
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC_comp_zero (L193-L206)
theorem CC_comp_zero : ∀ y, (Linear_CC' C hsC ho) ((πs C o) y) = 0 := by
intro y
  ext x
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁, LocallyConstant.sub_apply]
  simp only [sub_eq_zero]
  congr 1
  ext i
  dsimp [CC'₀, CC'₁, ProjRestrict, Proj]
  apply if_ctx_congr Iff.rfl _ (fun _ ↦ rfl)
  simp only [SwapTrue, ite_eq_right_iff]
  intro h₁ h₂
  exact (h₁.ne h₂).elim

include hsC in
```

-- snippet 20
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C0_projOrd (L207-L220)
theorem C0_projOrd {x : I → Bool} (hx : x ∈ C0 C ho) : Proj (ord I · < o) x = x := by
ext i
  simp only [Proj, ite_eq_left_iff, not_lt]
  intro hi
  rcases hi.lt_or_eq with hi | hi
  · specialize hsC x hx.1 i
    rw [← not_imp_not] at hsC
    simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC
    exact (hsC hi).symm
  · simp only [C0, Set.mem_inter_iff, Set.mem_setOf_eq] at hx
    rw [eq_comm, ord_term ho] at hi
    rw [← hx.2, hi]

include hsC in
```

-- snippet 21
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.C1_projOrd (L221-L236)
theorem C1_projOrd {x : I → Bool} (hx : x ∈ C1 C ho) : SwapTrue o (Proj (ord I · < o) x) = x := by
ext i
  dsimp [SwapTrue, Proj]
  split_ifs with hi h
  · rw [ord_term ho] at hi
    rw [← hx.2, hi]
  · rfl
  · simp only [not_lt] at h
    have h' : o < ord I i := lt_of_le_of_ne h (Ne.symm hi)
    specialize hsC x hx.1 i
    rw [← not_imp_not] at hsC
    simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC
    exact (hsC h').symm

include hC in
open scoped Classical in
```

-- snippet 22
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.CC_exact (L237-L271)
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap ⟨C₀C, h₀⟩) (f.comap ⟨C₁C, h₁⟩) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
  · ext ⟨x, hx⟩
    rw [← union_C0C1_eq C ho] at hx
    rcases hx with hx₀ | hx₁
    · have hx₀' : ProjRestrict C (ord I · < o) ⟨x, hx⟩ = x := by
        simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using C0_projOrd C hsC ho hx₀
      simp only [C₀C, πs_apply_apply, hx₀', hx₀, LocallyConstant.piecewise'_apply_left,
        LocallyConstant.coe_comap, ContinuousMap.coe_mk, Function.comp_apply]
    · have hx₁' : (ProjRestrict C (ord I · < o) ⟨x, hx⟩).val ∈ π (C1 C ho) (ord I · < o) := by
        simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using ⟨x, hx₁, rfl⟩
      simp only [C₁C, πs_apply_apply, LocallyConstant.coe_comap,
        Function.comp_apply, hx₁', LocallyConstant.piecewise'_apply_right]
      congr
      simp only [ContinuousMap.coe_mk, Subtype.mk.injEq]
      exact C1_projOrd C hsC ho hx₁

variable (o) in
```

-- snippet 23
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.succ_mono (L272-L276)
theorem succ_mono : CategoryTheory.Mono (ModuleCat.ofHom (πs C o)) := by
rw [ModuleCat.mono_iff_injective]
  exact injective_πs _ _

include hC in
```

-- snippet 24
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.succ_exact (L277-L291)
theorem succ_exact :
    (ShortComplex.mk (ModuleCat.ofHom (πs C o)) (ModuleCat.ofHom (Linear_CC' C hsC ho))
    (by ext : 2; apply CC_comp_zero)).Exact := by
rw [ShortComplex.moduleCat_exact_iff]
  intro f
  exact CC_exact C hC hsC ho

end ExactSequence

namespace GoodProducts

/--
The `GoodProducts` in `C` that contain `o` (they necessarily start with `o`, see
`GoodProducts.head!_eq_o_of_maxProducts`)
-/
```

-- snippet 25
```lean
-- Mathlib.Topology.Category.Profinite.Nobeling.Successor.MaxProducts (L292-L294)
def MaxProducts : Set (Products I) := {l | l.isGood C ∧ term I ho ∈ l.val}
include hsC in
```

-- snippet 26
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isClosedMap (L221-L224)
theorem isClosedMap {X Y : CompHausLike.{u} P} (f : X ⟶ Y) : IsClosedMap f := fun _ hC =>
(hC.isCompact.image f.hom.hom.continuous).isClosed

/-- Any continuous bijection of compact Hausdorff spaces is an isomorphism. -/
```

-- snippet 27
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.Sigma (L161-L170)
lemma Sigma.isOpenEmbedding_ι (a : α) :
    IsOpenEmbedding (Sigma.ι X a) := by
refine IsOpenEmbedding.of_comp _ (homeoOfIso ((colimit.isColimit _).coconePointUniqueUpToIso
    (finiteCoproduct.isColimit X))).isOpenEmbedding ?_
  convert finiteCoproduct.isOpenEmbedding_ι X a
  ext x
  change (Sigma.ι X a ≫ _) x = _
  simp

/-- The functor to `TopCat` preserves finite coproducts if they exist. -/
```

-- snippet 28
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.homeoOfIso (L256-L260)
def homeoOfIso {X Y : CompHausLike.{u} P} (f : X ≅ Y) : X ≃ₜ Y :=
TopCat.homeoOfIso <| (compHausLikeToTop P).mapIso f

/-- The equivalence between isomorphisms in `CompHaus` and homeomorphisms
of topological spaces. -/
```

-- snippet 29
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.ofHom (L67-L68)
abbrev ofHom (f : C(X, Y)) : of X ⟶ of Y := ConcreteCategory.ofHom f
```

-- snippet 30
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.coe_id (L123-L125)
theorem coe_id (X : CompHausLike P) : (𝟙 X : X → X) = id :=
rfl
```

-- snippet 31
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.of (L114-L119)
abbrev of : CompHausLike P where
  toTop := TopCat.of X
is_compact := ‹_›
  is_hausdorff := ‹_›
  prop := HasProp.hasProp
```

-- snippet 32
```lean
-- Mathlib.Topology.Category.Compactum.incl (L132-L134)
def incl (X : Compactum) : X → Ultrafilter X :=
(β).η.app _
```

-- snippet 33
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.hasPullbacksOfInclusions (L335-L350)
theorem hasPullbacksOfInclusions
    (hP' : ∀ ⦃X Y B : CompHausLike.{u} P⦄ (f : X ⟶ B) (g : Y ⟶ B)
      (_ : IsOpenEmbedding f), HasExplicitPullback f g) :
    HasExplicitPullbacksOfInclusions P :=
{ hasProp := by
      intro _ _ _ f
      apply hP'
      exact Sigma.isOpenEmbedding_ι _ _ }

/-- The functor to `TopCat` preserves pullbacks of inclusions if they exist. -/
noncomputable instance [HasExplicitPullbacksOfInclusions P] :
    PreservesPullbacksOfInclusions (compHausLikeToTop P) :=
  { preservesPullbackInl := by
      intro X Y Z f
      infer_instance }
```

-- snippet 34
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.isoOfHomeo (L86-L96)
def isoOfHomeo {X Y : CompactlyGenerated.{u, w}} (f : X ≃ₜ Y) : X ≅ Y where
  hom := ofHom ⟨f, f.continuous⟩
inv := ofHom ⟨f.symm, f.symm.continuous⟩
  hom_inv_id := by
    ext x
    exact f.symm_apply_apply x
  inv_hom_id := by
    ext x
    exact f.apply_symm_apply x

/-- Construct a homeomorphism from an isomorphism. -/
```

-- snippet 35
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.toCompHausLike (L152-L158)
def toCompHausLike {P P' : TopCat → Prop} (h : ∀ (X : CompHausLike P), P X.toTop → P' X.toTop) :
    CompHausLike P ⥤ CompHausLike P' where
  obj X :=
haveI : HasProp P' X := ⟨(h _ X.prop)⟩
    CompHausLike.of _ X
  map {X Y} f := ConcreteCategory.ofHom f.hom.hom
```

-- snippet 36
```lean
-- Mathlib.Topology.Category.Compactum.str_hom_commute (L142-L147)
theorem str_hom_commute (X Y : Compactum) (f : X ⟶ Y) (xs : Ultrafilter X) :
    f (X.str xs) = Y.str (map f xs) := by
change (X.a ≫ f.f) _ = _
  rw [← f.h]
  rfl
```

-- snippet 37
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.compHausLikeToCompHaus (L217-L218)
abbrev compHausLikeToCompHaus (P : TopCat → Prop) : CompHausLike P ⥤ CompHaus :=
CompHausLike.toCompHausLike (by simp only [implies_true])
```

-- snippet 38
```lean
-- Mathlib.Topology.Category.Compactum.free (L101-L104)
def free : Type* ⥤ Compactum :=
Monad.free _

/-- The adjunction between `free` and `forget`. -/
```

-- snippet 39
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.homeoOfIso (L98-L107)
def homeoOfIso {X Y : CompactlyGenerated.{u, w}} (f : X ≅ Y) : X ≃ₜ Y where
  toFun := f.hom
invFun := f.inv
  left_inv := f.hom_inv_id_apply
  right_inv := f.inv_hom_id_apply
  continuous_toFun := f.hom.hom.hom.continuous
  continuous_invFun := f.inv.hom.hom.continuous

/-- The equivalence between isomorphisms in `CompactlyGenerated` and homeomorphisms
of topological spaces. -/
```

-- snippet 40
```lean
-- Mathlib.Topology.Category.CompHausLike.EffectiveEpi.effectiveEpiStruct (L36-L63)
def effectiveEpiStruct {B X : CompHausLike P} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h :=
ofHom _ ((IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).lift e.hom.hom
      fun a b hab ↦
        CategoryTheory.congr_fun (h
          (ofHom _ ⟨fun _ ↦ a, continuous_const⟩)
          (ofHom _ ⟨fun _ ↦ b, continuous_const⟩)
        (by ext; exact hab)) a)
  fac e h :=
    InducedCategory.hom_ext (TopCat.hom_ext
      ((IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).lift_comp _ _))
  uniq e h g hm := by
    suffices g = ofHom _
        ((IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).liftEquiv ⟨e.hom.hom,
      fun a b hab ↦ CategoryTheory.congr_fun
        (h
          (ofHom _ ⟨fun _ ↦ a, continuous_const⟩)
          (ofHom _ ⟨fun _ ↦ b, continuous_const⟩)
          (by ext; exact hab))
        a⟩) by assumption
    apply ConcreteCategory.ext
    rw [hom_ofHom, ← Equiv.symm_apply_eq
      (IsQuotientMap.of_surjective_continuous hπ π.hom.hom.continuous).liftEquiv]
    ext
    simp only [IsQuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm]
    rfl
```

-- snippet 41
```lean
-- Mathlib.Topology.Category.Compactum.str_eq_of_le_nhds (L272-L341)
theorem str_eq_of_le_nhds {X : Compactum} (F : Ultrafilter X) (x : X) : ↑F ≤ 𝓝 x → X.str F = x := by
-- Notation to be used in this proof.
  let fsu := Finset (Set (Ultrafilter X))
  let ssu := Set (Set (Ultrafilter X))
  let ι : fsu → ssu := fun x ↦ ↑x
  let T0 : ssu := { S | ∃ A ∈ F, S = basic A }
  let AA := X.str ⁻¹' {x}
  let T1 := insert AA T0
  let T2 := finiteInterClosure T1
  intro cond
  -- If F contains a closed set A, then x is contained in A.
  have claim1 : ∀ A : Set X, IsClosed A → A ∈ F → x ∈ A := by
    intro A hA h
    by_contra H
    rw [le_nhds_iff] at cond
    specialize cond Aᶜ H hA.isOpen_compl
    rw [Ultrafilter.mem_coe, Ultrafilter.compl_mem_iff_notMem] at cond
    contradiction
  -- If A ∈ F, then x ∈ cl A.
  have claim2 : ∀ A : Set X, A ∈ F → x ∈ cl A := by
    intro A hA
    exact claim1 (cl A) (isClosed_cl A) (mem_of_superset hA (subset_cl A))
  -- T0 is closed under intersections.
  have claim3 : ∀ (S1) (_ : S1 ∈ T0) (S2) (_ : S2 ∈ T0), S1 ∩ S2 ∈ T0 := by
    rintro S1 ⟨S1, hS1, rfl⟩ S2 ⟨S2, hS2, rfl⟩
    exact ⟨S1 ∩ S2, inter_mem hS1 hS2, by simp [basic_inter]⟩
  -- For every S ∈ T0, the intersection AA ∩ S is nonempty.
  have claim4 : ∀ S ∈ T0, (AA ∩ S).Nonempty := by
    rintro S ⟨S, hS, rfl⟩
    rcases claim2 _ hS with ⟨G, hG, hG2⟩
    exact ⟨G, hG2, hG⟩
  -- Every element of T0 is nonempty.
  have claim5 : ∀ S ∈ T0, Set.Nonempty S := by
    rintro S ⟨S, hS, rfl⟩
    exact ⟨F, hS⟩
  -- Every element of T2 is nonempty.
  have claim6 : ∀ S ∈ T2, Set.Nonempty S := by
    suffices ∀ S ∈ T2, S ∈ T0 ∨ ∃ Q ∈ T0, S = AA ∩ Q by
      intro S hS
      rcases this _ hS with h | h
      · exact claim5 S h
      · rcases h with ⟨Q, hQ, rfl⟩
        exact claim4 Q hQ
    intro S hS
    apply finiteInterClosure_insert
    · constructor
      · use Set.univ
        refine ⟨Filter.univ_sets _, ?_⟩
        ext
        refine ⟨?_, by tauto⟩
        · intro
          apply Filter.univ_sets
      · exact claim3
    · exact hS
  -- It suffices to show that the intersection of any finite subset of T1 is nonempty.
  suffices ∀ F : fsu, ↑F ⊆ T1 → (⋂₀ ι F).Nonempty by
    obtain ⟨G, h1⟩ := Ultrafilter.exists_ultrafilter_of_finite_inter_nonempty _ this
    have c1 : X.join G = F := Ultrafilter.coe_le_coe.1 fun P hP => h1 (Or.inr ⟨P, hP, rfl⟩)
    have c2 : G.map X.str = X.incl x := by
      refine Ultrafilter.coe_le_coe.1 fun P hP => ?_
      apply mem_of_superset (h1 (Or.inl rfl))
      rintro x ⟨rfl⟩
      exact hP
    simp [← c1, c2]
  -- Finish...
  intro T hT
  refine claim6 _ (finiteInter_mem (.finiteInterClosure_finiteInter _) _ ?_)
  intro t ht
  exact finiteInterClosure.basic (@hT t ht)
```

-- snippet 42
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.productCone (L40-L47)
def productCone : BinaryFan X Y :=
BinaryFan.mk (P := CompHausLike.of P (X × Y))
    (ofHom _ { toFun := Prod.fst }) (ofHom _ { toFun := Prod.snd })

/--
When the predicate `P` is preserved under taking type-theoretic products, that product is a
category-theoretic product in `CompHausLike P`.
-/
```

-- snippet 43
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isoOfHomeo (L251-L254)
def isoOfHomeo {X Y : CompHausLike.{u} P} (f : X ≃ₜ Y) : X ≅ Y :=
(fullyFaithfulCompHausLikeToTop P).preimageIso (TopCat.isoOfHomeo f)

/-- Construct a homeomorphism from an isomorphism. -/
```

-- snippet 44
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isoEquivHomeo (L262-L266)
def isoEquivHomeo {X Y : CompHausLike.{u} P} : (X ≅ Y) ≃ (X ≃ₜ Y) where
  toFun := homeoOfIso
invFun := isoOfHomeo

/-- A constant map as a morphism in `CompHausLike` -/
```

-- snippet 45
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.fullyFaithfulCompHausLikeToTop (L187-L189)
def fullyFaithfulCompHausLikeToTop : (compHausLikeToTop P).FullyFaithful :=
fullyFaithfulInducedFunctor _
```

-- snippet 46
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.ofHom (L137-L138)
abbrev ofHom (f : C(X, Y)) : of P X ⟶ of P Y := ConcreteCategory.ofHom f
```

-- snippet 47
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.isIso_of_bijective (L225-L238)
theorem isIso_of_bijective {X Y : CompHausLike.{u} P} (f : X ⟶ Y) (bij : Function.Bijective f) :
    IsIso f := by
let E := Equiv.ofBijective _ bij
  have hE : Continuous E.symm := by
    rw [continuous_iff_isClosed]
    intro S hS
    rw [← E.image_eq_preimage_symm]
    exact isClosedMap f S hS
  refine ⟨⟨ofHom _ ⟨E.symm, hE⟩, ?_, ?_⟩⟩
  · ext x
    apply E.symm_apply_apply
  · ext x
    apply E.apply_symm_apply
```

-- snippet 48
```lean
-- Mathlib.Topology.Category.Compactum.le_nhds_of_str_eq (L342-L345)
theorem le_nhds_of_str_eq {X : Compactum} (F : Ultrafilter X) (x : X) : X.str F = x → ↑F ≤ 𝓝 x :=
fun h => le_nhds_iff.mpr fun s hx hs => hs _ <| by rwa [h]

-- All the hard work above boils down to this `T2Space` instance.
```

-- snippet 49
```lean
-- Mathlib.Topology.Category.CompHausLike.EffectiveEpi.preregular (L64-L74)
theorem preregular [HasExplicitPullbacks P]
    (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) :
    Preregular (CompHausLike P) where
  exists_fac := by
intro X Y Z f π hπ
    refine ⟨pullback f π, pullback.fst f π, ⟨⟨effectiveEpiStruct _ ?_⟩⟩, pullback.snd f π,
      (pullback.condition _ _).symm⟩
    intro y
    obtain ⟨z, hz⟩ := hs π hπ (f y)
    exact ⟨⟨(y, z), hz.symm⟩, rfl⟩
```

-- snippet 50
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.finiteCoproduct (L63-L67)
def finiteCoproduct : CompHausLike P := CompHausLike.of P (Σ (a : α), X a)
/--
The inclusion of one of the factors into the explicit finite coproduct.
-/
```

-- snippet 51
```lean
-- Mathlib.Topology.Category.CompHausLike.SigmaComparison.sigmaComparison (L43-L46)
def sigmaComparison : X.obj ⟨(of P ((a : α) × σ a))⟩ ⟶ ((a : α) → X.obj ⟨of P (σ a)⟩) :=
fun x a ↦ X.map (ofHom _ ⟨Sigma.mk a, continuous_sigmaMk⟩).op x

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 52
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.HasExplicitPullback (L196-L203)
abbrev HasExplicitPullback := HasProp P { xy : X × Y | f xy.fst = g xy.snd }
variable [HasExplicitPullback f g] -- (hP : P (TopCat.of { xy : X × Y | f xy.fst = g xy.snd }))

/--
The pullback of two morphisms `f,g` in `CompHaus`, constructed explicitly as the set of
pairs `(x,y)` such that `f x = g y`, with the topology induced by the product.
-/
```

-- snippet 53
```lean
-- Mathlib.Topology.Category.CompHausLike.EffectiveEpi.precoherent (L75-L81)
theorem precoherent [HasExplicitPullbacks P] [HasExplicitFiniteCoproducts.{0} P]
    (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) :
    Precoherent (CompHausLike P) := by
have : Preregular (CompHausLike P) := preregular hs
  infer_instance

end CompHausLike
```

-- snippet 54
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.finitaryExtensive (L354-L366)
theorem finitaryExtensive (hP' : ∀ ⦃X Y B : CompHausLike.{u} P⦄ (f : X ⟶ B) (g : Y ⟶ B)
    (_ : IsOpenEmbedding f), HasExplicitPullback f g) :
      FinitaryExtensive (CompHausLike P) :=
have := hasPullbacksOfInclusions hP'
  finitaryExtensive_of_preserves_and_reflects (compHausLikeToTop P)

end FiniteCoproducts

section Terminal

variable {P : TopCat.{u} → Prop}

/-- A one-element space is terminal in `CompHaus` -/
```

-- snippet 55
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.stoneCechObj (L79-L112)
def stoneCechObj (X : TopCat) : CompHaus :=
CompHaus.of (StoneCech X)

set_option backward.isDefEq.respectTransparency false in
/-- (Implementation) The bijection of homsets to establish the reflective adjunction of compact
Hausdorff spaces in topological spaces.
-/
noncomputable def stoneCechEquivalence (X : TopCat.{u}) (Y : CompHaus.{u}) :
    (stoneCechObj X ⟶ Y) ≃ (X ⟶ compHausToTop.obj Y) where
  toFun f := TopCat.ofHom
    { toFun := f ∘ stoneCechUnit
      continuous_toFun := f.hom.hom.2.comp (@continuous_stoneCechUnit X _) }
  invFun f := CompHausLike.ofHom _
    { toFun := stoneCechExtend f.hom.2
      continuous_toFun := continuous_stoneCechExtend f.hom.2 }
  left_inv := by
    rintro ⟨f : StoneCech X ⟶ Y, hf : Continuous f⟩
    ext x
    refine congr_fun ?_ x
    apply Continuous.ext_on denseRange_stoneCechUnit (continuous_stoneCechExtend _) hf
    · rintro _ ⟨y, rfl⟩
      apply congr_fun (stoneCechExtend_extends (hf.comp _)) y
      apply continuous_stoneCechUnit
  right_inv := by
    rintro ⟨f : (X : Type _) ⟶ Y, hf : Continuous f⟩
    ext
    exact congr_fun (stoneCechExtend_extends hf) _

/-- The Stone-Cech compactification functor from topological spaces to compact Hausdorff spaces,
left adjoint to the inclusion functor.
-/
noncomputable def topToCompHaus : TopCat.{u} ⥤ CompHaus.{u} :=
  Adjunction.leftAdjointOfEquiv stoneCechEquivalence.{u} fun _ _ _ _ _ => rfl
```

-- snippet 56
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.coe_comp (L127-L130)
theorem coe_comp {X Y Z : CompHausLike P} (f : X ⟶ Y) (g : Y ⟶ Z) :
    (f ≫ g : X → Z) = g ∘ f :=
rfl
```

-- snippet 57
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.fullyFaithfulCompactlyGeneratedToTop (L77-L79)
def fullyFaithfulCompactlyGeneratedToTop : compactlyGeneratedToTop.{u, w}.FullyFaithful :=
fullyFaithfulInducedFunctor _
```

-- snippet 58
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.epi_iff_surjective (L181-L216)
theorem epi_iff_surjective {X Y : CompHaus.{u}} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by
constructor
  · dsimp [Function.Surjective]
    contrapose!
    rintro ⟨y, hy⟩ hf
    let C := Set.range f
    have hC : IsClosed C := (isCompact_range f.hom.hom.continuous).isClosed
    let D := ({y} : Set Y)
    have hD : IsClosed D := isClosed_singleton
    have hCD : Disjoint C D := by
      rw [Set.disjoint_singleton_right]
      rintro ⟨y', hy'⟩
      exact hy y' hy'
    obtain ⟨φ, hφ0, hφ1, hφ01⟩ := exists_continuous_zero_one_of_isClosed hC hD hCD
    haveI : CompactSpace (ULift.{u} <| Set.Icc (0 : ℝ) 1) := Homeomorph.ulift.symm.compactSpace
    haveI : T2Space (ULift.{u} <| Set.Icc (0 : ℝ) 1) := Homeomorph.ulift.symm.t2Space
    let Z := of (ULift.{u} <| Set.Icc (0 : ℝ) 1)
    let g : Y ⟶ Z := ofHom _
      ⟨fun y' => ⟨⟨φ y', hφ01 y'⟩⟩,
        continuous_uliftUp.comp (φ.continuous.subtype_mk fun y' => hφ01 y')⟩
    let h : Y ⟶ Z := ofHom _
      ⟨fun _ => ⟨⟨0, Set.left_mem_Icc.mpr zero_le_one⟩⟩, continuous_const⟩
    have H : h = g := by
      rw [← cancel_epi f]
      ext x : 4
      simp [g, h, Z, hφ0 (Set.mem_range_self x)]
    apply_fun fun e => (e y).down.1 at H
    dsimp [g, h, Z] at H
    simp only [hφ1 (Set.mem_singleton y), Pi.one_apply] at H
    exact zero_ne_one H
  · rw [← CategoryTheory.epi_iff_surjective]
    apply (forget CompHaus).epi_of_epi_map

end CompHaus

/-- Every `CompHausLike` admits a functor to `CompHaus`. -/
```

-- snippet 59
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.coproductIsColimit (L86-L94)
def coproductIsColimit : IsColimit (coproductCocone X Y) := by
refine BinaryCofan.isColimitMk (fun s ↦ ofHom _ { toFun := Sum.elim s.inl s.inr })
    (by rfl_cat) (by rfl_cat) fun _ _ h₁ h₂ ↦ ?_
  ext ⟨⟩
  exacts [ConcreteCategory.congr_hom h₁ _, ConcreteCategory.congr_hom h₂ _]

end Coproduct

end CompHausLike
```

-- snippet 60
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.HasExplicitFiniteCoproduct (L55-L62)
abbrev HasExplicitFiniteCoproduct := HasProp P (Σ (a : α), X a)
variable [HasExplicitFiniteCoproduct X]

/--
The coproduct of a finite family of objects in `CompHaus`, constructed as the disjoint
union with its usual topology.
-/
```

-- snippet 61
```lean
-- Mathlib.Topology.Category.CompHaus.Projective.projective_ultrafilter (L41-L57)
instance projective_ultrafilter (X : Type*) : Projective (of <| Ultrafilter X) where
  factors {Y Z} f g hg := by
rw [epi_iff_surjective] at hg
    obtain ⟨g', hg'⟩ := hg.hasRightInverse
    let t : X → Y := g' ∘ f ∘ (pure : X → Ultrafilter X)
    let h : Ultrafilter X → Y := Ultrafilter.extend t
    have hh : Continuous h := continuous_ultrafilter_extend _
    use CompHausLike.ofHom _ ⟨h, hh⟩
    apply ConcreteCategory.coe_ext
    have : g.hom ∘ g' = id := hg'.comp_eq_id
    convert denseRange_pure.equalizer (g.hom.hom.continuous.comp hh) f.hom.hom.continuous _
    -- This used to be `rw`, but we need `rw; rfl` after https://github.com/leanprover/lean4/pull/2644
    rw [comp_assoc, ultrafilter_extend_extends, ← comp_assoc, this, id_comp]
    rfl

/-- For any compact Hausdorff space `X`,
  the natural map `Ultrafilter X → X` is a projective presentation. -/
```

-- snippet 62
```lean
-- Mathlib.Topology.Category.Compactum.str (L124-L127)
def str (X : Compactum) : Ultrafilter X → X :=
X.a

/-- The monadic join. -/
```

-- snippet 63
```lean
-- Mathlib.Topology.Category.CompHausLike.SigmaComparison.isIsoSigmaComparison (L69-L73)
instance isIsoSigmaComparison : IsIso <| sigmaComparison X σ := by
rw [sigmaComparison_eq_comp_isos]
  infer_instance

end CompHausLike
```

-- snippet 64
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.category (L92-L94)
instance category : Category (CompHausLike P) :=
inferInstanceAs (Category (InducedCategory _ toTop))
```

-- snippet 65
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.compHausLikeToTop (L178-L182)
def compHausLikeToTop : CompHausLike.{u} P ⥤ TopCat.{u} :=
inducedFunctor _
-- The `Full, Faithful` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
```

-- snippet 66
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.topToCompHaus_obj (L113-L124)
theorem topToCompHaus_obj (X : TopCat) : ↥(topToCompHaus.obj X) = StoneCech X :=
rfl

/-- The category of compact Hausdorff spaces is reflective in the category of topological spaces.
-/
noncomputable instance compHausToTop.reflective : Reflective compHausToTop where
  L := topToCompHaus
  adj := Adjunction.adjunctionOfEquivLeft _ _

noncomputable instance compHausToTop.createsLimits : CreatesLimits compHausToTop :=
  monadicCreatesLimits _
```

-- snippet 67
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.coproductCocone (L79-L85)
def coproductCocone : BinaryCofan X Y := BinaryCofan.mk (P := CompHausLike.of P (X ⊕ Y))
(ofHom _ { toFun := Sum.inl }) (ofHom _ { toFun := Sum.inr })

/--
When the predicate `P` is preserved under taking type-theoretic sums, that sum is a
category-theoretic coproduct in `CompHausLike P`.
-/
```

-- snippet 68
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.const_comp (L271-L275)
lemma const_comp {P : TopCat.{u} → Prop} {S T U : CompHausLike.{u} P}
    (s : S) (g : S ⟶ U) : T.const s ≫ g = T.const (g s) :=
rfl

end CompHausLike
```

-- snippet 69
```lean
-- Mathlib.Topology.Category.Compactum.forget (L91-L93)
def forget : Compactum ⥤ Type* :=
Monad.forget _
```

-- snippet 70
```lean
-- Mathlib.Topology.Category.Compactum.adj (L105-L107)
def adj : free ⊣ forget :=
Monad.adj _
```

-- snippet 71
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.of (L58-L61)
abbrev of : CompactlyGenerated.{u, w} where
  toTop := TopCat.of X
is_compactly_generated := ‹_›
```

-- snippet 72
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.limitConeIsLimit (L171-L180)
def limitConeIsLimit {J : Type v} [SmallCategory J] (F : J ⥤ CompHaus.{max v u}) :
    Limits.IsLimit.{v} (limitCone.{v, u} F) :=
letI FF : J ⥤ TopCat := F ⋙ compHausToTop
  { lift := fun S => InducedCategory.homMk
      ((TopCat.limitConeIsLimit FF).lift (compHausToTop.mapCone S))
    uniq := fun S m hm => InducedCategory.hom_ext
      ((TopCat.limitConeIsLimit FF).uniq (compHausToTop.mapCone S) _ (fun j ↦ by
        simp [← hm]
        rfl)) }
```

-- snippet 73
```lean
-- Mathlib.Topology.Category.Compactum.isClosed_iff (L162-L175)
theorem isClosed_iff {X : Compactum} (S : Set X) :
    IsClosed S ↔ ∀ F : Ultrafilter X, S ∈ F → X.str F ∈ S := by
rw [← isOpen_compl_iff]
  constructor
  · intro cond F h
    by_contra c
    specialize cond F c
    rw [compl_mem_iff_notMem] at cond
    contradiction
  · intro h1 F h2
    specialize h1 F
    rcases F.mem_or_compl_mem S with h | h
    exacts [absurd (h1 h) h2, h]
```

-- snippet 74
```lean
-- Mathlib.Topology.Category.Compactum.str_incl (L136-L140)
theorem str_incl (X : Compactum) (x : X) : X.str (X.incl x) = x := by
change ((β).η.app _ ≫ X.a) _ = _
  rw [Monad.Algebra.unit]
  rfl
```

-- snippet 75
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.forget_reflectsIsomorphisms (L239-L249)
instance forget_reflectsIsomorphisms :
    (forget (CompHausLike.{u} P)).ReflectsIsomorphisms :=
⟨by intro A B f hf; rw [isIso_iff_bijective] at hf; exact isIso_of_bijective _ hf⟩

/-- Any continuous bijection of compact Hausdorff spaces induces an isomorphism. -/
noncomputable def isoOfBijective {X Y : CompHausLike.{u} P} (f : X ⟶ Y)
    (bij : Function.Bijective f) : X ≅ Y :=
  letI := isIso_of_bijective _ bij
  asIso f

/-- Construct an isomorphism from a homeomorphism. -/
```

-- snippet 76
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.limitCone (L135-L170)
def limitCone {J : Type v} [SmallCategory J] (F : J ⥤ CompHaus.{max v u}) : Limits.Cone F :=
letI FF : J ⥤ TopCat := F ⋙ compHausToTop
  { pt := {
      toTop := (TopCat.limitCone FF).pt
      is_compact := by
        change CompactSpace { u : ∀ j, F.obj j | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j }
        rw [← isCompact_iff_compactSpace]
        apply IsClosed.isCompact
        have :
          { u : ∀ j, F.obj j | ∀ {i j : J} (f : i ⟶ j), F.map f (u i) = u j } =
            ⋂ (i : J) (j : J) (f : i ⟶ j), { u | F.map f (u i) = u j } := by
          ext1
          simp only [Set.mem_iInter, Set.mem_setOf_eq]
        rw [this]
        apply isClosed_iInter
        intro i
        apply isClosed_iInter
        intro j
        apply isClosed_iInter
        intro f
        apply isClosed_eq
        · exact ((F.map f).hom.hom.continuous).comp (continuous_apply i)
        · exact continuous_apply j
      is_hausdorff :=
        show T2Space { u : ∀ j, F.obj j | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j } from
          inferInstance
      prop := trivial }
    π := {
      app := fun j => InducedCategory.homMk ((TopCat.limitCone FF).π.app j)
      naturality := by
        intro _ _ f
        ext ⟨x, hx⟩
        simp only [Functor.const_obj_map]
        exact (hx f).symm } }

/-- The limit cone `CompHaus.limitCone F` is indeed a limit cone. -/
```

-- snippet 77
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.productIsLimit (L48-L61)
def productIsLimit : IsLimit (productCone X Y) := by
refine BinaryFan.isLimitMk (fun s ↦ ofHom _ { toFun x := (s.fst x, s.snd x) })
    (by rfl_cat) (by rfl_cat) fun _ _ h₁ h₂ ↦ ?_
  ext x
  exacts [ConcreteCategory.congr_hom h₁ _, ConcreteCategory.congr_hom h₂ _]

/--
When the predicate `P` is preserved under taking type-theoretic products and `PUnit` satisfies it,
then `CompHausLike P` is a cartesian monoidal category.

This could be an instance but that causes some slowness issues with typeclass search, therefore we
keep it as a def and turn it on as an instance for the explicit examples of `CompHausLike` as
needed.
-/
```

-- snippet 78
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.concreteCategory (L95-L97)
instance concreteCategory : ConcreteCategory (CompHausLike P) (C(·, ·)) :=
InducedCategory.concreteCategory toTop
```

-- snippet 79
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.mono_iff_injective (L209-L220)
theorem mono_iff_injective {X Y : CompHausLike.{u} P} (f : X ⟶ Y) :
    Mono f ↔ Function.Injective f := by
constructor
  · intro hf x₁ x₂ h
    let g₁ : X ⟶ X := ofHom _ ⟨fun _ => x₁, continuous_const⟩
    let g₂ : X ⟶ X := ofHom _ ⟨fun _ => x₂, continuous_const⟩
    have : g₁ ≫ f = g₂ ≫ f := by ext; exact h
    exact CategoryTheory.congr_fun ((cancel_mono _).mp this) x₁
  · rw [← CategoryTheory.mono_iff_injective]
    apply (forget (CompHausLike P)).mono_of_mono_map

/-- Any continuous function on compact Hausdorff spaces is a closed map. -/
```

-- snippet 80
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.isoEquivHomeo (L109-L113)
def isoEquivHomeo {X Y : CompactlyGenerated.{u, w}} : (X ≅ Y) ≃ (X ≃ₜ Y) where
  toFun := homeoOfIso
invFun := isoOfHomeo

end CompactlyGenerated
```

-- snippet 81
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.pullback (L204-L213)
def pullback : CompHausLike P :=
letI set := { xy : X × Y | f xy.fst = g xy.snd }
  haveI : CompactSpace set :=
    isCompact_iff_compactSpace.mp (isClosed_eq (f.hom.hom.continuous.comp continuous_fst)
      (g.hom.hom.continuous.comp continuous_snd)).isCompact
  CompHausLike.of P set

/--
The projection from the pullback to the first component.
-/
```

-- snippet 82
```lean
-- Mathlib.Topology.Category.CompHausLike.Cartesian.cartesianMonoidalCategory (L63-L78)
def cartesianMonoidalCategory [∀ (X Y : CompHausLike.{u} P), HasProp P (X × Y)]
    [HasProp P PUnit.{u + 1}] : CartesianMonoidalCategory (CompHausLike.{u} P) :=
.ofChosenFiniteProducts
    ⟨_, CompHausLike.isTerminalPUnit⟩
    (fun X Y ↦ ⟨productCone X Y, productIsLimit X Y⟩)

end Product

section Coproduct

variable [HasProp P (X ⊕ Y)]

/--
Explicit binary cofan in `CompHausLike P`, given that the predicate `P` is preserved under taking
type-theoretic sums.
-/
```

-- snippet 83
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.of (L67-L71)
abbrev of : CompHaus := CompHausLike.of _ X
end CompHaus

/-- The fully faithful embedding of `CompHaus` in `TopCat`. -/
```

-- snippet 84
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.CompHaus (L44-L47)
abbrev CompHaus := CompHausLike (fun _ ↦ True)
namespace CompHaus
```

-- snippet 85
```lean
-- Mathlib.Topology.Category.CompactlyGenerated.compactlyGeneratedToTop (L73-L76)
def compactlyGeneratedToTop : CompactlyGenerated.{u, w} ⥤ TopCat.{w} :=
inducedFunctor _

/-- `compactlyGeneratedToTop` is fully faithful. -/
```

-- snippet 86
```lean
-- Mathlib.Topology.Category.CompHaus.EffectiveEpi.effectiveEpi_tfae (L39-L50)
theorem effectiveEpi_tfae
    {B X : CompHaus.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
tfae_have 1 → 2 := fun _ ↦ inferInstance
  tfae_have 2 ↔ 3 := epi_iff_surjective π
  tfae_have 3 → 1 := fun hπ ↦ ⟨⟨effectiveEpiStruct π hπ⟩⟩
  tfae_finish
```

-- snippet 87
```lean
-- Mathlib.Topology.Category.Compactum.isClosed_cl (L267-L271)
theorem isClosed_cl {X : Compactum} (A : Set X) : IsClosed (cl A) := by
rw [isClosed_iff]
  intro F hF
  exact cl_cl _ ⟨F, hF, rfl⟩
```

-- snippet 88
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.const (L267-L270)
def const {P : TopCat.{u} → Prop}
    (T : CompHausLike.{u} P) {S : CompHausLike.{u} P} (s : S) : T ⟶ S :=
ofHom _ (ContinuousMap.const _ s)
```

-- snippet 89
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.epi_of_surjective (L204-L208)
theorem epi_of_surjective {X Y : CompHausLike.{u} P} (f : X ⟶ Y) (hf : Function.Surjective f) :
    Epi f := by
rw [← CategoryTheory.epi_iff_surjective] at hf
  exact (forget (CompHausLike P)).epi_of_epi_map hf
```

-- snippet 90
```lean
-- Mathlib.Topology.Category.Compactum.Compactum (L85-L90)
def Compactum :=
Monad.Algebra β deriving Category, Inhabited

namespace Compactum

/-- The forgetful functor to Type* -/
```

-- snippet 91
```lean
-- Mathlib.Topology.Category.CompHausLike.SigmaComparison.sigmaComparison_eq_comp_isos (L47-L68)
theorem sigmaComparison_eq_comp_isos : sigmaComparison X σ =
    (X.mapIso (opCoproductIsoProduct'
      (finiteCoproduct.isColimit.{u, u} (fun a ↦ of P (σ a)))
      (productIsProduct fun x ↦ Opposite.op (of P (σ x))))).hom ≫
    (PreservesProduct.iso X fun a ↦ ⟨of P (σ a)⟩).hom ≫
    (Types.productIso.{u, max u w} fun a ↦ X.obj ⟨of P (σ a)⟩).hom := by
ext x a
  simp only [Cofan.mk_pt, Fan.mk_pt, Functor.mapIso_hom,
    PreservesProduct.iso_hom, types_comp_apply, Types.productIso_hom_comp_eval_apply]
  have := congrFun (piComparison_comp_π X (fun a ↦ ⟨of P (σ a)⟩) a)
  simp only [types_comp_apply] at this
  rw [this, ← FunctorToTypes.map_comp_apply]
  simp only [sigmaComparison]
  apply congrFun
  congr 2
  rw [← opCoproductIsoProduct_inv_comp_ι]
  simp only [Opposite.unop_op, unop_comp, Quiver.Hom.unop_op, Category.assoc]
  simp only [opCoproductIsoProduct, ← unop_comp, opCoproductIsoProduct'_comp_self]
  erw [IsColimit.fac]
  rfl

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 92
```lean
-- Mathlib.Topology.Category.CompHaus.EffectiveEpi.effectiveEpiFamily_of_jointly_surjective (L102-L109)
theorem effectiveEpiFamily_of_jointly_surjective
    {α : Type} [Finite α] {B : CompHaus.{u}}
    (X : α → CompHaus.{u}) (π : (a : α) → (X a ⟶ B))
    (surj : ∀ b : B, ∃ (a : α) (x : X a), π a x = b) :
    EffectiveEpiFamily X π :=
((effectiveEpiFamily_tfae X π).out 2 0).mp surj

end CompHaus
```

-- snippet 93
```lean
-- Mathlib.Topology.Category.Compactum.join (L128-L131)
def join (X : Compactum) : Ultrafilter (Ultrafilter X) → Ultrafilter X :=
(β).μ.app _

/-- The inclusion of `X` into `Ultrafilter X`. -/
```

-- snippet 94
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.hasForget₂ (L98-L106)
instance hasForget₂ : HasForget₂ (CompHausLike P) TopCat :=
InducedCategory.hasForget₂ _

variable (X : Type u) [TopologicalSpace X] [CompactSpace X] [T2Space X]

/-- This wraps the predicate `P : TopCat → Prop` in a typeclass. -/
class HasProp : Prop where
  hasProp : P (TopCat.of X)
```

-- snippet 95
```lean
-- Mathlib.Topology.Category.CompHaus.Limits.isTerminalPUnit (L35-L43)
abbrev isTerminalPUnit : IsTerminal (CompHaus.of PUnit.{u + 1}) := CompHausLike.isTerminalPUnit
/-- The isomorphism from an arbitrary terminal object of `CompHaus` to a one-element space. -/
noncomputable def terminalIsoPUnit : ⊤_ CompHaus.{u} ≅ CompHaus.of PUnit :=
  terminalIsTerminal.uniqueUpToIso CompHaus.isTerminalPUnit

noncomputable example : PreservesFiniteCoproducts compHausToTop := inferInstance

end CompHaus
```

-- snippet 96
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.coe_of (L120-L121)
theorem coe_of : (CompHausLike.of P X : Type _) = X := rfl
```

-- snippet 97
```lean
-- Mathlib.Topology.Category.CompHaus.Frm.topCatOpToFrm (L22-L26)
def topCatOpToFrm : TopCatᵒᵖ ⥤ Frm where
  obj X := Frm.of (Opens (unop X : TopCat))
map f := Frm.ofHom <| Opens.comap <| (Quiver.Hom.unop f).hom

-- Note, `CompHaus` is too strong. We only need `T0Space`.
```

-- snippet 98
```lean
-- Mathlib.Topology.Category.CompHausLike.Limits.isTerminalPUnit (L367-L375)
def isTerminalPUnit [HasProp P PUnit.{u + 1}] :
    IsTerminal (CompHausLike.of P PUnit.{u + 1}) :=
haveI : ∀ X, Unique (X ⟶ CompHausLike.of P PUnit.{u + 1}) := fun _ ↦
    ⟨⟨ofHom _ ⟨fun _ ↦ PUnit.unit, continuous_const⟩⟩, fun _ ↦ rfl⟩
  Limits.IsTerminal.ofUnique _

end Terminal

end CompHausLike
```

-- snippet 99
```lean
-- Mathlib.Topology.Category.CompHaus.Basic.compHausToTop (L72-L77)
abbrev compHausToTop : CompHaus.{u} ⥤ TopCat.{u} :=
CompHausLike.compHausLikeToTop _

/-- (Implementation) The object part of the compactification functor from topological spaces to
compact Hausdorff spaces.
-/
```

-- snippet 100
```lean
-- Mathlib.Topology.Category.Compactum.join_distrib (L149-L154)
theorem join_distrib (X : Compactum) (uux : Ultrafilter (Ultrafilter X)) :
    X.str (X.join uux) = X.str (map X.str uux) := by
change ((β).μ.app _ ≫ X.a) _ = _
  rw [Monad.Algebra.assoc]
  rfl
```

-- snippet 101
```lean
-- Mathlib.Topology.Category.CompHaus.EffectiveEpi.effectiveEpiFamily_tfae (L59-L101)
theorem effectiveEpiFamily_tfae
    {α : Type} [Finite α] {B : CompHaus.{u}}
    (X : α → CompHaus.{u}) (π : (a : α) → (X a ⟶ B)) :
    TFAE
    [ EffectiveEpiFamily X π
    , Epi (Sigma.desc π)
    , ∀ b : B, ∃ (a : α) (x : X a), π a x = b
    ] := by
tfae_have 2 → 1
  | _ => by
    simpa [← effectiveEpi_desc_iff_effectiveEpiFamily, (effectiveEpi_tfae (Sigma.desc π)).out 0 1]
  tfae_have 1 → 2
  | _ => inferInstance
  tfae_have 3 → 2
  | e => by
    rw [epi_iff_surjective]
    intro b
    obtain ⟨t, x, h⟩ := e b
    refine ⟨Sigma.ι X t x, ?_⟩
    change (Sigma.ι X t ≫ Sigma.desc π) x = _
    simpa using h
  tfae_have 2 → 3
  | e => by
    rw [epi_iff_surjective] at e
    let i : ∐ X ≅ finiteCoproduct X :=
      (colimit.isColimit _).coconePointUniqueUpToIso (finiteCoproduct.isColimit _)
    intro b
    obtain ⟨t, rfl⟩ := e b
    let q := i.hom t
    refine ⟨q.1,q.2,?_⟩
    have : t = i.inv (i.hom t) := show t = (i.hom ≫ i.inv) t by simp only [i.hom_inv_id]; rfl
    rw [this]
    change _ = (i.inv ≫ Sigma.desc π) (i.hom t)
    suffices i.inv ≫ Sigma.desc π = finiteCoproduct.desc X π by
      rw [this]; rfl
    rw [Iso.inv_comp_eq]
    apply colimit.hom_ext
    rintro ⟨a⟩
    simp only [i, Discrete.functor_obj, colimit.ι_desc, Cofan.mk_pt, Cofan.mk_ι_app,
      colimit.comp_coconePointUniqueUpToIso_hom_assoc]
    ext; rfl
  tfae_finish
```

-- snippet 102
```lean
-- Mathlib.Topology.Category.Compactum.lim_eq_str (L352-L357)
theorem lim_eq_str {X : Compactum} (F : Ultrafilter X) : F.lim = X.str F := by
rw [Ultrafilter.lim_eq_iff_le_nhds, le_nhds_iff]
  tauto

set_option backward.privateInPublic true in
set_option backward.privateInPublic.warn false in
```

-- snippet 103
```lean
-- Mathlib.Topology.Category.CompHausLike.Basic.fullyFaithfulToCompHausLike (L165-L167)
def fullyFaithfulToCompHausLike : (toCompHausLike h).FullyFaithful where
  preimage f := ConcreteCategory.ofHom f.hom.hom
```

-- snippet 104
```lean
-- Mathlib.Topology.Category.CompHaus.Projective.projectivePresentation (L58-L65)
def projectivePresentation (X : CompHaus) : ProjectivePresentation X where
  p := of <| Ultrafilter X
f := CompHausLike.ofHom _ ⟨_, continuous_ultrafilter_extend id⟩
  projective := CompHaus.projective_ultrafilter X
  epi :=
    ConcreteCategory.epi_of_surjective _ fun x =>
      ⟨(pure x : Ultrafilter X), congr_fun (ultrafilter_extend_extends (𝟙 X)) x⟩
```

-- snippet 105
```lean
-- Mathlib.Topology.Category.CompHaus.Frm.CompHausOpToFrame (L27-L30)
instance CompHausOpToFrame.faithful : (compHausToTop.op ⋙ topCatOpToFrm.{u}).Faithful :=
⟨fun {X _ _ _} h =>  Quiver.Hom.unop_inj <| ConcreteCategory.ext <|
    Opens.comap_injective (β := (unop X).toTop) <| FrameHom.ext <|
      CategoryTheory.congr_fun h⟩
```
[/INST]