GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/combination_engine.cpp Lines: 44 46 95.7 %
Date: 2021-11-07 Branches: 39 110 35.5 %

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
15273
CombinationEngine::CombinationEngine(Env& env,
32
                                     TheoryEngine& te,
33
15273
                                     const std::vector<Theory*>& paraTheories)
34
    : EnvObj(env),
35
      d_te(te),
36
      d_valuation(&te),
37
15273
      d_pnm(env.isTheoryProofProducing() ? env.getProofNodeManager() : nullptr),
38
15273
      d_logicInfo(te.getLogicInfo()),
39
      d_paraTheories(paraTheories),
40
      d_eemanager(nullptr),
41
      d_mmanager(nullptr),
42
      d_sharedSolver(nullptr),
43
26017
      d_cmbsPg(d_pnm ? new EagerProofGenerator(d_pnm, env.getUserContext())
44
71836
                     : nullptr)
45
{
46
  // create the equality engine, model manager, and shared solver
47
15273
  if (options().theory.eeMode == options::EqEngineMode::DISTRIBUTED)
48
  {
49
    // use the distributed shared solver
50
15236
    d_sharedSolver.reset(new SharedSolverDistributed(env, d_te));
51
    // make the distributed equality engine manager
52
30472
    d_eemanager.reset(
53
15236
        new EqEngineManagerDistributed(env, d_te, *d_sharedSolver.get()));
54
    // make the distributed model manager
55
30472
    d_mmanager.reset(
56
15236
        new ModelManagerDistributed(env, d_te, *d_eemanager.get()));
57
  }
58
37
  else if (options().theory.eeMode == options::EqEngineMode::CENTRAL)
59
  {
60
    // for now, the shared solver is the same in both approaches; use the
61
    // distributed one for now
62
37
    d_sharedSolver.reset(new SharedSolverDistributed(env, d_te));
63
    // make the central equality engine manager
64
74
    d_eemanager.reset(
65
37
        new EqEngineManagerCentral(env, d_te, *d_sharedSolver.get()));
66
    // make the distributed model manager
67
74
    d_mmanager.reset(
68
37
        new ModelManagerDistributed(env, d_te, *d_eemanager.get()));
69
  }
70
  else
71
  {
72
    Unhandled() << "CombinationEngine::finishInit: equality engine mode "
73
                << options().theory.eeMode << " not supported";
74
  }
75
15273
}
76
77
15268
CombinationEngine::~CombinationEngine() {}
78
79
15273
void CombinationEngine::finishInit()
80
{
81
15273
  Assert(d_eemanager != nullptr);
82
83
  // initialize equality engines in all theories, including quantifiers engine
84
  // and the (provided) shared solver
85
15273
  d_eemanager->initializeTheories();
86
87
15273
  Assert(d_mmanager != nullptr);
88
  // initialize the model manager, based on the notify object of this class
89
15273
  eq::EqualityEngineNotify* meen = getModelEqualityEngineNotify();
90
15273
  d_mmanager->finishInit(meen);
91
15273
}
92
93
198549
const EeTheoryInfo* CombinationEngine::getEeTheoryInfo(TheoryId tid) const
94
{
95
198549
  return d_eemanager->getEeTheoryInfo(tid);
96
}
97
98
29793
void CombinationEngine::resetModel() { d_mmanager->resetModel(); }
99
100
9679
void CombinationEngine::postProcessModel(bool incomplete)
101
{
102
9679
  d_eemanager->notifyModel(incomplete);
103
  // postprocess with the model
104
9679
  d_mmanager->postProcessModel(incomplete);
105
9679
}
106
107
18218494
theory::TheoryModel* CombinationEngine::getModel()
108
{
109
18218494
  return d_mmanager->getModel();
110
}
111
112
15273
SharedSolver* CombinationEngine::getSharedSolver()
113
{
114
15273
  return d_sharedSolver.get();
115
}
116
39922
bool CombinationEngine::isProofEnabled() const { return d_cmbsPg != nullptr; }
117
118
15273
eq::EqualityEngineNotify* CombinationEngine::getModelEqualityEngineNotify()
119
{
120
  // by default, no notifications from model's equality engine
121
15273
  return nullptr;
122
}
123
124
91128
void CombinationEngine::resetRound()
125
{
126
  // compute the relevant terms?
127
91128
}
128
129
}  // namespace theory
130
31137
}  // namespace cvc5