Skip to content

Commit 3fc001b

Browse files
simplifications noticed by trying #4147
The change masks possible bugs in smt.threads and arrays.
1 parent 7cfd16c commit 3fc001b

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

src/smt/seq_axioms.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,15 @@ void seq_axioms::add_itos_axiom(expr* e) {
563563
/**
564564
stoi(s) >= -1
565565
stoi("") = -1
566-
stoi(s) >= 0 => len(s) > 0
567566
stoi(s) >= 0 => is_digit(nth(s,0))
568567
*/
569568
void seq_axioms::add_stoi_axiom(expr* e) {
570569
TRACE("seq", tout << mk_pp(e, m) << "\n";);
570+
literal ge0 = mk_ge(e, 0);
571571
expr* s = nullptr;
572572
VERIFY (seq.str.is_stoi(e, s));
573573
add_axiom(mk_ge(e, -1)); // stoi(s) >= -1
574574
add_axiom(~mk_eq_empty(s), mk_eq(e, a.mk_int(-1))); // s = "" => stoi(s) = -1
575-
literal ge0 = mk_ge(e, 0);
576575
add_axiom(~ge0, is_digit(mk_nth(s, 0))); // stoi(s) >= 0 => is_digit(nth(s,0))
577576

578577
}
@@ -614,9 +613,9 @@ void seq_axioms::add_stoi_axiom(expr* e, unsigned k) {
614613
expr_ref len = mk_len(s);
615614
literal ge0 = mk_ge(e, 0);
616615
literal lek = mk_le(len, k);
617-
add_axiom(~lek, mk_eq(e, stoi2(k-1))); // len(s) <= k => stoi(s) = stoi(s, k-1)
618-
add_axiom(mk_le(len, 0), ~is_digit_(0), mk_eq(stoi2(0), digit(0))); // len(s) > 0, is_digit(nth(s, 0)) => stoi(s,0) = digit(s,0)
619-
add_axiom(mk_le(len, 0), is_digit_(0), mk_eq(stoi2(0), a.mk_int(-1))); // len(s) > 0, ~is_digit(nth(s, 0)) => stoi(s,0) = -1
616+
add_axiom(~lek, mk_eq(e, stoi2(k-1))); // len(s) <= k => stoi(s) = stoi(s, k-1)
617+
add_axiom(mk_le(len, 0), ~is_digit_(0), mk_eq(stoi2(0), digit(0))); // len(s) > 0, is_digit(nth(s, 0)) => stoi(s,0) = digit(s,0)
618+
add_axiom(mk_le(len, 0), is_digit_(0), mk_eq(stoi2(0), a.mk_int(-1))); // len(s) > 0, ~is_digit(nth(s, 0)) => stoi(s,0) = -1
620619
for (unsigned i = 1; i < k; ++i) {
621620

622621
// len(s) <= i => stoi(s, i) = stoi(s, i - 1)

src/smt/smt_parallel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ namespace smt {
183183
}
184184
};
185185

186-
// for debugging: num_threads = 1;
186+
// for debugging: num_threads = 1;
187187

188188
while (true) {
189189
vector<std::thread> threads(num_threads);

src/smt/tactic/ctx_solver_simplify_tactic.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ Module Name:
1515
1616
Notes:
1717
18+
Implement the inference rule
19+
20+
n = V |- F[n] = F[x]
21+
--------------------
22+
F[x] = F[V]
23+
24+
where n is an uninterpreted variable (fresh for F[x])
25+
and V is a value (true or false) and x is a subterm
26+
(different from V).
27+
1828
--*/
1929

2030
#include "smt/tactic/ctx_solver_simplify_tactic.h"
@@ -184,9 +194,14 @@ class ctx_solver_simplify_tactic : public tactic {
184194
if (cache.contains(e)) {
185195
goto done;
186196
}
197+
if (m.is_true(e) || m.is_false(e)) {
198+
res = e;
199+
goto done;
200+
}
187201
if (m.is_bool(e) && simplify_bool(n, res)) {
188-
TRACE("ctx_solver_simplify_tactic",
189-
tout << "simplified: " << mk_pp(e, m) << " |-> " << mk_pp(res, m) << "\n";);
202+
TRACE("ctx_solver_simplify_tactic",
203+
m_solver.display(tout) << "\n";
204+
tout << "simplified: " << mk_pp(n, m) << "\n" << mk_pp(e, m) << " |-> " << mk_pp(res, m) << "\n";);
190205
goto done;
191206
}
192207
if (!is_app(e)) {
@@ -214,7 +229,7 @@ class ctx_solver_simplify_tactic : public tactic {
214229
args.push_back(arg);
215230
}
216231
}
217-
else if (!n2) {
232+
else if (!n2 && !m.is_value(arg)) {
218233
n2 = mk_fresh(id, m.get_sort(arg));
219234
trail.push_back(n2);
220235
todo.push_back(expr_pos(self_pos, ++child_id, i, arg));

src/tactic/core/distribute_forall_tactic.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Module Name:
1515
1616
--*/
1717
#include "tactic/tactical.h"
18+
#include "ast/ast_util.h"
1819
#include "ast/rewriter/rewriter_def.h"
1920
#include "ast/rewriter/var_subst.h"
2021

@@ -46,7 +47,7 @@ class distribute_forall_tactic : public tactic {
4647
expr_ref_buffer new_args(m);
4748
for (unsigned i = 0; i < num_args; i++) {
4849
expr * arg = or_e->get_arg(i);
49-
expr * not_arg = m.mk_not(arg);
50+
expr * not_arg = mk_not(m, arg);
5051
quantifier_ref tmp_q(m);
5152
tmp_q = m.update_quantifier(old_q, not_arg);
5253
new_args.push_back(elim_unused_vars(m, tmp_q, params_ref()));

0 commit comments

Comments
 (0)