* 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
245 lines
9.3 KiB
C++
245 lines
9.3 KiB
C++
// -*- coding: utf-8 -*-
|
|
// Copyright (C) 2008, 2013, 2014, 2015, 2016 Laboratoire de Recherche
|
|
// et Développement de l'Epita (LRDE).
|
|
// Copyright (C) 2003, 2004, 2005, 2006 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/>.
|
|
|
|
#pragma once
|
|
|
|
#include <stack>
|
|
#include <spot/twaalgos/gtec/status.hh>
|
|
#include <spot/twaalgos/emptiness.hh>
|
|
#include <spot/twaalgos/emptiness_stats.hh>
|
|
|
|
namespace spot
|
|
{
|
|
/// \addtogroup emptiness_check_algorithms
|
|
/// @{
|
|
|
|
/// \brief Check whether the language of an automate is empty.
|
|
///
|
|
/// This is based on the following paper.
|
|
/** \verbatim
|
|
@InProceedings{couvreur.99.fm,
|
|
author = {Jean-Michel Couvreur},
|
|
title = {On-the-fly Verification of Temporal Logic},
|
|
pages = {253--271},
|
|
editor = {Jeannette M. Wing and Jim Woodcock and Jim Davies},
|
|
booktitle = {Proceedings of the World Congress on Formal Methods in
|
|
the Development of Computing Systems (FM'99)},
|
|
publisher = {Springer-Verlag},
|
|
series = {Lecture Notes in Computer Science},
|
|
volume = {1708},
|
|
year = {1999},
|
|
address = {Toulouse, France},
|
|
month = {September},
|
|
isbn = {3-540-66587-0}
|
|
}
|
|
\endverbatim */
|
|
///
|
|
/// A recursive definition of the algorithm would look as follows,
|
|
/// but the implementation is of course not recursive.
|
|
/// (<code><Sigma, Q, delta, q, F></code> is the automaton to
|
|
/// check, H is an associative array mapping each state to its
|
|
/// positive DFS order or 0 if it is dead, SCC is and ACC are two
|
|
/// stacks.)
|
|
///
|
|
/** \verbatim
|
|
check(<Sigma, Q, delta, q, F>, H, SCC, ACC)
|
|
if q is not in H // new state
|
|
H[q] = H.size + 1
|
|
SCC.push(<H[q], {}>)
|
|
forall <a, s> : <q, _, a, s> in delta
|
|
ACC.push(a)
|
|
res = check(<Sigma, Q, delta, s, F>, H, SCC, ACC)
|
|
if res
|
|
return res
|
|
<n, _> = SCC.top()
|
|
if n = H[q]
|
|
SCC.pop()
|
|
mark_reachable_states_as_dead(<Sigma, Q, delta, q, F>, H$)
|
|
return 0
|
|
else
|
|
if H[q] = 0 // dead state
|
|
ACC.pop()
|
|
return true
|
|
else // state in stack: merge SCC
|
|
all = {}
|
|
do
|
|
<n, a> = SCC.pop()
|
|
all = all union a union { ACC.pop() }
|
|
until n <= H[q]
|
|
SCC.push(<n, all>)
|
|
if all != F
|
|
return 0
|
|
return new emptiness_check_result(necessary data)
|
|
\endverbatim */
|
|
///
|
|
/// check() returns 0 iff the automaton's language is empty. It
|
|
/// returns an instance of emptiness_check_result. If the automaton
|
|
/// accept a word. (Use emptiness_check_result::accepting_run() to
|
|
/// extract an accepting run.)
|
|
///
|
|
/// There are two variants of this algorithm: spot::couvreur99_check and
|
|
/// spot::couvreur99_check_shy. They differ in their memory usage, the
|
|
/// number for successors computed before they are used and the way
|
|
/// the depth first search is directed.
|
|
///
|
|
/// spot::couvreur99_check performs a straightforward depth first search.
|
|
/// The DFS stacks store twa_succ_iterators, so that only the
|
|
/// iterators which really are explored are computed.
|
|
///
|
|
/// spot::couvreur99_check_shy tries to explore successors which are
|
|
/// visited states first. this helps to merge SCCs and generally
|
|
/// helps to produce shorter counter-examples. However this
|
|
/// algorithm cannot stores unprocessed successors as
|
|
/// twa_succ_iterators: it must compute all successors of a state
|
|
/// at once in order to decide which to explore first, and must keep
|
|
/// a list of all unexplored successors in its DFS stack.
|
|
///
|
|
/// The couvreur99() function is a wrapper around these two flavors
|
|
/// of the algorithm. \a options is an option map that specifies
|
|
/// which algorithms should be used, and how.
|
|
///
|
|
/// The following options are available.
|
|
/// \li \c "shy" : if non zero, then spot::couvreur99_check_shy is used,
|
|
/// otherwise (and by default) spot::couvreur99_check is used.
|
|
///
|
|
/// \li \c "poprem" : specifies how the algorithm should handle the
|
|
/// destruction of non-accepting maximal strongly connected
|
|
/// components. If \c poprem is non null, the algorithm will keep a
|
|
/// list of all states of a SCC that are fully processed and should
|
|
/// be removed once the MSCC is popped. If \c poprem is null (the
|
|
/// default), the MSCC will be traversed again (i.e. generating the
|
|
/// successors of the root recursively) for deletion. This is a
|
|
/// choice between memory and speed.
|
|
///
|
|
/// \li \c "group" : this options is used only by spot::couvreur99_check_shy.
|
|
/// If non null (the default), the successors of all the
|
|
/// states that belong to the same SCC will be considered when
|
|
/// choosing a successor. Otherwise, only the successor of the
|
|
/// topmost state on the DFS stack are considered.
|
|
SPOT_API emptiness_check_ptr
|
|
couvreur99(const const_twa_ptr& a, option_map options = option_map());
|
|
|
|
#ifndef SWIG
|
|
/// \brief An implementation of the Couvreur99 emptiness-check algorithm.
|
|
///
|
|
/// See the documentation for spot::couvreur99.
|
|
class SPOT_API couvreur99_check: public emptiness_check, public ec_statistics
|
|
{
|
|
public:
|
|
couvreur99_check(const const_twa_ptr& a, option_map o = option_map());
|
|
|
|
virtual ~couvreur99_check();
|
|
|
|
/// Check whether the automaton's language is empty.
|
|
virtual emptiness_check_result_ptr check() override;
|
|
|
|
virtual std::ostream& print_stats(std::ostream& os) const override;
|
|
|
|
/// \brief Return the status of the emptiness-check.
|
|
///
|
|
/// When check() succeed, the status should be passed along
|
|
/// to spot::counter_example.
|
|
///
|
|
/// This status should not be deleted, it is a pointer
|
|
/// to a member of this class that will be deleted when
|
|
/// the couvreur99 object is deleted.
|
|
std::shared_ptr<const couvreur99_check_status> result() const;
|
|
|
|
protected:
|
|
std::shared_ptr<couvreur99_check_status> ecs_;
|
|
/// \brief Remove a strongly component from the hash.
|
|
///
|
|
/// This function remove all accessible state from a given
|
|
/// state. In other words, it removes the strongly connected
|
|
/// component that contains this state.
|
|
void remove_component(const state* start_delete);
|
|
|
|
/// Whether to store the state to be removed.
|
|
bool poprem_;
|
|
/// Number of dead SCC removed by the algorithm.
|
|
unsigned removed_components;
|
|
unsigned get_removed_components() const;
|
|
unsigned get_vmsize() const;
|
|
};
|
|
|
|
/// \brief A version of spot::couvreur99_check that tries to visit
|
|
/// known states first.
|
|
///
|
|
/// See the documentation for spot::couvreur99.
|
|
class SPOT_API couvreur99_check_shy final: public couvreur99_check
|
|
{
|
|
public:
|
|
couvreur99_check_shy(const const_twa_ptr& a, option_map o = option_map());
|
|
virtual ~couvreur99_check_shy();
|
|
|
|
virtual emptiness_check_result_ptr check() override;
|
|
|
|
protected:
|
|
struct successor {
|
|
acc_cond::mark_t acc;
|
|
const spot::state* s;
|
|
successor(acc_cond::mark_t acc, const spot::state* s): acc(acc), s(s) {}
|
|
};
|
|
|
|
// We use five main data in this algorithm:
|
|
// * couvreur99_check::root, a stack of strongly connected components (SCC),
|
|
// * couvreur99_check::h, a hash of all visited nodes, with their order,
|
|
// (it is called "Hash" in Couvreur's paper)
|
|
// * arc, a stack of acceptance conditions between each of these SCC,
|
|
std::stack<acc_cond::mark_t> arc;
|
|
// * num, the number of visited nodes. Used to set the order of each
|
|
// visited node,
|
|
int num;
|
|
// * todo, the depth-first search stack. This holds pairs of the
|
|
// form (STATE, SUCCESSORS) where SUCCESSORS is a list of
|
|
// (ACCEPTANCE_CONDITIONS, STATE) pairs.
|
|
typedef std::list<successor> succ_queue;
|
|
|
|
// Position in the loop seeking known successors.
|
|
succ_queue::iterator pos;
|
|
|
|
struct todo_item
|
|
{
|
|
const state* s;
|
|
int n;
|
|
succ_queue q; // Unprocessed successors of S
|
|
todo_item(const state* s, int n, couvreur99_check_shy* shy);
|
|
};
|
|
|
|
typedef std::list<todo_item> todo_list;
|
|
todo_list todo;
|
|
|
|
void clear_todo();
|
|
|
|
/// Dump the queue for debugging.
|
|
void dump_queue(std::ostream& os = std::cerr);
|
|
|
|
/// Whether successors should be grouped for states in the same SCC.
|
|
bool group_;
|
|
// If the "group2" option is set (it implies "group"), we
|
|
// reprocess the successor states of SCC that have been merged.
|
|
bool group2_;
|
|
};
|
|
#endif
|
|
|
|
/// @}
|
|
}
|