relabel: implement relabeling of Boolean subexpressions.
* src/ltlast/multop.cc, src/ltlast/multop.hh (multop::boolean_operands, multop::boolean_count): New methods. * src/ltlvisit/relabel.cc, src/ltlvisit/relabel.hh (relabel): Take an optional relabeling_map as parameter. (relabel_bse): New. * src/ltltest/ltlrel.test, src/ltltest/ltlrel.cc: New files. * src/ltltest/Makefile.am: Add them. * src/bin/ltlfilt.cc: Add option --relabel-bool. * src/ltltest/ltlfilt.test: Test it. * NEWS: Mention it. * doc/org/ltlfilt.org: Illustrate it.
This commit is contained in:
parent
2efe52fab0
commit
87b65b9bce
11 changed files with 869 additions and 74 deletions
|
|
@ -32,6 +32,7 @@ check_PROGRAMS = \
|
|||
length \
|
||||
ltl2dot \
|
||||
ltl2text \
|
||||
ltlrel \
|
||||
lunabbrev \
|
||||
nenoform \
|
||||
reduc \
|
||||
|
|
@ -52,6 +53,7 @@ length_SOURCES = length.cc
|
|||
ltl2dot_SOURCES = readltl.cc
|
||||
ltl2dot_CPPFLAGS = $(AM_CPPFLAGS) -DDOTTY
|
||||
ltl2text_SOURCES = readltl.cc
|
||||
ltlrel_SOURCES = ltlrel.cc
|
||||
lunabbrev_SOURCES = equals.cc
|
||||
lunabbrev_CPPFLAGS = $(AM_CPPFLAGS) -DLUNABBREV
|
||||
nenoform_SOURCES = equals.cc
|
||||
|
|
@ -94,6 +96,7 @@ TESTS = \
|
|||
consterm.test \
|
||||
kind.test \
|
||||
remove_x.test \
|
||||
ltlrel.test \
|
||||
ltlfilt.test \
|
||||
latex.test \
|
||||
lbt.test \
|
||||
|
|
|
|||
|
|
@ -139,3 +139,23 @@ GFa | FGb
|
|||
F(GFa | Gb)
|
||||
F(b W GFa)
|
||||
EOF
|
||||
|
||||
|
||||
cat >in <<EOF
|
||||
a & Xb & c
|
||||
a & b & GF(a | c) & FG(a | c)
|
||||
b & GF(a | c) & FG(a | c)
|
||||
G(d & e) | FG(Xf| !c) | h | i
|
||||
b & !Xc & e & (f | g)
|
||||
b & GF(a | c) & !GF!(a | c)
|
||||
EOF
|
||||
|
||||
cat >exp <<EOF
|
||||
p0 & Xp1
|
||||
p0 & p1 & GF(p0 | p2) & FG(p0 | p2)
|
||||
p0 & GFp1 & FGp1
|
||||
p0 | Gp1 | FG(p2 | Xp3)
|
||||
EOF
|
||||
|
||||
run 0 ../../bin/ltlfilt -u --nnf --relabel-bool=pnn in >out
|
||||
diff exp out
|
||||
|
|
|
|||
77
src/ltltest/ltlrel.cc
Normal file
77
src/ltltest/ltlrel.cc
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2013 Laboratoire de Recherche et Developement 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/>.
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include "ltlparse/public.hh"
|
||||
#include "ltlvisit/relabel.hh"
|
||||
#include "ltlast/allnodes.hh"
|
||||
#include "ltlvisit/tostring.hh"
|
||||
|
||||
void
|
||||
syntax(char *prog)
|
||||
{
|
||||
std::cerr << prog << " formula" << std::endl;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
syntax(argv[0]);
|
||||
|
||||
spot::ltl::parse_error_list p1;
|
||||
const spot::ltl::formula* f1 = spot::ltl::parse(argv[1], p1);
|
||||
|
||||
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
|
||||
return 2;
|
||||
|
||||
spot::ltl::relabeling_map* m = new spot::ltl::relabeling_map;
|
||||
const spot::ltl::formula* f2 = spot::ltl::relabel_bse(f1, spot::ltl::Pnn, m);
|
||||
f1->destroy();
|
||||
spot::ltl::to_string(f2, std::cout) << "\n";
|
||||
|
||||
|
||||
typedef std::map<std::string, std::string> map_t;
|
||||
map_t sorted_map;
|
||||
for (spot::ltl::relabeling_map::const_iterator i = m->begin();
|
||||
i != m->end(); ++i)
|
||||
sorted_map[spot::ltl::to_string(i->first)] =
|
||||
spot::ltl::to_string(i->second);
|
||||
for (map_t::const_iterator i = sorted_map.begin();
|
||||
i != sorted_map.end(); ++i)
|
||||
std::cout << " " << i->first << " -> "
|
||||
<< i->second << "\n";
|
||||
f2->destroy();
|
||||
delete m;
|
||||
|
||||
spot::ltl::atomic_prop::dump_instances(std::cerr);
|
||||
spot::ltl::unop::dump_instances(std::cerr);
|
||||
spot::ltl::binop::dump_instances(std::cerr);
|
||||
spot::ltl::multop::dump_instances(std::cerr);
|
||||
spot::ltl::automatop::dump_instances(std::cerr);
|
||||
assert(spot::ltl::atomic_prop::instance_count() == 0);
|
||||
assert(spot::ltl::unop::instance_count() == 0);
|
||||
assert(spot::ltl::binop::instance_count() == 0);
|
||||
assert(spot::ltl::multop::instance_count() == 0);
|
||||
assert(spot::ltl::automatop::instance_count() == 0);
|
||||
return 0;
|
||||
}
|
||||
79
src/ltltest/ltlrel.test
Executable file
79
src/ltltest/ltlrel.test
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#! /bin/sh
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2013 Laboratoire de Recherche et Dévelopement to
|
||||
# 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/>.
|
||||
|
||||
|
||||
# Check for the constant_term visitor
|
||||
|
||||
. ./defs || exit 1
|
||||
|
||||
set -e
|
||||
|
||||
t()
|
||||
{
|
||||
cat > tmp.$$
|
||||
run 0 ../ltlrel "`head -n 1 tmp.$$`" > out.$$
|
||||
sed 1d tmp.$$ > exp.$$
|
||||
diff out.$$ exp.$$
|
||||
}
|
||||
|
||||
t <<EOF
|
||||
a & Xb & c
|
||||
p0 & Xp1
|
||||
p0 -> a & c
|
||||
p1 -> b
|
||||
EOF
|
||||
|
||||
t <<EOF
|
||||
a & b & GF(a | c) & FG(a | c)
|
||||
p0 & p1 & GF(p0 | p2) & FG(p0 | p2)
|
||||
p0 -> a
|
||||
p1 -> b
|
||||
p2 -> c
|
||||
EOF
|
||||
|
||||
t <<EOF
|
||||
b & GF(a | c) & FG(a | c)
|
||||
p0 & GFp1 & FGp1
|
||||
p0 -> b
|
||||
p1 -> a | c
|
||||
EOF
|
||||
|
||||
t <<EOF
|
||||
G(d & e) | FG(Xf| !c) | h | i
|
||||
p0 | Gp1 | FG(p2 | Xp3)
|
||||
p0 -> h | i
|
||||
p1 -> d & e
|
||||
p2 -> !c
|
||||
p3 -> f
|
||||
EOF
|
||||
|
||||
t <<EOF
|
||||
a <-> b
|
||||
p0
|
||||
p0 -> a <-> b
|
||||
EOF
|
||||
|
||||
t <<EOF
|
||||
(a <-> b) & X(b -> c)
|
||||
(p0 <-> p1) & X(p1 -> p2)
|
||||
p0 -> a
|
||||
p1 -> b
|
||||
p2 -> c
|
||||
EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue