3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-29 09:28:45 +00:00

bound length of ubv2s

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-07-16 16:17:59 +02:00
parent 8e9bc86c23
commit 9e5dcf3ecb
5 changed files with 22 additions and 0 deletions

View file

@ -799,6 +799,24 @@ namespace seq {
add_clause(~ge10k, ge10k1, eq);
}
/*
* 1 <= len(ubv2s(b)) <= k, where k is min such that 10^k > 2^sz
*/
void axioms::ubv2s_len_axiom(expr* b) {
bv_util bv(m);
sort* bv_sort = b->get_sort();
unsigned sz = bv.get_bv_size(bv_sort);
unsigned k = 1;
rational pow(10);
while (pow <= rational::power_of_two(sz))
++k, pow *= 10;
expr_ref len(seq.str.mk_length(seq.str.mk_ubv2s(b)), m);
expr_ref ge(a.mk_ge(len, a.mk_int(1)), m);
expr_ref le(a.mk_le(len, a.mk_int(k)), m);
add_clause(le);
add_clause(ge);
}
/*
* len(ubv2s(b)) = k => 10^k-1 <= b < 10^{k} k > 1
* len(ubv2s(b)) = 1 => b < 10^{1} k = 1