-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maple bug in which inequalities in {con/dis}junction with 'chilled' subexpressions are discarded. #87
Comments
I think this is probably one of the issues that @ccshan doesn't understand. I get the gist of it (as you showed me the Somehow seeing the Maple-level symptoms would help me. And by this I mean stripping away as much of Hakaru as possible, and show a Maple call on Maple expressions that goes astray. |
I got the following reply from Maplesoft:
|
And a follow-up. The listing comes out not-so-nice, but should be sufficient to allow a patch.
SolveTools:-Transformers:-NonEquality:-Apply := proc(syst::SubSystem) |
So it seems that this patch is not necessarily safe. But there is a 'cute trick' that one can do:
Basically s stands for 1/(a-b). If a-b=0, i.e. a = b, then (a-b)*s=1 has no solutions. You can invert this process upon return from solve. |
Several updates:
|
|
|
|
I tried that too:
Maybe Maple is actually using your trick to solve inequalities and that is what leads to the bug in the first place? |
You replaced the inequality with an equality -- now you need to re-add it back after. So every tautology corresponds to an inequality that you had replaced. |
Can you give me an example of how this looks where the result should be something other than returning the input? I don't think I understand the logic of replacing the tautology with the original inequality; for example, for
applying the process produces
there is no tautology to replace, and the original expression can't be simplified, so the process should yield exactly the input. I don't see how the final step could be applied here. Of course, the example is a bit contrived, but I see no reason it shouldn't work. |
The process should introduce s = 1/(2a - 3b). The results should contain a tautology. It feels like there's a bug if the result contains {a = b + 1/2*a}. Maybe due to a typo? |
Indeed, sorry about that. The tautology does indeed occur here again. But:
still holds. I think I need to find and work through such a case (one with non-trivial solution) to be confident that I understand how to write a program to apply this trick in general. But it still seems that #88 is the better solution - I will take Ken's advice on that issue and see if I can pinpoint where execution begins to diverge in terms of |
For the integer case, it is a little tricky. We can't rely on In any case, if this isn't a 'live' issue, in that it is causing test failures, we can close it, and come back to it if it pops up again. |
It turns out my previous fix wasn't exactly ideal. It causes the following call to happen (it's quite long but it is of the form
and this either takes an absurdly long time (at least 90 minutes), or goes into an infinite loop. In either case, clearly I did not figure out what exactly is doing all this extra work. There are lots of calls to This arises from simplifying This changes achieves the same thing as the one it replaces, and doesn't cause this call to occur. |
|
Consider the following program fragment, which occurs as part of simplifying the program in #81:
NB:
sum
KB:-build_unsafely
was inserted manually so avid readers of this issue tracker could copy-paste from aboveCalling
simplify_factor_assuming
on this expression (sequence) produces completely bogus output. The error occurs insidesimplify_assuming
, inside the call tosimplify
. The mistake is that eachsum
is erroneously simplified to1
.This is almost certain the same problem as this, since the program mentioned here contains the condition:
which is the same condition discussed on that commit; and the expression contains additional conditions similar to this one, i.e. expressions which have an "
And
with an expression containing a 'chilled' [sub-]expression". The discussion there is aboutsolve
, but I wouldn't be surprised ifsolve
andsimplify
are sharing a good deal of machinery (and every Maple function shares Maple evaluation semantics, which seem to be at the core of the issue here).The particular example in this issue is worked-around by 8773d70, but it doesn't seem feasible to try to deal with this bug in such a manner in perpetuity, since having access to Maple evaluation semantics, and
solve
andsimplify
, all seems very important to the task at hand. More importantly, this fix applies at a certain stage in the simplification pipeline (right beforefromLO
) so a call tosimplify
orsolve
somewhere before could still break.Note that changing any one of the
sum
s toSum
s causes an additionalSum
to remain in the output; theseSum
s don't simplify and so should return unevaluated fromsimplify
. Changing all three toSum
causessimplify
(and by extension,simplify_assuming
andsimplify_factor_assuming
) to produce the correct answer. It seems the only way to convincesimplify
and friends to not evaluate things 'incorrectly' is to use the inert form, but that doesn't work everywhere (see #84 (comment)).In light of this, it seems that rewriting as much of the code as possible to not use
sum
orproduct
(etc.) anywhere where these expressions may be passed tosolve
orsimplify
while also chilled, is the way to go. However, I haven't been able to pinpoint all the places where this perfect storm of circumstances occurs. It seems there a great many places wheresum
orproduct
are used by themselves, and I suppose that potentially any of these could contain a condition which would trigger this bug.The text was updated successfully, but these errors were encountered: