blob: 9309a704fe15b979863f9e6972131b92b553f2da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/********************* */
/*! \file solver_state.h
** \verbatim
** Top contributors (to current version):
** Mudathir Mohamed
** This file is part of the CVC4 project.
** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
** in the top-level source directory and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief Bags state object
**/
#include "cvc4_private.h"
#ifndef CVC5__THEORY__BAGS__THEORY_SOLVER_STATE_H
#define CVC5__THEORY__BAGS__THEORY_SOLVER_STATE_H
#include <map>
#include "theory/theory_state.h"
namespace cvc5 {
namespace theory {
namespace bags {
class SolverState : public TheoryState
{
public:
SolverState(context::Context* c, context::UserContext* u, Valuation val);
/**
* This function adds the bag representative n to the set d_bags if it is not
* already there. This function is called during postCheck to collect bag
* terms in the equality engine. See the documentation of
* @link SolverState::collectBagsAndCountTerms
*/
void registerBag(TNode n);
/**
* @param n has the form (bag.count e A)
* @pre bag A needs is already registered using registerBag(A)
* @return a unique skolem for (bag.count e A)
*/
void registerCountTerm(TNode n);
/** get all bag terms that are representatives in the equality engine.
* This function is valid after the current solver is initialized during
* postCheck. See SolverState::initialize and BagSolver::postCheck
*/
const std::set<Node>& getBags();
/**
* @pre B is a registered bag
* @return all elements associated with bag B so far
* Note that associated elements are not necessarily elements in B
* Example:
* (assert (= 0 (bag.count x B)))
* element x is associated with bag B, albeit x is definitely not in B.
*/
const std::set<Node>& getElements(Node B);
/** initialize bag and count terms */
void initialize();
/** return disequal bag terms */
const std::set<Node>& getDisequalBagTerms();
private:
/** clear all bags data structures */
void reset();
/**
* collect bags' representatives and all count terms.
* This function is called during postCheck
*/
void collectBagsAndCountTerms();
/**
* collect disequal bag terms. This function is called during postCheck.
*/
void collectDisequalBagTerms();
/** constants */
Node d_true;
Node d_false;
/** node manager for this solver state */
NodeManager* d_nm;
/** collection of bag representatives */
std::set<Node> d_bags;
/** bag -> associated elements */
std::map<Node, std::set<Node>> d_bagElements;
/** Disequal bag terms */
std::set<Node> d_deq;
}; /* class SolverState */
} // namespace bags
} // namespace theory
} // namespace cvc5
#endif /* CVC5__THEORY__BAGS__THEORY_SOLVER_STATE_H */
|