GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/combination_care_graph.cpp Lines: 34 34 100.0 %
Date: 2021-11-08 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
15275
CombinationCareGraph::CombinationCareGraph(
29
15275
    Env& env, TheoryEngine& te, const std::vector<Theory*>& paraTheories)
30
15275
    : CombinationEngine(env, te, paraTheories)
31
{
32
15275
}
33
34
30540
CombinationCareGraph::~CombinationCareGraph() {}
35
36
34964
void CombinationCareGraph::combineTheories()
37
{
38
34964
  Trace("combineTheories") << "TheoryEngine::combineTheories()" << std::endl;
39
40
  // Care graph we'll be building
41
69928
  CareGraph careGraph;
42
43
  // get the care graph from the parametric theories
44
135236
  for (Theory* t : d_paraTheories)
45
  {
46
100272
    t->getCareGraph(&careGraph);
47
  }
48
49
69928
  Trace("combineTheories")
50
34964
      << "TheoryEngine::combineTheories(): care graph size = "
51
34964
      << careGraph.size() << std::endl;
52
53
  // Now add splitters for the ones we are interested in
54
34964
  prop::PropEngine* propEngine = d_te.getPropEngine();
55
84078
  for (const CarePair& carePair : careGraph)
56
  {
57
98228
    Debug("combineTheories")
58
49114
        << "TheoryEngine::combineTheories(): checking " << carePair.d_a << " = "
59
49114
        << carePair.d_b << " from " << carePair.d_theory << std::endl;
60
61
    // The equality in question (order for no repetition)
62
98228
    Node equality = carePair.d_a.eqNode(carePair.d_b);
63
64
    // We need to split on it
65
98228
    Debug("combineTheories")
66
49114
        << "TheoryEngine::combineTheories(): requesting a split " << std::endl;
67
68
98228
    TrustNode tsplit;
69
49114
    if (isProofEnabled())
70
    {
71
      // make proof of splitting lemma
72
10008
      tsplit = d_cmbsPg->mkTrustNodeSplit(equality);
73
    }
74
    else
75
    {
76
78212
      Node split = equality.orNode(equality.notNode());
77
39106
      tsplit = TrustNode::mkTrustLemma(split, nullptr);
78
    }
79
98228
    d_sharedSolver->sendLemma(
80
49114
        tsplit, carePair.d_theory, InferenceId::COMBINATION_SPLIT);
81
82
    // Could check the equality status here:
83
    //   EqualityStatus es = getEqualityStatus(carePair.d_a, carePair.d_b);
84
    // and only require true phase below if:
85
    //   es == EQUALITY_TRUE || es == EQUALITY_TRUE_IN_MODEL
86
    // and require false phase below if:
87
    //   es == EQUALITY_FALSE_IN_MODEL
88
    // This is supposed to force preference to follow what the theory models
89
    // already have but it doesn't seem to make a big difference - need to
90
    // explore more -Clark
91
98228
    Node e = d_valuation.ensureLiteral(equality);
92
49114
    propEngine->requirePhase(e, true);
93
  }
94
34964
}
95
96
45497
bool CombinationCareGraph::buildModel()
97
{
98
  // building the model happens as a separate step
99
45497
  return d_mmanager->buildModel();
100
}
101
102
}  // namespace theory
103
31140
}  // namespace cvc5