tgba: move boolean properties from tgba_digraph to tgba

* src/tgba/tgbagraph.hh: Remove the set_bprop/get_bprop interface.
* src/tgba/tgba.cc, src/tgba/tgba.hh: Add a new interface for
setting/querying/copying the following properties: single_acc_set,
state_based_acc, inherently_weak, deterministic.
* src/dstarparse/dra2ba.cc, src/dstarparse/nra2nba.cc,
src/neverparse/neverclaimparse.yy, src/saba/sabacomplementtgba.cc,
src/tgba/tgbagraph.cc, src/tgbaalgos/degen.cc, src/tgbaalgos/dotty.cc,
src/tgbaalgos/isdet.cc, src/tgbaalgos/lbtt.cc,
src/tgbaalgos/minimize.cc, src/tgbaalgos/neverclaim.cc,
src/tgbaalgos/postproc.cc, src/tgbaalgos/sccfilter.cc,
src/tgbaalgos/simulation.cc, src/tgbatest/degenlskip.test,
src/tgbatest/ltl2tgba.cc: Adjust to the new interface, or use
it to bypass some useless work.
This commit is contained in:
Alexandre Duret-Lutz 2014-08-15 16:10:39 +02:00
parent e3b5119f25
commit b43f75e917
19 changed files with 160 additions and 87 deletions

View file

@ -264,7 +264,9 @@ namespace spot
res->copy_ap_of(a);
res->set_single_acceptance_set();
if (want_sba)
res->set_bprop(tgba_digraph::StateBasedAcc);
res->prop_state_based_acc();
// Preserve determinism and weakness
res->prop_copy(a, false, false, true, true);
// Create an order of acceptance conditions. Each entry in this
// vector correspond to an acceptance set. Each index can
@ -624,8 +626,8 @@ namespace spot
{
// If this already a degeneralized digraph, there is nothing we
// can improve.
if (auto d = std::dynamic_pointer_cast<const tgba_digraph>(a))
if (d->get_bprop(tgba_digraph::SBA))
if (a->is_sba())
if (auto d = std::dynamic_pointer_cast<const tgba_digraph>(a))
return std::const_pointer_cast<tgba_digraph>(d);
return degeneralize_aux<true>(a, use_z_lvl, use_cust_acc_orders,
@ -639,8 +641,8 @@ namespace spot
{
// If this already a degeneralized digraph, there is nothing we
// can improve.
if (auto d = std::dynamic_pointer_cast<const tgba_digraph>(a))
if (d->get_bprop(tgba_digraph::SingleAccSet))
if (a->has_single_acc_set())
if (auto d = std::dynamic_pointer_cast<const tgba_digraph>(a))
return std::const_pointer_cast<tgba_digraph>(d);
return degeneralize_aux<false>(a, use_z_lvl, use_cust_acc_orders,

View file

@ -129,10 +129,7 @@ namespace spot
{
if (!dd)
dd = dotty_decorator::instance();
if (auto gd = dynamic_cast<const tgba_digraph*>(g.get()))
assume_sba |= gd->get_bprop(tgba_digraph::StateBasedAcc);
dotty_bfs d(os, g, assume_sba, dd);
dotty_bfs d(os, g, assume_sba || g->has_state_based_acc(), dd);
d.run();
return os;
}

View file

@ -25,9 +25,10 @@ namespace spot
{
namespace
{
template<bool count>
static
unsigned
count_nondet_states_aux(const const_tgba_ptr& aut, bool count = true)
count_nondet_states_aux(const const_tgba_ptr& aut)
{
unsigned res = 0;
typedef std::deque<const state*> todo_list;
@ -82,13 +83,15 @@ namespace spot
unsigned
count_nondet_states(const const_tgba_ptr& aut)
{
return count_nondet_states_aux(aut);
return count_nondet_states_aux<true>(aut);
}
bool
is_deterministic(const const_tgba_ptr& aut)
{
return !count_nondet_states_aux(aut, false);
if (aut->is_deterministic())
return true;
return !count_nondet_states_aux<false>(aut);
}
bool

View file

@ -79,13 +79,13 @@ namespace spot
all_acc_conds_(a->all_acceptance_conditions()),
acs_(all_acc_conds_),
sba_format_(sba_format),
// Check if the automaton can be converted into a
// tgba_digraph. This makes the state_is_accepting()
// function more efficient.
sba_(std::dynamic_pointer_cast<const tgba_digraph>(a))
sba_(nullptr)
{
if (sba_ && !sba_->get_bprop(tgba_digraph::SBA))
sba_ = nullptr;
// Check if the automaton can be converted into a
// tgba_digraph. This makes the state_is_accepting() function
// more efficient.
if (a->is_sba())
sba_ = std::dynamic_pointer_cast<const tgba_digraph>(a);
}
bool
@ -243,7 +243,7 @@ namespace spot
auto aut = make_tgba_digraph(dict);
acc_mapper_int acc_b(aut, num_acc, envacc);
aut->new_states(num_states);
aut->set_bprop(tgba_digraph::StateBasedAcc);
aut->prop_state_based_acc();
for (unsigned n = 0; n < num_states; ++n)
{

View file

@ -122,7 +122,7 @@ namespace spot
auto dict = a->get_dict();
auto res = make_tgba_digraph(dict);
res->copy_ap_of(a);
res->set_bprop(tgba_digraph::StateBasedAcc);
res->prop_state_based_acc();
// 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
@ -499,8 +499,10 @@ namespace spot
// non_final contain all states.
// final is empty: there is no acceptance condition
build_state_set(det_a, non_final);
return minimize_dfa(det_a, final, non_final);
auto res = minimize_dfa(det_a, final, non_final);
res->prop_deterministic();
res->prop_inherently_weak();
return res;
}
tgba_digraph_ptr minimize_wdba(const const_tgba_ptr& a)
@ -599,7 +601,10 @@ namespace spot
}
}
return minimize_dfa(det_a, final, non_final);
auto res = minimize_dfa(det_a, final, non_final);
res->prop_deterministic();
res->prop_inherently_weak();
return res;
}
tgba_digraph_ptr
@ -618,6 +623,11 @@ namespace spot
return std::const_pointer_cast<tgba_digraph>(aut_f);
}
// If the input automaton was already weak and deterministic, the
// output is necessary correct.
if (aut_f->is_inherently_weak() && aut_f->is_deterministic())
return min_aut_f;
// if f is a syntactic obligation formula, the WDBA minimization
// must be correct.
if (f && f->is_syntactic_obligation())

View file

@ -44,7 +44,7 @@ namespace spot
comments_(comments), all_acc_conds_(a->all_acceptance_conditions()),
sba_(std::dynamic_pointer_cast<const tgba_digraph>(a))
{
assert(!sba_ || sba_->get_bprop(tgba_digraph::StateBasedAcc));
assert(!sba_ || sba_->has_state_based_acc());
}
void

View file

@ -195,10 +195,11 @@ namespace spot
{
bool reject_bigger = (PREF_ == Small) && (level_ == Medium);
dba = minimize_obligation(a, f, 0, reject_bigger);
if (dba == a || !dba) // Minimization failed.
dba = nullptr;
else
if (dba && dba->is_inherently_weak() && dba->is_deterministic())
dba_is_minimal = dba_is_wdba = true;
else
// Minimization failed.
dba = nullptr;
// The WDBA is a BA, so no degeneralization is required.
}

View file

@ -498,10 +498,8 @@ namespace spot
tgba_digraph_ptr
scc_filter_states(const const_tgba_digraph_ptr& aut, scc_info* given_si)
{
bool sb = aut->get_bprop(tgba_digraph::StateBasedAcc);
auto res = scc_filter_apply<state_filter<>>(aut, given_si);
if (sb)
res->set_bprop(tgba_digraph::StateBasedAcc);
res->prop_copy(aut, true, true, true, true);
return res;
}
@ -519,6 +517,11 @@ namespace spot
<acc_filter_some
<acc_filter_simplify<>>>>(aut, given_si);
res->merge_transitions();
res->prop_copy(aut,
false, // state-based acceptance is not preserved
true,
true,
true);
return res;
}
@ -545,6 +548,11 @@ namespace spot
ignoredvars,
early_susp);
res->merge_transitions();
res->prop_copy(aut,
false, // state-based acceptance is not preserved
true,
true,
false); // determinism may not be preserved
return res;
}

View file

@ -526,15 +526,6 @@ namespace spot
}
}
bool result_is_deterministic() const
{
assert(stat.states != 0);
return res_is_deterministic;
}
// Build the minimal resulting automaton.
tgba_digraph_ptr build_result()
{
@ -550,7 +541,7 @@ namespace spot
res->copy_ap_of(a_);
res->set_acceptance_conditions(all_acceptance_conditions_);
if (Sba)
res->set_bprop(tgba_digraph::StateBasedAcc);
res->prop_state_based_acc();
bdd sup_all_acc = bdd_support(all_acceptance_conditions_);
// Non atomic propositions variables (= acc and class)
@ -691,7 +682,15 @@ namespace spot
}
delete gb;
res_is_deterministic = nb_minato == nb_satoneset;
res->prop_copy(original_,
false, // state-based acc forced below
false, // single acc is set by set_acceptance_conditions
true, // weakness preserved,
false); // determinism checked and set below
if (nb_minato == nb_satoneset)
res->prop_deterministic();
if (Sba)
res->prop_state_based_acc();
return res;
}
@ -779,8 +778,6 @@ namespace spot
const_tgba_ptr original_;
bdd all_acceptance_conditions_;
bool res_is_deterministic;
};
// For now, we don't try to handle cosimulation.
@ -1267,7 +1264,6 @@ namespace spot
{
min = tmp;
min_size_ = cur_size;
res_is_deterministic = dir_sim.result_is_deterministic();
}
}
@ -1342,7 +1338,7 @@ namespace spot
prev = next;
direct_simulation<false, Sba> simul(res ? res : t);
res = simul.run();
if (simul.result_is_deterministic())
if (res->is_deterministic())
break;
direct_simulation<true, Sba> cosimul(res);