#!/bin/sh # -*- coding: utf-8 -*- # Copyright (C) 2009, 2010, 2012, 2014, 2015, 2016 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 set -e cat >input <<\EOF HOA: v1 States: 3 Start: 0 AP: 3 "a" "b" "F\\G" acc-name: generalized-Buchi 2 Acceptance: 2 Inf(0)&Inf(1) properties: trans-labels explicit-labels state-acc deterministic --BODY-- State: 0 {0 1} [0&!1] 1 State: 1 {0} [2] 2 State: 2 [t] 0 --END-- EOF run 0 autfilt --hoa input > stdout diff stdout input test `autfilt -c --is-weak input` = 0 autfilt -H1.1 -v --is-weak input | grep properties: | tee props cat >expected.props <input <<\EOF HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" acc-name: Buchi Acceptance: 1 Inf(0) properties: trans-labels explicit-labels trans-acc --BODY-- State: 0 [0&1] 1 {0} [!1] 1 [0&!1] 1 {0} State: 1 [!1] 0 [1&0] 0 {0} [0&!1] 0 {0} --END-- EOF cat >expected <<\EOF HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" acc-name: Buchi Acceptance: 1 Inf(0) properties: trans-labels explicit-labels trans-acc --BODY-- State: 0 [!1] 1 [0] 1 {0} State: 1 [!1] 0 [0] 0 {0} --END-- EOF run 0 autfilt --merge-transitions --hoa input > stdout cat stdout run 0 autfilt -F stdout --isomorph expected # Likewise, with a randomly generated TGBA. run 0 randaut -Q 20 a b -e 0.2 -a 0.2 -A 2 --hoa | tee input # the first read-write can renumber the states run 0 autfilt --hoa --merge-transitions input > stdout run 0 autfilt -F input --isomorph stdout # But this second output should be the same as the first run 0 autfilt --hoa stdout > stdout2 diff stdout stdout2 # Find formula that can be translated into a 3-state automaton, and # exercise both %M and %m. The nonexistant file should never be # open, because the input stream is infinite and autfilt should # stop after 10 automata. randltl -n -1 a b | ltl2tgba | autfilt -F - -F nonexistant --states=3 --edges=..10 --acc-sets=1.. \ --name='%M, %S states' --stats='<%m>, %e, %a' -n 10 > output cat >expected <, 5, 1 , 5, 1 , 4, 1 , 4, 1 , 4, 1 , 6, 1 <(a & !b & (b | (!b M F!a))) | (!a & (b | (!b & (b W Ga)))), 3 states>, 5, 1 <(a & (a U !b)) | (!a & (!a R b)), 3 states>, 5, 1 , 4, 1 , 3, 1 EOF diff output expected cat >input <expected <32 edges, 64->33 transitions" States: 10 Start: 0 AP: 1 "a" acc-name: generalized-Buchi 3 Acceptance: 3 Inf(0)&Inf(1)&Inf(2) properties: trans-labels explicit-labels --BODY-- State: 0 [t] 0 {0} [!0] 1 {0} [!0] 2 {0 2} [0] 3 {0 2} [!0] 4 {0 1} [!0] 5 {0 1} [!0] 6 {0 1 2} [!0] 7 {0 1} [!0] 8 {0 1} [!0] 9 {0 1 2} State: 1 {0 2} [0] 3 State: 2 [!0] 2 {0 2} [!0] 6 {0 1 2} [!0] 9 {0 1 2} State: 3 [!0] 1 {0 2} [!0] 2 {0 2} [0] 3 {0 2} [!0] 5 {0 1 2} [!0] 6 {0 1 2} [!0] 8 {0 1 2} [!0] 9 {0 1 2} State: 4 [!0] 4 {1} [!0] 5 {1} [!0] 6 {1 2} [!0] 7 {1} [!0] 8 {1} [!0] 9 {1 2} State: 5 State: 6 {1 2} [!0] 6 [!0] 9 State: 7 [0] 0 {0} [0] 3 {0 2} State: 8 {0 2} [0] 3 State: 9 --END-- EOF autfilt --merge -Hm input --name="%E->%e edges, %T->%t transitions" > output diff output expected ltl2tgba -x degen-lskip=1 --ba > tmp.hoa < output cat >expected <input <output cat >expected < 3 subgraph cluster_0 { color=green 1 [label="s1", peripheries=2] } subgraph cluster_1 { color=green 0 [label="s0", peripheries=2] } subgraph cluster_2 { color=black 3 [label="s3"] } 0 -> 0 [label="b"] 1 -> 1 [label="a"] 2 [label="s2"] 2 -> 0 [label="b"] 3 -> 1 [label="a"] 3 -> 0 [label="b"] } EOF diff output expected test 1 = `autfilt -H input --complete | autfilt --is-complete --count` # The SPOT_DEFAULT_FORMAT envvar should be ignored if --dot is given. # --dot=k should be ignored when not applicable. SPOT_DEFAULT_FORMAT=hoa ltl2tgba --dot=ak 'GFa & GFb' >output cat output cat >expected < 0 0 [label="0"] 0 -> 0 [label="a & b\n{0,1}"] 0 -> 0 [label="!a & !b"] 0 -> 0 [label="!a & b\n{1}"] 0 -> 0 [label="a & !b\n{0}"] } EOF diff output expected ltl2tgba -dban 'GFa & GFb' >output cat output cat >expected < 0 0 [label="0"] 0 -> 0 [label="a & b\n⓿❶"] 0 -> 0 [label="!a & !b"] 0 -> 0 [label="!a & b\n❶"] 0 -> 0 [label="a & !b\n⓿"] } EOF diff output expected SPOT_DOTDEFAULT=bra ltl2tgba --dot='e.f(Lato)' 'GFa & GFb' >output cat output zero='' one='' cat >expected < labelloc="t" fontname="Lato" node [fontname="Lato"] edge [fontname="Lato"] I [label="", style=invis, width=0] I -> 0 0 [label="0"] 0 -> 0 [label=$zero$one>] 0 -> 0 [label=] 0 -> 0 [label=$one>] 0 -> 0 [label=$zero>] } EOF diff output expected cat >in <expected < 0 0 [label="0"] 0 -> 1 [label="!a & !b", taillabel="0"] 0 -> 2 [label="a & !b", taillabel="1"] 0 -> 3 [label="!a & b", taillabel="2"] 0 -> 4 [label="a & b", taillabel="3"] 1 [label="test me\n⓿❸"] 1 -> 1 [label="!a & !b", taillabel="0"] 1 -> 2 [label="a & !b", taillabel="1"] 1 -> 6 [label="!a & b", taillabel="2"] 1 -> 7 [label="a & b", taillabel="3"] 2 [label="2\n⓿❷❸"] 2 -> 1 [label="!a & !b", taillabel="0"] 2 -> 2 [label="a & !b", taillabel="1"] 2 -> 6 [label="!a & b", taillabel="2"] 2 -> 7 [label="a & b", taillabel="3"] 3 [label="3\n❸"] 3 -> 5 [label="1", taillabel="0"] 4 [label="hihi\n❷❸"] 4 -> 5 [label="1", taillabel="0"] 5 [label="5\n❶❸"] 5 -> 5 [label="1", taillabel="0"] 6 [label="6\n⓿"] 6 -> 8 [label="!a & !b", taillabel="0"] 6 -> 6 [label="!a & b", taillabel="1"] 6 -> 9 [label="a & !b", taillabel="2"] 6 -> 7 [label="a & b", taillabel="3"] 7 [label="7\n⓿❷"] 7 -> 8 [label="!a & !b", taillabel="0"] 7 -> 6 [label="!a & b", taillabel="1"] 7 -> 9 [label="a & !b", taillabel="2"] 7 -> 7 [label="a & b", taillabel="3"] 8 [label="8\n⓿❸"] 8 -> 8 [label="!a & !b", taillabel="0"] 8 -> 6 [label="!a & b", taillabel="1"] 8 -> 9 [label="a & !b", taillabel="2"] 8 -> 7 [label="a & b", taillabel="3"] 9 [label="9\n⓿❷❸"] 9 -> 8 [label="!a & !b", taillabel="0"] 9 -> 6 [label="!a & b", taillabel="1"] 9 -> 9 [label="a & !b", taillabel="2"] 9 -> 7 [label="a & b", taillabel="3"] } EOF autfilt --dot=bao in >out diff out expected cat >expected2 <' >out diff out expected2 cat >expected3 <' >out diff out expected3 # Let's pretend that this is some used supplied input, as discussed in # the comments of https://github.com/adl/hoaf/issues/39 cat >input <output1 && exit 1 cat >expect1 < output1b diff output1 output1b # Here is the scenario where the undefined states are actually states # we wanted to remove. So we tell autfilt to fix the automaton using # --remove-dead-states SPOT_DEFAULT_FORMAT=hoa autfilt --remove-dead input >output2 && exit 1 cat >expect2 <output2b cat >expect2b <input <output3 autfilt -H --remove-dead input >>output3 cat >expect3 <stderr && exit 1 grep 'print_hoa.*z' stderr cat >input4 <output4 autfilt -H --small input4 >output4b autfilt -H --high input4 >output4c cat output4 cat >expect4<output5 test `autfilt --is-weak -c output4` = 1 test `autfilt --is-terminal -c output4` = 0 sed 's/\[0\]/[t]/g' expect4 > output4d test `autfilt --is-terminal -c output4d` = 1 cat >expect5<input6 <output6 cat >expect6 <output6d cat >expect6d < 1 0 [label="0\nb"] 0 -> 2 [label=""] 0 -> 1 [label=""] 0 -> 1 [label=""] 1 [label="1\na"] 1 -> 0 [label=""] 1 -> 1 [label=""] 2 [label="2\na", peripheries=2] 2 -> 2 [label=""] 2 -> 0 [label=""] 2 -> 1 [label=""] } EOF diff output6d expect6d run 0 autfilt -dbark input6 >output6d2 cat >expect6d2 <⓿)> labelloc="t" I [label="", style=invis, width=0] I -> 1 0 [label=<0
b>] 0 -> 2 [label=<>] 0 -> 1 [label=<>] 0 -> 1 [label=<>] 1 [label=<1
a>] 1 -> 0 [label=<>] 1 -> 1 [label=<>] 2 [label=<2

a>] 2 -> 2 [label=<>] 2 -> 0 [label=<>] 2 -> 1 [label=<>] } EOF diff output6d2 expect6d2 cat >input7 <output7 cat >expected7 <input8 <input9 < output9 cat >expected9 < 2 0 [label="0", peripheries=2, style="bold", color="#5DA5DA"] 0 -> 0 [label="1", style=bold, color="#5DA5DA"] 1 [label="1"] 1 -> 0 [label="c", style=bold, color="#F17CB0"] 1 -> 1 [label="b & !c", style=bold, color="#FAA43A"] 2 [label="2", style="bold", color="#B276B2"] 2 -> 0 [label="c", style=bold, color="#B276B2"] 2 -> 1 [label="!a & b & !c"] 2 -> 2 [label="a & !c"] } EOF diff output9 expected9 # spot.hightlight.edges and spot.hightlight.states are not valid HOA # v1 output, so they should only but output for HOA 1.1 autfilt input9 -H1 | autfilt -H1 | grep highlight && exit 1 autfilt input9 -H1 | autfilt -H1.1 | grep highlight && exit 1 autfilt -H1.1 input9 | autfilt -H1.1 | grep highlight autfilt -H1.1 input9 | autfilt -d > output9b diff output9 output9b test 2 = `ltl2tgba 'GFa' 'a U b' 'a U b U c'| autfilt --ap=2..3 --count`