* src/ltlvisit/nenoform.hh, src/ltlvisit/nenoform.cc: New files.

* src/ltlvisit/Makefile.am (libltlvisit_a_SOURCES): Add them.
* src/ltltest/equals.cc (main) [NENOFORM]: Call negative_normal_form.
* src/ltltest/nenoform.test, src/ltltest/tunenoform.test: New files.
* src/ltltest/Makefile.am (check_PROGRAMS): Add nenoform and
tunenoform.
(nenoform_SOURCES, nenoform_CPPFLAGS, tunenoform_SOURCES,
tunenoform_CPPFLAGS): New variables.
(TESTS): Add nenoform.test and tunenoform.test.
This commit is contained in:
Alexandre Duret-Lutz 2003-04-17 13:12:11 +00:00
parent e58aae95c0
commit 0c7a2412a4
9 changed files with 308 additions and 2 deletions

View file

@ -10,3 +10,5 @@ defs
equals
lunabbrev
tunabbrev
nenoform
tunenoform

View file

@ -4,7 +4,17 @@ LDADD = ../ltlparse/libltlparse.a \
../ltlast/libltlast.a
check_SCRIPTS = defs
check_PROGRAMS = ltl2dot ltl2text equals lunabbrev tunabbrev
# Keep this sorted alphabetically.
check_PROGRAMS = \
equals \
ltl2dot \
ltl2text \
lunabbrev \
nenoform \
tunabbrev \
tunenoform
ltl2dot_SOURCES = readltl.cc
ltl2dot_CPPFLAGS = $(AM_CPPFLAGS) -DDOTTY
ltl2text_SOURCES = readltl.cc
@ -13,8 +23,21 @@ lunabbrev_SOURCES = equals.cc
lunabbrev_CPPFLAGS = $(AM_CPPFLAGS) -DLUNABBREV
tunabbrev_SOURCES = equals.cc
tunabbrev_CPPFLAGS = $(AM_CPPFLAGS) -DTUNABBREV
nenoform_SOURCES = equals.cc
nenoform_CPPFLAGS = $(AM_CPPFLAGS) -DNENOFORM
tunenoform_SOURCES = equals.cc
tunenoform_CPPFLAGS = $(AM_CPPFLAGS) -DNENOFORM -DTUNABBREV
EXTRA_DIST = $(TESTS)
TESTS = parse.test parseerr.test equals.test lunabbrev.test tunabbrev.test
# Ordered by strength of the test. Test basic features first.
TESTS = \
parse.test \
parseerr.test \
equals.test \
lunabbrev.test \
tunabbrev.test \
nenoform.test \
tunenoform.test
CLEANFILES = stdout expect parse.dot

View file

@ -4,6 +4,7 @@
#include "ltlvisit/lunabbrev.hh"
#include "ltlvisit/tunabbrev.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/nenoform.hh"
void
syntax(char *prog)
@ -34,10 +35,17 @@ main(int argc, char **argv)
#ifdef LUNABBREV
f1 = spot::ltl::unabbreviate_logic(f1);
spot::ltl::dump(*f1, std::cout);
std::cout << std::endl;
#endif
#ifdef TUNABBREV
f1 = spot::ltl::unabbreviate_ltl(f1);
spot::ltl::dump(*f1, std::cout);
std::cout << std::endl;
#endif
#ifdef NENOFORM
f1 = spot::ltl::negative_normal_form(f1);
spot::ltl::dump(*f1, std::cout);
std::cout << std::endl;
#endif
if (equals(f1, f2))

49
src/ltltest/nenoform.test Executable file
View file

@ -0,0 +1,49 @@
#! /bin/sh
# Check for the negative_normal_form visitor
. ./defs || exit 1
check()
{
./nenoform "$1" "$2" || exit 1
}
# A few things that do not change
check 'a' 'a'
check '1' '1'
check '0' '0'
check '!a' '!a'
check 'a U b' 'a U b'
check 'a & b' 'a & b'
check 'a & b' 'b & a'
check 'a & !b & c' 'c & a & !b'
check 'a & b & c' 'b & c & a'
check 'Xa & b & Xa' 'b & Xa & b'
check 'a & b' 'b & a & b'
check 'a & !b' '!b & a & a'
check 'a & b & (Xc |(f U !g)| e)' 'b & a & a & (Xc | e |(f U !g)| e | Xc) & b'
check 'GFa => FGb' 'GFa => FGb'
# Basic rewritings
check '!!a' 'a'
check '!!!!!a' '!a'
check '!Xa' 'X!a'
check '!Fa' 'G!a'
check '!Ga' 'F!a'
check '!(a ^ b)' 'a <=> b'
check '!(a <=> b)' '(((a) ^ (b)))'
check '!(a => b)' 'a&!b'
check '!(!a => !b)' '!a&b'
check '!(a U b)' '!a R !b'
check '!(a R b)' '!a U !b'
check '!(!a R !b)' 'a U b'
check '!(a & b & c & d & b)' '!a | !b | !c | !d'
check '!(a | b | c | d)' '!a & !b & !c & !d'
# Nested rewritings
check '!(a U (!b U ((a & b & c) R d)))' '!a R (b R ((!a | !b | !c) U !d))'
check '!(GF a => FG b)' 'GFa & GF!b'
# Success.
:

21
src/ltltest/tunenoform.test Executable file
View file

@ -0,0 +1,21 @@
#! /bin/sh
# Check for unabbreviate_ltl + negative_normal_form visitors
. ./defs || exit 1
check()
{
./tunenoform "$1" "$2" || exit 1
}
check '!(a ^ b)' '(a|!b) & (!a|b)'
check '!(a <=> b)' '(a|b) & (!a|!b)'
check '!(a => b)' 'a&!b'
check '!(!a => !b)' '!a&b'
check '!Fa' 'false R !a'
check '!G!a' 'true U a'
check '!(GF a => FG b)' '(0 R (1 U a)) & (0 R (1 U !b))'
# Success.
: