M2 icon indicating copy to clipboard operation
M2 copied to clipboard

equality of elements of submodules of the same module

Open mahrud opened this issue 5 months ago • 0 comments

Given two submodules M and N in a free module F, if I have elements m in M and n in N, what should m == n check? Currently, this is automatically false if M and N are not the same, but I think given that both are submodules of the same free module F, they should be equal, no? Here is an example:

R = kk[x,y]
M = image matrix {{x,0}, {0,y}}
N = image matrix {{0,x}, {y,0}}

-- As vectors:
M_0 ==  N_1 -- false, but I think this should be true
M_0 === N_1 -- false, which is fine

-- As matrices:
M_{0} ==  N_{1} -- true
M_{0} === N_{1} -- false, which is fine

If these vectors are considered equal, this would also be true:

debug needsPackage "FGLM"
I = cyclic(5)
M = module I
N = module ideal random I_*
S1 = set M_*
S2 = set N_*
S1 == S2 -- false

L1 = set apply(5, i -> image N_{i})
L2 = set apply(5, i -> image M_{i})
L1 == L2 -- true

Unrelated, but GC just crashed my M2 while I was comparing two vectors above:

i183 : M = image matrix {{x,0}, {0,y}}

o183 = image | x 0 |
             | 0 y |

                               2
o183 : R-module, submodule of R

i184 : N = image matrix {{0,x}, {y,0}}

o184 = image | 0 x |
             | y 0 |

                               2
o184 : R-module, submodule of R

i185 : M_0 ==  N_1

o185 = false

i186 : M_0 === N_1 -- M2 got stuck here so I interrupted it after a second
  C-c C-c  C-c C-c
Exit (y=yes/n=no/a=abort/b=backtrace)? b
-* stack trace, pid: 628252
 0# profiler_stacktrace(std::ostream&, int) at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/bin/main.cpp:131
 1# interrupt_handler at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/bin/main.cpp:285
 2# 0x0000000000019C30 in /lib64/libc.so.6
 3# GC_mark_from in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
 4# GC_mark_local in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
 5# GC_mark_some in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
 6# GC_stopped_mark in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
 7# GC_try_to_collect_inner in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
 8# GC_grow_table in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
 9# GC_register_finalizer_inner in /home/linuxbrew/.linuxbrew/opt/bdw-gc/lib/libgc.so.1
10# pthread0_newThreadRWLock at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/d/pthread0.d:50
11# hashtables_copy at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/d/hashtables.dd:298
12# override_2 at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/d/actors3.d:82
13# evaluate_evalraw at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/d/evaluate.d:1435
14# evaluate_evalSequence at /home/mahrud/Projects/M2/quickfix/M2/Macaulay2/d/evaluate.d:461

mahrud avatar Jun 10 '25 16:06 mahrud