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.
303 lines
8.7 KiB
C++
303 lines
8.7 KiB
C++
// -*- coding: utf-8 -*-
|
|
// Copyright (C) 2010, 2012, 2013, 2014 Laboratoire de Recherche et
|
|
// Developpement de l Epita (LRDE).
|
|
//
|
|
// 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/>.
|
|
|
|
#ifndef SPOT_TA_TA_HH
|
|
# define SPOT_TA_TA_HH
|
|
|
|
#include <set>
|
|
|
|
#include <cassert>
|
|
#include "misc/bddlt.hh"
|
|
#include "tgba/tgba.hh"
|
|
#include "tgba/bdddict.hh"
|
|
|
|
namespace spot
|
|
{
|
|
|
|
// Forward declarations. See below.
|
|
class ta_succ_iterator;
|
|
|
|
/// \defgroup ta TA (Testing Automata)
|
|
///
|
|
/// This type and its cousins are listed \ref ta_essentials "here".
|
|
/// This is an abstract interface. Its implementations are \ref
|
|
/// ta_representation "concrete representations". The
|
|
/// algorithms that work on spot::ta are \ref tgba_algorithms
|
|
/// "listed separately".
|
|
|
|
/// \addtogroup ta_essentials Essential TA types
|
|
/// \ingroup ta
|
|
|
|
/// \ingroup ta_essentials
|
|
/// \brief A Testing Automaton.
|
|
///
|
|
/// The Testing Automata (TA) were introduced by
|
|
/// Henri Hansen, Wojciech Penczek and Antti Valmari
|
|
/// in "Stuttering-insensitive automata for on-the-fly detection of livelock
|
|
/// properties" In Proc. of FMICSÕ02, vol. 66(2) of Electronic Notes in
|
|
/// Theoretical Computer Science.Elsevier.
|
|
///
|
|
/// While a TGBA automaton observes the value of the atomic propositions, the
|
|
/// basic idea of TA is to detect the changes in these values; if a valuation
|
|
/// does not change between two consecutive valuations of an execution,
|
|
/// the TA stay in the same state. A TA transition \c (s,k,d) is labeled by a
|
|
/// "changeset" \c k: i.e. the set of atomic propositions that change between
|
|
/// states \c s and \c d, if the changeset is empty then the transition is
|
|
/// called stuttering transition.
|
|
/// To detect execution that ends by stuttering in the same TA state, a
|
|
/// new kind of acceptance states is introduced: "livelock-acceptance states"
|
|
/// (in addition to the standard Buchi-acceptance states).
|
|
///
|
|
/// Browsing such automaton can be achieved using two functions:
|
|
/// \c get_initial_states_set or \c get_artificial_initial_state, and \c
|
|
/// succ_iter. The former returns the initial state(s) while the latter lists
|
|
/// the successor states of any state (filtred by "changeset").
|
|
///
|
|
/// Note that although this is a transition-based automata,
|
|
/// we never represent transitions! Transition informations are
|
|
/// obtained by querying the iterator over the successors of
|
|
/// a state.
|
|
|
|
class SPOT_API ta
|
|
{
|
|
protected:
|
|
acc_cond acc_;
|
|
|
|
public:
|
|
ta(const bdd_dict_ptr& d)
|
|
: acc_(d)
|
|
{
|
|
}
|
|
|
|
virtual
|
|
~ta()
|
|
{
|
|
}
|
|
|
|
typedef std::set<state*, state_ptr_less_than> states_set_t;
|
|
|
|
/// \brief Get the initial states set of the automaton.
|
|
virtual const states_set_t
|
|
get_initial_states_set() const = 0;
|
|
|
|
/// \brief Get the artificial initial state set of the automaton.
|
|
/// Return 0 if this artificial state is not implemented
|
|
/// (in this case, use \c get_initial_states_set)
|
|
/// The aim of adding this state is to have an unique initial state. This
|
|
/// artificial initial state have one transition to each real initial state,
|
|
/// and this transition is labeled by the corresponding initial condition.
|
|
/// (For more details, see the paper cited above)
|
|
virtual spot::state*
|
|
get_artificial_initial_state() const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// \brief Get an iterator over the successors of \a state.
|
|
///
|
|
/// The iterator has been allocated with \c new. It is the
|
|
/// responsability of the caller to \c delete it when no
|
|
/// longer needed.
|
|
///
|
|
virtual ta_succ_iterator*
|
|
succ_iter(const spot::state* state) const = 0;
|
|
|
|
/// \brief Get an iterator over the successors of \a state
|
|
/// filtred by the changeset on transitions
|
|
///
|
|
/// The iterator has been allocated with \c new. It is the
|
|
/// responsability of the caller to \c delete it when no
|
|
/// longer needed.
|
|
///
|
|
virtual ta_succ_iterator*
|
|
succ_iter(const spot::state* state, bdd changeset) const = 0;
|
|
|
|
/// \brief Get the dictionary associated to the automaton.
|
|
///
|
|
/// State are represented as BDDs. The dictionary allows
|
|
/// to map BDD variables back to formulae, and vice versa.
|
|
/// This is useful when dealing with several automata (which
|
|
/// may use the same BDD variable for different formula),
|
|
/// or simply when printing.
|
|
bdd_dict_ptr
|
|
get_dict() const
|
|
{
|
|
return acc_.get_dict();
|
|
}
|
|
|
|
/// \brief Format the state as a string for printing.
|
|
///
|
|
/// This formating is the responsability of the automata
|
|
/// that owns the state.
|
|
virtual std::string
|
|
format_state(const spot::state* s) const = 0;
|
|
|
|
/// \brief Return true if \a s is a Buchi-accepting state, otherwise false
|
|
virtual bool
|
|
is_accepting_state(const spot::state* s) const = 0;
|
|
|
|
/// \brief Return true if \a s is a livelock-accepting state
|
|
/// , otherwise false
|
|
virtual bool
|
|
is_livelock_accepting_state(const spot::state* s) const = 0;
|
|
|
|
/// \brief Return true if \a s is an initial state, otherwise false
|
|
virtual bool
|
|
is_initial_state(const spot::state* s) const = 0;
|
|
|
|
/// \brief Return a BDD condition that represents the valuation
|
|
/// of atomic propositions in the state \a s
|
|
virtual bdd
|
|
get_state_condition(const spot::state* s) const = 0;
|
|
|
|
/// \brief Release a state \a s
|
|
virtual void
|
|
free_state(const spot::state* s) const = 0;
|
|
|
|
|
|
const acc_cond& acc() const
|
|
{
|
|
return acc_;
|
|
}
|
|
|
|
acc_cond& acc()
|
|
{
|
|
return acc_;
|
|
}
|
|
|
|
};
|
|
|
|
typedef std::shared_ptr<ta> ta_ptr;
|
|
typedef std::shared_ptr<const ta> const_ta_ptr;
|
|
|
|
/// \ingroup ta_essentials
|
|
/// \brief Iterate over the successors of a state.
|
|
///
|
|
/// This class provides the basic functionalities required to
|
|
/// iterate over the successors of a state, as well as querying
|
|
/// transition labels. Because transitions are never explicitely
|
|
/// encoded, labels (conditions and acceptance conditions) can only
|
|
/// be queried while iterating over the successors.
|
|
class ta_succ_iterator : public tgba_succ_iterator
|
|
{
|
|
public:
|
|
virtual
|
|
~ta_succ_iterator()
|
|
{
|
|
}
|
|
|
|
virtual bool first() = 0;
|
|
virtual bool next() = 0;
|
|
virtual bool done() const = 0;
|
|
|
|
virtual state*
|
|
current_state() const = 0;
|
|
|
|
/// \brief Get the changeset on the transition leading to current successor.
|
|
///
|
|
/// This is a boolean function of atomic propositions.
|
|
virtual bdd
|
|
current_condition() const = 0;
|
|
|
|
acc_cond::mark_t
|
|
current_acceptance_conditions() const = 0;
|
|
|
|
};
|
|
|
|
#ifndef SWIG
|
|
// A stack of Strongly-Connected Components
|
|
class scc_stack_ta
|
|
{
|
|
public:
|
|
struct connected_component
|
|
{
|
|
public:
|
|
connected_component(int index = -1);
|
|
|
|
/// Index of the SCC.
|
|
int index;
|
|
|
|
bool is_accepting;
|
|
|
|
/// The bdd condition is the union of all acceptance conditions of
|
|
/// transitions which connect the states of the connected component.
|
|
acc_cond::mark_t condition;
|
|
|
|
std::list<state*> rem;
|
|
};
|
|
|
|
/// Stack a new SCC with index \a index.
|
|
void
|
|
push(int index);
|
|
|
|
/// Access the top SCC.
|
|
connected_component&
|
|
top();
|
|
|
|
/// Access the top SCC.
|
|
const connected_component&
|
|
top() const;
|
|
|
|
/// Pop the top SCC.
|
|
void
|
|
pop();
|
|
|
|
/// How many SCC are in stack.
|
|
size_t
|
|
size() const;
|
|
|
|
/// The \c rem member of the top SCC.
|
|
std::list<state*>&
|
|
rem();
|
|
|
|
/// Is the stack empty?
|
|
bool
|
|
empty() const;
|
|
|
|
typedef std::list<connected_component> stack_type;
|
|
stack_type s;
|
|
};
|
|
#endif // !SWIG
|
|
|
|
/// \addtogroup ta_representation TA representations
|
|
/// \ingroup ta
|
|
|
|
/// \addtogroup ta_algorithms TA algorithms
|
|
/// \ingroup ta
|
|
|
|
/// \addtogroup ta_io Input/Output of TA
|
|
/// \ingroup ta_algorithms
|
|
|
|
/// \addtogroup tgba_ta Transforming TGBA into TA
|
|
/// \ingroup ta_algorithms
|
|
|
|
|
|
/// \addtogroup ta_generic Algorithm patterns
|
|
/// \ingroup ta_algorithms
|
|
|
|
/// \addtogroup ta_reduction TA simplifications
|
|
/// \ingroup ta_algorithms
|
|
|
|
/// \addtogroup ta_misc Miscellaneous algorithms on TA
|
|
/// \ingroup ta_algorithms
|
|
|
|
|
|
}
|
|
|
|
#endif // SPOT_TA_TA_HH
|