3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-25 04:26:00 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-02-12 16:01:33 -08:00
parent 85f0084e9c
commit 612cc5cfba
9 changed files with 53 additions and 6 deletions

View file

@ -813,6 +813,7 @@ void seq_axioms::add_str_to_code_axiom(expr* n) {
literal len_is1 = mk_eq(mk_len(e), a.mk_int(1));
add_axiom(~len_is1, mk_ge(n, 0));
add_axiom(~len_is1, mk_le(n, seq.max_char()));
add_axiom(~len_is1, mk_eq(n, seq.mk_char2int(mk_nth(e, 0))));
if (!seq.str.is_from_code(e))
add_axiom(~len_is1, mk_eq(e, seq.str.mk_from_code(n)));
add_axiom(len_is1, mk_eq(n, a.mk_int(-1)));

View file

@ -79,6 +79,9 @@ namespace smt {
unsigned c = 0;
if (seq.is_const_char(term, c))
new_const_char(v, c);
expr* n = nullptr;
if (seq.is_char2int(term, n))
new_char2int(v, n);
return true;
}
@ -216,6 +219,27 @@ namespace smt {
}
}
void theory_char::new_char2int(theory_var v, expr* c) {
theory_var w = ctx.get_enode(c)->get_th_var(get_id());
init_bits(w);
auto const& bits = get_ebits(w);
expr_ref_vector sum(m);
unsigned p = 0;
arith_util a(m);
for (auto b : bits) {
sum.push_back(m.mk_ite(b, a.mk_int(1 << p), a.mk_int(0)));
p++;
}
expr_ref sum_bits(a.mk_add(sum), m);
enode* n1 = get_enode(v);
enode* n2 = ensure_enode(sum_bits);
justification* j =
ctx.mk_justification(
ext_theory_eq_propagation_justification(get_id(), ctx.get_region(), n1, n2));
ctx.assign_eq(n1, n2, eq_justification(j));
}
/**
* 1. Check that values of classes are unique.
* Check that values within each class is the same.

View file

@ -57,6 +57,7 @@ namespace smt {
bool final_check();
void new_const_char(theory_var v, unsigned c);
void new_char2int(theory_var v, expr* c);
unsigned get_char_value(theory_var v);
void internalize_le(literal lit, app* term);