summaryrefslogtreecommitdiff
path: root/src/theory/quantifiers/quant_module.h
blob: 53fb55aa06f5e437cb37a18319377af73e79a7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*********************                                                        */
/*! \file quant_module.h
 ** \verbatim
 ** Top contributors (to current version):
 **   Andrew Reynolds
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 ** in the top-level source directory and their institutional affiliations.
 ** All rights reserved.  See the file COPYING in the top-level source
 ** directory for licensing information.\endverbatim
 **
 ** \brief quantifier module
 **/

#include "cvc4_private.h"

#ifndef CVC4__THEORY__QUANT_MODULE_H
#define CVC4__THEORY__QUANT_MODULE_H

#include <iostream>
#include <map>
#include <vector>

#include "theory/quantifiers/quantifiers_inference_manager.h"
#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/term_registry.h"
#include "theory/theory.h"
#include "theory/uf/equality_engine.h"

namespace CVC5 {
namespace theory {
namespace quantifiers {
class TermDb;
}  // namespace quantifiers

/** QuantifiersModule class
 *
 * This is the virtual class for defining subsolvers of the quantifiers theory.
 * It has a similar interface to a Theory object.
 */
class QuantifiersModule
{
 public:
  /** effort levels for quantifiers modules check */
  enum QEffort
  {
    // conflict effort, for conflict-based instantiation
    QEFFORT_CONFLICT,
    // standard effort, for heuristic instantiation
    QEFFORT_STANDARD,
    // model effort, for model-based instantiation
    QEFFORT_MODEL,
    // last call effort, for last resort techniques
    QEFFORT_LAST_CALL,
    // none
    QEFFORT_NONE,
  };

 public:
  QuantifiersModule(quantifiers::QuantifiersState& qs,
                    quantifiers::QuantifiersInferenceManager& qim,
                    quantifiers::QuantifiersRegistry& qr,
                    quantifiers::TermRegistry& tr);
  virtual ~QuantifiersModule() {}
  /** Presolve.
   *
   * Called at the beginning of check-sat call.
   */
  virtual void presolve() {}
  /** Needs check.
   *
   * Returns true if this module wishes a call to be made
   * to check(e) during QuantifiersEngine::check(e).
   */
  virtual bool needsCheck(Theory::Effort e)
  {
    return e >= Theory::EFFORT_LAST_CALL;
  }
  /** Needs model.
   *
   * Whether this module needs a model built during a
   * call to QuantifiersEngine::check(e)
   * It returns one of QEFFORT_* from the enumeration above.
   * which specifies the quantifiers effort in which it requires the model to
   * be built.
   */
  virtual QEffort needsModel(Theory::Effort e);
  /** Reset.
   *
   * Called at the beginning of QuantifiersEngine::check(e).
   */
  virtual void reset_round(Theory::Effort e) {}
  /** Check.
   *
   *   Called during QuantifiersEngine::check(e) depending
   *   if needsCheck(e) returns true.
   */
  virtual void check(Theory::Effort e, QEffort quant_e) = 0;
  /** Check complete?
   *
   * Returns false if the module's reasoning was globally incomplete
   * (e.g. "sat" must be replaced with "incomplete").
   *
   * This is called just before the quantifiers engine will return
   * with no lemmas added during a LAST_CALL effort check.
   */
  virtual bool checkComplete() { return true; }
  /** Check was complete for quantified formula q
   *
   * If for each quantified formula q, some module returns true for
   * checkCompleteFor( q ),
   * and no lemmas are added by the quantifiers theory, then we may answer
   * "sat", unless
   * we are incomplete for other reasons.
   */
  virtual bool checkCompleteFor(Node q) { return false; }
  /** Check ownership
   *
   * Called once for new quantified formulas that are registered by the
   * quantifiers theory. The primary purpose of this function is to establish
   * if this module is the owner of quantified formula q.
   */
  virtual void checkOwnership(Node q) {}
  /** Register quantifier
   *
   * Called once for new quantified formulas q that are pre-registered by the
   * quantifiers theory, after internal ownership of quantified formulas is
   * finalized. This does context-independent initialization of this module
   * for quantified formula q.
   */
  virtual void registerQuantifier(Node q) {}
  /** Pre-register quantifier
   *
   * Called once for new quantified formulas that are
   * pre-registered by the quantifiers theory, after
   * internal ownership of quantified formulas is finalized.
   */
  virtual void preRegisterQuantifier(Node q) {}
  /** Assert node.
   *
   * Called when a quantified formula q is asserted to the quantifiers theory
   */
  virtual void assertNode(Node q) {}
  /** Identify this module (for debugging, dynamic configuration, etc..) */
  virtual std::string identify() const = 0;
  //----------------------------general queries
  /** get currently used the equality engine */
  eq::EqualityEngine* getEqualityEngine() const;
  /** are n1 and n2 equal in the current used equality engine? */
  bool areEqual(TNode n1, TNode n2) const;
  /** are n1 and n2 disequal in the current used equality engine? */
  bool areDisequal(TNode n1, TNode n2) const;
  /** get the representative of n in the current used equality engine */
  TNode getRepresentative(TNode n) const;
  /** get currently used term database */
  quantifiers::TermDb* getTermDatabase() const;
  /** get the quantifiers state */
  quantifiers::QuantifiersState& getState();
  /** get the quantifiers inference manager */
  quantifiers::QuantifiersInferenceManager& getInferenceManager();
  /** get the quantifiers registry */
  quantifiers::QuantifiersRegistry& getQuantifiersRegistry();
  //----------------------------end general queries
 protected:
  /** Reference to the state of the quantifiers engine */
  quantifiers::QuantifiersState& d_qstate;
  /** Reference to the quantifiers inference manager */
  quantifiers::QuantifiersInferenceManager& d_qim;
  /** Reference to the quantifiers registry */
  quantifiers::QuantifiersRegistry& d_qreg;
  /** Reference to the term registry */
  quantifiers::TermRegistry& d_treg;
}; /* class QuantifiersModule */

}  // namespace theory
}  // namespace CVC5

#endif /* CVC4__THEORY__QUANT_UTIL_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback