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: 2024-10-06 11:37:27 Functions: 2 2 100.0 %
Branches: 0 0 -

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

Generated by: LCOV version 1.14