Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * The base class for everything that nees access to the environment (Env) 11 : : * instance, which gives access to global utilities available to internal code. 12 : : */ 13 : : 14 : : #include "cvc5_private.h" 15 : : 16 : : #ifndef CVC5__SMT__ENV_OBJ_H 17 : : #define CVC5__SMT__ENV_OBJ_H 18 : : 19 : : #include <memory> 20 : : 21 : : #include "expr/node.h" 22 : : 23 : : namespace cvc5::context { 24 : : class Context; 25 : : class UserContext; 26 : : } // namespace cvc5::context 27 : : 28 : : namespace cvc5::internal { 29 : : 30 : : class Env; 31 : : class LogicInfo; 32 : : class NodeManager; 33 : : class Options; 34 : : class StatisticsRegistry; 35 : : 36 : : namespace options { 37 : : enum class OutputTag; 38 : : } 39 : : using OutputTag = options::OutputTag; 40 : : 41 : : class EnvObj 42 : : { 43 : : protected: 44 : : /** Constructor. */ 45 : : EnvObj(Env& env); 46 : : EnvObj() = delete; 47 : : /** Destructor. */ 48 : 17043656 : virtual ~EnvObj() {} 49 : : 50 : : /** Get a pointer to the node manager */ 51 : : NodeManager* nodeManager() const; 52 : : 53 : : /** 54 : : * Rewrite a node. 55 : : * This is a wrapper around theory::Rewriter::rewrite via Env. 56 : : */ 57 : : Node rewrite(TNode node) const; 58 : : /** 59 : : * Rewrite a node. 60 : : * This is a wrapper around theory::Rewriter::rewriteEqualityExt via Env. 61 : : */ 62 : : Node rewriteEqualityExt(TNode node) const; 63 : : /** 64 : : * Extended rewrite a node. 65 : : * This is a wrapper around theory::Rewriter::extendedRewrite via Env. 66 : : */ 67 : : Node extendedRewrite(TNode node, bool aggr = true) const; 68 : : /** 69 : : * Evaluate node n under the substitution args -> vals. 70 : : * This is a wrapper about theory::Rewriter::evaluate via Env. 71 : : */ 72 : : Node evaluate(TNode n, 73 : : const std::vector<Node>& args, 74 : : const std::vector<Node>& vals, 75 : : bool useRewriter = true) const; 76 : : /** Same as above, with a visited cache. */ 77 : : Node evaluate(TNode n, 78 : : const std::vector<Node>& args, 79 : : const std::vector<Node>& vals, 80 : : const std::unordered_map<Node, Node>& visited, 81 : : bool useRewriter = true) const; 82 : : 83 : : /** Get the options object (const version only) via Env. */ 84 : : const Options& options() const; 85 : : 86 : : /** Get a pointer to the Context via Env. */ 87 : : context::Context* context() const; 88 : : 89 : : /** Get a pointer to the UserContext via Env. */ 90 : : context::UserContext* userContext() const; 91 : : 92 : : /** Get the resource manager owned by this Env. */ 93 : : ResourceManager* resourceManager() const; 94 : : 95 : : /** Get the current logic information. */ 96 : : const LogicInfo& logicInfo() const; 97 : : 98 : : /** Get the statistics registry via Env. */ 99 : : StatisticsRegistry& statisticsRegistry() const; 100 : : 101 : : /** Convenience wrapper for Env::isOutputOn(). */ 102 : : bool isOutputOn(OutputTag tag) const; 103 : : 104 : : /** Convenience wrapper for Env::output(). */ 105 : : std::ostream& output(OutputTag tag) const; 106 : : 107 : : /** Convenience wrapper for Env::isVerboseOn(). */ 108 : : bool isVerboseOn(int64_t level) const; 109 : : 110 : : /** Convenience wrapper for Env::verbose(). */ 111 : : std::ostream& verbose(int64_t) const; 112 : : 113 : : /** Convenience wrapper for Env::verbose(0). */ 114 : : std::ostream& warning() const; 115 : : 116 : : /** The associated environment. */ 117 : : Env& d_env; 118 : : }; 119 : : 120 : : } // namespace cvc5::internal 121 : : #endif