Skip to content

Partial expression simplification #1020

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

Closed

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Jun 15, 2017

Depends on variable sensitivity domain: #708
Fixes part of diffblue/cbmc-toyota#132

When calling ai_simplify, previously if we couldn't simplify the whole expression we gave up. Now we
recurse over the sub-elements to get a partially simplified expression. E.g. if we have an array whose value is top, but the index i is known to be 1 then arr[i] will simplify to:

arr[1]

Real diff: de2f979

martin and others added 23 commits June 15, 2017 15:04
The option string --show --intervals is more flexible, --show-intervals is now an alias.
This includes skeleton code written by @martin-cs.

Added hook for running the variable sensitivity

Involved removing messaget inheritance since we require a zero parameter
constructor for ai_baset

Terminate correctly

Made the domain correclty find the fixed point. The merge operation
returns whether the merge actually changed any values by implementing a
operator== for each of the abstract objects.

Further, when merging a map, if a key is absent from one map then we
remove it from the other unless the map is bottom.

Adding handlers for the special types

They are just stubs at the moment, returning top as we need the abstract
objects that represent them.

Updated interface for ai_domain_baset
thk123 added 19 commits June 15, 2017 17:53
Modify the merge to return shared pointers by replacing returns of this
with returns of `shared_from_this`. This simplifies the code for dealing
with when need to modify the result in dervied classes as we are no
longer responsible for freeing the pointer returned by the super class.
The base merge should always result in either top or bottom (it is up
for dervied classes to clear the top flag if they are not top).

Correctly use the base class merge when appropriate in merging constant
values.
Refactored the merge maps method to use std::intersection as there was a
bug with empty maps caught by the unit tests.
Use the CPROVER_assert as behaviour is consistent across platforms.
Removed some unnecessary debug information from the tests
In release builds, the top/bottom status of the enviroment was
undefined. This ensures the enviroment is set to top (i.e. an entry
point).
Previously each abstract object that implemented merge had to correctly
redirect merging top with anything or merging with a bottom.

This is now handled directly in the root merge by checking the three
cases where the base merge must be used.

If this is bottom must still be handled by derived classes as we must
create an abstract object of the same type.
At some point this commit needs backdating as the ai_domain interface
has changed under our feet.
@martin-cs
Copy link
Collaborator

Looks good to me. The only nit is to make sure to update the call to ai_simplify to the new signature.

@martin-cs
Copy link
Collaborator

Let's see if the merge issues go away once the rebase is done. Other than that I am happy with this change.

If the ai_simplify is not able to resolve the expression to a constant,
it tries to simplify recursively any child operations. For example,
given a int i that is know to be 1, and an unknown (top) array a, it
would convert a[i] to a[1].
@thk123 thk123 force-pushed the bugfix/partial-expression-simplification branch from 9f2198a to de2f979 Compare June 15, 2017 17:58
@tautschnig tautschnig changed the base branch from master to develop August 22, 2017 12:22
@hannes-steffenhagen-diffblue
Copy link
Contributor

Closing as it's unlike @thk123 is going to pick this up again. Also I believe a version of this was eventually implemented regardless.

@martin-cs
Copy link
Collaborator

Just to close the loop, VSD did get merged and @jezhiggins is currently working on this bit of code, hopefully for a final version.

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.

5 participants