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 |
129100 |
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory) |
29 |
258200 |
: conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
30 |
258200 |
+ "conflicts")), |
31 |
258200 |
propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
32 |
258200 |
+ "propagations")), |
33 |
258200 |
lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
34 |
258200 |
+ "lemmas")), |
35 |
258200 |
requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
36 |
258200 |
+ "requirePhase")), |
37 |
258200 |
restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
38 |
258200 |
+ "restartDemands")), |
39 |
129100 |
trustedConflicts(smtStatisticsRegistry().registerInt( |
40 |
258200 |
getStatsPrefix(theory) + "trustedConflicts")), |
41 |
258200 |
trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory) |
42 |
903700 |
+ "trustedLemmas")) |
43 |
|
{ |
44 |
129100 |
} |
45 |
|
|
46 |
129100 |
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine, |
47 |
129100 |
theory::TheoryId theory) |
48 |
129100 |
: d_engine(engine), d_statistics(theory), d_theory(theory) |
49 |
|
{ |
50 |
129100 |
} |
51 |
|
|
52 |
243198 |
void EngineOutputChannel::safePoint(Resource r) |
53 |
|
{ |
54 |
243198 |
spendResource(r); |
55 |
243198 |
if (d_engine->d_interrupted) |
56 |
|
{ |
57 |
|
throw theory::Interrupted(); |
58 |
|
} |
59 |
243198 |
} |
60 |
|
|
61 |
|
void EngineOutputChannel::lemma(TNode lemma, LemmaProperty p) |
62 |
|
{ |
63 |
|
trustedLemma(TrustNode::mkTrustLemma(lemma), p); |
64 |
|
} |
65 |
|
|
66 |
9901249 |
bool EngineOutputChannel::propagate(TNode literal) |
67 |
|
{ |
68 |
19802498 |
Trace("theory::propagate") << "EngineOutputChannel<" << d_theory |
69 |
9901249 |
<< ">::propagate(" << literal << ")" << std::endl; |
70 |
9901249 |
++d_statistics.propagations; |
71 |
9901249 |
d_engine->d_outputChannelUsed = true; |
72 |
9901249 |
return d_engine->propagate(literal, d_theory); |
73 |
|
} |
74 |
|
|
75 |
|
void EngineOutputChannel::conflict(TNode conflictNode) |
76 |
|
{ |
77 |
|
Trace("theory::conflict") |
78 |
|
<< "EngineOutputChannel<" << d_theory << ">::conflict(" << conflictNode |
79 |
|
<< ")" << std::endl; |
80 |
|
++d_statistics.conflicts; |
81 |
|
d_engine->d_outputChannelUsed = true; |
82 |
|
TrustNode tConf = TrustNode::mkTrustConflict(conflictNode); |
83 |
|
d_engine->conflict(tConf, d_theory); |
84 |
|
} |
85 |
|
|
86 |
|
void EngineOutputChannel::demandRestart() |
87 |
|
{ |
88 |
|
NodeManager* nm = NodeManager::currentNM(); |
89 |
|
SkolemManager* sm = nm->getSkolemManager(); |
90 |
|
Node restartVar = sm->mkDummySkolem( |
91 |
|
"restartVar", |
92 |
|
nm->booleanType(), |
93 |
|
"A boolean variable asserted to be true to force a restart"); |
94 |
|
Trace("theory::restart") << "EngineOutputChannel<" << d_theory |
95 |
|
<< ">::restart(" << restartVar << ")" << std::endl; |
96 |
|
++d_statistics.restartDemands; |
97 |
|
lemma(restartVar, LemmaProperty::REMOVABLE); |
98 |
|
} |
99 |
|
|
100 |
39359 |
void EngineOutputChannel::requirePhase(TNode n, bool phase) |
101 |
|
{ |
102 |
78718 |
Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase |
103 |
39359 |
<< ")" << std::endl; |
104 |
39359 |
++d_statistics.requirePhase; |
105 |
39359 |
d_engine->getPropEngine()->requirePhase(n, phase); |
106 |
39359 |
} |
107 |
|
|
108 |
2100 |
void EngineOutputChannel::setIncomplete(IncompleteId id) |
109 |
|
{ |
110 |
2100 |
Trace("theory") << "setIncomplete(" << id << ")" << std::endl; |
111 |
2100 |
d_engine->setIncomplete(d_theory, id); |
112 |
2100 |
} |
113 |
|
|
114 |
5723119 |
void EngineOutputChannel::spendResource(Resource r) |
115 |
|
{ |
116 |
5723119 |
d_engine->spendResource(r); |
117 |
5723119 |
} |
118 |
|
|
119 |
114255 |
void EngineOutputChannel::trustedConflict(TrustNode pconf) |
120 |
|
{ |
121 |
114255 |
Assert(pconf.getKind() == TrustNodeKind::CONFLICT); |
122 |
228510 |
Trace("theory::conflict") |
123 |
114255 |
<< "EngineOutputChannel<" << d_theory << ">::trustedConflict(" |
124 |
114255 |
<< pconf.getNode() << ")" << std::endl; |
125 |
114255 |
if (pconf.getGenerator() != nullptr) |
126 |
|
{ |
127 |
15406 |
++d_statistics.trustedConflicts; |
128 |
|
} |
129 |
114255 |
++d_statistics.conflicts; |
130 |
114255 |
d_engine->d_outputChannelUsed = true; |
131 |
114255 |
d_engine->conflict(pconf, d_theory); |
132 |
114255 |
} |
133 |
|
|
134 |
316269 |
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p) |
135 |
|
{ |
136 |
632538 |
Trace("theory::lemma") << "EngineOutputChannel<" << d_theory |
137 |
316269 |
<< ">::trustedLemma(" << plem << ")" << std::endl; |
138 |
316269 |
Assert(plem.getKind() == TrustNodeKind::LEMMA); |
139 |
316269 |
if (plem.getGenerator() != nullptr) |
140 |
|
{ |
141 |
43819 |
++d_statistics.trustedLemmas; |
142 |
|
} |
143 |
316269 |
++d_statistics.lemmas; |
144 |
316269 |
d_engine->d_outputChannelUsed = true; |
145 |
316269 |
if (isLemmaPropertySendAtoms(p)) |
146 |
|
{ |
147 |
1195 |
d_engine->ensureLemmaAtoms(plem.getNode(), d_theory); |
148 |
|
} |
149 |
|
// now, call the normal interface for lemma |
150 |
316271 |
d_engine->lemma(plem, |
151 |
|
p, |
152 |
|
d_theory); |
153 |
316267 |
} |
154 |
|
|
155 |
|
} // namespace theory |
156 |
29505 |
} // namespace cvc5 |