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