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