replace sba_explicit_* by tgba_digraph, and use tgba_digraph is postproc
This is a huge patch. tgba_digraph are equiped with some boolean properties that can be used to indicate whether they represent SBA (and will carry more informations later). All algorithms that produce or use sba_explicit_* automata are changed to use tgba_digraph. postproc has been rewritten using only tgba_digraph, and this required changing the return types of many algorithms from tgba* to tgba_digraph*. * src/bin/dstar2tgba.cc, src/bin/ltlfilt.cc, src/dstarparse/dra2ba.cc, src/dstarparse/dstar2tgba.cc, src/dstarparse/nra2nba.cc, src/dstarparse/nsa2tgba.cc, src/dstarparse/public.hh, src/tgba/tgbagraph.hh, src/tgba/tgbasafracomplement.cc, src/tgbaalgos/compsusp.cc, src/tgbaalgos/compsusp.hh, src/tgbaalgos/degen.cc, src/tgbaalgos/degen.hh, src/tgbaalgos/dotty.cc, src/tgbaalgos/minimize.cc, src/tgbaalgos/minimize.hh, src/tgbaalgos/postproc.cc, src/tgbaalgos/postproc.hh, src/tgbaalgos/sccfilter.cc, src/tgbaalgos/sccinfo.cc, src/tgbaalgos/stripacc.cc, src/tgbaalgos/stripacc.hh, src/tgbaalgos/translate.cc, src/tgbaalgos/translate.hh, src/tgbatest/ltl2tgba.cc, wrap/python/spot.i: Update.
This commit is contained in:
parent
637aeff2d3
commit
6c9d5e4bb3
26 changed files with 296 additions and 257 deletions
|
|
@ -349,7 +349,7 @@ namespace spot
|
|||
}
|
||||
|
||||
|
||||
tgba*
|
||||
tgba_digraph*
|
||||
compsusp(const ltl::formula* f, bdd_dict* dict,
|
||||
bool no_wdba, bool no_simulation,
|
||||
bool early_susp, bool no_susp_product, bool wdba_smaller,
|
||||
|
|
@ -371,18 +371,11 @@ namespace spot
|
|||
|
||||
if (!no_wdba)
|
||||
{
|
||||
tgba* min = minimize_obligation(res, g, 0, wdba_smaller);
|
||||
tgba_digraph* min = minimize_obligation(res, g, 0, wdba_smaller);
|
||||
if (min != res)
|
||||
{
|
||||
delete res;
|
||||
// FIXME: minimize_obligation does not yet return a
|
||||
// tgba_digraph, so we convert the result using dupexp.
|
||||
// Once minimize_obligation is fixed, we should remove the
|
||||
// call to dupexp.
|
||||
assert(dynamic_cast<tgba_digraph*>(min) == nullptr);
|
||||
res = tgba_dupexp_dfs(min);
|
||||
delete min;
|
||||
//res = min;
|
||||
res = min;
|
||||
no_simulation = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
# define SPOT_TGBAALGOS_COMPSUSP_HH
|
||||
|
||||
#include "ltlast/formula.hh"
|
||||
#include "tgba/tgbagraph.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -49,7 +50,7 @@ namespace spot
|
|||
/// This interface is subject to change, and clients aiming for
|
||||
/// long-term stability should better use the services of the
|
||||
/// spot::translator class instead.
|
||||
SPOT_API tgba*
|
||||
SPOT_API tgba_digraph*
|
||||
compsusp(const ltl::formula* f, bdd_dict* dict,
|
||||
bool no_wdba = false, bool no_simulation = false,
|
||||
bool early_susp = false, bool no_susp_product = false,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
#include "degen.hh"
|
||||
#include "tgba/tgbaexplicit.hh"
|
||||
#include "tgba/tgbagraph.hh"
|
||||
#include "misc/hash.hh"
|
||||
#include "misc/hashfunc.hh"
|
||||
#include "ltlast/constant.hh"
|
||||
|
|
@ -251,7 +251,7 @@ namespace spot
|
|||
};
|
||||
}
|
||||
|
||||
sba*
|
||||
tgba_digraph*
|
||||
degeneralize(const tgba* a, bool use_z_lvl, bool use_cust_acc_orders,
|
||||
int use_lvl_cache, bool skip_levels)
|
||||
{
|
||||
|
|
@ -259,8 +259,9 @@ namespace spot
|
|||
|
||||
bdd_dict* dict = a->get_dict();
|
||||
|
||||
// The result (degeneralized) automaton uses numbered states.
|
||||
sba_explicit_number* res = new sba_explicit_number(dict);
|
||||
// The result automaton is an SBA.
|
||||
auto res = new tgba_digraph(dict);
|
||||
res->set_bprop(tgba_digraph::SBA);
|
||||
|
||||
// We use the same BDD variables as the input, except for the
|
||||
// acceptance.
|
||||
|
|
@ -314,7 +315,7 @@ namespace spot
|
|||
// (dest*2+acc) where dest is the destination state number, and
|
||||
// acc is 1 iff the transition is accepting. The source
|
||||
// is always that of the current iteration.
|
||||
typedef std::map<int, state_explicit_number::transition*> tr_cache_t;
|
||||
typedef std::map<int, unsigned> tr_cache_t;
|
||||
tr_cache_t tr_cache;
|
||||
|
||||
// State level cache
|
||||
|
|
@ -355,16 +356,7 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEGEN_DEBUG
|
||||
std::map<const state*, int>names;
|
||||
names[s.first] = 1;
|
||||
|
||||
ds2num[s] =
|
||||
10000 * names[s.first] + 100 * s.second + m.scc_of_state(s.first);
|
||||
#else
|
||||
ds2num[s] = 0;
|
||||
#endif
|
||||
|
||||
ds2num[s] = res->new_state();
|
||||
todo.push_back(s);
|
||||
|
||||
// If use_lvl_cache is on insert initial state to level cache
|
||||
|
|
@ -557,11 +549,7 @@ namespace spot
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEGEN_DEBUG
|
||||
dest = 10000 * names[d.first] + 100 * d.second + scc;
|
||||
#else
|
||||
dest = ds2num.size();
|
||||
#endif
|
||||
dest = res->new_state();
|
||||
ds2num[d] = dest;
|
||||
todo.push_back(d);
|
||||
// Insert new state to cache
|
||||
|
|
@ -582,24 +570,24 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
state_explicit_number::transition*& t =
|
||||
tr_cache[dest * 2 + is_acc];
|
||||
unsigned& t = tr_cache[dest * 2 + is_acc];
|
||||
|
||||
if (t == 0)
|
||||
{
|
||||
// Actually create the transition.
|
||||
t = res->create_transition(src, dest);
|
||||
t->condition = i->current_condition();
|
||||
// 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.)
|
||||
// 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)
|
||||
t->acceptance_conditions = degen_acc;
|
||||
acc = degen_acc;
|
||||
t = res->new_transition(src, dest,
|
||||
i->current_condition(), acc);
|
||||
}
|
||||
else
|
||||
{
|
||||
t->condition |= i->current_condition();
|
||||
res->trans_data(t).cond |= i->current_condition();
|
||||
}
|
||||
}
|
||||
tr_cache.clear();
|
||||
|
|
|
|||
|
|
@ -20,13 +20,10 @@
|
|||
#ifndef SPOT_TGBAALGOS_DEGEN_HH
|
||||
# define SPOT_TGBAALGOS_DEGEN_HH
|
||||
|
||||
# include "misc/common.hh"
|
||||
# include "tgba/tgbagraph.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
class sba;
|
||||
class tgba;
|
||||
|
||||
/// \ingroup tgba_misc
|
||||
/// \brief Degeneralize a spot::tgba into an equivalent sba with
|
||||
/// only one acceptance condition.
|
||||
|
|
@ -52,7 +49,7 @@ namespace spot
|
|||
/// \a a to be computed prior to its actual degeneralization.
|
||||
///
|
||||
/// \see tgba_sba_proxy, tgba_tba_proxy
|
||||
SPOT_API sba*
|
||||
SPOT_API tgba_digraph*
|
||||
degeneralize(const tgba* a, bool use_z_lvl = true,
|
||||
bool use_cust_acc_orders = false,
|
||||
int use_lvl_cache = 1,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "tgba/bddprint.hh"
|
||||
#include "reachiter.hh"
|
||||
#include "misc/escape.hh"
|
||||
#include "tgba/tgbatba.hh"
|
||||
#include "tgba/tgbagraph.hh"
|
||||
#include "tgba/formula2bdd.hh"
|
||||
|
||||
namespace spot
|
||||
|
|
@ -130,6 +130,9 @@ namespace spot
|
|||
{
|
||||
if (!dd)
|
||||
dd = dotty_decorator::instance();
|
||||
if (const tgba_digraph* gd = dynamic_cast<const tgba_digraph*>(g))
|
||||
assume_sba |= gd->get_bprop(tgba_digraph::StateBasedAcc);
|
||||
|
||||
dotty_bfs d(os, g, assume_sba, dd);
|
||||
d.run();
|
||||
return os;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
#include "tgbaalgos/bfssteps.hh"
|
||||
#include "tgbaalgos/isdet.hh"
|
||||
#include "tgbaalgos/dtgbacomp.hh"
|
||||
#include "priv/countstates.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -115,30 +114,43 @@ namespace spot
|
|||
|
||||
// From the base automaton and the list of sets, build the minimal
|
||||
// resulting automaton
|
||||
sba_explicit_number* build_result(const tgba* a,
|
||||
std::list<hash_set*>& sets,
|
||||
hash_set* final)
|
||||
tgba_digraph* build_result(const tgba* a,
|
||||
std::list<hash_set*>& sets,
|
||||
hash_set* final)
|
||||
{
|
||||
auto dict = a->get_dict();
|
||||
auto res = new tgba_digraph(dict);
|
||||
dict->register_all_variables_of(a, res);
|
||||
dict->unregister_all_typed_variables(bdd_dict::acc, res);
|
||||
res->set_bprop(tgba_digraph::StateBasedAcc);
|
||||
|
||||
// For each set, create a state in the resulting automaton.
|
||||
// For a state s, state_num[s] is the number of the state in the minimal
|
||||
// automaton.
|
||||
hash_map state_num;
|
||||
std::list<hash_set*>::iterator sit;
|
||||
unsigned num = 0;
|
||||
for (sit = sets.begin(); sit != sets.end(); ++sit)
|
||||
{
|
||||
hash_set::iterator hit;
|
||||
hash_set* h = *sit;
|
||||
unsigned num = res->new_state();
|
||||
for (hit = h->begin(); hit != h->end(); ++hit)
|
||||
state_num[*hit] = num;
|
||||
++num;
|
||||
}
|
||||
typedef state_explicit_number::transition trs;
|
||||
sba_explicit_number* res = new sba_explicit_number(a->get_dict());
|
||||
|
||||
// For each transition in the initial automaton, add the corresponding
|
||||
// transition in res.
|
||||
bdd allacc = bddfalse;
|
||||
if (!final->empty())
|
||||
res->declare_acceptance_condition(ltl::constant::true_instance());
|
||||
{
|
||||
res->set_bprop(tgba_digraph::SingleAccSet);
|
||||
int accvar =
|
||||
dict->register_acceptance_variable(ltl::constant::true_instance(),
|
||||
res);
|
||||
allacc = bdd_ithvar(accvar);
|
||||
res->set_acceptance_conditions(allacc);
|
||||
}
|
||||
|
||||
for (sit = sets.begin(); sit != sets.end(); ++sit)
|
||||
{
|
||||
hash_set::iterator hit;
|
||||
|
|
@ -157,17 +169,21 @@ namespace spot
|
|||
dst->destroy();
|
||||
if (i == state_num.end()) // Ignore useless destinations.
|
||||
continue;
|
||||
trs* t = res->create_transition(src_num, i->second);
|
||||
res->add_conditions(t, succit->current_condition());
|
||||
bdd acc = bddfalse;
|
||||
if (accepting)
|
||||
res->add_acceptance_condition(t, ltl::constant::true_instance());
|
||||
acc = allacc;
|
||||
res->new_transition(src_num, i->second,
|
||||
succit->current_condition(), acc);
|
||||
}
|
||||
}
|
||||
res->merge_transitions();
|
||||
const state* init_state = a->get_init_state();
|
||||
unsigned init_num = state_num[init_state];
|
||||
init_state->destroy();
|
||||
res->set_init_state(init_num);
|
||||
if (res->num_states() > 0)
|
||||
{
|
||||
const state* init_state = a->get_init_state();
|
||||
unsigned init_num = state_num[init_state];
|
||||
init_state->destroy();
|
||||
res->set_init_state(init_num);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -212,6 +228,7 @@ namespace spot
|
|||
wdba_scc_is_accepting(const tgba_digraph* det_a, unsigned scc_n,
|
||||
const tgba* orig_a, scc_map& sm, power_map& pm)
|
||||
{
|
||||
|
||||
// Get some state from the SCC #n.
|
||||
const state* start = sm.one_state_of(scc_n)->clone();
|
||||
|
||||
|
|
@ -272,8 +289,8 @@ namespace spot
|
|||
|
||||
}
|
||||
|
||||
sba_explicit_number* minimize_dfa(const tgba_digraph* det_a,
|
||||
hash_set* final, hash_set* non_final)
|
||||
tgba_digraph* minimize_dfa(const tgba_digraph* det_a,
|
||||
hash_set* final, hash_set* non_final)
|
||||
{
|
||||
typedef std::list<hash_set*> partition_t;
|
||||
partition_t cur_run;
|
||||
|
|
@ -460,7 +477,7 @@ namespace spot
|
|||
#endif
|
||||
|
||||
// Build the result.
|
||||
sba_explicit_number* res = build_result(det_a, done, final_copy);
|
||||
auto* res = build_result(det_a, done, final_copy);
|
||||
|
||||
// Free all the allocated memory.
|
||||
delete final_copy;
|
||||
|
|
@ -479,7 +496,7 @@ namespace spot
|
|||
}
|
||||
|
||||
|
||||
sba_explicit_number* minimize_monitor(const tgba* a)
|
||||
tgba_digraph* minimize_monitor(const tgba* a)
|
||||
{
|
||||
hash_set* final = new hash_set;
|
||||
hash_set* non_final = new hash_set;
|
||||
|
|
@ -497,7 +514,7 @@ namespace spot
|
|||
return minimize_dfa(det_a, final, non_final);
|
||||
}
|
||||
|
||||
sba_explicit_number* minimize_wdba(const tgba* a)
|
||||
tgba_digraph* minimize_wdba(const tgba* a)
|
||||
{
|
||||
hash_set* final = new hash_set;
|
||||
hash_set* non_final = new hash_set;
|
||||
|
|
@ -596,21 +613,21 @@ namespace spot
|
|||
return minimize_dfa(det_a, final, non_final);
|
||||
}
|
||||
|
||||
tgba*
|
||||
minimize_obligation(const tgba* aut_f,
|
||||
tgba_digraph*
|
||||
minimize_obligation(const tgba_digraph* aut_f,
|
||||
const ltl::formula* f, const tgba* aut_neg_f,
|
||||
bool reject_bigger)
|
||||
{
|
||||
sba_explicit_number* min_aut_f = minimize_wdba(aut_f);
|
||||
auto min_aut_f = minimize_wdba(aut_f);
|
||||
|
||||
if (reject_bigger)
|
||||
{
|
||||
// Abort if min_aut_f has more states than aut_f.
|
||||
unsigned orig_states = count_states(aut_f);
|
||||
unsigned orig_states = aut_f->num_states();
|
||||
if (orig_states < min_aut_f->num_states())
|
||||
{
|
||||
delete min_aut_f;
|
||||
return const_cast<tgba*>(aut_f);
|
||||
return const_cast<tgba_digraph*>(aut_f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -653,7 +670,7 @@ namespace spot
|
|||
{
|
||||
// Otherwise, we cannot check if the minimization is safe.
|
||||
delete min_aut_f;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -705,6 +722,6 @@ namespace spot
|
|||
if (ok)
|
||||
return min_aut_f;
|
||||
delete min_aut_f;
|
||||
return const_cast<tgba*>(aut_f);
|
||||
return const_cast<tgba_digraph*>(aut_f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche
|
||||
// et Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Laboratoire de
|
||||
// Recherche et Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef SPOT_TGBAALGOS_MINIMIZE_HH
|
||||
# define SPOT_TGBAALGOS_MINIMIZE_HH
|
||||
|
||||
# include "tgba/tgbaexplicit.hh"
|
||||
# include "tgba/tgbagraph.hh"
|
||||
# include "ltlast/formula.hh"
|
||||
|
||||
namespace spot
|
||||
|
|
@ -57,7 +57,7 @@ namespace spot
|
|||
/// \param a the automaton to convert into a minimal deterministic monitor
|
||||
/// \pre Dead SCCs should have been removed from \a a before
|
||||
/// calling this function.
|
||||
SPOT_API sba_explicit_number* minimize_monitor(const tgba* a);
|
||||
SPOT_API tgba_digraph* minimize_monitor(const tgba* a);
|
||||
|
||||
/// \brief Minimize a Büchi automaton in the WDBA class.
|
||||
///
|
||||
|
|
@ -93,7 +93,7 @@ namespace spot
|
|||
month = oct
|
||||
}
|
||||
\endverbatim */
|
||||
SPOT_API sba_explicit_number* minimize_wdba(const tgba* a);
|
||||
SPOT_API tgba_digraph* minimize_wdba(const tgba* a);
|
||||
|
||||
/// \brief Minimize an automaton if it represents an obligation property.
|
||||
///
|
||||
|
|
@ -150,10 +150,10 @@ namespace spot
|
|||
/// determinization step during minimize_wdba().) Note that
|
||||
/// checking the size of the minimized WDBA occurs before ensuring
|
||||
/// that the minimized WDBA is correct.
|
||||
SPOT_API tgba* minimize_obligation(const tgba* aut_f,
|
||||
const ltl::formula* f = 0,
|
||||
const tgba* aut_neg_f = 0,
|
||||
bool reject_bigger = false);
|
||||
SPOT_API tgba_digraph* minimize_obligation(const tgba_digraph* aut_f,
|
||||
const ltl::formula* f = 0,
|
||||
const tgba* aut_neg_f = 0,
|
||||
bool reject_bigger = false);
|
||||
|
||||
/// @}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
const tgba* postprocessor::do_simul(const tgba* a, int opt)
|
||||
const tgba_digraph* postprocessor::do_simul(const tgba_digraph* a, int opt)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
|
@ -95,7 +95,8 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
const tgba* postprocessor::do_ba_simul(const tgba* a, int opt)
|
||||
const tgba_digraph* postprocessor::do_ba_simul(const tgba_digraph* a,
|
||||
int opt)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
|
@ -112,18 +113,16 @@ namespace spot
|
|||
}
|
||||
|
||||
|
||||
const tgba* postprocessor::do_degen(const tgba* a)
|
||||
const tgba_digraph* postprocessor::do_degen(const tgba_digraph* a)
|
||||
{
|
||||
const tgba* d = degeneralize(a,
|
||||
degen_reset_,
|
||||
degen_order_,
|
||||
degen_cache_,
|
||||
degen_lskip_);
|
||||
auto d = degeneralize(a,
|
||||
degen_reset_, degen_order_,
|
||||
degen_cache_, degen_lskip_);
|
||||
delete a;
|
||||
if (ba_simul_ <= 0)
|
||||
return d;
|
||||
|
||||
const tgba* s = do_ba_simul(d, ba_simul_);
|
||||
auto s = do_ba_simul(d, ba_simul_);
|
||||
if (s != d)
|
||||
delete d;
|
||||
|
||||
|
|
@ -133,7 +132,8 @@ namespace spot
|
|||
#define PREF_ (pref_ & (Small | Deterministic))
|
||||
#define COMP_ (pref_ & Complete)
|
||||
|
||||
const tgba* postprocessor::run(const tgba* a, const ltl::formula* f)
|
||||
const tgba_digraph*
|
||||
postprocessor::run(const tgba_digraph* a, const ltl::formula* f)
|
||||
{
|
||||
if (type_ == TGBA && PREF_ == Any && level_ == Low)
|
||||
return a;
|
||||
|
|
@ -154,13 +154,13 @@ namespace spot
|
|||
{
|
||||
// Do not bother about acceptance conditions, they will be
|
||||
// ignored.
|
||||
const tgba* s = scc_filter_states(a);
|
||||
auto s = scc_filter_states(a);
|
||||
delete a;
|
||||
a = s;
|
||||
}
|
||||
else if (scc_filter_ > 0)
|
||||
{
|
||||
const tgba* s = scc_filter(a, scc_filter_ > 1);
|
||||
auto s = scc_filter(a, scc_filter_ > 1);
|
||||
delete a;
|
||||
a = s;
|
||||
}
|
||||
|
|
@ -169,20 +169,18 @@ namespace spot
|
|||
{
|
||||
if (PREF_ == Deterministic)
|
||||
{
|
||||
const tgba* m = minimize_monitor(a);
|
||||
auto m = minimize_monitor(a);
|
||||
delete a;
|
||||
return m;
|
||||
}
|
||||
else
|
||||
{
|
||||
const tgba* m = strip_acceptance(a);
|
||||
delete a;
|
||||
a = m;
|
||||
strip_acceptance_here(const_cast<tgba_digraph*>(a));
|
||||
}
|
||||
if (PREF_ == Any)
|
||||
return a;
|
||||
|
||||
const tgba* sim = do_simul(a, simul_);
|
||||
auto sim = do_simul(a, simul_);
|
||||
if (a == sim)
|
||||
// simulation was disabled.
|
||||
return a;
|
||||
|
|
@ -193,9 +191,9 @@ namespace spot
|
|||
}
|
||||
// For Small,High we return the smallest between the output of
|
||||
// the simulation, and that of the deterministic minimization.
|
||||
const tgba* m = minimize_monitor(a);
|
||||
auto m = minimize_monitor(a);
|
||||
delete a;
|
||||
if (count_states(m) > count_states(sim))
|
||||
if (m->num_states() > sim->num_states())
|
||||
{
|
||||
delete m;
|
||||
}
|
||||
|
|
@ -206,7 +204,7 @@ namespace spot
|
|||
}
|
||||
if (COMP_ == Complete)
|
||||
{
|
||||
const tgba* s = tgba_complete(sim);
|
||||
auto s = tgba_complete(sim);
|
||||
delete sim;
|
||||
sim = s;
|
||||
}
|
||||
|
|
@ -222,8 +220,8 @@ namespace spot
|
|||
|
||||
bool dba_is_wdba = false;
|
||||
bool dba_is_minimal = false;
|
||||
const tgba* dba = 0;
|
||||
const tgba* sim = 0;
|
||||
const tgba_digraph* dba = 0;
|
||||
const tgba_digraph* sim = 0;
|
||||
|
||||
// (Small,Low) is the only configuration where we do not run
|
||||
// WDBA-minimization.
|
||||
|
|
@ -231,7 +229,7 @@ namespace spot
|
|||
{
|
||||
bool reject_bigger = (PREF_ == Small) && (level_ == Medium);
|
||||
dba = minimize_obligation(a, f, 0, reject_bigger);
|
||||
if (dba == a) // Minimization failed.
|
||||
if (dba == a || dba == 0) // Minimization failed.
|
||||
dba = 0;
|
||||
else
|
||||
dba_is_minimal = dba_is_wdba = true;
|
||||
|
|
@ -243,7 +241,6 @@ namespace spot
|
|||
if (!dba || (level_ == High && PREF_ == Small))
|
||||
{
|
||||
sim = do_simul(a, simul_);
|
||||
|
||||
if (sim != a)
|
||||
delete a;
|
||||
|
||||
|
|
@ -363,8 +360,8 @@ namespace spot
|
|||
in = dba;
|
||||
}
|
||||
|
||||
const tgba* cmp = tgba_complete(in);
|
||||
const tgba* res = 0;
|
||||
const tgba_digraph* cmp = tgba_complete(in);
|
||||
const tgba_digraph* res = 0;
|
||||
if (target_acc == 1)
|
||||
{
|
||||
if (sat_states_ != -1)
|
||||
|
|
@ -408,14 +405,14 @@ namespace spot
|
|||
&& !(dba_is_minimal && state_based_
|
||||
&& dba->number_of_acceptance_conditions() == 1))
|
||||
{
|
||||
const tgba* d = degeneralize(dba);
|
||||
auto d = degeneralize(dba);
|
||||
delete dba;
|
||||
dba = d;
|
||||
}
|
||||
|
||||
if (dba && sim)
|
||||
{
|
||||
if (count_states(dba) > count_states(sim))
|
||||
if (dba->num_states() > sim->num_states())
|
||||
{
|
||||
delete dba;
|
||||
dba = 0;
|
||||
|
|
@ -432,14 +429,14 @@ namespace spot
|
|||
{
|
||||
if (dba && !dba_is_minimal) // WDBA is already clean.
|
||||
{
|
||||
const tgba* s = scc_filter(dba, true);
|
||||
auto s = scc_filter(dba, true);
|
||||
delete dba;
|
||||
assert(!sim);
|
||||
dba = s;
|
||||
}
|
||||
else if (sim)
|
||||
{
|
||||
const tgba* s = scc_filter(sim, true);
|
||||
auto s = scc_filter(sim, true);
|
||||
delete sim;
|
||||
assert(!dba);
|
||||
sim = s;
|
||||
|
|
@ -450,7 +447,7 @@ namespace spot
|
|||
|
||||
if (COMP_ == Complete)
|
||||
{
|
||||
const tgba* s = tgba_complete(sim);
|
||||
auto s = tgba_complete(sim);
|
||||
delete sim;
|
||||
sim = s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef SPOT_TGBAALGOS_POSTPROC_HH
|
||||
# define SPOT_TGBAALGOS_POSTPROC_HH
|
||||
|
||||
#include "tgba/tgba.hh"
|
||||
#include "tgba/tgbagraph.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -97,12 +97,13 @@ namespace spot
|
|||
}
|
||||
|
||||
/// Return the optimized automaton and delete \a input_disown.
|
||||
const tgba* run(const tgba* input_disown, const ltl::formula* f);
|
||||
const tgba_digraph* run(const tgba_digraph* input_disown,
|
||||
const ltl::formula* f);
|
||||
|
||||
protected:
|
||||
const tgba* do_simul(const tgba* input, int opt);
|
||||
const tgba* do_ba_simul(const tgba* input, int opt);
|
||||
const tgba* do_degen(const tgba* input);
|
||||
const tgba_digraph* do_simul(const tgba_digraph* input, int opt);
|
||||
const tgba_digraph* do_ba_simul(const tgba_digraph* input, int opt);
|
||||
const tgba_digraph* do_degen(const tgba_digraph* input);
|
||||
|
||||
output_type type_;
|
||||
int pref_;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
#include "tgba/tgbaexplicit.hh"
|
||||
#include "sccfilter.hh"
|
||||
#include "reachiter.hh"
|
||||
#include "tgbaalgos/scc.hh"
|
||||
#include "tgbaalgos/sccinfo.hh"
|
||||
#include "scc.hh"
|
||||
#include "sccinfo.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -903,7 +903,8 @@ namespace spot
|
|||
|
||||
if (keep && acc != bddfalse)
|
||||
{
|
||||
unsigned u = this->si->scc_of(src);
|
||||
unsigned u = this->si->scc_of(dst);
|
||||
|
||||
auto i = remap_[u].find(acc.id());
|
||||
if (i != remap_[u].end())
|
||||
acc = i->second;
|
||||
|
|
@ -920,6 +921,12 @@ namespace spot
|
|||
tgba_digraph* scc_filter_apply(const tgba_digraph* aut,
|
||||
scc_info* given_si, Args&&... args)
|
||||
{
|
||||
bdd_dict* bd = aut->get_dict();
|
||||
tgba_digraph* filtered = new tgba_digraph(bd);
|
||||
unsigned in_n = aut->num_states(); // Number of input states.
|
||||
if (in_n == 0) // Nothing to filter.
|
||||
return filtered;
|
||||
|
||||
// Compute scc_info if not supplied.
|
||||
scc_info* si = given_si;
|
||||
if (!si)
|
||||
|
|
@ -928,7 +935,6 @@ namespace spot
|
|||
F filter(si, std::forward<Args>(args)...);
|
||||
|
||||
// Renumber all useful states.
|
||||
unsigned in_n = aut->num_states(); // Number of input states.
|
||||
unsigned out_n = 0; // Number of output states.
|
||||
std::vector<unsigned> inout; // Associate old states to new ones.
|
||||
inout.reserve(in_n);
|
||||
|
|
@ -938,8 +944,6 @@ namespace spot
|
|||
else
|
||||
inout.push_back(-1U);
|
||||
|
||||
bdd_dict* bd = aut->get_dict();
|
||||
tgba_digraph* filtered = new tgba_digraph(bd);
|
||||
bd->register_all_variables_of(aut, filtered);
|
||||
{
|
||||
bdd all = aut->all_acceptance_conditions();
|
||||
|
|
@ -989,14 +993,17 @@ namespace spot
|
|||
scc_filter(const tgba_digraph* aut, bool remove_all_useless,
|
||||
scc_info* given_si)
|
||||
{
|
||||
tgba_digraph* res;
|
||||
if (remove_all_useless)
|
||||
return scc_filter_apply<state_filter
|
||||
<acc_filter_all
|
||||
<acc_filter_simplify<>>>>(aut, given_si);
|
||||
res = scc_filter_apply<state_filter
|
||||
<acc_filter_all
|
||||
<acc_filter_simplify<>>>>(aut, given_si);
|
||||
else
|
||||
return scc_filter_apply<state_filter
|
||||
<acc_filter_some
|
||||
<acc_filter_simplify<>>>>(aut, given_si);
|
||||
res = scc_filter_apply<state_filter
|
||||
<acc_filter_some
|
||||
<acc_filter_simplify<>>>>(aut, given_si);
|
||||
res->merge_transitions();
|
||||
return res;
|
||||
}
|
||||
|
||||
tgba_digraph*
|
||||
|
|
@ -1004,22 +1011,25 @@ namespace spot
|
|||
bdd suspvars, bdd ignoredvars, bool early_susp,
|
||||
scc_info* given_si)
|
||||
{
|
||||
tgba_digraph* res;
|
||||
if (remove_all_useless)
|
||||
return scc_filter_apply<susp_filter
|
||||
<state_filter
|
||||
<acc_filter_all
|
||||
<acc_filter_simplify<>>>>>(aut, given_si,
|
||||
suspvars,
|
||||
ignoredvars,
|
||||
early_susp);
|
||||
res = scc_filter_apply<susp_filter
|
||||
<state_filter
|
||||
<acc_filter_all
|
||||
<acc_filter_simplify<>>>>>(aut, given_si,
|
||||
suspvars,
|
||||
ignoredvars,
|
||||
early_susp);
|
||||
else
|
||||
return scc_filter_apply<susp_filter
|
||||
<state_filter
|
||||
<acc_filter_some
|
||||
<acc_filter_simplify<>>>>>(aut, given_si,
|
||||
suspvars,
|
||||
ignoredvars,
|
||||
early_susp);
|
||||
res = scc_filter_apply<susp_filter
|
||||
<state_filter
|
||||
<acc_filter_some
|
||||
<acc_filter_simplify<>>>>>(aut, given_si,
|
||||
suspvars,
|
||||
ignoredvars,
|
||||
early_susp);
|
||||
res->merge_transitions();
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,13 +76,14 @@ namespace spot
|
|||
|
||||
|
||||
// Setup depth-first search from the initial state.
|
||||
{
|
||||
unsigned init = aut->get_init_state_number();
|
||||
num_ = -1;
|
||||
h_[init] = num_;
|
||||
root_.emplace_front(num_, bddfalse, bddfalse);
|
||||
todo_.emplace(init, aut->out(init).begin());
|
||||
}
|
||||
if (n > 0)
|
||||
{
|
||||
unsigned init = aut->get_init_state_number();
|
||||
num_ = -1;
|
||||
h_[init] = num_;
|
||||
root_.emplace_front(num_, bddfalse, bddfalse);
|
||||
todo_.emplace(init, aut->out(init).begin());
|
||||
}
|
||||
|
||||
while (!todo_.empty())
|
||||
{
|
||||
|
|
@ -237,7 +238,7 @@ namespace spot
|
|||
for (unsigned src = 0; src < n; ++src)
|
||||
{
|
||||
unsigned src_scc = scc_of(src);
|
||||
if (!is_accepting_scc(src_scc))
|
||||
if (src_scc == -1U || !is_accepting_scc(src_scc))
|
||||
continue;
|
||||
for (auto& t: aut_->out(src))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
// Copyright (C) 2012, 2014 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -22,42 +22,13 @@
|
|||
|
||||
namespace spot
|
||||
{
|
||||
namespace
|
||||
void strip_acceptance_here(tgba_digraph* a)
|
||||
{
|
||||
class strip_iter: public tgba_reachable_iterator_depth_first
|
||||
{
|
||||
public:
|
||||
strip_iter(const tgba* a)
|
||||
: tgba_reachable_iterator_depth_first(a),
|
||||
out_(new sba_explicit_number(a->get_dict()))
|
||||
{
|
||||
}
|
||||
|
||||
sba_explicit_number*
|
||||
result()
|
||||
{
|
||||
return out_;
|
||||
}
|
||||
|
||||
void
|
||||
process_link(const state*, int in,
|
||||
const state*, int out,
|
||||
const tgba_succ_iterator* si)
|
||||
{
|
||||
state_explicit_number::transition* t = out_->create_transition(in, out);
|
||||
out_->add_conditions(t, si->current_condition());
|
||||
}
|
||||
|
||||
private:
|
||||
sba_explicit_number* out_;
|
||||
};
|
||||
}
|
||||
|
||||
sba_explicit_number*
|
||||
strip_acceptance(const tgba* a)
|
||||
{
|
||||
strip_iter si(a);
|
||||
si.run();
|
||||
return si.result();
|
||||
unsigned n = a->num_states();
|
||||
for (unsigned s = 0; s < n; ++s)
|
||||
for (auto& t: a->out(s))
|
||||
t.acc = bddfalse;
|
||||
a->set_acceptance_conditions(bddfalse);
|
||||
a->get_dict()->unregister_all_typed_variables(bdd_dict::acc, a);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -20,16 +20,16 @@
|
|||
#ifndef SPOT_TGBAALGOS_STRIPACC_HH
|
||||
# define SPOT_TGBAALGOS_STRIPACC_HH
|
||||
|
||||
# include "tgba/tgbaexplicit.hh"
|
||||
# include "tgba/tgbagraph.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
/// \ingroup tgba_misc
|
||||
/// \brief Duplicate automaton \a a, removing all acceptance sets.
|
||||
/// \brief Remove all acceptance sets from a tgba_digraph.
|
||||
///
|
||||
/// This is equivalent to marking all states/transitions as accepting.
|
||||
SPOT_API sba_explicit_number*
|
||||
strip_acceptance(const tgba* a);
|
||||
SPOT_API void
|
||||
strip_acceptance_here(tgba_digraph* a);
|
||||
}
|
||||
|
||||
#endif // SPOT_TGBAALGOS_STRIPACC_HH
|
||||
|
|
|
|||
|
|
@ -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 (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -61,7 +61,7 @@ namespace spot
|
|||
simpl_owned_ = simpl_ = new ltl::ltl_simplifier(options, dict);
|
||||
}
|
||||
|
||||
const tgba* translator::run(const ltl::formula** f)
|
||||
const tgba_digraph* translator::run(const ltl::formula** f)
|
||||
{
|
||||
const ltl::formula* r = simpl_->simplify(*f);
|
||||
(*f)->destroy();
|
||||
|
|
@ -71,7 +71,7 @@ namespace spot
|
|||
// natural way (improving the degeneralization).
|
||||
simpl_->clear_as_bdd_cache();
|
||||
|
||||
const tgba* aut;
|
||||
const tgba_digraph* aut;
|
||||
if (comp_susp_ > 0)
|
||||
{
|
||||
int skel_wdba = skel_wdba_;
|
||||
|
|
@ -91,10 +91,10 @@ namespace spot
|
|||
return aut;
|
||||
}
|
||||
|
||||
const tgba* translator::run(const ltl::formula* f)
|
||||
const tgba_digraph* translator::run(const ltl::formula* f)
|
||||
{
|
||||
f->clone();
|
||||
const tgba* aut = run(&f);
|
||||
auto aut = run(&f);
|
||||
f->destroy();
|
||||
return aut;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2013 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -103,14 +103,14 @@ namespace spot
|
|||
///
|
||||
/// The formula \a f is simplified internally, but it is not
|
||||
/// not destroyed (this is the responsibility of the caller).
|
||||
const tgba* run(const ltl::formula* f);
|
||||
const tgba_digraph* run(const ltl::formula* f);
|
||||
|
||||
/// \brief Convert \a f into an automaton, and update f.
|
||||
///
|
||||
/// The formula <code>*f</code> is destroyed, and replaced
|
||||
/// by the simplified version, which should be destroyed by
|
||||
/// the caller.
|
||||
const tgba* run(const ltl::formula** f);
|
||||
const tgba_digraph* run(const ltl::formula** f);
|
||||
|
||||
protected:
|
||||
void setup_opt(const option_map* opt);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue