GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/engine_output_channel.cpp Lines: 79 110 71.8 %
Date: 2021-08-01 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
127930
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory)
29
255860
    : conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
30
255860
                                                    + "conflicts")),
31
255860
      propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
32
255860
                                                       + "propagations")),
33
255860
      lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
34
255860
                                                 + "lemmas")),
35
255860
      requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
36
255860
                                                       + "requirePhase")),
37
255860
      restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
38
255860
                                                         + "restartDemands")),
39
127930
      trustedConflicts(smtStatisticsRegistry().registerInt(
40
255860
          getStatsPrefix(theory) + "trustedConflicts")),
41
255860
      trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
42
895510
                                                        + "trustedLemmas"))
43
{
44
127930
}
45
46
127930
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine,
47
127930
                                         theory::TheoryId theory)
48
127930
    : d_engine(engine), d_statistics(theory), d_theory(theory)
49
{
50
127930
}
51
52
160516
void EngineOutputChannel::safePoint(Resource r)
53
{
54
160516
  spendResource(r);
55
160516
  if (d_engine->d_interrupted)
56
  {
57
    throw theory::Interrupted();
58
  }
59
160516
}
60
61
1222
void EngineOutputChannel::lemma(TNode lemma, LemmaProperty p)
62
{
63
2444
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma("
64
1222
                         << lemma << ")"
65
1222
                         << ", properties = " << p << std::endl;
66
1222
  ++d_statistics.lemmas;
67
1222
  d_engine->d_outputChannelUsed = true;
68
69
2444
  TrustNode tlem = TrustNode::mkTrustLemma(lemma);
70
2444
  d_engine->lemma(tlem,
71
                  p,
72
1222
                  isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST,
73
                  d_theory);
74
1222
}
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
8467481
bool EngineOutputChannel::propagate(TNode literal)
91
{
92
16934962
  Trace("theory::propagate") << "EngineOutputChannel<" << d_theory
93
8467481
                             << ">::propagate(" << literal << ")" << std::endl;
94
8467481
  ++d_statistics.propagations;
95
8467481
  d_engine->d_outputChannelUsed = true;
96
8467481
  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
36026
void EngineOutputChannel::requirePhase(TNode n, bool phase)
125
{
126
72052
  Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
127
36026
                  << ")" << std::endl;
128
36026
  ++d_statistics.requirePhase;
129
36026
  d_engine->getPropEngine()->requirePhase(n, phase);
130
36026
}
131
132
2178
void EngineOutputChannel::setIncomplete(IncompleteId id)
133
{
134
2178
  Trace("theory") << "setIncomplete(" << id << ")" << std::endl;
135
2178
  d_engine->setIncomplete(d_theory, id);
136
2178
}
137
138
5184867
void EngineOutputChannel::spendResource(Resource r)
139
{
140
5184867
  d_engine->spendResource(r);
141
5184867
}
142
143
49190
void EngineOutputChannel::handleUserAttribute(const char* attr,
144
                                              theory::Theory* t)
145
{
146
49190
  d_engine->handleUserAttribute(attr, t);
147
49190
}
148
149
102336
void EngineOutputChannel::trustedConflict(TrustNode pconf)
150
{
151
102336
  Assert(pconf.getKind() == TrustNodeKind::CONFLICT);
152
204672
  Trace("theory::conflict")
153
102336
      << "EngineOutputChannel<" << d_theory << ">::trustedConflict("
154
102336
      << pconf.getNode() << ")" << std::endl;
155
102336
  if (pconf.getGenerator() != nullptr)
156
  {
157
13898
    ++d_statistics.trustedConflicts;
158
  }
159
102336
  ++d_statistics.conflicts;
160
102336
  d_engine->d_outputChannelUsed = true;
161
102336
  d_engine->conflict(pconf, d_theory);
162
102336
}
163
164
298445
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p)
165
{
166
596890
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory
167
298445
                         << ">::trustedLemma(" << plem << ")" << std::endl;
168
298445
  Assert(plem.getKind() == TrustNodeKind::LEMMA);
169
298445
  if (plem.getGenerator() != nullptr)
170
  {
171
39126
    ++d_statistics.trustedLemmas;
172
  }
173
298445
  ++d_statistics.lemmas;
174
298445
  d_engine->d_outputChannelUsed = true;
175
  // now, call the normal interface for lemma
176
596892
  d_engine->lemma(plem,
177
                  p,
178
298445
                  isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST,
179
                  d_theory);
180
298443
}
181
182
}  // namespace theory
183
29280
}  // namespace cvc5