mirror of
https://github.com/Z3Prover/z3
synced 2025-08-15 07:15:26 +00:00
fix pb rewriter
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
f04e805fa4
commit
e7d43ed516
16 changed files with 215 additions and 129 deletions
|
@ -20,6 +20,7 @@ Revision History:
|
|||
#include "sat/ba_solver.h"
|
||||
#include "sat/sat_types.h"
|
||||
#include "util/mpz.h"
|
||||
#include "sat/sat_simplifier_params.hpp"
|
||||
|
||||
|
||||
namespace sat {
|
||||
|
@ -3013,19 +3014,21 @@ namespace sat {
|
|||
}
|
||||
|
||||
unsigned ba_solver::set_non_external() {
|
||||
sat_simplifier_params p(s().m_params);
|
||||
// set variables to be non-external if they are not used in theory constraints.
|
||||
unsigned ext = 0;
|
||||
for (unsigned v = 0; v < s().num_vars(); ++v) {
|
||||
bool incremental_mode = s().get_config().m_incremental && !p.override_incremental();
|
||||
incremental_mode |= s().tracking_assumptions();
|
||||
for (unsigned v = 0; !incremental_mode && v < s().num_vars(); ++v) {
|
||||
literal lit(v, false);
|
||||
if (s().is_external(v) &&
|
||||
m_cnstr_use_list[lit.index()].empty() &&
|
||||
m_cnstr_use_list[(~lit).index()].empty() &&
|
||||
!s().is_assumption(v)) {
|
||||
m_cnstr_use_list[(~lit).index()].empty()) {
|
||||
s().set_non_external(v);
|
||||
++ext;
|
||||
}
|
||||
}
|
||||
// ensure that lemmas use only external variables.
|
||||
// ensure that lemmas use only non-eliminated variables
|
||||
for (constraint* cp : m_learned) {
|
||||
constraint& c = *cp;
|
||||
if (c.was_removed()) continue;
|
||||
|
@ -4182,6 +4185,9 @@ namespace sat {
|
|||
bool ba_solver::check_model(model const& m) const {
|
||||
bool ok = true;
|
||||
for (constraint const* c : m_constraints) {
|
||||
if (c->is_pure() && c->lit() != null_literal && m[c->lit().var()] == (c->lit().sign() ? l_true : l_false)) {
|
||||
continue;
|
||||
}
|
||||
switch (eval(m, *c)) {
|
||||
case l_false:
|
||||
IF_VERBOSE(0, verbose_stream() << "failed checking " << c->id() << ": " << *c << "\n";);
|
||||
|
|
|
@ -2358,6 +2358,14 @@ namespace sat {
|
|||
idx--;
|
||||
}
|
||||
reset_unmark(old_size);
|
||||
if (m_core.size() > 1) {
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < m_core.size(); ++i) {
|
||||
if (lvl(m_core[i]) > 0) m_core[j++] = m_core[i];
|
||||
}
|
||||
m_core.shrink(j);
|
||||
}
|
||||
|
||||
if (m_config.m_core_minimize) {
|
||||
if (m_min_core_valid && m_min_core.size() < m_core.size()) {
|
||||
IF_VERBOSE(1, verbose_stream() << "(sat.updating core " << m_min_core.size() << " " << m_core.size() << ")\n";);
|
||||
|
|
|
@ -18,6 +18,7 @@ Notes:
|
|||
--*/
|
||||
|
||||
|
||||
#include "util/gparams.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_translation.h"
|
||||
#include "ast/ast_util.h"
|
||||
|
@ -584,7 +585,9 @@ private:
|
|||
}
|
||||
|
||||
bool internalize_var(expr* v, sat::bool_var_vector& bvars) {
|
||||
obj_map<func_decl, expr*> const& const2bits = m_bb_rewriter->const2bits();
|
||||
obj_map<func_decl, expr*> const2bits;
|
||||
ptr_vector<func_decl> newbits;
|
||||
m_bb_rewriter->end_rewrite(const2bits, newbits);
|
||||
expr* bv;
|
||||
bv_util bvutil(m);
|
||||
bool internalized = false;
|
||||
|
@ -803,12 +806,13 @@ private:
|
|||
}
|
||||
TRACE("sat", model_smt2_pp(tout, m, *mdl, 0););
|
||||
|
||||
// IF_VERBOSE(0, model_smt2_pp(verbose_stream() << "after\n", m, *mdl, 0););
|
||||
|
||||
#if 0
|
||||
IF_VERBOSE(0, verbose_streamm() << "Verifying solution\n";);
|
||||
if (!gparams::get().get_bool("model_validate", false)) return;
|
||||
IF_VERBOSE(0, verbose_stream() << "Verifying solution\n";);
|
||||
model_evaluator eval(*mdl);
|
||||
eval.set_model_completion(false);
|
||||
bool all_true = true;
|
||||
//unsigned i = 0;
|
||||
for (expr * f : m_fmls) {
|
||||
expr_ref tmp(m);
|
||||
eval(f, tmp);
|
||||
|
@ -819,19 +823,21 @@ private:
|
|||
IF_VERBOSE(0, verbose_stream() << "failed to verify: " << mk_pp(f, m) << "\n";);
|
||||
all_true = false;
|
||||
}
|
||||
else {
|
||||
VERIFY(m.is_true(tmp));
|
||||
}
|
||||
//IF_VERBOSE(0, verbose_stream() << (i++) << ": " << mk_pp(f, m) << "\n");
|
||||
}
|
||||
if (!all_true) {
|
||||
IF_VERBOSE(0, verbose_stream() << m_params << "\n";);
|
||||
IF_VERBOSE(0, m_sat_mc->display(verbose_stream() << "sat mc\n"););
|
||||
IF_VERBOSE(0, if (m_mcs.back()) m_mcs.back()->display(verbose_stream() << "mc0\n"););
|
||||
IF_VERBOSE(0, verbose_stream() << m_params << "\n");
|
||||
IF_VERBOSE(0, m_sat_mc->display(verbose_stream() << "sat mc\n"));
|
||||
IF_VERBOSE(0, if (m_mcs.back()) m_mcs.back()->display(verbose_stream() << "mc0\n"));
|
||||
//IF_VERBOSE(0, m_solver.display(verbose_stream()));
|
||||
IF_VERBOSE(0, for (auto const& kv : m_map) verbose_stream() << mk_pp(kv.m_key, m) << " |-> " << kv.m_value << "\n";);
|
||||
IF_VERBOSE(0, for (auto const& kv : m_map) verbose_stream() << mk_pp(kv.m_key, m) << " |-> " << kv.m_value << "\n");
|
||||
}
|
||||
else {
|
||||
IF_VERBOSE(0, verbose_stream() << "solution verified\n");
|
||||
// IF_VERBOSE(0, if (m_mcs.back()) m_mcs.back()->display(verbose_stream() << "mcs\n"));
|
||||
// IF_VERBOSE(0, if (m_sat_mc) m_sat_mc->display(verbose_stream() << "sat_mc\n"));
|
||||
// IF_VERBOSE(0, model_smt2_pp(verbose_stream() << "after\n", m, *mdl, 0););
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue