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 |
15271 |
CombinationEngine::CombinationEngine(Env& env, |
32 |
|
TheoryEngine& te, |
33 |
15271 |
const std::vector<Theory*>& paraTheories) |
34 |
|
: EnvObj(env), |
35 |
|
d_te(te), |
36 |
|
d_valuation(&te), |
37 |
15271 |
d_pnm(env.isTheoryProofProducing() ? env.getProofNodeManager() : nullptr), |
38 |
15271 |
d_logicInfo(te.getLogicInfo()), |
39 |
|
d_paraTheories(paraTheories), |
40 |
|
d_eemanager(nullptr), |
41 |
|
d_mmanager(nullptr), |
42 |
|
d_sharedSolver(nullptr), |
43 |
26015 |
d_cmbsPg(d_pnm ? new EagerProofGenerator(d_pnm, env.getUserContext()) |
44 |
71828 |
: nullptr) |
45 |
|
{ |
46 |
|
// create the equality engine, model manager, and shared solver |
47 |
15271 |
if (options().theory.eeMode == options::EqEngineMode::DISTRIBUTED) |
48 |
|
{ |
49 |
|
// use the distributed shared solver |
50 |
15234 |
d_sharedSolver.reset(new SharedSolverDistributed(env, d_te)); |
51 |
|
// make the distributed equality engine manager |
52 |
30468 |
d_eemanager.reset( |
53 |
15234 |
new EqEngineManagerDistributed(env, d_te, *d_sharedSolver.get())); |
54 |
|
// make the distributed model manager |
55 |
30468 |
d_mmanager.reset( |
56 |
15234 |
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 |
15271 |
} |
76 |
|
|
77 |
15266 |
CombinationEngine::~CombinationEngine() {} |
78 |
|
|
79 |
15271 |
void CombinationEngine::finishInit() |
80 |
|
{ |
81 |
15271 |
Assert(d_eemanager != nullptr); |
82 |
|
|
83 |
|
// initialize equality engines in all theories, including quantifiers engine |
84 |
|
// and the (provided) shared solver |
85 |
15271 |
d_eemanager->initializeTheories(); |
86 |
|
|
87 |
15271 |
Assert(d_mmanager != nullptr); |
88 |
|
// initialize the model manager, based on the notify object of this class |
89 |
15271 |
eq::EqualityEngineNotify* meen = getModelEqualityEngineNotify(); |
90 |
15271 |
d_mmanager->finishInit(meen); |
91 |
15271 |
} |
92 |
|
|
93 |
198523 |
const EeTheoryInfo* CombinationEngine::getEeTheoryInfo(TheoryId tid) const |
94 |
|
{ |
95 |
198523 |
return d_eemanager->getEeTheoryInfo(tid); |
96 |
|
} |
97 |
|
|
98 |
29638 |
void CombinationEngine::resetModel() { d_mmanager->resetModel(); } |
99 |
|
|
100 |
9676 |
void CombinationEngine::postProcessModel(bool incomplete) |
101 |
|
{ |
102 |
9676 |
d_eemanager->notifyModel(incomplete); |
103 |
|
// postprocess with the model |
104 |
9676 |
d_mmanager->postProcessModel(incomplete); |
105 |
9676 |
} |
106 |
|
|
107 |
17442122 |
theory::TheoryModel* CombinationEngine::getModel() |
108 |
|
{ |
109 |
17442122 |
return d_mmanager->getModel(); |
110 |
|
} |
111 |
|
|
112 |
15271 |
SharedSolver* CombinationEngine::getSharedSolver() |
113 |
|
{ |
114 |
15271 |
return d_sharedSolver.get(); |
115 |
|
} |
116 |
30873 |
bool CombinationEngine::isProofEnabled() const { return d_cmbsPg != nullptr; } |
117 |
|
|
118 |
15271 |
eq::EqualityEngineNotify* CombinationEngine::getModelEqualityEngineNotify() |
119 |
|
{ |
120 |
|
// by default, no notifications from model's equality engine |
121 |
15271 |
return nullptr; |
122 |
|
} |
123 |
|
|
124 |
88696 |
void CombinationEngine::resetRound() |
125 |
|
{ |
126 |
|
// compute the relevant terms? |
127 |
88696 |
} |
128 |
|
|
129 |
|
} // namespace theory |
130 |
31125 |
} // namespace cvc5 |