introduce containement checks functions

* spot/twaalgos/contains.hh, spot/twaalgos/contains.cc: New files.
* spot/twaalgos/Makefile.am, python/spot/impl.i: Add them.
* python/spot/__init__.py: Also attach these functions as methods,
and support string arguments.
* tests/python/contains.ipynb: New file.
* tests/Makefile.am, doc/org/tut.org: Add it.
* bin/autfilt.cc, tests/python/streett_totgba.py, tests/python/sum.py,
tests/python/toweak.py: Use the new function.
This commit is contained in:
Alexandre Duret-Lutz 2018-05-04 17:00:38 +02:00
parent 58d9a12495
commit d6f9618172
13 changed files with 547 additions and 60 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2017 Laboratoire de Recherche et Développement de
# Copyright (C) 2017, 2018 Laboratoire de Recherche et Développement de
# l'EPITA.
#
# This file is part of Spot, a model checking library.
@ -23,29 +23,6 @@ import os
import shutil
import sys
def parse_multiple_auts(hoa):
l = hoa.split('--END--')
a = []
cpt = 0
for x in l:
if x.isspace() or x == '':
continue
x = x + "--END--"
a.append(spot.automaton(x))
return a
def ensure_deterministic(a):
if a.is_existential() and spot.is_deterministic(a):
return a
return a.postprocess('Generic', 'deterministic', 'Low')
def equivalent(a1, a2):
na1 = spot.dualize(ensure_deterministic(a1))
na2 = spot.dualize(ensure_deterministic(a2))
return (not a1.intersects(na2)) and (not a2.intersects(na1))
def tgba(a):
if not a.is_existential():
a = spot.remove_alternation(a)
@ -54,11 +31,11 @@ def tgba(a):
def test_aut(aut):
stgba = tgba(aut)
assert equivalent(stgba, aut)
assert stgba.equivalent_to(aut)
os.environ["SPOT_STREETT_CONV_MIN"] = '1'
sftgba = tgba(aut)
del os.environ["SPOT_STREETT_CONV_MIN"]
assert equivalent(stgba, sftgba)
assert stgba.equivalent_to(sftgba)
slike = spot.simplify_acceptance(aut)
@ -66,7 +43,7 @@ def test_aut(aut):
os.environ["SPOT_STREETT_CONV_MIN"] = "1"
slftgba = tgba(slike)
del os.environ["SPOT_STREETT_CONV_MIN"]
assert equivalent(sltgba, slftgba)
assert sltgba.equivalent_to(slftgba)
# Those automata are generated with ltl2dstar, which is NOT part of spot,
# using the following command: