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 : : * Synthesis finder 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__THEORY__QUANTIFIERS__SYNTH_FINDER_H 16 : : #define CVC5__THEORY__QUANTIFIERS__SYNTH_FINDER_H 17 : : 18 : : #include <cvc5/cvc5_types.h> 19 : : 20 : : #include "smt/env_obj.h" 21 : : 22 : : namespace cvc5::internal { 23 : : 24 : : class SygusTermEnumerator; 25 : : 26 : : namespace theory { 27 : : namespace quantifiers { 28 : : 29 : : class ExprMiner; 30 : : class ExprMinerId; 31 : : class SygusEnumeratorCallback; 32 : : class CandidateRewriteDatabase; 33 : : class QueryGenerator; 34 : : class RewriteVerifier; 35 : : class SygusSampler; 36 : : 37 : : /** 38 : : * Algorithms for finding terms from sygus enumeration. This can be 39 : : * seen as a wrapper around a (fast) sygus enumerator 40 : : */ 41 : : class SynthFinder : protected EnvObj 42 : : { 43 : : public: 44 : : SynthFinder(Env& env); 45 : 174 : ~SynthFinder() {} 46 : : /** 47 : : * Initialize find synth for the given target and provided grammar. 48 : : */ 49 : : void initialize(modes::FindSynthTarget fst, const TypeNode& gtn); 50 : : /** 51 : : * Increment the enumerator of this class, returns false if the enumerator 52 : : * is finished generating values. 53 : : */ 54 : : bool increment(); 55 : : /** 56 : : * Get the current found term based on the enumeration, or null if none 57 : : * is available. 58 : : */ 59 : : Node getCurrent(); 60 : : 61 : : private: 62 : : /** Initialize find synthesis target */ 63 : : void initializeInternal(modes::FindSynthTarget fst, const TypeNode& gtn); 64 : : /** Run find synthesis target */ 65 : : Node runNext(const Node& n, modes::FindSynthTarget fst); 66 : : /** An identity expression miner */ 67 : : std::unique_ptr<ExprMinerId> d_eid; 68 : : /** The enumerator callback */ 69 : : std::unique_ptr<SygusEnumeratorCallback> d_ecb; 70 : : /** candidate rewrite database */ 71 : : std::unique_ptr<CandidateRewriteDatabase> d_crd; 72 : : /** The query generator we are using */ 73 : : std::unique_ptr<QueryGenerator> d_qg; 74 : : /** Rewrite verifier */ 75 : : std::unique_ptr<RewriteVerifier> d_rrv; 76 : : /** sygus sampler object */ 77 : : std::unique_ptr<SygusSampler> d_sampler; 78 : : /** The enumerator */ 79 : : std::unique_ptr<SygusTermEnumerator> d_enum; 80 : : /** The active expression miner */ 81 : : ExprMiner* d_current; 82 : : /** The current target we are given as input */ 83 : : modes::FindSynthTarget d_fst; 84 : : /** The current target we are using */ 85 : : modes::FindSynthTarget d_fstu; 86 : : /** The current buffer of terms returned by expression mining */ 87 : : std::vector<Node> d_buffer; 88 : : /** The index in the buffer that is next to process */ 89 : : size_t d_bufferIndex; 90 : : }; 91 : : 92 : : } // namespace quantifiers 93 : : } // namespace theory 94 : : } // namespace cvc5::internal 95 : : 96 : : #endif /* CVC5__THEORY__QUANTIFIERS__SYNTH_FINDER_H */