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