spot 2.11.6.dev
Loading...
Searching...
No Matches
acc.hh
1// -*- coding: utf-8 -*-
2// Copyright (C) by the Spot authors, see the AUTHORS file for details.
3//
4// This file is part of Spot, a model checking library.
5//
6// Spot is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 3 of the License, or
9// (at your option) any later version.
10//
11// Spot is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14// License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19#pragma once
20
21#include <functional>
22#include <sstream>
23#include <vector>
24#include <iostream>
25#include <algorithm>
26#include <numeric>
27#include <bddx.h>
28#include <tuple>
29#include <spot/misc/_config.h>
30#include <spot/misc/bitset.hh>
31#include <spot/misc/trival.hh>
32
33namespace spot
34{
35 namespace internal
36 {
37 class mark_container;
38
39 template<bool>
40 struct _32acc {};
41 template<>
42 struct _32acc<true>
43 {
44 SPOT_DEPRECATED("mark_t no longer relies on unsigned, stop using value_t")
45 typedef unsigned value_t;
46 };
47 }
48
51
60 class SPOT_API acc_cond
61 {
62#ifndef SWIG
63 private:
64 [[noreturn]] static void report_too_many_sets();
65#endif
66 public:
67
82 struct mark_t :
83 public internal::_32acc<SPOT_MAX_ACCSETS == 8*sizeof(unsigned)>
84 {
85 private:
86 // configure guarantees that SPOT_MAX_ACCSETS % (8*sizeof(unsigned)) == 0
87 typedef bitset<SPOT_MAX_ACCSETS / (8*sizeof(unsigned))> _value_t;
88 _value_t id;
89
90 mark_t(_value_t id) noexcept
91 : id(id)
92 {
93 }
94
95 public:
97 mark_t() = default;
98
99#ifndef SWIG
101 template<class iterator>
102 mark_t(const iterator& begin, const iterator& end)
103 : mark_t(_value_t::zero())
104 {
105 for (iterator i = begin; i != end; ++i)
106 if (SPOT_LIKELY(*i < SPOT_MAX_ACCSETS))
107 set(*i);
108 else
109 report_too_many_sets();
110 }
111
113 mark_t(std::initializer_list<unsigned> vals)
114 : mark_t(vals.begin(), vals.end())
115 {
116 }
117
118 SPOT_DEPRECATED("use brace initialization instead")
119 mark_t(unsigned i)
120 {
121 unsigned j = 0;
122 while (i)
123 {
124 if (i & 1U)
125 this->set(j);
126 ++j;
127 i >>= 1;
128 }
129 }
130#endif
131
137 constexpr static unsigned max_accsets()
138 {
139 return SPOT_MAX_ACCSETS;
140 }
141
147 static mark_t all()
148 {
149 return mark_t(_value_t::mone());
150 }
151
152 size_t hash() const noexcept
153 {
154 std::hash<decltype(id)> h;
155 return h(id);
156 }
157
158 SPOT_DEPRECATED("compare mark_t to mark_t, not to unsigned")
159 bool operator==(unsigned o) const
160 {
161 SPOT_ASSERT(o == 0U);
162 (void)o;
163 return !id;
164 }
165
166 SPOT_DEPRECATED("compare mark_t to mark_t, not to unsigned")
167 bool operator!=(unsigned o) const
168 {
169 SPOT_ASSERT(o == 0U);
170 (void)o;
171 return !!id;
172 }
173
174 bool operator==(mark_t o) const
175 {
176 return id == o.id;
177 }
178
179 bool operator!=(mark_t o) const
180 {
181 return id != o.id;
182 }
183
184 bool operator<(mark_t o) const
185 {
186 return id < o.id;
187 }
188
189 bool operator<=(mark_t o) const
190 {
191 return id <= o.id;
192 }
193
194 bool operator>(mark_t o) const
195 {
196 return id > o.id;
197 }
198
199 bool operator>=(mark_t o) const
200 {
201 return id >= o.id;
202 }
203
204 explicit operator bool() const
205 {
206 return !!id;
207 }
208
209 bool has(unsigned u) const
210 {
211 return !!this->operator&(mark_t({0}) << u);
212 }
213
214 void set(unsigned u)
215 {
216 id.set(u);
217 }
218
219 void clear(unsigned u)
220 {
221 id.clear(u);
222 }
223
224 mark_t& operator&=(mark_t r)
225 {
226 id &= r.id;
227 return *this;
228 }
229
230 mark_t& operator|=(mark_t r)
231 {
232 id |= r.id;
233 return *this;
234 }
235
236 mark_t& operator-=(mark_t r)
237 {
238 id &= ~r.id;
239 return *this;
240 }
241
242 mark_t& operator^=(mark_t r)
243 {
244 id ^= r.id;
245 return *this;
246 }
247
248 mark_t operator&(mark_t r) const
249 {
250 return id & r.id;
251 }
252
253 mark_t operator|(mark_t r) const
254 {
255 return id | r.id;
256 }
257
258 mark_t operator-(mark_t r) const
259 {
260 return id & ~r.id;
261 }
262
263 mark_t operator~() const
264 {
265 return ~id;
266 }
267
268 mark_t operator^(mark_t r) const
269 {
270 return id ^ r.id;
271 }
272
273#if SPOT_DEBUG || defined(SWIGPYTHON)
274# define SPOT_WRAP_OP(ins) \
275 try \
276 { \
277 ins; \
278 } \
279 catch (const std::runtime_error& e) \
280 { \
281 report_too_many_sets(); \
282 }
283#else
284# define SPOT_WRAP_OP(ins) ins;
285#endif
286 mark_t operator<<(unsigned i) const
287 {
288 SPOT_WRAP_OP(return id << i);
289 }
290
291 mark_t& operator<<=(unsigned i)
292 {
293 SPOT_WRAP_OP(id <<= i; return *this);
294 }
295
296 mark_t operator>>(unsigned i) const
297 {
298 SPOT_WRAP_OP(return id >> i);
299 }
300
301 mark_t& operator>>=(unsigned i)
302 {
303 SPOT_WRAP_OP(id >>= i; return *this);
304 }
305#undef SPOT_WRAP_OP
306
307 mark_t strip(mark_t y) const
308 {
309 // strip every bit of id that is marked in y
310 // 100101110100.strip(
311 // 001011001000)
312 // == 10 1 11 100
313 // == 10111100
314
315 auto xv = id; // 100101110100
316 auto yv = y.id; // 001011001000
317
318 while (yv && xv)
319 {
320 // Mask for everything after the last 1 in y
321 auto rm = (~yv) & (yv - 1); // 000000000111
322 // Mask for everything before the last 1 in y
323 auto lm = ~(yv ^ (yv - 1)); // 111111110000
324 xv = ((xv & lm) >> 1) | (xv & rm);
325 yv = (yv & lm) >> 1;
326 }
327 return xv;
328 }
329
332 bool subset(mark_t m) const
333 {
334 return !((*this) - m);
335 }
336
339 bool proper_subset(mark_t m) const
340 {
341 return *this != m && this->subset(m);
342 }
343
345 unsigned count() const
346 {
347 return id.count();
348 }
349
354 unsigned max_set() const
355 {
356 if (id)
357 return id.highest()+1;
358 else
359 return 0;
360 }
361
366 unsigned min_set() const
367 {
368 if (id)
369 return id.lowest()+1;
370 else
371 return 0;
372 }
373
379 {
380 return id & -id;
381 }
382
384 bool is_singleton() const
385 {
386#if __GNUC__
387 /* With GCC and Clang, count() is implemented using popcount. */
388 return count() == 1;
389#else
390 return id && !(id & (id - 1));
391#endif
392 }
393
395 bool has_many() const
396 {
397#if __GNUC__
398 /* With GCC and Clang, count() is implemented using popcount. */
399 return count() > 1;
400#else
401 return !!(id & (id - 1));
402#endif
403 }
404
408 mark_t& remove_some(unsigned n)
409 {
410 while (n--)
411 id &= id - 1;
412 return *this;
413 }
414
416 template<class iterator>
417 void fill(iterator here) const
418 {
419 auto a = *this;
420 unsigned level = 0;
421 while (a)
422 {
423 if (a.has(0))
424 *here++ = level;
425 ++level;
426 a >>= 1;
427 }
428 }
429
431 spot::internal::mark_container sets() const;
432
433 SPOT_API
434 friend std::ostream& operator<<(std::ostream& os, mark_t m);
435
436 std::string as_string() const
437 {
438 std::ostringstream os;
439 os << *this;
440 return os.str();
441 }
442 };
443
445 enum class acc_op : unsigned short
446 { Inf, Fin, InfNeg, FinNeg, And, Or };
447
456 {
457 mark_t mark;
458 struct {
459 acc_op op; // Operator
460 unsigned short size; // Size of the subtree (number of acc_word),
461 // not counting this node.
462 } sub;
463 };
464
477 struct SPOT_API acc_code: public std::vector<acc_word>
478 {
480 unit_propagation();
481
482 bool operator==(const acc_code& other) const
483 {
484 // We have two ways to represent t, unfortunately.
485 if (is_t() && other.is_t())
486 return true;
487 unsigned pos = size();
488 if (other.size() != pos)
489 return false;
490 while (pos > 0)
491 {
492 auto op = (*this)[pos - 1].sub.op;
493 auto sz = (*this)[pos - 1].sub.size;
494 if (other[pos - 1].sub.op != op ||
495 other[pos - 1].sub.size != sz)
496 return false;
497 switch (op)
498 {
499 case acc_cond::acc_op::And:
500 case acc_cond::acc_op::Or:
501 --pos;
502 break;
503 case acc_cond::acc_op::Inf:
504 case acc_cond::acc_op::InfNeg:
505 case acc_cond::acc_op::Fin:
506 case acc_cond::acc_op::FinNeg:
507 pos -= 2;
508 if (other[pos].mark != (*this)[pos].mark)
509 return false;
510 break;
511 }
512 }
513 return true;
514 };
515
516 bool operator<(const acc_code& other) const
517 {
518 // We have two ways to represent t, unfortunately.
519 if (is_t() && other.is_t())
520 return false;
521 unsigned pos = size();
522 auto osize = other.size();
523 if (pos < osize)
524 return true;
525 if (pos > osize)
526 return false;
527 while (pos > 0)
528 {
529 auto op = (*this)[pos - 1].sub.op;
530 auto oop = other[pos - 1].sub.op;
531 if (op < oop)
532 return true;
533 if (op > oop)
534 return false;
535 auto sz = (*this)[pos - 1].sub.size;
536 auto osz = other[pos - 1].sub.size;
537 if (sz < osz)
538 return true;
539 if (sz > osz)
540 return false;
541 switch (op)
542 {
543 case acc_cond::acc_op::And:
544 case acc_cond::acc_op::Or:
545 --pos;
546 break;
547 case acc_cond::acc_op::Inf:
548 case acc_cond::acc_op::InfNeg:
549 case acc_cond::acc_op::Fin:
550 case acc_cond::acc_op::FinNeg:
551 {
552 pos -= 2;
553 auto m = (*this)[pos].mark;
554 auto om = other[pos].mark;
555 if (m < om)
556 return true;
557 if (m > om)
558 return false;
559 break;
560 }
561 }
562 }
563 return false;
564 }
565
566 bool operator>(const acc_code& other) const
567 {
568 return other < *this;
569 }
570
571 bool operator<=(const acc_code& other) const
572 {
573 return !(other < *this);
574 }
575
576 bool operator>=(const acc_code& other) const
577 {
578 return !(*this < other);
579 }
580
581 bool operator!=(const acc_code& other) const
582 {
583 return !(*this == other);
584 }
585
590 bool is_t() const
591 {
592 // We store "t" as an empty condition, or as Inf({}).
593 unsigned s = size();
594 return s == 0 || ((*this)[s - 1].sub.op == acc_op::Inf
595 && !((*this)[s - 2].mark));
596 }
597
604 bool is_f() const
605 {
606 // We store "f" as Fin({}).
607 unsigned s = size();
608 return s > 1
609 && (*this)[s - 1].sub.op == acc_op::Fin && !((*this)[s - 2].mark);
610 }
611
618 static acc_code f()
619 {
620 acc_code res;
621 res.resize(2);
622 res[0].mark = {};
623 res[1].sub.op = acc_op::Fin;
624 res[1].sub.size = 1;
625 return res;
626 }
627
632 static acc_code t()
633 {
634 return {};
635 }
636
645 {
646 acc_code res;
647 res.resize(2);
648 res[0].mark = m;
649 res[1].sub.op = acc_op::Fin;
650 res[1].sub.size = 1;
651 return res;
652 }
653
654 static acc_code fin(std::initializer_list<unsigned> vals)
655 {
656 return fin(mark_t(vals));
657 }
659
677 {
678 acc_code res;
679 res.resize(2);
680 res[0].mark = m;
681 res[1].sub.op = acc_op::FinNeg;
682 res[1].sub.size = 1;
683 return res;
684 }
685
686 static acc_code fin_neg(std::initializer_list<unsigned> vals)
687 {
688 return fin_neg(mark_t(vals));
689 }
691
701 {
702 acc_code res;
703 res.resize(2);
704 res[0].mark = m;
705 res[1].sub.op = acc_op::Inf;
706 res[1].sub.size = 1;
707 return res;
708 }
709
710 static acc_code inf(std::initializer_list<unsigned> vals)
711 {
712 return inf(mark_t(vals));
713 }
715
733 {
734 acc_code res;
735 res.resize(2);
736 res[0].mark = m;
737 res[1].sub.op = acc_op::InfNeg;
738 res[1].sub.size = 1;
739 return res;
740 }
741
742 static acc_code inf_neg(std::initializer_list<unsigned> vals)
743 {
744 return inf_neg(mark_t(vals));
745 }
747
752 {
753 return inf({0});
754 }
755
760 {
761 return fin({0});
762 }
763
769 static acc_code generalized_buchi(unsigned n)
770 {
771 if (n == 0)
772 return inf({});
773 acc_cond::mark_t m = mark_t::all();
774 m >>= mark_t::max_accsets() - n;
775 return inf(m);
776 }
777
784 {
785 if (n == 0)
786 return fin({});
787 acc_cond::mark_t m = mark_t::all();
788 m >>= mark_t::max_accsets() - n;
789 return fin(m);
790 }
791
796 static acc_code rabin(unsigned n)
797 {
798 acc_cond::acc_code res = f();
799 while (n > 0)
800 {
801 res |= inf({2*n - 1}) & fin({2*n - 2});
802 --n;
803 }
804 return res;
805 }
806
811 static acc_code streett(unsigned n)
812 {
813 acc_cond::acc_code res = t();
814 while (n > 0)
815 {
816 res &= inf({2*n - 1}) | fin({2*n - 2});
817 --n;
818 }
819 return res;
820 }
821
834 template<class Iterator>
835 static acc_code generalized_rabin(Iterator begin, Iterator end)
836 {
837 acc_cond::acc_code res = f();
838 unsigned n = 0;
839 for (Iterator i = begin; i != end; ++i)
840 {
841 unsigned f = n++;
842 acc_cond::mark_t m = {};
843 for (unsigned ni = *i; ni > 0; --ni)
844 m.set(n++);
845 auto pair = inf(m) & fin({f});
846 std::swap(pair, res);
847 res |= std::move(pair);
848 }
849 return res;
850 }
851
859 static acc_code parity(bool is_max, bool is_odd, unsigned sets);
860 static acc_code parity_max(bool is_odd, unsigned sets)
861 {
862 return parity(true, is_odd, sets);
863 }
864 static acc_code parity_max_odd(unsigned sets)
865 {
866 return parity_max(true, sets);
867 }
868 static acc_code parity_max_even(unsigned sets)
869 {
870 return parity_max(false, sets);
871 }
872 static acc_code parity_min(bool is_odd, unsigned sets)
873 {
874 return parity(false, is_odd, sets);
875 }
876 static acc_code parity_min_odd(unsigned sets)
877 {
878 return parity_min(true, sets);
879 }
880 static acc_code parity_min_even(unsigned sets)
881 {
882 return parity_min(false, sets);
883 }
885
902 static acc_code random(unsigned n, double reuse = 0.0);
903
906 {
907 if (is_t() || r.is_f())
908 {
909 *this = r;
910 return *this;
911 }
912 if (is_f() || r.is_t())
913 return *this;
914 unsigned s = size() - 1;
915 unsigned rs = r.size() - 1;
916 // We want to group all Inf(x) operators:
917 // Inf(a) & Inf(b) = Inf(a & b)
918 if (((*this)[s].sub.op == acc_op::Inf
919 && r[rs].sub.op == acc_op::Inf)
920 || ((*this)[s].sub.op == acc_op::InfNeg
921 && r[rs].sub.op == acc_op::InfNeg))
922 {
923 (*this)[s - 1].mark |= r[rs - 1].mark;
924 return *this;
925 }
926
927 // In the more complex scenarios, left and right may both
928 // be conjunctions, and Inf(x) might be a member of each
929 // side. Find it if it exists.
930 // left_inf points to the left Inf mark if any.
931 // right_inf points to the right Inf mark if any.
932 acc_word* left_inf = nullptr;
933 if ((*this)[s].sub.op == acc_op::And)
934 {
935 auto start = &(*this)[s] - (*this)[s].sub.size;
936 auto pos = &(*this)[s] - 1;
937 pop_back();
938 while (pos > start)
939 {
940 if (pos->sub.op == acc_op::Inf)
941 {
942 left_inf = pos - 1;
943 break;
944 }
945 pos -= pos->sub.size + 1;
946 }
947 }
948 else if ((*this)[s].sub.op == acc_op::Inf)
949 {
950 left_inf = &(*this)[s - 1];
951 }
952
953 const acc_word* right_inf = nullptr;
954 auto right_end = &r.back();
955 if (right_end->sub.op == acc_op::And)
956 {
957 auto start = &r[0];
958 auto pos = --right_end;
959 while (pos > start)
960 {
961 if (pos->sub.op == acc_op::Inf)
962 {
963 right_inf = pos - 1;
964 break;
965 }
966 pos -= pos->sub.size + 1;
967 }
968 }
969 else if (right_end->sub.op == acc_op::Inf)
970 {
971 right_inf = right_end - 1;
972 }
973
974 acc_cond::mark_t carry = {};
975 if (left_inf && right_inf)
976 {
977 carry = left_inf->mark;
978 auto pos = left_inf - &(*this)[0];
979 erase(begin() + pos, begin() + pos + 2);
980 }
981 auto sz = size();
982 insert(end(), &r[0], right_end + 1);
983 if (carry)
984 (*this)[sz + (right_inf - &r[0])].mark |= carry;
985
986 acc_word w;
987 w.sub.op = acc_op::And;
988 w.sub.size = size();
989 emplace_back(w);
990 return *this;
991 }
992
995 {
996 acc_code res = *this;
997 res &= r;
998 return res;
999 }
1000
1001#ifndef SWIG
1004 {
1005 acc_code res = *this;
1006 res &= r;
1007 return res;
1008 }
1009#endif // SWIG
1010
1013 {
1014 if (is_t() || r.is_f())
1015 return *this;
1016 if (is_f() || r.is_t())
1017 {
1018 *this = r;
1019 return *this;
1020 }
1021 unsigned s = size() - 1;
1022 unsigned rs = r.size() - 1;
1023 // Fin(a) | Fin(b) = Fin(a | b)
1024 if (((*this)[s].sub.op == acc_op::Fin
1025 && r[rs].sub.op == acc_op::Fin)
1026 || ((*this)[s].sub.op == acc_op::FinNeg
1027 && r[rs].sub.op == acc_op::FinNeg))
1028 {
1029 (*this)[s - 1].mark |= r[rs - 1].mark;
1030 return *this;
1031 }
1032
1033 // In the more complex scenarios, left and right may both
1034 // be disjunctions, and Fin(x) might be a member of each
1035 // side. Find it if it exists.
1036 // left_inf points to the left Inf mark if any.
1037 // right_inf points to the right Inf mark if any.
1038 acc_word* left_fin = nullptr;
1039 if ((*this)[s].sub.op == acc_op::Or)
1040 {
1041 auto start = &(*this)[s] - (*this)[s].sub.size;
1042 auto pos = &(*this)[s] - 1;
1043 pop_back();
1044 while (pos > start)
1045 {
1046 if (pos->sub.op == acc_op::Fin)
1047 {
1048 left_fin = pos - 1;
1049 break;
1050 }
1051 pos -= pos->sub.size + 1;
1052 }
1053 }
1054 else if ((*this)[s].sub.op == acc_op::Fin)
1055 {
1056 left_fin = &(*this)[s - 1];
1057 }
1058
1059 const acc_word* right_fin = nullptr;
1060 auto right_end = &r.back();
1061 if (right_end->sub.op == acc_op::Or)
1062 {
1063 auto start = &r[0];
1064 auto pos = --right_end;
1065 while (pos > start)
1066 {
1067 if (pos->sub.op == acc_op::Fin)
1068 {
1069 right_fin = pos - 1;
1070 break;
1071 }
1072 pos -= pos->sub.size + 1;
1073 }
1074 }
1075 else if (right_end->sub.op == acc_op::Fin)
1076 {
1077 right_fin = right_end - 1;
1078 }
1079
1080 acc_cond::mark_t carry = {};
1081 if (left_fin && right_fin)
1082 {
1083 carry = left_fin->mark;
1084 auto pos = (left_fin - &(*this)[0]);
1085 this->erase(begin() + pos, begin() + pos + 2);
1086 }
1087 auto sz = size();
1088 insert(end(), &r[0], right_end + 1);
1089 if (carry)
1090 (*this)[sz + (right_fin - &r[0])].mark |= carry;
1091 acc_word w;
1092 w.sub.op = acc_op::Or;
1093 w.sub.size = size();
1094 emplace_back(w);
1095 return *this;
1096 }
1097
1098#ifndef SWIG
1101 {
1102 acc_code res = *this;
1103 res |= r;
1104 return res;
1105 }
1106#endif // SWIG
1107
1110 {
1111 acc_code res = *this;
1112 res |= r;
1113 return res;
1114 }
1115
1121 acc_code& operator<<=(unsigned sets)
1122 {
1123 if (SPOT_UNLIKELY(sets >= mark_t::max_accsets()))
1124 report_too_many_sets();
1125 if (empty())
1126 return *this;
1127 unsigned pos = size();
1128 do
1129 {
1130 switch ((*this)[pos - 1].sub.op)
1131 {
1132 case acc_cond::acc_op::And:
1133 case acc_cond::acc_op::Or:
1134 --pos;
1135 break;
1136 case acc_cond::acc_op::Inf:
1137 case acc_cond::acc_op::InfNeg:
1138 case acc_cond::acc_op::Fin:
1139 case acc_cond::acc_op::FinNeg:
1140 pos -= 2;
1141 (*this)[pos].mark <<= sets;
1142 break;
1143 }
1144 }
1145 while (pos > 0);
1146 return *this;
1147 }
1148
1152 acc_code operator<<(unsigned sets) const
1153 {
1154 acc_code res = *this;
1155 res <<= sets;
1156 return res;
1157 }
1158
1165 bool is_dnf() const;
1166
1173 bool is_cnf() const;
1174
1186
1194
1199 bdd to_bdd(const bdd* map) const;
1200
1209 std::vector<acc_code> top_disjuncts() const;
1210
1219 std::vector<acc_code> top_conjuncts() const;
1220
1232
1247
1261
1274
1279 int fin_one() const;
1280
1301 std::pair<int, acc_code> fin_one_extract() const;
1302
1321 std::tuple<int, acc_cond::acc_code, acc_cond::acc_code>
1323 std::tuple<int, acc_cond::acc_code, acc_cond::acc_code>
1326
1339 std::vector<std::vector<int>>
1340 missing(mark_t inf, bool accepting) const;
1341
1344 bool accepting(mark_t inf) const;
1345
1351 bool inf_satisfiable(mark_t inf) const;
1352
1365 mark_t always_present) const;
1366
1377 std::vector<unsigned> symmetries() const;
1378
1392 acc_code remove(acc_cond::mark_t rem, bool missing) const;
1393
1398 acc_code strip(acc_cond::mark_t rem, bool missing) const;
1401
1404
1416 std::vector<std::pair<acc_cond::mark_t, acc_cond::mark_t>>
1418
1426
1428 std::pair<acc_cond::mark_t, acc_cond::mark_t> used_inf_fin_sets() const;
1429
1434 std::ostream&
1435 to_html(std::ostream& os,
1436 std::function<void(std::ostream&, int)>
1437 set_printer = nullptr) const;
1438
1443 std::ostream&
1444 to_text(std::ostream& os,
1445 std::function<void(std::ostream&, int)>
1446 set_printer = nullptr) const;
1447
1452 std::ostream&
1453 to_latex(std::ostream& os,
1454 std::function<void(std::ostream&, int)>
1455 set_printer = nullptr) const;
1456
1479 acc_code(const char* input);
1480
1485 {
1486 }
1487
1489 acc_code(const acc_word* other)
1490 : std::vector<acc_word>(other - other->sub.size, other + 1)
1491 {
1492 }
1493
1495 SPOT_API
1496 friend std::ostream& operator<<(std::ostream& os, const acc_code& code);
1497 };
1498
1506 acc_cond(unsigned n_sets = 0, const acc_code& code = {})
1507 : num_(0U), all_({}), code_(code)
1508 {
1509 add_sets(n_sets);
1510 uses_fin_acceptance_ = check_fin_acceptance();
1511 }
1512
1517 acc_cond(const acc_code& code)
1518 : num_(0U), all_({}), code_(code)
1519 {
1520 add_sets(code.used_sets().max_set());
1521 uses_fin_acceptance_ = check_fin_acceptance();
1522 }
1523
1526 : num_(o.num_), all_(o.all_), code_(o.code_),
1527 uses_fin_acceptance_(o.uses_fin_acceptance_)
1528 {
1529 }
1530
1533 {
1534 num_ = o.num_;
1535 all_ = o.all_;
1536 code_ = o.code_;
1537 uses_fin_acceptance_ = o.uses_fin_acceptance_;
1538 return *this;
1539 }
1540
1541 ~acc_cond()
1542 {
1543 }
1544
1548 void set_acceptance(const acc_code& code)
1549 {
1550 code_ = code;
1551 uses_fin_acceptance_ = check_fin_acceptance();
1552 }
1553
1556 {
1557 return code_;
1558 }
1559
1562 {
1563 return code_;
1564 }
1565
1566 bool operator==(const acc_cond& other) const
1567 {
1568 if (other.num_sets() != num_)
1569 return false;
1570 const acc_code& ocode = other.get_acceptance();
1571 // We have two ways to represent t, unfortunately.
1572 return (ocode == code_ || (ocode.is_t() && code_.is_t()));
1573 }
1574
1575 bool operator!=(const acc_cond& other) const
1576 {
1577 return !(*this == other);
1578 }
1579
1582 {
1583 return uses_fin_acceptance_;
1584 }
1585
1587 bool is_t() const
1588 {
1589 return code_.is_t();
1590 }
1591
1596 bool is_all() const
1597 {
1598 return num_ == 0 && is_t();
1599 }
1600
1602 bool is_f() const
1603 {
1604 return code_.is_f();
1605 }
1606
1611 bool is_none() const
1612 {
1613 return num_ == 0 && is_f();
1614 }
1615
1620 bool is_buchi() const
1621 {
1622 unsigned s = code_.size();
1623 return num_ == 1 &&
1624 s == 2 && code_[1].sub.op == acc_op::Inf && code_[0].mark == all_sets();
1625 }
1626
1631 bool is_co_buchi() const
1632 {
1633 return num_ == 1 && is_generalized_co_buchi();
1634 }
1635
1639 {
1640 set_acceptance(inf(all_sets()));
1641 }
1642
1646 {
1647 set_acceptance(fin(all_sets()));
1648 }
1649
1655 {
1656 unsigned s = code_.size();
1657 return (s == 0 && num_ == 0) || (s == 2 && code_[1].sub.op == acc_op::Inf
1658 && code_[0].mark == all_sets());
1659 }
1660
1666 {
1667 unsigned s = code_.size();
1668 return (s == 2 &&
1669 code_[1].sub.op == acc_op::Fin && code_[0].mark == all_sets());
1670 }
1671
1683 int is_rabin() const;
1684
1696 int is_streett() const;
1697
1707 struct SPOT_API rs_pair
1708 {
1709#ifndef SWIG
1710 rs_pair() = default;
1711 rs_pair(const rs_pair&) = default;
1712 rs_pair& operator=(const rs_pair&) = default;
1713#endif
1714
1715 rs_pair(acc_cond::mark_t fin, acc_cond::mark_t inf) noexcept:
1716 fin(fin),
1717 inf(inf)
1718 {}
1719 acc_cond::mark_t fin;
1720 acc_cond::mark_t inf;
1721
1722 bool operator==(rs_pair o) const
1723 {
1724 return fin == o.fin && inf == o.inf;
1725 }
1726 bool operator!=(rs_pair o) const
1727 {
1728 return fin != o.fin || inf != o.inf;
1729 }
1730 bool operator<(rs_pair o) const
1731 {
1732 return fin < o.fin || (!(o.fin < fin) && inf < o.inf);
1733 }
1734 bool operator<=(rs_pair o) const
1735 {
1736 return !(o < *this);
1737 }
1738 bool operator>(rs_pair o) const
1739 {
1740 return o < *this;
1741 }
1742 bool operator>=(rs_pair o) const
1743 {
1744 return !(*this < o);
1745 }
1746 };
1757 bool is_streett_like(std::vector<rs_pair>& pairs) const;
1758
1769 bool is_rabin_like(std::vector<rs_pair>& pairs) const;
1770
1780 bool is_generalized_rabin(std::vector<unsigned>& pairs) const;
1781
1794 bool is_generalized_streett(std::vector<unsigned>& pairs) const;
1795
1805 bool is_parity(bool& max, bool& odd, bool equiv = false) const;
1806
1807
1810 bool is_parity() const
1811 {
1812 bool max;
1813 bool odd;
1814 return is_parity(max, odd);
1815 }
1816
1825 {
1826 return acc_cond(num_, code_.unit_propagation());
1827 }
1828
1829 // Return (true, m) if there exist some acceptance mark m that
1830 // does not satisfy the acceptance condition. Return (false, 0U)
1831 // otherwise.
1832 std::pair<bool, acc_cond::mark_t> unsat_mark() const
1833 {
1834 return sat_unsat_mark(false);
1835 }
1836 // Return (true, m) if there exist some acceptance mark m that
1837 // does satisfy the acceptance condition. Return (false, 0U)
1838 // otherwise.
1839 std::pair<bool, acc_cond::mark_t> sat_mark() const
1840 {
1841 return sat_unsat_mark(true);
1842 }
1843
1844 protected:
1845 bool check_fin_acceptance() const;
1846 std::pair<bool, acc_cond::mark_t> sat_unsat_mark(bool) const;
1847
1848 public:
1857 static acc_code inf(mark_t mark)
1858 {
1859 return acc_code::inf(mark);
1860 }
1861
1862 static acc_code inf(std::initializer_list<unsigned> vals)
1863 {
1864 return inf(mark_t(vals.begin(), vals.end()));
1865 }
1867
1885 {
1886 return acc_code::inf_neg(mark);
1887 }
1888
1889 static acc_code inf_neg(std::initializer_list<unsigned> vals)
1890 {
1891 return inf_neg(mark_t(vals.begin(), vals.end()));
1892 }
1894
1902 static acc_code fin(mark_t mark)
1903 {
1904 return acc_code::fin(mark);
1905 }
1906
1907 static acc_code fin(std::initializer_list<unsigned> vals)
1908 {
1909 return fin(mark_t(vals.begin(), vals.end()));
1910 }
1912
1930 {
1931 return acc_code::fin_neg(mark);
1932 }
1933
1934 static acc_code fin_neg(std::initializer_list<unsigned> vals)
1935 {
1936 return fin_neg(mark_t(vals.begin(), vals.end()));
1937 }
1939
1944 unsigned add_sets(unsigned num)
1945 {
1946 if (num == 0)
1947 return -1U;
1948 unsigned j = num_;
1949 num += j;
1950 if (num > mark_t::max_accsets())
1951 report_too_many_sets();
1952 // Make sure we do not update if we raised an exception.
1953 num_ = num;
1954 all_ = all_sets_();
1955 return j;
1956 }
1957
1962 unsigned add_set()
1963 {
1964 return add_sets(1);
1965 }
1966
1968 mark_t mark(unsigned u) const
1969 {
1970 SPOT_ASSERT(u < num_sets());
1971 return mark_t({u});
1972 }
1973
1978 mark_t comp(const mark_t& l) const
1979 {
1980 return all_ ^ l;
1981 }
1982
1985 {
1986 return all_;
1987 }
1988
1991 bool accepting(mark_t inf) const
1992 {
1993 return code_.accepting(inf);
1994 }
1995
2001 bool inf_satisfiable(mark_t inf) const
2002 {
2003 return code_.inf_satisfiable(inf);
2004 }
2005
2017 trival maybe_accepting(mark_t infinitely_often, mark_t always_present) const
2018 {
2019 return code_.maybe_accepting(infinitely_often, always_present);
2020 }
2021
2036
2037 // Deprecated since Spot 2.8
2038 SPOT_DEPRECATED("Use operator<< instead.")
2039 std::ostream& format(std::ostream& os, mark_t m) const
2040 {
2041 if (!m)
2042 return os;
2043 return os << m;
2044 }
2045
2046 // Deprecated since Spot 2.8
2047 SPOT_DEPRECATED("Use operator<< or mark_t::as_string() instead.")
2048 std::string format(mark_t m) const
2049 {
2050 std::ostringstream os;
2051 if (m)
2052 os << m;
2053 return os.str();
2054 }
2055
2057 unsigned num_sets() const
2058 {
2059 return num_;
2060 }
2061
2069 template<class iterator>
2070 mark_t useless(iterator begin, iterator end) const
2071 {
2072 mark_t u = {}; // The set of useless sets
2073 for (unsigned x = 0; x < num_; ++x)
2074 {
2075 // Skip sets that are already known to be useless.
2076 if (u.has(x))
2077 continue;
2078 auto all = comp(u | mark_t({x}));
2079 // Iterate over all mark_t, and keep track of
2080 // set numbers that always appear with x.
2081 for (iterator y = begin; y != end; ++y)
2082 {
2083 const mark_t& v = *y;
2084 if (v.has(x))
2085 {
2086 all &= v;
2087 if (!all)
2088 break;
2089 }
2090 }
2091 u |= all;
2092 }
2093 return u;
2094 }
2095
2109 acc_cond remove(mark_t rem, bool missing) const
2110 {
2111 return {num_sets(), code_.remove(rem, missing)};
2112 }
2113
2118 acc_cond strip(mark_t rem, bool missing) const
2119 {
2120 return
2121 { num_sets() - (all_sets() & rem).count(), code_.strip(rem, missing) };
2122 }
2123
2126 {
2127 return {num_sets(), code_.force_inf(m)};
2128 }
2129
2133 {
2134 return {num_sets(), code_.remove(all_sets() - rem, true)};
2135 }
2136
2148 std::string name(const char* fmt = "alo") const;
2149
2164 {
2165 return code_.fin_unit();
2166 }
2167
2181 {
2182 return code_.mafins();
2183 }
2184
2197 {
2198 return code_.inf_unit();
2199 }
2200
2205 int fin_one() const
2206 {
2207 return code_.fin_one();
2208 }
2209
2230 std::pair<int, acc_cond> fin_one_extract() const
2231 {
2232 auto [f, c] = code_.fin_one_extract();
2233 return {f, {num_sets(), std::move(c)}};
2234 }
2235
2254 std::tuple<int, acc_cond, acc_cond>
2256 {
2257 auto [f, l, r] = code_.fin_unit_one_split();
2258 return {f, {num_sets(), std::move(l)}, {num_sets(), std::move(r)}};
2259 }
2260 std::tuple<int, acc_cond, acc_cond>
2262 {
2263 auto [f, l, r] = code_.fin_unit_one_split_improved();
2264 return {f, {num_sets(), std::move(l)}, {num_sets(), std::move(r)}};
2265 }
2267
2276 std::vector<acc_cond> top_disjuncts() const;
2277
2286 std::vector<acc_cond> top_conjuncts() const;
2287
2288 protected:
2289 mark_t all_sets_() const
2290 {
2291 return mark_t::all() >> (spot::acc_cond::mark_t::max_accsets() - num_);
2292 }
2293
2294 unsigned num_;
2295 mark_t all_;
2296 acc_code code_;
2297 bool uses_fin_acceptance_ = false;
2298
2299 };
2300
2302 typedef std::vector<acc_cond::rs_pair> rs_pairs;
2303
2304 // Creates view of pairs 'p' with restriction only to marks in 'm'
2305 explicit rs_pairs_view(const rs_pairs& p, const acc_cond::mark_t& m)
2306 : pairs_(p), view_marks_(m) {}
2307
2308 // Creates view of pairs without restriction to marks
2309 explicit rs_pairs_view(const rs_pairs& p)
2311
2312 acc_cond::mark_t infs() const
2313 {
2314 return do_view([&](const acc_cond::rs_pair& p)
2315 {
2316 return visible(p.inf) ? p.inf : acc_cond::mark_t({});
2317 });
2318 }
2319
2320 acc_cond::mark_t fins() const
2321 {
2322 return do_view([&](const acc_cond::rs_pair& p)
2323 {
2324 return visible(p.fin) ? p.fin : acc_cond::mark_t({});
2325 });
2326 }
2327
2328 acc_cond::mark_t fins_alone() const
2329 {
2330 return do_view([&](const acc_cond::rs_pair& p)
2331 {
2332 return !visible(p.inf) && visible(p.fin) ? p.fin
2333 : acc_cond::mark_t({});
2334 });
2335 }
2336
2337 acc_cond::mark_t infs_alone() const
2338 {
2339 return do_view([&](const acc_cond::rs_pair& p)
2340 {
2341 return !visible(p.fin) && visible(p.inf) ? p.inf
2342 : acc_cond::mark_t({});
2343 });
2344 }
2345
2346 acc_cond::mark_t paired_with_fin(unsigned mark) const
2347 {
2348 acc_cond::mark_t res = {};
2349 for (const auto& p: pairs_)
2350 if (p.fin.has(mark) && visible(p.fin) && visible(p.inf))
2351 res |= p.inf;
2352 return res;
2353 }
2354
2355 const rs_pairs& pairs() const
2356 {
2357 return pairs_;
2358 }
2359
2360 private:
2361 template<typename filter>
2362 acc_cond::mark_t do_view(const filter& filt) const
2363 {
2364 acc_cond::mark_t res = {};
2365 for (const auto& p: pairs_)
2366 res |= filt(p);
2367 return res;
2368 }
2369
2370 bool visible(const acc_cond::mark_t& v) const
2371 {
2372 return !!(view_marks_ & v);
2373 }
2374
2375 const rs_pairs& pairs_;
2376 acc_cond::mark_t view_marks_;
2377 };
2378
2379
2380 SPOT_API
2381 std::ostream& operator<<(std::ostream& os, const acc_cond& acc);
2382
2384
2385 namespace internal
2386 {
2387 class SPOT_API mark_iterator
2388 {
2389 public:
2390 typedef unsigned value_type;
2391 typedef const value_type& reference;
2392 typedef const value_type* pointer;
2393 typedef std::ptrdiff_t difference_type;
2394 typedef std::forward_iterator_tag iterator_category;
2395
2396 mark_iterator() noexcept
2397 : m_({})
2398 {
2399 }
2400
2401 mark_iterator(acc_cond::mark_t m) noexcept
2402 : m_(m)
2403 {
2404 }
2405
2406 bool operator==(mark_iterator m) const
2407 {
2408 return m_ == m.m_;
2409 }
2410
2411 bool operator!=(mark_iterator m) const
2412 {
2413 return m_ != m.m_;
2414 }
2415
2416 value_type operator*() const
2417 {
2418 SPOT_ASSERT(m_);
2419 return m_.min_set() - 1;
2420 }
2421
2422 mark_iterator& operator++()
2423 {
2424 m_.clear(this->operator*());
2425 return *this;
2426 }
2427
2428 mark_iterator operator++(int)
2429 {
2430 mark_iterator it = *this;
2431 ++(*this);
2432 return it;
2433 }
2434 private:
2435 acc_cond::mark_t m_;
2436 };
2437
2438 class SPOT_API mark_container
2439 {
2440 public:
2441 mark_container(spot::acc_cond::mark_t m) noexcept
2442 : m_(m)
2443 {
2444 }
2445
2446 mark_iterator begin() const
2447 {
2448 return {m_};
2449 }
2450 mark_iterator end() const
2451 {
2452 return {};
2453 }
2454 private:
2456 };
2457 }
2458
2459 inline spot::internal::mark_container acc_cond::mark_t::sets() const
2460 {
2461 return {*this};
2462 }
2463}
2464
2465namespace std
2466{
2467 template<>
2468 struct hash<spot::acc_cond::mark_t>
2469 {
2470 size_t operator()(spot::acc_cond::mark_t m) const noexcept
2471 {
2472 return m.hash();
2473 }
2474 };
2475}
An acceptance condition.
Definition acc.hh:61
const acc_code & get_acceptance() const
Retrieve the acceptance formula.
Definition acc.hh:1555
bool inf_satisfiable(mark_t inf) const
Assuming that we will visit at least all sets in inf, is there any chance that we will satisfy the co...
Definition acc.hh:2001
mark_t all_sets() const
Construct a mark_t with all declared sets.
Definition acc.hh:1984
static acc_code fin_neg(mark_t mark)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition acc.hh:1929
mark_t mafins() const
Find a Fin(i) that is mandatory.
Definition acc.hh:2180
static acc_code inf_neg(mark_t mark)
Construct a generalized Büchi acceptance for complemented sets.
Definition acc.hh:1884
acc_cond unit_propagation()
Remove superfluous Fin and Inf by unit propagation.
Definition acc.hh:1824
void set_generalized_co_buchi()
Change the acceptance condition to generalized-co-Büchi, over all declared sets.
Definition acc.hh:1645
std::pair< int, acc_cond > fin_one_extract() const
Return one acceptance set i that appears as Fin(i) in the condition, and all disjuncts containing it ...
Definition acc.hh:2230
static acc_code fin(mark_t mark)
Construct a generalized co-Büchi acceptance.
Definition acc.hh:1902
bool is_co_buchi() const
Whether the acceptance condition is "co-Büchi".
Definition acc.hh:1631
bool accepting(mark_t inf) const
Check whether visiting exactly all sets inf infinitely often satisfies the acceptance condition.
Definition acc.hh:1991
static acc_code inf(mark_t mark)
Construct a generalized Büchi acceptance.
Definition acc.hh:1857
bool is_generalized_buchi() const
Whether the acceptance condition is "generalized-Büchi".
Definition acc.hh:1654
static acc_code fin_neg(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition acc.hh:1934
static acc_code inf(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance.
Definition acc.hh:1862
unsigned add_set()
Add a single set to the acceptance condition.
Definition acc.hh:1962
bool is_parity(bool &max, bool &odd, bool equiv=false) const
check is the acceptance condition matches one of the four type of parity acceptance defined in the HO...
std::vector< acc_cond > top_disjuncts() const
Return the top-level disjuncts.
mark_t mark(unsigned u) const
Build a mark_t with a single set.
Definition acc.hh:1968
void set_generalized_buchi()
Change the acceptance condition to generalized-Büchi, over all declared sets.
Definition acc.hh:1638
acc_cond force_inf(mark_t m) const
For all x in m, replaces Fin(x) by false.
Definition acc.hh:2125
acc_cond remove(mark_t rem, bool missing) const
Remove all the acceptance sets in rem.
Definition acc.hh:2109
acc_op
Operators for acceptance formulas.
Definition acc.hh:446
acc_cond(unsigned n_sets=0, const acc_code &code={})
Build an acceptance condition.
Definition acc.hh:1506
unsigned add_sets(unsigned num)
Add more sets to the acceptance condition.
Definition acc.hh:1944
bool is_parity() const
check is the acceptance condition matches one of the four type of parity acceptance defined in the HO...
Definition acc.hh:1810
bool is_t() const
Whether the acceptance formula is "t" (true)
Definition acc.hh:1587
bool is_generalized_rabin(std::vector< unsigned > &pairs) const
Is the acceptance condition generalized-Rabin?
mark_t comp(const mark_t &l) const
Complement a mark_t.
Definition acc.hh:1978
acc_cond & operator=(const acc_cond &o)
Copy an acceptance condition.
Definition acc.hh:1532
acc_code & get_acceptance()
Retrieve the acceptance formula.
Definition acc.hh:1561
static acc_code fin(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance.
Definition acc.hh:1907
bool is_generalized_co_buchi() const
Whether the acceptance condition is "generalized-co-Büchi".
Definition acc.hh:1665
std::tuple< int, acc_cond, acc_cond > fin_unit_one_split_improved() const
Split an acceptance condition, trying to select one unit-Fin.
Definition acc.hh:2261
acc_cond restrict_to(mark_t rem) const
Restrict an acceptance condition to a subset of set numbers that are occurring at some point.
Definition acc.hh:2132
trival maybe_accepting(mark_t infinitely_often, mark_t always_present) const
Check potential acceptance of an SCC.
Definition acc.hh:2017
std::string name(const char *fmt="alo") const
Return the name of this acceptance condition, in the specified format.
bool is_none() const
Whether the acceptance condition is "none".
Definition acc.hh:1611
void set_acceptance(const acc_code &code)
Change the acceptance formula.
Definition acc.hh:1548
int is_rabin() const
Check if the acceptance condition matches the Rabin acceptance of the HOA format.
bool is_rabin_like(std::vector< rs_pair > &pairs) const
Test whether an acceptance condition is Rabin-like and returns each Rabin pair in an std::vector<rs_p...
mark_t accepting_sets(mark_t inf) const
Return an accepting subset of inf.
bool is_all() const
Whether the acceptance condition is "all".
Definition acc.hh:1596
acc_cond strip(mark_t rem, bool missing) const
Remove acceptance sets, and shift set numbers.
Definition acc.hh:2118
int fin_one() const
Return one acceptance set i that appear as Fin(i) in the condition.
Definition acc.hh:2205
mark_t useless(iterator begin, iterator end) const
Compute useless acceptance sets given a list of mark_t that occur in an SCC.
Definition acc.hh:2070
int is_streett() const
Check if the acceptance condition matches the Streett acceptance of the HOA format.
mark_t fin_unit() const
Find a Fin(i) that is a unit clause.
Definition acc.hh:2163
bool is_generalized_streett(std::vector< unsigned > &pairs) const
Is the acceptance condition generalized-Streett?
acc_cond(const acc_code &code)
Build an acceptance condition.
Definition acc.hh:1517
acc_cond(const acc_cond &o)
Copy an acceptance condition.
Definition acc.hh:1525
static acc_code inf_neg(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance for complemented sets.
Definition acc.hh:1889
bool is_streett_like(std::vector< rs_pair > &pairs) const
Test whether an acceptance condition is Streett-like and returns each Streett pair in an std::vector<...
bool is_buchi() const
Whether the acceptance condition is "Büchi".
Definition acc.hh:1620
std::vector< acc_cond > top_conjuncts() const
Return the top-level conjuncts.
std::tuple< int, acc_cond, acc_cond > fin_unit_one_split() const
Split an acceptance condition, trying to select one unit-Fin.
Definition acc.hh:2255
mark_t inf_unit() const
Find a Inf(i) that is a unit clause.
Definition acc.hh:2196
bool uses_fin_acceptance() const
Whether the acceptance condition uses Fin terms.
Definition acc.hh:1581
bool is_f() const
Whether the acceptance formula is "f" (false)
Definition acc.hh:1602
unsigned num_sets() const
The number of sets used in the acceptance condition.
Definition acc.hh:2057
Definition bitset.hh:38
A class implementing Kleene's three-valued logic.
Definition trival.hh:33
op
Operator types.
Definition formula.hh:78
@ Or
(omega-Rational) Or
@ U
until
@ And
(omega-Rational) And
Definition automata.hh:26
const mc_rvalue operator|(const mc_rvalue &lhs, const mc_rvalue &rhs)
This function helps to find the output value from a set of threads that may have different values.
Definition mc.hh:130
An acceptance formula.
Definition acc.hh:478
static acc_code parity_max(bool is_odd, unsigned sets)
Build a parity acceptance condition.
Definition acc.hh:860
std::tuple< int, acc_cond::acc_code, acc_cond::acc_code > fin_unit_one_split() const
Split an acceptance condition, trying to select one unit-Fin.
std::vector< std::vector< int > > missing(mark_t inf, bool accepting) const
Help closing accepting or rejecting cycle.
mark_t mafins() const
Find a Fin(i) that is mandatory.
friend std::ostream & operator<<(std::ostream &os, const acc_code &code)
prints the acceptance formula as text
std::ostream & to_html(std::ostream &os, std::function< void(std::ostream &, int)> set_printer=nullptr) const
Print the acceptance formula as HTML.
static acc_code inf(mark_t m)
Construct a generalized Büchi acceptance.
Definition acc.hh:700
acc_code to_cnf() const
Convert the acceptance formula into disjunctive normal form.
acc_code operator&(acc_code &&r) const
Conjunct the current condition with r.
Definition acc.hh:1003
acc_code force_inf(mark_t m) const
For all x in m, replaces Fin(x) by false.
static acc_code inf_neg(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance for complemented sets.
Definition acc.hh:742
std::vector< std::pair< acc_cond::mark_t, acc_cond::mark_t > > useless_colors_patterns() const
Find patterns of useless colors.
trival maybe_accepting(mark_t infinitely_often, mark_t always_present) const
Check potential acceptance of an SCC.
acc_code operator|(const acc_code &r) const
Disjunct the current condition with r.
Definition acc.hh:1109
std::vector< acc_code > top_conjuncts() const
Return the top-level conjuncts.
acc_code operator|(acc_code &&r) const
Disjunct the current condition with r.
Definition acc.hh:1100
static acc_code fin(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance.
Definition acc.hh:654
bool is_dnf() const
Whether the acceptance formula is in disjunctive normal form.
std::vector< acc_code > top_disjuncts() const
Return the top-level disjuncts.
acc_code operator&(const acc_code &r) const
Conjunct the current condition with r.
Definition acc.hh:994
static acc_code inf(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance.
Definition acc.hh:710
static acc_code parity_min_even(unsigned sets)
Build a parity acceptance condition.
Definition acc.hh:880
static acc_code parity(bool is_max, bool is_odd, unsigned sets)
Build a parity acceptance condition.
mark_t used_once_sets() const
Return the sets that appears only once in the acceptance.
acc_code & operator<<=(unsigned sets)
Apply a left shift to all mark_t that appear in the condition.
Definition acc.hh:1121
bool is_f() const
Is this the "false" acceptance condition?
Definition acc.hh:604
static acc_code generalized_buchi(unsigned n)
Build a generalized-Büchi acceptance condition with n sets.
Definition acc.hh:769
static acc_code parity_min_odd(unsigned sets)
Build a parity acceptance condition.
Definition acc.hh:876
acc_code(const acc_word *other)
Copy a part of another acceptance formula.
Definition acc.hh:1489
mark_t fin_unit() const
Find a Fin(i) that is a unit clause.
static acc_code parity_max_even(unsigned sets)
Build a parity acceptance condition.
Definition acc.hh:868
static acc_code f()
Construct the "false" acceptance condition.
Definition acc.hh:618
bool accepting(mark_t inf) const
Check whether visiting exactly all sets inf infinitely often satisfies the acceptance condition.
static acc_code parity_max_odd(unsigned sets)
Build a parity acceptance condition.
Definition acc.hh:864
std::ostream & to_latex(std::ostream &os, std::function< void(std::ostream &, int)> set_printer=nullptr) const
Print the acceptance formula as LaTeX.
std::pair< int, acc_code > fin_one_extract() const
Return one acceptance set i that appears as Fin(i) in the condition, and all disjuncts containing it ...
bool is_t() const
Is this the "true" acceptance condition?
Definition acc.hh:590
acc_code operator<<(unsigned sets) const
Apply a left shift to all mark_t that appear in the condition.
Definition acc.hh:1152
static acc_code random(unsigned n, double reuse=0.0)
Build a random acceptance condition.
static acc_code rabin(unsigned n)
Build a Rabin condition with n pairs.
Definition acc.hh:796
acc_code()
Build an empty acceptance formula.
Definition acc.hh:1484
std::tuple< int, acc_cond::acc_code, acc_cond::acc_code > fin_unit_one_split_improved() const
Split an acceptance condition, trying to select one unit-Fin.
static acc_code cobuchi()
Build a co-Büchi acceptance condition.
Definition acc.hh:759
acc_code complement() const
Complement an acceptance formula.
static acc_code inf_neg(mark_t m)
Construct a generalized Büchi acceptance for complemented sets.
Definition acc.hh:732
bdd to_bdd(const bdd *map) const
Convert the acceptance formula into a BDD.
std::ostream & to_text(std::ostream &os, std::function< void(std::ostream &, int)> set_printer=nullptr) const
Print the acceptance formula as text.
int fin_one() const
Return one acceptance set i that appears as Fin(i) in the condition.
acc_cond::mark_t used_sets() const
Return the set of sets appearing in the condition.
std::pair< acc_cond::mark_t, acc_cond::mark_t > used_inf_fin_sets() const
Return the sets used as Inf or Fin in the acceptance condition.
acc_code strip(acc_cond::mark_t rem, bool missing) const
Remove acceptance sets, and shift set numbers.
acc_code(const char *input)
Construct an acc_code from a string.
static acc_code fin_neg(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition acc.hh:686
acc_code & operator&=(const acc_code &r)
Conjunct the current condition in place with r.
Definition acc.hh:905
mark_t inf_unit() const
Find a Inf(i) that is a unit clause.
static acc_code streett(unsigned n)
Build a Streett condition with n pairs.
Definition acc.hh:811
static acc_code t()
Construct the "true" acceptance condition.
Definition acc.hh:632
std::vector< unsigned > symmetries() const
compute the symmetry class of the acceptance sets.
static acc_code fin_neg(mark_t m)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition acc.hh:676
static acc_code parity_min(bool is_odd, unsigned sets)
Build a parity acceptance condition.
Definition acc.hh:872
static acc_code fin(mark_t m)
Construct a generalized co-Büchi acceptance.
Definition acc.hh:644
acc_code & operator|=(const acc_code &r)
Disjunct the current condition in place with r.
Definition acc.hh:1012
bool inf_satisfiable(mark_t inf) const
Assuming that we will visit at least all sets in inf, is there any chance that we will satisfy the co...
bool is_cnf() const
Whether the acceptance formula is in conjunctive normal form.
static acc_code buchi()
Build a Büchi acceptance condition.
Definition acc.hh:751
static acc_code generalized_co_buchi(unsigned n)
Build a generalized-co-Büchi acceptance condition with n sets.
Definition acc.hh:783
acc_code remove(acc_cond::mark_t rem, bool missing) const
Remove all the acceptance sets in rem.
acc_code to_dnf() const
Convert the acceptance formula into disjunctive normal form.
static acc_code generalized_rabin(Iterator begin, Iterator end)
Build a generalized Rabin condition.
Definition acc.hh:835
An acceptance mark.
Definition acc.hh:84
static constexpr unsigned max_accsets()
The maximum number of acceptance sets supported by this implementation.
Definition acc.hh:137
bool is_singleton() const
Whether the mark contains only one bit set.
Definition acc.hh:384
mark_t lowest() const
A mark_t where all bits have been removed except the lowest one.
Definition acc.hh:378
unsigned max_set() const
The number of the highest set used plus one.
Definition acc.hh:354
mark_t & remove_some(unsigned n)
Remove n bits that where set.
Definition acc.hh:408
static mark_t all()
A mark_t with all bits set to one.
Definition acc.hh:147
spot::internal::mark_container sets() const
Returns some iterable object that contains the used sets.
Definition acc.hh:2459
bool proper_subset(mark_t m) const
Whether the set of bits represented by *this is a proper subset of those represented by m.
Definition acc.hh:339
mark_t(const iterator &begin, const iterator &end)
Create a mark_t from a range of set numbers.
Definition acc.hh:102
unsigned count() const
Number of bits sets.
Definition acc.hh:345
mark_t()=default
Initialize an empty mark_t.
mark_t(std::initializer_list< unsigned > vals)
Create a mark_t from a list of set numbers.
Definition acc.hh:113
bool has_many() const
Whether the mark contains at least two bits set.
Definition acc.hh:395
unsigned min_set() const
The number of the lowest set used plus one.
Definition acc.hh:366
bool subset(mark_t m) const
Whether the set of bits represented by *this is a subset of those represented by m.
Definition acc.hh:332
void fill(iterator here) const
Fill a container with the indices of the bits that are set.
Definition acc.hh:417
Rabin/streett pairs used by is_rabin_like and is_streett_like.
Definition acc.hh:1708
Definition acc.hh:40
Definition acc.hh:2301
A "node" in an acceptance formulas.
Definition acc.hh:456

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.8