mirror of
https://github.com/Z3Prover/z3
synced 2025-10-04 15:03:57 +00:00
merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
b482dbd589
379 changed files with 7440 additions and 3352 deletions
48
src/ast/CMakeLists.txt
Normal file
48
src/ast/CMakeLists.txt
Normal file
|
@ -0,0 +1,48 @@
|
|||
z3_add_component(ast
|
||||
SOURCES
|
||||
act_cache.cpp
|
||||
arith_decl_plugin.cpp
|
||||
array_decl_plugin.cpp
|
||||
ast.cpp
|
||||
ast_ll_pp.cpp
|
||||
ast_lt.cpp
|
||||
ast_pp_util.cpp
|
||||
ast_printer.cpp
|
||||
ast_smt2_pp.cpp
|
||||
ast_smt_pp.cpp
|
||||
ast_translation.cpp
|
||||
ast_util.cpp
|
||||
bv_decl_plugin.cpp
|
||||
datatype_decl_plugin.cpp
|
||||
decl_collector.cpp
|
||||
dl_decl_plugin.cpp
|
||||
expr2polynomial.cpp
|
||||
expr2var.cpp
|
||||
expr_abstract.cpp
|
||||
expr_functors.cpp
|
||||
expr_map.cpp
|
||||
expr_stat.cpp
|
||||
expr_substitution.cpp
|
||||
for_each_ast.cpp
|
||||
for_each_expr.cpp
|
||||
format.cpp
|
||||
fpa_decl_plugin.cpp
|
||||
func_decl_dependencies.cpp
|
||||
has_free_vars.cpp
|
||||
macro_substitution.cpp
|
||||
num_occurs.cpp
|
||||
occurs.cpp
|
||||
pb_decl_plugin.cpp
|
||||
pp.cpp
|
||||
reg_decl_plugins.cpp
|
||||
seq_decl_plugin.cpp
|
||||
shared_occs.cpp
|
||||
static_features.cpp
|
||||
used_vars.cpp
|
||||
well_sorted.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
polynomial
|
||||
util # Unnecessary? polynomial already depends on util
|
||||
PYG_FILES
|
||||
pp_params.pyg
|
||||
)
|
|
@ -275,7 +275,9 @@ public:
|
|||
bool is_uminus(expr const * n) const { return is_app_of(n, m_afid, OP_UMINUS); }
|
||||
bool is_mul(expr const * n) const { return is_app_of(n, m_afid, OP_MUL); }
|
||||
bool is_div(expr const * n) const { return is_app_of(n, m_afid, OP_DIV); }
|
||||
bool is_div0(expr const * n) const { return is_app_of(n, m_afid, OP_DIV_0); }
|
||||
bool is_idiv(expr const * n) const { return is_app_of(n, m_afid, OP_IDIV); }
|
||||
bool is_idiv0(expr const * n) const { return is_app_of(n, m_afid, OP_IDIV_0); }
|
||||
bool is_mod(expr const * n) const { return is_app_of(n, m_afid, OP_MOD); }
|
||||
bool is_rem(expr const * n) const { return is_app_of(n, m_afid, OP_REM); }
|
||||
bool is_to_real(expr const * n) const { return is_app_of(n, m_afid, OP_TO_REAL); }
|
||||
|
|
|
@ -667,6 +667,8 @@ public:
|
|||
expr * get_arg(unsigned idx) const { SASSERT(idx < m_num_args); return m_args[idx]; }
|
||||
expr * const * get_args() const { return m_args; }
|
||||
unsigned get_size() const { return get_obj_size(get_num_args()); }
|
||||
expr * const * begin() const { return m_args; }
|
||||
expr * const * end() const { return m_args + m_num_args; }
|
||||
|
||||
unsigned get_depth() const { return flags()->m_depth; }
|
||||
bool is_ground() const { return flags()->m_ground; }
|
||||
|
@ -2082,6 +2084,7 @@ public:
|
|||
|
||||
bool is_undef_proof(expr const * e) const { return e == m_undef_proof; }
|
||||
bool is_asserted(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_ASSERTED); }
|
||||
bool is_hypothesis (expr const *e) const {return is_app_of (e, m_basic_family_id, PR_HYPOTHESIS);}
|
||||
bool is_goal(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_GOAL); }
|
||||
bool is_modus_ponens(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_MODUS_PONENS); }
|
||||
bool is_reflexivity(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_REFLEXIVITY); }
|
||||
|
@ -2112,6 +2115,7 @@ public:
|
|||
bool is_skolemize(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_SKOLEMIZE); }
|
||||
|
||||
MATCH_UNARY(is_asserted);
|
||||
MATCH_UNARY(is_hypothesis);
|
||||
MATCH_UNARY(is_lemma);
|
||||
|
||||
bool has_fact(proof const * p) const {
|
||||
|
|
|
@ -557,7 +557,14 @@ class smt2_printer {
|
|||
format * f;
|
||||
if (v->get_idx() < m_var_names.size()) {
|
||||
symbol s = m_var_names[m_var_names.size() - v->get_idx() - 1];
|
||||
f = mk_string(m(), s.str().c_str());
|
||||
std::string vname;
|
||||
if (is_smt2_quoted_symbol (s)) {
|
||||
vname = mk_smt2_quoted_symbol (s);
|
||||
}
|
||||
else {
|
||||
vname = s.str();
|
||||
}
|
||||
f = mk_string(m(), vname.c_str ());
|
||||
}
|
||||
else {
|
||||
// fallback... it is not supposed to happen when the printer is correctly used.
|
||||
|
@ -884,7 +891,14 @@ class smt2_printer {
|
|||
symbol * it = m_var_names.end() - num_decls;
|
||||
for (unsigned i = 0; i < num_decls; i++, it++) {
|
||||
format * fs[1] = { m_env.pp_sort(q->get_decl_sort(i)) };
|
||||
buf.push_back(mk_seq1<format**,f2f>(m(), fs, fs+1, f2f(), it->str().c_str()));
|
||||
std::string var_name;
|
||||
if (is_smt2_quoted_symbol (*it)) {
|
||||
var_name = mk_smt2_quoted_symbol (*it);
|
||||
}
|
||||
else {
|
||||
var_name = it->str ();\
|
||||
}
|
||||
buf.push_back(mk_seq1<format**,f2f>(m(), fs, fs+1, f2f(), var_name.c_str ()));
|
||||
}
|
||||
return mk_seq5(m(), buf.begin(), buf.end(), f2f());
|
||||
}
|
||||
|
|
|
@ -732,7 +732,7 @@ void bv_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const
|
|||
op_names.push_back(builtin_name("bvudiv_i", OP_BUDIV_I));
|
||||
op_names.push_back(builtin_name("bvsrem_i", OP_BSREM_I));
|
||||
op_names.push_back(builtin_name("bvurem_i", OP_BUREM_I));
|
||||
op_names.push_back(builtin_name("bvumod_i", OP_BSMOD_I));
|
||||
op_names.push_back(builtin_name("bvsmod_i", OP_BSMOD_I));
|
||||
|
||||
op_names.push_back(builtin_name("ext_rotate_left",OP_EXT_ROTATE_LEFT));
|
||||
op_names.push_back(builtin_name("ext_rotate_right",OP_EXT_ROTATE_RIGHT));
|
||||
|
|
|
@ -35,6 +35,13 @@ class expr_map {
|
|||
obj_map<expr, expr*> m_expr2expr;
|
||||
obj_map<expr, proof*> m_expr2pr;
|
||||
public:
|
||||
typedef obj_map<expr, expr*> Map;
|
||||
typedef Map::iterator iterator;
|
||||
typedef Map::key key;
|
||||
typedef Map::value value;
|
||||
typedef Map::data data;
|
||||
typedef Map::entry entry;
|
||||
|
||||
expr_map(ast_manager & m);
|
||||
expr_map(ast_manager & m, bool store_proofs);
|
||||
~expr_map();
|
||||
|
@ -44,6 +51,8 @@ public:
|
|||
void erase(expr * k);
|
||||
void reset();
|
||||
void flush();
|
||||
iterator begin () const { return m_expr2expr.begin (); }
|
||||
iterator end () const {return m_expr2expr.end (); }
|
||||
void set_store_proofs(bool f) {
|
||||
if (m_store_proofs != f) flush();
|
||||
m_store_proofs = f;
|
||||
|
|
13
src/ast/fpa/CMakeLists.txt
Normal file
13
src/ast/fpa/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
z3_add_component(fpa
|
||||
SOURCES
|
||||
bv2fpa_converter.cpp
|
||||
fpa2bv_converter.cpp
|
||||
fpa2bv_rewriter.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
ast
|
||||
simplifier
|
||||
model
|
||||
util
|
||||
PYG_FILES
|
||||
fpa2bv_rewriter_params.pyg
|
||||
)
|
|
@ -1632,8 +1632,6 @@ void fpa2bv_converter::mk_fma(func_decl * f, unsigned num, expr * const * args,
|
|||
|
||||
res_exp = e_exp;
|
||||
|
||||
// Result could overflow into 4.xxx ...
|
||||
|
||||
family_id bvfid = m_bv_util.get_fid();
|
||||
expr_ref res_sgn_c1(m), res_sgn_c2(m), res_sgn_c3(m);
|
||||
expr_ref not_e_sgn(m), not_f_sgn(m), not_sign_bv(m);
|
||||
|
@ -1646,11 +1644,34 @@ void fpa2bv_converter::mk_fma(func_decl * f, unsigned num, expr * const * args,
|
|||
expr * res_sgn_or_args[3] = { res_sgn_c1, res_sgn_c2, res_sgn_c3 };
|
||||
res_sgn = m_bv_util.mk_bv_or(3, res_sgn_or_args);
|
||||
|
||||
// Result could have overflown into 4.xxx.
|
||||
SASSERT(m_bv_util.get_bv_size(sig_abs) == 2 * sbits + 2);
|
||||
expr_ref ovfl_into_4(m);
|
||||
ovfl_into_4 = m.mk_eq(m_bv_util.mk_extract(2 * sbits + 1, 2 * sbits, sig_abs),
|
||||
m_bv_util.mk_numeral(1, 2));
|
||||
dbg_decouple("fpa2bv_fma_ovfl_into_4", ovfl_into_4);
|
||||
if (sbits > 5) {
|
||||
sticky_raw = m_bv_util.mk_extract(sbits - 5, 0, sig_abs);
|
||||
sticky = m_bv_util.mk_zero_extend(sbits + 3, m.mk_app(bvfid, OP_BREDOR, sticky_raw.get()));
|
||||
expr * res_or_args[2] = { m_bv_util.mk_extract(2 * sbits - 1, sbits - 4, sig_abs), sticky };
|
||||
res_sig = m_bv_util.mk_bv_or(2, res_or_args);
|
||||
expr_ref sticky_raw(m), sig_upper(m), sticky_redd(m), res_sig_norm(m);
|
||||
sticky_raw = m_bv_util.mk_extract(sbits - 4, 0, sig_abs);
|
||||
sig_upper = m_bv_util.mk_extract(2 * sbits, sbits - 3, sig_abs);
|
||||
SASSERT(m_bv_util.get_bv_size(sig_upper) == sbits + 4);
|
||||
sticky_redd = m.mk_app(bvfid, OP_BREDOR, sticky_raw.get());
|
||||
sticky = m_bv_util.mk_zero_extend(sbits + 3, sticky_redd);
|
||||
expr * res_or_args[2] = { sig_upper, sticky };
|
||||
res_sig_norm = m_bv_util.mk_bv_or(2, res_or_args);
|
||||
|
||||
expr_ref sticky_raw_ovfl(m), sig_upper_ovfl(m), sticky_redd_ovfl(m), sticky_ovfl(m), res_sig_ovfl(m);
|
||||
sticky_raw_ovfl = m_bv_util.mk_extract(sbits - 4, 0, sig_abs);
|
||||
sig_upper_ovfl = m_bv_util.mk_extract(2 * sbits, sbits - 3, sig_abs);
|
||||
SASSERT(m_bv_util.get_bv_size(sig_upper_ovfl) == sbits + 4);
|
||||
sticky_redd_ovfl = m.mk_app(bvfid, OP_BREDOR, sticky_raw_ovfl.get());
|
||||
sticky_ovfl = m_bv_util.mk_zero_extend(sbits + 3, sticky_redd_ovfl);
|
||||
expr * res_or_args_ovfl[2] = { sig_upper_ovfl, sticky_ovfl };
|
||||
res_sig_ovfl = m_bv_util.mk_bv_or(2, res_or_args_ovfl);
|
||||
|
||||
res_sig = m.mk_ite(ovfl_into_4, res_sig_ovfl, res_sig_norm);
|
||||
res_exp = m.mk_ite(ovfl_into_4, m_bv_util.mk_bv_add(res_exp, m_bv_util.mk_numeral(1, ebits+2)),
|
||||
res_exp);
|
||||
}
|
||||
else {
|
||||
unsigned too_short = 6 - sbits;
|
||||
|
@ -1658,6 +1679,8 @@ void fpa2bv_converter::mk_fma(func_decl * f, unsigned num, expr * const * args,
|
|||
res_sig = m_bv_util.mk_extract(sbits + 3, 0, sig_abs);
|
||||
}
|
||||
dbg_decouple("fpa2bv_fma_add_sum_sticky", sticky);
|
||||
dbg_decouple("fpa2bv_fma_sig_abs", sig_abs);
|
||||
dbg_decouple("fpa2bv_fma_res_sig", res_sig);
|
||||
SASSERT(m_bv_util.get_bv_size(res_sig) == sbits + 4);
|
||||
|
||||
expr_ref is_zero_sig(m), nil_sbits4(m);
|
||||
|
|
9
src/ast/macros/CMakeLists.txt
Normal file
9
src/ast/macros/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
z3_add_component(macros
|
||||
SOURCES
|
||||
macro_finder.cpp
|
||||
macro_manager.cpp
|
||||
macro_util.cpp
|
||||
quasi_macros.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
simplifier
|
||||
)
|
13
src/ast/normal_forms/CMakeLists.txt
Normal file
13
src/ast/normal_forms/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
z3_add_component(normal_forms
|
||||
SOURCES
|
||||
defined_names.cpp
|
||||
name_exprs.cpp
|
||||
nnf.cpp
|
||||
pull_quant.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
rewriter
|
||||
PYG_FILES
|
||||
nnf_params.pyg
|
||||
EXTRA_REGISTER_MODULE_HEADERS
|
||||
nnf.h
|
||||
)
|
36
src/ast/pattern/CMakeLists.txt
Normal file
36
src/ast/pattern/CMakeLists.txt
Normal file
|
@ -0,0 +1,36 @@
|
|||
# If this code for adding the rule to generate the database file is ever needed
|
||||
# for other components then we should refactor this code into
|
||||
# z3_add_component()
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/database.h")
|
||||
message(FATAL_ERROR "The generated file \"${CMAKE_CURRENT_SOURCE_DIR}/database.h\""
|
||||
${z3_polluted_tree_msg})
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "database.h"
|
||||
COMMAND "${PYTHON_EXECUTABLE}"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/mk_pat_db.py"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/database.smt2"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/database.h"
|
||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/database.smt2"
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/scripts/mk_pat_db.py"
|
||||
${Z3_GENERATED_FILE_EXTRA_DEPENDENCIES}
|
||||
COMMENT "Generating \"database.h\""
|
||||
${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
z3_add_component(pattern
|
||||
SOURCES
|
||||
expr_pattern_match.cpp
|
||||
pattern_inference.cpp
|
||||
pattern_inference_params.cpp
|
||||
# Let CMake know this target depends on this generated
|
||||
# header file
|
||||
${CMAKE_CURRENT_BINARY_DIR}/database.h
|
||||
COMPONENT_DEPENDENCIES
|
||||
normal_forms
|
||||
simplifier
|
||||
smt2parser
|
||||
PYG_FILES
|
||||
pattern_inference_params_helper.pyg
|
||||
)
|
|
@ -109,6 +109,7 @@ public:
|
|||
bool is_ge(func_decl* a) const;
|
||||
bool is_ge(expr* a) const { return is_app(a) && is_ge(to_app(a)->get_decl()); }
|
||||
bool is_ge(expr* a, rational& k) const;
|
||||
bool is_aux_bool(func_decl* f) const { return is_decl_of(f, m_fid, OP_PB_AUX_BOOL); }
|
||||
bool is_aux_bool(expr* e) const { return is_app_of(e, m_fid, OP_PB_AUX_BOOL); }
|
||||
rational get_coeff(expr* a, unsigned index) const { return get_coeff(to_app(a)->get_decl(), index); }
|
||||
rational get_coeff(func_decl* a, unsigned index) const;
|
||||
|
|
6
src/ast/proof_checker/CMakeLists.txt
Normal file
6
src/ast/proof_checker/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
z3_add_component(proof_checker
|
||||
SOURCES
|
||||
proof_checker.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
rewriter
|
||||
)
|
41
src/ast/rewriter/CMakeLists.txt
Normal file
41
src/ast/rewriter/CMakeLists.txt
Normal file
|
@ -0,0 +1,41 @@
|
|||
z3_add_component(rewriter
|
||||
SOURCES
|
||||
arith_rewriter.cpp
|
||||
array_rewriter.cpp
|
||||
ast_counter.cpp
|
||||
bool_rewriter.cpp
|
||||
bv_bounds.cpp
|
||||
bv_rewriter.cpp
|
||||
datatype_rewriter.cpp
|
||||
der.cpp
|
||||
distribute_forall.cpp
|
||||
dl_rewriter.cpp
|
||||
enum2bv_rewriter.cpp
|
||||
expr_replacer.cpp
|
||||
expr_safe_replace.cpp
|
||||
factor_rewriter.cpp
|
||||
fpa_rewriter.cpp
|
||||
label_rewriter.cpp
|
||||
mk_simplified_app.cpp
|
||||
pb_rewriter.cpp
|
||||
pb2bv_rewriter.cpp
|
||||
quant_hoist.cpp
|
||||
rewriter.cpp
|
||||
seq_rewriter.cpp
|
||||
th_rewriter.cpp
|
||||
var_subst.cpp
|
||||
bv_trailing.cpp
|
||||
mk_extract_proc.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
ast
|
||||
automata
|
||||
polynomial
|
||||
PYG_FILES
|
||||
arith_rewriter_params.pyg
|
||||
array_rewriter_params.pyg
|
||||
bool_rewriter_params.pyg
|
||||
bv_rewriter_params.pyg
|
||||
fpa_rewriter_params.pyg
|
||||
poly_rewriter_params.pyg
|
||||
rewriter_params.pyg
|
||||
)
|
|
@ -1030,7 +1030,7 @@ br_status arith_rewriter::mk_power_core(expr * arg1, expr * arg2, expr_ref & res
|
|||
|
||||
br_status arith_rewriter::mk_to_int_core(expr * arg, expr_ref & result) {
|
||||
numeral a;
|
||||
expr* x;
|
||||
expr* x = 0;
|
||||
if (m_util.is_numeral(arg, a)) {
|
||||
result = m_util.mk_numeral(floor(a), true);
|
||||
return BR_DONE;
|
||||
|
|
8
src/ast/rewriter/bit_blaster/CMakeLists.txt
Normal file
8
src/ast/rewriter/bit_blaster/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
z3_add_component(bit_blaster
|
||||
SOURCES
|
||||
bit_blaster.cpp
|
||||
bit_blaster_rewriter.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
rewriter
|
||||
simplifier
|
||||
)
|
|
@ -196,6 +196,7 @@ void pb_rewriter::dump_pb_rewrite(expr* fml) {
|
|||
}
|
||||
|
||||
br_status pb_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) {
|
||||
if (m_util.is_aux_bool(f)) return BR_FAILED;
|
||||
ast_manager& m = result.get_manager();
|
||||
rational sum(0), maxsum(0);
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
|
|
29
src/ast/simplifier/CMakeLists.txt
Normal file
29
src/ast/simplifier/CMakeLists.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
z3_add_component(simplifier
|
||||
SOURCES
|
||||
arith_simplifier_params.cpp
|
||||
arith_simplifier_plugin.cpp
|
||||
array_simplifier_params.cpp
|
||||
array_simplifier_plugin.cpp
|
||||
basic_simplifier_plugin.cpp
|
||||
bit2int.cpp
|
||||
bv_elim.cpp
|
||||
bv_simplifier_params.cpp
|
||||
bv_simplifier_plugin.cpp
|
||||
datatype_simplifier_plugin.cpp
|
||||
elim_bounds.cpp
|
||||
fpa_simplifier_plugin.cpp
|
||||
inj_axiom.cpp
|
||||
maximise_ac_sharing.cpp
|
||||
poly_simplifier_plugin.cpp
|
||||
pull_ite_tree.cpp
|
||||
push_app_ite.cpp
|
||||
seq_simplifier_plugin.cpp
|
||||
simplifier.cpp
|
||||
simplifier_plugin.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
rewriter
|
||||
PYG_FILES
|
||||
arith_simplifier_params_helper.pyg
|
||||
array_simplifier_params_helper.pyg
|
||||
bv_simplifier_params_helper.pyg
|
||||
)
|
10
src/ast/substitution/CMakeLists.txt
Normal file
10
src/ast/substitution/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
z3_add_component(substitution
|
||||
SOURCES
|
||||
matcher.cpp
|
||||
substitution.cpp
|
||||
substitution_tree.cpp
|
||||
unifier.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
ast
|
||||
rewriter
|
||||
)
|
|
@ -85,7 +85,7 @@ void substitution::apply(unsigned num_actual_offsets, unsigned const * deltas, e
|
|||
m_state = APPLY;
|
||||
|
||||
unsigned j;
|
||||
expr * e;
|
||||
expr * e = 0;
|
||||
unsigned off;
|
||||
expr_offset n1;
|
||||
bool visited;
|
||||
|
@ -214,7 +214,7 @@ void substitution::apply(unsigned num_actual_offsets, unsigned const * deltas, e
|
|||
}
|
||||
}
|
||||
SASSERT(m_apply_cache.contains(n));
|
||||
m_apply_cache.find(n, e);
|
||||
VERIFY(m_apply_cache.find(n, e));
|
||||
m_new_exprs.push_back(e);
|
||||
result = e;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue