Go to the documentation of this file.
25 for(
const auto &bit : bv)
26 if(!bit.is_constant())
43 if(expr.
type().
id() != ID_bool)
68 return result.first->second;
74 result.first->second = literal;
91 else if(expr.
id() == ID_symbol)
93 symbolst::const_iterator result =
103 else if(expr.
id() == ID_literal)
110 if(expr.
id() == ID_not)
112 if(expr.
type().
id() == ID_bool)
121 else if(expr.
id() == ID_and || expr.
id() == ID_or)
131 if(expr.
id() == ID_and)
143 return expr.
id() == ID_and;
149 cachet::const_iterator cache_result =
cache.find(expr);
150 if(cache_result ==
cache.end())
158 if(!
use_cache || expr.
id() == ID_symbol || expr.
id() == ID_constant)
170 auto &cache_entry = result.first->second;
180 cache_entry = literal;
186 std::cout << literal <<
"=" << expr <<
'\n';
206 "constant expression of type bool should be either true or false");
210 else if(expr.
id() == ID_symbol)
214 else if(expr.
id() == ID_literal)
218 else if(expr.
id() == ID_nondet_symbol)
222 else if(expr.
id() == ID_implies)
228 else if(expr.
id() == ID_if)
236 else if(expr.
id() == ID_constraint_select_one)
240 "constraint_select_one should have at least two operands");
242 std::vector<literalt> op_bv;
243 op_bv.reserve(op.size());
251 b.reserve(op_bv.size() - 1);
253 for(
unsigned i = 1; i < op_bv.size(); i++)
261 expr.
id() == ID_or || expr.
id() == ID_and || expr.
id() == ID_xor ||
262 expr.
id() == ID_nor || expr.
id() == ID_nand)
266 "operator '" + expr.
id_string() +
"' takes at least one operand");
270 for(
const auto &operand : op)
271 bv.push_back(
convert(operand));
275 if(expr.
id() == ID_or)
277 else if(expr.
id() == ID_nor)
279 else if(expr.
id() == ID_and)
281 else if(expr.
id() == ID_nand)
283 else if(expr.
id() == ID_xor)
287 else if(expr.
id() == ID_not)
289 INVARIANT(op.size() == 1,
"not takes one operand");
292 else if(expr.
id() == ID_equal || expr.
id() == ID_notequal)
294 INVARIANT(op.size() == 2,
"equality takes two operands");
295 bool equal = (expr.
id() == ID_equal);
297 if(op[0].type().id() == ID_bool && op[1].type().id() == ID_bool)
303 else if(expr.
id() == ID_named_term)
309 return value_converted;
330 if(expr.
lhs().
id() == ID_symbol)
336 std::pair<symbolst::iterator, bool> result =
337 symbols.insert(std::pair<irep_idt, literalt>(identifier, tmp));
352 const bool has_only_boolean_operands = std::all_of(
354 return expr.type().id() == ID_bool;
357 if(has_only_boolean_operands)
359 if(expr.
id() == ID_not)
370 if(expr.
id() == ID_and)
377 else if(expr.
id() == ID_or)
394 else if(expr.
id() == ID_implies)
402 else if(expr.
id() == ID_equal)
411 if(expr.
id() == ID_implies)
419 else if(expr.
id() == ID_or)
449 const auto post_process_start = std::chrono::steady_clock::now();
455 const auto post_process_stop = std::chrono::steady_clock::now();
456 std::chrono::duration<double> post_process_runtime =
457 std::chrono::duration<double>(post_process_stop - post_process_start);
458 log.
status() <<
"Runtime Post-process: " << post_process_runtime.count()
479 if(expr.
type().
id() == ID_bool)
483 if(value.has_value())
503 for(
const auto &symbol :
symbols)
504 out << symbol.first <<
" = " <<
prop.
l_get(symbol.second) <<
'\n';
533 for(
const auto &assumption : assumptions)
568 return "propositional reduction";
#define UNREACHABLE
This should be used to mark dead code.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool equality_propagation
bvt assumption_stack
Assumptions on the stack.
literalt get_literal() const
virtual void set_assumptions(const bvt &)
virtual const std::string solver_text()=0
std::vector< size_t > context_size_stack
assumption_stack is segmented in contexts; Number of assumptions in each context on the stack
std::vector< literalt > bvt
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
mstreamt & status() const
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
The trinary if-then-else operator.
virtual literalt new_variable()=0
std::size_t context_literal_counter
To generate unique literal names for contexts.
Base class for all expressions.
void set_to_true(const exprt &expr)
For a Boolean expression expr, add the constraint 'expr'.
virtual void finish_eager_conversion()
virtual literalt lor(literalt a, literalt b)=0
void l_set_to_true(literalt a)
virtual void l_set_to(literalt a, bool value)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
bool is_true() const
Return whether the expression is a constant representing true.
virtual literalt convert_bool(const exprt &expr)
Expression to hold a symbol (variable)
virtual literalt land(literalt a, literalt b)=0
bool is_false() const
Return whether the expression is a constant representing false.
const literal_exprt & to_literal_expr(const exprt &expr)
Cast a generic exprt to a literal_exprt.
virtual void ignoring(const exprt &expr)
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 i...
typet & type()
Return the type of the expression.
void set_frozen(literalt)
virtual literalt lxor(literalt a, literalt b)=0
bool post_processing_done
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
virtual literalt limplies(literalt a, literalt b)=0
static const char * context_prefix
static optionalt< smt_termt > get_identifier(const exprt &expr, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_handle_identifiers, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_identifiers)
#define forall_operands(it, expr)
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
const std::string & id_string() const
exprt get(const exprt &expr) const override
Return expr with variables replaced by values from satisfying assignment if available.
literalt const_literal(bool value)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
virtual void set_frozen(literalt)
std::vector< exprt > operandst
The Boolean constant false.
std::size_t get_number_of_solver_calls() const
virtual literalt get_literal(const irep_idt &symbol)
nonstd::optional< T > optionalt
virtual bool is_in_conflict(literalt l) const =0
Returns true if an assumption is in the final conflict.
literalt convert(const exprt &expr) override
Convert a Boolean expression and return the corresponding literal.
resultt
Result of running the decision procedure.
virtual literalt convert_rest(const exprt &expr)
virtual void set_variable_name(literalt, const irep_idt &)
void add_constraints_to_prop(const exprt &expr, bool value)
Helper method used by set_to for adding the constraints to prop.
virtual literalt lequal(literalt a, literalt b)=0
bool is_in_conflict(const exprt &expr) const override
Returns true if an expression is in the final conflict leading to UNSAT.
virtual tvt l_get(literalt a) const =0
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
std::string decision_procedure_text() const override
Return a textual description of the decision procedure.
const implies_exprt & to_implies_expr(const exprt &expr)
Cast an exprt to a implies_exprt.
decision_proceduret::resultt dec_solve() override
Run the decision procedure to solve the problem.
bool is_constant() const
Return whether the expression is a constant.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
void print_assignment(std::ostream &out) const override
Print satisfying assignment to out.
const named_term_exprt & to_named_term_expr(const exprt &expr)
Cast an exprt to a named_term_exprt.
The Boolean constant true.
mstreamt & warning() const
void push() override
Push a new context on the stack This context becomes a child context nested in the current context.
void pop() override
Pop whatever is on top of the stack.
virtual optionalt< bool > get_bool(const exprt &expr) const
Get a boolean value from the model if the formula is satisfiable.
virtual literalt lselect(literalt a, literalt b, literalt c)=0
void lcnf(literalt l0, literalt l1)
void set_to(const exprt &expr, bool value) override
For a Boolean expression expr, add the constraint 'current_context => expr' if value is true,...
mstreamt & statistics() const
virtual bool set_equality_to_true(const equal_exprt &expr)
std::size_t get_number_of_solver_calls() const override
Return the number of incremental solver calls.