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