3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

working on pre-processing

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-12-26 09:53:33 -08:00
parent 70c4432bb4
commit 0641c4f694
8 changed files with 467 additions and 151 deletions

View file

@ -89,14 +89,14 @@ public:
bool is_at_least_k(expr *a) const { return is_app(a) && is_at_least_k(to_app(a)->get_decl()); }
bool is_at_least_k(app *a, rational& k) const;
rational get_k(func_decl *a) const;
rational get_k(app *a) const { return get_k(a->get_decl()); }
rational get_k(expr *a) const { return get_k(to_app(a)->get_decl()); }
bool is_le(func_decl *a) const;
bool is_le(expr *a) const { return is_app(a) && is_le(to_app(a)->get_decl()); }
bool is_le(app* a, rational& k) const;
bool is_ge(func_decl* a) const;
bool is_ge(expr* a) const { return is_app(a) && is_ge(to_app(a)->get_decl()); }
bool is_ge(app* a, rational& k) const;
rational get_coeff(app* a, unsigned index) const { return get_coeff(a->get_decl(), index); }
rational get_coeff(expr* a, unsigned index) const { return get_coeff(to_app(a)->get_decl(), index); }
rational get_coeff(func_decl* a, unsigned index) const;
private:
rational to_rational(parameter const& p) const;

View file

@ -36,7 +36,7 @@ void pb_rewriter_util<PBU>::display(std::ostream& out, typename PBU::args_t& arg
template<typename PBU>
void pb_rewriter_util<PBU>::unique(typename PBU::args_t& args, typename PBU::numeral& k) {
TRACE("pb", display(tout << "pre-unique:", args, k););
TRACE("pb_verbose", display(tout << "pre-unique:", args, k););
for (unsigned i = 0; i < args.size(); ++i) {
if (m_util.is_negated(args[i].first)) {
args[i].first = m_util.negate(args[i].first);
@ -73,9 +73,7 @@ void pb_rewriter_util<PBU>::unique(typename PBU::args_t& args, typename PBU::num
args[i] = args[j];
}
}
if (i + 1 < args.size()) {
args.resize(i+1);
}
args.resize(i+1);
// remove 0s.
for (i = 0, j = 0; j < args.size(); ++j) {
@ -86,22 +84,22 @@ void pb_rewriter_util<PBU>::unique(typename PBU::args_t& args, typename PBU::num
++i;
}
}
if (i < args.size()) {
args.resize(i);
}
TRACE("pb", display(tout << "post-unique:", args, k););
args.resize(i);
TRACE("pb_verbose", display(tout << "post-unique:", args, k););
}
template<typename PBU>
lbool pb_rewriter_util<PBU>::normalize(typename PBU::args_t& args, typename PBU::numeral& k) {
TRACE("pb", display(tout << "pre-normalize:", args, k););
TRACE("pb_verbose", display(tout << "pre-normalize:", args, k););
DEBUG_CODE(
bool found = false;
for (unsigned i = 0; !found && i < args.size(); ++i) {
found = args[i].second.is_zero();
}
if (found) display(verbose_stream(), args, k);
SASSERT(!found););
bool found = false;
for (unsigned i = 0; !found && i < args.size(); ++i) {
found = args[i].second.is_zero();
}
if (found) display(std::cout, args, k);
SASSERT(!found);
//
// Ensure all coefficients are positive:
// c*l + y >= k