#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2018, 2020 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# 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

cat >test1 <<EOF
/*
** This was a TGBA for GFa & GFb, but
** the acceptance has been changed to Fin(0)|Fin(1)
** so this is now the complement automaton.
*/
HOA: v1
States: 1
Start: 0
AP: 2 "a" "b"
Acceptance: 2 Fin(0)|Fin(1)
--BODY--
State: 0
[0&1] 0 {0 1}
[!0&!1] 0
[!0&1] 0 {1}
[0&!1] 0 {0}
--END--
/*
** This one has a mix of Inf and Fin acceptance, but no interference
** between the Fin sets
*/
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
Acceptance: 5 Inf(0)&Fin(1)&Fin(3) | Inf(2)&Inf(3) | Inf(4)
--BODY--
State: 0 {3 4}
[t] 0
[0] 1 {1}
[!0] 2 {0}
State: 1 {3}
[1] 0
[0&1] 1 {0}
[!0&1] 2 {2}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
/*
** This one is similar, but Inf(0) is used in two terms, so
** we need to introduce extra sets in the output.
*/
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 4 Inf(0)&Fin(1)&Fin(3) | Inf(2)&Inf(3) | Inf(0)
--BODY--
State: 0 {3}
[t] 0
[0] 1 {1}
[!0] 2 {0}
State: 1 {3}
[1] 0
[0&1] 1 {0}
[!0&1] 2 {2}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
/*
** The t and f acceptance.
*/
HOA: v1
States: 1
Start: 0
Acceptance: 0 f
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
Acceptance: 0 t
--BODY--
State: 0
[t] 0
--END--
/* An example from ltl2dstar.
** No new state should be added.
*/
HOA: v1
States: 2
acc-name: Rabin 1
Acceptance: 2 (Fin(0)&Inf(1))
Start: 0
AP: 1 "p0"
--BODY--
State: 0 {}
0
1
State: 1 {1}
1
1
--END--
HOA: v1
States: 8
Start: 2
AP: 1 "p1"
Acceptance: 4 (Fin(3) & Inf(0)) | (Fin(1) & Fin(3)) |
              (Fin(1) & Inf(2)) | (Inf(0)&Inf(2))
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0
[!0] 6
[0] 0
State: 1 {2}
[!0] 3
[0] 3
State: 2 {2}
[!0] 5
[0] 1
State: 3 {2}
[!0] 6
[0] 0
State: 4 {2}
[!0] 6
[0] 4
State: 5 {2}
[!0] 7
[0] 3
State: 6 {1 2}
[!0] 6
[0] 0
State: 7 {3}
[!0] 6
[0] 4
--END--
/* echo 'i F ^ F p1 U p0 V G p0 p1 F V f p0' | ltl2dstar -H - - | fmt */
HOA: v1 States: 14 properties: implicit-labels
trans-labels no-univ-branch deterministic complete comment:
"Union{Safra[NBA=9],Safra[NBA=2]}" acc-name: Rabin 5 Acceptance: 10
(Fin(0)&Inf(1))|(Fin(2)&Inf(3))|(Fin(4)&Inf(5))|(Fin(6)&Inf(7))|(Fin(8)&Inf(9))
Start: 13 AP: 2 "p1" "p0" --BODY-- State: 0 {3 4 7 9} 12 11 1 0 State:
1 {5 6 9} 12 11 1 0 State: 2 {3 4 6 9} 10 11 2 9 State: 3 {3 4 6 9}
12 11 1 3 State: 4 {3 4 6 9} 12 12 4 7 State: 5 {1 2 4 6 9} 10 12 5 8
State: 6 {1 2 4 6 9} 12 11 4 6 State: 7 {1 2 4 6 9} 12 12 4 7 State:
8 {0 2 4 6 9} 12 12 8 8 State: 9 {2 4 6 9} 12 11 1 3 State: 10 {1 2 4
6 8} 10 12 5 8 State: 11 {1 2 4 6 8} 12 11 8 6 State: 12 {0 2 4 6 8}
12 12 8 8 State: 13 {2 4 6 8} 10 11 2 3 --END--
/* ltlfilt -l -f '(F((p1) R (p0))) | (G(F(p0)))' | ltl2dstar -H - - |
   ./autfilt --merge -H | fmt

   This one is DBA-type, however because some unused acceptance sets are
   removed before calling remfin(), that function could miss the fact
   that this was a Rabin automaton...
*/
HOA: v1 States: 4 Start: 0 AP: 2 "p1" "p0" acc-name: Rabin 3 Acceptance:
6 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) | (Fin(4) & Inf(5)) properties:
trans-labels explicit-labels state-acc complete deterministic --BODY--
State: 0 {2} [!1] 0 [0&1] 2 [!0&1] 3 State: 1 {1 2} [!1] 1 [1] 2 State:
2 {1 2 5} [!1] 1 [1] 2 State: 3 {3 5} [!1] 0 [0&1] 2 [!0&1] 3 --END--
/*
  ltlfilt -f '(X((X(p0)) R ((!(p1)) | (X(p0)))))' -l |
  ltl2dstar --automata=streett -H --ltl2nba=spin:ltl2tgba@-s - - |
  fmt

  This Streett automaton can be seen as a Rabin-like automaton with
  two pairs.   So the BA-type check should apply.  During testing, it
  triggered assertions.
*/
HOA: v1 States: 6 properties: implicit-labels trans-labels no-univ-branch
deterministic complete comment: "Streett{Safra[NBA=5]}" acc-name: Streett
1 Acceptance: 2 (Fin(0)|Inf(1)) Start: 5 AP: 2 "p0" "p1" --BODY-- State:
0 {0} 0 0 0 0 State: 1 {0} 0 2 0 2 State: 2 {1} 2 2 2 2 State: 3 {}
3 2 1 2 State: 4 {} 3 3 1 1 State: 5 {} 4 4 4 4 --END--
/*
  ltlfilt -l -f '(F(!((1) U (!((G(p0)) -> (p1))))))' | ltl2dstar -H - - | fmt

  This Rabin automaton was incorrectly reduced at some point.
*/
HOA: v1 States: 4 properties: implicit-labels trans-labels no-univ-branch
deterministic complete stutter-insensitive comment: "Safra[NBA=3]"
acc-name: Rabin 2 Acceptance: 4 (Fin(0)&Inf(1))|(Fin(2)&Inf(3)) Start:
1 AP: 2 "p0" "p1" --BODY-- State: 0 {2} 2 0 2 3 State: 1 {0 2} 2 1 2 2
State: 2 {1 2} 2 0 2 2 State: 3 {3} 2 0 2 3 --END--
/* This is the square of smaller.hoa from issue #188. */
HOA: v1 States: 37 Start: 0 AP: 2 "a" "b" Acceptance: 24 (Inf(11) |
Fin(5)) & (Inf(10) | Fin(4)) & (Inf(9) | Fin(3)) & (Inf(8) | Fin(2)) &
(Inf(7) | Fin(1)) & (Inf(6) | Fin(0)) & (Inf(23) | Fin(17)) & (Inf(22)
| Fin(16)) & (Inf(21) | Fin(15)) & (Inf(20) | Fin(14)) & (Inf(19) |
Fin(13)) & (Inf(18) | Fin(12)) properties: trans-labels explicit-labels
trans-acc complete --BODY-- State: 0 [!0] 0 {0 12} [0] 1 [0&1] 2 [0&1]
3 [0&1] 4 State: 1 [t] 1 {1 13} [1] 2 {1} [1] 3 {13} [1] 4 State: 2
[t] 2 {1 14} [!1] 5 {1} [1] 4 {14} State: 3 [t] 3 {2 13} [1] 4 {2} [!1]
6 {13} State: 4 [t] 4 {2 14} [!1] 7 {2} [!1] 8 {14} [!1] 9 State: 5 [t]
5 {1 15} [1] 10 {1} [1] 7 {15} [1] 11 State: 6 [t] 6 {3 13} [1] 8 {3}
[1] 12 {13} [1] 13 State: 7 [t] 7 {2 15} [1] 11 {2} [!1] 9 {15} State:
8 [t] 8 {3 14} [!1] 9 {3} [1] 13 {14} State: 9 [t] 9 {3 15} [1] 14 {3}
[1] 15 {15} [1] 16 State: 10 [t] 10 {1 16} [!1] 17 {1} [1] 11 {16}
State: 11 [t] 11 {2 16} [!1] 18 {2} [!1] 14 {16} [!1] 19 State: 12 [t]
12 {4 13} [1] 13 {4} [!1] 20 {13} State: 13 [t] 13 {4 14} [!1] 15 {4}
[!1] 21 {14} [!1] 22 State: 14 [t] 14 {3 16} [!1] 19 {3} [1] 16 {16}
State: 15 [t] 15 {4 15} [1] 16 {4} [!1] 22 {15} State: 16 [t] 16 {4 16}
[!1] 23 {4} [!1] 24 {16} [!1] 25 State: 17 [1] 26 {1 23} [!1] 17 {1 17}
[1] 27 {23} State: 18 [1] 27 {2 23} [!1] 18 {2 17} [!1] 19 {17} State:
19 [1] 28 {3 23} [!1] 19 {3 17} [1] 29 {23} State: 20 [1] 30 {11 13}
[1] 31 {11} [!1] 20 {5 13} State: 21 [1] 31 {11 14} [!1] 21 {5 14} [!1]
22 {5} State: 22 [1] 32 {11 15} [1] 33 {11} [!1] 22 {5 15} State: 23
[1] 29 {4 23} [!1] 23 {4 17} [!1] 25 {17} State: 24 [1] 33 {11 16} [!1]
24 {5 16} [!1] 25 {5} State: 25 [1] 34 {11 23} [!1] 25 {5 17} State: 26
[t] 26 {1} [1] 27 State: 27 [t] 27 {2} [!1] 28 State: 28 [t] 28 {3} [1]
29 State: 29 [t] 29 {4} [!1] 35 State: 30 [t] 30 {13} [1] 31 State: 31
[t] 31 {14} [!1] 32 State: 32 [t] 32 {15} [1] 33 State: 33 [t] 33 {16}
[!1] 36 State: 34 [t] 34 State: 35 [1] 34 {11} [!1] 35 {5} State: 36
[1] 34 {23} [!1] 36 {17} --END--
HOA: v1
States: 2
Acceptance: 3 Fin(0) | (Fin(1)&Inf(2))
Start: 0
AP: 1 "a"
--BODY--
State: 0 {0}
[0] 1
[!0] 0
State: 1 {2}
[0] 1
[!0] 0
--END--
/*
** This random automaton caused remove_fin() to output
** an automaton with transition-based acceptance incorrectly marked as
** state-based.
*/
HOA: v1 States: 10 Start: 0 AP: 2 "p0" "p1" Acceptance: 4 Fin(1) |
(Fin(2) & Fin(3) & Fin(0)) properties: trans-labels explicit-labels
trans-acc --BODY-- State: 0 [!0&1] 5 [!0&1] 7 State: 1 [0&!1] 2 {2}
[0&1] 9 {1} [!0&1] 1 [0&!1] 6 {1 3} State: 2 [!0&1] 8 {0 1} [!0&!1]
1 {1} State: 3 [!0&1] 5 {1} [0&1] 2 State: 4 [0&!1] 4 {1} [0&1] 6 {0}
[0&1] 5 {1} State: 5 [0&1] 9 {1} State: 6 [0&1] 5 {2 3} [!0&1] 9 {2}
[!0&1] 4 State: 7 [0&!1] 8 {3} [!0&!1] 7 {2} [0&!1] 3 {2} [!0&1] 5 {1}
State: 8 [!0&1] 8 {2} [!0&!1] 3 {1} [!0&1] 4 State: 9 [0&!1] 6 {0 3}
[!0&1] 2 --END--
/* Exposed the bug from issue #279 */
HOA: v1 States: 3 Start: 0 AP: 2 "b" "c" Acceptance: 3 Fin(0) &
(Inf(1)&Inf(2)) properties: trans-labels explicit-labels trans-acc
complete --BODY-- State: 0 [!0] 0 {1 2} [0] 0 {0 1 2} [0&!1] 1 [0&1] 2
State: 1 [!0 | !1] 1 {1 2} [0&1] 2 {1} State: 2 [!1] 1 {1 2} [1] 2 {1}
--END--
/*
** Issue #313.  The TGBA conversion of this automaton was wrong.
*/
HOA: v1
States: 2
Start: 0
AP: 3 "a" "b" "c"
Acceptance: 4 (Fin(1)|Fin(2)) & Fin(0) & Inf(3)
properties: trans-labels explicit-labels trans-acc complete
--BODY--
State: 0
[t] 0 {0 3}
[1 | 2] 0 {1 3}
[0] 0 {2 3}
[!1&!2] 1 {1}
State: 1
[2] 0 {0 3}
[2] 0 {1 3}
[0&2] 0 {2 3}
[!2] 1 {0}
[!2] 1 {1}
[0&!2] 1 {2}
--END--
EOF

cat >expected <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[t] 0
[!0] 1
[!1] 2
State: 1 {0}
[!0] 1
State: 2 {0}
[!1] 2
--END--
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {0}
[0] 1 {0}
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1
[!0&!1] 2 {0}
--END--
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[0] 1
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1 {0}
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
properties: stutter-invariant weak
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!0] 0
[0] 1
State: 1 {0}
[!0] 1
[0] 1
--END--
HOA: v1
States: 10
Start: 2
AP: 1 "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[0] 0
[!0] 6
[0] 8
[0] 9
State: 1
[t] 3
State: 2
[0] 1
[!0] 5
State: 3
[0] 0
[!0] 6
State: 4 {0}
[0] 4
[!0] 6
State: 5
[0] 3
[!0] 7
State: 6
[0] 0
[!0] 6
State: 7
[0] 4
[!0] 6
State: 8
[0] 8
State: 9 {0}
[0] 9
--END--
HOA: v1
States: 15
Start: 13
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0 {0}
[0&1] 0
[!0&1] 1
[0&!1] 11
[!0&!1] 12
State: 1 {0}
[0&1] 0
[!0&1] 1
[0&!1] 11
[!0&!1] 12
State: 2 {0}
[!0&1] 2
[0&1] 9
[!0&!1] 10
[0&!1] 11
State: 3 {0}
[!0&1] 1
[0&1] 3
[0&!1] 11
[!0&!1] 12
State: 4 {0}
[!0&1] 4
[0&1] 7
[!1] 12
State: 5 {0}
[!0&1] 5
[0&1] 8
[!0&!1] 10
[0&!1] 12
State: 6 {0}
[!0&1] 4
[0&1] 6
[0&!1] 11
[!0&!1] 12
State: 7 {0}
[!0&1] 4
[0&1] 7
[!1] 12
State: 8
[1] 8
[!1] 12
[1] 14
State: 9
[!0&1] 1
[0&1] 3
[0&!1] 11
[!0&!1] 12
State: 10 {0}
[!0&1] 5
[0&1] 8
[!0&!1] 10
[0&!1] 12
State: 11 {0}
[0&1] 6
[!0&1] 8
[0&!1] 11
[!0&!1] 12
State: 12
[1] 8
[!1] 12
State: 13
[!0&1] 2
[0&1] 3
[!0&!1] 10
[0&!1] 11
State: 14 {0}
[1] 14
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!1] 0
[0&1] 2
[!0&1] 3
State: 1 {0}
[!1] 1
[1] 2
State: 2 {0}
[!1] 1
[1] 2
State: 3 {0}
[!1] 0
[0&1] 2
[!0&1] 3
--END--
HOA: v1
States: 6
Start: 5
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[t] 0
State: 1
[!0] 0
[0] 2
State: 2 {0}
[t] 2
State: 3 {0}
[!0&1] 1
[0] 2
[!0&!1] 3
State: 4
[1] 1
[!1] 3
State: 5
[t] 4
--END--
HOA: v1
States: 5
Start: 1
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[0&!1] 0
[!0] 2
[0&1] 3
State: 1
[0&!1] 1
[!0 | 1] 2
State: 2 {0}
[0&!1] 0
[!0 | 1] 2
State: 3
[0&!1] 0
[!0] 2
[0&1] 3
[0&1] 4
State: 4 {0}
[0&1] 4
--END--
HOA: v1
States: 37
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
--BODY--
State: 0
[!0] 0
[0] 1
[0&1] 2
[0&1] 3
[0&1] 4
State: 1
[t] 1
[1] 2
[1] 3
[1] 4
State: 2
[t] 2
[!1] 5
[1] 4
State: 3
[t] 3
[1] 4
[!1] 6
State: 4
[t] 4
[!1] 7
[!1] 8
[!1] 9
State: 5
[t] 5
[1] 10
[1] 7
[1] 11
State: 6
[t] 6
[1] 8
[1] 12
[1] 13
State: 7
[t] 7
[1] 11
[!1] 9
State: 8
[t] 8
[!1] 9
[1] 13
State: 9
[t] 9
[1] 14
[1] 15
[1] 16
State: 10
[t] 10
[!1] 17
[1] 11
State: 11
[t] 11
[!1] 18
[!1] 14
[!1] 19
State: 12
[t] 12
[1] 13
[!1] 20
State: 13
[t] 13
[!1] 15
[!1] 21
[!1] 22
State: 14
[t] 14
[!1] 19
[1] 16
State: 15
[t] 15
[1] 16
[!1] 22
State: 16
[t] 16
[!1] 23
[!1] 24
[!1] 25
State: 17
[1] 26
[!1] 17
[1] 27
State: 18
[1] 27
[!1] 18
[!1] 19
State: 19
[1] 28
[!1] 19
[1] 29
State: 20
[1] 30
[1] 31
[!1] 20
State: 21
[1] 31
[!1] 21
[!1] 22
State: 22
[1] 32
[1] 33
[!1] 22
State: 23
[1] 29
[!1] 23
[!1] 25
State: 24
[1] 33
[!1] 24
[!1] 25
State: 25
[1] 34
[!1] 25
State: 26
[t] 26
[1] 27
State: 27
[t] 27
[!1] 28
State: 28
[t] 28
[1] 29
State: 29
[t] 29
[!1] 35
State: 30
[t] 30
[1] 31
State: 31
[t] 31
[!1] 32
State: 32
[t] 32
[1] 33
State: 33
[t] 33
[!1] 36
State: 34 {0}
[t] 34
State: 35
[1] 34
[!1] 35
State: 36
[1] 34
[!1] 36
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "a"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[0] 1
[!0] 0
State: 1 {0}
[0] 1
[!0] 0
--END--
HOA: v1
States: 19
Start: 0
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[!0&1] 5
[!0&1] 7
State: 1
[!0&1] 1
[0&!1] 2
[0&!1] 6
[0&1] 9
[!0&1] 14
[!0&1] 18
State: 2
[!0&!1] 1
[!0&1] 8
[!0&!1] 18
State: 3
[0&1] 2
[!0&1] 5
State: 4
[0&!1] 4
[0&1] 5
[0&1] 6
[0&!1] 16
State: 5
[0&1] 9
State: 6
[!0&1] 4
[0&1] 5
[!0&1] 9
[!0&1] 12
State: 7 {0}
[0&!1] 3
[!0&1] 5
[!0&!1] 7
[0&!1] 8
State: 8
[!0&!1] 3
[!0&1] 4
[!0&1] 8
[!0&1] 13
State: 9
[!0&1] 2
[0&!1] 6
[0&!1] 11
[!0&1] 17
State: 10 {0}
[0&!1] 11
State: 11 {0}
[!0&1] 10
[!0&1] 12
State: 12 {0}
[0&1] 11
State: 13 {0}
[!0&1] 13
State: 14 {0}
[!0&1] 14
State: 15 {0}
[!0&1] 17
State: 16 {0}
[0&!1] 16
State: 17 {0}
[!0&!1] 18
State: 18 {0}
[0&1] 15
[!0&1] 18
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "b" "c"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[0&!1] 1
[0&1] 2
[!0] 3
State: 1
[!0 | !1] 1 {0}
[0&1] 2
State: 2
[!1] 1 {0}
[1] 2
State: 3
[!0] 3 {0}
--END--
HOA: v1
States: 6
Start: 0
AP: 3 "a" "b" "c"
Acceptance: 3 (Inf(1)&Inf(2)) | (Inf(0)&Inf(2))
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[!1&!2] 1
[0] 2
[1 | 2] 4
State: 1
[2] 0
[!2] 1
[0&!2] 3
[2] 4
[!2] 5
State: 2
[0] 2 {0 2}
State: 3
[0&!2] 3 {0}
State: 4
[1 | 2] 4 {1 2}
[!1&!2] 5 {1}
State: 5
[2] 4 {1 2}
[!2] 5 {1}
--END--
EOF

cat >expected-tgba <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[t] 0
[!0] 1
[!1] 2
State: 1 {0}
[!0] 1
State: 2 {0}
[!1] 2
--END--
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0 {0}
[0] 1 {0}
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1
[!0&!1] 2 {0}
--END--
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[0] 1
[!0] 2 {0}
State: 1
[1] 0
[0&1] 1 {0}
[!0&1] 2 {0}
State: 2
[!1] 0
[0&!1] 1 {0}
[!0&!1] 2 {0}
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
properties: stutter-invariant very-weak
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!0] 0
[0] 1
State: 1 {0}
[t] 1
--END--
HOA: v1
States: 9
Start: 2
AP: 1 "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[0] 0
[!0] 6
[0] 8
State: 1
[t] 3
State: 2
[0] 1
[!0] 5
State: 3
[0] 0
[!0] 6
State: 4
[0] 4 {0}
[!0] 6
State: 5
[0] 3
[!0] 7
State: 6
[0] 0
[!0] 6
State: 7
[0] 4
[!0] 6
State: 8
[0] 8 {0}
--END--
HOA: v1
States: 15
Start: 13
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[0&1] 0 {0}
[!0&1] 1 {0}
[0&!1] 11
[!0&!1] 12
State: 1
[0&1] 0 {0}
[!0&1] 1 {0}
[0&!1] 11
[!0&!1] 12
State: 2
[!0&1] 2 {0}
[0&1] 9
[!0&!1] 10
[0&!1] 11
State: 3
[!0&1] 1
[0&1] 3 {0}
[0&!1] 11
[!0&!1] 12
State: 4
[!0&1] 4 {0}
[0&1] 7 {0}
[!1] 12
State: 5
[!0&1] 5 {0}
[0&1] 8
[!0&!1] 10 {0}
[0&!1] 12
State: 6
[!0&1] 4
[0&1] 6 {0}
[0&!1] 11 {0}
[!0&!1] 12
State: 7
[!0&1] 4 {0}
[0&1] 7 {0}
[!1] 12
State: 8
[1] 8
[!1] 12
[1] 14
State: 9
[!0&1] 1
[0&1] 3
[0&!1] 11
[!0&!1] 12
State: 10
[!0&1] 5 {0}
[0&1] 8
[!0&!1] 10 {0}
[0&!1] 12
State: 11
[0&1] 6 {0}
[!0&1] 8
[0&!1] 11 {0}
[!0&!1] 12
State: 12
[1] 8
[!1] 12
State: 13
[!0&1] 2
[0&1] 3
[!0&!1] 10
[0&!1] 11
State: 14
[1] 14 {0}
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "p1" "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
--BODY--
State: 0
[!1] 0
[0&1] 2
[!0&1] 3
State: 1
[!1] 1 {0}
[1] 2 {0}
State: 2
[!1] 1 {0}
[1] 2 {0}
State: 3
[!1] 0 {0}
[0&1] 2
[!0&1] 3 {0}
--END--
HOA: v1
States: 5
Start: 4
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc deterministic
--BODY--
State: 0
[0] 1
State: 1
[t] 1 {0}
State: 2
[!0&1] 0
[0] 1
[!0&!1] 2 {0}
State: 3
[1] 0
[!1] 2
State: 4
[t] 3
--END--
HOA: v1
States: 5
Start: 1
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
[0&!1] 0
[!0] 2
[0&1] 3
State: 1
[0&!1] 1
[!0 | 1] 2
State: 2 {0}
[0&!1] 0
[!0 | 1] 2
State: 3
[0&!1] 0
[!0] 2
[0&1] 3
[0&1] 4
State: 4 {0}
[0&1] 4
--END--
HOA: v1
States: 37
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
--BODY--
State: 0
[!0] 0
[0] 1
[0&1] 2
[0&1] 3
[0&1] 4
State: 1
[t] 1
[1] 2
[1] 3
[1] 4
State: 2
[t] 2
[1] 4
[!1] 5
State: 3
[t] 3
[1] 4
[!1] 6
State: 4
[t] 4
[!1] 7
[!1] 8
[!1] 9
State: 5
[t] 5
[1] 7
[1] 10
[1] 11
State: 6
[t] 6
[1] 8
[1] 12
[1] 13
State: 7
[t] 7
[!1] 9
[1] 11
State: 8
[t] 8
[!1] 9
[1] 13
State: 9
[t] 9
[1] 14
[1] 15
[1] 16
State: 10
[t] 10
[1] 11
[!1] 17
State: 11
[t] 11
[!1] 14
[!1] 18
[!1] 19
State: 12
[t] 12
[1] 13
[!1] 20
State: 13
[t] 13
[!1] 15
[!1] 21
[!1] 22
State: 14
[t] 14
[1] 16
[!1] 19
State: 15
[t] 15
[1] 16
[!1] 22
State: 16
[t] 16
[!1] 23
[!1] 24
[!1] 25
State: 17
[!1] 17
[1] 26
[1] 27
State: 18
[!1] 18
[!1] 19
[1] 27
State: 19
[!1] 19
[1] 28
[1] 29
State: 20
[!1] 20
[1] 30
[1] 31
State: 21
[!1] 21
[!1] 22
[1] 31
State: 22
[!1] 22
[1] 32
[1] 33
State: 23
[!1] 23
[!1] 25
[1] 29
State: 24
[!1] 24
[!1] 25
[1] 33
State: 25
[!1] 25
[1] 34
State: 26
[t] 26
[1] 27
State: 27
[t] 27
[!1] 28
State: 28
[t] 28
[1] 29
State: 29
[t] 29
[!1] 35
State: 30
[t] 30
[1] 31
State: 31
[t] 31
[!1] 32
State: 32
[t] 32
[1] 33
State: 33
[t] 33
[!1] 36
State: 34 {0}
[t] 34
State: 35
[1] 34
[!1] 35
State: 36
[1] 34
[!1] 36
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "a"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[!0] 0
[0] 1
State: 1 {0}
[!0] 0
[0] 1
--END--
HOA: v1
States: 19
Start: 0
AP: 2 "p0" "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[!0&1] 5
[!0&1] 7
State: 1
[!0&1] 1
[0&!1] 2
[0&!1] 6
[0&1] 9
[!0&1] 14
[!0&1] 18
State: 2
[!0&!1] 1
[!0&1] 8
[!0&!1] 18
State: 3
[0&1] 2
[!0&1] 5
State: 4
[0&!1] 4
[0&1] 5
[0&1] 6
[0&!1] 16
State: 5
[0&1] 9
State: 6
[!0&1] 4
[0&1] 5
[!0&1] 9
[!0&1] 12
State: 7
[0&!1] 3
[!0&1] 5
[!0&!1] 7 {0}
[0&!1] 8
State: 8
[!0&!1] 3
[!0&1] 4
[!0&1] 8
[!0&1] 13
State: 9
[!0&1] 2
[0&!1] 6
[0&!1] 11
[!0&1] 17
State: 10
[0&!1] 11 {0}
State: 11
[!0&1] 10 {0}
[!0&1] 12 {0}
State: 12
[0&1] 11 {0}
State: 13
[!0&1] 13 {0}
State: 14
[!0&1] 14 {0}
State: 15
[!0&1] 17 {0}
State: 16
[0&!1] 16 {0}
State: 17
[!0&!1] 18 {0}
State: 18
[0&1] 15 {0}
[!0&1] 18 {0}
--END--
HOA: v1
States: 4
Start: 0
AP: 2 "b" "c"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[t] 1
[0&!1] 2
[0&1] 3
State: 1
[!0] 1 {0}
State: 2
[!0 | !1] 2 {0}
[0&1] 3
State: 3
[!1] 2 {0}
[1] 3
--END--
HOA: v1
States: 5
Start: 0
AP: 3 "a" "b" "c"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
[t] 0
[!1&!2] 1
[0] 2
[1 | 2] 3
State: 1
[2] 0
[!2] 1
[2] 3
[!2] 4
State: 2
[0] 2 {0}
State: 3
[1 | 2] 3 {0}
[!1&!2] 4
State: 4
[2] 3 {0}
[!2] 4
--END--
EOF

run 0 autfilt -H --remove-fin test1 > output
cat output
diff -u output expected

run 0 autfilt -H --tgba test1 > output
cat output
diff -u output expected-tgba

# Issue #324.
cat > 324 <<EOF
HOA: v1
States: 2
Start: 1
AP: 2 "a" "b"
acc-name: Rabin 3
Acceptance: 6 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) | (Fin(4) & Inf(5))
properties: trans-labels explicit-labels trans-acc deterministic
--BODY--
State: 0
[!0&!1] 0 {0 4}
[!0&1] 0 {0 3 4}
[0&!1] 0 {2 5}
[0&1] 0 {1 2 5}
State: 1
[0] 0
--END--
EOF
autfilt --remove-fin 324 > out
test 2 = `autfilt -c --reject-word='a;cycle{!a&!b}' 324 out`

# Add 10 small random automata for the next case
randaut -A'random 6' -Q10 -n10 3 -Hl >> test1

# make sure the above expected automata are correct
autcross --verbose --language-preserved -Ftest1 \
         'autfilt --remove-fin' 'autfilt --tgba'

# do it again, but make sure autfilt uses streett_to_generalized_buchi
# whenever buchi, and that autcross does not.  This helps findings bug
# in streett_to_generalized_buchi().
SPOT_STREETT_CONV_MIN=0 \
autcross --language-preserved -Ftest1 \
  'SPOT_STREETT_CONV_MIN=1 autfilt --remove-fin %H>%O' \
  'SPOT_STREETT_CONV_MIN=1 autfilt --tgba %H>%O'

ltl2tgba true > h1
autfilt -F h1 --acceptance-is=Fin-less
autfilt --complement -F h1 > h2
autfilt -F h2 --acceptance-is=f
autfilt -F h2 --acceptance-is=Fin-less && exit 1
autfilt --remove-fin -F h2 | autfilt --acceptance-is=Fin-less
