improve readability of parity(false, true, 5)

* spot/twa/acc.hh: Introduce parity_min_odd(n) and friends.
* spot/twaalgos/determinize.cc, spot/twaalgos/rabin2parity.cc,
spot/twaalgos/toparity.cc: Use them.
* tests/python/parity.py: Call each function exhaustively.
* NEWS: Mention the new functions.
This commit is contained in:
Alexandre Duret-Lutz 2019-10-08 15:18:48 +02:00
parent b2539e8399
commit 566a43dd17
6 changed files with 74 additions and 25 deletions

View file

@ -965,7 +965,7 @@ namespace spot
if (sets % 2 == 1)
sets += 1;
// Acceptance is now min(odd) since we can emit Red on paths 0 with new opti
res->set_acceptance(sets, acc_cond::acc_code::parity(false, true, sets));
res->set_acceptance(sets, acc_cond::acc_code::parity_min_odd(sets));
res->prop_universal(true);
res->prop_state_acc(false);

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2017-2018 Laboratoire de Recherche et Développement
// Copyright (C) 2017-2019 Laboratoire de Recherche et Développement
// de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -77,19 +77,19 @@ namespace spot
build_iar_scc(scc_.initial());
// resulting automaton has acceptance condition: parity max odd
// with priorities ranging from 0 to 2*(nb pairs)
// /!\ priorities are shifted by -1 compared to the original paper
if (is_rabin)
res_->set_acceptance(2*pairs_.size() + 1,
acc_cond::acc_code::parity(true, true, 2*pairs_.size() + 1));
else
res_->set_acceptance(2*pairs_.size() + 1,
acc_cond::acc_code::parity(true, false, 2*pairs_.size() + 1));
// set initial state
res_->set_init_state(
iar2num.at(state2iar.at(aut_->get_init_state_number())));
{
// resulting automaton has acceptance condition: parity max odd
// for Rabin-like input and parity max even for Streett-like input.
// with priorities ranging from 0 to 2*(nb pairs)
// /!\ priorities are shifted by -1 compared to the original paper
unsigned sets = 2 * pairs_.size() + 1;
res_->set_acceptance(sets, acc_cond::acc_code::parity_max(is_rabin,
sets));
}
{
unsigned s = iar2num.at(state2iar.at(aut_->get_init_state_number()));
res_->set_init_state(s);
}
// there could be quite a number of unreachable states, prune them
res_->purge_unreachable_states();

View file

@ -128,18 +128,17 @@ namespace spot
lar_state dst{e.dst, new_perm};
unsigned dst_num = get_state(dst);
// do the h last elements satisfy the acceptance condition?
// Do the h last elements satisfy the acceptance condition?
// If they do, emit 2h, if they don't emit 2h+1.
acc_cond::mark_t m(new_perm.end() - h, new_perm.end());
if (aut_->acc().accepting(m))
res_->new_edge(src_num, dst_num, e.cond, {2*h});
else
res_->new_edge(src_num, dst_num, e.cond, {2*h+1});
bool rej = !aut_->acc().accepting(m);
res_->new_edge(src_num, dst_num, e.cond, {2*h + rej});
}
}
// parity max even
res_->set_acceptance(2*aut_->num_sets() + 2,
acc_cond::acc_code::parity(true, false, 2*aut_->num_sets() + 2));
unsigned sets = 2*aut_->num_sets() + 2;
res_->set_acceptance(sets, acc_cond::acc_code::parity_max_even(sets));
if (pretty_print)
{