Commit c769f747 authored by martinez's avatar martinez
Browse files

* src/tgbatest/spotlbtt.test: We don't check the post-reduction

with scc and delayed simulation.

* src/tgbatest/ltl2tgba.cc: Adjust parameters.
* src/tgbatest/reductgba.cc, src/tgbatest/Makefile.am: More Test.
* src/tgbaalgos/reductgba_sim_del.cc: Not finish, lot of bugs.
* src/tgbaalgos/reductgba_sim.hh, src/tgbaalgos/reductgba_sim.cc:
Remove some useless comments.
* src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh: Bug in SCC.

* src/ltlvisit/reducform.cc: Correct some bug for multop.
* src/ltltest/reduccmp.test: More Test.
* src/ltltest/reduc.cc: Thinko
* src/ltltest/equals.cc: Reduction compare
parent 84e72c87
2004-06-17 Thomas Martinez <martinez@src.lip6.fr>
* src/tgbatest/spotlbtt.test: We don't check the post-reduction
with scc and delayed simulation.
* src/tgbatest/ltl2tgba.cc: Adjust parameters.
* src/tgbatest/reductgba.cc, src/tgbatest/Makefile.am: More Test.
* src/tgbaalgos/reductgba_sim_del.cc: Not finish, lot of bugs.
* src/tgbaalgos/reductgba_sim.hh, src/tgbaalgos/reductgba_sim.cc:
Remove some useless comments.
* src/tgba/tgbareduc.cc, src/tgba/tgbareduc.hh: Bug in SCC.
* src/ltlvisit/reducform.cc: Correct some bug for multop.
* src/ltltest/reduccmp.test: More Test.
* src/ltltest/reduc.cc: Thinko
* src/ltltest/equals.cc: Reduction compare
2004-06-17 Alexandre Duret-Lutz <adl@src.lip6.fr>
* iface/gspn/ssp.cc (emptiness_check_shy_ssp::find_state): Free s.
......
......@@ -84,11 +84,8 @@ main(int argc, char** argv)
spot::ltl::formula* tmp;
tmp = f1;
f1 = spot::ltl::reduce(f1);
//std::string f2s = spot::ltl::to_string(f2);
//std::string f1s = spot::ltl::to_string(f1);
spot::ltl::destroy(tmp);
spot::ltl::dump(std::cout, f1);
//std::cout << f1s << " // " << f2s << std::endl;
#endif
int exit_code = f1 != f2;
......
......@@ -179,6 +179,5 @@ main(int argc, char** argv)
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
//return exit_code;
return 0;
return exit_code;
}
......@@ -25,6 +25,38 @@
. ./defs || exit 1
# No reduction
run 0 ./reduccmp 'a U b' 'a U b'
run 0 ./reduccmp 'a R b' 'a R b'
run 0 ./reduccmp 'a & b' 'a & b'
run 0 ./reduccmp 'a | b' 'a | b'
run 0 ./reduccmp 'a & (a U b)' 'a & (a U b)'
run 0 ./reduccmp 'a | (a U b)' 'a | (a U b)'
# Syntactic reduction
run 0 ./reduccmp 'a & (!b R !a)' 'false'
run 0 ./reduccmp '(!b R !a) & a' 'false'
run 0 ./reduccmp '(!b R !a) | a' 'true'
run 0 ./reduccmp 'a | (!b R !a)' 'true'
run 0 ./reduccmp 'a & (!b R !a) & c' 'false'
run 0 ./reduccmp 'c & (!b R !a) & a' 'false'
run 0 ./reduccmp 'a | (!b R !a) | c' 'true'
run 0 ./reduccmp 'c | (!b R !a) | a' 'true'
run 0 ./reduccmp 'a & (b U a)' 'a'
run 0 ./reduccmp '(b U a) & a' 'a'
run 0 ./reduccmp 'a | (b U a)' '(b U a)'
run 0 ./reduccmp '(b U a) | a' '(b U a)'
run 0 ./reduccmp 'a U (b U a)' '(b U a)'
run 0 ./reduccmp 'a & (b U a) & a' 'a'
run 0 ./reduccmp 'a & (b U a) & a' 'a'
run 0 ./reduccmp 'a | (b U a) | a' '(b U a)'
run 0 ./reduccmp 'a | (b U a) | a' '(b U a)'
run 0 ./reduccmp 'a U (b U a)' '(b U a)'
# Basics reduction
run 0 ./reduccmp 'X(true)' 'true'
run 0 ./reduccmp 'X(false)' 'false'
......@@ -67,8 +99,3 @@ run 0 ./reduccmp 'Ga' 'Ga'
run 0 ./reduccmp 'GFGa' 'FGa'
run 0 ./reduccmp 'b R Ga' 'Ga'
run 0 ./reduccmp 'b R FGa' 'FGa'
# Syntactic reduction
run 0 ./reduccmp 'a & (b U a)' 'a'
run 0 ./reduccmp 'a | (b U a)' '(b U a)'
run 0 ./reduccmp 'a U (b U a)' '(b U a)'
......@@ -33,21 +33,6 @@ run 1 ./syntimpl 0 '(e R f)' '(g U f)'
run 1 ./syntimpl 0 '( X(a + b))' '( X((a + b)+(c)+(d)))'
run 1 ./syntimpl 0 '( X(a + b)) U (e R f)' '( X((a + b)+(c)+(d))) U (g U f)'
run 0 ./syntimpl 0 'Xa' 'XX(b U a)'
run 0 ./syntimpl 0 'XXa' 'X(b U a)'
run 0 ./syntimpl 0 '( X(a + b))' '( X(X(a + b)+(c)+(d)))'
run 0 ./syntimpl 0 '( X(a + b)) U (e R f)' '( X(X(a + b)+(c)+(d))) U (g U f)'
run 0 ./syntimpl 0 'a' 'b'
run 0 ./syntimpl 0 'a' 'b + c'
run 0 ./syntimpl 0 'a + b' 'a'
run 0 ./syntimpl 0 'a' 'a * c'
run 0 ./syntimpl 0 'a * b' 'c'
run 0 ./syntimpl 0 'a' 'a U b'
run 0 ./syntimpl 0 'a' 'a R b'
run 0 ./syntimpl 0 'a R b' 'a'
run 1 ./syntimpl 0 '1' '1'
run 1 ./syntimpl 0 '0' '0'
......@@ -81,3 +66,21 @@ run 1 ./syntimpl 0 'a R b' '1 R b'
run 1 ./syntimpl 0 'b * (a U b)' 'a U b'
run 1 ./syntimpl 0 'a U b' 'c + (a U b)'
run 0 ./syntimpl 0 'Xa' 'XX(b U a)'
run 0 ./syntimpl 0 'XXa' 'X(b U a)'
run 0 ./syntimpl 0 '( X(a + b))' '( X(X(a + b)+(c)+(d)))'
run 0 ./syntimpl 0 '( X(a + b)) U (e R f)' '( X(X(a + b)+(c)+(d))) U (g U f)'
run 0 ./syntimpl 0 'a' 'b'
run 0 ./syntimpl 0 'a' 'b + c'
run 0 ./syntimpl 0 'a + b' 'a'
run 0 ./syntimpl 0 'a' 'a * c'
run 0 ./syntimpl 0 'a * b' 'c'
run 0 ./syntimpl 0 'a' 'a U b'
run 0 ./syntimpl 0 'a' 'a R b'
run 0 ./syntimpl 0 'a R b' 'a'
run 0 ./syntimpl 0 'p2' 'p3 || G(p2 && p5)'
run 0 ./syntimpl 0 '!(p3 || G(p2 && p5))' '!p2'
\ No newline at end of file
......@@ -201,81 +201,71 @@ namespace spot
if (opt_ & Reduce_Syntactic_Implications)
{
formula* f1;
formula* f2;
multop::vec::iterator index = res->begin();
multop::vec::iterator indextmp = index;
switch (mo->op())
{
case multop::Or:
if (index != res->end())
break;
f1 = *index++;
for (; index != res->end(); index++)
{
f2 = *index;
/* a < b => a + b = b */
if (syntactic_implication(f1, f2)) // f1 < f2
{
f1 = f2;
destroy(*indextmp);
res->erase(indextmp);
indextmp = index;
index--;
}
else if (syntactic_implication(f2, f1)) // f2 < f1
{
destroy(*index);
res->erase(index);
index--;
}
}
break;
case multop::And:
if (index != res->end())
break;
f1 = *index++;
for (; index != res->end(); index++)
bool removed = true;;
multop::vec::iterator f1;
multop::vec::iterator f2;
while (removed)
{
removed = false;
f2 = f1 = res->begin();
++f1;
while (f1 != res->end())
{
f2 = *index;
/* a < b => a & b = a */
if (syntactic_implication(f1, f2)) // f1 < f2
assert(f1 != f2);
// a < b => a + b = b
// a < b => a & b = a
if ((syntactic_implication(*f1, *f2) && // f1 < f2
(mo->op() == multop::Or)) ||
((syntactic_implication(*f2, *f1)) && // f2 < f1
(mo->op() == multop::And)))
{
destroy(*index);
res->erase(index);
index--;
// We keep f2
destroy(*f1);
res->erase(f1);
removed = true;
break;
}
else if (syntactic_implication(f2, f1)) // f2 < f1
else if ((syntactic_implication(*f2, *f1) && // f2 < f1
(mo->op() == multop::Or)) ||
((syntactic_implication(*f1,* f2)) && // f1 < f2
(mo->op() == multop::And)))
{
f1 = f2;
destroy(*indextmp);
res->erase(indextmp);
indextmp = index;
index--;
// We keep f1
destroy(*f2);
res->erase(f2);
removed = true;
break;
}
else
++f1;
}
break;
}
// FIXME
/* f1 < !f2 => f1 & f2 = false
!f1 < f2 => f1 | f2 = true */
for (index = res->begin(); index != res->end(); index++)
for (indextmp = res->begin(); indextmp != res->end(); indextmp++)
if (index != indextmp
&& syntactic_implication_neg(*index, *indextmp,
mo->op() != multop::Or))
for (f1 = res->begin(); f1 != res->end(); f1++)
for (f2 = res->begin(); f2 != res->end(); f2++)
if (f1 != f2 &&
syntactic_implication_neg(*f1, *f2,
mo->op() != multop::Or))
{
for (multop::vec::iterator j = res->begin();
j != res->end(); j++)
destroy(*j);
res->clear();
delete res;
if (mo->op() == multop::Or)
result_ = constant::true_instance();
else
result_ = constant::false_instance();
return;
}
}
if (res->size())
{
result_ = multop::instance(mo->op(), res);
......
......@@ -131,17 +131,15 @@ namespace spot
const state_explicit* se = dynamic_cast<const state_explicit*>(s);
assert(se);
sn_map::const_iterator i = state_name_map_.find(se->get_state());
//seen_map::const_iterator j = si_.find(s);
seen_map::const_iterator j = si_.find(s);
assert(i != state_name_map_.end());
/*
if (j != si_.end()) // SCC have been computed
{
os << ", SCC " << j->second;
return i->second + std::string(os.str());
}
else
*/
return i->second;
return i->second;
}
int
......@@ -244,8 +242,10 @@ namespace spot
bdd cond_simul;
bdd acc_simul;
std::list<state*> ltmp;
const tgba_explicit::state* s1 = name_state_map_[this->format_state(s)];
const tgba_explicit::state* s2 = name_state_map_[this->format_state(simul)];
const tgba_explicit::state* s1 =
name_state_map_[tgba_explicit::format_state(s)];
const tgba_explicit::state* s2 =
name_state_map_[tgba_explicit::format_state(simul)];
sp_map::iterator i = state_predecessor_map_.find(s1);
if (i == state_predecessor_map_.end()) // 0 predecessor
......@@ -325,11 +325,13 @@ namespace spot
// But it can be have some predecessor in state_predecessor_map_ !!
// So, we remove from it.
ns_map::iterator k = name_state_map_.find(format_state(s));
ns_map::iterator k =
name_state_map_.find(tgba_explicit::format_state(s));
if (k == name_state_map_.end()) // 0 predecessor
return;
tgba_explicit::state* st = name_state_map_[format_state(s)];
tgba_explicit::state* st =
name_state_map_[tgba_explicit::format_state(s)];
// for all successor q of s, we remove s of the predecessor of q.
......@@ -370,8 +372,10 @@ namespace spot
void
tgba_reduc::merge_state(const spot::state* sim1, const spot::state* sim2)
{
const tgba_explicit::state* s1 = name_state_map_[this->format_state(sim1)];
const tgba_explicit::state* s2 = name_state_map_[this->format_state(sim2)];
const tgba_explicit::state* s1 =
name_state_map_[tgba_explicit::format_state(sim1)];
const tgba_explicit::state* s2 =
name_state_map_[tgba_explicit::format_state(sim2)];
const tgba_explicit::state* stmp = s1;
const spot::state* simtmp = sim1;
......@@ -424,6 +428,7 @@ namespace spot
/////////////////////////////////////////
// From gtec.cc
void
tgba_reduc::remove_component(const spot::state* from)
{
......@@ -459,6 +464,7 @@ namespace spot
}
}
// From gtec.cc
void
tgba_reduc::compute_scc()
{
......@@ -558,6 +564,8 @@ namespace spot
void
tgba_reduc::delete_scc()
{
std::cout << "delete_scc" << std::endl;
bool change = true;
Sgi::hash_map<int, const spot::state*>::iterator i;
Sgi::hash_map<int, const spot::state*>::iterator itmp;
......@@ -570,77 +578,23 @@ namespace spot
change = false;
for (i = state_scc_v_.begin(); i != state_scc_v_.end();)
{
//std::cout << "Is terminal ? : " << std::endl;
if (is_terminal(i->second))
std::cout << "delete_scc : ["
<< this->format_state(i->second)
<< "]"
<< "is_terminal ??" << std::endl;
if (is_terminal(i->second))
{
//std::cout << " YES" << std::endl;
change = true;
this->remove_scc(const_cast<spot::state*>(i->second));
//change = true;
change = false;
//this->remove_scc(const_cast<spot::state*>(i->second));
itmp = i;
++i;
state_scc_v_.erase(itmp);
}
else
{
++i;
//std::cout << " NO "<< std::endl;
//state_scc_v_.erase(itmp);
}
++i;
}
}
}
bool
tgba_reduc::is_alpha_ball(const spot::state* s, int n)
{
/// FIXME
bool b = false;
seen_map::const_iterator i;
if (n == -1)
{
acc_ == bddfalse;
b = true;
assert(seen_ == NULL);
seen_ = new seen_map();
i = si_.find(s);
assert(i->first != NULL);
n = i->second;
}
seen_map::const_iterator sm = seen_->find(s);
if (sm == seen_->end())
{
seen_->insert(std::pair<const spot::state*, int>(s, 1));
i = si_.find(s);
assert(i->first != 0);
if (n != i->second)
return false;
}
else
{
return true;
}
bool ret = true;
tgba_succ_iterator* j = this->succ_iter(s);
for (j->first(); !j->done(); j->next())
{
acc_ |= j->current_acceptance_conditions();
ret &= this->is_terminal(j->current_state(), n);
}
if (b)
{
delete seen_;
seen_ = NULL;
if (acc_ == this->all_acceptance_conditions())
ret = false;
}
return ret;
}
bool
tgba_reduc::is_terminal(const spot::state* s, int n)
{
......@@ -650,12 +604,18 @@ namespace spot
// So we can remove it safely without change the
// automaton language.
std::cout << "is_terminal : ["
<< this->format_state(s)
<< "]"
<< std::endl;
bool b = false;
// First call of is_terminal //
seen_map::const_iterator i;
if (n == -1)
{
acc_ == bddfalse;
acc_ = bddfalse;
b = true;
assert(seen_ == NULL);
seen_ = new seen_map();
......@@ -663,11 +623,13 @@ namespace spot
assert(i->first != NULL);
n = i->second;
}
///////////////////////////////
seen_map::const_iterator sm = seen_->find(s);
if (sm == seen_->end())
{
// this state is visited for the first time.
std::cout << "first time" << std::endl;
seen_->insert(std::pair<const spot::state*, int>(s, 1));
i = si_.find(s);
assert(i->first != 0);
......@@ -675,19 +637,27 @@ namespace spot
return false;
}
else
// This state is already visited.
{
// This state is already visited.
std::cout << "second time" << std::endl;
return true;
}
bool ret = true;
spot::state* s2;
tgba_succ_iterator* j = this->succ_iter(s);
int nb_succ = 0;
for (j->first(); !j->done(); j->next())
{
std::cout << "successor " << nb_succ++ << std::endl;
s2 = j->current_state();
acc_ |= j->current_acceptance_conditions();
ret &= this->is_terminal(j->current_state(), n);
ret &= this->is_terminal(s2, n);
delete s2;
}
delete j;
// First call of is_terminal //
if (b)
{
delete seen_;
......@@ -695,6 +665,7 @@ namespace spot
if (acc_ == this->all_acceptance_conditions())
ret = false;
}
///////////////////////////////
return ret;
}
......@@ -704,6 +675,8 @@ namespace spot
{
// To remove a scc, we remove all his state.
std::cout << "remove_scc" << std::endl;
seen_map::iterator sm = si_.find(s);
sm = si_.find(s);
int n = sm->second;
......@@ -748,6 +721,62 @@ namespace spot
}
}
bool
tgba_reduc::is_alpha_ball(const spot::state* s, bdd label, int n)
{
/// FIXME
// a SCC is alpha ball if she's terminal but with some acceptance
// condition, and all transition have the same label.
// So we replace this SCC by a single state.
bool b = false;
seen_map::const_iterator i;
if ((n == -1) &&
(label == bddfalse))
{
acc_ == bddfalse;
b = true;
assert(seen_ == NULL);
seen_ = new seen_map();
i = si_.find(s);
assert(i->first != NULL);
n = i->second;
}
seen_map::const_iterator sm = seen_->find(s);
if (sm == seen_->end())
{
seen_->insert(std::pair<const spot::state*, int>(s, 1));
i = si_.find(s);
assert(i->first != 0);
if (n != i->second)
return false;
}
else
{
return true;
}
bool ret = true;
tgba_succ_iterator* j = this->succ_iter(s);
for (j->first(); !j->done(); j->next())
{
acc_ |= j->current_acceptance_conditions();
ret &= this->is_terminal(j->current_state(), n);
}
if (b)
{
delete seen_;
seen_ = NULL;
if (acc_ == this->all_acceptance_conditions())
ret = false;
}
return ret;
}
//////// JUST FOR DEBUG //////////
void
......
......@@ -139,6 +139,7 @@ namespace spot
/// }
/// \endverbatim
bool is_alpha_ball(const spot::state* s,
bdd label = bddfalse,
int n = -1);
// Return true if we can't reach a state with
......
......@@ -33,7 +33,6 @@ namespace spot
{
num_ = num;
sc_ = new state_couple(d_node, s_node);
//lnode_succ = new Sgi::vector<spoiler_node*>;
lnode_succ = new sn_v;
lnode_pred = new sn_v;
this->not_win = false;
......@@ -48,33 +47,48 @@ namespace spot
delete sc_;
}
void
bool
spoiler_node::add_succ(spoiler_node* n)
{
/*
bool exist = false;
for (sn_v::iterator i = lnode_succ->begin();
i != lnode_succ->end();)
if (*i == n)
exist = true;
if (exist)
return false;
*/
lnode_succ->push_back(n);
return true;
}
void
spoiler_node::del_succ(spoiler_node* n)
{
//std::cout << "del_succ : begin" << std::endl;
for (sn_v::iterator i = lnode_succ->begin();
i != lnode_succ->end();)
{