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 management of equality engines. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__THEORY__EE_MANAGER__H 16 : : #define CVC5__THEORY__EE_MANAGER__H 17 : : 18 : : #include <map> 19 : : #include <memory> 20 : : 21 : : #include "smt/env_obj.h" 22 : : #include "theory/ee_setup_info.h" 23 : : #include "theory/theory.h" 24 : : #include "theory/uf/equality_engine.h" 25 : : 26 : : namespace cvc5::internal { 27 : : 28 : : class TheoryEngine; 29 : : 30 : : namespace theory { 31 : : 32 : : class SharedSolver; 33 : : 34 : : /** 35 : : * This is (theory-agnostic) information associated with the management of 36 : : * an equality engine for a single theory. This information is maintained 37 : : * by the manager class below. 38 : : * 39 : : * Currently, this simply is the equality engine itself, for memory 40 : : * management purposes. 41 : : */ 42 : : struct EeTheoryInfo 43 : : { 44 : 712810 : EeTheoryInfo() : d_usedEe(nullptr) {} 45 : : /** Equality engine that is used (if it exists) */ 46 : : eq::EqualityEngine* d_usedEe; 47 : : /** Equality engine allocated specifically for this theory (if it exists) */ 48 : : std::unique_ptr<eq::EqualityEngine> d_allocEe; 49 : : }; 50 : : 51 : : /** Virtual base class for equality engine managers */ 52 : : class EqEngineManager : protected EnvObj 53 : : { 54 : : public: 55 : : /** 56 : : * @param te Reference to the theory engine 57 : : * @param sharedSolver The shared solver that is being used in combination 58 : : * with this equality engine manager 59 : : */ 60 : : EqEngineManager(Env& env, TheoryEngine& te, SharedSolver& shs); 61 : 50570 : virtual ~EqEngineManager() {} 62 : : /** 63 : : * Initialize theories, called during TheoryEngine::finishInit after theory 64 : : * objects have been created but prior to their final initialization. This 65 : : * sets up equality engines for all theories. 66 : : * 67 : : * This method is context-independent, and is applied once during 68 : : * the lifetime of TheoryEngine (during finishInit). 69 : : */ 70 : : virtual void initializeTheories() = 0; 71 : : /** 72 : : * Get the equality engine theory information for theory with the given id. 73 : : */ 74 : : const EeTheoryInfo* getEeTheoryInfo(TheoryId tid) const; 75 : : 76 : : /** Allocate equality engine that is context-dependent on c with info esi */ 77 : : eq::EqualityEngine* allocateEqualityEngine(EeSetupInfo& esi, 78 : : context::Context* c); 79 : : /** 80 : : * Notify this class that we are about to terminate with a model. This method 81 : : * is for debugging only. 82 : : * 83 : : * @param incomplete Whether we are answering "unknown" instead of "sat". 84 : : */ 85 : 18 : virtual void notifyModel(CVC5_UNUSED bool incomplete) {} 86 : : 87 : : protected: 88 : : /** Reference to the theory engine */ 89 : : TheoryEngine& d_te; 90 : : /** Reference to the shared solver */ 91 : : SharedSolver& d_sharedSolver; 92 : : /** Information related to the equality engine, per theory. */ 93 : : std::map<TheoryId, EeTheoryInfo> d_einfo; 94 : : }; 95 : : 96 : : } // namespace theory 97 : : } // namespace cvc5::internal 98 : : 99 : : #endif /* CVC5__THEORY__EE_MANAGER__H */