Add a new form of TA with a Single-pass emptiness check (STA)

* src/ta/ta.cc, src/ta/ta.hh, src/ta/taexplicit.cc,
src/ta/taexplicit.hh, src/ta/taproduct.cc,src/ta/taproduct.hh,
src/taalgos/dotty.cc, src/taalgos/emptinessta.cc,
src/taalgos/emptinessta.hh, src/taalgos/minimize.cc,
src/taalgos/reachiter.cc, src/taalgos/sba2ta.cc, src/taalgos/sba2ta.hh,
src/tgbatest/ltl2ta.test, src/tgbatest/ltl2tgba.cc: Impacts of the
implementation of a new variant of TA, called STA, which involve a
Single-pass emptiness check. The new options (-in and -lv) added to
build the new variants of TA allow to add two artificial states:
1- an initial artificial state to have an unique initial state (-in)
2- a livelock artificial state which has no successors in order to
obtain the new form of TA which requires only a Single-pass emptiness-
check: STA (-lv).
This commit is contained in:
Ala-Eddine Ben-Salem 2011-05-17 23:41:45 +02:00 committed by Alexandre Duret-Lutz
parent 310973f88c
commit 782ba0010b
15 changed files with 1224 additions and 711 deletions

View file

@ -19,13 +19,16 @@
// 02111-1307, USA.
#include "ta.hh"
namespace spot
{
spot::state*
ta::get_artificial_initial_state() const
{
return 0;
}
scc_stack_ta::connected_component::connected_component(int i)
{
@ -76,5 +79,4 @@ namespace spot
return s.empty();
}
}

View file

@ -49,6 +49,9 @@ namespace spot
virtual const states_set_t
get_initial_states_set() const = 0;
virtual spot::state*
get_artificial_initial_state() const = 0;
virtual ta_succ_iterator*
succ_iter(const spot::state* s) const = 0;
@ -67,6 +70,7 @@ namespace spot
virtual bool
is_livelock_accepting_state(const spot::state* s) const = 0;
virtual bool
is_initial_state(const spot::state* s) const = 0;

View file

@ -64,7 +64,8 @@ namespace spot
bool
ta_explicit_succ_iterator::done() const
{
return transitions_ == 0 || i_ == transitions_->end();
return transitions_ == 0 || transitions_->empty() || i_
== transitions_->end();
}
state*
@ -122,8 +123,6 @@ namespace spot
if (transitions_ == 0)
transitions_ = new transitions;
transitions_->push_back(t);
transitions* transitions_condition = get_transitions(t->condition);
if (transitions_condition == 0)
@ -132,7 +131,24 @@ namespace spot
transitions_by_condition[(t->condition).id()] = transitions_condition;
}
state_ta_explicit::transitions::iterator it_trans;
bool transition_found = false;
for (it_trans = transitions_condition->begin(); (it_trans
!= transitions_condition->end() && !transition_found); it_trans++)
{
transition_found = ((*it_trans)->dest == t->dest);
}
if (!transition_found)
{
transitions_condition->push_back(t);
transitions_->push_back(t);
}
else
{
delete t;
}
}
@ -185,6 +201,13 @@ namespace spot
is_initial_state_ = is_initial_state;
}
bool
state_ta_explicit::is_hole_state() const
{
state_ta_explicit::transitions* trans = get_transitions();
return trans == 0 || trans->empty();
}
int
state_ta_explicit::compare(const spot::state* other) const
{
@ -196,7 +219,16 @@ namespace spot
if (compare_value != 0)
return compare_value;
return tgba_condition_.id() - o->tgba_condition_.id();
compare_value = tgba_condition_.id() - o->tgba_condition_.id();
// if (compare_value != 0)
// return compare_value;
//
// //unique artificial_livelock_accepting_state
// if (o->is_the_artificial_livelock_accepting_state())
// return is_the_artificial_livelock_accepting_state();
return compare_value;
}
size_t
@ -266,7 +298,6 @@ namespace spot
delete *it_trans;
}
delete trans;
get_tgba_state()->destroy();
Sgi::hash_map<int, transitions*, Sgi::hash<int> >::iterator i =
transitions_by_condition.begin();
@ -282,10 +313,17 @@ namespace spot
// ta_explicit
ta_explicit::ta_explicit(const tgba* tgba_) :
tgba_(tgba_)
ta_explicit::ta_explicit(const tgba* tgba_,
state_ta_explicit* artificial_initial_state) :
tgba_(tgba_), artificial_initial_state_(artificial_initial_state)
{
get_dict()->register_all_variables_of(&tgba_, this);
if (artificial_initial_state != 0)
{
state_ta_explicit* is = add_state(artificial_initial_state);
assert(is == artificial_initial_state);
}
}
ta_explicit::~ta_explicit()
@ -296,6 +334,7 @@ namespace spot
state_ta_explicit* s = down_cast<state_ta_explicit*> (*it);
s->free_transitions();
s->get_tgba_state()->destroy();
delete s;
}
get_dict()->unregister_all_my_variables(this);
@ -313,13 +352,19 @@ namespace spot
}
void
ta_explicit::add_to_initial_states_set(state* state)
ta_explicit::add_to_initial_states_set(state* state, bdd condition)
{
state_ta_explicit * s = down_cast<state_ta_explicit*> (state);
assert(s);
s->set_initial_state(true);
if (condition == bddfalse)
condition = get_state_condition(s);
std::pair<ta::states_set_t::iterator, bool> add_state =
initial_states_set_.insert(s);
if (get_artificial_initial_state() != 0)
if (add_state.second)
create_transition((state_ta_explicit*) get_artificial_initial_state(),
condition, s);
}
@ -329,7 +374,8 @@ namespace spot
state_ta_explicit * state = down_cast<state_ta_explicit*> (s);
assert(state);
state->delete_stuttering_and_hole_successors();
if (state->is_initial_state()) add_to_initial_states_set(state);
if (state->is_initial_state())
add_to_initial_states_set(state);
}

View file

@ -41,7 +41,8 @@ namespace spot
class ta_explicit : public ta
{
public:
ta_explicit(const tgba* tgba_);
ta_explicit(const tgba* tgba_, state_ta_explicit* artificial_initial_state =
0);
const tgba*
get_tgba() const;
@ -50,7 +51,7 @@ namespace spot
add_state(state_ta_explicit* s);
void
add_to_initial_states_set(state* s);
add_to_initial_states_set(state* s, bdd condition = bddfalse);
void
create_transition(state_ta_explicit* source, bdd condition,
@ -91,9 +92,28 @@ namespace spot
virtual void
free_state(const spot::state* s) const;
spot::state*
get_artificial_initial_state() const
{
return (spot::state*) artificial_initial_state_;
}
void
set_artificial_initial_state(state_ta_explicit* s)
{
artificial_initial_state_ = s;
}
virtual void
delete_stuttering_and_hole_successors(spot::state* s);
ta::states_set_t
get_states_set()
{
return states_set_;
}
private:
// Disallow copy.
ta_explicit(const ta_explicit& other);
@ -103,6 +123,7 @@ namespace spot
ta::states_set_t states_set_;
ta::states_set_t initial_states_set_;
const tgba* tgba_;
state_ta_explicit* artificial_initial_state_;
};
@ -122,7 +143,8 @@ namespace spot
state_ta_explicit(const state* tgba_state, const bdd tgba_condition,
bool is_initial_state = false, bool is_accepting_state = false,
bool is_livelock_accepting_state = false, transitions* trans = 0) :
bool is_livelock_accepting_state = false, transitions* trans = 0,
bool is_the_artificial_livelock_accepting_state = false) :
tgba_state_(tgba_state), tgba_condition_(tgba_condition),
is_initial_state_(is_initial_state), is_accepting_state_(
is_accepting_state), is_livelock_accepting_state_(
@ -164,10 +186,15 @@ namespace spot
is_livelock_accepting_state() const;
void
set_livelock_accepting_state(bool is_livelock_accepting_state);
bool
is_initial_state() const;
void
set_initial_state(bool is_initial_state);
bool
is_hole_state() const;
void
delete_stuttering_and_hole_successors();

View file

@ -1,4 +1,4 @@
// Copykripke_structure (C) 2010 Laboratoire de Recherche et Developpement
// Copyright (C) 2010 Laboratoire de Recherche et Developpement
// de l Epita (LRDE).
//
//
@ -138,7 +138,7 @@ namespace spot
== kripke_current_dest_condition);
if (is_stuttering_transition_)
{
current_condition_ = bddtrue;
current_condition_ = bddfalse;
}
else
{
@ -274,7 +274,7 @@ namespace spot
{
//build initial states set
const ta::states_set_t ta_init_states_set = ta_->get_initial_states_set();
ta::states_set_t ta_init_states_set;
ta::states_set_t::const_iterator it;
ta::states_set_t initial_states_set;
@ -282,10 +282,29 @@ namespace spot
bdd kripke_init_state_condition = kripke_->state_condition(
kripke_init_state);
spot::state* artificial_initial_state = ta_->get_artificial_initial_state();
if (artificial_initial_state != 0)
{
ta_succ_iterator* ta_init_it_ = ta_->succ_iter(
artificial_initial_state, kripke_init_state_condition);
for (ta_init_it_->first(); !ta_init_it_->done(); ta_init_it_->next())
{
ta_init_states_set.insert(ta_init_it_->current_state());
}
delete ta_init_it_;
}
else
{
ta_init_states_set = ta_->get_initial_states_set();
}
for (it = ta_init_states_set.begin(); it != ta_init_states_set.end(); it++)
{
if (kripke_init_state_condition == (ta_->get_state_condition(*it)))
if ((artificial_initial_state != 0) || (kripke_init_state_condition
== ta_->get_state_condition(*it)))
{
state_ta_product* stp = new state_ta_product((*it),
kripke_init_state->clone());
@ -341,6 +360,13 @@ namespace spot
return ta_->is_livelock_accepting_state(stp->get_ta_state());
}
spot::state*
ta_product::get_artificial_initial_state() const
{
return 0;
}
//TODO BUG FIX
bool
ta_product::is_initial_state(const spot::state* s) const
{
@ -356,6 +382,16 @@ namespace spot
== (ta_->get_state_condition(ta_s)));
}
bool
ta_product::is_hole_state_in_ta_component(const spot::state* s) const
{
const state_ta_product* stp = down_cast<const state_ta_product*> (s);
ta_succ_iterator* ta_succ_iter = get_ta()->succ_iter(stp->get_ta_state());
bool is_hole_state = ta_succ_iter->done();
delete ta_succ_iter;
return is_hole_state;
}
bdd
ta_product::get_state_condition(const spot::state* s) const
{

View file

@ -164,15 +164,34 @@ namespace spot
virtual bool
is_livelock_accepting_state(const spot::state* s) const;
virtual spot::state*
get_artificial_initial_state() const;
virtual bool
is_initial_state(const spot::state* s) const;
virtual bool
is_hole_state_in_ta_component(const spot::state* s) const;
virtual bdd
get_state_condition(const spot::state* s) const;
virtual void
free_state(const spot::state* s) const;
const ta*
get_ta() const
{
return ta_;
}
const kripke*
get_kripke() const
{
return kripke_;
}
private:
bdd_dict* dict_;
const ta* ta_;

View file

@ -43,10 +43,24 @@ namespace spot
os_ << "digraph G {" << std::endl;
int n = 0;
const ta::states_set_t init_states_set =
t_automata_->get_initial_states_set();
spot::state* artificial_initial_state =
t_automata_->get_artificial_initial_state();
ta::states_set_t init_states_set;
ta::states_set_t::const_iterator it;
if (artificial_initial_state != 0)
{
init_states_set.insert(artificial_initial_state);
}
else
{
init_states_set = t_automata_->get_initial_states_set();
}
for (it = (init_states_set.begin()); it != init_states_set.end(); it++)
{
// cout << (*it).first << " => " << (*it).second << endl;
@ -60,6 +74,7 @@ namespace spot
+ "\"]" << std::endl;
}
}
void

View file

@ -34,7 +34,7 @@
namespace spot
{
ta_check::ta_check(const ta* a, option_map o) :
ta_check::ta_check(const ta_product* a, option_map o) :
a_(a), o_(o)
{
is_full_2_pass_ = o.get("is_full_2_pass", 0);
@ -46,7 +46,7 @@ namespace spot
}
bool
ta_check::check()
ta_check::check(bool disable_second_pass)
{
// We use five main data in this algorithm:
@ -75,23 +75,21 @@ namespace spot
trace
<< "PASS 1" << std::endl;
//const std::string WHITE = "W";
//const std::string GREY = "G";
//const std::string BLUE = "B";
//const std::string BLACK = "BK";
Sgi::hash_map<const state*, std::set<const state*, state_ptr_less_than>,
state_ptr_hash, state_ptr_equal> liveset;
std::stack<spot::state*> livelock_roots;
bool livelock_acceptance_states_not_found = true;
const ta::states_set_t init_states_set = a_->get_initial_states_set();
ta::states_set_t::const_iterator it;
for (it = init_states_set.begin(); it != init_states_set.end(); it++)
{
state* init_state = (*it);
init_set.push(init_state);
//colour[init_state] = WHITE;
}
@ -114,7 +112,7 @@ namespace spot
ta_succ_iterator* iter = a_->succ_iter(init);
iter->first();
todo.push(pair_state_iter(init, iter));
//colour[init] = GREY;
inc_depth();
//push potential root of live-lock accepting cycle
@ -143,6 +141,14 @@ namespace spot
trace
<< "PASS 1 : backtrack" << std::endl;
if (a_->is_livelock_accepting_state(curr))
{
livelock_acceptance_states_not_found = false;
trace
<< "PASS 1 : livelock accepting state found" << std::endl;
}
// fill rem with any component removed,
numbered_state_heap::state_index_p spi =
h->index(curr->clone());
@ -195,9 +201,14 @@ namespace spot
// Fetch the values destination state we are interested in...
state* dest = succ->current_state();
//may be Buchi accepting scc
scc.top().is_accepting = a_->is_accepting_state(curr)
&& !succ->is_stuttering_transition();
bool curr_is_livelock_hole_state_in_ta_component =
(a_->is_hole_state_in_ta_component(curr))
&& a_->is_livelock_accepting_state(curr);
//may be Buchi accepting scc or livelock accepting state (contains a TA hole and livelock accepting state)
scc.top().is_accepting = (a_->is_accepting_state(curr)
&& !succ->is_stuttering_transition())
|| curr_is_livelock_hole_state_in_ta_component;
bool is_stuttering_transition = succ->is_stuttering_transition();
@ -320,6 +331,10 @@ namespace spot
}
clear(h, todo, init_set);
if (disable_second_pass || livelock_acceptance_states_not_found)
return false;
return livelock_detection(a_);
}
@ -378,8 +393,6 @@ namespace spot
// * init: the set of the depth-first search initial states
std::stack<spot::state*> init_set;
const ta::states_set_t init_states_set = a_->get_initial_states_set();
ta::states_set_t::const_iterator it;
for (it = init_states_set.begin(); it != init_states_set.end(); it++)
@ -387,10 +400,8 @@ namespace spot
state* init_state = (*it);
init_set.push(init_state);
}
while (!init_set.empty())
{
// Setup depth-first search from initial states.

View file

@ -24,7 +24,7 @@
#ifndef SPOT_TAALGOS_EMPTINESS_HH
# define SPOT_TAALGOS_EMPTINESS_HH
#include "ta/ta.hh"
#include "ta/taproduct.hh"
#include "misc/optionmap.hh"
#include "tgbaalgos/gtec/nsheap.hh"
#include "tgbaalgos/emptiness_stats.hh"
@ -43,13 +43,13 @@ namespace spot
class ta_check : public ec_statistics
{
public:
ta_check(const ta* a, option_map o = option_map());
ta_check(const ta_product* a, option_map o = option_map());
virtual
~ta_check();
/// Check whether the automaton's language is empty.
virtual bool
check();
check(bool disable_second_pass = false);
virtual bool
livelock_detection(const ta* t);
@ -75,7 +75,7 @@ namespace spot
heuristic_livelock_detection(const state * stuttering_succ,
numbered_state_heap* h, int h_livelock_root, std::set<const state*,
state_ptr_less_than> liveset_curr);
const ta* a_; ///< The automaton.
const ta_product* a_; ///< The automaton.
option_map o_; ///< The options
bool is_full_2_pass_;

View file

@ -106,7 +106,7 @@ namespace spot
state* tgba_state = tgba->add_state(src_num);
bdd tgba_condition = bddtrue;
bool is_initial_state = a->is_initial_state(src);
if (is_initial_state)
if ((a->get_artificial_initial_state() == 0) && is_initial_state)
tgba_condition = a->get_state_condition(src);
bool is_accepting_state = a->is_accepting_state(src);
bool is_livelock_accepting_state = a->is_livelock_accepting_state(src);
@ -120,10 +120,16 @@ namespace spot
if (ta_src != new_src)
{
new_src->destroy();
tgba_state->destroy();
}
else if (a->get_artificial_initial_state() != 0)
{
if (a->get_artificial_initial_state() == src)
ta->set_artificial_initial_state(new_src);
}
else if (is_initial_state)
{
ta->add_to_initial_states_set(new_src);
}
ta_succ_iterator* succit = a->succ_iter(src);
@ -138,7 +144,7 @@ namespace spot
state* tgba_state = tgba->add_state(i->second);
bdd tgba_condition = bddtrue;
is_initial_state = a->is_initial_state(dst);
if (is_initial_state)
if ((a->get_artificial_initial_state() == 0) && is_initial_state)
tgba_condition = a->get_state_condition(dst);
bool is_accepting_state = a->is_accepting_state(dst);
bool is_livelock_accepting_state = a->is_livelock_accepting_state(
@ -153,8 +159,13 @@ namespace spot
if (ta_dst != new_dst)
{
new_dst->destroy();
tgba_state->destroy();
}
else if (a->get_artificial_initial_state() != 0)
{
if (a->get_artificial_initial_state() == dst)
ta->set_artificial_initial_state(new_dst);
}
else if (is_initial_state)
ta->add_to_initial_states_set(new_dst);
@ -196,11 +207,17 @@ namespace spot
std::set<const state*>::iterator it;
spot::state* artificial_initial_state = ta_->get_artificial_initial_state();
for (it = states_set.begin(); it != states_set.end(); it++)
{
const state* s = (*it);
if (ta_->is_initial_state(s))
if (s == artificial_initial_state)
{
I->insert(s);
}
else if (artificial_initial_state == 0 && ta_->is_initial_state(s))
{
I->insert(s);
}
@ -259,7 +276,8 @@ namespace spot
if (!G->empty())
{
unsigned s = G->size();
unsigned num = ++set_num;
unsigned num = set_num;
set_num++;
used_var[num] = s;
free_var.erase(num);
if (s > 1)
@ -276,7 +294,8 @@ namespace spot
if (!F->empty())
{
unsigned s = F->size();
unsigned num = ++set_num;
unsigned num = set_num;
set_num++;
used_var[num] = s;
free_var.erase(num);
if (s > 1)
@ -292,7 +311,8 @@ namespace spot
if (!G_F->empty())
{
unsigned s = G_F->size();
unsigned num = ++set_num;
unsigned num = set_num;
set_num++;
used_var[num] = s;
free_var.erase(num);
if (s > 1)
@ -308,7 +328,8 @@ namespace spot
if (!S->empty())
{
unsigned s = S->size();
unsigned num = ++set_num;
unsigned num = set_num;
set_num++;
used_var[num] = s;
free_var.erase(num);
if (s > 1)

View file

@ -51,10 +51,23 @@ namespace spot
{
int n = 0;
start();
const ta::states_set_t init_states_set =
t_automata_->get_initial_states_set();
spot::state* artificial_initial_state =
t_automata_->get_artificial_initial_state();
ta::states_set_t init_states_set;
ta::states_set_t::const_iterator it;
if (artificial_initial_state != 0)
{
init_states_set.insert(artificial_initial_state);
}
else
{
init_states_set = t_automata_->get_initial_states_set();
}
for (it = init_states_set.begin(); it != init_states_set.end(); it++)
{
state* init_state = (*it);

View file

@ -29,6 +29,7 @@
#include "tgbaalgos/gtec/nsheap.hh"
#include <stack>
#include "sba2ta.hh"
#include "taalgos/statessetbuilder.hh"
using namespace std;
@ -36,16 +37,29 @@ namespace spot
{
ta*
sba_to_ta(const tgba_sba_proxy* tgba_, bdd atomic_propositions_set_)
sba_to_ta(const tgba_sba_proxy* tgba_, bdd atomic_propositions_set_,
bool artificial_initial_state_mode,
bool artificial_livelock_accepting_state_mode)
{
ta_explicit* ta = new spot::ta_explicit(tgba_);
ta_explicit* ta;
std::stack<state_ta_explicit*> todo;
// build Initial states set:
state* tgba_init_state = tgba_->get_init_state();
if (artificial_initial_state_mode)
{
state_ta_explicit* ta_init_state = new state_ta_explicit(
tgba_init_state->clone(), bddtrue, true);
ta = new spot::ta_explicit(tgba_, ta_init_state);
}
else
{
ta = new spot::ta_explicit(tgba_);
}
bdd tgba_condition = tgba_->support_conditions(tgba_init_state);
bdd satone_tgba_condition;
@ -56,9 +70,10 @@ namespace spot
state_ta_explicit* init_state = new state_ta_explicit(
tgba_init_state->clone(), satone_tgba_condition, true,
tgba_->state_is_accepting(tgba_init_state));
state_ta_explicit* is = ta->add_state(init_state);
assert(is == init_state);
ta->add_to_initial_states_set(is);
state_ta_explicit* s = ta->add_state(init_state);
assert(s == init_state);
ta->add_to_initial_states_set(s);
todo.push(init_state);
}
tgba_init_state->destroy();
@ -118,11 +133,97 @@ namespace spot
}
compute_livelock_acceptance_states(ta);
if (artificial_livelock_accepting_state_mode)
{
state_ta_explicit* artificial_livelock_accepting_state =
new state_ta_explicit(ta->get_tgba()->get_init_state(), bddfalse,
false, false, true, 0, true);
state_ta_explicit* artificial_livelock_accepting_state_added = ta->add_state(artificial_livelock_accepting_state);
// unique artificial_livelock_accepting_state
assert(artificial_livelock_accepting_state_added
== artificial_livelock_accepting_state);
add_artificial_livelock_accepting_state(ta,
artificial_livelock_accepting_state_added);
}
return ta;
}
void
add_artificial_livelock_accepting_state(ta_explicit* testing_automata,
state_ta_explicit* artificial_livelock_accepting_state)
{
ta::states_set_t states_set = testing_automata->get_states_set();
ta::states_set_t::iterator it;
std::set<bdd, bdd_less_than>* conditions_to_livelock_accepting_states =
new std::set<bdd, bdd_less_than>;
for (it = states_set.begin(); it != states_set.end(); it++)
{
state_ta_explicit* source = static_cast<state_ta_explicit*> (*it);
conditions_to_livelock_accepting_states->clear();
state_ta_explicit::transitions* trans = source->get_transitions();
state_ta_explicit::transitions::iterator it_trans;
if (trans != 0)
for (it_trans = trans->begin(); it_trans != trans->end();)
{
state_ta_explicit* dest = (*it_trans)->dest;
if (dest->is_livelock_accepting_state())
{
conditions_to_livelock_accepting_states->insert(
(*it_trans)->condition);
}
//remove hole successors states
state_ta_explicit::transitions* dest_trans =
(dest)->get_transitions();
bool dest_trans_empty = dest_trans == 0 || dest_trans->empty();
if (dest_trans_empty)
{
source->get_transitions((*it_trans)->condition)->remove(
*it_trans);
delete (*it_trans);
it_trans = trans->erase(it_trans);
}
else
{
it_trans++;
}
}
if (conditions_to_livelock_accepting_states != 0)
{
std::set<bdd, bdd_less_than>::iterator it_conditions;
for (it_conditions
= conditions_to_livelock_accepting_states->begin(); it_conditions
!= conditions_to_livelock_accepting_states->end(); it_conditions++)
{
testing_automata->create_transition(source, (*it_conditions),
artificial_livelock_accepting_state);
}
}
}
delete conditions_to_livelock_accepting_states;
}
namespace
{
typedef std::pair<spot::state*, tgba_succ_iterator*> pair_state_iter;
@ -158,7 +259,7 @@ namespace spot
ta::states_set_t init_states = testing_automata->get_initial_states_set();
for (it = init_states.begin(); it != init_states.end(); it++)
{
state* init_state = down_cast<state_ta_explicit*> (*it);
state* init_state = (*it);
init_set.push(init_state);
}
@ -243,7 +344,6 @@ namespace spot
livelock_accepting_state->set_livelock_accepting_state(
true);
}
}
@ -254,6 +354,7 @@ namespace spot
// automata reduction
testing_automata->delete_stuttering_and_hole_successors(curr);
delete succ;
// Do not delete CURR: it is a key in H.
continue;
@ -354,5 +455,4 @@ namespace spot
delete h;
}
}

View file

@ -31,13 +31,18 @@
#include "misc/bddlt.hh"
#include "ta/taexplicit.hh"
namespace spot
{
ta* sba_to_ta(const tgba_sba_proxy* tgba_to_convert, bdd atomic_propositions_set);
ta*
sba_to_ta(const tgba_sba_proxy* tgba_to_convert, bdd atomic_propositions_set, bool artificial_initial_state_mode = true,
bool artificial_livelock_accepting_state_mode = false);
void
compute_livelock_acceptance_states(ta_explicit* testing_automata);
void compute_livelock_acceptance_states(ta_explicit* testing_automata);
void
add_artificial_livelock_accepting_state(ta_explicit* testing_automata,
state_ta_explicit* artificial_livelock_accepting_state);
}

181
src/tgbatest/ltl2ta.test Executable file
View file

@ -0,0 +1,181 @@
#!/bin/sh
# Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement
# 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
# 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
check ()
{
run 0 ../ltl2tgba -TA "$1"
run 0 ../ltl2tgba -TM "$1"
}
# We don't check the output, but just running these might be enough to
# trigger assertions.
check a
check 'a U b'
check 'F a'
check 'a & b & c'
check 'a | b | (c U (d & (g U (h ^ i))))'
check 'a & (b U !a) & (b U !a)'
check 'Fa & b & GFc & Gd'
check 'Fa & a & GFc & Gc'
check 'Fc & (a | b) & GF(a | b) & Gc'
check 'a R (b R c)'
check '(a U b) U (c U d)'
check '((Gp2)U(F(1)))&(p1 R(p2 R p0))'
# Make sure 'a U (b U c)' has 21 states and 144 transitions,
# before and after degeneralization.
for opt in -TA; do
../ltl2tgba -ks $opt -in 'a U (b U c)' > stdout
grep 'transitions: 144$' stdout
grep 'states: 21$' stdout
done
for opt in -TM; do
../ltl2tgba -ks $opt -in 'a U (b U c)' > stdout
grep 'transitions: 69$' stdout
grep 'states: 10$' stdout
done
for opt in -TM; do
../ltl2tgba -ks $opt '!(Ga U b)' > stdout
grep 'transitions: 15$' stdout
grep 'states: 5$' stdout
done
# Make sure 'Ga U b' has 6 states and 12 transitions,
# before and after degeneralization.
for opt in -TM; do
../ltl2tgba -ks $opt 'Ga U b' > stdout
grep 'transitions: 13$' stdout
grep 'states: 6$' stdout
done
# Make sure '(G (p -> F q)) && ((X (p) U q) || ! X (p U (p && q)))'
# has 21 states and 96 transitions, before minimization.
f='(G (p -> F q)) && ((X (p) U q) || ! X (p U (p && q)))'
../ltl2tgba -ks -TA "$f" > stdout
grep 'transitions: 96$' stdout
grep 'states: 21$' stdout
# Note: after minimization with -TM.
# has 20 states and 89 transitions, after minimization.
../ltl2tgba -ks -TM "$f" > stdout
grep 'transitions: 89$' stdout
grep 'states: 20$' stdout
# Make sure 'GFa & GFb & GFc & GFd & GFe & GFf'
# has 448 states and 28224 transitions.
f='GFa & GFb & GFc & GFd & GFe & GFg'
../ltl2tgba -ks -TA -x "$f" > stdout
grep 'transitions: 28351$' stdout
grep 'states: 449$' stdout
# Make sure 'GFa & GFb & GFc & GFd & GFe & GFf'
# has 290 states and 18527 transitions with artificial livelock state.
f='GFa & GFb & GFc & GFd & GFe & GFg'
../ltl2tgba -ks -TM -x -lv "$f" > stdout
grep 'transitions: 18527$' stdout
grep 'states: 290$' stdout
#tests with artificial livelock state:
run 0 ../ltl2tgba -ks -TA -lv "Gq|Gr|(G(q|FGp)&G(r|FG!p))" >stdout
grep 'transitions: 920$' stdout
grep 'states: 78$' stdout
run 0 ../ltl2tgba -TM -ks -lv "Gq|Gr|(G(q|FGp)&G(r|FG!p))" >stdout
grep 'transitions: 458$' stdout
grep 'states: 28$' stdout
run 0 ../ltl2tgba -TM -ks -in -R3f -x "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 521$' stdout
grep 'states: 43$' stdout
run 0 ../ltl2tgba -TM -ks -lv -R3f -x "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 645$' stdout
grep 'states: 45$' stdout
run 0 ../ltl2tgba -TM -ks "G(F(GWaitLeft7 U Idle4) U (WaitLeft2 M IsEating2))" >stdout
grep 'transitions: 2779$' stdout
grep 'states: 127$' stdout
run 0 ../ltl2tgba -TM -ks -lv "G(F(GWaitLeft7 U Idle4) U (WaitLeft2 M IsEating2))" >stdout
grep 'transitions: 3105$' stdout
grep 'states: 128$' stdout
run 0 ../ltl2tgba -TM -ks "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 536$' stdout
grep 'states: 37$' stdout
run 0 ../ltl2tgba -TM -ks -lv -in "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 612$' stdout
grep 'states: 37$' stdout
run 0 ../ltl2tgba -TM -ks -in -R3 -x "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 464$' stdout
grep 'states: 36$' stdout
run 0 ../ltl2tgba -TM -ks -lv -R3 -x "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 575$' stdout
grep 'states: 38$' stdout
run 0 ../ltl2tgba -TA -ks -lv "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 876$' stdout
grep 'states: 56$' stdout
run 0 ../ltl2tgba -TM -ks -lv "FG((WaitRight4 M (HasRight1 W GWaitLeft0)) M HasLeft4)" >stdout
grep 'transitions: 631$' stdout
grep 'states: 38$' stdout
echo '.................. OK'

View file

@ -68,6 +68,7 @@
#include "taalgos/sba2ta.hh"
#include "taalgos/dotty.hh"
#include "taalgos/stats.hh"
std::string
ltl_defs()
@ -285,6 +286,12 @@ syntax(char* prog)
<< std::endl
<< std::endl
<< " -TM Translate an LTL formula into a minimal Testing automata"
<< std::endl
<< std::endl
<< " -lv Translate an LTL formula into a Testing automata with an artificial livelock accepting state"
<< std::endl
<< std::endl
<< " -in Translate an LTL formula into a Testing automata without artificial initial state"
<< std::endl;
@ -347,6 +354,8 @@ main(int argc, char** argv)
bool reduction_dir_sim = false;
spot::tgba* temp_dir_sim = 0;
bool ta_opt = false;
bool opt_with_artificial_livelock = false;
bool opt_with_artificial_initial_state = true;
for (;;)
@ -684,6 +693,14 @@ main(int argc, char** argv)
ta_opt = true;
opt_minimize = true;
}
else if (!strcmp(argv[formula_index], "-lv"))
{
opt_with_artificial_livelock = true;
}
else if (!strcmp(argv[formula_index], "-in"))
{
opt_with_artificial_initial_state = false;
}
else if (!strcmp(argv[formula_index], "-taa"))
{
translation = TransTAA;
@ -979,7 +996,7 @@ main(int argc, char** argv)
const spot::tgba* degeneralized = 0;
spot::tgba* minimized = 0;
if (opt_minimize)
if (opt_minimize && !ta_opt)
{
tm.start("obligation minimization");
minimized = minimize_obligation(a, f);
@ -1094,12 +1111,28 @@ main(int argc, char** argv)
}
delete aps;
spot::ta* testing_automata = sba_to_ta(degeneralized, atomic_props_set_bdd);
spot::ta* testing_automata = sba_to_ta(degeneralized, atomic_props_set_bdd, opt_with_artificial_initial_state, opt_with_artificial_livelock);
if (opt_minimize) testing_automata = minimize_ta(testing_automata);
spot::dotty_reachable(std::cout, testing_automata);
delete testing_automata;
if (output != -1)
{
tm.start("producing output");
switch (output)
{
case 0:
spot::dotty_reachable(std::cout, testing_automata);
break;
case 12:
stats_reachable(testing_automata).dump(std::cout);
break;
default:
assert(!"unknown output option");
}
tm.stop("producing output");
}
delete testing_automata;
output = -1;
}
spot::tgba* product_degeneralized = 0;