-
Notifications
You must be signed in to change notification settings - Fork 269
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
Use goto-analyzer to add assumptions, assertions and code contracts #7964
base: develop
Are you sure you want to change the base?
Use goto-analyzer to add assumptions, assertions and code contracts #7964
Conversation
6e78afd
to
1d4a86e
Compare
/// Gives a Boolean condition that is true for all values represented by the | ||
/// domain. This allows domains to be converted into program invariants. | ||
virtual exprt to_predicate(void) const | ||
/// Gives a Boolean condition involving expression from the set that |
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.
Gives a Boolean condition involving expressions from the given set that... ?
exprt target = value_stack.to_expression(); | ||
|
||
// This is simple if there are no restrictions: | ||
if(scope.size() == 0) |
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.
scope.empty() ?
#include <iosfwd> | ||
|
||
// What kind of instrumentation to add | ||
enum class instrument_actiont |
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.
❓ Maybe this should (eventually also) consider the contracts work that @remi-delmas-3000 et al are doing? Or at least it should be considered to avoid that the design is unnecessarily incompatible with it (I doubt it is, but might be worth checking).
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.
We are in contact and the goal is to fit with and support @remi-delmas-3000 's work. Thanks for the link though, if I didn't know about what he was doing it would be very important to find out!
An abstract domain may contain information about variables from a calling context which are not valid in an assertion in a different function. This commit changes the interface to give a limiting scope. This is particularly fiddly in the case of pointers to things that are out of scope.
1d4a86e
to
c0dc3a6
Compare
This is a work-in-progress PR posted for general feedback and early opinions. It adds a new 'task' to goto-analyzer which runs the abstract interpreter, converts the domains to predicates and then adds them into the goto program as assumptions, assertions or as contracts. Assumptions are intended to aid other analysis tools which can use (but not necessarily create) inductive invariants. Assertions are intended to give a way to cross-test the abstract interpreter using CBMC. Contracts are intended to give better default contracts for code that does not have them and to help users in writing the obvious but tedious parts.
Things that still need some work:
__CPROVER_return
in the contracts.true
which is correct and over-approximate but not very helpful. It is not immediately clear what the "right" approach is.assigns
contracts are not generated yet as they need additional support for domain difference.