mirror of
https://github.com/Z3Prover/z3
synced 2025-12-04 02:56:44 +00:00
add basic linearization as pre-processing and refinement
This commit is contained in:
parent
a12f4b9686
commit
360de4af03
4 changed files with 298 additions and 99 deletions
|
|
@ -15,11 +15,16 @@ namespace nla {
|
|||
class stellensatz : common {
|
||||
|
||||
class solver {
|
||||
stellensatz &s;
|
||||
scoped_ptr<lp::lar_solver> lra_solver;
|
||||
scoped_ptr<lp::int_solver> int_solver;
|
||||
lbool solve_lra(lp::explanation &ex);
|
||||
lbool solve_lia(lp::explanation &ex);
|
||||
lbool solve_lia(lp::explanation &ex);
|
||||
bool update_values();
|
||||
vector<std::pair<lpvar, rational>> m_to_refine;
|
||||
void saturate_basic_linearize();
|
||||
public:
|
||||
solver(stellensatz &s) : s(s) {};
|
||||
void init();
|
||||
lbool solve(lp::explanation &ex);
|
||||
lp::lar_solver &lra() { return *lra_solver; }
|
||||
|
|
@ -49,6 +54,23 @@ namespace nla {
|
|||
map<unsigned_vector, unsigned, svector_hash<unsigned_hash>, eq> m_vars2mon;
|
||||
u_map<unsigned_vector> m_mon2vars;
|
||||
|
||||
struct resolvent {
|
||||
lp::constraint_index old_ci;
|
||||
lpvar mi;
|
||||
lpvar x;
|
||||
struct eq {
|
||||
bool operator()(resolvent const& a, resolvent const& b) const {
|
||||
return a.old_ci == b.old_ci && a.mi == b.mi && a.x == b.x;
|
||||
}
|
||||
};
|
||||
struct hash {
|
||||
unsigned operator()(resolvent const& a) const {
|
||||
return hash_u_u(a.old_ci, hash_u_u(a.mi, a.x));
|
||||
}
|
||||
};
|
||||
};
|
||||
hashtable<resolvent, resolvent::hash, resolvent::eq> m_resolvents;
|
||||
|
||||
// initialization
|
||||
void init_solver();
|
||||
void init_vars();
|
||||
|
|
@ -59,14 +81,27 @@ namespace nla {
|
|||
|
||||
// additional variables and monomials and constraints
|
||||
lpvar add_monomial(svector<lp::lpvar> const& vars);
|
||||
lp::constraint_index add_ineq(bound_justifications const& bounds, lp::lar_term const &t, lp::lconstraint_kind k, rational const &rhs);
|
||||
lp::constraint_index add_ineq(bound_justifications const &bounds, lpvar j, lp::lconstraint_kind k,
|
||||
rational const &rhs);
|
||||
|
||||
bool is_int(svector<lp::lpvar> const& vars) const;
|
||||
rational value(lp::lar_term const &t) const;
|
||||
rational value(svector<lpvar> const &prod) const;
|
||||
lpvar add_var(bool is_int);
|
||||
lbool add_bounds(svector<lpvar> const &vars, bound_justifications &bounds);
|
||||
void saturate_constraints();
|
||||
void saturate_constraint(lp::constraint_index con_id, lp::lpvar mi, lpvar x);
|
||||
void saturate_basic_linearize();
|
||||
void saturate_basic_linearize(lpvar j, rational const &val_j, svector<lpvar> const &vars,
|
||||
rational const &val_vars);
|
||||
void saturate_signs(lpvar j, rational const& val_j, svector<lpvar> const& vars, rational const& val_vars);
|
||||
void saturate_units(lpvar j, svector<lpvar> const &vars);
|
||||
void saturate_monotonicity(lpvar j, rational const &val_j, svector<lpvar> const &vars, rational const &val_vars);
|
||||
void saturate_monotonicity(lpvar j, rational const & val_j, lpvar x, int sign_x, lpvar y, int sign_y);
|
||||
void saturate_monotonicity(lpvar j, rational const &val_j, lpvar x, lpvar y);
|
||||
|
||||
void saturate_squares(lpvar j, rational const &val_j, svector<lpvar> const &vars);
|
||||
|
||||
|
||||
// lemmas
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue