remove_fin: never return acceptance "f"
Fixes #333. * spot/twaalgos/remfin.cc, spot/twaalgos/remfin.hh, spot/twaalgos/totgba.cc: Adjust. The assert() added to remove_fin() triggered a lot of failure in the test suite before the different functions were fixed. * tests/core/remfin.test, tests/python/tra2tba.py: Adjust expected result. * NEWS: Mention the bug.
This commit is contained in:
parent
f2b3653226
commit
1db3472a99
6 changed files with 64 additions and 14 deletions
3
NEWS
3
NEWS
|
|
@ -28,6 +28,9 @@ New in spot 2.5.1.dev (not yet released)
|
||||||
acc_cond::is_generalized_streett() would segfault on weird
|
acc_cond::is_generalized_streett() would segfault on weird
|
||||||
acceptance conditions such as "3 t" or "3 f".
|
acceptance conditions such as "3 t" or "3 f".
|
||||||
|
|
||||||
|
- remove_fin(), streett_to_generalized_buchi() should never
|
||||||
|
return automata with "f" acceptance.
|
||||||
|
|
||||||
New in spot 2.5.1 (2018-02-20)
|
New in spot 2.5.1 (2018-02-20)
|
||||||
|
|
||||||
Library:
|
Library:
|
||||||
|
|
|
||||||
|
|
@ -465,6 +465,20 @@ namespace spot
|
||||||
|
|
||||||
twa_graph_ptr trivial_strategy(const const_twa_graph_ptr& aut)
|
twa_graph_ptr trivial_strategy(const const_twa_graph_ptr& aut)
|
||||||
{
|
{
|
||||||
|
if (aut->acc().is_f())
|
||||||
|
{
|
||||||
|
// The original acceptance was equivalent to
|
||||||
|
// "f". Simply return an empty automaton with "t"
|
||||||
|
// acceptance.
|
||||||
|
auto res = make_twa_graph(aut->get_dict());
|
||||||
|
res->set_generalized_buchi(0);
|
||||||
|
res->set_init_state(res->new_state());
|
||||||
|
res->prop_stutter_invariant(true);
|
||||||
|
res->prop_weak(true);
|
||||||
|
res->prop_complete(false);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
return (!aut->acc().uses_fin_acceptance())
|
return (!aut->acc().uses_fin_acceptance())
|
||||||
? std::const_pointer_cast<twa_graph>(aut)
|
? std::const_pointer_cast<twa_graph>(aut)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
@ -515,10 +529,14 @@ namespace spot
|
||||||
if (acccode.is_f())
|
if (acccode.is_f())
|
||||||
{
|
{
|
||||||
// The original acceptance was equivalent to
|
// The original acceptance was equivalent to
|
||||||
// "f". Simply return an empty automaton.
|
// "f". Simply return an empty automaton with "t"
|
||||||
|
// acceptance.
|
||||||
auto res = make_twa_graph(aut->get_dict());
|
auto res = make_twa_graph(aut->get_dict());
|
||||||
res->set_acceptance(0, acccode);
|
res->set_generalized_buchi(0);
|
||||||
res->set_init_state(res->new_state());
|
res->set_init_state(res->new_state());
|
||||||
|
res->prop_stutter_invariant(true);
|
||||||
|
res->prop_weak(true);
|
||||||
|
res->prop_complete(false);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -748,6 +766,18 @@ namespace spot
|
||||||
trace << "before cleanup: " << res->get_acceptance() << '\n';
|
trace << "before cleanup: " << res->get_acceptance() << '\n';
|
||||||
cleanup_acceptance_here(res);
|
cleanup_acceptance_here(res);
|
||||||
trace << "after cleanup: " << res->get_acceptance() << '\n';
|
trace << "after cleanup: " << res->get_acceptance() << '\n';
|
||||||
|
if (res->acc().is_f())
|
||||||
|
{
|
||||||
|
// "f" is not generalized-Büchi. Just return an
|
||||||
|
// empty automaton instead.
|
||||||
|
auto res2 = make_twa_graph(res->get_dict());
|
||||||
|
res2->set_generalized_buchi(0);
|
||||||
|
res2->set_init_state(res2->new_state());
|
||||||
|
res2->prop_stutter_invariant(true);
|
||||||
|
res2->prop_weak(true);
|
||||||
|
res2->prop_complete(false);
|
||||||
|
return res2;
|
||||||
|
}
|
||||||
res->merge_edges();
|
res->merge_edges();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -824,6 +854,9 @@ namespace spot
|
||||||
|
|
||||||
twa_graph_ptr remove_fin(const const_twa_graph_ptr& aut)
|
twa_graph_ptr remove_fin(const const_twa_graph_ptr& aut)
|
||||||
{
|
{
|
||||||
return remove_fin_impl(aut);
|
twa_graph_ptr res = remove_fin_impl(aut);
|
||||||
|
assert(!res->acc().uses_fin_acceptance());
|
||||||
|
assert(!res->acc().is_f());
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,16 @@ namespace spot
|
||||||
rabin_to_buchi_maybe(const const_twa_graph_ptr& aut);
|
rabin_to_buchi_maybe(const const_twa_graph_ptr& aut);
|
||||||
|
|
||||||
/// \ingroup twa_acc_transform
|
/// \ingroup twa_acc_transform
|
||||||
/// \brief Rewrite an automaton without Fin acceptance.
|
/// \brief Rewrite an automaton without Fin or f acceptance.
|
||||||
///
|
///
|
||||||
/// This algorithm dispatches between many strategies. It has
|
/// This algorithm dispatches between many strategies. It has
|
||||||
/// dedicated algorithms for weak automata, automata with Rabin-like
|
/// dedicated algorithms for weak automata, automata with Rabin-like
|
||||||
/// acceptance, automata with Streett-like acceptance, and some
|
/// acceptance, automata with Streett-like acceptance, and some
|
||||||
/// generic code that will work on any kind of acceptance condition.
|
/// generic code that will work on any kind of acceptance condition.
|
||||||
|
///
|
||||||
|
/// In Spot "f" acceptance is not considered Fin-less, because
|
||||||
|
/// it can be seen as a case of generalized co-Büchi with 0 sets.
|
||||||
|
/// Just like "t" corresponds generalized Büchi with 0 sets.)
|
||||||
SPOT_API twa_graph_ptr
|
SPOT_API twa_graph_ptr
|
||||||
remove_fin(const const_twa_graph_ptr& aut);
|
remove_fin(const const_twa_graph_ptr& aut);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -757,6 +757,18 @@ namespace spot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
simplify_acceptance_here(out);
|
simplify_acceptance_here(out);
|
||||||
|
if (out->acc().is_f())
|
||||||
|
{
|
||||||
|
// "f" is not generalized-Büchi. Just return an
|
||||||
|
// empty automaton instead.
|
||||||
|
auto res = make_twa_graph(out->get_dict());
|
||||||
|
res->set_generalized_buchi(0);
|
||||||
|
res->set_init_state(res->new_state());
|
||||||
|
res->prop_stutter_invariant(true);
|
||||||
|
res->prop_weak(true);
|
||||||
|
res->prop_complete(false);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -363,9 +363,10 @@ HOA: v1
|
||||||
States: 1
|
States: 1
|
||||||
Start: 0
|
Start: 0
|
||||||
AP: 0
|
AP: 0
|
||||||
acc-name: none
|
acc-name: all
|
||||||
Acceptance: 0 f
|
Acceptance: 0 t
|
||||||
properties: trans-labels explicit-labels state-acc deterministic
|
properties: trans-labels explicit-labels state-acc deterministic
|
||||||
|
properties: stutter-invariant weak
|
||||||
--BODY--
|
--BODY--
|
||||||
State: 0
|
State: 0
|
||||||
--END--
|
--END--
|
||||||
|
|
|
||||||
|
|
@ -91,18 +91,15 @@ State: 1
|
||||||
""")
|
""")
|
||||||
|
|
||||||
exp = """HOA: v1
|
exp = """HOA: v1
|
||||||
States: 2
|
States: 1
|
||||||
Start: 0
|
Start: 0
|
||||||
AP: 2 "a" "b"
|
AP: 0
|
||||||
acc-name: none
|
acc-name: all
|
||||||
Acceptance: 0 f
|
Acceptance: 0 t
|
||||||
properties: trans-labels explicit-labels state-acc deterministic
|
properties: trans-labels explicit-labels state-acc deterministic
|
||||||
|
properties: stutter-invariant weak
|
||||||
--BODY--
|
--BODY--
|
||||||
State: 0
|
State: 0
|
||||||
[!0] 0
|
|
||||||
[0] 1
|
|
||||||
State: 1
|
|
||||||
[0] 1
|
|
||||||
--END--"""
|
--END--"""
|
||||||
|
|
||||||
res = spot.remove_fin(aut)
|
res = spot.remove_fin(aut)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue