コード例 #1
0
ファイル: analyzer.py プロジェクト: adl/ltlcross_wrapper
 def get_sbacc(aut):
     if isinstance(aut, float) and math.isnan(aut):
         return None
     a = spot.automata(aut + '\n')
     aut = next(a)
     aut = spot.sbacc(aut)
     if col == 'states':
         return aut.num_states()
     if col == 'acc':
         return aut.num_sets()
コード例 #2
0
State: 5
[t] 5
--END--"""

opts = spot.option_map()
opts.set('output', spot.OUTPUTLTL)
opts.set('tree_size_min', 15)
opts.set('tree_size_max', 15)
opts.set('seed', 0)
opts.set('simplification_level', 0)
spot.srand(0)
rg = spot.randltlgenerator(2, opts)

for a in produce_automaton(produce_phi(rg, 1000)):
    test_assert(a)
    test_assert(spot.dualize(a), spot.dualize(spot.dualize(a)))

aut = spot.automaton("""
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 3 Fin(2) & (Inf(1) | Fin(0))
--BODY--
State: 0
--END--""")
test_complement(aut)

for a in spot.automata('randaut -A \"random 0..6\" -H -D -n50 4|'):
    test_complement(a)
コード例 #3
0
# (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

# This issue was reported by Florian Renkin.  The reduce() call used in
# intersecting_run() was bogus, and could incorrectly reduce a word
# intersecting the product into a word not intersecting the product if the
# acceptance condition uses some Fin.
a, b = spot.automata("""HOA: v1 States: 5 Start: 0 AP: 2 "p0" "p1" acc-name:
Rabin 2 Acceptance: 4 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) properties:
trans-labels explicit-labels trans-acc complete properties: deterministic
--BODY-- State: 0 [t] 3 State: 1 [t] 4 {1} State: 2 [0] 2 {1} [!0] 1 {0} State:
3 [t] 1 {1} State: 4 [!0&1] 4 {3} [!0&!1] 3 [0] 2 {0} --END-- HOA: v1 States: 5
Start: 0 AP: 2 "p0" "p1" Acceptance: 3 Inf(2) | (Fin(0) & Inf(1)) properties:
trans-labels explicit-labels trans-acc complete properties: deterministic
--BODY-- State: 0 [t] 3 State: 1 [t] 4 {1 2} State: 2 [0] 2 {1 2} [!0] 1 {0 2}
State: 3 [t] 1 {1 2} State: 4 [!0&1] 4 {2} [!0&!1] 3 {2} [0] 2 {0 2} --END--"""
                     )
r = b.intersecting_run(spot.complement(a))
c = spot.twa_word(r).as_automaton()
assert c.intersects(b)
assert not c.intersects(a)
コード例 #4
0
left, right = spot.automata('''
HOA: v1 States: 40 Start: 0 AP: 2 "p1" "p0" acc-name: Buchi Acceptance:
1 Inf(0) properties: trans-labels explicit-labels state-acc terminal
--BODY-- State: 0 [0] 1 [!0&1] 2 [!0] 3 [0&1] 4 [t] 5 [t] 6 State: 1
[!0&1] 2 [!0] 3 [!0] 5 [!0] 6 State: 2 [1] 2 [!1] 13 State: 3 [0] 1 [0&1]
4 [0] 5 [0] 6 State: 4 [!0&1] 2 [0&1] 4 [!0&!1] 13 [0&!1] 39 State: 5
[0] 1 [t] 5 [t] 14 [!0] 15 [0] 19 [0&1] 21 [!0&1] 31 [0&1] 34 [0] 38
State: 6 [!0] 3 [t] 6 [t] 14 [!0] 15 [0] 19 [0&1] 25 [!0&1] 26 [!0&1]
27 [!0] 36 State: 7 [t] 7 [!0] 8 [0] 9 State: 8 [0] 29 [0] 30 State:
9 [!0] 23 [!0] 24 State: 10 [!1] 7 [!0&!1] 8 [0&!1] 9 [1] 10 [0&1] 11
[!0&1] 12 State: 11 [!0&!1] 23 [!0&!1] 24 [!0&1] 26 [!0&1] 27 State:
12 [0&!1] 29 [0&!1] 30 [0&1] 31 [0&1] 32 State: 13 {0} [t] 13 State: 14
[!0&1] 10 [!0&1] 12 [t] 14 [!0] 15 [0] 16 [0&1] 17 [!0] 18 [0] 19 [0&1]
20 State: 15 [0] 1 [0] 5 [0] 14 [0] 19 [0&1] 21 [0&1] 34 [0] 38 State:
16 [!0&1] 10 [!0&1] 12 [!0] 14 [!0] 15 [!0] 18 State: 17 [!0&!1] 23
[!0&!1] 24 [!0&1] 26 [!0&1] 27 State: 18 [0] 14 [0] 16 [0&1] 17 [0]
19 [0&1] 20 State: 19 [!0] 3 [!0] 6 [!0] 14 [!0] 15 [!0&1] 26 [!0&1]
27 [!0] 36 State: 20 [!0&!1] 7 [!0&!1] 8 [!0&1] 10 [!0&1] 12 [0&1] 17
[0&1] 20 [0&!1] 22 [0&!1] 37 State: 21 [!0&1] 2 [!0&!1] 13 State: 22 [!0]
23 [!0] 24 State: 23 [0] 13 State: 24 [!0] 23 [t] 24 State: 25 [!0&!1]
23 [!0&!1] 24 [0&1] 25 [!0&1] 26 [!0&1] 27 [0&!1] 28 State: 26 [0&1] 2
[0&!1] 13 State: 27 [!0&!1] 23 [!1] 24 [!0&1] 26 [1] 27 State: 28 [!0]
23 [!0] 24 [0] 28 State: 29 [!0] 13 State: 30 [0] 29 [t] 30 State: 31
[0&!1] 29 [!1] 30 [1] 31 [0&1] 32 State: 32 [!0&1] 2 [!0&!1] 13 State:
33 [!0] 13 State: 34 [0&1] 21 [!0&!1] 30 [!0&1] 31 [0&!1] 33 [0&1] 34
[0&!1] 35 State: 35 [!0] 30 [0] 33 [0] 35 State: 36 [0] 6 [0] 14 [0] 19
[0&1] 25 State: 37 [!0] 7 [!0] 8 [0] 22 [0] 37 State: 38 [!0] 5 [!0] 14
[!0] 15 [!0&1] 31 State: 39 [!0] 13 [0] 39 --END--
HOA: v1 States: 73 Start: 0 AP: 2 "p1" "p0" acc-name: all Acceptance: 0
t properties: implicit-labels state-acc complete deterministic --BODY--
State: 0 1 3 2 4 State: 1 5 7 6 8 State: 2 9 11 10 12 State: 3 5 7 10
13 State: 4 9 14 10 8 State: 5 15 17 16 18 State: 6 19 20 16 21 State:
7 15 17 22 23 State: 8 24 25 22 18 State: 9 26 28 27 29 State: 10 24 20
22 21 State: 11 26 28 30 31 State: 12 24 32 22 33 State: 13 24 34 22 23
State: 14 26 35 30 36 State: 15 15 17 16 18 State: 16 37 38 16 39 State:
17 15 17 22 23 State: 18 40 41 22 18 State: 19 19 20 42 43 State: 20
24 20 44 45 State: 21 40 46 22 21 State: 22 40 38 22 39 State: 23 40 47
22 23 State: 24 24 20 48 43 State: 25 24 25 44 49 State: 26 26 28 27 29
State: 27 40 38 27 50 State: 28 26 28 30 31 State: 29 40 51 30 29 State:
30 40 38 30 50 State: 31 40 52 30 31 State: 32 24 32 44 53 State: 33
40 51 22 33 State: 34 24 34 44 54 State: 35 26 35 30 36 State: 36 40 41
30 36 State: 37 37 38 55 56 State: 38 40 38 57 58 State: 39 40 59 22 39
State: 40 40 38 60 56 State: 41 40 41 57 61 State: 42 37 38 42 62 State:
43 40 46 44 43 State: 44 40 38 44 62 State: 45 40 63 44 45 State: 46 40 46
57 64 State: 47 40 47 57 65 State: 48 40 38 48 62 State: 49 40 41 44 49
State: 50 40 59 30 50 State: 51 40 51 57 66 State: 52 40 52 57 67 State:
53 40 51 44 53 State: 54 40 47 44 54 State: 55 37 38 55 68 State: 56 40 59
57 56 State: 57 40 38 57 68 State: 58 40 69 57 58 State: 59 40 59 57 70
State: 60 40 38 60 68 State: 61 40 41 57 61 State: 62 40 59 44 62 State:
63 40 63 57 71 State: 64 40 46 57 64 State: 65 40 47 57 65 State: 66 40
51 57 66 State: 67 40 52 57 67 State: 68 40 59 57 68 State: 69 40 69 57 72
State: 70 40 59 57 70 State: 71 40 63 57 71 State: 72 40 69 57 72 --END--
''')
コード例 #5
0
def two_intersecting_automata():
    """return two random automata with a non-empty intersection"""
    g = spot.automata('randaut -A4 -Q5 -n-1 2 |')
    for a, b in zip(g, g):
        if a.intersects(b):
            return a, b
コード例 #6
0
# 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
import buddy


def complement(aut):
    return spot.dualize(aut.postprocess('det', 'gen'))


n = 10000

for aut in spot.automata(
        "randltl -n-1 a b "
        "| ltl2tgba "
        "| autfilt --is-semi-deterministic --acceptance-is=Buchi -n{} |".
        format(n)):

    comp = complement(aut)
    semidet_comp = spot.complement_semidet(aut, True)
    assert (comp.equivalent_to(semidet_comp))
コード例 #7
0
ファイル: dualize.py プロジェクト: mcc-petrinets/formulas
State: 5
[t] 5
--END--"""

opts = spot.option_map()
opts.set('output', spot.OUTPUTLTL)
opts.set('tree_size_min', 15)
opts.set('tree_size_max', 15)
opts.set('seed', 0)
opts.set('simplification_level', 0)
spot.srand(0)
rg = spot.randltlgenerator(2, opts)

for a in produce_automaton(produce_phi(rg, 1000)):
  test_assert(a)
  test_assert(spot.dualize(a), spot.dualize(spot.dualize(a)))

aut = spot.automaton("""
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 3 Fin(2) & (Inf(1) | Fin(0))
--BODY--
State: 0
--END--""")
test_complement(aut)

for a in spot.automata('randaut -A \"random 0..6\" -H -D -n50 4|'):
  test_complement(a)
コード例 #8
0
def test_aut(aut):
  stgba = tgba(aut)
  assert equivalent(stgba, aut)
  os.environ["SPOT_STREETT_CONV_MIN"] = '1'
  sftgba = tgba(aut)
  del os.environ["SPOT_STREETT_CONV_MIN"]
  assert equivalent(stgba, sftgba)

  slike = spot.simplify_acceptance(aut)

  sltgba = tgba(slike)
  os.environ["SPOT_STREETT_CONV_MIN"] = "1"
  slftgba = tgba(slike)
  del os.environ["SPOT_STREETT_CONV_MIN"]
  assert equivalent(sltgba, slftgba)

# Those automata are generated with ltl2dstar, which is NOT part of spot,
# using the following command:
# genltl --eh-patterns --dac-patterns --hkrss-patterns --sb-patterns |\
# ltldo "ltl2dstar --automata=streett --output-format=hoa\
#       --ltl2nba=spin:ltl2tgba@-s %L ->%O" -F- --name=%f -H"

if shutil.which('ltl2dstar') is None:
  sys.exit(77)
for a in spot.automata('genltl --eh-patterns --dac-patterns --hkrss-patterns\
                        --sb-patterns |\
                        ltldo "ltl2dstar --automata=streett --output-format=hoa\
                        --ltl2nba=spin:ltl2tgba@-s %L ->%O"\
                        -T5 -F- --name=%f -H|'):
  test_aut(a)
コード例 #9
0
a, b, d, f = spot.automata("""
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
Acceptance: 3 Inf(0)&Inf(1)|Fin(2)
--BODY--
State: 0
[0] 1 {1 2}
State: 1
[0] 0 {0}
--END--
HOA: v1
States: 3
Start: 2
AP: 1 "p0"
Acceptance: 3 Inf(0)&Inf(1)|Fin(2)
--BODY--
State: 0
[0] 1 {1 2}
State: 1
[0] 0 {0}
State: 2
[0] 0 {0}
[0] 0 {1}
--END--
HOA: v1
States: 1
Start: 0
AP: 1 "p0"
Acceptance: 1 Fin(0)
--BODY--
State: 0
[0] 0 {0}
--END--
HOA: v1
States: 2
Start: 0
AP: 1 "p0"
Acceptance: 2 Fin(0)|Fin(1)
--BODY--
State: 0
[0] 0 {0}
[0] 1 {1}
State: 1
[!0] 0
--END--
""")
コード例 #10
0
ファイル: simplacc.py プロジェクト: yanntm/spot
    spot.automata("""
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 2 Inf(0) | Inf(1) --BODY--
State: 0 [1] 0 [0] 1 {0} State: 1 [0] 1 [1] 0 {1} --END--
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 2 (Inf(0) | Inf(1)) &
Fin(0) --BODY-- State: 0 [1] 0 [0] 1 {0} State: 1 [0] 1 [1] 0 {1} --END--
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 3 (Inf(0) | Inf(1)) &
(Fin(0) | Inf(2)) --BODY-- State: 0 [1] 0 [0] 1 {0} State: 1 [0] 1 {2} [1] 0
{1} --END--
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 4 (Inf(0) |
(Inf(1)&(Inf(3)|Fin(2)))) --BODY-- State: 0 [1] 0 {3} [0] 1 {0} State: 1 [0] 1
{2} [1] 0 {1} --END--
/* The next automaton was incorrectly simplified. */
HOA: v1 States: 4 Start: 0 AP: 2 "p0" "p1" Acceptance: 6 ((Fin(1) | Inf(2)) &
Inf(5)) | (Fin(0) & (Fin(1) | (Fin(3) & Inf(4)))) properties: trans-labels
explicit-labels trans-acc complete properties: deterministic --BODY-- State: 0
[!0&!1] 0 {2} [0&1] 1 {0 5} [0&!1] 1 {0 2 5} [!0&1] 2 {1} State: 1 [0&1] 1 {0}
[!0&!1] 1 {2} [0&!1] 1 {0 2} [!0&1] 2 {1} State: 2 [!0&!1] 0 {2 3} [0&!1] 0 {0
2 3 5} [!0&1] 2 {1 4} [0&1] 3 {0 5} State: 3 [!0&!1] 0 {2 3} [0&!1] 0 {0 2 3 5}
[!0&1] 2 {1 4} [0&1] 3 {0} --END--
/* This one caused an infinite loop in the simplification code. */
HOA: v1 States: 10 Start: 0 AP: 2 "p0" "p1" Acceptance: 6 (((Fin(4) &
(Fin(3) | (Fin(3) & Inf(1))) & (Inf(0)&Inf(5))) | (Fin(5) & Fin(2)))
& Inf(5)) | Inf(5) | Inf(0) properties: trans-labels explicit-labels
trans-acc --BODY-- State: 0 [!0&!1] 2 [!0&!1] 7 {1} [!0&!1] 6 State:
1 [!0&!1] 5 {1 5} [0&!1] 9 {3} [!0&1] 1 {0} [!0&!1] 4 {0 3} State: 2
[0&1] 1 {1} State: 3 [!0&1] 8 {4} State: 4 [!0&!1] 0 {5} [!0&1] 3 {4}
State: 5 [!0&1] 4 {3 5} [!0&1] 3 {2 4} [!0&1] 2 {2 3} [!0&!1] 0 {0}
[!0&1] 7 {0 4 5} [0&1] 5 {2} State: 6 [0&!1] 7 [0&!1] 1 {1 4} [0&1]
4 {1 4} State: 7 [0&1] 3 {2 3} [0&1] 0 [!0&!1] 6 [0&1] 1 State: 8 [0&1]
3 [!0&!1] 0 [0&1] 9 State: 9 [0&!1] 7 {4 5} [!0&1] 8 {0} [0&1] 9 --END--
/* Derived from issue #405. */
HOA: v1 States: 2 Start: 0 AP: 2 "p0" "p1" Acceptance: 4 Fin(0) &
(Fin(1)|Fin(2)|Fin(3)) properties: trans-labels explicit-labels trans-acc
--BODY-- State: 0 [!0&!1] 0 {0 1 3} [0&1] 1 {0 2} [0&!1] 0 {2} State:
1 [0&1] 0 {0 2} [0&1] 1 {1} [0&!1] 1 --END--
/* More complex version of the previous automaton */
HOA: v1 States: 2 Start: 0 AP: 2 "p0" "p1" Acceptance: 5 Fin(0) &
(((Fin(1)|Fin(2)|Fin(3))&Inf(4)|Fin(3))) properties: trans-labels
explicit-labels trans-acc --BODY-- State: 0 [!0&!1] 0 {0 1 3} [0&1] 1
{0 2} [0&!1] 0 {2} State: 1 [0&1] 0 {0 2} [0&1] 1 {1} [0&!1] 1 {4} --END--
"""))
コード例 #11
0
    stgba = tgba(aut)
    assert stgba.equivalent_to(aut)
    os.environ["SPOT_STREETT_CONV_MIN"] = '1'
    sftgba = tgba(aut)
    del os.environ["SPOT_STREETT_CONV_MIN"]
    assert stgba.equivalent_to(sftgba)

    slike = spot.simplify_acceptance(aut)

    sltgba = tgba(slike)
    os.environ["SPOT_STREETT_CONV_MIN"] = "1"
    slftgba = tgba(slike)
    del os.environ["SPOT_STREETT_CONV_MIN"]
    assert sltgba.equivalent_to(slftgba)


# Those automata are generated with ltl2dstar, which is NOT part of spot,
# using the following command:
# genltl --eh-patterns --dac-patterns --hkrss-patterns --sb-patterns |\
# ltldo "ltl2dstar --automata=streett --output-format=hoa\
#       --ltl2nba=spin:ltl2tgba@-s %L ->%O" -F- --name=%f -H"

if shutil.which('ltl2dstar') is None:
    sys.exit(77)
for a in spot.automata('genltl --eh-patterns --dac-patterns --hkrss-patterns\
                        --sb-patterns |\
                        ltldo "ltl2dstar --automata=streett --output-format=hoa\
                        --ltl2nba=spin:ltl2tgba@-s %L ->%O"\
                        -T5 -F- --name=%f -H|'):
    test_aut(a)