3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-07-26 10:32:54 -07:00
parent 56c78753f0
commit 67c6f9be91
3 changed files with 34 additions and 32 deletions

View file

@ -1227,11 +1227,11 @@ public:
void display_axiom(std::ostream& out, z3::expr e) { void display_axiom(std::ostream& out, z3::expr e) {
out << "tff(formula" << (++m_formula_id) << ", axiom,\n "; out << "tff(formula" << (++m_formula_id) << ", axiom,\n ";
display(out, e); display(out, e, true);
out << ").\n"; out << ").\n";
} }
void display(std::ostream& out, z3::expr e) { void display(std::ostream& out, z3::expr e, bool in_paren) {
std::string s; std::string s;
if (e.is_numeral(s)) { if (e.is_numeral(s)) {
out << s; out << s;
@ -1249,32 +1249,33 @@ public:
out << "$false"; out << "$false";
break; break;
case Z3_OP_AND: case Z3_OP_AND:
display_infix(out, "&", e); display_infix(out, "&", e, in_paren);
break; break;
case Z3_OP_OR: case Z3_OP_OR:
display_infix(out, "|", e); display_infix(out, "|", e, in_paren);
break; break;
case Z3_OP_IMPLIES: case Z3_OP_IMPLIES:
display_infix(out, "=>", e); display_infix(out, "=>", e, in_paren);
break; break;
case Z3_OP_NOT: case Z3_OP_NOT:
out << "(~"; if (!in_paren) out << "(";
display(out, e.arg(0)); out << "~";
out << ")"; display(out, e.arg(0), false);
if (!in_paren) out << ")";
break; break;
case Z3_OP_EQ: case Z3_OP_EQ:
if (e.arg(0).is_bool()) { if (e.arg(0).is_bool()) {
display_infix(out, "<=>", e); display_infix(out, "<=>", e, in_paren);
} }
else { else {
display_infix(out, "=", e); display_infix(out, "=", e, in_paren);
} }
break; break;
case Z3_OP_IFF: case Z3_OP_IFF:
display_infix(out, "<=>", e); display_infix(out, "<=>", e, in_paren);
break; break;
case Z3_OP_XOR: case Z3_OP_XOR:
display_infix(out, "<~>", e); display_infix(out, "<~>", e, in_paren);
break; break;
case Z3_OP_MUL: case Z3_OP_MUL:
display_binary(out, "$product", e); display_binary(out, "$product", e);
@ -1351,7 +1352,7 @@ public:
} }
} }
out << "] : "; out << "] : ";
display(out, e.body()); display(out, e.body(), false);
for (unsigned i = 0; i < nb; ++i) { for (unsigned i = 0; i < nb; ++i) {
names.pop_back(); names.pop_back();
} }
@ -1366,7 +1367,7 @@ public:
out << lower_case_fun(e.decl().name()) << "("; out << lower_case_fun(e.decl().name()) << "(";
unsigned n = e.num_args(); unsigned n = e.num_args();
for(unsigned i = 0; i < n; ++i) { for(unsigned i = 0; i < n; ++i) {
display(out, e.arg(i)); display(out, e.arg(i), n == 1);
if (i + 1 < n) { if (i + 1 < n) {
out << ", "; out << ", ";
} }
@ -1389,23 +1390,23 @@ public:
} }
} }
void display_infix(std::ostream& out, char const* conn, z3::expr& e) { void display_infix(std::ostream& out, char const* conn, z3::expr& e, bool in_paren) {
out << "("; if (!in_paren) out << "(";
unsigned sz = e.num_args(); unsigned sz = e.num_args();
for (unsigned i = 0; i < sz; ++i) { for (unsigned i = 0; i < sz; ++i) {
display(out, e.arg(i)); display(out, e.arg(i), false);
if (i + 1 < sz) { if (i + 1 < sz) {
out << " " << conn << " "; out << " " << conn << " ";
} }
} }
out << ")"; if (!in_paren) out << ")";
} }
void display_prefix(std::ostream& out, char const* conn, z3::expr& e) { void display_prefix(std::ostream& out, char const* conn, z3::expr& e) {
out << conn << "("; out << conn << "(";
unsigned sz = e.num_args(); unsigned sz = e.num_args();
for (unsigned i = 0; i < sz; ++i) { for (unsigned i = 0; i < sz; ++i) {
display(out, e.arg(i)); display(out, e.arg(i), sz == 1);
if (i + 1 < sz) { if (i + 1 < sz) {
out << ", "; out << ", ";
} }
@ -1418,7 +1419,7 @@ public:
unsigned sz = e.num_args(); unsigned sz = e.num_args();
unsigned np = 1; unsigned np = 1;
for (unsigned i = 0; i < sz; ++i) { for (unsigned i = 0; i < sz; ++i) {
display(out, e.arg(i)); display(out, e.arg(i), false);
if (i + 1 < sz) { if (i + 1 < sz) {
out << ", "; out << ", ";
} }
@ -1562,7 +1563,7 @@ public:
formula_file = "unknown"; formula_file = "unknown";
} }
out << "tff(" << m_node_number << ",axiom,("; out << "tff(" << m_node_number << ",axiom,(";
display(out, get_proof_formula(p)); display(out, get_proof_formula(p), true);
out << "), file('" << formula_file << "','"; out << "), file('" << formula_file << "','";
out << formula_name << "')).\n"; out << formula_name << "')).\n";
break; break;
@ -1625,12 +1626,12 @@ public:
break; break;
case Z3_OP_PR_HYPOTHESIS: case Z3_OP_PR_HYPOTHESIS:
out << "tff(" << m_node_number << ",assumption,("; out << "tff(" << m_node_number << ",assumption,(";
display(out, get_proof_formula(p)); display(out, get_proof_formula(p), true);
out << "), introduced(assumption)).\n"; out << "), introduced(assumption)).\n";
break; break;
case Z3_OP_PR_LEMMA: { case Z3_OP_PR_LEMMA: {
out << "tff(" << m_node_number << ",plain,("; out << "tff(" << m_node_number << ",plain,(";
display(out, get_proof_formula(p)); display(out, get_proof_formula(p), true);
out << "), inference(lemma,lemma(discharge,"; out << "), inference(lemma,lemma(discharge,";
unsigned parent_id = Z3_get_ast_id(ctx, p.arg(0)); unsigned parent_id = Z3_get_ast_id(ctx, p.arg(0));
std::set<unsigned> const& hyps = m_proof_hypotheses.find(parent_id)->second; std::set<unsigned> const& hyps = m_proof_hypotheses.find(parent_id)->second;
@ -1747,7 +1748,7 @@ public:
unsigned id = Z3_get_ast_id(ctx, p); unsigned id = Z3_get_ast_id(ctx, p);
std::set<unsigned> const& hyps = m_proof_hypotheses.find(id)->second; std::set<unsigned> const& hyps = m_proof_hypotheses.find(id)->second;
out << "tff(" << m_node_number << ",plain,\n ("; out << "tff(" << m_node_number << ",plain,\n (";
display(out, get_proof_formula(p)); display(out, get_proof_formula(p), true);
out << "),\n inference(" << name << ",[status(" << status << ")"; out << "),\n inference(" << name << ",[status(" << status << ")";
if (!hyps.empty()) { if (!hyps.empty()) {
out << ", assumptions("; out << ", assumptions(";
@ -1776,7 +1777,7 @@ public:
unsigned display_hyp_inference(std::ostream& out, char const* name, char const* status, z3::expr conclusion, unsigned hyp1, unsigned hyp2 = 0) { unsigned display_hyp_inference(std::ostream& out, char const* name, char const* status, z3::expr conclusion, unsigned hyp1, unsigned hyp2 = 0) {
++m_node_number; ++m_node_number;
out << "tff(" << m_node_number << ",plain,(\n "; out << "tff(" << m_node_number << ",plain,(\n ";
display(out, conclusion); display(out, conclusion, true);
out << "),\n inference(" << name << ",[status(" << status << ")],"; out << "),\n inference(" << name << ",[status(" << status << ")],";
out << "[" << hyp1; out << "[" << hyp1;
if (hyp2) { if (hyp2) {
@ -2467,7 +2468,6 @@ static void prove_tptp() {
int main(int argc, char** argv) { int main(int argc, char** argv) {
//std::ostream* out = &std::cout;
g_start_time = static_cast<double>(clock()); g_start_time = static_cast<double>(clock());
signal(SIGINT, on_ctrl_c); signal(SIGINT, on_ctrl_c);
@ -2484,10 +2484,8 @@ int main(int argc, char** argv) {
prove_tptp(); prove_tptp();
} }
catch (z3::exception& ex) { catch (z3::exception& ex) {
std::cerr << "Proof display could not be completed: " << ex.msg() << "\n"; std::cerr << "Exception during proof: " << ex.msg() << "\n";
} }
} }
return 0; return 0;
} }

View file

@ -96,8 +96,8 @@ class symbolic_automata {
public: public:
symbolic_automata(M& m, ba_t& ba): m(m), m_ba(ba) {} symbolic_automata(M& m, ba_t& ba): m(m), m_ba(ba) {}
automaton_t* mk_determinstic(automaton_t& a); //automaton_t* mk_determinstic(automaton_t& a);
automaton_t* mk_complement(automaton_t& a); //automaton_t* mk_complement(automaton_t& a);
automaton_t* remove_epsilons(automaton_t& a); automaton_t* remove_epsilons(automaton_t& a);
automaton_t* mk_total(automaton_t& a); automaton_t* mk_total(automaton_t& a);
automaton_t* mk_minimize(automaton_t& a); automaton_t* mk_minimize(automaton_t& a);

View file

@ -895,7 +895,7 @@ namespace pdr {
SASSERT(m_prev); SASSERT(m_prev);
SASSERT(children().empty()); SASSERT(children().empty());
if (this == m_next) { if (this == m_next) {
SASSERT(root == this); // SASSERT(root == this);
root = 0; root = 0;
} }
else { else {
@ -1818,6 +1818,10 @@ namespace pdr {
m_fparams.m_arith_mode = AS_UTVPI; m_fparams.m_arith_mode = AS_UTVPI;
m_fparams.m_arith_expand_eqs = true; m_fparams.m_arith_expand_eqs = true;
} }
else {
m_fparams.m_arith_mode = AS_ARITH;
m_fparams.m_arith_expand_eqs = false;
}
} }
} }
if (m_params.pdr_use_convex_closure_generalizer()) { if (m_params.pdr_use_convex_closure_generalizer()) {