1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Tim King, Morgan Deters |
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 |
|
* The theory engine output channel. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/engine_output_channel.h" |
17 |
|
|
18 |
|
#include "expr/skolem_manager.h" |
19 |
|
#include "prop/prop_engine.h" |
20 |
|
#include "smt/smt_statistics_registry.h" |
21 |
|
#include "theory/theory_engine.h" |
22 |
|
|
23 |
|
using namespace cvc5::kind; |
24 |
|
|
25 |
|
namespace cvc5 { |
26 |
|
namespace theory { |
27 |
|
|
28 |
123003 |
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory) |
29 |
246006 |
: conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
30 |
246006 |
+ "conflicts")), |
31 |
246006 |
propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
32 |
246006 |
+ "propagations")), |
33 |
246006 |
lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
34 |
246006 |
+ "lemmas")), |
35 |
246006 |
requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
36 |
246006 |
+ "requirePhase")), |
37 |
246006 |
restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
38 |
246006 |
+ "restartDemands")), |
39 |
123003 |
trustedConflicts(smtStatisticsRegistry().registerInt( |
40 |
246006 |
getStatsPrefix(theory) + "trustedConflicts")), |
41 |
246006 |
trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
42 |
861021 |
+ "trustedLemmas")) |
43 |
|
{ |
44 |
123003 |
} |
45 |
|
|
46 |
123003 |
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine, |
47 |
123003 |
theory::TheoryId theory) |
48 |
123003 |
: d_engine(engine), d_statistics(theory), d_theory(theory) |
49 |
|
{ |
50 |
123003 |
} |
51 |
|
|
52 |
22244200 |
void EngineOutputChannel::safePoint(Resource r) |
53 |
|
{ |
54 |
22244200 |
spendResource(r); |
55 |
22244200 |
if (d_engine->d_interrupted) |
56 |
|
{ |
57 |
|
throw theory::Interrupted(); |
58 |
|
} |
59 |
22244200 |
} |
60 |
|
|
61 |
1376 |
void EngineOutputChannel::lemma(TNode lemma, LemmaProperty p) |
62 |
|
{ |
63 |
2752 |
Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma(" |
64 |
1376 |
<< lemma << ")" |
65 |
1376 |
<< ", properties = " << p << std::endl; |
66 |
1376 |
++d_statistics.lemmas; |
67 |
1376 |
d_engine->d_outputChannelUsed = true; |
68 |
|
|
69 |
2752 |
TrustNode tlem = TrustNode::mkTrustLemma(lemma); |
70 |
2752 |
d_engine->lemma(tlem, |
71 |
|
p, |
72 |
1376 |
isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST, |
73 |
|
d_theory); |
74 |
1376 |
} |
75 |
|
|
76 |
|
void EngineOutputChannel::splitLemma(TNode lemma, bool removable) |
77 |
|
{ |
78 |
|
Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma(" |
79 |
|
<< lemma << ")" << std::endl; |
80 |
|
++d_statistics.lemmas; |
81 |
|
d_engine->d_outputChannelUsed = true; |
82 |
|
|
83 |
|
Trace("pf::explain") << "EngineOutputChannel::splitLemma( " << lemma << " )" |
84 |
|
<< std::endl; |
85 |
|
TrustNode tlem = TrustNode::mkTrustLemma(lemma); |
86 |
|
LemmaProperty p = removable ? LemmaProperty::REMOVABLE : LemmaProperty::NONE; |
87 |
|
d_engine->lemma(tlem, p, d_theory); |
88 |
|
} |
89 |
|
|
90 |
8610802 |
bool EngineOutputChannel::propagate(TNode literal) |
91 |
|
{ |
92 |
17221604 |
Trace("theory::propagate") << "EngineOutputChannel<" << d_theory |
93 |
8610802 |
<< ">::propagate(" << literal << ")" << std::endl; |
94 |
8610802 |
++d_statistics.propagations; |
95 |
8610802 |
d_engine->d_outputChannelUsed = true; |
96 |
8610802 |
return d_engine->propagate(literal, d_theory); |
97 |
|
} |
98 |
|
|
99 |
|
void EngineOutputChannel::conflict(TNode conflictNode) |
100 |
|
{ |
101 |
|
Trace("theory::conflict") |
102 |
|
<< "EngineOutputChannel<" << d_theory << ">::conflict(" << conflictNode |
103 |
|
<< ")" << std::endl; |
104 |
|
++d_statistics.conflicts; |
105 |
|
d_engine->d_outputChannelUsed = true; |
106 |
|
TrustNode tConf = TrustNode::mkTrustConflict(conflictNode); |
107 |
|
d_engine->conflict(tConf, d_theory); |
108 |
|
} |
109 |
|
|
110 |
|
void EngineOutputChannel::demandRestart() |
111 |
|
{ |
112 |
|
NodeManager* nm = NodeManager::currentNM(); |
113 |
|
SkolemManager* sm = nm->getSkolemManager(); |
114 |
|
Node restartVar = sm->mkDummySkolem( |
115 |
|
"restartVar", |
116 |
|
nm->booleanType(), |
117 |
|
"A boolean variable asserted to be true to force a restart"); |
118 |
|
Trace("theory::restart") << "EngineOutputChannel<" << d_theory |
119 |
|
<< ">::restart(" << restartVar << ")" << std::endl; |
120 |
|
++d_statistics.restartDemands; |
121 |
|
lemma(restartVar, LemmaProperty::REMOVABLE); |
122 |
|
} |
123 |
|
|
124 |
29993 |
void EngineOutputChannel::requirePhase(TNode n, bool phase) |
125 |
|
{ |
126 |
59986 |
Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase |
127 |
29993 |
<< ")" << std::endl; |
128 |
29993 |
++d_statistics.requirePhase; |
129 |
29993 |
d_engine->getPropEngine()->requirePhase(n, phase); |
130 |
29993 |
} |
131 |
|
|
132 |
2095 |
void EngineOutputChannel::setIncomplete(IncompleteId id) |
133 |
|
{ |
134 |
2095 |
Trace("theory") << "setIncomplete(" << id << ")" << std::endl; |
135 |
2095 |
d_engine->setIncomplete(d_theory, id); |
136 |
2095 |
} |
137 |
|
|
138 |
26861241 |
void EngineOutputChannel::spendResource(Resource r) |
139 |
|
{ |
140 |
26861241 |
d_engine->spendResource(r); |
141 |
26861241 |
} |
142 |
|
|
143 |
47295 |
void EngineOutputChannel::handleUserAttribute(const char* attr, |
144 |
|
theory::Theory* t) |
145 |
|
{ |
146 |
47295 |
d_engine->handleUserAttribute(attr, t); |
147 |
47295 |
} |
148 |
|
|
149 |
102410 |
void EngineOutputChannel::trustedConflict(TrustNode pconf) |
150 |
|
{ |
151 |
102410 |
Assert(pconf.getKind() == TrustNodeKind::CONFLICT); |
152 |
204820 |
Trace("theory::conflict") |
153 |
102410 |
<< "EngineOutputChannel<" << d_theory << ">::trustedConflict(" |
154 |
102410 |
<< pconf.getNode() << ")" << std::endl; |
155 |
102410 |
if (pconf.getGenerator() != nullptr) |
156 |
|
{ |
157 |
13980 |
++d_statistics.trustedConflicts; |
158 |
|
} |
159 |
102410 |
++d_statistics.conflicts; |
160 |
102410 |
d_engine->d_outputChannelUsed = true; |
161 |
102410 |
d_engine->conflict(pconf, d_theory); |
162 |
102410 |
} |
163 |
|
|
164 |
268766 |
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p) |
165 |
|
{ |
166 |
537532 |
Trace("theory::lemma") << "EngineOutputChannel<" << d_theory |
167 |
268766 |
<< ">::trustedLemma(" << plem << ")" << std::endl; |
168 |
268766 |
Assert(plem.getKind() == TrustNodeKind::LEMMA); |
169 |
268766 |
if (plem.getGenerator() != nullptr) |
170 |
|
{ |
171 |
33093 |
++d_statistics.trustedLemmas; |
172 |
|
} |
173 |
268766 |
++d_statistics.lemmas; |
174 |
268766 |
d_engine->d_outputChannelUsed = true; |
175 |
|
// now, call the normal interface for lemma |
176 |
537534 |
d_engine->lemma(plem, |
177 |
|
p, |
178 |
268766 |
isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST, |
179 |
|
d_theory); |
180 |
268764 |
} |
181 |
|
|
182 |
|
} // namespace theory |
183 |
28191 |
} // namespace cvc5 |