GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/preprocessing_pass_context.cpp Lines: 27 30 90.0 %
Date: 2021-05-22 Branches: 12 28 42.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
9459
PreprocessingPassContext::PreprocessingPassContext(
27
    SmtEngine* smt,
28
    Env& env,
29
9459
    theory::booleans::CircuitPropagator* circuitPropagator)
30
    : d_smt(smt),
31
      d_env(env),
32
      d_circuitPropagator(circuitPropagator),
33
9459
      d_symsInAssertions(env.getUserContext())
34
{
35
9459
}
36
37
theory::TrustSubstitutionMap&
38
35556
PreprocessingPassContext::getTopLevelSubstitutions()
39
{
40
35556
  return d_env.getTopLevelSubstitutions();
41
}
42
43
149002
context::Context* PreprocessingPassContext::getUserContext()
44
{
45
149002
  return d_env.getUserContext();
46
}
47
18918
context::Context* PreprocessingPassContext::getDecisionContext()
48
{
49
18918
  return d_env.getContext();
50
}
51
245723
void PreprocessingPassContext::spendResource(Resource r)
52
{
53
245723
  d_env.getResourceManager()->spendResource(r);
54
245723
}
55
5550
void PreprocessingPassContext::recordSymbolsInAssertions(
56
    const std::vector<Node>& assertions)
57
{
58
11100
  std::unordered_set<TNode> visited;
59
11100
  std::unordered_set<Node> syms;
60
29324
  for (TNode cn : assertions)
61
  {
62
23774
    expr::getSymbols(cn, syms, visited);
63
  }
64
40309
  for (const Node& s : syms)
65
  {
66
34759
    d_symsInAssertions.insert(s);
67
  }
68
5550
}
69
70
406
void PreprocessingPassContext::addSubstitution(const Node& lhs,
71
                                               const Node& rhs,
72
                                               ProofGenerator* pg)
73
{
74
406
  getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg);
75
406
}
76
77
void PreprocessingPassContext::addSubstitution(const Node& lhs,
78
                                               const Node& rhs,
79
                                               PfRule id,
80
                                               const std::vector<Node>& args)
81
{
82
  getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args);
83
}
84
85
9459
ProofNodeManager* PreprocessingPassContext::getProofNodeManager()
86
{
87
9459
  return d_env.getProofNodeManager();
88
}
89
90
}  // namespace preprocessing
91
28191
}  // namespace cvc5