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:
parent
1eee12b8b4
commit
f7e7b4f14e
239 changed files with 25359 additions and 25355 deletions
|
|
@ -45,11 +45,11 @@ namespace spot
|
|||
{
|
||||
struct stack_entry
|
||||
{
|
||||
const state* s; // State stored in stack entry.
|
||||
const state* s; // State stored in stack entry.
|
||||
twa_succ_iterator* lasttr; // Last transition explored from this state.
|
||||
int lowlink; // Lowlink value if this entry.
|
||||
int pre; // DFS predecessor.
|
||||
int acc; // Accepting state link.
|
||||
int lowlink; // Lowlink value if this entry.
|
||||
int pre; // DFS predecessor.
|
||||
int acc; // Accepting state link.
|
||||
};
|
||||
|
||||
struct gv04: public emptiness_check, public ec_statistics
|
||||
|
|
@ -60,342 +60,342 @@ namespace spot
|
|||
// Stack of visited states on the path.
|
||||
std::vector<stack_entry> stack;
|
||||
|
||||
int top; // Top of SCC stack.
|
||||
int dftop; // Top of DFS stack.
|
||||
bool violation; // Whether an accepting run was found.
|
||||
int top; // Top of SCC stack.
|
||||
int dftop; // Top of DFS stack.
|
||||
bool violation; // Whether an accepting run was found.
|
||||
|
||||
gv04(const const_twa_ptr& a, option_map o)
|
||||
: emptiness_check(a, o)
|
||||
: emptiness_check(a, o)
|
||||
{
|
||||
assert(a->num_sets() <= 1);
|
||||
assert(a->num_sets() <= 1);
|
||||
}
|
||||
|
||||
~gv04()
|
||||
{
|
||||
for (auto i: stack)
|
||||
a_->release_iter(i.lasttr);
|
||||
auto s = h.begin();
|
||||
while (s != h.end())
|
||||
{
|
||||
// Advance the iterator before deleting the "key" pointer.
|
||||
const state* ptr = s->first;
|
||||
++s;
|
||||
ptr->destroy();
|
||||
}
|
||||
for (auto i: stack)
|
||||
a_->release_iter(i.lasttr);
|
||||
auto s = h.begin();
|
||||
while (s != h.end())
|
||||
{
|
||||
// Advance the iterator before deleting the "key" pointer.
|
||||
const state* ptr = s->first;
|
||||
++s;
|
||||
ptr->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
virtual emptiness_check_result_ptr
|
||||
check() override
|
||||
{
|
||||
top = dftop = -1;
|
||||
violation = false;
|
||||
push(a_->get_init_state(), false);
|
||||
top = dftop = -1;
|
||||
violation = false;
|
||||
push(a_->get_init_state(), false);
|
||||
|
||||
while (!violation && dftop >= 0)
|
||||
{
|
||||
trace << "Main iteration (top = " << top
|
||||
<< ", dftop = " << dftop
|
||||
<< ", s = " << a_->format_state(stack[dftop].s)
|
||||
<< ')' << std::endl;
|
||||
while (!violation && dftop >= 0)
|
||||
{
|
||||
trace << "Main iteration (top = " << top
|
||||
<< ", dftop = " << dftop
|
||||
<< ", s = " << a_->format_state(stack[dftop].s)
|
||||
<< ')' << std::endl;
|
||||
|
||||
twa_succ_iterator* iter = stack[dftop].lasttr;
|
||||
bool cont;
|
||||
if (!iter)
|
||||
{
|
||||
iter = stack[dftop].lasttr = a_->succ_iter(stack[dftop].s);
|
||||
cont = iter->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
cont = iter->next();
|
||||
}
|
||||
twa_succ_iterator* iter = stack[dftop].lasttr;
|
||||
bool cont;
|
||||
if (!iter)
|
||||
{
|
||||
iter = stack[dftop].lasttr = a_->succ_iter(stack[dftop].s);
|
||||
cont = iter->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
cont = iter->next();
|
||||
}
|
||||
|
||||
if (!cont)
|
||||
{
|
||||
trace << " No more successors" << std::endl;
|
||||
pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
const state* s_prime = iter->dst();
|
||||
bool acc =
|
||||
a_->acc().accepting(iter->acc());
|
||||
inc_transitions();
|
||||
if (!cont)
|
||||
{
|
||||
trace << " No more successors" << std::endl;
|
||||
pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
const state* s_prime = iter->dst();
|
||||
bool acc =
|
||||
a_->acc().accepting(iter->acc());
|
||||
inc_transitions();
|
||||
|
||||
trace << " Next successor: s_prime = "
|
||||
<< a_->format_state(s_prime)
|
||||
<< (acc ? " (with accepting link)" : "");
|
||||
trace << " Next successor: s_prime = "
|
||||
<< a_->format_state(s_prime)
|
||||
<< (acc ? " (with accepting link)" : "");
|
||||
|
||||
auto i = h.find(s_prime);
|
||||
auto i = h.find(s_prime);
|
||||
|
||||
if (i == h.end())
|
||||
{
|
||||
trace << " is a new state." << std::endl;
|
||||
push(s_prime, acc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second < stack.size()
|
||||
&& stack[i->second].s->compare(s_prime) == 0)
|
||||
{
|
||||
// s_prime has a clone on stack
|
||||
trace << " is on stack." << std::endl;
|
||||
// This is an addition to GV04 to support TBA.
|
||||
violation |= acc;
|
||||
lowlinkupdate(dftop, i->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace << " has been seen, but is no longer on stack."
|
||||
<< std::endl;
|
||||
}
|
||||
if (i == h.end())
|
||||
{
|
||||
trace << " is a new state." << std::endl;
|
||||
push(s_prime, acc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second < stack.size()
|
||||
&& stack[i->second].s->compare(s_prime) == 0)
|
||||
{
|
||||
// s_prime has a clone on stack
|
||||
trace << " is on stack." << std::endl;
|
||||
// This is an addition to GV04 to support TBA.
|
||||
violation |= acc;
|
||||
lowlinkupdate(dftop, i->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace << " has been seen, but is no longer on stack."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
s_prime->destroy();
|
||||
}
|
||||
}
|
||||
set_states(h.size());
|
||||
}
|
||||
if (violation)
|
||||
return std::make_shared<result>(*this);
|
||||
return nullptr;
|
||||
s_prime->destroy();
|
||||
}
|
||||
}
|
||||
set_states(h.size());
|
||||
}
|
||||
if (violation)
|
||||
return std::make_shared<result>(*this);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
push(const state* s, bool accepting)
|
||||
{
|
||||
trace << " push(s = " << a_->format_state(s)
|
||||
<< ", accepting = " << accepting << ")\n";
|
||||
trace << " push(s = " << a_->format_state(s)
|
||||
<< ", accepting = " << accepting << ")\n";
|
||||
|
||||
h[s] = ++top;
|
||||
h[s] = ++top;
|
||||
|
||||
stack_entry ss = { s, nullptr, top, dftop, 0 };
|
||||
stack_entry ss = { s, nullptr, top, dftop, 0 };
|
||||
|
||||
if (accepting)
|
||||
ss.acc = top - 1; // This differs from GV04 to support TBA.
|
||||
else if (dftop >= 0)
|
||||
ss.acc = stack[dftop].acc;
|
||||
else
|
||||
ss.acc = -1;
|
||||
if (accepting)
|
||||
ss.acc = top - 1; // This differs from GV04 to support TBA.
|
||||
else if (dftop >= 0)
|
||||
ss.acc = stack[dftop].acc;
|
||||
else
|
||||
ss.acc = -1;
|
||||
|
||||
trace << " s.lowlink = " << top << std::endl
|
||||
<< " s.acc = " << ss.acc << std::endl;
|
||||
trace << " s.lowlink = " << top << std::endl
|
||||
<< " s.acc = " << ss.acc << std::endl;
|
||||
|
||||
stack.push_back(ss);
|
||||
dftop = top;
|
||||
inc_depth();
|
||||
stack.push_back(ss);
|
||||
dftop = top;
|
||||
inc_depth();
|
||||
}
|
||||
|
||||
void
|
||||
pop()
|
||||
{
|
||||
trace << " pop()\n";
|
||||
trace << " pop()\n";
|
||||
|
||||
int p = stack[dftop].pre;
|
||||
if (p >= 0)
|
||||
lowlinkupdate(p, dftop);
|
||||
if (stack[dftop].lowlink == dftop)
|
||||
{
|
||||
assert(static_cast<unsigned int>(top + 1) == stack.size());
|
||||
for (int i = top; i >= dftop; --i)
|
||||
{
|
||||
a_->release_iter(stack[i].lasttr);
|
||||
stack.pop_back();
|
||||
dec_depth();
|
||||
}
|
||||
top = dftop - 1;
|
||||
}
|
||||
dftop = p;
|
||||
int p = stack[dftop].pre;
|
||||
if (p >= 0)
|
||||
lowlinkupdate(p, dftop);
|
||||
if (stack[dftop].lowlink == dftop)
|
||||
{
|
||||
assert(static_cast<unsigned int>(top + 1) == stack.size());
|
||||
for (int i = top; i >= dftop; --i)
|
||||
{
|
||||
a_->release_iter(stack[i].lasttr);
|
||||
stack.pop_back();
|
||||
dec_depth();
|
||||
}
|
||||
top = dftop - 1;
|
||||
}
|
||||
dftop = p;
|
||||
}
|
||||
|
||||
void
|
||||
lowlinkupdate(int f, int t)
|
||||
{
|
||||
trace << " lowlinkupdate(f = " << f << ", t = " << t
|
||||
<< ")\n t.lowlink = " << stack[t].lowlink
|
||||
<< "\n f.lowlink = " << stack[f].lowlink
|
||||
<< "\n f.acc = " << stack[f].acc << '\n';
|
||||
int stack_t_lowlink = stack[t].lowlink;
|
||||
if (stack_t_lowlink <= stack[f].lowlink)
|
||||
{
|
||||
if (stack_t_lowlink <= stack[f].acc)
|
||||
violation = true;
|
||||
stack[f].lowlink = stack_t_lowlink;
|
||||
trace << " f.lowlink updated to "
|
||||
<< stack[f].lowlink << '\n';
|
||||
}
|
||||
trace << " lowlinkupdate(f = " << f << ", t = " << t
|
||||
<< ")\n t.lowlink = " << stack[t].lowlink
|
||||
<< "\n f.lowlink = " << stack[f].lowlink
|
||||
<< "\n f.acc = " << stack[f].acc << '\n';
|
||||
int stack_t_lowlink = stack[t].lowlink;
|
||||
if (stack_t_lowlink <= stack[f].lowlink)
|
||||
{
|
||||
if (stack_t_lowlink <= stack[f].acc)
|
||||
violation = true;
|
||||
stack[f].lowlink = stack_t_lowlink;
|
||||
trace << " f.lowlink updated to "
|
||||
<< stack[f].lowlink << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::ostream&
|
||||
print_stats(std::ostream& os) const override
|
||||
{
|
||||
os << h.size() << " unique states visited\n";
|
||||
os << transitions() << " transitions explored\n";
|
||||
os << max_depth() << " items max on stack\n";
|
||||
return os;
|
||||
os << h.size() << " unique states visited\n";
|
||||
os << transitions() << " transitions explored\n";
|
||||
os << max_depth() << " items max on stack\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
struct result:
|
||||
public emptiness_check_result,
|
||||
public acss_statistics
|
||||
public emptiness_check_result,
|
||||
public acss_statistics
|
||||
{
|
||||
gv04& data;
|
||||
gv04& data;
|
||||
|
||||
result(gv04& data)
|
||||
: emptiness_check_result(data.automaton(), data.options()),
|
||||
data(data)
|
||||
{
|
||||
}
|
||||
result(gv04& data)
|
||||
: emptiness_check_result(data.automaton(), data.options()),
|
||||
data(data)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
update_lowlinks()
|
||||
{
|
||||
// Transitively update the lowlinks, so we can use them in
|
||||
// to check SCC inclusion
|
||||
for (int i = 0; i <= data.top; ++i)
|
||||
{
|
||||
int l = data.stack[i].lowlink;
|
||||
if (l < i)
|
||||
{
|
||||
int ll = data.stack[i].lowlink = data.stack[l].lowlink;
|
||||
for (int j = i - 1; data.stack[j].lowlink != ll; --j)
|
||||
data.stack[j].lowlink = ll;
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
update_lowlinks()
|
||||
{
|
||||
// Transitively update the lowlinks, so we can use them in
|
||||
// to check SCC inclusion
|
||||
for (int i = 0; i <= data.top; ++i)
|
||||
{
|
||||
int l = data.stack[i].lowlink;
|
||||
if (l < i)
|
||||
{
|
||||
int ll = data.stack[i].lowlink = data.stack[l].lowlink;
|
||||
for (int j = i - 1; data.stack[j].lowlink != ll; --j)
|
||||
data.stack[j].lowlink = ll;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual unsigned
|
||||
acss_states() const override
|
||||
{
|
||||
// Gross!
|
||||
const_cast<result*>(this)->update_lowlinks();
|
||||
virtual unsigned
|
||||
acss_states() const override
|
||||
{
|
||||
// Gross!
|
||||
const_cast<result*>(this)->update_lowlinks();
|
||||
|
||||
int scc = data.stack[data.dftop].lowlink;
|
||||
int j = data.dftop;
|
||||
int s = 0;
|
||||
while (j >= 0 && data.stack[j].lowlink == scc)
|
||||
{
|
||||
--j;
|
||||
++s;
|
||||
}
|
||||
assert(s > 0);
|
||||
return s;
|
||||
}
|
||||
int scc = data.stack[data.dftop].lowlink;
|
||||
int j = data.dftop;
|
||||
int s = 0;
|
||||
while (j >= 0 && data.stack[j].lowlink == scc)
|
||||
{
|
||||
--j;
|
||||
++s;
|
||||
}
|
||||
assert(s > 0);
|
||||
return s;
|
||||
}
|
||||
|
||||
virtual twa_run_ptr
|
||||
accepting_run() override
|
||||
{
|
||||
auto res = std::make_shared<twa_run>(automaton());
|
||||
virtual twa_run_ptr
|
||||
accepting_run() override
|
||||
{
|
||||
auto res = std::make_shared<twa_run>(automaton());
|
||||
|
||||
update_lowlinks();
|
||||
update_lowlinks();
|
||||
#ifdef TRACE
|
||||
for (int i = 0; i <= data.top; ++i)
|
||||
{
|
||||
trace << "state " << i << " ("
|
||||
<< data.a_->format_state(data.stack[i].s)
|
||||
<< ") has lowlink = " << data.stack[i].lowlink << std::endl;
|
||||
}
|
||||
for (int i = 0; i <= data.top; ++i)
|
||||
{
|
||||
trace << "state " << i << " ("
|
||||
<< data.a_->format_state(data.stack[i].s)
|
||||
<< ") has lowlink = " << data.stack[i].lowlink << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// We will use the root of the last SCC as the start of the
|
||||
// cycle.
|
||||
int scc_root = data.stack[data.dftop].lowlink;
|
||||
assert(scc_root >= 0);
|
||||
// We will use the root of the last SCC as the start of the
|
||||
// cycle.
|
||||
int scc_root = data.stack[data.dftop].lowlink;
|
||||
assert(scc_root >= 0);
|
||||
|
||||
// Construct the prefix by unwinding the DFS stack before
|
||||
// scc_root.
|
||||
int father = data.stack[scc_root].pre;
|
||||
while (father >= 0)
|
||||
{
|
||||
twa_run::step st =
|
||||
{
|
||||
data.stack[father].s->clone(),
|
||||
data.stack[father].lasttr->cond(),
|
||||
data.stack[father].lasttr->acc()
|
||||
};
|
||||
res->prefix.push_front(st);
|
||||
father = data.stack[father].pre;
|
||||
}
|
||||
// Construct the prefix by unwinding the DFS stack before
|
||||
// scc_root.
|
||||
int father = data.stack[scc_root].pre;
|
||||
while (father >= 0)
|
||||
{
|
||||
twa_run::step st =
|
||||
{
|
||||
data.stack[father].s->clone(),
|
||||
data.stack[father].lasttr->cond(),
|
||||
data.stack[father].lasttr->acc()
|
||||
};
|
||||
res->prefix.push_front(st);
|
||||
father = data.stack[father].pre;
|
||||
}
|
||||
|
||||
// Construct the cycle in two phases. A first BFS finds the
|
||||
// shortest path from scc_root to an accepting transition.
|
||||
// A second BFS then search a path back to scc_root. If
|
||||
// there is no acceptance conditions we just use the second
|
||||
// BFS to find a cycle around scc_root.
|
||||
// Construct the cycle in two phases. A first BFS finds the
|
||||
// shortest path from scc_root to an accepting transition.
|
||||
// A second BFS then search a path back to scc_root. If
|
||||
// there is no acceptance conditions we just use the second
|
||||
// BFS to find a cycle around scc_root.
|
||||
|
||||
struct first_bfs: bfs_steps
|
||||
{
|
||||
const gv04& data;
|
||||
int scc_root;
|
||||
result* r;
|
||||
struct first_bfs: bfs_steps
|
||||
{
|
||||
const gv04& data;
|
||||
int scc_root;
|
||||
result* r;
|
||||
|
||||
first_bfs(result* r, int scc_root)
|
||||
: bfs_steps(r->data.automaton()), data(r->data),
|
||||
scc_root(scc_root), r(r)
|
||||
{
|
||||
}
|
||||
first_bfs(result* r, int scc_root)
|
||||
: bfs_steps(r->data.automaton()), data(r->data),
|
||||
scc_root(scc_root), r(r)
|
||||
{
|
||||
}
|
||||
|
||||
virtual const state*
|
||||
filter(const state* s) override
|
||||
{
|
||||
// Do not escape the SCC
|
||||
auto j = data.h.find(s);
|
||||
if (// This state was never visited so far.
|
||||
j == data.h.end()
|
||||
// Or it was discarded
|
||||
|| j->second >= data.stack.size()
|
||||
// Or it was discarded (but its stack slot reused)
|
||||
|| data.stack[j->second].s->compare(s)
|
||||
// Or it is still on the stack but not in the SCC
|
||||
|| data.stack[j->second].lowlink < scc_root)
|
||||
{
|
||||
s->destroy();
|
||||
return nullptr;
|
||||
}
|
||||
r->inc_ars_cycle_states();
|
||||
s->destroy();
|
||||
return j->first;
|
||||
}
|
||||
virtual const state*
|
||||
filter(const state* s) override
|
||||
{
|
||||
// Do not escape the SCC
|
||||
auto j = data.h.find(s);
|
||||
if (// This state was never visited so far.
|
||||
j == data.h.end()
|
||||
// Or it was discarded
|
||||
|| j->second >= data.stack.size()
|
||||
// Or it was discarded (but its stack slot reused)
|
||||
|| data.stack[j->second].s->compare(s)
|
||||
// Or it is still on the stack but not in the SCC
|
||||
|| data.stack[j->second].lowlink < scc_root)
|
||||
{
|
||||
s->destroy();
|
||||
return nullptr;
|
||||
}
|
||||
r->inc_ars_cycle_states();
|
||||
s->destroy();
|
||||
return j->first;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
match(twa_run::step& step, const state*) override
|
||||
{
|
||||
return step.acc != 0U;
|
||||
}
|
||||
};
|
||||
virtual bool
|
||||
match(twa_run::step& step, const state*) override
|
||||
{
|
||||
return step.acc != 0U;
|
||||
}
|
||||
};
|
||||
|
||||
struct second_bfs final: first_bfs
|
||||
{
|
||||
const state* target;
|
||||
second_bfs(result* r, int scc_root, const state* target)
|
||||
: first_bfs(r, scc_root), target(target)
|
||||
{
|
||||
}
|
||||
struct second_bfs final: first_bfs
|
||||
{
|
||||
const state* target;
|
||||
second_bfs(result* r, int scc_root, const state* target)
|
||||
: first_bfs(r, scc_root), target(target)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool
|
||||
match(twa_run::step&, const state* s) override
|
||||
{
|
||||
return s == target;
|
||||
}
|
||||
};
|
||||
virtual bool
|
||||
match(twa_run::step&, const state* s) override
|
||||
{
|
||||
return s == target;
|
||||
}
|
||||
};
|
||||
|
||||
const state* bfs_start = data.stack[scc_root].s;
|
||||
const state* bfs_end = bfs_start;
|
||||
if (a_->num_sets() > 0)
|
||||
{
|
||||
first_bfs b1(this, scc_root);
|
||||
bfs_start = b1.search(bfs_start, res->cycle);
|
||||
assert(bfs_start);
|
||||
}
|
||||
if (bfs_start != bfs_end || res->cycle.empty())
|
||||
{
|
||||
second_bfs b2(this, scc_root, bfs_end);
|
||||
bfs_start = b2.search(bfs_start, res->cycle);
|
||||
assert(bfs_start == bfs_end);
|
||||
}
|
||||
const state* bfs_start = data.stack[scc_root].s;
|
||||
const state* bfs_end = bfs_start;
|
||||
if (a_->num_sets() > 0)
|
||||
{
|
||||
first_bfs b1(this, scc_root);
|
||||
bfs_start = b1.search(bfs_start, res->cycle);
|
||||
assert(bfs_start);
|
||||
}
|
||||
if (bfs_start != bfs_end || res->cycle.empty())
|
||||
{
|
||||
second_bfs b2(this, scc_root, bfs_end);
|
||||
bfs_start = b2.search(bfs_start, res->cycle);
|
||||
assert(bfs_start == bfs_end);
|
||||
}
|
||||
|
||||
assert(res->cycle.begin() != res->cycle.end());
|
||||
return res;
|
||||
}
|
||||
assert(res->cycle.begin() != res->cycle.end());
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue