3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

merge with opt

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-04-30 08:27:54 -07:00
commit 859c68c2ac
58 changed files with 1329 additions and 526 deletions

View file

@ -39,6 +39,7 @@ void smt_params::updt_local_params(params_ref const & _p) {
m_timeout = p.timeout();
m_rlimit = p.rlimit();
m_max_conflicts = p.max_conflicts();
m_restart_max = p.restart_max();
m_core_validate = p.core_validate();
m_logic = _p.get_sym("logic", m_logic);
m_string_solver = p.string_solver();

View file

@ -99,6 +99,7 @@ struct smt_params : public preprocessor_params,
unsigned m_phase_caching_off;
bool m_minimize_lemmas;
unsigned m_max_conflicts;
unsigned m_restart_max;
bool m_simplify_clauses;
unsigned m_tick;
bool m_display_features;

View file

@ -21,6 +21,7 @@ def_module_params(module_name='smt',
('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'),
('rlimit', UINT, 0, 'resource limit (0 means no limit)'),
('max_conflicts', UINT, UINT_MAX, 'maximum number of conflicts before giving up.'),
('restart.max', UINT, UINT_MAX, 'maximal number of restarts.'),
('mbqi', BOOL, True, 'model based quantifier instantiation (MBQI)'),
('mbqi.max_cexs', UINT, 1, 'initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation'),
('mbqi.max_cexs_incr', UINT, 0, 'increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI'),

View file

@ -1826,6 +1826,15 @@ namespace smt {
m_bvar_inc *= INV_ACTIVITY_LIMIT;
}
expr* context::next_decision() {
bool_var var;
lbool phase;
m_case_split_queue->next_case_split(var, phase);
if (var == null_bool_var) return m_manager.mk_true();
m_case_split_queue->unassign_var_eh(var);
return bool_var2expr(var);
}
/**
\brief Execute next clase split, return false if there are no
more case splits to be performed.
@ -3412,6 +3421,7 @@ namespace smt {
m_num_conflicts = 0;
m_num_conflicts_since_restart = 0;
m_num_conflicts_since_lemma_gc = 0;
m_num_restarts = 0;
m_restart_threshold = m_fparams.m_restart_initial;
m_restart_outer_threshold = m_fparams.m_restart_initial;
m_agility = 0.0;
@ -3543,7 +3553,7 @@ namespace smt {
inc_limits();
if (status == l_true || !m_fparams.m_restart_adaptive || m_agility < m_fparams.m_restart_agility_threshold) {
SASSERT(!inconsistent());
IF_VERBOSE(2, verbose_stream() << "(smt.restarting :propagations " << m_stats.m_num_propagations
IF_VERBOSE(2, verbose_stream() << "(smt.restarting :propagations " << m_stats.m_num_propagations
<< " :decisions " << m_stats.m_num_decisions
<< " :conflicts " << m_stats.m_num_conflicts << " :restart " << m_restart_threshold;
if (m_fparams.m_restart_strategy == RS_IN_OUT_GEOMETRIC) {
@ -3552,9 +3562,10 @@ namespace smt {
if (m_fparams.m_restart_adaptive) {
verbose_stream() << " :agility " << m_agility;
}
verbose_stream() << ")" << std::endl; verbose_stream().flush(););
verbose_stream() << ")\n");
// execute the restart
m_stats.m_num_restarts++;
m_num_restarts++;
if (m_scope_lvl > curr_lvl) {
pop_scope(m_scope_lvl - curr_lvl);
SASSERT(at_search_level());
@ -3571,6 +3582,11 @@ namespace smt {
status = l_false;
return false;
}
if (m_num_restarts >= m_fparams.m_restart_max) {
status = l_undef;
m_last_search_failure = NUM_CONFLICTS;
return false;
}
}
if (m_fparams.m_simplify_clauses)
simplify_clauses();

View file

@ -896,6 +896,8 @@ namespace smt {
unsigned m_num_conflicts;
unsigned m_num_conflicts_since_restart;
unsigned m_num_conflicts_since_lemma_gc;
unsigned m_num_restarts;
unsigned m_num_simplifications;
unsigned m_restart_threshold;
unsigned m_restart_outer_threshold;
unsigned m_luby_idx;
@ -1037,6 +1039,8 @@ namespace smt {
enode * get_enode_eq_to(func_decl * f, unsigned num_args, enode * const * args);
expr* next_decision();
protected:
bool decide();

View file

@ -174,11 +174,15 @@ namespace smt {
void get_guessed_literals(expr_ref_vector & result) {
m_kernel.get_guessed_literals(result);
}
expr* next_decision() {
return m_kernel.next_decision();
}
void collect_statistics(::statistics & st) const {
m_kernel.collect_statistics(st);
}
void reset_statistics() {
}
@ -343,6 +347,10 @@ namespace smt {
m_imp->get_guessed_literals(result);
}
expr* kernel::next_decision() {
return m_imp->next_decision();
}
void kernel::display(std::ostream & out) const {
m_imp->display(out);
}

View file

@ -212,6 +212,11 @@ namespace smt {
*/
void get_guessed_literals(expr_ref_vector & result);
/**
\brief return the next case split literal.
*/
expr* next_decision();
/**
\brief (For debubbing purposes) Prints the state of the kernel
*/

View file

@ -30,9 +30,35 @@ Notes:
namespace smt {
class smt_solver : public solver_na2as {
struct cuber {
smt_solver& m_solver;
unsigned m_round;
expr_ref m_result;
cuber(smt_solver& s):
m_solver(s),
m_round(0),
m_result(s.get_manager()) {}
expr_ref cube() {
switch (m_round) {
case 0:
m_result = m_solver.m_context.next_decision();
break;
case 1:
m_result = m_solver.get_manager().mk_not(m_result);
break;
default:
m_result = m_solver.get_manager().mk_false();
break;
}
++m_round;
return m_result;
}
};
smt_params m_smt_params;
smt::kernel m_context;
progress_callback * m_callback;
cuber* m_cuber;
symbol m_logic;
bool m_minimizing_core;
bool m_core_extend_patterns;
@ -45,6 +71,7 @@ namespace smt {
solver_na2as(m),
m_smt_params(p),
m_context(m, m_smt_params),
m_cuber(nullptr),
m_minimizing_core(false),
m_core_extend_patterns(false),
m_core_extend_patterns_max_distance(UINT_MAX),
@ -72,6 +99,7 @@ namespace smt {
~smt_solver() override {
dec_ref_values(get_manager(), m_name2assertion);
dealloc(m_cuber);
}
void updt_params(params_ref const & p) override {
@ -204,7 +232,6 @@ namespace smt {
ast_manager & get_manager() const override { return m_context.m(); }
void set_progress_callback(progress_callback * callback) override {
m_callback = callback;
m_context.set_progress_callback(callback);
}
@ -217,13 +244,24 @@ namespace smt {
return m_context.get_formula(idx);
}
virtual expr_ref lookahead(expr_ref_vector const& assumptions, expr_ref_vector const& candidates) {
virtual expr_ref_vector cube(expr_ref_vector& vars, unsigned cutoff) {
ast_manager& m = get_manager();
return expr_ref(m.mk_true(), m);
}
virtual expr_ref_vector cube(expr_ref_vector&, unsigned) {
return expr_ref_vector(get_manager());
if (!m_cuber) {
m_cuber = alloc(cuber, *this);
}
expr_ref result = m_cuber->cube();
expr_ref_vector lits(m);
if (m.is_false(result)) {
dealloc(m_cuber);
m_cuber = nullptr;
}
if (m.is_true(result)) {
dealloc(m_cuber);
m_cuber = nullptr;
return lits;
}
lits.push_back(result);
return lits;
}
struct collect_fds_proc {

View file

@ -16,19 +16,21 @@ Author:
Notes:
--*/
#include "tactic/tactic.h"
#include "tactic/tactical.h"
#include "util/lp/lp_params.hpp"
#include "ast/rewriter/rewriter_types.h"
#include "ast/ast_util.h"
#include "smt/smt_kernel.h"
#include "smt/params/smt_params.h"
#include "smt/params/smt_params_helper.hpp"
#include "util/lp/lp_params.hpp"
#include "ast/rewriter/rewriter_types.h"
#include "tactic/generic_model_converter.h"
#include "ast/ast_util.h"
#include "solver/solver2tactic.h"
#include "smt/smt_solver.h"
#include "tactic/tactic.h"
#include "tactic/tactical.h"
#include "tactic/generic_model_converter.h"
#include "solver/solver2tactic.h"
#include "solver/solver.h"
#include "solver/mus.h"
#include "solver/parallel_tactic.h"
#include "solver/parallel_params.hpp"
typedef obj_map<expr, expr *> expr2expr_map;
@ -301,3 +303,20 @@ tactic * mk_smt_tactic_using(bool auto_config, params_ref const & _p) {
return using_params(r, p);
}
tactic * mk_psmt_tactic(ast_manager& m, params_ref const& p, symbol const& logic) {
parallel_params pp(p);
bool use_parallel = pp.enable();
return pp.enable() ? mk_parallel_tactic(mk_smt_solver(m, p, logic), p) : mk_smt_tactic(p);
}
tactic * mk_psmt_tactic_using(ast_manager& m, bool auto_config, params_ref const& _p, symbol const& logic) {
parallel_params pp(_p);
bool use_parallel = pp.enable();
params_ref p = _p;
p.set_bool("auto_config", auto_config);
return using_params(pp.enable() ? mk_parallel_tactic(mk_smt_solver(m, p, logic), p) : mk_smt_tactic(p), p);
}
tactic * mk_parallel_smt_tactic(ast_manager& m, params_ref const& p) {
return mk_parallel_tactic(mk_smt_solver(m, p, symbol::null), p);
}

View file

@ -31,8 +31,13 @@ tactic * mk_smt_tactic(params_ref const & p = params_ref());
// syntax sugar for using_params(mk_smt_tactic(), p) where p = (:auto_config, auto_config)
tactic * mk_smt_tactic_using(bool auto_config = true, params_ref const & p = params_ref());
tactic * mk_psmt_tactic(ast_manager& m, params_ref const& p, symbol const& logic = symbol::null);
tactic * mk_psmt_tactic_using(ast_manager& m, bool auto_config, params_ref const& p, symbol const& logic = symbol::null);
tactic * mk_parallel_smt_tactic(ast_manager& m, params_ref const& p);
/*
ADD_TACTIC("smt", "apply a SAT based SMT solver.", "mk_smt_tactic(p)")
ADD_TACTIC("psmt", "builtin strategy for SMT tactic in parallel.", "mk_parallel_smt_tactic(m, p)")
*/
#endif