LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/bags - theory_bags.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 4 75.0 %
Date: 2026-08-07 10:35:07 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                 :            :  * Bags theory.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "cvc5_private.h"
      14                 :            : 
      15                 :            : #ifndef CVC5__THEORY__BAGS__THEORY_BAGS_H
      16                 :            : #define CVC5__THEORY__BAGS__THEORY_BAGS_H
      17                 :            : 
      18                 :            : #include "theory/bags/bag_reduction.h"
      19                 :            : #include "theory/bags/bag_solver.h"
      20                 :            : #include "theory/bags/bags_rewriter.h"
      21                 :            : #include "theory/bags/bags_statistics.h"
      22                 :            : #include "theory/bags/inference_generator.h"
      23                 :            : #include "theory/bags/inference_manager.h"
      24                 :            : #include "theory/bags/solver_state.h"
      25                 :            : #include "theory/bags/strategy.h"
      26                 :            : #include "theory/bags/term_registry.h"
      27                 :            : #include "theory/care_pair_argument_callback.h"
      28                 :            : #include "theory/theory.h"
      29                 :            : #include "theory/theory_eq_notify.h"
      30                 :            : 
      31                 :            : namespace cvc5::internal {
      32                 :            : namespace theory {
      33                 :            : namespace bags {
      34                 :            : 
      35                 :            : class TheoryBags : public Theory
      36                 :            : {
      37                 :            :  public:
      38                 :            :   /** Constructs a new instance of TheoryBags w.r.t. the provided contexts. */
      39                 :            :   TheoryBags(Env& env, OutputChannel& out, Valuation valuation);
      40                 :            :   ~TheoryBags() override;
      41                 :            : 
      42                 :            :   //--------------------------------- initialization
      43                 :            :   /** get the official theory rewriter of this theory */
      44                 :            :   TheoryRewriter* getTheoryRewriter() override;
      45                 :            :   /** get the proof checker of this theory */
      46                 :            :   ProofRuleChecker* getProofChecker() override;
      47                 :            :   /**
      48                 :            :    * Returns true if we need an equality engine. If so, we initialize the
      49                 :            :    * information regarding how it should be setup. For details, see the
      50                 :            :    * documentation in Theory::needsEqualityEngine.
      51                 :            :    */
      52                 :            :   bool needsEqualityEngine(EeSetupInfo& esi) override;
      53                 :            :   /** finish initialization */
      54                 :            :   void finishInit() override;
      55                 :            :   /** preprocess rewrite */
      56                 :            :   TrustNode ppRewrite(TNode atom, std::vector<SkolemLemma>& lems) override;
      57                 :            :   //--------------------------------- end initialization
      58                 :            : 
      59                 :            :   /**
      60                 :            :    * initialize bag and count terms
      61                 :            :    */
      62                 :            :   void initialize();
      63                 :            :   /**
      64                 :            :    * collect bags' representatives and all count terms.
      65                 :            :    */
      66                 :            :   void collectBagsAndCountTerms();
      67                 :            : 
      68                 :            :   //--------------------------------- standard check
      69                 :            :   /** Post-check, called after the fact queue of the theory is processed. */
      70                 :            :   void postCheck(Effort effort) override;
      71                 :            :   /** Notify fact */
      72                 :            :   void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) override;
      73                 :            :   //--------------------------------- end standard check
      74                 :            :   /** Collect model values in m based on the relevant terms given by termSet */
      75                 :            :   bool collectModelValues(TheoryModel* m,
      76                 :            :                           const std::set<Node>& termSet) override;
      77                 :            :   TrustNode explain(TNode) override;
      78                 :            :   Node getCandidateModelValue(TNode) override;
      79                 :          0 :   std::string identify() const override { return "THEORY_BAGS"; }
      80                 :            :   void preRegisterTerm(TNode n) override;
      81                 :            : 
      82                 :            :   void presolve() override;
      83                 :            :   void computeCareGraph() override;
      84                 :            :   void processCarePairArgs(TNode a, TNode b) override;
      85                 :            :   bool isCareArg(Node n, unsigned a);
      86                 :            :   /** run strategy for effort e */
      87                 :            :   void runStrategy(Theory::Effort e);
      88                 :            :   /** run the given inference step */
      89                 :            :   bool runInferStep(InferStep s, int effort);
      90                 :            : 
      91                 :            :  private:
      92                 :            :   /** Functions to handle callbacks from equality engine */
      93                 :            :   class NotifyClass : public TheoryEqNotifyClass
      94                 :            :   {
      95                 :            :    public:
      96                 :      28700 :     NotifyClass(TheoryBags& theory, TheoryInferenceManager& inferenceManager)
      97                 :            : 
      98                 :      28700 :         : TheoryEqNotifyClass(inferenceManager), d_theory(theory)
      99                 :            :     {
     100                 :      28700 :     }
     101                 :            :     void eqNotifyNewClass(TNode n) override;
     102                 :            :     void eqNotifyMerge(TNode n1, TNode n2) override;
     103                 :            :     void eqNotifyDisequal(TNode n1, TNode n2, TNode reason) override;
     104                 :            : 
     105                 :            :    private:
     106                 :            :     TheoryBags& d_theory;
     107                 :            :   };
     108                 :            : 
     109                 :            :   /** expand the definition of the bag.choose operator */
     110                 :            :   TrustNode expandChooseOperator(const Node& node,
     111                 :            :                                  std::vector<SkolemLemma>& lems);
     112                 :            : 
     113                 :            :   /** The state of the bags solver at full effort */
     114                 :            :   SolverState d_state;
     115                 :            :   /** The inference manager */
     116                 :            :   InferenceManager d_im;
     117                 :            :   /** The inference generator */
     118                 :            :   InferenceGenerator d_ig;
     119                 :            :   /** Instance of the above class */
     120                 :            :   NotifyClass d_notify;
     121                 :            :   /** Statistics for the theory of bags. */
     122                 :            :   BagsStatistics d_statistics;
     123                 :            :   /** The theory rewriter for this theory. */
     124                 :            :   BagsRewriter d_rewriter;
     125                 :            :   /** The term registry for this theory */
     126                 :            :   TermRegistry d_termReg;
     127                 :            :   /** the main solver for bags */
     128                 :            :   BagSolver d_solver;
     129                 :            : 
     130                 :            :   /** The care pair argument callback, used for theory combination */
     131                 :            :   CarePairArgumentCallback d_cpacb;
     132                 :            :   /** map kinds to their terms. It is cleared during post check */
     133                 :            :   std::map<Kind, std::vector<Node>> d_opMap;
     134                 :            : 
     135                 :            :   /** The representation of the strategy */
     136                 :            :   Strategy d_strat;
     137                 :            : 
     138                 :            :   void eqNotifyNewClass(TNode n);
     139                 :            :   void eqNotifyMerge(TNode n1, TNode n2);
     140                 :            :   void eqNotifyDisequal(TNode t1, TNode t2, TNode reason);
     141                 :            : }; /* class TheoryBags */
     142                 :            : 
     143                 :            : }  // namespace bags
     144                 :            : }  // namespace theory
     145                 :            : }  // namespace cvc5::internal
     146                 :            : 
     147                 :            : #endif /* CVC5__THEORY__BAGS__THEORY_BAGS_H */

Generated by: LCOV version 1.14