regularity -- compute the Castelnuovo-Mumford regularity

Description

For a free chain complex C, the regularity r is the smallest number so that each basis element of C_i has degree at most i+r. For a module M, the regularity is the regularity of a free minimal resolution of M.
 i1 : R=ZZ/32003[a..d]; i2 : I=ideal(a^20,b^20,a*c^19-b*d^19); o2 : Ideal of R i3 : regularity I o3 = 399

The regularity is the label of the last row in the betti diagram of a chain complex.

 i4 : J=ideal(a^3,a^2*b,a*b^6,a^2*c); o4 : Ideal of R i5 : C=resolution J 1 4 4 1 o5 = R <-- R <-- R <-- R <-- 0 0 1 2 3 4 o5 : ChainComplex i6 : betti C 0 1 2 3 o6 = total: 1 4 4 1 0: 1 . . . 1: . . . . 2: . 3 3 1 3: . . . . 4: . . . . 5: . . . . 6: . 1 1 . o6 : BettiTally i7 : regularity C o7 = 6