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.
259 lines
6.1 KiB
C++
259 lines
6.1 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 "replayrun.hh"
|
|
#include "tgba/tgba.hh"
|
|
#include "emptiness.hh"
|
|
#include "tgba/bddprint.hh"
|
|
#include <sstream>
|
|
|
|
namespace spot
|
|
{
|
|
namespace
|
|
{
|
|
void
|
|
print_annotation(std::ostream& os,
|
|
const const_tgba_ptr& a,
|
|
const tgba_succ_iterator* i)
|
|
{
|
|
std::string s = a->transition_annotation(i);
|
|
if (s == "")
|
|
return;
|
|
os << ' ' << s;
|
|
}
|
|
}
|
|
|
|
bool
|
|
replay_tgba_run(std::ostream& os, const const_tgba_ptr& a,
|
|
const const_tgba_run_ptr& run, bool debug)
|
|
{
|
|
const state* s = a->get_init_state();
|
|
int serial = 1;
|
|
const tgba_run::steps* l;
|
|
std::string in;
|
|
acc_cond::mark_t all_acc = 0U;
|
|
bool all_acc_seen = false;
|
|
typedef std::unordered_map<const state*, std::set<int>,
|
|
state_ptr_hash, state_ptr_equal> state_map;
|
|
state_map seen;
|
|
|
|
if (run->prefix.empty())
|
|
{
|
|
l = &run->cycle;
|
|
in = "cycle";
|
|
if (!debug)
|
|
os << "No prefix.\nCycle:\n";
|
|
}
|
|
else
|
|
{
|
|
l = &run->prefix;
|
|
in = "prefix";
|
|
if (!debug)
|
|
os << "Prefix:\n";
|
|
}
|
|
|
|
tgba_run::steps::const_iterator i = l->begin();
|
|
|
|
if (s->compare(i->s))
|
|
{
|
|
if (debug)
|
|
os << "ERROR: First state of run (in " << in << "): "
|
|
<< a->format_state(i->s)
|
|
<< "\ndoes not match initial state of automata: "
|
|
<< a->format_state(s) << '\n';
|
|
s->destroy();
|
|
return false;
|
|
}
|
|
|
|
for (; i != l->end(); ++serial)
|
|
{
|
|
if (debug)
|
|
{
|
|
// Keep track of the serial associated to each state so we
|
|
// can note duplicate states and make the replay easier to read.
|
|
state_map::iterator o = seen.find(s);
|
|
std::ostringstream msg;
|
|
if (o != seen.end())
|
|
{
|
|
for (auto d: o->second)
|
|
msg << " == " << d;
|
|
o->second.insert(serial);
|
|
s->destroy();
|
|
s = o->first;
|
|
}
|
|
else
|
|
{
|
|
seen[s].insert(serial);
|
|
}
|
|
os << "state " << serial << " in " << in << msg.str() << ": ";
|
|
}
|
|
else
|
|
{
|
|
os << " ";
|
|
}
|
|
os << a->format_state(s) << '\n';
|
|
|
|
// expected outgoing transition
|
|
bdd label = i->label;
|
|
acc_cond::mark_t acc = i->acc;
|
|
|
|
// compute the next expected state
|
|
const state* next;
|
|
++i;
|
|
if (i != l->end())
|
|
{
|
|
next = i->s;
|
|
}
|
|
else
|
|
{
|
|
if (l == &run->prefix)
|
|
{
|
|
l = &run->cycle;
|
|
in = "cycle";
|
|
i = l->begin();
|
|
if (!debug)
|
|
os << "Cycle:\n";
|
|
}
|
|
next = l->begin()->s;
|
|
}
|
|
|
|
// browse the actual outgoing transitions
|
|
tgba_succ_iterator* j = a->succ_iter(s);
|
|
// When not debugging, S is not used as key in SEEN, so we can
|
|
// destroy it right now.
|
|
if (!debug)
|
|
s->destroy();
|
|
if (j->first())
|
|
do
|
|
{
|
|
if (j->current_condition() != label
|
|
|| j->current_acceptance_conditions() != acc)
|
|
continue;
|
|
|
|
const state* s2 = j->current_state();
|
|
if (s2->compare(next))
|
|
{
|
|
s2->destroy();
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
s = s2;
|
|
break;
|
|
}
|
|
}
|
|
while (j->next());
|
|
if (j->done())
|
|
{
|
|
if (debug)
|
|
{
|
|
os << "ERROR: no transition with label="
|
|
<< bdd_format_formula(a->get_dict(), label)
|
|
<< " and acc=" << a->acc().format(acc)
|
|
<< " leaving state " << serial
|
|
<< " for state " << a->format_state(next) << '\n'
|
|
<< "The following transitions leave state " << serial
|
|
<< ":\n";
|
|
if (j->first())
|
|
do
|
|
{
|
|
const state* s2 = j->current_state();
|
|
os << " *";
|
|
print_annotation(os, a, j);
|
|
os << " label="
|
|
<< bdd_format_formula(a->get_dict(),
|
|
j->current_condition())
|
|
<< " and acc="
|
|
<< a->acc().format(j->current_acceptance_conditions())
|
|
<< " going to " << a->format_state(s2) << '\n';
|
|
s2->destroy();
|
|
}
|
|
while (j->next());
|
|
}
|
|
a->release_iter(j);
|
|
s->destroy();
|
|
return false;
|
|
}
|
|
if (debug)
|
|
{
|
|
os << "transition";
|
|
print_annotation(os, a, j);
|
|
os << " with label="
|
|
<< bdd_format_formula(a->get_dict(), label)
|
|
<< " and acc=" << a->acc().format(acc)
|
|
<< std::endl;
|
|
}
|
|
else
|
|
{
|
|
os << " | ";
|
|
print_annotation(os, a, j);
|
|
bdd_print_formula(os, a->get_dict(), label);
|
|
os << '\t';
|
|
a->acc().format(acc);
|
|
os << std::endl;
|
|
}
|
|
a->release_iter(j);
|
|
|
|
// Sum acceptance conditions.
|
|
//
|
|
// (Beware l and i designate the next step to consider.
|
|
// Therefore if i is at the beginning of the cycle, `acc'
|
|
// contains the acceptance conditions of the last transition
|
|
// in the prefix; we should not account it.)
|
|
if (l == &run->cycle && i != l->begin())
|
|
{
|
|
all_acc |= acc;
|
|
if (!all_acc_seen && a->acc().accepting(all_acc))
|
|
{
|
|
all_acc_seen = true;
|
|
if (debug)
|
|
os << "all acceptance conditions ("
|
|
<< a->acc().format(all_acc)
|
|
<< ") have been seen\n";
|
|
}
|
|
}
|
|
}
|
|
s->destroy();
|
|
if (!a->acc().accepting(all_acc))
|
|
{
|
|
if (debug)
|
|
os << "ERROR: The cycle's acceptance conditions ("
|
|
<< a->acc().format(all_acc)
|
|
<< ") do not\nmatch those of the automaton ("
|
|
<< a->acc().format(a->acc().all_sets())
|
|
<< ")\n";
|
|
return false;
|
|
}
|
|
|
|
state_map::const_iterator o = seen.begin();
|
|
while (o != seen.end())
|
|
{
|
|
// Advance the iterator before deleting the "key" pointer.
|
|
const state* ptr = o->first;
|
|
++o;
|
|
ptr->destroy();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|