I need to answer myself to post some code which became necessary as the truncate function did not seem to work correctly in many examples:
The following code ran for me successfully on the Web M2 interface. A quick hack for a better truncate (truncate1) and the dirty trick of mapping the result chain complex into a newly made up basering brough success (at least for the example below and some similar examples):
--load "Truncations.m2"
--
-- compute the H^i(proj S, moM~) for S=A[x_1,...,x_n]
--
compCohX = (moM, d) ->
(
S := ring moM;
A := coefficientRing S;
n1 := numgens A;
B := (coefficientRing A)[t_1..t_(n1)];
n := numgens S;
moMt := truncate1(moM, d);
-- the number 10 must be chosen accordingly with n
-- C := presX (moMt, 10);
C := res moMt;
C1 := Hom(C, S^{-n});
Dlis := {};
for i from min(C1) to max (C1) do
(
Dlis = prepend( transpose lift(matrix basis(0, C1.dd_(i)), A), Dlis);
);
D:= chainComplex(Dlis);
D, C, prune HH(D);
D1 := (map(B,A,gens B))(D);
return D1;
);
truncate1 = (moM, d) ->
(
S := ring moM;
A := coefficientRing S;
n := numgens S;
phi := presentation moM;
cross := gens truncate(d, S);
mat1 := (target(phi)) ** cross;
phi1 := map(moM, source(mat1), mat1);
return image(phi1);
);
--
-- compute a free resolution of moM with S(-d_{i,1}) + .. + S(-d_{i,j_i}) terms
--
presX = (moM, k) ->
(
moN := moM;
philis := {};
moN = prune moN;
i := 0;
phi := presentation moN;
degs := degrees target phi;
print degs;
philis = append(philis, phi);
moN = ker phi;
while (((prune moN) != 0) and (i <= k)) do
(
phi = presentation moN;
psi := gens moN;
philis = append(philis, psi);
philis = append(philis, phi);
moN = ker phi;
i = i + 1;
);
D := chainComplex(philis);
return D;
);
-*
A=QQ[a,Degrees=>{1:{}}]
S=A[x_0,x_1,x_2, Join => false]
ma = matrix {{(a-1) * x_0, (a-1) * x_1, (a-1) * x_2}}
mo = coker ma
*-
A=QQ[a,Degrees=>{1:{}}];
S=A[x_0..x_4];
ma = matrix {{(a-1) * x_0,(a-1) * x_1, (a-1) * x_2,(a-1) * x_3, (a-1) * x_4, (x_0 * x_1 + x_2 * x_3 + x_4 * x_0 * a)}}
mo1 = coker ma
D1 = compCohX(mo1, 2)
print(D1)
-*
T=A[t,u];
phi = map(T,S, {t^4, t^3*u, a* t^2 * u^2, t * u^3, u^4});
id1 = ker phi;
R=QQ[w_0..w_4]
ma1 = module id1;
na1 = S^1/id1;
phi1 = map(R, S, {w_0, w_1, w_2, w_3, w_4, 0})
ma11 = phi1(ma1)
resol1 = apply(0..4, i->HH^i(sheaf ma11))
print(resol1)
*-