Add an algorithm to complement Büchi automata.
* src/tgba/tgbacomplement.hh, src/tgba/tgbacomplement.cc: New files. The complementation algorithm. * src/tgba/Makefile.am: Adjust. * src/tgbatest/complementation.test, src/tgbatest/complementation.cc: New files. Test suite for the complementation algorithm. * src/tgbatest/Makefile.am: Adjust. * src/tgbaalgos/Makefile.am: Reformat the header using 80 columns.
This commit is contained in:
parent
e48338e8d8
commit
c5f8eafb01
8 changed files with 1586 additions and 3 deletions
14
ChangeLog
14
ChangeLog
|
|
@ -1,3 +1,17 @@
|
||||||
|
2009-06-05 Guillaume Sadegh <sadegh@lrde.epita.fr>
|
||||||
|
|
||||||
|
Add an algorithm to complement Büchi automata.
|
||||||
|
|
||||||
|
* src/tgba/tgbacomplement.hh, src/tgba/tgbacomplement.cc: New
|
||||||
|
files. The complementation algorithm.
|
||||||
|
* src/tgba/Makefile.am: Adjust.
|
||||||
|
* src/tgbatest/complementation.test,
|
||||||
|
src/tgbatest/complementation.cc: New files. Test suite for the
|
||||||
|
complementation algorithm.
|
||||||
|
* src/tgbatest/Makefile.am: Adjust.
|
||||||
|
* src/tgbaalgos/Makefile.am: Reformat the header using 80
|
||||||
|
columns.
|
||||||
|
|
||||||
2009-06-05 Damien Lefortier <dam@lrde.epita.fr>
|
2009-06-05 Damien Lefortier <dam@lrde.epita.fr>
|
||||||
|
|
||||||
Modify the ELTL parser to be able to support PSL operators. Add a
|
Modify the ELTL parser to be able to support PSL operators. Add a
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
## Copyright (C) 2003, 2004, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
## Copyright (C) 2003, 2004, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
## et Marie Curie.
|
## et Marie Curie.
|
||||||
##
|
##
|
||||||
|
|
@ -41,6 +41,7 @@ tgba_HEADERS = \
|
||||||
tgbabddcoredata.hh \
|
tgbabddcoredata.hh \
|
||||||
tgbabddfactory.hh \
|
tgbabddfactory.hh \
|
||||||
tgbascc.hh \
|
tgbascc.hh \
|
||||||
|
tgbacomplement.hh \
|
||||||
tgbaexplicit.hh \
|
tgbaexplicit.hh \
|
||||||
tgbaproduct.hh \
|
tgbaproduct.hh \
|
||||||
tgbatba.hh \
|
tgbatba.hh \
|
||||||
|
|
@ -60,6 +61,7 @@ libtgba_la_SOURCES = \
|
||||||
tgbabddconcreteproduct.cc \
|
tgbabddconcreteproduct.cc \
|
||||||
tgbabddcoredata.cc \
|
tgbabddcoredata.cc \
|
||||||
tgbascc.cc \
|
tgbascc.cc \
|
||||||
|
tgbacomplement.cc \
|
||||||
tgbaexplicit.cc \
|
tgbaexplicit.cc \
|
||||||
tgbaproduct.cc \
|
tgbaproduct.cc \
|
||||||
tgbatba.cc \
|
tgbatba.cc \
|
||||||
|
|
|
||||||
1247
src/tgba/tgbacomplement.cc
Normal file
1247
src/tgba/tgbacomplement.cc
Normal file
File diff suppressed because it is too large
Load diff
68
src/tgba/tgbacomplement.hh
Normal file
68
src/tgba/tgbacomplement.hh
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#ifndef SPOT_TGBA_TGBACOMPLEMENT_HH
|
||||||
|
# define SPOT_TGBA_TGBACOMPLEMENT_HH
|
||||||
|
|
||||||
|
# include "tgba/tgba.hh"
|
||||||
|
|
||||||
|
namespace spot
|
||||||
|
{
|
||||||
|
struct safra_tree_automaton;
|
||||||
|
|
||||||
|
/// \brief Build a complemented automaton.
|
||||||
|
/// \ingroup tgba
|
||||||
|
///
|
||||||
|
/// It creates an automaton that recognizes the
|
||||||
|
/// negated language of \a aut.
|
||||||
|
///
|
||||||
|
/// 1. First Safra construction algorithm produces a
|
||||||
|
/// deterministic Rabin automaton.
|
||||||
|
/// 2. Interpreting this deterministic Rabin automaton as a
|
||||||
|
/// deterministic Streett will produce a complemented automaton.
|
||||||
|
/// 3. Then we use a transformation from deterministic Streett
|
||||||
|
/// automaton to nondeterministic Büchi automaton.
|
||||||
|
///
|
||||||
|
/// Safra construction is done in \a tgba_complement, the transformation
|
||||||
|
/// is done on-the-fly when successors are called.
|
||||||
|
///
|
||||||
|
/// \sa safra_determinisation, tgba_complement::succ_iter.
|
||||||
|
class tgba_complement : public tgba
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
tgba_complement(const tgba* a);
|
||||||
|
virtual ~tgba_complement();
|
||||||
|
|
||||||
|
safra_tree_automaton* get_safra() const
|
||||||
|
{
|
||||||
|
return safra_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tgba interface.
|
||||||
|
virtual state* get_init_state() const;
|
||||||
|
virtual tgba_succ_iterator*
|
||||||
|
succ_iter(const state* local_state,
|
||||||
|
const state* global_state = 0,
|
||||||
|
const tgba* global_automaton = 0) const;
|
||||||
|
|
||||||
|
virtual bdd_dict* get_dict() const;
|
||||||
|
virtual std::string format_state(const state* state) const;
|
||||||
|
virtual bdd all_acceptance_conditions() const;
|
||||||
|
virtual bdd neg_acceptance_conditions() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bdd compute_support_conditions(const state* state) const;
|
||||||
|
virtual bdd compute_support_variables(const state* state) const;
|
||||||
|
private:
|
||||||
|
const tgba* automaton_;
|
||||||
|
safra_tree_automaton* safra_;
|
||||||
|
bdd the_acceptance_cond_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \brief Produce a dot output of the Safra automaton associated
|
||||||
|
/// to \a a.
|
||||||
|
///
|
||||||
|
/// @param a The \c tgba_complement with an intermediate Safra
|
||||||
|
/// automaton to display
|
||||||
|
///
|
||||||
|
void display_safra(const tgba_complement* a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SPOT_TGBA_TGBACOMPLEMENT_HH
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
## Copyright (C) 2003, 2004, 2005, 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
|
## Copyright (C) 2003, 2004, 2005, 2008, 2009 Laboratoire
|
||||||
|
## d'Informatique de Paris 6 (LIP6),
|
||||||
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
## et Marie Curie.
|
## et Marie Curie.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ check_SCRIPTS = defs
|
||||||
# Keep this sorted alphabetically.
|
# Keep this sorted alphabetically.
|
||||||
check_PROGRAMS = \
|
check_PROGRAMS = \
|
||||||
bddprod \
|
bddprod \
|
||||||
|
complement \
|
||||||
explicit \
|
explicit \
|
||||||
expldot \
|
expldot \
|
||||||
explprod \
|
explprod \
|
||||||
|
|
@ -46,6 +47,7 @@ check_PROGRAMS = \
|
||||||
# Keep this sorted alphabetically.
|
# Keep this sorted alphabetically.
|
||||||
bddprod_SOURCES = ltlprod.cc
|
bddprod_SOURCES = ltlprod.cc
|
||||||
bddprod_CXXFLAGS = -DBDD_CONCRETE_PRODUCT
|
bddprod_CXXFLAGS = -DBDD_CONCRETE_PRODUCT
|
||||||
|
complement_SOURCES = complementation.cc
|
||||||
eltl2tgba_SOURCES = eltl2tgba.cc
|
eltl2tgba_SOURCES = eltl2tgba.cc
|
||||||
explicit_SOURCES = explicit.cc
|
explicit_SOURCES = explicit.cc
|
||||||
expldot_SOURCES = powerset.cc
|
expldot_SOURCES = powerset.cc
|
||||||
|
|
@ -88,7 +90,8 @@ TESTS = \
|
||||||
emptchke.test \
|
emptchke.test \
|
||||||
dfs.test \
|
dfs.test \
|
||||||
emptchkr.test \
|
emptchkr.test \
|
||||||
spotlbtt.test
|
spotlbtt.test \
|
||||||
|
complementation.test
|
||||||
|
|
||||||
EXTRA_DIST = $(TESTS)
|
EXTRA_DIST = $(TESTS)
|
||||||
|
|
||||||
|
|
|
||||||
217
src/tgbatest/complementation.cc
Normal file
217
src/tgbatest/complementation.cc
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
#include "tgbaalgos/dotty.hh"
|
||||||
|
#include "tgbaparse/public.hh"
|
||||||
|
#include "tgba/tgbaproduct.hh"
|
||||||
|
#include "tgbaalgos/gtec/gtec.hh"
|
||||||
|
#include "tgbaalgos/ltl2tgba_fm.hh"
|
||||||
|
#include "ltlparse/public.hh"
|
||||||
|
#include "tgbaalgos/stats.hh"
|
||||||
|
#include "tgbaalgos/emptiness.hh"
|
||||||
|
#include "ltlast/unop.hh"
|
||||||
|
#include "tgbaalgos/stats.hh"
|
||||||
|
#include "tgbaalgos/emptiness_stats.hh"
|
||||||
|
#include "ltlvisit/destroy.hh"
|
||||||
|
#include "ltlvisit/clone.hh"
|
||||||
|
#include "tgba/tgbatba.hh"
|
||||||
|
|
||||||
|
#include "tgba/tgbacomplement.hh"
|
||||||
|
|
||||||
|
void usage(const char* prog)
|
||||||
|
{
|
||||||
|
std::cout << "usage: " << prog << " [options]" << std::endl;
|
||||||
|
std::cout << "with options" << std::endl
|
||||||
|
<< "-s buchi_automaton display the safra automaton"
|
||||||
|
<< std::endl
|
||||||
|
<< "-a buchi_automaton display the complemented automaton"
|
||||||
|
<< std::endl
|
||||||
|
<< "-astat buchi_automaton statistics for !a" << std::endl
|
||||||
|
<< "-fstat formula statistics for !A_f" << std::endl
|
||||||
|
<< "-f formula test !A_f and !A_!f" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
char *file = 0;
|
||||||
|
bool print_safra = false;
|
||||||
|
bool print_automaton = false;
|
||||||
|
bool check = false;
|
||||||
|
int return_value = 0;
|
||||||
|
bool stats = false;
|
||||||
|
bool formula = false;
|
||||||
|
bool automaton = false;
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if (argv[i][0] == '-')
|
||||||
|
{
|
||||||
|
if (strcmp(argv[i] + 1, "astat") == 0)
|
||||||
|
{
|
||||||
|
stats = true;
|
||||||
|
automaton = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[i] + 1, "fstat") == 0)
|
||||||
|
{
|
||||||
|
stats = true;
|
||||||
|
formula = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (argv[i][1])
|
||||||
|
{
|
||||||
|
case 's': print_safra = true; break;
|
||||||
|
case 'a': print_automaton = true; break;
|
||||||
|
case 'f': check = true; break;
|
||||||
|
default:
|
||||||
|
std::cerr << "unrecognized option `-" << argv[i][1]
|
||||||
|
<< "'" << std::endl;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
file = argv[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file == 0)
|
||||||
|
{
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
spot::bdd_dict* dict = new spot::bdd_dict();
|
||||||
|
if (print_automaton || print_safra)
|
||||||
|
{
|
||||||
|
spot::ltl::environment& env(spot::ltl::default_environment::instance());
|
||||||
|
spot::tgba_parse_error_list pel;
|
||||||
|
spot::tgba_explicit* a = spot::tgba_parse(file, pel, dict, env);
|
||||||
|
if (spot::format_tgba_parse_errors(std::cerr, file, pel))
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
spot::tgba_complement* complement = new spot::tgba_complement(a);
|
||||||
|
|
||||||
|
if (print_automaton)
|
||||||
|
spot::dotty_reachable(std::cout, complement);
|
||||||
|
|
||||||
|
if (print_safra)
|
||||||
|
spot::display_safra(complement);
|
||||||
|
delete complement;
|
||||||
|
delete a;
|
||||||
|
}
|
||||||
|
else if (stats)
|
||||||
|
{
|
||||||
|
spot::tgba* a;
|
||||||
|
spot::ltl::formula* f1 = 0;
|
||||||
|
|
||||||
|
if (formula)
|
||||||
|
{
|
||||||
|
spot::ltl::parse_error_list p1;
|
||||||
|
f1 = spot::ltl::parse(file, p1);
|
||||||
|
|
||||||
|
if (spot::ltl::format_parse_errors(std::cerr, file, p1))
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
a = spot::ltl_to_tgba_fm(f1, dict);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spot::tgba_parse_error_list pel;
|
||||||
|
spot::ltl::environment& env(spot::ltl::default_environment::instance());
|
||||||
|
a = spot::tgba_parse(file, pel, dict, env);
|
||||||
|
if (spot::format_tgba_parse_errors(std::cerr, file, pel))
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
spot::tgba_complement* complement = new spot::tgba_complement(a);
|
||||||
|
|
||||||
|
spot::tgba_statistics a_size = spot::stats_reachable(a);
|
||||||
|
std::cout << "Original: "
|
||||||
|
<< a_size.states << ", "
|
||||||
|
<< a_size.transitions << std::endl;
|
||||||
|
|
||||||
|
spot::tgba *buchi = new spot::tgba_sba_proxy(a);
|
||||||
|
a_size = spot::stats_reachable(buchi);
|
||||||
|
std::cout << "Buchi: "
|
||||||
|
<< a_size.states << ", "
|
||||||
|
<< a_size.transitions << std::endl;
|
||||||
|
delete buchi;
|
||||||
|
|
||||||
|
spot::tgba_statistics b_size = spot::stats_reachable(complement);
|
||||||
|
std::cout << "Complement: "
|
||||||
|
<< b_size.states << ", "
|
||||||
|
<< b_size.transitions << std::endl;
|
||||||
|
|
||||||
|
delete complement;
|
||||||
|
delete a;
|
||||||
|
if (formula)
|
||||||
|
{
|
||||||
|
spot::ltl::formula* nf1 =
|
||||||
|
spot::ltl::unop::instance(spot::ltl::unop::Not,
|
||||||
|
spot::ltl::clone(f1));
|
||||||
|
spot::tgba* a2 = spot::ltl_to_tgba_fm(nf1, dict);
|
||||||
|
spot::tgba_statistics a_size = spot::stats_reachable(a2);
|
||||||
|
std::cout << "Not Formula: "
|
||||||
|
<< a_size.states << ", "
|
||||||
|
<< a_size.transitions << std::endl;
|
||||||
|
|
||||||
|
delete a2;
|
||||||
|
spot::ltl::destroy(f1);
|
||||||
|
spot::ltl::destroy(nf1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spot::ltl::parse_error_list p1;
|
||||||
|
spot::ltl::formula* f1 = spot::ltl::parse(file, p1);
|
||||||
|
|
||||||
|
if (spot::ltl::format_parse_errors(std::cerr, file, p1))
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
spot::tgba* Af = spot::ltl_to_tgba_fm(f1, dict);
|
||||||
|
spot::ltl::formula* nf1 = spot::ltl::unop::instance(spot::ltl::unop::Not,
|
||||||
|
spot::ltl::clone(f1));
|
||||||
|
spot::tgba* Anf = spot::ltl_to_tgba_fm(nf1, dict);
|
||||||
|
spot::tgba_complement* nAf = new spot::tgba_complement(Af);
|
||||||
|
spot::tgba_complement* nAnf = new spot::tgba_complement(Anf);
|
||||||
|
spot::tgba* prod = new spot::tgba_product(nAf, nAnf);
|
||||||
|
spot::emptiness_check* ec = spot::couvreur99(prod);
|
||||||
|
spot::emptiness_check_result* res = ec->check();
|
||||||
|
spot::tgba_statistics a_size = spot::stats_reachable(ec->automaton());
|
||||||
|
std::cout << std::right << std::setw(10)
|
||||||
|
<< a_size.states << ", "
|
||||||
|
<< std::right << std::setw(10)
|
||||||
|
<< a_size.transitions << ", "
|
||||||
|
<< ec->automaton()->number_of_acceptance_conditions();
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
std::cout << ", FAIL";
|
||||||
|
return_value = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << ", OK";
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
delete res;
|
||||||
|
delete ec;
|
||||||
|
delete prod;
|
||||||
|
delete nAf;
|
||||||
|
delete Af;
|
||||||
|
delete nAnf;
|
||||||
|
delete Anf;
|
||||||
|
|
||||||
|
spot::ltl::destroy(nf1);
|
||||||
|
spot::ltl::destroy(f1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
delete dict;
|
||||||
|
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
31
src/tgbatest/complementation.test
Executable file
31
src/tgbatest/complementation.test
Executable file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
. ./defs
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
FORMULAE='GFa FGa <>p1->(p0Up1) [](p0-><>p3) GFa&&FGa'
|
||||||
|
|
||||||
|
for f in $FORMULAE; do
|
||||||
|
run 0 ./complement -f "$f"
|
||||||
|
done
|
||||||
Loading…
Add table
Add a link
Reference in a new issue