GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/combination_engine.cpp Lines: 43 45 95.6 %
Date: 2021-08-06 Branches: 35 110 31.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Management of a care graph based approach for theory combination.
14
 */
15
16
#include "theory/combination_engine.h"
17
18
#include "expr/node_visitor.h"
19
#include "proof/eager_proof_generator.h"
20
#include "theory/care_graph.h"
21
#include "theory/ee_manager_central.h"
22
#include "theory/ee_manager_distributed.h"
23
#include "theory/model_manager.h"
24
#include "theory/model_manager_distributed.h"
25
#include "theory/shared_solver_distributed.h"
26
#include "theory/theory_engine.h"
27
28
namespace cvc5 {
29
namespace theory {
30
31
9853
CombinationEngine::CombinationEngine(TheoryEngine& te,
32
                                     Env& env,
33
                                     const std::vector<Theory*>& paraTheories,
34
9853
                                     ProofNodeManager* pnm)
35
    : d_te(te),
36
      d_env(env),
37
      d_valuation(&te),
38
      d_pnm(pnm),
39
9853
      d_logicInfo(te.getLogicInfo()),
40
      d_paraTheories(paraTheories),
41
      d_eemanager(nullptr),
42
      d_mmanager(nullptr),
43
      d_sharedSolver(nullptr),
44
2490
      d_cmbsPg(pnm ? new EagerProofGenerator(pnm, te.getUserContext())
45
22196
                   : nullptr)
46
{
47
  // create the equality engine, model manager, and shared solver
48
17368439
  if (options::eeMode() == options::EqEngineMode::DISTRIBUTED)
49
  {
50
    // use the distributed shared solver
51
9818
    d_sharedSolver.reset(new SharedSolverDistributed(d_te, d_pnm));
52
    // make the distributed equality engine manager
53
19636
    d_eemanager.reset(
54
9818
        new EqEngineManagerDistributed(d_te, *d_sharedSolver.get()));
55
    // make the distributed model manager
56
19636
    d_mmanager.reset(
57
9818
        new ModelManagerDistributed(d_te, d_env, *d_eemanager.get()));
58
  }
59
35
  else if (options::eeMode() == options::EqEngineMode::CENTRAL)
60
  {
61
    // for now, the shared solver is the same in both approaches; use the
62
    // distributed one for now
63
35
    d_sharedSolver.reset(new SharedSolverDistributed(d_te, d_pnm));
64
    // make the central equality engine manager
65
70
    d_eemanager.reset(
66
35
        new EqEngineManagerCentral(d_te, *d_sharedSolver.get(), d_pnm));
67
    // make the distributed model manager
68
70
    d_mmanager.reset(
69
35
        new ModelManagerDistributed(d_te, d_env, *d_eemanager.get()));
70
  }
71
  else
72
  {
73
    Unhandled() << "CombinationEngine::finishInit: equality engine mode "
74
                << options::eeMode() << " not supported";
75
  }
76
9853
}
77
78
9853
CombinationEngine::~CombinationEngine() {}
79
80
9853
void CombinationEngine::finishInit()
81
{
82
9853
  Assert(d_eemanager != nullptr);
83
84
  // initialize equality engines in all theories, including quantifiers engine
85
  // and the (provided) shared solver
86
9853
  d_eemanager->initializeTheories();
87
88
9853
  Assert(d_mmanager != nullptr);
89
  // initialize the model manager, based on the notify object of this class
90
9853
  eq::EqualityEngineNotify* meen = getModelEqualityEngineNotify();
91
9853
  d_mmanager->finishInit(meen);
92
9853
}
93
94
128089
const EeTheoryInfo* CombinationEngine::getEeTheoryInfo(TheoryId tid) const
95
{
96
128089
  return d_eemanager->getEeTheoryInfo(tid);
97
}
98
99
21105
void CombinationEngine::resetModel() { d_mmanager->resetModel(); }
100
101
7483
void CombinationEngine::postProcessModel(bool incomplete)
102
{
103
7483
  d_eemanager->notifyModel(incomplete);
104
  // postprocess with the model
105
7483
  d_mmanager->postProcessModel(incomplete);
106
7483
}
107
108
288304
theory::TheoryModel* CombinationEngine::getModel()
109
{
110
288304
  return d_mmanager->getModel();
111
}
112
113
9853
SharedSolver* CombinationEngine::getSharedSolver()
114
{
115
9853
  return d_sharedSolver.get();
116
}
117
39296
bool CombinationEngine::isProofEnabled() const { return d_cmbsPg != nullptr; }
118
119
9853
eq::EqualityEngineNotify* CombinationEngine::getModelEqualityEngineNotify()
120
{
121
  // by default, no notifications from model's equality engine
122
9853
  return nullptr;
123
}
124
125
77463
void CombinationEngine::resetRound()
126
{
127
  // compute the relevant terms?
128
77463
}
129
130
}  // namespace theory
131
29322
}  // namespace cvc5