This is a huge patch, that took over a month to complete. The bit sets are currently restricted to what 'unsigned can store', but it should be easy to extend it to 'uint64_t' should we need it. * NEWS: Update. * src/tgba/acc.hh: New file. * src/tgbatest/acc.cc, src/tgbatest/acc.test: Test it. * src/tgba/tgbakvcomplement.cc, src/tgba/tgbakvcomplement.hh, src/tgba/tgbasgba.cc, src/tgba/tgbasgba.hh: Delete. The KV complementation is too slow to be used in practice, and I somehow broke it during the conversion to bitsets. The tgba->sgba conversion was only used for the KV complementation, and should be better redone on tgba_digraph_ptr should it be needed again. * src/bin/ltlcross.cc, src/dstarparse/dra2ba.cc, src/dstarparse/nsa2tgba.cc, src/graphtest/tgbagraph.cc, src/graphtest/tgbagraph.test, src/kripke/fairkripke.cc, src/kripke/fairkripke.hh, src/kripke/kripke.cc, src/kripke/kripke.hh, src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh, src/misc/hash.hh, src/neverparse/neverclaimparse.yy, src/priv/accmap.hh, src/ta/ta.cc, src/ta/ta.hh, src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/taproduct.cc, src/ta/taproduct.hh, src/ta/tgta.cc, src/ta/tgta.hh, src/ta/tgtaexplicit.cc, src/ta/tgtaexplicit.hh, src/ta/tgtaproduct.cc, src/ta/tgtaproduct.hh, src/taalgos/dotty.cc, src/taalgos/emptinessta.cc, src/taalgos/minimize.cc, src/taalgos/tgba2ta.cc, src/tgba/Makefile.am, src/tgba/fwd.hh, src/tgba/taatgba.cc, src/tgba/taatgba.hh, src/tgba/tgba.cc, src/tgba/tgba.hh, src/tgba/tgbagraph.cc, src/tgba/tgbagraph.hh, src/tgba/tgbamask.cc, src/tgba/tgbamask.hh, src/tgba/tgbaproduct.cc, src/tgba/tgbaproduct.hh, src/tgba/tgbaproxy.cc, src/tgba/tgbaproxy.hh, src/tgba/tgbasafracomplement.cc, src/tgba/tgbasafracomplement.hh, src/tgbaalgos/bfssteps.cc, src/tgbaalgos/complete.cc, src/tgbaalgos/compsusp.cc, src/tgbaalgos/degen.cc, src/tgbaalgos/dotty.cc, src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtgbacomp.cc, src/tgbaalgos/dtgbasat.cc, src/tgbaalgos/dupexp.cc, src/tgbaalgos/emptiness.cc, src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/ce.cc, src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/gtec/gtec.hh, src/tgbaalgos/gtec/sccstack.cc, src/tgbaalgos/gtec/sccstack.hh, src/tgbaalgos/gv04.cc, src/tgbaalgos/hoaf.cc, src/tgbaalgos/isweakscc.cc, src/tgbaalgos/lbtt.cc, src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/magic.cc, src/tgbaalgos/ndfs_result.hxx, src/tgbaalgos/neverclaim.cc, src/tgbaalgos/postproc.cc, src/tgbaalgos/powerset.cc, src/tgbaalgos/randomgraph.cc, src/tgbaalgos/randomgraph.hh, src/tgbaalgos/reducerun.cc, src/tgbaalgos/replayrun.cc, src/tgbaalgos/safety.cc, src/tgbaalgos/save.cc, src/tgbaalgos/scc.cc, src/tgbaalgos/scc.hh, src/tgbaalgos/sccfilter.cc, src/tgbaalgos/sccinfo.cc, src/tgbaalgos/sccinfo.hh, src/tgbaalgos/se05.cc, src/tgbaalgos/simulation.cc, src/tgbaalgos/simulation.hh, src/tgbaalgos/stats.cc, src/tgbaalgos/stripacc.cc, src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.cc, src/tgbaalgos/weight.cc, src/tgbaalgos/weight.hh, src/tgbaparse/tgbaparse.yy, src/tgbatest/Makefile.am, src/tgbatest/complementation.cc, src/tgbatest/complementation.test, src/tgbatest/degenlskip.test, src/tgbatest/det.test, src/tgbatest/dstar.test, src/tgbatest/emptchk.cc, src/tgbatest/explpro2.test, src/tgbatest/explpro3.test, src/tgbatest/explpro4.test, src/tgbatest/explprod.test, src/tgbatest/ltl2tgba.cc, src/tgbatest/ltl2tgba.test, src/tgbatest/maskacc.cc, src/tgbatest/maskacc.test, src/tgbatest/neverclaimread.test, src/tgbatest/randtgba.cc, src/tgbatest/readsave.test, src/tgbatest/sim.test, src/tgbatest/sim2.test, src/tgbatest/spotlbtt.test, src/tgbatest/tgbaread.test, src/tgbatest/tripprod.test, iface/dve2/dve2.cc: Adjust or use to the new acceptance interface.
186 lines
5.3 KiB
C++
186 lines
5.3 KiB
C++
// -*- coding: utf-8 -*-
|
|
// Copyright (C) 2011, 2013, 2014 Laboratoire de Recherche et
|
|
// Développement de l'Epita (LRDE).
|
|
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
|
// et Marie Curie.
|
|
//
|
|
// This file is part of Spot, a model checking library.
|
|
//
|
|
// Spot is free software; you can redistribute it and/or modify it
|
|
// under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
// License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#include "misc/hash.hh"
|
|
#include "emptiness.hh"
|
|
#include "tgba/tgba.hh"
|
|
#include "bfssteps.hh"
|
|
#include "reducerun.hh"
|
|
|
|
namespace spot
|
|
{
|
|
namespace
|
|
{
|
|
class shortest_path: public bfs_steps
|
|
{
|
|
public:
|
|
shortest_path(const const_tgba_ptr& a)
|
|
: bfs_steps(a), target(0)
|
|
{
|
|
}
|
|
|
|
~shortest_path()
|
|
{
|
|
state_set::const_iterator i = seen.begin();
|
|
while (i != seen.end())
|
|
{
|
|
const state* ptr = *i;
|
|
++i;
|
|
ptr->destroy();
|
|
}
|
|
}
|
|
|
|
void
|
|
set_target(const state_set* t)
|
|
{
|
|
target = t;
|
|
}
|
|
|
|
const state*
|
|
search(const state* start, tgba_run::steps& l)
|
|
{
|
|
return this->bfs_steps::search(filter(start), l);
|
|
}
|
|
|
|
const state*
|
|
filter(const state* s)
|
|
{
|
|
state_set::const_iterator i = seen.find(s);
|
|
if (i == seen.end())
|
|
seen.insert(s);
|
|
else
|
|
{
|
|
s->destroy();
|
|
s = *i;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
bool
|
|
match(tgba_run::step&, const state* dest)
|
|
{
|
|
return target->find(dest) != target->end();
|
|
}
|
|
|
|
private:
|
|
state_set seen;
|
|
const state_set* target;
|
|
};
|
|
}
|
|
|
|
tgba_run_ptr
|
|
reduce_run(const const_tgba_ptr& a, const const_tgba_run_ptr& org)
|
|
{
|
|
auto res = std::make_shared<tgba_run>();
|
|
state_set ss;
|
|
shortest_path shpath(a);
|
|
shpath.set_target(&ss);
|
|
|
|
// We want to find a short segment of the original cycle that
|
|
// contains all acceptance conditions.
|
|
|
|
const state* segment_start; // The initial state of the segment.
|
|
const state* segment_next; // The state immediately after the segment.
|
|
|
|
// Start from the end of the original cycle, and rewind until all
|
|
// acceptance sets have been seen.
|
|
acc_cond::mark_t seen_acc = 0U;
|
|
tgba_run::steps::const_iterator seg = org->cycle.end();
|
|
do
|
|
{
|
|
assert(seg != org->cycle.begin());
|
|
--seg;
|
|
seen_acc |= seg->acc;
|
|
}
|
|
while (!a->acc().accepting(seen_acc));
|
|
segment_start = seg->s;
|
|
|
|
// Now go forward and ends the segment as soon as we have seen all
|
|
// acceptance sets, cloning it in our result along the way.
|
|
seen_acc = 0U;
|
|
do
|
|
{
|
|
assert(seg != org->cycle.end());
|
|
seen_acc |= seg->acc;
|
|
|
|
tgba_run::step st = { seg->s->clone(), seg->label, seg->acc };
|
|
res->cycle.push_back(st);
|
|
|
|
++seg;
|
|
}
|
|
while (!a->acc().accepting(seen_acc));
|
|
segment_next = seg == org->cycle.end() ? org->cycle.front().s : seg->s;
|
|
|
|
// Close this cycle if needed, that is, compute a cycle going
|
|
// from the state following the segment to its starting state.
|
|
if (segment_start != segment_next)
|
|
{
|
|
ss.insert(segment_start);
|
|
const state* s = shpath.search(segment_next->clone(), res->cycle);
|
|
ss.clear();
|
|
assert(s->compare(segment_start) == 0);
|
|
(void)s;
|
|
}
|
|
|
|
// Compute the prefix: it's the shortest path from the initial
|
|
// state of the automata to any state of the cycle.
|
|
|
|
// Register all states from the cycle as target of the BFS.
|
|
for (tgba_run::steps::const_iterator i = res->cycle.begin();
|
|
i != res->cycle.end(); ++i)
|
|
ss.insert(i->s);
|
|
|
|
const state* prefix_start = a->get_init_state();
|
|
// There are two cases: either the initial state is already on
|
|
// the cycle, or it is not. If it is, we will have to rotate
|
|
// the cycle so it begins on this position. Otherwise we will shift
|
|
// the cycle so it begins on the state that follows the prefix.
|
|
// cycle_entry_point is that state.
|
|
const state* cycle_entry_point;
|
|
state_set::const_iterator ps = ss.find(prefix_start);
|
|
if (ps != ss.end())
|
|
{
|
|
// The initial state is on the cycle.
|
|
prefix_start->destroy();
|
|
cycle_entry_point = *ps;
|
|
}
|
|
else
|
|
{
|
|
// This initial state is outside the cycle. Compute the prefix.
|
|
cycle_entry_point = shpath.search(prefix_start, res->prefix);
|
|
}
|
|
|
|
// Locate cycle_entry_point on the cycle.
|
|
tgba_run::steps::iterator cycle_ep_it;
|
|
for (cycle_ep_it = res->cycle.begin();
|
|
cycle_ep_it != res->cycle.end()
|
|
&& cycle_entry_point->compare(cycle_ep_it->s); ++cycle_ep_it)
|
|
continue;
|
|
assert(cycle_ep_it != res->cycle.end());
|
|
|
|
// Now shift the cycle so it starts on cycle_entry_point.
|
|
res->cycle.splice(res->cycle.end(), res->cycle,
|
|
res->cycle.begin(), cycle_ep_it);
|
|
|
|
return res;
|
|
}
|
|
}
|