forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request diffblue#1404 from LAJW/string-refinement-functional
TG-634 Functional style for string refinement
- Loading branch information
Showing
9 changed files
with
757 additions
and
533 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -20,11 +20,9 @@ Author: Daniel Kroening, [email protected] | |
|
||
class bv_refinementt:public bv_pointerst | ||
{ | ||
public: | ||
struct infot | ||
private: | ||
struct configt | ||
{ | ||
const namespacet *ns=nullptr; | ||
propt *prop=nullptr; | ||
ui_message_handlert::uit ui=ui_message_handlert::uit::PLAIN; | ||
/// Max number of times we refine a formula node | ||
unsigned max_node_refinement=5; | ||
|
@@ -33,6 +31,12 @@ class bv_refinementt:public bv_pointerst | |
/// Enable arithmetic refinement | ||
bool refine_arithmetic=true; | ||
}; | ||
public: | ||
struct infot:public configt | ||
{ | ||
const namespacet *ns=nullptr; | ||
propt *prop=nullptr; | ||
}; | ||
|
||
explicit bv_refinementt(const infot &info); | ||
|
||
|
@@ -103,18 +107,12 @@ class bv_refinementt:public bv_pointerst | |
|
||
// 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 | ||
ui_message_handlert::uit ui; | ||
configt config_; | ||
}; | ||
|
||
#endif // CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H |
This file contains 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 |
---|---|---|
|
@@ -14,11 +14,8 @@ Author: Daniel Kroening, [email protected] | |
|
||
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(info.ui) | ||
config_(info) | ||
{ | ||
// check features we need | ||
PRECONDITION(prop.has_set_assumptions()); | ||
|
@@ -44,11 +41,11 @@ decision_proceduret::resultt bv_refinementt::dec_solve() | |
status() << "BV-Refinement: iteration " << iteration << eom; | ||
|
||
// output the very same information in a structured fashion | ||
if(ui==ui_message_handlert::uit::XML_UI) | ||
if(config_.ui==ui_message_handlert::uit::XML_UI) | ||
{ | ||
xmlt xml("refinement-iteration"); | ||
xml.data=std::to_string(iteration); | ||
std::cout << xml << '\n'; | ||
status() << xml << '\n'; | ||
} | ||
|
||
switch(prop_solve()) | ||
|
This file contains 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 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 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 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 |
---|---|---|
|
@@ -28,10 +28,10 @@ Author: Romain Brenguier, [email protected] | |
#include <util/ssa_expr.h> | ||
|
||
string_constraint_generatort::string_constraint_generatort( | ||
const string_constraint_generatort::infot& info): | ||
const string_constraint_generatort::infot& info, const namespacet& ns): | ||
max_string_length(info.string_max_length), | ||
m_force_printable_characters(info.string_printable), | ||
m_ns(*info.ns) { } | ||
m_ns(ns) { } | ||
|
||
const std::vector<exprt> &string_constraint_generatort::get_axioms() const | ||
{ | ||
|
@@ -628,3 +628,19 @@ exprt string_constraint_generatort::add_axioms_for_to_char_array( | |
string_exprt str=get_string_expr(args(f, 1)[0]); | ||
return str.content(); | ||
} | ||
|
||
exprt string_constraint_generatort::substitute_function_applications( | ||
const exprt &expr) | ||
{ | ||
exprt copy=expr; | ||
for(exprt &operand : copy.operands()) | ||
operand=substitute_function_applications(exprt(operand)); | ||
|
||
if(copy.id()==ID_function_application) | ||
{ | ||
function_application_exprt f=to_function_application_expr(copy); | ||
return this->add_axioms_for_function_application(f); | ||
} | ||
|
||
return copy; | ||
} |
Oops, something went wrong.