1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mudathir Mohamed, Haniel Barbosa |
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 |
|
* Bags theory. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BAGS__THEORY_BAGS_H |
19 |
|
#define CVC5__THEORY__BAGS__THEORY_BAGS_H |
20 |
|
|
21 |
|
#include "theory/bags/bag_solver.h" |
22 |
|
#include "theory/bags/bags_rewriter.h" |
23 |
|
#include "theory/bags/bags_statistics.h" |
24 |
|
#include "theory/bags/inference_generator.h" |
25 |
|
#include "theory/bags/inference_manager.h" |
26 |
|
#include "theory/bags/solver_state.h" |
27 |
|
#include "theory/bags/term_registry.h" |
28 |
|
#include "theory/theory.h" |
29 |
|
#include "theory/theory_eq_notify.h" |
30 |
|
|
31 |
|
namespace cvc5 { |
32 |
|
namespace theory { |
33 |
|
namespace bags { |
34 |
|
|
35 |
|
class TheoryBags : public Theory |
36 |
|
{ |
37 |
|
public: |
38 |
|
/** Constructs a new instance of TheoryBags w.r.t. the provided contexts. */ |
39 |
|
TheoryBags(context::Context* c, |
40 |
|
context::UserContext* u, |
41 |
|
OutputChannel& out, |
42 |
|
Valuation valuation, |
43 |
|
const LogicInfo& logicInfo, |
44 |
|
ProofNodeManager* pnm); |
45 |
|
~TheoryBags() 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 effort) 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 |
|
TrustNode explain(TNode) override; |
72 |
|
Node getModelValue(TNode) override; |
73 |
|
std::string identify() const override { return "THEORY_BAGS"; } |
74 |
|
void preRegisterTerm(TNode n) override; |
75 |
|
void presolve() override; |
76 |
|
|
77 |
|
private: |
78 |
|
/** Functions to handle callbacks from equality engine */ |
79 |
9853 |
class NotifyClass : public TheoryEqNotifyClass |
80 |
|
{ |
81 |
|
public: |
82 |
9853 |
NotifyClass(TheoryBags& theory, TheoryInferenceManager& inferenceManager) |
83 |
|
|
84 |
9853 |
: TheoryEqNotifyClass(inferenceManager), d_theory(theory) |
85 |
|
{ |
86 |
9853 |
} |
87 |
|
void eqNotifyNewClass(TNode n) override; |
88 |
|
void eqNotifyMerge(TNode n1, TNode n2) override; |
89 |
|
void eqNotifyDisequal(TNode n1, TNode n2, TNode reason) override; |
90 |
|
|
91 |
|
private: |
92 |
|
TheoryBags& d_theory; |
93 |
|
}; |
94 |
|
|
95 |
|
/** The state of the bags solver at full effort */ |
96 |
|
SolverState d_state; |
97 |
|
/** The inference manager */ |
98 |
|
InferenceManager d_im; |
99 |
|
/** The inference generator */ |
100 |
|
InferenceGenerator d_ig; |
101 |
|
/** Instance of the above class */ |
102 |
|
NotifyClass d_notify; |
103 |
|
/** Statistics for the theory of bags. */ |
104 |
|
BagsStatistics d_statistics; |
105 |
|
/** The theory rewriter for this theory. */ |
106 |
|
BagsRewriter d_rewriter; |
107 |
|
/** The term registry for this theory */ |
108 |
|
TermRegistry d_termReg; |
109 |
|
/** the main solver for bags */ |
110 |
|
BagSolver d_solver; |
111 |
|
|
112 |
|
void eqNotifyNewClass(TNode n); |
113 |
|
void eqNotifyMerge(TNode n1, TNode n2); |
114 |
|
void eqNotifyDisequal(TNode t1, TNode t2, TNode reason); |
115 |
|
}; /* class TheoryBags */ |
116 |
|
|
117 |
|
} // namespace bags |
118 |
|
} // namespace theory |
119 |
|
} // namespace cvc5 |
120 |
|
|
121 |
|
#endif /* CVC5__THEORY__BAGS__THEORY_BAGS_H */ |