From 7144efabb927f2c1fbee02c1378672ef5fe8c1e8 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 20 Apr 2016 15:19:14 +0200 Subject: [PATCH] hoa: add option to output version 1.1 * spot/twaalgos/hoa.cc: Implement the option. * bin/common_aoutput.cc, doc/org/hoa.org, doc/org/oaut.org, spot/twaalgos/hoa.hh, NEWS: Document it. * tests/core/strength.test: Test that. --- NEWS | 9 + bin/common_aoutput.cc | 3 +- doc/org/hoa.org | 18 ++ doc/org/oaut.org | 47 +++++ spot/twaalgos/hoa.cc | 40 ++++- spot/twaalgos/hoa.hh | 3 +- tests/core/strength.test | 369 ++++++++++++++++++++++++++++++++++++++- 7 files changed, 484 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 525dac33c..fd86eb0e3 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,14 @@ New in spot 2.0a (not yet released) + Library: + + * The print_hoa() function will now output version 1.1 of the HOA + format when passed the "1.1" option (i.e., use -H1.1 from any + command-line tool). As far as Spot is concerned, this allows + negated properties to be expressed. Version 1 of the HOA format + is still the default, but we plan to default to version 1.1 in the + future. + Bug fixes: * Typo in documentation of the -H option in --help output. diff --git a/bin/common_aoutput.cc b/bin/common_aoutput.cc index a966c40bf..285234b45 100644 --- a/bin/common_aoutput.cc +++ b/bin/common_aoutput.cc @@ -101,8 +101,9 @@ static const argp_option options[] = "(+INT) add INT to all set numbers, " "(num_states(); const char nl = newline ? '\n' : ' '; - os << "HOA: v1" << nl; + os << (v1_1 ? "HOA: v1.1" : "HOA: v1") << nl; auto n = aut->get_named_prop("automaton-name"); if (n) escape_str(os << "name: \"", *n) << '"' << nl; @@ -423,10 +440,16 @@ namespace spot prop(" trans-acc"); if (md.is_colored) prop(" colored"); + else if (verbose && v1_1) + prop(" !colored"); if (md.is_complete) prop(" complete"); + else if (v1_1) + prop(" !complete"); if (md.is_deterministic) prop(" deterministic"); + else if (v1_1) + prop(" !deterministic"); // Deterministic automata are also unambiguous, so writing both // properties seems redundant. People working on unambiguous // automata are usually concerned about non-deterministic @@ -434,16 +457,29 @@ namespace spot // in the case of deterministic automata. if (aut->prop_unambiguous() && (verbose || !md.is_deterministic)) prop(" unambiguous"); + else if (v1_1 && !aut->prop_unambiguous()) + prop(" !unambiguous"); if (aut->prop_stutter_invariant()) prop(" stutter-invariant"); if (!aut->prop_stutter_invariant()) - prop(" stutter-sensitive"); + { + if (v1_1) + prop(" !stutter-invariant"); + else + prop(" stutter-sensitive"); + } if (aut->prop_terminal()) prop(" terminal"); if (aut->prop_weak() && (verbose || aut->prop_terminal() != true)) prop(" weak"); if (aut->prop_inherently_weak() && (verbose || aut->prop_weak() != true)) prop(" inherently-weak"); + if (v1_1 && !aut->prop_terminal() && (aut->prop_weak() || verbose)) + prop(" !terminal"); + if (v1_1 && !aut->prop_weak() && (aut->prop_inherently_weak() || verbose)) + prop(" !weak"); + if (v1_1 && !aut->prop_inherently_weak()) + prop(" !inherently-weak"); os << nl; // If we want to output implicit labels, we have to diff --git a/spot/twaalgos/hoa.hh b/spot/twaalgos/hoa.hh index b5acff88f..5f9258555 100644 --- a/spot/twaalgos/hoa.hh +++ b/spot/twaalgos/hoa.hh @@ -35,7 +35,8 @@ namespace spot /// deterministic automata, (k) state labels when possible, /// (s) state-based acceptance when possible, (t) /// transition-based acceptance, (m) mixed acceptance, (l) - /// single-line output, (v) verbose properties. + /// single-line output, (v) verbose properties, (1.1) use + /// version 1.1 of the HOA format. SPOT_API std::ostream& print_hoa(std::ostream& os, const const_twa_ptr& g, diff --git a/tests/core/strength.test b/tests/core/strength.test index f9fe38811..50c0efe2a 100755 --- a/tests/core/strength.test +++ b/tests/core/strength.test @@ -588,4 +588,371 @@ State: 4 EOF diff out expected -autfilt -q expected + +# Test HOA v1.1 +autfilt expected -H1.1 --check > out2 + +cat >expected2 < out3 +diff out3 expected2