31 #include <spot/misc/_config.h>
32 #include <spot/misc/bitset.hh>
33 #include <spot/misc/trival.hh>
57 [[noreturn]]
static void report_too_many_sets();
93 template<
class iterator>
94 mark_t(
const iterator& begin,
const iterator& end)
97 for (iterator i = begin; i != end; ++i)
98 if (SPOT_LIKELY(*i < SPOT_MAX_ACCSETS))
101 report_too_many_sets();
105 mark_t(std::initializer_list<unsigned> vals)
106 :
mark_t(vals.begin(), vals.end())
118 return SPOT_MAX_ACCSETS;
128 return mark_t(_value_t::mone());
134 std::hash<decltype(
id)> h;
175 explicit operator bool()
const
181 bool has(
unsigned u)
const
256 #if SPOT_DEBUG || defined(SWIGPYTHON)
257 # define SPOT_WRAP_OP(ins) \
262 catch (const std::runtime_error& e) \
264 report_too_many_sets(); \
267 # define SPOT_WRAP_OP(ins) ins;
272 SPOT_WRAP_OP(
return id << i);
278 SPOT_WRAP_OP(
id <<= i;
return *
this);
284 SPOT_WRAP_OP(
return id >> i);
290 SPOT_WRAP_OP(
id >>= i;
return *
this);
312 auto rm = (~yv) & (yv - 1);
314 auto lm = ~(yv ^ (yv - 1));
315 xv = ((xv & lm) >> 1) | (xv & rm);
325 return !((*this) - m);
332 return *
this != m && this->subset(m);
348 return id.highest()+1;
360 return id.lowest()+1;
381 return id && !(
id & (
id - 1));
392 return !!(
id & (
id - 1));
407 template<
class iterator>
408 void fill(iterator here)
const;
411 spot::internal::mark_container sets()
const;
419 { Inf, Fin, InfNeg, FinNeg,
And,
Or };
455 struct SPOT_API
acc_code:
public std::vector<acc_word>
465 if (is_t() && other.
is_t())
467 unsigned pos = size();
468 if (other.size() != pos)
472 auto op = (*this)[pos - 1].sub.op;
473 auto sz = (*this)[pos - 1].sub.size;
474 if (other[pos - 1].sub.op !=
op ||
475 other[pos - 1].sub.size != sz)
479 case acc_cond::acc_op::And:
480 case acc_cond::acc_op::Or:
483 case acc_cond::acc_op::Inf:
484 case acc_cond::acc_op::InfNeg:
485 case acc_cond::acc_op::Fin:
486 case acc_cond::acc_op::FinNeg:
488 if (other[pos].mark != (*
this)[pos].mark)
500 if (is_t() && other.
is_t())
502 unsigned pos = size();
503 auto osize = other.size();
510 auto op = (*this)[pos - 1].sub.op;
511 auto oop = other[pos - 1].sub.op;
516 auto sz = (*this)[pos - 1].sub.size;
517 auto osz = other[pos - 1].sub.size;
524 case acc_cond::acc_op::And:
525 case acc_cond::acc_op::Or:
528 case acc_cond::acc_op::Inf:
529 case acc_cond::acc_op::InfNeg:
530 case acc_cond::acc_op::Fin:
531 case acc_cond::acc_op::FinNeg:
534 auto m = (*this)[pos].mark;
535 auto om = other[pos].mark;
550 return other < *
this;
556 return !(other < *
this);
562 return !(*
this < other);
568 return !(*
this == other);
579 return s == 0 || ((*this)[s - 1].sub.op == acc_op::Inf
580 && !((*this)[s - 2].mark));
594 && (*this)[s - 1].sub.op == acc_op::Fin && !((*this)[s - 2].mark);
602 static constexpr
size_t max_acc_formula_size_ = (1U << 24) - 1;
606 [[noreturn]]
static void report_too_large_acceptance_formula_()
608 throw std::runtime_error(
"acceptance formula is too large");
624 res[1].sub.op = acc_op::Fin;
650 res[1].sub.op = acc_op::Fin;
682 res[1].sub.op = acc_op::FinNeg;
689 return fin_neg(
mark_t(vals));
706 res[1].sub.op = acc_op::Inf;
738 res[1].sub.op = acc_op::InfNeg;
745 return inf_neg(
mark_t(vals));
775 m >>= mark_t::max_accsets() - n;
789 m >>= mark_t::max_accsets() - n;
802 res |= inf({2*n - 1}) & fin({2*n - 2});
817 res &= inf({2*n - 1}) | fin({2*n - 2});
835 template<
class Iterator>
840 for (Iterator i = begin; i != end; ++i)
844 for (
unsigned ni = *i; ni > 0; --ni)
846 auto pair = inf(m) & fin({f});
847 std::swap(pair, res);
848 res |= std::move(pair);
863 return parity(
true, is_odd, sets);
867 return parity_max(
true, sets);
871 return parity_max(
false, sets);
875 return parity(
false, is_odd, sets);
879 return parity_min(
true, sets);
883 return parity_min(
false, sets);
908 if (is_t() || r.
is_f())
913 if (is_f() || r.
is_t())
915 unsigned s = size() - 1;
916 unsigned rs = r.size() - 1;
919 if (((*
this)[s].sub.op == acc_op::Inf
920 && r[rs].sub.op == acc_op::Inf)
921 || ((*
this)[s].sub.op == acc_op::InfNeg
922 && r[rs].sub.op == acc_op::InfNeg))
924 (*this)[s - 1].mark |= r[rs - 1].mark;
934 if ((*
this)[s].sub.op == acc_op::And)
936 auto start = &(*this)[s] - (*this)[s].
sub.
size;
937 auto pos = &(*this)[s] - 1;
941 if (pos->sub.op == acc_op::Inf)
949 else if ((*
this)[s].sub.op == acc_op::Inf)
951 left_inf = &(*this)[s - 1];
954 const acc_word* right_inf =
nullptr;
955 auto right_end = &r.back();
956 if (right_end->sub.op == acc_op::And)
959 auto pos = --right_end;
962 if (pos->sub.op == acc_op::Inf)
970 else if (right_end->sub.op == acc_op::Inf)
972 right_inf = right_end - 1;
976 if (left_inf && right_inf)
978 carry = left_inf->
mark;
979 auto pos = left_inf - &(*this)[0];
980 erase(begin() + pos, begin() + pos + 2);
983 insert(end(), &r[0], right_end + 1);
985 (*this)[sz + (right_inf - &r[0])].mark |= carry;
988 w.
sub.
op = acc_op::And;
989 auto new_size = size();
990 if (SPOT_UNLIKELY(new_size > max_acc_formula_size_))
991 report_too_large_acceptance_formula_();
992 w.sub.size = new_size;
1018 if (is_t() || r.
is_f())
1020 if (is_f() || r.
is_t())
1025 unsigned s = size() - 1;
1026 unsigned rs = r.size() - 1;
1028 if (((*
this)[s].sub.op == acc_op::Fin
1029 && r[rs].sub.op == acc_op::Fin)
1030 || ((*
this)[s].sub.op == acc_op::FinNeg
1031 && r[rs].sub.op == acc_op::FinNeg))
1033 (*this)[s - 1].mark |= r[rs - 1].mark;
1043 if ((*
this)[s].sub.op == acc_op::Or)
1045 auto start = &(*this)[s] - (*this)[s].
sub.
size;
1046 auto pos = &(*this)[s] - 1;
1050 if (pos->sub.op == acc_op::Fin)
1058 else if ((*
this)[s].sub.op == acc_op::Fin)
1060 left_fin = &(*this)[s - 1];
1063 const acc_word* right_fin =
nullptr;
1064 auto right_end = &r.back();
1065 if (right_end->sub.op == acc_op::Or)
1068 auto pos = --right_end;
1071 if (pos->sub.op == acc_op::Fin)
1073 right_fin = pos - 1;
1079 else if (right_end->sub.op == acc_op::Fin)
1081 right_fin = right_end - 1;
1085 if (left_fin && right_fin)
1087 carry = left_fin->
mark;
1088 auto pos = (left_fin - &(*this)[0]);
1089 this->erase(begin() + pos, begin() + pos + 2);
1092 insert(end(), &r[0], right_end + 1);
1094 (*this)[sz + (right_fin - &r[0])].mark |= carry;
1096 w.
sub.
op = acc_op::Or;
1097 auto new_size = size();
1098 if (SPOT_UNLIKELY(new_size > max_acc_formula_size_))
1099 report_too_large_acceptance_formula_();
1100 w.sub.size = new_size;
1130 if (SPOT_UNLIKELY(sets >= mark_t::max_accsets()))
1131 report_too_many_sets();
1134 unsigned pos = size();
1137 switch ((*
this)[pos - 1].sub.op)
1139 case acc_cond::acc_op::And:
1140 case acc_cond::acc_op::Or:
1143 case acc_cond::acc_op::Inf:
1144 case acc_cond::acc_op::InfNeg:
1145 case acc_cond::acc_op::Fin:
1146 case acc_cond::acc_op::FinNeg:
1148 (*this)[pos].mark <<= sets;
1328 std::tuple<int, acc_cond::acc_code, acc_cond::acc_code>
1330 std::tuple<int, acc_cond::acc_code, acc_cond::acc_code>
1349 std::vector<std::pair<acc_cond::mark_t, acc_cond::acc_code>>
1364 std::vector<std::vector<int>>
1391 mark_t always_present)
const;
1407 mark_t always_present)
const;
1465 std::vector<std::pair<acc_cond::mark_t, acc_cond::mark_t>>
1485 std::function<
void(std::ostream&,
int)>
1486 set_printer =
nullptr)
const;
1494 std::function<
void(std::ostream&,
int)>
1495 set_printer =
nullptr)
const;
1503 std::function<
void(std::ostream&,
int)>
1504 set_printer =
nullptr)
const;
1539 : std::vector<
acc_word>(other - other->sub.size, other + 1)
1553 : num_(0U), all_({}), code_(code)
1556 uses_fin_acceptance_ = check_fin_acceptance();
1564 : num_(0
U), all_({}), code_(code)
1566 add_sets(code.used_sets().max_set());
1567 uses_fin_acceptance_ = check_fin_acceptance();
1572 : num_(o.num_), all_(o.all_), code_(o.code_),
1573 uses_fin_acceptance_(o.uses_fin_acceptance_)
1597 uses_fin_acceptance_ = check_fin_acceptance();
1619 return (ocode == code_ || (ocode.
is_t() && code_.is_t()));
1625 return !(*
this == other);
1631 return uses_fin_acceptance_;
1637 return code_.is_t();
1646 return num_ == 0 && is_t();
1652 return code_.is_f();
1661 return num_ == 0 && is_f();
1670 unsigned s = code_.size();
1672 s == 2 && code_[1].sub.op == acc_op::Inf && code_[0].mark == all_sets();
1681 return num_ == 1 && is_generalized_co_buchi();
1688 set_acceptance(inf(all_sets()));
1695 set_acceptance(fin(all_sets()));
1704 unsigned s = code_.size();
1705 return (s == 0 && num_ == 0) || (s == 2 && code_[1].sub.op == acc_op::Inf
1706 && code_[0].mark == all_sets());
1715 unsigned s = code_.size();
1717 code_[1].sub.op == acc_op::Fin && code_[0].mark == all_sets());
1776 return fin == o.
fin && inf == o.
inf;
1781 return fin != o.
fin || inf != o.
inf;
1786 return fin < o.
fin || (!(o.
fin < fin) && inf < o.
inf);
1791 return !(o < *
this);
1801 return !(*
this < o);
1862 bool is_parity(
bool& max,
bool& odd,
bool equiv =
false)
const;
1871 return is_parity(max, odd);
1883 return acc_cond(num_, code_.unit_propagation());
1892 return sat_unsat_mark(
false);
1900 return sat_unsat_mark(
true);
1920 return acc_code::inf(mark);
1925 return inf(
mark_t(vals.begin(), vals.end()));
1947 return acc_code::inf_neg(mark);
1952 return inf_neg(
mark_t(vals.begin(), vals.end()));
1965 return acc_code::fin(mark);
1970 return fin(
mark_t(vals.begin(), vals.end()));
1992 return acc_code::fin_neg(mark);
1997 return fin_neg(
mark_t(vals.begin(), vals.end()));
2011 if (num > mark_t::max_accsets())
2012 report_too_many_sets();
2031 SPOT_ASSERT(u < num_sets());
2054 return code_.accepting(inf);
2064 return code_.inf_satisfiable(inf);
2090 return code_.maybe_accepting(infinitely_often, always_present);
2109 return code_.weakly_accepting(infinitely_often, always_present);
2140 template<
class iterator>
2144 for (
unsigned x = 0; x < num_; ++x)
2149 auto all = comp(u |
mark_t({x}));
2152 for (iterator y = begin; y != end; ++y)
2182 return {num_sets(), code_.
remove(rem, missing)};
2192 { num_sets() - (all_sets() & rem).count(), code_.
strip(rem, missing) };
2198 return {num_sets(), code_.
force_inf(m)};
2205 return {num_sets(), code_.
remove(all_sets() - rem,
true)};
2219 std::string
name(
const char* fmt =
"alo")
const;
2236 return code_.fin_unit();
2253 return code_.mafins();
2262 auto v = code_.mafins_split();
2263 std::vector<std::pair<mark_t, acc_cond>> result;
2264 result.reserve(v.size());
2265 for (
auto& [m, c] : v)
2266 result.emplace_back(m,
acc_cond(num_, c));
2283 return code_.inf_unit();
2292 return code_.fin_one();
2317 auto [f, c] = code_.fin_one_extract();
2318 return {f, {num_sets(), std::move(c)}};
2339 std::tuple<int, acc_cond, acc_cond>
2342 auto [f, l, r] = code_.fin_unit_one_split();
2343 return {f, {num_sets(), std::move(l)}, {num_sets(), std::move(r)}};
2345 std::tuple<int, acc_cond, acc_cond>
2348 auto [f, l, r] = code_.fin_unit_one_split_improved();
2349 return {f, {num_sets(), std::move(l)}, {num_sets(), std::move(r)}};
2384 bool uses_fin_acceptance_ =
false;
2396 : pairs_(p), view_marks_(m) {}
2425 return !visible(p.
inf) && visible(p.
fin) ? p.
fin
2435 return !visible(p.
fin) && visible(p.
inf) ? p.
inf
2446 for (
const auto& p: pairs_)
2447 if (p.fin.has(mark) && visible(p.fin) && visible(p.inf))
2459 template<
typename filter>
2463 for (
const auto& p: pairs_)
2468 bool visible(
const acc_cond::mark_t& v)
const
2470 return !!(view_marks_ & v);
2474 acc_cond::mark_t view_marks_;
2498 class SPOT_API mark_iterator
2501 typedef unsigned value_type;
2502 typedef const value_type& reference;
2503 typedef const value_type* pointer;
2504 typedef std::ptrdiff_t difference_type;
2505 typedef std::forward_iterator_tag iterator_category;
2507 mark_iterator() noexcept
2512 mark_iterator(acc_cond::mark_t m) noexcept
2527 value_type operator*()
const
2530 return m_.min_set() - 1;
2533 mark_iterator& operator++()
2535 m_.clear(this->
operator*());
2539 mark_iterator operator++(
int)
2541 mark_iterator it = *
this;
2546 acc_cond::mark_t m_;
2549 class SPOT_API mark_container
2557 mark_iterator begin()
const
2561 mark_iterator end()
const
2575 template<
class iterator>
2578 for (
unsigned s : sets())
2588 struct hash<
spot::acc_cond::mark_t>
An acceptance condition.
Definition: acc.hh:54
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:2062
mark_t all_sets() const
Construct a mark_t with all declared sets.
Definition: acc.hh:2045
static acc_code fin_neg(mark_t mark)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition: acc.hh:1990
mark_t mafins() const
Find a Fin(i) that is mandatory.
Definition: acc.hh:2251
static acc_code inf_neg(mark_t mark)
Construct a generalized Büchi acceptance for complemented sets.
Definition: acc.hh:1945
std::pair< bool, acc_cond::mark_t > sat_unsat_mark(bool) const
Shared implementation for sat_mark() and unsat_mark().
acc_cond unit_propagation()
Remove superfluous Fin and Inf by unit propagation.
Definition: acc.hh:1881
void set_generalized_co_buchi()
Change the acceptance condition to generalized-co-Büchi, over all declared sets.
Definition: acc.hh:1693
std::pair< bool, acc_cond::mark_t > unsat_mark() const
Return an unsatisfying mark if one exists.
Definition: acc.hh:1890
const acc_code & get_acceptance() const
Retrieve the acceptance formula.
Definition: acc.hh:1601
bool operator==(const acc_cond &other) const
Equality: same number of sets and equivalent formula.
Definition: acc.hh:1613
static acc_code fin(mark_t mark)
Construct a generalized co-Büchi acceptance.
Definition: acc.hh:1963
bool is_co_buchi() const
Whether the acceptance condition is "co-Büchi".
Definition: acc.hh:1679
bool accepting(mark_t inf) const
Check whether visiting exactly all sets inf infinitely often satisfies the acceptance condition.
Definition: acc.hh:2052
static acc_code inf(mark_t mark)
Construct a generalized Büchi acceptance.
Definition: acc.hh:1918
unsigned num_
Number of declared acceptance sets.
Definition: acc.hh:2380
bool is_generalized_buchi() const
Whether the acceptance condition is "generalized-Büchi".
Definition: acc.hh:1702
static acc_code fin_neg(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition: acc.hh:1995
static acc_code inf(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance.
Definition: acc.hh:1923
unsigned add_set()
Add a single set to the acceptance condition.
Definition: acc.hh:2023
bool check_fin_acceptance() const
Recompute whether the formula uses Fin acceptance.
bool is_parity(bool &max, bool &odd, bool equiv=false) const
Check if the acceptance condition matches one of the four type of parity acceptance defined in the HO...
mark_t mark(unsigned u) const
Build a mark_t with a single set.
Definition: acc.hh:2029
void set_generalized_buchi()
Change the acceptance condition to generalized-Büchi, over all declared sets.
Definition: acc.hh:1686
acc_cond force_inf(mark_t m) const
For all x in m, replaces Fin(x) by false.
Definition: acc.hh:2196
acc_cond remove(mark_t rem, bool missing) const
Remove all the acceptance sets in rem.
Definition: acc.hh:2180
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:2340
acc_cond(unsigned n_sets=0, const acc_code &code={})
Build an acceptance condition.
Definition: acc.hh:1552
unsigned add_sets(unsigned num)
Add more sets to the acceptance condition.
Definition: acc.hh:2005
bool is_parity() const
Check if the acceptance condition matches one of the four type of parity acceptance defined in the HO...
Definition: acc.hh:1867
bool is_t() const
Whether the acceptance formula is "t" (true)
Definition: acc.hh:1635
trival weakly_accepting(mark_t infinitely_often, mark_t always_present) const
Check if cycles in a SCC are all accepting, all rejecting, or mixed.
Definition: acc.hh:2107
bool is_generalized_rabin(std::vector< unsigned > &pairs) const
Is the acceptance condition generalized-Rabin?
acc_op
Operators for acceptance formulas.
Definition: acc.hh:419
mark_t comp(const mark_t &l) const
Complement a mark_t.
Definition: acc.hh:2039
acc_cond keep_one_inf_per_branch() const
Rewrite an acceptance condition by keeping at most one Inf(x) on each disjunctive branch.
Definition: acc.hh:2072
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:2346
std::vector< acc_cond > top_conjuncts() const
Return the top-level conjuncts.
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:2315
static acc_code fin(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance.
Definition: acc.hh:1968
bool is_generalized_co_buchi() const
Whether the acceptance condition is "generalized-co-Büchi".
Definition: acc.hh:1713
std::vector< std::pair< mark_t, acc_cond > > mafins_split() const
Split an acceptance condition into disjuncts according to mandatory fins.
Definition: acc.hh:2260
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:2203
trival maybe_accepting(mark_t infinitely_often, mark_t always_present) const
Check potential acceptance of an SCC.
Definition: acc.hh:2088
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:1659
void set_acceptance(const acc_code &code)
Change the acceptance formula.
Definition: acc.hh:1594
int is_rabin() const
Check if the acceptance condition matches the Rabin acceptance of the HOA format.
bool uses_fin_acceptance_
Whether the formula contains any Fin term.
Definition: acc.hh:2384
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:1644
acc_cond strip(mark_t rem, bool missing) const
Remove acceptance sets, and shift set numbers.
Definition: acc.hh:2189
int fin_one() const
Return one acceptance set i that appear as Fin(i) in the condition.
Definition: acc.hh:2290
mark_t all_sets_() const
Returns a mark with one bit set per declared acceptance set.
Definition: acc.hh:2375
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:2141
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:2234
acc_code & get_acceptance()
Retrieve the acceptance formula.
Definition: acc.hh:1607
mark_t all_
Precomputed all_sets_() value.
Definition: acc.hh:2381
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:1563
acc_cond(const acc_cond &o)
Copy an acceptance condition.
Definition: acc.hh:1571
std::pair< bool, acc_cond::mark_t > sat_mark() const
Return a satisfying mark if one exists.
Definition: acc.hh:1898
acc_code code_
Definition: acc.hh:2382
acc_cond & operator=(const acc_cond &o)
Copy an acceptance condition.
Definition: acc.hh:1578
bool operator!=(const acc_cond &other) const
Inequality comparison.
Definition: acc.hh:1623
static acc_code inf_neg(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance for complemented sets.
Definition: acc.hh:1950
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:1668
mark_t inf_unit() const
Find a Inf(i) that is a unit clause.
Definition: acc.hh:2281
bool uses_fin_acceptance() const
Whether the acceptance condition uses Fin terms.
Definition: acc.hh:1629
bool is_f() const
Whether the acceptance formula is "f" (false)
Definition: acc.hh:1650
unsigned num_sets() const
The number of sets used in the acceptance condition.
Definition: acc.hh:2128
std::vector< acc_cond > top_disjuncts() const
Return the top-level disjuncts.
A fixed-size bitset backed by N unsigned words.
Definition: bitset.hh:40
A class implementing Kleene's three-valued logic.
Definition: trival.hh:33
op
Operator types.
Definition: formula.hh:85
@ And
(omega-Rational) And
scc_info_options operator&(scc_info_options left, scc_info_options right)
Bitwise AND of two scc_info_options values.
Definition: sccinfo.hh:427
Definition: automata.hh:26
std::ostream & operator<<(std::ostream &os, const mc_algorithm &ma)
Print an mc_algorithm value to a stream.
Definition: mc.hh:74
constexpr bool operator==(trival a, trival b)
Equality comparison of two trival values.
Definition: trival.hh:134
constexpr bool operator!=(trival a, trival b)
Inequality comparison of two trival values.
Definition: trival.hh:140
An acceptance formula.
Definition: acc.hh:456
std::vector< std::pair< acc_cond::mark_t, acc_cond::mark_t > > useless_colors_patterns() const
Find patterns of useless colors.
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.
static acc_code parity_max(bool is_odd, unsigned sets)
Build a parity acceptance condition.
Definition: acc.hh:861
bool operator!=(const acc_code &other) const
Inequality comparison of acceptance formulas.
Definition: acc.hh:566
mark_t mafins() const
Find a Fin(i) that is mandatory.
static acc_code inf(mark_t m)
Construct a generalized Büchi acceptance.
Definition: acc.hh:701
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:1007
acc_code force_inf(mark_t m) const
For all x in m, replaces Fin(x) by false.
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_neg(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance for complemented sets.
Definition: acc.hh:743
std::vector< std::pair< acc_cond::mark_t, acc_cond::acc_code > > mafins_split() const
Split an acceptance conditions into disjuncts according to mandatory fins.
std::vector< acc_code > top_disjuncts() const
Return the top-level disjuncts.
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.
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:1116
std::vector< std::vector< int > > missing(mark_t inf, bool accepting) const
Help closing accepting or rejecting cycle.
acc_code operator|(acc_code &&r) const
Disjunct the current condition with r.
Definition: acc.hh:1107
static acc_code fin(std::initializer_list< unsigned > vals)
Construct a generalized co-Büchi acceptance.
Definition: acc.hh:655
bool is_dnf() const
Whether the acceptance formula is in disjunctive normal form.
acc_code operator&(const acc_code &r) const
Conjunct the current condition with r.
Definition: acc.hh:998
static acc_code inf(std::initializer_list< unsigned > vals)
Construct a generalized Büchi acceptance.
Definition: acc.hh:711
static acc_code parity_min_even(unsigned sets)
Build a parity acceptance condition.
Definition: acc.hh:881
static acc_code parity(bool is_max, bool is_odd, unsigned sets)
Build a parity acceptance 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.
mark_t used_once_sets() const
Return the sets that appears only once in the acceptance.
bool is_f() const
Is this the "false" acceptance condition?
Definition: acc.hh:589
std::ostream & to_text(std::ostream &os, std::function< void(std::ostream &, int)> set_printer=nullptr) const
Print the acceptance formula as text.
static acc_code generalized_buchi(unsigned n)
Build a generalized-Büchi acceptance condition with n sets.
Definition: acc.hh:770
bool operator>(const acc_code &other) const
Greater-than comparison of acceptance formulas.
Definition: acc.hh:548
static acc_code parity_min_odd(unsigned sets)
Build a parity acceptance condition.
Definition: acc.hh:877
acc_code(const acc_word *other)
Copy a part of another acceptance formula.
Definition: acc.hh:1538
mark_t fin_unit() const
Find a Fin(i) that is a unit clause.
trival weakly_accepting(mark_t infinitely_often, mark_t always_present) const
Check if cycles in a SCC are all accepting, all rejecting, or mixed.
static acc_code parity_max_even(unsigned sets)
Build a parity acceptance condition.
Definition: acc.hh:869
static acc_code f()
Construct the "false" acceptance condition.
Definition: acc.hh:619
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:865
bool is_t() const
Is this the "true" acceptance condition?
Definition: acc.hh:575
acc_code operator<<(unsigned sets) const
Apply a left shift to all mark_t that appear in the condition.
Definition: acc.hh:1159
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:797
acc_code()
Build an empty acceptance formula.
Definition: acc.hh:1533
acc_code keep_one_inf_per_branch() const
Rewrite an acceptance condition by keeping at most one Inf(x) on each disjunctive branch.
bool operator==(const acc_code &other) const
Equality comparison of acceptance formulas.
Definition: acc.hh:462
static acc_code cobuchi()
Build a co-Büchi acceptance condition.
Definition: acc.hh:760
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:733
bdd to_bdd(const bdd *map) const
Convert the acceptance formula into a BDD.
int fin_one() const
Return one acceptance set i that appears as Fin(i) in the condition.
bool operator<=(const acc_code &other) const
Less-or-equal comparison of acceptance formulas.
Definition: acc.hh:554
acc_cond::mark_t used_sets() const
Return the set of sets appearing in the condition.
bool operator>=(const acc_code &other) const
Greater-or-equal comparison of acceptance formulas.
Definition: acc.hh:560
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:687
acc_code & operator<<=(unsigned sets)
Apply a left shift to all mark_t that appear in the condition.
Definition: acc.hh:1128
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:812
acc_code unit_propagation()
Apply unit propagation to simplify the formula.
std::vector< acc_code > top_conjuncts() const
Return the top-level conjuncts.
static acc_code t()
Construct the "true" acceptance condition.
Definition: acc.hh:633
static acc_code fin_neg(mark_t m)
Construct a generalized co-Büchi acceptance for complemented sets.
Definition: acc.hh:677
bool operator<(const acc_code &other) const
Lexicographic less-than comparison on acceptance formulas.
Definition: acc.hh:497
static acc_code parity_min(bool is_odd, unsigned sets)
Build a parity acceptance condition.
Definition: acc.hh:873
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 ...
static acc_code fin(mark_t m)
Construct a generalized co-Büchi acceptance.
Definition: acc.hh:645
bool inf_satisfiable(mark_t inf) const
Assuming that we will visit infinitely often at least all sets in inf, is there any chance that we wi...
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:752
static acc_code generalized_co_buchi(unsigned n)
Build a generalized-co-Büchi acceptance condition with n sets.
Definition: acc.hh:784
std::vector< unsigned > symmetries() const
compute the symmetry class of the acceptance sets.
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:836
acc_code & operator|=(const acc_code &r)
Disjunct the current condition in place with r.
Definition: acc.hh:1016
acc_code & operator&=(const acc_code &r)
Conjunct the current condition in place with r.
Definition: acc.hh:906
std::ostream & to_latex(std::ostream &os, std::function< void(std::ostream &, int)> set_printer=nullptr) const
Print the acceptance formula as LaTeX.
An acceptance mark.
Definition: acc.hh:76
std::string as_string() const
Returns a string representation of this mark.
mark_t operator~() const
Bitwise complement.
Definition: acc.hh:245
bool is_singleton() const
Whether the mark contains only one bit set.
Definition: acc.hh:375
mark_t lowest() const
A mark_t where all bits have been removed except the lowest one.
Definition: acc.hh:369
unsigned max_set() const
The number of the highest set used plus one.
Definition: acc.hh:345
mark_t & remove_some(unsigned n)
Remove n bits that were set.
Definition: acc.hh:399
constexpr static unsigned max_accsets()
The maximum number of acceptance sets supported by this implementation.
Definition: acc.hh:116
size_t hash() const noexcept
Returns a hash value for this mark.
Definition: acc.hh:132
bool operator<=(mark_t o) const
Less-or-equal comparison.
Definition: acc.hh:157
static mark_t all()
A mark_t with all bits set to one.
Definition: acc.hh:126
spot::internal::mark_container sets() const
Returns some iterable object that contains the used sets.
Definition: acc.hh:2570
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:330
mark_t & operator-=(mark_t r)
Difference-assignment (removes bits set in r).
Definition: acc.hh:213
mark_t strip(mark_t y) const
Remove bits indexed by y and compact the remaining bits.
Definition: acc.hh:298
mark_t(const iterator &begin, const iterator &end)
Create a mark_t from a range of set numbers.
Definition: acc.hh:94
mark_t & operator<<=(unsigned i)
Left-shift-assignment.
Definition: acc.hh:276
unsigned count() const
Number of bits set.
Definition: acc.hh:336
mark_t operator>>(unsigned i) const
Right-shift all acceptance set indices by i.
Definition: acc.hh:282
mark_t & operator>>=(unsigned i)
Right-shift-assignment.
Definition: acc.hh:288
mark_t & operator|=(mark_t r)
Union-assignment.
Definition: acc.hh:206
mark_t operator^(mark_t r) const
Symmetric difference.
Definition: acc.hh:251
mark_t operator-(mark_t r) const
Difference (bits in this mark but not in r).
Definition: acc.hh:239
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:105
bool operator!=(mark_t o) const
Inequality comparison.
Definition: acc.hh:145
mark_t operator<<(unsigned i) const
Left-shift all acceptance set indices by i.
Definition: acc.hh:270
bool operator>=(mark_t o) const
Greater-or-equal comparison.
Definition: acc.hh:169
bool has_many() const
Whether the mark contains at least two bits set.
Definition: acc.hh:386
mark_t & operator^=(mark_t r)
Symmetric-difference-assignment.
Definition: acc.hh:220
void clear(unsigned u)
Remove acceptance set u from this mark.
Definition: acc.hh:193
mark_t & operator&=(mark_t r)
Intersection-assignment.
Definition: acc.hh:199
unsigned min_set() const
The number of the lowest set used plus one.
Definition: acc.hh:357
mark_t operator&(mark_t r) const
Intersection.
Definition: acc.hh:227
bool has(unsigned u) const
Returns true iff acceptance set u is in this mark.
Definition: acc.hh:181
bool operator<(mark_t o) const
Less-than comparison.
Definition: acc.hh:151
bool operator>(mark_t o) const
Greater-than comparison.
Definition: acc.hh:163
mark_t operator|(mark_t r) const
Union.
Definition: acc.hh:233
bool operator==(mark_t o) const
Equality comparison.
Definition: acc.hh:139
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:323
void fill(iterator here) const
Fill a container with the indices of the bits that are set.
Definition: acc.hh:2576
void set(unsigned u)
Add acceptance set u to this mark.
Definition: acc.hh:187
Rabin/streett pairs used by is_rabin_like and is_streett_like.
Definition: acc.hh:1756
rs_pair(acc_cond::mark_t fin, acc_cond::mark_t inf) noexcept
Construct a pair with Fin mark fin and Inf mark inf.
Definition: acc.hh:1766
rs_pair(const rs_pair &)=default
Copy constructor.
bool operator<=(rs_pair o) const
Less-or-equal comparison.
Definition: acc.hh:1789
rs_pair & operator=(const rs_pair &)=default
Copy-assignment operator.
acc_cond::mark_t fin
The Fin acceptance mark of this pair.
Definition: acc.hh:1770
bool operator>=(rs_pair o) const
Greater-or-equal comparison.
Definition: acc.hh:1799
bool operator>(rs_pair o) const
Greater-than comparison.
Definition: acc.hh:1794
bool operator<(rs_pair o) const
Less-than comparison (lexicographic on fin then inf).
Definition: acc.hh:1784
bool operator==(rs_pair o) const
Equality comparison.
Definition: acc.hh:1774
bool operator!=(rs_pair o) const
Inequality comparison.
Definition: acc.hh:1779
acc_cond::mark_t inf
The Inf acceptance mark of this pair.
Definition: acc.hh:1771
A view over Rabin-Streett pairs restricted to a subset of acceptance marks.
Definition: acc.hh:2390
std::vector< acc_cond::rs_pair > rs_pairs
Type alias for a vector of Rabin-Streett pairs.
Definition: acc.hh:2392
acc_cond::mark_t fins() const
Returns the union of all visible Fin marks across all pairs.
Definition: acc.hh:2412
rs_pairs_view(const rs_pairs &p, const acc_cond::mark_t &m)
Create a view of pairs p restricted to marks visible in m.
Definition: acc.hh:2395
rs_pairs_view(const rs_pairs &p)
Create an unrestricted view of all pairs in p.
Definition: acc.hh:2399
acc_cond::mark_t paired_with_fin(unsigned mark) const
Returns all Inf marks paired with a Fin containing mark.
Definition: acc.hh:2443
acc_cond::mark_t fins_alone() const
Returns Fin marks from pairs whose Inf part is not visible.
Definition: acc.hh:2421
acc_cond::mark_t infs_alone() const
Returns Inf marks from pairs whose Fin part is not visible.
Definition: acc.hh:2431
const rs_pairs & pairs() const
Returns a reference to the underlying vector of pairs.
Definition: acc.hh:2453
acc_cond::mark_t infs() const
Returns the union of all visible Inf marks across all pairs.
Definition: acc.hh:2403
size_t operator()(spot::acc_cond::mark_t m) const noexcept
Returns the hash of acceptance mark m.
Definition: acc.hh:2591
A "node" in an acceptance formulas.
Definition: acc.hh:429
mark_t mark
A set of acceptance marks.
Definition: acc.hh:430
acc_op op
Operator (6 possible values, stored in 8 bits)
Definition: acc.hh:433
unsigned size
Size of the subtree.
Definition: acc.hh:439
struct spot::acc_cond::acc_word::@5 sub
An operator node with its subtree size.