Skip to content

Commit f29b033

Browse files
mtrberziNikolajBjorner
authored andcommitted
z3str3: add is_var() similar to theory_seq's implementation
1 parent 1c70bce commit f29b033

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/smt/theory_str.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8374,6 +8374,21 @@ namespace smt {
83748374
}
83758375
}
83768376

8377+
bool theory_str::is_var(expr * e) const {
8378+
ast_manager & m = get_manager();
8379+
sort * ex_sort = m.get_sort(e);
8380+
sort * str_sort = u.str.mk_string_sort();
8381+
// non-string-sort terms cannot be string variables
8382+
if (ex_sort != str_sort) return false;
8383+
// string constants cannot be variables
8384+
if (u.str.is_string(e)) return false;
8385+
if (u.str.is_concat(e) || u.str.is_at(e) || u.str.is_extract(e) || u.str.is_replace(e) || u.str.is_itos(e))
8386+
return false;
8387+
if (m.is_ite(e))
8388+
return false;
8389+
return true;
8390+
}
8391+
83778392
void theory_str::set_up_axioms(expr * ex) {
83788393
ast_manager & m = get_manager();
83798394
context & ctx = get_context();
@@ -8417,7 +8432,7 @@ namespace smt {
84178432
TRACE("str", tout << "found string-integer conversion term: " << mk_pp(ex, get_manager()) << std::endl;);
84188433
string_int_conversion_terms.push_back(ap);
84198434
m_library_aware_axiom_todo.push_back(n);
8420-
} else if (/*ap->get_num_args() == 0 &&*/ !u.str.is_string(ap)) {
8435+
} else if (is_var(ex)) {
84218436
// if ex is a variable, add it to our list of variables
84228437
TRACE("str", tout << "tracking variable " << mk_ismt2_pp(ap, get_manager()) << std::endl;);
84238438
variable_set.insert(ex);

src/smt/theory_str.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ class theory_str : public theory {
572572
expr * z3str2_get_eqc_value(expr * n , bool & hasEqcValue);
573573
bool in_same_eqc(expr * n1, expr * n2);
574574
expr * collect_eq_nodes(expr * n, expr_ref_vector & eqcSet);
575+
bool is_var(expr * e) const;
575576

576577
bool get_arith_value(expr* e, rational& val) const;
577578
bool get_len_value(expr* e, rational& val);

0 commit comments

Comments
 (0)