From e3de75f67760a55dc0f0de6de5348ba94f3d91e4 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 2 Nov 2004 16:26:57 +0000 Subject: [PATCH] * src/tgbaalgos/projrun.hh, src/tgbaalgos/projrun.cc: New files. * src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS, libtgbaalgos_la_SOURCES): Add them. * iface/gspn/ltlgspn.cc (main): Call project_tgba_run if -P. --- ChangeLog | 5 ++++ iface/gspn/ltlgspn.cc | 25 ++++++++++++++++--- src/tgbaalgos/Makefile.am | 2 ++ src/tgbaalgos/projrun.cc | 51 +++++++++++++++++++++++++++++++++++++++ src/tgbaalgos/projrun.hh | 47 ++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 src/tgbaalgos/projrun.cc create mode 100644 src/tgbaalgos/projrun.hh diff --git a/ChangeLog b/ChangeLog index 02f25ae17..fce3c828b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-11-02 Alexandre Duret-Lutz + * src/tgbaalgos/projrun.hh, src/tgbaalgos/projrun.cc: New files. + * src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS, + libtgbaalgos_la_SOURCES): Add them. + * iface/gspn/ltlgspn.cc (main): Call project_tgba_run if -P. + * src/tgbaalgos/emptiness.cc, src/tgbaalgos/emptiness.hh (print_tgba_run): Take the tgba* argument before the tgba_run* argument (for consistency with diff --git a/iface/gspn/ltlgspn.cc b/iface/gspn/ltlgspn.cc index 06cc09fdf..ccd67ec24 100644 --- a/iface/gspn/ltlgspn.cc +++ b/iface/gspn/ltlgspn.cc @@ -37,6 +37,7 @@ #include "tgbaalgos/magic.hh" #include "tgbaalgos/gtec/gtec.hh" #include "tgbaalgos/gtec/ce.hh" +#include "tgbaalgos/projrun.hh" void @@ -266,8 +267,16 @@ main(int argc, char **argv) } #endif spot::tgba_run* run = ce->accepting_run(); - // FIXME: reimplement the projection - spot::print_tgba_run(std::cout, prod, run); + if (proj) + { + spot::tgba_run* p = project_tgba_run(prod, model, run); + spot::print_tgba_run(std::cout, model, p); + delete p; + } + else + { + spot::print_tgba_run(std::cout, prod, run); + } ce->print_stats(std::cout); delete run; delete ce; @@ -301,8 +310,16 @@ main(int argc, char **argv) if (compute_counter_example) { spot::tgba_run* run = res->accepting_run(); - // FIXME: reimplement the projection - spot::print_tgba_run(std::cout, prod, run); + if (proj) + { + spot::tgba_run* p = project_tgba_run(prod, model, run); + spot::print_tgba_run(std::cout, model, p); + delete p; + } + else + { + spot::print_tgba_run(std::cout, prod, run); + } delete run; } else diff --git a/src/tgbaalgos/Makefile.am b/src/tgbaalgos/Makefile.am index 0971e76e8..c82498942 100644 --- a/src/tgbaalgos/Makefile.am +++ b/src/tgbaalgos/Makefile.am @@ -36,6 +36,7 @@ tgbaalgos_HEADERS = \ magic.hh \ neverclaim.hh \ powerset.hh \ + projrun.hh \ reachiter.hh \ replayrun.hh \ save.hh \ @@ -53,6 +54,7 @@ libtgbaalgos_la_SOURCES = \ magic.cc \ neverclaim.cc \ powerset.cc \ + projrun.cc \ reachiter.cc \ replayrun.cc \ save.cc \ diff --git a/src/tgbaalgos/projrun.cc b/src/tgbaalgos/projrun.cc new file mode 100644 index 000000000..99cdae61f --- /dev/null +++ b/src/tgbaalgos/projrun.cc @@ -0,0 +1,51 @@ +// 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. + +#include "projrun.hh" +#include "tgba/tgba.hh" +#include "tgbaalgos/emptiness.hh" + +namespace spot +{ + + tgba_run* + project_tgba_run(const tgba* a_run, const tgba* a_proj, const tgba_run* run) + { + tgba_run* res = new tgba_run; + for (tgba_run::steps::const_iterator i = run->prefix.begin(); + i != run->prefix.end(); ++i) + { + tgba_run::step s = { a_run->project_state(i->s, a_proj), + i->label, + i->acc }; + res->prefix.push_back(s); + } + for (tgba_run::steps::const_iterator i = run->cycle.begin(); + i != run->cycle.end(); ++i) + { + tgba_run::step s = { a_run->project_state(i->s, a_proj), + i->label, + i->acc }; + res->cycle.push_back(s); + } + return res; + } +} diff --git a/src/tgbaalgos/projrun.hh b/src/tgbaalgos/projrun.hh new file mode 100644 index 000000000..1d9f37e0c --- /dev/null +++ b/src/tgbaalgos/projrun.hh @@ -0,0 +1,47 @@ +// 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_TGBAALGOS_PROJRUN_HH +# define SPOT_TGBAALGOS_PROJRUN_HH + +#include + +namespace spot +{ + struct tgba_run; + class tgba; + + /// \brief Project a tgba_run on a tgba. + /// + /// If a tgba_run has been generated on a product, or any other + /// on-the-fly algorithm with tgba operands, + /// + /// \param run the run to replay + /// \param a_run the automata on which the run was generated + /// \param a_proj the automata on which to project the run + /// \param os the stream on which the replay should be traced + /// \return true iff the run could be completed + tgba_run* project_tgba_run(const tgba* a_run, + const tgba* a_proj, + const tgba_run* run); +} + +#endif // SPOT_TGBAALGOS_PROJRUN_HH