summaryrefslogtreecommitdiff
path: root/src/proof/dot/dot_printer.h
blob: 6e6785080f7d5702bd641e6f3e785f3c55e85cfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/******************************************************************************
 * Top contributors (to current version):
 *   Diego Della Rocca de Camargos
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * The module for printing dot proofs.
 */

#include "cvc5_private.h"

#ifndef CVC5__PROOF__DOT__DOT_PRINTER_H
#define CVC5__PROOF__DOT__DOT_PRINTER_H

#include <iostream>

#include "expr/proof_node.h"

namespace cvc5 {
namespace proof {

class DotPrinter
{
 public:
  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);

 private:
  /**
   * Print the nodes of the proof in the format:
   * $NODE_ID [ label = "{$CONCLUSION|$RULE_NAME($RULE_ARGUMENTS)}",
   * $COLORS_AND_CLASSES_RELATED_TO_THE_RULE ]; and then for each child of the
   * node $CHILD_ID -> $NODE_ID; and then recursively calls the function with
   * the child as argument.
   * @param out the output stream
   * @param pn the proof node to print
   * @param ruleID the id of the rule to print
   * @param scopeCounter counter of how many SCOPE were already depth-first
   * traversed in the proof up to this point
   * @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);

  /**
   * Return the arguments of a ProofNode
   * @param currentArguments an ostringstream that will store the arguments of
   * pn formatted as "$ARG[0], $ARG[1], ..., $ARG[N-1]"
   * @param pn a ProofNode
   */
  static 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.
   * @return The string with the special characters escaped.
   */
  static std::string sanitizeString(const std::string& s);
};

}  // namespace proof
}  // namespace cvc5

#endif
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback