Opened 6 years ago
Last modified 3 years ago
#18787 closed defect
Bug with products of symbolic variables with modular integers — at Version 13
Reported by: | tmonteil | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | symbolics | Keywords: | |
Cc: | kcrisman, slelievre | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
As reported on this ask question
sage: _ = var('A,B') sage: (A + 3*B)*Zmod(9)(6) 0*B
while the result should be 6*A
.
It seems that the internal state of these objects is really messed up:
sage: _ = var('A,B') sage: (3*A + 3*B)*Zmod(9)(6) # Yes, the output is really empty! sage: (3*A + 3*B)*Zmod(9)(6)*A ------------------------------------------------------------------------ Unhandled SIGSEGV: A segmentation fault occurred in Sage. This probably occurred because a *compiled* component of Sage has a bug in it and is not properly wrapped with sig_on(), sig_off(). Sage will now terminate. ------------------------------------------------------------------------
Change History (13)
comment:1 Changed 6 years ago by
- Description modified (diff)
comment:2 Changed 6 years ago by
- Description modified (diff)
comment:3 Changed 6 years ago by
- Summary changed from Bug with matrice products over Symbolic Ring with modular integers to Bug with products of symbolic variables with modular integers
comment:4 Changed 6 years ago by
- Description modified (diff)
comment:5 Changed 6 years ago by
- Cc kcrisman added
Thanks very much to both for reporting and simplifying this.
comment:6 follow-up: ↓ 10 Changed 6 years ago by
A different issue, but it might be related:
sage: F=sum((i+1)*x^i for i in [0..20]) sage: G=sum(Zmod(7)(i+1)*x^i for i in [0..20]) sage: F*Zmod(7)(1) - G x^19 + 2*x^18 + 0*x^13 + 0*x^6 sage: G*Zmod(7)(1) - G 0
so there seems to be something fishy with symbolic multiplication involving integers and elements of Z/n in general. It's not just a zero-divisor problem.
It's not just powers either:
sage: V=[SR.var("x%s"%i) for i in [0..20]] sage: F=sum((i+1)*V[i] for i in [0..20]) sage: G=sum(Zmod(7)(i+1)*V[i] for i in [0..20]) sage: sage: F*Zmod(7)(1)-G -x0 + 0*x13 + 6*x14 + 0*x20 + 3*x3 + 0*x6 sage: F-G 14*x13 + 21*x20 + 7*x6
The last one is correct, since the terms with x6, x20 and x13 are really missing from G. This illustrates why mixing characteristics in SR is always going to be a mess (even if non-zero characteristic works properly otherwise).
comment:7 Changed 6 years ago by
It seems to be a pynac/ginac issue, right ? So what should we do on our side ? Add a stopgap during conversion/coercion Zmod(n) -> SR ?
comment:8 Changed 6 years ago by
(Or even just disallow it?)
comment:9 Changed 6 years ago by
This is working in pynac-0.4.1 (but not 0.3.9.1).
EDIT: I meant the original case.
comment:10 in reply to: ↑ 6 Changed 6 years ago by
Replying to nbruin:
It's not just powers either:
sage: V=[SR.var("x%s"%i) for i in [0..20]] sage: F=sum((i+1)*V[i] for i in [0..20]) sage: G=sum(Zmod(7)(i+1)*V[i] for i in [0..20]) sage: sage: F*Zmod(7)(1)-G -x0 + 0*x13 + 6*x14 + 0*x20 + 3*x3 + 0*x6 sage: F-G 14*x13 + 21*x20 + 7*x6
This is different in 0.4.1:
sage: sage: sage: F*Zmod(7)(1)-G -x0 + 0*x13 + 0*x20 + 4*x9 sage: F-G 14*x13 + 21*x20 + 7*x6 sage: F x0 + 2*x1 + 11*x10 + 12*x11 + 13*x12 + 14*x13 + 15*x14 + 16*x15 + 17*x16 + 18*x17 + 19*x18 + 20*x19 + 3*x2 + 21*x20 + 4*x3 + 5*x4 + 6*x5 + 7*x6 + 8*x7 + 9*x8 + 10*x9 sage: G x0 + 2*x1 + 4*x10 + 5*x11 + 6*x12 + x14 + 2*x15 + 3*x16 + 4*x17 + 5*x18 + 6*x19 + 3*x2 + 4*x3 + 5*x4 + 6*x5 + x7 + 2*x8 + 3*x9
EDIT: Added F
,G
.
comment:11 Changed 6 years ago by
Correction: this is not pynac-0.4.1 but pynac master. Narrowing down the reponsible change...
comment:12 Changed 6 years ago by
- Description modified (diff)
comment:13 Changed 6 years ago by
- Description modified (diff)
Thanks for isolating the problem.