GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/preprocessing_pass_context.cpp Lines: 32 35 91.4 %
Date: 2021-08-17 Branches: 15 32 46.9 %

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 "theory/theory_engine.h"
21
#include "theory/theory_model.h"
22
23
namespace cvc5 {
24
namespace preprocessing {
25
26
9850
PreprocessingPassContext::PreprocessingPassContext(
27
    SmtEngine* smt,
28
    Env& env,
29
9850
    theory::booleans::CircuitPropagator* circuitPropagator)
30
    : d_smt(smt),
31
      d_env(env),
32
      d_circuitPropagator(circuitPropagator),
33
      d_llm(env.getTopLevelSubstitutions(),
34
            env.getUserContext(),
35
            env.getProofNodeManager()),
36
9850
      d_symsInAssertions(env.getUserContext())
37
{
38
9850
}
39
40
theory::TrustSubstitutionMap&
41
38050
PreprocessingPassContext::getTopLevelSubstitutions()
42
{
43
38050
  return d_env.getTopLevelSubstitutions();
44
}
45
46
155526
context::Context* PreprocessingPassContext::getUserContext()
47
{
48
155526
  return d_env.getUserContext();
49
}
50
19700
context::Context* PreprocessingPassContext::getDecisionContext()
51
{
52
19700
  return d_env.getContext();
53
}
54
249707
void PreprocessingPassContext::spendResource(Resource r)
55
{
56
249707
  d_env.getResourceManager()->spendResource(r);
57
249707
}
58
6147
void PreprocessingPassContext::recordSymbolsInAssertions(
59
    const std::vector<Node>& assertions)
60
{
61
12294
  std::unordered_set<TNode> visited;
62
12294
  std::unordered_set<Node> syms;
63
31502
  for (TNode cn : assertions)
64
  {
65
25355
    expr::getSymbols(cn, syms, visited);
66
  }
67
40288
  for (const Node& s : syms)
68
  {
69
34141
    d_symsInAssertions.insert(s);
70
  }
71
6147
}
72
73
59771
void PreprocessingPassContext::notifyLearnedLiteral(TNode lit)
74
{
75
59771
  d_llm.notifyLearnedLiteral(lit);
76
59771
}
77
78
2
std::vector<Node> PreprocessingPassContext::getLearnedLiterals()
79
{
80
2
  return d_llm.getLearnedLiterals();
81
}
82
83
455
void PreprocessingPassContext::addSubstitution(const Node& lhs,
84
                                               const Node& rhs,
85
                                               ProofGenerator* pg)
86
{
87
455
  getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg);
88
455
}
89
90
void PreprocessingPassContext::addSubstitution(const Node& lhs,
91
                                               const Node& rhs,
92
                                               PfRule id,
93
                                               const std::vector<Node>& args)
94
{
95
  getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args);
96
}
97
98
9850
ProofNodeManager* PreprocessingPassContext::getProofNodeManager()
99
{
100
9850
  return d_env.getProofNodeManager();
101
}
102
103
}  // namespace preprocessing
104
29337
}  // namespace cvc5