Skip to content

Preparation to make goto-analyzer work with the goto_verifiert framework #4703

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

Conversation

hannes-steffenhagen-diffblue
Copy link
Contributor

  • Make ai_baset work with abstract_goto_modelt rather than goto_modelt
  • Add a version of static_verifier that works with abstract_goto_modelt and propertiest

This will (eventually) allow us to use the goto-checker stuff in goto-analyzer, which will be useful to make reporting of results and things like that more consistent with the rest of CPROVER.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

auto &property_status = property.second.status;
auto const &property_location = property.second.pc;
auto condition = property_location->get_condition();
auto const predecessor = ai.abstract_state_before(property_location);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not obvious to me why we want to evaluate the condition in the preceding state, rather than the current one? Is it possible that evaluating the property will change the value of the condition?

Copy link
Contributor

@xbauch xbauch left a comment

Choose a reason for hiding this comment

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

It's not really used here, but it seems to do what it claims to be doing.

Copy link
Contributor

@owen-mc-diffblue owen-mc-diffblue left a comment

Choose a reason for hiding this comment

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

The first commit is fine. I didn't review the second one as I know nothing about goto-analyzer.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 4b0eb7f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113100556

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature/goto-analyzer-usability branch from 4b0eb7f to fadb25a Compare May 24, 2019 14:55
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: fadb25a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113111770

}
else if(condition.is_false())
{
property_status = property_statust::FAIL;
Copy link
Member

Choose a reason for hiding this comment

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

Is this a definite fail? If not, then it should be UNKNOWN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if a condition is false that means that using domain information it could be simplified to false, i.e. definite fail.

}
else
{
property_status = property_statust::UNKNOWN;
Copy link
Member

Choose a reason for hiding this comment

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

How can this happen? If the location is never assigned a value then it should be NOT_REACHED.

Copy link
Contributor Author

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue May 28, 2019

Choose a reason for hiding this comment

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

This means the condition could not be simplified to true or false using domain information (so it's neither definite fail or success) and the domain state at the location is not bottom so the location is reachable (edit: or rather, potentially reachable), therefore it is unknown.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to have this commentary on the various states in the code as well, and not just in the PR :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some comments explaining what was going on

@@ -9,6 +9,8 @@ Author: Martin Brain, [email protected]
#ifndef CPROVER_GOTO_ANALYZER_STATIC_VERIFIER_H
#define CPROVER_GOTO_ANALYZER_STATIC_VERIFIER_H

#include <goto-checker/properties.h>
#include <goto-programs/abstract_goto_model.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't a forward declaration be sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean just for abstract_goto_modelt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

const ai_baset &ai,
propertiest &properties)
{
auto const ns = namespacet{abstract_goto_model.get_symbol_table()};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have complained about this before and I'll keep doing so: why is the above better than const namespacet ns{abstract_goto_model.get_symbol_table()};? To me it seems that would be shorter and avoid any doubt about 1) the type of the object and 2) whether some operator= is being invoked or not. And if "consistency" is part of the rationale: in fact the above is the only case of auto that's not in violation of our current coding guidelines...

I keep going after this, because I'm worried that we will at some point arrive at write-only code. Explicitly spelling out types may seem like a nuisance to the person writing the code, but they are really helpful to any reader. In the code below, I actually have no idea what the types of property_status or predecessor are. Alas I'm actually unable to judge whether (not) using references is the right thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have to say I share the concerns of @tautschnig too, though he's put them more eloquently than I probably would have done. I'm not a huge fan of auto in anything other than very trivial contexts.

Copy link
Contributor Author

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue May 28, 2019

Choose a reason for hiding this comment

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

I don't omit the types here because I don't care about readability, but rather because in my opinion they're not very useful for readability; I did another scan over the code and tried to clarify as much a possible, adding types where I thought they're useful. I kept the auto in the for loop and for property_status - the former because it'd otherwise just be propertiest::value_type which IMHO doesn't really add much useful information, and the latter because the type would be property_statust which again doesn't really communicate anything over the variable name.

(Side note: operator= is never involved in initialisation)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature/goto-analyzer-usability branch 2 times, most recently from da3dd1d to 80daeef Compare May 28, 2019 18:11
@@ -23,4 +25,9 @@ bool static_verifier(
message_handlert &,
std::ostream &);

void static_verifier(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be documented. And it's a bit confusing to use a noun for a function which is returning void. (for me "verifier" here should imply you return an object which has a verify method)

Copy link
Contributor Author

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue May 29, 2019

Choose a reason for hiding this comment

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

This is doing more or less the same thing as the other static_verifier function that already is in this file, the only difference is that it writes the result to the propertiest passed in rather than writing them to stdout or to a file.

The "return" value here is the properties parameter (it's an in/out parameter, we read some information from each property and write its verification status back to it)

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature/goto-analyzer-usability branch from 80daeef to 17d4503 Compare May 29, 2019 10:54
@tautschnig
Copy link
Collaborator

@hannes-steffenhagen-diffblue Please rebase now that #4729 is in to make CI happy.

There is no need to restrict it to goto_modelt, this makes it easier to use in
some contexts.
This will make it easier to use with static_verifiert going forward.
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (develop@f175f75). Click here to learn what that means.
The diff coverage is 26.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #4703   +/-   ##
==========================================
  Coverage           ?   68.44%           
==========================================
  Files              ?     1270           
  Lines              ?   104817           
  Branches           ?        0           
==========================================
  Hits               ?    71744           
  Misses             ?    33073           
  Partials           ?        0
Impacted Files Coverage Δ
src/goto-analyzer/static_verifier.cpp 45.16% <0%> (ø)
src/analyses/ai.h 59.15% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f175f75...0f4a362. Read the comment docs.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 0f4a362).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/114085606

@tautschnig tautschnig merged commit 798f651 into diffblue:develop Jun 3, 2019
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.

9 participants