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