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,5 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2017 Laboratoire de Recherche et Développement
# de l'Epita
# Copyright (C) 2017, 2018 Laboratoire de Recherche et Développement de l'Epita
#
# This file is part of Spot, a model checking library.
#
@ -55,37 +54,29 @@ def produce_phi(rg, n):
phi.append(f)
return phi
def equivalent(a, phi):
negphi = spot.formula.Not(phi)
nega = spot.dualize(spot.tgba_determinize(a))
a2 = spot.ltl_to_tgba_fm(phi, dict)
nega2 = spot.ltl_to_tgba_fm(negphi, dict)
return spot.product(a, nega2).is_empty()\
and spot.product(nega, a2).is_empty()
phi1 = produce_phi(rg, 1000)
phi2 = produce_phi(rg, 1000)
inputres = []
aut = []
for p in zip(phi1, phi2):
inputres.append(spot.formula.Or(p))
a1 = spot.ltl_to_tgba_fm(p[0], dict)
a2 = spot.ltl_to_tgba_fm(p[1], dict)
a1 = spot.ltl_to_tgba_fm(p[0], dict)
a2 = spot.ltl_to_tgba_fm(p[1], dict)
aut.append(spot.to_generalized_buchi( \
spot.remove_alternation(spot.sum(a1, a2), True)))
for p in zip(aut, inputres):
assert equivalent(p[0], p[1])
assert p[0].equivalent_to(p[1])
aut = []
inputres = []
for p in zip(phi1, phi2):
inputres.append(spot.formula.And(p))
a1 = spot.ltl_to_tgba_fm(p[0], dict)
a2 = spot.ltl_to_tgba_fm(p[1], dict)
a1 = spot.ltl_to_tgba_fm(p[0], dict)
a2 = spot.ltl_to_tgba_fm(p[1], dict)
aut.append(spot.to_generalized_buchi( \
spot.remove_alternation(spot.sum_and(a1, a2), True)))
for p in zip(aut, inputres):
assert equivalent(p[0], p[1])
assert p[0].equivalent_to(p[1])