-
Notifications
You must be signed in to change notification settings - Fork 277
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,49 @@ struct static_verifier_resultt | |
irep_idt function_id; | ||
}; | ||
|
||
void static_verifier( | ||
const abstract_goto_modelt &abstract_goto_model, | ||
const ai_baset &ai, | ||
propertiest &properties) | ||
{ | ||
const namespacet ns{abstract_goto_model.get_symbol_table()}; | ||
// this is mutable because we want to change the property status | ||
// in this loop | ||
for(auto &property : properties) | ||
{ | ||
auto &property_status = property.second.status; | ||
const goto_programt::const_targett &property_location = property.second.pc; | ||
exprt condition = property_location->get_condition(); | ||
const std::unique_ptr<ai_baset::statet> predecessor_state_copy = | ||
ai.abstract_state_before(property_location); | ||
// simplify the condition given the domain information we have | ||
// about the state right before the assertion is evaluated | ||
predecessor_state_copy->ai_simplify(condition, ns); | ||
// if the condition simplifies to true the assertion always succeeds | ||
if(condition.is_true()) | ||
{ | ||
property_status = property_statust::PASS; | ||
} | ||
// if the condition simplifies to false the assertion always fails | ||
else if(condition.is_false()) | ||
{ | ||
property_status = property_statust::FAIL; | ||
} | ||
// if the domain state is bottom then the assertion is definitely | ||
// unreachable | ||
else if(predecessor_state_copy->is_bottom()) | ||
{ | ||
property_status = property_statust::NOT_REACHABLE; | ||
} | ||
// if the condition isn't definitely true, false or unreachable | ||
// we don't know whether or not it may fail | ||
else | ||
{ | ||
property_status = property_statust::UNKNOWN; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some comments explaining what was going on |
||
} | ||
} | ||
} | ||
|
||
/// Makes a status message string from a status. | ||
static const char *message(const static_verifier_resultt::statust &status) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,10 @@ Author: Martin Brain, martin.brain@cs.ox.ac.uk | |
#ifndef CPROVER_GOTO_ANALYZER_STATIC_VERIFIER_H | ||
#define CPROVER_GOTO_ANALYZER_STATIC_VERIFIER_H | ||
|
||
#include <goto-checker/properties.h> | ||
#include <iosfwd> | ||
|
||
class abstract_goto_modelt; | ||
class ai_baset; | ||
class goto_modelt; | ||
class message_handlert; | ||
|
@@ -23,4 +25,15 @@ bool static_verifier( | |
message_handlert &, | ||
std::ostream &); | ||
|
||
/// Use the information from the abstract interpreter to fill out the statuses | ||
/// of the passed properties | ||
/// \param abstract_goto_model The goto program to verify | ||
/// \param ai The abstract interpreter (should be run to fixpoint | ||
/// before calling this function) | ||
/// \param properties The properties to fill out | ||
void static_verifier( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is doing more or less the same thing as the other The "return" value here is the |
||
const abstract_goto_modelt &abstract_goto_model, | ||
const ai_baset &ai, | ||
propertiest &properties); | ||
|
||
#endif // CPROVER_GOTO_ANALYZER_STATIC_VERIFIER_H |
There was a problem hiding this comment.
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
.There was a problem hiding this comment.
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.