LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/smt - preprocess_proof_generator.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2026-03-28 10:41:09 Functions: 2 2 100.0 %
Branches: 0 0 -

           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 module for proofs for preprocessing in an SMT engine.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "cvc5_private.h"
      14                 :            : 
      15                 :            : #ifndef CVC5__SMT__PREPROCESS_PROOF_GENERATOR_H
      16                 :            : #define CVC5__SMT__PREPROCESS_PROOF_GENERATOR_H
      17                 :            : 
      18                 :            : #include "context/cdhashmap.h"
      19                 :            : #include "proof/lazy_proof.h"
      20                 :            : #include "proof/proof.h"
      21                 :            : #include "proof/proof_generator.h"
      22                 :            : #include "proof/proof_set.h"
      23                 :            : #include "proof/trust_id.h"
      24                 :            : #include "proof/trust_node.h"
      25                 :            : #include "smt/env_obj.h"
      26                 :            : 
      27                 :            : namespace cvc5::internal {
      28                 :            : 
      29                 :            : class LazyCDProof;
      30                 :            : class ProofNodeManager;
      31                 :            : 
      32                 :            : namespace smt {
      33                 :            : 
      34                 :            : /**
      35                 :            :  * This is a proof generator that manages proofs for a set of formulas that
      36                 :            :  * may be replaced over time. This set of formulas is implicit; formulas that
      37                 :            :  * are not notified as assertions to this class are treated as assumptions.
      38                 :            :  *
      39                 :            :  * The main use case of this proof generator is for proofs of preprocessing,
      40                 :            :  * although it can be used in other scenarios where proofs for an evolving set
      41                 :            :  * of formulas is maintained. In the remainder of the description here, we
      42                 :            :  * describe its role as a proof generator for proofs of preprocessing.
      43                 :            :  *
      44                 :            :  * This class has two main interfaces during solving:
      45                 :            :  * (1) notifyNewAssert, for assertions that are not part of the input and are
      46                 :            :  * added to the assertion pipeline by preprocessing passes,
      47                 :            :  * (2) notifyPreprocessed, which is called when a preprocessing pass rewrites
      48                 :            :  * an assertion into another.
      49                 :            :  * Notice that input assertions do not need to be provided to this class.
      50                 :            :  *
      51                 :            :  * Its getProofFor method produces a proof for a preprocessed assertion
      52                 :            :  * whose free assumptions are intended to be input assertions, which are
      53                 :            :  * implictly all assertions that are not notified to this class.
      54                 :            :  */
      55                 :            : class PreprocessProofGenerator : protected EnvObj, public ProofGenerator
      56                 :            : {
      57                 :            :   typedef context::CDHashMap<Node, TrustNode> NodeTrustNodeMap;
      58                 :            : 
      59                 :            :  public:
      60                 :            :   /**
      61                 :            :    * @param env Reference to the environment
      62                 :            :    * @param c The context this class depends on
      63                 :            :    * @param name The name of this generator (for debugging)
      64                 :            :    */
      65                 :            :   PreprocessProofGenerator(Env& env,
      66                 :            :                            context::Context* c = nullptr,
      67                 :            :                            std::string name = "PreprocessProofGenerator");
      68                 :      79610 :   ~PreprocessProofGenerator() {}
      69                 :            :   /**
      70                 :            :    * Notify that n is an input (its proof is ASSUME).
      71                 :            :    */
      72                 :            :   void notifyInput(Node n);
      73                 :            :   /**
      74                 :            :    * Notify that n is a new assertion, where pg can provide a proof of n.
      75                 :            :    *
      76                 :            :    * @param n The formula to assert.
      77                 :            :    * @param pg The proof generator that may provide a proof of n.
      78                 :            :    * @param id The trust id to use, if pg is nullptr.
      79                 :            :    */
      80                 :            :   void notifyNewAssert(Node n,
      81                 :            :                        ProofGenerator* pg,
      82                 :            :                        TrustId id = TrustId::UNKNOWN_PREPROCESS_LEMMA);
      83                 :            :   /**
      84                 :            :    * Notify a new assertion, trust node version.
      85                 :            :    *
      86                 :            :    * @param tn The trust node
      87                 :            :    * @param id The trust id to use, if the generator of the trust node is null.
      88                 :            :    */
      89                 :            :   void notifyNewTrustedAssert(TrustNode tn,
      90                 :            :                               TrustId id = TrustId::UNKNOWN_PREPROCESS_LEMMA);
      91                 :            :   /**
      92                 :            :    * Notify that n was replaced by np due to preprocessing, where pg can
      93                 :            :    * provide a proof of the equality n=np.
      94                 :            :    * @param n The original formula.
      95                 :            :    * @param np The preprocessed formula.
      96                 :            :    * @param pg The proof generator that may provide a proof of (= n np).
      97                 :            :    * @param id The trust id to use, if the proof generator is null.
      98                 :            :    */
      99                 :            :   void notifyPreprocessed(Node n,
     100                 :            :                           Node np,
     101                 :            :                           ProofGenerator* pg,
     102                 :            :                           TrustId id = TrustId::UNKNOWN_PREPROCESS);
     103                 :            :   /** Notify preprocessed, trust node version */
     104                 :            :   void notifyTrustedPreprocessed(TrustNode tnp,
     105                 :            :                                  TrustId id = TrustId::UNKNOWN_PREPROCESS);
     106                 :            :   /**
     107                 :            :    * Get proof for f, which returns a proof based on proving an equality based
     108                 :            :    * on transitivity of preprocessing steps, and then using the original
     109                 :            :    * assertion with EQ_RESOLVE to obtain the proof of the ending assertion f.
     110                 :            :    */
     111                 :            :   std::shared_ptr<ProofNode> getProofFor(Node f) override;
     112                 :            :   /** Identify */
     113                 :            :   std::string identify() const override;
     114                 :            : 
     115                 :            :  private:
     116                 :            :   /**
     117                 :            :    * Possibly check pedantic failure for null proof generator provided
     118                 :            :    * to this class.
     119                 :            :    */
     120                 :            :   void checkEagerPedantic(TrustId r);
     121                 :            :   /** A dummy context used by this class if none is provided */
     122                 :            :   context::Context d_context;
     123                 :            :   /** The context used here */
     124                 :            :   context::Context* d_ctx;
     125                 :            :   /**
     126                 :            :    * The trust node that was the source of each node constructed during
     127                 :            :    * preprocessing. For each n, d_src[n] is a trust node whose node is n. This
     128                 :            :    * can either be:
     129                 :            :    * (1) A trust node REWRITE proving (n_src = n) for some n_src, or
     130                 :            :    * (2) A trust node LEMMA proving n.
     131                 :            :    */
     132                 :            :   NodeTrustNodeMap d_src;
     133                 :            :   /**
     134                 :            :    * A cd proof for input assertions, this is an empty proof that intentionally
     135                 :            :    * returns (ASSUME f) for all f.
     136                 :            :    */
     137                 :            :   CDProof d_inputPf;
     138                 :            :   /**
     139                 :            :    * A cd proof used for when preprocessing steps are not given justification.
     140                 :            :    * Stores only trust steps.
     141                 :            :    */
     142                 :            :   CDProof d_trustPf;
     143                 :            :   /** Name for debugging */
     144                 :            :   std::string d_name;
     145                 :            : };
     146                 :            : 
     147                 :            : }  // namespace smt
     148                 :            : }  // namespace cvc5::internal
     149                 :            : 
     150                 :            : #endif

Generated by: LCOV version 1.14