1 /********************* */
2 /*! \file ee_manager_distributed.cpp
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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.\endverbatim
12 ** \brief Management of a distributed approach for equality sharing.
15 #include "theory/ee_manager_distributed.h"
17 #include "theory/quantifiers_engine.h"
18 #include "theory/theory_engine.h"
23 const EeTheoryInfo
* EqEngineManager::getEeTheoryInfo(TheoryId tid
) const
25 std::map
<TheoryId
, EeTheoryInfo
>::const_iterator it
= d_einfo
.find(tid
);
26 if (it
!= d_einfo
.end())
33 EqEngineManagerDistributed::EqEngineManagerDistributed(TheoryEngine
& te
)
34 : d_te(te
), d_masterEENotify(nullptr)
38 EqEngineManagerDistributed::~EqEngineManagerDistributed() {}
40 void EqEngineManagerDistributed::finishInit()
42 context::Context
* c
= d_te
.getSatContext();
43 // allocate equality engines per theory
44 for (TheoryId theoryId
= theory::THEORY_FIRST
;
45 theoryId
!= theory::THEORY_LAST
;
48 Theory
* t
= d_te
.theoryOf(theoryId
);
51 // theory not active, skip
54 // always allocate an object in d_einfo here
55 EeTheoryInfo
& eet
= d_einfo
[theoryId
];
57 if (!t
->needsEqualityEngine(esi
))
59 // theory said it doesn't need an equality engine, skip
62 // allocate the equality engine
63 eet
.d_allocEe
.reset(allocateEqualityEngine(esi
, c
));
64 eet
.d_usedEe
= eet
.d_allocEe
.get();
67 const LogicInfo
& logicInfo
= d_te
.getLogicInfo();
68 if (logicInfo
.isQuantified())
70 // construct the master equality engine
71 Assert(d_masterEqualityEngine
== nullptr);
72 QuantifiersEngine
* qe
= d_te
.getQuantifiersEngine();
73 Assert(qe
!= nullptr);
74 d_masterEENotify
.reset(new MasterNotifyClass(qe
));
75 d_masterEqualityEngine
.reset(new eq::EqualityEngine(*d_masterEENotify
.get(),
80 for (TheoryId theoryId
= theory::THEORY_FIRST
;
81 theoryId
!= theory::THEORY_LAST
;
84 Theory
* t
= d_te
.theoryOf(theoryId
);
87 // theory not active, skip
90 EeTheoryInfo
& eet
= d_einfo
[theoryId
];
91 // Get the allocated equality engine, and connect it to the master
93 eq::EqualityEngine
* eeAlloc
= eet
.d_allocEe
.get();
94 if (eeAlloc
!= nullptr)
96 // set the master equality engine of the theory's equality engine
97 eeAlloc
->setMasterEqualityEngine(d_masterEqualityEngine
.get());
103 void EqEngineManagerDistributed::MasterNotifyClass::eqNotifyNewClass(TNode t
)
105 // adds t to the quantifiers term database
106 d_quantEngine
->eqNotifyNewClass(t
);
109 eq::EqualityEngine
* EqEngineManagerDistributed::getMasterEqualityEngine()
111 return d_masterEqualityEngine
.get();
114 eq::EqualityEngine
* EqEngineManagerDistributed::allocateEqualityEngine(
115 EeSetupInfo
& esi
, context::Context
* c
)
117 if (esi
.d_notify
!= nullptr)
119 return new eq::EqualityEngine(
120 *esi
.d_notify
, c
, esi
.d_name
, esi
.d_constantsAreTriggers
);
122 // the theory doesn't care about explicit notifications
123 return new eq::EqualityEngine(c
, esi
.d_name
, esi
.d_constantsAreTriggers
);
126 } // namespace theory