diff --git a/NEWS b/NEWS index 72ff8e454..eadd144ea 100644 --- a/NEWS +++ b/NEWS @@ -100,8 +100,16 @@ New in spot 2.8.7.dev (not yet released) same transition structure (where the ..._maybe() variant would modify the Rabin automaton if needed). - - to_parity() now combines several strategies for paritizing any - automaton. + - to_parity() has been rewritten now combines several strategies for + paritizing automata with any acceptance condition. + + Backward-incompatible changes: + + - iar() and iar_maybe() have been moved from + spot/twaalgos/rabin2parity.hh spot/twaalgos/toparity.hh and marked + as deprecated, they should be replaced by to_parity(). In case + the input is Rabin-like or Streett-like, to_parity() should be at + least as good as iar(). New in spot 2.8.7 (2020-03-13) diff --git a/spot/twaalgos/toparity.cc b/spot/twaalgos/toparity.cc index 64b9d392e..81118f18b 100644 --- a/spot/twaalgos/toparity.cc +++ b/spot/twaalgos/toparity.cc @@ -39,8 +39,8 @@ namespace spot { -// Old version of IAR. -namespace + // Old version of IAR. + namespace { using perm_t = std::vector; @@ -346,31 +346,39 @@ namespace std::vector state2pos_iar_states; std::vector> iar_states; }; - } - twa_graph_ptr - iar_maybe_old(const const_twa_graph_ptr& aut, bool pretty_print) - { - std::vector pairs; - if (!aut->acc().is_rabin_like(pairs)) - if (!aut->acc().is_streett_like(pairs)) - return nullptr; + // Make this a function different from iar_maybe(), so that + // iar() does not have to call a deprecated function. + static twa_graph_ptr + iar_maybe_(const const_twa_graph_ptr& aut, bool pretty_print) + { + std::vector pairs; + if (!aut->acc().is_rabin_like(pairs)) + if (!aut->acc().is_streett_like(pairs)) + return nullptr; + else + { + iar_generator gen(aut, pairs, pretty_print); + return gen.run(); + } else { - iar_generator gen(aut, pairs, pretty_print); + iar_generator gen(aut, pairs, pretty_print); return gen.run(); } - else - { - iar_generator gen(aut, pairs, pretty_print); - return gen.run(); - } + } } twa_graph_ptr - iar_old(const const_twa_graph_ptr& aut, bool pretty_print) + iar_maybe(const const_twa_graph_ptr& aut, bool pretty_print) { - if (auto res = iar_maybe_old(aut, pretty_print)) + return iar_maybe_(aut, pretty_print); + } + + twa_graph_ptr + iar(const const_twa_graph_ptr& aut, bool pretty_print) + { + if (auto res = iar_maybe_(aut, pretty_print)) return res; throw std::runtime_error("iar() expects Rabin-like or Streett-like input"); } diff --git a/spot/twaalgos/toparity.hh b/spot/twaalgos/toparity.hh index c9c45bd00..0b806d6c1 100644 --- a/spot/twaalgos/toparity.hh +++ b/spot/twaalgos/toparity.hh @@ -91,7 +91,7 @@ namespace spot /// It is better to use to_parity() instead, as it will use better /// strategies when possible, and has additional optimizations. SPOT_API twa_graph_ptr - to_parity_old(const const_twa_graph_ptr& aut, bool pretty_print=false); + to_parity_old(const const_twa_graph_ptr& aut, bool pretty_print = false); /// \ingroup twa_acc_transform /// \brief Turn a Rabin-like or Streett-like automaton into a parity automaton @@ -113,17 +113,18 @@ namespace spot /// /// It is better to use to_parity() instead, as it will use better /// strategies when possible, and has additional optimizations. + SPOT_DEPRECATED("use to_parity() instead") // deprecated since Spot 2.9 SPOT_API twa_graph_ptr - iar_old(const const_twa_graph_ptr& aut, bool pretty_print = false); + iar(const const_twa_graph_ptr& aut, bool pretty_print = false); /// \ingroup twa_acc_transform /// \brief Turn a Rabin-like or Streett-like automaton into a parity automaton /// based on the index appearence record (IAR) /// /// Returns nullptr if the input automaton is neither Rabin-like nor - /// Streett-like, and calls spot::iar_old() otherwise. - SPOT_API - twa_graph_ptr - iar_maybe_old(const const_twa_graph_ptr& aut, bool pretty_print = false); + /// Streett-like, and calls spot::iar() otherwise. + SPOT_DEPRECATED("use to_parity() and spot::acc_cond::is_rabin_like() instead") + SPOT_API twa_graph_ptr // deprecated since Spot 2.9 + iar_maybe(const const_twa_graph_ptr& aut, bool pretty_print = false); } // namespace spot diff --git a/tests/python/except.py b/tests/python/except.py index fbcc1563e..926aa864d 100644 --- a/tests/python/except.py +++ b/tests/python/except.py @@ -33,7 +33,7 @@ def report_missing_exception(): aut = spot.translate('GFa & GFb & GFc') aut.set_acceptance(spot.acc_cond("parity min even 4")) try: - spot.iar_old(aut) + spot.iar(aut) except RuntimeError as e: assert 'iar() expects Rabin-like or Streett-like input' in str(e) else: