GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/env.h Lines: 2 2 100.0 %
Date: 2021-05-22 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Andres Noetzli, 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
 * Smt Environment, main access to global utilities available to
14
 * internal code
15
 */
16
17
#include "cvc5_public.h"
18
19
#ifndef CVC5__SMT__ENV_H
20
#define CVC5__SMT__ENV_H
21
22
#include <memory>
23
24
#include "options/options.h"
25
#include "theory/logic_info.h"
26
#include "util/statistics_registry.h"
27
28
namespace cvc5 {
29
30
class NodeManager;
31
class StatisticsRegistry;
32
class ProofNodeManager;
33
class Printer;
34
class ResourceManager;
35
36
namespace context {
37
class Context;
38
class UserContext;
39
}  // namespace context
40
41
namespace smt {
42
class DumpManager;
43
}
44
45
namespace theory {
46
class Rewriter;
47
class TrustSubstitutionMap;
48
}
49
50
/**
51
 * The environment class.
52
 *
53
 * This class lives in the SmtEngine and contains all utilities that are
54
 * globally available to all internal code.
55
 */
56
class Env
57
{
58
  friend class SmtEngine;
59
60
 public:
61
  /**
62
   * Construct an Env with the given node manager.
63
   */
64
  Env(NodeManager* nm, Options* opts);
65
  /** Destruct the env.  */
66
  ~Env();
67
68
  /* Access to members------------------------------------------------------- */
69
  /** Get a pointer to the Context owned by this Env. */
70
  context::Context* getContext();
71
72
  /** Get a pointer to the UserContext owned by this Env. */
73
  context::UserContext* getUserContext();
74
75
  /** Get a pointer to the underlying NodeManager. */
76
  NodeManager* getNodeManager() const;
77
78
  /**
79
   * Get the underlying proof node manager. Note since proofs depend on option
80
   * initialization, this is only available after the SmtEngine that owns this
81
   * environment is initialized, and only non-null if proofs are enabled.
82
   */
83
  ProofNodeManager* getProofNodeManager();
84
85
  /** Get a pointer to the Rewriter owned by this Env. */
86
  theory::Rewriter* getRewriter();
87
88
  /** Get a reference to the top-level substitution map */
89
  theory::TrustSubstitutionMap& getTopLevelSubstitutions();
90
91
  /** Get a pointer to the underlying dump manager. */
92
  smt::DumpManager* getDumpManager();
93
94
  template <typename Opt>
95
115068
  const auto& getOption(Opt opt) const
96
  {
97
115068
    return d_options[opt];
98
  }
99
100
  /** Get the options object (const version only) owned by this Env. */
101
  const Options& getOptions() const;
102
103
  /** Get the resource manager owned by this Env. */
104
  ResourceManager* getResourceManager() const;
105
106
  /** Get the logic information currently set. */
107
  const LogicInfo& getLogicInfo() const;
108
109
  /** Get a pointer to the StatisticsRegistry. */
110
  StatisticsRegistry& getStatisticsRegistry();
111
112
  /* Option helpers---------------------------------------------------------- */
113
114
  /**
115
   * Get the current printer based on the current options
116
   * @return the current printer
117
   */
118
  const Printer& getPrinter();
119
120
  /**
121
   * Get the output stream that --dump=X should print to
122
   * @return the output stream
123
   */
124
  std::ostream& getDumpOut();
125
126
 private:
127
  /* Private initialization ------------------------------------------------- */
128
129
  /** Set proof node manager if it exists */
130
  void setProofNodeManager(ProofNodeManager* pnm);
131
132
  /* Private shutdown ------------------------------------------------------- */
133
  /**
134
   * Shutdown method, which destroys the non-essential members of this class
135
   * in preparation for destroying SMT engine.
136
   */
137
  void shutdown();
138
  /* Members ---------------------------------------------------------------- */
139
140
  /** The SAT context owned by this Env */
141
  std::unique_ptr<context::Context> d_context;
142
  /** User level context owned by this Env */
143
  std::unique_ptr<context::UserContext> d_userContext;
144
  /**
145
   * A pointer to the node manager of this environment. A node manager is
146
   * not necessarily unique to an SmtEngine instance.
147
   */
148
  NodeManager* d_nodeManager;
149
  /**
150
   * A pointer to the proof node manager, which is non-null if proofs are
151
   * enabled. This is owned by the proof manager of the SmtEngine that owns
152
   * this environment.
153
   */
154
  ProofNodeManager* d_proofNodeManager;
155
  /**
156
   * The rewriter owned by this Env. We have a different instance
157
   * of the rewriter for each Env instance. This is because rewriters may
158
   * hold references to objects that belong to theory solvers, which are
159
   * specific to an SmtEngine/TheoryEngine instance.
160
   */
161
  std::unique_ptr<theory::Rewriter> d_rewriter;
162
  /** The top level substitutions */
163
  std::unique_ptr<theory::TrustSubstitutionMap> d_topLevelSubs;
164
  /** The dump manager */
165
  std::unique_ptr<smt::DumpManager> d_dumpManager;
166
  /**
167
   * The logic we're in. This logic may be an extension of the logic set by the
168
   * user, which may be different from the user-provided logic due to the
169
   * options we have set.
170
   *
171
   * This is the authorative copy of the logic that internal subsolvers should
172
   * consider during solving and initialization.
173
   */
174
  LogicInfo d_logic;
175
  /**
176
   * The statistics registry owned by this Env.
177
   */
178
  std::unique_ptr<StatisticsRegistry> d_statisticsRegistry;
179
  /**
180
   * The options object, which contains the modified version of the options
181
   * provided as input to the SmtEngine that owns this environment. Note
182
   * that d_options may be modified by the options manager, e.g. based
183
   * on the input logic.
184
   *
185
   * This is the authorative copy of the options that internal subsolvers should
186
   * consider during solving and initialization.
187
   */
188
  Options d_options;
189
  /** Manager for limiting time and abstract resource usage. */
190
  std::unique_ptr<ResourceManager> d_resourceManager;
191
}; /* class Env */
192
193
}  // namespace cvc5
194
195
#endif /* CVC5__SMT__ENV_H */