3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

bv2char and char2bv with Clemens

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-09-13 16:09:03 +02:00
parent 34f878fb97
commit f13ccf8969
7 changed files with 93 additions and 10 deletions

View file

@ -16,6 +16,7 @@ Author:
--*/
#include "ast/ast_ll_pp.h"
#include "ast/bv_decl_plugin.h"
#include "smt/theory_char.h"
#include "smt/smt_context.h"
#include "smt/smt_model_generator.h"
@ -84,6 +85,11 @@ namespace smt {
expr* n = nullptr;
if (seq.is_char2int(term, n))
new_char2int(v, n);
else if (seq.is_char2bv(term, n))
new_char2bv(term, n);
else if (seq.is_bv2char(term, n))
new_bv2char(v, n);
return true;
}
@ -265,6 +271,34 @@ namespace smt {
ctx.assign_eq(n1, n2, eq_justification(j));
}
void theory_char::new_char2bv(expr* b, expr* c) {
theory_var w = ctx.get_enode(c)->get_th_var(get_id());
init_bits(w);
auto const& bits = get_bits(w);
bv_util bv(m);
SASSERT(bits.size() == bv.get_bv_size(b));
unsigned i = 0;
for (auto bit1 : bits) {
auto bit2 = mk_literal(bv.mk_bit2bool(b, i++));
ctx.mk_th_axiom(get_id(), ~bit1, bit2);
ctx.mk_th_axiom(get_id(), bit1, ~bit2);
}
}
void theory_char::new_bv2char(theory_var v, expr* b) {
init_bits(v);
auto const& bits = get_bits(v);
bv_util bv(m);
SASSERT(bits.size() == bv.get_bv_size(b));
unsigned i = 0;
for (auto bit1 : bits) {
auto bit2 = mk_literal(bv.mk_bit2bool(b, i++));
ctx.mk_th_axiom(get_id(), ~bit1, bit2);
ctx.mk_th_axiom(get_id(), bit1, ~bit2);
}
}
/**
* 1. Check that values of classes are unique.

View file

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