Lean4
/-- A pretopology `K` can be completed to a Grothendieck topology `J` by declaring a sieve to be
`J`-covering if it contains a family in `K`.
See also [MM92] Chapter III, Section 2, Equation (2).
-/
@[stacks 00ZC]
def toGrothendieck (K : Pretopology C) : GrothendieckTopology C
where
sieves X S := ∃ R ∈ K X, R ≤ (S : Presieve _)
top_mem' _ := ⟨Presieve.singleton (𝟙 _), K.has_isos _, fun _ _ _ => ⟨⟩⟩
pullback_stable' X Y S
g := by
rintro ⟨R, hR, RS⟩
refine ⟨_, K.pullbacks g _ hR, ?_⟩
rw [← Sieve.generate_le_iff, Sieve.pullbackArrows_comm]
apply Sieve.pullback_monotone
rwa [Sieve.giGenerate.gc]
transitive' := by
rintro X S ⟨R', hR', RS⟩ R t
choose t₁ t₂ t₃ using t
refine ⟨_, K.transitive _ _ hR' fun _ f hf => t₂ (RS _ hf), ?_⟩
rintro Y _ ⟨Z, g, f, hg, hf, rfl⟩
apply t₃ (RS _ hg) _ hf