mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 22:23:22 +00:00
before changes is basic_sign_lemma
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
1230b46008
commit
3441f565b2
4 changed files with 22 additions and 17 deletions
|
@ -38,11 +38,11 @@ bool assertions_enabled();
|
||||||
#include "util/error_codes.h"
|
#include "util/error_codes.h"
|
||||||
#include "util/warning.h"
|
#include "util/warning.h"
|
||||||
|
|
||||||
//#ifdef Z3DEBUG
|
#ifdef Z3DEBUG
|
||||||
//#define DEBUG_CODE(CODE) { CODE } ((void) 0)
|
#define DEBUG_CODE(CODE) { CODE } ((void) 0)
|
||||||
//#else
|
#else
|
||||||
#define DEBUG_CODE(CODE) ((void) 0)
|
#define DEBUG_CODE(CODE) ((void) 0)
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
|
|
|
@ -684,6 +684,7 @@ struct solver::imp {
|
||||||
bool basic_sign_lemma_on_mon(unsigned i){
|
bool basic_sign_lemma_on_mon(unsigned i){
|
||||||
TRACE("nla_solver", tout << "i = " << i << ", mon = "; print_monomial_with_vars(m_monomials[i], tout););
|
TRACE("nla_solver", tout << "i = " << i << ", mon = "; print_monomial_with_vars(m_monomials[i], tout););
|
||||||
const monomial& m = m_monomials[i];
|
const monomial& m = m_monomials[i];
|
||||||
|
|
||||||
for (unsigned n : equiv_monomials(m, [this](lpvar j) {return &abs_eq_vars(j);},
|
for (unsigned n : equiv_monomials(m, [this](lpvar j) {return &abs_eq_vars(j);},
|
||||||
[this](const unsigned_vector& key) {return find_monomial(key);})
|
[this](const unsigned_vector& key) {return find_monomial(key);})
|
||||||
) {
|
) {
|
||||||
|
@ -716,6 +717,7 @@ struct solver::imp {
|
||||||
-ab = a(-b)
|
-ab = a(-b)
|
||||||
*/
|
*/
|
||||||
bool basic_sign_lemma() {
|
bool basic_sign_lemma() {
|
||||||
|
TRACE("nla_solver", tout << "m_to_refine.size = " << m_to_refine.size(););
|
||||||
for (unsigned i : m_to_refine){
|
for (unsigned i : m_to_refine){
|
||||||
if (basic_sign_lemma_on_mon(i))
|
if (basic_sign_lemma_on_mon(i))
|
||||||
return true;
|
return true;
|
||||||
|
@ -1177,13 +1179,13 @@ struct solver::imp {
|
||||||
|
|
||||||
// x is equivalent to y if x = +- y
|
// x is equivalent to y if x = +- y
|
||||||
void init_vars_equivalence() {
|
void init_vars_equivalence() {
|
||||||
TRACE("nla_solver",);
|
|
||||||
SASSERT(m_vars_equivalence.empty());
|
SASSERT(m_vars_equivalence.empty());
|
||||||
collect_equivs();
|
collect_equivs();
|
||||||
m_vars_equivalence.create_tree();
|
m_vars_equivalence.create_tree();
|
||||||
for (lpvar j = 0; j < m_lar_solver.number_of_vars(); j++) {
|
for (lpvar j = 0; j < m_lar_solver.number_of_vars(); j++) {
|
||||||
m_vars_equivalence.register_var(j, vvr(j));
|
m_vars_equivalence.register_var(j, vvr(j));
|
||||||
}
|
}
|
||||||
|
TRACE("nla_solver", tout << "number of equivs = " << m_vars_equivalence.size(););
|
||||||
|
|
||||||
SASSERT((m_lar_solver.settings().random_next() % 100) || tables_are_ok());
|
SASSERT((m_lar_solver.settings().random_next() % 100) || tables_are_ok());
|
||||||
}
|
}
|
||||||
|
@ -1564,6 +1566,7 @@ struct solver::imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool order_lemma() {
|
bool order_lemma() {
|
||||||
|
TRACE("nla_solver", );
|
||||||
for (const auto& rm : m_rm_table.vec()) {
|
for (const auto& rm : m_rm_table.vec()) {
|
||||||
if (check_monomial(m_monomials[rm.orig_index()]))
|
if (check_monomial(m_monomials[rm.orig_index()]))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -21,6 +21,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/lp/lp_utils.h"
|
#include "util/lp/lp_utils.h"
|
||||||
namespace nla {
|
namespace nla {
|
||||||
|
struct index_with_sign {
|
||||||
|
unsigned m_i; // the index
|
||||||
|
rational m_sign; // the sign: -1 or 1
|
||||||
|
index_with_sign(unsigned i, rational sign) : m_i(i), m_sign(sign) {}
|
||||||
|
index_with_sign() {}
|
||||||
|
bool operator==(const index_with_sign& b) {
|
||||||
|
return m_i == b.m_i && m_sign == b.m_sign;
|
||||||
|
}
|
||||||
|
unsigned var() const { return m_i; }
|
||||||
|
const rational& sign() const { return m_sign; }
|
||||||
|
};
|
||||||
|
|
||||||
struct rooted_mon {
|
struct rooted_mon {
|
||||||
svector<lpvar> m_vars;
|
svector<lpvar> m_vars;
|
||||||
index_with_sign m_orig;
|
index_with_sign m_orig;
|
||||||
|
|
|
@ -29,17 +29,6 @@ struct hash_svector {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct index_with_sign {
|
|
||||||
unsigned m_i; // the index
|
|
||||||
rational m_sign; // the sign: -1 or 1
|
|
||||||
index_with_sign(unsigned i, rational sign) : m_i(i), m_sign(sign) {}
|
|
||||||
index_with_sign() {}
|
|
||||||
bool operator==(const index_with_sign& b) {
|
|
||||||
return m_i == b.m_i && m_sign == b.m_sign;
|
|
||||||
}
|
|
||||||
unsigned var() const { return m_i; }
|
|
||||||
const rational& sign() const { return m_sign; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct vars_equivalence {
|
struct vars_equivalence {
|
||||||
|
@ -68,7 +57,7 @@ struct vars_equivalence {
|
||||||
// m_tree is a spanning tree of the graph of equivs represented by m_equivs
|
// m_tree is a spanning tree of the graph of equivs represented by m_equivs
|
||||||
std::unordered_map<unsigned, unsigned> m_tree;
|
std::unordered_map<unsigned, unsigned> m_tree;
|
||||||
// If m_tree[v] == -1 then the variable is a root.
|
// If m_tree[v] == -1 then the variable is a root.
|
||||||
// if m_tree[v] is not equal to -1 then m_equivs[m_tree[v]] = (k, v) or (v, k), that k is the parent of v
|
// if m_tree[v] is not equal to -1 then m_equivs[m_tree[v]] = (k, v) or (v, k), where k is the parent of v
|
||||||
vector<equiv> m_equivs; // all equivalences extracted from constraints
|
vector<equiv> m_equivs; // all equivalences extracted from constraints
|
||||||
std::unordered_map<rational, unsigned_vector> m_vars_by_abs_values;
|
std::unordered_map<rational, unsigned_vector> m_vars_by_abs_values;
|
||||||
std::function<rational(lpvar)> m_vvr;
|
std::function<rational(lpvar)> m_vvr;
|
||||||
|
@ -86,6 +75,7 @@ struct vars_equivalence {
|
||||||
const svector<lpvar>& get_vars_with_the_same_abs_val(const rational& v) const {
|
const svector<lpvar>& get_vars_with_the_same_abs_val(const rational& v) const {
|
||||||
auto it = m_vars_by_abs_values.find(abs(v));
|
auto it = m_vars_by_abs_values.find(abs(v));
|
||||||
SASSERT (it != m_vars_by_abs_values.end());
|
SASSERT (it != m_vars_by_abs_values.end());
|
||||||
|
TRACE("nla_solver", tout << "size of same_abs_vals = " << it->second.size(); );
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue