Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
348 stars 232 forks source link

Bug in pruning map over ZZ with torsion #2563

Open mahrud opened 2 years ago

mahrud commented 2 years ago

Still haven't looked into the root cause, but I think this is a bug:

N = prune coker matrix{{2, -1}, {-1, 2}, {-1, -1}}
-- cokernel | 3 |
--          | 0 |
f = inverse N.cache.pruningMap
-- | 1 2 0 |
-- | 1 1 1 |
g = map(target f, source f, matrix f)
-- | 1 -1 0 |
-- | 1 1  1 |
f == g -- false

The matrices are not the same over the integers, but as morphisms of Z-modules they are identical. In particular, I think one would expect f == map(target f, source f, matrix f) to always be true.

The closest I got to directly defining such matrices is something like this, which returns a non-sense error:

i1 : debug Core;

i2 : R = ZZ/3;

i3 : m = map(R, raw matrix{{2}})

o3 = | 2 |

             1       1
o3 : Matrix R  <--- R

i4 : n = matrix(R, {{2}})

o4 = | -1 |

             1       1
o4 : Matrix R  <--- R

i5 : m == n
stdio:5:3:(3): error: expected same ring

i6 : ring m === ring n

o6 = true
DanGrayson commented 2 years ago

This is a bug. Perhaps inverse is not reducing the matrix it finds modulo the relations in the target.