# Divisor Maps and Riemann-Roch Spaces

As stated at the beginning of the chapter, one of our main initial aims in introducing sheaf machinery has been to provide a way of computing the (rational) maps associated to invertible sheaves in reasonable generality (see Section 7, Chapter 2 of [[Hartshorne, 1977](../../references.md#cite-hartshorne)]) and similarly for effective Cartier divisors (as closed subschemes) in the form of the map or their Riemann-Roch spaces. This section describes the main intrinsics. We hope to add further functionality to capture the correspondence between divisors and invertible sheaves in future releases.

## `DivisorMap(S): ShfCoh -> Map, Sch`

```magma
graphmap: BoolElt                    Default: false
```

Given an invertible sheaf $S$ on the scheme $X$ this function returns the rational map from $X$ into the projective space associated to $S$. For efficiency, the invertibility of $S$ is not checked, so that if the user is unsure whether a potential $S$ actually is invertible (ie, locally free of rank one) he should apply the [`IsLocallyFree`](shf:preds.md#function-shf-loc-free) intrinsic.

The rational map that is returned can be thought of as $X \rightarrow \rm{Proj}(R) \rightarrow {\bf P}^r$ where $R$ is the graded $k$-subalgebra of the graded ring $\oplus_{n \ge 0} H^0(X,S^{\otimes n})$ generated by the weight $1$ subspace $H^0(X,S)$ – the space of global sections of $S$ – and the map to ${\bf P}^r$, where $r+1$ is the dimension of the space of global sections, is that induced by choosing a basis for the global sections. The divisor map, as usual, is only unique up to a linear change of coordinates of the codomain. The map is defined on the open subscheme of $X$ where $S$ is generated by global sections. Also returned is the image of the map on $X$.

In most cases, the map returned is a graph map of type `MapSchGrph` (see Section [Scheme Graph Maps](../Schemes/maps.md#sch-grph-mps)). This computation naturally computes the graph of the map and, in complicated situations, it is not particularly efficient to convert this to the more usual `MapSch` which will be defined by very nasty, high degree polynomials (often with a large base scheme) without some further specialised reduction routine. The user can however convert to a `MapSch` using [`SchemeGraphMapToSchemeMap`](../Schemes/maps.md#function-sch-gr-mp-to-sch-mp). In cases when the sheaf has been constructed from a divisor using the `DivisorToSheaf` intrinsic below with the `GetMax` parameter `true`, so that a Riemann-Roch space has been stored, a traditional `MapSch` is returned. If in doubt, the user can distinguish using the `Type` intrinsic. Sometimes the user may still want a `MapSchGrph` in the latter case (e.g. because it is maximally defined, it is good for getting the genuine inverse image of a point/subscheme without components of the base scheme which appear for a non-maximally defined `MapSch`). This can be forced by setting the parameter `graphmap` to `true`.

The major stage of the computation is the determination of the graph of the map. An ideal defining the graph can be written down directly from the relation matrix of a minimal presentation of the global section submodule $M_0$ of $S$, and this ideal then only needs to be saturated with respect to an appropriate domain variable. The submodule $M_0$ is computed (and stored) as described earlier in the chapter.

## `DivisorToSheaf(X, I): Sch, RngMPol -> ShfCoh`

## `RiemannRochBasis(X, I): Sch, RngMPol -> SeqEnum, RngMPolElt, ShfCoh`

```magma
GetMax: BoolElt                    Default: true
```

Given an ordinary, projective scheme $X$ and an ideal $I$ of the coordinate ring of the ambient of $X$ that defines a subscheme $D$ of $X$ that is an effective Cartier (locally principal) divisor of $X$, this function returns the invertible sheaf corresponding to the divisor class of $D$, commonly denoted ${\cal L}(D)$ (see Section 6, Chapter 2 of [[Hartshorne, 1977](../../references.md#cite-hartshorne)]). The conditions require $D$ to be purely of codimension 1 in $X$ and that it is everywhere locally defined by a single equation. Again for efficiency, Magma does not perform the computationally expensive checks to verify that $D$ is locally principal within $X$. If $X$ is a non-singular variety, then a closed subscheme of codimension $1$ is automatically Cartier.

If `GetMax` is `true`, then the maximal module of ${\cal L}(D)$ is computed and an explicit basis for the Riemann-Roch space $L(D)$ is computed and stored along the way. This basis is of the form $[G_1/G,\ldots,G_n/G]$, where $G$ and the $G_i$ are homogeneous polynomials of some degree $d$ on the ambient of $X$ and the $G_i/G$ are the usual rational functions restricted to $X$.

If instead of `DivisorToSheaf`, the intrinsic `RiemannRochBasis` is called, then the above procedure is carried out and a basis of the Riemann Roch space is returned as the sequence of numerators $[G_1,\ldots,G_n]$ and the denominator $G$, along with the sheaf ${\cal L}(D)$. If ${\cal L}(D)$ has been computed from `DivisorToSheaf` and returned as $S$, then the RiemannRoch basis can be recovered at a later stage from the *attribute* of $S$, `rr_space`. This attribute, if assigned, contains a pair consisting of the above sequence of numerators and the denominator.

The algorithm used is based on the following observation. If we choose $r > 0$ such that $I$ contains a homogeneous polynomial $G$ of degree $r$ that doesn’t lie in the ideal of $X$, $I_X$ (which is a proper subideal of $I$), then there is a “complementary” divisor $E$ of $X$ such that $rH \sim D + E$, where $H$ is a hyperplane divisor of $X$. Then ${\cal L}(D) \simeq {\cal L}(-E)(r)$ and ${\cal L}(-E)$ is represented by the module $I_E/I_X$, where $I_E$ is the ideal of $E$, a subscheme of $X$ (see Prop 6.18 of the above reference). Once a suitable $G$ is found, $I_E$ is computed by invoking intrinsics `ColonIdeal` and `Saturation` a few times. If the `GetMax` option is on, $r$ is chosen large enough so that $H^1(I_X(m)), m \ge r$ vanishes, which guarantees that we end up with a maximal representing module and can get a full basis of Riemann-Roch numerators with $G$ as the denominator.

## `IneffectiveDivisorToSheaf(X, I, J): Sch, RngMPol, RngMPol -> ShfCoh`

## `IneffectiveRiemannRochBasis(X, I, J): Sch, RngMPol, RngMPol -> SeqEnum, RngMPolElt, ShfCoh`

```magma
GetMax: BoolElt                    Default: true
```

These are extensions of the above 2 intrinsics that compute the sheaf or Riemann-Roch basis for a non-effective divisor that can be represented as a difference $D-E$ of two effective locally principal divisors $D,E$, which have no irreducible component in common. Instead of having a single ideal to represent the divisor, the divisor is represented by two ideals $I$ and $J$ which are the ideals of the coordinate ring of the ambient of variety $X$ that define respectively the effective divisors $D$ and $E$ as subschemes of the ambient.

The algorithm is a fairly straightforward variant of the effective divisor version.

## `Example: Shf:rr Scroll (ex-72931f)`

As a simple example, we consider a degree 3 rational scroll in ${\bf P}^4$. This is a ruled surface that contains a family of disjoint lines. If $l$ is a line in the family, then the divisor map for ${\cal L}(l)$ is a map to the projective line, the fibres of which are the lines of the family. We take such a scroll $X$ and line $l$ and get the Riemann-Roch space $L(l)$ and the divisor map down to ${\mathbb{P}}^1$.

```magma
> P4<a,b,c,d,e> := ProjectiveSpace(Rationals(),4);
> X := Scheme(P4,[a*b - c^2, a*d - c*e, c*d - b*e]);
> Il := ideal<CoordinateRing(P4)|[a,c,e]>; // ideal of l
> rr_seq,G, Sl := RiemannRochBasis(X,Il);
> rr_seq; G;
[
    d,
    e
]
e

```

Thus, $1$ and $d/e$ are a basis for the rational functions in $L(l)$.

```magma
> fib_mp := DivisorMap(Sl);
> fib_mp;
Mapping from: Sch: X to Projective Space of dimension 1
Variables: $.1, $.2
with equations :
d
e

```

Here the divisor map is not a graph map and is not maximally defined. So we extend it to make it so. Note that the fibres are lines.

```magma
> fib_mp := Extend(fib_mp);
> (Codomain(fib_mp)![1,0])@@fib_mp;
Scheme over Rational Field defined by
a,
c,
e,
a*b - c^2,
a*d - c*e,
c*d - b*e
> (Codomain(fib_mp)![0,1])@@fib_mp;
c,
b,
d,
a*b - c^2,
a*d - c*e,
c*d - b*e

```

Alternatively, we could ask for `fib_mp` as a `MapSchGrph` and not have to extend it.

```magma
> fib_mp := DivisorMap(Sl : graphmap := true);
> Type(fib_mp);
MapSchGrph
> (Codomain(fib_mp)![1,0])@@fib_mp;
Scheme over Rational Field defined by
a,
c,
e,
a*b - c^2,
a*d - c*e,
c*d - b*e

```

## `Example: shf:dp3to6 (ex-774e58)`

As a second example, we consider the degree 3 Del Pezzo surface example from the Del Pezzo chapter. There we mapped it to a degree 6 Del Pezzo surface by blowing down 3 disjoint lines in an explicit fashion. We do the same thing here using the sheaf machinery.

First we get the surface $X_3$ and the union of the 3 lines $L_{123}$:-

```magma
> R3<x,y,z,t> := PolynomialRing(Rationals(),4,"grevlex");
> P3 := Proj(R3);

```

We set up the equation defining the degree 3 surface:

```magma
> F := -x^2*z + x*z^2 - y*z^2 + x^2*t - y^2*t - y*z*t + x*t^2 + y*t^2;
> X3 := Scheme(P3,F);

```

Get the ideal defining the union of the 3 lines:

```magma
> I1 := ideal<R3|[x,y]>; // line 1 L1
> I2 := ideal<R3|[z,t]>; // line 2 L2
> I3 := ideal<R3|[x-z,y-t]>; //line 3 L3
> I := I1*I2*I3; // (non-saturated) ideal of L1+L2+L3 = L123

```

Now we blow down to get the degree 6 Del Pezzo in ${\bf P}^6$. The divisor we need for the map is $H+L_{123}$ where H is a hyperplane section. We get this simply by twisting the sheaf corresponding to $L_{123}$ once.

```magma
> S123 := DivisorToSheaf(X3,I);
> H6 := Twist(S123,1); // sheaf of H+L123
> mp, X := DivisorMap(H6);
> X;
Scheme over Rational Field defined by
y[1]*y[2] - y[2]*y[3] - y[4]*y[5] + y[1]*y[6] + 3*y[2]*y[6] - y[4]*y[6] + y[6]^2
    + y[1]*y[7] + 2*y[2]*y[7] - y[4]*y[7] - y[5]*y[7] + 3*y[6]*y[7],
y[2]^2 - y[2]*y[3] + 2*y[2]*y[6] + y[6]^2 + 2*y[2]*y[7] + 3*y[6]*y[7],
y[1]*y[3] - y[2]*y[3] + 2*y[2]*y[6] - y[5]*y[6] + y[6]^2 + y[2]*y[7] - y[4]*y[7]
    + 3*y[6]*y[7],
y[2]*y[4] - y[2]*y[6] + y[4]*y[6] + y[4]*y[7] + y[5]*y[7],
y[3]*y[4] - y[2]*y[6] - y[6]^2 - y[6]*y[7] + y[7]^2,
y[4]^2 - y[4]*y[6] + y[5]*y[6] + y[1]*y[7] - y[2]*y[7] + y[4]*y[7] + y[5]*y[7],
y[2]*y[5] - y[4]*y[6] + y[5]*y[6] - y[2]*y[7] + y[4]*y[7] + y[5]*y[7],
y[3]*y[5] - y[6]^2 - y[2]*y[7] - y[7]^2,
y[5]^2 - y[1]*y[6] + y[2]*y[6] - 2*y[4]*y[6] + y[5]*y[6] + y[1]*y[7] - y[2]*y[7]
> Dimension(X); Degree(X);
2
6

```
