Commit 0c7c9338 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

simulation: Fix co-simulation and iterated simulations of BA automata

* src/tgbaalgos/simulation.hh, src/tgbaalgos/simulation.cc
(simulation_sba, cosimulation_sba, iterated_simulations_sba): New
function.  Also speedup the existing functions by avoiding
add_acceptince_conditions() and add_conditions().  Finally, use
scc_filter_states() when dealing with degeneralized automata.
* src/tgbaalgos/postproc.cc, src/tgbaalgos/postproc.hh (do_ba_simul):
New method.  Use it after degeneralization.
* src/tgba/tgbaexplicit.hh (get_transition, get_state): New methods.
* src/tgbatest/basimul.test: New file.
* src/tgbatest/Makefile.am (TESTS): Add it.
* NEWS: Introduce the new function and summarize the bug.
parent 372790a4
......@@ -30,6 +30,15 @@ New in spot 1.1a (not yet released):
the automaton. scc_filter_state() should be used when
post-processing TGBAs that actually represent BAs.
- simulation_sba(), cosimulation_sba(), and
iterated_simulations_sba() are new functions that apply to TGBAs
that actually represent BAs. They preserve the imporant
property that if a state of the BA is is accepting, the outgoing
transitions of that state are all accepting in the TGBA that
represent the BA. This is something that was not preserved by
functions cosimultion() and iterated_simulations() as mentionned
in the bug fixes below.
- ltlcross has a new option --seed, that makes it possible to
change the seed used by the random graph generator.
......@@ -40,6 +49,14 @@ New in spot 1.1a (not yet released):
- ltlfilt --stutter-invariant would trigger an assert on PSL formulas.
- ltl2tgba, ltl2tgta, ltlcross, and ltlfilt, would all choke on empty
lines in a file of formulas. They now ignore empty lines.
- The iterated simulation applied on degeneralized TGBA was bogus
for two reasons: one was that cosimulation was applied using the
generic cosimulation for TGBA, and the second is that
SCC-filtering, performed between iterations, was also a
TGBA-based algorithm. Both of these algorithms could lose the
property that if a TGBA represents a BA, all the outgoing
transitions of a state should be accepting. As a consequence, some
formulas where translated to incorrect Büchi automata.
New in spot 1.1 (2013-04-28):
......
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
// Développement de l'Epita.
// Copyright (C) 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche
// et Développement de l'Epita.
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
......@@ -318,6 +318,15 @@ namespace spot
return const_cast<transition*>(&(*(si->get_iterator())));
}
transition*
get_transition(const tgba_succ_iterator* si)
{
const tgba_explicit_succ_iterator<State>* tmp
= down_cast<const tgba_explicit_succ_iterator<State>*>(si);
assert(tmp);
return get_transition(tmp);
}
void add_condition(transition* t, const ltl::formula* f)
{
t->condition &= formula_to_bdd(f, dict_, this);
......@@ -336,12 +345,24 @@ namespace spot
return dict_->is_registered_acceptance_variable(f, this);
}
//old tgba explicit labelled interface
//old tgba explicit labeled interface
bool has_state(const label_t& name)
{
return ls_.find(name) != ls_.end();
}
/// \brief Return the state associated to a given label.
///
/// This is similar to add_state(), except that it returns 0 if
/// the state does not exist.
const State* get_state(const label_t& name)
{
typename ls_map::const_iterator i = ls_.find(name);
if (i == ls_.end())
return 0;
return &i->second;
}
const label_t& get_label(const State* s) const
{
typename sl_map::const_iterator i = sl_.find(s);
......
......@@ -80,6 +80,23 @@ namespace spot
}
}
const tgba* postprocessor::do_ba_simul(const tgba* a, int opt)
{
switch (opt)
{
case 0:
return a;
case 1:
return simulation_sba(a);
case 2:
return cosimulation_sba(a);
case 3:
default:
return iterated_simulations_sba(a);
}
}
const tgba* postprocessor::do_degen(const tgba* a)
{
const tgba* d = degeneralize(a,
......@@ -90,7 +107,7 @@ namespace spot
if (ba_simul_ <= 0)
return d;
const tgba* s = do_simul(d, ba_simul_);
const tgba* s = do_ba_simul(d, ba_simul_);
if (s != d)
delete d;
......
......@@ -91,6 +91,7 @@ namespace spot
protected:
const tgba* do_simul(const tgba* input, int opt);
const tgba* do_ba_simul(const tgba* input, int opt);
const tgba* do_degen(const tgba* input);
output_type type_;
......
This diff is collapsed.
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -20,7 +20,6 @@
#ifndef SPOT_TGBAALGOS_SIMULATION_HH
# define SPOT_TGBAALGOS_SIMULATION_HH
namespace spot
{
class tgba;
......@@ -28,6 +27,7 @@ namespace spot
/// \addtogroup tgba_reduction
/// @{
/// @{
/// \brief Attempt to reduce the automaton by direct simulation.
///
/// When the suffixes (letter and acceptance conditions) reachable
......@@ -68,7 +68,10 @@ namespace spot
/// \return a new automaton which is at worst a copy of the received
/// one
tgba* simulation(const tgba* automaton);
tgba* simulation_sba(const tgba* automaton);
/// @}
/// @{
/// \brief Attempt to reduce the automaton by reverse simulation.
///
/// When the prefixes (letter and acceptance conditions) leading to
......@@ -116,7 +119,10 @@ namespace spot
/// \return a new automaton which is at worst a copy of the received
/// one
tgba* cosimulation(const tgba* automaton);
tgba* cosimulation_sba(const tgba* automaton);
/// @}
/// @{
/// \brief Iterate simulation() and cosimulation().
///
/// Runs simulation(), cosimulation(), and scc_filter() in a loop,
......@@ -132,6 +138,8 @@ namespace spot
/// \return a new automaton which is at worst a copy of the received
/// one
tgba* iterated_simulations(const tgba* automaton);
tgba* iterated_simulations_sba(const tgba* automaton);
/// @}
tgba* dont_care_simulation(const tgba* t, int limit = -1);
......
......@@ -110,6 +110,7 @@ TESTS = \
dfs.test \
emptchkr.test \
ltlcounter.test \
basimul.test \
spotlbtt.test \
ltlcross.test \
spotlbtt2.test \
......
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2013 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
ltl2tgba=../../bin/ltl2tgba
# This bug was found while working on the state-based acceptance
# output for the LBTT format. Using ba-simul=2 causes reverse
# simulation to be applied to the BA automaton obtained after
# degeneralization. Unfortunately in Spot 1.1, reverse simulation is
# only implemented on TGBA, and when applied to a TGBA that is a BA,
# it may merge one state that is accepting with one state that is not
# accepting, just because they have the same incoming transitions.
# (Applying direct simulation on a TGBA that is a BA is not a problem,
# since an accepting state will never have the same outgoing
# transitions as a BA.)
# In previous tests, we did not notice the bug because the --lbtt
# output was always using transition-based acceptance (the equivalent
# of --lbtt=t today), so the result of the reverse-simulation on the
# BA was output as a TGBA with a single acceptance set, and some state
# had both accepting and non-accepting transitions because of the
# merge. Unfortunately, this is not a Büchi automaton. Using the
# --spin output, or the new (state-based) --lbtt output highlights the
# bug.
# In the cases below, the following configurations used to fail
# cross-comparison with the other "sane" configurations, at least
# with the first formula. (The other three formulas were added because
# they also triggered related issues while debugging the first one.)
# --lbtt -x ba-simul=2
# --lbtt -x ba-simul=3
# --spin -x ba-simul=2
# --spin -x ba-simul=3
for seed in 1 2 3; do
../../bin/ltlcross --seed=$seed --density=0.$seed \
-f 'X((F(Xa | b) W c) U (Xc W (a & d)))' \
-f '((<> p5 V ((p0 U p1) <-> (p5 \/ p1))) -> ((<> p4 V p2) M p2))' \
-f '!p2 & (Fp5 R (((p0 U p1) & (p5 | p1)) | (!p5 & (!p0 R !p1))))' \
-f '! ((p0 /\ p4) <-> ! ((! p0 U (p0 W p4)) /\ (X p5 -> ([] p3 /\ p5))))' \
"$ltl2tgba --ba --high --lbtt=t -x ba-simul=0 %f >%T" \
"$ltl2tgba --ba --high --lbtt=t -x ba-simul=1 %f >%T" \
"$ltl2tgba --ba --high --lbtt=t -x ba-simul=2 %f >%T" \
"$ltl2tgba --ba --high --lbtt=t -x ba-simul=3 %f >%T" \
"$ltl2tgba --ba --high --lbtt -x ba-simul=0 %f >%T" \
"$ltl2tgba --ba --high --lbtt -x ba-simul=1 %f >%T" \
"$ltl2tgba --ba --high --lbtt -x ba-simul=2 %f >%T" \
"$ltl2tgba --ba --high --lbtt -x ba-simul=3 %f >%T" \
"$ltl2tgba --ba --high --spin -x ba-simul=0 %f >%N" \
"$ltl2tgba --ba --high --spin -x ba-simul=1 %f >%N" \
"$ltl2tgba --ba --high --spin -x ba-simul=2 %f >%N" \
"$ltl2tgba --ba --high --spin -x ba-simul=3 %f >%N"
done
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