add support for the weak property

This fixes #119.

* doc/org/tut21.org, doc/org/hoa.org, NEWS: Document it.
* src/twa/twa.hh: Support it in automata.
* src/twaalgos/hoa.cc, src/parseaut/parseaut.yy: Add I/O support.
* src/twaalgos/minimize.cc, src/twaalgos/totgba.cc: Set weak
automata on output.
* src/tests/complement.test, src/tests/parseaut.test,
src/tests/readsave.test, src/tests/remfin.test, src/tests/sccsimpl.test,
src/tests/wdba2.test, wrap/python/tests/automata-io.ipynb: Adjust.
This commit is contained in:
Alexandre Duret-Lutz 2015-11-06 18:31:05 +01:00
parent eecd201273
commit 654888718c
15 changed files with 62 additions and 33 deletions

View file

@ -436,8 +436,10 @@ header: format-version header-items
res.h->aut->prop_stutter_sensitive(ss);
bool iw = res.props.find("inherently-weak") != e;
res.h->aut->prop_inherently_weak(iw);
bool iu = res.props.find("unambiguous") != e;
res.h->aut->prop_unambiguous(iu);
bool wk = res.props.find("weak") != e;
res.h->aut->prop_weak(wk);
bool un = res.props.find("unambiguous") != e;
res.h->aut->prop_unambiguous(un);
}
}

View file

@ -78,7 +78,7 @@ AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic inherently-weak
properties: deterministic weak
--BODY--
State: 0
[0] 2

View file

@ -1189,8 +1189,7 @@ run 2 ../ikwiad -XH foob 2>output.err
grep 'foob:1.1: Cannot open file foob' output.err
# Make sure we can read multiple automata from stdin
../../bin/ltl2tgba 'a U b' 'GFa' --hoa | grep -v '^name:' |
sed 's/ stutter-invariant//;s/ inherently-weak//;/properties:$/d' > input
../../bin/ltl2tgba 'a U b' 'GFa' --hoa | grep -v '^name:' > input
../../bin/autfilt --hoa < input | ../../bin/autfilt --hoa > output
diff input output

View file

@ -726,8 +726,7 @@ Start: 1
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc deterministic
properties: inherently-weak
properties: trans-labels explicit-labels state-acc deterministic weak
--BODY--
State: 0
[1] 2
@ -752,7 +751,7 @@ AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: no-univ-branch trans-labels explicit-labels state-acc
properties: deterministic unambiguous inherently-weak
properties: deterministic unambiguous weak inherently-weak
--BODY--
State: 0
[1] 2

View file

@ -602,7 +602,7 @@ AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
properties: stutter-invariant inherently-weak
properties: stutter-invariant weak
--BODY--
State: 0
--END--

View file

@ -316,7 +316,7 @@ AP: 1 "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic inherently-weak
properties: deterministic weak
--BODY--
State: 0 {0}
[t] 0
@ -331,7 +331,7 @@ AP: 1 "p0"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
properties: deterministic inherently-weak
properties: deterministic weak
--BODY--
State: 0 {0}
[t] 0

View file

@ -67,8 +67,7 @@ Start: 2
AP: 1 "p1"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: implicit-labels state-acc complete deterministic
properties: inherently-weak
properties: implicit-labels state-acc complete deterministic weak
--BODY--
State: 0 {0}
0 0

View file

@ -755,7 +755,8 @@ namespace spot
struct bprop
{
bool state_based_acc:1; // State-based acceptance.
bool inherently_weak:1; // Weak automaton.
bool inherently_weak:1; // Inherently Weak automaton.
bool weak:1; // Weak automaton.
bool deterministic:1; // Deterministic automaton.
bool unambiguous:1; // Unambiguous automaton.
bool stutter_invariant:1; // Stutter invariant language.
@ -830,6 +831,19 @@ namespace spot
is.inherently_weak = val;
}
bool prop_weak() const
{
return is.weak;
}
void prop_weak(bool val)
{
if (val)
is.inherently_weak = is.weak = true;
else
is.weak = false;
}
bool prop_deterministic() const
{
return is.deterministic;
@ -882,9 +896,9 @@ namespace spot
struct prop_set
{
bool state_based;
bool inherently_weak;
bool deterministic;
bool stutter_inv;
bool inherently_weak; // and weak
bool deterministic; // and unambiguous
bool stutter_inv; // and stutter_sensitive
static prop_set all()
{
@ -899,7 +913,10 @@ namespace spot
if (p.state_based)
prop_state_acc(other->prop_state_acc());
if (p.inherently_weak)
prop_inherently_weak(other->prop_inherently_weak());
{
prop_weak(other->prop_weak());
prop_inherently_weak(other->prop_inherently_weak());
}
if (p.deterministic)
{
prop_deterministic(other->prop_deterministic());
@ -917,7 +934,10 @@ namespace spot
if (!p.state_based)
prop_state_acc(false);
if (!p.inherently_weak)
prop_inherently_weak(false);
{
prop_weak(false);
prop_inherently_weak(false);
}
if (!p.deterministic)
{
prop_deterministic(false);

View file

@ -425,7 +425,9 @@ namespace spot
prop(" stutter-invariant");
if (aut->prop_stutter_sensitive())
prop(" stutter-sensitive");
if (aut->prop_inherently_weak())
if (aut->prop_weak())
prop(" weak");
if (aut->prop_inherently_weak() && (verbose || !aut->prop_weak()))
prop(" inherently-weak");
os << nl;

View file

@ -482,7 +482,7 @@ namespace spot
auto res = minimize_dfa(det_a, final, non_final);
res->prop_copy(a, { false, false, false, true });
res->prop_deterministic(true);
res->prop_inherently_weak(true);
res->prop_weak(true);
res->prop_state_acc(true);
return res;
}
@ -583,7 +583,7 @@ namespace spot
auto res = minimize_dfa(det_a, final, non_final);
res->prop_copy(a, { false, false, false, true });
res->prop_deterministic(true);
res->prop_inherently_weak(true);
res->prop_weak(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->prop_inherently_weak() && aut_f->prop_deterministic())
if (aut_f->prop_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->prop_inherently_weak());
assert(min_aut_f->prop_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

View file

@ -335,7 +335,7 @@ namespace spot
res = make_twa_graph(aut->get_dict());
res->set_init_state(res->new_state());
res->prop_state_acc(true);
res->prop_inherently_weak(true);
res->prop_weak(true);
res->prop_deterministic(true);
res->prop_stutter_invariant(true);
return res;