GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/engine_output_channel.cpp Lines: 79 110 71.8 %
Date: 2021-05-22 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
123016
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory)
29
246032
    : conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
30
246032
                                                    + "conflicts")),
31
246032
      propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
32
246032
                                                       + "propagations")),
33
246032
      lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
34
246032
                                                 + "lemmas")),
35
246032
      requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
36
246032
                                                       + "requirePhase")),
37
246032
      restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
38
246032
                                                         + "restartDemands")),
39
123016
      trustedConflicts(smtStatisticsRegistry().registerInt(
40
246032
          getStatsPrefix(theory) + "trustedConflicts")),
41
246032
      trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
42
861112
                                                        + "trustedLemmas"))
43
{
44
123016
}
45
46
123016
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine,
47
123016
                                         theory::TheoryId theory)
48
123016
    : d_engine(engine), d_statistics(theory), d_theory(theory)
49
{
50
123016
}
51
52
22244238
void EngineOutputChannel::safePoint(Resource r)
53
{
54
22244238
  spendResource(r);
55
22244238
  if (d_engine->d_interrupted)
56
  {
57
    throw theory::Interrupted();
58
  }
59
22244238
}
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
8798640
bool EngineOutputChannel::propagate(TNode literal)
91
{
92
17597280
  Trace("theory::propagate") << "EngineOutputChannel<" << d_theory
93
8798640
                             << ">::propagate(" << literal << ")" << std::endl;
94
8798640
  ++d_statistics.propagations;
95
8798640
  d_engine->d_outputChannelUsed = true;
96
8798640
  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
30523
void EngineOutputChannel::requirePhase(TNode n, bool phase)
125
{
126
61046
  Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
127
30523
                  << ")" << std::endl;
128
30523
  ++d_statistics.requirePhase;
129
30523
  d_engine->getPropEngine()->requirePhase(n, phase);
130
30523
}
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
26971786
void EngineOutputChannel::spendResource(Resource r)
139
{
140
26971786
  d_engine->spendResource(r);
141
26971786
}
142
143
47300
void EngineOutputChannel::handleUserAttribute(const char* attr,
144
                                              theory::Theory* t)
145
{
146
47300
  d_engine->handleUserAttribute(attr, t);
147
47300
}
148
149
103505
void EngineOutputChannel::trustedConflict(TrustNode pconf)
150
{
151
103505
  Assert(pconf.getKind() == TrustNodeKind::CONFLICT);
152
207010
  Trace("theory::conflict")
153
103505
      << "EngineOutputChannel<" << d_theory << ">::trustedConflict("
154
103505
      << pconf.getNode() << ")" << std::endl;
155
103505
  if (pconf.getGenerator() != nullptr)
156
  {
157
13980
    ++d_statistics.trustedConflicts;
158
  }
159
103505
  ++d_statistics.conflicts;
160
103505
  d_engine->d_outputChannelUsed = true;
161
103505
  d_engine->conflict(pconf, d_theory);
162
103505
}
163
164
270062
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p)
165
{
166
540124
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory
167
270062
                         << ">::trustedLemma(" << plem << ")" << std::endl;
168
270062
  Assert(plem.getKind() == TrustNodeKind::LEMMA);
169
270062
  if (plem.getGenerator() != nullptr)
170
  {
171
33093
    ++d_statistics.trustedLemmas;
172
  }
173
270062
  ++d_statistics.lemmas;
174
270062
  d_engine->d_outputChannelUsed = true;
175
  // now, call the normal interface for lemma
176
540126
  d_engine->lemma(plem,
177
                  p,
178
270062
                  isLemmaPropertySendAtoms(p) ? d_theory : theory::THEORY_LAST,
179
                  d_theory);
180
270060
}
181
182
}  // namespace theory
183
28194
}  // namespace cvc5