rename is_deterministic to is_universal

For #212.

* spot/twa/twa.hh: Rename prop_deterministic() as prop_universal(),
and keep the old name as deprecated.
* spot/twaalgos/isdet.cc, spot/twaalgos/isdet.hh: Rename
is_deterministic() as is_universal(), and add a new function
for is_deterministic().
* doc/org/concepts.org, doc/org/hoa.org, doc/org/tut21.org,
spot/tl/hierarchy.cc, spot/twa/twagraph.cc,
spot/twaalgos/are_isomorphic.cc, spot/twaalgos/determinize.cc,
spot/twaalgos/dtbasat.cc, spot/twaalgos/dtwasat.cc,
spot/twaalgos/hoa.cc, spot/twaalgos/minimize.cc,
spot/twaalgos/postproc.cc, spot/twaalgos/product.cc,
spot/twaalgos/randomgraph.cc, spot/twaalgos/remfin.cc,
spot/twaalgos/simulation.cc, spot/twaalgos/totgba.cc,
spot/twaalgos/word.cc, tests/python/product.ipynb,
tests/python/remfin.py: Adjust.
* NEWS: Mention the change.
This commit is contained in:
Alexandre Duret-Lutz 2017-03-27 19:19:52 +02:00
parent 4518724a5b
commit 4a5d7a3978
24 changed files with 181 additions and 180 deletions

View file

@ -113,7 +113,7 @@ namespace spot
isomorphism_checker::isomorphism_checker(const const_twa_graph_ptr ref)
{
ref_ = make_twa_graph(ref, twa::prop_set::all());
trival prop_det = ref_->prop_deterministic();
trival prop_det = ref_->prop_universal();
if (prop_det)
{
ref_deterministic_ = true;
@ -135,10 +135,10 @@ namespace spot
if (!aut->is_existential())
throw std::runtime_error
("isomorphism_checker does not yet support alternation");
trival autdet = aut->prop_deterministic();
trival autdet = aut->prop_universal();
if (ref_deterministic_)
{
if (!spot::is_deterministic(aut))
if (!spot::is_universal(aut))
return false;
return are_isomorphic_det(ref_, aut);
}

View file

@ -32,6 +32,7 @@
#include <spot/twaalgos/degen.hh>
#include <spot/twaalgos/sccfilter.hh>
#include <spot/twaalgos/simulation.hh>
#include <spot/twaalgos/isdet.hh>
namespace spot
@ -582,7 +583,7 @@ namespace spot
if (!a->is_existential())
throw std::runtime_error
("tgba_determinize() does not support alternation");
if (a->prop_deterministic())
if (is_universal(a))
return std::const_pointer_cast<twa_graph>(a);
// Degeneralize
@ -701,7 +702,7 @@ namespace spot
remove_dead_acc(res, sets);
// Acceptance is now min(odd) since we con emit Red on paths 0 with new opti
res->set_acceptance(sets, acc_cond::acc_code::parity(false, true, sets));
res->prop_deterministic(true);
res->prop_universal(true);
res->prop_state_acc(false);
if (pretty_print)

View file

@ -599,7 +599,7 @@ namespace spot
a->set_buchi();
if (state_based)
a->prop_state_acc(true);
a->prop_deterministic(true);
a->prop_universal(true);
a->new_states(satdict.cand_size);
#if DEBUG

View file

@ -879,7 +879,7 @@ namespace spot
a->copy_ap_of(aut);
if (state_based)
a->prop_state_acc(true);
a->prop_deterministic(true);
a->prop_universal(true);
a->set_acceptance(satdict.cand_nacc, satdict.cand_acc);
a->new_states(satdict.cand_size);
@ -1474,7 +1474,7 @@ namespace spot
// mode. If the desired output is a Büchi automaton, or not
// desired acceptance was specified, stop here. There is not
// point in minimizing a minimal automaton.
if (a->prop_inherently_weak() && a->prop_deterministic()
if (a->prop_weak() && a->prop_universal()
&& (target_is_buchi || !user_supplied_acc))
return a;
}

View file

@ -158,10 +158,10 @@ namespace spot
// some states without successors do not declare it as
// colored.
is_colored = colored && (!has_state_acc || nodeadend);
// If the automaton declares that it is deterministic or
// If the automaton declares that it is universal or
// state-based, make sure that it really is.
assert(!aut->prop_deterministic().is_known() ||
deterministic == aut->prop_deterministic().is_true());
assert(!aut->prop_universal().is_known() ||
deterministic == aut->prop_universal().is_true());
assert(!aut->prop_complete().is_known() ||
complete == aut->prop_complete().is_true());
assert(state_acc || !aut->prop_state_acc().is_true());

View file

@ -50,7 +50,7 @@ namespace spot
break;
}
std::const_pointer_cast<twa_graph>(aut)
->prop_deterministic(!nondet_states);
->prop_universal(!nondet_states);
return nondet_states;
}
}
@ -58,29 +58,35 @@ namespace spot
unsigned
count_nondet_states(const const_twa_graph_ptr& aut)
{
if (aut->prop_deterministic())
if (aut->prop_universal())
return 0;
return count_nondet_states_aux<true>(aut);
}
bool
is_deterministic(const const_twa_graph_ptr& aut)
is_universal(const const_twa_graph_ptr& aut)
{
trival d = aut->prop_deterministic();
trival d = aut->prop_universal();
if (d.is_known())
return d.is_true();
return !count_nondet_states_aux<false>(aut);
}
bool
is_deterministic(const const_twa_graph_ptr& aut)
{
return aut->is_existential() && is_universal(aut);
}
void
highlight_nondet_states(twa_graph_ptr& aut, unsigned color)
{
if (aut->prop_deterministic())
if (aut->prop_universal())
return;
unsigned ns = aut->num_states();
auto* highlight = aut->get_or_set_named_prop<std::map<unsigned, unsigned>>
("highlight-states");
bool deterministic = true;
bool universal = true;
for (unsigned src = 0; src < ns; ++src)
{
bdd available = bddtrue;
@ -88,25 +94,25 @@ namespace spot
if (!bdd_implies(t.cond, available))
{
(*highlight)[src] = color;
deterministic = false;
universal = false;
}
else
{
available -= t.cond;
}
}
aut->prop_deterministic(deterministic);
aut->prop_universal(universal);
}
void
highlight_nondet_edges(twa_graph_ptr& aut, unsigned color)
{
if (aut->prop_deterministic())
if (aut->prop_universal())
return;
unsigned ns = aut->num_states();
auto* highlight = aut->get_or_set_named_prop<std::map<unsigned, unsigned>>
("highlight-edges");
bool deterministic = true;
bool universal = true;
for (unsigned src = 0; src < ns; ++src)
{
// Make a first pass to gather non-deterministic labels
@ -116,19 +122,19 @@ namespace spot
if (!bdd_implies(t.cond, available))
{
extra |= (t.cond - available);
deterministic = false;
universal = false;
}
else
{
available -= t.cond;
}
// Second pass to gather the relevant edges.
if (!deterministic)
if (!universal)
for (auto& t: aut->out(src))
if ((t.cond & extra) != bddfalse)
(*highlight)[aut->get_graph().index_of_edge(t)] = color;
}
aut->prop_deterministic(deterministic);
aut->prop_universal(universal);
}
bool

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2014, 2015, 2016 Laboratoire de Recherche
// Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -26,24 +26,33 @@ namespace spot
/// \addtogroup twa_misc
/// @{
/// \brief Count the number of non-deterministic states in \a aut.
/// \brief Count the number of states with non-deterministic
/// branching in \a aut.
///
/// The automaton is deterministic if it has 0 nondeterministic states,
/// but it is more efficient to call is_deterministic() if you do not
/// care about the number of nondeterministic states.
/// The automaton is universal if it has 0 states with
/// non-deterministic branching but it is more efficient to call
/// is_universal() if you do not care about the number of
/// non-deterministic states.
SPOT_API unsigned
count_nondet_states(const const_twa_graph_ptr& aut);
/// \brief Return true iff \a aut is deterministic.
/// \brief Return true iff \a aut is universal.
///
/// This function is more efficient than count_nondet_states() when
/// the automaton is nondeterministic, because it can return before
/// the entire automaton has been explored.
///
/// In addition to returning the result as a Boolean, this will set
/// the prop_deterministic() property of the automaton as a
/// the prop_universal() property of the automaton as a
/// side-effect, so further calls will return in constant-time.
SPOT_API bool
is_universal(const const_twa_graph_ptr& aut);
/// \brief Return true iff \a aut is deterministic.
///
/// An automaton is called deterministic if it is both universal and
/// existential.
SPOT_API bool
is_deterministic(const const_twa_graph_ptr& aut);
/// \brief Highlight nondeterministic states

View file

@ -487,7 +487,7 @@ namespace spot
build_state_set(det_a, non_final);
auto res = minimize_dfa(det_a, final, non_final);
res->prop_copy(a, { false, false, false, false, true, true });
res->prop_deterministic(true);
res->prop_universal(true);
res->prop_weak(true);
res->prop_state_acc(true);
// Quickly check if this is a terminal automaton
@ -596,7 +596,7 @@ namespace spot
auto res = minimize_dfa(det_a, final, non_final);
res->prop_copy(a, { false, false, false, false, false, true });
res->prop_deterministic(true);
res->prop_universal(true);
res->prop_weak(true);
// If the input was terminal, then the output is also terminal.
// FIXME:
@ -633,7 +633,7 @@ namespace spot
// If the input automaton was already weak and deterministic, the
// output is necessary correct.
if (aut_f->prop_weak() && aut_f->prop_deterministic())
if (aut_f->prop_weak() && aut_f->prop_universal())
return min_aut_f;
// if f is a syntactic obligation formula, the WDBA minimization

View file

@ -272,7 +272,7 @@ namespace spot
dba = minimize_obligation(a, f, nullptr, reject_bigger);
if (dba
&& dba->prop_inherently_weak().is_true()
&& dba->prop_deterministic().is_true())
&& dba->prop_universal().is_true())
{
// The WDBA is a BA, so no degeneralization is required.
// We just need to add an acceptance set if there is none.

View file

@ -107,9 +107,9 @@ namespace spot
}
// The product of two non-deterministic automata could be
// deterministic. likewise for non-complete automata.
if (left->prop_deterministic() && right->prop_deterministic())
res->prop_deterministic(true);
// deterministic. Likewise for non-complete automata.
if (left->prop_universal() && right->prop_universal())
res->prop_universal(true);
if (left->prop_complete() && right->prop_complete())
res->prop_complete(true);
if (left->prop_stutter_invariant() && right->prop_stutter_invariant())

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014, 2015 Laboratoire de
// Recherche et Développement de l'Epita (LRDE).
// Copyright (C) 2008-2010, 2012-2017 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2004, 2005, 2007 Laboratoire d'Informatique de
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
@ -130,7 +130,7 @@ namespace spot
throw std::invalid_argument("random_graph() requires n>0 states");
auto res = make_twa_graph(dict);
if (deterministic)
res->prop_deterministic(true);
res->prop_universal(true);
if (state_acc)
res->prop_state_acc(true);

View file

@ -228,7 +228,7 @@ namespace spot
res->new_states(nst);
res->set_buchi();
res->set_init_state(aut->get_init_state_number());
trival deterministic = aut->prop_deterministic();
trival deterministic = aut->prop_universal();
trival complete = aut->prop_complete();
std::vector<unsigned> state_map(aut->num_states());
@ -302,7 +302,7 @@ namespace spot
}
}
res->prop_complete(complete);
res->prop_deterministic(deterministic);
res->prop_universal(deterministic);
res->purge_dead_states();
return res;
}

View file

@ -600,7 +600,7 @@ namespace spot
});
// !unambiguous and !semi-deterministic are not preserved
if (!Cosimulation)
res->prop_deterministic(nb_minato == nb_satoneset);
res->prop_universal(nb_minato == nb_satoneset);
if (Sba)
res->prop_state_acc(true);
return res;
@ -736,7 +736,7 @@ namespace spot
prev = next;
direct_simulation<false, Sba> simul(res ? res : t);
res = simul.run();
if (res->prop_deterministic())
if (res->prop_universal())
break;
direct_simulation<true, Sba> cosimul(res);

View file

@ -336,7 +336,7 @@ namespace spot
res->set_init_state(res->new_state());
res->prop_state_acc(true);
res->prop_weak(true);
res->prop_deterministic(true);
res->prop_universal(true);
res->prop_stutter_invariant(true);
return res;
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2014, 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2013-2017 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -226,7 +226,7 @@ namespace spot
twa_graph_ptr aut = make_twa_graph(dict_);
aut->prop_weak(true);
aut->prop_deterministic(true);
aut->prop_universal(true);
// Register the atomic propositions used in the word.
{