1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
gradedRing = varCount -> (
x := symbol x;
variables := apply(1..varCount, k -> x_k);
listApply := args -> toList(apply args);
makeVector := i -> listApply(1..varCount, k -> if k == i then 1 else 0);
vectors := listApply(1..varCount, makeVector);
return ZZ[variables, Degrees=>vectors];
)
coerceMonomial = R -> m -> (
exps := first exponents m;
return product apply(gens R, exps, (v, e) -> v^e);
)
toGrade = id -> (
R := ring id;
gR := gradedRing(#(gens R));
return monomialIdeal(apply(id_*, coerceMonomial gR));
)
niceHilbert = id -> (
R := ring id;
gR := gradedRing(#(gens R));
gId := monomialIdeal(apply(id_*, coerceMonomial gR));
badHilbert = poincare gId;
mapping := apply(gens(ring badHilbert), gens R, (a, b) -> a => b);
return sub(badHilbert, mapping)
)
|