Everywhere locally, nowhere globally
On the punctured plane , does have a logarithm — a holomorphic with ? Near every point, yes: on any disc avoiding there is a branch of , unique up to adding . On all of , no: following a branch once around the origin adds . The question "does a solution exist?" has a local answer (yes, everywhere) and a global answer (no), and the gap between them is a topological invariant of — the class of the loop around .
Many problems have this shape: solving a differential equation, finding a potential for a vector field with zero curl, choosing a consistent orientation, building a meromorphic function with prescribed poles (Mittag-Leffler), patching local coordinates into a manifold. A sheaf is the structure that records what exists locally and how local pieces restrict and glue. Its global sections are the global solutions, its stalks describe what happens at a point, and its cohomology measures the obstructions in between.
Sheaves are also a bridge. Topologically they are spaces lying over (étale spaces, covering spaces); geometrically they are how algebraic and complex geometry define their spaces (a scheme is a space with a sheaf of rings); categorically they form a topos, a universe of "sets varying over " with its own logic. This lesson builds on point-set topology and limits and colimits.
Restrict, compare, glue
Think of an atlas. Each page is a map of a region; a map of a region can be cut down to a map of any smaller region; and if maps of two regions agree where the regions overlap, they combine into one map of the union — in exactly one way. Replace "map of a region" by "continuous function on an open set", or "solution of a differential equation on an open set", or "branch of on an open set", and you have the three ingredients of a sheaf:
- sections over each open set ;
- restriction to smaller open sets , compatible with restricting in stages;
- gluing: sections over the pieces of an open cover that agree on overlaps come from exactly one section over the union.
Not every natural assignment glues. Bounded functions do not: the function is bounded on every bounded interval, and these local pieces agree, but they glue to an unbounded function on . Boundedness is a global condition; continuity is local. Sheaves are exactly the assignments defined by local conditions.
Definitions
Let be a topological space and the poset of its open sets, viewed as a category with an arrow when .
Definition— presheaf
A presheaf (of sets) on is a functor : a set of sections for each open and a restriction map , , for each , with and . Elements of are global sections. A morphism of presheaves is a natural transformation: maps commuting with restriction. Presheaves of abelian groups, rings or modules are defined in the same way.
Definition— sheaf
A presheaf is a sheaf if for every open and every open cover :
- (Locality) if satisfy for all , then ;
- (Gluing) if satisfy for all , then there is with for all .
Equivalently, the diagram below is an equaliser in , where , and . Sheaves form a full subcategory of the presheaf category .
Definition— stalk; germ
The stalk of a presheaf at is the colimit over open neighbourhoods of ,
The class of is its germ at . A morphism induces maps on stalks.
Definition— étale space
The étale space of is with the topology generated by the sets for , and projection . Every section becomes a continuous section of over , and is a local homeomorphism.
Definition— direct image; skyscraper
For a continuous map and a sheaf on , the direct image is the sheaf on . For a point and a set , the skyscraper sheaf has sections over open sets containing and a single point otherwise.
Examples and non-examples
Example— Sheaves of functions
For any space , (continuous maps) is a sheaf: functions that agree on overlaps define one function on the union, and continuity can be checked locally (Proposition 2). The same holds for smooth functions on a manifold, holomorphic functions on a complex manifold, solutions of a linear differential equation, and sections of any continuous map . In each case the defining condition is local.
Example— Constant presheaves, and the sheaf of locally constant functions
The constant presheaf , with all restrictions the identity, fails to be a sheaf if has at least two elements: the empty set is covered by the empty family, and gluing then forces to be a single point (Proposition 1). Repairing this by setting does not help: if with disjoint, non-empty and open, the sections and agree on the empty overlap but do not glue to a single element of . The sheaf that does the job is the sheaf of locally constant functions , with when is locally connected. It is the sheafification of the constant presheaf (Corollary 6).
Example— Bounded functions
satisfies locality but not gluing: the restrictions of to the intervals are bounded and compatible, but there is no bounded function on restricting to them.
Example— Branches of the logarithm and a twisted sheaf on the circle
On let be the set of continuous (equivalently holomorphic) branches of on . Every point has a neighbourhood with , but . Similarly, on let be the continuous functions on the preimage of in with values in and . Locally looks like the sheaf of locally constant integers, with every stalk ; but a global section would be a constant integer equal to its own negative, so . A non-zero sheaf can have no non-zero global sections.
Example— Finite spaces
On a finite space every point has a smallest open neighbourhood , so . The pseudocircle , with open sets and the whole space, is a finite model of the circle (McCord, 1966); sheaves on it can be checked exhaustively, as in the computation section.
Gluing, germs and stalks
Theorem— Proposition 1 (the empty set)
If is a sheaf, then has exactly one element.
Proof
The empty set is covered by the empty family (). The compatibility condition is vacuous, so gluing gives some , and locality, which is also vacuous, says that any two elements of are equal.
∎
Theorem— Proposition 2 (continuity is local)
For every space , the presheaf on is a sheaf.
Proof
Let . Locality: if for all then for every , as lies in some . Gluing: given continuous agreeing on overlaps, define for any with ; this is well defined because when . For continuity, let be open; then , and each is open in , hence in because is open. So is continuous and .
∎
Theorem— Theorem 3 (sections are determined by germs)
Let be a sheaf and . If for every , then .
Proof
For each , means there is an open with and . The sets cover , so by locality.
∎
Theorem— Theorem 4 (isomorphisms are detected on stalks)
A morphism of sheaves is an isomorphism if and only if is bijective for every .
Proof
An isomorphism clearly induces bijections on colimits. Conversely, assume every is bijective; we show every is bijective, and then the inverses automatically commute with restriction.
Injective. If , then , so for all , and by Theorem 3.
Surjective. Let . For each , surjectivity of gives a section , , with ; shrinking we may assume . On an overlap , the sections and both map to , so they agree by the injectivity just proved. By gluing there is with , and then and agree on every , so by locality in .
∎
The hypothesis that is a sheaf is essential: the inclusion of the constant presheaf into is bijective on all stalks but not an isomorphism. And "surjective on stalks" does not imply "surjective on sections" (see the exponential sequence below): the proof of surjectivity used injectivity, i.e. bijectivity, on stalks.
Theorem— Theorem 5 (sheafification)
Every presheaf has a sheaf and a morphism such that every morphism from to a sheaf factors uniquely through . In other words, sheafification is left adjoint to the inclusion . Moreover is bijective for every .
Proof
Let be the set of functions with that are locally germs of sections: every has an open neighbourhood and some with for all . (These are exactly the continuous sections of the étale space.) Restriction is restriction of functions, and .
is a sheaf: functions agreeing on overlaps glue uniquely to a function, and the defining condition is local, so the glued function satisfies it — the same argument as Proposition 2. Stalks: every germ of at is represented near by some , so is surjective; if and have the same germ at then , so is injective. Universal property: given with a sheaf, and locally of the form on a cover , the sections have the same germs on overlaps, so they agree there by Theorem 3 and glue to a unique ; this defines with , and uniqueness follows because is forced on the local pieces .
∎
Theorem— Corollary 6 (sheafifying a constant presheaf)
The sheafification of the constant presheaf with value is the sheaf of locally constant functions .
Proof
For , the stalk of the constant presheaf is (all restriction maps are the identity, and every neighbourhood system is non-empty). A section of over is therefore a function that is locally equal to a constant section, i.e. a locally constant function. Over there is exactly one (empty) function, as Proposition 1 requires.
∎
Theorem— Theorem 7 (sheaves form a topos)
is a Grothendieck topos: it has all limits and colimits, it is cartesian closed, and it has a subobject classifier with .
Limits of sheaves are computed sectionwise; colimits are sheafified sectionwise colimits; the internal hom is . A subsheaf is classified by sending to the largest open with — the "set of points where belongs to " (Mac Lane–Moerdijk, Chapters II and III). This is the starting point of elementary topos theory, where truth values become open sets.
A preview of sheaf cohomology
For sheaves of abelian groups, a sequence is called exact if it is exact on every stalk. Taking global sections preserves exactness on the left but not on the right, and sheaf cohomology measures the failure.
Example— The exponential sequence
On let be the sheaf of holomorphic functions and that of nowhere-vanishing ones (a group under multiplication). The sequence
is exact on stalks, because every non-vanishing holomorphic germ has a logarithm on a small disc. But is not surjective: is not for any holomorphic on . The long exact sequence sends to the generator of : its winding number.
Definition— Čech cohomology
For a sheaf of abelian groups and an open cover with totally ordered, set and , with differential . The Čech cohomology is the cohomology of this complex. By the sheaf axioms, .
Example— The circle
Cover by two open arcs whose intersection is two disjoint arcs, and take . Then and , and . The kernel is the diagonal, so (global locally constant functions), and the cokernel is , so . A cocycle describes "local constants that jump by on one overlap and on the other"; only the difference survives, and it is the obstruction to gluing — the same integer as the winding number above.
On a manifold, when the cover is good (all non-empty finite intersections are contractible), Čech cohomology of agrees with singular cohomology. The general definition is Grothendieck's: are the right derived functors of the global sections functor on sheaves of abelian groups. The de Rham theorem is a theorem about sheaves: on a smooth manifold the sequence is exact on stalks — that is precisely the Poincaré lemma — and the sheaves have no higher cohomology (partitions of unity), so is computed by global forms: .
Sheaves in Lean
To keep every definition visible, the independent part of the formalisation uses a small notion of presheaf of types on the open sets of a space, with the sheaf condition stated as "compatible local sections glue uniquely" — a single ∃! that packages locality and gluing. (Mathlib's TopCat.Presheaf is a functor (Opens X)ᵒᵖ ⥤ C; its sheaf condition is equivalent to ours for presheaves of types.)
/-- A **presheaf of sets** on `X`: a set of sections `sec U` for every open `U`, and restriction
maps `sec V → sec U` for `U ⊆ V`, such that restricting to `U` itself does nothing and restricting
in two steps is restricting in one. Equivalently, a functor `O(X)ᵒᵖ → Set`
(Mathlib: `TopCat.Presheaf (Type v) X`). -/
structure Presheaf (X : Type u) [TopologicalSpace X] where
/-- The sections over each open set. -/
sec : Opens X → Type v
/-- Restriction from `V` to a smaller open set `U`. -/
res : ∀ {U V : Opens X}, U ≤ V → sec V → sec U
/-- Restricting to the same open set is the identity. -/
res_id : ∀ (U : Opens X) (s : sec U), res (le_refl U) s = s
/-- Restriction is transitive: `(s|_V)|_U = s|_U`. -/
res_res : ∀ {U V W : Opens X} (hUV : U ≤ V) (hVW : V ≤ W) (s : sec W),
res hUV (res hVW s) = res (hUV.trans hVW) s/-- The **sheaf condition**: whenever opens `Uᵢ ⊆ V` cover `V` and sections `sᵢ ∈ F(Uᵢ)` agree
on every overlap `Uᵢ ∩ Uⱼ`, there is exactly one section `t ∈ F(V)` restricting to every `sᵢ`.
"Exactly one" packages both axioms: *gluing* (existence) and *locality* (uniqueness). This is the
statement that `F(V) → ∏ F(Uᵢ) ⇉ ∏ F(Uᵢ ∩ Uⱼ)` is an equaliser. -/
def IsSheaf (F : Presheaf.{u, v} X) : Prop :=
∀ (V : Opens X) (ι : Type u) (U : ι → Opens X) (hU : ∀ i, U i ≤ V) (_hcov : V ≤ ⨆ i, U i)
(s : ∀ i, F.sec (U i)),
(∀ i j, F.res inf_le_left (s i) = F.res inf_le_right (s j)) →
∃! t : F.sec V, ∀ i, F.res (hU i) t = s iProposition 1, and the failure of constant presheaves at the empty set:
/-- **A sheaf has exactly one section over the empty set.** The empty set is covered by the empty
family; the compatibility condition is vacuous, so "exactly one gluing" means exactly one section
over `∅`. -/
theorem sec_empty (F : Presheaf.{u, v} X) (hF : IsSheaf F) :
Nonempty (F.sec ⊥) ∧ ∀ s t : F.sec ⊥, s = t := by
obtain ⟨t, -, huniq⟩ := hF ⊥ PEmpty (fun i => i.elim) (fun i => i.elim) bot_le
(fun i => i.elim) (fun i => i.elim)
exact ⟨⟨t⟩, fun s s' => (huniq s (fun i => i.elim)).trans (huniq s' (fun i => i.elim)).symm⟩/-- The **constant presheaf** with value `A`: every open set, including `∅`, gets the set `A`, and
every restriction map is the identity. -/
def constPresheaf (A : Type v) : Presheaf.{u, v} X where
sec _ := A
res _ a := a
res_id _ _ := rfl
res_res _ _ _ := rfl/-- **Constant presheaves are usually not sheaves.** If `A` has two different elements, the
constant presheaf has two sections over `∅`, but a sheaf has only one. (Even after repairing the
value at `∅`, gluing fails on any disconnected open set; the sheafification is the sheaf of
locally constant functions — see the lesson.) -/
theorem const_not_sheaf (A : Type v) (a b : A) (hab : a ≠ b) :
¬ IsSheaf (constPresheaf (X := X) A) := by
intro hF
exact hab ((sec_empty _ hF).2 a b)Proposition 2: continuous maps into any space form a sheaf. The glued map is built with Mathlib's ContinuousMap.liftCover, which is exactly the "continuity is local" argument of the proof.
/-- The **presheaf of continuous maps** into a space `Y`: over `U`, the continuous maps `U → Y`;
restriction is restriction of functions. -/
def contPresheaf (Y : Type v) [TopologicalSpace Y] : Presheaf.{u, max u v} X where
sec U := C(U, Y)
res h f := f.comp ⟨fun x => ⟨x.1, h x.2⟩, by fun_prop⟩
res_id _ _ := rfl
res_res _ _ _ := rfl/-- **Continuous functions form a sheaf: continuity is local.** Compatible continuous maps
`sᵢ : Uᵢ → Y` define a single function on `V = ⋃ Uᵢ` (well defined because they agree on
overlaps), which is continuous because it is continuous near every point; and two functions that
agree on every `Uᵢ` agree on `V`. The gluing is Mathlib's `ContinuousMap.liftCover`. -/
theorem cont_isSheaf (Y : Type v) [TopologicalSpace Y] :
IsSheaf (contPresheaf (X := X) Y) := by
intro V ι U hU hcov s hcomp
-- every point of `V` lies in some `Uᵢ`
have hmem : ∀ x : V, ∃ i, (x : X) ∈ U i := fun x => by
simpa [Opens.mem_iSup] using hcov x.2
-- the pieces `Uᵢ`, seen as subsets of `V`, and the local maps on them
let S : ι → Set V := fun i => {x | (x : X) ∈ U i}
let φ : ∀ i, C(S i, Y) := fun i => (s i).comp ⟨fun x => ⟨x.1.1, x.2⟩, by fun_prop⟩
-- compatibility on overlaps
have hφ : ∀ i j (x : V) (hxi : x ∈ S i) (hxj : x ∈ S j), φ i ⟨x, hxi⟩ = φ j ⟨x, hxj⟩ := by
intro i j x hxi hxj
exact congrArg (fun f : C((U i ⊓ U j : Opens X), Y) => f ⟨x.1, hxi, hxj⟩) (hcomp i j)
-- each `Sᵢ` is open in `V`, so the pieces form a neighbourhood cover
have hS : ∀ x : V, ∃ i, S i ∈ nhds x := fun x => by
obtain ⟨i, hi⟩ := hmem x
exact ⟨i, ((U i).isOpen.preimage continuous_subtype_val).mem_nhds hi⟩
refine ⟨ContinuousMap.liftCover S φ hφ hS, ?_, ?_⟩
· -- the glued map restricts to each `sᵢ`
intro i
refine ContinuousMap.ext (X := U i) (Y := Y) fun x => ?_
exact ContinuousMap.liftCover_coe (S := S) (φ := φ) (hφ := hφ) (hS := hS) (i := i)
(⟨⟨x.1, hU i x.2⟩, x.2⟩ : S i)
· -- any other map with the same restrictions is equal to it
intro t ht
refine ContinuousMap.ext (X := V) (Y := Y) fun x => ?_
obtain ⟨i, hi⟩ := hmem x
have h1 := congrArg (fun f : C(U i, Y) => f ⟨x.1, hi⟩) (ht i)
have h2 := ContinuousMap.liftCover_coe (S := S) (φ := φ) (hφ := hφ) (hS := hS) (i := i)
(⟨x, hi⟩ : S i)
exact h1.trans h2.symmTheorem 3, with germs defined by agreement on a neighbourhood: choose a neighbourhood for each point, observe that they cover, and apply uniqueness of gluing.
/-- Two sections over `U` have the **same germ at `x`** if they agree on some smaller open
neighbourhood of `x`. The stalk `F_x` is the set of equivalence classes. -/
def SameGerm (F : Presheaf.{u, v} X) {U : Opens X} (x : X) (s t : F.sec U) : Prop :=
∃ (W : Opens X) (hWU : W ≤ U), x ∈ W ∧ F.res hWU s = F.res hWU t/-- **A section of a sheaf is determined by its germs.** If `s, t ∈ F(U)` have the same germ at
every point of `U`, choose for each `x` a neighbourhood `W_x` on which they agree. The `W_x` cover
`U`, and `s` and `t` both glue the compatible family `s|_{W_x}`, so by uniqueness `s = t`. -/
theorem eq_of_sameGerm (F : Presheaf.{u, v} X) (hF : IsSheaf F) {U : Opens X} (s t : F.sec U)
(h : ∀ x ∈ U, SameGerm F x s t) : s = t := by
-- choose the neighbourhoods
choose W hWU hxW heq using fun x : U => h x.1 x.2
-- the family `s|_{W_x}` is compatible
have hcomp : ∀ i j : U, F.res inf_le_left (F.res (hWU i) s)
= F.res inf_le_right (F.res (hWU j) s) := by
intro i j
rw [F.res_res, F.res_res]
-- the `W_x` cover `U`
have hcov : U ≤ ⨆ x : U, W x := fun x hx =>
Opens.mem_iSup.mpr ⟨⟨x, hx⟩, hxW ⟨x, hx⟩⟩
obtain ⟨g, -, huniq⟩ := hF U U W hWU hcov (fun x => F.res (hWU x) s) hcomp
exact (huniq s fun _ => rfl).trans (huniq t fun x => (heq x).symm).symmMathlib's sheaf theory supplies the rest. Its version of Theorem 3 uses the stalk defined as a colimit; Theorem 4 and the sheafification adjunction of Theorem 5 are in the library, as are a subobject classifier for sheaf categories (one of the topos axioms of Theorem 7) and the étale space, which is a covering space when the sheaf is locally constant:
/-- In Mathlib's language: the presheaf `U ↦ (U → T)` of *all* functions into a type `T` is a
sheaf. This applies `TopCat.Presheaf.toType_isSheaf`. -/
theorem functions_isSheaf (X : TopCat.{u}) (T : Type u) : (X.presheafToType T).IsSheaf :=
TopCat.Presheaf.toType_isSheaf X T/-- Mathlib's version of `eq_of_sameGerm`: two sections of a sheaf of sets with equal germs at
every point coincide. This applies `TopCat.Presheaf.section_ext`, where the germ is the canonical
map from sections into the stalk, defined as a colimit. -/
theorem section_ext {X : TopCat.{u}} (F : TopCat.Sheaf (Type u) X) (U : Opens X)
(s t : F.1.obj (op U))
(h : ∀ (x : X) (hx : x ∈ U), F.presheaf.germ U x hx s = F.presheaf.germ U x hx t) :
s = t :=
TopCat.Presheaf.section_ext F U s t h/-- **A morphism of sheaves is an isomorphism if and only if it is an isomorphism on every
stalk.** This applies Mathlib's `TopCat.Presheaf.isIso_iff_stalkFunctor_map_iso`. -/
theorem iso_iff_stalks {X : TopCat.{u}} {F G : TopCat.Sheaf (Type u) X} (f : F ⟶ G) :
IsIso f ↔ ∀ x : X, IsIso ((TopCat.Presheaf.stalkFunctor (Type u) x).map f.1) :=
TopCat.Presheaf.isIso_iff_stalkFunctor_map_iso f/-- **Sheafification is left adjoint to the inclusion of sheaves into presheaves.** This applies
Mathlib's `CategoryTheory.sheafificationAdjunction` for the Grothendieck topology of open covers
of `X`. -/
theorem sheafification_adjunction (X : TopCat.{u}) :
Nonempty (presheafToSheaf (Opens.grothendieckTopology X) (Type u) ⊣
sheafToPresheaf (Opens.grothendieckTopology X) (Type u)) :=
⟨sheafificationAdjunction _ _⟩/-- **Sheaves form a topos (one axiom of it).** The category of sheaves of sets on `X` has a
subobject classifier — the sheaf `Ω` with `Ω(U)` the set of open subsets of `U`. This applies
Mathlib's instance for sheaves on an essentially small site (in `Mathlib.CategoryTheory.Topos`). -/
theorem subobject_classifier (X : TopCat.{u}) :
HasSubobjectClassifier (Sheaf (Opens.grothendieckTopology X) (Type u)) :=
inferInstance/-- **Locally constant sheaves are covering spaces.** If every point has a neighbourhood `U` on
which all germ maps `F(U) → F_y` are bijective (as for the sheaf of locally constant functions),
then the projection from the étale space of `F` to `X` is a covering map. This applies Mathlib's
`TopCat.Presheaf.EtaleSpace.isCoveringMap_base`. -/
theorem etale_covering {X : TopCat.{u}} (F : TopCat.Presheaf (Type u) X)
(hF : ∀ x, ∃ U : Opens X, x ∈ U ∧ ∀ y (hyU : y ∈ U), Function.Bijective (F.germ U y hyU)) :
IsCoveringMap (TopCat.Presheaf.EtaleSpace.base (F := F)) :=
TopCat.Presheaf.EtaleSpace.isCoveringMap_base hFWhat is and is not formalised. Formalised independently: Proposition 1, the failure of the constant presheaf, Proposition 2 and Theorem 3, for our self-contained notion of sheaf. From Mathlib: the sheaf of functions, Theorem 3 with colimit stalks, Theorem 4, the sheafification adjunction, the subobject classifier of , and étale spaces of locally constant sheaves as covering spaces. Not formalised here: the equivalence between our IsSheaf and Mathlib's, Corollary 6, the topos structure in full, and sheaf cohomology (Mathlib has sheaf cohomology via derived functors in general, but we do not use it).
Sheaves on a finite space, exhaustively
On a finite space the sheaf condition involves finitely many covers, so it can be checked completely. The experiment works on the pseudocircle: it tests the constant presheaf, the constant presheaf repaired at , and the locally constant functions against every cover of every open set; computes the stalks ; and computes Čech and of for the cover by the two minimal neighbourhoods and , whose intersection has two components — the finite analogue of the two-arc cover of the circle.
"""Sheaves on finite topological spaces, checked exhaustively.
On a finite space every open cover is finite and every presheaf of finite sets
can be tested completely. We take the four-point "pseudocircle" (a finite model
of the circle), test the sheaf condition for every open set and every open
cover, compare the constant presheaf with the sheaf of locally constant
functions, compute stalks, and compute the Cech cohomology of the locally
constant sheaf Z/2 for a two-set cover. Exhaustive checks on one small space;
the general statements are the theorems of the lesson.
"""
from itertools import combinations, product
#: The pseudocircle: a, b open points, c, d closed points.
PSEUDOCIRCLE = ["a", "b", "c", "d"]
PSEUDOCIRCLE_OPENS = [set(), {"a"}, {"b"}, {"a", "b"}, {"a", "b", "c"},
{"a", "b", "d"}, {"a", "b", "c", "d"}]
#: A finite model of an interval: a open, c, d closed.
INTERVAL = ["a", "c", "d"]
INTERVAL_OPENS = [set(), {"a"}, {"a", "c"}, {"a", "d"}, {"a", "c", "d"}]
def opens_of(opens):
"""The open sets as frozensets, smallest first."""
return sorted({frozenset(u) for u in opens}, key=lambda u: (len(u), sorted(u)))
def minimal_nbhd(x, opens):
"""The smallest open set containing x (it exists in a finite space)."""
return frozenset.intersection(*[u for u in opens if x in u])
def locally_constant(u, opens, values):
"""Sections over u: functions u -> values constant on each U_x, x in u."""
pts = sorted(u)
sections = []
for vals in product(values, repeat=len(pts)):
f = dict(zip(pts, vals))
if all(len({f[y] for y in minimal_nbhd(x, opens)}) == 1 for x in pts):
sections.append(tuple(sorted(f.items())))
return sections
def restrict(section, v):
"""Restrict a function (stored as sorted pairs) to the subset v."""
return tuple((x, y) for x, y in section if x in v)
def constant_repaired(u):
"""The constant presheaf {0, 1} with a single section over the empty set."""
return [0, 1] if u else [None]
def restrict_repaired(s, w):
"""Restriction for constant_repaired: identity, except onto the empty set."""
return s if w else None
def sheaf_failures(opens, sec, res):
"""All (open set, cover) pairs where unique gluing fails."""
failures = []
for u in opens:
subs = [w for w in opens if w <= u]
for k in range(len(subs) + 1):
for cover in combinations(subs, k):
if frozenset().union(*cover) != u:
continue
images = {}
for s in sec(u):
key = tuple(res(s, w) for w in cover)
images[key] = images.get(key, 0) + 1
compatible = [fam for fam in product(*[sec(w) for w in cover])
if all(res(fam[i], cover[i] & cover[j]) ==
res(fam[j], cover[i] & cover[j])
for i in range(k) for j in range(k))]
if any(images.get(f, 0) != 1 for f in compatible) or \
len(images) != len(compatible):
failures.append((u, cover))
return failures
def cech_h1_dimension(cover, opens):
"""dim over Z/2 of H^0 and H^1 for the locally constant sheaf Z/2 and a
cover by two open sets U, V: C^0 = F(U) x F(V) -> C^1 = F(U & V)."""
u, v = cover
su = locally_constant(u, opens, (0, 1))
sv = locally_constant(v, opens, (0, 1))
suv = locally_constant(u & v, opens, (0, 1))
image = set()
kernel = 0
for s, t in product(su, sv):
diff = tuple((x, (a + b) % 2) for (x, a), (_, b) in
zip(restrict(s, u & v), restrict(t, u & v)))
image.add(diff)
kernel += all(a == 0 for _, a in diff)
h0 = kernel.bit_length() - 1
h1 = (len(suv) // len(image)).bit_length() - 1
return h0, h1
def main():
opens = opens_of(PSEUDOCIRCLE_OPENS)
print("Pseudocircle X = {a, b, c, d}: a, b open points; 7 open sets")
const = sheaf_failures(opens, lambda u: [0, 1], lambda s, w: s)
print(f"constant presheaf U -> {{0,1}}: fails on {len(const)} (U, cover):")
print(" U = empty set, empty cover (two sections over the empty set)")
repaired = sheaf_failures(opens, constant_repaired, restrict_repaired)
print(f"same, one section over the empty set: fails on {len(repaired)} pairs")
disc = [(sorted(u), [sorted(w) for w in c]) for u, c in repaired
if len(c) == 2][0]
print(f" e.g. U = {disc[0]} covered by {disc[1]}: 0 on one piece and 1")
print(" on the other agree on the (empty) overlap but do not glue")
def lc(u):
return locally_constant(u, opens, (0, 1))
good = sheaf_failures(opens, lc, restrict)
print(f"locally constant functions to {{0,1}}: {len(good)} failures")
print()
print("number of sections of the locally constant sheaf F:")
names = ["".join(sorted(u)) or "{}" for u in opens]
print(" U: " + "".join(f"{n:>6}" for n in names))
print(" |F(U)|" + "".join(f"{len(lc(u)):>6}" for u in opens))
stalks = {x: len(lc(minimal_nbhd(x, opens))) for x in PSEUDOCIRCLE}
print(f"stalks F_x = F(U_x), sizes: {stalks}")
print()
uc, ud = frozenset("abc"), frozenset("abd")
h0, h1 = cech_h1_dimension((uc, ud), opens)
print(f"Cech, cover {{abc, abd}} of the pseudocircle: dim H^0 = {h0}, "
f"dim H^1 = {h1}")
iopens = opens_of(INTERVAL_OPENS)
h0i, h1i = cech_h1_dimension((frozenset("ac"), frozenset("ad")), iopens)
print(f"Cech, cover {{ac, ad}} of the finite interval: dim H^0 = {h0i}, "
f"dim H^1 = {h1i}")
print()
print("Epistemic status: exhaustive over every open set and every open")
print("cover of these two finite spaces, so for them the statements are")
print("proved by enumeration. That the pseudocircle is a finite model of")
print("the circle (McCord, 1966) is a theorem; the computation only agrees")
print("with H^1(S^1; Z/2) = Z/2.")
if __name__ == "__main__":
main()As in the circle example, for the pseudocircle, while for a three-point "interval", whose cover has connected overlap, . For these finite spaces the checks are exhaustive and so amount to proofs of the specific statements; that the pseudocircle models the circle is McCord's theorem.
Explore: local potentials that do not glue
The vortex field has zero curl away from the origin, so on every disc avoiding the origin it is the gradient of a local potential — a branch of the angle . These local potentials are sections of a sheaf (locally constant up to an additive constant, i.e. a torsor under ). Drag the loop around the origin: the circulation is , so the local potentials cannot be glued into a global one. Move the loop off the origin: circulation .
A vortex: locally a gradient, globally not
Circulation around the origin is 2π: the local potentials θ do not glue.
F(x, y) = (−y/(x² + y²), x/(x² + y²))
Drag the gold centre (or click anywhere) to move the loop. With the keyboard, focus the centre and use the arrow keys.
Turns so far: 0.09
- Circulation
- ∮ F·dr ≈ 6.2832 | ∬ curl F dA ≈ −0.0322
- Flux out
- ∮ F·n ds ≈ 0 | ∬ div F dA ≈ 0.1043
- At the centre
- curl F ≈ 0, div F ≈ 0, πr² ≈ 8.042
- Index
- 1
All values are numerical approximations (sums around the loop and over the disc).
The two sides differ: the field must fail to be smooth (or be undefined) somewhere inside the loop, so Green’s theorem does not apply to this loop.
Index 1 ≠ 0: walking once around the loop, the arrow makes 1 net full turns (negative means clockwise). A field that is continuous on the whole disc would have to vanish inside; this one is not (see above), and the point where it breaks down carries the index instead.
The same obstruction for the logarithm: follow a continuous branch of the argument of around a loop. When it comes back, it has changed by times the winding number, so a branch chosen at the start disagrees with itself at the end exactly when the winding number is non-zero.
Winding around a hole
Continuing a branch of arg(z − a) around the loop changes it by 2π × the winding number.
Drag a hole to move it. Press Play to send the point around the loop, or use the slider. The small square marks the start.
Winding number around p₁1
(1/2πi)∮ dz/(z − p₁) ≈ 1.000 + 0.000i
Turns swept so far by each dashed arrow:
p₁: 0.00
The winding number is found by adding up the small changes in direction of the arrow from the hole to the moving point, and dividing the total by 360°. Counter-clockwise counts as positive.
Two loops in the plane with one hole can be deformed into each other, without ever crossing the hole, exactly when they have the same winding number. In the language of topology: the fundamental group of the punctured plane — like that of a circle — is the integers, π₁ = ℤ.
A link to complex analysis: think of the plane as the complex numbers and of a hole as a point a. Then (1/2πi)∮ dz/(z − a) equals the winding number around a. The values above are computed numerically along the loop.
Exercises
1. Sheaves
Warm-upHumanWhich of these presheaves of real-valued functions on are sheaves? (Select all that apply.)
2. Sheaves
Warm-upHumanHow many sections does the sheaf of locally constant -valued functions have over ?
3. Sheaves
CoreHumanIn the sheaf of continuous functions on , which pair of functions has the same germ at ?
4. Sheaves
CoreHumanOn , the morphism is surjective on every stalk. Is surjective?
5. Sheaves
CoreHumanIn the proof that a morphism of sheaves which is bijective on stalks is surjective on sections, local preimages of are glued. Why do and agree on ?
6. Sheaves
StretchHumanCover by three open arcs such that each pairwise intersection is a single (connected) arc and the triple intersection is empty. What is ?
7. Sheaves
CoreFormalGiven a cover U : ι → Opens X of V with hU : ∀ i, U i ≤ V and a compatible family s, which conclusion in the definition of IsSheaf captures both locality and gluing?
8. Sheaves
CoreComputationalSections of the sheaf of all functions on a finite set are dictionaries. Write glue(sections) that takes a list of dictionaries (functions on subsets) and returns the single dictionary on the union that restricts to each of them, or None if two of them disagree on a common point.
Common misconceptions
Misconception
"Every presheaf is a sheaf." Constant presheaves usually are not (they fail at the empty set, and after repair on every disconnected open set), and neither are presheaves defined by global conditions, such as bounded functions or constant functions. A presheaf is a sheaf exactly when its sections are determined by, and can be assembled from, local data.
Misconception
"A sheaf is determined by its global sections." The sheaf of holomorphic functions on the Riemann sphere has only the constants as global sections (Liouville), the same as the constant sheaf , yet the two sheaves are very different. The twisted sheaf on has , like the zero sheaf, although all its stalks are . Sheaves are determined by their sections over all open sets, or by their stalks together with how germs fit together.
Misconception
"A morphism that is surjective on stalks is surjective on sections." The exponential map on is surjective on stalks but has no global logarithm. Injectivity, by contrast, is detected on stalks (Theorem 4's proof), and isomorphisms are detected on stalks.
Misconception
"The stalk at is the value at ." A germ remembers the section on a whole (arbitrarily small) neighbourhood. The functions and on have the same value at but different germs; and have the same germ at . For holomorphic functions a germ is the same as a convergent power series, which carries much more than one value.
Viewpoints
Topology— Sheaves are spaces over X; covering spaces are locally constant sheaves
The étale space construction is an equivalence between sheaves on and local homeomorphisms ; under it, sections of the sheaf are continuous sections of . Locally constant sheaves correspond to covering spaces, and for connected, locally path-connected, semi-locally simply connected both correspond to sets with an action of — the twisted sheaf on the circle is the -set on which the generator acts by . Sheaf cohomology with constant coefficients agrees with singular cohomology on such spaces, so algebraic topology can be rebuilt sheaf-theoretically, as Leray did. See also the fundamental group.
Geometry— Spaces defined by their functions
A smooth manifold is a space with a sheaf of rings locally isomorphic to , a complex manifold one locally isomorphic to , and a scheme one locally isomorphic to the spectrum of a commutative ring with its structure sheaf; morphisms are morphisms of locally ringed spaces. Vector bundles become locally free sheaves of modules, line bundles form the Picard group , and the first Chern class is the connecting map of the exponential sequence (see vector bundles). Serre's theorems on coherent sheaves and Grothendieck's cohomology made sheaves the language of algebraic geometry.
Analysis— Analytic continuation and the Cousin problems
For holomorphic functions the identity theorem makes the étale space of Hausdorff — germs that agree near a point agree on connected domains — and the Riemann surface of or is a connected component of this étale space: Weierstrass's analytic continuation, made into a space. The étale space of continuous (or smooth) functions is not Hausdorff: the germs of and of a smooth function vanishing only on cannot be separated at . Classical existence problems become cohomology: the Mittag-Leffler and Cousin problems ask for meromorphic functions with prescribed principal parts, and their obstruction lies in , which vanishes on domains of holomorphy (Cartan's Theorem B, following Oka). Sato's hyperfunctions are defined as cohomology classes with coefficients in .
Logic— Truth varies over a space
In the topos , a proposition about sections has as truth value the open set where it holds, and the internal logic is intuitionistic: " or " holds only on the union of the interior of and the interior of its complement, which need not be all of . Kripke models of intuitionistic logic are sheaves on posets with the Alexandrov topology, and forcing arguments can be phrased in sheaf toposes. See elementary topos theory.
Category theory— Sheaves on a site
Only the poset and the notion of a covering family were used. Grothendieck replaced them by a category with a Grothendieck topology, and sheaves on such a site — for example the étale site of a scheme — give the cohomology theories behind the Weil conjectures. Sheafification is a left exact left adjoint, presheaf categories are free cocompletions, and Giraud's theorem characterises the categories of sheaves on sites intrinsically. See limits and colimits.
Physics— Contextuality as a missing global section
Samson Abramsky and Adam Brandenburger (2011) described quantum measurement scenarios by a presheaf assigning to each set of jointly measurable observables (a "context") the possible outcome distributions. The empirical data form a compatible family on the cover by contexts. Bell non-locality and Kochen–Specker contextuality are precisely the failure of such a family to come from a global section — a joint outcome assignment for all observables at once — and the obstruction can sometimes be detected by Čech cohomology. This is a precise mathematical reformulation of known theorems, not a new physical claim.
Computation— Cellular sheaves and data on networks
On a graph or cell complex, a cellular sheaf assigns a vector space to each vertex and edge and linear restriction maps from vertices to incident edges (Justin Curry, 2014). Global sections are consistent assignments of data across the network, measures irreconcilable local measurements, and the sheaf Laplacian (Jakob Hansen and Robert Ghrist, 2019) generalises the graph Laplacian, with its kernel equal to the global sections. These ideas are used for sensor fusion, distributed consensus and signal processing on networks.
History and global context
- Leray. Jean Leray created sheaf theory, together with spectral sequences, while a prisoner of war in Oflag XVII-A in Austria (1940–45), where he organised a university for fellow prisoners; his work appeared from 1945–46 and introduced the word faisceau.
- The Cartan seminar. Henri Cartan's Paris seminar (1948–51) reformulated sheaves with open sets and étale spaces and developed sheaf cohomology. In Japan, Kiyoshi Oka's work on several complex variables, including his coherence theorem (1950), led — through Cartan's Theorems A and B (1951–53) — to the solution of the Cousin problems on Stein manifolds.
- Algebraic geometry. Jean-Pierre Serre's Faisceaux algébriques cohérents (1955) brought sheaves into algebraic geometry, and Alexander Grothendieck's Tôhoku paper (1957) defined sheaf cohomology by derived functors. Roger Godement's Topologie algébrique et théorie des faisceaux (1958) became the standard reference. Grothendieck's sites and toposes (SGA 4, 1963–64, with Michael Artin and Jean-Louis Verdier) extended the theory far beyond spaces.
- Analysis. Mikio Sato introduced hyperfunctions (1958–59) as sheaf cohomology classes, and the Kyoto school of Sato, Masaki Kashiwara and Takahiro Kawai developed microlocal analysis and -modules in sheaf-theoretic language.
- Today. Sheaves are basic in algebraic and complex geometry, representation theory (perverse sheaves), logic and topos theory, and increasingly in applied topology, network science and the foundations of quantum theory.
Further reading
- Saunders Mac Lane and Ieke Moerdijk, Sheaves in Geometry and Logic (1992), Chapter II — sheaves on spaces, étale spaces and sheafification, leading into toposes.
- Masaki Kashiwara and Pierre Schapira, Categories and Sheaves (2006) — the categorical foundations, at research level; see also their Sheaves on Manifolds (1990).
- Glen E. Bredon, Sheaf Theory (2nd ed., 1997) — the topologist's comprehensive treatment of sheaf cohomology.
- Robin Hartshorne, Algebraic Geometry (1977), §II.1 and Chapter III — sheaves and their cohomology for algebraic geometry.
- Raoul Bott and Loring W. Tu, Differential Forms in Algebraic Topology (1982), §10 — presheaves, Čech cohomology and the de Rham theorem.
- Raymond O. Wells, Differential Analysis on Complex Manifolds (1973; 3rd ed. 2008), Chapter II — sheaves in complex analysis.
- Robert Ghrist, Elementary Applied Topology (2014), Chapter 9 — cellular sheaves and applications.
Reading path: Mac Lane–Moerdijk Chapter II or Bott–Tu §10 with this lesson; then Hartshorne for geometry, Bredon for topology, or elementary toposes for logic.