diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 9955cbc8f..eda6831b5 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -964,8 +964,7 @@ extern "C" { case PR_TH_LEMMA: return Z3_OP_PR_TH_LEMMA; case PR_HYPER_RESOLVE: return Z3_OP_PR_HYPER_RESOLVE; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } if (mk_c(c)->get_arith_fid() == _d->get_family_id()) { @@ -989,8 +988,7 @@ extern "C" { case OP_TO_INT: return Z3_OP_TO_INT; case OP_IS_INT: return Z3_OP_IS_INT; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } if (mk_c(c)->get_array_fid() == _d->get_family_id()) { @@ -1008,8 +1006,7 @@ extern "C" { case OP_AS_ARRAY: return Z3_OP_AS_ARRAY; case OP_ARRAY_EXT: return Z3_OP_ARRAY_EXT; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } @@ -1075,8 +1072,7 @@ extern "C" { case OP_BUREM_I: return Z3_OP_BUREM_I; case OP_BSMOD_I: return Z3_OP_BSMOD_I; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } if (mk_c(c)->get_dt_fid() == _d->get_family_id()) { @@ -1086,8 +1082,7 @@ extern "C" { case OP_DT_ACCESSOR: return Z3_OP_DT_ACCESSOR; case OP_DT_UPDATE_FIELD: return Z3_OP_DT_UPDATE_FIELD; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } if (mk_c(c)->get_datalog_fid() == _d->get_family_id()) { @@ -1108,8 +1103,7 @@ extern "C" { case datalog::OP_DL_CONSTANT: return Z3_OP_FD_CONSTANT; case datalog::OP_DL_LT: return Z3_OP_FD_LT; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } @@ -1135,7 +1129,7 @@ extern "C" { case Z3_OP_RE_CONCAT: return Z3_OP_RE_CONCAT; case Z3_OP_RE_UNION: return Z3_OP_RE_UNION; default: - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } @@ -1195,8 +1189,7 @@ extern "C" { case OP_FPA_INTERNAL_TO_IEEE_BV_UNSPECIFIED: return Z3_OP_UNINTERPRETED; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } @@ -1205,8 +1198,7 @@ extern "C" { case OP_LABEL: return Z3_OP_LABEL; case OP_LABEL_LIT: return Z3_OP_LABEL_LIT; default: - UNREACHABLE(); - return Z3_OP_UNINTERPRETED; + return Z3_OP_INTERNAL; } } @@ -1215,7 +1207,7 @@ extern "C" { case OP_PB_LE: return Z3_OP_PB_LE; case OP_PB_GE: return Z3_OP_PB_GE; case OP_AT_MOST_K: return Z3_OP_PB_AT_MOST; - default: UNREACHABLE(); + default: return Z3_OP_INTERNAL; } } diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 5ce2740d9..41ca923bb 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -945,6 +945,8 @@ typedef enum - Z3_OP_FPA_TO_IEEE_BV: Floating-point conversion to IEEE-754 bit-vector + - Z3_OP_INTERNAL: internal (often interpreted) symbol, but no additional information is exposed. Tools may use the string representation of the function declaration to obtain more information. + - Z3_OP_UNINTERPRETED: kind used for uninterpreted symbols. */ typedef enum { @@ -1217,6 +1219,8 @@ typedef enum { Z3_OP_FPA_MIN_I, Z3_OP_FPA_MAX_I, + Z3_OP_INTERNAL, + Z3_OP_UNINTERPRETED } Z3_decl_kind; diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index d8a6c47bc..d138685ed 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -2991,7 +2991,10 @@ proof * ast_manager::mk_unit_resolution(unsigned num_proofs, proof * const * pro for (unsigned i = 0; i < num_proofs; i++) tout << mk_pp(get_fact(proofs[i]), *this) << "\n"; tout << "===>\n"; tout << mk_pp(new_fact, *this) << "\n";); - SASSERT(num_proofs == cls_sz || (num_proofs == cls_sz + 1 && is_false(new_fact))); + // + // typically: num_proofs == cls_sz || (num_proofs == cls_sz + 1 && is_false(new_fact)) + // but formula could have repeated literals that are merged in the clausal representation. + // unsigned num_matches = 0; for (unsigned i = 0; i < cls_sz; i++) { expr * lit = cls->get_arg(i); diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index 45bd75ab7..a17271e4e 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -1045,15 +1045,13 @@ namespace smt { bool context::simplify_aux_clause_literals(unsigned & num_lits, literal * lits, literal_buffer & simp_lits) { std::sort(lits, lits + num_lits); literal prev = null_literal; - unsigned i = 0; unsigned j = 0; - for (; i < num_lits; i++) { + for (unsigned i = 0; i < num_lits; i++) { literal curr = lits[i]; lbool val = get_assignment(curr); - if (val == l_false) - simp_lits.push_back(~curr); switch(val) { case l_false: + simp_lits.push_back(~curr); break; // ignore literal case l_undef: if (curr == ~prev) @@ -1295,8 +1293,9 @@ namespace smt { SASSERT(get_assignment(simp_lits[i]) == l_true); } }); - if (old_num_lits != num_lits) + if (!simp_lits.empty()) { j = mk_justification(unit_resolution_justification(m_region, j, simp_lits.size(), simp_lits.c_ptr())); + } break; } case CLS_AUX_LEMMA: { diff --git a/src/smt/smt_justification.cpp b/src/smt/smt_justification.cpp index de3594fcc..c091f6973 100644 --- a/src/smt/smt_justification.cpp +++ b/src/smt/smt_justification.cpp @@ -52,6 +52,7 @@ namespace smt { tout << lits[i] << " "; } tout << "\n";); + SASSERT(m_num_literals > 0); } unit_resolution_justification::unit_resolution_justification(justification * js, @@ -68,6 +69,7 @@ namespace smt { tout << lits[i] << " "; } tout << "\n";); + SASSERT(num_lits != 0); } unit_resolution_justification::~unit_resolution_justification() { diff --git a/src/smt/theory_bv.cpp b/src/smt/theory_bv.cpp index 2945c8c93..a53580b73 100644 --- a/src/smt/theory_bv.cpp +++ b/src/smt/theory_bv.cpp @@ -312,6 +312,7 @@ namespace smt { SASSERT(v != null_theory_var); unsigned sz = bits.size(); SASSERT(get_bv_size(n) == sz); + m_bits[v].reset(); for (unsigned i = 0; i < sz; i++) { expr * bit = bits.get(i); expr_ref s_bit(m); @@ -809,6 +810,7 @@ namespace smt { theory_var v = e->get_th_var(get_id()); unsigned num_args = n->get_num_args(); unsigned i = num_args; + m_bits[v].reset(); while (i > 0) { i--; theory_var arg = get_arg_var(e, i); @@ -830,6 +832,7 @@ namespace smt { unsigned end = n->get_decl()->get_parameter(0).get_int(); SASSERT(start <= end); literal_vector & arg_bits = m_bits[arg]; + m_bits[v].reset(); for (unsigned i = start; i <= end; ++i) add_bit(v, arg_bits[i]); find_wpos(v); @@ -1533,6 +1536,7 @@ namespace smt { } void theory_bv::unmerge_eh(theory_var v1, theory_var v2) { + // v1 was the root of the equivalence class // I must remove the zero_one_bits that are from v2.