postproc: introduce -x merge-states-min

* spot/twaalgos/postproc.cc, spot/twaalgos/postproc.hh: Introduce a
merge-states-min option.
* bin/spot-x.cc: Document it.
* spot/gen/automata.cc, spot/gen/automata.hh, bin/genaut.cc: Add
option to generate cyclist test cases.
* NEWS: Document the above.
* tests/core/included.test: Add test cases that used to be too slow.
This commit is contained in:
Alexandre Duret-Lutz 2022-09-13 13:53:59 +02:00
parent d9248e2e97
commit b3b22388c9
8 changed files with 99 additions and 8 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2017-2019, 2021 Laboratoire de Recherche et
// Copyright (C) 2017-2019, 2021-2022 Laboratoire de Recherche et
// Developpement de l'EPITA (LRDE).
//
// This file is part of Spot, a model checking library.
@ -220,13 +220,48 @@ namespace spot
return aut;
}
static twa_graph_ptr
cyclist_trace_or_proof(unsigned n, bool trace, bdd_dict_ptr dict)
{
auto aut = make_twa_graph(dict);
acc_cond::mark_t m = aut->set_buchi();
aut->new_states(n + 2);
aut->set_init_state(0);
if (trace)
m = {};
aut->prop_state_acc(true);
// How many AP to we need to represent n letters
unsigned nap = ulog2(n + 1);
std::vector<int> apvars(nap);
for (unsigned a = 0; a < nap; ++a)
apvars[a] = aut->register_ap("p" + std::to_string(a));
if (trace)
aut->new_edge(0, 0, bddtrue); // the only non-deterministic edge
else
aut->prop_universal(true);
bdd zero = bdd_ibuildcube(0, nap, apvars.data());
aut->new_edge(0, 1, zero, m);
for (unsigned letter = 1; letter <= n; ++letter)
{
bdd cond = bdd_ibuildcube(letter, nap, apvars.data());
aut->new_acc_edge(1, letter + 1, cond);
aut->new_edge(letter + 1, 1, zero, m);
}
return aut;
}
twa_graph_ptr aut_pattern(aut_pattern_id pattern, int n, bdd_dict_ptr dict)
{
if (n < 0)
{
std::ostringstream err;
err << "pattern argument for " << aut_pattern_name(pattern)
<< " should be positive";
<< " should be non-negative";
throw std::runtime_error(err.str());
}
@ -241,6 +276,10 @@ namespace spot
return l_dsa(n, dict);
case AUT_M_NBA:
return m_nba(n, dict);
case AUT_CYCLIST_TRACE_NBA:
return cyclist_trace_or_proof(n, true, dict);
case AUT_CYCLIST_PROOF_DBA:
return cyclist_trace_or_proof(n, false, dict);
case AUT_END:
break;
}
@ -255,6 +294,8 @@ namespace spot
"l-nba",
"l-dsa",
"m-nba",
"cyclist-trace-nba",
"cyclist-proof-dba",
};
// Make sure we do not forget to update the above table every
// time a new pattern is added.

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2017, 2019 Laboratoire de Recherche et Developpement de
// Copyright (C) 2017, 2019, 2022 Laboratoire de Recherche et Developpement de
// l'EPITA (LRDE).
//
// This file is part of Spot, a model checking library.
@ -79,6 +79,24 @@ namespace spot
/// propositions to encode the $n+1$ letters used in the
/// original alphabet.
AUT_M_NBA,
/// \brief An NBA with (n+2) states derived from a Cyclic test
/// case.
///
/// This familly of automata is derived from a couple of
/// examples supplied by Reuben Rowe. The task is to
/// check that the automaton generated with AUT_CYCLIST_TRACE_NBA
/// for a given n contain the automaton generated with
/// AUT_CYCLIST_PROOF_DBA for the same n.
AUT_CYCLIST_TRACE_NBA,
/// \brief A DBA with (n+2) states derived from a Cyclic test
/// case.
///
/// This familly of automata is derived from a couple of
/// examples supplied by Reuben Rowe. The task is to
/// check that the automaton generated with AUT_CYCLIST_TRACE_NBA
/// for a given n contain the automaton generated with
/// AUT_CYCLIST_PROOF_DBA for the same n.
AUT_CYCLIST_PROOF_DBA,
AUT_END
};

View file

@ -89,6 +89,7 @@ namespace spot
wdba_minimize_ = opt->get("wdba-minimize", -1);
gen_reduce_parity_ = opt->get("gen-reduce-parity", 1);
simul_max_ = opt->get("simul-max", 4096);
merge_states_min_ = opt->get("merge-states-min", 128);
wdba_det_max_ = opt->get("wdba-det-max", 4096);
simul_trans_pruning_ = opt->get("simul-trans-pruning", 512);
@ -118,6 +119,9 @@ namespace spot
{
if (opt == 0)
return a;
if (merge_states_min_ > 0
&& static_cast<unsigned>(merge_states_min_) < a->num_states())
a->merge_states();
if (simul_max_ > 0 && static_cast<unsigned>(simul_max_) < a->num_states())
return a;

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012-2021 Laboratoire de Recherche et Développement
// Copyright (C) 2012-2022 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -268,6 +268,7 @@ namespace spot
bool state_based_ = false;
int wdba_minimize_ = -1;
int simul_max_ = 4096;
int merge_states_min_ = 128;
int wdba_det_max_ = 4096;
};
/// @}