1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer |
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 |
|
* Management of a distributed approach for equality engines over |
14 |
|
* all theories. |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "cvc5_private.h" |
18 |
|
|
19 |
|
#ifndef CVC5__THEORY__EE_MANAGER_DISTRIBUTED__H |
20 |
|
#define CVC5__THEORY__EE_MANAGER_DISTRIBUTED__H |
21 |
|
|
22 |
|
#include <memory> |
23 |
|
|
24 |
|
#include "theory/ee_manager.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
namespace theory { |
28 |
|
|
29 |
|
namespace eq { |
30 |
|
class EqualityEngine; |
31 |
|
} |
32 |
|
|
33 |
|
/** |
34 |
|
* The (distributed) equality engine manager. This encapsulates an architecture |
35 |
|
* in which all theories maintain their own copy of an equality engine. |
36 |
|
* |
37 |
|
* This class is not responsible for actually initializing equality engines in |
38 |
|
* theories (since this class does not have access to the internals of Theory). |
39 |
|
* Instead, it is only responsible for the construction of the equality |
40 |
|
* engine objects themselves. TheoryEngine is responsible for querying this |
41 |
|
* class during finishInit() to determine the equality engines to pass to each |
42 |
|
* theories based on getEeTheoryInfo. |
43 |
|
* |
44 |
|
* This class is also responsible for setting up the master equality engine, |
45 |
|
* which is used as a special communication channel to quantifiers engine (e.g. |
46 |
|
* for ensuring quantifiers E-matching is aware of terms from all theories). |
47 |
|
*/ |
48 |
|
class EqEngineManagerDistributed : public EqEngineManager |
49 |
|
{ |
50 |
|
public: |
51 |
|
EqEngineManagerDistributed(TheoryEngine& te, SharedSolver& shs); |
52 |
|
~EqEngineManagerDistributed(); |
53 |
|
/** |
54 |
|
* Initialize theories. This method allocates unique equality engines |
55 |
|
* per theories and connects them to a master equality engine. |
56 |
|
*/ |
57 |
|
void initializeTheories() override; |
58 |
|
/** Notify model */ |
59 |
|
void notifyModel(bool incomplete) override; |
60 |
|
|
61 |
|
private: |
62 |
|
/** notify class for master equality engine */ |
63 |
12572 |
class MasterNotifyClass : public theory::eq::EqualityEngineNotify |
64 |
|
{ |
65 |
|
public: |
66 |
6286 |
MasterNotifyClass(QuantifiersEngine* qe) : d_quantEngine(qe) {} |
67 |
|
/** |
68 |
|
* Called when a new equivalence class is created in the master equality |
69 |
|
* engine. |
70 |
|
*/ |
71 |
|
void eqNotifyNewClass(TNode t) override; |
72 |
|
|
73 |
|
bool eqNotifyTriggerPredicate(TNode predicate, bool value) override |
74 |
|
{ |
75 |
|
return true; |
76 |
|
} |
77 |
|
bool eqNotifyTriggerTermEquality(TheoryId tag, |
78 |
|
TNode t1, |
79 |
|
TNode t2, |
80 |
|
bool value) override |
81 |
|
{ |
82 |
|
return true; |
83 |
|
} |
84 |
7810 |
void eqNotifyConstantTermMerge(TNode t1, TNode t2) override {} |
85 |
4106648 |
void eqNotifyMerge(TNode t1, TNode t2) override {} |
86 |
|
void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override {} |
87 |
|
|
88 |
|
private: |
89 |
|
/** Pointer to quantifiers engine */ |
90 |
|
QuantifiersEngine* d_quantEngine; |
91 |
|
}; |
92 |
|
/** The master equality engine notify class */ |
93 |
|
std::unique_ptr<MasterNotifyClass> d_masterEENotify; |
94 |
|
/** The master equality engine. */ |
95 |
|
std::unique_ptr<eq::EqualityEngine> d_masterEqualityEngine; |
96 |
|
/** The equality engine of the shared solver / shared terms database. */ |
97 |
|
std::unique_ptr<eq::EqualityEngine> d_stbEqualityEngine; |
98 |
|
}; |
99 |
|
|
100 |
|
} // namespace theory |
101 |
|
} // namespace cvc5 |
102 |
|
|
103 |
|
#endif /* CVC5__THEORY__EE_MANAGER_DISTRIBUTED__H */ |