1 | initial version |
SageMath uses Singular for this, and Singular can compute intersections of modules over polynomial rings.
I don't think this functionality has been exposed to SageMath, but we can easily do that ourselves:
def intersection(M1,M2):
return singular.intersect(M1.transpose(),M2.transpose()).sage().transpose()
Then we can do:
sage: M3 = intersection(M1,M2); M3
[x*y + x + y + 1 x*z + x + z + 1 y*z + y + z + 1]
sage: M3[0]
(x*y + x + y + 1, x*z + x + z + 1, y*z + y + z + 1)
sage: [f.factor() for f in M3[0]]
[(y + 1) * (x + 1), (z + 1) * (x + 1), (z + 1) * (y + 1)]
Indeed, this single generator lies in the intersection:
sage: sum(a*b for (a,b) in zip(M3[0], I1.gens()))
0
sage: sum(a*b for (a,b) in zip(M3[0], I2.gens()))
0