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 : : * Utilities for term enumeration. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__THEORY__QUANTIFIERS__TERM_POOLS_H 16 : : #define CVC5__THEORY__QUANTIFIERS__TERM_POOLS_H 17 : : 18 : : #include <unordered_set> 19 : : #include <vector> 20 : : 21 : : #include "expr/node.h" 22 : : #include "theory/quantifiers/quant_util.h" 23 : : 24 : : namespace cvc5::internal { 25 : : namespace theory { 26 : : namespace quantifiers { 27 : : 28 : : class QuantifiersState; 29 : : 30 : : /** 31 : : * Information concerning a pool variable. 32 : : */ 33 : : class TermPoolDomain 34 : : { 35 : : public: 36 : : /** initialize, which clears the data below */ 37 : : void initialize(); 38 : : /** add node to this pool */ 39 : : void add(Node n); 40 : : /** Get the terms in this pool */ 41 : : std::vector<Node>& getTerms(); 42 : : /** 43 : : * The list of terms on this round. This is cleared at the beginning of an 44 : : * instantiation round. The members are unique modulo equality. 45 : : */ 46 : : std::vector<Node> d_currTerms; 47 : : 48 : : private: 49 : : /** The list in this pool */ 50 : : std::vector<Node> d_terms; 51 : : }; 52 : : 53 : : /** 54 : : * Contains all annotations that pertain to pools for a given quantified 55 : : * formula. 56 : : */ 57 : : class TermPoolQuantInfo 58 : : { 59 : : public: 60 : : /** initialize, which clears the data below */ 61 : : void initialize(); 62 : : /** Annotations of kind INST_ADD_TO_POOL */ 63 : : std::vector<Node> d_instAddToPool; 64 : : /** Annotations of kind SKOLEM_ADD_TO_POOL */ 65 : : std::vector<Node> d_skolemAddToPool; 66 : : }; 67 : : 68 : : /** 69 : : * Term pools, which tracks the values of "pools", which are used for 70 : : * pool-based instantiation. 71 : : */ 72 : : class TermPools : public QuantifiersUtil 73 : : { 74 : : public: 75 : : TermPools(Env& env, QuantifiersState& qs); 76 : 99216 : ~TermPools() {} 77 : : /** reset, which resets the current values of pools */ 78 : : bool reset(Theory::Effort e) override; 79 : : /** Called for new quantifiers, which computes TermPoolQuantInfo above */ 80 : : void registerQuantifier(Node q) override; 81 : : /** Identify this module (for debugging, dynamic configuration, etc..) */ 82 : : std::string identify() const override; 83 : : /** Register pool p with initial value initValue. */ 84 : : void registerPool(Node p, const std::vector<Node>& initValue); 85 : : /** Get terms for pool p, adds them to the vector terms. */ 86 : : void getTermsForPool(Node p, std::vector<Node>& terms); 87 : : /** 88 : : * Process instantiation, called at the moment we successfully instantiate 89 : : * q with terms. This adds terms to pools based on INST_ADD_TO_POOL 90 : : * annotations. 91 : : */ 92 : : void processInstantiation(Node q, const std::vector<Node>& terms); 93 : : /** Same as above, for SKOLEM_ADD_TO_POOL. */ 94 : : void processSkolemization(Node q, const std::vector<Node>& skolems); 95 : : private: 96 : : void processInternal(Node q, const std::vector<Node>& ts, bool isInst); 97 : : /** reference to the quantifiers state */ 98 : : QuantifiersState& d_qs; 99 : : /** Maps pools to a domain */ 100 : : std::map<Node, TermPoolDomain> d_pools; 101 : : /** Maps quantifiers to info */ 102 : : std::map<Node, TermPoolQuantInfo> d_qinfo; 103 : : }; 104 : : 105 : : } // namespace quantifiers 106 : : } // namespace theory 107 : : } // namespace cvc5::internal 108 : : 109 : : #endif /* CVC5__THEORY__QUANTIFIERS__TERM_POOLS_H */