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