GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/combination_care_graph.cpp Lines: 34 34 100.0 %
Date: 2021-08-20 Branches: 48 90 53.3 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Dejan Jovanovic
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
 * Management of a care graph based approach for theory combination.
14
 */
15
16
#include "theory/combination_care_graph.h"
17
18
#include "expr/node_visitor.h"
19
#include "prop/prop_engine.h"
20
#include "theory/care_graph.h"
21
#include "theory/model_manager.h"
22
#include "theory/shared_solver.h"
23
#include "theory/theory_engine.h"
24
25
namespace cvc5 {
26
namespace theory {
27
28
9856
CombinationCareGraph::CombinationCareGraph(
29
    TheoryEngine& te,
30
    Env& env,
31
    const std::vector<Theory*>& paraTheories,
32
9856
    ProofNodeManager* pnm)
33
9856
    : CombinationEngine(te, env, paraTheories, pnm)
34
{
35
9856
}
36
37
19712
CombinationCareGraph::~CombinationCareGraph() {}
38
39
24007
void CombinationCareGraph::combineTheories()
40
{
41
24007
  Trace("combineTheories") << "TheoryEngine::combineTheories()" << std::endl;
42
43
  // Care graph we'll be building
44
48014
  CareGraph careGraph;
45
46
  // get the care graph from the parametric theories
47
94217
  for (Theory* t : d_paraTheories)
48
  {
49
70210
    t->getCareGraph(&careGraph);
50
  }
51
52
48014
  Trace("combineTheories")
53
24007
      << "TheoryEngine::combineTheories(): care graph size = "
54
24007
      << careGraph.size() << std::endl;
55
56
  // Now add splitters for the ones we are interested in
57
24007
  prop::PropEngine* propEngine = d_te.getPropEngine();
58
63323
  for (const CarePair& carePair : careGraph)
59
  {
60
78632
    Debug("combineTheories")
61
39316
        << "TheoryEngine::combineTheories(): checking " << carePair.d_a << " = "
62
39316
        << carePair.d_b << " from " << carePair.d_theory << std::endl;
63
64
    // The equality in question (order for no repetition)
65
78632
    Node equality = carePair.d_a.eqNode(carePair.d_b);
66
67
    // We need to split on it
68
78632
    Debug("combineTheories")
69
39316
        << "TheoryEngine::combineTheories(): requesting a split " << std::endl;
70
71
78632
    TrustNode tsplit;
72
39316
    if (isProofEnabled())
73
    {
74
      // make proof of splitting lemma
75
10024
      tsplit = d_cmbsPg->mkTrustNodeSplit(equality);
76
    }
77
    else
78
    {
79
58584
      Node split = equality.orNode(equality.notNode());
80
29292
      tsplit = TrustNode::mkTrustLemma(split, nullptr);
81
    }
82
78632
    d_sharedSolver->sendLemma(
83
39316
        tsplit, carePair.d_theory, InferenceId::COMBINATION_SPLIT);
84
85
    // Could check the equality status here:
86
    //   EqualityStatus es = getEqualityStatus(carePair.d_a, carePair.d_b);
87
    // and only require true phase below if:
88
    //   es == EQUALITY_TRUE || es == EQUALITY_TRUE_IN_MODEL
89
    // and require false phase below if:
90
    //   es == EQUALITY_FALSE_IN_MODEL
91
    // This is supposed to force preference to follow what the theory models
92
    // already have but it doesn't seem to make a big difference - need to
93
    // explore more -Clark
94
78632
    Node e = d_valuation.ensureLiteral(equality);
95
39316
    propEngine->requirePhase(e, true);
96
  }
97
24007
}
98
99
25427
bool CombinationCareGraph::buildModel()
100
{
101
  // building the model happens as a separate step
102
25427
  return d_mmanager->buildModel();
103
}
104
105
}  // namespace theory
106
29358
}  // namespace cvc5