Given a ring R, typically a domain, this produces an ideal isomorphic to the canonical module of R. This will not always produce the same ideal, especially in a non-domain. It uses the function embedAsIdeal from Divisor.m2.
i1 : S = QQ[x,y,u,v]; |
i2 : T = QQ[a,b]; |
i3 : f = map(T, S, {a^3, a^2*b, a*b^2, b^3}); o3 : RingMap T <--- S |
i4 : R = S/(ker f); |
i5 : canonicalIdeal(R) o5 = ideal (v, u) o5 : Ideal of R |
Here’s an example in a non-domain.
i6 : R = ZZ/13[x,y,z]/ideal(x*y, x*z, y*z); |
i7 : canonicalIdeal(R) o7 = ideal (y - 5z, x + 4z) o7 : Ideal of R |