Commit bf7ccfe7 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

new partial_degeneralize() algorithm

* spot/twaalgos/degen.hh, spot/twaalgos/degen.cc: Implement it.
* tests/python/pdegen.py: New file.
* tests/Makefile.am: Add it.
* NEWS: Mention the new function.
parent 894fda21
Pipeline #15209 passed with stage
in 82 minutes and 56 seconds
......@@ -54,6 +54,10 @@ New in spot 2.8.4.dev (not yet released)
parity_min_odd(n) = parity_min(true, n)
parity_min_even(n) = parity_min(false, n)
- partial_degeneralize() is a new function performing partial
degeneralization to get rid of conjunction of Inf terms in
acceptance conditions.
New in spot 2.8.4 (2019-12-08)
Bugs fixed:
......
This diff is collapsed.
// -*- coding: utf-8 -*-
// Copyright (C) 2012-2015, 2017, 2018 Laboratoire de
// Copyright (C) 2012-2015, 2017-2019 Laboratoire de
// Recherche et Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
......@@ -27,7 +27,7 @@ namespace spot
/// \brief Degeneralize a spot::tgba into an equivalent sba with
/// only one acceptance condition.
///
/// This algorithms will build a new explicit automaton that has
/// This algorithm will build a new explicit automaton that has
/// at most (N+1) times the number of states of the original automaton.
///
/// When \a use_z_lvl is set, the level of the degeneralized
......@@ -78,4 +78,27 @@ namespace spot
bool ignaccsl = false,
bool remove_extra_scc = true);
/// \@}
/// \ingroup twa_acc_transform
/// \brief Partial degeneralization of a TwA
///
/// Given an automaton whose acceptance contains a conjunction of
/// Inf terms, perform a partial degeneralization to replace this
/// conjunction by a single Inf term.
///
/// For instance if the input has acceptance
/// (Fin(0)&Inf(1)&Inf(3))|Fin(2)
/// calling partial_degeneralize with \a todegen set to `{1,3}`
/// will build an equivalent automaton with acceptance
/// (Fin(0)&Inf(2))|Fin(1)
///
/// where Inf(2) tracks the acceptance of the original
/// Inf(1)&Inf(3), and Fin(1) tracks the acceptance of the original
/// Fin(2).
///
/// Cases where the sets listed in \a todegen also occur outside
/// of the Inf-conjunction are also supported.
SPOT_API twa_graph_ptr
partial_degeneralize(const const_twa_graph_ptr& a,
acc_cond::mark_t todegen);
}
......@@ -393,6 +393,7 @@ TESTS_python = \
python/otfcrash.py \
python/parsetgba.py \
python/parity.py \
python/pdegen.py \
python/prodexpt.py \
python/_product_weak.ipynb \
python/_product_susp.ipynb \
......
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2019 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
#
# 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/>.
# Test that the spot.gen package works, in particular, we want
# to make sure that the objects created from spot.gen methods
# are usable with methods from the spot package.
import spot
a, b, d = spot.automata("""
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
Acceptance: 3 Inf(0)&Inf(1)|Fin(2)
--BODY--
State: 0
[0] 1 {1 2}
State: 1
[0] 0 {0}
--END--
HOA: v1
States: 3
Start: 2
AP: 1 "p0"
Acceptance: 3 Inf(0)&Inf(1)|Fin(2)
--BODY--
State: 0
[0] 1 {1 2}
State: 1
[0] 0 {0}
State: 2
[0] 0 {0}
[0] 0 {1}
--END--
HOA: v1
States: 1
Start: 0
AP: 1 "p0"
Acceptance: 1 Fin(0)
--BODY--
State: 0
[0] 0 {0}
--END--
""")
da = spot.partial_degeneralize(a, [0, 1])
assert da.equivalent_to(a)
assert da.num_states() == 2
db = spot.partial_degeneralize(b, [0, 1])
assert db.equivalent_to(b)
assert db.num_states() == 3
db.copy_state_names_from(b)
dbhoa = db.to_str('hoa')
assert dbhoa == """HOA: v1
States: 3
Start: 0
AP: 1 "p0"
acc-name: Streett 1
Acceptance: 2 Fin(0) | Inf(1)
properties: trans-labels explicit-labels state-acc deterministic
--BODY--
State: 0 "2#0"
[0] 2
State: 1 "1#0"
[0] 2
State: 2 "0#1" {0 1}
[0] 1
--END--"""
c = spot.automaton("randaut -A'(Fin(0)&Inf(1)&Inf(2))|Fin(2)' 1 |")
dc = spot.partial_degeneralize(c, [1, 2])
assert dc.equivalent_to(c)
assert str(dc.get_acceptance()) == '(Fin(0) & Inf(2)) | Fin(1)'
dd = spot.partial_degeneralize(d, [])
assert dd.equivalent_to(d)
assert dd.num_states() == 1
assert str(dd.get_acceptance()) == 'Inf(1) & Fin(0)'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment