-
Notifications
You must be signed in to change notification settings - Fork 154
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
Symbolics.jl simplify
behaves differently for different variable names
#1265
Comments
I'm not sure there's anything odd here. It's just a property of a rewrite based rule system that the rule application order can change the result. The order in which the rules are applied can be a function of the lexicographical sorting, since that's the default sort ordering on the arguments. |
@ChrisRackauckas Would you agree that this is just wrong:
The result is not simplified. Either there is a rule that identical factors should be drawn before the sum, using a bracket, or not. If there is such a rule it should always be applied. |
But that's not this issue? This issue is about "strange random fashion". The answer is that it's not random and it's instead based on sort ordering which is a property inherent to rule-based rewriting systems since they are a greedy algorithm, and you'd need a non-greedy e-graph approach (which would be much more expensive too) in order to not have that property. So, case closed. But yes, we should also improve the rewrite rules in simplify. That's a different discussion from the one in this thread. |
simplify
behaves in a strange random fashionsimplify
behaves differently for different variable names
@ChrisRackauckas Certainly from my perspective as a user of this package who doesn't understand the underlying algorithm in depth, even after reading your last response I have no idea why just changing the letter of the variable leads to different results on different runs. In other words I still don't understand why "a" works and "b" doesn't. So it seems there are two possibilities:
|
It's a bit of both. Lexicographical sorting means that different sort behaviors can change the out come of a rule-based eager pattern matching system. But the default results for simplify should improve to make this case better. Basically the rules that are defined need to be robust to that behavior. So with the new issue here, yes that is something to handle which is why I didn't close the issue. Hopefully that makes sense. |
Yes that explanation makes sense. Thanks! |
Bug description
I was trying to simplify some expression and it didn’t work. Boiling it down to its simplest form, if I use different letters of the alphabet sometimes the exact same expression simplifies and sometimes it doesn’t. I give 5 examples below to show it’s not even the order of the alphabet. I also go in and out of the Julia REPL each time to be sure previous attempts don’t influence the next.
Version Info:
From the
Project.toml
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
From the
Manifest.toml
Replicating the bug:
The text was updated successfully, but these errors were encountered: