/-- If `X` is a cofiltered limit of profinite sets, then any clopen subset of `X` arises from
a clopen set in one of the terms in the limit.
-/
theorem exists_isClopen_of_cofiltered {U : Set C.pt} (hC : IsLimit C) (hU : IsClopen U) :
    ∃ (j : J) (V : Set (F.obj j)), IsClopen V ∧ U = C.π.app j ⁻¹' V := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  -- First, we have the topological basis of the cofiltered limit obtained by pulling back
  -- clopen sets from the factors in the limit. By continuity, all such sets are again clopen.
  have hB := TopCat.isTopologicalBasis_cofiltered_limit.{u, v} (F ⋙ Profinite.toTopCat)
      (Profinite.toTopCat.mapCone C) (isLimitOfPreserves _ hC) (fun j => {W | IsClopen W}) ?_
      (fun i => isClopen_univ) (fun i U1 U2 hU1 hU2 => hU1.inter hU2) ?_
  rotate_left
  · intro i
    change TopologicalSpace.IsTopologicalBasis {W : Set (F.obj i) | IsClopen W}
    apply isTopologicalBasis_isClopen
  · rintro i j f V (hV : IsClopen _)
    exact ⟨hV.1.preimage ((F ⋙ toTopCat).map f).continuous,
      hV.2.preimage ((F ⋙ toTopCat).map f).continuous⟩
    -- Porting note: `<;> continuity` fails
  -- Using this, since `U` is open, we can write `U` as a union of clopen sets all of which
  -- are preimages of clopens from the factors in the limit.
  obtain ⟨S, hS, h⟩ := hB.open_eq_sUnion hU.1
  clear hB
  let j : S → J := fun s => (hS s.2).choose
  let V : ∀ s : S, Set (F.obj (j s)) := fun s => (hS s.2).choose_spec.choose
  have hV : ∀ s : S, IsClopen (V s) ∧ s.1 = C.π.app (j s) ⁻¹' V s := fun s =>
    (hS s.2).choose_spec.choose_spec

  -- Since `U` is also closed, hence compact, it is covered by finitely many of the
  -- clopens constructed in the previous step.
  have hUo : ∀ (i : ↑S), IsOpen ((fun s ↦ (forget Profinite).map (C.π.app (j s)) ⁻¹' V s) i)
  · intro s
    exact (hV s).1.1.preimage (C.π.app (j s)).continuous
  have hsU : U ⊆ ⋃ (i : ↑S), (fun s ↦ (forget Profinite).map (C.π.app (j s)) ⁻¹' V s) i
  · 

Proof state:
case hsU
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
U : Set ↑C.pt.toCompHaus.toTop
hC : IsLimit C
hU : IsClopen U
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : Set (Set ↑(toTopCat.mapCone C).pt)
hS : S ⊆ {U | ∃ j, ∃ V ∈ (fun j => {W | IsClopen W}) j, U = ⇑((toTopCat.mapCone C).π.app j) ⁻¹' V}
h : U = ⋃₀ S
j : ↑S → J :=
  fun s =>
    Exists.choose (_ : ↑s ∈ {U | ∃ j, ∃ V ∈ (fun j => {W | IsClopen W}) j, U = ⇑((toTopCat.mapCone C).π.app j) ⁻¹' V})
V : (s : ↑S) → Set ↑(F.obj (j s)).toCompHaus.toTop :=
  fun s =>
    Exists.choose
      (_ :
        ∃
          V ∈
            (fun j => {W | IsClopen W})
              (Exists.choose
                (_ : ↑s ∈ {U | ∃ j, ∃ V ∈ (fun j => {W | IsClopen W}) j, U = ⇑((toTopCat.mapCone C).π.app j) ⁻¹' V})),
          ↑s =
            ⇑((toTopCat.mapCone C).π.app
                  (Exists.choose
                    (_ :
                      ↑s ∈
                        {U | ∃ j, ∃ V ∈ (fun j => {W | IsClopen W}) j, U = ⇑((toTopCat.mapCone C).π.app j) ⁻¹' V}))) ⁻¹'
              V)
hV : ∀ (s : ↑S), IsClopen (V s) ∧ ↑s = ⇑(C.π.app (j s)) ⁻¹' V s
hUo : ∀ (i : ↑S), IsOpen ((fun s => (forget Profinite).map (C.π.app (j s)) ⁻¹' V s) i)
⊢ U ⊆ ⋃ i, (fun s => (forget Profinite).map (C.π.app (j s)) ⁻¹' V s) i

Next tactic:
dsimp only