CBMC
|
#include <smt2_incremental_decision_procedure.h>
Classes | |
class | sequencet |
Generators of sequences of uniquely identifying numbers used for naming SMT functions introduced by the decision procedure. More... | |
Public Member Functions | |
smt2_incremental_decision_proceduret (const namespacet &_ns, std::unique_ptr< smt_base_solver_processt > solver_process, message_handlert &message_handler) | |
exprt | handle (const exprt &expr) override |
Generate a handle, which is an expression that has the same value as the argument in any model that is generated; this offers an efficient way to refer to the expression in subsequent calls to get or set_to. More... | |
exprt | get (const exprt &expr) const override |
Return expr with variables replaced by values from satisfying assignment if available. More... | |
void | print_assignment (std::ostream &out) const override |
Print satisfying assignment to out . More... | |
std::string | decision_procedure_text () const override |
Return a textual description of the decision procedure. More... | |
std::size_t | get_number_of_solver_calls () const override |
Return the number of incremental solver calls. More... | |
void | set_to (const exprt &expr, bool value) override |
For a Boolean expression expr , add the constraint 'expr' if value is true , otherwise add 'not expr'. More... | |
void | push (const std::vector< exprt > &assumptions) override |
Pushes a new context on the stack that consists of the given (possibly empty vector of) assumptions . More... | |
void | push () override |
Push a new context on the stack This context becomes a child context nested in the current context. More... | |
void | pop () override |
Pop whatever is on top of the stack. More... | |
std::optional< exprt > | get_expr (const smt_termt &descriptor, const typet &type) const |
Gets the value of descriptor from the solver and returns the solver response expressed as an exprt of type type . More... | |
std::optional< exprt > | get_expr (const smt_termt &struct_term, const struct_tag_typet &type) const |
std::optional< exprt > | get_expr (const smt_termt &union_term, const union_tag_typet &type) const |
std::optional< exprt > | get_expr (const smt_termt &array, const array_typet &type) const |
Public Member Functions inherited from stack_decision_proceduret | |
virtual | ~stack_decision_proceduret ()=default |
Public Member Functions inherited from decision_proceduret | |
void | set_to_true (const exprt &) |
For a Boolean expression expr , add the constraint 'expr'. More... | |
void | set_to_false (const exprt &) |
For a Boolean expression expr , add the constraint 'not expr'. More... | |
resultt | operator() () |
Run the decision procedure to solve the problem This corresponds to SMT-LIB's check-sat. More... | |
resultt | operator() (const exprt &assumption) |
Run the decision procedure to solve the problem under the given assumption. More... | |
virtual | ~decision_proceduret () |
Protected Member Functions | |
resultt | dec_solve (const exprt &) override |
Implementation of the decision procedure. More... | |
template<typename t_exprt > | |
void | define_array_function (const t_exprt &array) |
Defines a function of array sort and asserts the element values from array_exprt or array_of_exprt . More... | |
void | initialize_array_elements (const array_exprt &array, const smt_identifier_termt &array_identifier) |
Generate and send to the SMT solver clauses asserting that each array element is as specified by array . More... | |
void | initialize_array_elements (const array_of_exprt &array, const smt_identifier_termt &array_identifier) |
Generate and send to the SMT solver clauses asserting that each array element is as specified by array . More... | |
void | initialize_array_elements (const string_constantt &string, const smt_identifier_termt &array_identifier) |
void | define_dependent_functions (const exprt &expr) |
Defines any functions which expr depends on, which have not yet been defined, along with their dependencies in turn. More... | |
void | ensure_handle_for_expr_defined (const exprt &expr) |
If a function has not been defined for handling expr , then a new function is defined. More... | |
smt_termt | convert_expr_to_smt (const exprt &expr) |
Add objects in expr to object_map if needed and convert to smt. More... | |
void | define_index_identifiers (const exprt &expr) |
exprt | substitute_defined_padding (exprt expr) |
In the case where lowering passes insert instances of the anonymous nondet_padding_exprt , these need functions declaring for each instance. More... | |
void | define_object_properties () |
Sends the solver the definitions of the object sizes and dynamic memory statuses. More... | |
exprt | lower (exprt expression) const |
Performs a combination of transformations which reduces the set of possible expression forms by expressing these in terms of the remaining language features. More... | |
std::optional< smt_termt > | get_identifier (const exprt &expr) const |
Protected Attributes | |
const namespacet & | ns |
Namespace for looking up the expressions which symbol_exprts relate to. More... | |
size_t | number_of_solver_calls |
The number of times dec_solve() has been called. More... | |
std::unique_ptr< smt_base_solver_processt > | solver_process |
For handling the lifetime of and communication with the separate SMT solver process. More... | |
messaget | log |
For reporting errors, warnings and debugging information back to the user. More... | |
class smt2_incremental_decision_proceduret::sequencet | handle_sequence |
class smt2_incremental_decision_proceduret::sequencet | array_sequence |
class smt2_incremental_decision_proceduret::sequencet | index_sequence |
class smt2_incremental_decision_proceduret::sequencet | padding_sequence |
std::unordered_map< exprt, smt_identifier_termt, irep_hash > | expression_handle_identifiers |
When the handle(exprt) member function is called, the decision procedure commands the SMT solver to define a new function corresponding to the given expression. More... | |
std::unordered_map< exprt, smt_identifier_termt, irep_hash > | expression_identifiers |
As part of the decision procedure's overall translation of CBMCs exprt s into SMT terms, some subexpressions are substituted for separate SMT functions. More... | |
std::unordered_map< irep_idt, smt_identifier_termt > | identifier_table |
This maps from the unsorted/untyped string/symbol for the identifiers which we have declared in SMT solver to the corresponding sorted/typed smt_identifier_termt . More... | |
smt_object_mapt | object_map |
This map is used to track object related state. More... | |
std::vector< bool > | object_properties_defined |
The size of each object and the dynamic object stus is separately defined as a pre-solving step. More... | |
smt_object_sizet | object_size_function |
Implementation of the SMT formula for the object size function. More... | |
smt_is_dynamic_objectt | is_dynamic_object_function |
Implementation of the SMT formula for the dynamic object status lookup function. More... | |
type_size_mapt | pointer_sizes_map |
Precalculated type sizes used for pointer arithmetic. More... | |
struct_encodingt | struct_encoding |
Additional Inherited Members | |
Public Types inherited from decision_proceduret | |
enum class | resultt { D_SATISFIABLE , D_UNSATISFIABLE , D_ERROR } |
Result of running the decision procedure. More... | |
Definition at line 28 of file smt2_incremental_decision_procedure.h.
|
explicit |
_ns | Namespace for looking up the expressions which symbol_exprts relate to. |
solver_process | The smt2 solver process communication interface. |
message_handler | The messaging system to be used for logging purposes. |
Definition at line 263 of file smt2_incremental_decision_procedure.cpp.
Add objects in expr
to object_map if needed and convert to smt.
Definition at line 380 of file smt2_incremental_decision_procedure.cpp.
|
overrideprotectedvirtual |
Implementation of the decision procedure.
Implements decision_proceduret.
Definition at line 705 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
Return a textual description of the decision procedure.
Implements decision_proceduret.
Definition at line 602 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Defines a function of array sort and asserts the element values from array_exprt
or array_of_exprt
.
The new array function identifier is added to the expression_identifiers
map.
array_exprt
or array_of_exprt
. Definition at line 150 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Defines any functions which expr
depends on, which have not yet been defined, along with their dependencies in turn.
Definition at line 184 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Definition at line 334 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Sends the solver the definitions of the object sizes and dynamic memory statuses.
Definition at line 672 of file smt2_incremental_decision_procedure.cpp.
|
protected |
If a function has not been defined for handling expr
, then a new function is defined.
If the corresponding function exists already, then no action is taken.
Definition at line 311 of file smt2_incremental_decision_procedure.cpp.
Return expr
with variables replaced by values from satisfying assignment if available.
Return nil
if not available
Implements decision_proceduret.
Definition at line 548 of file smt2_incremental_decision_procedure.cpp.
std::optional< exprt > smt2_incremental_decision_proceduret::get_expr | ( | const smt_termt & | array, |
const array_typet & | type | ||
) | const |
Definition at line 434 of file smt2_incremental_decision_procedure.cpp.
std::optional< exprt > smt2_incremental_decision_proceduret::get_expr | ( | const smt_termt & | descriptor, |
const typet & | type | ||
) | const |
Gets the value of descriptor
from the solver and returns the solver response expressed as an exprt of type type
.
This is an implementation detail of the get(exprt)
member function.
Definition at line 486 of file smt2_incremental_decision_procedure.cpp.
std::optional< exprt > smt2_incremental_decision_proceduret::get_expr | ( | const smt_termt & | struct_term, |
const struct_tag_typet & | type | ||
) | const |
Definition at line 464 of file smt2_incremental_decision_procedure.cpp.
std::optional< exprt > smt2_incremental_decision_proceduret::get_expr | ( | const smt_termt & | union_term, |
const union_tag_typet & | type | ||
) | const |
Definition at line 475 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Definition at line 411 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
Return the number of incremental solver calls.
Implements decision_proceduret.
Definition at line 608 of file smt2_incremental_decision_procedure.cpp.
Generate a handle, which is an expression that has the same value as the argument in any model that is generated; this offers an efficient way to refer to the expression in subsequent calls to get or set_to.
The returned expression may be the expression itself or a more compact but solver-specific representation.
Implements decision_proceduret.
Definition at line 401 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Generate and send to the SMT solver clauses asserting that each array element is as specified by array
.
Definition at line 107 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Generate and send to the SMT solver clauses asserting that each array element is as specified by array
.
ALL
SMT logic that is not in the SMT 2.6 standard, but that it has been tested working on Z3 and CVC5. Definition at line 124 of file smt2_incremental_decision_procedure.cpp.
|
protected |
Definition at line 142 of file smt2_incremental_decision_procedure.cpp.
Performs a combination of transformations which reduces the set of possible expression forms by expressing these in terms of the remaining language features.
Definition at line 690 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
Pop whatever is on top of the stack.
Popping from the empty stack results in an invariant violation.
Implements stack_decision_proceduret.
Definition at line 654 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
Print satisfying assignment to out
.
Implements decision_proceduret.
Definition at line 595 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
Push a new context on the stack This context becomes a child context nested in the current context.
Implements stack_decision_proceduret.
Definition at line 649 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
Pushes a new context on the stack that consists of the given (possibly empty vector of) assumptions
.
This context becomes a child context nested in the current context. An assumption is usually obtained by calling decision_proceduret::handle
. Thus it can be a Boolean expression or something more solver-specific such as literal_exprt
. An empty vector of assumptions counts as an element on the stack (and therefore needs to be popped), but has no effect beyond that.
Implements stack_decision_proceduret.
Definition at line 638 of file smt2_incremental_decision_procedure.cpp.
|
overridevirtual |
For a Boolean expression expr
, add the constraint 'expr' if value
is true
, otherwise add 'not expr'.
Implements decision_proceduret.
Definition at line 613 of file smt2_incremental_decision_procedure.cpp.
In the case where lowering passes insert instances of the anonymous nondet_padding_exprt
, these need functions declaring for each instance.
These instances are then substituted for the function identifier in order to free the solver to choose a non-det value.
Definition at line 363 of file smt2_incremental_decision_procedure.cpp.
|
protected |
|
protected |
When the handle(exprt)
member function is called, the decision procedure commands the SMT solver to define a new function corresponding to the given expression.
The mapping of the expressions to the function identifiers is stored in this map so that when there is as subsequent get(exprt)
call for the same expression, the function identifier can be requested from the solver, rather than reconverting the expression.
Definition at line 154 of file smt2_incremental_decision_procedure.h.
|
protected |
As part of the decision procedure's overall translation of CBMCs exprt
s into SMT terms, some subexpressions are substituted for separate SMT functions.
This map associates these sub-expressions to the identifiers of the separated functions. This applies to symbol_exprt
where it is fairly natural to define the value of the symbol using a separate function, but also to the expressions which define entire arrays. This includes array_exprt
for example and will additionally include other similar array expressions when support for them is implemented.
Definition at line 164 of file smt2_incremental_decision_procedure.h.
|
protected |
|
protected |
This maps from the unsorted/untyped string/symbol for the identifiers which we have declared in SMT solver to the corresponding sorted/typed smt_identifier_termt
.
This enables type checking the parse trees of responses received back from the solver. It is required because without the definitive sorts we would need to attempt to infer the sorts of identifiers from the surrounding terms which would be a looser check with a more complex implementation.
Definition at line 172 of file smt2_incremental_decision_procedure.h.
|
protected |
|
protected |
Implementation of the SMT formula for the dynamic object status lookup function.
This is stateful because it depends on the configuration of the number of object bits and how many bits wide the size type is configured to be.
Definition at line 190 of file smt2_incremental_decision_procedure.h.
|
protected |
For reporting errors, warnings and debugging information back to the user.
Definition at line 134 of file smt2_incremental_decision_procedure.h.
|
protected |
Namespace for looking up the expressions which symbol_exprts relate to.
This includes the symbols defined outside of the decision procedure but does not include any additional SMT function identifiers introduced by the decision procedure.
Definition at line 126 of file smt2_incremental_decision_procedure.h.
|
protected |
The number of times dec_solve()
has been called.
Definition at line 128 of file smt2_incremental_decision_procedure.h.
|
protected |
This map is used to track object related state.
See documentation in object_tracking.h for details.
Definition at line 175 of file smt2_incremental_decision_procedure.h.
|
protected |
The size of each object and the dynamic object stus is separately defined as a pre-solving step.
object_properties_defined[object ID]
is set to true for objects where the size has been defined. This is used to avoid defining the size of the same object multiple times in the case where multiple rounds of solving are carried out.
Definition at line 181 of file smt2_incremental_decision_procedure.h.
|
protected |
Implementation of the SMT formula for the object size function.
This is stateful because it depends on the configuration of the number of object bits and how many bits wide the size type is configured to be.
Definition at line 185 of file smt2_incremental_decision_procedure.h.
|
protected |
|
protected |
Precalculated type sizes used for pointer arithmetic.
Definition at line 192 of file smt2_incremental_decision_procedure.h.
|
protected |
For handling the lifetime of and communication with the separate SMT solver process.
Definition at line 132 of file smt2_incremental_decision_procedure.h.
|
protected |
Definition at line 193 of file smt2_incremental_decision_procedure.h.