l3lab/ntp-mathlib huggingface dataset:
theorem exists_locallyConstant_finite_nonempty {α : Type*} [Finite α] [Nonempty α]
    (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  inhabit α
  obtain ⟨j, gg, h⟩ := exists_locallyConstant_finite_aux _ hC f
  let ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1
  let σ : (α → Fin 2) → α := fun f => if h : ∃ a : α, ι a = f then h.choose else default
  refine' ⟨j, gg.map σ, _⟩
  ext x
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  erw [LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
  dsimp
  have h1 : ι (f x) = gg (C.π.app j x) := by
    change f.map (fun a b => if a = b then (0 : Fin 2) else 1) x = _
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [h, LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
    rfl
  have h2 : ∃ a : α, ι a = gg (C.π.app j x) := ⟨f x, h1⟩
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  erw [dif_pos h2]
  apply_fun ι
  · rw [h2.choose_spec]
    exact h1
  · intro a b hh
    have hhh := congr_fun hh a
    dsimp at hhh
    rw [if_pos rfl] at hhh
    

Proof state:
case intro.intro.h.inj
J : Type v
inst✝³ : SmallCategory J
inst✝² : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝¹ : Finite α
inst✝ : Nonempty α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
inhabited_h : Inhabited α
j : J
gg : LocallyConstant (↑(F.obj j).toCompHaus.toTop) (α → Fin 2)
h : LocallyConstant.map (fun a b => if a = b then 0 else 1) f = LocallyConstant.comap (⇑(C.π.app j)) gg
ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1
σ : (α → Fin 2) → α := fun f => if h : ∃ a, ι a = f then Exists.choose h else default
x : ↑C.pt.toCompHaus.toTop
h1 : ι (f x) = gg ((C.π.app j) x)
h2 : ∃ a, ι a = gg ((C.π.app j) x)
a b : α
hh : ι a = ι b
hhh : 0 = if b = a then 0 else 1
⊢ a = b

Next tactic:
split_ifs at hhh with hh1
theorem exists_locallyConstant_finite_nonempty {α : Type*} [Finite α] [Nonempty α]
    (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  inhabit α
  obtain ⟨j, gg, h⟩ := exists_locallyConstant_finite_aux _ hC f
  let ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1
  let σ : (α → Fin 2) → α := fun f => if h : ∃ a : α, ι a = f then h.choose else default
  refine' ⟨j, gg.map σ, _⟩
  ext x
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  erw [LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
  dsimp
  have h1 : ι (f x) = gg (C.π.app j x) := by
    change f.map (fun a b => if a = b then (0 : Fin 2) else 1) x = _
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [h, LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
    rfl
  have h2 : ∃ a : α, ι a = gg (C.π.app j x) := ⟨f x, h1⟩
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  erw [dif_pos h2]
  apply_fun ι
  · rw [h2.choose_spec]
    exact h1
  · intro a b hh
    have hhh := congr_fun hh a
    dsimp at hhh
    rw [if_pos rfl] at hhh
    split_ifs at hhh with hh1
    · 

Proof state:
case pos
J : Type v
inst✝³ : SmallCategory J
inst✝² : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝¹ : Finite α
inst✝ : Nonempty α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
inhabited_h : Inhabited α
j : J
gg : LocallyConstant (↑(F.obj j).toCompHaus.toTop) (α → Fin 2)
h : LocallyConstant.map (fun a b => if a = b then 0 else 1) f = LocallyConstant.comap (⇑(C.π.app j)) gg
ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1
σ : (α → Fin 2) → α := fun f => if h : ∃ a, ι a = f then Exists.choose h else default
x : ↑C.pt.toCompHaus.toTop
h1 : ι (f x) = gg ((C.π.app j) x)
h2 : ∃ a, ι a = gg ((C.π.app j) x)
a b : α
hh : ι a = ι b
hh1 : b = a
hhh : 0 = 0
⊢ a = b

Next tactic:
exact hh1.symm
theorem exists_locallyConstant_finite_nonempty {α : Type*} [Finite α] [Nonempty α]
    (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  inhabit α
  obtain ⟨j, gg, h⟩ := exists_locallyConstant_finite_aux _ hC f
  let ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1
  let σ : (α → Fin 2) → α := fun f => if h : ∃ a : α, ι a = f then h.choose else default
  refine' ⟨j, gg.map σ, _⟩
  ext x
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  erw [LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
  dsimp
  have h1 : ι (f x) = gg (C.π.app j x) := by
    change f.map (fun a b => if a = b then (0 : Fin 2) else 1) x = _
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [h, LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
    rfl
  have h2 : ∃ a : α, ι a = gg (C.π.app j x) := ⟨f x, h1⟩
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  erw [dif_pos h2]
  apply_fun ι
  · rw [h2.choose_spec]
    exact h1
  · intro a b hh
    have hhh := congr_fun hh a
    dsimp at hhh
    rw [if_pos rfl] at hhh
    split_ifs at hhh with hh1
    · exact hh1.symm
    · 

Proof state:
case neg
J : Type v
inst✝³ : SmallCategory J
inst✝² : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝¹ : Finite α
inst✝ : Nonempty α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
inhabited_h : Inhabited α
j : J
gg : LocallyConstant (↑(F.obj j).toCompHaus.toTop) (α → Fin 2)
h : LocallyConstant.map (fun a b => if a = b then 0 else 1) f = LocallyConstant.comap (⇑(C.π.app j)) gg
ι : α → α → Fin 2 := fun a b => if a = b then 0 else 1
σ : (α → Fin 2) → α := fun f => if h : ∃ a, ι a = f then Exists.choose h else default
x : ↑C.pt.toCompHaus.toTop
h1 : ι (f x) = gg ((C.π.app j) x)
h2 : ∃ a, ι a = gg ((C.π.app j) x)
a b : α
hh : ι a = ι b
hh1 : ¬b = a
hhh : 0 = 1
⊢ a = b

Next tactic:
exact False.elim (bot_ne_top hhh)
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  

Proof state:
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
⊢ ∃ j g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
have := preserves_smaller_limits_toTopCat.{u, v}
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  

Proof state:
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
⊢ ∃ j g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
let S := f.discreteQuotient
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  

Proof state:
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
⊢ ∃ j g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
let ff : S → α := f.lift
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  

Proof state:
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
⊢ ∃ j g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
cases isEmpty_or_nonempty S
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · 

Proof state:
case inl
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
⊢ ∃ j g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          exact isOpen_empty
        exact @Set.eq_empty_of_isEmpty _ hj _
      · ext x
        exact hj.elim' (C.π.app j x)
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      

Proof state:
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
⊢ ∃ j g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
refine' this.imp fun j hj => _
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      

Proof state:
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
⊢ ∃ g, f = LocallyConstant.comap (⇑(C.π.app j)) g

Next tactic:
refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · 

Proof state:
case refine'_1
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
A : Set α
⊢ IsOpen ((fun a => IsEmpty.elim hj a) ⁻¹' A)

Next tactic:
suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · 

Proof state:
case refine'_1
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝¹ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this✝ : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
A : Set α
this : (fun a => IsEmpty.elim hj a) ⁻¹' A = ∅
⊢ IsOpen ((fun a => IsEmpty.elim hj a) ⁻¹' A)

Next tactic:
rw [this]
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          

Proof state:
case refine'_1
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝¹ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this✝ : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
A : Set α
this : (fun a => IsEmpty.elim hj a) ⁻¹' A = ∅
⊢ IsOpen ∅

Next tactic:
exact isOpen_empty
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          exact isOpen_empty
        

Proof state:
case this
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
A : Set α
⊢ (fun a => IsEmpty.elim hj a) ⁻¹' A = ∅

Next tactic:
exact @Set.eq_empty_of_isEmpty _ hj _
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          exact isOpen_empty
        exact @Set.eq_empty_of_isEmpty _ hj _
      · 

Proof state:
case refine'_2
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
⊢ f =
    LocallyConstant.comap ⇑(C.π.app j)
      { toFun := fun a => IsEmpty.elim hj a,
        isLocallyConstant := (_ : ∀ (A : Set α), IsOpen ((fun a => IsEmpty.elim hj a) ⁻¹' A)) }

Next tactic:
ext x
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          exact isOpen_empty
        exact @Set.eq_empty_of_isEmpty _ hj _
      · ext x
        

Proof state:
case refine'_2.h
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this✝ : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
this : ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop
j : J
hj : IsEmpty ↑(F.obj j).toCompHaus.toTop
x : ↑C.pt.toCompHaus.toTop
⊢ f x =
    (LocallyConstant.comap ⇑(C.π.app j)
        { toFun := fun a => IsEmpty.elim hj a,
          isLocallyConstant := (_ : ∀ (A : Set α), IsOpen ((fun a => IsEmpty.elim hj a) ⁻¹' A)) })
      x

Next tactic:
exact hj.elim' (C.π.app j x)
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          exact isOpen_empty
        exact @Set.eq_empty_of_isEmpty _ hj _
      · ext x
        exact hj.elim' (C.π.app j x)
    

Proof state:
case inl
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
⊢ ∃ j, IsEmpty ↑(F.obj j).toCompHaus.toTop

Next tactic:
simp only [← not_nonempty_iff, ← not_forall]
/-- Any locally constant function from a cofiltered limit of profinite sets factors through
one of the components. -/
theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstant C.pt α) :
    ∃ (j : J) (g : LocallyConstant (F.obj j) α), f = g.comap (C.π.app _) := by
  have := preserves_smaller_limits_toTopCat.{u, v}
  let S := f.discreteQuotient
  let ff : S → α := f.lift
  cases isEmpty_or_nonempty S
  · suffices ∃ j, IsEmpty (F.obj j) by
      refine' this.imp fun j hj => _
      refine' ⟨⟨hj.elim, fun A => _⟩, _⟩
      · suffices : (fun a ↦ IsEmpty.elim hj a) ⁻¹' A = ∅
        · rw [this]
          exact isOpen_empty
        exact @Set.eq_empty_of_isEmpty _ hj _
      · ext x
        exact hj.elim' (C.π.app j x)
    simp only [← not_nonempty_iff, ← not_forall]
    

Proof state:
case inl
J : Type v
inst✝¹ : SmallCategory J
inst✝ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
this : PreservesLimitsOfSize.{v, v, max u v, max u v, max (u + 1) (v + 1), max (u + 1) (v + 1)} toTopCat
S : DiscreteQuotient ↑C.pt.toCompHaus.toTop := LocallyConstant.discreteQuotient f
ff : Quotient S.toSetoid → α := ⇑(LocallyConstant.lift f)
h✝ : IsEmpty (Quotient S.toSetoid)
⊢ ¬∀ (x : J), Nonempty ↑(F.obj x).toCompHaus.toTop

Next tactic:
intro h