GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/preprocessing_pass_context.cpp Lines: 32 35 91.4 %
Date: 2021-09-29 Branches: 19 40 47.5 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Aina Niemetz, Andrew Reynolds, Mathias Preiner
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
 * The preprocessing pass context for passes.
14
 */
15
16
#include "preprocessing/preprocessing_pass_context.h"
17
18
#include "expr/node_algorithm.h"
19
#include "smt/env.h"
20
#include "smt/smt_engine.h"
21
#include "theory/theory_engine.h"
22
#include "theory/theory_model.h"
23
24
namespace cvc5 {
25
namespace preprocessing {
26
27
6345
PreprocessingPassContext::PreprocessingPassContext(
28
    SmtEngine* smt,
29
    Env& env,
30
6345
    theory::booleans::CircuitPropagator* circuitPropagator)
31
    : EnvObj(env),
32
      d_smt(smt),
33
      d_circuitPropagator(circuitPropagator),
34
      d_llm(
35
          env.getTopLevelSubstitutions(), userContext(), getProofNodeManager()),
36
6345
      d_symsInAssertions(userContext())
37
{
38
6345
}
39
40
theory::TrustSubstitutionMap&
41
25734
PreprocessingPassContext::getTopLevelSubstitutions() const
42
{
43
25734
  return d_env.getTopLevelSubstitutions();
44
}
45
46
214072
TheoryEngine* PreprocessingPassContext::getTheoryEngine() const
47
{
48
214072
  return d_smt->getTheoryEngine();
49
}
50
8540
prop::PropEngine* PreprocessingPassContext::getPropEngine() const
51
{
52
8540
  return d_smt->getPropEngine();
53
}
54
55
153339
void PreprocessingPassContext::spendResource(Resource r)
56
{
57
153339
  d_env.getResourceManager()->spendResource(r);
58
153339
}
59
3881
void PreprocessingPassContext::recordSymbolsInAssertions(
60
    const std::vector<Node>& assertions)
61
{
62
7762
  std::unordered_set<TNode> visited;
63
7762
  std::unordered_set<Node> syms;
64
19430
  for (TNode cn : assertions)
65
  {
66
15549
    expr::getSymbols(cn, syms, visited);
67
  }
68
24254
  for (const Node& s : syms)
69
  {
70
20373
    d_symsInAssertions.insert(s);
71
  }
72
3881
}
73
74
39013
void PreprocessingPassContext::notifyLearnedLiteral(TNode lit)
75
{
76
39013
  d_llm.notifyLearnedLiteral(lit);
77
39013
}
78
79
1
std::vector<Node> PreprocessingPassContext::getLearnedLiterals() const
80
{
81
1
  return d_llm.getLearnedLiterals();
82
}
83
84
305
void PreprocessingPassContext::addSubstitution(const Node& lhs,
85
                                               const Node& rhs,
86
                                               ProofGenerator* pg)
87
{
88
305
  getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg);
89
305
}
90
91
void PreprocessingPassContext::addSubstitution(const Node& lhs,
92
                                               const Node& rhs,
93
                                               PfRule id,
94
                                               const std::vector<Node>& args)
95
{
96
  getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args);
97
}
98
99
12616
ProofNodeManager* PreprocessingPassContext::getProofNodeManager() const
100
{
101
12616
  return d_env.getProofNodeManager();
102
}
103
104
}  // namespace preprocessing
105
22746
}  // namespace cvc5