postproc: option to wdba-minimize only when sure

Fixes #15.

* spot/twaalgos/minimize.hh, spot/twaalgos/minimize.cc
(minimize_obligation_garanteed_to_work): New function.
* spot/twaalgos/postproc.hh, spot/twaalgos/postproc.cc: Use it if
wdba-minimize=1.  Handle new default for wdba-minimize.
* NEWS, bin/spot-x.cc: Document those changes.
* tests/core/ltl2tgba2.test: Add some test cases.
* tests/core/genltl.test: Improve expected results.
This commit is contained in:
Alexandre Duret-Lutz 2020-05-21 15:42:05 +02:00
parent 8744751ec0
commit 64aee87d76
8 changed files with 79 additions and 22 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2010-2019 Laboratoire de Recherche et Développement
// Copyright (C) 2010-2020 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -567,6 +567,16 @@ namespace spot
return product(min_aut, aut_neg)->is_empty();
}
bool minimize_obligation_garanteed_to_work(const const_twa_graph_ptr& aut_f,
formula f)
{
// WDBA-minimization necessarily work for obligations
return ((f && f.is_syntactic_obligation())
// Weak deterministic automata are obligations
|| (aut_f->prop_weak().is_true() && is_deterministic(aut_f))
// Guarantee automata are obligations as well.
|| is_terminal_automaton(aut_f));
}
twa_graph_ptr
minimize_obligation(const const_twa_graph_ptr& aut_f,
@ -580,12 +590,7 @@ namespace spot
("minimize_obligation() does not support alternation");
bool minimization_will_be_correct = false;
// WDBA-minimization necessarily work for obligations
if ((f && f.is_syntactic_obligation())
// Weak deterministic automata are obligations
|| (aut_f->prop_weak() && is_deterministic(aut_f))
// Guarantee automata are obligations as well.
|| is_terminal_automaton(aut_f))
if (minimize_obligation_garanteed_to_work(aut_f, f))
{
minimization_will_be_correct = true;
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019
// Laboratoire de Recherche et Développement de l'Epita (LRDE).
// Copyright (C) 2009-2016, 2018-2020 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -116,5 +116,23 @@ namespace spot
const_twa_graph_ptr aut_neg_f = nullptr,
bool reject_bigger = false,
const output_aborter* aborter = nullptr);
/// \brief Whether calling minimize_obligation is sure to work
///
/// This checks whether \a f is a syntactic obligation, or if \a
/// aut_f obviously corresponds to an obligation (for instance if
/// this is a terminal automaton, or if it is both weak and
/// deterministic). In this case, calling minimize_obligation()
/// should not be a waste of time, as it will return a new
/// automaton.
///
/// If this function returns false, the input property might still
/// be a pathological obligation. The only way to know is to call
/// minimize_obligation(), but as it is less likely, you might
/// decide to save time.
SPOT_API
bool minimize_obligation_garanteed_to_work(const const_twa_graph_ptr& aut_f,
formula f = nullptr);
/// @}
}

View file

@ -83,7 +83,7 @@ namespace spot
sat_acc_ = opt->get("sat-acc", 0);
sat_states_ = opt->get("sat-states", 0);
state_based_ = opt->get("state-based", 0);
wdba_minimize_ = opt->get("wdba-minimize", 1);
wdba_minimize_ = opt->get("wdba-minimize", -1);
gen_reduce_parity_ = opt->get("gen-reduce-parity", 1);
if (sat_acc_ && sat_minimize_ == 0)
@ -371,9 +371,19 @@ namespace spot
output_aborter* aborter =
(det_max_states_ >= 0 || det_max_edges_ >= 0) ? &aborter_ : nullptr;
// (Small,Low) is the only configuration where we do not run
// WDBA-minimization.
if ((PREF_ != Small || level_ != Low) && wdba_minimize_)
int wdba_minimize = wdba_minimize_;
if (wdba_minimize == -1)
{
if (level_ == High)
wdba_minimize = 1;
else if (level_ == Medium || PREF_ == Deterministic)
wdba_minimize = 2;
else
wdba_minimize = 0;
}
if (wdba_minimize == 2)
wdba_minimize = minimize_obligation_garanteed_to_work(a, f);
if (wdba_minimize)
{
bool reject_bigger = (PREF_ == Small) && (level_ <= Medium);
dba = minimize_obligation(a, f, nullptr, reject_bigger, aborter);

View file

@ -253,7 +253,7 @@ namespace spot
int sat_states_ = 0;
int gen_reduce_parity_ = 1;
bool state_based_ = false;
bool wdba_minimize_ = true;
int wdba_minimize_ = -1;
};
/// @}
}