GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/engine_output_channel.cpp Lines: 79 110 71.8 %
Date: 2021-05-21 Branches: 89 296 30.1 %

Line Exec Source
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
116438
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory)
29
232876
    : conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
30
232876
                                                    + "conflicts")),
31
232876
      propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
32
232876
                                                       + "propagations")),
33
232876
      lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
34
232876
                                                 + "lemmas")),
35
232876
      requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
36
232876
                                                       + "requirePhase")),
37
232876
      restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
38
232876
                                                         + "restartDemands")),
39
116438
      trustedConflicts(smtStatisticsRegistry().registerInt(
40
232876
          getStatsPrefix(theory) + "trustedConflicts")),
41
232876
      trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
42
815066
                                                        + "trustedLemmas"))
43
{
44
116438
}
45
46
116438
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine,
47
116438
                                         theory::TheoryId theory)
48
116438
    : d_engine(engine), d_statistics(theory), d_theory(theory)
49
{
50
116438
}
51
52
21979609
void EngineOutputChannel::safePoint(Resource r)
53
{
54
21979609
  spendResource(r);
55
21979609
  if (d_engine->d_interrupted)
56
  {
57
    throw theory::Interrupted();
58
  }
59
21979609
}
60
61
1309
void EngineOutputChannel::lemma(TNode lemma, LemmaProperty p)
62
{
63
2618
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma("
64
1309
                         << lemma << ")"
65
1309
                         << ", properties = " << p << std::endl;
66
1309
  ++d_statistics.lemmas;
67
1309
  d_engine->d_outputChannelUsed = true;
68
69
2618
  TrustNode tlem = TrustNode::mkTrustLemma(lemma);
70
2618
  d_engine->lemma(tlem,
71
                  p,
72
1309
                  isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST,
73
                  d_theory);
74
1309
}
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
8348863
bool EngineOutputChannel::propagate(TNode literal)
91
{
92
16697726
  Trace("theory::propagate") << "EngineOutputChannel<" << d_theory
93
8348863
                             << ">::propagate(" << literal << ")" << std::endl;
94
8348863
  ++d_statistics.propagations;
95
8348863
  d_engine->d_outputChannelUsed = true;
96
8348863
  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
29808
void EngineOutputChannel::requirePhase(TNode n, bool phase)
125
{
126
59616
  Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
127
29808
                  << ")" << std::endl;
128
29808
  ++d_statistics.requirePhase;
129
29808
  d_engine->getPropEngine()->requirePhase(n, phase);
130
29808
}
131
132
2097
void EngineOutputChannel::setIncomplete(IncompleteId id)
133
{
134
2097
  Trace("theory") << "setIncomplete(" << id << ")" << std::endl;
135
2097
  d_engine->setIncomplete(d_theory, id);
136
2097
}
137
138
26504958
void EngineOutputChannel::spendResource(Resource r)
139
{
140
26504958
  d_engine->spendResource(r);
141
26504958
}
142
143
44770
void EngineOutputChannel::handleUserAttribute(const char* attr,
144
                                              theory::Theory* t)
145
{
146
44770
  d_engine->handleUserAttribute(attr, t);
147
44770
}
148
149
96216
void EngineOutputChannel::trustedConflict(TrustNode pconf)
150
{
151
96216
  Assert(pconf.getKind() == TrustNodeKind::CONFLICT);
152
192432
  Trace("theory::conflict")
153
96216
      << "EngineOutputChannel<" << d_theory << ">::trustedConflict("
154
96216
      << pconf.getNode() << ")" << std::endl;
155
96216
  if (pconf.getGenerator() != nullptr)
156
  {
157
14013
    ++d_statistics.trustedConflicts;
158
  }
159
96216
  ++d_statistics.conflicts;
160
96216
  d_engine->d_outputChannelUsed = true;
161
96216
  d_engine->conflict(pconf, d_theory);
162
96216
}
163
164
261709
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p)
165
{
166
523418
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory
167
261709
                         << ">::trustedLemma(" << plem << ")" << std::endl;
168
261709
  Assert(plem.getKind() == TrustNodeKind::LEMMA);
169
261709
  if (plem.getGenerator() != nullptr)
170
  {
171
33178
    ++d_statistics.trustedLemmas;
172
  }
173
261709
  ++d_statistics.lemmas;
174
261709
  d_engine->d_outputChannelUsed = true;
175
  // now, call the normal interface for lemma
176
523420
  d_engine->lemma(plem,
177
                  p,
178
261709
                  isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST,
179
                  d_theory);
180
261707
}
181
182
}  // namespace theory
183
27735
}  // namespace cvc5