3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-27 22:47:55 +00:00

merge with unstable

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2014-10-05 10:37:55 -07:00
commit c706e91019
18 changed files with 49 additions and 38 deletions

View file

@ -4117,7 +4117,6 @@ namespace polynomial {
polynomial_ref H(m_wrapper), C(m_wrapper); polynomial_ref H(m_wrapper), C(m_wrapper);
polynomial_ref lc_H(m_wrapper); polynomial_ref lc_H(m_wrapper);
unsigned min_deg_q = UINT_MAX; unsigned min_deg_q = UINT_MAX;
var next_x = vars[idx+1];
unsigned counter = 0; unsigned counter = 0;
for (;; counter++) { for (;; counter++) {
@ -4137,7 +4136,7 @@ namespace polynomial {
var q_var = max_var(q); var q_var = max_var(q);
unsigned deg_q = q_var == null_var ? 0 : degree(q, q_var); unsigned deg_q = q_var == null_var ? 0 : degree(q, q_var);
TRACE("mgcd_detail", tout << "counter: " << counter << "\nidx: " << idx << "\nq: " << q << "\ndeg_q: " << deg_q << "\nmin_deg_q: " << TRACE("mgcd_detail", tout << "counter: " << counter << "\nidx: " << idx << "\nq: " << q << "\ndeg_q: " << deg_q << "\nmin_deg_q: " <<
min_deg_q << "\nnext_x: x" << next_x << "\nmax_var(q): " << q_var << "\n";); min_deg_q << "\nnext_x: x" << vars[idx+1] << "\nmax_var(q): " << q_var << "\n";);
if (deg_q < min_deg_q) { if (deg_q < min_deg_q) {
TRACE("mgcd_detail", tout << "reseting...\n";); TRACE("mgcd_detail", tout << "reseting...\n";);
counter = 0; counter = 0;
@ -5113,10 +5112,9 @@ namespace polynomial {
monomial const * m_r = R.m(max_R); monomial const * m_r = R.m(max_R);
numeral const & a_r = R.a(max_R); numeral const & a_r = R.a(max_R);
monomial * m_r_q = 0; monomial * m_r_q = 0;
bool q_div_r = div(m_r, m_q, m_r_q); VERIFY(div(m_r, m_q, m_r_q));
TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n"; TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n";
if (m_r_q) { tout << "m_r_q: "; m_r_q->display(tout); tout << "\n"; }); if (m_r_q) { tout << "m_r_q: "; m_r_q->display(tout); tout << "\n"; });
SASSERT(q_div_r);
m_r_q_ref = m_r_q; m_r_q_ref = m_r_q;
m_manager.div(a_r, a_q, a_r_q); m_manager.div(a_r, a_q, a_r_q);
C.add(a_r_q, m_r_q); // C <- C + (a_r/a_q)*(m_r/m_q) C.add(a_r_q, m_r_q); // C <- C + (a_r/a_q)*(m_r/m_q)

View file

@ -68,6 +68,9 @@ namespace sat {
m_restart_factor = p.restart_factor(); m_restart_factor = p.restart_factor();
m_random_freq = p.random_freq(); m_random_freq = p.random_freq();
m_random_seed = p.random_seed();
if (m_random_seed == 0)
m_random_seed = _p.get_uint("random_seed", 0);
m_burst_search = p.burst_search(); m_burst_search = p.burst_search();

View file

@ -53,6 +53,7 @@ namespace sat {
unsigned m_restart_initial; unsigned m_restart_initial;
double m_restart_factor; // for geometric case double m_restart_factor; // for geometric case
double m_random_freq; double m_random_freq;
unsigned m_random_seed;
unsigned m_burst_search; unsigned m_burst_search;
unsigned m_max_conflicts; unsigned m_max_conflicts;

View file

@ -9,6 +9,7 @@ def_module_params('sat',
('restart.initial', UINT, 100, 'initial restart (number of conflicts)'), ('restart.initial', UINT, 100, 'initial restart (number of conflicts)'),
('restart.factor', DOUBLE, 1.5, 'restart increment factor for geometric strategy'), ('restart.factor', DOUBLE, 1.5, 'restart increment factor for geometric strategy'),
('random_freq', DOUBLE, 0.01, 'frequency of random case splits'), ('random_freq', DOUBLE, 0.01, 'frequency of random case splits'),
('random_seed', UINT, 0, 'random seed'),
('burst_search', UINT, 100, 'number of conflicts before first global simplification'), ('burst_search', UINT, 100, 'number of conflicts before first global simplification'),
('max_conflicts', UINT, UINT_MAX, 'maximum number of conflicts'), ('max_conflicts', UINT, UINT_MAX, 'maximum number of conflicts'),
('gc', SYMBOL, 'glue_psm', 'garbage collection strategy: psm, glue, glue_psm, dyn_psm'), ('gc', SYMBOL, 'glue_psm', 'garbage collection strategy: psm, glue, glue_psm, dyn_psm'),

View file

@ -922,6 +922,7 @@ namespace sat {
if (s.is_external(l.var()) || s.was_eliminated(l.var())) if (s.is_external(l.var()) || s.was_eliminated(l.var()))
return; return;
{ {
m_to_remove.reset(); m_to_remove.reset();
{ {
clause_use_list & occs = s.m_use_list.get(l); clause_use_list & occs = s.m_use_list.get(l);
@ -1341,6 +1342,7 @@ namespace sat {
} }
TRACE("resolution", tout << "found var to eliminate, before: " << before_clauses << " after: " << after_clauses << "\n";); TRACE("resolution", tout << "found var to eliminate, before: " << before_clauses << " after: " << after_clauses << "\n";);
// eliminate variable // eliminate variable
model_converter::entry & mc_entry = s.m_mc.mk(model_converter::ELIM_VAR, v); model_converter::entry & mc_entry = s.m_mc.mk(model_converter::ELIM_VAR, v);
save_clauses(mc_entry, m_pos_cls); save_clauses(mc_entry, m_pos_cls);

View file

@ -49,7 +49,7 @@ namespace sat {
m_qhead(0), m_qhead(0),
m_scope_lvl(0), m_scope_lvl(0),
m_params(p) { m_params(p) {
m_config.updt_params(p); updt_params(p);
m_conflicts_since_gc = 0; m_conflicts_since_gc = 0;
m_conflicts = 0; m_conflicts = 0;
m_next_simplify = 0; m_next_simplify = 0;
@ -2358,7 +2358,7 @@ namespace sat {
m_asymm_branch.updt_params(p); m_asymm_branch.updt_params(p);
m_probing.updt_params(p); m_probing.updt_params(p);
m_scc.updt_params(p); m_scc.updt_params(p);
m_rand.set_seed(p.get_uint("random_seed", 0)); m_rand.set_seed(m_config.m_random_seed);
} }
void solver::collect_param_descrs(param_descrs & d) { void solver::collect_param_descrs(param_descrs & d) {

View file

@ -1616,6 +1616,8 @@ namespace smt {
unsigned qhead = m_qhead; unsigned qhead = m_qhead;
if (!bcp()) if (!bcp())
return false; return false;
if (m_cancel_flag)
return true;
SASSERT(!inconsistent()); SASSERT(!inconsistent());
propagate_relevancy(qhead); propagate_relevancy(qhead);
if (inconsistent()) if (inconsistent())
@ -3950,7 +3952,7 @@ namespace smt {
m_fingerprints.display(tout); m_fingerprints.display(tout);
); );
failure fl = get_last_search_failure(); failure fl = get_last_search_failure();
if (fl == TIMEOUT || fl == MEMOUT || fl == CANCELED || fl == NUM_CONFLICTS || fl == THEORY) { if (fl == TIMEOUT || fl == MEMOUT || fl == CANCELED || fl == NUM_CONFLICTS) {
// don't generate model. // don't generate model.
return; return;
} }

View file

@ -1274,8 +1274,10 @@ namespace smt {
} }
} }
while (m_final_check_idx != old_idx); while (m_final_check_idx != old_idx);
if (result == FC_DONE && m_found_unsupported_op) if (result == FC_DONE && m_found_unsupported_op) {
TRACE("arith", tout << "Found unsupported operation\n";);
result = FC_GIVEUP; result = FC_GIVEUP;
}
return result; return result;
} }

View file

@ -1299,8 +1299,10 @@ namespace smt {
} }
tout << "max: " << max << ", min: " << min << "\n";); tout << "max: " << max << ", min: " << min << "\n";);
if (m_params.m_arith_ignore_int) if (m_params.m_arith_ignore_int) {
TRACE("arith", tout << "Ignore int: give up\n";);
return FC_GIVEUP; return FC_GIVEUP;
}
if (!gcd_test()) if (!gcd_test())
return FC_CONTINUE; return FC_CONTINUE;

View file

@ -2314,13 +2314,15 @@ namespace smt {
return FC_DONE; return FC_DONE;
} }
if (!m_params.m_nl_arith) if (!m_params.m_nl_arith) {
TRACE("non_linear", tout << "Non-linear is not enabled\n";);
return FC_GIVEUP; return FC_GIVEUP;
}
TRACE("process_non_linear", display(tout);); TRACE("process_non_linear", display(tout););
if (m_nl_rounds > m_params.m_nl_arith_rounds) { if (m_nl_rounds > m_params.m_nl_arith_rounds) {
TRACE("non_linear", tout << "GIVE UP non linear problem...\n";); TRACE("non_linear", tout << "GIVEUP non linear problem...\n";);
IF_VERBOSE(3, verbose_stream() << "Max. non linear arithmetic rounds. Increase threshold using NL_ARITH_ROUNDS=<limit>\n";); IF_VERBOSE(3, verbose_stream() << "Max. non linear arithmetic rounds. Increase threshold using NL_ARITH_ROUNDS=<limit>\n";);
return FC_GIVEUP; return FC_GIVEUP;
} }

View file

@ -1066,11 +1066,8 @@ template<typename Ext>
void theory_diff_logic<Ext>::get_eq_antecedents( void theory_diff_logic<Ext>::get_eq_antecedents(
theory_var v1, theory_var v2, unsigned timestamp, conflict_resolution & cr) { theory_var v1, theory_var v2, unsigned timestamp, conflict_resolution & cr) {
imp_functor functor(cr); imp_functor functor(cr);
bool r; VERIFY(m_graph.find_shortest_zero_edge_path(v1, v2, timestamp, functor));
r = m_graph.find_shortest_zero_edge_path(v1, v2, timestamp, functor); VERIFY(m_graph.find_shortest_zero_edge_path(v2, v1, timestamp, functor));
SASSERT(r);
r = m_graph.find_shortest_zero_edge_path(v2, v1, timestamp, functor);
SASSERT(r);
} }
template<typename Ext> template<typename Ext>

View file

@ -138,9 +138,8 @@ bool bit_vector::operator==(bit_vector const & source) const {
bit_vector & bit_vector::operator|=(bit_vector const & source) { bit_vector & bit_vector::operator|=(bit_vector const & source) {
if (size() < source.size()) if (size() < source.size())
resize(source.size(), false); resize(source.size(), false);
unsigned n1 = num_words();
unsigned n2 = source.num_words(); unsigned n2 = source.num_words();
SASSERT(n2 <= n1); SASSERT(n2 <= num_words());
unsigned bit_rest = source.m_num_bits % 32; unsigned bit_rest = source.m_num_bits % 32;
if (bit_rest == 0) { if (bit_rest == 0) {
unsigned i = 0; unsigned i = 0;

View file

@ -55,12 +55,12 @@ class cmd_exception : public default_exception {
} }
public: public:
cmd_exception(char const * msg):default_exception(msg), m_line(-1), m_pos(-1) {} cmd_exception(char const * msg):default_exception(msg), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg):default_exception(msg.c_str()), m_line(-1), m_pos(-1) {} cmd_exception(std::string const & msg):default_exception(msg), m_line(-1), m_pos(-1) {}
cmd_exception(std::string const & msg, int line, int pos):default_exception(msg.c_str()), m_line(line), m_pos(pos) {} cmd_exception(std::string const & msg, int line, int pos):default_exception(msg), m_line(line), m_pos(pos) {}
cmd_exception(char const * msg, symbol const & s): cmd_exception(char const * msg, symbol const & s):
default_exception(compose(msg,s).c_str()),m_line(-1),m_pos(-1) {} default_exception(compose(msg,s)),m_line(-1),m_pos(-1) {}
cmd_exception(char const * msg, symbol const & s, int line, int pos): cmd_exception(char const * msg, symbol const & s, int line, int pos):
default_exception(compose(msg,s).c_str()),m_line(line),m_pos(pos) {} default_exception(compose(msg,s)),m_line(line),m_pos(pos) {}
bool has_pos() const { return m_line >= 0; } bool has_pos() const { return m_line >= 0; }
int line() const { SASSERT(has_pos()); return m_line; } int line() const { SASSERT(has_pos()); return m_line; }

View file

@ -120,7 +120,8 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
// double === mpf(11, 53) // double === mpf(11, 53)
COMPILE_TIME_ASSERT(sizeof(double) == 8); COMPILE_TIME_ASSERT(sizeof(double) == 8);
uint64 raw = *reinterpret_cast<uint64*>(&value); uint64 raw;
memcpy(&raw, &value, sizeof(double));
bool sign = (raw >> 63) != 0; bool sign = (raw >> 63) != 0;
int64 e = ((raw & 0x7FF0000000000000ull) >> 52) - 1023; int64 e = ((raw & 0x7FF0000000000000ull) >> 52) - 1023;
uint64 s = raw & 0x000FFFFFFFFFFFFFull; uint64 s = raw & 0x000FFFFFFFFFFFFFull;
@ -155,7 +156,8 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, float value) {
// single === mpf(8, 24) // single === mpf(8, 24)
COMPILE_TIME_ASSERT(sizeof(float) == 4); COMPILE_TIME_ASSERT(sizeof(float) == 4);
unsigned int raw = *reinterpret_cast<unsigned int*>(&value); unsigned int raw;
memcpy(&raw, &value, sizeof(float));
bool sign = (raw >> 31) != 0; bool sign = (raw >> 31) != 0;
signed int e = ((raw & 0x7F800000) >> 23) - 127; signed int e = ((raw & 0x7F800000) >> 23) - 127;
unsigned int s = raw & 0x007FFFFF; unsigned int s = raw & 0x007FFFFF;
@ -1288,7 +1290,9 @@ double mpf_manager::to_double(mpf const & x) {
if (x.sign) if (x.sign)
raw = raw | 0x8000000000000000ull; raw = raw | 0x8000000000000000ull;
return *reinterpret_cast<double*>(&raw); double ret;
memcpy(&ret, &raw, sizeof(double));
return ret;
} }
float mpf_manager::to_float(mpf const & x) { float mpf_manager::to_float(mpf const & x) {
@ -1318,7 +1322,9 @@ float mpf_manager::to_float(mpf const & x) {
if (x.sign) if (x.sign)
raw = raw | 0x80000000; raw = raw | 0x80000000;
return *reinterpret_cast<float*>(&raw); float ret;
memcpy(&ret, &raw, sizeof(float));
return ret;
} }
bool mpf_manager::is_nan(mpf const & x) { bool mpf_manager::is_nan(mpf const & x) {
@ -1679,7 +1685,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
TRACE("mpf_dbg", tout << "OVF2 = " << OVF2 << std::endl;); TRACE("mpf_dbg", tout << "OVF2 = " << OVF2 << std::endl;);
TRACE("mpf_dbg", tout << "o_has_max_exp = " << o_has_max_exp << std::endl;); TRACE("mpf_dbg", tout << "o_has_max_exp = " << o_has_max_exp << std::endl;);
if (!OVFen && SIGovf && o_has_max_exp) if (!OVFen && OVF2)
mk_round_inf(rm, o); mk_round_inf(rm, o);
else { else {
const mpz & p = m_powers2(o.sbits-1); const mpz & p = m_powers2(o.sbits-1);

View file

@ -43,8 +43,7 @@ mpff_manager::mpff_manager(unsigned prec, unsigned initial_capacity) {
for (unsigned i = 0; i < MPFF_NUM_BUFFERS; i++) for (unsigned i = 0; i < MPFF_NUM_BUFFERS; i++)
m_buffers[i].resize(2 * prec, 0); m_buffers[i].resize(2 * prec, 0);
// Reserve space for zero // Reserve space for zero
unsigned zero_sig_idx = m_id_gen.mk(); VERIFY(m_id_gen.mk() == 0);
SASSERT(zero_sig_idx == 0);
set(m_one, 1); set(m_one, 1);
} }

View file

@ -38,8 +38,7 @@ mpfx_manager::mpfx_manager(unsigned int_sz, unsigned frac_sz, unsigned initial_c
m_buffer0.resize(2*m_total_sz, 0); m_buffer0.resize(2*m_total_sz, 0);
m_buffer1.resize(2*m_total_sz, 0); m_buffer1.resize(2*m_total_sz, 0);
m_buffer2.resize(2*m_total_sz, 0); m_buffer2.resize(2*m_total_sz, 0);
unsigned zero_sig_idx = m_id_gen.mk(); VERIFY(m_id_gen.mk() == 0);
SASSERT(zero_sig_idx == 0);
set(m_one, 1); set(m_one, 1);
} }

View file

@ -235,6 +235,9 @@ void mpq_manager<SYNCH>::set(mpq & a, char const * val) {
SASSERT(str[0] - '0' <= 9); SASSERT(str[0] - '0' <= 9);
exp = (10*exp) + (str[0] - '0'); exp = (10*exp) + (str[0] - '0');
} }
else if ('/' == str[0]) {
throw default_exception("mixing rational/scientific notation");
}
TRACE("mpq_set", tout << "[exp]: " << exp << ", str[0]: " << (str[0] - '0') << std::endl;); TRACE("mpq_set", tout << "[exp]: " << exp << ", str[0]: " << (str[0] - '0') << std::endl;);
++str; ++str;
} }

View file

@ -24,9 +24,6 @@ Revision History:
#include<iostream> #include<iostream>
#include<climits> #include<climits>
#include<limits> #include<limits>
#ifdef _MSC_VER
#include<intrin.h>
#endif
#ifndef SIZE_MAX #ifndef SIZE_MAX
#define SIZE_MAX std::numeric_limits<std::size_t>::max() #define SIZE_MAX std::numeric_limits<std::size_t>::max()
@ -99,9 +96,7 @@ COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
// Return the number of 1 bits in v. // Return the number of 1 bits in v.
static inline unsigned get_num_1bits(unsigned v) { static inline unsigned get_num_1bits(unsigned v) {
#ifdef _MSC_VER #ifdef __GNUC__
return __popcnt(v);
#elif defined(__GNUC__)
return __builtin_popcount(v); return __builtin_popcount(v);
#else #else
#ifdef Z3DEBUG #ifdef Z3DEBUG