-
Notifications
You must be signed in to change notification settings - Fork 273
Refactor string refinement constructors #1300
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
Merged
romainbrenguier
merged 32 commits into
diffblue:develop
from
LAJW:refactor/string-refinement-constructors
Aug 31, 2017
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
22b4885
Remove usage of static in the header file
848f2a5
Constraint gen cosmetics
3217fe3
constraint_generator message is a member
c51e35e
Use C++11 initialization for constraint generator members
cf950ab
Use vector instead of list for constraint_generator data
8043a0d
Hide index_symbols and boolean_symbols in constraint generator
16a0a34
constraint generator const namespace
51d897a
Better string_refinement constructor Act 1
9146575
Better string_refinement constructor Act II
a00b2db
String refinement - remove unused public methods, fix comments
30fe11b
Better string_constraint_generator constructor
99c815e
Make string_constraint_generatort::fresh_symbol non-static
abe4046
Better bv_refinement constructor
792a70d
Hide bv_refinement members, add override specifier
07f6b39
Remove unnecessary typedef
50173d6
Make some string_constraint_generator methods static
aa85392
Make more generator methods private
5368c8c
Private get_created_strings
a440da7
Group generator's member variables
01c6767
Rename axioms to m_axioms
e5c45a5
Prefix all generator member variables with "m_"
1282d03
Update unit tests with new constructors
4087187
Don't pass language_uit::uit as a pointer
83a29dc
Fix linter errors
107704a
Fix is_in_conflict with conflict override
fd59d47
Preprocess constexpr
acaad4f
Remove dead bv_refinementt::set_to
04fae6d
Correct comment
7fd2bfa
Use_counter_example assignable via constructor
22d699c
Move constexpr ifdef into a util header
8da7c30
Constraint generator doxygen
0838f61
Fix function declaration slicing
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,34 +21,44 @@ Author: Daniel Kroening, [email protected] | |
class bv_refinementt:public bv_pointerst | ||
{ | ||
public: | ||
bv_refinementt(const namespacet &_ns, propt &_prop); | ||
~bv_refinementt(); | ||
struct infot | ||
{ | ||
const namespacet *ns=nullptr; | ||
propt *prop=nullptr; | ||
language_uit::uit ui=language_uit::uit::PLAIN; | ||
/// Max number of times we refine a formula node | ||
unsigned max_node_refinement=5; | ||
/// Enable array refinement | ||
bool refine_arrays=true; | ||
/// Enable arithmetic refinement | ||
bool refine_arithmetic=true; | ||
}; | ||
|
||
virtual decision_proceduret::resultt dec_solve(); | ||
explicit bv_refinementt(const infot &info); | ||
|
||
virtual std::string decision_procedure_text() const | ||
decision_proceduret::resultt dec_solve() override; | ||
|
||
std::string decision_procedure_text() const override | ||
{ | ||
return "refinement loop with "+prop.solver_text(); | ||
} | ||
|
||
// NOLINTNEXTLINE(readability/identifiers) | ||
typedef bv_pointerst SUB; | ||
|
||
// maximal number of times we refine a formula node | ||
unsigned max_node_refinement; | ||
// enable/disable refinements | ||
bool do_array_refinement; | ||
bool do_arithmetic_refinement; | ||
protected: | ||
|
||
using bv_pointerst::is_in_conflict; | ||
// Refine array | ||
void post_process_arrays() override; | ||
|
||
void set_ui(language_uit::uit _ui) { ui=_ui; } | ||
// Refine arithmetic | ||
bvt convert_mult(const exprt &expr) override; | ||
bvt convert_div(const div_exprt &expr) override; | ||
bvt convert_mod(const mod_exprt &expr) override; | ||
bvt convert_floatbv_op(const exprt &expr) override; | ||
|
||
protected: | ||
resultt prop_solve(); | ||
void set_assumptions(const bvt &_assumptions) override; | ||
|
||
private: | ||
// the list of operator approximations | ||
struct approximationt | ||
struct approximationt final | ||
{ | ||
public: | ||
explicit approximationt(std::size_t _id_nr): | ||
|
@@ -79,39 +89,30 @@ class bv_refinementt:public bv_pointerst | |
std::size_t id_nr; | ||
}; | ||
|
||
typedef std::list<approximationt> approximationst; | ||
approximationst approximations; | ||
|
||
resultt prop_solve(); | ||
approximationt &add_approximation(const exprt &expr, bvt &bv); | ||
bool conflicts_with(approximationt &approximation); | ||
void check_SAT(approximationt &approximation); | ||
void check_UNSAT(approximationt &approximation); | ||
void initialize(approximationt &approximation); | ||
void get_values(approximationt &approximation); | ||
bool is_in_conflict(approximationt &approximation); | ||
|
||
virtual void check_SAT(); | ||
virtual void check_UNSAT(); | ||
bool progress; | ||
|
||
// we refine the theory of arrays | ||
virtual void post_process_arrays(); | ||
void check_SAT(); | ||
void check_UNSAT(); | ||
void arrays_overapproximated(); | ||
void freeze_lazy_constraints(); | ||
|
||
// we refine expensive arithmetic | ||
virtual bvt convert_mult(const exprt &expr); | ||
virtual bvt convert_div(const div_exprt &expr); | ||
virtual bvt convert_mod(const mod_exprt &expr); | ||
virtual bvt convert_floatbv_op(const exprt &expr); | ||
|
||
// for collecting statistics | ||
virtual void set_to(const exprt &expr, bool value); | ||
|
||
// overloading | ||
virtual void set_assumptions(const bvt &_assumptions); | ||
// MEMBERS | ||
|
||
// Maximum number of times we refine a formula node | ||
const unsigned max_node_refinement; | ||
// Refinement toggles | ||
const bool do_array_refinement; | ||
const bool do_arithmetic_refinement; | ||
bool progress; | ||
std::vector<approximationt> approximations; | ||
bvt parent_assumptions; | ||
|
||
protected: | ||
// use gui format | ||
language_uit::uit ui; | ||
}; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,25 +12,20 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <util/xml.h> | ||
|
||
bv_refinementt::bv_refinementt( | ||
const namespacet &_ns, propt &_prop): | ||
bv_pointerst(_ns, _prop), | ||
max_node_refinement(5), | ||
do_array_refinement(true), | ||
do_arithmetic_refinement(true), | ||
bv_refinementt::bv_refinementt(const infot &info): | ||
bv_pointerst(*info.ns, *info.prop), | ||
max_node_refinement(info.max_node_refinement), | ||
do_array_refinement(info.refine_arrays), | ||
do_arithmetic_refinement(info.refine_arithmetic), | ||
progress(false), | ||
ui(ui_message_handlert::uit::PLAIN) | ||
ui(info.ui) | ||
{ | ||
// check features we need | ||
PRECONDITION(prop.has_set_assumptions()); | ||
PRECONDITION(prop.has_set_to()); | ||
PRECONDITION(prop.has_is_in_conflict()); | ||
} | ||
|
||
bv_refinementt::~bv_refinementt() | ||
{ | ||
} | ||
|
||
decision_proceduret::resultt bv_refinementt::dec_solve() | ||
{ | ||
// do the usual post-processing | ||
|
@@ -96,17 +91,16 @@ decision_proceduret::resultt bv_refinementt::prop_solve() | |
// this puts the underapproximations into effect | ||
bvt assumptions=parent_assumptions; | ||
|
||
for(approximationst::const_iterator | ||
a_it=approximations.begin(); | ||
a_it!=approximations.end(); | ||
a_it++) | ||
for(const approximationt &approximation : approximations) | ||
{ | ||
assumptions.insert( | ||
assumptions.end(), | ||
a_it->over_assumptions.begin(), a_it->over_assumptions.end()); | ||
approximation.over_assumptions.begin(), | ||
approximation.over_assumptions.end()); | ||
assumptions.insert( | ||
assumptions.end(), | ||
a_it->under_assumptions.begin(), a_it->under_assumptions.end()); | ||
approximation.under_assumptions.begin(), | ||
approximation.under_assumptions.end()); | ||
} | ||
|
||
prop.set_assumptions(assumptions); | ||
|
@@ -127,40 +121,16 @@ void bv_refinementt::check_SAT() | |
|
||
arrays_overapproximated(); | ||
|
||
for(approximationst::iterator | ||
a_it=approximations.begin(); | ||
a_it!=approximations.end(); | ||
a_it++) | ||
check_SAT(*a_it); | ||
for(approximationt &approximation : this->approximations) | ||
check_SAT(approximation); | ||
} | ||
|
||
void bv_refinementt::check_UNSAT() | ||
{ | ||
progress=false; | ||
|
||
for(approximationst::iterator | ||
a_it=approximations.begin(); | ||
a_it!=approximations.end(); | ||
a_it++) | ||
check_UNSAT(*a_it); | ||
} | ||
|
||
void bv_refinementt::set_to(const exprt &expr, bool value) | ||
{ | ||
#if 0 | ||
unsigned prev=prop.no_variables(); | ||
SUB::set_to(expr, value); | ||
unsigned n=prop.no_variables()-prev; | ||
std::cout << n << " EEE " << expr.id() << "@" << expr.type().id(); | ||
forall_operands(it, expr) | ||
std::cout << " " << it->id() << "@" << it->type().id(); | ||
if(expr.id()=="=" && expr.operands().size()==2) | ||
forall_operands(it, expr.op1()) | ||
std::cout << " " << it->id() << "@" << it->type().id(); | ||
std::cout << '\n'; | ||
#else | ||
SUB::set_to(expr, value); | ||
#endif | ||
for(approximationt &approximation : this->approximations) | ||
check_UNSAT(approximation); | ||
} | ||
|
||
void bv_refinementt::set_assumptions(const bvt &_assumptions) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you can used ranged for
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.
Indeed I could. But this is just a function rename to make clang compile without warnings.