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 |
8954 |
SharedSolverDistributed::SharedSolverDistributed(TheoryEngine& te, |
24 |
8954 |
ProofNodeManager* pnm) |
25 |
8954 |
: SharedSolver(te, pnm) |
26 |
|
{ |
27 |
8954 |
} |
28 |
|
|
29 |
8954 |
bool SharedSolverDistributed::needsEqualityEngine(theory::EeSetupInfo& esi) |
30 |
|
{ |
31 |
8954 |
return d_sharedTerms.needsEqualityEngine(esi); |
32 |
|
} |
33 |
|
|
34 |
8954 |
void SharedSolverDistributed::setEqualityEngine(eq::EqualityEngine* ee) |
35 |
|
{ |
36 |
8954 |
d_sharedTerms.setEqualityEngine(ee); |
37 |
8954 |
} |
38 |
|
|
39 |
724745 |
void SharedSolverDistributed::preRegisterSharedInternal(TNode t) |
40 |
|
{ |
41 |
724745 |
if (t.getKind() == kind::EQUAL) |
42 |
|
{ |
43 |
|
// When sharing is enabled, we propagate from the shared terms manager also |
44 |
391944 |
d_sharedTerms.addEqualityToPropagate(t); |
45 |
|
} |
46 |
724745 |
} |
47 |
|
|
48 |
1151328 |
EqualityStatus SharedSolverDistributed::getEqualityStatus(TNode a, TNode b) |
49 |
|
{ |
50 |
|
// if we're using a shared terms database, ask its status if a and b are |
51 |
|
// shared. |
52 |
1151328 |
if (d_sharedTerms.isShared(a) && d_sharedTerms.isShared(b)) |
53 |
|
{ |
54 |
1100228 |
if (d_sharedTerms.areEqual(a, b)) |
55 |
|
{ |
56 |
171165 |
return EQUALITY_TRUE_AND_PROPAGATED; |
57 |
|
} |
58 |
929063 |
else if (d_sharedTerms.areDisequal(a, b)) |
59 |
|
{ |
60 |
2262 |
return EQUALITY_FALSE_AND_PROPAGATED; |
61 |
|
} |
62 |
|
} |
63 |
|
// otherwise, ask the theory |
64 |
977901 |
return d_te.theoryOf(Theory::theoryOf(a.getType()))->getEqualityStatus(a, b); |
65 |
|
} |
66 |
|
|
67 |
320553 |
TrustNode SharedSolverDistributed::explain(TNode literal, TheoryId id) |
68 |
|
{ |
69 |
320553 |
TrustNode texp; |
70 |
320553 |
if (id == THEORY_BUILTIN) |
71 |
|
{ |
72 |
|
// explanation using the shared terms database |
73 |
118306 |
texp = d_sharedTerms.explain(literal); |
74 |
236612 |
Trace("shared-solver") |
75 |
118306 |
<< "\tTerm was propagated by THEORY_BUILTIN. Explanation: " |
76 |
118306 |
<< texp.getNode() << std::endl; |
77 |
|
} |
78 |
|
else |
79 |
|
{ |
80 |
|
// By default, we ask the individual theory for the explanation. |
81 |
|
// It is possible that a centralized approach could preempt this. |
82 |
202247 |
texp = d_te.theoryOf(id)->explain(literal); |
83 |
404494 |
Trace("shared-solver") << "\tTerm was propagated by owner theory: " << id |
84 |
202247 |
<< ". Explanation: " << texp.getNode() << std::endl; |
85 |
|
} |
86 |
320553 |
return texp; |
87 |
|
} |
88 |
|
|
89 |
4620441 |
void SharedSolverDistributed::assertSharedEquality(TNode equality, |
90 |
|
bool polarity, |
91 |
|
TNode reason) |
92 |
|
{ |
93 |
4620441 |
d_sharedTerms.assertEquality(equality, polarity, reason); |
94 |
4620441 |
} |
95 |
|
|
96 |
|
} // namespace theory |
97 |
27735 |
} // namespace cvc5 |