mirror of
https://github.com/Z3Prover/z3
synced 2025-06-08 23:23:23 +00:00
bypass simplifier if (m_is_clausal) {
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9d75babcda
commit
301f441801
10 changed files with 39 additions and 23 deletions
|
@ -149,7 +149,7 @@ extern "C" {
|
||||||
to_param_ref(p).validate(r);
|
to_param_ref(p).validate(r);
|
||||||
to_solver_ref(s)->updt_params(to_param_ref(p));
|
to_solver_ref(s)->updt_params(to_param_ref(p));
|
||||||
}
|
}
|
||||||
to_solver(s)->m_params = to_param_ref(p);
|
to_solver(s)->m_params.append(to_param_ref(p));
|
||||||
Z3_CATCH;
|
Z3_CATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,8 @@ public:
|
||||||
simp2_p.set_bool("hoist_mul", false); // required by som
|
simp2_p.set_bool("hoist_mul", false); // required by som
|
||||||
m_preprocess =
|
m_preprocess =
|
||||||
and_then(mk_card2bv_tactic(m, m_params),
|
and_then(mk_card2bv_tactic(m, m_params),
|
||||||
mk_simplify_tactic(m),
|
//mk_simplify_tactic(m),
|
||||||
mk_propagate_values_tactic(m),
|
//mk_propagate_values_tactic(m),
|
||||||
using_params(mk_simplify_tactic(m), simp2_p),
|
using_params(mk_simplify_tactic(m), simp2_p),
|
||||||
mk_max_bv_sharing_tactic(m),
|
mk_max_bv_sharing_tactic(m),
|
||||||
mk_bit_blaster_tactic(m),
|
mk_bit_blaster_tactic(m),
|
||||||
|
|
|
@ -88,6 +88,7 @@ private:
|
||||||
rational m_max_upper;
|
rational m_max_upper;
|
||||||
bool m_found_feasible_optimum;
|
bool m_found_feasible_optimum;
|
||||||
bool m_hill_climb; // prefer large weight soft clauses for cores
|
bool m_hill_climb; // prefer large weight soft clauses for cores
|
||||||
|
unsigned m_last_index; // last index used during hill-climbing
|
||||||
bool m_add_upper_bound_block; // restrict upper bound with constraint
|
bool m_add_upper_bound_block; // restrict upper bound with constraint
|
||||||
unsigned m_max_num_cores; // max number of cores per round.
|
unsigned m_max_num_cores; // max number of cores per round.
|
||||||
unsigned m_max_core_size; // max core size per round.
|
unsigned m_max_core_size; // max core size per round.
|
||||||
|
@ -110,6 +111,7 @@ public:
|
||||||
m_st(st),
|
m_st(st),
|
||||||
m_found_feasible_optimum(false),
|
m_found_feasible_optimum(false),
|
||||||
m_hill_climb(true),
|
m_hill_climb(true),
|
||||||
|
m_last_index(0),
|
||||||
m_add_upper_bound_block(false),
|
m_add_upper_bound_block(false),
|
||||||
m_max_num_cores(UINT_MAX),
|
m_max_num_cores(UINT_MAX),
|
||||||
m_max_core_size(3),
|
m_max_core_size(3),
|
||||||
|
@ -353,15 +355,20 @@ public:
|
||||||
Give preference to cores that have large minmal values.
|
Give preference to cores that have large minmal values.
|
||||||
*/
|
*/
|
||||||
sort_assumptions(asms);
|
sort_assumptions(asms);
|
||||||
unsigned index = 0;
|
|
||||||
unsigned last_index = 0;
|
m_last_index = std::min(m_last_index, asms.size()-1);
|
||||||
|
m_last_index = 0;
|
||||||
|
unsigned index = m_last_index>0?m_last_index-1:0;
|
||||||
|
m_last_index = 0;
|
||||||
|
bool first = index > 0;
|
||||||
|
SASSERT(index < asms.size() || asms.empty());
|
||||||
while (index < asms.size() && is_sat == l_true) {
|
while (index < asms.size() && is_sat == l_true) {
|
||||||
while (asms.size() > 20*(index - last_index) && index < asms.size()) {
|
while (!first && asms.size() > 20*(index - m_last_index) && index < asms.size()) {
|
||||||
index = next_index(asms, index);
|
index = next_index(asms, index);
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
IF_VERBOSE(3, verbose_stream() << "weight: " << get_weight(asms[0].get()) << " " << get_weight(asms[index-1].get()) << "\n";);
|
first = false;
|
||||||
last_index = index;
|
IF_VERBOSE(3, verbose_stream() << "weight: " << get_weight(asms[0].get()) << " " << get_weight(asms[index-1].get()) << " num soft: " << index << "\n";);
|
||||||
|
m_last_index = index;
|
||||||
is_sat = s().check_sat(index, asms.c_ptr());
|
is_sat = s().check_sat(index, asms.c_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -880,6 +887,7 @@ public:
|
||||||
}
|
}
|
||||||
m_max_upper = m_upper;
|
m_max_upper = m_upper;
|
||||||
m_found_feasible_optimum = false;
|
m_found_feasible_optimum = false;
|
||||||
|
m_last_index = 0;
|
||||||
add_upper_bound_block();
|
add_upper_bound_block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ namespace opt {
|
||||||
m_objective_refs(m),
|
m_objective_refs(m),
|
||||||
m_enable_sat(false),
|
m_enable_sat(false),
|
||||||
m_enable_sls(false),
|
m_enable_sls(false),
|
||||||
|
m_is_clausal(false),
|
||||||
m_pp_neat(false)
|
m_pp_neat(false)
|
||||||
{
|
{
|
||||||
params_ref p;
|
params_ref p;
|
||||||
|
@ -553,6 +554,10 @@ namespace opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
void context::simplify_fmls(expr_ref_vector& fmls) {
|
void context::simplify_fmls(expr_ref_vector& fmls) {
|
||||||
|
if (m_is_clausal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
goal_ref g(alloc(goal, m, true, false));
|
goal_ref g(alloc(goal, m, true, false));
|
||||||
for (unsigned i = 0; i < fmls.size(); ++i) {
|
for (unsigned i = 0; i < fmls.size(); ++i) {
|
||||||
g->assert_expr(fmls[i].get());
|
g->assert_expr(fmls[i].get());
|
||||||
|
|
|
@ -126,6 +126,7 @@ namespace opt {
|
||||||
tactic_ref m_simplify;
|
tactic_ref m_simplify;
|
||||||
bool m_enable_sat;
|
bool m_enable_sat;
|
||||||
bool m_enable_sls;
|
bool m_enable_sls;
|
||||||
|
bool m_is_clausal;
|
||||||
bool m_pp_neat;
|
bool m_pp_neat;
|
||||||
symbol m_maxsat_engine;
|
symbol m_maxsat_engine;
|
||||||
symbol m_logic;
|
symbol m_logic;
|
||||||
|
@ -155,6 +156,7 @@ namespace opt {
|
||||||
virtual void display_assignment(std::ostream& out);
|
virtual void display_assignment(std::ostream& out);
|
||||||
virtual bool is_pareto() { return m_pareto.get() != 0; }
|
virtual bool is_pareto() { return m_pareto.get() != 0; }
|
||||||
virtual void set_logic(symbol const& s) { m_logic = s; }
|
virtual void set_logic(symbol const& s) { m_logic = s; }
|
||||||
|
void set_clausal(bool f) { m_is_clausal = f; }
|
||||||
|
|
||||||
void display(std::ostream& out);
|
void display(std::ostream& out);
|
||||||
static void collect_param_descrs(param_descrs & r);
|
static void collect_param_descrs(param_descrs & r);
|
||||||
|
|
|
@ -161,17 +161,9 @@ namespace opt {
|
||||||
|
|
||||||
void opt_solver::maximize_objectives(expr_ref_vector& blockers) {
|
void opt_solver::maximize_objectives(expr_ref_vector& blockers) {
|
||||||
expr_ref blocker(m);
|
expr_ref blocker(m);
|
||||||
vector<inf_eps> values;
|
|
||||||
for (unsigned i = 0; i < m_objective_vars.size(); ++i) {
|
|
||||||
values.push_back(current_objective_value(i));
|
|
||||||
}
|
|
||||||
for (unsigned i = 0; i < m_objective_vars.size(); ++i) {
|
for (unsigned i = 0; i < m_objective_vars.size(); ++i) {
|
||||||
maximize_objective(i, blocker);
|
maximize_objective(i, blocker);
|
||||||
blockers.push_back(blocker);
|
blockers.push_back(blocker);
|
||||||
if (values[i] > m_objective_values[i]) {
|
|
||||||
std::cout << "local optimization produced a worse result\n";
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,15 +90,17 @@ namespace sat {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
unsigned num_literals = core.size() + mus.size();
|
unsigned num_literals = core.size() + mus.size();
|
||||||
|
if (num_literals <= 2) {
|
||||||
|
// IF_VERBOSE(0, verbose_stream() << "num literals: " << core << " " << mus << "\n";);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
literal lit = core.back();
|
literal lit = core.back();
|
||||||
core.pop_back();
|
core.pop_back();
|
||||||
lbool is_sat;
|
lbool is_sat;
|
||||||
{
|
{
|
||||||
scoped_append _sa(mus, core);
|
scoped_append _sa(mus, core);
|
||||||
if (true || core_miss < 2) {
|
mus.push_back(~lit);
|
||||||
mus.push_back(~lit); // TBD: measure
|
|
||||||
}
|
|
||||||
is_sat = s.check(mus.size(), mus.c_ptr());
|
is_sat = s.check(mus.size(), mus.c_ptr());
|
||||||
TRACE("sat", tout << "mus: " << mus << "\n";);
|
TRACE("sat", tout << "mus: " << mus << "\n";);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +148,7 @@ namespace sat {
|
||||||
}
|
}
|
||||||
TRACE("sat", tout << "new core: " << mus << "\n";);
|
TRACE("sat", tout << "new core: " << mus << "\n";);
|
||||||
set_core();
|
set_core();
|
||||||
IF_VERBOSE(2, verbose_stream() << "(sat.mus.new " << core << ")\n";);
|
IF_VERBOSE(2, verbose_stream() << "(sat.mus.new " << s.m_core << ")\n";);
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,9 @@ class wcnf {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
wcnf(opt::context& opt, stream_buffer& in): opt(opt), m(opt.get_manager()), in(in) {}
|
wcnf(opt::context& opt, stream_buffer& in): opt(opt), m(opt.get_manager()), in(in) {
|
||||||
|
opt.set_clausal(true);
|
||||||
|
}
|
||||||
|
|
||||||
void parse() {
|
void parse() {
|
||||||
int num_vars = 0, num_clauses = 0, max_weight = 0;
|
int num_vars = 0, num_clauses = 0, max_weight = 0;
|
||||||
|
|
|
@ -135,6 +135,7 @@ class propagate_values_tactic : public tactic {
|
||||||
|
|
||||||
TRACE("shallow_context_simplifier_bug", tout << mk_ismt2_pp(curr, m()) << "\n---->\n" << mk_ismt2_pp(new_curr, m()) << "\n";);
|
TRACE("shallow_context_simplifier_bug", tout << mk_ismt2_pp(curr, m()) << "\n---->\n" << mk_ismt2_pp(new_curr, m()) << "\n";);
|
||||||
push_result(new_curr, new_pr);
|
push_result(new_curr, new_pr);
|
||||||
|
|
||||||
if (new_curr != curr)
|
if (new_curr != curr)
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +161,9 @@ class propagate_values_tactic : public tactic {
|
||||||
if (m_goal->inconsistent())
|
if (m_goal->inconsistent())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
if (m_max_rounds == 0)
|
||||||
|
goto end;
|
||||||
|
|
||||||
m_subst = alloc(expr_substitution, m(), g->unsat_core_enabled(), g->proofs_enabled());
|
m_subst = alloc(expr_substitution, m(), g->unsat_core_enabled(), g->proofs_enabled());
|
||||||
m_r.set_substitution(m_subst.get());
|
m_r.set_substitution(m_subst.get());
|
||||||
m_occs(*m_goal);
|
m_occs(*m_goal);
|
||||||
|
|
|
@ -230,6 +230,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) {
|
void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) {
|
||||||
param_kind k = d.get_kind(param_name);
|
param_kind k = d.get_kind(param_name);
|
||||||
params_ref & ps = get_params(mod_name);
|
params_ref & ps = get_params(mod_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue