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

Teach online what4 backend about smtFile option #1476

Merged
merged 1 commit into from
Dec 17, 2022
Merged

Teach online what4 backend about smtFile option #1476

merged 1 commit into from
Dec 17, 2022

Conversation

RyanGlScott
Copy link
Contributor

@RyanGlScott RyanGlScott commented Nov 30, 2022

This passes the value of smtFile to each call to startSolverProcess in the online what4 backend, thereby fixing #1475. After this patch, the test case in #1475 now produces an .smt2 file, as expected.

@RyanGlScott
Copy link
Contributor Author

Hm. I opted to copy the existing code that writes to smtFile when using w4-offline. However, one thing that I didn't realize is that this code always prints a message saying "Writing to SMT-Lib file ...", even if smtFile isn't explicitly set. This is what is causing the various test suite failures, as many more tests are now printing out "Writing to SMT-Lib file ..." than before.

Any objections if I change the code such that this "Writing to SMT-Lib file ..." message is only printed if smtFile is explicitly set?

Copy link
Member

@yav yav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

QueryType ->
Maybe FilePath ->
(String -> IO ()) {- ^ Continuation for displaying user messages -} ->
(Handle -> IO ()) {- ^ Continuation for writing file output -} ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more traditional name for these are "callbacks" rather than "continuations"?

@RyanGlScott
Copy link
Contributor Author

@yav, do you have an opinion on #1476 (comment)?

@yav
Copy link
Member

yav commented Dec 2, 2022

Yes, I thin we should only print the message when we were explicitly asked to save the file

This passes the value of `smtFile` to each call to `startSolverProcess` in the
online `what4` backend, thereby fixing #1475. After this patch, the test case
in #1475 now produces an `.smt2` file, as expected.
@RyanGlScott
Copy link
Contributor Author

Looking at this more closely, the way I am going about this is entirely wrong. The behavior of {sbv,w4}-offline is to always print out the SMT-LIB2 term, regardless of whether you are using stdout or an smtFile. As a result, I really shouldn't be copying the code that implements w4-offline, as that's meant for a different purpose.

Luckily, there is a much simpler way to solve this issue: we are currently calling startSolverProcess (which initiates an online what4 solver connection) like so:

(W4.startSolverProcess fs Nothing (w4 sym))

That Nothing (of type Maybe Handle) indicates that the output will not be duplicated to any file handle. All we have to do to fix the issue at hand is obtain pcSmtFile's Handle and pass it there. I've pushed a change which does this, and now all of the test cases pass once more.

This is now ready for another round of review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants