GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/proof/lfsc/lfsc_printer.h Lines: 1 1 100.0 %
Date: 2021-11-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * The printer for LFSC proofs
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC4__PROOF__LFSC__LFSC_PRINTER_H
19
#define CVC4__PROOF__LFSC__LFSC_PRINTER_H
20
21
#include <iosfwd>
22
#include <map>
23
24
#include "expr/node.h"
25
#include "printer/let_binding.h"
26
#include "proof/lfsc/lfsc_node_converter.h"
27
#include "proof/lfsc/lfsc_util.h"
28
#include "proof/print_expr.h"
29
#include "proof/proof_node.h"
30
31
namespace cvc5 {
32
namespace proof {
33
34
class LfscPrintChannel;
35
36
/**
37
 * The LFSC printer, which prints proof nodes in a proof that is checkable
38
 * by LFSC using the signature, currently located at:
39
 * https://github.com/CVC4/signatures/tree/master/lfsc/new.
40
 *
41
 * It expects to print proof nodes that have been processed by the LFSC
42
 * proof post processor.
43
 */
44
class LfscPrinter
45
{
46
 public:
47
  LfscPrinter(LfscNodeConverter& ltp);
48
1
  ~LfscPrinter() {}
49
50
  /**
51
   * Print the full proof of assertions => false by pn on output stream out.
52
   */
53
  void print(std::ostream& out,
54
             const std::vector<Node>& assertions,
55
             const ProofNode* pn);
56
57
  /**
58
   * Print node to stream in the expected format of LFSC.
59
   */
60
  void print(std::ostream& out, Node n);
61
  /**
62
   * Print type node to stream in the expected format of LFSC.
63
   */
64
  void printType(std::ostream& out, TypeNode n);
65
66
 private:
67
  /**
68
   * Print node to stream in the expected format of LFSC.
69
   */
70
  void printLetify(std::ostream& out, Node n);
71
  /**
72
   * Print node to stream in the expected format of LFSC, where n has been
73
   * processed by the LFSC node converter.
74
   */
75
  void printInternal(std::ostream& out, Node n);
76
  /**
77
   * Print node n to stream in the expected format of LFSC, with let binding,
78
   * where n has been processed by the LFSC node converter.
79
   *
80
   * @param out The output stream
81
   * @param n The node to print
82
   * @param lbind The let binding to consider
83
   * @param letTop Whether we should consider the top-most application in n
84
   * for the let binding (see LetBinding::convert).
85
   */
86
  void printInternal(std::ostream& out,
87
                     Node n,
88
                     LetBinding& lbind,
89
                     bool letTop = true);
90
  /**
91
   * print let list, prints definitions of lbind on out in order, and closing
92
   * parentheses on cparen.
93
   */
94
  void printLetList(std::ostream& out, std::ostream& cparen, LetBinding& lbind);
95
96
  //------------------------------ printing proofs
97
  /**
98
   * Print proof internal, after term lets and proofs for assumptions have
99
   * been computed.
100
   */
101
  void printProofLetify(LfscPrintChannel* out,
102
                        const ProofNode* pn,
103
                        const LetBinding& lbind,
104
                        const std::vector<const ProofNode*>& pletList,
105
                        std::map<const ProofNode*, size_t>& pletMap,
106
                        std::map<Node, size_t>& passumeMap);
107
  /**
108
   * Print proof internal, after all mappings have been computed.
109
   */
110
  void printProofInternal(LfscPrintChannel* out,
111
                          const ProofNode* pn,
112
                          const LetBinding& lbind,
113
                          const std::map<const ProofNode*, size_t>& pletMap,
114
                          std::map<Node, size_t>& passumeMap);
115
  /**
116
   * Get the arguments for the proof node application. This adds the arguments
117
   * of the given proof to the vector pargs.
118
   *
119
   * @return false if the proof cannot be printed in LFSC format.
120
   */
121
  bool computeProofArgs(const ProofNode* pn, std::vector<PExpr>& pargs);
122
  /**
123
   * Compute proof letification for proof node pn.
124
   */
125
  void computeProofLetification(const ProofNode* pn,
126
                                std::vector<const ProofNode*>& pletList,
127
                                std::map<const ProofNode*, size_t>& pletMap);
128
  //------------------------------ end printing proofs
129
  /** The term processor */
130
  LfscNodeConverter& d_tproc;
131
  /** The proof traversal callback */
132
  LfscProofLetifyTraverseCallback d_lpltc;
133
  /** true and false nodes */
134
  Node d_tt;
135
  Node d_ff;
136
  /** Boolean type */
137
  TypeNode d_boolType;
138
  /** assumption counter */
139
  size_t d_assumpCounter;
140
  /** for debugging the open rules, the set of PfRule we have warned about */
141
  std::unordered_set<PfRule, PfRuleHashFunction> d_trustWarned;
142
};
143
144
}  // namespace proof
145
}  // namespace cvc5
146
147
#endif