Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Morgan Deters, Aina Niemetz 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 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 : : * Inst match class. 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__THEORY__QUANTIFIERS__INST_MATCH_H 19 : : #define CVC5__THEORY__QUANTIFIERS__INST_MATCH_H 20 : : 21 : : #include <vector> 22 : : 23 : : #include "expr/node.h" 24 : : #include "smt/env_obj.h" 25 : : #include "theory/quantifiers/ieval/inst_evaluator.h" 26 : : 27 : : namespace cvc5::internal { 28 : : namespace theory { 29 : : namespace quantifiers { 30 : : 31 : : class QuantifiersState; 32 : : class TermRegistry; 33 : : 34 : : /** Inst match 35 : : * 36 : : * This is the basic class specifying an instantiation. Its domain size (the 37 : : * size of d_vals) is the number of bound variables of the quantified formula 38 : : * that is passed to its constructor. 39 : : * 40 : : * The values of d_vals may be null, which indicate that the field has 41 : : * yet to be initialized. 42 : : */ 43 : : class InstMatch : protected EnvObj 44 : : { 45 : : public: 46 : : InstMatch(Env& env, QuantifiersState& qs, TermRegistry& tr, TNode q); 47 : : /** 48 : : * Set evaluator mode. This can be modified if there are no variable 49 : : * assignments. 50 : : */ 51 : : void setEvaluatorMode(ieval::TermEvaluatorMode tev); 52 : : /** is this complete, i.e. are all fields non-null? */ 53 : : bool isComplete() const; 54 : : /** is this empty, i.e. are all fields the null node? */ 55 : : bool empty() const; 56 : : /** 57 : : * Clear the instantiation, i.e. set all fields to the null node. 58 : : * Note that this does not clear information regarding the instantiation 59 : : * evaluator, e.g. its evaluation mode and watched information. 60 : : */ 61 : : void resetAll(); 62 : : /** debug print method */ 63 : : void debugPrint(const char* c); 64 : : /** to stream */ 65 : : void toStream(std::ostream& out) const; 66 : : /** get the i^th term in the instantiation */ 67 : : Node get(size_t i) const; 68 : : /** set the i^th term in the instantiation to n 69 : : * 70 : : * If the d_vals[i] is not null, then this return true iff it is equal to 71 : : * n based on the quantifiers state. 72 : : * 73 : : * If the d_vals[i] is null, then this sets d_vals[i] to n, and pushes a 74 : : * context scope in the inst evaluator (if used). 75 : : */ 76 : : bool set(size_t i, TNode n); 77 : : /** 78 : : * Resets index i, which sets d_vals[i] to null, and pops a context scope in 79 : : * the inst evaluator (if used). 80 : : */ 81 : : void reset(size_t i); 82 : : /** Get the values */ 83 : : const std::vector<Node>& get() const; 84 : : 85 : : private: 86 : : /** Reference to the state */ 87 : : QuantifiersState& d_qs; 88 : : /** Reference to the term registry */ 89 : : TermRegistry& d_tr; 90 : : /** 91 : : * Ground terms for each variable of the quantified formula, in order. 92 : : * Null nodes indicate the variable has not been set. 93 : : */ 94 : : std::vector<Node> d_vals; 95 : : /** The quantified formula */ 96 : : Node d_quant; 97 : : /** The instantiation evaluator */ 98 : : ieval::InstEvaluator* d_ieval; 99 : : }; 100 : : 101 : 0 : inline std::ostream& operator<<(std::ostream& out, const InstMatch& m) { 102 : 0 : m.toStream(out); 103 : 0 : return out; 104 : : } 105 : : 106 : : } // namespace quantifiers 107 : : } // namespace theory 108 : : } // namespace cvc5::internal 109 : : 110 : : #endif /* CVC5__THEORY__QUANTIFIERS__INST_MATCH_H */