GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/combination_care_graph.cpp Lines: 33 33 100.0 %
Date: 2021-05-22 Branches: 48 92 52.2 %

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/theory_engine.h"
23
24
namespace cvc5 {
25
namespace theory {
26
27
9459
CombinationCareGraph::CombinationCareGraph(
28
    TheoryEngine& te,
29
    Env& env,
30
    const std::vector<Theory*>& paraTheories,
31
9459
    ProofNodeManager* pnm)
32
9459
    : CombinationEngine(te, env, paraTheories, pnm)
33
{
34
9459
}
35
36
18918
CombinationCareGraph::~CombinationCareGraph() {}
37
38
20889
void CombinationCareGraph::combineTheories()
39
{
40
20889
  Trace("combineTheories") << "TheoryEngine::combineTheories()" << std::endl;
41
42
  // Care graph we'll be building
43
41778
  CareGraph careGraph;
44
45
  // get the care graph from the parametric theories
46
83964
  for (Theory* t : d_paraTheories)
47
  {
48
63075
    t->getCareGraph(&careGraph);
49
  }
50
51
41778
  Trace("combineTheories")
52
20889
      << "TheoryEngine::combineTheories(): care graph size = "
53
20889
      << careGraph.size() << std::endl;
54
55
  // Now add splitters for the ones we are interested in
56
20889
  prop::PropEngine* propEngine = d_te.getPropEngine();
57
50258
  for (const CarePair& carePair : careGraph)
58
  {
59
58738
    Debug("combineTheories")
60
29369
        << "TheoryEngine::combineTheories(): checking " << carePair.d_a << " = "
61
29369
        << carePair.d_b << " from " << carePair.d_theory << std::endl;
62
63
    // The equality in question (order for no repetition)
64
58738
    Node equality = carePair.d_a.eqNode(carePair.d_b);
65
66
    // We need to split on it
67
58738
    Debug("combineTheories")
68
29369
        << "TheoryEngine::combineTheories(): requesting a split " << std::endl;
69
70
58738
    TrustNode tsplit;
71
29369
    if (isProofEnabled())
72
    {
73
      // make proof of splitting lemma
74
9864
      tsplit = d_cmbsPg->mkTrustNodeSplit(equality);
75
    }
76
    else
77
    {
78
39010
      Node split = equality.orNode(equality.notNode());
79
19505
      tsplit = TrustNode::mkTrustLemma(split, nullptr);
80
    }
81
29369
    sendLemma(tsplit, carePair.d_theory);
82
83
    // Could check the equality status here:
84
    //   EqualityStatus es = getEqualityStatus(carePair.d_a, carePair.d_b);
85
    // and only require true phase below if:
86
    //   es == EQUALITY_TRUE || es == EQUALITY_TRUE_IN_MODEL
87
    // and require false phase below if:
88
    //   es == EQUALITY_FALSE_IN_MODEL
89
    // This is supposed to force preference to follow what the theory models
90
    // already have but it doesn't seem to make a big difference - need to
91
    // explore more -Clark
92
58738
    Node e = d_valuation.ensureLiteral(equality);
93
29369
    propEngine->requirePhase(e, true);
94
  }
95
20889
}
96
97
23582
bool CombinationCareGraph::buildModel()
98
{
99
  // building the model happens as a separate step
100
23582
  return d_mmanager->buildModel();
101
}
102
103
}  // namespace theory
104
28191
}  // namespace cvc5