GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.cpp Lines: 54 55 98.2 %
Date: 2021-08-19 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
10498
Env::Env(NodeManager* nm, Options* opts)
37
10498
    : d_context(new context::Context()),
38
10498
      d_userContext(new context::UserContext()),
39
      d_nodeManager(nm),
40
      d_proofNodeManager(nullptr),
41
10498
      d_rewriter(new theory::Rewriter()),
42
20996
      d_topLevelSubs(new theory::TrustSubstitutionMap(d_userContext.get())),
43
10498
      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
73486
      d_resourceManager()
49
{
50
10498
  if (opts != nullptr)
51
  {
52
9624
    d_options.copyValues(*opts);
53
  }
54
10498
  d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
55
10498
}
56
57
10498
Env::~Env() {}
58
59
3769
void Env::setProofNodeManager(ProofNodeManager* pnm)
60
{
61
3769
  Assert(pnm != nullptr);
62
3769
  Assert(d_proofNodeManager == nullptr);
63
3769
  d_proofNodeManager = pnm;
64
3769
  d_rewriter->setProofNodeManager(pnm);
65
3769
  d_topLevelSubs->setProofNodeManager(pnm);
66
3769
}
67
68
6183
void Env::setFilename(const std::string& filename) { d_filename = filename; }
69
70
10498
void Env::shutdown()
71
{
72
10498
  d_rewriter.reset(nullptr);
73
10498
  d_dumpManager.reset(nullptr);
74
  // d_resourceManager must be destroyed before d_statisticsRegistry
75
10498
  d_resourceManager.reset(nullptr);
76
10498
}
77
78
983620
context::UserContext* Env::getUserContext() { return d_userContext.get(); }
79
80
33359982
context::Context* Env::getContext() { return d_context.get(); }
81
82
1388346
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
83
84
68219
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
85
86
107943
const std::string& Env::getFilename() const { return d_filename; }
87
88
12734
bool Env::isSatProofProducing() const
89
{
90
12734
  return d_proofNodeManager != nullptr
91
16802
         && (!d_options.smt.unsatCores
92
6598
             || d_options.smt.unsatCoresMode
93
12734
                    != options::UnsatCoresMode::ASSUMPTIONS);
94
}
95
96
248646
bool Env::isTheoryProofProducing() const
97
{
98
248646
  return d_proofNodeManager != nullptr
99
284406
         && (!d_options.smt.unsatCores
100
99312
             || d_options.smt.unsatCoresMode
101
248646
                    == options::UnsatCoresMode::FULL_PROOF);
102
}
103
104
31874516
theory::Rewriter* Env::getRewriter() { return d_rewriter.get(); }
105
106
352444
theory::TrustSubstitutionMap& Env::getTopLevelSubstitutions()
107
{
108
352444
  return *d_topLevelSubs.get();
109
}
110
111
22712
DumpManager* Env::getDumpManager() { return d_dumpManager.get(); }
112
113
303772
const LogicInfo& Env::getLogicInfo() const { return d_logic; }
114
115
4691835
StatisticsRegistry& Env::getStatisticsRegistry()
116
{
117
4691835
  return *d_statisticsRegistry;
118
}
119
120
138432
const Options& Env::getOptions() const { return d_options; }
121
122
const Options& Env::getOriginalOptions() const { return *d_originalOptions; }
123
124
15709684
ResourceManager* Env::getResourceManager() const
125
{
126
15709684
  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
29349
}  // namespace cvc5