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/shared_solver.h"
19 #include "theory/theory_engine.h"
24 EqEngineManagerDistributed::EqEngineManagerDistributed(TheoryEngine
& te
,
26 : EqEngineManager(te
, shs
), d_masterEENotify(nullptr)
30 EqEngineManagerDistributed::~EqEngineManagerDistributed()
34 void EqEngineManagerDistributed::initializeTheories()
36 context::Context
* c
= d_te
.getSatContext();
37 // initialize the shared solver
39 if (d_sharedSolver
.needsEqualityEngine(esis
))
41 // allocate an equality engine for the shared terms database
42 d_stbEqualityEngine
.reset(allocateEqualityEngine(esis
, c
));
43 d_sharedSolver
.setEqualityEngine(d_stbEqualityEngine
.get());
47 Unhandled() << "Expected shared solver to use equality engine";
50 const LogicInfo
& logicInfo
= d_te
.getLogicInfo();
51 if (logicInfo
.isQuantified())
53 // construct the master equality engine
54 Assert(d_masterEqualityEngine
== nullptr);
55 QuantifiersEngine
* qe
= d_te
.getQuantifiersEngine();
56 Assert(qe
!= nullptr);
57 d_masterEENotify
.reset(new MasterNotifyClass(qe
));
58 d_masterEqualityEngine
.reset(new eq::EqualityEngine(*d_masterEENotify
.get(),
63 // allocate equality engines per theory
64 for (TheoryId theoryId
= theory::THEORY_FIRST
;
65 theoryId
!= theory::THEORY_LAST
;
68 Theory
* t
= d_te
.theoryOf(theoryId
);
71 // theory not active, skip
74 // always allocate an object in d_einfo here
75 EeTheoryInfo
& eet
= d_einfo
[theoryId
];
77 if (!t
->needsEqualityEngine(esi
))
79 // the theory said it doesn't need an equality engine, skip
84 // the theory said it wants to use the master equality engine
85 eet
.d_usedEe
= d_masterEqualityEngine
.get();
88 // allocate the equality engine
89 eet
.d_allocEe
.reset(allocateEqualityEngine(esi
, c
));
90 // the theory uses the equality engine
91 eet
.d_usedEe
= eet
.d_allocEe
.get();
92 // if there is a master equality engine
93 if (d_masterEqualityEngine
!= nullptr)
95 // set the master equality engine of the theory's equality engine
96 eet
.d_allocEe
->setMasterEqualityEngine(d_masterEqualityEngine
.get());
101 void EqEngineManagerDistributed::notifyModel(bool incomplete
)
103 // should have a consistent master equality engine
104 if (d_masterEqualityEngine
.get() != nullptr)
106 AlwaysAssert(d_masterEqualityEngine
->consistent());
110 void EqEngineManagerDistributed::MasterNotifyClass::eqNotifyNewClass(TNode t
)
112 // adds t to the quantifiers term database
113 d_quantEngine
->eqNotifyNewClass(t
);
116 } // namespace theory