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
feat(assumptions): reorganize facts for new assumptions #21279
Conversation
Implement Q.positive_infinite Implement Q.negative_infinite Introduce predicate decomposition into primitive predicates Fix Q.hermitian and Q.antihermitian
Implement Q.extended_positive Implement Q.extended_negative Implement Q.extended_nonzero Implement Q.extended_nonpositive Implement Q.extended_nonnegative
Introduce assumptions/facts.py
Apply Q.extended_positive to FinitePredicate Uncomment commented tests in test_query
Fix test_args
✅ Hi, I am the SymPy bot (v161). 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.9. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
🟠Hi, I am the SymPy bot (v161). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files:
If these files were added/deleted on purpose, you can ignore this message. |
As you suggested in #21220, I implemented primitive predicates and confirmed that it reduced the complexity of sat CNF fact by ~7 items without slowdown. (Checked with benchmark.) With primitive predicates, I implemented I also reorganized the facts and fixed bugs from Finally, I moved all the fact-related features from In |
Fix test_known_facts_consistent()
@@ -595,13 +601,13 @@ def test_I(): | |||
assert ask(Q.real(z)) is True | |||
|
|||
|
|||
|
|||
@XFAIL # definition for boundedness fixed! will be changed in next commit | |||
def test_bounded(): |
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.
Why is this XFAIL?
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.
It is because this test is based on incorrect design of Q.positive()
and Q.negative()
. I have fixed it, but it will make the diff quite large so I will open another PR for that.
sympy/assumptions/cnf.py
Outdated
(Literal(Q.even(x), False) & Literal(Q.positive(x), True)) | ||
|
||
``to_NNF`` decomposes the predicate into a combination of primitive | ||
predicates if possible. |
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.
It doesn't seem like this belongs as part of the to_NNF
function.
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.
Do you mean that predicate decomposition should be done by some other function?
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.
It just seems messy to me to do it as part of this function which has a clearly defined purpose: take a logical expression and convert it to NNF (without applying any interpretation to the meaning of the literals).
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.
What about giving keyword argument decompose=True/False
to this function?
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.
Perhaps it could take a composite_map
argument or something like that.
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.
Done.
Fix handlers of FinitePredicate
Add composite_map argument to to_NNF
Looks good to me |
References to other Issues or PRs
Fixes #21228
Brief description of what is fixed or changed
Q.positive_infinite()
andQ.negative_infinite()
predicates are introduced.Q.extended_positive()
,Q.extended_negative()
,Q.extended_nonzero()
,Q.extended_nonpositive()
, andQ.extended_nonnegative()
predicates are introduced.Q.positive()
andQ.negative()
now correctly implies the argument being finite.Incorrect results from
Q.hermitian()
andQ.antihermitian()
are fixed.In order to reduce the complexity of sat solver, some predicates are now decomposed into a combination of primitive predicates.
Facts are now defined in
assumptions/facts.py
, instead of inassumptions/ask.py
.Other comments
Benchmark showed no slowdown.
Release Notes
Q.positive_infinite()
andQ.negative_infinite()
predicates are introduced.Q.extended_positive()
,Q.extended_negative()
,Q.extended_nonzero()
,Q.extended_nonpositive()
, andQ.extended_nonnegative()
predicates are introduced.Q.positive()
andQ.negative()
now correctly implies the argument being finite.Q.hermitian()
andQ.antihermitian()
are fixed.