GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 53 54 98.1 %
Date: 2021-09-10 Branches: 36 86 41.9 %

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
13182
Env::Env(NodeManager* nm, const Options* opts)
37
13182
    : d_context(new context::Context()),
38
13182
      d_userContext(new context::UserContext()),
39
      d_nodeManager(nm),
40
      d_proofNodeManager(nullptr),
41
13182
      d_rewriter(new theory::Rewriter()),
42
26364
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
43
13182
      d_dumpManager(new DumpManager(d_userContext.get())),
44
      d_logic(),
45
      d_statisticsRegistry(std::make_unique<StatisticsRegistry>()),
46
      d_options(),
47
      d_originalOptions(opts),
48
92274
      d_resourceManager()
49
{
50
13182
  if (opts != nullptr)
51
  {
52
12296
    d_options.copyValues(*opts);
53
  }
54
13182
  d_statisticsRegistry->registerTimer("global::totalTime").start();
55
13182
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
56
13182
}
57
58
10541
Env::~Env() {}
59
60
3781
void Env::setProofNodeManager(ProofNodeManager* pnm)
61
{
62
3781
  Assert(pnm != nullptr);
63
3781
  Assert(d_proofNodeManager == nullptr);
64
3781
  d_proofNodeManager = pnm;
65
3781
  d_rewriter->setProofNodeManager(pnm);
66
3781
  d_topLevelSubs->setProofNodeManager(pnm);
67
3781
}
68
69
10529
void Env::shutdown()
70
{
71
10529
  d_rewriter.reset(nullptr);
72
10529
  d_dumpManager.reset(nullptr);
73
  // d_resourceManager must be destroyed before d_statisticsRegistry
74
10529
  d_resourceManager.reset(nullptr);
75
10529
}
76
77
1029645
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
78
79
36476621
context::Context* Env::getContext() { return d_context.get(); }
80
81
3065371
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
82
83
92211
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
84
85
133241
bool Env::isSatProofProducing() const
86
{
87
133241
  return d_proofNodeManager != nullptr
88
155970
         && (!d_options.smt.unsatCores
89
54162
             || d_options.smt.unsatCoresMode
90
133241
                    != options::UnsatCoresMode::ASSUMPTIONS);
91
}
92
93
174714
bool Env::isTheoryProofProducing() const
94
{
95
174714
  return d_proofNodeManager != nullptr
96
196279
         && (!d_options.smt.unsatCores
97
65780
             || d_options.smt.unsatCoresMode
98
174714
                    == options::UnsatCoresMode::FULL_PROOF);
99
}
100
101
36901761
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
102
103
359714
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
104
{
105
359714
  return *d_topLevelSubs.get();
106
}
107
108
25449
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
109
110
5921545
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
111
112
4738026
StatisticsRegistry& Env::getStatisticsRegistry()
113
{
114
4738026
  return *d_statisticsRegistry;
115
}
116
117
35641283
const Options& Env::getOptions() const { return d_options; }
118
119
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
120
121
16755971
ResourceManager* Env::getResourceManager() const
122
{
123
16755971
  return d_resourceManager.get();
124
}
125
126
57
const Printer& Env::getPrinter()
127
{
128
57
  return *Printer::getPrinter(d_options.base.outputLanguage);
129
}
130
131
57
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
132
133
29502
}  // namespace cvc5