1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Liana Hadarean, Tim King, Dejan Jovanovic |
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 |
|
* Interface for bit-vectors sub-solvers. |
14 |
|
*/ |
15 |
|
|
16 |
|
#ifndef CVC5__THEORY__BV__BV_SUBTHEORY_H |
17 |
|
#define CVC5__THEORY__BV__BV_SUBTHEORY_H |
18 |
|
|
19 |
|
#include "context/cdqueue.h" |
20 |
|
#include "context/context.h" |
21 |
|
#include "cvc5_private.h" |
22 |
|
#include "theory/theory.h" |
23 |
|
#include "theory/uf/equality_engine.h" |
24 |
|
|
25 |
|
namespace cvc5 { |
26 |
|
|
27 |
|
namespace theory { |
28 |
|
|
29 |
|
class TheoryModel; |
30 |
|
|
31 |
|
namespace bv { |
32 |
|
|
33 |
|
enum SubTheory { |
34 |
|
SUB_CORE = 1, |
35 |
|
SUB_BITBLAST = 2, |
36 |
|
SUB_INEQUALITY = 3, |
37 |
|
SUB_ALGEBRAIC = 4 |
38 |
|
}; |
39 |
|
|
40 |
|
inline std::ostream& operator<<(std::ostream& out, SubTheory subtheory) { |
41 |
|
switch (subtheory) { |
42 |
|
case SUB_BITBLAST: |
43 |
|
return out << "BITBLASTER"; |
44 |
|
case SUB_CORE: |
45 |
|
return out << "BV_CORE_SUBTHEORY"; |
46 |
|
case SUB_INEQUALITY: |
47 |
|
return out << "BV_INEQUALITY_SUBTHEORY"; |
48 |
|
case SUB_ALGEBRAIC: |
49 |
|
return out << "BV_ALGEBRAIC_SUBTHEORY"; |
50 |
|
default: |
51 |
|
break; |
52 |
|
} |
53 |
|
Unreachable(); |
54 |
|
} |
55 |
|
|
56 |
|
// forward declaration |
57 |
|
class BVSolverLazy; |
58 |
|
|
59 |
|
using AssertionQueue = context::CDQueue<Node>; |
60 |
|
|
61 |
|
/** |
62 |
|
* Abstract base class for bit-vector subtheory solvers |
63 |
|
* |
64 |
|
*/ |
65 |
|
class SubtheorySolver { |
66 |
|
public: |
67 |
28213 |
SubtheorySolver(context::Context* c, BVSolverLazy* bv) |
68 |
28213 |
: d_context(c), d_bv(bv), d_assertionQueue(c), d_assertionIndex(c, 0) |
69 |
|
{ |
70 |
28213 |
} |
71 |
28213 |
virtual ~SubtheorySolver() {} |
72 |
|
virtual bool check(Theory::Effort e) = 0; |
73 |
|
virtual void explain(TNode literal, std::vector<TNode>& assumptions) = 0; |
74 |
|
virtual void preRegister(TNode node) {} |
75 |
|
virtual void propagate(Theory::Effort e) {} |
76 |
|
virtual bool collectModelValues(TheoryModel* m, |
77 |
|
const std::set<Node>& termSet) = 0; |
78 |
|
virtual Node getModelValue(TNode var) = 0; |
79 |
|
virtual bool isComplete() = 0; |
80 |
|
virtual EqualityStatus getEqualityStatus(TNode a, TNode b) = 0; |
81 |
8664190 |
bool done() { return d_assertionQueue.size() == d_assertionIndex; } |
82 |
4017224 |
TNode get() { |
83 |
4017224 |
Assert(!done()); |
84 |
4017224 |
TNode res = d_assertionQueue[d_assertionIndex]; |
85 |
4017224 |
d_assertionIndex = d_assertionIndex + 1; |
86 |
4017224 |
return res; |
87 |
|
} |
88 |
2795278 |
virtual void assertFact(TNode fact) { d_assertionQueue.push_back(fact); } |
89 |
|
|
90 |
|
AssertionQueue::const_iterator assertionsBegin() { |
91 |
|
return d_assertionQueue.begin(); |
92 |
|
} |
93 |
|
AssertionQueue::const_iterator assertionsEnd() { |
94 |
|
return d_assertionQueue.end(); |
95 |
|
} |
96 |
|
|
97 |
|
protected: |
98 |
|
/** The context we are using */ |
99 |
|
context::Context* d_context; |
100 |
|
|
101 |
|
/** The bit-vector theory */ |
102 |
|
BVSolverLazy* d_bv; |
103 |
|
AssertionQueue d_assertionQueue; |
104 |
|
context::CDO<uint32_t> d_assertionIndex; |
105 |
|
}; /* class SubtheorySolver */ |
106 |
|
|
107 |
|
} // namespace bv |
108 |
|
} // namespace theory |
109 |
|
} // namespace cvc5 |
110 |
|
|
111 |
|
#endif /* CVC5__THEORY__BV__BV_SUBTHEORY_H */ |