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 |
|
* Shared solver in the distributed architecture. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/shared_solver_distributed.h" |
17 |
|
|
18 |
|
#include "theory/theory_engine.h" |
19 |
|
|
20 |
|
namespace cvc5 { |
21 |
|
namespace theory { |
22 |
|
|
23 |
15272 |
SharedSolverDistributed::SharedSolverDistributed(Env& env, TheoryEngine& te) |
24 |
15272 |
: SharedSolver(env, te) |
25 |
|
{ |
26 |
15272 |
} |
27 |
|
|
28 |
15272 |
bool SharedSolverDistributed::needsEqualityEngine(theory::EeSetupInfo& esi) |
29 |
|
{ |
30 |
15272 |
return d_sharedTerms.needsEqualityEngine(esi); |
31 |
|
} |
32 |
|
|
33 |
15272 |
void SharedSolverDistributed::setEqualityEngine(eq::EqualityEngine* ee) |
34 |
|
{ |
35 |
15272 |
d_sharedTerms.setEqualityEngine(ee); |
36 |
15272 |
} |
37 |
|
|
38 |
1008769 |
void SharedSolverDistributed::preRegisterSharedInternal(TNode t) |
39 |
|
{ |
40 |
1008769 |
if (t.getKind() == kind::EQUAL) |
41 |
|
{ |
42 |
|
// When sharing is enabled, we propagate from the shared terms manager also |
43 |
524506 |
d_sharedTerms.addEqualityToPropagate(t); |
44 |
|
} |
45 |
1008769 |
} |
46 |
|
|
47 |
1200849 |
EqualityStatus SharedSolverDistributed::getEqualityStatus(TNode a, TNode b) |
48 |
|
{ |
49 |
|
// if we're using a shared terms database, ask its status if a and b are |
50 |
|
// shared. |
51 |
1200849 |
if (d_sharedTerms.isShared(a) && d_sharedTerms.isShared(b)) |
52 |
|
{ |
53 |
1129214 |
if (d_sharedTerms.areEqual(a, b)) |
54 |
|
{ |
55 |
174526 |
return EQUALITY_TRUE_AND_PROPAGATED; |
56 |
|
} |
57 |
954688 |
else if (d_sharedTerms.areDisequal(a, b)) |
58 |
|
{ |
59 |
6127 |
return EQUALITY_FALSE_AND_PROPAGATED; |
60 |
|
} |
61 |
|
} |
62 |
|
// otherwise, ask the theory |
63 |
1020196 |
return d_te.theoryOf(Theory::theoryOf(a.getType()))->getEqualityStatus(a, b); |
64 |
|
} |
65 |
|
|
66 |
370162 |
TrustNode SharedSolverDistributed::explain(TNode literal, TheoryId id) |
67 |
|
{ |
68 |
370162 |
TrustNode texp; |
69 |
370162 |
if (id == THEORY_BUILTIN) |
70 |
|
{ |
71 |
|
// explanation using the shared terms database |
72 |
138151 |
texp = d_sharedTerms.explain(literal); |
73 |
276302 |
Trace("shared-solver") |
74 |
138151 |
<< "\tTerm was propagated by THEORY_BUILTIN. Explanation: " |
75 |
138151 |
<< texp.getNode() << std::endl; |
76 |
|
} |
77 |
|
else |
78 |
|
{ |
79 |
|
// By default, we ask the individual theory for the explanation. |
80 |
|
// It is possible that a centralized approach could preempt this. |
81 |
232011 |
texp = d_te.theoryOf(id)->explain(literal); |
82 |
464022 |
Trace("shared-solver") << "\tTerm was propagated by owner theory: " << id |
83 |
232011 |
<< ". Explanation: " << texp.getNode() << std::endl; |
84 |
|
} |
85 |
370162 |
return texp; |
86 |
|
} |
87 |
|
|
88 |
7628244 |
void SharedSolverDistributed::assertShared(TNode n, bool polarity, TNode reason) |
89 |
|
{ |
90 |
7628244 |
d_sharedTerms.assertShared(n, polarity, reason); |
91 |
7628244 |
} |
92 |
|
|
93 |
|
} // namespace theory |
94 |
31137 |
} // namespace cvc5 |