LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/bv - bv_solver_bitblast.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 3 66.7 %
Date: 2026-05-08 10:22:53 Functions: 3 4 75.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                 :            :  * Bit-blasting solver that supports multiple SAT back ends.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "cvc5_private.h"
      14                 :            : 
      15                 :            : #ifndef CVC5__THEORY__BV__BV_SOLVER_BITBLAST_H
      16                 :            : #define CVC5__THEORY__BV__BV_SOLVER_BITBLAST_H
      17                 :            : 
      18                 :            : #include <unordered_map>
      19                 :            : 
      20                 :            : #include "context/cdqueue.h"
      21                 :            : #include "proof/eager_proof_generator.h"
      22                 :            : #include "prop/cnf_stream.h"
      23                 :            : #include "prop/sat_solver.h"
      24                 :            : #include "smt/env_obj.h"
      25                 :            : #include "theory/bv/bitblast/node_bitblaster.h"
      26                 :            : #include "theory/bv/bv_solver.h"
      27                 :            : #include "theory/bv/proof_checker.h"
      28                 :            : 
      29                 :            : namespace cvc5::internal {
      30                 :            : 
      31                 :            : namespace theory {
      32                 :            : namespace bv {
      33                 :            : 
      34                 :            : class NotifyResetAssertions;
      35                 :            : class BBRegistrar;
      36                 :            : 
      37                 :            : /**
      38                 :            :  * Bit-blasting solver with support for different SAT back ends.
      39                 :            :  */
      40                 :            : class BVSolverBitblast : public BVSolver
      41                 :            : {
      42                 :            :  public:
      43                 :            :   BVSolverBitblast(Env& env,
      44                 :            :                    TheoryState* state,
      45                 :            :                    TheoryInferenceManager& inferMgr);
      46                 :      79864 :   ~BVSolverBitblast() = default;
      47                 :            : 
      48                 :            :   bool needsEqualityEngine(EeSetupInfo& esi) override;
      49                 :            : 
      50                 :     184533 :   void preRegisterTerm(CVC5_UNUSED TNode n) override {}
      51                 :            : 
      52                 :            :   void postCheck(Theory::Effort level) override;
      53                 :            : 
      54                 :            :   bool preNotifyFact(TNode atom,
      55                 :            :                      bool pol,
      56                 :            :                      TNode fact,
      57                 :            :                      bool isPrereg,
      58                 :            :                      bool isInternal) override;
      59                 :            : 
      60                 :            :   TrustNode explain(TNode n) override;
      61                 :            : 
      62                 :          0 :   std::string identify() const override { return "BVSolverBitblast"; };
      63                 :            : 
      64                 :            :   void computeRelevantTerms(std::set<Node>& termSet) override;
      65                 :            : 
      66                 :            :   bool collectModelValues(TheoryModel* m,
      67                 :            :                           const std::set<Node>& termSet) override;
      68                 :            : 
      69                 :            :   /**
      70                 :            :    * Get the current value of `node`.
      71                 :            :    *
      72                 :            :    * The `initialize` flag indicates whether bits should be zero-initialized
      73                 :            :    * if they were not bit-blasted yet.
      74                 :            :    */
      75                 :            :   Node getValue(TNode node, bool initialize) override;
      76                 :            : 
      77                 :            :  private:
      78                 :            :   /** Initialize SAT solver and CNF stream.  */
      79                 :            :   void initSatSolver();
      80                 :            : 
      81                 :            :   /**
      82                 :            :    * Handle BITVECTOR_EAGER_ATOM atoms and assert/assume to CnfStream.
      83                 :            :    *
      84                 :            :    * @param assertFact: Indicates whether the fact should be asserted (true) or
      85                 :            :    * assumed (false).
      86                 :            :    */
      87                 :            :   void handleEagerAtom(TNode fact, bool assertFact);
      88                 :            : 
      89                 :            :   /** Bit-blaster used to bit-blast atoms/terms. */
      90                 :            :   std::unique_ptr<NodeBitblaster> d_bitblaster;
      91                 :            : 
      92                 :            :   /** Used for initializing `d_cnfStream`. */
      93                 :            :   std::unique_ptr<BBRegistrar> d_bbRegistrar;
      94                 :            :   std::unique_ptr<context::Context> d_nullContext;
      95                 :            : 
      96                 :            :   /** SAT solver back end (configured via options::bvSatSolver. */
      97                 :            :   std::unique_ptr<prop::SatSolver> d_satSolver;
      98                 :            :   /** CNF stream. */
      99                 :            :   std::unique_ptr<prop::CnfStream> d_cnfStream;
     100                 :            : 
     101                 :            :   /**
     102                 :            :    * Bit-blast queue for facts sent to this solver.
     103                 :            :    *
     104                 :            :    * Gets populated on preNotifyFact().
     105                 :            :    */
     106                 :            :   context::CDQueue<Node> d_bbFacts;
     107                 :            : 
     108                 :            :   /**
     109                 :            :    * Bit-blast queue for user-level 0 input facts sent to this solver.
     110                 :            :    *
     111                 :            :    * Get populated on preNotifyFact().
     112                 :            :    */
     113                 :            :   context::CDQueue<Node> d_bbInputFacts;
     114                 :            : 
     115                 :            :   /** Corresponds to the SAT literals of the currently asserted facts. */
     116                 :            :   context::CDList<prop::SatLiteral> d_assumptions;
     117                 :            : 
     118                 :            :   /** Stores the current input assertions. */
     119                 :            :   context::CDList<Node> d_assertions;
     120                 :            : 
     121                 :            :   /** Proof generator that manages proofs for lemmas generated by this class. */
     122                 :            :   std::unique_ptr<EagerProofGenerator> d_epg;
     123                 :            : 
     124                 :            :   BVProofRuleChecker d_bvProofChecker;
     125                 :            : 
     126                 :            :   /** Stores the SatLiteral for a given fact. */
     127                 :            :   context::CDHashMap<Node, prop::SatLiteral> d_factLiteralCache;
     128                 :            : 
     129                 :            :   /** Reverse map of `d_factLiteralCache`. */
     130                 :            :   context::CDHashMap<prop::SatLiteral, Node, prop::SatLiteralHashFunction>
     131                 :            :       d_literalFactCache;
     132                 :            : 
     133                 :            :   /** Option to enable/disable bit-level propagation. */
     134                 :            :   bool d_propagate;
     135                 :            : 
     136                 :            :   /** Notifies when reset-assertion was called. */
     137                 :            :   std::unique_ptr<NotifyResetAssertions> d_resetNotify;
     138                 :            : };
     139                 :            : 
     140                 :            : }  // namespace bv
     141                 :            : }  // namespace theory
     142                 :            : }  // namespace cvc5::internal
     143                 :            : 
     144                 :            : #endif

Generated by: LCOV version 1.14