l3lab/ntp-mathlib huggingface dataset:
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
⊢ LocallyConstant.map (fun a b => if a = b then 0 else 1) f = LocallyConstant.comap (⇑(C.π.app j0)) ggg

Next tactic:
have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by 

Proof state:
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
⊢ LocallyConstant.map ι f = LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f))

Next tactic:
simp
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
this : LocallyConstant.map ι f = LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f))
⊢ LocallyConstant.map (fun a b => if a = b then 0 else 1) f = LocallyConstant.comap (⇑(C.π.app j0)) ggg

Next tactic:
rw [this]
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; 

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
this : LocallyConstant.map ι f = LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f))
⊢ LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f)) = LocallyConstant.comap (⇑(C.π.app j0)) ggg

Next tactic:
clear this
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; clear this
  

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
⊢ LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f)) = LocallyConstant.comap (⇑(C.π.app j0)) ggg

Next tactic:
have :
    LocallyConstant.comap (C.π.app j0) ggg =
      LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip :=
    by simp
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; clear this
  have :
    LocallyConstant.comap (C.π.app j0) ggg =
      LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip :=
    by 

Proof state:
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
⊢ LocallyConstant.comap (⇑(C.π.app j0)) ggg =
    LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.comap (⇑(C.π.app j0)) ggg))

Next tactic:
simp
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; clear this
  have :
    LocallyConstant.comap (C.π.app j0) ggg =
      LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip :=
    by simp
  

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
this :
  LocallyConstant.comap (⇑(C.π.app j0)) ggg =
    LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.comap (⇑(C.π.app j0)) ggg))
⊢ LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f)) = LocallyConstant.comap (⇑(C.π.app j0)) ggg

Next tactic:
rw [this]
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; clear this
  have :
    LocallyConstant.comap (C.π.app j0) ggg =
      LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip :=
    by simp
  rw [this]; 

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
this :
  LocallyConstant.comap (⇑(C.π.app j0)) ggg =
    LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.comap (⇑(C.π.app j0)) ggg))
⊢ LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f)) =
    LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.comap (⇑(C.π.app j0)) ggg))

Next tactic:
clear this
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; clear this
  have :
    LocallyConstant.comap (C.π.app j0) ggg =
      LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip :=
    by simp
  rw [this]; clear this
  

Proof state:
case intro.intro
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
⊢ LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.map ι f)) =
    LocallyConstant.unflip (LocallyConstant.flip (LocallyConstant.comap (⇑(C.π.app j0)) ggg))

Next tactic:
congr 1
theorem exists_locallyConstant_finite_aux {α : Type*} [Finite α] (hC : IsLimit C)
    (f : LocallyConstant C.pt α) : ∃ (j : J) (g : LocallyConstant (F.obj j) (α → Fin 2)),
      (f.map fun a b => if a = b then (0 : Fin 2) else 1) = g.comap (C.π.app _) := by
  cases nonempty_fintype α
  let ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
  let ff := (f.map ι).flip
  have hff := fun a : α => exists_locallyConstant_fin_two _ hC (ff a)
  choose j g h using hff
  let G : Finset J := Finset.univ.image j
  obtain ⟨j0, hj0⟩ := IsCofiltered.inf_objs_exists G
  have hj : ∀ a, j a ∈ (Finset.univ.image j : Finset J) := by
    intro a
    simp only [Finset.mem_image, Finset.mem_univ, true_and, exists_apply_eq_apply]
  let fs : ∀ a : α, j0 ⟶ j a := fun a => (hj0 (hj a)).some
  let gg : α → LocallyConstant (F.obj j0) (Fin 2) := fun a => (g a).comap (F.map (fs _))
  let ggg := LocallyConstant.unflip gg
  refine' ⟨j0, ggg, _⟩
  have : f.map ι = LocallyConstant.unflip (f.map ι).flip := by simp
  rw [this]; clear this
  have :
    LocallyConstant.comap (C.π.app j0) ggg =
      LocallyConstant.unflip (LocallyConstant.comap (C.π.app j0) ggg).flip :=
    by simp
  rw [this]; clear this
  congr 1
  

Proof state:
case intro.intro.e_f
J : Type v
inst✝² : SmallCategory J
inst✝¹ : IsCofiltered J
F : J ⥤ ProfiniteMax
C : Cone F
α : Type u_1
inst✝ : Finite α
hC : IsLimit C
f : LocallyConstant (↑C.pt.toCompHaus.toTop) α
val✝ : Fintype α
ι : α → α → Fin 2 := fun x y => if x = y then 0 else 1
ff : α → LocallyConstant (↑C.pt.toCompHaus.toTop) (Fin 2) := LocallyConstant.flip (LocallyConstant.map ι f)
j : α → J
g : (a : α) → LocallyConstant (↑(F.obj (j a)).toCompHaus.toTop) (Fin 2)
h : ∀ (a : α), ff a = LocallyConstant.comap (⇑(C.π.app (j a))) (g a)
G : Finset J := Finset.image j Finset.univ
j0 : J
hj0 : ∀ {X : J}, X ∈ G → Nonempty (j0 ⟶ X)
hj : ∀ (a : α), j a ∈ Finset.image j Finset.univ
fs : (a : α) → j0 ⟶ j a := fun a => Nonempty.some (_ : Nonempty (j0 ⟶ j a))
gg : α → LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (Fin 2) :=
  fun a => LocallyConstant.comap (⇑(F.map (fs a))) (g a)
ggg : LocallyConstant (↑(F.obj j0).toCompHaus.toTop) (α → Fin 2) := LocallyConstant.unflip gg
⊢ LocallyConstant.flip (LocallyConstant.map ι f) = LocallyConstant.flip (LocallyConstant.comap (⇑(C.π.app j0)) ggg)

Next tactic:
ext1 a