Commit 9bea364e authored by Denis Poitrenaud's avatar Denis Poitrenaud
Browse files

* src/tgbaalgos/magic.hh: Fix a comment and remove se05 interface.

* src/tgbaalgos/magic.cc: Fix a comment.
* src/tgbaalgos/se05.hh: New file.
* src/tgbaalgos/se05.cc: Fix a comment.
* src/tgbaalgos/tau03.hh: New file.
* src/tgbaalgos/tau03.cc: New file.
* src/tgbaalgos/Makefile.am: Add it.
* src/tgbatest/ltl2tgba.cc: Add tau03 new emptiness check.
* src/tgbatest/randtgba.cc: Add tau03 new emptiness check.
* src/tgbatest/emptchkr: Fix a comment.
* src/tgbatest/tba_samples_from_spin/explicit1_1.tba,
src/tgbatest/tba_samples_from_spin/explicit1_2.tba,
src/tgbatest/tba_samples_from_spin/explicit1_3.tba,
src/tgbatest/tba_samples_from_spin/explicit1_4.tba,
src/tgbatest/tba_samples_from_spin/explicit1_5.tba,
src/tgbatest/tba_samples_from_spin/explicit1_6.tba,
src/tgbatest/tba_samples_from_spin/explicit1_7.tba,
src/tgbatest/tba_samples_from_spin/explicit1_8.tba,
src/tgbatest/tba_samples_from_spin/explicit1_9.tba,
src/tgbatest/tba_samples_from_spin/explicit2_1.tba,
src/tgbatest/tba_samples_from_spin/explicit2_2.tba,
src/tgbatest/tba_samples_from_spin/explicit2_3.tba,
src/tgbatest/tba_samples_from_spin/explicit2_4.tba,
src/tgbatest/tba_samples_from_spin/explicit2_5.tba,
src/tgbatest/tba_samples_from_spin/explicit2_6.tba,
src/tgbatest/tba_samples_from_spin/explicit2_7.tba,
src/tgbatest/tba_samples_from_spin/explicit2_8.tba,
src/tgbatest/tba_samples_from_spin/explicit2_9.tba: New files
* src/tgbatest/tba_samples_from_spin.test : New test.
* src/tgbatest/Makefile.am: Add it.
parent c3e399c8
2004-11-17 Poitrenaud Denis <denis@src.lip6.fr>
* src/tgbaalgos/magic.hh: Fix a comment and remove se05 interface.
* src/tgbaalgos/magic.cc: Fix a comment.
* src/tgbaalgos/se05.hh: New file.
* src/tgbaalgos/se05.cc: Fix a comment.
* src/tgbaalgos/tau03.hh: New file.
* src/tgbaalgos/tau03.cc: New file.
* src/tgbaalgos/Makefile.am: Add it.
* src/tgbatest/ltl2tgba.cc: Add tau03 new emptiness check.
* src/tgbatest/randtgba.cc: Add tau03 new emptiness check.
* src/tgbatest/emptchkr: Fix a comment.
* src/tgbatest/tba_samples_from_spin/explicit1_1.tba,
src/tgbatest/tba_samples_from_spin/explicit1_2.tba,
src/tgbatest/tba_samples_from_spin/explicit1_3.tba,
src/tgbatest/tba_samples_from_spin/explicit1_4.tba,
src/tgbatest/tba_samples_from_spin/explicit1_5.tba,
src/tgbatest/tba_samples_from_spin/explicit1_6.tba,
src/tgbatest/tba_samples_from_spin/explicit1_7.tba,
src/tgbatest/tba_samples_from_spin/explicit1_8.tba,
src/tgbatest/tba_samples_from_spin/explicit1_9.tba,
src/tgbatest/tba_samples_from_spin/explicit2_1.tba,
src/tgbatest/tba_samples_from_spin/explicit2_2.tba,
src/tgbatest/tba_samples_from_spin/explicit2_3.tba,
src/tgbatest/tba_samples_from_spin/explicit2_4.tba,
src/tgbatest/tba_samples_from_spin/explicit2_5.tba,
src/tgbatest/tba_samples_from_spin/explicit2_6.tba,
src/tgbatest/tba_samples_from_spin/explicit2_7.tba,
src/tgbatest/tba_samples_from_spin/explicit2_8.tba,
src/tgbatest/tba_samples_from_spin/explicit2_9.tba: New files
* src/tgbatest/tba_samples_from_spin.test : New test.
* src/tgbatest/Makefile.am: Add it.
2004-11-17 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgba/tgba.hh, src/tgbaalgos/dotty.hh,
......
......@@ -43,7 +43,9 @@ tgbaalgos_HEADERS = \
replayrun.hh \
rundotdec.hh \
save.hh \
se05.hh \
stats.hh \
tau03.hh \
reductgba_sim.hh
noinst_LTLIBRARIES = libtgbaalgos.la
......@@ -66,6 +68,7 @@ libtgbaalgos_la_SOURCES = \
save.cc \
se05.cc \
stats.cc \
tau03.cc \
reductgba_sim.cc \
reductgba_sim_del.cc
......
......@@ -19,12 +19,12 @@
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include <cstring>
#include <iostream>
#include "misc/hash.hh"
#include <cassert>
#include <list>
#include <iterator>
#include <cassert>
#include "misc/hash.hh"
#include "tgba/tgba.hh"
#include "emptiness.hh"
#include "magic.hh"
namespace spot
......@@ -68,7 +68,7 @@ namespace spot
/// \brief Perform a Magic Search.
///
/// \return non null pointer iff the algorithm has found a
/// \return non null pointer iff the algorithm has found a
/// new accepting path.
///
/// check() can be called several times (until it returns a null
......@@ -129,10 +129,10 @@ namespace spot
const state* s;
/// Design the next successor of \a s which has to be visited.
tgba_succ_iterator* it;
/// The label of the transition followed to reach \a s
/// The label of the transition traversed to reach \a s
/// (false for the first one).
bdd label;
/// The acc set of the transition followed to reach \a s
/// The acceptance set of the transition traversed to reach \a s
/// (false for the first one).
bdd acc;
};
......@@ -255,9 +255,6 @@ namespace spot
f.it->next();
typename heap::color_ref c = h.get_color_ref(s_prime);
if (c.is_white())
// Notice that this case is taken into account only to
// support successive calls to the check method. Without
// this functionnality, one can check assert(c.is_white()).
// Go down the edge (f.s, <label, acc>, s_prime)
{
++nbn;
......
......@@ -22,25 +22,26 @@
#ifndef SPOT_TGBAALGOS_MAGIC_HH
# define SPOT_TGBAALGOS_MAGIC_HH
#include "tgba/tgba.hh"
#include "emptiness.hh"
#include <cstddef>
namespace spot
{
class tgba;
class emptiness_check;
/// \addtogroup emptiness_check_algorithms
/// @{
/// \brief Returns an emptiness checker on the spot::tgba automaton \a a.
/// During the visit of \a a, the returned checker stores explicitely all
/// the traversed states.
///
/// \pre The automaton \a a must have at most one accepting condition (i.e.
/// it is a TBA).
///
/// The method \a check() of the returned checker can be called several times
/// During the visit of \a a, the returned checker stores explicitely all
/// the traversed states.
/// The method \a check() of the checker can be called several times
/// (until it returns a null pointer) to enumerate all the visited accepting
/// paths. The implemented algorithm is the following.
/// paths. The implemented algorithm is the following:
///
/// \verbatim
/// procedure check ()
......@@ -95,110 +96,30 @@ namespace spot
emptiness_check* explicit_magic_search(const tgba *a);
/// \brief Returns an emptiness checker on the spot::tgba automaton \a a.
/// During the visit of \a a, the returned checker does not store explicitely
/// the traversed states but uses the bit state hashing technic. However, the
/// implemented algorithm is the same as the one of
/// spot::explicit_magic_search.
///
/// \pre The automaton \a a must have at most one accepting condition (i.e.
/// it is a TBA).
///
/// \sa spot::explicit_magic_search
///
emptiness_check* bit_state_hashing_magic_search(const tgba *a, size_t size);
/// \brief Returns an emptiness check on the spot::tgba automaton \a a.
/// During the visit of \a a, the returned checker stores explicitely all
/// the traversed states.
///
/// \pre The automaton \a a must have at most one accepting condition (i.e.
/// it is a TBA).
///
/// The method \a check() of the returned checker can be called several times
/// (until it returns a null pointer) to enumerate all the visited accepting
/// paths. The implemented algorithm is the following:
///
/// \verbatim
/// procedure check ()
/// begin
/// weight = 0;
/// call dfs_blue(s0);
/// end;
///
/// procedure dfs_blue (s)
/// begin
/// s.color = cyan;
/// s.weight = weight;
/// for all t in post(s) do
/// if t.color == white then
/// if the edge (s,t) is accepting then
/// weight = weight + 1;
/// end if;
/// call dfs_blue(t);
/// if the edge (s,t) is accepting then
/// weight = weight - 1;
/// end if;
/// else if t.color == cyan and
/// (the edge (s,t) is accepting or
/// weight > t.weight) then
/// report cycle;
/// end if;
/// if the edge (s,t) is accepting then
/// call dfs_red(t);
/// end if;
/// end for;
/// s.color = blue;
/// end;
///
/// procedure dfs_red(s)
/// begin
/// if s.color == cyan then
/// report cycle;
/// end if;
/// s.color = red;
/// for all t in post(s) do
/// if t.color != red then
/// call dfs_red(t);
/// end if;
/// end for;
/// end;
/// \endverbatim
/// During the visit of \a a, the returned checker does not store explicitely
/// the traversed states but uses the bit-state hashing technic presented in:
///
/// It is an adaptation to TBA (and a slight extension) of the one
/// presented in
/// \verbatim
/// InProceedings{ schwoon.05.tacas,
/// author = {Stephan Schwoon and Javier Esparza},
/// title = {A Note on On-The-Fly Verification Algorithms},
/// booktitle = {TACAS'05},
/// pages = {},
/// year = {2005},
/// volume = {},
/// series = {LNCS},
/// publisher = {Springer-Verlag}
/// }
/// @book{Holzmann91,
/// author = {G.J. Holzmann},
/// title = {Design and Validation of Computer Protocols},
/// publisher = {Prentice-Hall},
/// address = {Englewood Cliffs, New Jersey},
/// year = {1991}
/// }
/// \endverbatim
///
/// The extention consists in the introduction of a weight associated
/// to each state in the blue stack (the cyan states). The weight of a
/// cyan state corresponds to the number of accepting arcs traversed to reach
/// it from the initial state. Weights are used to detect accepting cycle in
/// the blue dfs.
///
emptiness_check* explicit_se05_search(const tgba *a);
/// \brief Returns an emptiness checker on the spot::tgba automaton \a a.
/// During the visit of \a a, the returned checker does not store explicitely
/// the traversed states but uses the bit state hashing technic. However, the
/// Consequently, the detection of an acceptence cycle is not ensured. The
/// implemented algorithm is the same as the one of
/// spot::explicit_se05_search.
///
/// \pre The automaton \a a must have at most one accepting condition (i.e.
/// it is a TBA).
/// spot::explicit_magic_search.
///
/// \sa spot::explicit_se05_search
/// \sa spot::explicit_magic_search
///
emptiness_check* bit_state_hashing_se05_search(const tgba *a, size_t size);
emptiness_check* bit_state_hashing_magic_search(const tgba *a, size_t size);
/// @}
}
......
......@@ -24,11 +24,14 @@
#ifdef TRACE
#include <iostream>
#endif
#include "misc/hash.hh"
#include <cassert>
#include <list>
#include <iterator>
#include <cassert>
#include "magic.hh"
#include "misc/hash.hh"
#include "tgba/tgba.hh"
#include "emptiness.hh"
#include "se05.hh"
namespace spot
{
......@@ -133,10 +136,10 @@ namespace spot
const state* s;
/// Design the next successor of \a s which has to be visited.
tgba_succ_iterator* it;
/// The label of the transition followed to reach \a s
/// The label of the transition traversed to reach \a s
/// (false for the first one).
bdd label;
/// The acc set of the transition followed to reach \a s
/// The acceptance set of the transition traversed to reach \a s
/// (false for the first one).
bdd acc;
};
......@@ -181,7 +184,7 @@ namespace spot
stack_item& f = st_blue.front();
#ifdef TRACE
std::cout << "DFS_BLUE treats: "
<< a->format_state(f.s) << std::endl;
<< a->format_state(f.s) << std::endl;
#endif
if (!f.it->done())
{
......@@ -299,7 +302,7 @@ namespace spot
stack_item& f = st_red.front();
#ifdef TRACE
std::cout << "DFS_RED treats: "
<< a->format_state(f.s) << std::endl;
<< a->format_state(f.s) << std::endl;
#endif
if (!f.it->done())
{
......@@ -314,9 +317,6 @@ namespace spot
f.it->next();
typename heap::color_ref c = h.get_color_ref(s_prime);
if (c.is_white())
// Notice that this case is taken into account only to
// support successive calls to the check method. Without
// this functionnality => assert(c.is_white())
// Go down the edge (f.s, <label, acc>, s_prime)
{
#ifdef TRACE
......
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// 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 2 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef SPOT_TGBAALGOS_SE05_HH
# define SPOT_TGBAALGOS_SE05_HH
#include <cstddef>
namespace spot
{
class tgba;
class emptiness_check;
/// \addtogroup emptiness_check_algorithms
/// @{
/// \brief Returns an emptiness check on the spot::tgba automaton \a a.
///
/// \pre The automaton \a a must have at most one accepting condition (i.e.
/// it is a TBA).
///
/// During the visit of \a a, the returned checker stores explicitely all
/// the traversed states.
/// The method \a check() of the checker can be called several times
/// (until it returns a null pointer) to enumerate all the visited accepting
/// paths. The implemented algorithm is an optimization of
/// spot::explicit_magic_search and is the following:
///
/// \verbatim
/// procedure check ()
/// begin
/// weight = 0;
/// call dfs_blue(s0);
/// end;
///
/// procedure dfs_blue (s)
/// begin
/// s.color = cyan;
/// s.weight = weight;
/// for all t in post(s) do
/// if t.color == white then
/// if the edge (s,t) is accepting then
/// weight = weight + 1;
/// end if;
/// call dfs_blue(t);
/// if the edge (s,t) is accepting then
/// weight = weight - 1;
/// end if;
/// else if t.color == cyan and
/// (the edge (s,t) is accepting or
/// weight > t.weight) then
/// report cycle;
/// end if;
/// if the edge (s,t) is accepting then
/// call dfs_red(t);
/// end if;
/// end for;
/// s.color = blue;
/// end;
///
/// procedure dfs_red(s)
/// begin
/// if s.color == cyan then
/// report cycle;
/// end if;
/// s.color = red;
/// for all t in post(s) do
/// if t.color != red then
/// call dfs_red(t);
/// end if;
/// end for;
/// end;
/// \endverbatim
///
/// It is an adaptation to TBA (and a slight extension) of the one
/// presented in
/// \verbatim
/// @techreport{SE04,
/// author = {Stefan Schwoon and Javier Esparza},
/// institution = {Universit{\"a}t Stuttgart, Fakult\"at Informatik,
/// Elektrotechnik und Informationstechnik},
/// month = {November},
/// number = {2004/06},
/// title = {A Note on On-The-Fly Verification Algorithms},
/// year = {2004},
/// url =
///{http://www.fmi.uni-stuttgart.de/szs/publications/info/schwoosn.SE04.shtml}
/// }
/// \endverbatim
///
/// The extention consists in the introduction of a weight associated
/// to each state in the blue stack (the cyan states). The weight of a
/// cyan state corresponds to the number of accepting arcs traversed to reach
/// it from the initial state. Weights are used to detect accepting cycle in
/// the blue dfs.
///
/// \sa spot::explicit_magic_search
///
emptiness_check* explicit_se05_search(const tgba *a);
/// \brief Returns an emptiness checker on the spot::tgba automaton \a a.
///
/// \pre The automaton \a a must have at most one accepting condition (i.e.
/// it is a TBA).
///
/// During the visit of \a a, the returned checker does not store explicitely
/// the traversed states but uses the bit-state hashing technicpresented in:
///
/// \verbatim
/// @book{Holzmann91,
/// author = {G.J. Holzmann},
/// title = {Design and Validation of Computer Protocols},
/// publisher = {Prentice-Hall},
/// address = {Englewood Cliffs, New Jersey},
/// year = {1991}
/// }
/// \endverbatim
///
/// Consequently, the detection of an acceptence cycle is not ensured. The
/// implemented algorithm is the same as the one of
/// spot::explicit_se05_search.
///
/// \sa spot::explicit_se05_search
///
emptiness_check* bit_state_hashing_se05_search(const tgba *a, size_t size);
/// @}
}
#endif // SPOT_TGBAALGOS_MAGIC_HH
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// 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 2 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//#define TRACE
#ifdef TRACE
#include <iostream>
#include "tgba/bddprint.hh"
#endif
#include <cassert>
#include <list>
#include <iterator>
#include "misc/hash.hh"
#include "tgba/tgba.hh"
#include "emptiness.hh"
#include "magic.hh"
#include "tau03.hh"
namespace spot
{
namespace
{
enum color {WHITE, CYAN, BLUE};
/// \brief Emptiness checker on spot::tgba automata having at most one
/// accepting condition (i.e. a TBA).
template <typename heap>
class tau03_search : public emptiness_check
{
public:
/// \brief Initialize the search algorithm on the automaton \a a
tau03_search(const tgba *a, size_t size)
: h(size), a(a), all_cond(a->all_acceptance_conditions())
{
assert(a->number_of_acceptance_conditions() > 0);
}
virtual ~tau03_search()
{
// Release all iterators on the stacks.
while (!st_blue.empty())
{
h.pop_notify(st_blue.front().s);
delete st_blue.front().it;
st_blue.pop_front();
}
while (!st_red.empty())
{
h.pop_notify(st_red.front().s);
delete st_red.front().it;
st_red.pop_front();
}
}
/// \brief Perform a Magic Search.
///
/// \return non null pointer iff the algorithm has found an
/// accepting path.
virtual emptiness_check_result* check()
{
if (!st_red.empty())
{
assert(!st_blue.empty());
return 0;
}
assert(st_blue.empty());
nbn = nbt = 0;
sts = mdp = 0;
const state* s0 = a->get_init_state();
++nbn;
h.add_new_state(s0, CYAN);
push(st_blue, s0, bddfalse, bddfalse);
if (dfs_blue())
return new emptiness_check_result;
return 0;
}
virtual std::ostream& print_stats(std::ostream &os) const
{
os << nbn << " distinct nodes visited" << std::endl;
os << nbt << " transitions explored" << std::endl;
os << mdp << " nodes for the maximal stack depth" << std::endl;
return os;
}
private:
/// \brief counters for statistics (number of distinct nodes, of
/// transitions and maximal stacks size.
int nbn, nbt, mdp, sts;
struct stack_item
{
stack_item(const state* n, tgba_succ_iterator* i, bdd l, bdd a)
: s(n), it(i), label(l), acc(a) {};
/// The visited state.
const state* s;
/// Design the next successor of \a s which has to be visited.
tgba_succ_iterator* it;
/// The label of the transition traversed to reach \a s
/// (false for the first one).
bdd label;
/// The acceptance set of the transition traversed to reach \a s
/// (false for the first one).
bdd acc;
};
typedef std::list<stack_item> stack_type;
void push(stack_type& st, const state* s,
const bdd& label, const bdd& acc)
{
++sts;
if (sts>mdp)
mdp = sts;
tgba_succ_iterator* i = a->succ_iter(s);
i->first();
st.push_front(stack_item(s, i, label, acc));
}
/// \brief Stack of the blue dfs.
stack_type st_blue;
/// \brief Stack of the red dfs.
stack_type st_red;
/// \brief Map where each visited state is colored
/// by the last dfs visiting it.
heap h;
/// State targeted by the red dfs.
const state* target;
/// The automata to check.
const tgba* a;
/// The unique accepting condition of the automaton \a a.
bdd all_cond;
bool dfs_blue()
{
while (!st_blue.empty())
{
stack_item& f = st_blue.front();
#ifdef TRACE
std::cout << "DFS_BLUE treats: "
<< a->format_state(f.s) << std::endl;
#endif
if (!f.it->done())
{
++nbt;
const state *s_prime = f.it->current_state();
bdd label = f.it->current_condition();
bdd acc = f.it->current_acceptance_conditions();