24 #ifndef PPL_Ask_Tell_templates_hh
25 #define PPL_Ask_Tell_templates_hh 1
35 x_end = end(), xi = x_begin; xi != x_end; ++xi)
38 if (xi->tell().definitely_entails(yi->tell())) {
39 if (yi->ask().definitely_entails(xi->ask())) {
43 else if (xi->tell().definitely_entails(yi->ask())) {
46 if (xi->ask().definitely_entails(yi->ask())
47 && !xi->ask().definitely_entails(yi->tell())) {
59 x_end = sequence.end(), xi = x_begin; xi != x_end; ++xi)
62 && yi->ask().definitely_entails(xi->ask())
63 && xi->tell().definitely_entails(yi->tell())) {
64 yi = sequence.erase(yi);
65 x_begin = sequence.begin();
66 x_end = sequence.end();
73 PPL_ASSERT_HEAVY(OK());
82 x_end = sequence.end(), xi = x_begin; xi != x_end; ++xi) {
83 D& xi_tell = xi->tell();
89 && xi_tell.definitely_entails(yi->ask())
90 && !xi_tell.definitely_entails(yi->tell())) {
91 xi_tell.meet_assign(yi->tell());
92 changed = tell_changed =
true;
95 }
while (tell_changed);
100 PPL_ASSERT_HEAVY(OK());
104 template <
typename D>
107 bool changed =
false;
109 x_end = sequence.end(), xi = x_begin; xi != x_end; ) {
110 D& xi_ask = xi->ask();
111 D& xi_tell = xi->tell();
116 bool must_check_xi_pair =
false;
122 D& yi_ask = yi->ask();
123 D& yi_tell = yi->tell();
124 if (xi_ask.definitely_entails(yi_ask)
125 && !xi_ask.definitely_entails(yi_tell)) {
126 xi_ask.meet_assign(yi_tell);
127 must_check_xi_pair =
true;
132 }
while (ask_changed);
133 if (must_check_xi_pair) {
135 if (xi_ask.definitely_entails(xi_tell)) {
136 xi = sequence.erase(xi);
137 x_begin = sequence.begin();
138 x_end = sequence.end();
151 PPL_ASSERT_HEAVY(OK());
155 template <
typename D>
158 if (D::has_nontrivial_weakening()) {
161 x_end = sequence.end(), xi = x_begin; xi != x_end; ++xi)
164 const D& xi_ask = xi->ask();
165 const D& yi_ask = yi->ask();
166 if (xi_ask.definitely_entails(yi_ask)) {
168 new_ask.weakening_assign(yi->tell());
169 new_ask.meet_assign(yi_ask);
170 if (!new_ask.definitely_entails(xi_ask)) {
171 new_sequence.push_back(
Pair(new_ask, xi->tell()));
176 if (!new_sequence.empty()) {
178 std::copy(new_sequence.begin(), new_sequence.end(),
185 else if (!normalized) {
190 PPL_ASSERT_HEAVY(OK());
193 template <
typename D>
201 x_end = x.
end(); xi != x_end; ++xi)
203 y_end = y.
end(); yi != y_end; ++yi) {
207 ask.meet_assign(yi->ask());
208 if (!ask.definitely_entails(tell)) {
213 PPL_ASSERT_HEAVY(OK());
216 template <
typename D>
220 x_end = end(); xi != x_end; ++xi) {
225 if (!p.
tell().OK()) {
228 if (p.
ask().definitely_entails(p.
tell())) {
230 using namespace IO_Operators;
231 std::cerr <<
"Illegal agent in ask-and-tell: "
232 << p.
ask() <<
" -> " << p.
tell()
238 if (normalized && !check_normalized()) {
240 std::cerr <<
"Ask_Tell claims to be normalized, but it is not!"
248 namespace IO_Operators {
250 template <
typename D>
252 operator<<(std::ostream& s, const Ask_Tell<D>& x) {
256 else if (x.is_bottom()) {
261 x_end = x.end(); xi != x_end; ++xi)
262 s <<
"(" << xi->ask() <<
" -> " << xi->tell() <<
")";
271 #endif // !defined(PPL_Ask_Tell_templates_hh)
iterator begin()
Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-th...
const D & ask() const
Const accessor to the ask component.
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the pairs.
iterator end()
Returns the past-the-end iterator.
Sequence sequence
The sequence container holding the pairs/.
std::list< Ask_Tell_Pair< D > > Sequence
An ask-tell agent is implemented as a sequence of ask-tell pairs.
void upper_bound_assign(const Ask_Tell &y)
Assigns to *this an upper bound of *this and y.
A const_iterator on a sequence of read-only objects.
The entire library is confined to this namespace.
Sequence::const_iterator Sequence_const_iterator
Alias for the low-level const_iterator on the pairs.
const D & tell() const
Const accessor to the ask component.
bool check_normalized() const
Does the hard work of checking whether *this is normalized and returns true if and only if it is...
A pair of ask and tell descriptions.
void pair_insert(const D &a, const D &t)
The ask and tell construction on a base-level domain.
bool OK() const
Checks if all the invariants are satisfied.