GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 54 55 98.2 %
Date: 2021-09-15 Branches: 38 88 43.2 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Gereon Kremer, Aina Niemetz
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
 * Smt Environment, main access to global utilities available to
14
 * internal code.
15
 */
16
17
#include "smt/env.h"
18
19
#include "context/context.h"
20
#include "expr/node.h"
21
#include "options/base_options.h"
22
#include "options/smt_options.h"
23
#include "printer/printer.h"
24
#include "proof/conv_proof_generator.h"
25
#include "smt/dump_manager.h"
26
#include "smt/smt_engine_stats.h"
27
#include "theory/rewriter.h"
28
#include "theory/trust_substitutions.h"
29
#include "util/resource_manager.h"
30
#include "util/statistics_registry.h"
31
32
using namespace cvc5::smt;
33
34
namespace cvc5 {
35
36
13223
Env::Env(NodeManager* nm, const Options* opts)
37
13223
    : d_context(new context::Context()),
38
13223
      d_userContext(new context::UserContext()),
39
      d_nodeManager(nm),
40
      d_proofNodeManager(nullptr),
41
13223
      d_rewriter(new theory::Rewriter()),
42
26446
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
43
13223
      d_dumpManager(new DumpManager(d_userContext.get())),
44
      d_logic(),
45
      d_statisticsRegistry(std::make_unique<StatisticsRegistry>(*this)),
46
      d_options(),
47
      d_originalOptions(opts),
48
92561
      d_resourceManager()
49
{
50
13223
  if (opts != nullptr)
51
  {
52
12337
    d_options.copyValues(*opts);
53
  }
54
13223
  d_statisticsRegistry->registerTimer("global::totalTime").start();
55
13223
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
56
13223
}
57
58
10576
Env::~Env() {}
59
60
3796
void Env::setProofNodeManager(ProofNodeManager* pnm)
61
{
62
3796
  Assert(pnm != nullptr);
63
3796
  Assert(d_proofNodeManager == nullptr);
64
3796
  d_proofNodeManager = pnm;
65
3796
  d_rewriter->setProofNodeManager(pnm);
66
3796
  d_topLevelSubs->setProofNodeManager(pnm);
67
3796
}
68
69
10562
void Env::shutdown()
70
{
71
10562
  d_rewriter.reset(nullptr);
72
10562
  d_dumpManager.reset(nullptr);
73
  // d_resourceManager must be destroyed before d_statisticsRegistry
74
10562
  d_resourceManager.reset(nullptr);
75
10562
}
76
77
1023739
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
78
79
38478189
context::Context* Env::getContext() { return d_context.get(); }
80
81
3082380
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
82
83
92480
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
84
85
133875
bool Env::isSatProofProducing() const
86
{
87
133875
  return d_proofNodeManager != nullptr
88
156491
         && (!d_options.smt.unsatCores
89
54775
             || (d_options.smt.unsatCoresMode
90
                     != options::UnsatCoresMode::ASSUMPTIONS
91
22620
                 && d_options.smt.unsatCoresMode
92
133875
                        != options::UnsatCoresMode::PP_ONLY));
93
}
94
95
175199
bool Env::isTheoryProofProducing() const
96
{
97
175199
  return d_proofNodeManager != nullptr
98
196809
         && (!d_options.smt.unsatCores
99
66025
             || d_options.smt.unsatCoresMode
100
175199
                    == options::UnsatCoresMode::FULL_PROOF);
101
}
102
103
37547941
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
104
105
359858
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
106
{
107
359858
  return *d_topLevelSubs.get();
108
}
109
110
25517
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
111
112
6396652
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
113
114
3996328
StatisticsRegistry& Env::getStatisticsRegistry()
115
{
116
3996328
  return *d_statisticsRegistry;
117
}
118
119
37137009
const Options& Env::getOptions() const { return d_options; }
120
121
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
122
123
17176777
ResourceManager* Env::getResourceManager() const
124
{
125
17176777
  return d_resourceManager.get();
126
}
127
128
27
const Printer& Env::getPrinter()
129
{
130
27
  return *Printer::getPrinter(d_options.base.outputLanguage);
131
}
132
133
27
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
134
135
29577
}  // namespace cvc5