GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/engine_output_channel.cpp Lines: 70 93 75.3 %
Date: 2021-08-19 Branches: 74 228 32.5 %

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
128138
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory)
29
256276
    : conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
30
256276
                                                    + "conflicts")),
31
256276
      propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
32
256276
                                                       + "propagations")),
33
256276
      lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
34
256276
                                                 + "lemmas")),
35
256276
      requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
36
256276
                                                       + "requirePhase")),
37
256276
      restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
38
256276
                                                         + "restartDemands")),
39
128138
      trustedConflicts(smtStatisticsRegistry().registerInt(
40
256276
          getStatsPrefix(theory) + "trustedConflicts")),
41
256276
      trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
42
896966
                                                        + "trustedLemmas"))
43
{
44
128138
}
45
46
128138
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine,
47
128138
                                         theory::TheoryId theory)
48
128138
    : d_engine(engine), d_statistics(theory), d_theory(theory)
49
{
50
128138
}
51
52
235963
void EngineOutputChannel::safePoint(Resource r)
53
{
54
235963
  spendResource(r);
55
235963
  if (d_engine->d_interrupted)
56
  {
57
    throw theory::Interrupted();
58
  }
59
235963
}
60
61
void EngineOutputChannel::lemma(TNode lemma, LemmaProperty p)
62
{
63
  trustedLemma(TrustNode::mkTrustLemma(lemma), p);
64
}
65
66
9173469
bool EngineOutputChannel::propagate(TNode literal)
67
{
68
18346938
  Trace("theory::propagate") << "EngineOutputChannel<" << d_theory
69
9173469
                             << ">::propagate(" << literal << ")" << std::endl;
70
9173469
  ++d_statistics.propagations;
71
9173469
  d_engine->d_outputChannelUsed = true;
72
9173469
  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
37202
void EngineOutputChannel::requirePhase(TNode n, bool phase)
101
{
102
74404
  Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
103
37202
                  << ")" << std::endl;
104
37202
  ++d_statistics.requirePhase;
105
37202
  d_engine->getPropEngine()->requirePhase(n, phase);
106
37202
}
107
108
2150
void EngineOutputChannel::setIncomplete(IncompleteId id)
109
{
110
2150
  Trace("theory") << "setIncomplete(" << id << ")" << std::endl;
111
2150
  d_engine->setIncomplete(d_theory, id);
112
2150
}
113
114
5309957
void EngineOutputChannel::spendResource(Resource r)
115
{
116
5309957
  d_engine->spendResource(r);
117
5309957
}
118
119
49270
void EngineOutputChannel::handleUserAttribute(const char* attr,
120
                                              theory::Theory* t)
121
{
122
49270
  d_engine->handleUserAttribute(attr, t);
123
49270
}
124
125
103407
void EngineOutputChannel::trustedConflict(TrustNode pconf)
126
{
127
103407
  Assert(pconf.getKind() == TrustNodeKind::CONFLICT);
128
206814
  Trace("theory::conflict")
129
103407
      << "EngineOutputChannel<" << d_theory << ">::trustedConflict("
130
103407
      << pconf.getNode() << ")" << std::endl;
131
103407
  if (pconf.getGenerator() != nullptr)
132
  {
133
13896
    ++d_statistics.trustedConflicts;
134
  }
135
103407
  ++d_statistics.conflicts;
136
103407
  d_engine->d_outputChannelUsed = true;
137
103407
  d_engine->conflict(pconf, d_theory);
138
103407
}
139
140
306745
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p)
141
{
142
613490
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory
143
306745
                         << ">::trustedLemma(" << plem << ")" << std::endl;
144
306745
  Assert(plem.getKind() == TrustNodeKind::LEMMA);
145
306745
  if (plem.getGenerator() != nullptr)
146
  {
147
39991
    ++d_statistics.trustedLemmas;
148
  }
149
306745
  ++d_statistics.lemmas;
150
306745
  d_engine->d_outputChannelUsed = true;
151
306745
  if (isLemmaPropertySendAtoms(p))
152
  {
153
1185
    d_engine->ensureLemmaAtoms(plem.getNode(), d_theory);
154
  }
155
  // now, call the normal interface for lemma
156
306747
  d_engine->lemma(plem,
157
                  p,
158
                  d_theory);
159
306743
}
160
161
}  // namespace theory
162
29349
}  // namespace cvc5