Commit d6e22c06 authored by Guillaume Sadegh's avatar Guillaume Sadegh

A new complementation construction based on ranking.

* src/tgba/tgbacomplement.cc, src/tgba/tgbacomplement.hh: The
construction.
* src/tgbatest/Makefile.am: Adjust.
* src/tgbatest/complementation.cc: Add options to support this
construction in addition to Safra construction.
* src/tgba/Makefile.am: Adjust.
* src/tgbatest/complementation.test: Adjust to test also this
complementation.
parent d037008c
2009-09-29 Guillaume Sadegh <sadegh@lrde.epita.fr>
A new complementation construction based on ranking.
* src/tgba/tgbacomplement.cc, src/tgba/tgbacomplement.hh: The
construction.
* src/tgbatest/Makefile.am: Adjust.
* src/tgbatest/complementation.cc: Add options to support this
construction in addition to Safra construction.
* src/tgba/Makefile.am: Adjust.
* src/tgbatest/complementation.test: Adjust to test also this
complementation.
2009-09-29 Guillaume Sadegh <sadegh@lrde.epita.fr>
* src/ltltest/randltl.cc, src/ltltest/reduc.test,
......
......@@ -40,6 +40,7 @@ tgba_HEADERS = \
tgbabddconcreteproduct.hh \
tgbabddcoredata.hh \
tgbabddfactory.hh \
tgbacomplement.hh \
tgbaexplicit.hh \
tgbafromfile.hh \
tgbascc.hh \
......@@ -63,8 +64,9 @@ libtgba_la_SOURCES = \
tgbabddconcretefactory.cc \
tgbabddconcreteproduct.cc \
tgbabddcoredata.cc \
tgbafromfile.cc \
tgbacomplement.cc \
tgbaexplicit.cc \
tgbafromfile.cc \
tgbaproduct.cc \
tgbareduc.cc \
tgbasafracomplement.cc \
......
This diff is collapsed.
#ifndef SPOT_TGBA_TGBACOMPLEMENT_HH
#define SPOT_TGBA_TGBACOMPLEMENT_HH
#include <vector>
#include "bdd.h"
#include "tgba.hh"
#include "tgba/tgbasgba.hh"
namespace spot
{
class bdd_ordered
{
public:
bdd_ordered()
: order_(0)
{};
bdd_ordered(int bdd_, unsigned order_)
: bdd_(bdd_), order_(order_)
{
}
unsigned order() const
{
return order_;
}
unsigned& order()
{
return order_;
}
bdd get_bdd() const
{
return bdd_ithvar(bdd_);
}
private:
int bdd_;
unsigned order_;
};
typedef std::vector<bdd_ordered> acc_list_t;
/// \brief Build a complemented automaton.
/// \ingroup tgba
///
/// The construction comes from:
/// @Article{ kupferman.05.tcs,
/// title = {{From complementation to certification}},
/// author = {Kupferman, O. and Vardi, M.Y.},
/// journal = {Theoretical Computer Science},
/// volume = {345},
/// number = {1},
/// pages = {83--100},
/// year = {2005},
/// publisher = {Elsevier}
/// }
///
/// The original automaton is used as a States-based Generalized
/// Büchi Automaton.
///
/// The construction is done on-the-fly, by the
/// \c tgba_complement_succ_iterator class.
/// \see tgba_complement_succ_iteratora
class tgba_complement : public tgba
{
public:
tgba_complement(const tgba* a);
virtual ~tgba_complement();
// 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:
/// Retrieve all the atomic acceptance conditions of the automaton.
/// They are inserted into \a acc_list_.
void get_acc_list();
private:
const tgba_sgba_proxy* automaton_;
bdd the_acceptance_cond_;
unsigned nb_states_;
acc_list_t acc_list_;
}; // end class tgba_complement.
} // end namespace spot.
#endif // !SPOT_TGBA_TGBACOMPLEMENT_HH
......@@ -31,7 +31,7 @@ check_SCRIPTS = defs
# Keep this sorted alphabetically.
check_PROGRAMS = \
bddprod \
safracomplement \
complement \
explicit \
expldot \
explprod \
......
......@@ -16,18 +16,22 @@
#include "tgba/tgbatba.hh"
#include "tgba/tgbasafracomplement.hh"
#include "tgba/tgbacomplement.hh"
void usage(const char* prog)
{
std::cout << "usage: " << prog << " [options]" << std::endl;
std::cout << "with options" << std::endl
<< "-S Use safra complementation"
<< 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;
<< "-f formula test !A_f and !A_!f" << std::endl
<< "-p formula print the automaton for f" << std::endl;
}
int main(int argc, char* argv[])
......@@ -40,6 +44,8 @@ int main(int argc, char* argv[])
bool stats = false;
bool formula = false;
bool automaton = false;
bool safra = false;
bool print_formula = false;
if (argc < 3)
{
......@@ -67,12 +73,16 @@ int main(int argc, char* argv[])
switch (argv[i][1])
{
case 'S':
safra = true; break;
case 's':
print_safra = true; break;
safra = true; print_safra = true; break;
case 'a':
print_automaton = true; break;
case 'f':
check = true; break;
case 'p':
print_formula = true; break;
default:
std::cerr << "unrecognized option `-" << argv[i][1]
<< "'" << std::endl;
......@@ -98,14 +108,46 @@ int main(int argc, char* argv[])
if (spot::format_tgba_parse_errors(std::cerr, file, pel))
return 2;
spot::tgba_safra_complement* complement =
new spot::tgba_safra_complement(a);
spot::tgba* complement = 0;
if (safra)
complement = new spot::tgba_safra_complement(a);
else
complement = new spot::tgba_complement(a);
if (print_automaton)
spot::dotty_reachable(std::cout, complement);
if (print_safra)
spot::display_safra(complement);
{
spot::tgba_safra_complement* safra_complement =
dynamic_cast<spot::tgba_safra_complement*>(complement);
spot::display_safra(safra_complement);
}
delete complement;
delete a;
}
else if (print_formula)
{
spot::tgba* a;
spot::ltl::formula* f1 = 0;
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);
spot::tgba* complement = 0;
if (safra)
complement = new spot::tgba_safra_complement(a);
else
complement = new spot::tgba_complement(a);
spot::dotty_reachable(std::cout, complement);
spot::ltl::destroy(f1);
delete complement;
delete a;
}
......@@ -133,7 +175,7 @@ int main(int argc, char* argv[])
return 2;
}
spot::tgba_safra_complement* complement =
spot::tgba_safra_complement* safra_complement =
new spot::tgba_safra_complement(a);
spot::tgba_statistics a_size = spot::stats_reachable(a);
......@@ -152,8 +194,18 @@ int main(int argc, char* argv[])
<< std::endl;
delete buchi;
spot::tgba_statistics b_size = spot::stats_reachable(complement);
std::cout << "Complement: "
spot::tgba_statistics b_size = spot::stats_reachable(safra_complement);
std::cout << "Safra Complement: "
<< b_size.states << ", "
<< b_size.transitions << ", "
<< safra_complement->number_of_acceptance_conditions()
<< std::endl;
spot::tgba_complement* complement =
new spot::tgba_complement(a);
b_size = spot::stats_reachable(complement);
std::cout << "GBA Complement: "
<< b_size.states << ", "
<< b_size.transitions << ", "
<< complement->number_of_acceptance_conditions()
......@@ -191,8 +243,19 @@ int main(int argc, char* argv[])
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_safra_complement* nAf = new spot::tgba_safra_complement(Af);
spot::tgba_safra_complement* nAnf = new spot::tgba_safra_complement(Anf);
spot::tgba* nAf;
spot::tgba* nAnf;
if (safra)
{
nAf = new spot::tgba_safra_complement(Af);
nAnf = new spot::tgba_safra_complement(Anf);
}
else
{
nAf = new spot::tgba_complement(Af);
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();
......
......@@ -26,6 +26,7 @@ set -e
while read f; do
run 0 ../complement -f "$f"
run 0 ../complement -S -f "$f"
done <<EOF
GFa
FGa
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment