mc: merge deadlock and reachabilty algorithms

* spot/mc/deadlock.hh,
spot/mc/mc.hh,
spot/mc/mc_instanciator.hh,
tests/ltsmin/modelcheck.cc: Here.
This commit is contained in:
Etienne Renault 2020-05-13 13:51:09 +02:00
parent 1736a7364c
commit 369a8b8b14
4 changed files with 32 additions and 7 deletions

View file

@ -35,8 +35,11 @@ namespace spot
/// \brief This class aims to explore a model to detect wether it /// \brief This class aims to explore a model to detect wether it
/// contains a deadlock. This deadlock detection performs a DFS traversal /// contains a deadlock. This deadlock detection performs a DFS traversal
/// sharing information shared among multiple threads. /// sharing information shared among multiple threads.
/// If Deadlock equals std::true_type performs dealock algorithm,
/// otherwise perform a simple reachability.
template<typename State, typename SuccIterator, template<typename State, typename SuccIterator,
typename StateHash, typename StateEqual> typename StateHash, typename StateEqual,
typename Deadlock>
class SPOT_API swarmed_deadlock class SPOT_API swarmed_deadlock
{ {
/// \brief Describes the status of a state /// \brief Describes the status of a state
@ -79,6 +82,9 @@ namespace spot
} }
}; };
static constexpr bool compute_deadlock =
std::is_same<std::true_type, Deadlock>::value;
public: public:
///< \brief Shortcut to ease shared map manipulation ///< \brief Shortcut to ease shared map manipulation
@ -132,7 +138,7 @@ namespace spot
if (SPOT_LIKELY(pop())) if (SPOT_LIKELY(pop()))
{ {
deadlock_ = todo_.back().current_tr == transitions_; deadlock_ = todo_.back().current_tr == transitions_;
if (deadlock_) if (compute_deadlock && deadlock_)
break; break;
sys_.recycle(todo_.back().it, tid_); sys_.recycle(todo_.back().it, tid_);
todo_.pop_back(); todo_.pop_back();
@ -234,7 +240,9 @@ namespace spot
std::string name() std::string name()
{ {
if (compute_deadlock)
return "deadlock"; return "deadlock";
return "reachability";
} }
int sccs() int sccs()
@ -244,7 +252,9 @@ namespace spot
mc_rvalue result() mc_rvalue result()
{ {
if (compute_deadlock)
return deadlock_ ? mc_rvalue::DEADLOCK : mc_rvalue::NO_DEADLOCK; return deadlock_ ? mc_rvalue::DEADLOCK : mc_rvalue::NO_DEADLOCK;
return mc_rvalue::SUCCESS;
} }
std::string trace() std::string trace()

View file

@ -32,6 +32,7 @@ namespace spot
BLOEMEN_SCC, ///< \brief Bloemen.16.ppopp SCC computation BLOEMEN_SCC, ///< \brief Bloemen.16.ppopp SCC computation
CNDFS, ///< \brief Evangelista.12.atva emptiness check CNDFS, ///< \brief Evangelista.12.atva emptiness check
DEADLOCK, ///< \brief Check wether there is a deadlock DEADLOCK, ///< \brief Check wether there is a deadlock
REACHABILITY, ///< \brief Only perform a reachability algorithm
SWARMING, ///< \brief Holzmann.11.ieee applied to renault.13.lpar SWARMING, ///< \brief Holzmann.11.ieee applied to renault.13.lpar
}; };
@ -70,6 +71,8 @@ namespace spot
os << "cndfs"; break; os << "cndfs"; break;
case mc_algorithm::DEADLOCK: case mc_algorithm::DEADLOCK:
os << "deadlock"; break; os << "deadlock"; break;
case mc_algorithm::REACHABILITY:
os << "reachability"; break;
case mc_algorithm::SWARMING: case mc_algorithm::SWARMING:
os << "swarming"; break; os << "swarming"; break;
} }

View file

@ -187,7 +187,13 @@ namespace spot
kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace); kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
case mc_algorithm::DEADLOCK: case mc_algorithm::DEADLOCK:
return instanciate<spot::swarmed_deadlock<State, Iterator, Hash, Equal>, return instanciate
<spot::swarmed_deadlock<State, Iterator, Hash, Equal, std::true_type>,
kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
case mc_algorithm::REACHABILITY:
return instanciate
<spot::swarmed_deadlock<State, Iterator, Hash, Equal, std::false_type>,
kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace); kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
case mc_algorithm::SWARMING: case mc_algorithm::SWARMING:

View file

@ -134,6 +134,10 @@ parse_opt_finput(int key, char* arg, struct argp_state*)
mc_options.nb_threads = to_unsigned(arg, "-p/--parallel"); mc_options.nb_threads = to_unsigned(arg, "-p/--parallel");
mc_options.force_parallel = true; mc_options.force_parallel = true;
break; break;
case 'r':
mc_options.algorithm = spot::mc_algorithm::REACHABILITY;
mc_options.force_parallel = true;
break;
case 's': case 's':
mc_options.dead_ap = arg; mc_options.dead_ap = arg;
break; break;
@ -184,6 +188,8 @@ static const argp_option options[] =
"is found." "is found."
, 0 }, , 0 },
{ "parallel", 'p', "INT", 0, "use INT threads (when possible)", 0 }, { "parallel", 'p', "INT", 0, "use INT threads (when possible)", 0 },
{ "reachability", 'r', nullptr, 0, "performs a traversal of the model "
, 0 },
{ "selfloopize", 's', "STRING", 0, { "selfloopize", 's', "STRING", 0,
"use STRING as property for marking deadlock " "use STRING as property for marking deadlock "
"states (by default selfloopize is activated with STRING='true')", 0 }, "states (by default selfloopize is activated with STRING='true')", 0 },