22 #include <unordered_set>
39 static std::unordered_set<exprt, irep_hash>
43 auto index_str_containing_qvar = [&](
const exprt &e) {
44 if(
auto index_expr = expr_try_dynamic_cast<index_exprt>(e))
46 const auto &arr = index_expr->array();
47 const auto str_it = std::find(arr.depth_begin(), arr.depth_end(), str);
48 return str_it != arr.depth_end() &&
contains(index_expr->index(), qvar);
54 if(index_str_containing_qvar(e))
55 result.insert(to_index_expr(e).index());
65 std::list<std::pair<exprt, bool>> to_process;
66 to_process.emplace_back(f,
true);
68 while(!to_process.empty())
70 const exprt cur = to_process.back().first;
71 bool positive = to_process.back().second;
72 to_process.pop_back();
73 if(
auto integer = numeric_cast<mp_integer>(cur))
77 else if(cur.
id() == ID_plus)
80 to_process.emplace_back(op, positive);
82 else if(cur.
id() == ID_minus)
87 else if(cur.
id() == ID_unary_minus)
118 const exprt &t = term.first;
119 const mp_integer factor = negated ? (-term.second) : term.second;
154 const bool positive = it->second == 1;
168 std::ostringstream stream;
171 stream <<
" + " << pair.second <<
" * " <<
::format(pair.first);
183 const exprt univ_var_value =
191 conjuncts.push_back(instance);
205 const std::set<std::pair<exprt, exprt>> &index_pairs,
206 const std::unordered_map<string_not_contains_constraintt, symbol_exprt>
209 std::vector<exprt> lemmas;
214 for(
const auto &pair : index_pairs)
218 const exprt &i0 = pair.first;
219 const exprt &i1 = pair.second;
232 const and_exprt body(differ, existential_bound);
235 lemmas.push_back(lemma);
A base class for relations, i.e., binary predicates whose two operands have the same type.
Base class for all expressions.
std::vector< exprt > operandst
depth_iteratort depth_end()
depth_iteratort depth_begin()
typet & type()
Return the type of the expression.
const irep_idt & id() const
Canonical representation of linear function, for instance, expression $x + x - y + 5 - 3$ would given...
exprt to_expr(bool negated=false) const
static exprt solve(linear_functiont f, const exprt &var, const exprt &val)
Return an expression y such that f(var <- y) = val.
linear_functiont(const exprt &f)
Put an expression f composed of additions and subtractions into its cannonical representation.
std::unordered_map< exprt, mp_integer, irep_hash > coefficients
std::string format()
Format the linear function as a string, can be used for debugging.
void add(const linear_functiont &other)
Make this function the sum of the current function with other.
mp_integer constant_coefficient
Binary multiplication Associativity is not specified.
The plus expression Associativity is not specified.
std::vector< exprt > instantiate_not_contains(const string_not_contains_constraintt &axiom, const std::set< std::pair< exprt, exprt >> &index_pairs, const std::unordered_map< string_not_contains_constraintt, symbol_exprt > &witnesses)
Instantiates a quantified formula representing not_contains by substituting the quantifiers and gener...
Expression to hold a symbol (variable)
The unary minus expression.
Forward depth-first search iterators These iterators' copy operations are expensive,...
bool replace_expr(const exprt &what, const exprt &by, exprt &dest)
#define PRECONDITION(CONDITION)
exprt conjunction(const exprt::operandst &op)
1) generates a conjunction for two or more operands 2) for one operand, returns the operand 3) return...
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
Defines string constraints.
static bool contains(const exprt &index, const symbol_exprt &qvar)
Look for symbol qvar in the expression index and return true if found.
exprt instantiate(const string_constraintt &axiom, const exprt &str, const exprt &val)
Instantiates a string constraint by substituting the quantifiers.
static std::unordered_set< exprt, irep_hash > find_indexes(const exprt &expr, const exprt &str, const symbol_exprt &qvar)
Find indexes of str used in expr that contains qvar, for instance with arguments (str[k+1]=='a'),...
Defines related function for string constraints.
Constraints to encode non containement of strings.