Title
Silent mis-parse: division following a monomial (x/2) yields a wrong answer
or a spurious "no solutions", with exit code 0
Body
Version: 0.10.1 (banner: msolve library for polynomial system solving, version 0.10.1), Linux x86-64.
msolve accepts input in which a division follows a monomial, e.g. x/2 or
a*b/2, and silently computes with a different system. There is no error, no
warning on stderr, and the exit code is 0. In the worst case it reports that a
solvable system has no solutions.
Reproducer
$ printf 'x, y\n0\nx/2 - y,\ny - 3\n' > bug.ms
$ msolve -f bug.ms
[-1]:
The system x/2 - y = 0, y - 3 = 0 has the unique solution (x, y) = (6, 3).
msolve reports [-1], i.e. no solutions in the algebraic closure. stderr is
empty.
The documented form of the same system behaves correctly:
$ printf 'x, y\n0\n1/2*x - y,\ny - 3\n' > ok.ms
$ msolve -f ok.ms
[0, [1,
[[[6, 6], [3, 3]]]
]]:
Other instances of the same mis-parse
| input (char 0) |
correct |
msolve returns |
x/2 - y, y - 3 |
x = 6, y = 3 |
[-1] (no solutions) |
x - y/2, y - 3 |
x = 3/2, y = 3 |
x = 1, y = 3 |
x*y/2 - 2, y - 4 |
x = 1, y = 4 |
x = 2, y = 4 |
x - 1/2 |
x = 1/2 |
x = 1/2 ✔ |
1/2*x - y, y - 3 |
x = 6, y = 3 |
✔ |
-2/3*x - y, y - 2 |
x = −3, y = 2 |
✔ |
So a rational constant and a leading fraction are handled correctly; only a
division appearing after a monomial is affected. The behaviour is identical
over a prime field (1073741827 in place of 0 on line 2 gives [-1] for the
first example).
Why this is worth an error rather than a silent result
The README documents rational coefficients only in the leading form
(-2/3*x2*y1^2+...), so x/2 is arguably outside the specified input format.
However, users using scripts to produce the file that is fed to msolve may
not realize the format error if msolve swallows it silently. In my project the printer
emits e.g. Rational(1,2)*g14 as g14/2. I only discovered the problem because
in my case a solution was known to exist. If msolve returned with an error
users would see it immediately and fix their input rather than draw incorrect conclusions.
Environment
- msolve 0.10.1, built from release, Linux x86-64, GMP/FLINT as bundled.
- Reproduced with
-t 1 and -t 8, char 0 and char 1073741827.
Title
Silent mis-parse: division following a monomial (
x/2) yields a wrong answeror a spurious "no solutions", with exit code 0
Body
Version: 0.10.1 (banner:
msolve library for polynomial system solving, version 0.10.1), Linux x86-64.msolve accepts input in which a division follows a monomial, e.g.
x/2ora*b/2, and silently computes with a different system. There is no error, nowarning on stderr, and the exit code is 0. In the worst case it reports that a
solvable system has no solutions.
Reproducer
The system
x/2 - y = 0, y - 3 = 0has the unique solution(x, y) = (6, 3).msolve reports
[-1], i.e. no solutions in the algebraic closure. stderr isempty.
The documented form of the same system behaves correctly:
Other instances of the same mis-parse
x/2 - y, y - 3[-1](no solutions)x - y/2, y - 3x*y/2 - 2, y - 4x - 1/21/2*x - y, y - 3-2/3*x - y, y - 2So a rational constant and a leading fraction are handled correctly; only a
division appearing after a monomial is affected. The behaviour is identical
over a prime field (
1073741827in place of0on line 2 gives[-1]for thefirst example).
Why this is worth an error rather than a silent result
The README documents rational coefficients only in the leading form
(
-2/3*x2*y1^2+...), sox/2is arguably outside the specified input format.However, users using scripts to produce the file that is fed to msolve may
not realize the format error if msolve swallows it silently. In my project the printer
emits e.g.
Rational(1,2)*g14asg14/2. I only discovered the problem becausein my case a solution was known to exist. If msolve returned with an error
users would see it immediately and fix their input rather than draw incorrect conclusions.
Environment
-t 1and-t 8, char 0 and char 1073741827.