1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mudathir Mohamed |
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 state object. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BAGS__THEORY_SOLVER_STATE_H |
19 |
|
#define CVC5__THEORY__BAGS__THEORY_SOLVER_STATE_H |
20 |
|
|
21 |
|
#include <map> |
22 |
|
|
23 |
|
#include "theory/theory_state.h" |
24 |
|
|
25 |
|
namespace cvc5 { |
26 |
|
namespace theory { |
27 |
|
namespace bags { |
28 |
|
|
29 |
9910 |
class SolverState : public TheoryState |
30 |
|
{ |
31 |
|
public: |
32 |
|
SolverState(Env& env, |
33 |
|
Valuation val); |
34 |
|
|
35 |
|
/** |
36 |
|
* This function adds the bag representative n to the set d_bags if it is not |
37 |
|
* already there. This function is called during postCheck to collect bag |
38 |
|
* terms in the equality engine. See the documentation of |
39 |
|
* @link SolverState::collectBagsAndCountTerms |
40 |
|
*/ |
41 |
|
void registerBag(TNode n); |
42 |
|
|
43 |
|
/** |
44 |
|
* @param n has the form (bag.count e A) |
45 |
|
* @pre bag A needs is already registered using registerBag(A) |
46 |
|
* @return a unique skolem for (bag.count e A) |
47 |
|
*/ |
48 |
|
void registerCountTerm(TNode n); |
49 |
|
/** get all bag terms that are representatives in the equality engine. |
50 |
|
* This function is valid after the current solver is initialized during |
51 |
|
* postCheck. See SolverState::initialize and BagSolver::postCheck |
52 |
|
*/ |
53 |
|
const std::set<Node>& getBags(); |
54 |
|
/** |
55 |
|
* @pre B is a registered bag |
56 |
|
* @return all elements associated with bag B so far |
57 |
|
* Note that associated elements are not necessarily elements in B |
58 |
|
* Example: |
59 |
|
* (assert (= 0 (bag.count x B))) |
60 |
|
* element x is associated with bag B, albeit x is definitely not in B. |
61 |
|
*/ |
62 |
|
const std::set<Node>& getElements(Node B); |
63 |
|
/** initialize bag and count terms */ |
64 |
|
void initialize(); |
65 |
|
/** return disequal bag terms */ |
66 |
|
const std::set<Node>& getDisequalBagTerms(); |
67 |
|
|
68 |
|
private: |
69 |
|
/** clear all bags data structures */ |
70 |
|
void reset(); |
71 |
|
/** |
72 |
|
* collect bags' representatives and all count terms. |
73 |
|
* This function is called during postCheck |
74 |
|
*/ |
75 |
|
void collectBagsAndCountTerms(); |
76 |
|
/** |
77 |
|
* collect disequal bag terms. This function is called during postCheck. |
78 |
|
*/ |
79 |
|
void collectDisequalBagTerms(); |
80 |
|
/** constants */ |
81 |
|
Node d_true; |
82 |
|
Node d_false; |
83 |
|
/** node manager for this solver state */ |
84 |
|
NodeManager* d_nm; |
85 |
|
/** collection of bag representatives */ |
86 |
|
std::set<Node> d_bags; |
87 |
|
/** bag -> associated elements */ |
88 |
|
std::map<Node, std::set<Node>> d_bagElements; |
89 |
|
/** Disequal bag terms */ |
90 |
|
std::set<Node> d_deq; |
91 |
|
}; /* class SolverState */ |
92 |
|
|
93 |
|
} // namespace bags |
94 |
|
} // namespace theory |
95 |
|
} // namespace cvc5 |
96 |
|
|
97 |
|
#endif /* CVC5__THEORY__BAGS__THEORY_SOLVER_STATE_H */ |