LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory - combination_engine.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 49 51 96.1 %
Date: 2026-03-21 10:41:10 Functions: 11 12 91.7 %
Branches: 7 16 43.8 %

           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                 :            :  * Management of a care graph based approach for theory combination.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "theory/combination_engine.h"
      14                 :            : 
      15                 :            : #include "expr/node_visitor.h"
      16                 :            : #include "proof/eager_proof_generator.h"
      17                 :            : #include "theory/care_graph.h"
      18                 :            : #include "theory/ee_manager_central.h"
      19                 :            : #include "theory/ee_manager_distributed.h"
      20                 :            : #include "theory/model_manager.h"
      21                 :            : #include "theory/model_manager_distributed.h"
      22                 :            : #include "theory/shared_solver_distributed.h"
      23                 :            : #include "theory/theory_engine.h"
      24                 :            : 
      25                 :            : namespace cvc5::internal {
      26                 :            : namespace theory {
      27                 :            : 
      28                 :      50263 : CombinationEngine::CombinationEngine(Env& env,
      29                 :            :                                      TheoryEngine& te,
      30                 :      50263 :                                      const std::vector<Theory*>& paraTheories)
      31                 :            :     : EnvObj(env),
      32                 :      50263 :       d_te(te),
      33                 :      50263 :       d_valuation(&te),
      34                 :      50263 :       d_logicInfo(env.getLogicInfo()),
      35                 :      50263 :       d_paraTheories(paraTheories),
      36                 :      50263 :       d_eemanager(nullptr),
      37                 :      50263 :       d_mmanager(nullptr),
      38                 :      50263 :       d_sharedSolver(nullptr),
      39                 :      70905 :       d_cmbsPg(env.isTheoryProofProducing()
      40                 :      20642 :                    ? new EagerProofGenerator(env, env.getUserContext())
      41                 :      50263 :                    : nullptr)
      42                 :            : {
      43                 :            :   // create the equality engine, model manager, and shared solver
      44         [ +  + ]:      50263 :   if (options().theory.eeMode == options::EqEngineMode::DISTRIBUTED)
      45                 :            :   {
      46                 :            :     // use the distributed shared solver
      47                 :      50198 :     d_sharedSolver.reset(new SharedSolverDistributed(env, d_te));
      48                 :            :     // make the distributed equality engine manager
      49                 :      50198 :     d_eemanager.reset(
      50                 :      50198 :         new EqEngineManagerDistributed(env, d_te, *d_sharedSolver.get()));
      51                 :            :     // make the distributed model manager
      52                 :      50198 :     d_mmanager.reset(
      53                 :      50198 :         new ModelManagerDistributed(env, d_te, *d_eemanager.get()));
      54                 :            :   }
      55         [ +  - ]:         65 :   else if (options().theory.eeMode == options::EqEngineMode::CENTRAL)
      56                 :            :   {
      57                 :            :     // for now, the shared solver is the same in both approaches; use the
      58                 :            :     // distributed one for now
      59                 :         65 :     d_sharedSolver.reset(new SharedSolverDistributed(env, d_te));
      60                 :            :     // make the central equality engine manager
      61                 :         65 :     d_eemanager.reset(
      62                 :         65 :         new EqEngineManagerCentral(env, d_te, *d_sharedSolver.get()));
      63                 :            :     // make the distributed model manager
      64                 :         65 :     d_mmanager.reset(
      65                 :         65 :         new ModelManagerDistributed(env, d_te, *d_eemanager.get()));
      66                 :            :   }
      67                 :            :   else
      68                 :            :   {
      69                 :          0 :     Unhandled() << "CombinationEngine::finishInit: equality engine mode "
      70                 :          0 :                 << options().theory.eeMode << " not supported";
      71                 :            :   }
      72                 :      50263 : }
      73                 :            : 
      74                 :      49918 : CombinationEngine::~CombinationEngine() {}
      75                 :            : 
      76                 :      50263 : void CombinationEngine::finishInit()
      77                 :            : {
      78 [ -  + ][ -  + ]:      50263 :   Assert(d_eemanager != nullptr);
                 [ -  - ]
      79                 :            : 
      80                 :            :   // initialize equality engines in all theories, including quantifiers engine
      81                 :            :   // and the (provided) shared solver
      82                 :      50263 :   d_eemanager->initializeTheories();
      83                 :            : 
      84 [ -  + ][ -  + ]:      50263 :   Assert(d_mmanager != nullptr);
                 [ -  - ]
      85                 :            :   // initialize the model manager, based on the notify object of this class
      86                 :      50263 :   eq::EqualityEngineNotify* meen = getModelEqualityEngineNotify();
      87                 :      50263 :   d_mmanager->finishInit(meen);
      88                 :      50263 : }
      89                 :            : 
      90                 :     703682 : const EeTheoryInfo* CombinationEngine::getEeTheoryInfo(TheoryId tid) const
      91                 :            : {
      92                 :     703682 :   return d_eemanager->getEeTheoryInfo(tid);
      93                 :            : }
      94                 :            : 
      95                 :      57145 : void CombinationEngine::resetModel() { d_mmanager->resetModel(); }
      96                 :            : 
      97                 :      23971 : void CombinationEngine::postProcessModel(bool incomplete)
      98                 :            : {
      99                 :      23971 :   d_eemanager->notifyModel(incomplete);
     100                 :            :   // postprocess with the model
     101                 :      23971 :   d_mmanager->postProcessModel(incomplete);
     102                 :      23971 : }
     103                 :            : 
     104                 :    1987434 : theory::TheoryModel* CombinationEngine::getModel()
     105                 :            : {
     106                 :    1987434 :   return d_mmanager->getModel();
     107                 :            : }
     108                 :            : 
     109                 :      50263 : SharedSolver* CombinationEngine::getSharedSolver()
     110                 :            : {
     111                 :      50263 :   return d_sharedSolver.get();
     112                 :            : }
     113                 :      82566 : bool CombinationEngine::isProofEnabled() const { return d_cmbsPg != nullptr; }
     114                 :            : 
     115                 :      50263 : eq::EqualityEngineNotify* CombinationEngine::getModelEqualityEngineNotify()
     116                 :            : {
     117                 :            :   // by default, no notifications from model's equality engine
     118                 :      50263 :   return nullptr;
     119                 :            : }
     120                 :            : 
     121                 :     170091 : void CombinationEngine::resetRound()
     122                 :            : {
     123                 :            :   // compute the relevant terms?
     124                 :     170091 : }
     125                 :            : 
     126                 :            : }  // namespace theory
     127                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14