l3lab/ntp-mathlib huggingface dataset:
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; 

Proof state:
case mk
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
hSF : ∀ {B : C} (S : Presieve B) [inst : regular S] [inst : hasPullbacks S], IsSheafFor F S
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this : regular (ofArrows (fun x => X) fun x => π)
Z✝ : C
x✝ : Z✝ ⟶ B
hg : ofArrows (fun x => X) (fun x => π) x✝
i✝ : Unit
⊢ HasPullback π x✝

Next tactic:
cases hg
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; 

Proof state:
case mk.mk
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
hSF : ∀ {B : C} (S : Presieve B) [inst : regular S] [inst : hasPullbacks S], IsSheafFor F S
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this : regular (ofArrows (fun x => X) fun x => π)
i✝¹ i✝ : Unit
⊢ HasPullback π π

Next tactic:
infer_instance
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
hSF : ∀ {B : C} (S : Presieve B) [inst : regular S] [inst : hasPullbacks S], IsSheafFor F S
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
⊢ Function.Bijective (MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π))

Next tactic:
specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : IsSheafFor F (ofArrows (fun x => X) fun x => π)
⊢ Function.Bijective (MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π))

Next tactic:
rw [isSheafFor_arrows_iff_pullbacks] at hSF
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  rw [isSheafFor_arrows_iff_pullbacks] at hSF
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : ∀ (x : Unit → F.obj (op X)), Arrows.PullbackCompatible F (fun x => π) x → ∃! t, ∀ (i : Unit), F.map π.op t = x i
⊢ Function.Bijective (MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π))

Next tactic:
rw [Function.bijective_iff_existsUnique]
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  rw [isSheafFor_arrows_iff_pullbacks] at hSF
  rw [Function.bijective_iff_existsUnique]
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : ∀ (x : Unit → F.obj (op X)), Arrows.PullbackCompatible F (fun x => π) x → ∃! t, ∀ (i : Unit), F.map π.op t = x i
⊢ ∀ (b : ↑{x | F.map pullback.fst.op x = F.map pullback.snd.op x}),
    ∃! a, MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π) a = b

Next tactic:
intro ⟨x, hx⟩
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  rw [isSheafFor_arrows_iff_pullbacks] at hSF
  rw [Function.bijective_iff_existsUnique]
  intro ⟨x, hx⟩
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : ∀ (x : Unit → F.obj (op X)), Arrows.PullbackCompatible F (fun x => π) x → ∃! t, ∀ (i : Unit), F.map π.op t = x i
x : F.obj (op X)
hx : x ∈ {x | F.map pullback.fst.op x = F.map pullback.snd.op x}
⊢ ∃! a,
    MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π) a =
      { val := x, property := hx }

Next tactic:
obtain ⟨t, ht, ht'⟩ := hSF (fun _ ↦ x) (fun _ _ ↦ hx)
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  rw [isSheafFor_arrows_iff_pullbacks] at hSF
  rw [Function.bijective_iff_existsUnique]
  intro ⟨x, hx⟩
  obtain ⟨t, ht, ht'⟩ := hSF (fun _ ↦ x) (fun _ _ ↦ hx)
  

Proof state:
case intro.intro
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : ∀ (x : Unit → F.obj (op X)), Arrows.PullbackCompatible F (fun x => π) x → ∃! t, ∀ (i : Unit), F.map π.op t = x i
x : F.obj (op X)
hx : x ∈ {x | F.map pullback.fst.op x = F.map pullback.snd.op x}
t : F.obj (op B)
ht : Unit → F.map π.op t = x
ht' : ∀ (y : F.obj (op B)), (fun t => Unit → F.map π.op t = x) y → y = t
⊢ ∃! a,
    MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π) a =
      { val := x, property := hx }

Next tactic:
refine ⟨t, ?_, fun y h ↦ ht' y ?_⟩
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  rw [isSheafFor_arrows_iff_pullbacks] at hSF
  rw [Function.bijective_iff_existsUnique]
  intro ⟨x, hx⟩
  obtain ⟨t, ht, ht'⟩ := hSF (fun _ ↦ x) (fun _ _ ↦ hx)
  refine ⟨t, ?_, fun y h ↦ ht' y ?_⟩
  · 

Proof state:
case intro.intro.refine_1
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : ∀ (x : Unit → F.obj (op X)), Arrows.PullbackCompatible F (fun x => π) x → ∃! t, ∀ (i : Unit), F.map π.op t = x i
x : F.obj (op X)
hx : x ∈ {x | F.map pullback.fst.op x = F.map pullback.snd.op x}
t : F.obj (op B)
ht : Unit → F.map π.op t = x
ht' : ∀ (y : F.obj (op B)), (fun t => Unit → F.map π.op t = x) y → y = t
⊢ (fun a =>
      MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π) a =
        { val := x, property := hx })
    t

Next tactic:
simpa [MapToEqualizer] using ht ()
lemma equalizerCondition_of_regular {F : Cᵒᵖ ⥤ Type (max u v)}
    (hSF : ∀ {B : C} (S : Presieve B) [S.regular] [S.hasPullbacks], S.IsSheafFor F) :
    EqualizerCondition F := by
  intro X B π _ _
  have : (ofArrows (fun _ ↦ X) (fun _ ↦ π)).regular := ⟨X, π, rfl, inferInstance⟩
  have : (ofArrows (fun () ↦ X) (fun _ ↦ π)).hasPullbacks := ⟨
      fun hf _ hg ↦ (by cases hf; cases hg; infer_instance)⟩
  specialize hSF (ofArrows (fun () ↦ X) (fun _ ↦ π))
  rw [isSheafFor_arrows_iff_pullbacks] at hSF
  rw [Function.bijective_iff_existsUnique]
  intro ⟨x, hx⟩
  obtain ⟨t, ht, ht'⟩ := hSF (fun _ ↦ x) (fun _ _ ↦ hx)
  refine ⟨t, ?_, fun y h ↦ ht' y ?_⟩
  · simpa [MapToEqualizer] using ht ()
  · 

Proof state:
case intro.intro.refine_2
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
X B : C
π : X ⟶ B
inst✝¹ : EffectiveEpi π
inst✝ : HasPullback π π
this✝ : regular (ofArrows (fun x => X) fun x => π)
this : hasPullbacks (ofArrows (fun x => X) fun x => π)
hSF : ∀ (x : Unit → F.obj (op X)), Arrows.PullbackCompatible F (fun x => π) x → ∃! t, ∀ (i : Unit), F.map π.op t = x i
x : F.obj (op X)
hx : x ∈ {x | F.map pullback.fst.op x = F.map pullback.snd.op x}
t : F.obj (op B)
ht : Unit → F.map π.op t = x
ht' : ∀ (y : F.obj (op B)), (fun t => Unit → F.map π.op t = x) y → y = t
y : F.obj (op B)
h :
  (fun a =>
      MapToEqualizer F π pullback.fst pullback.snd (_ : pullback.fst ≫ π = pullback.snd ≫ π) a =
        { val := x, property := hx })
    y
⊢ (fun t => Unit → F.map π.op t = x) y

Next tactic:
simpa [MapToEqualizer] using h
lemma isSheafFor_regular_of_projective {X : C} (S : Presieve X) [S.regular] [Projective X]
    (F : Cᵒᵖ ⥤ Type (max u v)) : S.IsSheafFor F := by
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
X : C
S : Presieve X
inst✝¹ : regular S
inst✝ : Projective X
F : Cᵒᵖ ⥤ Type (max u v)
⊢ IsSheafFor F S

Next tactic:
obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
lemma isSheafFor_regular_of_projective {X : C} (S : Presieve X) [S.regular] [Projective X]
    (F : Cᵒᵖ ⥤ Type (max u v)) : S.IsSheafFor F := by
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  

Proof state:
case intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
X : C
inst✝¹ : Projective X
F : Cᵒᵖ ⥤ Type (max u v)
Y : C
f : Y ⟶ X
hf : EffectiveEpi f
inst✝ : regular (ofArrows (fun x => Y) fun x => f)
⊢ IsSheafFor F (ofArrows (fun x => Y) fun x => f)

Next tactic:
rw [isSheafFor_arrows_iff]
lemma isSheafFor_regular_of_projective {X : C} (S : Presieve X) [S.regular] [Projective X]
    (F : Cᵒᵖ ⥤ Type (max u v)) : S.IsSheafFor F := by
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  rw [isSheafFor_arrows_iff]
  

Proof state:
case intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
X : C
inst✝¹ : Projective X
F : Cᵒᵖ ⥤ Type (max u v)
Y : C
f : Y ⟶ X
hf : EffectiveEpi f
inst✝ : regular (ofArrows (fun x => Y) fun x => f)
⊢ ∀ (x : Unit → F.obj (op Y)), Arrows.Compatible F (fun x => f) x → ∃! t, ∀ (i : Unit), F.map f.op t = x i

Next tactic:
refine fun x hx ↦ ⟨F.map (Projective.factorThru (𝟙 _) f).op <| x (), fun _ ↦ ?_, fun y h ↦ ?_⟩
lemma isSheafFor_regular_of_projective {X : C} (S : Presieve X) [S.regular] [Projective X]
    (F : Cᵒᵖ ⥤ Type (max u v)) : S.IsSheafFor F := by
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  rw [isSheafFor_arrows_iff]
  refine fun x hx ↦ ⟨F.map (Projective.factorThru (𝟙 _) f).op <| x (), fun _ ↦ ?_, fun y h ↦ ?_⟩
  · 

Proof state:
case intro.intro.intro.refine_1
C : Type u
inst✝² : Category.{v, u} C
X : C
inst✝¹ : Projective X
F : Cᵒᵖ ⥤ Type (max u v)
Y : C
f : Y ⟶ X
hf : EffectiveEpi f
inst✝ : regular (ofArrows (fun x => Y) fun x => f)
x : Unit → F.obj (op Y)
hx : Arrows.Compatible F (fun x => f) x
x✝ : Unit
⊢ F.map f.op (F.map (Projective.factorThru (𝟙 X) f).op (x ())) = x x✝

Next tactic:
simpa using (hx () () Y (𝟙 Y) (f ≫ (Projective.factorThru (𝟙 _) f)) (by simp)).symm
lemma isSheafFor_regular_of_projective {X : C} (S : Presieve X) [S.regular] [Projective X]
    (F : Cᵒᵖ ⥤ Type (max u v)) : S.IsSheafFor F := by
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  rw [isSheafFor_arrows_iff]
  refine fun x hx ↦ ⟨F.map (Projective.factorThru (𝟙 _) f).op <| x (), fun _ ↦ ?_, fun y h ↦ ?_⟩
  · simpa using (hx () () Y (𝟙 Y) (f ≫ (Projective.factorThru (𝟙 _) f)) (by 

Proof state:
C : Type u
inst✝² : Category.{v, u} C
X : C
inst✝¹ : Projective X
F : Cᵒᵖ ⥤ Type (max u v)
Y : C
f : Y ⟶ X
hf : EffectiveEpi f
inst✝ : regular (ofArrows (fun x => Y) fun x => f)
x : Unit → F.obj (op Y)
hx : Arrows.Compatible F (fun x => f) x
x✝ : Unit
⊢ 𝟙 Y ≫ (fun x => f) () = (f ≫ Projective.factorThru (𝟙 X) f) ≫ (fun x => f) ()

Next tactic:
simp
lemma isSheafFor_regular_of_projective {X : C} (S : Presieve X) [S.regular] [Projective X]
    (F : Cᵒᵖ ⥤ Type (max u v)) : S.IsSheafFor F := by
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  rw [isSheafFor_arrows_iff]
  refine fun x hx ↦ ⟨F.map (Projective.factorThru (𝟙 _) f).op <| x (), fun _ ↦ ?_, fun y h ↦ ?_⟩
  · simpa using (hx () () Y (𝟙 Y) (f ≫ (Projective.factorThru (𝟙 _) f)) (by simp)).symm
  · 

Proof state:
case intro.intro.intro.refine_2
C : Type u
inst✝² : Category.{v, u} C
X : C
inst✝¹ : Projective X
F : Cᵒᵖ ⥤ Type (max u v)
Y : C
f : Y ⟶ X
hf : EffectiveEpi f
inst✝ : regular (ofArrows (fun x => Y) fun x => f)
x : Unit → F.obj (op Y)
hx : Arrows.Compatible F (fun x => f) x
y : F.obj (op X)
h : (fun t => ∀ (i : Unit), F.map f.op t = x i) y
⊢ y = F.map (Projective.factorThru (𝟙 X) f).op (x ())

Next tactic:
simp only [← h (), ← FunctorToTypes.map_comp_apply, ← op_comp, Projective.factorThru_comp,
      op_id, FunctorToTypes.map_id_apply]
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
⊢ IsSheaf (Coverage.toGrothendieck C (regularCoverage C)) F ↔ EqualizerCondition F

Next tactic:
rw [Presieve.isSheaf_coverage]
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  rw [Presieve.isSheaf_coverage]
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
⊢ (∀ {X : C}, ∀ R ∈ Coverage.covering (regularCoverage C) X, IsSheafFor F R) ↔ EqualizerCondition F

Next tactic:
refine ⟨fun h ↦ equalizerCondition_of_regular fun S ⟨Y, f, hh⟩ _ ↦ h S ⟨Y, f, hh⟩, ?_⟩
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  rw [Presieve.isSheaf_coverage]
  refine ⟨fun h ↦ equalizerCondition_of_regular fun S ⟨Y, f, hh⟩ _ ↦ h S ⟨Y, f, hh⟩, ?_⟩
  

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
⊢ EqualizerCondition F → ∀ {X : C}, ∀ R ∈ Coverage.covering (regularCoverage C) X, IsSheafFor F R

Next tactic:
rintro h X S ⟨Y, f, rfl, hf⟩
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  rw [Presieve.isSheaf_coverage]
  refine ⟨fun h ↦ equalizerCondition_of_regular fun S ⟨Y, f, hh⟩ _ ↦ h S ⟨Y, f, hh⟩, ?_⟩
  rintro h X S ⟨Y, f, rfl, hf⟩
  

Proof state:
case intro.intro.intro
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
h : EqualizerCondition F
X Y : C
f : Y ⟶ X
hf : EffectiveEpi f
⊢ IsSheafFor F (ofArrows (fun x => Y) fun x => f)

Next tactic:
exact @isSheafFor _ _ _ _ ⟨Y, f, rfl, hf⟩ ⟨fun g _ h ↦ by cases g; cases h; infer_instance⟩ _ h
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  rw [Presieve.isSheaf_coverage]
  refine ⟨fun h ↦ equalizerCondition_of_regular fun S ⟨Y, f, hh⟩ _ ↦ h S ⟨Y, f, hh⟩, ?_⟩
  rintro h X S ⟨Y, f, rfl, hf⟩
  exact @isSheafFor _ _ _ _ ⟨Y, f, rfl, hf⟩ ⟨fun g _ h ↦ by 

Proof state:
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
h✝ : EqualizerCondition F
X Y : C
f : Y ⟶ X
hf : EffectiveEpi f
Y✝ Z✝ : C
f✝ : Y✝ ⟶ X
g : ofArrows (fun x => Y) (fun x => f) f✝
x✝ : Z✝ ⟶ X
h : ofArrows (fun x => Y) (fun x => f) x✝
⊢ HasPullback f✝ x✝

Next tactic:
cases g
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  rw [Presieve.isSheaf_coverage]
  refine ⟨fun h ↦ equalizerCondition_of_regular fun S ⟨Y, f, hh⟩ _ ↦ h S ⟨Y, f, hh⟩, ?_⟩
  rintro h X S ⟨Y, f, rfl, hf⟩
  exact @isSheafFor _ _ _ _ ⟨Y, f, rfl, hf⟩ ⟨fun g _ h ↦ by cases g; 

Proof state:
case mk
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
h✝ : EqualizerCondition F
X Y : C
f : Y ⟶ X
hf : EffectiveEpi f
Z✝ : C
x✝ : Z✝ ⟶ X
h : ofArrows (fun x => Y) (fun x => f) x✝
i✝ : Unit
⊢ HasPullback f x✝

Next tactic:
cases h
lemma EqualizerCondition.isSheaf_iff (F : Cᵒᵖ ⥤ Type (max u v))
    [∀ ⦃X Y : C⦄ (π : X ⟶ Y) [EffectiveEpi π], HasPullback π π] [Preregular C] :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck F ↔ EqualizerCondition F := by
  rw [Presieve.isSheaf_coverage]
  refine ⟨fun h ↦ equalizerCondition_of_regular fun S ⟨Y, f, hh⟩ _ ↦ h S ⟨Y, f, hh⟩, ?_⟩
  rintro h X S ⟨Y, f, rfl, hf⟩
  exact @isSheafFor _ _ _ _ ⟨Y, f, rfl, hf⟩ ⟨fun g _ h ↦ by cases g; cases h; 

Proof state:
case mk.mk
C : Type u
inst✝² : Category.{v, u} C
F : Cᵒᵖ ⥤ Type (max u v)
inst✝¹ : ∀ ⦃X Y : C⦄ (π : X ⟶ Y) [inst : EffectiveEpi π], HasPullback π π
inst✝ : Preregular C
h : EqualizerCondition F
X Y : C
f : Y ⟶ X
hf : EffectiveEpi f
i✝¹ i✝ : Unit
⊢ HasPullback f f

Next tactic:
infer_instance
/-- Every Yoneda-presheaf is a sheaf for the regular topology. -/
theorem isSheaf_yoneda_obj [Preregular C] (W : C)  :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck (yoneda.obj W) := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preregular C
W : C
⊢ IsSheaf (Coverage.toGrothendieck C (regularCoverage C)) (yoneda.obj W)

Next tactic:
rw [isSheaf_coverage]
/-- Every Yoneda-presheaf is a sheaf for the regular topology. -/
theorem isSheaf_yoneda_obj [Preregular C] (W : C)  :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck (yoneda.obj W) := by
  rw [isSheaf_coverage]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preregular C
W : C
⊢ ∀ {X : C}, ∀ R ∈ Coverage.covering (regularCoverage C) X, IsSheafFor (yoneda.obj W) R

Next tactic:
intro X S ⟨_, hS⟩
/-- Every Yoneda-presheaf is a sheaf for the regular topology. -/
theorem isSheaf_yoneda_obj [Preregular C] (W : C)  :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck (yoneda.obj W) := by
  rw [isSheaf_coverage]
  intro X S ⟨_, hS⟩
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preregular C
W X : C
S : Presieve X
w✝ : C
hS : ∃ f, (S = ofArrows (fun x => w✝) fun x => f) ∧ EffectiveEpi f
⊢ IsSheafFor (yoneda.obj W) S

Next tactic:
have : S.regular := ⟨_, hS⟩
/-- Every Yoneda-presheaf is a sheaf for the regular topology. -/
theorem isSheaf_yoneda_obj [Preregular C] (W : C)  :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck (yoneda.obj W) := by
  rw [isSheaf_coverage]
  intro X S ⟨_, hS⟩
  have : S.regular := ⟨_, hS⟩
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preregular C
W X : C
S : Presieve X
w✝ : C
hS : ∃ f, (S = ofArrows (fun x => w✝) fun x => f) ∧ EffectiveEpi f
this : regular S
⊢ IsSheafFor (yoneda.obj W) S

Next tactic:
obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
/-- Every Yoneda-presheaf is a sheaf for the regular topology. -/
theorem isSheaf_yoneda_obj [Preregular C] (W : C)  :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck (yoneda.obj W) := by
  rw [isSheaf_coverage]
  intro X S ⟨_, hS⟩
  have : S.regular := ⟨_, hS⟩
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  

Proof state:
case intro.intro.intro
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preregular C
W X w✝ Y : C
f : Y ⟶ X
hf : EffectiveEpi f
hS : ∃ f_1, ((ofArrows (fun x => Y) fun x => f) = ofArrows (fun x => w✝) fun x => f_1) ∧ EffectiveEpi f_1
this : regular (ofArrows (fun x => Y) fun x => f)
⊢ IsSheafFor (yoneda.obj W) (ofArrows (fun x => Y) fun x => f)

Next tactic:
have h_colim := isColimitOfEffectiveEpiStruct f hf.effectiveEpi.some
/-- Every Yoneda-presheaf is a sheaf for the regular topology. -/
theorem isSheaf_yoneda_obj [Preregular C] (W : C)  :
    Presieve.IsSheaf (regularCoverage C).toGrothendieck (yoneda.obj W) := by
  rw [isSheaf_coverage]
  intro X S ⟨_, hS⟩
  have : S.regular := ⟨_, hS⟩
  obtain ⟨Y, f, rfl, hf⟩ := Presieve.regular.single_epi (R := S)
  have h_colim := isColimitOfEffectiveEpiStruct f hf.effectiveEpi.some
  

Proof state:
case intro.intro.intro
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preregular C
W X w✝ Y : C
f : Y ⟶ X
hf : EffectiveEpi f
hS : ∃ f_1, ((ofArrows (fun x => Y) fun x => f) = ofArrows (fun x => w✝) fun x => f_1) ∧ EffectiveEpi f_1
this : regular (ofArrows (fun x => Y) fun x => f)
h_colim : IsColimit (cocone (Sieve.generateSingleton f).arrows)
⊢ IsSheafFor (yoneda.obj W) (ofArrows (fun x => Y) fun x => f)

Next tactic:
rw [← Sieve.generateSingleton_eq, ← Presieve.ofArrows_pUnit] at h_colim