1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Dejan Jovanovic |
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_care_graph.h" |
17 |
|
|
18 |
|
#include "expr/node_visitor.h" |
19 |
|
#include "prop/prop_engine.h" |
20 |
|
#include "theory/care_graph.h" |
21 |
|
#include "theory/model_manager.h" |
22 |
|
#include "theory/shared_solver.h" |
23 |
|
#include "theory/theory_engine.h" |
24 |
|
|
25 |
|
namespace cvc5 { |
26 |
|
namespace theory { |
27 |
|
|
28 |
9854 |
CombinationCareGraph::CombinationCareGraph( |
29 |
|
TheoryEngine& te, |
30 |
|
Env& env, |
31 |
|
const std::vector<Theory*>& paraTheories, |
32 |
9854 |
ProofNodeManager* pnm) |
33 |
9854 |
: CombinationEngine(te, env, paraTheories, pnm) |
34 |
|
{ |
35 |
9854 |
} |
36 |
|
|
37 |
19708 |
CombinationCareGraph::~CombinationCareGraph() {} |
38 |
|
|
39 |
21921 |
void CombinationCareGraph::combineTheories() |
40 |
|
{ |
41 |
21921 |
Trace("combineTheories") << "TheoryEngine::combineTheories()" << std::endl; |
42 |
|
|
43 |
|
// Care graph we'll be building |
44 |
43842 |
CareGraph careGraph; |
45 |
|
|
46 |
|
// get the care graph from the parametric theories |
47 |
90045 |
for (Theory* t : d_paraTheories) |
48 |
|
{ |
49 |
68124 |
t->getCareGraph(&careGraph); |
50 |
|
} |
51 |
|
|
52 |
43842 |
Trace("combineTheories") |
53 |
21921 |
<< "TheoryEngine::combineTheories(): care graph size = " |
54 |
21921 |
<< careGraph.size() << std::endl; |
55 |
|
|
56 |
|
// Now add splitters for the ones we are interested in |
57 |
21921 |
prop::PropEngine* propEngine = d_te.getPropEngine(); |
58 |
52045 |
for (const CarePair& carePair : careGraph) |
59 |
|
{ |
60 |
60248 |
Debug("combineTheories") |
61 |
30124 |
<< "TheoryEngine::combineTheories(): checking " << carePair.d_a << " = " |
62 |
30124 |
<< carePair.d_b << " from " << carePair.d_theory << std::endl; |
63 |
|
|
64 |
|
// The equality in question (order for no repetition) |
65 |
60248 |
Node equality = carePair.d_a.eqNode(carePair.d_b); |
66 |
|
|
67 |
|
// We need to split on it |
68 |
60248 |
Debug("combineTheories") |
69 |
30124 |
<< "TheoryEngine::combineTheories(): requesting a split " << std::endl; |
70 |
|
|
71 |
60248 |
TrustNode tsplit; |
72 |
30124 |
if (isProofEnabled()) |
73 |
|
{ |
74 |
|
// make proof of splitting lemma |
75 |
10024 |
tsplit = d_cmbsPg->mkTrustNodeSplit(equality); |
76 |
|
} |
77 |
|
else |
78 |
|
{ |
79 |
40200 |
Node split = equality.orNode(equality.notNode()); |
80 |
20100 |
tsplit = TrustNode::mkTrustLemma(split, nullptr); |
81 |
|
} |
82 |
60248 |
d_sharedSolver->sendLemma( |
83 |
30124 |
tsplit, carePair.d_theory, InferenceId::COMBINATION_SPLIT); |
84 |
|
|
85 |
|
// Could check the equality status here: |
86 |
|
// EqualityStatus es = getEqualityStatus(carePair.d_a, carePair.d_b); |
87 |
|
// and only require true phase below if: |
88 |
|
// es == EQUALITY_TRUE || es == EQUALITY_TRUE_IN_MODEL |
89 |
|
// and require false phase below if: |
90 |
|
// es == EQUALITY_FALSE_IN_MODEL |
91 |
|
// This is supposed to force preference to follow what the theory models |
92 |
|
// already have but it doesn't seem to make a big difference - need to |
93 |
|
// explore more -Clark |
94 |
60248 |
Node e = d_valuation.ensureLiteral(equality); |
95 |
30124 |
propEngine->requirePhase(e, true); |
96 |
|
} |
97 |
21921 |
} |
98 |
|
|
99 |
25431 |
bool CombinationCareGraph::buildModel() |
100 |
|
{ |
101 |
|
// building the model happens as a separate step |
102 |
25431 |
return d_mmanager->buildModel(); |
103 |
|
} |
104 |
|
|
105 |
|
} // namespace theory |
106 |
29349 |
} // namespace cvc5 |