Commit 0ec5ebac authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

autcross: support %M in tool specifications

Fixes #335.

* bin/common_trans.cc: Add support.
* tests/core/autcross4.test: New file.
* tests/Makefile.am: Add it.
* doc/org/autcross.org, NEWS: Document it.
parent 028b56d5
New in spot 2.5.1.dev (not yet released)
Command-line tools:
- autcross' tool specifications now have %M replaced by the name of
the input automaton.
Library:
- Option "a" of print_dot(), for printing the acceptance condition,
......
// -*- coding: utf-8 -*-
// Copyright (C) 2015, 2016, 2017 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2015-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
......@@ -312,6 +312,7 @@ filed_automaton::print(std::ostream& os, const char* pos) const
{
std::ostringstream ss;
char* opt = nullptr;
bool filename = true;
if (*pos == '[')
{
++pos;
......@@ -330,9 +331,19 @@ filed_automaton::print(std::ostream& os, const char* pos) const
case 'L':
spot::print_lbtt(ss, aut_, opt);
break;
case 'M':
{
filename = false;
std::string* name = aut_->get_named_prop<std::string>("automaton-name");
spot::quote_shell_string(os,
name ? name->c_str() :
opt ? opt :
"");
}
}
if (opt)
free(opt);
if (filename)
os << '\'' << string_to_tmp(ss.str(), serial_) << '\'';
}
......@@ -409,6 +420,7 @@ autproc_runner::autproc_runner(bool no_output_allowed)
declare('H', &filename_automaton);
declare('S', &filename_automaton);
declare('L', &filename_automaton);
declare('M', &filename_automaton);
declare('O', &output);
size_t s = tools.size();
......@@ -420,9 +432,10 @@ autproc_runner::autproc_runner(bool no_output_allowed)
std::vector<bool> has(256);
const tool_spec& t = tools[n];
scan(t.cmd, has);
if (!(has['H'] || has['S'] || has['L']))
if (!(has['H'] || has['S'] || has['L'] || has['M']))
error(2, 0, "no input %%-sequence in '%s'.\n Use "
"one of %%H,%%S,%%L to indicate the input automaton filename.",
"one of %%H,%%S,%%L to indicate the input automaton filename.\n"
" (Or use %%M if you want to work from its name.)\n",
t.spec);
if (!no_output_allowed && !has['O'])
error(2, 0, "no output %%-sequence in '%s'.\n Use "
......@@ -831,6 +844,8 @@ static const argp_option options_aut[] =
{ "%H,%S,%L", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"filename for the input automaton in (H) HOA, (S) Spin's neverclaim, "
"or (L) LBTT's format", 0 },
{ "%M, %[val]M", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"the name of the input automaton, with an optional default value", 0 },
{ "%O", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"filename for the automaton output in HOA, never claim, LBTT, or "
"ltl2dstar's format", 0 },
......
......@@ -40,6 +40,8 @@ following character sequences:
: %% a single %
: %H,%S,%L filename for the input automaton in (H) HOA, (S)
: Spin's neverclaim, or (L) LBTT's format
: %M, %[val]M the name of the input automaton, with an optional
: default value
: %O filename for the automaton output in HOA, never
: claim, LBTT, or ltl2dstar's format
......@@ -123,7 +125,7 @@ will be changed into
What this implies is our previous example could be shortened to:
#+BEGIN_SRC sh :results verbatim :exports code
#+BEGIN_SRC sh :results silent :exports code
randaut -B -n 3 a b |
autcross 'autfilt --complement' 'ltl2dstar --complement-input=yes'
#+END_SRC
......@@ -386,3 +388,91 @@ No problem detected.
# LocalWords: ok complementation Ai Aj gRqrd ubUpHb JxFi oQGbj SQT
# LocalWords: kWt Eo Xsc WXgCB vLwKMQ tI SXF qqlE KXplk ZFTCz PNY
# LocalWords: hUAK IjnFhD cWys ZqjdQh
* Use-cases for =%M=
If the input automata are named, it is possible to use =%M= in some
tool specification to pass this name to the tool. In particular, this
can be used to replace the input automaton by something else.
For instance if the name of the automaton is an actual LTL formula
(automata produced by [[file:ltl2tgba.org][=ltl2tgba=]] follow this convention), you can
cross-compare some tool that input that formula instead of the
automaton. For instance consider the following command-line, where we
compare the determinization of =autfilt -D= (starting from an
automaton) to the determinization of =ltl2dstar= (starting from the
LTL formula encoded in the name of the automaton). That LTL formula
is not in a syntax supported by =ltl2dstar=, so we call =ltl2dstar=
via [[file:ltldo.org][=ltldo=]] to arrange that.
#+BEGIN_SRC sh :results silent :export code
genltl --eh-patterns=1..3 | ltl2tgba |
autcross 'autfilt -P -D' 'ltldo ltl2dstar -f %M >%O'
#+END_SRC
#+BEGIN_SRC sh :results verbatim :export results
genltl --eh-patterns=1..3 | ltl2tgba |
autcross 'autfilt -P -D' 'ltldo ltl2dstar -f %M >%O' 2>&1
#+END_SRC
#+RESULTS:
#+begin_example
-:1.1-16.7 p0 U (p1 & Gp2)
Running [A0]: autfilt -P -D 'lcr-i0-rBSCo9'>'lcr-o0-xyRJhy'
Running [A1]: ltldo ltl2dstar -f 'p0 U (p1 & Gp2)' >'lcr-o1-9uDUjX'
Performing sanity checks and gathering statistics...
-:17.1-34.7 p0 U (p1 & X(p2 U p3))
Running [A0]: autfilt -P -D 'lcr-i1-LFDrvm'>'lcr-o0-6fBZGL'
Running [A1]: ltldo ltl2dstar -f 'p0 U (p1 & X(p2 U p3))' >'lcr-o1-AUXx0a'
Performing sanity checks and gathering statistics...
-:35.1-64.7 p0 U (p1 & X(p2 & F(p3 & XF(p4 & XF(p5 & XFp6)))))
Running [A0]: autfilt -P -D 'lcr-i2-UaZCtA'>'lcr-o0-hhbJWZ'
Running [A1]: ltldo ltl2dstar -f 'p0 U (p1 & X(p2 & F(p3 & XF(p4 & XF(p5 & XFp6)))))' >'lcr-o1-xhS4Ap'
Performing sanity checks and gathering statistics...
No problem detected.
#+end_example
This example is a bit contrived, and in this case, an alternative would
be to use [[file:ltlcross.org][=ltlcross=]], as in:
#+BEGIN_SRC sh :results silent :export code
genltl --eh-patterns=1..3 |
ltlcross 'ltl2tgba %f | autfilt -P -D > %O' 'ltl2dstar'
#+END_SRC
#+BEGIN_SRC sh :results verbatim :export results
genltl --eh-patterns=1..3 |
ltlcross 'ltl2tgba %f | autfilt -P -D > %O' 'ltl2dstar' 2>&1
#+END_SRC
#+RESULTS:
#+begin_example
-:1: (p0) U ((p1) & (G(p2)))
Running [P0]: ltl2tgba '(p0) U ((p1) & (G(p2)))' | autfilt -P -D > 'lcr-o0-DnV1rm'
Running [P1]: ltl2dstar --output-format=hoa 'lcr-i0-jBLulv' 'lcr-o1-epwYeE'
Running [N0]: ltl2tgba '!((p0) U ((p1) & (G(p2))))' | autfilt -P -D > 'lcr-o0-8bVQ9M'
Running [N1]: ltl2dstar --output-format=hoa 'lcr-i0-5oAAdW' 'lcr-o1-W7elh5'
Performing sanity checks and gathering statistics...
-:2: (p0) U ((p1) & (X((p2) U (p3))))
Running [P0]: ltl2tgba '(p0) U ((p1) & (X((p2) U (p3))))' | autfilt -P -D > 'lcr-o0-xMdCve'
Running [P1]: ltl2dstar --output-format=hoa 'lcr-i1-OJU1Sn' 'lcr-o1-wOCsgx'
Running [N0]: ltl2tgba '!((p0) U ((p1) & (X((p2) U (p3)))))' | autfilt -P -D > 'lcr-o0-SzgmFG'
Running [N1]: ltl2dstar --output-format=hoa 'lcr-i1-8iIddQ' 'lcr-o1-zBV5KZ'
Performing sanity checks and gathering statistics...
-:3: (p0) U ((p1) & (X((p2) & (F((p3) & (X(F((p4) & (X(F((p5) & (X(F(p6))))))))))))))
Running [P0]: ltl2tgba '(p0) U ((p1) & (X((p2) & (F((p3) & (X(F((p4) & (X(F((p5) & (X(F(p6))))))))))))))' | autfilt -P -D > 'lcr-o0-FEA6s9'
Running [P1]: ltl2dstar --output-format=hoa 'lcr-i2-E0Ikpj' 'lcr-o1-ppDzlt'
Running [N0]: ltl2tgba '!((p0) U ((p1) & (X((p2) & (F((p3) & (X(F((p4) & (X(F((p5) & (X(F(p6)))))))))))))))' | autfilt -P -D > 'lcr-o0-jqlelD'
Running [N1]: ltl2dstar --output-format=hoa 'lcr-i2-IwU1uN' 'lcr-o1-6YdQEX'
Performing sanity checks and gathering statistics...
No problem detected.
#+end_example
However in practice you could also use the =name:= field of the input
automaton, combined with =%M= in the tool specification, to designate
an alternate filename to load, or some key to look up somewhere.
......@@ -305,6 +305,7 @@ TESTS_twa = \
core/autcross.test \
core/autcross2.test \
core/autcross3.test \
core/autcross4.test \
core/complementation.test \
core/randpsl.test \
core/cycles.test \
......
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test the timeout handling of autcross.
. ./defs
set -e
ltl2tgba -f FGa '"a = b"U!c' |
autcross 'autfilt' 'ltl2tgba -B %M >%O' --csv=out.csv
test 2 = `grep -c '"FGa"' out.csv`
test 2 = `grep -c '"""a = b"" U !c"' out.csv`
cat >in <<EOF
HOA: v1
name: "yes"
States: 1
Start: 0
AP: 0
Acceptance: 0 t
--BODY--
State: 0
--END--
HOA: v1
States: 1
Start: 0
AP: 0
Acceptance: 0 t
--BODY--
State: 0
--END--
EOF
autcross -Fin 'ltl2tgba %[no]M>%O' 'ltl2tgba %M>%O' --csv=out.csv && exit 1
test 3 = `grep -c '"ok"' out.csv`
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