postprocess, translate: add support for Büchi (not state-based)
spot/twaalgos/postproc.hh: Introduce options Buchi and GeneralizedBuchi. The latter is similar to TGBA but the former differs from BA in that it does not imply state-based acceptance, since that can be specified separately. Also all other acceptance types are not abbreviated, so those new names make more sense. * NEWS: Mention that. * spot/twaalgos/postproc.cc, spot/twaalgos/translate.cc: Adjust to support Buchi and GeneralizedBuchi without breaking BA and TGBA. * bin/autfilt.cc, bin/common_aoutput.cc, bin/common_post.cc, bin/ltl2tgta.cc, doc/org/tut10.org, doc/org/tut12.org, doc/org/tut30.org, python/spot/__init__.py, tests/python/automata.ipynb, tests/python/langmap.py, tests/python/misc-ec.py, tests/python/satmin.ipynb, tests/python/satmin.py, tests/python/toweak.py: Use the new names. * tests/Makefile.am: Add missing langmap.py.
This commit is contained in:
parent
72c492b0cf
commit
9cc1bdf10f
19 changed files with 274 additions and 201 deletions
|
|
@ -88,7 +88,7 @@ that takes a formula (possibly as a string) as first argument:
|
|||
|
||||
#+BEGIN_SRC python
|
||||
import spot
|
||||
print(spot.translate('GFa -> GFb', 'BA').to_str('spin'))
|
||||
print(spot.translate('GFa -> GFb', 'buchi', 'sbacc').to_str('spin'))
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
|
@ -120,15 +120,16 @@ T0_S3:
|
|||
|
||||
* C++
|
||||
|
||||
All the translation pipeline (this include simplifying the formula,
|
||||
All the translation pipeline (this includes simplifying the formula,
|
||||
translating the simplified formula into an automaton, and simplifying
|
||||
the resulting automaton) is handled by the =spot::translator= class.
|
||||
An instance of this class can configured by calling =set_type()= to
|
||||
chose the type of automaton to output, =set_level()= to set the level
|
||||
of optimization (it's high by default), and =set_pref()= to set
|
||||
various preferences (like small or deterministic) or characteristic
|
||||
(complete, unambiguous) for the resulting automaton. Finally, the
|
||||
output as a never claim is done via the =print_never_claim= function.
|
||||
(complete, unambiguous, state-based acceptance) for the resulting
|
||||
automaton. Finally, the output as a never claim is done via the
|
||||
=print_never_claim= function.
|
||||
|
||||
#+BEGIN_SRC C++
|
||||
#include <iostream>
|
||||
|
|
@ -138,11 +139,13 @@ output as a never claim is done via the =print_never_claim= function.
|
|||
|
||||
int main()
|
||||
{
|
||||
spot::parsed_formula pf = spot::parse_infix_psl("[]<>p0 || <>[]p1");
|
||||
spot::parsed_formula pf = spot::parse_infix_psl("[]<>a || <>[]b");
|
||||
if (pf.format_errors(std::cerr))
|
||||
return 1;
|
||||
spot::translator trans;
|
||||
trans.set_type(spot::postprocessor::BA);
|
||||
trans.set_type(spot::postprocessor::Buchi);
|
||||
trans.set_pref(spot::postprocessor::SBAcc
|
||||
| spot::postprocessor::Small);
|
||||
spot::twa_graph_ptr aut = trans.run(pf.f);
|
||||
print_never_claim(std::cout, aut) << '\n';
|
||||
return 0;
|
||||
|
|
@ -155,24 +158,25 @@ never {
|
|||
T0_init:
|
||||
if
|
||||
:: (true) -> goto T0_init
|
||||
:: (p0) -> goto accept_S1
|
||||
:: (p1) -> goto accept_S2
|
||||
:: (a) -> goto accept_S1
|
||||
:: (b) -> goto accept_S2
|
||||
fi;
|
||||
accept_S1:
|
||||
if
|
||||
:: (p0) -> goto accept_S1
|
||||
:: (!(p0)) -> goto T0_S3
|
||||
:: (a) -> goto accept_S1
|
||||
:: (!(a)) -> goto T0_S3
|
||||
fi;
|
||||
accept_S2:
|
||||
if
|
||||
:: (p1) -> goto accept_S2
|
||||
:: (b) -> goto accept_S2
|
||||
fi;
|
||||
T0_S3:
|
||||
if
|
||||
:: (p0) -> goto accept_S1
|
||||
:: (!(p0)) -> goto T0_S3
|
||||
:: (a) -> goto accept_S1
|
||||
:: (!(a)) -> goto T0_S3
|
||||
fi;
|
||||
}
|
||||
|
||||
#+end_example
|
||||
|
||||
* Additional comments
|
||||
|
|
@ -188,17 +192,17 @@ help(spot.translate)
|
|||
#+begin_example
|
||||
Help on function translate in module spot:
|
||||
|
||||
translate(formula, *args, dict=<spot.impl.bdd_dict; proxy of <Swig Object of type 'std::shared_ptr< spot::bdd_dict > *' at 0x7f1f9541c090> >, xargs=None)
|
||||
translate(formula, *args, dict=<spot.impl.bdd_dict; proxy of <Swig Object of type 'std::shared_ptr< spot::bdd_dict > *' at 0x7f42f4cea030> >, xargs=None)
|
||||
Translate a formula into an automaton.
|
||||
|
||||
Keep in mind that 'Deterministic' expresses just a preference that
|
||||
may not be satisfied.
|
||||
|
||||
The optional arguments should be strings among the following:
|
||||
- at most one in 'TGBA', 'BA', or 'Monitor', 'generic',
|
||||
'parity', 'parity min odd', 'parity min even',
|
||||
'parity max odd', 'parity max even' (type of automaton to
|
||||
build), 'coBuchi'
|
||||
- at most one in 'GeneralizedBuchi', 'Buchi', or 'Monitor',
|
||||
'generic', 'parity', 'parity min odd', 'parity min even',
|
||||
'parity max odd', 'parity max even', 'coBuchi'
|
||||
(type of acceptance condition to build)
|
||||
- at most one in 'Small', 'Deterministic', 'Any'
|
||||
(preferred characteristics of the produced automaton)
|
||||
- at most one in 'Low', 'Medium', 'High'
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ more simplification opportunities.)
|
|||
#+begin_src python
|
||||
import spot
|
||||
# Translate LTLf to Büchi.
|
||||
aut = spot.from_ltlf('(a U b) & Fc').translate('ba')
|
||||
aut = spot.from_ltlf('(a U b) & Fc').translate('small', 'buchi', 'sbacc')
|
||||
# Remove "alive" atomic proposition
|
||||
rem = spot.remove_ap()
|
||||
rem.add_ap('alive')
|
||||
|
|
@ -141,7 +141,7 @@ AP: 3 "b" "a" "c"
|
|||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
properties: trans-labels explicit-labels state-acc deterministic
|
||||
properties: very-weak
|
||||
properties: terminal
|
||||
--BODY--
|
||||
State: 0
|
||||
[!2] 0
|
||||
|
|
@ -171,36 +171,38 @@ wrappers around the =spot::translator= and =spot::postprocessor=
|
|||
objects that we need to use here.
|
||||
|
||||
#+begin_src C++
|
||||
#include <iostream>
|
||||
#include <spot/tl/parse.hh>
|
||||
#include <spot/tl/ltlf.hh>
|
||||
#include <spot/twaalgos/translate.hh>
|
||||
#include <spot/twaalgos/hoa.hh>
|
||||
#include <spot/twaalgos/remprop.hh>
|
||||
#include <iostream>
|
||||
#include <spot/tl/parse.hh>
|
||||
#include <spot/tl/ltlf.hh>
|
||||
#include <spot/twaalgos/translate.hh>
|
||||
#include <spot/twaalgos/hoa.hh>
|
||||
#include <spot/twaalgos/remprop.hh>
|
||||
|
||||
int main()
|
||||
{
|
||||
spot::parsed_formula pf = spot::parse_infix_psl("(a U b) & Fc");
|
||||
if (pf.format_errors(std::cerr))
|
||||
return 1;
|
||||
int main()
|
||||
{
|
||||
spot::parsed_formula pf = spot::parse_infix_psl("(a U b) & Fc");
|
||||
if (pf.format_errors(std::cerr))
|
||||
return 1;
|
||||
|
||||
spot::translator trans;
|
||||
trans.set_type(spot::postprocessor::BA);
|
||||
trans.set_pref(spot::postprocessor::Small);
|
||||
spot::twa_graph_ptr aut = trans.run(spot::from_ltlf(pf.f));
|
||||
spot::translator trans;
|
||||
trans.set_type(spot::postprocessor::Buchi);
|
||||
trans.set_pref(spot::postprocessor::SBAcc
|
||||
| spot::postprocessor::Small);
|
||||
spot::twa_graph_ptr aut = trans.run(spot::from_ltlf(pf.f));
|
||||
|
||||
spot::remove_ap rem;
|
||||
rem.add_ap("alive");
|
||||
aut = rem.strip(aut);
|
||||
spot::remove_ap rem;
|
||||
rem.add_ap("alive");
|
||||
aut = rem.strip(aut);
|
||||
|
||||
spot::postprocessor post;
|
||||
post.set_type(spot::postprocessor::BA);
|
||||
post.set_pref(spot::postprocessor::Small); // or ::Deterministic
|
||||
aut = post.run(aut);
|
||||
spot::postprocessor post;
|
||||
post.set_type(spot::postprocessor::Buchi);
|
||||
post.set_pref(spot::postprocessor::SBAcc
|
||||
| spot::postprocessor::Small); // or ::Deterministic
|
||||
aut = post.run(aut);
|
||||
|
||||
print_hoa(std::cout, aut) << '\n';
|
||||
return 0;
|
||||
}
|
||||
print_hoa(std::cout, aut) << '\n';
|
||||
return 0;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
|
|
@ -212,7 +214,7 @@ AP: 3 "b" "a" "c"
|
|||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
properties: trans-labels explicit-labels state-acc deterministic
|
||||
properties: very-weak
|
||||
properties: terminal
|
||||
--BODY--
|
||||
State: 0
|
||||
[!2] 0
|
||||
|
|
|
|||
|
|
@ -94,11 +94,11 @@ The Python version uses the =postprocess()= routine:
|
|||
|
||||
#+BEGIN_SRC python :wrap SRC hoa
|
||||
import spot
|
||||
aut = spot.automaton('tut30.hoa').postprocess('BA', 'deterministic')
|
||||
aut = spot.automaton('tut30.hoa').postprocess('buchi', 'sbacc', 'deterministic')
|
||||
print(aut.to_str('hoa'))
|
||||
#+END_SRC
|
||||
#+RESULTS:
|
||||
#+BEGIN_SRC hoa
|
||||
#+begin_SRC hoa
|
||||
HOA: v1
|
||||
States: 5
|
||||
Start: 1
|
||||
|
|
@ -106,7 +106,7 @@ AP: 1 "p1"
|
|||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
properties: trans-labels explicit-labels state-acc complete
|
||||
properties: deterministic weak
|
||||
properties: deterministic terminal
|
||||
--BODY--
|
||||
State: 0 {0}
|
||||
[t] 0
|
||||
|
|
@ -122,7 +122,7 @@ State: 4
|
|||
[!0] 0
|
||||
[0] 4
|
||||
--END--
|
||||
#+END_SRC
|
||||
#+end_SRC
|
||||
|
||||
The =postprocess()= function has an interface similar to
|
||||
[[file:tut10.org][the =translate()= function discussed previously]]:
|
||||
|
|
@ -145,10 +145,10 @@ postprocess(automaton, *args, formula=None, xargs=None)
|
|||
not already 'Deterministic'.
|
||||
|
||||
The optional arguments should be strings among the following:
|
||||
- at most one in 'Generic', 'TGBA', 'BA', or 'Monitor',
|
||||
'parity', 'parity min odd', 'parity min even',
|
||||
'parity max odd', 'parity max even' (type of automaton to
|
||||
build), 'coBuchi'
|
||||
- at most one in 'Generic', 'GeneralizedBuchi', 'Buchi', or
|
||||
'Monitor', 'parity', 'parity min odd', 'parity min even',
|
||||
'parity max odd', 'parity max even', 'coBuchi'
|
||||
(type of acceptance condition to build)
|
||||
- at most one in 'Small', 'Deterministic', 'Any'
|
||||
(preferred characteristics of the produced automaton)
|
||||
- at most one in 'Low', 'Medium', 'High'
|
||||
|
|
@ -195,8 +195,9 @@ automaton to process.
|
|||
return 1;
|
||||
}
|
||||
spot::postprocessor post;
|
||||
post.set_type(spot::postprocessor::BA);
|
||||
post.set_pref(spot::postprocessor::Deterministic);
|
||||
post.set_type(spot::postprocessor::Buchi);
|
||||
post.set_pref(spot::postprocessor::SBAcc
|
||||
| spot::postprocessor::Deterministic);
|
||||
post.set_level(spot::postprocessor::High);
|
||||
auto aut = post.run(pa->aut);
|
||||
spot::print_hoa(std::cout, aut) << '\n';
|
||||
|
|
@ -213,7 +214,7 @@ AP: 1 "p1"
|
|||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
properties: trans-labels explicit-labels state-acc complete
|
||||
properties: deterministic very-weak
|
||||
properties: deterministic terminal
|
||||
--BODY--
|
||||
State: 0 {0}
|
||||
[t] 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue