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
Support RandomSymbol and assumptions in SMT-Lib Printer. #24406
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # sympy/printing/smtlib.py
✅ Hi, I am the SymPy bot (v169). 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.
|
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] [c87cd361]
<sympy-1.11.1^0>
- 975±4μs 635±2μs 0.65 solve.TimeSparseSystem.time_linear_eq_to_matrix(10)
- 2.78±0ms 1.17±0ms 0.42 solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
- 5.55±0.02ms 1.72±0ms 0.31 solve.TimeSparseSystem.time_linear_eq_to_matrix(30)
Full benchmark results can be found as artifacts in GitHub Actions |
Most solvers ignore assumptions and infer the meaning based on context or docs e.g. |
Btw it's better to make a dedicated branch for a pull request rather than using master. |
How would RandomSymbol be handled in the context of smtlib? |
Hi! RandomSymbol is reduced to a constant within a domain, though this domain doesn't necessarily have to be an interval. This is not an exploit because "RandomSymbol" and "Symbol with a domain" have distinct meanings:
Example:
Also, the same argument could be made against for-loops with respect to while-loops. Sure it is possible to only use while-loops. But idiomatically, for-loops mean something different in the same way RandomSymbol means something different than just asserting a domain on a Symbol. |
I think that sympy old assumptions are only used correctly in the I'm not sure if it is necessarily needed, if same thing about RandomSymbol can already be done with giving a mix of equations/inequality that gives. |
And I'm also not sure about why things like |
raises a type error for the same reason that
raises a type error. That is, saying a value has a uniform distribution forces it to be a float, and asserting a float is a mistake. |
I see. I do not want to ignore any information or constraints sent to the SMT interface, however. Would a better way to proceed be to throw an exception if any of the symbols contain assumptions? For RVs, I think it may be possible to implement a totally separate function (maybe in the sympy.stats package) which does the domain-to-query translation independently from the SMTlib printer. Does this sound better to you? @sylee957 |
I'm not sure you mean by 'domain-to-query' translation though, |
References to other Issues or PRs
Brief description of what is fixed or changed
Other comments
Certain assumptions, like e.g.
prime
, cannot easily be automatically asserted in the SMT-Lib code. If a user passes e.g.Symbol('x', prime=True)
intosmtlib_code(..)
, should this be alog_warn
or an error?Is there any precedent set by sympy's built-in solvers for unsupported/ignored assumptions?
Release Notes