GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/engine_output_channel.cpp Lines: 67 90 74.4 %
Date: 2021-11-05 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
198559
EngineOutputChannel::Statistics::Statistics(theory::TheoryId theory)
29
397118
    : conflicts(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
30
397118
                                                    + "conflicts")),
31
397118
      propagations(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
32
397118
                                                       + "propagations")),
33
397118
      lemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
34
397118
                                                 + "lemmas")),
35
397118
      requirePhase(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
36
397118
                                                       + "requirePhase")),
37
397118
      restartDemands(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
38
397118
                                                         + "restartDemands")),
39
198559
      trustedConflicts(smtStatisticsRegistry().registerInt(
40
397118
          getStatsPrefix(theory) + "trustedConflicts")),
41
397118
      trustedLemmas(smtStatisticsRegistry().registerInt(getStatsPrefix(theory)
42
1389913
                                                        + "trustedLemmas"))
43
{
44
198559
}
45
46
198559
EngineOutputChannel::EngineOutputChannel(TheoryEngine* engine,
47
198559
                                         theory::TheoryId theory)
48
198559
    : d_engine(engine), d_statistics(theory), d_theory(theory)
49
{
50
198559
}
51
52
181865
void EngineOutputChannel::safePoint(Resource r)
53
{
54
181865
  spendResource(r);
55
181865
  if (d_engine->d_interrupted)
56
  {
57
    throw theory::Interrupted();
58
  }
59
181865
}
60
61
void EngineOutputChannel::lemma(TNode lemma, LemmaProperty p)
62
{
63
  trustedLemma(TrustNode::mkTrustLemma(lemma), p);
64
}
65
66
13245455
bool EngineOutputChannel::propagate(TNode literal)
67
{
68
26490910
  Trace("theory::propagate") << "EngineOutputChannel<" << d_theory
69
13245455
                             << ">::propagate(" << literal << ")" << std::endl;
70
13245455
  ++d_statistics.propagations;
71
13245455
  d_engine->d_outputChannelUsed = true;
72
13245455
  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
41155
void EngineOutputChannel::requirePhase(TNode n, bool phase)
101
{
102
82310
  Trace("theory") << "EngineOutputChannel::requirePhase(" << n << ", " << phase
103
41155
                  << ")" << std::endl;
104
41155
  ++d_statistics.requirePhase;
105
41155
  d_engine->getPropEngine()->requirePhase(n, phase);
106
41155
}
107
108
4992
void EngineOutputChannel::setIncomplete(IncompleteId id)
109
{
110
4992
  Trace("theory") << "setIncomplete(" << id << ")" << std::endl;
111
4992
  d_engine->setIncomplete(d_theory, id);
112
4992
}
113
114
7250922
void EngineOutputChannel::spendResource(Resource r)
115
{
116
7250922
  d_engine->spendResource(r);
117
7250922
}
118
119
130499
void EngineOutputChannel::trustedConflict(TrustNode pconf)
120
{
121
130499
  Assert(pconf.getKind() == TrustNodeKind::CONFLICT);
122
260998
  Trace("theory::conflict")
123
130499
      << "EngineOutputChannel<" << d_theory << ">::trustedConflict("
124
130499
      << pconf.getNode() << ")" << std::endl;
125
130499
  if (pconf.getGenerator() != nullptr)
126
  {
127
15123
    ++d_statistics.trustedConflicts;
128
  }
129
130499
  ++d_statistics.conflicts;
130
130499
  d_engine->d_outputChannelUsed = true;
131
130499
  d_engine->conflict(pconf, d_theory);
132
130499
}
133
134
364394
void EngineOutputChannel::trustedLemma(TrustNode plem, LemmaProperty p)
135
{
136
728788
  Trace("theory::lemma") << "EngineOutputChannel<" << d_theory
137
364394
                         << ">::trustedLemma(" << plem << ")" << std::endl;
138
364394
  Assert(plem.getKind() == TrustNodeKind::LEMMA);
139
364394
  if (plem.getGenerator() != nullptr)
140
  {
141
47288
    ++d_statistics.trustedLemmas;
142
  }
143
364394
  ++d_statistics.lemmas;
144
364394
  d_engine->d_outputChannelUsed = true;
145
364394
  if (isLemmaPropertySendAtoms(p))
146
  {
147
1627
    d_engine->ensureLemmaAtoms(plem.getNode(), d_theory);
148
  }
149
  // now, call the normal interface for lemma
150
364396
  d_engine->lemma(plem,
151
                  p,
152
                  d_theory);
153
364392
}
154
155
}  // namespace theory
156
31125
}  // namespace cvc5