Skip to content

Commit

Permalink
return unknown if m_array_weak was used and result is satisfiable
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Aug 1, 2019
1 parent 3f032e8 commit 0a29002
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 18 deletions.
10 changes: 10 additions & 0 deletions src/ast/rewriter/seq_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,16 @@ br_status seq_rewriter::mk_seq_at(expr* a, expr* b, expr_ref& result) {
return BR_FAILED;
}
unsigned len = r.get_unsigned();
expr* a2 = nullptr, *i2 = nullptr;
if (m_util.str.is_at(a, a2, i2)) {
if (len > 0) {
result = m_util.str.mk_empty(m().get_sort(a));
}
else {
result = a2;
}
return BR_DONE;
}

expr_ref_vector as(m());
m_util.str.get_concat_units(a, as);
Expand Down
27 changes: 20 additions & 7 deletions src/smt/theory_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ namespace smt {
for (enode* n : d->m_stores) {
instantiate_axiom2a(s, n);
}
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
for (enode* store : d->m_parent_stores) {
SASSERT(is_store(store));
if (!m_params.m_array_cg || store->is_cgr()) {
if (m_params.m_array_weak) {
found_unsupported_op(store->get_owner());
break;
}
instantiate_axiom2b(s, store);
}
}
Expand All @@ -118,10 +122,17 @@ namespace smt {
var_data * d = m_var_data[v];
d->m_parent_stores.push_back(s);
m_trail_stack.push(push_back_trail<theory_array, enode *, false>(d->m_parent_stores));
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward)
for (enode* n : d->m_parent_selects)
if (!m_params.m_array_cg || n->is_cgr())
if (d->m_prop_upward && !m_params.m_array_delay_exp_axiom) {
for (enode* n : d->m_parent_selects) {
if (!m_params.m_array_cg || n->is_cgr()) {
if (m_params.m_array_weak) {
found_unsupported_op(s);
break;
}
instantiate_axiom2b(n, s);
}
}
}
}

bool theory_array::instantiate_axiom2b_for(theory_var v) {
Expand All @@ -138,15 +149,17 @@ namespace smt {
\brief Mark v for upward propagation. That is, enables the propagation of select(v, i) to store(v,j,k).
*/
void theory_array::set_prop_upward(theory_var v) {
if (m_params.m_array_weak)
return;
v = find(v);
var_data * d = m_var_data[v];
if (!d->m_prop_upward) {
TRACE("array", tout << "#" << v << "\n";);
m_trail_stack.push(reset_flag_trail<theory_array>(d->m_prop_upward));
d->m_prop_upward = true;
if (!m_params.m_array_delay_exp_axiom)
if (m_params.m_array_weak) {
found_unsupported_op(v);
return;
}
if (!m_params.m_array_delay_exp_axiom)
instantiate_axiom2b_for(v);
for (enode * n : d->m_stores)
set_prop_upward(n);
Expand Down
2 changes: 2 additions & 0 deletions src/smt/theory_array_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace smt {
bool m_found_unsupported_op;

void found_unsupported_op(expr * n);
void found_unsupported_op(enode* n) { found_unsupported_op(n->get_owner()); }
void found_unsupported_op(theory_var v) { found_unsupported_op(get_enode(v)->get_owner()); }

bool is_store(app const* n) const { return n->is_app_of(get_id(), OP_STORE); }
bool is_map(app const* n) const { return n->is_app_of(get_id(), OP_ARRAY_MAP); }
Expand Down
34 changes: 26 additions & 8 deletions src/smt/theory_array_full.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ namespace smt {
var_data_full * d_full = m_var_data_full[v];
d_full->m_parent_maps.push_back(s);
m_trail_stack.push(push_back_trail<theory_array, enode *, false>(d_full->m_parent_maps));
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
for (enode * n : d->m_parent_selects) {
if (!m_params.m_array_cg || n->is_cgr()) {
if (m_params.m_array_weak) {
found_unsupported_op(s);
break;
}
instantiate_select_map_axiom(n, s);
}
}
Expand All @@ -100,14 +104,16 @@ namespace smt {
// set set_prop_upward on root and recursively on children if necessary.
//
void theory_array_full::set_prop_upward(theory_var v) {
if (m_params.m_array_weak)
return;
v = find(v);
var_data * d = m_var_data[v];
if (!d->m_prop_upward) {
m_trail_stack.push(reset_flag_trail<theory_array>(d->m_prop_upward));
d->m_prop_upward = true;
TRACE("array", tout << "#" << v << "\n";);
if (m_params.m_array_weak) {
found_unsupported_op(v);
return;
}
if (!m_params.m_array_delay_exp_axiom) {
instantiate_axiom2b_for(v);
instantiate_axiom_map_for(v);
Expand Down Expand Up @@ -355,8 +361,13 @@ namespace smt {
instantiate_default_store_axiom(store);
}

if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
instantiate_parent_stores_default(v);
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
if (m_params.m_array_weak) {
found_unsupported_op(v);
}
else {
instantiate_parent_stores_default(v);
}
}
}

Expand All @@ -376,10 +387,14 @@ namespace smt {
SASSERT(is_map(map));
instantiate_select_map_axiom(s, map);
}
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
for (enode * map : d_full->m_parent_maps) {
SASSERT(is_map(map));
if (!m_params.m_array_cg || map->is_cgr()) {
if (m_params.m_array_weak) {
found_unsupported_op(s);
break;
}
instantiate_select_map_axiom(s, map);
}
}
Expand Down Expand Up @@ -748,8 +763,11 @@ namespace smt {
var_data * d = m_var_data[v];
if (d->m_prop_upward && instantiate_axiom_map_for(v))
r = FC_CONTINUE;
if (d->m_prop_upward && !m_params.m_array_weak) {
if (instantiate_parent_stores_default(v))
if (d->m_prop_upward) {
if (m_params.m_array_weak) {
found_unsupported_op(v);
}
else if (instantiate_parent_stores_default(v))
r = FC_CONTINUE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/smt/theory_seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5208,7 +5208,7 @@ void theory_seq::add_nth_axiom(expr* e) {
expr_ref zero(m_autil.mk_int(0), m);
literal i_ge_0 = mk_simplified_literal(m_autil.mk_ge(i, zero));
literal i_ge_len_s = mk_simplified_literal(m_autil.mk_ge(mk_sub(i, mk_len(s)), zero));
add_axiom(~i_ge_0, i_ge_len_s, mk_eq(m_util.str.mk_unit(e), m_util.str.mk_at(s, i), false));
add_axiom(~i_ge_0, i_ge_len_s, mk_eq(m_util.str.mk_unit(e), m_util.str.mk_at(s, i), false));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ class params {
};
};
typedef std::pair<symbol, value> entry;
svector<entry> m_entries;
std::atomic<unsigned> m_ref_count;
svector<entry> m_entries;
std::atomic<unsigned> m_ref_count;
void del_value(entry & e);
void del_values();

Expand Down

0 comments on commit 0a29002

Please sign in to comment.