twaalgos/cobuchi: Add dnf_to_nca() method

* NEWS: Update.
* spot/twaalgos/cobuchi.hh: Declare dnf_to_nca().
* spot/twaalgos/cobuchi.cc: Implement it.
* tests/core/dca.test: Add tests.
This commit is contained in:
Alexandre GBAGUIDI AISSE 2017-06-17 21:31:43 +02:00
parent 50e99cdca7
commit f2616069be
4 changed files with 343 additions and 12 deletions

View file

@ -28,6 +28,13 @@
#include <stack>
#include <unordered_map>
#define DEBUG 0
#if DEBUG
#define debug std::cerr
#else
#define debug while (0) std::cout
#endif
namespace spot
{
namespace
@ -249,14 +256,45 @@ namespace spot
}
twa_graph_ptr
dnf_to_nca(const const_twa_graph_ptr& ref,
bool named_states,
vect_nca_info* nca_info)
{
const acc_cond::acc_code& code = ref->get_acceptance();
if (!code.is_dnf())
throw std::runtime_error("dnf_to_nca() only works with DNF acceptance "
"condition");
auto streett_aut = spot::dnf_to_streett(ref, true);
std::vector<acc_cond::rs_pair> pairs;
if (!streett_aut->acc().is_streett_like(pairs))
throw std::runtime_error("dnf_to_nca() could not convert the original "
"automaton into an intermediate Streett-like automaton");
nsa_to_nca_converter nca_converter(streett_aut,
ref,
pairs,
named_states,
true,
ref->num_states());
return nca_converter.run(nca_info);
}
twa_graph_ptr
to_dca(const const_twa_graph_ptr& aut, bool named_states)
{
const acc_cond::acc_code& code = aut->get_acceptance();
std::vector<acc_cond::rs_pair> pairs;
if (aut->acc().is_streett_like(pairs) || aut->acc().is_parity())
return nsa_to_nca(aut, named_states);
else if (code.is_dnf())
return dnf_to_nca(aut, named_states);
else
throw std::runtime_error("to_dca() only works with Streett-like or Parity"
" acceptance condition");
throw std::runtime_error("to_dca() only works with Streett-like, Parity "
"or any acceptance condition in DNF");
}
}

View file

@ -26,9 +26,10 @@
namespace spot
{
/// A vector of nca_st_info is given as argument to nsa_to_nca(). Each
/// nca_st_info has information about a state that must be seen infinitely
/// often. For a state 's' visited infinitely often by a run, the information
/// A vector of nca_st_info is given as argument to nsa_to_nca() or
/// dnf_to_nca(). Each nca_st_info has information about a state that must be
/// seen infinitely often.
/// For a state 's' visited infinitely often by a run, the information
/// provided is:
/// - the clause number satisfied by the run (from left to right)
/// - the state number of 's'
@ -81,6 +82,31 @@ namespace spot
bool named_states = false,
vect_nca_info* nca_info = nullptr);
/// \brief Converts an aut. with acceptance in DNF to a nondet. co-Büchi aut.
///
/// This function converts the Rabin-like automaton into a Strett-like
/// automaton and then calls nsa_to_nca() on it. It is described in section
/// 3.2 of:
/** \verbatim
@Article{boker.2009.lcs,
author = {Udi Boker and Orna Kupferman},
title = {Co-Büching Them All},
booktitle = {Foundations of Software Science and Computational
Structures - 14th International Conference, FOSSACS 2011}
year = {2011},
pages = {184--198},
url = {\url{www.cs.huji.ac.il/~ornak/publications/fossacs11b.pdf}}
}
\endverbatim */
///
/// \a aut The automaton to convert.
/// \a named_states name each state for easier debugging.
/// \a nca_info retrieve information about state visited infinitely often.
SPOT_API twa_graph_ptr
dnf_to_nca(const const_twa_graph_ptr& aut,
bool named_states = false,
vect_nca_info* nca_info = nullptr);
/// \brief Converts any ω-automata to det. co-buchi (when possible)
///
/// The resulting automaton will always recognize at least the same language.