Commit 7cb6ff33 authored by Guillaume Sadegh's avatar Guillaume Sadegh
Browse files

Add a new type of automata: State-labeled Alternating Büchi

Automata (SABA).

* src/saba/saba.hh, src/saba/saba.cc, src/saba/sabastate.hh,
src/saba/sabasucciter.hh: New.  Interface for
SABA (State-labeled Alternating Büchi Automata).
* src/saba/explicitstateconjunction.cc,
src/saba/explicitstateconjunction.hh: New.  Default
implementation for a conjunction of states.
* src/saba/Makefile.am: New.
* src/Makefile.am, configure.ac: Adjust.
* src/sabaalgos/sabareachiter.cc,
src/sabaalgos/sabareachiter.hh: New.  Iterate over all reachable
states of a spot::saba.
* src/sabaalgos/sabadotty.cc, src/sabaalgos/sabadotty.hh: New.
Print reachable states in dot format.
* src/sabaalgos/Makefile.am: New.
parent f00aa49d
2009-11-30 Guillaume Sadegh <sadegh@lrde.epita.fr>
Add a new type of automata: State-labeled Alternating Bchi
Automata (SABA).
* src/saba/saba.hh, src/saba/saba.cc, src/saba/sabastate.hh,
src/saba/sabasucciter.hh: New. Interface for
SABA (State-labeled Alternating Bchi Automata).
* src/saba/explicitstateconjunction.cc,
src/saba/explicitstateconjunction.hh: New. Default
implementation for a conjunction of states.
* src/saba/Makefile.am: New.
* src/Makefile.am, configure.ac: Adjust.
* src/sabaalgos/sabareachiter.cc,
src/sabaalgos/sabareachiter.hh: New. Iterate over all reachable
states of a spot::saba.
* src/sabaalgos/sabadotty.cc, src/sabaalgos/sabadotty.hh: New.
Print reachable states in dot format.
* src/sabaalgos/Makefile.am: New.
2009-11-27 Guillaume Sadegh <sadegh@lrde.epita.fr>
Rename the class taa as taa_tgba.
......
......@@ -108,6 +108,10 @@ AC_CONFIG_FILES([
src/Makefile
src/misc/Makefile
src/sanity/Makefile
src/saba/Makefile
src/sabaalgos/Makefile
src/sabatest/defs
src/sabatest/Makefile
src/tgbaalgos/gtec/Makefile
src/tgbaalgos/Makefile
src/tgba/Makefile
......
......@@ -23,11 +23,10 @@ AUTOMAKE_OPTIONS = subdir-objects
# List directories in the order they must be built.
# Keep tests at the end.
SUBDIRS = misc ltlenv ltlast ltlvisit ltlparse eltlparse \
tgba tgbaalgos tgbaparse \
evtgba evtgbaalgos evtgbaparse \
kripke . \
ltltest eltltest tgbatest evtgbatest sanity
SUBDIRS = misc ltlenv ltlast ltlvisit ltlparse eltlparse tgba \
tgbaalgos tgbaparse evtgba evtgbaalgos evtgbaparse kripke \
saba sabaalgos ltltest eltltest tgbatest evtgbatest sabatest \
sanity
lib_LTLIBRARIES = libspot.la
libspot_la_SOURCES =
......@@ -45,6 +44,8 @@ libspot_la_LIBADD = \
evtgba/libevtgba.la \
evtgbaalgos/libevtgbaalgos.la \
evtgbaparse/libevtgbaparse.la \
saba/libsaba.la \
sabaalgos/libsabaalgos.la \
kripke/libkripke.la
# Dummy C++ source to cause C++ linking.
......
## Copyright (C) 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
## dpartement Systmes Rpartis Coopratifs (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.
AM_CPPFLAGS = -I$(srcdir)/.. $(BUDDY_CPPFLAGS)
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
sabadir = $(pkgincludedir)/saba
saba_HEADERS = \
explicitstateconjunction.hh \
saba.hh \
sabastate.hh \
sabasucciter.hh \
sabacomplementtgba.hh
noinst_LTLIBRARIES = libsaba.la
libsaba_la_SOURCES = \
explicitstateconjunction.cc \
saba.cc \
sabacomplementtgba.cc
// Copyright (C) 2009 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.
#include "explicitstateconjunction.hh"
namespace spot
{
/// explicit_state_conjunction
////////////////////////////////////////
explicit_state_conjunction::explicit_state_conjunction()
{
}
explicit_state_conjunction::
explicit_state_conjunction(const explicit_state_conjunction* other)
: set_(other->set_)
{
}
explicit_state_conjunction*
explicit_state_conjunction::operator=(const explicit_state_conjunction& o)
{
if (this != &o)
{
this->~explicit_state_conjunction();
new (this) explicit_state_conjunction(&o);
}
return this;
}
explicit_state_conjunction::~explicit_state_conjunction()
{
}
void
explicit_state_conjunction::first()
{
it_ = set_.begin();
}
void
explicit_state_conjunction::next()
{
++it_;
}
bool
explicit_state_conjunction::done() const
{
return it_ == set_.end();
}
explicit_state_conjunction*
explicit_state_conjunction::clone() const
{
return new explicit_state_conjunction(this);
}
saba_state*
explicit_state_conjunction::current_state() const
{
return (*it_)->clone();
}
void
explicit_state_conjunction::add(saba_state* state)
{
set_.insert(shared_saba_state(state));
}
} // end namespace spot.
// Copyright (C) 2009 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_SABA_EXPLICITSTATECONJUNCTION_HH
# define SPOT_SABA_EXPLICITSTATECONJUNCTION_HH
#include <misc/hash.hh>
#include "sabasucciter.hh"
namespace spot
{
/// \brief Basic implementation of saba_state_conjunction.
/// \ingroup saba_essentials
///
/// This class provides a basic implementation to
/// iterate over a conjunction of states of a saba.
class explicit_state_conjunction : public saba_state_conjunction
{
public:
explicit_state_conjunction();
explicit_state_conjunction(const explicit_state_conjunction* other);
virtual ~explicit_state_conjunction();
explicit_state_conjunction* operator=(const explicit_state_conjunction& o);
/// \name Iteration
//@{
virtual void first();
virtual void next();
virtual bool done() const;
//@}
/// \name Inspection
//@{
/// Duplicate a this conjunction.
explicit_state_conjunction* clone() const;
/// Return the a new instance on the current state.
/// This is the caller responsibility to delete the returned state.
virtual saba_state* current_state() const;
//@}
/// Add a new state in the conjunction.
/// The class becomes owner of \a state.
void add(saba_state* state);
private:
typedef Sgi::hash_set<shared_saba_state,
spot::saba_state_shared_ptr_hash,
spot::saba_state_shared_ptr_equal> saba_state_set_t;
saba_state_set_t set_;
saba_state_set_t::iterator it_;
};
} // end namespace spot.
#endif // SPOT_SABA_EXPLICITSTATECONJUNCTION_HH
// Copyright (C) 2009 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.
#include "saba.hh"
namespace spot
{
saba::saba()
: num_acc_(-1)
{
}
saba::~saba()
{
}
unsigned int
saba::number_of_acceptance_conditions() const
{
if (num_acc_ < 0)
{
bdd all = all_acceptance_conditions();
unsigned int n = 0;
while (all != bddfalse)
{
++n;
all -= bdd_satone(all);
}
num_acc_ = n;
}
return num_acc_;
}
} // end namespace spot.
// Copyright (C) 2009 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_SABA_SABA_HH
# define SPOT_SABA_SABA_HH
#include "sabastate.hh"
#include "sabasucciter.hh"
#include <tgba/bdddict.hh>
namespace spot
{
/// \defgroup saba SABA (State-based Alternating Büchi Automata)
///
/// Spot was centered around non-deterministic \ref tgba.
/// Alternating automata are an extension to non-deterministic
/// automata, and are presented with spot::saba.
/// This type and its cousins are listed \ref saba_essentials "here".
/// This is an abstract interface.
/// \addtogroup saba_essentials Essential SABA types
/// \ingroup saba
/// \brief A State-based Alternating (Generalized) Büchi Automaton.
/// \ingroup saba_essentials
///
/// Browsing such automaton can be achieved using two functions:
/// \c get_init_state, and \c succ_iter. The former returns
/// the initial state while the latter lists the
/// successor states of any state.
///
/// Note that although this is a transition-based automata,
/// we never represent transitions! Transition informations are
/// obtained by querying the iterator over the successors of
/// a state.
class saba
{
protected:
saba();
public:
virtual ~saba();
/// \brief Get the initial state of the automaton.
///
/// The state has been allocated with \c new. It is the
/// responsability of the caller to \c delete it when no
/// longer needed.
virtual saba_state* get_init_state() const = 0;
/// \brief Get an iterator over the successors of \a local_state.
///
/// The iterator has been allocated with \c new. It is the
/// responsability of the caller to \c delete it when no
/// longer needed.
///
/// \param local_state The state whose successors are to be explored.
/// This pointer is not adopted in any way by \c succ_iter, and
/// it is still the caller's responsability to delete it when
/// appropriate (this can be done during the lifetime of
/// the iterator).
virtual saba_succ_iterator*
succ_iter(const saba_state* local_state) const = 0;
/// \brief Get the dictionary associated to the automaton.
///
/// State are represented as BDDs. The dictionary allows
/// to map BDD variables back to formulae, and vice versa.
/// This is useful when dealing with several automata (which
/// may use the same BDD variable for different formula),
/// or simply when printing.
virtual bdd_dict* get_dict() const = 0;
/// \brief Format the state as a string for printing.
///
/// This formating is the responsability of the automata
/// that owns the state.
virtual std::string format_state(const saba_state* state) const = 0;
/// \brief Return the set of all acceptance conditions used
/// by this automaton.
///
/// The goal of the emptiness check is to ensure that
/// a strongly connected component walks through each
/// of these acceptiong conditions. I.e., the union
/// of the acceptiong conditions of all transition in
/// the SCC should be equal to the result of this function.
virtual bdd all_acceptance_conditions() const = 0;
/// The number of acceptance conditions.
virtual unsigned int number_of_acceptance_conditions() const;
private:
mutable int num_acc_;
};
} // end namespace spot.
#endif // SPOT_SABA_SABA_HH
// Copyright (C) 2009 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_SABA_SABASTATE_HH
# define SPOT_SABA_SABASTATE_HH
#include <bdd.h>
#include <functional>
#include <boost/shared_ptr.hpp>
namespace spot
{
/// \brief Abstract class for saba states.
/// \ingroup saba_essentials
class saba_state
{
public:
/// \brief Compares two states (that come from the same automaton).
///
/// This method returns an integer less than, equal to, or greater
/// than zero if \a this is found, respectively, to be less than, equal
/// to, or greater than \a other according to some implicit total order.
///
/// This method should not be called to compare states from
/// different automata.
///
/// \sa spot::saba_state_ptr_less_than
virtual int compare(const saba_state* other) const = 0;
/// \brief Hash a state.
///
/// This method returns an integer that can be used as a
/// hash value for this state.
///
/// Note that the hash value is guaranteed to be unique for all
/// equal states (in compare()'s sense) for only has long has one
/// of these states exists. So it's OK to use a spot::saba_state as a
/// key in a \c hash_map because the mere use of the state as a
/// key in the hash will ensure the state continues to exist.
///
/// However if you create the state, get its hash key, delete the
/// state, recreate the same state, and get its hash key, you may
/// obtain two different hash keys if the same state were not
/// already used elsewhere. In practice this weird situation can
/// occur only when the state is BDD-encoded, because BDD numbers
/// (used to build the hash value) can be reused for other
/// formulas. That probably doesn't matter, since the hash value
/// is meant to be used in a \c hash_map, but it had to be noted.
virtual size_t hash() const = 0;
/// Duplicate a state.
virtual saba_state* clone() const = 0;
/// \brief Get the acceptance condition.
///
/// saba are state-labeled automata, then their acceptance conditions
/// are labeled on states.
virtual bdd acceptance_conditions() const = 0;
virtual ~saba_state()
{
}
};
/// \brief Strict Weak Ordering for \c saba_state*.
/// \ingroup saba_essentials
///
/// This is meant to be used as a comparison functor for
/// STL \c map whose key are of type \c saba_state*.
///
/// For instance here is how one could declare
/// a map of \c saba_state*.
/// \code
/// // Remember how many times each state has been visited.
/// std::map<spot::saba_state*, int, spot::saba_state_ptr_less_than> seen;
/// \endcode
struct saba_state_ptr_less_than:
public std::binary_function<const saba_state*, const saba_state*, bool>
{
bool
operator()(const saba_state* left, const saba_state* right) const
{
assert(left);
return left->compare(right) < 0;
}
};
/// \brief An Equivalence Relation for \c saba_state*.
/// \ingroup saba_essentials
///
/// This is meant to be used as a comparison functor for
/// Sgi \c hash_map whose key are of type \c saba_state*.
///
/// For instance here is how one could declare
/// a map of \c saba_state*.
/// \code
/// // Remember how many times each state has been visited.
/// Sgi::hash_map<spot::saba_state*, int, spot::saba_state_ptr_hash,
/// spot::saba_state_ptr_equal> seen;
/// \endcode
struct saba_state_ptr_equal:
public std::binary_function<const saba_state*, const saba_state*, bool>
{
bool
operator()(const saba_state* left, const saba_state* right) const
{
assert(left);
return 0 == left->compare(right);
}
};
/// \brief Hash Function for \c saba_state*.
/// \ingroup saba_essentials
/// \ingroup hash_funcs
///
/// This is meant to be used as a hash functor for
/// Sgi's \c hash_map whose key are of type \c saba_state*.
///
/// For instance here is how one could declare
/// a map of \c saba_state*.
/// \code
/// // Remember how many times each state has been visited.
/// Sgi::hash_map<spot::saba_state*, int, spot::saba_state_ptr_hash,
/// spot::saba_state_ptr_equal> seen;
/// \endcode
struct saba_state_ptr_hash:
public std::unary_function<const saba_state*, size_t>
{
size_t
operator()(const saba_state* that) const
{
assert(that);
return that->hash();
}
};
// Functions related to shared_ptr.
//////////////////////////////////////////////////
typedef boost::shared_ptr<const saba_state> shared_saba_state;
/// \brief Strict Weak Ordering for \c shared_saba_state
/// (shared_ptr<const saba_state*>).
/// \ingroup saba_essentials
///
/// This is meant to be used as a comparison functor for
/// STL \c map whose key are of type \c shared_saba_state.
///
/// For instance here is how one could declare
/// a map of \c shared_saba_state.
/// \code
/// // Remember how many times each state has been visited.
/// std::map<shared_saba_state, int, spot::saba_state_shared_ptr_less_than>
/// seen;
/// \endcode
struct saba_state_shared_ptr_less_than:
public std::binary_function<shared_saba_state,
shared_saba_state, bool>
{
bool
operator()(shared_saba_state left,
shared_saba_state right) const
{
assert(left);
return left->compare(right.get()) < 0;
}
};
/// \brief An Equivalence Relation for \c shared_saba_state
/// (shared_ptr<const saba_state*>).
/// \ingroup saba_essentials