#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009-2020 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie.
#
# 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 .
. ./defs
# If the size of automata produced by ltl2tgba on the formulas we
# commonly use as benchmark change, we want to notice it.
set -e
genltl --dac --eh --sb --hkrss --p --and-fg=32 --format=%F,%L,%f >pos
(cat pos; ltlfilt --negate pos/3 --format='!%<,%f') |
ltlfilt -u -F-/3 >formulas
ltl2tgba -Fformulas/3 --stats='%<,%f, %s,%t' |
ltl2tgba -D -F-/3 --stats='%<,%f,%>, %s,%t' |
ltl2tgba -b -F-/3 --stats='%<,%f,%>, %s,%t' |
ltl2tgba -bD -F-/3 --stats='%<,%f,%>, %s,%t' |
ltl2tgba -B -F-/3 --stats='%<,%f,%>, %s,%t' |
ltl2tgba -BD -F-/3 --stats='%<,%>, %s,%t' > output
fg42=2,4294967298
gf42=1,4294967296
cat >expected <formulas <. Issue #380.
ltlfilt -Fformulas/1 --stats='%f,%f,%>' |
ltl2tgba -F-/2 --stats='%<,%<, %s,%t' |
ltl2tgba -D -F-/2 --stats='%<,%<,%>, %s,%t' |
$PERL -p -e 's/$/\r/' |
ltl2tgba -B -F-/2 --stats='%<,%<,%>, %s,%t' |
ltl2tgba -BD -F-/2 --stats='%<,%<,%>, %s,%t' |
ltl2tgba -GD -F-/2 --stats='%<,%>, %s,%t' > output
diff formulas output
# Issue #367.
test 4 = `ltl2tgba 'GF(a<->XXa)' --stats=%s`
test 9 = `ltl2tgba --low 'GF(a<->XXa)' --stats=%s`
test 9 = `ltl2tgba -x gf-guarantee=0 'GF(a<->XXa)' --stats=%s`
test 4 = `ltl2tgba --low -x gf-guarantee=1 'GF(a<->XXa)' --stats=%s`
# Regression test for issue #357. The second formula used to
# incorrectly produce 13 edges when translated after the first one
# because the transition were explored in a different order.
ltl2tgba -D 'a | Fb' 'GF(d & (!c | XXc))' --stats=%s,%e,%d >out
cat >expected <in <out
cat >expected < c) W d))' | grep '\[f\]' && exit 1
# Reported by Jens Kreber
ltl2tgba '!b & e U (a & b & c)' | grep '\[f\]' && exit 1
ltl2tgba '!b & e U (a & b & c)' --stats=%w | grep 0 && exit 1
ltl2tgba 'X!c & X(b & c & d & a U e)' | grep '\[f\]' && exit 1
ltl2tgba 'X!c & X(b & c & d & a U e)' --stats=%w | grep 0 && exit 1
# This caused issue at some point, because simplify_acceptance would
# leave some undeclared acceptance set in the automaton, which would
# cause simulation-based reduction to produce garbage output, which
# would in turn cause the HOA printer to choke.
ltlcross -f 'G(F(Gb ^ Fa) & FG!a)' 'ltl2tgba -G -D'
# Issue #402, reported by Juraj Major.
f='(GFp0 | FGp1) & (GF!p1 | FGp2) & (GF!p2 | FG!p0)'
test 1,8,3 = `ltl2tgba -G -D "$f" --stats=%s,%e,%a`
test 1,3,2 = `ltl2tgba -G -D "(GFp0 | FGp1)" --stats=%s,%e,%a`
# Handling of Xor and <-> by ltl-split and -D -G.
res=`ltl2tgba -D -G 'X((Fa & Fb & Fc & Fd) <-> GFe)' --stats='%s %g'`
test "$res" = "17 (Inf(0)&Inf(1)) | (Fin(0) & Fin(1))"
res=`ltl2tgba -D -G 'X((Fa & Fb & Fc & Fd) ^ GFe)' --stats='%s %g'`
test "$res" = "17 (Inf(0) & Fin(1)) | (Fin(0) & Inf(1))"
ltlcross 'ltl2tgba -D -G' 'ltl2tgba -G' -f '(Fa & Fb & Fc & Fd) ^ GFe'
f='G(p1 | G!p0) M Xp1'
test "6,1" = `ltl2tgba "$f" --stats=%s,%d`
test "6,0" = `ltl2tgba -x wdba-minimize=2 "$f" --stats=%s,%d`
test "6,0" = `ltl2tgba -x wdba-minimize=0 "$f" --stats=%s,%d`
test "6,0" = `ltl2tgba --med "$f" --stats=%s,%d`
f='X((p1 & Xp1) M Fp1)'
test "4,1" = `ltl2tgba -D "$f" --stats=%s,%d`
test "4,1" = `ltl2tgba -D -x wdba-minimize=2 "$f" --stats=%s,%d`
test "4,0" = `ltl2tgba -D -x wdba-minimize=0 "$f" --stats=%s,%d`
test "4,1" = `ltl2tgba -D --med "$f" --stats=%s,%d`
# Issue #418.
f='(G!a | G!b | G!c) & (FG!a2 | GFb2 | GFc2) & (GFc2 | FG!b2 | GFa2)'
test 28 = `ltl2tgba -D -G -S --stats=%s "$f"`
# Issue #443. This used to be too long.
f='(!(G({(a)} |=> {(b)[*32]})))'
test 34,0 = `ltl2tgba -B --stats=%s,%d "$f"`
# Issue #444. Because WDBA-minimization disables itself for large
# automata, the output is only deterministic up to a certain point,
# and the goal is to raise that point.
f='(!(G({(a)} |=> {(b)[*12]})))'
test 14,1 = `ltl2tgba -B --stats=%s,%d "$f"`
f='(!(G({(a)} |=> {(b)[*13]})))'
test 15,0 = `ltl2tgba -B --stats=%s,%d "$f"`
# Related to Issue #298. The difference between the translation of
# this formula with --med and --high is just a different ordering of
# the states caused by the use of exprop.
opts="-x scc-filter=0,tls-impl=0,gf-guarantee=0,wdba-minimize=0"
f='G(p0 -> F(p1 & !p2 & X(!p2 U p3)))'
ltl2tgba $opts --med "$f" >med.hoa
ltl2tgba $opts,exprop=0 "$f" > high.hoa
diff med.hoa high.hoa
ltl2tgba $opts "$f" > high.hoa
test $(wc -l < med.hoa) = $(wc -l < high.hoa)
cmp med.hoa high.hoa && exit 1
autfilt --stats=%F:%s,%e med.hoa high.hoa >out
cat >exp <