def generic_emptiness2_rec(aut):
    spot.cleanup_acceptance_here(aut, False)
    # Catching 'false' acceptance here is an optimization that could be removed.
    if aut.acc().is_f():
        return True
    # Catching Fin-less acceptance here to use a regular emptiness check is an
    # optimization.  This "if" block could be removed without breaking the
    # algorithm.
    if not aut.acc().uses_fin_acceptance():
        return aut.is_empty()
    si = spot.scc_info(aut, spot.scc_info_options_STOP_ON_ACC)
    acc_scc = si.one_accepting_scc()
    if acc_scc >= 0:
        return False
    nscc = si.scc_count()
    # Now recurse in all non-rejecting SCC
    for scc in range(nscc):
        if not si.is_rejecting_scc(scc):
            acc = aut.acc()
            sets = si.acc_sets_of(scc)
            acc = acc.restrict_to(sets)
            # Do we have any unit Fin?
            fu = acc.fin_unit()
            if fu:
                for part in si.split_on_sets(scc, fu):
                    if not generic_emptiness2(part):
                        return False
            else:
                # Find some Fin set, we necessarily have one, otherwise the SCC
                # would have been found to be either rejecting or accepting.
                fo = acc.fin_one()
                assert fo >= 0, acc
                for part in si.split_on_sets(scc, [fo]):
                    if not generic_emptiness2(part):
                        return False
                whole = si.split_on_sets(scc, [])[0]
                whole.set_acceptance(acc.force_inf([fo]))
                if not generic_emptiness2(whole):
                    return False
    return True
Beispiel #2
0
alt = spot.dualize(spot.translate('FGa | FGb'))

try:
    spot.tgba_determinize(alt)
except RuntimeError as e:
    assert 'tgba_determinize() does not support alternation' in str(e)


aut = spot.translate('a U b U c')
aps = aut.ap()
rem = spot.remove_ap()
rem.add_ap('"a"=0,b')
aut = rem.strip(aut)
assert aut.ap() == aps[2:]
try:
    rem.add_ap('"a=0,b')
except ValueError as e:
    assert """missing closing '"'""" in str(e)

try:
    rem.add_ap('a=0=b')
except ValueError as e:
    assert """unexpected '=' at position 3""" in str(e)


si = spot.scc_info(alt)
try:
    si.determine_unknown_acceptance()
except RuntimeError as e:
    assert "scc_info::determine_unknown_acceptance() does not supp" in str(e)
Beispiel #3
0
assert aut.ap() == aps[2:]
try:
    rem.add_ap('"a=0,b')
except ValueError as e:
    assert """missing closing '"'""" in str(e)
else:
    report_missing_exception()

try:
    rem.add_ap('a=0=b')
except ValueError as e:
    assert """unexpected '=' at position 3""" in str(e)
else:
    report_missing_exception()

si = spot.scc_info(aut)
for meth in ('scc_has_rejecting_cycle', 'is_inherently_weak_scc',
             'is_weak_scc', 'is_complete_scc', 'is_terminal_scc'):
    try:
        getattr(spot, meth)(si, 20)
    except ValueError as e:
        assert "invalid SCC number" in str(e)
    else:
        report_missing_exception()


s1 = alt.new_state()
s2 = alt.new_state()
alt.new_edge(0, s1, buddy.bddtrue)
alt.new_edge(s1, s2, buddy.bddtrue, [0])
alt.new_edge(s2, s1, buddy.bddtrue)
Beispiel #4
0
alt = spot.dualize(spot.translate('FGa | FGb'))

try:
    spot.tgba_determinize(alt)
except RuntimeError as e:
    assert 'tgba_determinize() does not support alternation' in str(e)


aut = spot.translate('a U b U c')
aps = aut.ap()
rem = spot.remove_ap()
rem.add_ap('"a"=0,b')
aut = rem.strip(aut)
assert aut.ap() == aps[2:]
try:
    rem.add_ap('"a=0,b')
except ValueError as e:
    assert """missing closing '"'""" in str(e)

try:
    rem.add_ap('a=0=b')
except ValueError as e:
    assert """unexpected '=' at position 3""" in str(e)


si = spot.scc_info(alt)
try:
    si.determine_unknown_acceptance()
except RuntimeError as e:
    assert "scc_info::determine_unknown_acceptance() does not supp" in str(e)
Beispiel #5
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

a = spot.translate('(Ga -> Gb) W c')

try:
    si = spot.scc_info(a, 10)
    exit(2)
except RuntimeError as e:
    assert "initial state does not exist" in str(e)

si = spot.scc_info(a)
n = si.scc_count()
assert n == 4

acc = 0
rej = 0
triv = 0
for i in range(n):
    acc += si.is_accepting_scc(i)
    rej += si.is_rejecting_scc(i)
    triv += si.is_trivial(i)
#!/usr/bin/python3
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018 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

aut = spot.translate('GF(a <-> Xa) & GF(b <-> XXb)')
si = spot.scc_info(aut)
s = ""
for aut2 in si.split_on_sets(0, [0]):
    # This call to to_str() used to fail because split_on_sets had not
    # registered the atomic propositions of aut
    s += aut2.to_str()
assert spot.automaton(s).num_states() == 8
Beispiel #7
0
for e in a.out(1):
    if e.dst == 0:
        e.cond = bddfalse

assert a.accepting_run() is None
assert a.is_empty()

for name in ['SE05', 'CVWY90', 'GV04', 'Cou99(shy)', 'Cou99', 'Tau03']:
    print(name)
    ec = spot.make_emptiness_check_instantiator(name)[0].instantiate(a)
    res = ec.check()
    if res is not None:
        print(res.accepting_run())
    assert res is None

si = spot.scc_info(a)
assert si.scc_count() == 1  # only one accessible SCC
a.set_init_state(0)
si = spot.scc_info(a)
assert si.scc_count() == 2

a = spot.automaton("""HOA: v1 States: 11 Start: 0 AP: 2 "a" "b" Acceptance: 8
(Fin(0) | Inf(1)) & (Fin(2) | Inf(3)) & ((Fin(4) & Inf(5)) | (Fin(6) & Inf(7)))
properties: trans-labels explicit-labels trans-acc --BODY-- State: 0 [!0&!1] 1
{0 4 6 7} [!0&!1] 2 {0 5 6} [!0&!1] 3 {3 4 6 7} [!0&!1] 4 {3 5 6} State: 1
[0&1] 5 {2 5 7} [0&1] 6 {2 7} [0&1] 7 {2 3 5 7} [0&1] 8 {2 3 7} [0&1] 0 {2 5 7}
[0&1] 9 {2 7} State: 2 [0&1] 1 {2} [0&1] 3 {2 3} [0&1] 10 {2} State: 3 [0&1] 0
{3 5 7} [0&1] 9 {3 7} State: 4 [!0&!1] 5 {4 6} [!0&!1] 6 {7} [0&1] 10 {3}
State: 5 State: 6 State: 7 [!0&!1] 1 {4 6 7} [!0&!1] 2 {5 6} State: 8 [!0&!1] 2
{4} State: 9 [!0&!1] 2 {0 4} [!0&!1] 4 {3 4} State: 10 --END-- """)
Beispiel #8
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

a = spot.translate('(Ga -> Gb) W c')

try:
    si = spot.scc_info(a, 10)
    exit(2)
except RuntimeError as e:
    assert "initial state does not exist" in str(e)

si = spot.scc_info(a)
n = si.scc_count()
assert n == 4

acc = 0
rej = 0
triv = 0
for i in range(n):
    acc += si.is_accepting_scc(i)
    rej += si.is_rejecting_scc(i)
    triv += si.is_trivial(i)
# 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

aut = spot.translate('(Ga -> Gb) W c')
si = spot.scc_info(aut)

assert (spot.decompose_scc(si, 2).to_str('hoa', '1.1') == """HOA: v1.1
States: 3
Start: 0
AP: 3 "b" "a" "c"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc !complete
properties: deterministic terminal
--BODY--
State: 0
[!1&!2] 0
[1&!2] 1
State: 1
[!1&!2] 0