Lean4
/-- Given a `P : PrelocalPredicate`, we can always construct a `LocalPredicate`
by asking that the condition from `P` holds locally near every point.
-/
def sheafify {T : X → Type*} (P : PrelocalPredicate T) : LocalPredicate T
where
pred {U} f := ∀ x : U, ∃ (V : Opens X) (_ : x.1 ∈ V) (i : V ⟶ U), P.pred fun x : V ↦ f (i x : U)
res {V U} i f w
x := by
specialize w (i x)
rcases w with ⟨V', m', i', p⟩
exact ⟨V ⊓ V', ⟨x.2, m'⟩, V.infLELeft _, P.res (V.infLERight V') _ p⟩
locality {U} f w
x := by
specialize w x
rcases w with ⟨V, m, i, p⟩
specialize p ⟨x.1, m⟩
rcases p with ⟨V', m', i', p'⟩
exact ⟨V', m', i' ≫ i, p'⟩