3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00

remove bit-vector dependencies in seq theory

This commit is contained in:
Nikolaj Bjorner 2021-02-06 10:46:32 -08:00
parent 43d1ef2fee
commit 0f29fff836
4 changed files with 19 additions and 49 deletions

View file

@ -3,7 +3,6 @@ RELEASE NOTES
Version 4.8.next Version 4.8.next
================ ================
- Planned features - Planned features
- self-contained character theory, direct support for UTF8, Unicode character sets
- specialized solver support for QF_ABV and ABV based on lazy SMT and dual reduction - specialized solver support for QF_ABV and ABV based on lazy SMT and dual reduction
- the smtfd solver and tactic implement this strategy, but is not prime for users. - the smtfd solver and tactic implement this strategy, but is not prime for users.
- introduction of simple induction lemmas to handle a limited repertoire of induction proofs. - introduction of simple induction lemmas to handle a limited repertoire of induction proofs.
@ -11,6 +10,14 @@ Version 4.8.next
option, but at this point does not translate into benefits. It is currently option, but at this point does not translate into benefits. It is currently
turned off by default. turned off by default.
Version 4.8.11
==============
- self-contained character theory, direct support for UTF8, Unicode character sets.
Characters are by default unicode with an 18 bit range.
- support for incremental any-time MaxSAT using the option opt.enable_lns. The API
allows registering a callback function that is invoked on each incremental improvement
to objectives.
Version 4.8.10 Version 4.8.10
============== ==============
- rewritten arithmetic solver replacing legacy arithmetic solver and on by default - rewritten arithmetic solver replacing legacy arithmetic solver and on by default

View file

@ -7610,6 +7610,11 @@ class Optimize(Z3PPObject):
return Statistics(Z3_optimize_get_statistics(self.ctx.ref(), self.optimize), self.ctx) return Statistics(Z3_optimize_get_statistics(self.ctx.ref(), self.optimize), self.ctx)
def set_on_model(self, on_model): def set_on_model(self, on_model):
"""Register a callback that is invoked with every incremental improvement to
objective values. The callback takes a model as argument.
The life-time of the model is limited to the callback so the
model has to be (deep) copied if it is to be used after the callback
"""
id = len(_on_models) + 41 id = len(_on_models) + 41
mdl = Model(self.ctx) mdl = Model(self.ctx)
_on_models[id] = (on_model, mdl) _on_models[id] = (on_model, mdl)

View file

@ -278,10 +278,7 @@ void seq_decl_plugin::set_manager(ast_manager* m, family_id id) {
decl_plugin::set_manager(m, id); decl_plugin::set_manager(m, id);
bv_util bv(*m); bv_util bv(*m);
m_char_plugin = static_cast<char_decl_plugin*>(m_manager->get_plugin(m_manager->mk_family_id("char"))); m_char_plugin = static_cast<char_decl_plugin*>(m_manager->get_plugin(m_manager->mk_family_id("char")));
if (unicode()) m_char = get_char_plugin().char_sort();
m_char = get_char_plugin().char_sort();
else
m_char = bv.mk_sort(8);
m->inc_ref(m_char); m->inc_ref(m_char);
parameter param(m_char); parameter param(m_char);
m_string = m->mk_sort(symbol("String"), sort_info(m_family_id, SEQ_SORT, 1, &param)); m_string = m->mk_sort(symbol("String"), sort_info(m_family_id, SEQ_SORT, 1, &param));
@ -644,16 +641,9 @@ app* seq_decl_plugin::mk_string(zstring const& s) {
} }
app* seq_decl_plugin::mk_char(unsigned u) { app* seq_decl_plugin::mk_char(unsigned u) {
if (unicode()) { return get_char_plugin().mk_char(u);
return get_char_plugin().mk_char(u);
}
else {
bv_util bv(*m_manager);
return bv.mk_numeral(rational(u), 8);
}
} }
bool seq_decl_plugin::is_considered_uninterpreted(func_decl * f) { bool seq_decl_plugin::is_considered_uninterpreted(func_decl * f) {
seq_util util(*m_manager); seq_util util(*m_manager);
return util.str.is_nth_u(f); return util.str.is_nth_u(f);
@ -759,11 +749,6 @@ app* seq_util::mk_char_bit(expr* e, unsigned i) {
return m.mk_app(f, 1, &e); return m.mk_app(f, 1, &e);
} }
bv_util& seq_util::bv() const {
if (!m_bv) m_bv = alloc(bv_util, m);
return *m_bv.get();
}
unsigned seq_util::max_plus(unsigned x, unsigned y) const { unsigned seq_util::max_plus(unsigned x, unsigned y) const {
if (x + y < x || x + y < y) if (x + y < x || x + y < y)
return UINT_MAX; return UINT_MAX;
@ -777,43 +762,19 @@ unsigned seq_util::max_mul(unsigned x, unsigned y) const {
bool seq_util::is_const_char(expr* e, unsigned& c) const { bool seq_util::is_const_char(expr* e, unsigned& c) const {
if (seq.unicode()) { return ch.is_const_char(e, c);
return ch.is_const_char(e, c);
}
else {
rational r;
unsigned sz;
return bv().is_numeral(e, r, sz) && sz == 8 && r.is_unsigned() && (c = r.get_unsigned(), true);
}
} }
bool seq_util::is_char_le(expr const* e) const { bool seq_util::is_char_le(expr const* e) const {
if (seq.unicode()) return ch.is_le(e);
return ch.is_le(e);
else
return bv().is_bv_ule(e) && is_char(to_app(e)->get_arg(0));
} }
app* seq_util::mk_char(unsigned ch) const { app* seq_util::mk_char(unsigned ch) const {
if (seq.unicode()) return seq.mk_char(ch);
return seq.mk_char(ch);
else
return bv().mk_numeral(rational(ch), 8);
} }
app* seq_util::mk_le(expr* ch1, expr* ch2) const { app* seq_util::mk_le(expr* ch1, expr* ch2) const {
expr_ref _ch1(ch1, m), _ch2(ch2, m); return ch.mk_le(ch1, ch2);
if (seq.unicode()) {
return ch.mk_le(ch1, ch2);
}
else {
rational r1, r2;
if (bv().is_numeral(ch1, r1) && bv().is_numeral(ch2, r2)) {
return m.mk_bool_val(r1 <= r2);
}
return bv().mk_ule(ch1, ch2);
}
} }
app* seq_util::mk_lt(expr* ch1, expr* ch2) const { app* seq_util::mk_lt(expr* ch1, expr* ch2) const {

View file

@ -23,7 +23,6 @@ Revision History:
#pragma once #pragma once
#include "ast/ast.h" #include "ast/ast.h"
#include "ast/bv_decl_plugin.h"
#include "ast/char_decl_plugin.h" #include "ast/char_decl_plugin.h"
#include "util/lbool.h" #include "util/lbool.h"
#include "util/zstring.h" #include "util/zstring.h"
@ -211,8 +210,6 @@ class seq_util {
seq_decl_plugin& seq; seq_decl_plugin& seq;
char_decl_plugin& ch; char_decl_plugin& ch;
family_id m_fid; family_id m_fid;
mutable scoped_ptr<bv_util> m_bv;
bv_util& bv() const;
public: public: