Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Utilities for printing expressions in proofs 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__PROOF__PRINT_EXPR_H 16 : : #define CVC5__PROOF__PRINT_EXPR_H 17 : : 18 : : #include <iostream> 19 : : #include <map> 20 : : 21 : : #include "expr/node.h" 22 : : #include "proof/proof_node.h" 23 : : 24 : : namespace cvc5::internal { 25 : : namespace proof { 26 : : 27 : : /** 28 : : * A term, type or a proof. This class is used for printing combinations of 29 : : * proofs terms and types. 30 : : */ 31 : : class PExpr 32 : : { 33 : : public: 34 : 15854216 : PExpr() : d_node(), d_pnode(nullptr), d_typeNode() {} 35 : 6510326 : PExpr(Node n) : d_node(n), d_pnode(nullptr), d_typeNode() {} 36 : 36605330 : PExpr(const ProofNode* pn) : d_node(), d_pnode(pn), d_typeNode() {} 37 : 41266 : PExpr(TypeNode tn) : d_node(), d_pnode(nullptr), d_typeNode(tn) {} 38 : 347115186 : ~PExpr() {} 39 : : /** The node, if this p-exression is a node */ 40 : : Node d_node; 41 : : /** The proof node, if this p-expression is a proof */ 42 : : const ProofNode* d_pnode; 43 : : /** The type node, if this p-expression is a type */ 44 : : TypeNode d_typeNode; 45 : : }; 46 : : 47 : : /** 48 : : * A stream of p-expressions, which appends p-expressions to a reference vector. 49 : : * That vector can then be used when printing a proof. 50 : : */ 51 : : class PExprStream 52 : : { 53 : : public: 54 : : /** 55 : : * Takes a reference to a stream (vector of p-expressions), and the 56 : : * representation true/false (tt/ff). 57 : : */ 58 : : PExprStream(std::vector<PExpr>& stream, 59 : : Node tt = Node::null(), 60 : : Node ff = Node::null()); 61 : : /** Append a proof node */ 62 : : PExprStream& operator<<(const ProofNode* pn); 63 : : /** Append a node */ 64 : : PExprStream& operator<<(Node n); 65 : : /** Append a type node */ 66 : : PExprStream& operator<<(TypeNode tn); 67 : : /** Append a Boolean */ 68 : : PExprStream& operator<<(bool b); 69 : : /** Append a pexpr */ 70 : : PExprStream& operator<<(PExpr p); 71 : : 72 : : private: 73 : : /** Reference to the stream */ 74 : : std::vector<PExpr>& d_stream; 75 : : /** Builtin nodes for true and false */ 76 : : Node d_tt; 77 : : Node d_ff; 78 : : }; 79 : : 80 : : } // namespace proof 81 : : } // namespace cvc5::internal 82 : : 83 : : #endif