Given a ring $R$, typically a domain, canonicalIdeal(R) produces an ideal isomorphic to the canonical module of $R$. 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 |
The function canonicalIdeal will not always produce the same ideal, especially in a non-domain.
i6 : R = ZZ/13[x,y,z]/(x*y, x*z, y*z); |
i7 : print \ unique apply(10, i -> canonicalIdeal(R)); ideal (y - 5z, x + 4z) ideal (y - 4z, x + 2z) ideal (y - 3z, x + z) ideal (y + 3z, x + 2z) ideal (y - 4z, x - z) ideal (y - 4z, x - 4z) ideal (y + 5z, x - 3z) ideal (y - 6z, x + 6z) ideal (y + 6z, x + 2z) ideal (y + 6z, x + 4z) |
The option Attempts is passed to embedAsIdeal, and tells it how many times to try to embed the canonical module as an ideal before giving up.
The object canonicalIdeal is a method function with options.