# Hilbert functions and free resolutions -- including degree and betti numbers

In this section, we give examples of common operations involving modules. Throughout this section, we suppose that the base ring R is graded, with each variable having degree one, and that M is a graded R-module. If the ring is not graded, or is multi-graded, or if M is not graded, some of these functions still work, but care must be taken in interpreting the output. Here, we just consider the standard grading case.

## checking homogeneity

Let's start by making a module over a ring with 18 variables
 i1 : R = ZZ/32003[vars(0..17)]; i2 : M = coker genericMatrix(R,a,3,6) o2 = cokernel | a d g j m p | | b e h k n q | | c f i l o r | 3 o2 : R-module, quotient of R
Use isHomogeneous to check whether a given module is graded.
 i3 : isHomogeneous M o3 = true

## codimension, degree, and sectional arithmetic genera

Use codim(Module), degree(Module), and genera(Module) for some basic numeric information about a module.
 i4 : codim M o4 = 4 i5 : degree M o5 = 15 i6 : genera M o6 = {-2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, 4, 14} o6 : List
The last number in the list of genera is the degree minus one. The second to last number is the genus of the generic linear section curve, ..., and the first number is the arithmetic genus.

## the Hilbert series

The Hilbert series (hilbertSeries(Module)) of M is by definition the formal power series H(t) = sum(d in ZZ) dim(M_d) t^d. This is a rational function with denominator (1-t)^n, where n is the number of variables in the polynomial ring. The numerator of this rational function is called the poincare polynomial, and is obtained by the poincare(Module) function.
 i7 : poincare M 4 5 6 o7 = 3 - 6T + 15T - 18T + 6T o7 : ZZ[T] i8 : hf = hilbertSeries M 4 5 6 3 - 6T + 15T - 18T + 6T o8 = -------------------------- 18 (1 - T) o8 : Expression of class Divide

It is often useful to divide the poincare polynomial by (1-t) as many times as possible. This can be done by using reduceHilbert:

 i9 : reduceHilbert hf 2 3 + 6T + 6T o9 = ------------ 14 (1 - T) o9 : Expression of class Divide
 i10 : poincare' = (M) -> ( H := poincare M; t := (ring H)_0; -- The variable t above while H % (1-t) == 0 do H = H // (1-t); H); i11 : poincare' M 2 o11 = 3 + 6T + 6T o11 : ZZ[T]

## free resolutions

The minimal free resolution C is computed using resolution(Module). The specific matrices are obtained by indexing C.dd.
 i12 : C = resolution M 3 6 15 18 6 o12 = R <-- R <-- R <-- R <-- R <-- 0 0 1 2 3 4 5 o12 : ChainComplex i13 : C.dd_3 o13 = {4} | m -n o p -q r 0 0 0 0 0 0 0 0 0 0 0 0 | {4} | -j k -l 0 0 0 p 0 0 0 -q r 0 0 0 0 0 0 | {4} | g -h i 0 0 0 0 p 0 0 0 0 -q 0 0 r 0 0 | {4} | -d e -f 0 0 0 0 0 p 0 0 0 0 -q 0 0 r 0 | {4} | a -b c 0 0 0 0 0 0 p 0 0 0 0 -q 0 0 r | {4} | 0 0 0 -j k -l -m 0 0 0 n -o 0 0 0 0 0 0 | {4} | 0 0 0 g -h i 0 -m 0 0 0 0 n 0 0 -o 0 0 | {4} | 0 0 0 -d e -f 0 0 -m 0 0 0 0 n 0 0 -o 0 | {4} | 0 0 0 a -b c 0 0 0 -m 0 0 0 0 n 0 0 -o | {4} | 0 0 0 0 0 0 g j 0 0 -h i -k 0 0 l 0 0 | {4} | 0 0 0 0 0 0 -d 0 j 0 e -f 0 -k 0 0 l 0 | {4} | 0 0 0 0 0 0 a 0 0 j -b c 0 0 -k 0 0 l | {4} | 0 0 0 0 0 0 0 -d -g 0 0 0 e h 0 -f -i 0 | {4} | 0 0 0 0 0 0 0 a 0 -g 0 0 -b 0 h c 0 -i | {4} | 0 0 0 0 0 0 0 0 a d 0 0 0 -b -e 0 c f | 15 18 o13 : Matrix R <--- R
 i14 : betti C 0 1 2 3 4 o14 = total: 3 6 15 18 6 0: 3 6 . . . 1: . . . . . 2: . . 15 18 6 o14 : BettiTally