mirror of
https://github.com/Z3Prover/z3
synced 2025-08-23 19:47:52 +00:00
convert reduce-args to a simplifier
- convert reduce-args to a simplifier. Currently exposed as reduce-args2 tactic until the old tactic code gets removed. - bug fixes in model_reconstruction trail - allow multiple defs to be added with same pool of removed formulas - fix tracking of function symbols instead of expressions to filter replay - add nla_divisions to track (cheap) divisibility lemmas. -
This commit is contained in:
parent
246d6f7b77
commit
8ea49eed8e
23 changed files with 740 additions and 92 deletions
65
src/math/lp/nla_divisions.cpp
Normal file
65
src/math/lp/nla_divisions.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*++
|
||||
Copyright (c) 2017 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
nla_divisions.cpp
|
||||
|
||||
Author:
|
||||
Lev Nachmanson (levnach)
|
||||
Nikolaj Bjorner (nbjorner)
|
||||
|
||||
Description:
|
||||
|
||||
Check divisions
|
||||
|
||||
--*/
|
||||
#include "math/lp/nla_core.h"
|
||||
|
||||
namespace nla {
|
||||
|
||||
void divisions::add_idivision(lpvar r, lpvar x, lpvar y) {
|
||||
m_idivisions.push_back({r, x, y});
|
||||
m_core.trail().push(push_back_vector(m_idivisions));
|
||||
}
|
||||
|
||||
typedef lp::lar_term term;
|
||||
|
||||
// y1 >= y2 > 0 & x1 <= x2 => x1/y1 <= x2/y2
|
||||
// y2 <= y1 < 0 & x1 >= x2 => x1/y1 <= x2/y2
|
||||
void divisions::check(vector<lemma>& lemmas) {
|
||||
core& c = m_core;
|
||||
if (c.use_nra_model())
|
||||
return;
|
||||
|
||||
for (auto const & [r, x, y] : m_idivisions) {
|
||||
auto xval = c.val(x);
|
||||
auto yval = c.val(y);
|
||||
auto rval = c.val(r);
|
||||
if (!c.var_is_int(x))
|
||||
continue;
|
||||
if (yval == 0)
|
||||
continue;
|
||||
// idiv semantics
|
||||
if (rval == div(xval, yval))
|
||||
continue;
|
||||
for (auto const& [r2, x2, y2] : m_idivisions) {
|
||||
if (r2 == r)
|
||||
continue;
|
||||
auto x2val = c.val(x2);
|
||||
auto y2val = c.val(y2);
|
||||
auto r2val = c.val(r2);
|
||||
if (yval >= y2val && y2val > 0 && xval <= x2val && rval > r2val) {
|
||||
new_lemma lemma(c, "y1 >= y2 > 0 & x1 <= x2 => x1/y1 <= x2/y2");
|
||||
lemma |= ineq(term(y, rational(-1), y2), llc::LT, rational::zero());
|
||||
lemma |= ineq(y2, llc::LE, rational::zero());
|
||||
lemma |= ineq(term(x, rational(-1), x2), llc::GT, rational::zero());
|
||||
lemma |= ineq(term(r, rational(-1), r2), llc::LE, rational::zero());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue