fix complete
Alexandre Lewkowicz reported a case where complete() would peek an existing state that is accepting, and wrongly use it as a sink. * spot/twaalgos/complete.cc: Fix the function. * tests/core/complete.test: Add two more tests. * NEWS: Mention the bug.
This commit is contained in:
parent
6c62362fe9
commit
51483b9b7f
3 changed files with 85 additions and 14 deletions
2
NEWS
2
NEWS
|
|
@ -130,6 +130,8 @@ New in spot 1.99.6a (not yet released)
|
||||||
was registered several times.
|
was registered several times.
|
||||||
* product() would incorrectly mark the product of two
|
* product() would incorrectly mark the product of two
|
||||||
sttuter-sensitive automata as stutter-sensitive as well.
|
sttuter-sensitive automata as stutter-sensitive as well.
|
||||||
|
* complete() could incorrectly reuse an existing (but accepting!)
|
||||||
|
state as a sink.
|
||||||
|
|
||||||
New in spot 1.99.6 (2015-12-04)
|
New in spot 1.99.6 (2015-12-04)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,27 +45,38 @@ namespace spot
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Loop over the states and seek a state that has only self
|
// Loop over the states and search a state that has only self
|
||||||
// loops, and that is not accepting. This will be our sink
|
// loop labeled by the same non-accepting mark. This will be
|
||||||
// state. Note that we do not even have to ensure that the
|
// our sink state. Note that we do not even have to ensure
|
||||||
// state is complete as we will complete the whole automaton
|
// that the state is complete as we will complete the whole
|
||||||
// in a second pass.
|
// automaton in a second pass.
|
||||||
for (unsigned i = 0; i < n; ++i)
|
for (unsigned i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
bool selfloop = true;
|
bool sinkable = true;
|
||||||
acc_cond::mark_t accsum = 0U;
|
bool first = true;
|
||||||
|
acc_cond::mark_t commonacc = 0U;
|
||||||
for (auto& t: aut->out(i))
|
for (auto& t: aut->out(i))
|
||||||
{
|
{
|
||||||
if (t.dst != i) // Not a self-loop
|
if (t.dst != i) // Not a self-loop
|
||||||
{
|
{
|
||||||
selfloop = false;
|
sinkable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
accsum |= t.acc;
|
if (first)
|
||||||
|
{
|
||||||
|
commonacc = t.acc;
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
if (selfloop && !aut->acc().accepting(accsum))
|
else if (t.acc != commonacc)
|
||||||
|
{
|
||||||
|
sinkable = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sinkable && !aut->acc().accepting(commonacc))
|
||||||
{
|
{
|
||||||
// We have found a sink!
|
// We have found a sink!
|
||||||
|
um.second = commonacc;
|
||||||
sink = i;
|
sink = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -74,8 +85,7 @@ namespace spot
|
||||||
|
|
||||||
unsigned t = aut->num_edges();
|
unsigned t = aut->num_edges();
|
||||||
|
|
||||||
// If the automaton is empty,
|
// If the automaton is empty, pretend that state 0 is a sink.
|
||||||
// pretend that state
|
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
sink = init;
|
sink = init;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (C) 2015 Laboratoire de Recherche et Développement de
|
# Copyright (C) 2015, 2016 Laboratoire de Recherche et Développement
|
||||||
# l'Epita (LRDE).
|
# de l'Epita (LRDE).
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
#
|
#
|
||||||
|
|
@ -57,6 +57,31 @@ State: 0
|
||||||
State: 1
|
State: 1
|
||||||
[0] 1
|
[0] 1
|
||||||
--END--
|
--END--
|
||||||
|
/* This example comes from Alexandre Lewkowicz */
|
||||||
|
HOA: v1
|
||||||
|
States: 2
|
||||||
|
Start: 0
|
||||||
|
AP: 1 "a"
|
||||||
|
Acceptance: 2 Fin(0)&Inf(1)
|
||||||
|
--BODY--
|
||||||
|
State: 0
|
||||||
|
[0] 1
|
||||||
|
State: 1
|
||||||
|
[0] 1 {0}
|
||||||
|
[!0] 1 {1}
|
||||||
|
--END--
|
||||||
|
HOA: v1
|
||||||
|
States: 2
|
||||||
|
Start: 0
|
||||||
|
AP: 1 "a"
|
||||||
|
Acceptance: 2 Fin(0)&Inf(1)
|
||||||
|
--BODY--
|
||||||
|
State: 0
|
||||||
|
[0] 1
|
||||||
|
State: 1
|
||||||
|
[0] 1 {0}
|
||||||
|
[!0] 1 {0}
|
||||||
|
--END--
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expected <<EOF
|
cat >expected <<EOF
|
||||||
|
|
@ -112,6 +137,40 @@ State: 1
|
||||||
[0] 1
|
[0] 1
|
||||||
[!0] 1
|
[!0] 1
|
||||||
--END--
|
--END--
|
||||||
|
HOA: v1
|
||||||
|
States: 3
|
||||||
|
Start: 0
|
||||||
|
AP: 1 "a"
|
||||||
|
acc-name: Rabin 1
|
||||||
|
Acceptance: 2 Fin(0) & Inf(1)
|
||||||
|
properties: trans-labels explicit-labels trans-acc complete
|
||||||
|
properties: deterministic
|
||||||
|
--BODY--
|
||||||
|
State: 0
|
||||||
|
[0] 1
|
||||||
|
[!0] 2
|
||||||
|
State: 1
|
||||||
|
[0] 1 {0}
|
||||||
|
[!0] 1 {1}
|
||||||
|
State: 2
|
||||||
|
[t] 2
|
||||||
|
--END--
|
||||||
|
HOA: v1
|
||||||
|
States: 2
|
||||||
|
Start: 0
|
||||||
|
AP: 1 "a"
|
||||||
|
acc-name: Rabin 1
|
||||||
|
Acceptance: 2 Fin(0) & Inf(1)
|
||||||
|
properties: trans-labels explicit-labels state-acc complete
|
||||||
|
properties: deterministic
|
||||||
|
--BODY--
|
||||||
|
State: 0
|
||||||
|
[0] 1
|
||||||
|
[!0] 1
|
||||||
|
State: 1 {0}
|
||||||
|
[0] 1
|
||||||
|
[!0] 1
|
||||||
|
--END--
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
run 0 autfilt -CH automaton >out
|
run 0 autfilt -CH automaton >out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue