Commit cbb2e64e authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

twa: rename the is_* getters as prop_*

This fixes #116.

* src/twa/twa.hh: Rename those methods.
* NEWS: Document the renamings.
* doc/org/hoa.org, doc/org/tut21.org, src/parseaut/parseaut.yy,
src/tests/ikwiad.cc, src/twa/twagraph.hh,
src/twaalgos/are_isomorphic.cc, src/twaalgos/complete.cc,
src/twaalgos/degen.cc, src/twaalgos/dot.cc, src/twaalgos/dtbasat.cc,
src/twaalgos/dtgbasat.cc, src/twaalgos/hoa.cc, src/twaalgos/isdet.cc,
src/twaalgos/isunamb.cc, src/twaalgos/lbtt.cc,
src/twaalgos/minimize.cc, src/twaalgos/postproc.cc,
src/twaalgos/product.cc, src/twaalgos/randomgraph.cc,
src/twaalgos/remfin.cc, src/twaalgos/sbacc.cc,
src/twaalgos/simulation.cc, src/twaalgos/stutter.cc,
src/twaalgos/totgba.cc: Adjust.
parent 8ea5f73c
New in spot 1.99.5a (not yet released)
Library:
* Properties of automata (like the "properties:" line of the HOA
format) are stored as bits whose interpretation is True=yes,
False=maybe. Having getters like "aut->is_deterministic()" or
"aut->is_unambiguous()" was confusing, because there are separate
functions "is_deterministic(aut)" and "is_unambiguous(aut)" that
do actually check the automaton. The getters have been renamed
to avoid confusion, and get the names more in line with HOA.
- twa::has_state_based_acc() -> twa::prop_state_acc()
- twa::prop_state_based_acc(bool) -> twa::prop_state_acc(bool)
- twa::is_inherently_weak() -> twa::prop_inherently_weak()
- twa::is_deterministic() -> twa::prop_deterministic()
- twa::is_unambiguous() -> twa::prop_unambiguous()
- twa::is_stutter_invariant() -> twa::prop_stutter_invariant()
- twa::is_stutter_sensitive() -> twa::prop_stutter_sensitive()
The setters have the same name as the getters, except they take a
Boolean argument. This argument used to be optionnal (defaulting
to True), but it no longer is.
Bug fixes:
* automaton parser was ignoring the "unambiguous" property.
......
......@@ -536,7 +536,7 @@ bit is false, it only means that it is unknown whether the property is
true. For instance if in some algorithm you want to know whether an
automaton is deterministic (the equivalent of calling =autfilt -q
--is-deterministic aut.hoa= from the command-line), you not call the
method =aut->is_deterministic()= because that only check the property
method =aut->prop_deterministic()= because that only check the property
bit, and it might be false even if the =aut= is deterministic.
Instead, call the function =is_deterministic(aut)=. This function
will first test the property bit, and do the actual check if it has
......
......@@ -104,12 +104,12 @@ corresponding BDD variable number, and then use for instance
// automaton, so they can be queried in constant time, and they are
// only set whenever they can be determined at a cheap cost.
out << "Deterministic: "
<< (aut->is_deterministic() ? "yes\n" : "maybe\n");
<< (aut->prop_deterministic() ? "yes\n" : "maybe\n");
out << "StateBasedAcc: "
<< (aut->has_state_based_acc() ? "yes\n" : "maybe\n");
<< (aut->prop_state_acc() ? "yes\n" : "maybe\n");
out << "Stutter Invariant: "
<< (aut->is_stutter_invariant() ? "yes\n" :
aut->is_stutter_sensitive() ? "no\n" : "maybe\n");
<< (aut->prop_stutter_invariant() ? "yes\n" :
aut->prop_stutter_sensitive() ? "no\n" : "maybe\n");
// States are numbered from 0 to n-1
unsigned n = aut->num_states();
......
......@@ -1158,7 +1158,7 @@ dstar_header: dstar_sizes
res.h->aut->new_states(res.states);;
res.info_states.resize(res.states);
}
res.h->aut->prop_state_based_acc(true);
res.h->aut->prop_state_acc(true);
res.h->aut->prop_deterministic(true);
// res.h->aut->prop_complete();
fill_guards(res);
......@@ -1303,7 +1303,7 @@ dstar_states:
never: "never" { res.namer = res.h->aut->create_namer<std::string>();
res.h->aut->set_buchi();
res.h->aut->prop_state_based_acc(true);
res.h->aut->prop_state_acc(true);
res.acc_state = State_Acc;
res.pos_acc_sets = res.h->aut->acc().all_sets();
}
......@@ -1560,7 +1560,7 @@ lbtt-header-states: LBTT
lbtt-header: lbtt-header-states INT_S
{
res.acc_mapper = new spot::acc_mapper_int(res.h->aut, $2);
res.h->aut->prop_state_based_acc(true);
res.h->aut->prop_state_acc(true);
res.acc_state = State_Acc;
}
| lbtt-header-states INT
......@@ -1869,7 +1869,7 @@ static void fix_properties(result_& r)
//r.h->aut->prop_complete(r.complete);
if (r.acc_style == State_Acc ||
(r.acc_style == Mixed_Acc && !r.trans_acc_seen))
r.h->aut->prop_state_based_acc(true);
r.h->aut->prop_state_acc(true);
}
static void check_version(const result_& r)
......
......@@ -1026,7 +1026,7 @@ checked_main(int argc, char** argv)
if (scc_filter)
{
tm.start("SCC-filter");
if (a->has_state_based_acc() & !scc_filter_all)
if (a->prop_state_acc() & !scc_filter_all)
a = spot::scc_filter_states(ensure_digraph(a));
else
a = spot::scc_filter(ensure_digraph(a), scc_filter_all);
......
......@@ -706,7 +706,7 @@ namespace spot
set_num_sets_(num);
acc_.set_acceptance(c);
if (num == 0)
prop_state_based_acc(true);
prop_state_acc(true);
}
/// \brief Copy the acceptance condition of another tgba.
......@@ -715,7 +715,7 @@ namespace spot
acc_ = a->acc();
unsigned num = acc_.num_sets();
if (num == 0)
prop_state_based_acc(true);
prop_state_acc(true);
}
void copy_ap_of(const const_twa_ptr& a)
......@@ -730,7 +730,7 @@ namespace spot
set_num_sets_(num);
acc_.set_generalized_buchi();
if (num == 0)
prop_state_based_acc(true);
prop_state_acc(true);
}
acc_cond::mark_t set_buchi()
......@@ -805,22 +805,22 @@ namespace spot
named_prop_.clear();
}
bool has_state_based_acc() const
bool prop_state_acc() const
{
return is.state_based_acc;
}
void prop_state_based_acc(bool val)
void prop_state_acc(bool val)
{
is.state_based_acc = val;
}
bool is_sba() const
{
return has_state_based_acc() && acc().is_buchi();
return prop_state_acc() && acc().is_buchi();
}
bool is_inherently_weak() const
bool prop_inherently_weak() const
{
return is.inherently_weak;
}
......@@ -830,7 +830,7 @@ namespace spot
is.inherently_weak = val;
}
bool is_deterministic() const
bool prop_deterministic() const
{
return is.deterministic;
}
......@@ -840,7 +840,7 @@ namespace spot
is.deterministic = val;
}
bool is_unambiguous() const
bool prop_unambiguous() const
{
return is.unambiguous;
}
......@@ -850,12 +850,12 @@ namespace spot
is.unambiguous = val;
}
bool is_stutter_invariant() const
bool prop_stutter_invariant() const
{
return is.stutter_invariant;
}
bool is_stutter_sensitive() const
bool prop_stutter_sensitive() const
{
return is.stutter_sensitive;
}
......@@ -888,25 +888,25 @@ namespace spot
void prop_copy(const const_twa_ptr& other, prop_set p)
{
if (p.state_based)
prop_state_based_acc(other->has_state_based_acc());
prop_state_acc(other->prop_state_acc());
if (p.inherently_weak)
prop_inherently_weak(other->is_inherently_weak());
prop_inherently_weak(other->prop_inherently_weak());
if (p.deterministic)
{
prop_deterministic(other->is_deterministic());
prop_unambiguous(other->is_unambiguous());
prop_deterministic(other->prop_deterministic());
prop_unambiguous(other->prop_unambiguous());
}
if (p.stutter_inv)
{
prop_stutter_invariant(other->is_stutter_invariant());
prop_stutter_sensitive(other->is_stutter_sensitive());
prop_stutter_invariant(other->prop_stutter_invariant());
prop_stutter_sensitive(other->prop_stutter_sensitive());
}
}
void prop_keep(prop_set p)
{
if (!p.state_based)
prop_state_based_acc(false);
prop_state_acc(false);
if (!p.inherently_weak)
prop_inherently_weak(false);
if (!p.deterministic)
......
......@@ -433,7 +433,7 @@ namespace spot
acc_cond::mark_t state_acc_sets(unsigned s) const
{
assert(has_state_based_acc() || num_sets() == 0);
assert(prop_state_acc() || num_sets() == 0);
for (auto& t: g_.out(s))
// Stop at the first edge, since the remaining should be
// labeled identically.
......@@ -443,7 +443,7 @@ namespace spot
bool state_is_accepting(unsigned s) const
{
assert(has_state_based_acc() || num_sets() == 0);
assert(prop_state_acc() || num_sets() == 0);
for (auto& t: g_.out(s))
// Stop at the first edge, since the remaining should be
// labeled identically.
......
......@@ -113,7 +113,7 @@ namespace spot
isomorphism_checker::isomorphism_checker(const const_twa_graph_ptr ref)
{
ref_ = make_twa_graph(ref, twa::prop_set::all());
ref_deterministic_ = ref_->is_deterministic();
ref_deterministic_ = ref_->prop_deterministic();
if (!ref_deterministic_)
{
nondet_states_ = spot::count_nondet_states(ref_);
......@@ -130,14 +130,14 @@ namespace spot
if (ref_deterministic_)
{
if (aut->is_deterministic() || spot::is_deterministic(aut))
if (aut->prop_deterministic() || spot::is_deterministic(aut))
{
return are_isomorphic_det(ref_, aut);
}
}
else
{
if (aut->is_deterministic() ||
if (aut->prop_deterministic() ||
nondet_states_ != spot::count_nondet_states(aut))
{
return false;
......
......@@ -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->has_state_based_acc())
if (!aut->prop_state_acc())
acc = 0U;
aut->new_edge(i, sink, missingcond, acc);
}
......
......@@ -207,7 +207,7 @@ namespace spot
res->copy_ap_of(a);
res->set_buchi();
if (want_sba)
res->prop_state_based_acc(true);
res->prop_state_acc(true);
// Preserve determinism, weakness, and stutter-invariance
res->prop_copy(a, { false, true, true, true });
......
......@@ -468,7 +468,7 @@ namespace spot
sn_ = aut->get_named_prop<std::vector<std::string>>("state-names");
if (opt_name_)
name_ = aut_->get_named_prop<std::string>("automaton-name");
mark_states_ = !opt_force_acc_trans_ && aut_->has_state_based_acc();
mark_states_ = !opt_force_acc_trans_ && aut_->prop_state_acc();
if (opt_shape_ == ShapeAuto)
{
if (sn_ || aut->num_states() > 100)
......
......@@ -640,7 +640,7 @@ namespace spot
a->copy_ap_of(aut);
acc_cond::mark_t acc = a->set_buchi();
if (state_based)
a->prop_state_based_acc(true);
a->prop_state_acc(true);
a->prop_deterministic(true);
a->new_states(satdict.cand_size);
......
......@@ -1026,7 +1026,7 @@ namespace spot
auto a = make_twa_graph(autdict);
a->copy_ap_of(aut);
if (state_based)
a->prop_state_based_acc(true);
a->prop_state_acc(true);
a->prop_deterministic(true);
a->set_acceptance(satdict.cand_nacc, satdict.cand_acc);
a->new_states(satdict.cand_size);
......@@ -1303,7 +1303,7 @@ namespace spot
if (int preproc = om.get("preproc", 3))
{
postprocessor post;
auto sba = (state_based && a->has_state_based_acc()) ?
auto sba = (state_based && a->prop_state_acc()) ?
postprocessor::SBAcc : postprocessor::Any;
post.set_pref(postprocessor::Deterministic
| postprocessor::Complete
......@@ -1332,7 +1332,7 @@ namespace spot
// mode. If the desired output is a Büchi automaton, or not
// desired acceptance was specified, stop here. There is not
// point in minimizing a minimal automaton.
if (a->is_inherently_weak() && a->is_deterministic()
if (a->prop_inherently_weak() && a->prop_deterministic()
&& (target_is_buchi || !user_supplied_acc))
return a;
}
......
......@@ -153,8 +153,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->is_deterministic() || deterministic);
assert(!aut->has_state_based_acc() || state_acc);
assert(!aut->prop_deterministic() || deterministic);
assert(!aut->prop_state_acc() || state_acc);
}
void number_all_ap()
......@@ -402,14 +402,14 @@ namespace spot
prop(" complete");
if (md.is_deterministic)
prop(" deterministic");
if (aut->is_unambiguous())
if (aut->prop_unambiguous())
prop(" unambiguous");
assert(!(aut->is_stutter_invariant() && aut->is_stutter_sensitive()));
if (aut->is_stutter_invariant())
assert(!(aut->prop_stutter_invariant() && aut->prop_stutter_sensitive()));
if (aut->prop_stutter_invariant())
prop(" stutter-invariant");
if (aut->is_stutter_sensitive())
if (aut->prop_stutter_sensitive())
prop(" stutter-sensitive");
if (aut->is_inherently_weak())
if (aut->prop_inherently_weak())
prop(" inherently-weak");
os << nl;
......
......@@ -63,7 +63,7 @@ namespace spot
bool
is_deterministic(const const_twa_graph_ptr& aut)
{
if (aut->is_deterministic())
if (aut->prop_deterministic())
return true;
return !count_nondet_states_aux<false>(aut);
}
......
......@@ -27,7 +27,7 @@ namespace spot
{
bool is_unambiguous(const const_twa_graph_ptr& aut)
{
if (aut->is_deterministic() || aut->is_unambiguous())
if (aut->prop_deterministic() || aut->prop_unambiguous())
return true;
auto clean_a = scc_filter_states(aut);
if (clean_a->num_edges() == 0)
......@@ -41,6 +41,6 @@ namespace spot
bool check_unambiguous(const twa_graph_ptr& aut)
{
aut->prop_unambiguous(is_unambiguous(aut));
return aut->is_unambiguous();
return aut->prop_unambiguous();
}
}
......@@ -133,7 +133,7 @@ namespace spot
throw std::runtime_error
("LBTT only supports generalized Büchi acceptance");
bool sba = g->has_state_based_acc();
bool sba = g->prop_state_acc();
if (opt)
switch (char c = *opt++)
{
......
......@@ -122,7 +122,7 @@ namespace spot
auto dict = a->get_dict();
auto res = make_twa_graph(dict);
res->copy_ap_of(a);
res->prop_state_based_acc(true);
res->prop_state_acc(true);
// 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
......@@ -483,7 +483,7 @@ namespace spot
res->prop_copy(a, { false, false, false, true });
res->prop_deterministic(true);
res->prop_inherently_weak(true);
res->prop_state_based_acc(true);
res->prop_state_acc(true);
return res;
}
......@@ -605,7 +605,7 @@ namespace spot
// If the input automaton was already weak and deterministic, the
// output is necessary correct.
if (aut_f->is_inherently_weak() && aut_f->is_deterministic())
if (aut_f->prop_inherently_weak() && aut_f->prop_deterministic())
return min_aut_f;
// if f is a syntactic obligation formula, the WDBA minimization
......@@ -654,7 +654,7 @@ namespace spot
if (product(min_aut_f, aut_neg_f)->is_empty())
{
// Complement the minimized WDBA.
assert(min_aut_f->is_inherently_weak());
assert(min_aut_f->prop_inherently_weak());
auto neg_min_aut_f = remove_fin(dtwa_complement(min_aut_f));
if (product(aut_f, neg_min_aut_f)->is_empty())
// Finally, we are now sure that it was safe
......
......@@ -146,7 +146,7 @@ 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->is_inherently_weak()) && a->has_state_based_acc())
if ((state_based_ || a->prop_inherently_weak()) && a->prop_state_acc())
return scc_filter_states(a, arg);
else
return scc_filter(a, arg);
......@@ -253,7 +253,7 @@ namespace spot
{
bool reject_bigger = (PREF_ == Small) && (level_ == Medium);
dba = minimize_obligation(a, f, nullptr, reject_bigger);
if (dba && dba->is_inherently_weak() && dba->is_deterministic())
if (dba && dba->prop_inherently_weak() && dba->prop_deterministic())
{
// The WDBA is a BA, so no degeneralization is required.
// We just need to add an acceptance set if there is none.
......@@ -272,7 +272,7 @@ namespace spot
// at hard levels if we want a small output.
if (!dba || (level_ == High && PREF_ == Small))
{
if (((SBACC_ && a->has_state_based_acc())
if (((SBACC_ && a->prop_state_acc())
|| (type_ == BA && a->is_sba()))
&& !tba_determinisation_)
{
......
......@@ -103,14 +103,14 @@ namespace spot
}
}
res->prop_deterministic(left->is_deterministic()
&& right->is_deterministic());
res->prop_stutter_invariant(left->is_stutter_invariant()
&& right->is_stutter_invariant());
res->prop_stutter_sensitive(left->is_stutter_sensitive()
&& right->is_stutter_sensitive());
res->prop_state_based_acc(left->has_state_based_acc()
&& right->has_state_based_acc());
res->prop_deterministic(left->prop_deterministic()
&& right->prop_deterministic());
res->prop_stutter_invariant(left->prop_stutter_invariant()
&& right->prop_stutter_invariant());
res->prop_stutter_sensitive(left->prop_stutter_sensitive()
&& right->prop_stutter_sensitive());
res->prop_state_acc(left->prop_state_acc()
&& right->prop_state_acc());
return res;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment