Skip to content

Commit 0a29002

Browse files
return unknown if m_array_weak was used and result is satisfiable
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 3f032e8 commit 0a29002

File tree

6 files changed

+61
-18
lines changed

6 files changed

+61
-18
lines changed

src/ast/rewriter/seq_rewriter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,16 @@ br_status seq_rewriter::mk_seq_at(expr* a, expr* b, expr_ref& result) {
954954
return BR_FAILED;
955955
}
956956
unsigned len = r.get_unsigned();
957+
expr* a2 = nullptr, *i2 = nullptr;
958+
if (m_util.str.is_at(a, a2, i2)) {
959+
if (len > 0) {
960+
result = m_util.str.mk_empty(m().get_sort(a));
961+
}
962+
else {
963+
result = a2;
964+
}
965+
return BR_DONE;
966+
}
957967

958968
expr_ref_vector as(m());
959969
m_util.str.get_concat_units(a, as);

src/smt/theory_array.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ namespace smt {
100100
for (enode* n : d->m_stores) {
101101
instantiate_axiom2a(s, n);
102102
}
103-
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
103+
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
104104
for (enode* store : d->m_parent_stores) {
105105
SASSERT(is_store(store));
106106
if (!m_params.m_array_cg || store->is_cgr()) {
107+
if (m_params.m_array_weak) {
108+
found_unsupported_op(store->get_owner());
109+
break;
110+
}
107111
instantiate_axiom2b(s, store);
108112
}
109113
}
@@ -118,10 +122,17 @@ namespace smt {
118122
var_data * d = m_var_data[v];
119123
d->m_parent_stores.push_back(s);
120124
m_trail_stack.push(push_back_trail<theory_array, enode *, false>(d->m_parent_stores));
121-
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward)
122-
for (enode* n : d->m_parent_selects)
123-
if (!m_params.m_array_cg || n->is_cgr())
125+
if (d->m_prop_upward && !m_params.m_array_delay_exp_axiom) {
126+
for (enode* n : d->m_parent_selects) {
127+
if (!m_params.m_array_cg || n->is_cgr()) {
128+
if (m_params.m_array_weak) {
129+
found_unsupported_op(s);
130+
break;
131+
}
124132
instantiate_axiom2b(n, s);
133+
}
134+
}
135+
}
125136
}
126137

127138
bool theory_array::instantiate_axiom2b_for(theory_var v) {
@@ -138,15 +149,17 @@ namespace smt {
138149
\brief Mark v for upward propagation. That is, enables the propagation of select(v, i) to store(v,j,k).
139150
*/
140151
void theory_array::set_prop_upward(theory_var v) {
141-
if (m_params.m_array_weak)
142-
return;
143152
v = find(v);
144153
var_data * d = m_var_data[v];
145154
if (!d->m_prop_upward) {
146155
TRACE("array", tout << "#" << v << "\n";);
147156
m_trail_stack.push(reset_flag_trail<theory_array>(d->m_prop_upward));
148157
d->m_prop_upward = true;
149-
if (!m_params.m_array_delay_exp_axiom)
158+
if (m_params.m_array_weak) {
159+
found_unsupported_op(v);
160+
return;
161+
}
162+
if (!m_params.m_array_delay_exp_axiom)
150163
instantiate_axiom2b_for(v);
151164
for (enode * n : d->m_stores)
152165
set_prop_upward(n);

src/smt/theory_array_base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ namespace smt {
3232
bool m_found_unsupported_op;
3333

3434
void found_unsupported_op(expr * n);
35+
void found_unsupported_op(enode* n) { found_unsupported_op(n->get_owner()); }
36+
void found_unsupported_op(theory_var v) { found_unsupported_op(get_enode(v)->get_owner()); }
3537

3638
bool is_store(app const* n) const { return n->is_app_of(get_id(), OP_STORE); }
3739
bool is_map(app const* n) const { return n->is_app_of(get_id(), OP_ARRAY_MAP); }

src/smt/theory_array_full.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ namespace smt {
8787
var_data_full * d_full = m_var_data_full[v];
8888
d_full->m_parent_maps.push_back(s);
8989
m_trail_stack.push(push_back_trail<theory_array, enode *, false>(d_full->m_parent_maps));
90-
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
90+
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
9191
for (enode * n : d->m_parent_selects) {
9292
if (!m_params.m_array_cg || n->is_cgr()) {
93+
if (m_params.m_array_weak) {
94+
found_unsupported_op(s);
95+
break;
96+
}
9397
instantiate_select_map_axiom(n, s);
9498
}
9599
}
@@ -100,14 +104,16 @@ namespace smt {
100104
// set set_prop_upward on root and recursively on children if necessary.
101105
//
102106
void theory_array_full::set_prop_upward(theory_var v) {
103-
if (m_params.m_array_weak)
104-
return;
105107
v = find(v);
106108
var_data * d = m_var_data[v];
107109
if (!d->m_prop_upward) {
108110
m_trail_stack.push(reset_flag_trail<theory_array>(d->m_prop_upward));
109111
d->m_prop_upward = true;
110112
TRACE("array", tout << "#" << v << "\n";);
113+
if (m_params.m_array_weak) {
114+
found_unsupported_op(v);
115+
return;
116+
}
111117
if (!m_params.m_array_delay_exp_axiom) {
112118
instantiate_axiom2b_for(v);
113119
instantiate_axiom_map_for(v);
@@ -355,8 +361,13 @@ namespace smt {
355361
instantiate_default_store_axiom(store);
356362
}
357363

358-
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
359-
instantiate_parent_stores_default(v);
364+
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
365+
if (m_params.m_array_weak) {
366+
found_unsupported_op(v);
367+
}
368+
else {
369+
instantiate_parent_stores_default(v);
370+
}
360371
}
361372
}
362373

@@ -376,10 +387,14 @@ namespace smt {
376387
SASSERT(is_map(map));
377388
instantiate_select_map_axiom(s, map);
378389
}
379-
if (!m_params.m_array_weak && !m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
390+
if (!m_params.m_array_delay_exp_axiom && d->m_prop_upward) {
380391
for (enode * map : d_full->m_parent_maps) {
381392
SASSERT(is_map(map));
382393
if (!m_params.m_array_cg || map->is_cgr()) {
394+
if (m_params.m_array_weak) {
395+
found_unsupported_op(s);
396+
break;
397+
}
383398
instantiate_select_map_axiom(s, map);
384399
}
385400
}
@@ -748,8 +763,11 @@ namespace smt {
748763
var_data * d = m_var_data[v];
749764
if (d->m_prop_upward && instantiate_axiom_map_for(v))
750765
r = FC_CONTINUE;
751-
if (d->m_prop_upward && !m_params.m_array_weak) {
752-
if (instantiate_parent_stores_default(v))
766+
if (d->m_prop_upward) {
767+
if (m_params.m_array_weak) {
768+
found_unsupported_op(v);
769+
}
770+
else if (instantiate_parent_stores_default(v))
753771
r = FC_CONTINUE;
754772
}
755773
}

src/smt/theory_seq.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5208,7 +5208,7 @@ void theory_seq::add_nth_axiom(expr* e) {
52085208
expr_ref zero(m_autil.mk_int(0), m);
52095209
literal i_ge_0 = mk_simplified_literal(m_autil.mk_ge(i, zero));
52105210
literal i_ge_len_s = mk_simplified_literal(m_autil.mk_ge(mk_sub(i, mk_len(s)), zero));
5211-
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));
5211+
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));
52125212
}
52135213
}
52145214

src/util/params.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ class params {
324324
};
325325
};
326326
typedef std::pair<symbol, value> entry;
327-
svector<entry> m_entries;
328-
std::atomic<unsigned> m_ref_count;
327+
svector<entry> m_entries;
328+
std::atomic<unsigned> m_ref_count;
329329
void del_value(entry & e);
330330
void del_values();
331331

0 commit comments

Comments
 (0)