tgba_digraph: add a set_single_acceptance_set() method.
* src/tgba/tgbagraph.cc: New file. * src/tgba/Makefile.am: Adjust. * src/tgba/tgbagraph.hh (set_single_acceptance_set, new_acc_transition): New methods. (set_acceptance_conditions, merge_transitions): Move body to tgbagraph.cc. * src/tgbaalgos/complete.cc, src/tgbaalgos/degen.cc, src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtgbacomp.cc, src/neverparse/neverclaimparse.yy, src/dstarparse/dra2ba.cc, src/dstarparse/nra2nba.cc: Simplify using these new methods.
This commit is contained in:
parent
5739240c0f
commit
917f70073f
10 changed files with 144 additions and 145 deletions
|
|
@ -18,7 +18,6 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "complete.hh"
|
||||
#include "ltlast/constant.hh"
|
||||
#include "dupexp.hh"
|
||||
|
||||
namespace spot
|
||||
|
|
@ -33,10 +32,7 @@ namespace spot
|
|||
// We cannot safely complete an automaton if it has no
|
||||
// acceptance set as the added sink would become accepting.
|
||||
// In this case, add an acceptance set to all transitions.
|
||||
const ltl::formula* t = ltl::constant::true_instance();
|
||||
int v = aut->get_dict()->register_acceptance_variable(t, aut);
|
||||
allacc = bdd_ithvar(v);
|
||||
aut->set_acceptance_conditions(allacc);
|
||||
allacc = aut->set_single_acceptance_set();
|
||||
for (auto& t: aut->transitions())
|
||||
t.acc = allacc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#include "tgba/tgbagraph.hh"
|
||||
#include "misc/hash.hh"
|
||||
#include "misc/hashfunc.hh"
|
||||
#include "ltlast/constant.hh"
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
|
@ -261,19 +260,13 @@ namespace spot
|
|||
|
||||
// The result automaton is an SBA.
|
||||
auto res = new tgba_digraph(dict);
|
||||
res->set_single_acceptance_set();
|
||||
if (want_sba)
|
||||
res->set_bprop(tgba_digraph::StateBasedAcc);
|
||||
|
||||
// We use the same BDD variables as the input, except for the
|
||||
// acceptance.
|
||||
dict->register_all_variables_of(a, res);
|
||||
dict->unregister_all_typed_variables(bdd_dict::acc, res);
|
||||
|
||||
// Invent a new acceptance set for the degeneralized automaton.
|
||||
int accvar =
|
||||
dict->register_acceptance_variable(ltl::constant::true_instance(), res);
|
||||
bdd degen_acc = bdd_ithvar(accvar);
|
||||
res->set_acceptance_conditions(degen_acc);
|
||||
|
||||
// Create an order of acceptance conditions. Each entry in this
|
||||
// vector correspond to an acceptance set. Each index can
|
||||
|
|
@ -600,23 +593,11 @@ namespace spot
|
|||
|
||||
unsigned& t = tr_cache[dest * 2 + is_acc];
|
||||
|
||||
if (t == 0)
|
||||
{
|
||||
// Actually create the transition. If the source
|
||||
// state is accepting, we have to put degen_acc on all
|
||||
// outgoing transitions. (We are still building a
|
||||
// TGBA; we only assure that it can be used as an
|
||||
// SBA.)
|
||||
bdd acc = bddfalse;
|
||||
if (is_acc)
|
||||
acc = degen_acc;
|
||||
t = res->new_transition(src, dest,
|
||||
i->current_condition(), acc);
|
||||
}
|
||||
else
|
||||
{
|
||||
res->trans_data(t).cond |= i->current_condition();
|
||||
}
|
||||
if (t == 0) // Create transition.
|
||||
t = res->new_acc_transition(src, dest,
|
||||
i->current_condition(), is_acc);
|
||||
else // Update existing transition.
|
||||
res->trans_data(t).cond |= i->current_condition();
|
||||
}
|
||||
tr_cache.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <utility>
|
||||
#include "scc.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
#include "ltlast/constant.hh"
|
||||
#include "stats.hh"
|
||||
#include "misc/satsolver.hh"
|
||||
#include "misc/timer.hh"
|
||||
|
|
@ -673,11 +672,7 @@ namespace spot
|
|||
auto autdict = aut->get_dict();
|
||||
auto a = new tgba_digraph(autdict);
|
||||
autdict->register_all_variables_of(aut, a);
|
||||
|
||||
const ltl::formula* t = ltl::constant::true_instance();
|
||||
bdd acc = bdd_ithvar(autdict->register_acceptance_variable(t, a));
|
||||
a->set_acceptance_conditions(acc);
|
||||
|
||||
bdd acc = a->set_single_acceptance_set();
|
||||
a->new_states(satdict.cand_size);
|
||||
|
||||
unsigned last_aut_trans = -1U;
|
||||
|
|
@ -710,16 +705,13 @@ namespace spot
|
|||
if (seen_trans.insert(src_cond(t->second.src,
|
||||
t->second.cond)).second)
|
||||
{
|
||||
bdd accept = bddfalse;
|
||||
// Mark the transition as accepting if the source is.
|
||||
if (state_based
|
||||
&& acc_states.find(t->second.src) != acc_states.end())
|
||||
accept = acc;
|
||||
bool accept = state_based
|
||||
&& acc_states.find(t->second.src) != acc_states.end();
|
||||
|
||||
last_aut_trans = a->new_transition(t->second.src - 1,
|
||||
t->second.dst - 1,
|
||||
t->second.cond,
|
||||
accept);
|
||||
last_aut_trans =
|
||||
a->new_acc_transition(t->second.src - 1, t->second.dst - 1,
|
||||
t->second.cond, accept);
|
||||
last_sat_trans = &t->second;
|
||||
|
||||
dout << v << '\t' << t->second << "δ\n";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "dtgbacomp.hh"
|
||||
#include "ltlast/constant.hh"
|
||||
#include "dupexp.hh"
|
||||
|
||||
namespace spot
|
||||
|
|
@ -28,18 +27,12 @@ namespace spot
|
|||
// Clone the original automaton.
|
||||
tgba_digraph* res = tgba_dupexp_dfs(aut);
|
||||
|
||||
auto dict = res->get_dict();
|
||||
|
||||
bdd oldaccs = aut->all_acceptance_conditions();
|
||||
bdd oldnegs = aut->neg_acceptance_conditions();
|
||||
|
||||
// We will modify res in place, and the resulting
|
||||
// automaton will only have one acceptance set.
|
||||
dict->unregister_all_typed_variables(bdd_dict::acc, res);
|
||||
bdd theacc =
|
||||
bdd_ithvar(dict->register_acceptance_variable
|
||||
(ltl::constant::true_instance(), res));
|
||||
res->set_acceptance_conditions(theacc);
|
||||
res->set_single_acceptance_set();
|
||||
|
||||
unsigned num_acc = aut->number_of_acceptance_conditions();
|
||||
unsigned n = res->num_states();
|
||||
|
|
@ -48,7 +41,7 @@ namespace spot
|
|||
res->new_states(num_acc * n + 1);
|
||||
unsigned sink = res->num_states() - 1;
|
||||
// The sink state has an accepting self-loop.
|
||||
res->new_transition(sink, sink, bddtrue, theacc);
|
||||
res->new_acc_transition(sink, sink, bddtrue);
|
||||
|
||||
for (unsigned src = 0; src < n; ++src)
|
||||
{
|
||||
|
|
@ -85,7 +78,7 @@ namespace spot
|
|||
if (h == bddfalse)
|
||||
{
|
||||
// Clone the transition
|
||||
res->new_transition(src + add, dst + add, cond, theacc);
|
||||
res->new_acc_transition(src + add, dst + add, cond);
|
||||
assert(dst + add < sink);
|
||||
// Using `t' is disallowed from now on as it is a
|
||||
// reference to a transition that may have been
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue