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(Env& env, OutputChannel& out, Valuation valuation); |
40 |
|
~TheoryBags() override; |
41 |
|
|
42 |
|
//--------------------------------- initialization |
43 |
|
/** get the official theory rewriter of this theory */ |
44 |
|
TheoryRewriter* getTheoryRewriter() override; |
45 |
|
/** get the proof checker of this theory */ |
46 |
|
ProofRuleChecker* getProofChecker() override; |
47 |
|
/** |
48 |
|
* Returns true if we need an equality engine. If so, we initialize the |
49 |
|
* information regarding how it should be setup. For details, see the |
50 |
|
* documentation in Theory::needsEqualityEngine. |
51 |
|
*/ |
52 |
|
bool needsEqualityEngine(EeSetupInfo& esi) override; |
53 |
|
/** finish initialization */ |
54 |
|
void finishInit() override; |
55 |
|
//--------------------------------- end initialization |
56 |
|
|
57 |
|
//--------------------------------- standard check |
58 |
|
/** Post-check, called after the fact queue of the theory is processed. */ |
59 |
|
void postCheck(Effort effort) override; |
60 |
|
/** Notify fact */ |
61 |
|
void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) override; |
62 |
|
//--------------------------------- end standard check |
63 |
|
/** Collect model values in m based on the relevant terms given by termSet */ |
64 |
|
bool collectModelValues(TheoryModel* m, |
65 |
|
const std::set<Node>& termSet) override; |
66 |
|
TrustNode explain(TNode) override; |
67 |
|
Node getModelValue(TNode) override; |
68 |
|
std::string identify() const override { return "THEORY_BAGS"; } |
69 |
|
void preRegisterTerm(TNode n) override; |
70 |
|
void presolve() override; |
71 |
|
|
72 |
|
private: |
73 |
|
/** Functions to handle callbacks from equality engine */ |
74 |
9912 |
class NotifyClass : public TheoryEqNotifyClass |
75 |
|
{ |
76 |
|
public: |
77 |
9915 |
NotifyClass(TheoryBags& theory, TheoryInferenceManager& inferenceManager) |
78 |
|
|
79 |
9915 |
: TheoryEqNotifyClass(inferenceManager), d_theory(theory) |
80 |
|
{ |
81 |
9915 |
} |
82 |
|
void eqNotifyNewClass(TNode n) override; |
83 |
|
void eqNotifyMerge(TNode n1, TNode n2) override; |
84 |
|
void eqNotifyDisequal(TNode n1, TNode n2, TNode reason) override; |
85 |
|
|
86 |
|
private: |
87 |
|
TheoryBags& d_theory; |
88 |
|
}; |
89 |
|
|
90 |
|
/** The state of the bags solver at full effort */ |
91 |
|
SolverState d_state; |
92 |
|
/** The inference manager */ |
93 |
|
InferenceManager d_im; |
94 |
|
/** The inference generator */ |
95 |
|
InferenceGenerator d_ig; |
96 |
|
/** Instance of the above class */ |
97 |
|
NotifyClass d_notify; |
98 |
|
/** Statistics for the theory of bags. */ |
99 |
|
BagsStatistics d_statistics; |
100 |
|
/** The theory rewriter for this theory. */ |
101 |
|
BagsRewriter d_rewriter; |
102 |
|
/** The term registry for this theory */ |
103 |
|
TermRegistry d_termReg; |
104 |
|
/** the main solver for bags */ |
105 |
|
BagSolver d_solver; |
106 |
|
|
107 |
|
void eqNotifyNewClass(TNode n); |
108 |
|
void eqNotifyMerge(TNode n1, TNode n2); |
109 |
|
void eqNotifyDisequal(TNode t1, TNode t2, TNode reason); |
110 |
|
}; /* class TheoryBags */ |
111 |
|
|
112 |
|
} // namespace bags |
113 |
|
} // namespace theory |
114 |
|
} // namespace cvc5 |
115 |
|
|
116 |
|
#endif /* CVC5__THEORY__BAGS__THEORY_BAGS_H */ |