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
Add dontcare argument to simplify_logic #23986
Conversation
✅ Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
6e1c236
to
abd14d5
Compare
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[41d90958] [fb7c59c1]
<sympy-1.11.1^0>
- 950±2μs 611±1μs 0.64 solve.TimeSparseSystem.time_linear_eq_to_matrix(10)
- 2.75±0ms 1.14±0ms 0.42 solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
- 5.49±0.02ms 1.68±0ms 0.31 solve.TimeSparseSystem.time_linear_eq_to_matrix(30)
Full benchmark results can be found as artifacts in GitHub Actions |
@@ -2769,20 +2769,24 @@ def simplify_logic(expr, form=None, deep=True, force=False): | |||
made. By setting ``force`` to ``True``, this limit is removed. Be | |||
aware that this can lead to very long simplification times. | |||
|
|||
dontcare : Boolean expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking as someone who only recently learned what "don't care" means in logic maybe it would be good to have a reference for this:
https://en.wikipedia.org/wiki/Don%27t-care_term
Looks good to me |
abd14d5
to
a090f22
Compare
Rebased, the link added in three relevant positions and some crosslinking between POSform and SOPform. |
>>> b = (~x & ~y & ~z) | ( ~x & ~y & z) | ||
>>> simplify_logic(b) | ||
~x & ~y | ||
>>> simplify_logic(x | y, dontcare=y) | ||
x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a less trivial example would be better. Perhaps this:
In [6]: simplify_logic(x ^ y, dontcare=x & y)
Out[6]: x ∨ y
Here it is not as simple as just supposing that the dontcare is False.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can modify it as part of next PR. Agreed that it is probably better.
Looks good to me. +1 to merge. |
References to other Issues or PRs
Another part of #22753
Brief description of what is fixed or changed
simplify_logic
now has adontcare
keyword argument, so that one can simplify the expression under the assumption that thedontcare
-expression does not matter. Useful in general, but especially for Piecewise simplification where one then can set the previous conditions to don't care.Other comments
Release Notes
simplify_logic
now has adontcare
keyword argument for simplifying under don't care-conditions.