mirror of
https://github.com/Z3Prover/z3
synced 2025-05-09 00:35:47 +00:00
Z3 sources
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
3f9edad676
commit
e9eab22e5c
1186 changed files with 381859 additions and 0 deletions
84
lib/expr2dot.cpp
Normal file
84
lib/expr2dot.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
expr2dot.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2008-03-07.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"expr2dot.h"
|
||||
#include"for_each_expr.h"
|
||||
|
||||
class dot_printer {
|
||||
std::ostream & m_out;
|
||||
ast_manager & m_manager;
|
||||
bool m_proofs_only;
|
||||
public:
|
||||
dot_printer(std::ostream & out, ast_manager & m, bool proofs):
|
||||
m_out(out),
|
||||
m_manager(m),
|
||||
m_proofs_only(proofs) {
|
||||
}
|
||||
|
||||
char const * get_color(app * n) {
|
||||
if (m_manager.is_unit_resolution(n))
|
||||
return "blue";
|
||||
else if (m_manager.is_lemma(n))
|
||||
return "gold";
|
||||
else if (m_manager.is_transitivity(n))
|
||||
return "red";
|
||||
else if (m_manager.is_monotonicity(n))
|
||||
return "green";
|
||||
else
|
||||
return "black";
|
||||
}
|
||||
|
||||
void operator()(var * n) {
|
||||
if (!m_proofs_only) {
|
||||
m_out << n->get_id() << "[label=\"\",shape=circle];\n";
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(quantifier * n) {
|
||||
if (!m_proofs_only) {
|
||||
m_out << n->get_id() << "[label=\"\",shape=circle,color=gray];\n";
|
||||
m_out << n->get_expr()->get_id() << " -> " << n->get_id() << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(app * n) {
|
||||
if (!m_proofs_only || m_manager.is_proof(n)) {
|
||||
char const * c = get_color(n);
|
||||
m_out << n->get_id() << "[label=\"\",shape=circle,color=" << c << "];\n";
|
||||
if (m_proofs_only) {
|
||||
unsigned num = m_manager.get_num_parents(n);
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
m_out << m_manager.get_parent(n, i)->get_id() << " -> " << n->get_id() << " [color=" << c << "];\n";
|
||||
}
|
||||
else {
|
||||
unsigned num = n->get_num_args();
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
m_out << n->get_arg(i)->get_id() << " -> " << n->get_id() << " [color=" << c << "];\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void expr2dot(std::ostream & out, expr * n, ast_manager & m, bool proofs) {
|
||||
out << "digraph \"ast\" {\n";
|
||||
dot_printer p(out, m, proofs);
|
||||
for_each_expr(p, n);
|
||||
out << "}\n";
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue