27 if(truth && cond.
id() == ID_lt && expr.
id() == ID_lt)
33 cond_lt.op0() == expr_lt.op0() && cond_lt.op1().is_constant() &&
34 expr_lt.op1().is_constant() &&
35 cond_lt.op1().type() == expr_lt.op1().type())
52 cond_lt.op1() == expr_lt.op1() && cond_lt.op0().is_constant() &&
53 expr_lt.op0().is_constant() &&
54 cond_lt.op0().type() == expr_lt.op0().type())
98 bool no_change =
true;
108 for(
const auto &op : cond.
operands())
117 bool no_change =
true;
127 for(
const auto &op : cond.
operands())
136 bool no_change =
true;
149 bool tno_change =
true;
150 bool fno_change =
true;
152 if(cond.
id() == ID_and)
157 else if(cond.
id() == ID_or)
173 return tno_change && fno_change;
178 bool no_change =
true;
185 if(expr.
id() == ID_and)
190 for(exprt::operandst::iterator it1 = operands.begin();
191 it1 != operands.end();
194 for(exprt::operandst::iterator it2 = operands.begin();
195 it2 != operands.end();
208 no_change = tmp && no_change;
231 result.
cond() = std::move(cond.
expr);
251 if(r_cond.expr.is_constant())
254 simplify_rec(r_cond.expr.is_true() ? truevalue : falsevalue));
259 bool swap_branches =
false;
261 if(r_cond.expr.id() == ID_not)
264 swap_branches =
true;
267 #ifdef USE_LOCAL_REPLACE_MAP
271 if(r_cond.expr.id() == ID_and)
273 for(
const auto &op : r_cond.expr.operands())
275 if(op.id() == ID_not)
276 local_replace_map.insert(std::make_pair(op.op0(),
false_exprt()));
278 local_replace_map.insert(std::make_pair(op,
true_exprt()));
282 local_replace_map.insert(std::make_pair(r_cond.expr,
true_exprt()));
284 auto r_truevalue =
simplify_rec(swap_branches ? falsevalue : truevalue);
286 local_replace_map = map_before;
289 if(r_cond.expr.id() == ID_or)
291 for(
const auto &op : r_cond.expr.operands())
293 if(op.id() == ID_not)
294 local_replace_map.insert(std::make_pair(op.op0(),
true_exprt()));
296 local_replace_map.insert(std::make_pair(op,
false_exprt()));
300 local_replace_map.insert(std::make_pair(r_cond.expr,
false_exprt()));
302 auto r_falsevalue =
simplify_rec(swap_branches ? truevalue : falsevalue);
304 local_replace_map.swap(map_before);
309 r_truevalue.expr_changed = CHANGED;
310 r_falsevalue.expr_changed = CHANGED;
312 return build_if_expr(expr, r_cond, r_truevalue, r_falsevalue);
388 if(truevalue == falsevalue)
393 ((truevalue.
id() == ID_struct && falsevalue.
id() == ID_struct) ||
394 (truevalue.
id() == ID_array && falsevalue.
id() == ID_array)) &&
397 exprt cond_copy = cond;
398 exprt falsevalue_copy = falsevalue;
399 exprt truevalue_copy = truevalue;
403 auto new_expr = truevalue;
406 for(
const auto &pair : range_true.zip(range_false))
408 new_expr.operands().push_back(
412 return std::move(new_expr);
Base class for all expressions.
std::vector< exprt > operandst
bool has_operands() const
Return true if there is at least one operand.
bool is_true() const
Return whether the expression is a constant representing true.
bool is_boolean() const
Return whether the expression represents a Boolean.
bool is_false() const
Return whether the expression is a constant representing false.
typet & type()
Return the type of the expression.
The Boolean constant false.
The trinary if-then-else operator.
const irep_idt & id() const
bool simplify_if_conj(exprt &expr, const exprt &cond)
bool simplify_if_disj(exprt &expr, const exprt &cond)
static resultt changed(resultt<> result)
resultt simplify_if(const if_exprt &)
bool simplify_if_recursive(exprt &expr, const exprt &cond, bool truth)
resultt simplify_rec(const exprt &)
bool simplify_if_cond(exprt &expr)
resultt simplify_boolean(const exprt &)
bool simplify_if_branch(exprt &trueexpr, exprt &falseexpr, const exprt &cond)
resultt simplify_not(const not_exprt &)
static resultt unchanged(exprt expr)
resultt simplify_if_preorder(const if_exprt &expr)
bool simplify_if_implies(exprt &expr, const exprt &cond, bool truth, bool &new_truth)
The Boolean constant true.
#define Forall_operands(it, expr)
Ranges: pair of begin and end iterators, which can be initialized from containers,...
ranget< iteratort > make_range(iteratort begin, iteratort end)
std::unordered_map< exprt, exprt, irep_hash > replace_mapt
static simplify_exprt::resultt build_if_expr(const if_exprt &expr, simplify_exprt::resultt<> cond, simplify_exprt::resultt<> truevalue, simplify_exprt::resultt<> falsevalue)
API to expression classes.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.