GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 54 55 98.2 %
Date: 2021-08-20 Branches: 33 80 41.3 %

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
10513
Env::Env(NodeManager* nm, Options* opts)
37
10513
    : d_context(new context::Context()),
38
10513
      d_userContext(new context::UserContext()),
39
      d_nodeManager(nm),
40
      d_proofNodeManager(nullptr),
41
10513
      d_rewriter(new theory::Rewriter()),
42
21026
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
43
10513
      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
73591
      d_resourceManager()
49
{
50
10513
  if (opts != nullptr)
51
  {
52
9639
    d_options.copyValues(*opts);
53
  }
54
10513
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
55
10513
}
56
57
10513
Env::~Env() {}
58
59
3771
void Env::setProofNodeManager(ProofNodeManager* pnm)
60
{
61
3771
  Assert(pnm != nullptr);
62
3771
  Assert(d_proofNodeManager == nullptr);
63
3771
  d_proofNodeManager = pnm;
64
3771
  d_rewriter->setProofNodeManager(pnm);
65
3771
  d_topLevelSubs->setProofNodeManager(pnm);
66
3771
}
67
68
6185
void Env::setFilename(const std::string& filename) { d_filename = filename; }
69
70
10501
void Env::shutdown()
71
{
72
10501
  d_rewriter.reset(nullptr);
73
10501
  d_dumpManager.reset(nullptr);
74
  // d_resourceManager must be destroyed before d_statisticsRegistry
75
10501
  d_resourceManager.reset(nullptr);
76
10501
}
77
78
1025016
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
79
80
35496570
context::Context* Env::getContext() { return d_context.get(); }
81
82
1388486
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
83
84
73010
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
85
86
107947
const std::string& Env::getFilename() const { return d_filename; }
87
88
123849
bool Env::isSatProofProducing() const
89
{
90
123849
  return d_proofNodeManager != nullptr
91
146233
         && (!d_options.smt.unsatCores
92
53612
             || d_options.smt.unsatCoresMode
93
123849
                    != options::UnsatCoresMode::ASSUMPTIONS);
94
}
95
96
173644
bool Env::isTheoryProofProducing() const
97
{
98
173644
  return d_proofNodeManager != nullptr
99
195279
         && (!d_options.smt.unsatCores
100
65580
             || d_options.smt.unsatCoresMode
101
173644
                    == options::UnsatCoresMode::FULL_PROOF);
102
}
103
104
32392738
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
105
106
352447
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
107
{
108
352447
  return *d_topLevelSubs.get();
109
}
110
111
22717
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
112
113
303957
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
114
115
4692785
StatisticsRegistry& Env::getStatisticsRegistry()
116
{
117
4692785
  return *d_statisticsRegistry;
118
}
119
120
30885667
const Options& Env::getOptions() const { return d_options; }
121
122
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
123
124
16131394
ResourceManager* Env::getResourceManager() const
125
{
126
16131394
  return d_resourceManager.get();
127
}
128
129
10
const Printer& Env::getPrinter()
130
{
131
10
  return *Printer::getPrinter(d_options.base.outputLanguage);
132
}
133
134
9
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
135
136
29358
}  // namespace cvc5