c++11: introduce tgba::succ(s) to replace tgba::succ_iter(s).
| tgba_succ_iterator* i = aut->succ_iter(s);
| for (i->begin(); !i->done(); i->next())
| {
| // ...
| }
| delete i;
becomes
| for (auto i: aut->succ(s))
| {
| // ...
| }
hiding the begin()/done()/next() interface, taking care of the delete,
and allowing more optimization to come.
* src/tgba/succiter.hh, src/tgba/tgba.hh: Implement the above
new interface.
* iface/gspn/ssp.cc, src/dstarparse/nsa2tgba.cc,
src/saba/sabacomplementtgba.cc, src/tgba/tgbakvcomplement.cc,
src/tgba/tgbamask.cc, src/tgba/tgbasafracomplement.cc,
src/tgba/tgbatba.cc, src/tgbaalgos/compsusp.cc, src/tgbaalgos/cutscc.cc,
src/tgbaalgos/degen.cc, src/tgbaalgos/emptiness.cc,
src/tgbaalgos/isdet.cc, src/tgbaalgos/ltl2tgba_fm.cc,
src/tgbaalgos/minimize.cc, src/tgbaalgos/powerset.cc,
src/tgbaalgos/safety.cc, src/tgbaalgos/simulation.cc,
src/tgbaalgos/tau03.cc, src/tgbatest/explicit2.cc: Update for
loops.
This commit is contained in:
parent
f59773e3c7
commit
487cd01d9f
21 changed files with 418 additions and 522 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -277,8 +277,7 @@ namespace spot
|
|||
const state* rs = p.second;
|
||||
int src = seen[p];
|
||||
|
||||
tgba_succ_iterator* li = left->succ_iter(ls);
|
||||
for (li->first(); !li->done(); li->next())
|
||||
for (auto li: left->succ(ls))
|
||||
{
|
||||
state_pair d(li->current_state(), ris);
|
||||
bdd lc = li->current_condition();
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ namespace spot
|
|||
{
|
||||
cur = tovisit.front();
|
||||
tovisit.pop();
|
||||
tgba_succ_iterator* sit = a->succ_iter(cur);
|
||||
for (sit->first(); !sit->done(); sit->next())
|
||||
for (auto sit: a->succ(cur))
|
||||
{
|
||||
cur_format = a->format_state(cur);
|
||||
state* dst = sit->current_state();
|
||||
|
|
@ -78,7 +77,6 @@ namespace spot
|
|||
dst->destroy();
|
||||
}
|
||||
}
|
||||
delete sit;
|
||||
}
|
||||
return sub_a;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,8 +88,7 @@ namespace spot
|
|||
unsigned s1 = sm_ ? sm_->scc_of_state(s) : 0;
|
||||
bdd common = a_->all_acceptance_conditions();
|
||||
bdd union_ = bddfalse;
|
||||
tgba_succ_iterator* it = a_->succ_iter(s);
|
||||
for (it->first(); !it->done(); it->next())
|
||||
for (auto it: a_->succ(s))
|
||||
{
|
||||
// Ignore transitions that leave the SCC of s.
|
||||
const state* d = it->current_state();
|
||||
|
|
@ -102,7 +101,6 @@ namespace spot
|
|||
common &= set;
|
||||
union_ |= set;
|
||||
}
|
||||
delete it;
|
||||
cache_entry e(common, union_);
|
||||
return cache_.insert(std::make_pair(s, e)).first;
|
||||
}
|
||||
|
|
@ -150,8 +148,7 @@ namespace spot
|
|||
if (p.second)
|
||||
{
|
||||
bdd all = a_->all_acceptance_conditions();
|
||||
tgba_succ_iterator* it = a_->succ_iter(s);
|
||||
for (it->first(); !it->done(); it->next())
|
||||
for (auto it: a_->succ(s))
|
||||
{
|
||||
// Look only for transitions that are accepting.
|
||||
if (all != it->current_acceptance_conditions())
|
||||
|
|
@ -164,7 +161,6 @@ namespace spot
|
|||
break;
|
||||
}
|
||||
}
|
||||
delete it;
|
||||
}
|
||||
return p.first->second;
|
||||
}
|
||||
|
|
@ -387,8 +383,7 @@ namespace spot
|
|||
if (use_scc)
|
||||
s_scc = m.scc_of_state(s.first);
|
||||
|
||||
tgba_succ_iterator* i = a->succ_iter(s.first);
|
||||
for (i->first(); !i->done(); i->next())
|
||||
for (auto i: a->succ(s.first))
|
||||
{
|
||||
degen_state d(uniq(i->current_state()), 0);
|
||||
|
||||
|
|
@ -576,7 +571,6 @@ namespace spot
|
|||
t->condition |= i->current_condition();
|
||||
}
|
||||
}
|
||||
delete i;
|
||||
tr_cache.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2009, 2011, 2012, 2013 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2009, 2011, 2012, 2013, 2014 Laboratoire de Recherche
|
||||
// et Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
|
|
@ -345,29 +345,26 @@ namespace spot
|
|||
next = l->begin()->s;
|
||||
}
|
||||
|
||||
// browse the actual outgoing transitions
|
||||
tgba_succ_iterator* j = a->succ_iter(s);
|
||||
s->destroy(); // FIXME: is it always legitimate to destroy s before j?
|
||||
for (j->first(); !j->done(); j->next())
|
||||
// browse the actual outgoing transitions and
|
||||
// look for next;
|
||||
const state* the_next = nullptr;
|
||||
for (auto j: a->succ(s))
|
||||
{
|
||||
if (j->current_condition() != label
|
||||
|| j->current_acceptance_conditions() != acc)
|
||||
continue;
|
||||
|
||||
const state* s2 = j->current_state();
|
||||
if (s2->compare(next) != 0)
|
||||
if (s2->compare(next) == 0)
|
||||
{
|
||||
s2->destroy();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = s2;
|
||||
break;
|
||||
}
|
||||
the_next = s2;
|
||||
break;
|
||||
}
|
||||
s2->destroy();
|
||||
}
|
||||
assert(!j->done());
|
||||
delete j;
|
||||
assert(res);
|
||||
s->destroy();
|
||||
s = the_next;
|
||||
|
||||
state_map::const_iterator its = seen.find(next);
|
||||
if (its == seen.end())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -44,10 +44,9 @@ namespace spot
|
|||
const state* src = todo.front();
|
||||
todo.pop_front();
|
||||
|
||||
tgba_succ_iterator* i = aut->succ_iter(src);
|
||||
bool nondeterministic = false;
|
||||
bdd available = bddtrue;
|
||||
for (i->first(); !i->done(); i->next())
|
||||
for (auto i: aut->succ(src))
|
||||
{
|
||||
// If we know the state is nondeterministic, just skip the
|
||||
// test for the remaining transitions. But don't break
|
||||
|
|
@ -67,7 +66,6 @@ namespace spot
|
|||
else
|
||||
dst->destroy();
|
||||
}
|
||||
delete i;
|
||||
res += nondeterministic;
|
||||
if (!count && nondeterministic)
|
||||
break;
|
||||
|
|
@ -110,9 +108,8 @@ namespace spot
|
|||
const state* src = todo.front();
|
||||
todo.pop_front();
|
||||
|
||||
tgba_succ_iterator* i = aut->succ_iter(src);
|
||||
bdd available = bddtrue;
|
||||
for (i->first(); !i->done(); i->next())
|
||||
for (auto i: aut->succ(src))
|
||||
{
|
||||
available -= i->current_condition();
|
||||
const state* dst = i->current_state();
|
||||
|
|
@ -121,7 +118,6 @@ namespace spot
|
|||
else
|
||||
dst->destroy();
|
||||
}
|
||||
delete i;
|
||||
if (available != bddfalse)
|
||||
{
|
||||
complete = false;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Laboratoire
|
||||
// de Recherche et Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2003, 2004, 2005, 2006 Laboratoire
|
||||
// d'Informatique de Paris 6 (LIP6), département Systèmes Répartis
|
||||
// Coopératifs (SRC), Université Pierre et Marie Curie.
|
||||
|
|
@ -152,8 +152,8 @@ namespace spot
|
|||
~translate_dict()
|
||||
{
|
||||
fv_map::iterator i;
|
||||
for (i = next_map.begin(); i != next_map.end(); ++i)
|
||||
i->first->destroy();
|
||||
for (auto& i: next_map)
|
||||
i.first->destroy();
|
||||
dict->unregister_all_my_variables(this);
|
||||
|
||||
flagged_formula_to_bdd_map::iterator j = ltl_bdd_.begin();
|
||||
|
|
@ -306,10 +306,10 @@ namespace spot
|
|||
{
|
||||
fv_map::const_iterator fi;
|
||||
os << "Next Variables:" << std::endl;
|
||||
for (fi = next_map.begin(); fi != next_map.end(); ++fi)
|
||||
for (auto& fi: next_map)
|
||||
{
|
||||
os << " " << fi->second << ": Next[";
|
||||
to_string(fi->first, os) << "]" << std::endl;
|
||||
os << " " << fi.second << ": Next[";
|
||||
to_string(fi.first, os) << "]" << std::endl;
|
||||
}
|
||||
os << "Shared Dict:" << std::endl;
|
||||
dict->dump(os);
|
||||
|
|
@ -1005,9 +1005,8 @@ namespace spot
|
|||
|
||||
ratexp_to_dfa::~ratexp_to_dfa()
|
||||
{
|
||||
std::vector<tgba_explicit_formula*>::const_iterator it;
|
||||
for (it = automata_.begin(); it != automata_.end(); ++it)
|
||||
delete *it;
|
||||
for (auto i: automata_)
|
||||
delete i;
|
||||
}
|
||||
|
||||
tgba_explicit_formula*
|
||||
|
|
@ -1087,13 +1086,12 @@ namespace spot
|
|||
// SCC are numbered in topological order
|
||||
for (unsigned n = 0; n < scc_count; ++n)
|
||||
{
|
||||
bool coacc = false;
|
||||
const std::list<const state*>& st = sm->states_of(n);
|
||||
// The SCC is coaccessible if any of its states
|
||||
// is final (i.e., it accepts [*0])...
|
||||
std::list<const state*>::const_iterator it;
|
||||
for (it = st.begin(); it != st.end(); ++it)
|
||||
if (a->get_label(*it)->accepts_eword())
|
||||
bool coacc = false;
|
||||
const std::list<const state*>& st = sm->states_of(n);
|
||||
for (auto l: st)
|
||||
if (a->get_label(l)->accepts_eword())
|
||||
{
|
||||
coacc = true;
|
||||
break;
|
||||
|
|
@ -1101,10 +1099,8 @@ namespace spot
|
|||
if (!coacc)
|
||||
{
|
||||
// ... or if any of its successors is coaccessible.
|
||||
const scc_map::succ_type& succ = sm->succ(n);
|
||||
for (scc_map::succ_type::const_iterator i = succ.begin();
|
||||
i != succ.end(); ++i)
|
||||
if (coaccessible[i->first])
|
||||
for (auto& i: sm->succ(n))
|
||||
if (coaccessible[i.first])
|
||||
{
|
||||
coacc = true;
|
||||
break;
|
||||
|
|
@ -1113,13 +1109,13 @@ namespace spot
|
|||
if (!coacc)
|
||||
{
|
||||
// Mark all formulas of this SCC as useless.
|
||||
for (it = st.begin(); it != st.end(); ++it)
|
||||
f2a_[a->get_label(*it)] = 0;
|
||||
for (auto f: st)
|
||||
f2a_[a->get_label(f)] = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (it = st.begin(); it != st.end(); ++it)
|
||||
f2a_[a->get_label(*it)] = a;
|
||||
for (auto f: st)
|
||||
f2a_[a->get_label(f)] = a;
|
||||
}
|
||||
coaccessible[n] = coacc;
|
||||
}
|
||||
|
|
@ -1136,6 +1132,7 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: use the new tgba::succ() interface
|
||||
tgba_succ_iterator*
|
||||
ratexp_to_dfa::succ(const formula* f)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,26 +93,24 @@ namespace spot
|
|||
tovisit.push(init);
|
||||
seen->insert(init);
|
||||
while (!tovisit.empty())
|
||||
{
|
||||
const state* src = tovisit.front();
|
||||
tovisit.pop();
|
||||
|
||||
tgba_succ_iterator* sit = a->succ_iter(src);
|
||||
for (sit->first(); !sit->done(); sit->next())
|
||||
{
|
||||
const state* dst = sit->current_state();
|
||||
// Is it a new state ?
|
||||
if (seen->find(dst) == seen->end())
|
||||
const state* src = tovisit.front();
|
||||
tovisit.pop();
|
||||
|
||||
for (auto sit: a->succ(src))
|
||||
{
|
||||
// Register the successor for later processing.
|
||||
tovisit.push(dst);
|
||||
seen->insert(dst);
|
||||
const state* dst = sit->current_state();
|
||||
// Is it a new state ?
|
||||
if (seen->find(dst) == seen->end())
|
||||
{
|
||||
// Register the successor for later processing.
|
||||
tovisit.push(dst);
|
||||
seen->insert(dst);
|
||||
}
|
||||
else
|
||||
dst->destroy();
|
||||
}
|
||||
else
|
||||
dst->destroy();
|
||||
}
|
||||
delete sit;
|
||||
}
|
||||
}
|
||||
|
||||
// From the base automaton and the list of sets, build the minimal
|
||||
|
|
@ -128,13 +126,13 @@ namespace spot
|
|||
std::list<hash_set*>::iterator sit;
|
||||
unsigned num = 0;
|
||||
for (sit = sets.begin(); sit != sets.end(); ++sit)
|
||||
{
|
||||
hash_set::iterator hit;
|
||||
hash_set* h = *sit;
|
||||
for (hit = h->begin(); hit != h->end(); ++hit)
|
||||
state_num[*hit] = num;
|
||||
++num;
|
||||
}
|
||||
{
|
||||
hash_set::iterator hit;
|
||||
hash_set* h = *sit;
|
||||
for (hit = h->begin(); hit != h->end(); ++hit)
|
||||
state_num[*hit] = num;
|
||||
++num;
|
||||
}
|
||||
typedef state_explicit_number::transition trs;
|
||||
sba_explicit_number* res = new sba_explicit_number(a->get_dict());
|
||||
// For each transition in the initial automaton, add the corresponding
|
||||
|
|
@ -142,31 +140,29 @@ namespace spot
|
|||
if (!final->empty())
|
||||
res->declare_acceptance_condition(ltl::constant::true_instance());
|
||||
for (sit = sets.begin(); sit != sets.end(); ++sit)
|
||||
{
|
||||
hash_set::iterator hit;
|
||||
hash_set* h = *sit;
|
||||
{
|
||||
hash_set::iterator hit;
|
||||
hash_set* h = *sit;
|
||||
|
||||
// Pick one state.
|
||||
const state* src = *h->begin();
|
||||
unsigned src_num = state_num[src];
|
||||
bool accepting = (final->find(src) != final->end());
|
||||
// Pick one state.
|
||||
const state* src = *h->begin();
|
||||
unsigned src_num = state_num[src];
|
||||
bool accepting = (final->find(src) != final->end());
|
||||
|
||||
// Connect it to all destinations.
|
||||
tgba_succ_iterator* succit = a->succ_iter(src);
|
||||
for (succit->first(); !succit->done(); succit->next())
|
||||
{
|
||||
const state* dst = succit->current_state();
|
||||
hash_map::const_iterator i = state_num.find(dst);
|
||||
dst->destroy();
|
||||
if (i == state_num.end()) // Ignore useless destinations.
|
||||
continue;
|
||||
trs* t = res->create_transition(src_num, i->second);
|
||||
res->add_conditions(t, succit->current_condition());
|
||||
if (accepting)
|
||||
res->add_acceptance_condition(t, ltl::constant::true_instance());
|
||||
}
|
||||
delete succit;
|
||||
}
|
||||
// Connect it to all destinations.
|
||||
for (auto succit: a->succ(src))
|
||||
{
|
||||
const state* dst = succit->current_state();
|
||||
hash_map::const_iterator i = state_num.find(dst);
|
||||
dst->destroy();
|
||||
if (i == state_num.end()) // Ignore useless destinations.
|
||||
continue;
|
||||
trs* t = res->create_transition(src_num, i->second);
|
||||
res->add_conditions(t, succit->current_condition());
|
||||
if (accepting)
|
||||
res->add_acceptance_condition(t, ltl::constant::true_instance());
|
||||
}
|
||||
}
|
||||
res->merge_transitions();
|
||||
const state* init_state = a->get_init_state();
|
||||
unsigned init_num = state_num[init_state];
|
||||
|
|
@ -362,8 +358,7 @@ namespace spot
|
|||
{
|
||||
const state* src = *hi;
|
||||
bdd f = bddfalse;
|
||||
tgba_succ_iterator* si = det_a->succ_iter(src);
|
||||
for (si->first(); !si->done(); si->next())
|
||||
for (auto si: det_a->succ(src))
|
||||
{
|
||||
const state* dst = si->current_state();
|
||||
hash_map::const_iterator i = state_set_map.find(dst);
|
||||
|
|
@ -378,7 +373,6 @@ namespace spot
|
|||
continue;
|
||||
f |= (bdd_ithvar(i->second) & si->current_condition());
|
||||
}
|
||||
delete si;
|
||||
|
||||
// Have we already seen this formula ?
|
||||
bdd_states_map::iterator bsi = bdd_map.find(f);
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ namespace spot
|
|||
bdd all_vars = bddtrue;
|
||||
power_state::const_iterator i;
|
||||
|
||||
for (i = src.begin(); i != src.end(); ++i)
|
||||
all_vars &= aut->support_variables(*i);
|
||||
for (auto s: src)
|
||||
all_vars &= aut->support_variables(s);
|
||||
|
||||
// Compute all possible combinations of these variables.
|
||||
bdd all_conds = bddtrue;
|
||||
|
|
@ -84,17 +84,10 @@ namespace spot
|
|||
|
||||
// Construct the set of all states reachable via COND.
|
||||
power_state dest;
|
||||
for (i = src.begin(); i != src.end(); ++i)
|
||||
{
|
||||
tgba_succ_iterator *si = aut->succ_iter(*i);
|
||||
for (si->first(); !si->done(); si->next())
|
||||
if ((cond >> si->current_condition()) == bddtrue)
|
||||
{
|
||||
const state* s = pm.canonicalize(si->current_state());
|
||||
dest.insert(s);
|
||||
}
|
||||
delete si;
|
||||
}
|
||||
for (auto s: src)
|
||||
for (auto si: aut->succ(s))
|
||||
if ((cond >> si->current_condition()) == bddtrue)
|
||||
dest.insert(pm.canonicalize(si->current_state()));
|
||||
if (dest.empty())
|
||||
continue;
|
||||
// Add that transition.
|
||||
|
|
@ -177,10 +170,8 @@ namespace spot
|
|||
// }
|
||||
|
||||
bdd acc = aut_->all_acceptance_conditions();
|
||||
for (trans_set::iterator i = all_.begin(); i != all_.end(); ++i)
|
||||
{
|
||||
(*i)->acceptance_conditions = acc;
|
||||
}
|
||||
for (auto i: all_)
|
||||
i->acceptance_conditions = acc;
|
||||
return threshold_ != 0 && cycles_left_ == 0;
|
||||
}
|
||||
|
||||
|
|
@ -213,17 +204,13 @@ namespace spot
|
|||
// start of the loop in the determinized automaton.
|
||||
const power_map::power_state& ps =
|
||||
refmap_.states_of(a->get_label(begin->ts->first));
|
||||
for (power_map::power_state::const_iterator it = ps.begin();
|
||||
it != ps.end() && !accepting; ++it)
|
||||
for (auto s: ps)
|
||||
{
|
||||
// Construct a product between
|
||||
// LOOP_A, and ORIG_A starting in *IT.
|
||||
|
||||
tgba* p = new tgba_product_init(&loop_a, ref_,
|
||||
loop_a_init, *it);
|
||||
// LOOP_A, and ORIG_A starting in S.
|
||||
tgba* p = new tgba_product_init(&loop_a, ref_, loop_a_init, s);
|
||||
|
||||
//spot::dotty_reachable(std::cout, p);
|
||||
|
||||
couvreur99_check* ec = down_cast<couvreur99_check*>(couvreur99(p));
|
||||
assert(ec);
|
||||
emptiness_check_result* res = ec->check();
|
||||
|
|
@ -232,6 +219,8 @@ namespace spot
|
|||
delete res;
|
||||
delete ec;
|
||||
delete p;
|
||||
if (accepting)
|
||||
break;
|
||||
}
|
||||
|
||||
loop_a_init->destroy();
|
||||
|
|
@ -242,8 +231,8 @@ namespace spot
|
|||
print_set(std::ostream& o, const trans_set& s) const
|
||||
{
|
||||
o << "{ ";
|
||||
for (trans_set::const_iterator i = s.begin(); i != s.end(); ++i)
|
||||
o << *i << " ";
|
||||
for (auto i: s)
|
||||
o << i << " ";
|
||||
o << "}";
|
||||
return o;
|
||||
}
|
||||
|
|
@ -272,15 +261,11 @@ namespace spot
|
|||
}
|
||||
else
|
||||
{
|
||||
for (trans_set::const_iterator i = ts.begin(); i != ts.end(); ++i)
|
||||
for (auto t: ts)
|
||||
{
|
||||
trans* t = *i;
|
||||
reject_.insert(t);
|
||||
for (set_set::iterator j = accept_.begin();
|
||||
j != accept_.end(); ++j)
|
||||
{
|
||||
j->erase(t);
|
||||
}
|
||||
for (auto& j: accept_)
|
||||
j.erase(t);
|
||||
all_.erase(t);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ namespace spot
|
|||
const state* s = todo.front();
|
||||
todo.pop_front();
|
||||
|
||||
tgba_succ_iterator* it = aut->succ_iter(s);
|
||||
for (it->first(); !it->done(); it->next())
|
||||
for (auto it: aut->succ(s))
|
||||
{
|
||||
bdd acc = it->current_acceptance_conditions();
|
||||
if (acc != all_acc)
|
||||
|
|
@ -97,7 +96,6 @@ namespace spot
|
|||
if (const state* d = seen.is_new(it->current_state()))
|
||||
todo.push_back(d);
|
||||
}
|
||||
delete it;
|
||||
}
|
||||
return all_accepting;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -156,12 +156,10 @@ namespace spot
|
|||
void add_to_map(const std::list<constraint>& list,
|
||||
map_constraint& feed_me)
|
||||
{
|
||||
for (std::list<constraint>::const_iterator it = list.begin();
|
||||
it != list.end();
|
||||
++it)
|
||||
for (auto& p: list)
|
||||
{
|
||||
if (feed_me.find(it->first) == feed_me.end())
|
||||
feed_me[it->first] = it->second;
|
||||
if (feed_me.find(p.first) == feed_me.end())
|
||||
feed_me[p.first] = p.second;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -434,13 +432,8 @@ namespace spot
|
|||
// We fetch the result the run of acc_compl_automaton which
|
||||
// has recorded all the state in a hash table, and we set all
|
||||
// to init.
|
||||
for (map_state_bdd::iterator it
|
||||
= acc_compl.previous_class_.begin();
|
||||
it != acc_compl.previous_class_.end();
|
||||
++it)
|
||||
{
|
||||
previous_class_[it->first] = init;
|
||||
}
|
||||
for (auto& p: acc_compl.previous_class_)
|
||||
previous_class_[p.first] = init;
|
||||
|
||||
// Put all the anonymous variable in a queue, and record all
|
||||
// of these in a variable all_class_var_ which will be used
|
||||
|
|
@ -481,26 +474,21 @@ namespace spot
|
|||
|
||||
// We run through the map bdd/list<state>, and we update
|
||||
// the previous_class_ with the new data.
|
||||
for (map_bdd_lstate::iterator it = bdd_lstate_.begin();
|
||||
it != bdd_lstate_.end();
|
||||
++it)
|
||||
for (auto& p: bdd_lstate_)
|
||||
{
|
||||
for (std::list<const state*>::iterator it_s = it->second.begin();
|
||||
it_s != it->second.end();
|
||||
++it_s)
|
||||
{
|
||||
// If the signature of a state is bddfalse (no
|
||||
// transitions) the class of this state is bddfalse
|
||||
// instead of an anonymous variable. It allows
|
||||
// simplifications in the signature by removing a
|
||||
// transition which has as a destination a state with
|
||||
// no outgoing transition.
|
||||
if (it->first == bddfalse)
|
||||
previous_class_[*it_s] = bddfalse;
|
||||
else
|
||||
previous_class_[*it_s] = *it_bdd;
|
||||
}
|
||||
++it_bdd;
|
||||
// If the signature of a state is bddfalse (no
|
||||
// transitions) the class of this state is bddfalse
|
||||
// instead of an anonymous variable. It allows
|
||||
// simplifications in the signature by removing a
|
||||
// transition which has as a destination a state with
|
||||
// no outgoing transition.
|
||||
if (p.first == bddfalse)
|
||||
for (auto s: p.second)
|
||||
previous_class_[s] = bddfalse;
|
||||
else
|
||||
for (auto s: p.second)
|
||||
previous_class_[s] = *it_bdd;
|
||||
++it_bdd;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -533,10 +521,9 @@ namespace spot
|
|||
// Take a state and compute its signature.
|
||||
bdd compute_sig(const state* src)
|
||||
{
|
||||
tgba_succ_iterator* sit = a_->succ_iter(src);
|
||||
bdd res = bddfalse;
|
||||
|
||||
for (sit->first(); !sit->done(); sit->next())
|
||||
for (auto sit: a_->succ(src))
|
||||
{
|
||||
const state* dst = sit->current_state();
|
||||
bdd acc = bddtrue;
|
||||
|
|
@ -574,7 +561,6 @@ namespace spot
|
|||
if (Cosimulation && initial_state == src)
|
||||
res |= bdd_initial;
|
||||
|
||||
delete sit;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -585,12 +571,9 @@ namespace spot
|
|||
// all the reachable states of this automaton. We do not
|
||||
// have to make (again) a traversal. We just have to run
|
||||
// through this map.
|
||||
for (std::list<const state*>::const_iterator it = order_.begin();
|
||||
it != order_.end();
|
||||
++it)
|
||||
for (auto s: order_)
|
||||
{
|
||||
const state* src = previous_class_.find(*it)->first;
|
||||
|
||||
const state* src = previous_class_.find(s)->first;
|
||||
bdd_lstate_[compute_sig(src)].push_back(src);
|
||||
}
|
||||
}
|
||||
|
|
@ -636,22 +619,17 @@ namespace spot
|
|||
|
||||
std::list<bdd>::iterator it_bdd = used_var_.begin();
|
||||
|
||||
for (map_bdd_lstate::iterator it = bdd_lstate_.begin();
|
||||
it != bdd_lstate_.end();
|
||||
++it)
|
||||
for (auto& p: bdd_lstate_)
|
||||
{
|
||||
// If the signature of a state is bddfalse (which is
|
||||
// roughly equivalent to no transition) the class of
|
||||
// this state is bddfalse instead of an anonymous
|
||||
// variable. It allows simplifications in the signature
|
||||
// by removing a transition which has as a destination a
|
||||
// state with no outgoing transition.
|
||||
if (it->first == bddfalse)
|
||||
now_to_next[it->first] = bddfalse;
|
||||
else
|
||||
now_to_next[it->first] = *it_bdd;
|
||||
|
||||
++it_bdd;
|
||||
// If the signature of a state is bddfalse (no
|
||||
// transitions) the class of this state is bddfalse
|
||||
// instead of an anonymous variable. It allows
|
||||
// simplifications in the signature by removing a
|
||||
// transition which has as a destination a state with
|
||||
// no outgoing transition.
|
||||
now_to_next[p.first] =
|
||||
(p.first == bddfalse) ? bddfalse : *it_bdd;
|
||||
++it_bdd;
|
||||
}
|
||||
|
||||
update_po(now_to_next, relation_);
|
||||
|
|
@ -745,11 +723,10 @@ namespace spot
|
|||
bdd nonapvars = sup_all_acc & bdd_support(all_class_var_);
|
||||
|
||||
// Create one state per partition.
|
||||
for (map_bdd_lstate::iterator it = bdd_lstate_.begin();
|
||||
it != bdd_lstate_.end(); ++it)
|
||||
for (auto& p: bdd_lstate_)
|
||||
{
|
||||
res->add_state(++current_max);
|
||||
bdd part = previous_class_[*it->second.begin()];
|
||||
bdd part = previous_class_[*p.second.begin()];
|
||||
|
||||
// The difference between the two next lines is:
|
||||
// the first says "if you see A", the second "if you
|
||||
|
|
@ -771,12 +748,10 @@ namespace spot
|
|||
|
||||
// For each partition, we will create
|
||||
// all the transitions between the states.
|
||||
for (map_bdd_lstate::iterator it = bdd_lstate_.begin();
|
||||
it != bdd_lstate_.end();
|
||||
++it)
|
||||
for (auto& p: bdd_lstate_)
|
||||
{
|
||||
// Get the signature.
|
||||
bdd sig = compute_sig(*(it->second.begin()));
|
||||
bdd sig = compute_sig(*(p.second.begin()));
|
||||
|
||||
if (Cosimulation)
|
||||
sig = bdd_compose(sig, bddfalse, bdd_var(bdd_initial));
|
||||
|
|
@ -840,7 +815,7 @@ namespace spot
|
|||
// know the source, we must take a random state in
|
||||
// the list which is in the class we currently
|
||||
// work on.
|
||||
int src = bdd2state[previous_class_[*it->second.begin()]];
|
||||
int src = bdd2state[previous_class_[*p.second.begin()]];
|
||||
int dst = bdd2state[dest];
|
||||
|
||||
if (Cosimulation)
|
||||
|
|
@ -875,15 +850,13 @@ namespace spot
|
|||
for (unsigned snum = current_max; snum > 0; --snum)
|
||||
{
|
||||
const state* s = res->get_state(snum);
|
||||
tgba_succ_iterator* it = res->succ_iter(s);
|
||||
bdd acc = accst[snum];
|
||||
for (it->first(); !it->done(); it->next())
|
||||
for (auto it: res->succ(s))
|
||||
{
|
||||
tgba_explicit_number::transition* t =
|
||||
res->get_transition(it);
|
||||
t->acceptance_conditions = acc;
|
||||
}
|
||||
delete it;
|
||||
}
|
||||
|
||||
res_is_deterministic = nb_minato == nb_satoneset;
|
||||
|
|
@ -899,33 +872,23 @@ namespace spot
|
|||
// where is the new class name.
|
||||
void print_partition()
|
||||
{
|
||||
for (map_bdd_lstate::iterator it = bdd_lstate_.begin();
|
||||
it != bdd_lstate_.end();
|
||||
++it)
|
||||
for (auto& p: bdd_lstate_)
|
||||
{
|
||||
std::cerr << "partition: "
|
||||
<< bdd_format_isop(a_->get_dict(), it->first)
|
||||
<< bdd_format_isop(a_->get_dict(), p.first)
|
||||
<< std::endl;
|
||||
|
||||
for (std::list<const state*>::iterator it_s = it->second.begin();
|
||||
it_s != it->second.end();
|
||||
++it_s)
|
||||
{
|
||||
std::cerr << " - "
|
||||
<< a_->format_state(*it_s) << std::endl;
|
||||
}
|
||||
for (auto s: p.second)
|
||||
std::cerr << " - " << a_->format_state(s) << '\n';
|
||||
}
|
||||
|
||||
std::cerr << "\nPrevious iteration\n" << std::endl;
|
||||
|
||||
for (map_state_bdd::const_iterator it = previous_class_.begin();
|
||||
it != previous_class_.end();
|
||||
++it)
|
||||
for (auto p: previous_class_)
|
||||
{
|
||||
std::cerr << a_->format_state(it->first)
|
||||
std::cerr << a_->format_state(p.first)
|
||||
<< " was in "
|
||||
<< bdd_format_set(a_->get_dict(), it->second)
|
||||
<< std::endl;
|
||||
<< bdd_format_set(a_->get_dict(), p.second)
|
||||
<< '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1039,13 +1002,12 @@ namespace spot
|
|||
// signature later.
|
||||
bdd dont_care_compute_sig(const state* src)
|
||||
{
|
||||
tgba_succ_iterator* sit = a_->succ_iter(src);
|
||||
bdd res = bddfalse;
|
||||
|
||||
unsigned scc = scc_map_->scc_of_state(old_name_[src]);
|
||||
bool sccacc = scc_map_->accepting(scc);
|
||||
|
||||
for (sit->first(); !sit->done(); sit->next())
|
||||
for (auto sit: a_->succ(src))
|
||||
{
|
||||
const state* dst = sit->current_state();
|
||||
bdd cl = previous_class_[dst];
|
||||
|
|
@ -1061,8 +1023,6 @@ namespace spot
|
|||
bdd to_add = acc & sit->current_condition() & relation_[cl];
|
||||
res |= to_add;
|
||||
}
|
||||
|
||||
delete sit;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1315,22 +1275,15 @@ namespace spot
|
|||
}
|
||||
|
||||
// Iterate over the transitions of both states.
|
||||
for (map_bdd_bdd::const_iterator lit = sigl_map.begin();
|
||||
lit != sigl_map.end(); ++lit)
|
||||
for (map_bdd_bdd::iterator rit = sigr_map.begin();
|
||||
rit != sigr_map.end(); ++rit)
|
||||
{
|
||||
// And create constraints if any of the transitions
|
||||
// is out of the SCC and the left could imply the right.
|
||||
if ((is_out_scc(lit->second) || is_out_scc(rit->second))
|
||||
&& (bdd_exist(lit->first, on_cycle_) ==
|
||||
bdd_exist(rit->first, on_cycle_)))
|
||||
{
|
||||
create_simple_constraint(lit->second, rit->second,
|
||||
left, right, res);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto lp: sigl_map)
|
||||
for (auto rp: sigr_map)
|
||||
// And create constraints if any of the transitions
|
||||
// is out of the SCC and the left could imply the right.
|
||||
if ((is_out_scc(lp.second) || is_out_scc(rp.second))
|
||||
&& (bdd_exist(lp.first, on_cycle_) ==
|
||||
bdd_exist(rp.first, on_cycle_)))
|
||||
create_simple_constraint(lp.second, rp.second,
|
||||
left, right, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1358,11 +1311,9 @@ namespace spot
|
|||
bdd_lstate_.clear();
|
||||
|
||||
// Compute the don't care signature for all the states.
|
||||
for (std::list<const state*>::const_iterator my_it = order_.begin();
|
||||
my_it != order_.end();
|
||||
++my_it)
|
||||
for (auto s: order_)
|
||||
{
|
||||
map_state_bdd::iterator it = previous_class_.find(*my_it);
|
||||
map_state_bdd::iterator it = previous_class_.find(s);
|
||||
const state* src = it->first;
|
||||
|
||||
bdd sig = dont_care_compute_sig(src);
|
||||
|
|
@ -1384,12 +1335,8 @@ namespace spot
|
|||
|
||||
constraint_list cc;
|
||||
|
||||
for (map_bdd_bdd::iterator it = relation.begin();
|
||||
it != relation.end();
|
||||
++it)
|
||||
{
|
||||
revert_relation_[it->second] = class2state[it->first];
|
||||
}
|
||||
for (auto p: relation)
|
||||
revert_relation_[p.second] = class2state[p.first];
|
||||
|
||||
int number_constraints = 0;
|
||||
relation_ = relation;
|
||||
|
|
@ -1397,11 +1344,9 @@ namespace spot
|
|||
|
||||
// order_ is here for the determinism. Here we make the diff
|
||||
// between the two tables: imply and could_imply.
|
||||
for (std::list<const state*>::const_iterator my_it = order_.begin();
|
||||
my_it != order_.end();
|
||||
++my_it)
|
||||
for (auto s: order_)
|
||||
{
|
||||
map_state_bdd::iterator it = previous_class_.find(*my_it);
|
||||
map_state_bdd::iterator it = previous_class_.find(s);
|
||||
assert(relation.find(it->second) != relation.end());
|
||||
assert(dont_care_relation.find(it->second)
|
||||
!= dont_care_relation.end());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2011, 2013 Laboratoire de Recherche et Developpement de
|
||||
// l'Epita (LRDE).
|
||||
// Copyright (C) 2011, 2013, 2014 Laboratoire de Recherche et
|
||||
// Developpement de l'Epita (LRDE).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
|
|
@ -189,8 +189,7 @@ namespace spot
|
|||
<< std::endl;
|
||||
typename heap::color_ref c = h.get_color_ref(f.s);
|
||||
assert(!c.is_white());
|
||||
tgba_succ_iterator* i = a_->succ_iter(f.s);
|
||||
for (i->first(); !i->done(); i->next())
|
||||
for (auto i: a_->succ(f.s))
|
||||
{
|
||||
inc_transitions();
|
||||
const state *s_prime = i->current_state();
|
||||
|
|
@ -211,7 +210,6 @@ namespace spot
|
|||
dfs_red(acu);
|
||||
}
|
||||
}
|
||||
delete i;
|
||||
if (c.get_acc() == all_cond)
|
||||
{
|
||||
trace << "DFS_BLUE propagation is successful, report a"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue