mirror of
https://github.com/Z3Prover/z3
synced 2025-08-18 01:02:15 +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
|
@ -105,7 +105,7 @@ namespace opt {
|
|||
|
||||
app* maxsmt_solver_base::mk_fresh_bool(char const* name) {
|
||||
app* result = m.mk_fresh_const(name, m.mk_bool_sort());
|
||||
m_c.fm().insert(result->get_decl());
|
||||
m_c.fm().hide(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ Notes:
|
|||
#include "ast/ast.h"
|
||||
#include "util/params.h"
|
||||
#include "solver/solver.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "util/statistics.h"
|
||||
#include "smt/smt_context.h"
|
||||
#include "smt/smt_theory.h"
|
||||
|
|
|
@ -40,7 +40,7 @@ Notes:
|
|||
#include "ast/bv_decl_plugin.h"
|
||||
#include "ast/pb_decl_plugin.h"
|
||||
#include "ast/ast_smt_pp.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
#include "ast/ast_pp_util.h"
|
||||
#include "qe/qsat.h"
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ namespace opt {
|
|||
}
|
||||
|
||||
void context::purify(app_ref& term) {
|
||||
filter_model_converter_ref fm;
|
||||
generic_model_converter_ref fm;
|
||||
if (m_arith.is_add(term)) {
|
||||
expr_ref_vector args(m);
|
||||
unsigned sz = term->get_num_args();
|
||||
|
@ -1058,13 +1058,13 @@ namespace opt {
|
|||
(m_arith.is_mul(e, e2, e1) && m_arith.is_numeral(e1) && is_uninterp_const(e2));
|
||||
}
|
||||
|
||||
app* context::purify(filter_model_converter_ref& fm, expr* term) {
|
||||
app* context::purify(generic_model_converter_ref& fm, expr* term) {
|
||||
std::ostringstream out;
|
||||
out << mk_pp(term, m);
|
||||
app* q = m.mk_fresh_const(out.str().c_str(), m.get_sort(term));
|
||||
if (!fm) fm = alloc(filter_model_converter, m);
|
||||
if (!fm) fm = alloc(generic_model_converter, m);
|
||||
m_hard_constraints.push_back(m.mk_eq(q, term));
|
||||
fm->insert(q->get_decl());
|
||||
fm->hide(q);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ namespace opt {
|
|||
- filter "obj" from generated model.
|
||||
*/
|
||||
void context::mk_atomic(expr_ref_vector& terms) {
|
||||
filter_model_converter_ref fm;
|
||||
generic_model_converter_ref fm;
|
||||
for (unsigned i = 0; i < terms.size(); ++i) {
|
||||
expr_ref p(terms[i].get(), m);
|
||||
app_ref q(m);
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace opt {
|
|||
|
||||
class maxsat_context {
|
||||
public:
|
||||
virtual filter_model_converter& fm() = 0; // converter that removes fresh names introduced by simplification.
|
||||
virtual generic_model_converter& fm() = 0; // converter that removes fresh names introduced by simplification.
|
||||
virtual bool sat_enabled() const = 0; // is using th SAT solver core enabled?
|
||||
virtual solver& get_solver() = 0; // retrieve solver object (SAT or SMT solver)
|
||||
virtual ast_manager& get_manager() const = 0;
|
||||
|
@ -155,7 +155,7 @@ namespace opt {
|
|||
vector<objective> m_objectives;
|
||||
model_ref m_model;
|
||||
model_converter_ref m_model_converter;
|
||||
filter_model_converter m_fm;
|
||||
generic_model_converter m_fm;
|
||||
obj_map<func_decl, unsigned> m_objective_fns;
|
||||
obj_map<func_decl, expr*> m_objective_orig;
|
||||
func_decl_ref_vector m_objective_refs;
|
||||
|
@ -219,7 +219,7 @@ namespace opt {
|
|||
virtual expr_ref mk_le(unsigned i, model_ref& model);
|
||||
|
||||
virtual smt::context& smt_context() { return m_opt_solver->get_context(); }
|
||||
virtual filter_model_converter& fm() { return m_fm; }
|
||||
virtual generic_model_converter& fm() { return m_fm; }
|
||||
virtual bool sat_enabled() const { return 0 != m_sat_solver.get(); }
|
||||
virtual solver& get_solver();
|
||||
virtual ast_manager& get_manager() const { return this->m; }
|
||||
|
@ -253,7 +253,7 @@ namespace opt {
|
|||
vector<rational>& weights, rational& offset, bool& neg,
|
||||
symbol& id, expr_ref& orig_term, unsigned& index);
|
||||
void purify(app_ref& term);
|
||||
app* purify(filter_model_converter_ref& fm, expr* e);
|
||||
app* purify(generic_model_converter_ref& fm, expr* e);
|
||||
bool is_mul_const(expr* e);
|
||||
expr* mk_maximize(unsigned index, app* t);
|
||||
expr* mk_minimize(unsigned index, app* t);
|
||||
|
|
|
@ -37,7 +37,7 @@ Notes:
|
|||
namespace opt {
|
||||
|
||||
opt_solver::opt_solver(ast_manager & mgr, params_ref const & p,
|
||||
filter_model_converter& fm):
|
||||
generic_model_converter& fm):
|
||||
solver_na2as(mgr),
|
||||
m_params(p),
|
||||
m_context(mgr, m_params),
|
||||
|
@ -80,7 +80,7 @@ namespace opt {
|
|||
m_context.collect_statistics(st);
|
||||
}
|
||||
|
||||
void opt_solver::assert_expr(expr * t) {
|
||||
void opt_solver::assert_expr_core(expr * t) {
|
||||
if (has_quantifiers(t)) {
|
||||
m_params.m_relevancy_lvl = 2;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ Notes:
|
|||
#include "smt/params/smt_params.h"
|
||||
#include "smt/smt_types.h"
|
||||
#include "smt/theory_opt.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
|
||||
namespace opt {
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace opt {
|
|||
smt_params m_params;
|
||||
smt::kernel m_context;
|
||||
ast_manager& m;
|
||||
filter_model_converter& m_fm;
|
||||
generic_model_converter& m_fm;
|
||||
progress_callback * m_callback;
|
||||
symbol m_logic;
|
||||
svector<smt::theory_var> m_objective_vars;
|
||||
|
@ -84,14 +84,14 @@ namespace opt {
|
|||
bool m_first;
|
||||
bool m_was_unknown;
|
||||
public:
|
||||
opt_solver(ast_manager & m, params_ref const & p, filter_model_converter& fm);
|
||||
opt_solver(ast_manager & m, params_ref const & p, generic_model_converter& fm);
|
||||
virtual ~opt_solver();
|
||||
|
||||
virtual solver* translate(ast_manager& m, params_ref const& p);
|
||||
virtual void updt_params(params_ref const& p);
|
||||
virtual void collect_param_descrs(param_descrs & r);
|
||||
virtual void collect_statistics(statistics & st) const;
|
||||
virtual void assert_expr(expr * t);
|
||||
virtual void assert_expr_core(expr * t);
|
||||
virtual void assert_lemma(expr* t) {}
|
||||
virtual void push_core();
|
||||
virtual void pop_core(unsigned n);
|
||||
|
|
|
@ -24,7 +24,7 @@ Notes:
|
|||
#include "smt/smt_context.h"
|
||||
#include "opt/opt_context.h"
|
||||
#include "util/sorting_network.h"
|
||||
#include "tactic/filter_model_converter.h"
|
||||
#include "tactic/generic_model_converter.h"
|
||||
|
||||
namespace opt {
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace opt {
|
|||
psort_nw<sortmax> m_sort;
|
||||
expr_ref_vector m_trail;
|
||||
func_decl_ref_vector m_fresh;
|
||||
ref<filter_model_converter> m_filter;
|
||||
ref<generic_model_converter> m_filter;
|
||||
sortmax(maxsat_context& c, weights_t& ws, expr_ref_vector const& soft):
|
||||
maxsmt_solver_base(c, ws, soft), m_sort(*this), m_trail(m), m_fresh(m) {}
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace opt {
|
|||
if (is_sat != l_true) {
|
||||
return is_sat;
|
||||
}
|
||||
m_filter = alloc(filter_model_converter, m);
|
||||
m_filter = alloc(generic_model_converter, m);
|
||||
rational offset = m_lower;
|
||||
m_upper = offset;
|
||||
expr_ref_vector in(m);
|
||||
|
@ -142,7 +142,7 @@ namespace opt {
|
|||
expr_ref fr(m.mk_fresh_const(n, m.mk_bool_sort()), m);
|
||||
func_decl* f = to_app(fr)->get_decl();
|
||||
m_fresh.push_back(f);
|
||||
m_filter->insert(f);
|
||||
m_filter->hide(f);
|
||||
return trail(fr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue