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 : : * A proof generator for buffered proof steps. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__PROOF__BUFFERED_PROOF_GENERATOR_H 16 : : #define CVC5__PROOF__BUFFERED_PROOF_GENERATOR_H 17 : : 18 : : #include "context/cdhashmap.h" 19 : : #include "proof/proof_generator.h" 20 : : #include "smt/env_obj.h" 21 : : 22 : : namespace cvc5::internal { 23 : : 24 : : class ProofNodeManager; 25 : : class ProofStep; 26 : : 27 : : /** 28 : : * The proof generator for buffered steps. This class is a context-dependent 29 : : * mapping from formulas to proof steps. It does not generate ProofNodes until 30 : : * it is asked to provide a proof for a given fact. 31 : : */ 32 : : class BufferedProofGenerator : protected EnvObj, public ProofGenerator 33 : : { 34 : : public: 35 : : /** Constructor 36 : : * 37 : : * @param env Reference to the environment 38 : : * @param c Pointer to a context to make this object dependent on 39 : : * @param mkUniqueAssume Whether to restrict the proof nodes generated when 40 : : * proofs are requested so that the same ASSUMPTION step is used for repeated 41 : : * premises. Note that this can only be done safely if the user of this 42 : : * buffered proof generator does not use SCOPE steps, which would have the 43 : : * danger of mixing the scopes of assumptions. 44 : : * @param autoSymm Whether the proof requestes are robust to (dis)equality 45 : : * symmetry. 46 : : */ 47 : : BufferedProofGenerator(Env& env, 48 : : context::Context* c, 49 : : bool mkUniqueAssume = false, 50 : : bool autoSymm = true); 51 : 155688 : ~BufferedProofGenerator() {} 52 : : /** add step 53 : : * Unless the overwrite policy is ALWAYS it does not replace previously 54 : : * registered steps (modulo (dis)equality symmetry). 55 : : */ 56 : : bool addStep(Node fact, 57 : : ProofStep ps, 58 : : CDPOverwrite opolicy = CDPOverwrite::NEVER); 59 : : /** Get proof for. It is robust to (dis)equality symmetry. */ 60 : : std::shared_ptr<ProofNode> getProofFor(Node f) override; 61 : : /** Whether a step has been registered for f. */ 62 : : bool hasProofFor(Node f) override; 63 : : /** identify */ 64 : 0 : std::string identify() const override { return "BufferedProofGenerator"; } 65 : : 66 : : protected: 67 : : using NodeProofStepMap = context::CDHashMap<Node, std::shared_ptr<ProofStep>>; 68 : : using NodeProofNodeMap = context::CDHashMap<Node, std::shared_ptr<ProofNode>>; 69 : : 70 : : /** maps expected to ProofStep */ 71 : : NodeProofStepMap d_facts; 72 : : /** whether we are forcing unique assumptions */ 73 : : bool d_mkUniqueAssume; 74 : : /** whether we automatically add symmetry steps */ 75 : : bool d_autoSymm; 76 : : /** Cache of ASSUMPTION proof nodes for nodes used as assumptions in proof 77 : : * steps. Used only if d_mkUniqueAssume is true. */ 78 : : NodeProofNodeMap d_assumptionsToPfNodes; 79 : : }; 80 : : 81 : : } // namespace cvc5::internal 82 : : 83 : : #endif /* CVC5__PROOF__BUFFERED_PROOF_GENERATOR_H */