GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/preprocessing_pass_context.h Lines: 8 8 100.0 %
Date: 2021-08-17 Branches: 0 0 0.0 %

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
 * Implementation of the preprocessing pass context for passes. This context
16
 * allows preprocessing passes to retrieve information besides the assertions
17
 * from the solver and interact with it without getting full access.
18
 */
19
20
#include "cvc5_private.h"
21
22
#ifndef CVC5__PREPROCESSING__PREPROCESSING_PASS_CONTEXT_H
23
#define CVC5__PREPROCESSING__PREPROCESSING_PASS_CONTEXT_H
24
25
#include "context/cdhashset.h"
26
#include "preprocessing/learned_literal_manager.h"
27
#include "smt/smt_engine.h"
28
#include "util/resource_manager.h"
29
30
namespace cvc5 {
31
class SmtEngine;
32
class TheoryEngine;
33
namespace theory::booleans {
34
class CircuitPropagator;
35
}
36
namespace prop {
37
class PropEngine;
38
}
39
namespace preprocessing {
40
41
9850
class PreprocessingPassContext
42
{
43
 public:
44
  PreprocessingPassContext(
45
      SmtEngine* smt,
46
      Env& env,
47
      theory::booleans::CircuitPropagator* circuitPropagator);
48
49
1
  SmtEngine* getSmt() { return d_smt; }
50
324576
  TheoryEngine* getTheoryEngine() { return d_smt->getTheoryEngine(); }
51
13746
  prop::PropEngine* getPropEngine() { return d_smt->getPropEngine(); }
52
  context::Context* getUserContext();
53
  context::Context* getDecisionContext();
54
55
11028
  theory::booleans::CircuitPropagator* getCircuitPropagator()
56
  {
57
11028
    return d_circuitPropagator;
58
  }
59
60
2645
  context::CDHashSet<Node>& getSymsInAssertions() { return d_symsInAssertions; }
61
62
  void spendResource(Resource r);
63
64
  /** Get the current logic info of the SmtEngine */
65
9912
  const LogicInfo& getLogicInfo() { return d_smt->getLogicInfo(); }
66
67
  /** Gets a reference to the top-level substitution map */
68
  theory::TrustSubstitutionMap& getTopLevelSubstitutions();
69
70
  /** Record symbols in assertions
71
   *
72
   * This method is called when a set of assertions is finalized. It adds
73
   * the symbols to d_symsInAssertions that occur in assertions.
74
   */
75
  void recordSymbolsInAssertions(const std::vector<Node>& assertions);
76
77
  /**
78
   * Notify learned literal. This method is called when a literal is
79
   * entailed by the current set of assertions.
80
   *
81
   * It should be rewritten, and such that top level substitutions have
82
   * been applied to it.
83
   */
84
  void notifyLearnedLiteral(TNode lit);
85
  /**
86
   * Get the learned literals
87
   */
88
  std::vector<Node> getLearnedLiterals();
89
  /**
90
   * Add substitution to the top-level substitutions, which also as a
91
   * consequence is used by the theory model.
92
   * @param lhs The node replaced by node 'rhs'
93
   * @param rhs The node to substitute node 'lhs'
94
   * @param pg The proof generator that can provide a proof of lhs == rhs.
95
   */
96
  void addSubstitution(const Node& lhs,
97
                       const Node& rhs,
98
                       ProofGenerator* pg = nullptr);
99
  /** Same as above, with proof id */
100
  void addSubstitution(const Node& lhs,
101
                       const Node& rhs,
102
                       PfRule id,
103
                       const std::vector<Node>& args);
104
105
  /** The the proof node manager associated with this context, if it exists */
106
  ProofNodeManager* getProofNodeManager();
107
108
 private:
109
  /** Pointer to the SmtEngine that this context was created in. */
110
  SmtEngine* d_smt;
111
  /** Reference to the environment. */
112
  Env& d_env;
113
  /** Instance of the circuit propagator */
114
  theory::booleans::CircuitPropagator* d_circuitPropagator;
115
  /**
116
   * The learned literal manager
117
   */
118
  LearnedLiteralManager d_llm;
119
120
  /**
121
   * The (user-context-dependent) set of symbols that occur in at least one
122
   * assertion in the current user context.
123
   */
124
  context::CDHashSet<Node> d_symsInAssertions;
125
126
};  // class PreprocessingPassContext
127
128
}  // namespace preprocessing
129
}  // namespace cvc5
130
131
#endif /* CVC5__PREPROCESSING__PREPROCESSING_PASS_CONTEXT_H */