Open ollieclarke8787 opened 9 months ago
This issue is most probably due to a bug in QEPCAD. Using the interactive version we can see where the problem is:
var('a1, a2, a3, a4, d1, d2, d3, d4')
f = qepcad_formula.and_(a1 >= 1,
a2 >= 1,
a3 >= 1,
a4 >= 1,
d1 >= 0,
d2 >= 0,
d3 >= 0,
d4 >= 1,
a1*d1 + a2*d2 + a3*d3 - a4*d4 == 0,
d1 + d2 < d3 + d4)
f = qepcad_formula.exists(sorted(f.vars), f)
qe = qepcad(f, interact=True)
qe.go()
qe.go()
which produces:
go &
** 97578 cells, 19999 arrays in 21 milliseconds.
Failure occurred in: GCSI (final check)
Reason for the failure: Too few cells reclaimed.
N = 97578
NU = 1000000
RHO = 10
Now the FAIL handler is aborting the program ...
See also this example.
The too few cells
error can sometimes be alleviated by using parameter memcells=
to qepcad.
As for the current issue, I'd suggest Sage to always run qepcad in interactive mode under the hood, which will allow it to monitor and report any error arising along the way.
Actually, Sage does run .go()
multiple times. However, it does not care about their output. Rather than discarding the output of qe.go()
, it should do something like this:
result = qe.go()
if result.find('Failure occurred in:'):
# parse the error and raise an exception
I ran into the same issue. It's very frustrating that this is not acknowledged in the documentation https://doc.sagemath.org/html/en/reference/interfaces/sage/interfaces/qepcad.html#sage.interfaces.qepcad.qepcad. The documentation also does not explain what memcells
is. It should also definitely warn users that anything past like 6 variables might not work.
Steps To Reproduce
In the Sage cell server, I ran the following code:
var('a1, a2, a3, a4, d1, d2, d3, d4')
qf = qepcad_formula
F1 = qf.and_( a1 >= 1, a2 >= 1, a3 >= 1, a4 >= 1, d1 >= 0, d2 >= 0, d3 >= 0, d4 >= 0, a1*d1 + a2*d2 + a3*d3 - a4*d4 == 0, d1 + d2 < d3 + d4 )
qepcad(F1, solution = 'any-point')
which produces a point:{'a1': 1, 'a2': 1, 'a3': 1, 'a4': 1, 'd1': 0, 'd2': 0, 'd3': 1, 'd4': 1}
However if I change
d4 >= 0
tod4 >= 1
and run:var('a1, a2, a3, a4, d1, d2, d3, d4')
qf = qepcad_formula
F1 = qf.and_( a1 >= 1, a2 >= 1, a3 >= 1, a4 >= 1, d1 >= 0, d2 >= 0, d3 >= 0, d4 >= 1, a1*d1 + a2*d2 + a3*d3 - a4*d4 == 0, d1 + d2 < d3 + d4 )
qepcad(F1, solution = 'any-point')
which produces a value error
ValueError: input formula is false everywhere
despite the first output being a valid solution.Expected Behavior
The second piece of code should output a valid solution, such as the first one
Actual Behavior
Produces
ValueError: input formula is false everywhere
Additional Information
I have observed the same behaviour when running this code in a cocalc Sage environment for Sage 10.1.
Environment
Checklist