scc_filter: preserve state names and highlighted states
Suggested by Juraj Major. * spot/twaalgos/sccfilter.cc: Here. * tests/python/sccfilter.py: New file. * tests/Makefile.am: Add it. * NEWS: Mention the news.
This commit is contained in:
parent
dd706d7847
commit
85f6e0e158
4 changed files with 92 additions and 2 deletions
2
NEWS
2
NEWS
|
|
@ -40,6 +40,8 @@ New in spot 2.1.2.dev (not yet released)
|
|||
this halves the run time of
|
||||
genltl --rv-counter=10 | ltl2tgba
|
||||
|
||||
* scc_filter() learned to preserve state names and highlighted states.
|
||||
|
||||
Bugs:
|
||||
|
||||
* ltl2tgba was alway using the highest settings for the LTL
|
||||
|
|
|
|||
|
|
@ -330,10 +330,37 @@ namespace spot
|
|||
// has one initial state).
|
||||
auto init = inout[aut->get_init_state_number()];
|
||||
filtered->set_init_state(init < out_n ? init : filtered->new_state());
|
||||
|
||||
if (auto* names =
|
||||
aut->get_named_prop<std::vector<std::string>>("state-names"))
|
||||
{
|
||||
std::cerr << "names\n";
|
||||
unsigned size = names->size();
|
||||
if (size > in_n)
|
||||
size = in_n;
|
||||
auto* new_names = new std::vector<std::string>(out_n);
|
||||
filtered->set_named_prop("state-names", new_names);
|
||||
for (unsigned s = 0; s < size; ++s)
|
||||
{
|
||||
unsigned new_s = inout[s];
|
||||
if (new_s != -1U)
|
||||
(*new_names)[new_s] = (*names)[s];
|
||||
}
|
||||
}
|
||||
if (auto hs =
|
||||
aut->get_named_prop<std::map<unsigned, unsigned>>("highlight-states"))
|
||||
{
|
||||
auto* new_hs = new std::map<unsigned, unsigned>;
|
||||
filtered->set_named_prop("highlight-states", new_hs);
|
||||
for (auto p: *hs)
|
||||
{
|
||||
unsigned new_s = inout[p.first];
|
||||
if (new_s != -1U)
|
||||
new_hs->emplace(new_s, p.second);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
twa_graph_ptr
|
||||
|
|
|
|||
|
|
@ -342,6 +342,7 @@ TESTS_python = \
|
|||
python/remfin.py \
|
||||
python/satmin.py \
|
||||
python/setacc.py \
|
||||
python/sccfilter.py \
|
||||
python/setxor.py \
|
||||
python/trival.py \
|
||||
$(TESTS_ipython)
|
||||
|
|
|
|||
60
tests/python/sccfilter.py
Normal file
60
tests/python/sccfilter.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- mode: python; coding: utf-8 -*-
|
||||
# Copyright (C) 2016 Laboratoire de Recherche et Développement de
|
||||
# l'EPITA.
|
||||
#
|
||||
# This file is part of Spot, a model checking library.
|
||||
#
|
||||
# Spot is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make sure scc_filter preserves state-names (suggested by Juraj
|
||||
# Major)
|
||||
|
||||
import spot
|
||||
|
||||
a = spot.automaton("""
|
||||
HOA: v1.1
|
||||
States: 3
|
||||
Start: 1
|
||||
AP: 1 "a"
|
||||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
spot.highlight.states: 0 0 2 3
|
||||
--BODY--
|
||||
State: 0 "baz"
|
||||
[t] 0
|
||||
State: 2 "foo" {0}
|
||||
[0] 0
|
||||
[0] 2
|
||||
[!0] 2
|
||||
State: 1 "bar"
|
||||
[0] 2
|
||||
--END--
|
||||
""")
|
||||
|
||||
assert (spot.scc_filter(a, True).to_str('hoa', '1.1') == """HOA: v1.1
|
||||
States: 2
|
||||
Start: 0
|
||||
AP: 1 "a"
|
||||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
properties: trans-labels explicit-labels state-acc !complete
|
||||
properties: deterministic
|
||||
spot.highlight.states: 1 3
|
||||
--BODY--
|
||||
State: 0 "bar"
|
||||
[0] 1
|
||||
State: 1 "foo" {0}
|
||||
[t] 1
|
||||
--END--""")
|
||||
Loading…
Add table
Add a link
Reference in a new issue