3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-02 13:27:01 +00:00

Cleanup fixedpoint options

Replace pdr options with spacer
Repace fixedpoint module with fp
This commit is contained in:
Arie Gurfinkel 2018-06-13 15:29:34 -07:00
parent 619f681d28
commit 9109968e55
23 changed files with 344 additions and 353 deletions

View file

@ -30,23 +30,23 @@ Notes:
#include "util/scoped_ctrl_c.h"
#include "util/scoped_timer.h"
#include "util/trail.h"
#include "muz/base/fixedpoint_params.hpp"
#include "muz/base/fp_params.hpp"
#include<iomanip>
struct dl_context {
smt_params m_fparams;
params_ref m_params_ref;
fixedpoint_params m_params;
fp_params m_params;
cmd_context & m_cmd;
datalog::register_engine m_register_engine;
dl_collected_cmds* m_collected_cmds;
unsigned m_ref_count;
datalog::dl_decl_plugin* m_decl_plugin;
scoped_ptr<datalog::context> m_context;
scoped_ptr<datalog::context> m_context;
trail_stack<dl_context> m_trail;
fixedpoint_params const& get_params() {
fp_params const& get_params() {
init();
return m_context->get_params();
}
@ -58,18 +58,18 @@ struct dl_context {
m_ref_count(0),
m_decl_plugin(nullptr),
m_trail(*this) {}
void inc_ref() {
++m_ref_count;
}
void dec_ref() {
--m_ref_count;
if (0 == m_ref_count) {
dealloc(this);
}
}
void init() {
ast_manager& m = m_cmd.m();
if (!m_context) {
@ -83,10 +83,10 @@ struct dl_context {
else {
m_decl_plugin = alloc(datalog::dl_decl_plugin);
m.register_plugin(symbol("datalog_relation"), m_decl_plugin);
}
}
}
}
void reset() {
m_context = nullptr;
}
@ -97,9 +97,9 @@ struct dl_context {
m_trail.push(push_back_vector<dl_context, func_decl_ref_vector>(m_collected_cmds->m_rels));
}
dlctx().register_predicate(pred, false);
dlctx().set_predicate_representation(pred, num_kinds, kinds);
dlctx().set_predicate_representation(pred, num_kinds, kinds);
}
void add_rule(expr * rule, symbol const& name, unsigned bound) {
init();
if (m_collected_cmds) {
@ -112,7 +112,7 @@ struct dl_context {
else {
m_context->add_rule(rule, name, bound);
}
}
}
bool collect_query(func_decl* q) {
if (m_collected_cmds) {
@ -127,7 +127,7 @@ struct dl_context {
m_collected_cmds->m_queries.push_back(qr);
m_trail.push(push_back_vector<dl_context, expr_ref_vector>(m_collected_cmds->m_queries));
return true;
}
}
else {
return false;
}
@ -142,7 +142,7 @@ struct dl_context {
m_trail.pop_scope(1);
dlctx().pop();
}
datalog::context & dlctx() {
init();
return *m_context;
@ -162,7 +162,7 @@ class dl_rule_cmd : public cmd {
public:
dl_rule_cmd(dl_context * dl_ctx):
cmd("rule"),
m_dl_ctx(dl_ctx),
m_dl_ctx(dl_ctx),
m_arg_idx(0),
m_t(nullptr),
m_bound(UINT_MAX) {}
@ -210,7 +210,7 @@ public:
}
char const * get_usage() const override { return "predicate"; }
char const * get_main_descr() const override {
return "pose a query to a predicate based on the Horn rules.";
return "pose a query to a predicate based on the Horn rules.";
}
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override {
@ -243,9 +243,9 @@ public:
return;
}
datalog::context& dlctx = m_dl_ctx->dlctx();
set_background(ctx);
set_background(ctx);
dlctx.updt_params(m_params);
unsigned timeout = m_dl_ctx->get_params().timeout();
unsigned timeout = m_dl_ctx->get_params().timeout();
cancel_eh<reslimit> eh(ctx.m().limit());
bool query_exn = false;
lbool status = l_undef;
@ -271,12 +271,12 @@ public:
ctx.regular_stream() << "unsat\n";
print_certificate(ctx);
break;
case l_true:
case l_true:
ctx.regular_stream() << "sat\n";
print_answer(ctx);
print_certificate(ctx);
break;
case l_undef:
case l_undef:
if (dlctx.get_status() == datalog::BOUNDED){
ctx.regular_stream() << "bounded\n";
print_certificate(ctx);
@ -287,7 +287,7 @@ public:
case datalog::INPUT_ERROR:
ctx.regular_stream() << "input error\n";
break;
case datalog::MEMOUT:
ctx.regular_stream() << "memory bounds exceeded\n";
break;
@ -295,12 +295,12 @@ public:
case datalog::TIMEOUT:
ctx.regular_stream() << "timeout\n";
break;
case datalog::APPROX:
ctx.regular_stream() << "approximated relations\n";
break;
case datalog::OK:
case datalog::OK:
(void)query_exn;
SASSERT(query_exn);
break;
@ -324,7 +324,7 @@ public:
void init_pdescrs(cmd_context & ctx, param_descrs & p) override {
m_dl_ctx->dlctx().collect_params(p);
}
private:
void set_background(cmd_context& ctx) {
@ -356,8 +356,8 @@ private:
statistics st;
datalog::context& dlctx = m_dl_ctx->dlctx();
dlctx.collect_statistics(st);
st.update("time", ctx.get_seconds());
st.display_smt2(ctx.regular_stream());
st.update("time", ctx.get_seconds());
st.display_smt2(ctx.regular_stream());
}
}
@ -391,8 +391,8 @@ public:
void prepare(cmd_context & ctx) override {
ctx.m(); // ensure manager is initialized.
m_arg_idx = 0;
m_query_arg_idx = 0;
m_arg_idx = 0;
m_query_arg_idx = 0;
m_domain.reset();
m_kinds.reset();
}
@ -443,21 +443,21 @@ public:
m_arg_idx(0),
m_dl_ctx(dl_ctx)
{}
char const * get_usage() const override { return "<symbol> <sort>"; }
char const * get_descr(cmd_context & ctx) const override { return "declare constant as variable"; }
unsigned get_arity() const override { return 2; }
void prepare(cmd_context & ctx) override {
ctx.m(); // ensure manager is initialized.
m_arg_idx = 0;
m_arg_idx = 0;
}
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override {
SASSERT(m_arg_idx <= 1);
if (m_arg_idx == 0) {
return CPK_SYMBOL;
return CPK_SYMBOL;
}
return CPK_SORT;
return CPK_SORT;
}
void set_next_arg(cmd_context & ctx, sort* s) override {
@ -466,7 +466,7 @@ public:
}
void set_next_arg(cmd_context & ctx, symbol const & s) override {
m_var_name = s;
m_var_name = s;
++m_arg_idx;
}
@ -523,7 +523,7 @@ static void install_dl_cmds_aux(cmd_context& ctx, dl_collected_cmds* collected_c
ctx.insert(alloc(dl_query_cmd, dl_ctx));
ctx.insert(alloc(dl_declare_rel_cmd, dl_ctx));
ctx.insert(alloc(dl_declare_var_cmd, dl_ctx));
ctx.insert(alloc(dl_push_cmd, dl_ctx));
ctx.insert(alloc(dl_push_cmd, dl_ctx));
ctx.insert(alloc(dl_pop_cmd, dl_ctx));
}

View file

@ -27,7 +27,7 @@ Revision History:
#include "muz/transforms/dl_mk_slice.h"
#include "tactic/generic_model_converter.h"
#include "muz/transforms/dl_transforms.h"
#include "muz/base/fixedpoint_params.hpp"
#include "muz/base/fp_params.hpp"
#include "ast/ast_util.h"
#include "ast/rewriter/var_subst.h"
@ -71,7 +71,7 @@ class horn_tactic : public tactic {
f = to_quantifier(f)->get_expr();
}
else if (is_exists(f) && !is_positive) {
f = to_quantifier(f)->get_expr();
f = to_quantifier(f)->get_expr();
}
else if (m.is_not(f, e)) {
is_positive = !is_positive;
@ -84,7 +84,7 @@ class horn_tactic : public tactic {
if (!is_positive) {
f = m.mk_not(f);
}
}
bool is_predicate(expr* a) {
@ -144,7 +144,7 @@ class horn_tactic : public tactic {
expr* a = nullptr, *a1 = nullptr;
flatten_or(tmp, args);
for (unsigned i = 0; i < args.size(); ++i) {
a = args[i].get();
a = args[i].get();
check_predicate(mark, a);
if (m.is_not(a, a1)) {
body.push_back(a1);
@ -176,13 +176,13 @@ class horn_tactic : public tactic {
return expr_ref(m.mk_implies(body, head), m);
}
void operator()(goal_ref const & g,
void operator()(goal_ref const & g,
goal_ref_buffer & result) {
SASSERT(g->is_well_sorted());
tactic_report report("horn", *g);
bool produce_proofs = g->proofs_enabled();
if (produce_proofs) {
if (produce_proofs) {
if (!m_ctx.generate_proof_trace()) {
params_ref params = m_ctx.get_params().p;
params.set_bool("generate_proof_trace", true);
@ -208,7 +208,7 @@ class horn_tactic : public tactic {
case IS_QUERY:
queries.push_back(f);
break;
default:
default:
msg << "formula is not in Horn fragment: " << mk_pp(g->form(i), m) << "\n";
TRACE("horn", tout << msg.str(););
throw tactic_exception(msg.str().c_str());
@ -243,10 +243,10 @@ class horn_tactic : public tactic {
g->set(mc.get());
}
void verify(expr* q,
void verify(expr* q,
goal_ref const& g,
goal_ref_buffer & result,
model_converter_ref & mc,
goal_ref_buffer & result,
model_converter_ref & mc,
proof_converter_ref & pc) {
lbool is_reachable = l_undef;
@ -275,9 +275,9 @@ class horn_tactic : public tactic {
else {
g->assert_expr(m.mk_false());
}
break;
break;
}
case l_false: {
case l_false: {
// goal is sat
g->reset();
if (produce_models) {
@ -290,11 +290,11 @@ class horn_tactic : public tactic {
mc = mc2;
}
}
break;
break;
}
case l_undef:
case l_undef:
// subgoal is unchanged.
break;
break;
}
TRACE("horn", g->display(tout););
SASSERT(g->is_well_sorted());
@ -314,20 +314,20 @@ class horn_tactic : public tactic {
}
}
void simplify(expr* q,
void simplify(expr* q,
goal_ref const& g,
goal_ref_buffer & result,
model_converter_ref & mc,
goal_ref_buffer & result,
model_converter_ref & mc,
proof_converter_ref & pc) {
expr_ref fml(m);
expr_ref fml(m);
func_decl* query_pred = to_app(q)->get_decl();
m_ctx.set_output_predicate(query_pred);
m_ctx.get_rules(); // flush adding rules.
apply_default_transformation(m_ctx);
if (m_ctx.xform_slice()) {
datalog::rule_transformer transformer(m_ctx);
datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx);
@ -351,7 +351,7 @@ class horn_tactic : public tactic {
g->assert_expr(fml);
}
}
};
bool m_is_simplify;
@ -368,7 +368,7 @@ public:
tactic * translate(ast_manager & m) override {
return alloc(horn_tactic, m_is_simplify, m, m_params);
}
~horn_tactic() override {
dealloc(m_imp);
}
@ -378,16 +378,16 @@ public:
m_imp->updt_params(p);
}
void collect_param_descrs(param_descrs & r) override {
m_imp->collect_param_descrs(r);
}
void operator()(goal_ref const & in,
void operator()(goal_ref const & in,
goal_ref_buffer & result) override {
(*m_imp)(in, result);
}
void collect_statistics(statistics & st) const override {
m_imp->collect_statistics(st);
st.copy(m_stats);
@ -397,15 +397,15 @@ public:
m_stats.reset();
m_imp->reset_statistics();
}
void cleanup() override {
ast_manager & m = m_imp->m;
m_imp->collect_statistics(m_stats);
dealloc(m_imp);
m_imp = alloc(imp, m_is_simplify, m, m_params);
}
};
@ -416,4 +416,3 @@ tactic * mk_horn_tactic(ast_manager & m, params_ref const & p) {
tactic * mk_horn_simplify_tactic(ast_manager & m, params_ref const & p) {
return clean(alloc(horn_tactic, true, m, p));
}