spot/tests/core/568.test
Alexandre Duret-Lutz ab7f4f51c4 simulation: fix determinism check
Commit bda40a5f introduced a subtle bug where nm_minato was being
increased in more cases causing some non-deterministic automata to be
incorrectly tagged as deterministic automata.

Fixes issue #575, reported by Dávid Smolka.

* spot/twaalgos/simulation.cc (create_edges): Do not increment
nm_minato when dest is bddfalse.
* tests/core/568.test: Add Dávid's first test-case.
* tests/python/forq_contains.py: Add Dávid's second test-case.
2024-04-24 23:59:07 +02:00

127 lines
4 KiB
Bash
Executable file

#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) by the Spot authors, see the AUTHORS file for details.
#
# 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/>.
. ./defs
set -e
# For issue #568. Before the patch implemented for #568, running
# simulation-based reduction on automata with many APs was getting
# exponentially slow even if few different labels were used.
#
# For instance we had this:
#
# % genaut --cycle-onehot=10..20 --name='size %L' |
# autfilt --small --stats='%M: %S->%s in %r seconds'
# size 10: 100->10 in 0.0395407 seconds
# size 11: 121->11 in 0.0950484 seconds
# size 12: 144->12 in 0.227828 seconds
# size 13: 169->13 in 0.391545 seconds
# size 14: 196->14 in 0.954784 seconds
# size 15: 225->15 in 2.34656 seconds
# size 16: 256->16 in 5.80549 seconds
# size 17: 289->17 in 14.3545 seconds
# size 18: 324->18 in 47.1589 seconds
# size 19: 361->19 in 138.023 seconds
#
# The test below shows that even with --cycle-onehot-nba=80 we don't
# have any problem now.
genaut --cycle-onehot-nba=20 \
--cycle-onehot-nba=40 \
--cycle-onehot-nba=60 \
--cycle-onehot-nba=80 \
--cycle-log-nba=20 \
--cycle-log-nba=40 \
--cycle-log-nba=60 \
--cycle-log-nba=80 \
| autfilt --small --stats='%S -> %s' > out
cat >expected <<EOF
400 -> 20
1600 -> 40
3600 -> 60
6400 -> 6400
400 -> 20
1600 -> 40
3600 -> 60
6400 -> 6400
EOF
diff expected out
# the reason for the 6400 states above is that simulation-based
# reductions are disabled above 4096 states by default. This can be
# changed with -x simul-max=N.
genaut --cycle-onehot-nba=80 --cycle-log-nba=80 \
| autfilt -x simul-max=6400 --small --stats='%S -> %s' > out
cat >expected <<EOF
6400 -> 80
6400 -> 80
EOF
diff expected out
genaut --cycle-onehot=7..12 |
autfilt --parity -D --stats="%S -> %s" > out
cat >expected <<EOF
49 -> 13
64 -> 15
81 -> 17
100 -> 19
121 -> 4360
144 -> 9481
EOF
genaut --cycle-onehot=7..12 |
autfilt -x simul-max=10000 --parity -D --stats="%S -> %s" > out
cat >expected <<EOF
49 -> 13
64 -> 15
81 -> 17
100 -> 19
121 -> 21
144 -> 23
EOF
# Using autcross will also test tgba_determinize
genaut --cycle-onehot-nba=11..12 --cycle-log-nba=11..12 |
autcross --language-preserved 'autfilt --small' --verbose
# A test case from issue #575
cat >575.hoa <<EOF
HOA: v1 States: 16 Start: 0 AP: 7 "p12" "p28" "p14" "p34" "p30" "p29"
"p35" acc-name: Buchi Acceptance: 1 Inf(0) properties: trans-labels
explicit-labels state-acc --BODY-- State: 0 [0&1&!3] 1 [0&1&3] 2
[!0&1&!3] 3 [0&!1&!3] 4 [!0&!1&3] 5 [!0&1&3] 6 [0&!1&3] 7 [!0&!1&!3] 8
State: 1 {0} [t] 1 State: 2 [!3] 1 [3] 2 State: 3 [t] 9 State: 4 [t]
10 State: 5 [3] 12 [!3 | !6] 13 State: 6 [!3 | !6] 9 [3] 14 State: 7
[!3 | !6] 10 [3] 15 State: 8 [t] 13 State: 9 [2] 1 [!2] 9 State: 10
[4] 1 [!4] 10 [!4&5] 11 State: 11 {0} [5] 11 State: 12 [2&!3&4] 1
[2&3&4] 2 [!2&!3&4] 9 [2&!3&!4] 10 [2&!3&!4&5] 11 [!2&3&!4] 12
[!2&!3&!4] 13 [!2&3&4] 14 [2&3&!4] 15 State: 13 [2&4] 1 [!2&4] 9
[2&!4] 10 [2&!4&5] 11 [!2&!4] 13 State: 14 [2&!3] 1 [2&3] 2 [!2&!3] 9
[!2&3] 14 State: 15 [!3&4] 1 [3&4] 2 [!3&!4] 10 [!3&!4&5] 11 [3&!4] 15
--END--
EOF
# the automaton original bug was detected by print_hoa, which complained
# that the non-derministic automaton was incorrectly tagged as deterministic.
# So let's print the automaton in HOA format before checking its size.
autfilt --small 575.hoa -H > res.hoa
test "16 49 0" = "`autfilt --stats='%s %e %d' res.hoa`"