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