1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 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 |
|
* Equality engine manager for central equality engine architecture |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__EE_MANAGER_CENTRAL__H |
19 |
|
#define CVC5__THEORY__EE_MANAGER_CENTRAL__H |
20 |
|
|
21 |
|
#include <map> |
22 |
|
#include <memory> |
23 |
|
|
24 |
|
#include "theory/ee_manager.h" |
25 |
|
#include "theory/quantifiers/master_eq_notify.h" |
26 |
|
#include "theory/uf/equality_engine.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
|
31 |
|
/** |
32 |
|
* The (central) equality engine manager. This encapsulates an architecture |
33 |
|
* in which all applicable theories use a single central equality engine. |
34 |
|
* |
35 |
|
* This class is not responsible for actually initializing equality engines in |
36 |
|
* theories (since this class does not have access to the internals of Theory). |
37 |
|
* Instead, it is only responsible for the construction of the equality |
38 |
|
* engine objects themselves. TheoryEngine is responsible for querying this |
39 |
|
* class during finishInit() to determine the equality engines to pass to each |
40 |
|
* theories based on getEeTheoryInfo. |
41 |
|
* |
42 |
|
* It also may allocate a "master" equality engine, which is intuitively the |
43 |
|
* equality engine of the theory of quantifiers. If all theories use the |
44 |
|
* central equality engine, then the master equality engine is the same as the |
45 |
|
* central equality engine. |
46 |
|
* |
47 |
|
* The theories that use central equality engine are determined by |
48 |
|
* Theory::usesCentralEqualityEngine. |
49 |
|
* |
50 |
|
* The main idea behind this class is to use a notification class on the |
51 |
|
* central equality engine which dispatches *multiple* notifications to the |
52 |
|
* theories that use the central equality engine. |
53 |
|
*/ |
54 |
|
class EqEngineManagerCentral : public EqEngineManager |
55 |
|
{ |
56 |
|
public: |
57 |
|
EqEngineManagerCentral(TheoryEngine& te, |
58 |
|
SharedSolver& shs, |
59 |
|
ProofNodeManager* pnm); |
60 |
|
~EqEngineManagerCentral(); |
61 |
|
/** |
62 |
|
* Initialize theories. This method allocates unique equality engines |
63 |
|
* per theories and connects them to a master equality engine. |
64 |
|
*/ |
65 |
|
void initializeTheories() override; |
66 |
|
/** Notify this class that we are building the model. */ |
67 |
|
void notifyBuildingModel(); |
68 |
|
|
69 |
|
private: |
70 |
|
/** |
71 |
|
* Notify class for central equality engine. This class dispatches |
72 |
|
* notifications from the central equality engine to the appropriate |
73 |
|
* theory(s). |
74 |
|
*/ |
75 |
35 |
class CentralNotifyClass : public theory::eq::EqualityEngineNotify |
76 |
|
{ |
77 |
|
public: |
78 |
|
CentralNotifyClass(EqEngineManagerCentral& eemc); |
79 |
|
bool eqNotifyTriggerPredicate(TNode predicate, bool value) override; |
80 |
|
bool eqNotifyTriggerTermEquality(TheoryId tag, |
81 |
|
TNode t1, |
82 |
|
TNode t2, |
83 |
|
bool value) override; |
84 |
|
void eqNotifyConstantTermMerge(TNode t1, TNode t2) override; |
85 |
|
void eqNotifyNewClass(TNode t) override; |
86 |
|
void eqNotifyMerge(TNode t1, TNode t2) override; |
87 |
|
void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override; |
88 |
|
/** Parent */ |
89 |
|
EqEngineManagerCentral& d_eemc; |
90 |
|
/** List of notify classes that need new class notification */ |
91 |
|
std::vector<eq::EqualityEngineNotify*> d_newClassNotify; |
92 |
|
/** List of notify classes that need merge notification */ |
93 |
|
std::vector<eq::EqualityEngineNotify*> d_mergeNotify; |
94 |
|
/** List of notify classes that need disequality notification */ |
95 |
|
std::vector<eq::EqualityEngineNotify*> d_disequalNotify; |
96 |
|
/** The model notify class */ |
97 |
|
eq::EqualityEngineNotify* d_mNotify; |
98 |
|
/** The quantifiers engine */ |
99 |
|
QuantifiersEngine* d_quantEngine; |
100 |
|
}; |
101 |
|
/** Notification when predicate gets value in central equality engine */ |
102 |
|
bool eqNotifyTriggerPredicate(TNode predicate, bool value); |
103 |
|
bool eqNotifyTriggerTermEquality(TheoryId tag, |
104 |
|
TNode t1, |
105 |
|
TNode t2, |
106 |
|
bool value); |
107 |
|
/** Notification when constants are merged in central equality engine */ |
108 |
|
void eqNotifyConstantTermMerge(TNode t1, TNode t2); |
109 |
|
/** The master equality engine notify class */ |
110 |
|
std::unique_ptr<quantifiers::MasterNotifyClass> d_masterEENotify; |
111 |
|
/** The master equality engine. */ |
112 |
|
eq::EqualityEngine* d_masterEqualityEngine; |
113 |
|
/** The master equality engine, if we allocated it */ |
114 |
|
std::unique_ptr<eq::EqualityEngine> d_masterEqualityEngineAlloc; |
115 |
|
/** The central equality engine notify class */ |
116 |
|
CentralNotifyClass d_centralEENotify; |
117 |
|
/** The central equality engine. */ |
118 |
|
eq::EqualityEngine d_centralEqualityEngine; |
119 |
|
/** The proof equality engine for the central equality engine */ |
120 |
|
std::unique_ptr<eq::ProofEqEngine> d_centralPfee; |
121 |
|
/** |
122 |
|
* A table of from theory IDs to notify classes. |
123 |
|
*/ |
124 |
|
eq::EqualityEngineNotify* d_theoryNotify[theory::THEORY_LAST]; |
125 |
|
}; |
126 |
|
|
127 |
|
} // namespace theory |
128 |
|
} // namespace cvc5 |
129 |
|
|
130 |
|
#endif /* CVC5__THEORY__EE_MANAGER_CENTRAL__H */ |