Commit 93c0732f authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* src/tgbaalgos/emptinesscheck.hh, src/tgbaalgos/emptinesscheck.cc

(emptiness_check::seq_counter, emptiness_check::periode): Rename as ...
(emptiness_check::prefix, emptiness_check::period): ... these.
parent 3784895e
2003-10-22 Alexandre Duret-Lutz <adl@src.lip6.fr> 2003-10-22 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbaalgos/emptinesscheck.hh, src/tgbaalgos/emptinesscheck.cc
(emptiness_check::seq_counter, emptiness_check::periode): Rename as ...
(emptiness_check::prefix, emptiness_check::period): ... these.
* src/tgbaalgos/emptinesscheck.cc * src/tgbaalgos/emptinesscheck.cc
(emptiness_check::tgba_emptiness_check, (emptiness_check::tgba_emptiness_check,
emptiness_check::accepting_path): Simplify BDD operations. emptiness_check::accepting_path): Simplify BDD operations.
......
...@@ -196,8 +196,8 @@ namespace spot ...@@ -196,8 +196,8 @@ namespace spot
os << "Prefix:" << std::endl; os << "Prefix:" << std::endl;
os << "======================" << std::endl; os << "======================" << std::endl;
const bdd_dict* d = aut->get_dict(); const bdd_dict* d = aut->get_dict();
for (state_sequence::const_iterator i_se = seq_counter.begin(); for (state_sequence::const_iterator i_se = suffix.begin();
i_se != seq_counter.end(); i_se++) i_se != suffix.end(); i_se++)
{ {
if (restrict) if (restrict)
{ {
...@@ -212,8 +212,8 @@ namespace spot ...@@ -212,8 +212,8 @@ namespace spot
os << "======================" << std::endl; os << "======================" << std::endl;
os << "Cycle:" <<std::endl; os << "Cycle:" <<std::endl;
os << "======================" << std::endl; os << "======================" << std::endl;
for (cycle_path::const_iterator it = periode.begin(); for (cycle_path::const_iterator it = period.begin();
it != periode.end(); it++) it != period.end(); it++)
{ {
if (restrict) if (restrict)
{ {
...@@ -231,7 +231,7 @@ namespace spot ...@@ -231,7 +231,7 @@ namespace spot
return os; return os;
} }
/// \brief Build a possible prefixe and period for a counter example. /// \brief Build a possible prefix and period for a counter example.
void void
emptiness_check::counter_example(const spot::tgba* aut_counter) emptiness_check::counter_example(const spot::tgba* aut_counter)
{ {
...@@ -240,135 +240,140 @@ namespace spot ...@@ -240,135 +240,140 @@ namespace spot
spot::state_ptr_less_than> path_state; spot::state_ptr_less_than> path_state;
path_state path_map; path_state path_map;
if (!root_component.empty()){ if (!root_component.empty())
int comp_size = root_component.size(); {
typedef std::vector<connected_component> vec_compo; int comp_size = root_component.size();
vec_compo vec_component; typedef std::vector<connected_component> vec_compo;
vec_component.resize(comp_size); vec_compo vec_component;
vec_sequence.resize(comp_size); vec_component.resize(comp_size);
state_sequence seq; vec_sequence.resize(comp_size);
state_sequence tmp_lst; state_sequence seq;
state_sequence best_lst; state_sequence tmp_lst;
bdd tmp_acc = bddfalse; state_sequence best_lst;
std::stack<pair_state_iter> todo_accept; bdd tmp_acc = bddfalse;
std::stack<pair_state_iter> todo_accept;
for (int j = comp_size -1; j >= 0; j--) for (int j = comp_size -1; j >= 0; j--)
{ {
vec_component[j] = root_component.top(); vec_component[j] = root_component.top();
root_component.pop(); root_component.pop();
} }
int q_index; int q_index;
int tmp_int = 0; int tmp_int = 0;
// Fill the SCC in the stack root_component. // Fill the SCC in the stack root_component.
for (seen::iterator iter_map = seen_state_num.begin(); for (seen::iterator iter_map = seen_state_num.begin();
iter_map != seen_state_num.end(); iter_map++) iter_map != seen_state_num.end(); iter_map++)
{ {
q_index = (*iter_map).second; q_index = (*iter_map).second;
tmp_int = 0; tmp_int = 0;
if (q_index > 0) if (q_index > 0)
{ {
while ((tmp_int < comp_size) while ((tmp_int < comp_size)
&& (vec_component[tmp_int].index <= q_index)) && (vec_component[tmp_int].index <= q_index))
tmp_int = tmp_int+1; tmp_int = tmp_int+1;
if (tmp_int < comp_size) if (tmp_int < comp_size)
vec_component[tmp_int-1].state_set.insert((*iter_map).first); vec_component[tmp_int-1].state_set.insert((*iter_map).first);
else else
vec_component[comp_size-1].state_set.insert((*iter_map).first); vec_component[comp_size-1].state_set
} .insert((*iter_map).first);
} }
}
state* start_state = aut_counter->get_init_state(); state* start_state = aut_counter->get_init_state();
if (comp_size != 1) if (comp_size != 1)
{ {
tgba_succ_iterator* i = aut_counter->succ_iter(start_state); tgba_succ_iterator* i = aut_counter->succ_iter(start_state);
todo_trace.push_back(pair_state_iter(start_state, i)); todo_trace.push_back(pair_state_iter(start_state, i));
for (int k = 0; k < comp_size-1; k++) for (int k = 0; k < comp_size-1; k++)
{ {
// We build a path trought all SCC in the stack : a // We build a path trought all SCC in the stack: a
// possible prefixe for a counter example. // possible prefix for a counter example.
while (!todo_trace.empty()) while (!todo_trace.empty())
{ {
pair_state_iter started_from = todo_trace.front(); pair_state_iter started_from = todo_trace.front();
todo_trace.pop_front(); todo_trace.pop_front();
started_from.second->first(); started_from.second->first();
for (started_from.second->first(); for (started_from.second->first();
!started_from.second->done(); !started_from.second->done();
started_from.second->next()) started_from.second->next())
{ {
const state* curr_state = const state* curr_state =
started_from.second->current_state(); started_from.second->current_state();
connected_component::set_of_state::iterator iter_set = connected_component::set_of_state::iterator iter_set =
vec_component[k+1].state_set.find(curr_state); vec_component[k+1].state_set.find(curr_state);
if (iter_set != vec_component[k+1].state_set.end()) if (iter_set != vec_component[k+1].state_set.end())
{ {
const state* curr_father = started_from.first; const state* curr_father = started_from.first;
seq.push_front(*iter_set); seq.push_front(*iter_set);
seq.push_front(curr_father); seq.push_front(curr_father);
seen::iterator i_2 = seen::iterator i_2 =
seen_state_num.find(curr_father); seen_state_num.find(curr_father);
assert(i_2 != seen_state_num.end()); assert(i_2 != seen_state_num.end());
while ((vec_component[k].index while ((vec_component[k].index
< seen_state_num[curr_father]) < seen_state_num[curr_father])
&& (seen_state_num[curr_father] != 1)) && (seen_state_num[curr_father] != 1))
{ {
seq.push_front(path_map[curr_father]); seq.push_front(path_map[curr_father]);
curr_father = path_map[curr_father]; curr_father = path_map[curr_father];
seen::iterator i_3 = seen::iterator i_3 =
seen_state_num.find(curr_father); seen_state_num.find(curr_father);
assert(i_3 != seen_state_num.end()); assert(i_3 != seen_state_num.end());
} }
vec_sequence[k] = seq; vec_sequence[k] = seq;
seq.clear(); seq.clear();
todo_trace.clear(); todo_trace.clear();
break; break;
} }
else else
{ {
connected_component::set_of_state::iterator i_s = connected_component::set_of_state::iterator i_s =
vec_component[k].state_set.find(curr_state); vec_component[k].state_set.find(curr_state);
if (i_s != vec_component[k].state_set.end()) if (i_s != vec_component[k].state_set.end())
{ {
path_state::iterator i_path = path_state::iterator i_path =
path_map.find(curr_state); path_map.find(curr_state);
seen::iterator i_seen = seen::iterator i_seen =
seen_state_num.find(curr_state); seen_state_num.find(curr_state);
if (i_seen != seen_state_num.end() if (i_seen != seen_state_num.end()
&& seen_state_num[curr_state] > 0 && seen_state_num[curr_state] > 0
&& i_path == path_map.end()) && i_path == path_map.end())
{ {
todo_trace. todo_trace.
push_back(pair_state_iter(curr_state, push_back(pair_state_iter(curr_state,
aut_counter->succ_iter(curr_state))); aut_counter->succ_iter(curr_state)));
path_map[curr_state] = started_from.first; path_map[curr_state] = started_from.first;
} }
} }
} }
} }
} }
todo_trace. todo_trace.
push_back(pair_state_iter(vec_sequence[k].back(), push_back(pair_state_iter(vec_sequence[k].back(),
aut_counter->succ_iter(vec_sequence[k].back()))); aut_counter->succ_iter(vec_sequence[k].back())));
} }
} }
else else
{ {
seq_counter.push_front(start_state); suffix.push_front(start_state);
} }
for (int n_ = 0; n_ < comp_size-1; n_++) for (int n_ = 0; n_ < comp_size-1; n_++)
{ {
for (state_sequence::iterator it = vec_sequence[n_].begin(); for (state_sequence::iterator it = vec_sequence[n_].begin();
it != vec_sequence[n_].end(); it++) it != vec_sequence[n_].end(); it++)
{ {
seq_counter.push_back(*it); suffix.push_back(*it);
} }
} }
seq_counter.unique(); suffix.unique();
emptiness_check::accepting_path(aut_counter, vec_component[comp_size-1], seq_counter.back(),vec_component[comp_size-1].condition); emptiness_check::accepting_path(aut_counter,
} vec_component[comp_size-1],
suffix.back(),
vec_component[comp_size-1].condition);
}
else else
{ {
std::cout << "EMPTY LANGUAGE NO COUNTER EXEMPLE" << std::endl; std::cout << "EMPTY LANGUAGE NO COUNTER EXEMPLE" << std::endl;
...@@ -414,7 +419,7 @@ namespace spot ...@@ -414,7 +419,7 @@ namespace spot
complete_map[curr_father].second)); complete_map[curr_father].second));
curr_father = complete_map[curr_father].first; curr_father = complete_map[curr_father].first;
} }
emptiness_check::periode.splice(periode.end(), emptiness_check::period.splice(period.end(),
tmp_comp); tmp_comp);
todo_complete.clear(); todo_complete.clear();
break; break;
...@@ -533,22 +538,22 @@ namespace spot ...@@ -533,22 +538,22 @@ namespace spot
} }
for (cycle_path::iterator it = best_lst.begin(); for (cycle_path::iterator it = best_lst.begin();
it != best_lst.end(); it++) it != best_lst.end(); it++)
emptiness_check::periode.push_back(*it); emptiness_check::period.push_back(*it);
if (best_acc != to_accept) if (best_acc != to_accept)
{ {
bdd rec_to_acc = to_accept - best_acc; bdd rec_to_acc = to_accept - best_acc;
emptiness_check::accepting_path(aut_counter, comp_path, emptiness_check::accepting_path(aut_counter, comp_path,
periode.back().first, rec_to_acc); period.back().first, rec_to_acc);
} }
else else
{ {
if (!periode.empty()) if (!period.empty())
{ {
/// The path contains all accepting conditions. Then we /// The path contains all accepting conditions. Then we
///complete the cycle in this SCC by calling complete_cycle. ///complete the cycle in this SCC by calling complete_cycle.
complete_cycle(aut_counter, comp_path, periode.back().first, complete_cycle(aut_counter, comp_path, period.back().first,
seq_counter.back()); suffix.back());
} }
} }
} }
......
...@@ -93,8 +93,8 @@ namespace spot ...@@ -93,8 +93,8 @@ namespace spot
std::stack<bdd> arc_accepting; std::stack<bdd> arc_accepting;
std::stack<connected_component> root_component; std::stack<connected_component> root_component;
seen seen_state_num; seen seen_state_num;
state_sequence seq_counter; state_sequence suffix;
cycle_path periode; cycle_path period;
private: private:
std::stack<pair_state_iter> todo; std::stack<pair_state_iter> todo;
std::vector<state_sequence> vec_sequence; std::vector<state_sequence> vec_sequence;
...@@ -102,10 +102,9 @@ namespace spot ...@@ -102,10 +102,9 @@ namespace spot
/// Called by counter_example to find a path which traverses all /// Called by counter_example to find a path which traverses all
/// accepting conditions in the accepted SCC. /// accepting conditions in the accepted SCC.
void void accepting_path (const spot::tgba* aut_counter,
accepting_path (const spot::tgba* aut_counter, const connected_component& comp_path,
const connected_component& comp_path, const spot::state* start_path, bdd to_accept);
const spot::state* start_path, bdd to_accept);
/// Complete a cycle that caraterise the period of the counter /// Complete a cycle that caraterise the period of the counter
/// example. Append a sequence to the path given by accepting_path. /// example. Append a sequence to the path given by accepting_path.
......
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