remove wdbacomp.cc and wdbacomp.hh

The weak complementation is now implemented by dtgba_complement(), with
dispatch based on the automaton property.

* src/tgba/wdbacomp.cc, src/tgba/wdbacomp.hh: Remove.
* src/tgba/Makefile.am: Adjust.
* src/tgbaalgos/dtgbacomp.cc: Implement the weak version.
* src/tgbaalgos/dtgbacomp.hh: Document it.
* src/tgbaalgos/minimize.cc: Use dtgba_complement() instead.
This commit is contained in:
Alexandre Duret-Lutz 2014-08-31 00:54:52 +02:00
parent c8b399c02a
commit 359e0c6fb4
6 changed files with 72 additions and 342 deletions

View file

@ -19,10 +19,11 @@
#include "dtgbacomp.hh"
#include "dupexp.hh"
#include "sccinfo.hh"
namespace spot
{
tgba_digraph_ptr dtgba_complement(const const_tgba_ptr& aut)
tgba_digraph_ptr dtgba_complement_nonweak(const const_tgba_ptr& aut)
{
// Clone the original automaton.
tgba_digraph_ptr res = tgba_dupexp_dfs(aut);
@ -50,7 +51,7 @@ namespace spot
bdd missingcond = bddtrue;
for (auto& t: res->out(src))
{
if (t.dst >= n) // Ignore transition we added.
if (t.dst >= n) // Ignore transitions we added.
break;
missingcond -= t.cond;
bdd curacc = t.acc;
@ -121,4 +122,65 @@ namespace spot
// FIXME: Remove unreachable states.
return res;
}
tgba_digraph_ptr dtgba_complement_weak(const const_tgba_ptr& aut)
{
// Clone the original automaton.
tgba_digraph_ptr res = tgba_dupexp_dfs(aut);
res->prop_copy(aut,
true, // state based
true, // single acc
true, // inherently_weak
true); // deterministic
bdd oldaccs = aut->all_acceptance_conditions();
bdd oldnegs = aut->neg_acceptance_conditions();
scc_info si(res);
// We will modify res in place, and the resulting
// automaton will only have one acceptance set.
bdd all_acc = res->set_single_acceptance_set();
res->prop_state_based_acc();
unsigned sink = res->num_states();
for (unsigned src = 0; src < sink; ++src)
{
bdd acc = bddfalse;
unsigned scc = si.scc_of(src);
if (!si.is_accepting_scc(scc) && !si.is_trivial(scc))
acc = all_acc;
// Keep track of all conditions on transition leaving state
// SRC, so we can complete it.
bdd missingcond = bddtrue;
for (auto& t: res->out(src))
{
missingcond -= t.cond;
t.acc = acc;
}
// Complete the original automaton.
if (missingcond != bddfalse)
{
if (res->num_states() == sink)
{
res->new_state();
res->new_acc_transition(sink, sink, bddtrue);
}
res->new_transition(src, sink, missingcond);
}
}
//res->merge_transitions();
return res;
}
tgba_digraph_ptr dtgba_complement(const const_tgba_ptr& aut)
{
if (aut->is_inherently_weak())
return dtgba_complement_weak(aut);
else
return dtgba_complement_nonweak(aut);
}
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement
// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita.
//
// This file is part of Spot, a model checking library.
@ -28,8 +28,9 @@ namespace spot
///
/// The automaton \a aut should be deterministic. It does no need
/// to be complete. Acceptance can be transition-based, or
/// state-based. The resulting automaton is very unlikely to be
/// deterministic.
/// state-based. Unless the input automaton is marked as weak (in
/// which case the output will also be weak and deterministic) the
/// resulting automaton is very unlikely to be deterministic.
SPOT_API tgba_digraph_ptr
dtgba_complement(const const_tgba_ptr& aut);
}

View file

@ -37,7 +37,6 @@
#include "misc/hash.hh"
#include "misc/bddlt.hh"
#include "tgba/tgbaproduct.hh"
#include "tgba/wdbacomp.hh"
#include "tgbaalgos/powerset.hh"
#include "tgbaalgos/gtec/gtec.hh"
#include "tgbaalgos/safety.hh"
@ -671,7 +670,8 @@ namespace spot
if (product(min_aut_f, aut_neg_f)->is_empty())
{
// Complement the minimized WDBA.
auto neg_min_aut_f = wdba_complement(min_aut_f);
assert(min_aut_f->is_inherently_weak());
auto neg_min_aut_f = dtgba_complement(min_aut_f);
if (product(aut_f, neg_min_aut_f)->is_empty())
// Finally, we are now sure that it was safe
// to minimize the automaton.