3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 11:25:51 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-05-09 18:49:00 -07:00
parent f044071f5e
commit 4890c3ce31
7 changed files with 61 additions and 33 deletions

View file

@ -91,7 +91,7 @@ void basics::basic_sign_lemma_model_based_one_mon(const monic& m, int product_si
TRACE("nla_solver_bl", tout << "zero product sign: " << pp_mon(_(), m)<< "\n"; );
generate_zero_lemmas(m);
} else {
new_lemma lemma(c());
new_lemma lemma(c(), __FUNCTION__);
for(lpvar j: m.vars()) {
negate_strict_sign(j);
}
@ -157,7 +157,7 @@ bool basics::basic_sign_lemma(bool derived) {
// the value of the i-th monic has to be equal to the value of the k-th monic modulo sign
// but it is not the case in the model
void basics::generate_sign_lemma(const monic& m, const monic& n, const rational& sign) {
new_lemma lemma(c());
new_lemma lemma(c(), "sign lemma");
TRACE("nla_solver",
tout << "m = " << pp_mon_with_vars(_(), m);
tout << "n = " << pp_mon_with_vars(_(), n);
@ -184,14 +184,14 @@ lpvar basics::find_best_zero(const monic& m, unsigned_vector & fixed_zeros) cons
return zero_j;
}
void basics::add_trival_zero_lemma(lpvar zero_j, const monic& m) {
new_lemma lemma(c());
new_lemma lemma(c(), "x = 0 or x != 0");
c().mk_ineq(zero_j, llc::NE);
c().mk_ineq(m.var(), llc::EQ);
}
void basics::generate_strict_case_zero_lemma(const monic& m, unsigned zero_j, int sign_of_zj) {
TRACE("nla_solver_bl", tout << "sign_of_zj = " << sign_of_zj << "\n";);
// we know all the signs
new_lemma lemma(c());
new_lemma lemma(c(), "strict case 0");
c().mk_ineq(zero_j, (sign_of_zj == 1? llc::GT : llc::LT));
for (unsigned j : m.vars()){
if (j != zero_j) {
@ -201,7 +201,7 @@ void basics::generate_strict_case_zero_lemma(const monic& m, unsigned zero_j, in
negate_strict_sign(m.var());
}
void basics::add_fixed_zero_lemma(const monic& m, lpvar j) {
new_lemma lemma(c());
new_lemma lemma(c(), "fixed zero");
c().explain_fixed_var(j);
c().mk_ineq(m.var(), llc::EQ);
}
@ -229,7 +229,7 @@ bool basics::basic_lemma_for_mon_zero(const monic& rm, const factorization& f) {
return true;
#if 0
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout););
new_lemma lemma(c());
new_lemma lemma(c(), "xy = 0 -> x = 0 or y = 0");
c().explain_fixed_var(var(rm));
std::unordered_set<lpvar> processed;
for (auto j : f) {
@ -247,7 +247,7 @@ bool basics::basic_lemma(bool derived) {
if (derived)
return false;
const auto& mon_inds_to_ref = c().m_to_refine;
TRACE("nla_solver", tout << "mon_inds_to_ref = "; print_vector(mon_inds_to_ref, tout););
TRACE("nla_solver", tout << "mon_inds_to_ref = "; print_vector(mon_inds_to_ref, tout) << "\n";);
unsigned start = c().random();
unsigned sz = mon_inds_to_ref.size();
for (unsigned j = 0; j < sz; ++j) {
@ -309,7 +309,7 @@ bool basics::basic_lemma_for_mon_non_zero_derived(const monic& rm, const factori
if (zero_j == null_lpvar) {
return false;
}
new_lemma lemma(c());
new_lemma lemma(c(), "x = 0 or y = 0 -> xy = 0");
c().explain_fixed_var(zero_j);
c().explain_var_separated_from_zero(var(rm));
explain(rm);
@ -357,7 +357,7 @@ bool basics::basic_lemma_for_mon_neutral_monic_to_factor_derived(const monic& rm
return false;
}
new_lemma lemma(c());
new_lemma lemma(c(), "|xa| = |x| & x != 0 -> |a| = 1");
// mon_var = 0
if (mon_var_is_sep_from_zero)
c().explain_var_separated_from_zero(mon_var);
@ -418,7 +418,7 @@ bool basics::proportion_lemma_derived(const monic& rm, const factorization& fact
}
// if there are no zero factors then |m| >= |m[factor_index]|
void basics::generate_pl_on_mon(const monic& m, unsigned factor_index) {
new_lemma lemma(c());
new_lemma lemma(c(), "generate_pl_on_mon");
unsigned mon_var = m.var();
rational mv = val(mon_var);
rational sm = rational(nla::rat_sign(mv));
@ -448,7 +448,7 @@ void basics::generate_pl(const monic& m, const factorization& fc, int factor_ind
generate_pl_on_mon(m, factor_index);
return;
}
new_lemma lemma(c());
new_lemma lemma(c(), "generate_pl");
int fi = 0;
rational mv = var_val(m);
rational sm = rational(nla::rat_sign(mv));
@ -496,7 +496,7 @@ bool basics::factorization_has_real(const factorization& f) const {
void basics::basic_lemma_for_mon_zero_model_based(const monic& rm, const factorization& f) {
TRACE("nla_solver", c().trace_print_monic_and_factorization(rm, f, tout););
SASSERT(var_val(rm).is_zero()&& ! c().rm_check(rm));
new_lemma lemma(c());
new_lemma lemma(c(), "xy = 0 -> x = 0 or y = 0");
if (!is_separated_from_zero(f)) {
c().mk_ineq(var(rm), llc::NE);
for (auto j : f) {
@ -552,8 +552,10 @@ bool basics::basic_lemma_for_mon_neutral_monic_to_factor_model_based_fm(const mo
if (jl == null_lpvar)
return false;
lpvar not_one_j = null_lpvar;
unsigned num_occs = 0;
for (auto j : m.vars() ) {
if (j == jl) {
++num_occs;
continue;
}
if (abs(val(j)) != rational(1)) {
@ -562,11 +564,14 @@ bool basics::basic_lemma_for_mon_neutral_monic_to_factor_model_based_fm(const mo
}
}
if (num_occs > 1)
return false;
if (not_one_j == null_lpvar) {
return false;
}
new_lemma lemma(c());
new_lemma lemma(c(), __FUNCTION__);
// mon_var = 0
c().mk_ineq(mon_var, llc::EQ);
@ -614,7 +619,7 @@ bool basics::basic_lemma_for_mon_neutral_from_factors_to_monic_model_based_fm(co
}
}
new_lemma lemma(c());
new_lemma lemma(c(), __FUNCTION__);
for (auto j : m.vars()){
if (not_one == j) continue;
c().mk_ineq(j, llc::NE, val(j));
@ -666,7 +671,7 @@ bool basics::basic_lemma_for_mon_neutral_monic_to_factor_model_based(const monic
return false;
}
new_lemma lemma(c());
new_lemma lemma(c(), __FUNCTION__);
// mon_var = 0
c().mk_ineq(mon_var, llc::EQ);
@ -748,7 +753,7 @@ bool basics::basic_lemma_for_mon_neutral_from_factors_to_monic_model_based(const
TRACE("nla_solver_bl", tout << "not_one = " << not_one << "\n";);
new_lemma lemma(c());
new_lemma lemma(c(), __FUNCTION__);
for (auto j : f) {
lpvar var_j = var(j);
@ -780,7 +785,7 @@ void basics::basic_lemma_for_mon_non_zero_model_based_mf(const factorization& f)
}
if (zero_j == null_lpvar) { return; }
new_lemma lemma(c());
new_lemma lemma(c(), __FUNCTION__);
c().mk_ineq(zero_j, llc::NE);
c().mk_ineq(f.mon().var(), llc::EQ);
}