17 const std::map<irep_idt, exprt> &substitutions,
20 if(src.
id() == ID_symbol)
22 auto s_it = substitutions.find(
to_symbol_expr(src).get_identifier());
23 if(s_it == substitutions.end())
29 src.
id() == ID_forall || src.
id() == ID_exists || src.
id() == ID_lambda)
35 auto new_substitutions = substitutions;
36 for(
const auto &variable : binding_expr.variables())
37 new_substitutions.erase(variable.get_identifier());
41 if(op_result.has_value())
43 auto new_binding_expr = binding_expr;
44 new_binding_expr.where() = std::move(op_result.value());
45 return std::move(new_binding_expr);
50 else if(src.
id() == ID_let)
57 auto new_substitutions = substitutions;
58 for(
const auto &variable : binding_expr.variables())
59 new_substitutions.erase(variable.get_identifier());
61 bool op_changed =
false;
63 for(
auto &op : new_let_expr.values())
67 if(op_result.has_value())
69 op = op_result.value();
76 if(op_result.has_value())
78 new_let_expr.where() = op_result.value();
83 return std::move(new_let_expr);
91 bool op_changed =
false;
97 if(op_result.has_value())
99 op = op_result.value();
Base class for all expressions.
bool has_operands() const
Return true if there is at least one operand.
const irep_idt & id() const
binding_exprt & binding()
API to expression classes.
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const binding_exprt & to_binding_expr(const exprt &expr)
Cast an exprt to a binding_exprt.
static std::optional< exprt > substitute_symbols_rec(const std::map< irep_idt, exprt > &substitutions, exprt src)
std::optional< exprt > substitute_symbols(const std::map< irep_idt, exprt > &substitutions, exprt src)
Substitute free occurrences of the variables given by their identifiers in the keys of the map in the...