1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Morgan Deters, 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 |
|
* A theory state for Theory. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__THEORY_STATE_H |
19 |
|
#define CVC5__THEORY__THEORY_STATE_H |
20 |
|
|
21 |
|
#include "context/cdo.h" |
22 |
|
#include "expr/node.h" |
23 |
|
#include "smt/env.h" |
24 |
|
#include "smt/env_obj.h" |
25 |
|
#include "theory/valuation.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
namespace theory { |
29 |
|
|
30 |
|
namespace eq { |
31 |
|
class EqualityEngine; |
32 |
|
} |
33 |
|
|
34 |
|
class TheoryState : protected EnvObj |
35 |
|
{ |
36 |
|
public: |
37 |
|
TheoryState(Env& env, |
38 |
|
Valuation val); |
39 |
183234 |
virtual ~TheoryState() {} |
40 |
|
/** |
41 |
|
* Set equality engine, where ee is a pointer to the official equality engine |
42 |
|
* of theory. |
43 |
|
*/ |
44 |
|
void setEqualityEngine(eq::EqualityEngine* ee); |
45 |
|
//-------------------------------------- equality information |
46 |
|
/** Is t registered as a term in the equality engine of this class? */ |
47 |
|
virtual bool hasTerm(TNode a) const; |
48 |
|
/** |
49 |
|
* Get the representative of t in the equality engine of this class, or t |
50 |
|
* itself if it is not registered as a term. |
51 |
|
*/ |
52 |
|
virtual TNode getRepresentative(TNode t) const; |
53 |
|
/** |
54 |
|
* Are a and b equal according to the equality engine of this class? Also |
55 |
|
* returns true if a and b are identical. |
56 |
|
*/ |
57 |
|
virtual bool areEqual(TNode a, TNode b) const; |
58 |
|
/** |
59 |
|
* Are a and b disequal according to the equality engine of this class? Also |
60 |
|
* returns true if the representative of a and b are distinct constants. |
61 |
|
*/ |
62 |
|
virtual bool areDisequal(TNode a, TNode b) const; |
63 |
|
/** get list of members in the equivalence class of a */ |
64 |
|
virtual void getEquivalenceClass(Node a, std::vector<Node>& eqc) const; |
65 |
|
/** get equality engine */ |
66 |
|
eq::EqualityEngine* getEqualityEngine() const; |
67 |
|
//-------------------------------------- end equality information |
68 |
|
/** |
69 |
|
* Set that the current state of the solver is in conflict. This should be |
70 |
|
* called immediately after a call to conflict(...) on the output channel of |
71 |
|
* the theory. |
72 |
|
*/ |
73 |
|
virtual void notifyInConflict(); |
74 |
|
/** Are we currently in conflict? */ |
75 |
|
virtual bool isInConflict() const; |
76 |
|
|
77 |
|
/** Returns true if lit is a SAT literal. */ |
78 |
|
virtual bool isSatLiteral(TNode lit) const; |
79 |
|
/** |
80 |
|
* Returns pointer to model. This model is only valid during last call effort |
81 |
|
* check. |
82 |
|
*/ |
83 |
|
TheoryModel* getModel(); |
84 |
|
/** |
85 |
|
* Returns a pointer to the sort inference module, which lives in TheoryEngine |
86 |
|
* and is non-null when options::sortInference is true. |
87 |
|
*/ |
88 |
|
SortInference* getSortInference(); |
89 |
|
|
90 |
|
/** Returns true if n has a current SAT assignment and stores it in value. */ |
91 |
|
virtual bool hasSatValue(TNode n, bool& value) const; |
92 |
|
|
93 |
|
//------------------------------------------- access methods for assertions |
94 |
|
/** |
95 |
|
* The following methods are intended only to be used in limited use cases, |
96 |
|
* for cases where a theory (e.g. quantifiers) requires knowing about the |
97 |
|
* assertions from other theories. |
98 |
|
*/ |
99 |
|
/** The beginning iterator of facts for theory tid.*/ |
100 |
|
context::CDList<Assertion>::const_iterator factsBegin(TheoryId tid); |
101 |
|
/** The beginning iterator of facts for theory tid.*/ |
102 |
|
context::CDList<Assertion>::const_iterator factsEnd(TheoryId tid); |
103 |
|
|
104 |
|
/** Get the underlying valuation class */ |
105 |
|
Valuation& getValuation(); |
106 |
|
|
107 |
|
protected: |
108 |
|
/** |
109 |
|
* The valuation proxy for the Theory to communicate back with the |
110 |
|
* theory engine (and other theories). |
111 |
|
*/ |
112 |
|
Valuation d_valuation; |
113 |
|
/** Pointer to equality engine of the theory. */ |
114 |
|
eq::EqualityEngine* d_ee; |
115 |
|
/** Are we in conflict? */ |
116 |
|
context::CDO<bool> d_conflict; |
117 |
|
}; |
118 |
|
|
119 |
|
} // namespace theory |
120 |
|
} // namespace cvc5 |
121 |
|
|
122 |
|
#endif /* CVC5__THEORY__SOLVER_STATE_H */ |