3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-24 23:03:41 +00:00

implementing model updates

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-10-30 16:11:51 -05:00
parent 92b5301b7f
commit 3de8c193ea
63 changed files with 482 additions and 294 deletions

View file

@ -18,10 +18,53 @@ Notes:
--*/
#include "tactic/model_converter.h"
#include "model/model_v2_pp.h"
#include "ast/ast_smt2_pp.h"
/*
* Add or overwrite value in model.
*/
void model_converter::display_add(std::ostream& out, ast_manager& m, func_decl* f, expr* e) const {
// TBD: for arity > 0, requires signature of arguments.
if (m_env) {
ast_smt2_pp(out, f, e, *m_env, params_ref(), 0, "model-add");
}
else {
unsigned indent = f->get_name().size() + 4;
out << "(model-add " << f->get_name() << " " << mk_ismt2_pp(e, m, indent) << ")\n";
}
}
/*
* A value is removed from the model.
*/
void model_converter::display_del(std::ostream& out, func_decl* f) const {
if (m_env) {
ast_smt2_pp(out, f, *m_env, params_ref(), 0, "model-del");
}
else {
out << "(model-del " << f->get_name() << ")\n";
}
}
void model_converter::display_add(std::ostream& out, ast_manager& m) {
// default printer for converter that adds entries
model_ref mdl = alloc(model, m);
(*this)(mdl);
for (unsigned i = 0, sz = mdl->get_num_constants(); i < sz; ++i) {
func_decl* f = mdl->get_constant(i);
display_add(out, m, f, mdl->get_const_interp(f));
}
for (unsigned i = 0, sz = mdl->get_num_functions(); i < sz; ++i) {
func_decl* f = mdl->get_function(i);
func_interp* fi = mdl->get_func_interp(f);
display_add(out, m, f, fi->get_interp());
}
}
class concat_model_converter : public concat_converter<model_converter> {
public:
concat_model_converter(model_converter * mc1, model_converter * mc2):concat_converter<model_converter>(mc1, mc2) {}
concat_model_converter(model_converter * mc1, model_converter * mc2): concat_converter<model_converter>(mc1, mc2) {}
virtual void operator()(model_ref & m) {
this->m_c2->operator()(m);
@ -37,7 +80,6 @@ public:
this->m_c2->operator()(r, goal_idx);
this->m_c1->operator()(r, 0);
}
virtual char const * get_name() const { return "concat-model-converter"; }
@ -90,9 +132,9 @@ public:
// found the model converter that should be used
model_converter * c2 = this->m_c2s[i];
if (c2)
c2->operator()(r, goal_idx);
c2->operator()(r, goal_idx);
if (m_c1)
this->m_c1->operator()(r, i);
this->m_c1->operator()(r, i);
return;
}
// invalid goal
@ -143,10 +185,10 @@ public:
}
virtual void operator()(labels_vec & r, unsigned goal_idx) {
r.append(m_labels.size(), m_labels.c_ptr());
r.append(m_labels.size(), m_labels.c_ptr());
}
virtual void cancel() {
virtual void cancel() {
}
virtual void display(std::ostream & out) {