LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/prop - proof_post_processor.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2026-04-08 10:18:47 Functions: 1 2 50.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 processing proof nodes in the prop engine.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "cvc5_private.h"
      14                 :            : 
      15                 :            : #ifndef CVC5__PROP__PROOF_POST_PROCESSOR_H
      16                 :            : #define CVC5__PROP__PROOF_POST_PROCESSOR_H
      17                 :            : 
      18                 :            : #include <map>
      19                 :            : #include <unordered_set>
      20                 :            : 
      21                 :            : #include "context/cdhashset.h"
      22                 :            : #include "proof/proof_generator.h"
      23                 :            : #include "proof/proof_node_updater.h"
      24                 :            : #include "smt/env_obj.h"
      25                 :            : 
      26                 :            : namespace cvc5::internal {
      27                 :            : namespace prop {
      28                 :            : 
      29                 :            : /**
      30                 :            :  * A callback class used by PropEngine for post-processing proof nodes by
      31                 :            :  * connecting proofs of resolution, whose leaves are clausified preprocessed
      32                 :            :  * assertions and lemmas, with the CNF transformation of these formulas, while
      33                 :            :  * expanding the generators of lemmas.
      34                 :            :  */
      35                 :            : class ProofPostprocessCallback : protected EnvObj,
      36                 :            :                                  public ProofNodeUpdaterCallback
      37                 :            : {
      38                 :            :  public:
      39                 :            :   ProofPostprocessCallback(Env& env, ProofGenerator* pg);
      40                 :      19901 :   ~ProofPostprocessCallback() {}
      41                 :            :   /**
      42                 :            :    * Initialize, called once for each new ProofNode to process. This initializes
      43                 :            :    * static information to be used by successive calls to update. For this
      44                 :            :    * callback it resets d_assumpToProof.
      45                 :            :    */
      46                 :            :   void initializeUpdate();
      47                 :            :   /** Should proof pn be updated?
      48                 :            :    *
      49                 :            :    * For this callback a proof node is updatable if it's an assumption for which
      50                 :            :    * the proof cnf straem has a proof. However if the proof node is blocked
      51                 :            :    * (which is the case for proof nodes introduced into the proof cnf stream's
      52                 :            :    * proof via expansion of its generators) then traversal is the proof node is
      53                 :            :    * cancelled, i.e., continueUpdate is set to false.
      54                 :            :    */
      55                 :            :   bool shouldUpdate(std::shared_ptr<ProofNode> pn,
      56                 :            :                     const std::vector<Node>& fa,
      57                 :            :                     bool& continueUpdate) override;
      58                 :            :   /** Update the proof rule application.
      59                 :            :    *
      60                 :            :    * Replaces assumptions by their proof in proof cnf stream. Note that in doing
      61                 :            :    * this the proof node is blocked, so that future post-processing does not
      62                 :            :    * traverse it.
      63                 :            :    *
      64                 :            :    * This method uses the cache in d_assumpToProof to avoid recomputing proofs
      65                 :            :    * for the same assumption (in the same scope).
      66                 :            :    */
      67                 :            :   bool update(Node res,
      68                 :            :               ProofRule id,
      69                 :            :               const std::vector<Node>& children,
      70                 :            :               const std::vector<Node>& args,
      71                 :            :               CDProof* cdp,
      72                 :            :               bool& continueUpdate) override;
      73                 :            : 
      74                 :            :  private:
      75                 :            :   /**
      76                 :            :    * Blocks a proof, so that it is not further updated by a post processor of
      77                 :            :    * this class's proof. */
      78                 :            :   void addBlocked(std::shared_ptr<ProofNode> pfn);
      79                 :            : 
      80                 :            :   /**
      81                 :            :    * Whether a given proof is blocked for further updates.  An example of a
      82                 :            :    * blocked proof node is one integrated into this class via an external proof
      83                 :            :    * generator. */
      84                 :            :   bool isBlocked(std::shared_ptr<ProofNode> pfn);
      85                 :            :   /** The cnf stream proof generator */
      86                 :            :   ProofGenerator* d_pg;
      87                 :            :   /** Blocked proofs.
      88                 :            :    *
      89                 :            :    * These are proof nodes added to this class by external generators. */
      90                 :            :   context::CDHashSet<std::shared_ptr<ProofNode>, ProofNodeHashFunction>
      91                 :            :       d_blocked;
      92                 :            :   //---------------------------------reset at the begining of each update
      93                 :            :   /** Mapping assumptions to their proof from cnf transformation */
      94                 :            :   std::map<Node, std::shared_ptr<ProofNode> > d_assumpToProof;
      95                 :            :   //---------------------------------end reset at the begining of each update
      96                 :            : };
      97                 :            : 
      98                 :            : /**
      99                 :            :  * The proof postprocessor module. This postprocesses the refutation proof
     100                 :            :  * produced by the SAT solver. Its main task is to connect the refutation's
     101                 :            :  * assumptions to the CNF transformation proof in ProofGenerator.
     102                 :            :  */
     103                 :            : class ProofPostprocess : protected EnvObj
     104                 :            : {
     105                 :            :  public:
     106                 :            :   ProofPostprocess(Env& env, ProofGenerator* pg);
     107                 :            :   ~ProofPostprocess();
     108                 :            :   /** post-process
     109                 :            :    *
     110                 :            :    * The post-processing is done via a proof node updater run on pf with this
     111                 :            :    * class's callback d_cb.
     112                 :            :    */
     113                 :            :   void process(std::shared_ptr<ProofNode> pf);
     114                 :            : 
     115                 :            :  private:
     116                 :            :   /** The post process callback */
     117                 :            :   ProofPostprocessCallback d_cb;
     118                 :            : };
     119                 :            : 
     120                 :            : }  // namespace prop
     121                 :            : }  // namespace cvc5::internal
     122                 :            : 
     123                 :            : #endif

Generated by: LCOV version 1.14