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