l3lab/ntp-mathlib huggingface dataset:
/--
The extensive coverage on an extensive category `C`

TODO: use general colimit API instead of `IsIso (Sigma.desc π)`
-/
def extensiveCoverage [FinitaryPreExtensive C] : Coverage C where
  covering B := { S | ∃ (α : Type) (_ : Fintype α) (X : α → C) (π : (a : α) → (X a ⟶ B)),
    S = Presieve.ofArrows X π ∧ IsIso (Sigma.desc π) }
  pullback := by
    intro X Y f S ⟨α, hα, Z, π, hS, h_iso⟩
    let Z' : α → C := fun a ↦ pullback f (π a)
    let π' : (a : α) → Z' a ⟶ Y := fun a ↦ pullback.fst
    refine ⟨@Presieve.ofArrows C _ _ α Z' π', ⟨?_, ?_⟩⟩
    · constructor
      exact ⟨hα, Z', π', ⟨by simp only, FinitaryPreExtensive.sigma_desc_iso (fun x => π x) f h_iso⟩⟩
    · intro W g hg
      rcases hg with ⟨a⟩
      

Proof state:
case refine_2.mk
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : FinitaryPreExtensive C
X Y✝ : C
f : Y✝ ⟶ X
S : Presieve X
α : Type
hα : Fintype α
Z : α → C
π : (a : α) → Z a ⟶ X
hS : S = Presieve.ofArrows Z π
h_iso : IsIso (Sigma.desc π)
Z' : α → C := fun a => pullback f (π a)
π' : (a : α) → Z' a ⟶ Y✝ := fun a => pullback.fst
Y : C
a : α
⊢ ∃ W i e, S e ∧ i ≫ e = π' a ≫ f

Next tactic:
refine ⟨Z a, pullback.snd, π a, ?_, by rw [CategoryTheory.Limits.pullback.condition]⟩
/--
The extensive coverage on an extensive category `C`

TODO: use general colimit API instead of `IsIso (Sigma.desc π)`
-/
def extensiveCoverage [FinitaryPreExtensive C] : Coverage C where
  covering B := { S | ∃ (α : Type) (_ : Fintype α) (X : α → C) (π : (a : α) → (X a ⟶ B)),
    S = Presieve.ofArrows X π ∧ IsIso (Sigma.desc π) }
  pullback := by
    intro X Y f S ⟨α, hα, Z, π, hS, h_iso⟩
    let Z' : α → C := fun a ↦ pullback f (π a)
    let π' : (a : α) → Z' a ⟶ Y := fun a ↦ pullback.fst
    refine ⟨@Presieve.ofArrows C _ _ α Z' π', ⟨?_, ?_⟩⟩
    · constructor
      exact ⟨hα, Z', π', ⟨by simp only, FinitaryPreExtensive.sigma_desc_iso (fun x => π x) f h_iso⟩⟩
    · intro W g hg
      rcases hg with ⟨a⟩
      refine ⟨Z a, pullback.snd, π a, ?_, by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : FinitaryPreExtensive C
X Y✝ : C
f : Y✝ ⟶ X
S : Presieve X
α : Type
hα : Fintype α
Z : α → C
π : (a : α) → Z a ⟶ X
hS : S = Presieve.ofArrows Z π
h_iso : IsIso (Sigma.desc π)
Z' : α → C := fun a => pullback f (π a)
π' : (a : α) → Z' a ⟶ Y✝ := fun a => pullback.fst
Y : C
a : α
⊢ pullback.snd ≫ π a = π' a ≫ f

Next tactic:
rw [CategoryTheory.Limits.pullback.condition]
/--
The extensive coverage on an extensive category `C`

TODO: use general colimit API instead of `IsIso (Sigma.desc π)`
-/
def extensiveCoverage [FinitaryPreExtensive C] : Coverage C where
  covering B := { S | ∃ (α : Type) (_ : Fintype α) (X : α → C) (π : (a : α) → (X a ⟶ B)),
    S = Presieve.ofArrows X π ∧ IsIso (Sigma.desc π) }
  pullback := by
    intro X Y f S ⟨α, hα, Z, π, hS, h_iso⟩
    let Z' : α → C := fun a ↦ pullback f (π a)
    let π' : (a : α) → Z' a ⟶ Y := fun a ↦ pullback.fst
    refine ⟨@Presieve.ofArrows C _ _ α Z' π', ⟨?_, ?_⟩⟩
    · constructor
      exact ⟨hα, Z', π', ⟨by simp only, FinitaryPreExtensive.sigma_desc_iso (fun x => π x) f h_iso⟩⟩
    · intro W g hg
      rcases hg with ⟨a⟩
      refine ⟨Z a, pullback.snd, π a, ?_, by rw [CategoryTheory.Limits.pullback.condition]⟩
      

Proof state:
case refine_2.mk
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : FinitaryPreExtensive C
X Y✝ : C
f : Y✝ ⟶ X
S : Presieve X
α : Type
hα : Fintype α
Z : α → C
π : (a : α) → Z a ⟶ X
hS : S = Presieve.ofArrows Z π
h_iso : IsIso (Sigma.desc π)
Z' : α → C := fun a => pullback f (π a)
π' : (a : α) → Z' a ⟶ Y✝ := fun a => pullback.fst
Y : C
a : α
⊢ S (π a)

Next tactic:
rw [hS]
/--
The extensive coverage on an extensive category `C`

TODO: use general colimit API instead of `IsIso (Sigma.desc π)`
-/
def extensiveCoverage [FinitaryPreExtensive C] : Coverage C where
  covering B := { S | ∃ (α : Type) (_ : Fintype α) (X : α → C) (π : (a : α) → (X a ⟶ B)),
    S = Presieve.ofArrows X π ∧ IsIso (Sigma.desc π) }
  pullback := by
    intro X Y f S ⟨α, hα, Z, π, hS, h_iso⟩
    let Z' : α → C := fun a ↦ pullback f (π a)
    let π' : (a : α) → Z' a ⟶ Y := fun a ↦ pullback.fst
    refine ⟨@Presieve.ofArrows C _ _ α Z' π', ⟨?_, ?_⟩⟩
    · constructor
      exact ⟨hα, Z', π', ⟨by simp only, FinitaryPreExtensive.sigma_desc_iso (fun x => π x) f h_iso⟩⟩
    · intro W g hg
      rcases hg with ⟨a⟩
      refine ⟨Z a, pullback.snd, π a, ?_, by rw [CategoryTheory.Limits.pullback.condition]⟩
      rw [hS]
      

Proof state:
case refine_2.mk
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : FinitaryPreExtensive C
X Y✝ : C
f : Y✝ ⟶ X
S : Presieve X
α : Type
hα : Fintype α
Z : α → C
π : (a : α) → Z a ⟶ X
hS : S = Presieve.ofArrows Z π
h_iso : IsIso (Sigma.desc π)
Z' : α → C := fun a => pullback f (π a)
π' : (a : α) → Z' a ⟶ Y✝ := fun a => pullback.fst
Y : C
a : α
⊢ Presieve.ofArrows Z π (π a)

Next tactic:
exact Presieve.ofArrows.mk a
theorem effectiveEpi_desc_iff_effectiveEpiFamily [FinitaryPreExtensive C] {α : Type} [Fintype α]
    {B : C} (X : α → C) (π : (a : α) → X a ⟶ B) :
    EffectiveEpi (Sigma.desc π) ↔ EffectiveEpiFamily X π := by
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
α : Type
inst✝ : Fintype α
B : C
X : α → C
π : (a : α) → X a ⟶ B
⊢ EffectiveEpi (Sigma.desc π) ↔ EffectiveEpiFamily X π

Next tactic:
exact ⟨fun h ↦ ⟨⟨@effectiveEpiFamilyStructOfEffectiveEpiDesc _ _ _ _ X π _ h _ _ (fun g ↦
    (FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X a) g inferInstance).epi_of_iso)⟩⟩,
    fun _ ↦ inferInstance⟩
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    

Proof state:
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
⊢ ∃ β x X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : β), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
refine ⟨α, inferInstance, ?_⟩
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    

Proof state:
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
⊢ ∃ X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
⊢ ∃ X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
⊢ ∃ X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
⊢ ∃ X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
⊢ ∃ X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
⊢ ∃ X₂ π₂, EffectiveEpiFamily X₂ π₂ ∧ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
refine ⟨X₂, π₂, ?_, ?_⟩
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · 

Proof state:
case intro.intro.intro.intro.refine_1
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
⊢ EffectiveEpiFamily X₂ π₂

Next tactic:
have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by 

Proof state:
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
⊢ Sigma.desc π' ≫ g = Sigma.desc π₂

Next tactic:
ext
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; 

Proof state:
case h
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
b✝ : α
⊢ Sigma.ι (fun b => pullback g' (Sigma.ι X₁ b)) b✝ ≫ Sigma.desc π' ≫ g =
    Sigma.ι (fun b => pullback g' (Sigma.ι X₁ b)) b✝ ≫ Sigma.desc π₂

Next tactic:
simp
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
      

Proof state:
case intro.intro.intro.intro.refine_1
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
this : Sigma.desc π' ≫ g = Sigma.desc π₂
⊢ EffectiveEpiFamily X₂ π₂

Next tactic:
rw [← effectiveEpi_desc_iff_effectiveEpiFamily, ← this]
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
      rw [← effectiveEpi_desc_iff_effectiveEpiFamily, ← this]
      

Proof state:
case intro.intro.intro.intro.refine_1
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
this : Sigma.desc π' ≫ g = Sigma.desc π₂
⊢ EffectiveEpi (Sigma.desc π' ≫ g)

Next tactic:
infer_instance
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
      rw [← effectiveEpi_desc_iff_effectiveEpiFamily, ← this]
      infer_instance
    · 

Proof state:
case intro.intro.intro.intro.refine_2
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
⊢ ∃ i ι, ∀ (b : α), ι b ≫ π₁ (i b) = π₂ b ≫ f

Next tactic:
refine ⟨id, fun b ↦ pullback.snd, fun b ↦ ?_⟩
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
      rw [← effectiveEpi_desc_iff_effectiveEpiFamily, ← this]
      infer_instance
    · refine ⟨id, fun b ↦ pullback.snd, fun b ↦ ?_⟩
      

Proof state:
case intro.intro.intro.intro.refine_2
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
b : α
⊢ (fun b => pullback.snd) b ≫ π₁ (id b) = π₂ b ≫ f

Next tactic:
simp only [id_eq, Category.assoc, ← hg]
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
      rw [← effectiveEpi_desc_iff_effectiveEpiFamily, ← this]
      infer_instance
    · refine ⟨id, fun b ↦ pullback.snd, fun b ↦ ?_⟩
      simp only [id_eq, Category.assoc, ← hg]
      

Proof state:
case intro.intro.intro.intro.refine_2
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
b : α
⊢ pullback.snd ≫ π₁ b = pullback.fst ≫ g' ≫ Sigma.desc π₁

Next tactic:
rw [← Category.assoc, pullback.condition]
instance [FinitaryPreExtensive C] [Preregular C] : Precoherent C where
  pullback {B₁ B₂} f α _ X₁ π₁ h := by
    refine ⟨α, inferInstance, ?_⟩
    obtain ⟨Y, g, _, g', hg⟩ := Preregular.exists_fac f (Sigma.desc π₁)
    let X₂ := fun a ↦ pullback g' (Sigma.ι X₁ a)
    let π₂ := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a) ≫ g
    let π' := fun a ↦ pullback.fst (f := g') (g := Sigma.ι X₁ a)
    have _ := FinitaryPreExtensive.sigma_desc_iso (fun a ↦ Sigma.ι X₁ a) g' inferInstance
    refine ⟨X₂, π₂, ?_, ?_⟩
    · have : (Sigma.desc π' ≫ g) = Sigma.desc π₂ := by ext; simp
      rw [← effectiveEpi_desc_iff_effectiveEpiFamily, ← this]
      infer_instance
    · refine ⟨id, fun b ↦ pullback.snd, fun b ↦ ?_⟩
      simp only [id_eq, Category.assoc, ← hg]
      rw [← Category.assoc, pullback.condition]
      

Proof state:
case intro.intro.intro.intro.refine_2
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : FinitaryPreExtensive C
inst✝ : Preregular C
B₁ B₂ : C
f : B₂ ⟶ B₁
α : Type
x✝¹ : Fintype α
X₁ : α → C
π₁ : (a : α) → X₁ a ⟶ B₁
h : EffectiveEpiFamily X₁ π₁
Y : C
g : Y ⟶ B₂
w✝ : EffectiveEpi g
g' : Y ⟶ ∐ fun b => X₁ b
hg : g' ≫ Sigma.desc π₁ = g ≫ f
X₂ : α → C := fun a => pullback g' (Sigma.ι X₁ a)
π₂ : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ B₂ := fun a => pullback.fst ≫ g
π' : (a : α) → pullback g' (Sigma.ι X₁ a) ⟶ Y := fun a => pullback.fst
x✝ : IsIso (Sigma.desc fun x => pullback.fst)
b : α
⊢ pullback.snd ≫ π₁ b = (pullback.snd ≫ Sigma.ι X₁ b) ≫ Sigma.desc π₁

Next tactic:
simp
/-- The union of the extensive and regular coverages generates the coherent topology on `C`. -/
lemma extensive_regular_generate_coherent [Preregular C] [FinitaryPreExtensive C] :
    ((extensiveCoverage C) ⊔ (regularCoverage C)).toGrothendieck =
    (coherentTopology C) := by
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
inst✝¹ : Preregular C
inst✝ : FinitaryPreExtensive C
⊢ Coverage.toGrothendieck C (extensiveCoverage C ⊔ regularCoverage C) = coherentTopology C

Next tactic:
ext B S