3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-22 16:45:31 +00:00
This commit is contained in:
Nikolaj Bjorner 2017-03-25 19:32:17 +01:00
commit 0c4b792dac
9 changed files with 39 additions and 57 deletions

View file

@ -189,10 +189,9 @@ bool rewriter_tpl<Config>::constant_fold(app * t, frame & fr) {
result_stack().shrink(fr.m_spos);
result_stack().push_back(arg);
fr.m_state = REWRITE_BUILTIN;
unsigned max_depth = fr.m_max_depth;
if (visit<false>(arg, fr.m_max_depth)) {
m_r = result_stack().back();
result_stack().pop_back();
result_stack().pop_back();
result_stack().pop_back();
result_stack().push_back(m_r);
cache_result<false>(t, m_r, m_pr, fr.m_cache_result);

View file

@ -739,8 +739,11 @@ void cmd_context::insert_rec_fun(func_decl* f, expr_ref_vector const& binding, s
lhs = m().mk_app(f, binding.size(), binding.c_ptr());
eq = m().mk_eq(lhs, e);
if (!ids.empty()) {
expr* pat = m().mk_pattern(lhs);
eq = m().mk_forall(ids.size(), f->get_domain(), ids.c_ptr(), eq, 0, m().rec_fun_qid(), symbol::null, 1, &pat);
if (!is_app(e)) {
throw cmd_exception("Z3 only supports recursive definitions that are proper terms (not binders or variables)");
}
expr* pats[2] = { m().mk_pattern(lhs), m().mk_pattern(to_app(e)) };
eq = m().mk_forall(ids.size(), f->get_domain(), ids.c_ptr(), eq, 0, m().rec_fun_qid(), symbol::null, 2, pats);
}
//

View file

@ -101,7 +101,7 @@ namespace sat {
if (!it->is_binary_non_learned_clause())
continue;
literal l2 = it->get_literal();
if (l.index() > l2.index())
if (l.index() > l2.index())
continue;
mk_clause_core(l, l2);
}
@ -223,7 +223,7 @@ namespace sat {
if (propagate_bin_clause(l1, l2)) {
if (scope_lvl() == 0)
return;
if (!learned)
if (!learned)
m_clauses_to_reinit.push_back(clause_wrapper(l1, l2));
}
m_stats.m_mk_bin_clause++;
@ -248,7 +248,7 @@ namespace sat {
void solver::push_reinit_stack(clause & c) {
TRACE("sat_reinit", tout << "adding to reinit stack: " << c << "\n";);
m_clauses_to_reinit.push_back(clause_wrapper(c));
c.set_reinit_stack(true);
c.set_reinit_stack(true);
}
@ -257,7 +257,7 @@ namespace sat {
clause * r = m_cls_allocator.mk_clause(3, lits, learned);
bool reinit = attach_ter_clause(*r);
if (reinit && !learned) push_reinit_stack(*r);
if (learned)
m_learned.push_back(r);
else
@ -806,22 +806,22 @@ namespace sat {
m_params.set_uint("random_seed", m_rand());
if (i == 1 + num_threads/2) {
m_params.set_sym("phase", symbol("random"));
}
}
solvers[i] = alloc(sat::solver, m_params, rlims[i], 0);
solvers[i]->copy(*this);
solvers[i]->set_par(&par);
scoped_rlimit.push_child(&solvers[i]->rlimit());
scoped_rlimit.push_child(&solvers[i]->rlimit());
}
set_par(&par);
m_params.set_sym("phase", saved_phase);
int finished_id = -1;
std::string ex_msg;
par_exception_kind ex_kind;
par_exception_kind ex_kind = DEFAULT_EX;
unsigned error_code = 0;
lbool result = l_undef;
#pragma omp parallel for
for (int i = 0; i < num_threads; ++i) {
try {
try {
lbool r = l_undef;
if (i < num_extra_solvers) {
r = solvers[i]->check(num_lits, lits);
@ -851,7 +851,7 @@ namespace sat {
rlims[j].cancel();
}
}
}
}
}
catch (z3_error & err) {
if (i == 0) {
@ -871,7 +871,7 @@ namespace sat {
m_stats = solvers[finished_id]->m_stats;
}
for (int i = 0; i < num_extra_solvers; ++i) {
for (int i = 0; i < num_extra_solvers; ++i) {
dealloc(solvers[i]);
}
if (finished_id == -1) {
@ -1140,7 +1140,7 @@ namespace sat {
for (unsigned i = 0; !inconsistent() && i < m_assumptions.size(); ++i) {
assign(m_assumptions[i], justification());
}
TRACE("sat",
TRACE("sat",
for (unsigned i = 0; i < m_assumptions.size(); ++i) {
index_set s;
if (m_antecedents.find(m_assumptions[i].var(), s)) {
@ -2037,7 +2037,7 @@ namespace sat {
}
}
literal consequent = m_not_l;
literal consequent = m_not_l;
justification js = m_conflict;
@ -3115,7 +3115,7 @@ namespace sat {
literal_pair p(l1, l2);
if (!seen_bc.contains(p)) {
seen_bc.insert(p);
mc.add_edge(l1.index(), l2.index());
mc.add_edge(l1.index(), l2.index());
}
}
vector<unsigned_vector> _mutexes;
@ -3168,7 +3168,7 @@ namespace sat {
}
void solver::fixup_consequence_core() {
index_set s;
index_set s;
TRACE("sat", tout << m_core << "\n";);
for (unsigned i = 0; i < m_core.size(); ++i) {
TRACE("sat", tout << m_core[i] << ": "; display_index_set(tout, m_antecedents.find(m_core[i].var())) << "\n";);
@ -3218,20 +3218,20 @@ namespace sat {
while (true) {
++num_iterations;
SASSERT(!inconsistent());
lbool r = bounded_search();
if (r != l_undef) {
fixup_consequence_core();
return r;
}
extract_fixed_consequences(num_units, asms, unfixed_vars, conseq);
if (m_conflicts > m_config.m_max_conflicts) {
IF_VERBOSE(SAT_VB_LVL, verbose_stream() << "(sat \"abort: max-conflicts = " << m_conflicts << "\")\n";);
return l_undef;
}
restart();
simplify_problem();
if (check_inconsistent()) {
@ -3239,11 +3239,11 @@ namespace sat {
return l_false;
}
gc();
if (m_config.m_restart_max <= num_iterations) {
IF_VERBOSE(SAT_VB_LVL, verbose_stream() << "(sat \"abort: max-restarts\")\n";);
return l_undef;
}
}
}
}

View file

@ -4217,40 +4217,18 @@ namespace smt {
TRACE("context", tout << mk_pp(e, m) << "\n";);
quantifier* q = to_quantifier(e);
if (!m.is_rec_fun_def(q)) continue;
SASSERT(q->get_num_patterns() == 1);
SASSERT(q->get_num_patterns() == 2);
expr* fn = to_app(q->get_pattern(0))->get_arg(0);
expr* body = to_app(q->get_pattern(1))->get_arg(0);
SASSERT(is_app(fn));
func_decl* f = to_app(fn)->get_decl();
expr* eq = q->get_expr();
expr_ref body(m);
if (is_fun_def(fn, q->get_expr(), body)) {
func_interp* fi = alloc(func_interp, m, f->get_arity());
fi->set_else(body);
m_model->register_decl(f, fi);
}
func_interp* fi = alloc(func_interp, m, f->get_arity());
fi->set_else(body);
m_model->register_decl(f, fi);
}
}
}
bool context::is_fun_def(expr* f, expr* body, expr_ref& result) {
expr* t1, *t2, *t3;
if (m_manager.is_eq(body, t1, t2) || m_manager.is_iff(body, t1, t2)) {
if (t1 == f) return result = t2, true;
if (t2 == f) return result = t1, true;
return false;
}
if (m_manager.is_ite(body, t1, t2, t3)) {
expr_ref body1(m_manager), body2(m_manager);
if (is_fun_def(f, t2, body1) && is_fun_def(f, t3, body2)) {
// f is not free in t1
result = m_manager.mk_ite(t1, body1, body2);
return true;
}
}
return false;
}
};

View file

@ -1167,8 +1167,6 @@ namespace smt {
void add_rec_funs_to_model();
bool is_fun_def(expr* f, expr* q, expr_ref& body);
public:
bool can_propagate() const;

View file

@ -613,7 +613,7 @@ namespace smt {
out << "justification ";
literal_vector lits;
const_cast<conflict_resolution&>(*m_conflict_resolution).justification2literals(j.get_justification(), lits);
display_literals_verbose(out, lits.size(), lits.c_ptr());
display_literals(out, lits.size(), lits.c_ptr());
break;
}
default:

View file

@ -318,7 +318,7 @@ namespace smt {
bool model_checker::check_rec_fun(quantifier* q) {
TRACE("model_checker", tout << mk_pp(q, m) << "\n";);
SASSERT(q->get_num_patterns() == 1);
SASSERT(q->get_num_patterns() == 2); // first pattern is the function, second is the body.
expr* fn = to_app(q->get_pattern(0))->get_arg(0);
SASSERT(is_app(fn));
func_decl* f = to_app(fn)->get_decl();

View file

@ -52,8 +52,10 @@ Revision History:
#ifdef USE_INTRINSICS
#include <emmintrin.h>
#if defined(_MSC_VER) || defined(__SSE4_1__)
#include <smmintrin.h>
#endif
#endif
hwf_manager::hwf_manager() :
m_mpz_manager(m_mpq_manager)
@ -304,7 +306,9 @@ void hwf_manager::round_to_integral(mpf_rounding_mode rm, hwf const & x, hwf & o
// According to the Intel Architecture manual, the x87-instrunction FRNDINT is the
// same in 32-bit and 64-bit mode. The _mm_round_* intrinsics are SSE4 extensions.
#ifdef _WINDOWS
#ifdef USE_INTRINSICS
#if defined(USE_INTRINSICS) && \
(defined(_WINDOWS) && (defined(__AVX__) || defined(_M_X64))) || \
(!defined(_WINDOWS) && defined(__SSE4_1__))
switch (rm) {
case 0: _mm_store_sd(&o.value, _mm_round_pd(_mm_set_sd(x.value), _MM_FROUND_TO_NEAREST_INT)); break;
case 2: _mm_store_sd(&o.value, _mm_round_pd(_mm_set_sd(x.value), _MM_FROUND_TO_POS_INF)); break;