Skip to content
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

SMT-Lib printing: Handle predicate objects from new assumptions #25245

Merged
merged 1 commit into from Jul 6, 2023

Conversation

TiloRC
Copy link
Contributor

@TiloRC TiloRC commented Jun 16, 2023

The smtlib_code function will no longer throw an error when it tries to print some predicate from the new assumptions. The printer throws an error if given a predicate that can’t be translated to SMT-Lib or could be but hasn’t been Implemented. While it’s possible to handle even, odd, and some other predicate, this isn’t really all that important so this functionality was dropped.

Example:

In [1]: from sympy.printing.smtlib import smtlib_code

In [2]: from sympy.assumptions.ask import Q

In [3]:smtlib_code(Q.positive(x))

Out[3]]: '(declare-const x Real)\n(assert (> x 0))'

References to other Issues or PRs

This is a continuation of this pull request #25232. I worked on a lot of stuff that didn't seem to be a priority so this pull request contains the most essential bits of that one without any distracting commits or comments.

Other Comments

@kunalsheth if you want to review this it would be appreciated.

Release Notes

  • printing
    • make SMT-Lib printer handle some predicates from the new assumptions

@TiloRC TiloRC added the GSoC label Jun 20, 2023
@TiloRC TiloRC marked this pull request as draft June 22, 2023 18:31
@TiloRC TiloRC marked this pull request as ready for review June 22, 2023 19:00
@sympy-bot
Copy link

sympy-bot commented Jun 22, 2023

Hi, I am the SymPy bot (v170). 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:

  • printing
    • make SMT-Lib printer handle some predicates from the new assumptions (#25245 by @TiloRC)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13.

Click here to see the pull request description that was parsed.
The smtlib_code function will no longer throw an error when it tries to print some predicate from the new assumptions. The printer throws an error if given a predicate that can’t be translated to SMT-Lib or could be but hasn’t been Implemented. While it’s possible to handle even, odd, and some other predicate, this isn’t really all that important so this functionality was dropped.

Example:

In [1]: from sympy.printing.smtlib import smtlib_code

In [2]: from sympy.assumptions.ask import Q

In [3]:smtlib_code(Q.positive(x))

Out[3]]: '(declare-const x Real)\n(assert (> x 0))'

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

This is a continuation of this pull request #25232. I worked on a lot of stuff that didn't seem to be a priority so this pull request contains the most essential bits of that one without any distracting commits or comments.

#### Other Comments

@kunalsheth if you want to review this it would be appreciated. 

#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers. Formerly, `log(-x)` incorrectly gave `-log(x)`.

* physics.units
  * Corrected a semantical error in the conversion between volt and statvolt which
    reported the volt as being larger than the statvolt.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* printing
  * make SMT-Lib printer handle some predicates from the new assumptions
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@asmeurer
Copy link
Member

@kunalsheth I know you wrote the original SMT-LIB printing code in SymPy. You may be interested in some of the changes being made here.

@TiloRC
Copy link
Contributor Author

TiloRC commented Jun 29, 2023

I need to remove the "Started to implement EncodedCNF printing" commit before this ready to merge.

@TiloRC
Copy link
Contributor Author

TiloRC commented Jul 3, 2023

How do I cancel a review request? That happened automatically. I messed up my git rebase and it forgot I merged master which caused it to think there are like 50 more commits than there actually should be.

The smtlib_code function will no longer throw an error when it tries to print some
predicate from the new assumptions. The printer throws an error if given a
predicate that can’t be translated to SMT-Lib or could be but hasn’t been
Implemented. While it’s possible to handle even, odd, and some other
predicate, this isn’t really all that important so this functionality was dropped.

Example:

In [1]: from sympy.printing.smtlib import smtlib_code

In [2]: from sympy.assumptions.ask import Q

In [3]:smtlib_code(Q.positive(x))

Out[3]]: '(declare-const x Real)\n(assert (> x 0))'
@TiloRC TiloRC force-pushed the smtlib-predicate-simplified branch from d782cd7 to d20130a Compare July 3, 2023 20:59
@TiloRC TiloRC marked this pull request as draft July 3, 2023 21:00
@TiloRC TiloRC marked this pull request as ready for review July 3, 2023 21:00
@TiloRC TiloRC requested a review from asmeurer July 3, 2023 21:00
@TiloRC
Copy link
Contributor Author

TiloRC commented Jul 3, 2023

@moorepants you can ignore this pull request.

@github-actions
Copy link

github-actions bot commented Jul 3, 2023

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [8059df73]       [42803477]
     <sympy-1.12^0>                 
-        82.8±1ms       54.9±0.2ms     0.66  integrate.TimeIntegrationRisch02.time_doit(10)

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@asmeurer asmeurer merged commit 76de489 into sympy:master Jul 6, 2023
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants