1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Tim King, Kshitij Bansal |
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 |
|
* Sets theory. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__SETS__THEORY_SETS_H |
19 |
|
#define CVC5__THEORY__SETS__THEORY_SETS_H |
20 |
|
|
21 |
|
#include <memory> |
22 |
|
|
23 |
|
#include "smt/logic_exception.h" |
24 |
|
#include "theory/sets/inference_manager.h" |
25 |
|
#include "theory/sets/skolem_cache.h" |
26 |
|
#include "theory/sets/solver_state.h" |
27 |
|
#include "theory/theory.h" |
28 |
|
#include "theory/theory_eq_notify.h" |
29 |
|
#include "theory/uf/equality_engine.h" |
30 |
|
|
31 |
|
namespace cvc5 { |
32 |
|
namespace theory { |
33 |
|
namespace sets { |
34 |
|
|
35 |
|
class TheorySetsPrivate; |
36 |
|
class TheorySetsScrutinize; |
37 |
|
|
38 |
|
class TheorySets : public Theory |
39 |
|
{ |
40 |
|
friend class TheorySetsPrivate; |
41 |
|
friend class TheorySetsRels; |
42 |
|
public: |
43 |
|
/** Constructs a new instance of TheorySets w.r.t. the provided contexts. */ |
44 |
|
TheorySets(Env& env, OutputChannel& out, Valuation valuation); |
45 |
|
~TheorySets() override; |
46 |
|
|
47 |
|
//--------------------------------- initialization |
48 |
|
/** get the official theory rewriter of this theory */ |
49 |
|
TheoryRewriter* getTheoryRewriter() override; |
50 |
|
/** get the proof checker of this theory */ |
51 |
|
ProofRuleChecker* getProofChecker() override; |
52 |
|
/** |
53 |
|
* Returns true if we need an equality engine. If so, we initialize the |
54 |
|
* information regarding how it should be setup. For details, see the |
55 |
|
* documentation in Theory::needsEqualityEngine. |
56 |
|
*/ |
57 |
|
bool needsEqualityEngine(EeSetupInfo& esi) override; |
58 |
|
/** finish initialization */ |
59 |
|
void finishInit() override; |
60 |
|
//--------------------------------- end initialization |
61 |
|
|
62 |
|
//--------------------------------- standard check |
63 |
|
/** Post-check, called after the fact queue of the theory is processed. */ |
64 |
|
void postCheck(Effort level) override; |
65 |
|
/** Notify fact */ |
66 |
|
void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) override; |
67 |
|
//--------------------------------- end standard check |
68 |
|
/** Collect model values in m based on the relevant terms given by termSet */ |
69 |
|
bool collectModelValues(TheoryModel* m, |
70 |
|
const std::set<Node>& termSet) override; |
71 |
|
void computeCareGraph() override; |
72 |
|
TrustNode explain(TNode) override; |
73 |
|
Node getModelValue(TNode) override; |
74 |
|
std::string identify() const override { return "THEORY_SETS"; } |
75 |
|
void preRegisterTerm(TNode node) override; |
76 |
|
/** |
77 |
|
* If the sets-ext option is not set and we have an extended operator, |
78 |
|
* we throw an exception. Additionally, we expand operators like choose |
79 |
|
* and is_singleton. |
80 |
|
*/ |
81 |
|
TrustNode ppRewrite(TNode n, std::vector<SkolemLemma>& lems) override; |
82 |
|
PPAssertStatus ppAssert(TrustNode tin, |
83 |
|
TrustSubstitutionMap& outSubstitutions) override; |
84 |
|
void presolve() override; |
85 |
|
bool isEntailed(Node n, bool pol); |
86 |
|
|
87 |
|
private: |
88 |
|
/** Functions to handle callbacks from equality engine */ |
89 |
9939 |
class NotifyClass : public TheoryEqNotifyClass |
90 |
|
{ |
91 |
|
public: |
92 |
9942 |
NotifyClass(TheorySetsPrivate& theory, TheoryInferenceManager& im) |
93 |
9942 |
: TheoryEqNotifyClass(im), d_theory(theory) |
94 |
|
{ |
95 |
9942 |
} |
96 |
|
void eqNotifyNewClass(TNode t) override; |
97 |
|
void eqNotifyMerge(TNode t1, TNode t2) override; |
98 |
|
void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override; |
99 |
|
|
100 |
|
private: |
101 |
|
TheorySetsPrivate& d_theory; |
102 |
|
}; |
103 |
|
/** The skolem cache */ |
104 |
|
SkolemCache d_skCache; |
105 |
|
/** The state of the sets solver at full effort */ |
106 |
|
SolverState d_state; |
107 |
|
/** The inference manager */ |
108 |
|
InferenceManager d_im; |
109 |
|
/** The internal theory */ |
110 |
|
std::unique_ptr<TheorySetsPrivate> d_internal; |
111 |
|
/** Instance of the above class */ |
112 |
|
NotifyClass d_notify; |
113 |
|
}; /* class TheorySets */ |
114 |
|
|
115 |
|
} // namespace sets |
116 |
|
} // namespace theory |
117 |
|
} // namespace cvc5 |
118 |
|
|
119 |
|
#endif /* CVC5__THEORY__SETS__THEORY_SETS_H */ |