sanity: Replace tabulars by spaces in *.cc *.hh *.hxx

* bin/autfilt.cc, bin/common_aoutput.cc, bin/common_aoutput.hh,
bin/common_finput.cc, bin/common_finput.hh, bin/common_hoaread.cc,
bin/common_output.cc, bin/common_output.hh, bin/common_post.cc,
bin/common_post.hh, bin/common_r.hh, bin/common_range.cc,
bin/common_range.hh, bin/common_setup.cc, bin/common_trans.cc,
bin/common_trans.hh, bin/dstar2tgba.cc, bin/genltl.cc,
bin/ltl2tgba.cc, bin/ltl2tgta.cc, bin/ltlcross.cc, bin/ltldo.cc,
bin/ltlfilt.cc, bin/ltlgrind.cc, bin/randaut.cc, bin/randltl.cc,
bin/spot-x.cc, spot/graph/graph.hh, spot/graph/ngraph.hh,
spot/kripke/kripkegraph.hh, spot/ltsmin/ltsmin.cc,
spot/ltsmin/ltsmin.hh, spot/misc/bareword.cc, spot/misc/bitvect.cc,
spot/misc/bitvect.hh, spot/misc/common.hh, spot/misc/escape.cc,
spot/misc/fixpool.hh, spot/misc/formater.cc, spot/misc/hash.hh,
spot/misc/intvcmp2.cc, spot/misc/intvcmp2.hh, spot/misc/intvcomp.cc,
spot/misc/intvcomp.hh, spot/misc/location.hh, spot/misc/minato.cc,
spot/misc/minato.hh, spot/misc/mspool.hh, spot/misc/optionmap.cc,
spot/misc/optionmap.hh, spot/misc/random.cc, spot/misc/random.hh,
spot/misc/satsolver.cc, spot/misc/satsolver.hh, spot/misc/timer.cc,
spot/misc/timer.hh, spot/misc/tmpfile.cc, spot/misc/trival.hh,
spot/parseaut/fmterror.cc, spot/parseaut/parsedecl.hh,
spot/parseaut/public.hh, spot/parsetl/fmterror.cc,
spot/parsetl/parsedecl.hh, spot/priv/accmap.hh, spot/priv/bddalloc.cc,
spot/priv/freelist.cc, spot/priv/trim.cc, spot/priv/weight.cc,
spot/priv/weight.hh, spot/ta/taexplicit.cc, spot/ta/taexplicit.hh,
spot/ta/taproduct.cc, spot/ta/taproduct.hh, spot/ta/tgtaexplicit.cc,
spot/ta/tgtaexplicit.hh, spot/ta/tgtaproduct.cc,
spot/ta/tgtaproduct.hh, spot/taalgos/dot.cc, spot/taalgos/dot.hh,
spot/taalgos/emptinessta.cc, spot/taalgos/emptinessta.hh,
spot/taalgos/minimize.cc, spot/taalgos/tgba2ta.cc,
spot/taalgos/tgba2ta.hh, spot/tl/apcollect.cc, spot/tl/contain.cc,
spot/tl/contain.hh, spot/tl/dot.cc, spot/tl/exclusive.cc,
spot/tl/exclusive.hh, spot/tl/formula.cc, spot/tl/formula.hh,
spot/tl/length.cc, spot/tl/mark.cc, spot/tl/mutation.cc,
spot/tl/mutation.hh, spot/tl/parse.hh, spot/tl/print.cc,
spot/tl/print.hh, spot/tl/randomltl.cc, spot/tl/randomltl.hh,
spot/tl/relabel.cc, spot/tl/relabel.hh, spot/tl/remove_x.cc,
spot/tl/simplify.cc, spot/tl/simplify.hh, spot/tl/snf.cc,
spot/tl/snf.hh, spot/tl/unabbrev.cc, spot/tl/unabbrev.hh,
spot/twa/acc.cc, spot/twa/acc.hh, spot/twa/bdddict.cc,
spot/twa/bdddict.hh, spot/twa/bddprint.cc, spot/twa/formula2bdd.cc,
spot/twa/formula2bdd.hh, spot/twa/taatgba.cc, spot/twa/taatgba.hh,
spot/twa/twa.cc, spot/twa/twa.hh, spot/twa/twagraph.cc,
spot/twa/twagraph.hh, spot/twa/twaproduct.cc, spot/twa/twaproduct.hh,
spot/twaalgos/are_isomorphic.cc, spot/twaalgos/are_isomorphic.hh,
spot/twaalgos/bfssteps.cc, spot/twaalgos/bfssteps.hh,
spot/twaalgos/cleanacc.cc, spot/twaalgos/complete.cc,
spot/twaalgos/compsusp.cc, spot/twaalgos/compsusp.hh,
spot/twaalgos/copy.cc, spot/twaalgos/cycles.cc,
spot/twaalgos/cycles.hh, spot/twaalgos/degen.cc,
spot/twaalgos/degen.hh, spot/twaalgos/determinize.cc,
spot/twaalgos/determinize.hh, spot/twaalgos/dot.cc,
spot/twaalgos/dot.hh, spot/twaalgos/dtbasat.cc,
spot/twaalgos/dtbasat.hh, spot/twaalgos/dtwasat.cc,
spot/twaalgos/dtwasat.hh, spot/twaalgos/emptiness.cc,
spot/twaalgos/emptiness.hh, spot/twaalgos/emptiness_stats.hh,
spot/twaalgos/gtec/ce.cc, spot/twaalgos/gtec/ce.hh,
spot/twaalgos/gtec/gtec.cc, spot/twaalgos/gtec/gtec.hh,
spot/twaalgos/gtec/sccstack.cc, spot/twaalgos/gtec/status.cc,
spot/twaalgos/gv04.cc, spot/twaalgos/hoa.cc, spot/twaalgos/hoa.hh,
spot/twaalgos/isdet.cc, spot/twaalgos/isunamb.cc,
spot/twaalgos/isweakscc.cc, spot/twaalgos/lbtt.cc,
spot/twaalgos/lbtt.hh, spot/twaalgos/ltl2taa.cc,
spot/twaalgos/ltl2taa.hh, spot/twaalgos/ltl2tgba_fm.cc,
spot/twaalgos/ltl2tgba_fm.hh, spot/twaalgos/magic.cc,
spot/twaalgos/magic.hh, spot/twaalgos/mask.cc, spot/twaalgos/mask.hh,
spot/twaalgos/minimize.cc, spot/twaalgos/minimize.hh,
spot/twaalgos/ndfs_result.hxx, spot/twaalgos/neverclaim.cc,
spot/twaalgos/neverclaim.hh, spot/twaalgos/postproc.cc,
spot/twaalgos/postproc.hh, spot/twaalgos/powerset.cc,
spot/twaalgos/powerset.hh, spot/twaalgos/product.cc,
spot/twaalgos/product.hh, spot/twaalgos/projrun.cc,
spot/twaalgos/projrun.hh, spot/twaalgos/randomgraph.cc,
spot/twaalgos/randomgraph.hh, spot/twaalgos/randomize.cc,
spot/twaalgos/randomize.hh, spot/twaalgos/reachiter.cc,
spot/twaalgos/reachiter.hh, spot/twaalgos/relabel.cc,
spot/twaalgos/relabel.hh, spot/twaalgos/remfin.cc,
spot/twaalgos/remprop.cc, spot/twaalgos/sbacc.cc,
spot/twaalgos/sccfilter.cc, spot/twaalgos/sccfilter.hh,
spot/twaalgos/sccinfo.cc, spot/twaalgos/sccinfo.hh,
spot/twaalgos/se05.cc, spot/twaalgos/se05.hh,
spot/twaalgos/sepsets.cc, spot/twaalgos/simulation.cc,
spot/twaalgos/simulation.hh, spot/twaalgos/stats.cc,
spot/twaalgos/stats.hh, spot/twaalgos/strength.cc,
spot/twaalgos/strength.hh, spot/twaalgos/stripacc.cc,
spot/twaalgos/stutter.cc, spot/twaalgos/stutter.hh,
spot/twaalgos/tau03.cc, spot/twaalgos/tau03opt.cc,
spot/twaalgos/tau03opt.hh, spot/twaalgos/totgba.cc,
spot/twaalgos/translate.cc, spot/twaalgos/word.cc, tests/core/acc.cc,
tests/core/bitvect.cc, tests/core/checkpsl.cc, tests/core/checkta.cc,
tests/core/consterm.cc, tests/core/emptchk.cc, tests/core/equalsf.cc,
tests/core/graph.cc, tests/core/ikwiad.cc, tests/core/intvcmp2.cc,
tests/core/intvcomp.cc, tests/core/kind.cc, tests/core/kripkecat.cc,
tests/core/ltlrel.cc, tests/core/ngraph.cc, tests/core/randtgba.cc,
tests/core/readltl.cc, tests/core/reduc.cc, tests/core/safra.cc,
tests/core/syntimpl.cc, tests/ltsmin/modelcheck.cc: Replace tabulars by
8 spaces.
* tests/sanity/style.test: Add checks for no tabulars in *.cc *.hh *.hxx
This commit is contained in:
Laurent XU 2016-03-09 00:23:20 +01:00 committed by Alexandre Duret-Lutz
parent 1eee12b8b4
commit f7e7b4f14e
239 changed files with 25359 additions and 25355 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -50,21 +50,21 @@ namespace spot
// a hash; but we should ensure that no object in the hash is
// constructed with p==0.
anon_free_list(bdd_dict_priv* p = nullptr)
: priv_(p)
: priv_(p)
{
}
virtual int
extend(int n) override
{
assert(priv_);
int b = priv_->allocate_variables(n);
free_anonymous_list_of_type::iterator i;
for (i = priv_->free_anonymous_list_of.begin();
i != priv_->free_anonymous_list_of.end(); ++i)
if (&i->second != this)
i->second.insert(b, n);
return b;
assert(priv_);
int b = priv_->allocate_variables(n);
free_anonymous_list_of_type::iterator i;
for (i = priv_->free_anonymous_list_of.begin();
i != priv_->free_anonymous_list_of.end(); ++i)
if (&i->second != this)
i->second.insert(b, n);
return b;
}
private:
@ -102,15 +102,15 @@ namespace spot
fv_map::iterator sii = var_map.find(f);
if (sii != var_map.end())
{
num = sii->second;
num = sii->second;
}
else
{
num = priv_->allocate_variables(1);
var_map[f] = num;
bdd_map.resize(bdd_varnum());
bdd_map[num].type = var;
bdd_map[num].f = f;
num = priv_->allocate_variables(1);
var_map[f] = num;
bdd_map.resize(bdd_varnum());
bdd_map[num].type = var;
bdd_map[num].f = f;
}
bdd_map[num].refs.insert(for_me);
return num;
@ -118,7 +118,7 @@ namespace spot
int
bdd_dict::has_registered_proposition(formula f,
const void* me)
const void* me)
{
auto ssi = var_map.find(f);
if (ssi == var_map.end())
@ -132,24 +132,24 @@ namespace spot
int
bdd_dict::register_acceptance_variable(formula f,
const void* for_me)
const void* for_me)
{
int num;
// Do not build an acceptance variable that already exists.
fv_map::iterator sii = acc_map.find(f);
if (sii != acc_map.end())
{
num = sii->second;
num = sii->second;
}
else
{
num = priv_->allocate_variables(1);
acc_map[f] = num;
bdd_map.resize(bdd_varnum());
bdd_info& i = bdd_map[num];
i.type = acc;
i.f = f;
i.clone_counts = 0;
num = priv_->allocate_variables(1);
acc_map[f] = num;
bdd_map.resize(bdd_varnum());
bdd_info& i = bdd_map[num];
i.type = acc;
i.f = f;
i.clone_counts = 0;
}
bdd_map[num].refs.insert(for_me);
return num;
@ -163,9 +163,9 @@ namespace spot
if (i == priv_->free_anonymous_list_of.end())
{
i = (priv_->free_anonymous_list_of.insert
(fal::value_type(for_me,
priv_->free_anonymous_list_of[nullptr]))).first;
i = (priv_->free_anonymous_list_of.insert
(fal::value_type(for_me,
priv_->free_anonymous_list_of[nullptr]))).first;
}
int res = i->second.register_n(n);
@ -173,8 +173,8 @@ namespace spot
while (n--)
{
bdd_map[res + n].type = anon;
bdd_map[res + n].refs.insert(for_me);
bdd_map[res + n].type = anon;
bdd_map[res + n].refs.insert(for_me);
}
return res;
@ -183,7 +183,7 @@ namespace spot
void
bdd_dict::register_all_variables_of(const void* from_other,
const void* for_me)
const void* for_me)
{
auto j = priv_->free_anonymous_list_of.find(from_other);
if (j != priv_->free_anonymous_list_of.end())
@ -191,24 +191,24 @@ namespace spot
for (auto& i: bdd_map)
{
ref_set& s = i.refs;
if (s.find(from_other) != s.end())
s.insert(for_me);
ref_set& s = i.refs;
if (s.find(from_other) != s.end())
s.insert(for_me);
}
}
void
bdd_dict::register_all_propositions_of(const void* from_other,
const void* for_me)
const void* for_me)
{
for (auto& i: bdd_map)
{
if (i.type != var_type::var)
continue;
ref_set& s = i.refs;
if (s.find(from_other) != s.end())
s.insert(for_me);
if (i.type != var_type::var)
continue;
ref_set& s = i.refs;
if (s.find(from_other) != s.end())
s.insert(for_me);
}
}
@ -241,24 +241,24 @@ namespace spot
switch (bdd_map[v].type)
{
case var:
f = bdd_map[v].f;
var_map.erase(f);
break;
f = bdd_map[v].f;
var_map.erase(f);
break;
case acc:
f = bdd_map[v].f;
acc_map.erase(f);
break;
f = bdd_map[v].f;
acc_map.erase(f);
break;
case anon:
{
bdd_dict_priv::free_anonymous_list_of_type::iterator i;
// Nobody use this variable as an anonymous variable
// anymore, so remove it entirely from the anonymous
// free list so it can be used for something else.
for (i = priv_->free_anonymous_list_of.begin();
i != priv_->free_anonymous_list_of.end(); ++i)
i->second.remove(v, n);
break;
}
{
bdd_dict_priv::free_anonymous_list_of_type::iterator i;
// Nobody use this variable as an anonymous variable
// anymore, so remove it entirely from the anonymous
// free list so it can be used for something else.
for (i = priv_->free_anonymous_list_of.begin();
i != priv_->free_anonymous_list_of.end(); ++i)
i->second.remove(v, n);
break;
}
}
// Actually release the associated BDD variables, and the
// formula itself.
@ -283,39 +283,39 @@ namespace spot
unsigned s = bdd_map.size();
for (unsigned i = 0; i < s; ++i)
{
os << ' ' << i << ' ';
const bdd_info& r = bdd_map[i];
switch (r.type)
{
case anon:
os << (r.refs.empty() ? "Free" : "Anon");
break;
case acc:
os << "Acc[";
print_psl(os, r.f) << ']';
break;
case var:
os << "Var[";
print_psl(os, r.f) << ']';
break;
}
if (!r.refs.empty())
{
os << " x" << r.refs.size() << " {";
for (ref_set::const_iterator si = r.refs.begin();
si != r.refs.end(); ++si)
os << ' ' << *si;
os << " }";
}
os << '\n';
os << ' ' << i << ' ';
const bdd_info& r = bdd_map[i];
switch (r.type)
{
case anon:
os << (r.refs.empty() ? "Free" : "Anon");
break;
case acc:
os << "Acc[";
print_psl(os, r.f) << ']';
break;
case var:
os << "Var[";
print_psl(os, r.f) << ']';
break;
}
if (!r.refs.empty())
{
os << " x" << r.refs.size() << " {";
for (ref_set::const_iterator si = r.refs.begin();
si != r.refs.end(); ++si)
os << ' ' << *si;
os << " }";
}
os << '\n';
}
os << "Anonymous lists:\n";
bdd_dict_priv::free_anonymous_list_of_type::const_iterator ai;
for (ai = priv_->free_anonymous_list_of.begin();
ai != priv_->free_anonymous_list_of.end(); ++ai)
ai != priv_->free_anonymous_list_of.end(); ++ai)
{
os << " [" << ai->first << "] ";
ai->second.dump_free_list(os) << std::endl;
os << " [" << ai->first << "] ";
ai->second.dump_free_list(os) << std::endl;
}
os << "Free list:\n";
priv_->dump_free_list(os);
@ -334,42 +334,42 @@ namespace spot
unsigned s = bdd_map.size();
for (unsigned i = 0; i < s; ++i)
{
switch (bdd_map[i].type)
{
case var:
var_seen = true;
break;
case acc:
acc_seen = true;
break;
case anon:
break;
}
refs_seen |= !bdd_map[i].refs.empty();
switch (bdd_map[i].type)
{
case var:
var_seen = true;
break;
case acc:
acc_seen = true;
break;
case anon:
break;
}
refs_seen |= !bdd_map[i].refs.empty();
}
if (var_map.empty() && acc_map.empty())
{
if (var_seen)
{
std::cerr << "var_map is empty but Var in map" << std::endl;
fail = true;
}
if (acc_seen)
{
std::cerr << "acc_map is empty but Acc in map" << std::endl;
fail = true;
}
if (refs_seen)
{
std::cerr << "maps are empty but var_refs is not" << std::endl;
fail = true;
}
if (!fail)
return;
if (var_seen)
{
std::cerr << "var_map is empty but Var in map" << std::endl;
fail = true;
}
if (acc_seen)
{
std::cerr << "acc_map is empty but Acc in map" << std::endl;
fail = true;
}
if (refs_seen)
{
std::cerr << "maps are empty but var_refs is not" << std::endl;
fail = true;
}
if (!fail)
return;
}
else
{
std::cerr << "some maps are not empty" << std::endl;
std::cerr << "some maps are not empty" << std::endl;
}
dump(std::cerr);
abort();

View file

@ -70,8 +70,8 @@ namespace spot
/// BDD-variable-to-formula maps.
typedef std::map<int, formula> vf_map;
fv_map var_map; ///< Maps atomic propositions to BDD variables
fv_map acc_map; ///< Maps acceptance conditions to BDD variables
fv_map var_map; ///< Maps atomic propositions to BDD variables
fv_map acc_map; ///< Maps acceptance conditions to BDD variables
/// BDD-variable reference counts.
typedef std::set<const void*> ref_set;
@ -80,7 +80,7 @@ namespace spot
struct bdd_info {
bdd_info() : type(anon) {}
var_type type;
formula f; // Used unless t==anon.
formula f; // Used unless t==anon.
ref_set refs;
int clone_counts;
};
@ -180,21 +180,21 @@ namespace spot
template <typename T>
void register_all_variables_of(const void* from_other,
std::shared_ptr<T> for_me)
std::shared_ptr<T> for_me)
{
register_all_variables_of(from_other, for_me.get());
}
template <typename T>
void register_all_variables_of(std::shared_ptr<T> from_other,
const void* for_me)
const void* for_me)
{
register_all_variables_of(from_other.get(), for_me);
}
template <typename T, typename U>
void register_all_variables_of(std::shared_ptr<T> from_other,
std::shared_ptr<U> for_me)
std::shared_ptr<U> for_me)
{
register_all_variables_of(from_other.get(), for_me.get());
}
@ -209,25 +209,25 @@ namespace spot
/// is still alive.
/// @{
void register_all_propositions_of(const void* from_other,
const void* for_me);
const void* for_me);
template <typename T>
void register_all_propositions_of(const void* from_other,
std::shared_ptr<T> for_me)
std::shared_ptr<T> for_me)
{
register_all_propositions_of(from_other, for_me.get());
}
template <typename T>
void register_all_propositions_of(std::shared_ptr<T> from_other,
const void* for_me)
const void* for_me)
{
register_all_propositions_of(from_other.get(), for_me);
}
template <typename T, typename U>
void register_all_propositions_of(std::shared_ptr<T> from_other,
std::shared_ptr<U> for_me)
std::shared_ptr<U> for_me)
{
register_all_propositions_of(from_other.get(), for_me.get());
}

View file

@ -58,22 +58,22 @@ namespace spot
switch (ref.type)
{
case bdd_dict::var:
print_(o, ref.f);
break;
print_(o, ref.f);
break;
case bdd_dict::acc:
if (want_acc)
{
o << "Acc[";
print_(o, ref.f) << ']';
}
else
{
o << '"';
print_(o, ref.f) << '"';
}
break;
if (want_acc)
{
o << "Acc[";
print_(o, ref.f) << ']';
}
else
{
o << '"';
print_(o, ref.f) << '"';
}
break;
case bdd_dict::anon:
o << '?' << v;
o << '?' << v;
}
}
@ -85,15 +85,15 @@ namespace spot
bool not_first = false;
for (int v = 0; v < size; ++v)
{
if (varset[v] < 0)
continue;
if (not_first)
*where << ' ';
else
not_first = true;
if (varset[v] == 0)
*where << "! ";
print_handler(*where, v);
if (varset[v] < 0)
continue;
if (not_first)
*where << ' ';
else
not_first = true;
if (varset[v] == 0)
*where << "! ";
print_handler(*where, v);
}
}
@ -114,11 +114,11 @@ namespace spot
{
for (int v = 0; v < size; ++v)
if (varset[v] > 0)
{
*where << (first_done ? ", " : "{");
print_handler(*where, v);
first_done = true;
}
{
*where << (first_done ? ", " : "{");
print_handler(*where, v);
first_done = true;
}
}
std::ostream&

View file

@ -33,30 +33,30 @@ namespace spot
conj_to_formula(bdd b, const bdd_dict_ptr d)
{
if (b == bddfalse)
return formula::ff();
return formula::ff();
std::vector<formula> v;
while (b != bddtrue)
{
int var = bdd_var(b);
const bdd_dict::bdd_info& i = d->bdd_map[var];
assert(i.type == bdd_dict::var);
formula res = i.f;
{
int var = bdd_var(b);
const bdd_dict::bdd_info& i = d->bdd_map[var];
assert(i.type == bdd_dict::var);
formula res = i.f;
bdd high = bdd_high(b);
if (high == bddfalse)
{
res = formula::Not(res);
b = bdd_low(b);
}
else
{
// If bdd_low is not false, then b was not a conjunction.
assert(bdd_low(b) == bddfalse);
b = high;
}
assert(b != bddfalse);
v.push_back(res);
}
bdd high = bdd_high(b);
if (high == bddfalse)
{
res = formula::Not(res);
b = bdd_low(b);
}
else
{
// If bdd_low is not false, then b was not a conjunction.
assert(bdd_low(b) == bddfalse);
b = high;
}
assert(b != bddfalse);
v.push_back(res);
}
return formula::And(v);
}
} // anonymous
@ -66,14 +66,14 @@ namespace spot
{
auto recurse = [&d, owner](formula f)
{
return formula_to_bdd(f, d, owner);
return formula_to_bdd(f, d, owner);
};
switch (f.kind())
{
case op::ff:
return bddfalse;
return bddfalse;
case op::tt:
return bddtrue;
return bddtrue;
case op::eword:
case op::Star:
case op::FStar:
@ -95,32 +95,32 @@ namespace spot
case op::AndNLM:
case op::OrRat:
case op::AndRat:
SPOT_UNIMPLEMENTED();
SPOT_UNIMPLEMENTED();
case op::ap:
return bdd_ithvar(d->register_proposition(f, owner));
return bdd_ithvar(d->register_proposition(f, owner));
case op::Not:
return bdd_not(recurse(f[0]));
return bdd_not(recurse(f[0]));
case op::Xor:
return bdd_apply(recurse(f[0]), recurse(f[1]), bddop_xor);
return bdd_apply(recurse(f[0]), recurse(f[1]), bddop_xor);
case op::Implies:
return bdd_apply(recurse(f[0]), recurse(f[1]), bddop_imp);
return bdd_apply(recurse(f[0]), recurse(f[1]), bddop_imp);
case op::Equiv:
return bdd_apply(recurse(f[0]), recurse(f[1]), bddop_biimp);
return bdd_apply(recurse(f[0]), recurse(f[1]), bddop_biimp);
case op::And:
case op::Or:
{
int o = bddop_and;
bdd res = bddtrue;
if (f.is(op::Or))
{
o = bddop_or;
res = bddfalse;
}
unsigned s = f.size();
for (unsigned n = 0; n < s; ++n)
res = bdd_apply(res, recurse(f[n]), o);
return res;
}
{
int o = bddop_and;
bdd res = bddtrue;
if (f.is(op::Or))
{
o = bddop_or;
res = bddfalse;
}
unsigned s = f.size();
for (unsigned n = 0; n < s; ++n)
res = bdd_apply(res, recurse(f[n]), o);
return res;
}
}
SPOT_UNREACHABLE();
return bddfalse;

View file

@ -44,7 +44,7 @@ namespace spot
template<typename T>
SPOT_API bdd
formula_to_bdd(formula f, const bdd_dict_ptr& d,
const std::shared_ptr<T>& for_me)
const std::shared_ptr<T>& for_me)
{
return formula_to_bdd(f, d, for_me.get());
}

View file

@ -94,7 +94,7 @@ namespace spot
{
int i = *it1++ - *it2++;
if (i != 0)
return i;
return i;
}
return 0;
}
@ -162,14 +162,14 @@ namespace spot
unsigned p;
for (p = 0; p < pos.size() && t->condition != bddfalse; ++p)
{
taa_tgba::state_set::const_iterator j;
for (j = (*pos[p])->dst->begin(); j != (*pos[p])->dst->end(); ++j)
if ((*j)->size() > 0) // Remove sink states.
ss->insert(*j);
taa_tgba::state_set::const_iterator j;
for (j = (*pos[p])->dst->begin(); j != (*pos[p])->dst->end(); ++j)
if ((*j)->size() > 0) // Remove sink states.
ss->insert(*j);
// Fill the new transition.
t->condition &= (*pos[p])->condition;
t->acceptance_conditions |= (*pos[p])->acceptance_conditions;
// Fill the new transition.
t->condition &= (*pos[p])->condition;
t->acceptance_conditions |= (*pos[p])->acceptance_conditions;
} // If p != pos.size() we have found a contradiction
assert(p > 0);
t->dst = ss;
@ -182,54 +182,54 @@ namespace spot
std::vector<taa_tgba::transition*>::iterator j;
if (t->condition != bddfalse)
{
i = seen_.find(b);
if (i != seen_.end())
for (j = i->second.begin(); j != i->second.end(); ++j)
{
taa_tgba::transition* current = *j;
if (*current->dst == *t->dst
&& current->condition == t->condition)
{
current->acceptance_conditions &= t->acceptance_conditions;
break;
}
if (*current->dst == *t->dst
&& current->acceptance_conditions == t->acceptance_conditions)
{
current->condition |= t->condition;
break;
}
}
i = seen_.find(b);
if (i != seen_.end())
for (j = i->second.begin(); j != i->second.end(); ++j)
{
taa_tgba::transition* current = *j;
if (*current->dst == *t->dst
&& current->condition == t->condition)
{
current->acceptance_conditions &= t->acceptance_conditions;
break;
}
if (*current->dst == *t->dst
&& current->acceptance_conditions == t->acceptance_conditions)
{
current->condition |= t->condition;
break;
}
}
}
// Mark the new transition as seen and keep it if we have not
// found any contradiction and no other transition to merge
// with, or delete it otherwise.
if (t->condition != bddfalse
&& (i == seen_.end() || j == i->second.end()))
&& (i == seen_.end() || j == i->second.end()))
{
seen_[b].push_back(t);
if (i != seen_.end())
delete b;
succ_.push_back(t);
seen_[b].push_back(t);
if (i != seen_.end())
delete b;
succ_.push_back(t);
}
else
{
delete t->dst;
delete t;
delete b;
delete t->dst;
delete t;
delete b;
}
for (int i = pos.size() - 1; i >= 0; --i)
{
if ((i < int(p))
&& (std::distance(pos[i], bounds[i].second) > 1
|| (i == 0 && std::distance(pos[i], bounds[i].second) == 1)))
{
++pos[i];
break;
}
else
pos[i] = bounds[i].first;
if ((i < int(p))
&& (std::distance(pos[i], bounds[i].second) > 1
|| (i == 0 && std::distance(pos[i], bounds[i].second) == 1)))
{
++pos[i];
break;
}
else
pos[i] = bounds[i].first;
}
}
}

View file

@ -88,7 +88,7 @@ namespace spot
virtual ~set_state()
{
if (delete_me_)
delete s_;
delete s_;
}
const taa_tgba::state_set* get_state() const;
@ -118,18 +118,18 @@ namespace spot
typedef std::pair<iterator, iterator> iterator_pair;
typedef std::vector<iterator_pair> bounds_t;
typedef std::unordered_map<const spot::set_state*,
std::vector<taa_tgba::transition*>,
state_ptr_hash, state_ptr_equal> seen_map;
std::vector<taa_tgba::transition*>,
state_ptr_hash, state_ptr_equal> seen_map;
struct distance_sort :
public std::binary_function<const iterator_pair&,
const iterator_pair&, bool>
const iterator_pair&, bool>
{
bool
operator()(const iterator_pair& lhs, const iterator_pair& rhs) const
{
return std::distance(lhs.first, lhs.second) <
std::distance(rhs.first, rhs.second);
return std::distance(lhs.first, lhs.second) <
std::distance(rhs.first, rhs.second);
}
};
@ -150,11 +150,11 @@ namespace spot
~taa_tgba_labelled()
{
for (auto i: name_state_map_)
{
for (auto i2: *i.second)
delete i2;
delete i.second;
}
{
for (auto i2: *i.second)
delete i2;
delete i.second;
}
}
void set_init_state(const label& s)
@ -170,7 +170,7 @@ namespace spot
transition*
create_transition(const label& s,
const std::vector<label>& d)
const std::vector<label>& d)
{
state* src = add_state(s);
state_set* dst = add_state_set(d);
@ -194,7 +194,7 @@ namespace spot
{
auto p = acc_map_.emplace(f, 0);
if (p.second)
p.first->second = acc_cond::mark_t({acc().add_set()});
p.first->second = acc_cond::mark_t({acc().add_set()});
t->acceptance_conditions |= p.first->second;
}
@ -220,14 +220,14 @@ namespace spot
typename ns_map::const_iterator i;
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
{
taa_tgba::state::const_iterator i2;
os << "State: " << label_to_string(i->first) << std::endl;
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
{
os << ' ' << format_state_set((*i2)->dst)
<< ", C:" << (*i2)->condition
<< ", A:" << (*i2)->acceptance_conditions << std::endl;
}
taa_tgba::state::const_iterator i2;
os << "State: " << label_to_string(i->first) << std::endl;
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
{
os << ' ' << format_state_set((*i2)->dst)
<< ", C:" << (*i2)->condition
<< ", A:" << (*i2)->acceptance_conditions << std::endl;
}
}
}
@ -236,7 +236,7 @@ namespace spot
typedef std::unordered_map<label, taa_tgba::state*> ns_map;
typedef std::unordered_map<const taa_tgba::state*, label,
ptr_hash<taa_tgba::state> > sn_map;
ptr_hash<taa_tgba::state> > sn_map;
ns_map name_state_map_;
sn_map state_name_map_;
@ -252,10 +252,10 @@ namespace spot
typename ns_map::iterator i = name_state_map_.find(name);
if (i == name_state_map_.end())
{
taa_tgba::state* s = new taa_tgba::state;
name_state_map_[name] = s;
state_name_map_[s] = name;
return s;
taa_tgba::state* s = new taa_tgba::state;
name_state_map_[name] = s;
state_name_map_[s] = name;
return s;
}
return i->second;
}
@ -265,7 +265,7 @@ namespace spot
{
state_set* ss = new state_set;
for (unsigned i = 0; i < names.size(); ++i)
ss->insert(add_state(names[i]));
ss->insert(add_state(names[i]));
state_set_vec_.push_back(ss);
return ss;
}
@ -275,25 +275,25 @@ namespace spot
state_set::const_iterator i1 = ss->begin();
typename sn_map::const_iterator i2;
if (ss->empty())
return std::string("{}");
return std::string("{}");
if (ss->size() == 1)
{
i2 = state_name_map_.find(*i1);
assert(i2 != state_name_map_.end());
return "{" + label_to_string(i2->second) + "}";
i2 = state_name_map_.find(*i1);
assert(i2 != state_name_map_.end());
return "{" + label_to_string(i2->second) + "}";
}
else
{
std::string res("{");
while (i1 != ss->end())
{
i2 = state_name_map_.find(*i1++);
assert(i2 != state_name_map_.end());
res += label_to_string(i2->second);
res += ",";
}
res[res.size() - 1] = '}';
return res;
std::string res("{");
while (i1 != ss->end())
{
i2 = state_name_map_.find(*i1++);
assert(i2 != state_name_map_.end());
res += label_to_string(i2->second);
res += ",";
}
res[res.size() - 1] = '}';
return res;
}
}
};

View file

@ -45,7 +45,7 @@ namespace spot
state*
twa::project_state(const state* s,
const const_twa_ptr& t) const
const const_twa_ptr& t) const
{
if (t.get() == this)
return s->clone();
@ -61,25 +61,25 @@ namespace spot
auto a = shared_from_this();
if (a->acc().uses_fin_acceptance())
{
auto aa = std::dynamic_pointer_cast<const twa_graph>(a);
if (!aa)
aa = make_twa_graph(a, prop_set::all());
a = remove_fin(aa);
auto aa = std::dynamic_pointer_cast<const twa_graph>(a);
if (!aa)
aa = make_twa_graph(a, prop_set::all());
a = remove_fin(aa);
}
return !couvreur99(a)->check();
}
void
twa::set_named_prop(std::string s,
void* val, std::function<void(void*)> destructor)
void* val, std::function<void(void*)> destructor)
{
auto p = named_prop_.emplace(std::piecewise_construct,
std::forward_as_tuple(s),
std::forward_as_tuple(val, destructor));
std::forward_as_tuple(s),
std::forward_as_tuple(val, destructor));
if (!p.second)
{
p.first->second.second(p.first->second.first);
p.first->second = std::make_pair(val, destructor);
p.first->second.second(p.first->second.first);
p.first->second = std::make_pair(val, destructor);
}
}

View file

@ -180,14 +180,14 @@ namespace spot
///
/// \see state_unicity_table
typedef std::unordered_set<const state*,
state_ptr_hash, state_ptr_equal> state_set;
state_ptr_hash, state_ptr_equal> state_set;
/// \brief Unordered map of abstract states
///
/// Destroying each state if needed is the user's responsibility.
template<class val>
using state_map = std::unordered_map<const state*, val,
state_ptr_hash, state_ptr_equal>;
state_ptr_hash, state_ptr_equal>;
/// \ingroup twa_essentials
/// \brief Render state pointers unique via a hash table.
@ -208,7 +208,7 @@ namespace spot
{
auto p = m.insert(s);
if (!p.second)
s->destroy();
s->destroy();
return *p.first;
}
@ -220,22 +220,22 @@ namespace spot
{
auto p = m.insert(s);
if (!p.second)
{
s->destroy();
return nullptr;
}
{
s->destroy();
return nullptr;
}
return *p.first;
}
~state_unicity_table()
{
for (state_set::iterator i = m.begin(); i != m.end();)
{
// Advance the iterator before destroying its key. This
// avoid issues with old g++ implementations.
state_set::iterator old = i++;
(*old)->destroy();
}
{
// Advance the iterator before destroying its key. This
// avoid issues with old g++ implementations.
state_set::iterator old = i++;
(*old)->destroy();
}
}
size_t
@ -336,8 +336,8 @@ namespace spot
/// Unordered set of shared states
typedef std::unordered_set<shared_state,
state_shared_ptr_hash,
state_shared_ptr_equal> shared_state_set;
state_shared_ptr_hash,
state_shared_ptr_equal> shared_state_set;
/// \ingroup twa_essentials
/// \brief Iterate over the successors of a state.
@ -483,29 +483,29 @@ namespace spot
public:
succ_iterator(twa_succ_iterator* it):
it_(it)
it_(it)
{
}
bool operator==(succ_iterator o) const
{
return it_ == o.it_;
return it_ == o.it_;
}
bool operator!=(succ_iterator o) const
{
return it_ != o.it_;
return it_ != o.it_;
}
const twa_succ_iterator* operator*() const
{
return it_;
return it_;
}
void operator++()
{
if (!it_->next())
it_ = nullptr;
if (!it_->next())
it_ = nullptr;
}
};
}
@ -597,30 +597,30 @@ namespace spot
twa_succ_iterator* it_;
public:
succ_iterable(const twa* aut, twa_succ_iterator* it)
: aut_(aut), it_(it)
: aut_(aut), it_(it)
{
}
succ_iterable(succ_iterable&& other)
: aut_(other.aut_), it_(other.it_)
: aut_(other.aut_), it_(other.it_)
{
other.it_ = nullptr;
other.it_ = nullptr;
}
~succ_iterable()
{
if (it_)
aut_->release_iter(it_);
if (it_)
aut_->release_iter(it_);
}
internal::succ_iterator begin()
{
return it_->first() ? it_ : nullptr;
return it_->first() ? it_ : nullptr;
}
internal::succ_iterator end()
{
return nullptr;
return nullptr;
}
};
#endif
@ -682,9 +682,9 @@ namespace spot
void release_iter(twa_succ_iterator* i) const
{
if (iter_cache_)
delete i;
delete i;
else
iter_cache_ = i;
iter_cache_ = i;
}
/// \brief Get the dictionary associated to the automaton.
@ -724,11 +724,11 @@ namespace spot
{
int res = dict_->has_registered_proposition(ap, this);
if (res < 0)
{
aps_.push_back(ap);
res = dict_->register_proposition(ap, this);
bddaps_ &= bdd_ithvar(res);
}
{
aps_.push_back(ap);
res = dict_->register_proposition(ap, this);
bddaps_ &= bdd_ithvar(res);
}
return res;
}
@ -773,7 +773,7 @@ namespace spot
/// or a new \c state* (the projected state) that must be
/// destroyed by the caller.
virtual state* project_state(const state* s,
const const_twa_ptr& t) const;
const const_twa_ptr& t) const;
///@{
/// \brief The acceptance condition of the automaton.
@ -797,10 +797,10 @@ namespace spot
void set_num_sets_(unsigned num)
{
if (num < acc_.num_sets())
{
acc_.~acc_cond();
new (&acc_) acc_cond;
}
{
acc_.~acc_cond();
new (&acc_) acc_cond;
}
acc_.add_sets(num - acc_.num_sets());
}
@ -826,7 +826,7 @@ namespace spot
set_num_sets_(num);
acc_.set_acceptance(c);
if (num == 0)
prop_state_acc(true);
prop_state_acc(true);
}
/// Copy the acceptance condition of another TωA.
@ -835,14 +835,14 @@ namespace spot
acc_ = a->acc();
unsigned num = acc_.num_sets();
if (num == 0)
prop_state_acc(true);
prop_state_acc(true);
}
/// Copy the atomic propositions of another TωA
void copy_ap_of(const const_twa_ptr& a)
{
for (auto f: a->ap())
this->register_ap(f);
this->register_ap(f);
}
/// \brief Set generalized Büchi acceptance
@ -862,7 +862,7 @@ namespace spot
set_num_sets_(num);
acc_.set_generalized_buchi();
if (num == 0)
prop_state_acc(true);
prop_state_acc(true);
}
/// \brief Set Büchi acceptance.
@ -895,8 +895,8 @@ namespace spot
{
trival::repr_t state_based_acc:2; // State-based acceptance.
trival::repr_t inherently_weak:2; // Inherently Weak automaton.
trival::repr_t weak:2; // Weak automaton.
trival::repr_t terminal:2; // Terminal automaton.
trival::repr_t weak:2; // Weak automaton.
trival::repr_t terminal:2; // Terminal automaton.
trival::repr_t deterministic:2; // Deterministic automaton.
trival::repr_t unambiguous:2; // Unambiguous automaton.
trival::repr_t stutter_invariant:2; // Stutter invariant language.
@ -910,8 +910,8 @@ namespace spot
#ifndef SWIG
// Dynamic properties, are given with a name and a destructor function.
std::unordered_map<std::string,
std::pair<void*,
std::function<void(void*)>>> named_prop_;
std::pair<void*,
std::function<void(void*)>>> named_prop_;
#endif
void* get_named_prop_(std::string s) const;
@ -930,7 +930,7 @@ namespace spot
/// When the automaton is destroyed, the \a destructor function will
/// be called to destroy the attached object.
void set_named_prop(std::string s,
void* val, std::function<void(void*)> destructor);
void* val, std::function<void(void*)> destructor);
/// \brief Declare a named property
///
@ -966,7 +966,7 @@ namespace spot
{
void* p = get_named_prop_(s);
if (!p)
return nullptr;
return nullptr;
return static_cast<T*>(p);
}
#endif
@ -979,7 +979,7 @@ namespace spot
{
// Destroy all named properties.
for (auto& np: named_prop_)
np.second.second(np.second.first);
np.second.second(np.second.first);
named_prop_.clear();
}
@ -1036,7 +1036,7 @@ namespace spot
{
is.inherently_weak = val.val();
if (!val)
is.terminal = is.weak = val.val();
is.terminal = is.weak = val.val();
}
/// \brief Whether the automaton is terminal.
@ -1064,7 +1064,7 @@ namespace spot
{
is.terminal = val.val();
if (val)
is.inherently_weak = is.weak = val.val();
is.inherently_weak = is.weak = val.val();
}
/// \brief Whether the automaton is weak.
@ -1091,9 +1091,9 @@ namespace spot
{
is.weak = val.val();
if (val)
is.inherently_weak = val.val();
is.inherently_weak = val.val();
if (!val)
is.terminal = val.val();
is.terminal = val.val();
}
/// \brief Whether the automaton is deterministic.
@ -1122,8 +1122,8 @@ namespace spot
{
is.deterministic = val.val();
if (val)
// deterministic implies unambiguous
is.unambiguous = val.val();
// deterministic implies unambiguous
is.unambiguous = val.val();
}
/// \brief Whether the automaton is unambiguous
@ -1154,7 +1154,7 @@ namespace spot
{
is.unambiguous = val.val();
if (!val)
is.deterministic = val.val();
is.deterministic = val.val();
}
/// \brief Whether the automaton is stutter-invariant.
@ -1215,10 +1215,10 @@ namespace spot
/// \see prop_copy
struct prop_set
{
bool state_based; ///< preserve state-based acceptnace
bool inherently_weak; ///< preserve inherently weak, weak, & terminal
bool deterministic; ///< preserve deterministic and unambiguous
bool stutter_inv; ///< preserve stutter invariance
bool state_based; ///< preserve state-based acceptnace
bool inherently_weak; ///< preserve inherently weak, weak, & terminal
bool deterministic; ///< preserve deterministic and unambiguous
bool stutter_inv; ///< preserve stutter invariance
/// \brief An all-true \c prop_set
///
@ -1237,7 +1237,7 @@ namespace spot
/// algorithm X, in case that new property is not preserved.
static prop_set all()
{
return { true, true, true, true };
return { true, true, true, true };
}
};
@ -1254,20 +1254,20 @@ namespace spot
void prop_copy(const const_twa_ptr& other, prop_set p)
{
if (p.state_based)
prop_state_acc(other->prop_state_acc());
prop_state_acc(other->prop_state_acc());
if (p.inherently_weak)
{
prop_terminal(other->prop_terminal());
prop_weak(other->prop_weak());
prop_inherently_weak(other->prop_inherently_weak());
}
{
prop_terminal(other->prop_terminal());
prop_weak(other->prop_weak());
prop_inherently_weak(other->prop_inherently_weak());
}
if (p.deterministic)
{
prop_deterministic(other->prop_deterministic());
prop_unambiguous(other->prop_unambiguous());
}
{
prop_deterministic(other->prop_deterministic());
prop_unambiguous(other->prop_unambiguous());
}
if (p.stutter_inv)
prop_stutter_invariant(other->prop_stutter_invariant());
prop_stutter_invariant(other->prop_stutter_invariant());
}
/// \brief Keep only a subset of properties of the current
@ -1278,20 +1278,20 @@ namespace spot
void prop_keep(prop_set p)
{
if (!p.state_based)
prop_state_acc(trival::maybe());
prop_state_acc(trival::maybe());
if (!p.inherently_weak)
{
prop_terminal(trival::maybe());
prop_weak(trival::maybe());
prop_inherently_weak(trival::maybe());
}
{
prop_terminal(trival::maybe());
prop_weak(trival::maybe());
prop_inherently_weak(trival::maybe());
}
if (!p.deterministic)
{
prop_deterministic(trival::maybe());
prop_unambiguous(trival::maybe());
}
{
prop_deterministic(trival::maybe());
prop_unambiguous(trival::maybe());
}
if (!p.stutter_inv)
prop_stutter_invariant(trival::maybe());
prop_stutter_invariant(trival::maybe());
}
};

View file

@ -24,21 +24,21 @@ namespace spot
{
void
twa_graph::release_formula_namer(namer<formula>* namer,
bool keep_names)
bool keep_names)
{
if (keep_names)
{
auto v = new std::vector<std::string>(num_states());
auto& n = namer->names();
unsigned ns = n.size();
assert(n.size() <= v->size());
for (unsigned i = 0; i < ns; ++i)
{
auto f = n[i];
if (f)
(*v)[i] = str_psl(f);
}
set_named_prop("state-names", v);
auto v = new std::vector<std::string>(num_states());
auto& n = namer->names();
unsigned ns = n.size();
assert(n.size() <= v->size());
for (unsigned i = 0; i < ns; ++i)
{
auto f = n[i];
if (f)
(*v)[i] = str_psl(f);
}
set_named_prop("state-names", v);
}
delete namer;
}
@ -49,19 +49,19 @@ namespace spot
typedef graph_t::edge_storage_t tr_t;
g_.sort_edges_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.acc < rhs.acc;
// Do not sort on conditions, we'll merge
// them.
});
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.acc < rhs.acc;
// Do not sort on conditions, we'll merge
// them.
});
auto& trans = this->edge_vector();
unsigned tend = trans.size();
@ -72,30 +72,30 @@ namespace spot
++in;
if (in < tend)
{
++out;
if (out != in)
trans[out] = trans[in];
for (++in; in < tend; ++in)
{
if (trans[in].cond == bddfalse) // Unusable edge
continue;
// Merge edges with the same source, destination, and
// acceptance. (We test the source last, because this is the
// most likely test to be true as edges are ordered by
// sources and then destinations.)
if (trans[out].dst == trans[in].dst
&& trans[out].acc == trans[in].acc
&& trans[out].src == trans[in].src)
{
trans[out].cond |= trans[in].cond;
}
else
{
++out;
if (in != out)
trans[out] = trans[in];
}
}
++out;
if (out != in)
trans[out] = trans[in];
for (++in; in < tend; ++in)
{
if (trans[in].cond == bddfalse) // Unusable edge
continue;
// Merge edges with the same source, destination, and
// acceptance. (We test the source last, because this is the
// most likely test to be true as edges are ordered by
// sources and then destinations.)
if (trans[out].dst == trans[in].dst
&& trans[out].acc == trans[in].acc
&& trans[out].src == trans[in].src)
{
trans[out].cond |= trans[in].cond;
}
else
{
++out;
if (in != out)
trans[out] = trans[in];
}
}
}
if (++out != tend)
trans.resize(out);
@ -109,42 +109,42 @@ namespace spot
// both as Inf and Fin)
if ((in < tend) && !acc().uses_fin_acceptance())
{
typedef graph_t::edge_storage_t tr_t;
g_.sort_edges_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.cond.id() < rhs.cond.id();
// Do not sort on acceptance, we'll merge
// them.
});
typedef graph_t::edge_storage_t tr_t;
g_.sort_edges_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.cond.id() < rhs.cond.id();
// Do not sort on acceptance, we'll merge
// them.
});
for (; in < tend; ++in)
{
// Merge edges with the same source, destination,
// and conditions. (We test the source last, for the
// same reason as above.)
if (trans[out].dst == trans[in].dst
&& trans[out].cond.id() == trans[in].cond.id()
&& trans[out].src == trans[in].src)
{
trans[out].acc |= trans[in].acc;
}
else
{
++out;
if (in != out)
trans[out] = trans[in];
}
}
if (++out != tend)
trans.resize(out);
for (; in < tend; ++in)
{
// Merge edges with the same source, destination,
// and conditions. (We test the source last, for the
// same reason as above.)
if (trans[out].dst == trans[in].dst
&& trans[out].cond.id() == trans[in].cond.id()
&& trans[out].src == trans[in].src)
{
trans[out].acc |= trans[in].acc;
}
else
{
++out;
if (in != out)
trans[out] = trans[in];
}
}
if (++out != tend)
trans.resize(out);
}
g_.chain_edges_();
@ -170,25 +170,25 @@ namespace spot
unsigned todo_pos = 1;
do
{
unsigned cur = todo[--todo_pos] & mask;
todo[todo_pos] ^= cur; // Zero the state
for (auto& t: g_.out(cur))
if (!(todo[t.dst] & seen))
{
todo[t.dst] |= seen;
todo[todo_pos++] |= t.dst;
}
unsigned cur = todo[--todo_pos] & mask;
todo[todo_pos] ^= cur; // Zero the state
for (auto& t: g_.out(cur))
if (!(todo[t.dst] & seen))
{
todo[t.dst] |= seen;
todo[todo_pos++] |= t.dst;
}
}
while (todo_pos > 0);
// Now renumber each used state.
unsigned current = 0;
for (auto& v: todo)
if (!(v & seen))
v = -1U;
v = -1U;
else
v = current++;
v = current++;
if (current == todo.size())
return; // No unreachable state.
return; // No unreachable state.
init_number_ = todo[init_number_];
defrag_states(std::move(todo), current);
}
@ -209,46 +209,46 @@ namespace spot
todo.emplace_back(init_number_, g_.state_storage(init_number_).succ);
do
{
unsigned src;
unsigned tid;
std::tie(src, tid) = todo.back();
if (tid == 0U)
{
todo.pop_back();
order.push_back(src);
continue;
}
auto& t = g_.edge_storage(tid);
todo.back().second = t.next_succ;
unsigned dst = t.dst;
if (useful[dst] != 1)
{
todo.emplace_back(dst, g_.state_storage(dst).succ);
useful[dst] = 1;
}
unsigned src;
unsigned tid;
std::tie(src, tid) = todo.back();
if (tid == 0U)
{
todo.pop_back();
order.push_back(src);
continue;
}
auto& t = g_.edge_storage(tid);
todo.back().second = t.next_succ;
unsigned dst = t.dst;
if (useful[dst] != 1)
{
todo.emplace_back(dst, g_.state_storage(dst).succ);
useful[dst] = 1;
}
}
while (!todo.empty());
// Process states in topological order
for (auto s: order)
{
auto t = g_.out_iteraser(s);
bool useless = true;
while (t)
{
// Erase any edge to a useless state.
if (!useful[t->dst])
{
t.erase();
continue;
}
// if we have a edge to a useful state, then the
// state is useful.
useless = false;
++t;
}
if (useless)
useful[s] = 0;
auto t = g_.out_iteraser(s);
bool useless = true;
while (t)
{
// Erase any edge to a useless state.
if (!useful[t->dst])
{
t.erase();
continue;
}
// if we have a edge to a useful state, then the
// state is useful.
useless = false;
++t;
}
if (useless)
useful[s] = 0;
}
// Make sure the initial state is useful (even if it has been
@ -260,30 +260,30 @@ namespace spot
unsigned current = 0;
for (unsigned s = 0; s < num_states; ++s)
if (useful[s])
useful[s] = current++;
useful[s] = current++;
else
useful[s] = -1U;
useful[s] = -1U;
if (current == num_states)
return; // No useless state.
return; // No useless state.
init_number_ = useful[init_number_];
defrag_states(std::move(useful), current);
}
void twa_graph::defrag_states(std::vector<unsigned>&& newst,
unsigned used_states)
unsigned used_states)
{
auto* names = get_named_prop<std::vector<std::string>>("state-names");
if (names)
{
unsigned size = names->size();
for (unsigned s = 0; s < size; ++s)
{
unsigned dst = newst[s];
if (dst == s || dst == -1U)
continue;
(*names)[dst] = std::move((*names)[s]);
}
names->resize(used_states);
unsigned size = names->size();
for (unsigned s = 0; s < size; ++s)
{
unsigned dst = newst[s];
if (dst == s || dst == -1U)
continue;
(*names)[dst] = std::move((*names)[s]);
}
names->resize(used_states);
}
g_.defrag_states(std::move(newst), used_states);
}

View file

@ -49,16 +49,16 @@ namespace spot
// Do not simply return "other - this", it might not fit in an int.
if (o < this)
return -1;
return -1;
if (o > this)
return 1;
return 1;
return 0;
}
virtual size_t hash() const override
{
return
reinterpret_cast<const char*>(this) - static_cast<const char*>(nullptr);
reinterpret_cast<const char*>(this) - static_cast<const char*>(nullptr);
}
virtual twa_graph_state*
@ -90,9 +90,9 @@ namespace spot
bool operator<(const twa_graph_edge_data& other) const
{
if (cond.id() < other.cond.id())
return true;
return true;
if (cond.id() > other.cond.id())
return false;
return false;
return acc < other.acc;
}
@ -178,7 +178,7 @@ namespace spot
// handle graph_t::state as an abstract type.
typedef unsigned state_num;
static_assert(std::is_same<typename graph_t::state, state_num>::value,
"type mismatch");
"type mismatch");
protected:
graph_t g_;
@ -187,7 +187,7 @@ namespace spot
public:
twa_graph(const bdd_dict_ptr& dict)
: twa(dict),
init_number_(0)
init_number_(0)
{
}
@ -195,9 +195,9 @@ namespace spot
: twa(other->get_dict()),
g_(other->g_), init_number_(other->init_number_)
{
copy_acceptance_of(other);
copy_ap_of(other);
prop_copy(other, p);
copy_acceptance_of(other);
copy_ap_of(other);
prop_copy(other, p);
}
virtual ~twa_graph()
@ -206,13 +206,13 @@ namespace spot
#ifndef SWIG
template <typename State_Name,
typename Name_Hash = std::hash<State_Name>,
typename Name_Equal = std::equal_to<State_Name>>
typename Name_Hash = std::hash<State_Name>,
typename Name_Equal = std::equal_to<State_Name>>
using namer = named_graph<graph_t, State_Name, Name_Hash, Name_Equal>;
template <typename State_Name,
typename Name_Hash = std::hash<State_Name>,
typename Name_Equal = std::equal_to<State_Name>>
typename Name_Hash = std::hash<State_Name>,
typename Name_Equal = std::equal_to<State_Name>>
namer<State_Name, Name_Hash, Name_Equal>*
create_namer()
{
@ -263,14 +263,14 @@ namespace spot
state_num get_init_state_number() const
{
if (num_states() == 0)
const_cast<graph_t&>(g_).new_state();
const_cast<graph_t&>(g_).new_state();
return init_number_;
}
virtual const twa_graph_state* get_init_state() const override
{
if (num_states() == 0)
const_cast<graph_t&>(g_).new_state();
const_cast<graph_t&>(g_).new_state();
return state_from_number(init_number_);
}
@ -282,13 +282,13 @@ namespace spot
assert(!s->succ || g_.valid_trans(s->succ));
if (this->iter_cache_)
{
auto it =
down_cast<twa_graph_succ_iterator<graph_t>*>(this->iter_cache_);
it->recycle(s->succ);
this->iter_cache_ = nullptr;
return it;
}
{
auto it =
down_cast<twa_graph_succ_iterator<graph_t>*>(this->iter_cache_);
it->recycle(s->succ);
this->iter_cache_ = nullptr;
return it;
}
return new twa_graph_succ_iterator<graph_t>(&g_, s->succ);
}
@ -374,18 +374,18 @@ namespace spot
}
unsigned new_edge(unsigned src, unsigned dst,
bdd cond, acc_cond::mark_t acc = 0U)
bdd cond, acc_cond::mark_t acc = 0U)
{
return g_.new_edge(src, dst, cond, acc);
}
unsigned new_acc_edge(unsigned src, unsigned dst,
bdd cond, bool acc = true)
bdd cond, bool acc = true)
{
if (acc)
return g_.new_edge(src, dst, cond, this->acc().all_sets());
return g_.new_edge(src, dst, cond, this->acc().all_sets());
else
return g_.new_edge(src, dst, cond);
return g_.new_edge(src, dst, cond);
}
#ifndef SWIG
@ -445,9 +445,9 @@ namespace spot
{
assert((bool)prop_state_acc() || num_sets() == 0);
for (auto& t: g_.out(s))
// Stop at the first edge, since the remaining should be
// labeled identically.
return t.acc;
// Stop at the first edge, since the remaining should be
// labeled identically.
return t.acc;
return 0U;
}
@ -455,9 +455,9 @@ namespace spot
{
assert((bool)prop_state_acc() || num_sets() == 0);
for (auto& t: g_.out(s))
// Stop at the first edge, since the remaining should be
// labeled identically.
return acc().accepting(t.acc);
// Stop at the first edge, since the remaining should be
// labeled identically.
return acc().accepting(t.acc);
return false;
}
@ -487,19 +487,19 @@ namespace spot
}
inline twa_graph_ptr make_twa_graph(const twa_graph_ptr& aut,
twa::prop_set p)
twa::prop_set p)
{
return std::make_shared<twa_graph>(aut, p);
}
inline twa_graph_ptr make_twa_graph(const const_twa_graph_ptr& aut,
twa::prop_set p)
twa::prop_set p)
{
return std::make_shared<twa_graph>(aut, p);
}
inline twa_graph_ptr make_twa_graph(const const_twa_ptr& aut,
twa::prop_set p)
twa::prop_set p)
{
auto a = std::dynamic_pointer_cast<const twa_graph>(aut);
if (a)

View file

@ -83,58 +83,58 @@ namespace spot
{
public:
twa_succ_iterator_product_common(twa_succ_iterator* left,
twa_succ_iterator* right,
const twa_product* prod,
fixed_size_pool* pool)
: left_(left), right_(right), prod_(prod), pool_(pool)
twa_succ_iterator* right,
const twa_product* prod,
fixed_size_pool* pool)
: left_(left), right_(right), prod_(prod), pool_(pool)
{
}
void recycle(const const_twa_ptr& l, twa_succ_iterator* left,
const_twa_ptr r, twa_succ_iterator* right)
const_twa_ptr r, twa_succ_iterator* right)
{
l->release_iter(left_);
left_ = left;
r->release_iter(right_);
right_ = right;
l->release_iter(left_);
left_ = left;
r->release_iter(right_);
right_ = right;
}
virtual ~twa_succ_iterator_product_common()
{
delete left_;
delete right_;
delete left_;
delete right_;
}
virtual bool next_non_false_() = 0;
bool first()
{
if (!right_)
return false;
if (!right_)
return false;
// If one of the two successor sets is empty initially, we
// reset right_, so that done() can detect this situation
// easily. (We choose to reset right_ because this variable
// is already used by done().)
if (!(left_->first() && right_->first()))
{
delete right_;
right_ = nullptr;
return false;
}
return next_non_false_();
// If one of the two successor sets is empty initially, we
// reset right_, so that done() can detect this situation
// easily. (We choose to reset right_ because this variable
// is already used by done().)
if (!(left_->first() && right_->first()))
{
delete right_;
right_ = nullptr;
return false;
}
return next_non_false_();
}
bool done() const
{
return !right_ || right_->done();
return !right_ || right_->done();
}
const state_product* dst() const
{
return new(pool_->allocate()) state_product(left_->dst(),
right_->dst(),
pool_);
return new(pool_->allocate()) state_product(left_->dst(),
right_->dst(),
pool_);
}
protected:
@ -151,10 +151,10 @@ namespace spot
{
public:
twa_succ_iterator_product(twa_succ_iterator* left,
twa_succ_iterator* right,
const twa_product* prod,
fixed_size_pool* pool)
: twa_succ_iterator_product_common(left, right, prod, pool)
twa_succ_iterator* right,
const twa_product* prod,
fixed_size_pool* pool)
: twa_succ_iterator_product_common(left, right, prod, pool)
{
}
@ -164,46 +164,46 @@ namespace spot
bool step_()
{
if (left_->next())
return true;
left_->first();
return right_->next();
if (left_->next())
return true;
left_->first();
return right_->next();
}
bool next_non_false_()
{
assert(!done());
do
{
bdd l = left_->cond();
bdd r = right_->cond();
bdd current_cond = l & r;
assert(!done());
do
{
bdd l = left_->cond();
bdd r = right_->cond();
bdd current_cond = l & r;
if (current_cond != bddfalse)
{
current_cond_ = current_cond;
return true;
}
}
while (step_());
return false;
if (current_cond != bddfalse)
{
current_cond_ = current_cond;
return true;
}
}
while (step_());
return false;
}
bool next()
{
if (step_())
return next_non_false_();
return false;
if (step_())
return next_non_false_();
return false;
}
bdd cond() const
{
return current_cond_;
return current_cond_;
}
acc_cond::mark_t acc() const
{
return left_->acc() | (right_->acc() << prod_->left_acc().num_sets());
return left_->acc() | (right_->acc() << prod_->left_acc().num_sets());
}
protected:
@ -217,10 +217,10 @@ namespace spot
{
public:
twa_succ_iterator_product_kripke(twa_succ_iterator* left,
twa_succ_iterator* right,
const twa_product* prod,
fixed_size_pool* pool)
: twa_succ_iterator_product_common(left, right, prod, pool)
twa_succ_iterator* right,
const twa_product* prod,
fixed_size_pool* pool)
: twa_succ_iterator_product_common(left, right, prod, pool)
{
}
@ -230,43 +230,43 @@ namespace spot
bool next_non_false_()
{
// All the transitions of left_ iterator have the
// same label, because it is a Kripke structure.
bdd l = left_->cond();
assert(!right_->done());
do
{
bdd r = right_->cond();
bdd current_cond = l & r;
// All the transitions of left_ iterator have the
// same label, because it is a Kripke structure.
bdd l = left_->cond();
assert(!right_->done());
do
{
bdd r = right_->cond();
bdd current_cond = l & r;
if (current_cond != bddfalse)
{
current_cond_ = current_cond;
return true;
}
}
while (right_->next());
return false;
if (current_cond != bddfalse)
{
current_cond_ = current_cond;
return true;
}
}
while (right_->next());
return false;
}
bool next()
{
if (left_->next())
return true;
left_->first();
if (right_->next())
return next_non_false_();
return false;
if (left_->next())
return true;
left_->first();
if (right_->next())
return next_non_false_();
return false;
}
bdd cond() const
{
return current_cond_;
return current_cond_;
}
acc_cond::mark_t acc() const
{
return right_->acc();
return right_->acc();
}
protected:
@ -279,13 +279,13 @@ namespace spot
// twa_product
twa_product::twa_product(const const_twa_ptr& left,
const const_twa_ptr& right)
const const_twa_ptr& right)
: twa(left->get_dict()), left_(left), right_(right),
pool_(sizeof(state_product))
{
if (left->get_dict() != right->get_dict())
throw std::runtime_error("twa_product: left and right automata should "
"share their bdd_dict");
"share their bdd_dict");
assert(get_dict() == right_->get_dict());
// If one of the side is a Kripke structure, it is easier to deal
@ -293,16 +293,16 @@ namespace spot
// computing the successors can be improved a bit).
if (dynamic_cast<const kripke*>(left_.get()))
{
left_kripke_ = true;
left_kripke_ = true;
}
else if (dynamic_cast<const kripke*>(right_.get()))
{
std::swap(left_, right_);
left_kripke_ = true;
std::swap(left_, right_);
left_kripke_ = true;
}
else
{
left_kripke_ = false;
left_kripke_ = false;
}
auto d = get_dict();
@ -329,7 +329,7 @@ namespace spot
{
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
return new(p->allocate()) state_product(left_->get_init_state(),
right_->get_init_state(), p);
right_->get_init_state(), p);
}
twa_succ_iterator*
@ -342,11 +342,11 @@ namespace spot
if (iter_cache_)
{
twa_succ_iterator_product_common* it =
down_cast<twa_succ_iterator_product_common*>(iter_cache_);
it->recycle(left_, li, right_, ri);
iter_cache_ = nullptr;
return it;
twa_succ_iterator_product_common* it =
down_cast<twa_succ_iterator_product_common*>(iter_cache_);
it->recycle(left_, li, right_, ri);
iter_cache_ = nullptr;
return it;
}
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
@ -372,8 +372,8 @@ namespace spot
const state_product* s = down_cast<const state_product*>(state);
assert(s);
return (left_->format_state(s->left())
+ " * "
+ right_->format_state(s->right()));
+ " * "
+ right_->format_state(s->right()));
}
state*
@ -393,9 +393,9 @@ namespace spot
// twa_product_init
twa_product_init::twa_product_init(const const_twa_ptr& left,
const const_twa_ptr& right,
const state* left_init,
const state* right_init)
const const_twa_ptr& right,
const state* left_init,
const state* right_init)
: twa_product(left, right),
left_init_(left_init), right_init_(right_init)
{
@ -408,7 +408,7 @@ namespace spot
{
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
return new(p->allocate()) state_product(left_init_->clone(),
right_init_->clone(), p);
right_init_->clone(), p);
}
}

View file

@ -43,9 +43,9 @@ namespace spot
/// These states are acquired by spot::state_product, and will
/// be destroyed on destruction.
state_product(const state* left,
const state* right,
fixed_size_pool* pool)
: left_(left), right_(right), count_(1), pool_(pool)
const state* right,
fixed_size_pool* pool)
: left_(left), right_(right), count_(1), pool_(pool)
{
}
@ -68,8 +68,8 @@ namespace spot
virtual state_product* clone() const override;
private:
const state* left_; ///< State from the left automaton.
const state* right_; ///< State from the right automaton.
const state* left_; ///< State from the left automaton.
const state* right_; ///< State from the right automaton.
mutable unsigned count_;
fixed_size_pool* pool_;
@ -120,7 +120,7 @@ namespace spot
{
public:
twa_product_init(const const_twa_ptr& left, const const_twa_ptr& right,
const state* left_init, const state* right_init);
const state* left_init, const state* right_init);
virtual const state* get_init_state() const override;
protected:
const state* left_init_;
@ -129,18 +129,18 @@ namespace spot
/// \brief on-the-fly TGBA product
inline twa_product_ptr otf_product(const const_twa_ptr& left,
const const_twa_ptr& right)
const const_twa_ptr& right)
{
return std::make_shared<twa_product>(left, right);
}
/// \brief on-the-fly TGBA product with forced initial states
inline twa_product_ptr otf_product_at(const const_twa_ptr& left,
const const_twa_ptr& right,
const state* left_init,
const state* right_init)
const const_twa_ptr& right,
const state* left_init,
const state* right_init)
{
return std::make_shared<twa_product_init>(left, right,
left_init, right_init);
left_init, right_init);
}
}