stutter: fix sl, sl2 to never accept on added self-loop

Fixes #401, reported by Victor Khomenko.

* spot/twaalgos/stutter.cc (sl, sl2): If {} is accepting, upgrade the
acceptance condition.
* tests/core/stutter-tgba.test, tests/python/stutter.py: Add test cases.
This commit is contained in:
Alexandre Duret-Lutz 2020-03-12 21:54:13 +01:00
parent 150f815c87
commit b5d688dc97
3 changed files with 72 additions and 8 deletions

View file

@ -1,6 +1,6 @@
#! /bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2019 Laboratoire de Recherche et
# Copyright (C) 2014-2020 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -156,4 +156,12 @@ grep ' stutter-invariant' out
grep -q '^spot.accepted-word: "' out && exit 1
grep -q '^spot.rejected-word: "' out && exit 1
ltl2tgba 'G({x} |-> ({x[+]} <>-> ({Y1[+]} <>=> Y2)))' \
--check=stutter-sensitive-example > out
grep ' stutter-sensitive' out
grep -F 'spot-accepted-word: "cycle{!Y1 & !Y2 & x; Y1 & Y2 & x;' out
grep -F 'spot-rejected-word: "cycle{!Y1 & !Y2 & x; Y1 & Y2 & x}' out
:

View file

@ -1,5 +1,5 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2019 Laboratoire de Recherche et Développement de
# Copyright (C) 2019, 2020 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -47,3 +47,16 @@ def explain_stut(f):
w1, w2 = explain_stut('{(a:b) | (a;b)}|->Gc')
assert str(w1) == 'a & !b & !c; cycle{!a & b & !c}'
assert str(w2) == 'a & !b & !c; a & !b & !c; cycle{!a & b & !c}'
# Test from issue #401
w1, w2 = explain_stut('G({x} |-> ({x[+]} <>-> ({Y1[+]} <>=> Y2)))')
assert str(w1) == 'cycle{!Y1 & !Y2 & x; Y1 & Y2 & x}'
assert str(w2) == 'cycle{!Y1 & !Y2 & x; Y1 & Y2 & x; Y1 & Y2 & x}'
# Related to issue #401 as well. sl() and sl2() should upgrade
# the t acceptance condition into inf(0).
pos = spot.translate('Xa & XXb')
w = pos.accepting_word().as_automaton()
assert w.acc().is_t()
assert not spot.sl2(w).acc().is_buchi()
assert not spot.sl(w).acc().is_buchi()