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]
  

Proof state:
case intro.intro.h
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
⊢ f x = (⇑(LocallyConstant.map σ gg) ∘ ⇑(C.π.app j)) x

Next tactic:
dsimp
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
  

Proof state:
case intro.intro.h
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
⊢ f x = if h : ∃ a, (fun b => if a = b then 0 else 1) = gg ((C.π.app j) x) then Exists.choose h else default

Next tactic:
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
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
    

Proof state:
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
⊢ ι (f x) = gg ((C.π.app j) x)

Next tactic:
change f.map (fun a b => if a = b then (0 : Fin 2) else 1) x = _
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
    

Proof state:
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
⊢ (LocallyConstant.map (fun a b => if a = b then 0 else 1) f) x = gg ((C.π.app j) x)

Next tactic:
erw [h, LocallyConstant.coe_comap _ _ (C.π.app j).continuous]
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]
    

Proof state:
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
⊢ (⇑gg ∘ ⇑(C.π.app j)) x = gg ((C.π.app j) x)

Next tactic:
rfl
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
  

Proof state:
case intro.intro.h
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)
⊢ f x = if h : ∃ a, (fun b => if a = b then 0 else 1) = gg ((C.π.app j) x) then Exists.choose h else default

Next tactic:
have h2 : ∃ a : α, ι a = gg (C.π.app j x) := ⟨f x, h1⟩
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
  

Proof state:
case intro.intro.h
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)
⊢ f x = if h : ∃ a, (fun b => if a = b then 0 else 1) = gg ((C.π.app j) x) then Exists.choose h else default

Next tactic:
erw [dif_pos h2]
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]
  

Proof state:
case intro.intro.h
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)
⊢ f x = Exists.choose h2

Next tactic:
apply_fun ι
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 ι
  · 

Proof state:
case intro.intro.h
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)
⊢ ι (f x) = ι (Exists.choose h2)

Next tactic:
rw [h2.choose_spec]
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]
    

Proof state:
case intro.intro.h
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)
⊢ ι (f x) = gg ((C.π.app j) x)

Next tactic:
exact h1
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
  · 

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)
⊢ Function.Injective ι

Next tactic:
intro a b hh
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
    

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
⊢ a = b

Next tactic:
have hhh := congr_fun hh a
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
    

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 : ι a a = ι b a
⊢ a = b

Next tactic:
dsimp at hhh
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
    

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 : (if a = a then 0 else 1) = if b = a then 0 else 1
⊢ a = b

Next tactic:
rw [if_pos rfl] at hhh