accparse2.py 3.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2015  Laboratoire de Recherche et Développement
# de l'Epita
#
# 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/>.

import spot

a = spot.acc_cond(5)
23
a.set_acceptance(spot.acc_code('parity min odd 5'))
24
assert(a.is_parity() == [True, False, True])
25
a.set_acceptance('parity max even 5')
26
assert(a.is_parity() == [True, True, False])
27
a.set_acceptance('generalized-Buchi 5')
28 29
assert(a.is_parity()[0] == False)
assert(a.is_parity(True)[0] == False)
30
a.set_acceptance('Inf(4) | (Fin(3)&Inf(2)) | (Fin(3)&Fin(1)&Inf(0))')
31
assert(a.is_parity()[0] == False)
32
assert(a.is_parity(True) == [True, True, False])
33 34

a = spot.acc_cond(0)
35
a.set_acceptance('all')
36 37
assert(a.is_rabin() == -1)
assert(a.is_streett() == 0)
38
assert(a.is_parity() == [True, True, True])
39
a.set_acceptance('none')
40 41
assert(a.is_rabin() == 0)
assert(a.is_streett() == -1)
42
assert(a.is_parity() == [True, True, False])
43

44
a = spot.acc_cond('(Fin(0)&Inf(1))')
45 46
assert(a.is_rabin() == 1)
assert(a.is_streett() == -1)
47
a.set_acceptance('Inf(1)&Fin(0)')
48 49
assert(a.is_rabin() == 1)
assert(a.is_streett() == -1)
50
a.set_acceptance('(Fin(0)|Inf(1))')
51 52
assert(a.is_rabin() == -1)
assert(a.is_streett() == 1)
53
a.set_acceptance('Inf(1)|Fin(0)')
54 55 56
assert(a.is_rabin() == -1)
assert(a.is_streett() == 1)

57
a = spot.acc_cond('(Fin(0)&Inf(1))|(Fin(2)&Inf(3))')
58 59
assert(a.is_rabin() == 2)
assert(a.is_streett() == -1)
60
a.set_acceptance(spot.acc_code('(Inf(3)&Fin(2))|(Fin(0)&Inf(1))'))
61 62
assert(a.is_rabin() == 2)
assert(a.is_streett() == -1)
63
a.set_acceptance(spot.acc_code('(Inf(2)&Fin(3))|(Fin(0)&Inf(1))'))
64 65
assert(a.is_rabin() == -1)
assert(a.is_streett() == -1)
66
a.set_acceptance(spot.acc_code('(Inf(3)&Fin(2))|(Fin(2)&Inf(1))'))
67 68
assert(a.is_rabin() == -1)
assert(a.is_streett() == -1)
69
a.set_acceptance(spot.acc_code('(Inf(1)&Fin(0))|(Fin(0)&Inf(1))'))
70 71
assert(a.is_rabin() == -1)
assert(a.is_streett() == -1)
72
a.set_acceptance('(Fin(0)&Inf(1))|(Inf(1)&Fin(0))|(Inf(3)&Fin(2))')
73 74 75
assert(a.is_rabin() == 2)
assert(a.is_streett() == -1)

76
a.set_acceptance('(Fin(0)|Inf(1))&(Fin(2)|Inf(3))')
77 78
assert(a.is_rabin() == -1)
assert(a.is_streett() == 2)
79
a.set_acceptance('(Inf(3)|Fin(2))&(Fin(0)|Inf(1))')
80 81
assert(a.is_rabin() == -1)
assert(a.is_streett() == 2)
82
a.set_acceptance('(Inf(2)|Fin(3))&(Fin(0)|Inf(1))')
83 84
assert(a.is_rabin() == -1)
assert(a.is_streett() == -1)
85
a.set_acceptance('(Inf(3)|Fin(2))&(Fin(2)|Inf(1))')
86 87
assert(a.is_rabin() == -1)
assert(a.is_streett() == -1)
88
a.set_acceptance('(Inf(1)|Fin(0))&(Fin(0)|Inf(1))')
89 90
assert(a.is_rabin() == -1)
assert(a.is_streett() == -1)
91
a.set_acceptance('(Fin(0)|Inf(1))&(Inf(1)|Fin(0))&(Inf(3)|Fin(2))')
92 93
assert(a.is_rabin() == -1)
assert(a.is_streett() == 2)