twagraph: new kill_state method

This proceeds from a discussion with Michaël Cadilhac.
http://lists.lrde.epita.fr/pipermail/spot/2021q1/000356.html

* bin/autfilt.cc (--kill-states): New option.
* NEWS: Mention those.
* spot/twa/twagraph.hh, spot/twa/twagraph.cc: Add a kill_state()
method.
* tests/core/maskkeep.test: Test it.
This commit is contained in:
Alexandre Duret-Lutz 2021-02-19 16:31:49 +01:00
parent da0dd4c534
commit caa960d857
5 changed files with 100 additions and 0 deletions

View file

@ -822,6 +822,35 @@ namespace spot
set_named_prop("state-names", names.release());
}
void twa_graph::kill_state(unsigned state)
{
auto t = g_.out_iteraser(state);
while (t)
t.erase();
// A complete automaton is unlikely to stay
// complete after killing a state.
if (prop_complete().is_true())
prop_complete(trival::maybe());
prop_stutter_invariant(trival::maybe());
// Many properties are preserved by state removal, and may even
// become true if they were false before and the appropriate
// states are removed.
if (prop_universal().is_false())
prop_universal(trival::maybe());
if (prop_inherently_weak().is_false())
prop_inherently_weak(trival::maybe());
if (prop_weak().is_false())
prop_weak(trival::maybe());
if (prop_very_weak().is_false())
prop_very_weak(trival::maybe());
if (prop_terminal().is_false())
prop_terminal(trival::maybe());
if (prop_unambiguous().is_false())
prop_unambiguous(trival::maybe());
if (prop_semi_deterministic().is_false())
prop_semi_deterministic(trival::maybe());
}
void twa_graph::dump_storage_as_dot(std::ostream& out,
const char* opt) const
{

View file

@ -726,6 +726,15 @@ namespace spot
///@}
#endif // SWIG
/// \brief Make a state dead.
///
/// A state is dead if it has no successors. So this function
/// simply erases all edges leaving \a state.
///
/// It can be used together with purge_dead_states() to remove a
/// set of states from an automaton.
void kill_state(unsigned state);
/// \brief Print the data structures used to represent the
/// automaton in dot's format.
///