twa: store property bits as trivals

* spot/twa/twa.hh: Store property bits as trivals.
* NEWS: Mention the change.
* spot/parseaut/parseaut.yy, spot/twaalgos/are_isomorphic.cc,
spot/twaalgos/complete.cc, spot/twaalgos/dot.cc, spot/twaalgos/hoa.cc,
spot/twaalgos/isdet.cc, spot/twaalgos/isunamb.cc, spot/twaalgos/lbtt.cc,
spot/twaalgos/ltl2tgba_fm.cc, spot/twaalgos/postproc.cc,
spot/twaalgos/remfin.cc, spot/twaalgos/strength.cc,
spot/twaalgos/stutter.cc, spot/twaalgos/stutter.hh,
spot/twaalgos/totgba.cc, tests/core/ikwiad.cc,
tests/python/product.ipynb, tests/python/remfin.py: Adjust.
* doc/org/hoa.org, doc/org/tut21.org: Update documentation.
This commit is contained in:
Alexandre Duret-Lutz 2016-01-12 19:37:18 +01:00
parent 1aeb260adf
commit da391492f3
22 changed files with 337 additions and 258 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014, 2015 Laboratoire de Recherche et
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -113,9 +113,16 @@ namespace spot
isomorphism_checker::isomorphism_checker(const const_twa_graph_ptr ref)
{
ref_ = make_twa_graph(ref, twa::prop_set::all());
ref_deterministic_ = ref_->prop_deterministic();
if (!ref_deterministic_)
trival prop_det = ref_->prop_deterministic();
if (prop_det)
{
ref_deterministic_ = true;
}
else
{
// Count the number of state even if we know that the
// automaton is non-deterministic, as this can be used to
// decide if two automata are non-isomorphic.
nondet_states_ = spot::count_nondet_states(ref_);
ref_deterministic_ = (nondet_states_ == 0);
}
@ -125,10 +132,10 @@ namespace spot
bool
isomorphism_checker::is_isomorphic_(const const_twa_graph_ptr aut)
{
bool autdet = aut->prop_deterministic();
trival autdet = aut->prop_deterministic();
if (ref_deterministic_)
{
if (autdet || spot::is_deterministic(aut))
if (autdet || (!autdet && spot::is_deterministic(aut)))
return are_isomorphic_det(ref_, aut);
}
else

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2014, 2015 Laboratoire de Recherche et
// Copyright (C) 2013, 2014, 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -114,7 +114,7 @@ namespace spot
}
// In case the automaton use state-based acceptance, propagate
// the acceptance of the first edge to the one we add.
if (!aut->prop_state_acc())
if (aut->prop_state_acc() != true)
acc = 0U;
aut->new_edge(i, sink, missingcond, acc);
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2014, 2015 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE).
// Copyright (C) 2011, 2012, 2014, 2015, 2016 Laboratoire de Recherche
// et Developpement de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
@ -499,7 +499,8 @@ namespace spot
}
if (opt_name_)
name_ = aut_->get_named_prop<std::string>("automaton-name");
mark_states_ = !opt_force_acc_trans_ && aut_->prop_state_acc();
mark_states_ = (!opt_force_acc_trans_
&& aut_->prop_state_acc().is_true());
if (opt_shape_ == ShapeAuto)
{
if (sn_ || sprod_ || aut->num_states() > 100)

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2014, 2015 Laboratoire de Recherche et
// Copyright (C) 2011, 2012, 2014, 2015, 2016 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -159,8 +159,8 @@ namespace spot
is_colored = colored && (!has_state_acc || nodeadend);
// If the automaton declares that it is deterministic or
// state-based, make sure that it really is.
assert(!aut->prop_deterministic() || deterministic);
assert(!aut->prop_state_acc() || state_acc);
assert(deterministic || aut->prop_deterministic() != true);
assert(state_acc || aut->prop_state_acc() != true);
}
void number_all_ap()
@ -433,16 +433,15 @@ namespace spot
// in the case of deterministic automata.
if (aut->prop_unambiguous() && (verbose || !md.is_deterministic))
prop(" unambiguous");
assert(!(aut->prop_stutter_invariant() && aut->prop_stutter_sensitive()));
if (aut->prop_stutter_invariant())
prop(" stutter-invariant");
if (aut->prop_stutter_sensitive())
if (!aut->prop_stutter_invariant())
prop(" stutter-sensitive");
if (aut->prop_terminal())
prop(" terminal");
if (aut->prop_weak() && (verbose || !aut->prop_terminal()))
if (aut->prop_weak() && (verbose || aut->prop_terminal() != true))
prop(" weak");
if (aut->prop_inherently_weak() && (verbose || !aut->prop_weak()))
if (aut->prop_inherently_weak() && (verbose || aut->prop_weak() != true))
prop(" inherently-weak");
os << nl;

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2012, 2013, 2014, 2015, 2016 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -63,8 +63,9 @@ namespace spot
bool
is_deterministic(const const_twa_graph_ptr& aut)
{
if (aut->prop_deterministic())
return true;
trival d = aut->prop_deterministic();
if (d.is_known())
return d.is_true();
return !count_nondet_states_aux<false>(aut);
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2015 Laboratoire de Recherche et Developpement
// Copyright (C) 2013, 2015, 2016 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -27,20 +27,23 @@ namespace spot
{
bool is_unambiguous(const const_twa_graph_ptr& aut)
{
if (aut->prop_unambiguous())
return true;
trival u = aut->prop_unambiguous();
if (u.is_known())
return u.is_true();
auto clean_a = scc_filter_states(aut);
if (clean_a->num_edges() == 0)
return true;
auto prod = product(clean_a, clean_a);
auto clean_p = scc_filter_states(prod);
return clean_a->num_states() == clean_p->num_states()
&& clean_a->num_edges() == clean_p->num_edges();
return (clean_a->num_states() == clean_p->num_states()
&& clean_a->num_edges() == clean_p->num_edges());
}
bool check_unambiguous(const twa_graph_ptr& aut)
{
aut->prop_unambiguous(is_unambiguous(aut));
return aut->prop_unambiguous();
bool u = is_unambiguous(aut);
aut->prop_unambiguous(u);
return u;
}
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2013, 2014, 2015 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Laboratoire de
// Recherche et Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
@ -133,7 +133,7 @@ namespace spot
throw std::runtime_error
("LBTT only supports generalized Büchi acceptance");
bool sba = g->prop_state_acc();
bool sba = g->prop_state_acc().is_true();
if (opt)
switch (char c = *opt++)
{

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
// Laboratoire de Recherche et Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2005, 2006 Laboratoire
// d'Informatique de Paris 6 (LIP6), département Systèmes Répartis
@ -2182,16 +2182,18 @@ namespace spot
acc.set_generalized_buchi();
a->prop_inherently_weak(f2.is_syntactic_persistence());
a->prop_stutter_invariant(f2.is_syntactic_stutter_invariant());
if (f2.is_syntactic_persistence())
a->prop_inherently_weak(true);
if (f2.is_syntactic_stutter_invariant())
a->prop_stutter_invariant(true);
if (orig_f.is_syntactic_guarantee())
{
a->prop_terminal(true);
assert(a->num_sets() <= 1);
}
// Currently the unambiguous option work only with LTL.
a->prop_unambiguous(f2.is_ltl_formula() && unambiguous);
if (unambiguous)
a->prop_unambiguous();
// Set the following to true to preserve state names.
a->release_formula_namer(namer, false);

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
// Copyright (C) 2012, 2013, 2014, 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -146,7 +146,8 @@ namespace spot
return a;
// If the automaton is weak, using transition-based acceptance
// won't help, so let's preserve it.
if ((state_based_ || a->prop_inherently_weak()) && a->prop_state_acc())
if ((state_based_ || a->prop_inherently_weak().is_true())
&& a->prop_state_acc().is_true())
return scc_filter_states(a, arg);
else
return scc_filter(a, arg);
@ -253,7 +254,9 @@ namespace spot
{
bool reject_bigger = (PREF_ == Small) && (level_ == Medium);
dba = minimize_obligation(a, f, nullptr, reject_bigger);
if (dba && dba->prop_inherently_weak() && dba->prop_deterministic())
if (dba
&& dba->prop_inherently_weak().is_true()
&& dba->prop_deterministic().is_true())
{
// The WDBA is a BA, so no degeneralization is required.
// We just need to add an acceptance set if there is none.
@ -272,7 +275,7 @@ namespace spot
// at hard levels if we want a small output.
if (!dba || (level_ == High && PREF_ == Small))
{
if (((SBACC_ && a->prop_state_acc())
if (((SBACC_ && a->prop_state_acc().is_true())
|| (type_ == BA && a->is_sba()))
&& !tba_determinisation_)
{

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015 Laboratoire de Recherche et
// Copyright (C) 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -227,7 +227,7 @@ namespace spot
res->new_states(nst);
res->set_buchi();
res->set_init_state(aut->get_init_state_number());
bool deterministic = aut->prop_deterministic();
trival deterministic = aut->prop_deterministic();
std::vector<unsigned> state_map(aut->num_states());
for (unsigned n = 0; n < scc_max; ++n)
@ -307,7 +307,7 @@ namespace spot
static twa_graph_ptr
rabin_to_buchi_maybe(const const_twa_graph_ptr& aut)
{
if (!aut->prop_state_acc())
if (!aut->prop_state_acc().is_true())
return nullptr;
auto code = aut->get_acceptance();
@ -508,7 +508,7 @@ namespace spot
return std::const_pointer_cast<twa_graph>(aut);
// FIXME: we should check whether the automaton is weak.
if (aut->prop_inherently_weak() && is_deterministic(aut))
if (aut->prop_inherently_weak().is_true() && is_deterministic(aut))
return remove_fin_det_weak(aut);
if (auto maybe = streett_to_generalized_buchi_maybe(aut))
@ -668,7 +668,7 @@ namespace spot
res->set_acceptance(aut->num_sets() + extra_sets, new_code);
res->set_init_state(aut->get_init_state_number());
bool sbacc = aut->prop_state_acc();
bool sbacc = aut->prop_state_acc().is_true();
scc_info si(aut);
unsigned nscc = si.scc_count();
std::vector<unsigned> state_map(nst);

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2011, 2013, 2014, 2015 Laboratoire de Recherche
// et Développement de l'Epita (LRDE)
// Copyright (C) 2010, 2011, 2013, 2014, 2015, 2016 Laboratoire de
// Recherche et Développement de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
//
@ -84,10 +84,12 @@ namespace spot
delete si;
if (set)
{
if (terminal)
aut->prop_terminal(is_term && is_weak);
aut->prop_weak(is_weak);
aut->prop_inherently_weak(is_inweak);
if (terminal && is_term && is_weak)
aut->prop_terminal(true);
if (is_weak)
aut->prop_weak(true);
if (is_inweak)
aut->prop_inherently_weak(true);
}
if (inweak)
return is_inweak;
@ -98,25 +100,30 @@ namespace spot
bool
is_terminal_automaton(const const_twa_graph_ptr& aut, scc_info* si)
{
return (aut->prop_terminal() ||
is_type_automaton<true>(std::const_pointer_cast<twa_graph>(aut),
si));
trival v = aut->prop_terminal();
if (v.is_known())
return v.is_true();
return is_type_automaton<true>(std::const_pointer_cast<twa_graph>(aut), si);
}
bool
is_weak_automaton(const const_twa_graph_ptr& aut, scc_info* si)
{
return (aut->prop_weak() ||
is_type_automaton<false>(std::const_pointer_cast<twa_graph>(aut),
si));
trival v = aut->prop_weak();
if (v.is_known())
return v.is_true();
return is_type_automaton<false>(std::const_pointer_cast<twa_graph>(aut),
si);
}
bool
is_inherently_weak_automaton(const const_twa_graph_ptr& aut, scc_info* si)
{
return (aut->prop_inherently_weak() ||
is_type_automaton<false, true>
(std::const_pointer_cast<twa_graph>(aut), si));
trival v = aut->prop_inherently_weak();
if (v.is_known())
return v.is_true();
return is_type_automaton<false, true>
(std::const_pointer_cast<twa_graph>(aut), si);
}
void check_strength(const twa_graph_ptr& aut, scc_info* si)

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014, 2015 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -410,10 +410,10 @@ namespace spot
}
if (num_states != a->num_states())
a->prop_keep({true, // state_based
false, // inherently_weak
false, // deterministic
false, // stutter inv.
});
false, // inherently_weak
false, // deterministic
false, // stutter inv.
});
a->merge_edges();
return a;
}
@ -430,10 +430,10 @@ namespace spot
closure(twa_graph_ptr&& a)
{
a->prop_keep({false, // state_based
false, // inherently_weak
false, // deterministic
false, // stutter inv.
});
false, // inherently_weak
false, // deterministic
false, // stutter inv.
});
unsigned n = a->num_states();
std::vector<unsigned> todo;
@ -612,12 +612,12 @@ namespace spot
}
}
bool
trival
check_stutter_invariance(const twa_graph_ptr& aut, formula f)
{
bool is_stut = aut->prop_stutter_invariant();
if (is_stut)
return is_stut;
trival is_stut = aut->prop_stutter_invariant();
if (is_stut.is_known())
return is_stut.is_true();
twa_graph_ptr neg = nullptr;
if (f)
@ -630,14 +630,13 @@ namespace spot
// know how to complement it.
aut->prop_deterministic(is_deterministic(aut));
if (!aut->prop_deterministic())
return false;
return trival::maybe();
neg = remove_fin(dtwa_complement(aut));
}
is_stut = is_stutter_invariant(make_twa_graph(aut, twa::prop_set::all()),
std::move(neg), aut->ap_var());
aut->prop_stutter_invariant(is_stut);
aut->prop_stutter_sensitive(!is_stut);
return is_stut;
}
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014, 2015 Laboratoire de Recherche
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -63,7 +63,10 @@ namespace spot
/// This procedure only works if \a aut is deterministic, or if the
/// equivalent formula \a f is given. The stutter-invariant property
/// of the automaton is updated and also returned.
SPOT_API bool
///
/// If no formula is given and the automaton is not deterministic,
/// the result will be returned as trival::maybe().
SPOT_API trival
check_stutter_invariance(const twa_graph_ptr& aut,
formula f = nullptr);
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015 Laboratoire de Recherche et Développement
// Copyright (C) 2015, 2016 Laboratoire de Recherche et Développement
// de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -164,7 +164,7 @@ namespace spot
bs2num[s] = out->new_state();
todo.push_back(s);
bool sbacc = in->prop_state_acc();
bool sbacc = in->prop_state_acc().is_true();
// States of the original automaton are marked with s.pend == -1U.
const acc_cond::mark_t orig_copy(-1U);