GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/quant_module.h Lines: 9 11 81.8 %
Date: 2021-09-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
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
 * quantifier module
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANT_MODULE_H
19
#define CVC5__THEORY__QUANT_MODULE_H
20
21
#include <iostream>
22
#include <map>
23
#include <vector>
24
25
#include "smt/env_obj.h"
26
#include "theory/quantifiers/quantifiers_inference_manager.h"
27
#include "theory/quantifiers/quantifiers_registry.h"
28
#include "theory/quantifiers/quantifiers_state.h"
29
#include "theory/quantifiers/term_registry.h"
30
#include "theory/theory.h"
31
#include "theory/uf/equality_engine.h"
32
33
namespace cvc5 {
34
namespace theory {
35
namespace quantifiers {
36
class TermDb;
37
}  // namespace quantifiers
38
39
/** QuantifiersModule class
40
 *
41
 * This is the virtual class for defining subsolvers of the quantifiers theory.
42
 * It has a similar interface to a Theory object.
43
 */
44
class QuantifiersModule : protected EnvObj
45
{
46
 public:
47
  /** effort levels for quantifiers modules check */
48
  enum QEffort
49
  {
50
    // conflict effort, for conflict-based instantiation
51
    QEFFORT_CONFLICT,
52
    // standard effort, for heuristic instantiation
53
    QEFFORT_STANDARD,
54
    // model effort, for model-based instantiation
55
    QEFFORT_MODEL,
56
    // last call effort, for last resort techniques
57
    QEFFORT_LAST_CALL,
58
    // none
59
    QEFFORT_NONE,
60
  };
61
62
 public:
63
  QuantifiersModule(quantifiers::QuantifiersState& qs,
64
                    quantifiers::QuantifiersInferenceManager& qim,
65
                    quantifiers::QuantifiersRegistry& qr,
66
                    quantifiers::TermRegistry& tr);
67
34613
  virtual ~QuantifiersModule() {}
68
  /** Presolve.
69
   *
70
   * Called at the beginning of check-sat call.
71
   */
72
22739
  virtual void presolve() {}
73
  /** Needs check.
74
   *
75
   * Returns true if this module wishes a call to be made
76
   * to check(e) during QuantifiersEngine::check(e).
77
   */
78
  virtual bool needsCheck(Theory::Effort e)
79
  {
80
    return e >= Theory::EFFORT_LAST_CALL;
81
  }
82
  /** Needs model.
83
   *
84
   * Whether this module needs a model built during a
85
   * call to QuantifiersEngine::check(e)
86
   * It returns one of QEFFORT_* from the enumeration above.
87
   * which specifies the quantifiers effort in which it requires the model to
88
   * be built.
89
   */
90
  virtual QEffort needsModel(Theory::Effort e);
91
  /** Reset.
92
   *
93
   * Called at the beginning of QuantifiersEngine::check(e).
94
   */
95
32966
  virtual void reset_round(Theory::Effort e) {}
96
  /** Check.
97
   *
98
   *   Called during QuantifiersEngine::check(e) depending
99
   *   if needsCheck(e) returns true.
100
   */
101
  virtual void check(Theory::Effort e, QEffort quant_e) = 0;
102
  /** Check complete?
103
   *
104
   * Returns false if the module's reasoning was globally incomplete
105
   * (e.g. "sat" must be replaced with "incomplete").
106
   *
107
   * This is called just before the quantifiers engine will return
108
   * with no lemmas added during a LAST_CALL effort check.
109
   *
110
   * If this method returns false, it should update incId to the reason for
111
   * why the module was incomplete.
112
   */
113
10343
  virtual bool checkComplete(IncompleteId& incId) { return true; }
114
  /** Check was complete for quantified formula q
115
   *
116
   * If for each quantified formula q, some module returns true for
117
   * checkCompleteFor( q ),
118
   * and no lemmas are added by the quantifiers theory, then we may answer
119
   * "sat", unless
120
   * we are incomplete for other reasons.
121
   */
122
4185
  virtual bool checkCompleteFor(Node q) { return false; }
123
  /** Check ownership
124
   *
125
   * Called once for new quantified formulas that are registered by the
126
   * quantifiers theory. The primary purpose of this function is to establish
127
   * if this module is the owner of quantified formula q.
128
   */
129
55747
  virtual void checkOwnership(Node q) {}
130
  /** Register quantifier
131
   *
132
   * Called once for new quantified formulas q that are pre-registered by the
133
   * quantifiers theory, after internal ownership of quantified formulas is
134
   * finalized. This does context-independent initialization of this module
135
   * for quantified formula q.
136
   */
137
39428
  virtual void registerQuantifier(Node q) {}
138
  /** Pre-register quantifier
139
   *
140
   * Called once for new quantified formulas that are
141
   * pre-registered by the quantifiers theory, after
142
   * internal ownership of quantified formulas is finalized.
143
   */
144
91655
  virtual void preRegisterQuantifier(Node q) {}
145
  /** Assert node.
146
   *
147
   * Called when a quantified formula q is asserted to the quantifiers theory
148
   */
149
330688
  virtual void assertNode(Node q) {}
150
  /** Identify this module (for debugging, dynamic configuration, etc..) */
151
  virtual std::string identify() const = 0;
152
  //----------------------------general queries
153
  /** get currently used the equality engine */
154
  eq::EqualityEngine* getEqualityEngine() const;
155
  /** are n1 and n2 equal in the current used equality engine? */
156
  bool areEqual(TNode n1, TNode n2) const;
157
  /** are n1 and n2 disequal in the current used equality engine? */
158
  bool areDisequal(TNode n1, TNode n2) const;
159
  /** get the representative of n in the current used equality engine */
160
  TNode getRepresentative(TNode n) const;
161
  /** get currently used term database */
162
  quantifiers::TermDb* getTermDatabase() const;
163
  /** get the quantifiers state */
164
  quantifiers::QuantifiersState& getState();
165
  /** get the quantifiers inference manager */
166
  quantifiers::QuantifiersInferenceManager& getInferenceManager();
167
  /** get the quantifiers registry */
168
  quantifiers::QuantifiersRegistry& getQuantifiersRegistry();
169
  //----------------------------end general queries
170
 protected:
171
  /** Reference to the state of the quantifiers engine */
172
  quantifiers::QuantifiersState& d_qstate;
173
  /** Reference to the quantifiers inference manager */
174
  quantifiers::QuantifiersInferenceManager& d_qim;
175
  /** Reference to the quantifiers registry */
176
  quantifiers::QuantifiersRegistry& d_qreg;
177
  /** Reference to the term registry */
178
  quantifiers::TermRegistry& d_treg;
179
}; /* class QuantifiersModule */
180
181
}  // namespace theory
182
}  // namespace cvc5
183
184
#endif /* CVC5__THEORY__QUANT_UTIL_H */