The Sheaf type

The Sheaf class derives from CellComplex to describe its base space. The additional attributes and methods of Sheaf describe the “vertical fiber” structure of the sheaf.

class Sheaf(CellComplex)

The base sheaf class in PySheaf consists of a list cell of SheafCell instances, describing the cells and the stalks over them. Restriction maps are built into SheafCoface instances that are stored with each SheafCell.

coboundary(k, compactSupport=False)

Compute the degree k coboundary map of the Sheaf, returning it as a numpy.ndarray. If you want compactly supported cohomology (if you don’t know what that means, you don’t) then set compactSupport=True.

cohomology(k, compactSupport=False)

Compute the degree k sheaf cohomology for the Sheaf. If you want compactly supported cohomology (if you don’t know what that means, you don’t) then set compactSupport=True. This returns a numpy.ndarray whose columns are the generators for cohomology.

betti(k)

The dimension of the degree k sheaf cohomology space.

Warning

This is not the dimension of the CellComplex.homology(), which is inherited into Sheaf!

class SheafCell(Cell)
stalkDim

The dimension of the stalk over this cell.

Warning

This has nothing to do with SheafCell.dimension inherited from Cell.

metric

The metric on the stalk, used to measure distances between values in that stalk. This must by a function object that takes two arguments, each of which is a numpy.ndarray and produces a numerical value. By default, it is the Euclidean distance given by numpy.linalg.norm().

cofaces

Like Cell, this should be a list of coface relations, but unlike Cell, they must be SheafCoface instances!

class SheafCoface(Coface)

A coface relation in a sheaf on a cell complex is built just like a Coface in a CellComplex, but with the addition of a restriction.

restriction

A restriction in a sheaf generally needs to be a morphism in some category. It must be an object that supports composition, namely a class that implements a multiplication operator. In most examples, this is one of SetMorphism (for functions between sets), LinearMorphism (for linear maps), or a SheafMorphism (for a Sheaf of sheaves). Note that if you construct a SheafCoface by passing a numpy.ndarray, PySheaf will construct a LinearMorphism restriction automatically.

Morphisms: SetMorphism, LinearMorphism, and SheafMorphism

Since cellular sheaves are special functors from the face category of a cell complex to some other data category, PySheaf supports three kinds of data categories:

  1. Sets,
  2. Finite dimensional vector spaces (via numpy), and
  3. Sheaves (of some of other type).

The restrictions in a given SheafCoface instance are therefore of a corresponding morphism class:

  1. SetMorphism,
  2. LinearMorphism, and
  3. SheafMorphism.

The simplest of these is SetMorphism.

class SetMorphism

This represents a set morphism, otherwise known as a function between sets. This is implemented by a single attribute

fcn

which is a function object taking one argument.

SetMorphism objects support a multiplication operator, which composes their respective fcn attributes to form a new function object. They also support call semantics, so you can simply call a SetMorphism object as a function to access its fcn attribute.

Namely, if you say:

foo = pysheaf.SetMorphism( lambda x : x**2 )
bar = pysheaf.SetMorphism( lambda y : 3*y )

then:

foo(3)

returns 9 and:

baaz = foo * bar
baaz(1)

is also 9.

A Sheaf with only SetMorphism restrictions does not allow you to compute Sheaf.cohomology(). For that, you need linearity, which is implemented by the following subclass of SetMorphism.

class LinearMorphism(SetMorphism)

This implements a linear map, encoded as a numpy.ndarray. Since it subclasses SetMorphism, it inherits composition (as multiplication, which is of course also matrix multiplication) and call semantics. It also stores the matrix as a new attribute

matrix

as you might expect.

When constructing a SheafCoface, if you pass an numpy.ndarray as the restriction argument, PySheaf will automatically create LinearMorphism objects as the restriction.

The final kind of morphism that is supported is SheafMorphism, which supports composition by implementing a multiplication operator, but not call semantics since sheaf morphisms are not functions. (It is true that they induce functions of various kinds, but PySheaf refrains from demanding that any particular kind of induced maps be computed by default.)

class SheafMorphism

A sheaf morphism from one sheaf to another consists of lists destinations and maps which correspond to the Sheaf.cells list in the domain sheaf.

destinations

List of indices into the codomain sheaf’s Sheaf.cells list for each component map of the sheaf morphism. Entries correspond to the Sheaf.cells list in the domain sheaf.

maps

List of component maps (each of which may be any morphism class, like SetMorphism, LinearMorphism, or even SetMorphism) corresponding to the Sheaf.cells list in the domain sheaf.

Constructing Sheaf instances

Sheaf objects are constructed in essentially the same way as CellComplex objects. Determining the indices for the Sheaf.cells list is crucial, as each SheafCoface.index will refer into it. Changes to the base space – the inherited structure from CellComplex – are not easy and will generally involve many updates. Additionally, each SheafCoface.restriction ought to be known beforehand, though these can be changed at run time if needed.