mirror of
https://github.com/Z3Prover/z3
synced 2025-10-07 08:21:56 +00:00
Merge branch 'master' of https://github.com/z3prover/z3 into opt
This commit is contained in:
commit
f698efa403
92 changed files with 8030 additions and 1822 deletions
|
@ -44,4 +44,4 @@ public:
|
|||
|
||||
void install_smt2_extra_cmds(cmd_context & ctx) {
|
||||
ctx.insert(alloc(include_cmd));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -471,12 +471,16 @@ namespace smt {
|
|||
setup_r_arith();
|
||||
}
|
||||
|
||||
void setup::setup_QF_LIRA(static_features const& st) {
|
||||
setup_mi_arith();
|
||||
}
|
||||
|
||||
void setup::setup_QF_LIA() {
|
||||
TRACE("setup", tout << "setup_QF_LIA(st)\n";);
|
||||
m_params.m_relevancy_lvl = 0;
|
||||
m_params.m_arith_expand_eqs = true;
|
||||
m_params.m_arith_reflect = false;
|
||||
m_params.m_arith_propagate_eqs = false;
|
||||
m_params.m_arith_propagate_eqs = false;
|
||||
m_params.m_nnf_cnf = false;
|
||||
setup_i_arith();
|
||||
}
|
||||
|
@ -720,10 +724,9 @@ namespace smt {
|
|||
}
|
||||
|
||||
void setup::setup_r_arith() {
|
||||
m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params));
|
||||
|
||||
// Disabled in initial commit of LRA additions
|
||||
// m_context.register_plugin(alloc(smt::theory_lra, m_manager, m_params));
|
||||
// to disable theory lra
|
||||
// m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params));
|
||||
m_context.register_plugin(alloc(smt::theory_lra, m_manager, m_params));
|
||||
}
|
||||
|
||||
void setup::setup_mi_arith() {
|
||||
|
@ -937,7 +940,9 @@ namespace smt {
|
|||
}
|
||||
|
||||
if (st.num_theories() == 1 && is_arith(st)) {
|
||||
if (st.m_has_real)
|
||||
if ((st.m_has_int && st.m_has_real) || (st.m_num_non_linear != 0))
|
||||
setup_QF_LIRA(st);
|
||||
else if (st.m_has_real)
|
||||
setup_QF_LRA(st);
|
||||
else
|
||||
setup_QF_LIA(st);
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace smt {
|
|||
void setup_QF_LRA();
|
||||
void setup_QF_LRA(static_features const & st);
|
||||
void setup_QF_LIA();
|
||||
void setup_QF_LIRA(static_features const& st);
|
||||
void setup_QF_LIA(static_features const & st);
|
||||
void setup_QF_UFLIA();
|
||||
void setup_QF_UFLIA(static_features & st);
|
||||
|
|
|
@ -21,6 +21,7 @@ Notes:
|
|||
#include"smt_kernel.h"
|
||||
#include"smt_params.h"
|
||||
#include"smt_params_helper.hpp"
|
||||
#include"lp_params.hpp"
|
||||
#include"rewriter_types.h"
|
||||
#include"filter_model_converter.h"
|
||||
#include"ast_util.h"
|
||||
|
@ -64,6 +65,10 @@ public:
|
|||
return m_params;
|
||||
}
|
||||
|
||||
params_ref & params() {
|
||||
return m_params_ref;
|
||||
}
|
||||
|
||||
void updt_params_core(params_ref const & p) {
|
||||
m_candidate_models = p.get_bool("candidate_models", false);
|
||||
m_fail_if_inconclusive = p.get_bool("fail_if_inconclusive", true);
|
||||
|
@ -73,6 +78,7 @@ public:
|
|||
TRACE("smt_tactic", tout << "updt_params: " << p << "\n";);
|
||||
updt_params_core(p);
|
||||
fparams().updt_params(p);
|
||||
m_params_ref.copy(p);
|
||||
m_logic = p.get_sym(symbol("logic"), m_logic);
|
||||
if (m_logic != symbol::null && m_ctx) {
|
||||
m_ctx->set_logic(m_logic);
|
||||
|
@ -84,6 +90,7 @@ public:
|
|||
r.insert("candidate_models", CPK_BOOL, "(default: false) create candidate models even when quantifier or theory reasoning is incomplete.");
|
||||
r.insert("fail_if_inconclusive", CPK_BOOL, "(default: true) fail if found unsat (sat) for under (over) approximated goal.");
|
||||
smt_params_helper::collect_param_descrs(r);
|
||||
lp_params::collect_param_descrs(r);
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,10 +119,12 @@ public:
|
|||
struct scoped_init_ctx {
|
||||
smt_tactic & m_owner;
|
||||
smt_params m_params; // smt-setup overwrites parameters depending on the current assertions.
|
||||
params_ref m_params_ref;
|
||||
|
||||
scoped_init_ctx(smt_tactic & o, ast_manager & m):m_owner(o) {
|
||||
m_params = o.fparams();
|
||||
smt::kernel * new_ctx = alloc(smt::kernel, m, m_params);
|
||||
m_params_ref = o.params();
|
||||
smt::kernel * new_ctx = alloc(smt::kernel, m, m_params, m_params_ref);
|
||||
TRACE("smt_tactic", tout << "logic: " << o.m_logic << "\n";);
|
||||
new_ctx->set_logic(o.m_logic);
|
||||
if (o.m_callback) {
|
||||
|
|
2615
src/smt/theory_lra.cpp
Normal file
2615
src/smt/theory_lra.cpp
Normal file
File diff suppressed because it is too large
Load diff
97
src/smt/theory_lra.h
Normal file
97
src/smt/theory_lra.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*++
|
||||
Copyright (c) 2016 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
theory_lra.h
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Lev Nachmanson (levnach) 2016-25-3
|
||||
Nikolaj Bjorner (nbjorner)
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
--*/
|
||||
#pragma once
|
||||
|
||||
#include "theory_opt.h"
|
||||
|
||||
namespace smt {
|
||||
class theory_lra : public theory, public theory_opt {
|
||||
class imp;
|
||||
imp* m_imp;
|
||||
|
||||
public:
|
||||
theory_lra(ast_manager& m, theory_arith_params& ap);
|
||||
virtual ~theory_lra();
|
||||
virtual theory* mk_fresh(context* new_ctx);
|
||||
virtual char const* get_name() const { return "lra"; }
|
||||
|
||||
virtual void init(context * ctx);
|
||||
|
||||
virtual bool internalize_atom(app * atom, bool gate_ctx);
|
||||
|
||||
virtual bool internalize_term(app * term);
|
||||
|
||||
virtual void internalize_eq_eh(app * atom, bool_var v);
|
||||
|
||||
virtual void assign_eh(bool_var v, bool is_true);
|
||||
|
||||
virtual void new_eq_eh(theory_var v1, theory_var v2);
|
||||
|
||||
virtual bool use_diseqs() const;
|
||||
|
||||
virtual void new_diseq_eh(theory_var v1, theory_var v2);
|
||||
|
||||
virtual void push_scope_eh();
|
||||
|
||||
virtual void pop_scope_eh(unsigned num_scopes);
|
||||
|
||||
virtual void restart_eh();
|
||||
|
||||
virtual void relevant_eh(app* e);
|
||||
|
||||
virtual void init_search_eh();
|
||||
|
||||
virtual final_check_status final_check_eh();
|
||||
|
||||
virtual bool is_shared(theory_var v) const;
|
||||
|
||||
virtual bool can_propagate();
|
||||
|
||||
virtual void propagate();
|
||||
|
||||
virtual justification * why_is_diseq(theory_var v1, theory_var v2);
|
||||
|
||||
// virtual void flush_eh();
|
||||
|
||||
virtual void reset_eh();
|
||||
|
||||
virtual void init_model(model_generator & m);
|
||||
|
||||
virtual model_value_proc * mk_value(enode * n, model_generator & mg);
|
||||
|
||||
virtual bool get_value(enode* n, expr_ref& r);
|
||||
|
||||
virtual bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const;
|
||||
|
||||
virtual void display(std::ostream & out) const;
|
||||
|
||||
virtual void collect_statistics(::statistics & st) const;
|
||||
|
||||
// optimization
|
||||
virtual inf_eps value(theory_var);
|
||||
virtual inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared);
|
||||
virtual theory_var add_objective(app* term);
|
||||
virtual expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
|
@ -2176,6 +2176,8 @@ bool theory_seq::simplify_and_solve_eqs() {
|
|||
return m_new_propagation || ctx.inconsistent();
|
||||
}
|
||||
|
||||
void theory_seq::internalize_eq_eh(app * atom, bool_var v) {}
|
||||
|
||||
|
||||
bool theory_seq::internalize_term(app* term) {
|
||||
context & ctx = get_context();
|
||||
|
|
|
@ -343,7 +343,7 @@ namespace smt {
|
|||
virtual final_check_status final_check_eh();
|
||||
virtual bool internalize_atom(app* atom, bool) { return internalize_term(atom); }
|
||||
virtual bool internalize_term(app*);
|
||||
virtual void internalize_eq_eh(app * atom, bool_var v) {}
|
||||
virtual void internalize_eq_eh(app * atom, bool_var v);
|
||||
virtual void new_eq_eh(theory_var, theory_var);
|
||||
virtual void new_diseq_eh(theory_var, theory_var);
|
||||
virtual void assign_eh(bool_var v, bool is_true);
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace smt {
|
|||
totalCacheAccessCount(0),
|
||||
cacheHitCount(0),
|
||||
cacheMissCount(0),
|
||||
m_fresh_id(0),
|
||||
m_find(*this),
|
||||
m_trail_stack(*this)
|
||||
{
|
||||
|
@ -441,7 +442,12 @@ namespace smt {
|
|||
}
|
||||
|
||||
app * theory_str::mk_fresh_const(char const* name, sort* s) {
|
||||
return u.mk_skolem(symbol(name), 0, 0, s);
|
||||
string_buffer<64> buffer;
|
||||
buffer << name;
|
||||
buffer << "!tmp";
|
||||
buffer << m_fresh_id;
|
||||
m_fresh_id++;
|
||||
return u.mk_skolem(symbol(buffer.c_str()), 0, 0, s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5552,8 +5558,8 @@ namespace smt {
|
|||
for (; arg1_grdItor != groundedMap[arg1DeAlias].end(); arg1_grdItor++) {
|
||||
std::vector<expr*> ndVec;
|
||||
ndVec.insert(ndVec.end(), arg0_grdItor->first.begin(), arg0_grdItor->first.end());
|
||||
int arg0VecSize = arg0_grdItor->first.size();
|
||||
int arg1VecSize = arg1_grdItor->first.size();
|
||||
size_t arg0VecSize = arg0_grdItor->first.size();
|
||||
size_t arg1VecSize = arg1_grdItor->first.size();
|
||||
if (arg0VecSize > 0 && arg1VecSize > 0 && u.str.is_string(arg0_grdItor->first[arg0VecSize - 1]) && u.str.is_string(arg1_grdItor->first[0])) {
|
||||
ndVec.pop_back();
|
||||
ndVec.push_back(mk_concat(arg0_grdItor->first[arg0VecSize - 1], arg1_grdItor->first[0]));
|
||||
|
@ -5645,8 +5651,8 @@ namespace smt {
|
|||
}
|
||||
|
||||
bool theory_str::is_partial_in_grounded_concat(const std::vector<expr*> & strVec, const std::vector<expr*> & subStrVec) {
|
||||
int strCnt = strVec.size();
|
||||
int subStrCnt = subStrVec.size();
|
||||
size_t strCnt = strVec.size();
|
||||
size_t subStrCnt = subStrVec.size();
|
||||
|
||||
if (strCnt == 0 || subStrCnt == 0) {
|
||||
return false;
|
||||
|
@ -5717,7 +5723,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
// tail nodes
|
||||
int tailIdx = i + subStrCnt - 1;
|
||||
size_t tailIdx = i + subStrCnt - 1;
|
||||
zstring subStrTailVal;
|
||||
if (u.str.is_string(subStrVec[subStrCnt - 1], subStrTailVal)) {
|
||||
zstring strTailVal;
|
||||
|
@ -5908,8 +5914,14 @@ namespace smt {
|
|||
app * n2_curr = to_app(n2);
|
||||
|
||||
// case 0: n1_curr is const string, n2_curr is const string
|
||||
if (u.str.is_string(n1_curr) && u.str.is_string(n2_curr)) {
|
||||
if (n1_curr != n2_curr) {
|
||||
zstring n1_curr_str, n2_curr_str;
|
||||
if (u.str.is_string(n1_curr, n1_curr_str) && u.str.is_string(n2_curr, n2_curr_str)) {
|
||||
TRACE("str", tout << "checking string constants: n1=" << n1_curr_str << ", n2=" << n2_curr_str << std::endl;);
|
||||
if (n1_curr_str == n2_curr_str) {
|
||||
// TODO(mtrberzi) potential correction: if n1_curr != n2_curr,
|
||||
// assert that these two terms are in fact equal, because they ought to be
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -6864,7 +6876,7 @@ namespace smt {
|
|||
// easiest case. we will search within these bounds
|
||||
} else if (upper_bound_exists && !lower_bound_exists) {
|
||||
// search between 0 and the upper bound
|
||||
v_lower_bound == rational::zero();
|
||||
v_lower_bound = rational::zero();
|
||||
} else if (lower_bound_exists && !upper_bound_exists) {
|
||||
// check some finite portion of the search space
|
||||
v_upper_bound = v_lower_bound + rational(10);
|
||||
|
@ -8251,7 +8263,7 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
if (lId == -1)
|
||||
lId = mLMap.size();
|
||||
lId = static_cast<int>(mLMap.size());
|
||||
for (std::set<expr*>::iterator itor2 = nSet.begin(); itor2 != nSet.end(); itor2++) {
|
||||
bool itorHasEqcValue = false;
|
||||
get_eqc_value(*itor2, itorHasEqcValue);
|
||||
|
@ -8290,7 +8302,7 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
if (rId == -1)
|
||||
rId = mRMap.size();
|
||||
rId = static_cast<int>(mRMap.size());
|
||||
for (itor2 = nSet.begin(); itor2 != nSet.end(); itor2++) {
|
||||
bool rHasEqcValue = false;
|
||||
get_eqc_value(*itor2, rHasEqcValue);
|
||||
|
@ -9182,7 +9194,7 @@ namespace smt {
|
|||
// ----------------------------------------------------------------------------------------
|
||||
int len = atoi(lenStr.encode().c_str());
|
||||
bool coverAll = false;
|
||||
svector<int_vector> options;
|
||||
vector<int_vector, true, long long> options;
|
||||
int_vector base;
|
||||
|
||||
TRACE("str", tout
|
||||
|
@ -9227,16 +9239,16 @@ namespace smt {
|
|||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
ptr_vector<expr> orList;
|
||||
ptr_vector<expr> andList;
|
||||
|
||||
for (long long i = l; i < h; i++) {
|
||||
orList.push_back(m.mk_eq(val_indicator, mk_string(longlong_to_string(i).c_str()) ));
|
||||
if (m_params.m_AggressiveValueTesting) {
|
||||
literal l = mk_eq(val_indicator, mk_string(longlong_to_string(i).c_str()), false);
|
||||
ctx.mark_as_relevant(l);
|
||||
ctx.force_phase(l);
|
||||
literal lit = mk_eq(val_indicator, mk_string(longlong_to_string(i).c_str()), false);
|
||||
ctx.mark_as_relevant(lit);
|
||||
ctx.force_phase(lit);
|
||||
}
|
||||
|
||||
zstring aStr = gen_val_string(len, options[i - l]);
|
||||
|
|
|
@ -350,6 +350,8 @@ protected:
|
|||
unsigned long cacheHitCount;
|
||||
unsigned long cacheMissCount;
|
||||
|
||||
unsigned m_fresh_id;
|
||||
|
||||
// cache mapping each string S to Length(S)
|
||||
obj_map<expr, app*> length_ast_map;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue