GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/combination_care_graph.cpp Lines: 34 34 100.0 %
Date: 2021-11-05 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
15271
CombinationCareGraph::CombinationCareGraph(
29
15271
    Env& env, TheoryEngine& te, const std::vector<Theory*>& paraTheories)
30
15271
    : CombinationEngine(env, te, paraTheories)
31
{
32
15271
}
33
34
30532
CombinationCareGraph::~CombinationCareGraph() {}
35
36
30599
void CombinationCareGraph::combineTheories()
37
{
38
30599
  Trace("combineTheories") << "TheoryEngine::combineTheories()" << std::endl;
39
40
  // Care graph we'll be building
41
61198
  CareGraph careGraph;
42
43
  // get the care graph from the parametric theories
44
126789
  for (Theory* t : d_paraTheories)
45
  {
46
96190
    t->getCareGraph(&careGraph);
47
  }
48
49
61198
  Trace("combineTheories")
50
30599
      << "TheoryEngine::combineTheories(): care graph size = "
51
30599
      << careGraph.size() << std::endl;
52
53
  // Now add splitters for the ones we are interested in
54
30599
  prop::PropEngine* propEngine = d_te.getPropEngine();
55
61472
  for (const CarePair& carePair : careGraph)
56
  {
57
61746
    Debug("combineTheories")
58
30873
        << "TheoryEngine::combineTheories(): checking " << carePair.d_a << " = "
59
30873
        << carePair.d_b << " from " << carePair.d_theory << std::endl;
60
61
    // The equality in question (order for no repetition)
62
61746
    Node equality = carePair.d_a.eqNode(carePair.d_b);
63
64
    // We need to split on it
65
61746
    Debug("combineTheories")
66
30873
        << "TheoryEngine::combineTheories(): requesting a split " << std::endl;
67
68
61746
    TrustNode tsplit;
69
30873
    if (isProofEnabled())
70
    {
71
      // make proof of splitting lemma
72
10034
      tsplit = d_cmbsPg->mkTrustNodeSplit(equality);
73
    }
74
    else
75
    {
76
41678
      Node split = equality.orNode(equality.notNode());
77
20839
      tsplit = TrustNode::mkTrustLemma(split, nullptr);
78
    }
79
61746
    d_sharedSolver->sendLemma(
80
30873
        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
61746
    Node e = d_valuation.ensureLiteral(equality);
92
30873
    propEngine->requirePhase(e, true);
93
  }
94
30599
}
95
96
45288
bool CombinationCareGraph::buildModel()
97
{
98
  // building the model happens as a separate step
99
45288
  return d_mmanager->buildModel();
100
}
101
102
}  // namespace theory
103
31125
}  // namespace cvc5