mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
add stubs for converting assertions, consolidate filter_model_converter
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
53e36c9cf9
commit
0d15b6abb7
76 changed files with 244 additions and 356 deletions
|
@ -164,7 +164,7 @@ public:
|
|||
m_solver2->set_produce_models(f);
|
||||
}
|
||||
|
||||
virtual void assert_expr(expr * t) {
|
||||
virtual void assert_expr_core(expr * t) {
|
||||
if (m_check_sat_executed)
|
||||
switch_inc_mode();
|
||||
m_solver1->assert_expr(t);
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
m_solver2->assert_expr(t);
|
||||
}
|
||||
|
||||
virtual void assert_expr(expr * t, expr * a) {
|
||||
virtual void assert_expr_core(expr * t, expr * a) {
|
||||
if (m_check_sat_executed)
|
||||
switch_inc_mode();
|
||||
m_solver1->assert_expr(t, a);
|
||||
|
|
|
@ -182,13 +182,26 @@ bool solver::is_literal(ast_manager& m, expr* e) {
|
|||
return is_uninterp_const(e) || (m.is_not(e, e) && is_uninterp_const(e));
|
||||
}
|
||||
|
||||
#if 0
|
||||
expr_ref solver::lookahead(expr_ref_vector const& candidates) {
|
||||
std::cout << "lookahead: " << candidates.size() << "\n";
|
||||
INVOKE_DEBUGGER();
|
||||
ast_manager& m = candidates.get_manager();
|
||||
return expr_ref(m.mk_true(), m);
|
||||
|
||||
void solver::assert_expr(expr* f) {
|
||||
expr_ref fml(f, get_manager());
|
||||
if (mc0()) {
|
||||
(*mc0())(fml);
|
||||
}
|
||||
assert_expr_core(fml);
|
||||
}
|
||||
#endif
|
||||
|
||||
void solver::assert_expr(expr* f, expr* t) {
|
||||
// let mc0 be the model converter associated with the solver
|
||||
// that converts models to their "real state".
|
||||
ast_manager& m = get_manager();
|
||||
expr_ref fml(f, m);
|
||||
expr_ref a(t, m);
|
||||
|
||||
if (mc0()) {
|
||||
(*mc0())(fml);
|
||||
// (*mc0())(a);
|
||||
}
|
||||
assert_expr_core(fml, a);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,14 +80,16 @@ public:
|
|||
/**
|
||||
\brief Add a new formula to the assertion stack.
|
||||
*/
|
||||
virtual void assert_expr(expr * t) = 0;
|
||||
void assert_expr(expr* f);
|
||||
|
||||
virtual void assert_expr_core(expr * t) = 0;
|
||||
|
||||
void assert_expr(expr_ref_vector const& ts) {
|
||||
for (unsigned i = 0; i < ts.size(); ++i) assert_expr(ts[i]);
|
||||
for (expr* e : ts) assert_expr(e);
|
||||
}
|
||||
|
||||
void assert_expr(ptr_vector<expr> const& ts) {
|
||||
for (unsigned i = 0; i < ts.size(); ++i) assert_expr(ts[i]);
|
||||
for (expr* e : ts) assert_expr(e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +97,10 @@ public:
|
|||
The propositional variable \c a is used to track the use of \c t in a proof
|
||||
of unsatisfiability.
|
||||
*/
|
||||
virtual void assert_expr(expr * t, expr * a) = 0;
|
||||
|
||||
void assert_expr(expr * t, expr* a);
|
||||
|
||||
virtual void assert_expr_core(expr * t, expr * a) = 0;
|
||||
|
||||
/**
|
||||
\brief Add a lemma to the assertion stack. A lemma is assumed to be a consequence of already
|
||||
|
@ -210,11 +215,13 @@ public:
|
|||
~scoped_push() { if (!m_nopop) s.pop(1); }
|
||||
void disable_pop() { m_nopop = true; }
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences);
|
||||
|
||||
|
||||
bool is_literal(ast_manager& m, expr* e);
|
||||
|
||||
};
|
||||
|
|
|
@ -19,13 +19,13 @@ Notes:
|
|||
|
||||
#include "solver/solver.h"
|
||||
#include "tactic/tactic.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
#include "solver/solver2tactic.h"
|
||||
#include "ast/ast_util.h"
|
||||
|
||||
typedef obj_map<expr, expr *> expr2expr_map;
|
||||
|
||||
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, expr2expr_map& bool2dep, ref<filter_model_converter>& fmc) {
|
||||
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, expr2expr_map& bool2dep, ref<generic_model_converter>& fmc) {
|
||||
expr2expr_map dep2bool;
|
||||
ptr_vector<expr> deps;
|
||||
ast_manager& m = g->m();
|
||||
|
@ -65,9 +65,9 @@ void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clause
|
|||
bool2dep.insert(b, d);
|
||||
assumptions.push_back(b);
|
||||
if (!fmc) {
|
||||
fmc = alloc(filter_model_converter, m);
|
||||
fmc = alloc(generic_model_converter, m);
|
||||
}
|
||||
fmc->insert(to_app(b)->get_decl());
|
||||
fmc->hide(to_app(b)->get_decl());
|
||||
}
|
||||
clause.push_back(m.mk_not(b));
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
expr_ref_vector clauses(m);
|
||||
expr2expr_map bool2dep;
|
||||
ptr_vector<expr> assumptions;
|
||||
ref<filter_model_converter> fmc;
|
||||
ref<generic_model_converter> fmc;
|
||||
extract_clauses_and_dependencies(in, clauses, assumptions, bool2dep, fmc);
|
||||
ref<solver> local_solver = m_solver->translate(m, m_params);
|
||||
local_solver->assert_expr(clauses);
|
||||
|
|
|
@ -20,11 +20,11 @@ Notes:
|
|||
#define SOLVER2TACTIC_H_
|
||||
|
||||
#include "tactic/tactic.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
class solver;
|
||||
|
||||
tactic * mk_solver2tactic(solver* s);
|
||||
|
||||
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, obj_map<expr, expr*>& bool2dep, ref<filter_model_converter>& fmc);
|
||||
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, obj_map<expr, expr*>& bool2dep, ref<generic_model_converter>& fmc);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,9 +30,9 @@ solver_na2as::solver_na2as(ast_manager & m):
|
|||
|
||||
solver_na2as::~solver_na2as() {}
|
||||
|
||||
void solver_na2as::assert_expr(expr * t, expr * a) {
|
||||
void solver_na2as::assert_expr_core(expr * t, expr * a) {
|
||||
if (a == 0) {
|
||||
assert_expr(t);
|
||||
assert_expr_core(t);
|
||||
}
|
||||
else {
|
||||
SASSERT(is_uninterp_const(a));
|
||||
|
@ -41,7 +41,7 @@ void solver_na2as::assert_expr(expr * t, expr * a) {
|
|||
m_assumptions.push_back(a);
|
||||
expr_ref new_t(m);
|
||||
new_t = m.mk_implies(a, t);
|
||||
assert_expr(new_t);
|
||||
assert_expr_core(new_t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ public:
|
|||
solver_na2as(ast_manager & m);
|
||||
virtual ~solver_na2as();
|
||||
|
||||
virtual void assert_expr(expr * t, expr * a);
|
||||
virtual void assert_expr(expr * t) = 0;
|
||||
void assert_expr_core(expr * t, expr * a) override;
|
||||
virtual void assert_expr_core(expr * t) = 0;
|
||||
|
||||
// Subclasses of solver_na2as should redefine the following *_core methods instead of these ones.
|
||||
virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
m_in_delayed_scope(false),
|
||||
m_dump_counter(0) {
|
||||
if (is_virtual()) {
|
||||
solver_na2as::assert_expr(m.mk_true(), pred);
|
||||
solver_na2as::assert_expr_core(m.mk_true(), pred);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void assert_expr(expr * e) {
|
||||
virtual void assert_expr_core(expr * e) {
|
||||
SASSERT(!m_pushed || get_scope_level() > 0);
|
||||
if (m.is_true(e)) return;
|
||||
if (m_in_delayed_scope) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
|
||||
virtual void set_produce_models(bool f) { m_produce_models = f; }
|
||||
|
||||
virtual void assert_expr(expr * t);
|
||||
virtual void assert_expr_core(expr * t);
|
||||
virtual void assert_lemma(expr * t);
|
||||
|
||||
virtual void push_core();
|
||||
|
@ -112,7 +112,7 @@ void tactic2solver::collect_param_descrs(param_descrs & r) {
|
|||
m_tactic->collect_param_descrs(r);
|
||||
}
|
||||
|
||||
void tactic2solver::assert_expr(expr * t) {
|
||||
void tactic2solver::assert_expr_core(expr * t) {
|
||||
m_assertions.push_back(t);
|
||||
m_result = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue