twaalgos/totgba: Add dnf_to_streett() method

* NEWS: Update.
* spot/twaalgos/totgba.hh: Declare dnf_to_streett().
* spot/twaalgos/totgba.cc: Implement dnf_to_streett().
* bin/autfilt.cc: Add --dnf-to-streett cmd line option.
* tests/core/dnfstreett.test: Add test.
* tests/Makefile.am: Add test file.
parent cf18c069
......@@ -9,6 +9,10 @@ New in spot 2.4.0.dev (not yet released)
--ms-phi-r=RANGE (FGa{n}&GFb{n})|((FGa{n-1}|GFb{n-1})&(...))
--ms-phi-s=RANGE (FGa{n}|GFb{n})&((FGa{n-1}&GFb{n-1})|(...))
- autfilt learned --streett-like to convert an automaton in order to
have a Streett-like acceptance condition. It only works with
ω-automata having an acceptance in disjunctive normal form.
Library:
- Rename three methods of spot::scc_info. New names are clearer. The
......@@ -26,6 +30,11 @@ New in spot 2.4.0.dev (not yet released)
recognize more if the original language can not be expressed with
a co-Büchi acceptance condition.
- The new function dnf_to_streett() is able to convert any automaton
with an acceptance condition in Disjunctive Normal Form to a
Streett-like automaton. This is used by the new option
'--streett-like' of autfilt.
Deprecation notices:
(These functions still work but compilers emit warnings.)
......
......@@ -142,6 +142,7 @@ enum {
OPT_SIMPLIFY_EXCLUSIVE_AP,
OPT_SPLIT_EDGES,
OPT_STATES,
OPT_STREETT_LIKE,
OPT_STRIPACC,
OPT_SUM_OR,
OPT_SUM_AND,
......@@ -275,6 +276,9 @@ static const argp_option options[] =
"initial state. Implies --remove-unreachable-states.", 0 },
{ "dnf-acceptance", OPT_DNF_ACC, nullptr, 0,
"put the acceptance condition in Disjunctive Normal Form", 0 },
{ "streett-like", OPT_STREETT_LIKE, nullptr, 0,
"convert to an automaton with Streett-like acceptance. Works only with "
"acceptance condition in DNF", 0 },
{ "cnf-acceptance", OPT_CNF_ACC, nullptr, 0,
"put the acceptance condition in Conjunctive Normal Form", 0 },
{ "remove-fin", OPT_REM_FIN, nullptr, 0,
......@@ -520,6 +524,7 @@ static int opt_highlight_nondet_states = -1;
static int opt_highlight_nondet_edges = -1;
static bool opt_highlight_languages = false;
static bool opt_dca = false;
static bool opt_streett_like = false;
static spot::twa_graph_ptr
ensure_deterministic(const spot::twa_graph_ptr& aut, bool nonalt = false)
......@@ -622,6 +627,9 @@ parse_opt(int key, char* arg, struct argp_state*)
opt_dnf_acc = true;
opt_cnf_acc = false;
break;
case OPT_STREETT_LIKE:
opt_streett_like = true;
break;
case OPT_EDGES:
opt_edges = parse_range(arg, 0, std::numeric_limits<int>::max());
break;
......@@ -1205,6 +1213,9 @@ namespace
if (opt_dca)
aut = spot::to_dca(aut, false);
if (opt_streett_like)
aut = spot::dnf_to_streett(aut);
if (opt_simplify_exclusive_ap && !opt->excl_ap.empty())
aut = opt->excl_ap.constrain(aut, true);
else if (opt_rem_unused_ap) // constrain(aut, true) already does that
......
This diff is collapsed.
......@@ -21,6 +21,8 @@
#include <spot/twa/twagraph.hh>
#include <unordered_map>
namespace spot
{
/// \brief Take an automaton with any acceptance condition and return
......@@ -66,4 +68,38 @@ namespace spot
SPOT_API twa_graph_ptr
to_generalized_streett(const const_twa_graph_ptr& aut,
bool share_fin = false);
/// \brief Converts any DNF acceptance condition into Streett-like.
///
/// This function is an optimized version of the construction described
/// by Lemma 4 and 5 of the paper below.
/** \verbatim
@Article{boker.2009.lcs,
author = {Udi Boker and Orna Kupferman},
title = {Co-Büching Them All},
booktitle = {Foundations of Software Science and Computational
Structures - 14th International Conference, FOSSACS 2011}
year = {2011},
pages = {184--198},
url = {\url{www.cs.huji.ac.il/~ornak/publications/fossacs11b.pdf}}
}
\endverbatim */
///
/// In the described construction, as many copies as there are minterms in
/// the acceptance condition are made and the union of all those copies is
/// returned.
/// Instead of cloning the automaton for each minterm and end up with many
/// rejecting and useless SCC, we construct the automaton SCC by SCC. Each SCC
/// is copied at most as many times as there are minterms for which it is not
/// rejecting and at least one time if it is always rejecting (to be
/// consistent with the recognized language).
///
/// \a aut The automaton to convert.
/// \a original_states Enable mapping between each state of the resulting
/// automaton and the original state of the input automaton. This is stored
/// in the "original-states" named property of the produced automaton. Call
/// `aut->get_named_prop<std::vector<unsigned>>("original-states")`
/// to retrieve it.
SPOT_API twa_graph_ptr
dnf_to_streett(const const_twa_graph_ptr& aut, bool original_states = false);
}
......@@ -300,7 +300,8 @@ TESTS_twa = \
core/randpsl.test \
core/cycles.test \
core/acc_word.test \
core/dca.test
core/dca.test \
core/dnfstreett.test
############################## PYTHON ##############################
......
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2017 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# 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/>.
. ./defs
set -e
cat >accs << 'EOF'
(Fin(0) & Inf(1)) | Fin(2)
(Fin(0) & Inf(1)) | Inf(2)
(Fin(0) & Fin(1) & Fin(2) & Inf(3)) | Inf(4) | Fin(5)
Rabin1
Rabin2
Rabin3
(Fin(0) & Inf(1)) | (Fin(2) & Fin(3) & Fin(4)) | (Inf(5) & Inf(6) & Inf(7))
Fin(0) | (Fin(1) & Fin(2) & Inf(3)) | (Inf(4) & Inf(5) & Fin(6))
Fin(0) | Inf(1) | Inf(2) | Fin(3)
EOF
while read line
do
randaut -A "$line" a b c > input.hoa
autfilt --streett-like input.hoa > res.hoa
autfilt input.hoa --equivalent-to='res.hoa'
autfilt --complement input.hoa > input_comp.hoa
autfilt --complement res.hoa > res_comp.hoa
autfilt input_comp.hoa --equivalent-to='res_comp.hoa'
done < accs
cat >random_ltl<< 'EOF'
F(a R !c)
XXF(a R b)
FG(Xa xor !(a W c))
XX(1 U ((X(b W a) M 1) R c))
(b | GFXb) -> (a xor b)
F(!a R c) | (b <-> XX(!Gb R b))
X!G(0 R (b M 1))
XF((Fc <-> (!b W c)) <-> (Gc M 1))
F((!b | FGc) -> (b W (!c <-> Xc)))
((a xor b) -> a) U (Ga & (b R c))
F((a M Xc) | FG(Xb <-> X(b | c)))
XFG!a
((b R c) | F!XGF(b | c)) R !b
Xc U Ga
(Fa & Xc) | G(b U Ga)
X!(((c <-> (!a M b)) W 0) W 0)
b U (c W Fa)
F(Xa W (b xor (Ga U !Xb)))
!(G(c R Gc) U X(Fc W !Xb))
F(0 R (c W a))
EOF
ltlcross -F random_ltl \
--timeout=60 \
'{1} ltl2tgba %f | autfilt --gra >%T' \
'{2} ltl2tgba %f | autfilt --gra | autfilt --streett-like >%T'
cat >input.hoa<< 'EOF'
HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
Acceptance: 6 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) | (Fin(4) & Inf(5))
--BODY--
State: 0
[!0&!1] 3
[!0&!1] 1
State: 1
[0&1] 2 {1 2 4}
State: 2
[0&1] 1
State: 3
[!0&1] 0 {0 3 5}
[!0&!1] 2 {1 2 4}
--END--
EOF
autfilt --streett-like input.hoa > res.hoa
autfilt input.hoa --equivalent-to='res.hoa'
autfilt --complement input.hoa > input_comp.hoa
autfilt --complement res.hoa > res_comp.hoa
autfilt input_comp.hoa --equivalent-to='res_comp.hoa'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment