dstarparse: Preliminary work on a parser for ltl2dstar.

Supports reading Rabin and Streett automata, and converting them to
nondeterministic Büchi automata (for Rabin) or TGBA (for Streett).

* src/dstarparse/Makefile.am, src/dstarparse/dstarparse.yy,
src/dstarparse/dstarscan.ll, src/dstarparse/fmterror.cc,
src/dstarparse/parsedecl.hh, src/dstarparse/public.hh,
src/dstarparse/nra2nba.cc, src/dstarparse/nsa2tgba.cc: New files.
* configure.ac, src/Makefile.am, README: Adjust.
* src/tgbatest/ltl2tgba.cc: Add options -XD, -XDB.
* src/tgbatest/dstar.test: New file.
* src/tgbatest/Makefile.am (TESTS): Add it.
This commit is contained in:
Alexandre Duret-Lutz 2013-07-24 19:16:18 +02:00
parent 5a3b1a9905
commit 2da0053c53
15 changed files with 1390 additions and 55 deletions

View file

@ -80,6 +80,7 @@ TESTS = \
renault.test \
nondet.test \
neverclaimread.test \
dstar.test \
readsave.test \
simdet.test \
sim.test \

131
src/tgbatest/dstar.test Executable file
View file

@ -0,0 +1,131 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2013 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/>.
# Do some quick translations to make sure the neverclaims produced by
# spot actually look correct! We do that by parsing them via ltlcross.
# ltl2neverclaim-lbtt.test does the same with LBTT if it is installed.
. ./defs
set -e
cat >dra.dstar <<EOF
DRA v2 explicit
Comment: "Safra[NBA=2]"
States: 3
Acceptance-Pairs: 1
Start: 0
AP: 2 "a" "b"
---
State: 0
Acc-Sig:
1
0
2
2
State: 1
Acc-Sig: -0
1
1
1
1
State: 2
Acc-Sig: +0
2
2
2
2
EOF
run 0 ../ltl2tgba -XD dra.dstar | tee stdout
cat >expected <<EOF
digraph G {
0 [label="", style=invis, height=0]
0 -> 1
1 [label="0"]
1 -> 1 [label="a & !b\n"]
1 -> 2 [label="!a & !b\n"]
1 -> 3 [label="b\n"]
2 [label="1"]
2 -> 2 [label="1\n"]
3 [label="2"]
3 -> 3 [label="1\n"]
}
EOF
diff expected stdout
cat >dsa.dstar <<EOF
DSA v2 explicit
Comment: "Streett{Safra[NBA=2]}"
States: 3
Acceptance-Pairs: 1
Start: 1
AP: 1 "a"
---
State: 0
Acc-Sig: +0
0
2
State: 1
Acc-Sig:
0
0
State: 2
Acc-Sig:
0
2
EOF
run 0 ../ltl2tgba -XDB dsa.dstar | tee stdout
cat >expected <<EOF
digraph G {
0 [label="", style=invis, height=0]
0 -> 1
1 [label="0"]
1 -> 2 [label="1\n"]
1 -> 3 [label="1\n"]
2 [label="1"]
2 -> 2 [label="!a\n"]
2 -> 3 [label="!a\n"]
2 -> 4 [label="a\n"]
2 -> 5 [label="a\n"]
3 [label="2"]
3 -> 6 [label="!a\n"]
3 -> 5 [label="a\n{Acc[\"0\"]}"]
4 [label="3"]
4 -> 2 [label="!a\n"]
4 -> 3 [label="!a\n"]
4 -> 4 [label="a\n"]
4 -> 5 [label="a\n"]
5 [label="4"]
5 -> 6 [label="!a\n"]
5 -> 5 [label="a\n{Acc[\"0\"]}"]
6 [label="5"]
6 -> 6 [label="!a\n"]
6 -> 7 [label="a\n"]
7 [label="6"]
7 -> 6 [label="!a\n"]
7 -> 7 [label="a\n"]
}
EOF
diff expected stdout

View file

@ -45,6 +45,7 @@
#include "tgbaalgos/reducerun.hh"
#include "tgbaparse/public.hh"
#include "neverparse/public.hh"
#include "dstarparse/public.hh"
#include "tgbaalgos/dupexp.hh"
#include "tgbaalgos/minimize.hh"
#include "taalgos/minimize.hh"
@ -119,6 +120,10 @@ syntax(char* prog)
<< std::endl
<< " -X do not compute an automaton, read it from a file"
<< std::endl
<< " -XD do not compute an automaton, read it from an"
<< " ltl2dstar file" << std::endl
<< " -XDB read the from an ltl2dstar file and convert it to "
<< "TGBA" << std::endl
<< " -XL do not compute an automaton, read it from an"
<< " LBTT file" << std::endl
<< " -XN do not compute an automaton, read it from a"
@ -361,8 +366,8 @@ main(int argc, char** argv)
bool accepting_run = false;
bool accepting_run_replay = false;
bool from_file = false;
bool read_neverclaim = false;
bool read_lbtt = false;
enum { ReadSpot, ReadLbtt, ReadNeverclaim, ReadDstar } readformat = ReadSpot;
bool nra2nba = false;
bool scc_filter = false;
bool simpltl = false;
spot::ltl::ltl_simplifier_options redopt(false, false, false, false,
@ -899,16 +904,28 @@ main(int argc, char** argv)
else if (!strcmp(argv[formula_index], "-X"))
{
from_file = true;
readformat = ReadSpot;
}
else if (!strcmp(argv[formula_index], "-XN"))
else if (!strcmp(argv[formula_index], "-XD"))
{
from_file = true;
read_neverclaim = true;
readformat = ReadDstar;
}
else if (!strcmp(argv[formula_index], "-XDB"))
{
from_file = true;
readformat = ReadDstar;
nra2nba = true;
}
else if (!strcmp(argv[formula_index], "-XL"))
{
from_file = true;
read_lbtt = true;
readformat = ReadLbtt;
}
else if (!strcmp(argv[formula_index], "-XN"))
{
from_file = true;
readformat = ReadNeverclaim;
}
else if (!strcmp(argv[formula_index], "-y"))
{
@ -1018,59 +1035,102 @@ main(int argc, char** argv)
if (from_file)
{
spot::tgba_explicit_string* e = 0;
if (!read_neverclaim && !read_lbtt)
switch (readformat)
{
spot::tgba_parse_error_list pel;
tm.start("parsing automaton");
to_free = a = e = spot::tgba_parse(input, pel, dict,
env, env, debug_opt);
tm.stop("parsing automaton");
if (spot::format_tgba_parse_errors(std::cerr, input, pel))
case ReadSpot:
{
delete to_free;
delete dict;
return 2;
}
}
else if (read_neverclaim)
{
spot::neverclaim_parse_error_list pel;
tm.start("parsing neverclaim");
to_free = a = e = spot::neverclaim_parse(input, pel, dict,
env, debug_opt);
tm.stop("parsing neverclaim");
if (spot::format_neverclaim_parse_errors(std::cerr, input, pel))
{
delete to_free;
delete dict;
return 2;
}
assume_sba = true;
}
else
{
std::string error;
std::fstream f(input.c_str());
if (!f)
{
std::cerr << "cannot open " << input << std::endl;
delete dict;
return 2;
}
tm.start("parsing lbtt");
to_free = a =
const_cast<spot::tgba*>(spot::lbtt_parse(f, error, dict,
env, env));
tm.stop("parsing lbtt");
if (!to_free)
{
std::cerr << error << std::endl;
delete dict;
return 2;
spot::tgba_parse_error_list pel;
tm.start("parsing automaton");
to_free = a = e = spot::tgba_parse(input, pel, dict,
env, env, debug_opt);
tm.stop("parsing automaton");
if (spot::format_tgba_parse_errors(std::cerr, input, pel))
{
delete to_free;
delete dict;
return 2;
}
}
break;
case ReadNeverclaim:
{
spot::neverclaim_parse_error_list pel;
tm.start("parsing neverclaim");
to_free = a = e = spot::neverclaim_parse(input, pel, dict,
env, debug_opt);
tm.stop("parsing neverclaim");
if (spot::format_neverclaim_parse_errors(std::cerr, input, pel))
{
delete to_free;
delete dict;
return 2;
}
assume_sba = true;
}
break;
case ReadLbtt:
{
std::string error;
std::fstream f(input.c_str());
if (!f)
{
std::cerr << "cannot open " << input << std::endl;
delete dict;
return 2;
}
tm.start("parsing lbtt");
to_free = a =
const_cast<spot::tgba*>(spot::lbtt_parse(f, error, dict,
env, env));
tm.stop("parsing lbtt");
if (!to_free)
{
std::cerr << error << std::endl;
delete dict;
return 2;
}
}
break;
case ReadDstar:
{
spot::dstar_parse_error_list pel;
tm.start("parsing dstar");
spot::dstar_aut* daut;
daut = spot::dstar_parse(input, pel, dict,
env, debug_opt);
if (nra2nba)
{
if (daut->type == spot::Rabin)
{
to_free = a = spot::nra_to_nba(daut);
assume_sba = true;
}
else
{
to_free = a = spot::nsa_to_tgba(daut);
assume_sba = false;
}
}
else
{
to_free = a = daut->aut;
daut->aut = 0;
assume_sba = false;
}
delete daut;
tm.stop("parsing dstar");
if (spot::format_dstar_parse_errors(std::cerr, input, pel))
{
delete to_free;
delete dict;
return 2;
}
}
break;
}
if (e)
e->merge_transitions();
}
else
{