Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Hans-Joerg Schurr, Gereon Kremer 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 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 : : * Proof rule checker utility. 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__PROOF__PROOF_RULE_CHECKER_H 19 : : #define CVC5__PROOF__PROOF_RULE_CHECKER_H 20 : : 21 : : #include <vector> 22 : : 23 : : #include "expr/node.h" 24 : : #include "cvc5/cvc5_proof_rule.h" 25 : : 26 : : namespace cvc5::internal { 27 : : 28 : : class ProofChecker; 29 : : class ProofNode; 30 : : 31 : : /** A virtual base class for checking a proof rule */ 32 : : class ProofRuleChecker 33 : : { 34 : : public: 35 : 692622 : ProofRuleChecker(NodeManager* nm) : d_nm(nm) {} 36 : 687800 : virtual ~ProofRuleChecker() {} 37 : : /** 38 : : * This checks a single step in a proof. 39 : : * 40 : : * Return the formula that is proven by a proof node with the given id, 41 : : * premises and arguments, or null if such a proof node is not well-formed. 42 : : * 43 : : * Note that the input/output of this method expects to be terms in *Skolem 44 : : * form*, which is passed to checkInternal below. Rule checkers may 45 : : * convert premises to witness form when necessary. 46 : : * 47 : : * @param id The id of the proof node to check 48 : : * @param children The premises of the proof node to check. These are nodes 49 : : * corresponding to the conclusion (ProofNode::getResult) of the children 50 : : * of the proof node we are checking in Skolem form. 51 : : * @param args The arguments of the proof node to check 52 : : * @return The conclusion of the proof node, in Skolem form, if successful or 53 : : * null if such a proof node is malformed. 54 : : */ 55 : : Node check(ProofRule id, 56 : : const std::vector<Node>& children, 57 : : const std::vector<Node>& args); 58 : : 59 : : /** get an index from a node, return false if we fail */ 60 : : static bool getUInt32(TNode n, uint32_t& i); 61 : : /** get a Boolean from a node, return false if we fail */ 62 : : static bool getBool(TNode n, bool& b); 63 : : /** get a Kind from a node, return false if we fail */ 64 : : static bool getKind(TNode n, Kind& k); 65 : : /** Make a Kind into a node */ 66 : : static Node mkKindNode(NodeManager* nm, Kind k); 67 : : 68 : : /** Register all rules owned by this rule checker into pc. */ 69 : 0 : virtual void registerTo(ProofChecker* pc) {} 70 : : 71 : : protected: 72 : : /** 73 : : * This checks a single step in a proof. 74 : : * 75 : : * @param id The id of the proof node to check 76 : : * @param children The premises of the proof node to check. These are nodes 77 : : * corresponding to the conclusion (ProofNode::getResult) of the children 78 : : * of the proof node we are checking. 79 : : * @param args The arguments of the proof node to check 80 : : * @return The conclusion of the proof node if successful or null if such a 81 : : * proof node is malformed. 82 : : */ 83 : : virtual Node checkInternal(ProofRule id, 84 : : const std::vector<Node>& children, 85 : : const std::vector<Node>& args) = 0; 86 : : /** Get a pointer to the node manager */ 87 : : NodeManager* nodeManager() const; 88 : : /** The underlying node manager */ 89 : : NodeManager* d_nm; 90 : : }; 91 : : 92 : : } // namespace cvc5::internal 93 : : 94 : : #endif /* CVC5__PROOF__PROOF_RULE_CHECKER_H */