namespace cvc5 {
namespace proof {
+DotPrinter::DotPrinter() {}
+DotPrinter::~DotPrinter() {}
+
std::string DotPrinter::sanitizeString(const std::string& s)
{
std::string newS;
return newS;
}
-void DotPrinter::countSubproofs(
- const ProofNode* pn, std::map<const ProofNode*, size_t>& subpfCounter)
+void DotPrinter::countSubproofs(const ProofNode* pn)
{
std::vector<const ProofNode*> visit;
std::unordered_map<const ProofNode*, bool> visited;
cur->getChildren();
for (const std::shared_ptr<ProofNode>& c : children)
{
- counter += subpfCounter[c.get()];
+ counter += d_subpfCounter[c.get()];
}
- subpfCounter[cur] = counter;
+ d_subpfCounter[cur] = counter;
}
} while (!visit.empty());
}
void DotPrinter::print(std::ostream& out, const ProofNode* pn)
{
uint64_t ruleID = 0;
- std::map<const ProofNode*, size_t> subpfCounter;
- countSubproofs(pn, subpfCounter);
+ countSubproofs(pn);
// The dot attribute rankdir="BT" sets the direction of the graph layout,
// placing the root node at the top. The "node [shape..." attribute sets the
// shape of all nodes to record.
out << "digraph proof {\n\trankdir=\"BT\";\n\tnode [shape=record];\n";
- DotPrinter::printInternal(out, pn, ruleID, 0, false, subpfCounter);
+ DotPrinter::printInternal(out, pn, ruleID, 0, false);
out << "}\n";
}
-void DotPrinter::printInternal(
- std::ostream& out,
- const ProofNode* pn,
- uint64_t& ruleID,
- uint64_t scopeCounter,
- bool inPropositionalView,
- const std::map<const ProofNode*, size_t>& subpfCounter)
+void DotPrinter::printInternal(std::ostream& out,
+ const ProofNode* pn,
+ uint64_t& ruleID,
+ uint64_t scopeCounter,
+ bool inPropositionalView)
{
uint64_t currentRuleID = ruleID;
const std::vector<std::shared_ptr<ProofNode>>& children = pn->getChildren();
classes << " \"";
out << classes.str() << colors.str();
// add number of subchildren
- std::map<const ProofNode*, size_t>::const_iterator it = subpfCounter.find(pn);
+ std::map<const ProofNode*, size_t>::const_iterator it =
+ d_subpfCounter.find(pn);
out << ", comment = \"\{\"subProofQty\":" << it->second << "}\"";
out << " ];\n";
{
++ruleID;
out << "\t" << ruleID << " -> " << currentRuleID << ";\n";
- printInternal(
- out, c.get(), ruleID, scopeCounter, inPropositionalView, subpfCounter);
+ printInternal(out, c.get(), ruleID, scopeCounter, inPropositionalView);
}
}
{
public:
DotPrinter();
- ~DotPrinter() {}
+ ~DotPrinter();
/**
* Print the full proof of assertions => false by pn using the dot format.
* @param out the output stream
* @param pn the root node of the proof to print
*/
- static void print(std::ostream& out, const ProofNode* pn);
+ void print(std::ostream& out, const ProofNode* pn);
private:
/**
* @param inPropositionalView flag used to mark the proof node being traversed
* was generated by the SAT solver and thus belong to the propositional view
*/
- static void printInternal(
- std::ostream& out,
- const ProofNode* pn,
- uint64_t& ruleID,
- uint64_t scopeCounter,
- bool inPropositionalView,
- const std::map<const ProofNode*, size_t>& subpfCounter);
+ void printInternal(std::ostream& out,
+ const ProofNode* pn,
+ uint64_t& ruleID,
+ uint64_t scopeCounter,
+ bool inPropositionalView);
/**
* Return the arguments of a ProofNode
* pn formatted as "$ARG[0], $ARG[1], ..., $ARG[N-1]"
* @param pn a ProofNode
*/
- static void ruleArguments(std::ostringstream& currentArguments,
- const ProofNode* pn);
+ void ruleArguments(std::ostringstream& currentArguments, const ProofNode* pn);
/** Add an escape character before special characters of the given string.
* @param s The string to have the characters processed.
*/
static std::string sanitizeString(const std::string& s);
- /** Traverse proof node and map each proof node to the number of subproofs it
- * contains, including itself
+ /** Traverse proof node and populate d_subpfCounter, mapping each proof node
+ * to the number of subproofs it contains, including itself
*
* @param pn the proof node to be traversed
- * @param subpfCounter the map to be populated
*/
- static void countSubproofs(const ProofNode* pn,
- std::map<const ProofNode*, size_t>& subpfCounter);
+ void countSubproofs(const ProofNode* pn);
+
+ /** All unique subproofs of a given proof node (counting itself). */
+ std::map<const ProofNode*, size_t> d_subpfCounter;
+
};
} // namespace proof