Make it possible to output UTF-8 for dotty().
* src/tgba/tgbaexplicit.hh: Rerganize a bit to allow different functions to be used to format states. Add an enabled_utf8() method to tgba_explicit_formula. * src/tgbaalgos/dotty.hh, src/tgbaalgos/dotty.cc: Simplify the interface by not depending on dotty_decorator explicitely. * src/tgba/bddprint.hh (enable_utf8): New function. * src/tgba/bddprint.cc (enable_utf8): Implement it and use the global utf8 flag in other functions. * src/tgbatest/ltl2tgba.cc: Add an -8 option for UTF-8 outpout. * wrap/python/spot.i: Adjust for tgbexplicit.hh changes.
This commit is contained in:
parent
f082700fb2
commit
e93ceebafe
7 changed files with 235 additions and 101 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2009 Laboratoire de Recherche et Développement
|
// Copyright (C) 2009, 2012 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004 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
|
||||||
|
|
@ -36,6 +36,19 @@ namespace spot
|
||||||
/// Global flag to enable Acc[x] output (instead of `x').
|
/// Global flag to enable Acc[x] output (instead of `x').
|
||||||
static bool want_acc;
|
static bool want_acc;
|
||||||
|
|
||||||
|
/// Global flag to enable UTF-8 output.
|
||||||
|
static bool utf8;
|
||||||
|
|
||||||
|
static
|
||||||
|
std::ostream& print_ltl(const ltl::formula* f, std::ostream& o)
|
||||||
|
{
|
||||||
|
if (utf8)
|
||||||
|
ltl::to_utf8_string(f, o);
|
||||||
|
else
|
||||||
|
ltl::to_string(f, o);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
/// Stream handler used by Buddy to display BDD variables.
|
/// Stream handler used by Buddy to display BDD variables.
|
||||||
static void
|
static void
|
||||||
print_handler(std::ostream& o, int var)
|
print_handler(std::ostream& o, int var)
|
||||||
|
|
@ -52,12 +65,12 @@ namespace spot
|
||||||
if (want_acc)
|
if (want_acc)
|
||||||
{
|
{
|
||||||
o << "Acc[";
|
o << "Acc[";
|
||||||
to_string(isi->second, o) << "]";
|
print_ltl(isi->second, o) << "]";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
o << "\"";
|
o << "\"";
|
||||||
to_string(isi->second, o) << "\"";
|
print_ltl(isi->second, o) << "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -65,14 +78,16 @@ namespace spot
|
||||||
isi = dict->now_formula_map.find(var);
|
isi = dict->now_formula_map.find(var);
|
||||||
if (isi != dict->now_formula_map.end())
|
if (isi != dict->now_formula_map.end())
|
||||||
{
|
{
|
||||||
o << "Now["; to_string(isi->second, o) << "]";
|
o << "Now[";
|
||||||
|
print_ltl(isi->second, o) << "]";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isi = dict->now_formula_map.find(var - 1);
|
isi = dict->now_formula_map.find(var - 1);
|
||||||
if (isi != dict->now_formula_map.end())
|
if (isi != dict->now_formula_map.end())
|
||||||
{
|
{
|
||||||
o << "Next["; to_string(isi->second, o) << "]";
|
o << "Next[";
|
||||||
|
print_ltl(isi->second, o) << "]";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -202,7 +217,7 @@ namespace spot
|
||||||
bdd_print_formula(std::ostream& os, const bdd_dict* d, bdd b)
|
bdd_print_formula(std::ostream& os, const bdd_dict* d, bdd b)
|
||||||
{
|
{
|
||||||
const ltl::formula* f = bdd_to_formula(b, d);
|
const ltl::formula* f = bdd_to_formula(b, d);
|
||||||
to_string(f, os);
|
print_ltl(f, os);
|
||||||
f->destroy();
|
f->destroy();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
@ -237,4 +252,9 @@ namespace spot
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
enable_utf8()
|
||||||
|
{
|
||||||
|
utf8 = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004, 2012 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.
|
||||||
//
|
//
|
||||||
|
|
@ -113,6 +113,8 @@ namespace spot
|
||||||
std::ostream& bdd_print_table(std::ostream& os,
|
std::ostream& bdd_print_table(std::ostream& os,
|
||||||
const bdd_dict* dict, bdd b);
|
const bdd_dict* dict, bdd b);
|
||||||
|
|
||||||
|
/// \brief Enable UTF-8 output for bdd printers.
|
||||||
|
void enable_utf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SPOT_TGBA_BDDPRINT_HH
|
#endif // SPOT_TGBA_BDDPRINT_HH
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Label Label_t;
|
typedef Label label_t;
|
||||||
typedef label_hash label_hash_t;
|
typedef label_hash label_hash_t;
|
||||||
|
|
||||||
struct transition
|
struct transition
|
||||||
|
|
@ -154,12 +154,6 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int default_val;
|
static const int default_val;
|
||||||
static std::string to_string(int l)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << l;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// States labeled by a string
|
/// States labeled by a string
|
||||||
|
|
@ -183,10 +177,6 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string default_val;
|
static const std::string default_val;
|
||||||
static std::string to_string(const std::string& l)
|
|
||||||
{
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// States labeled by a formula
|
/// States labeled by a formula
|
||||||
|
|
@ -210,10 +200,6 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
static const ltl::formula* default_val;
|
static const ltl::formula* default_val;
|
||||||
static std::string to_string(const ltl::formula* l)
|
|
||||||
{
|
|
||||||
return ltl::to_string(l);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Successor iterators used by spot::tgba_explicit.
|
/// Successor iterators used by spot::tgba_explicit.
|
||||||
|
|
@ -280,19 +266,22 @@ namespace spot
|
||||||
bdd all_acceptance_conditions_;
|
bdd all_acceptance_conditions_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Graph implementation for automata representation
|
/// Graph implementation for explicit automgon
|
||||||
/// \ingroup tgba_representation
|
/// \ingroup tgba_representation
|
||||||
template<typename State, typename Type>
|
template<typename State, typename Type>
|
||||||
class explicit_graph: public Type
|
class explicit_graph: public Type
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef typename State::label_t label_t;
|
||||||
|
typedef typename State::label_hash_t label_hash_t;
|
||||||
|
typedef typename State::transitions_t transitions_t;
|
||||||
|
typedef typename State::transition transition;
|
||||||
|
typedef State state;
|
||||||
protected:
|
protected:
|
||||||
typedef Sgi::hash_map<typename State::Label_t, State,
|
typedef Sgi::hash_map<label_t, State, label_hash_t> ls_map;
|
||||||
typename State::label_hash_t> ls_map;
|
typedef Sgi::hash_map<const State*, label_t, ptr_hash<State> > sl_map;
|
||||||
typedef Sgi::hash_map<const State*, typename State::Label_t,
|
|
||||||
ptr_hash<State> > sl_map;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename State::transition transition;
|
|
||||||
|
|
||||||
explicit_graph(bdd_dict* dict)
|
explicit_graph(bdd_dict* dict)
|
||||||
: ls_(),
|
: ls_(),
|
||||||
|
|
@ -319,15 +308,14 @@ namespace spot
|
||||||
t.condition = bddtrue;
|
t.condition = bddtrue;
|
||||||
t.acceptance_conditions = bddfalse;
|
t.acceptance_conditions = bddfalse;
|
||||||
|
|
||||||
typename State::transitions_t::iterator i =
|
typename transitions_t::iterator i =
|
||||||
source->successors.insert(source->successors.end(), t);
|
source->successors.insert(source->successors.end(), t);
|
||||||
|
|
||||||
return &*i;
|
return &*i;
|
||||||
}
|
}
|
||||||
|
|
||||||
transition*
|
transition*
|
||||||
create_transition(const typename State::Label_t& source,
|
create_transition(const label_t& source, const label_t& dest)
|
||||||
const typename State::Label_t& dest)
|
|
||||||
{
|
{
|
||||||
// It's important that the source be created before the
|
// It's important that the source be created before the
|
||||||
// destination, so the first source encountered becomes the
|
// destination, so the first source encountered becomes the
|
||||||
|
|
@ -361,19 +349,19 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
//old tgba explicit labelled interface
|
//old tgba explicit labelled interface
|
||||||
bool has_state(const typename State::Label_t& name)
|
bool has_state(const label_t& name)
|
||||||
{
|
{
|
||||||
return ls_.find(name) != ls_.end();
|
return ls_.find(name) != ls_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
const typename State::Label_t& get_label(const State* s) const
|
const label_t& get_label(const State* s) const
|
||||||
{
|
{
|
||||||
typename sl_map::const_iterator i = sl_.find(s);
|
typename sl_map::const_iterator i = sl_.find(s);
|
||||||
assert(i != sl_.end());
|
assert(i != sl_.end());
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const typename State::Label_t& get_label(const spot::state* s) const
|
const label_t& get_label(const spot::state* s) const
|
||||||
{
|
{
|
||||||
const State* se = down_cast<const State*>(s);
|
const State* se = down_cast<const State*>(s);
|
||||||
assert(se);
|
assert(se);
|
||||||
|
|
@ -381,8 +369,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
transition*
|
transition*
|
||||||
create_trainsition(const typename State::Label_t& source,
|
create_trainsition(const label_t& source, const label_t& dest)
|
||||||
const typename State::Label_t& dest)
|
|
||||||
{
|
{
|
||||||
// It's important that the source be created before the
|
// It's important that the source be created before the
|
||||||
// destination, so the first source encountered becomes the
|
// destination, so the first source encountered becomes the
|
||||||
|
|
@ -398,7 +385,7 @@ namespace spot
|
||||||
typename ls_map::iterator i;
|
typename ls_map::iterator i;
|
||||||
for (i = ls_.begin(); i != ls_.end(); ++i)
|
for (i = ls_.begin(); i != ls_.end(); ++i)
|
||||||
{
|
{
|
||||||
typename State::transitions_t::iterator i2;
|
typename transitions_t::iterator i2;
|
||||||
for (i2 = i->second.successors.begin();
|
for (i2 = i->second.successors.begin();
|
||||||
i2 != i->second.successors.end(); ++i2)
|
i2 != i->second.successors.end(); ++i2)
|
||||||
i2->acceptance_conditions = all - i2->acceptance_conditions;
|
i2->acceptance_conditions = all - i2->acceptance_conditions;
|
||||||
|
|
@ -411,21 +398,20 @@ namespace spot
|
||||||
typename ls_map::iterator i;
|
typename ls_map::iterator i;
|
||||||
for (i = ls_.begin(); i != ls_.end(); ++i)
|
for (i = ls_.begin(); i != ls_.end(); ++i)
|
||||||
{
|
{
|
||||||
typename State::transitions_t::iterator t1;
|
typename transitions_t::iterator t1;
|
||||||
for (t1 = i->second.successors.begin();
|
for (t1 = i->second.successors.begin();
|
||||||
t1 != i->second.successors.end(); ++t1)
|
t1 != i->second.successors.end(); ++t1)
|
||||||
{
|
{
|
||||||
bdd acc = t1->acceptance_conditions;
|
bdd acc = t1->acceptance_conditions;
|
||||||
const state_explicit<typename State::Label_t,
|
const state_explicit<label_t, label_hash_t>* dest = t1->dest;
|
||||||
typename State::label_hash_t>* dest = t1->dest;
|
|
||||||
|
|
||||||
// Find another transition with the same destination and
|
// Find another transition with the same destination and
|
||||||
// acceptance conditions.
|
// acceptance conditions.
|
||||||
typename State::transitions_t::iterator t2 = t1;
|
typename transitions_t::iterator t2 = t1;
|
||||||
++t2;
|
++t2;
|
||||||
while (t2 != i->second.successors.end())
|
while (t2 != i->second.successors.end())
|
||||||
{
|
{
|
||||||
typename State::transitions_t::iterator t2copy = t2++;
|
typename transitions_t::iterator t2copy = t2++;
|
||||||
if (t2copy->acceptance_conditions == acc && t2copy->dest == dest)
|
if (t2copy->acceptance_conditions == acc && t2copy->dest == dest)
|
||||||
{
|
{
|
||||||
t1->condition |= t2copy->condition;
|
t1->condition |= t2copy->condition;
|
||||||
|
|
@ -438,7 +424,7 @@ namespace spot
|
||||||
|
|
||||||
/// Return the state_explicit for \a name, creating the state if
|
/// Return the state_explicit for \a name, creating the state if
|
||||||
/// it does not exist.
|
/// it does not exist.
|
||||||
State* add_state(const typename State::Label_t& name)
|
State* add_state(const label_t& name)
|
||||||
{
|
{
|
||||||
typename ls_map::iterator i = ls_.find(name);
|
typename ls_map::iterator i = ls_.find(name);
|
||||||
if (i == ls_.end())
|
if (i == ls_.end())
|
||||||
|
|
@ -458,7 +444,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
State*
|
State*
|
||||||
set_init_state(const typename State::Label_t& state)
|
set_init_state(const label_t& state)
|
||||||
{
|
{
|
||||||
State* s = add_state(state);
|
State* s = add_state(state);
|
||||||
init_ = s;
|
init_ = s;
|
||||||
|
|
@ -472,14 +458,14 @@ namespace spot
|
||||||
|
|
||||||
while (i != ls_.end())
|
while (i != ls_.end())
|
||||||
{
|
{
|
||||||
typename State::Label_t s = i->first;
|
label_t s = i->first;
|
||||||
|
|
||||||
// Do not erase the same state twice(Because of possible aliases).
|
// Do not erase the same state twice(Because of possible aliases).
|
||||||
if (sl_.erase(&(i->second)))
|
if (sl_.erase(&(i->second)))
|
||||||
i->second.destroy();
|
i->second.destroy();
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
destroy_key<typename State::Label_t> dest;
|
destroy_key<label_t> dest;
|
||||||
dest.destroy(s);
|
dest.destroy(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -515,21 +501,33 @@ namespace spot
|
||||||
->all_acceptance_conditions());
|
->all_acceptance_conditions());
|
||||||
}
|
}
|
||||||
|
|
||||||
//no need?
|
|
||||||
|
typedef std::string (*to_string_func_t)(const label_t& t);
|
||||||
|
|
||||||
|
void set_to_string_func(to_string_func_t f)
|
||||||
|
{
|
||||||
|
to_string_func_ = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
to_string_func_t get_to_string_func() const
|
||||||
|
{
|
||||||
|
return to_string_func_;
|
||||||
|
}
|
||||||
|
|
||||||
virtual std::string format_state(const spot::state* state) const
|
virtual std::string format_state(const spot::state* state) const
|
||||||
{
|
{
|
||||||
const State* se = down_cast<const State*>(state);
|
const State* se = down_cast<const State*>(state);
|
||||||
assert(se);
|
assert(se);
|
||||||
typename sl_map::const_iterator i = sl_.find(se);
|
typename sl_map::const_iterator i = sl_.find(se);
|
||||||
assert(i != sl_.end());
|
assert(i != sl_.end());
|
||||||
return State::to_string(i->second);
|
assert(to_string_func_);
|
||||||
|
return to_string_func_(i->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// old implementation in tgba_explicit_string
|
/// old implementation in tgba_explicit_string
|
||||||
/// Create an alias for a state. Any reference to \a alias_name
|
/// Create an alias for a state. Any reference to \a alias_name
|
||||||
/// will act as a reference to \a real_name.
|
/// will act as a reference to \a real_name.
|
||||||
void add_state_alias(const typename State::Label_t& alias,
|
void add_state_alias(const label_t& alias, const label_t& real)
|
||||||
const typename State::Label_t& real)
|
|
||||||
{
|
{
|
||||||
ls_[alias] = *(add_state(real));
|
ls_[alias] = *(add_state(real));
|
||||||
}
|
}
|
||||||
|
|
@ -614,7 +612,7 @@ namespace spot
|
||||||
typename explicit_graph<State, tgba>::ls_map::iterator i;
|
typename explicit_graph<State, tgba>::ls_map::iterator i;
|
||||||
for (i = this->ls_.begin(); i != this->ls_.end(); ++i)
|
for (i = this->ls_.begin(); i != this->ls_.end(); ++i)
|
||||||
{
|
{
|
||||||
typename State::transitions_t::iterator i2;
|
typename transitions_t::iterator i2;
|
||||||
for (i2 = i->second.successors.begin();
|
for (i2 = i->second.successors.begin();
|
||||||
i2 != i->second.successors.end(); ++i2)
|
i2 != i->second.successors.end(); ++i2)
|
||||||
i2->acceptance_conditions &= neg;
|
i2->acceptance_conditions &= neg;
|
||||||
|
|
@ -639,11 +637,11 @@ namespace spot
|
||||||
{
|
{
|
||||||
const State* s = down_cast<const State*>(in);
|
const State* s = down_cast<const State*>(in);
|
||||||
assert(s);
|
assert(s);
|
||||||
const typename State::transitions_t& st = s->successors;
|
const transitions_t& st = s->successors;
|
||||||
|
|
||||||
bdd res = bddfalse;
|
bdd res = bddfalse;
|
||||||
|
|
||||||
typename State::transitions_t::const_iterator i;
|
typename transitions_t::const_iterator i;
|
||||||
for (i = st.begin(); i != st.end(); ++i)
|
for (i = st.begin(); i != st.end(); ++i)
|
||||||
res |= i->condition;
|
res |= i->condition;
|
||||||
|
|
||||||
|
|
@ -654,11 +652,11 @@ namespace spot
|
||||||
{
|
{
|
||||||
const State* s = down_cast<const State*>(in);
|
const State* s = down_cast<const State*>(in);
|
||||||
assert(s);
|
assert(s);
|
||||||
const typename State::transitions_t& st = s->successors;
|
const transitions_t& st = s->successors;
|
||||||
|
|
||||||
bdd res = bddtrue;
|
bdd res = bddtrue;
|
||||||
|
|
||||||
typename State::transitions_t::const_iterator i;
|
typename transitions_t::const_iterator i;
|
||||||
for (i = st.begin(); i != st.end(); ++i)
|
for (i = st.begin(); i != st.end(); ++i)
|
||||||
res &= bdd_support(i->condition);
|
res &= bdd_support(i->condition);
|
||||||
|
|
||||||
|
|
@ -674,17 +672,14 @@ namespace spot
|
||||||
mutable bdd all_acceptance_conditions_;
|
mutable bdd all_acceptance_conditions_;
|
||||||
mutable bool all_acceptance_conditions_computed_;
|
mutable bool all_acceptance_conditions_computed_;
|
||||||
bdd neg_acceptance_conditions_;
|
bdd neg_acceptance_conditions_;
|
||||||
|
to_string_func_t to_string_func_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename State>
|
template <typename State>
|
||||||
class tgba_explicit: public explicit_graph<State, tgba>
|
class tgba_explicit: public explicit_graph<State, tgba>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename State::transition transition;
|
tgba_explicit(bdd_dict* dict): explicit_graph<State,tgba>(dict)
|
||||||
typedef State state;
|
|
||||||
|
|
||||||
tgba_explicit(bdd_dict* dict):
|
|
||||||
explicit_graph<State,tgba>(dict)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -702,11 +697,7 @@ namespace spot
|
||||||
class sba_explicit: public explicit_graph<State, sba>
|
class sba_explicit: public explicit_graph<State, sba>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename State::transition transition;
|
sba_explicit(bdd_dict* dict): explicit_graph<State, sba>(dict)
|
||||||
typedef State state;
|
|
||||||
|
|
||||||
sba_explicit(bdd_dict* dict):
|
|
||||||
explicit_graph<State, sba>(dict)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -741,15 +732,90 @@ namespace spot
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// It is tempting to write
|
||||||
|
//
|
||||||
|
// template<template<typename T>class graph, typename Type>
|
||||||
|
// class explicit_conf: public graph<T>
|
||||||
|
//
|
||||||
|
// to simplify the typedefs at the end of the file, however swig
|
||||||
|
// cannot parse this syntax.
|
||||||
|
|
||||||
|
/// Configuration of graph automata
|
||||||
|
/// \ingroup tgba_representation
|
||||||
|
template<class graph, typename Type>
|
||||||
|
class explicit_conf: public graph
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit_conf(bdd_dict* d): graph(d)
|
||||||
|
{
|
||||||
|
set_to_string_func(to_string);
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string to_string(const typename Type::label_t& l)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << l;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class graph>
|
||||||
|
class explicit_conf<graph, state_explicit_string>: public graph
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit_conf(bdd_dict* d): graph(d)
|
||||||
|
{
|
||||||
|
set_to_string_func(to_string);
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string to_string(const std::string& l)
|
||||||
|
{
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class graph>
|
||||||
|
class explicit_conf<graph, state_explicit_formula>: public graph
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit_conf(bdd_dict* d): graph(d)
|
||||||
|
{
|
||||||
|
set_to_string_func(to_string);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Enable UTF8 output for the formulae that label states.
|
||||||
|
void enable_utf8()
|
||||||
|
{
|
||||||
|
set_to_string_func(to_utf8_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string to_string(const ltl::formula* const& l)
|
||||||
|
{
|
||||||
|
return ltl::to_string(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string to_utf8_string(const ltl::formula* const& l)
|
||||||
|
{
|
||||||
|
return ltl::to_utf8_string(l);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Typedefs for tgba
|
// Typedefs for tgba
|
||||||
typedef tgba_explicit<state_explicit_string> tgba_explicit_string;
|
typedef explicit_conf<tgba_explicit<state_explicit_string>,
|
||||||
typedef tgba_explicit<state_explicit_formula> tgba_explicit_formula;
|
state_explicit_string> tgba_explicit_string;
|
||||||
typedef tgba_explicit<state_explicit_number> tgba_explicit_number;
|
typedef explicit_conf<tgba_explicit<state_explicit_formula>,
|
||||||
|
state_explicit_formula> tgba_explicit_formula;
|
||||||
|
typedef explicit_conf<tgba_explicit<state_explicit_number>,
|
||||||
|
state_explicit_number> tgba_explicit_number;
|
||||||
|
|
||||||
// Typedefs for sba
|
// Typedefs for sba
|
||||||
typedef sba_explicit<state_explicit_string> sba_explicit_string;
|
typedef explicit_conf<sba_explicit<state_explicit_string>,
|
||||||
typedef sba_explicit<state_explicit_formula> sba_explicit_formula;
|
state_explicit_string> sba_explicit_string;
|
||||||
typedef sba_explicit<state_explicit_number> sba_explicit_number;
|
typedef explicit_conf<sba_explicit<state_explicit_formula>,
|
||||||
|
state_explicit_formula> sba_explicit_formula;
|
||||||
|
typedef explicit_conf<sba_explicit<state_explicit_number>,
|
||||||
|
state_explicit_number> sba_explicit_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SPOT_TGBA_TGBAEXPLICIT_HH
|
#endif // SPOT_TGBA_TGBAEXPLICIT_HH
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,12 @@
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include "tgba/tgba.hh"
|
#include "tgba/tgba.hh"
|
||||||
#include "dotty.hh"
|
#include "dotty.hh"
|
||||||
|
#include "dottydec.hh"
|
||||||
#include "tgba/bddprint.hh"
|
#include "tgba/bddprint.hh"
|
||||||
#include "reachiter.hh"
|
#include "reachiter.hh"
|
||||||
#include "misc/escape.hh"
|
#include "misc/escape.hh"
|
||||||
#include "tgba/tgbatba.hh"
|
#include "tgba/tgbatba.hh"
|
||||||
|
#include "tgba/formula2bdd.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -126,6 +128,8 @@ namespace spot
|
||||||
dotty_reachable(std::ostream& os, const tgba* g,
|
dotty_reachable(std::ostream& os, const tgba* g,
|
||||||
bool assume_sba, dotty_decorator* dd)
|
bool assume_sba, dotty_decorator* dd)
|
||||||
{
|
{
|
||||||
|
if (!dd)
|
||||||
|
dd = dotty_decorator::instance();
|
||||||
dotty_bfs d(os, g, assume_sba, dd);
|
dotty_bfs d(os, g, assume_sba, dd);
|
||||||
d.run();
|
d.run();
|
||||||
return os;
|
return os;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
// Copyright (C) 2003, 2004, 2011 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// -*- coding: utf-
|
||||||
|
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Developpement de
|
||||||
|
// l'Epita (LRDE).
|
||||||
|
// Copyright (C) 2003, 2004 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.
|
||||||
//
|
//
|
||||||
|
|
@ -22,27 +25,29 @@
|
||||||
#ifndef SPOT_TGBAALGOS_DOTTY_HH
|
#ifndef SPOT_TGBAALGOS_DOTTY_HH
|
||||||
# define SPOT_TGBAALGOS_DOTTY_HH
|
# define SPOT_TGBAALGOS_DOTTY_HH
|
||||||
|
|
||||||
#include "dottydec.hh"
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
class tgba;
|
class tgba;
|
||||||
|
class dotty_decorator;
|
||||||
|
|
||||||
/// \brief Print reachable states in dot format.
|
/// \brief Print reachable states in dot format.
|
||||||
/// \ingroup tgba_io
|
/// \ingroup tgba_io
|
||||||
///
|
///
|
||||||
/// If assume_sba is set, this assumes that the automaton
|
/// If \a assume_sba is set, this assumes that the automaton
|
||||||
/// is an SBA and use double elipse to mark accepting states.
|
/// is an SBA and use double elipse to mark accepting states.
|
||||||
///
|
///
|
||||||
/// The \a dd argument allows to customize the output in various
|
/// The \a dd argument allows to customize the output in various
|
||||||
/// ways. See \ref tgba_dotty "this page" for a list of available
|
/// ways. See \ref tgba_dotty "this page" for a list of available
|
||||||
/// decorators.
|
/// decorators. If no decorator is specified, the dotty_decorator
|
||||||
|
/// is used.
|
||||||
|
/// labels the transitions are encoded in UTF-8.
|
||||||
std::ostream&
|
std::ostream&
|
||||||
dotty_reachable(std::ostream& os,
|
dotty_reachable(std::ostream& os,
|
||||||
const tgba* g,
|
const tgba* g,
|
||||||
bool assume_sba = false,
|
bool assume_sba = false,
|
||||||
dotty_decorator* dd = dotty_decorator::instance());
|
dotty_decorator* dd = 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SPOT_TGBAALGOS_DOTTY_HH
|
#endif // SPOT_TGBAALGOS_DOTTY_HH
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,7 @@ syntax(char* prog)
|
||||||
<< "Miscellaneous options:" << std::endl
|
<< "Miscellaneous options:" << std::endl
|
||||||
<< " -0 produce minimal output dedicated to the paper"
|
<< " -0 produce minimal output dedicated to the paper"
|
||||||
<< std::endl
|
<< std::endl
|
||||||
|
<< " -8 output UTF-8 formulae" << std::endl
|
||||||
<< " -d turn on traces during parsing" << std::endl
|
<< " -d turn on traces during parsing" << std::endl
|
||||||
<< " -T time the different phases of the translation"
|
<< " -T time the different phases of the translation"
|
||||||
<< std::endl
|
<< std::endl
|
||||||
|
|
@ -281,6 +282,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
bool debug_opt = false;
|
bool debug_opt = false;
|
||||||
bool paper_opt = false;
|
bool paper_opt = false;
|
||||||
|
bool utf8_opt = false;
|
||||||
enum { NoDegen, DegenTBA, DegenSBA } degeneralize_opt = NoDegen;
|
enum { NoDegen, DegenTBA, DegenSBA } degeneralize_opt = NoDegen;
|
||||||
enum { TransitionLabeled, StateLabeled } labeling_opt = TransitionLabeled;
|
enum { TransitionLabeled, StateLabeled } labeling_opt = TransitionLabeled;
|
||||||
enum { TransFM, TransLaCIM, TransLaCIM_ELTL, TransLaCIM_ELTL_ops, TransTAA }
|
enum { TransFM, TransLaCIM, TransLaCIM_ELTL, TransLaCIM_ELTL_ops, TransTAA }
|
||||||
|
|
@ -304,7 +306,7 @@ main(int argc, char** argv)
|
||||||
spot::ltl::ltl_simplifier_options redopt(false, false, false, false, false);
|
spot::ltl::ltl_simplifier_options redopt(false, false, false, false, false);
|
||||||
bool scc_filter_all = false;
|
bool scc_filter_all = false;
|
||||||
bool symbolic_scc_pruning = false;
|
bool symbolic_scc_pruning = false;
|
||||||
bool display_reduce_form = false;
|
bool display_reduced_form = false;
|
||||||
bool post_branching = false;
|
bool post_branching = false;
|
||||||
bool fair_loop_approx = false;
|
bool fair_loop_approx = false;
|
||||||
bool graph_run_opt = false;
|
bool graph_run_opt = false;
|
||||||
|
|
@ -339,6 +341,11 @@ main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
paper_opt = true;
|
paper_opt = true;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[formula_index], "-8"))
|
||||||
|
{
|
||||||
|
utf8_opt = true;
|
||||||
|
spot::enable_utf8();
|
||||||
|
}
|
||||||
else if (!strcmp(argv[formula_index], "-a"))
|
else if (!strcmp(argv[formula_index], "-a"))
|
||||||
{
|
{
|
||||||
output = 2;
|
output = 2;
|
||||||
|
|
@ -609,7 +616,7 @@ main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[formula_index], "-rd"))
|
else if (!strcmp(argv[formula_index], "-rd"))
|
||||||
{
|
{
|
||||||
display_reduce_form = true;
|
display_reduced_form = true;
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[formula_index], "-RDS"))
|
else if (!strcmp(argv[formula_index], "-RDS"))
|
||||||
{
|
{
|
||||||
|
|
@ -772,9 +779,9 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
if (f || from_file)
|
if (f || from_file)
|
||||||
{
|
{
|
||||||
const spot::tgba_bdd_concrete* concrete = 0;
|
spot::tgba_bdd_concrete* concrete = 0;
|
||||||
const spot::tgba* to_free = 0;
|
const spot::tgba* to_free = 0;
|
||||||
const spot::tgba* a = 0;
|
spot::tgba* a = 0;
|
||||||
|
|
||||||
if (from_file)
|
if (from_file)
|
||||||
{
|
{
|
||||||
|
|
@ -822,8 +829,13 @@ main(int argc, char** argv)
|
||||||
f->destroy();
|
f->destroy();
|
||||||
tm.stop("reducing formula");
|
tm.stop("reducing formula");
|
||||||
f = t;
|
f = t;
|
||||||
if (display_reduce_form)
|
if (display_reduced_form)
|
||||||
std::cout << spot::ltl::to_string(f) << std::endl;
|
{
|
||||||
|
if (utf8_opt)
|
||||||
|
std::cout << spot::ltl::to_utf8_string(f) << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << spot::ltl::to_string(f) << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->is_psl_formula()
|
if (f->is_psl_formula()
|
||||||
|
|
@ -900,14 +912,13 @@ main(int argc, char** argv)
|
||||||
if (scc_filter)
|
if (scc_filter)
|
||||||
{
|
{
|
||||||
tm.start("reducing A_f w/ SCC");
|
tm.start("reducing A_f w/ SCC");
|
||||||
a = aut_scc = spot::scc_filter(a, scc_filter_all);
|
aut_scc = a = spot::scc_filter(a, scc_filter_all);
|
||||||
tm.stop("reducing A_f w/ SCC");
|
tm.stop("reducing A_f w/ SCC");
|
||||||
}
|
}
|
||||||
|
|
||||||
const spot::tgba_tba_proxy* degeneralized = 0;
|
const spot::tgba* degeneralized = 0;
|
||||||
const spot::tgba_sgba_proxy* state_labeled = 0;
|
|
||||||
|
|
||||||
const spot::tgba* minimized = 0;
|
spot::tgba* minimized = 0;
|
||||||
if (opt_minimize)
|
if (opt_minimize)
|
||||||
{
|
{
|
||||||
tm.start("obligation minimization");
|
tm.start("obligation minimization");
|
||||||
|
|
@ -961,39 +972,39 @@ main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (degeneralize_opt == DegenTBA)
|
if (degeneralize_opt == DegenTBA)
|
||||||
{
|
{
|
||||||
a = degeneralized = new spot::tgba_tba_proxy(a);
|
degeneralized = a = new spot::tgba_tba_proxy(a);
|
||||||
}
|
}
|
||||||
else if (degeneralize_opt == DegenSBA)
|
else if (degeneralize_opt == DegenSBA)
|
||||||
{
|
{
|
||||||
a = degeneralized = new spot::tgba_sba_proxy(a);
|
degeneralized = a = new spot::tgba_sba_proxy(a);
|
||||||
assume_sba = true;
|
assume_sba = true;
|
||||||
}
|
}
|
||||||
else if (labeling_opt == StateLabeled)
|
else if (labeling_opt == StateLabeled)
|
||||||
{
|
{
|
||||||
a = state_labeled = new spot::tgba_sgba_proxy(a);
|
degeneralized = a = new spot::tgba_sgba_proxy(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_monitor)
|
if (opt_monitor)
|
||||||
{
|
{
|
||||||
tm.start("Monitor minimization");
|
tm.start("Monitor minimization");
|
||||||
a = minimized = minimize_monitor(a);
|
minimized = a = minimize_monitor(a);
|
||||||
tm.stop("Monitor minimization");
|
tm.stop("Monitor minimization");
|
||||||
assume_sba = false; // All states are accepting, so double
|
assume_sba = false; // All states are accepting, so double
|
||||||
// circles in the dot output are
|
// circles in the dot output are
|
||||||
// pointless.
|
// pointless.
|
||||||
}
|
}
|
||||||
|
|
||||||
const spot::tgba_explicit_string* expl = 0;
|
const spot::tgba* expl = 0;
|
||||||
switch (dupexp)
|
switch (dupexp)
|
||||||
{
|
{
|
||||||
case NoneDup:
|
case NoneDup:
|
||||||
break;
|
break;
|
||||||
case BFS:
|
case BFS:
|
||||||
a = expl = tgba_dupexp_bfs(a);
|
expl = a = tgba_dupexp_bfs(a);
|
||||||
break;
|
break;
|
||||||
case DFS:
|
case DFS:
|
||||||
a = expl = tgba_dupexp_dfs(a);
|
expl = a = tgba_dupexp_dfs(a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1001,7 +1012,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
if (system)
|
if (system)
|
||||||
{
|
{
|
||||||
a = product = product_to_free = new spot::tgba_product(system, a);
|
product = product_to_free = a = new spot::tgba_product(system, a);
|
||||||
|
|
||||||
assume_sba = false;
|
assume_sba = false;
|
||||||
|
|
||||||
|
|
@ -1013,12 +1024,12 @@ main(int argc, char** argv)
|
||||||
degeneralize_opt = DegenTBA;
|
degeneralize_opt = DegenTBA;
|
||||||
if (degeneralize_opt == DegenTBA)
|
if (degeneralize_opt == DegenTBA)
|
||||||
{
|
{
|
||||||
a = product = product_degeneralized =
|
product = product_degeneralized = a =
|
||||||
new spot::tgba_tba_proxy(product);
|
new spot::tgba_tba_proxy(product);
|
||||||
}
|
}
|
||||||
else if (degeneralize_opt == DegenSBA)
|
else if (degeneralize_opt == DegenSBA)
|
||||||
{
|
{
|
||||||
a = product = product_degeneralized =
|
product = product_degeneralized = a =
|
||||||
new spot::tgba_sba_proxy(product);
|
new spot::tgba_sba_proxy(product);
|
||||||
assume_sba = true;
|
assume_sba = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1047,6 +1058,11 @@ main(int argc, char** argv)
|
||||||
a = new spot::future_conditions_collector(a, true);
|
a = new spot::future_conditions_collector(a, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (utf8_opt)
|
||||||
|
if (spot::tgba_explicit_formula* tef =
|
||||||
|
dynamic_cast<spot::tgba_explicit_formula*>(a))
|
||||||
|
tef->enable_utf8();
|
||||||
|
|
||||||
if (output != -1)
|
if (output != -1)
|
||||||
{
|
{
|
||||||
tm.start("producing output");
|
tm.start("producing output");
|
||||||
|
|
@ -1266,7 +1282,7 @@ main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
spot::tgba* ar =
|
spot::tgba* ar =
|
||||||
spot::tgba_run_to_tgba(a, run);
|
spot::tgba_run_to_tgba(a, run);
|
||||||
spot::dotty_reachable(std::cout, ar);
|
spot::dotty_reachable(std::cout, ar, false);
|
||||||
delete ar;
|
delete ar;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1301,7 +1317,6 @@ main(int argc, char** argv)
|
||||||
delete minimized;
|
delete minimized;
|
||||||
delete degeneralized;
|
delete degeneralized;
|
||||||
delete aut_scc;
|
delete aut_scc;
|
||||||
delete state_labeled;
|
|
||||||
delete to_free;
|
delete to_free;
|
||||||
delete echeck_inst;
|
delete echeck_inst;
|
||||||
delete temp_dir_sim;
|
delete temp_dir_sim;
|
||||||
|
|
|
||||||
|
|
@ -213,9 +213,23 @@ using namespace spot;
|
||||||
spot::explicit_graph<state_explicit_number, tgba>;
|
spot::explicit_graph<state_explicit_number, tgba>;
|
||||||
%template(explicit_graph__formula_tgba)
|
%template(explicit_graph__formula_tgba)
|
||||||
spot::explicit_graph<state_explicit_formula, tgba>;
|
spot::explicit_graph<state_explicit_formula, tgba>;
|
||||||
%template(tgba_explicit__string) spot::tgba_explicit<state_explicit_string>;
|
|
||||||
%template(tgba_explicit__number) spot::tgba_explicit<state_explicit_number>;
|
%template(explicit_string_tgba)
|
||||||
%template(tgba_explicit__formula) spot::tgba_explicit<state_explicit_formula>;
|
spot::explicit_graph<state_explicit_string, tgba>;
|
||||||
|
%template(explicit_number_tgba)
|
||||||
|
spot::tgba_explicit<state_explicit_formula>;
|
||||||
|
%template(explicit__number_tgba)
|
||||||
|
spot::tgba_explicit<state_explicit_number>;
|
||||||
|
|
||||||
|
%template(explicit_string__tgba)
|
||||||
|
spot::explicit_conf<tgba_explicit<state_explicit_string>,
|
||||||
|
state_explicit_string>;
|
||||||
|
%template(explicit_number__tgba)
|
||||||
|
spot::explicit_conf<tgba_explicit<state_explicit_number>,
|
||||||
|
state_explicit_number>;
|
||||||
|
%template(explicit_formula__tgba)
|
||||||
|
spot::explicit_conf<tgba_explicit<state_explicit_formula>,
|
||||||
|
state_explicit_formula>;
|
||||||
|
|
||||||
%include "tgbaalgos/dottydec.hh"
|
%include "tgbaalgos/dottydec.hh"
|
||||||
%include "tgbaalgos/dotty.hh"
|
%include "tgbaalgos/dotty.hh"
|
||||||
|
|
@ -302,6 +316,14 @@ minimize_obligation_new(const spot::tgba* a, const spot::ltl::formula* f)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tgba_enable_utf8(spot::tgba* a)
|
||||||
|
{
|
||||||
|
if (spot::tgba_explicit_formula* tef =
|
||||||
|
dynamic_cast<spot::tgba_explicit_formula*>(a))
|
||||||
|
tef->enable_utf8();
|
||||||
|
}
|
||||||
|
|
||||||
spot::ltl::parse_error_list
|
spot::ltl::parse_error_list
|
||||||
empty_parse_error_list()
|
empty_parse_error_list()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue