Commit 73ff928b authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Preliminary support for Event-based GBA.

* src/evtgba/Makefile.am, src/evtgba/evtgba.cc,
src/evtgba/evtgba.hh, src/evtgba/evtgbaiter.hh,
src/evtgba/explicit.cc, src/evtgba/explicit.hh,
src/evtgba/product.cc, src/evtgba/product.hh,
src/evtgba/symbol.cc, src/evtgba/symbol.hh,
src/evtgbaalgos/Makefile.am, src/evtgbaalgos/dotty.cc,
src/evtgbaalgos/dotty.hh, src/evtgbaalgos/reachiter.cc,
src/evtgbaalgos/reachiter.hh, src/evtgbaalgos/save.cc,
src/evtgbaalgos/save.hh, src/evtgbaparse/Makefile.am,
src/evtgbaparse/evtgbaparse.yy, src/evtgbaparse/evtgbascan.ll,
src/evtgbaparse/fmterror.cc, src/evtgbaparse/parsedecl.hh,
src/evtgbaparse/public.hh, src/evtgbatest/Makefile.am,
src/evtgbatest/defs.in, src/evtgbatest/explicit.cc,
src/evtgbatest/explicit.test, src/evtgbatest/product.cc,
src/evtgbatest/product.test, src/evtgbatest/readsave.cc,
src/evtgbatest/readsave.test: New files.
* configure.ac: Create the Makefiles in these new subdirectories.
* src/Makefile.am: Recurse them.
parent d9b29a05
2004-10-22 Alexandre Duret-Lutz <adl@src.lip6.fr>
Preliminary support for Event-based GBA.
* src/evtgba/Makefile.am, src/evtgba/evtgba.cc,
src/evtgba/evtgba.hh, src/evtgba/evtgbaiter.hh,
src/evtgba/explicit.cc, src/evtgba/explicit.hh,
src/evtgba/product.cc, src/evtgba/product.hh,
src/evtgba/symbol.cc, src/evtgba/symbol.hh,
src/evtgbaalgos/Makefile.am, src/evtgbaalgos/dotty.cc,
src/evtgbaalgos/dotty.hh, src/evtgbaalgos/reachiter.cc,
src/evtgbaalgos/reachiter.hh, src/evtgbaalgos/save.cc,
src/evtgbaalgos/save.hh, src/evtgbaparse/Makefile.am,
src/evtgbaparse/evtgbaparse.yy, src/evtgbaparse/evtgbascan.ll,
src/evtgbaparse/fmterror.cc, src/evtgbaparse/parsedecl.hh,
src/evtgbaparse/public.hh, src/evtgbatest/Makefile.am,
src/evtgbatest/defs.in, src/evtgbatest/explicit.cc,
src/evtgbatest/explicit.test, src/evtgbatest/product.cc,
src/evtgbatest/product.test, src/evtgbatest/readsave.cc,
src/evtgbatest/readsave.test: New files.
* configure.ac: Create the Makefiles in these new subdirectories.
* src/Makefile.am: Recurse them.
* src/misc/bareword.hh, src/misc/bareword.cc (quote_unless_bare_word):
New function.
......
......@@ -64,6 +64,11 @@ AC_CONFIG_FILES([
iface/gspn/Makefile
iface/gspn/defs
src/Makefile
src/evtgba/Makefile
src/evtgbaalgos/Makefile
src/evtgbaparse/Makefile
src/evtgbatest/Makefile
src/evtgbatest/defs
src/ltlast/Makefile
src/ltlenv/Makefile
src/ltlparse/Makefile
......
......@@ -23,8 +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 tgba tgbaalgos tgbaparse . \
ltltest tgbatest sanity
SUBDIRS = misc ltlenv ltlast ltlvisit ltlparse \
tgba tgbaalgos tgbaparse \
evtgba evtgbaalgos evtgbaparse . \
ltltest tgbatest evtgbatest sanity
lib_LTLIBRARIES = libspot.la
libspot_la_SOURCES =
......@@ -37,6 +39,10 @@ libspot_la_LIBADD = \
ltlast/libltlast.la \
tgba/libtgba.la \
tgbaalgos/libtgbaalgos.la \
tgbaparse/libtgbaparse.la
tgbaparse/libtgbaparse.la \
evtgba/libevtgba.la \
evtgbaalgos/libevtgbaalgos.la \
evtgbaparse/libevtgbaparse.la
# Dummy C++ source to cause C++ linking.
nodist_EXTRA_libspot_la_SOURCES = _.cc
.deps
.libs
*.lo
*.la
Makefile
Makefile.in
## Copyright (C) 2004 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)
evtgbadir = $(pkgincludedir)/evtgba
evtgba_HEADERS = \
evtgba.hh \
evtgbaiter.hh \
explicit.hh \
product.hh \
symbol.hh
noinst_LTLIBRARIES = libevtgba.la
libevtgba_la_SOURCES = \
evtgba.cc \
explicit.cc \
product.cc \
symbol.cc
// Copyright (C) 2004 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.
#include <sstream>
#include "evtgba.hh"
#include "misc/escape.hh"
#include "misc/bareword.hh"
namespace spot
{
evtgba::evtgba()
{
}
evtgba::~evtgba()
{
}
std::string
evtgba::format_label(const symbol* symbol) const
{
return symbol->name();
}
std::string
evtgba::format_acceptance_condition(const symbol* symbol) const
{
return symbol->name();
}
std::string
evtgba::format_acceptance_conditions(const symbol_set& symset) const
{
std::ostringstream o;
symbol_set::const_iterator i = symset.begin();
if (i != symset.end())
{
o << '{';
for (;;)
{
o << quote_unless_bare_word(format_acceptance_condition(*i));
if (++i == symset.end())
break;
o << ", ";
}
o << '}';
}
return o.str();
}
}
// Copyright (C) 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_EVTGBA_EVTGBA_HH
# define SPOT_EVTGBA_EVTGBA_HH
#include "tgba/state.hh"
#include "evtgbaiter.hh"
namespace spot
{
// FIXME: doc me
class evtgba
{
protected:
evtgba();
public:
virtual ~evtgba();
virtual evtgba_iterator* init_iter() const = 0;
virtual evtgba_iterator* succ_iter(const state* s) const = 0;
virtual evtgba_iterator* pred_iter(const state* s) const = 0;
/// \brief Format the state as a string for printing.
///
/// This formating is the responsability of the automata
/// who owns the state.
virtual std::string format_state(const state* state) const = 0;
virtual std::string format_label(const symbol* symbol) const;
virtual std::string format_acceptance_condition(const symbol* symbol) const;
virtual std::string
format_acceptance_conditions(const symbol_set& symset) const;
/// \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 const symbol_set& all_acceptance_conditions() const = 0;
virtual const symbol_set& alphabet() const = 0;
};
}
#endif // SPOT_EVTGBA_EVTGBA_HH
// Copyright (C) 2004 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.
#ifndef SPOT_EVTGBA_ITER_HH
# define SPOT_EVTGBA_ITER_HH
#include "tgba/state.hh"
#include "symbol.hh"
#include "evtgbaiter.hh"
namespace spot
{
// FIXME: doc me
class evtgba_iterator
{
public:
virtual
~evtgba_iterator()
{
}
virtual void first() = 0;
virtual void next() = 0;
virtual bool done() const = 0;
virtual const state* current_state() const = 0;
virtual const symbol* current_label() const = 0;
virtual symbol_set current_acceptance_conditions() const = 0;
};
}
#endif // SPOT_EVTGBA_ITER_HH
// Copyright (C) 2004 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.
#include "explicit.hh"
#include "misc/bareword.hh"
#include "misc/escape.hh"
namespace spot
{
const evtgba_explicit::state*
state_evtgba_explicit::get_state() const
{
return state_;
}
int
state_evtgba_explicit::compare(const spot::state* other) const
{
const state_evtgba_explicit* o =
dynamic_cast<const state_evtgba_explicit*>(other);
assert(o);
return o->get_state() - get_state();
}
size_t
state_evtgba_explicit::hash() const
{
return
reinterpret_cast<const char*>(get_state()) - static_cast<const char*>(0);
}
state_evtgba_explicit*
state_evtgba_explicit::clone() const
{
return new state_evtgba_explicit(*this);
}
namespace
{
class evtgba_explicit_iterator: public evtgba_iterator
{
public:
evtgba_explicit_iterator(const evtgba_explicit::transition_list* s)
: s_(s), i_(s_->end())
{
}
virtual
~evtgba_explicit_iterator()
{
}
virtual void first()
{
i_ = s_->begin();
}
virtual void
next()
{
++i_;
}
virtual bool
done() const
{
return i_ == s_->end();
}
virtual const symbol*
current_label() const
{
return (*i_)->label;
}
virtual symbol_set
current_acceptance_conditions() const
{
return (*i_)->acceptance_conditions;
}
protected:
const evtgba_explicit::transition_list* s_;
evtgba_explicit::transition_list::const_iterator i_;
};
class evtgba_explicit_iterator_fw: public evtgba_explicit_iterator
{
public:
evtgba_explicit_iterator_fw(const evtgba_explicit::transition_list* s)
: evtgba_explicit_iterator(s)
{
}
virtual
~evtgba_explicit_iterator_fw()
{
}
const state*
current_state() const
{
return new state_evtgba_explicit((*i_)->out);
}
};
class evtgba_explicit_iterator_bw: public evtgba_explicit_iterator
{
public:
evtgba_explicit_iterator_bw(const evtgba_explicit::transition_list* s)
: evtgba_explicit_iterator(s)
{
}
virtual
~evtgba_explicit_iterator_bw()
{
}
const state*
current_state() const
{
return new state_evtgba_explicit((*i_)->in);
}
};
}
evtgba_explicit::evtgba_explicit()
{
}
evtgba_explicit::~evtgba_explicit()
{
for (transition_list::const_iterator i = init_states_.begin();
i != init_states_.end(); ++i)
delete *i;
for (ns_map::const_iterator j = name_state_map_.begin();
j != name_state_map_.end(); ++j)
{
for (transition_list::const_iterator i = j->second->out.begin();
i != j->second->out.end(); ++i)
delete *i;
delete j->second;
}
for (symbol_set::const_iterator i = alphabet_.begin();
i != alphabet_.end(); ++i)
(*i)->unref();
for (symbol_set::const_iterator i = acc_set_.begin();
i != acc_set_.end(); ++i)
(*i)->unref();
}
evtgba_iterator*
evtgba_explicit::init_iter() const
{
return new evtgba_explicit_iterator_fw(&init_states_);
}
evtgba_iterator*
evtgba_explicit::succ_iter(const spot::state* s) const
{
const state_evtgba_explicit* u =
dynamic_cast<const state_evtgba_explicit*>(s);
assert(u);
return new evtgba_explicit_iterator_fw(&u->get_state()->out);
}
evtgba_iterator*
evtgba_explicit::pred_iter(const spot::state* s) const
{
const state_evtgba_explicit* u =
dynamic_cast<const state_evtgba_explicit*>(s);
assert(u);
return new evtgba_explicit_iterator_fw(&u->get_state()->in);
}
std::string
evtgba_explicit::format_state(const spot::state* s) const
{
const state_evtgba_explicit* u =
dynamic_cast<const state_evtgba_explicit*>(s);
assert(u);
sn_map::const_iterator i = state_name_map_.find(u->get_state());
assert(i != state_name_map_.end());
return i->second;
}
const symbol_set&
evtgba_explicit::all_acceptance_conditions() const
{
return acc_set_;
}
const symbol_set&
evtgba_explicit::alphabet() const
{
return alphabet_;
}
evtgba_explicit::state*
evtgba_explicit::declare_state(const std::string& name)
{
ns_map::const_iterator i = name_state_map_.find(name);
if (i != name_state_map_.end())
return i->second;
state* s = new state;
name_state_map_[name] = s;
state_name_map_[s] = name;
return s;
}
evtgba_explicit::transition*
evtgba_explicit::add_transition(const std::string& source,
const rsymbol& label,
rsymbol_set acc,
const std::string& dest)
{
state* in = declare_state(source);
state* out = declare_state(dest);
transition* t = new transition;
t->in = in;
t->label = label;
t->out = out;
in->out.push_back(t);
out->in.push_back(t);
for (rsymbol_set::const_iterator i = acc.begin(); i != acc.end(); ++i)
{
const symbol* s = *i;
t->acceptance_conditions.insert(s);
declare_acceptance_condition(*i);
}
if (alphabet_.find(t->label) == alphabet_.end())
{
alphabet_.insert(t->label);
t->label->ref();
}
return t;
}
void
evtgba_explicit::declare_acceptance_condition(const rsymbol& acc)
{
const symbol* s = acc;
if (acc_set_.find(s) == acc_set_.end())
{
acc_set_.insert(s);
s->ref();
}
}
void
evtgba_explicit::set_init_state(const std::string& name)
{
transition* t = new transition;
t->in = 0;
t->out = declare_state(name);
t->label = 0;
init_states_.push_back(t);
}
}
// Copyright (C) 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_EVTGBA_EXPLICIT_HH
# define SPOT_EVTGBA_EXPLICIT_HH
#include "evtgba.hh"
#include <list>
#include "misc/hash.hh"
namespace spot
{
// FIXME: doc me
class evtgba_explicit: public evtgba
{
public:
struct transition;
typedef std::list<transition*> transition_list;
struct state
{
transition_list in, out;
};
/// E