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

SMTChecker: Introduce first draft of Z3CHCSmtlib2Interface #15348

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

blishko
Copy link
Contributor

@blishko blishko commented Aug 20, 2024

This commit introduces the interface class without actually using it. The actual switch will be done later, after all things are set up.
This was separated from #15252.

@ekpyron ekpyron added the 🟡 PR review label label Aug 20, 2024
response = querySolver(query);
setupSmtCallback(true);
if (!boost::starts_with(response, "unsat"))
return {CheckResult::SATISFIABLE, Expression(true), {}};
Copy link
Member

Choose a reason for hiding this comment

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

If it is not unsat couldn't it also be UNKNOWN or ERROR here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If solver for some reason would not return unsat (which is what we expect), then we ignore this second call and just return what we would have returned if we would not want to compute counterexample.
See my response below for the SAT/UNSAT confusion.

CHCSolverInterface::CexGraph graphFromZ3Answer(std::string const& _proof) const;
static CHCSolverInterface::CexGraph graphFromSMTLib2Expression(
smtutil::SMTLib2Expression const& _proof,
ScopedParser & context
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ScopedParser & context
ScopedParser& _context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

libsolidity/formal/Z3CHCSmtLib2Interface.cpp Show resolved Hide resolved
libsolidity/formal/Z3CHCSmtLib2Interface.cpp Show resolved Hide resolved
libsolidity/formal/Z3CHCSmtLib2Interface.cpp Show resolved Hide resolved
libsolidity/formal/Z3CHCSmtLib2Interface.cpp Show resolved Hide resolved
libsolidity/formal/Z3CHCSmtLib2Interface.cpp Show resolved Hide resolved

auto const* root = proofStack.top();
auto const& derivedRootFact = fact(*root);
visitedIds.insert({root, nextId++});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
visitedIds.insert({root, nextId++});
visitedIds.emplace(root, nextId++);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

auto const* child = &args[i];
if (!visitedIds.count(child))
{
visitedIds.insert({child, nextId++});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
visitedIds.insert({child, nextId++});
visitedIds.emplace(child, nextId++);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@nikola-matic
Copy link
Collaborator

Seeing as this is an unused interface, I expect you're going to be making some tweaks in subsequent PR regardless, so please take a glance at the comments, and then we can merge.

This commit introduces the interface class without actually using it.
The actual switch will be done later, after all things are set up.
@blishko
Copy link
Contributor Author

blishko commented Aug 28, 2024

@nikola-matic, I think I addressed all your comments, except the solAssert -> smtAssert. I believe I have that prepared somewhere down the pipeline. If you are OK with it, I would address this one later.

@nikola-matic
Copy link
Collaborator

@nikola-matic, I think I addressed all your comments, except the solAssert -> smtAssert. I believe I have that prepared somewhere down the pipeline. If you are OK with it, I would address this one later.

Yup, that's fine.

@blishko blishko merged commit d5cdf07 into develop Aug 28, 2024
72 checks passed
@blishko blishko deleted the smt-z3smtlib-first-draft branch August 28, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🟡 PR review label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants