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 : : * The abstract proof generator class. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__PROOF__PROOF_GENERATOR_H 16 : : #define CVC5__PROOF__PROOF_GENERATOR_H 17 : : 18 : : #include "expr/node.h" 19 : : 20 : : namespace cvc5::internal { 21 : : 22 : : class CDProof; 23 : : class ProofNode; 24 : : 25 : : /** An overwrite policy for CDProof */ 26 : : enum class CDPOverwrite : uint32_t 27 : : { 28 : : // always overwrite an existing step. 29 : : ALWAYS, 30 : : // overwrite ASSUME with non-ASSUME steps. 31 : : ASSUME_ONLY, 32 : : // never overwrite an existing step. 33 : : NEVER, 34 : : }; 35 : : /** Writes a overwrite policy name to a stream. */ 36 : : std::ostream& operator<<(std::ostream& out, CDPOverwrite opol); 37 : : 38 : : /** 39 : : * An abstract proof generator class. 40 : : * 41 : : * A proof generator is intended to be used as a utility e.g. in theory 42 : : * solvers for constructing and storing proofs internally. A theory may have 43 : : * multiple instances of ProofGenerator objects, e.g. if it has more than one 44 : : * way of justifying lemmas or conflicts. 45 : : * 46 : : * A proof generator has two main interfaces for generating proofs: 47 : : * (1) getProofFor, and (2) addProofTo. The latter is optional. 48 : : * 49 : : * The addProofTo method can be used as an optimization for avoiding 50 : : * the construction of the ProofNode for a given fact. 51 : : * 52 : : * If no implementation of addProofTo is provided, then addProofTo(f, pf) 53 : : * calls getProofFor(f) and links the topmost ProofNode of the returned proof 54 : : * into pf. Note this top-most ProofNode can be avoided in the addProofTo 55 : : * method. 56 : : */ 57 : : class ProofGenerator 58 : : { 59 : : public: 60 : : ProofGenerator(); 61 : : virtual ~ProofGenerator(); 62 : : /** Get the proof for formula f 63 : : * 64 : : * This forces the proof generator to construct a proof for formula f and 65 : : * return it. If this is an "eager" proof generator, this function is expected 66 : : * to be implemented as a map lookup. If this is a "lazy" proof generator, 67 : : * this function is expected to invoke a proof producing procedure of the 68 : : * generator. 69 : : * 70 : : * It should be the case that hasProofFor(f) is true. 71 : : * 72 : : * @param f The fact to get the proof for. 73 : : * @return The proof for f. 74 : : */ 75 : : virtual std::shared_ptr<ProofNode> getProofFor(Node f); 76 : : /** 77 : : * Add the proof for formula f to proof pf. The proof of f is overwritten in 78 : : * pf based on the policy opolicy. 79 : : * 80 : : * @param f The fact to get the proof for. 81 : : * @param pf The CDProof object to add the proof to. 82 : : * @param opolicy The overwrite policy for adding to pf. 83 : : * @param doCopy Whether to do a deep copy of the proof steps into pf. 84 : : * @return True if this call was sucessful. 85 : : */ 86 : : virtual bool addProofTo(Node f, 87 : : CDProof* pf, 88 : : CDPOverwrite opolicy = CDPOverwrite::ASSUME_ONLY, 89 : : bool doCopy = false); 90 : : /** 91 : : * Can we give the proof for formula f? This is used for debugging. This 92 : : * returns false if the generator cannot provide a proof of formula f. 93 : : * 94 : : * Also notice that this function does not require the proof for f to be 95 : : * constructed at the time of this call. Thus, if this is a "lazy" proof 96 : : * generator, it is expected that this call is implemented as a map lookup 97 : : * into the bookkeeping maintained by the generator only. 98 : : * 99 : : * Notice the default return value is true. In other words, a proof generator 100 : : * may choose to override this function to verify the construction, although 101 : : * we do not insist this is the case. 102 : : */ 103 : 5635772 : virtual bool hasProofFor(CVC5_UNUSED Node f) { return true; } 104 : : /** Identify this generator (for debugging, etc..) */ 105 : : virtual std::string identify() const = 0; 106 : : }; 107 : : 108 : : } // namespace cvc5::internal 109 : : 110 : : #endif /* CVC5__PROOF__PROOF_GENERATOR_H */