LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/preprocessing/passes - pseudo_boolean_processor.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 2 100.0 %
Date: 2026-08-06 10:35:32 Functions: 1 1 100.0 %
Branches: 5 8 62.5 %

           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                 :            :  * [[ Add one-line brief description here ]]
      11                 :            :  *
      12                 :            :  * [[ Add lengthier description here ]]
      13                 :            :  * \todo document this file
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_private.h"
      17                 :            : 
      18                 :            : #ifndef CVC5__PREPROCESSING__PASSES__PSEUDO_BOOLEAN_PROCESSOR_H
      19                 :            : #define CVC5__PREPROCESSING__PASSES__PSEUDO_BOOLEAN_PROCESSOR_H
      20                 :            : 
      21                 :            : #include <optional>
      22                 :            : #include <unordered_set>
      23                 :            : #include <vector>
      24                 :            : 
      25                 :            : #include "context/cdhashmap.h"
      26                 :            : #include "context/cdo.h"
      27                 :            : #include "expr/node.h"
      28                 :            : #include "preprocessing/preprocessing_pass.h"
      29                 :            : #include "theory/substitutions.h"
      30                 :            : #include "util/rational.h"
      31                 :            : 
      32                 :            : namespace cvc5::internal {
      33                 :            : namespace preprocessing {
      34                 :            : namespace passes {
      35                 :            : 
      36                 :            : class PseudoBooleanProcessor : public PreprocessingPass
      37                 :            : {
      38                 :            :  public:
      39                 :            :   PseudoBooleanProcessor(PreprocessingPassContext* preprocContext);
      40                 :            : 
      41                 :            :  protected:
      42                 :            :   PreprocessingPassResult applyInternal(
      43                 :            :       AssertionPipeline* assertionsToPreprocess) override;
      44                 :            : 
      45                 :            :  private:
      46                 :            :   /** Assumes that the assertions have been rewritten. */
      47                 :            :   void learn(const std::vector<Node>& assertions);
      48                 :            : 
      49                 :            :   /** Assumes that the assertions have been rewritten. */
      50                 :            :   void applyReplacements(AssertionPipeline* assertionsToPreprocess);
      51                 :            : 
      52                 :            :   bool likelyToHelp() const;
      53                 :            : 
      54                 :            :   bool isPseudoBoolean(Node v) const;
      55                 :            : 
      56                 :            :   // Adds the fact the that integert typed variable v
      57                 :            :   //   must be >= 0 to the context.
      58                 :            :   // This is explained by the explanation exp.
      59                 :            :   // exp cannot be null.
      60                 :            :   void addGeqZero(Node v, Node exp);
      61                 :            : 
      62                 :            :   // Adds the fact the that integert typed variable v
      63                 :            :   //   must be <= 1 to the context.
      64                 :            :   // This is explained by the explanation exp.
      65                 :            :   // exp cannot be null.
      66                 :            :   void addLeqOne(Node v, Node exp);
      67                 :            : 
      68                 :        802 :   static inline bool isIntVar(Node v)
      69                 :            :   {
      70 [ +  + ][ +  - ]:        802 :     return v.isVar() && v.getType().isInteger();
         [ +  + ][ -  - ]
      71                 :            :   }
      72                 :            : 
      73                 :            :   void clear();
      74                 :            : 
      75                 :            :   /** Assumes that the assertion has been rewritten. */
      76                 :            :   void learn(Node assertion);
      77                 :            : 
      78                 :            :   /** Rewrites a node  */
      79                 :            :   Node applyReplacements(Node pre);
      80                 :            : 
      81                 :            :   void learnInternal(Node assertion, bool negated, Node orig);
      82                 :            :   void learnRewrittenGeq(Node assertion, bool negated, Node orig);
      83                 :            : 
      84                 :            :   void addSub(Node from, Node to);
      85                 :            :   void learnGeqSub(Node geq);
      86                 :            : 
      87                 :            :   static Node mkGeqOne(NodeManager* nm, Node v);
      88                 :            : 
      89                 :            :   // x ->  <geqZero, leqOne>
      90                 :            :   typedef context::CDHashMap<Node, std::pair<Node, Node>> CDNode2PairMap;
      91                 :            :   CDNode2PairMap d_pbBounds;
      92                 :            :   theory::SubstitutionMap d_subCache;
      93                 :            : 
      94                 :            :   typedef std::unordered_set<Node> NodeSet;
      95                 :            :   NodeSet d_learningCache;
      96                 :            : 
      97                 :            :   context::CDO<unsigned> d_pbs;
      98                 :            : 
      99                 :            :   // decompose into \sum pos >= neg + off
     100                 :            :   std::optional<Rational> d_off;
     101                 :            :   std::vector<Node> d_pos;
     102                 :            :   std::vector<Node> d_neg;
     103                 :            : 
     104                 :            :   /** Returns true if successful. */
     105                 :            :   bool decomposeAssertion(Node assertion, bool negated);
     106                 :            : };
     107                 :            : 
     108                 :            : }  // namespace passes
     109                 :            : }  // namespace preprocessing
     110                 :            : }  // namespace cvc5::internal
     111                 :            : 
     112                 :            : #endif  // CVC5__PREPROCESSING__PASSES__PSEUDO_BOOLEAN_PROCESSOR_H

Generated by: LCOV version 1.14