GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/shared_solver_distributed.cpp Lines: 35 35 100.0 %
Date: 2021-03-22 Branches: 56 102 54.9 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file shared_solver_distributed.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Andrew Reynolds
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief Shared solver in the distributed architecture
13
 **/
14
15
#include "theory/shared_solver_distributed.h"
16
17
#include "theory/theory_engine.h"
18
19
namespace CVC4 {
20
namespace theory {
21
22
8995
SharedSolverDistributed::SharedSolverDistributed(TheoryEngine& te,
23
8995
                                                 ProofNodeManager* pnm)
24
8995
    : SharedSolver(te, pnm)
25
{
26
8995
}
27
28
8995
bool SharedSolverDistributed::needsEqualityEngine(theory::EeSetupInfo& esi)
29
{
30
8995
  return d_sharedTerms.needsEqualityEngine(esi);
31
}
32
33
8995
void SharedSolverDistributed::setEqualityEngine(eq::EqualityEngine* ee)
34
{
35
8995
  d_sharedTerms.setEqualityEngine(ee);
36
8995
}
37
38
714399
void SharedSolverDistributed::preRegisterSharedInternal(TNode t)
39
{
40
714399
  if (t.getKind() == kind::EQUAL)
41
  {
42
    // When sharing is enabled, we propagate from the shared terms manager also
43
380784
    d_sharedTerms.addEqualityToPropagate(t);
44
  }
45
714399
}
46
47
1558001
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
1558001
  if (d_sharedTerms.isShared(a) && d_sharedTerms.isShared(b))
52
  {
53
1493487
    if (d_sharedTerms.areEqual(a, b))
54
    {
55
176090
      return EQUALITY_TRUE_AND_PROPAGATED;
56
    }
57
1317397
    else if (d_sharedTerms.areDisequal(a, b))
58
    {
59
2239
      return EQUALITY_FALSE_AND_PROPAGATED;
60
    }
61
  }
62
  // otherwise, ask the theory
63
1379672
  return d_te.theoryOf(Theory::theoryOf(a.getType()))->getEqualityStatus(a, b);
64
}
65
66
406409
TrustNode SharedSolverDistributed::explain(TNode literal, TheoryId id)
67
{
68
406409
  TrustNode texp;
69
406409
  if (id == THEORY_BUILTIN)
70
  {
71
    // explanation using the shared terms database
72
151611
    texp = d_sharedTerms.explain(literal);
73
303222
    Trace("shared-solver")
74
151611
        << "\tTerm was propagated by THEORY_BUILTIN. Explanation: "
75
151611
        << 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
254798
    texp = d_te.theoryOf(id)->explain(literal);
82
509596
    Trace("shared-solver") << "\tTerm was propagated by owner theory: " << id
83
254798
                           << ". Explanation: " << texp.getNode() << std::endl;
84
  }
85
406409
  return texp;
86
}
87
88
6289368
void SharedSolverDistributed::assertSharedEquality(TNode equality,
89
                                                   bool polarity,
90
                                                   TNode reason)
91
{
92
6289368
  d_sharedTerms.assertEquality(equality, polarity, reason);
93
6289368
}
94
95
}  // namespace theory
96
26676
}  // namespace CVC4