Add trivial identity {b}=b and !{b}=!b for any Boolean formula b.

* src/ltlast/unop.cc: Perform the simplification.
* src/ltlast/unop.hh, doc/tl/tl.tex: Document it.
* src/ltltest/equals.test: Adjust test cases.
This commit is contained in:
Alexandre Duret-Lutz 2011-11-07 11:30:27 +01:00
parent 98f67973eb
commit 77d704ea9e
4 changed files with 28 additions and 18 deletions

View file

@ -295,19 +295,25 @@ namespace spot
break;
case Closure:
if (child == constant::true_instance()
|| child == constant::empty_word_instance())
return constant::true_instance();
if (child == constant::false_instance())
// {0} = 0, {1} = 1, {b} = b
if (child->is_boolean())
return child;
// {[*0]} = 1
if (child == constant::empty_word_instance())
return constant::true_instance();
break;
case NegClosure:
// {1} = 0, {[*0]} = 0
if (child == constant::true_instance()
|| child == constant::empty_word_instance())
return constant::false_instance();
// {0} = 1
if (child == constant::false_instance())
return constant::true_instance();
// {b} = !b
if (child->is_boolean())
return unop::instance(Not, child);
break;
}

View file

@ -1,4 +1,4 @@
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
@ -73,9 +73,11 @@ namespace spot
/// - Closure([*0]) = 1
/// - Closure(1) = 1
/// - Closure(0) = 0
/// - Closure(b) = b
/// - NegClosure([*0]) = 0
/// - NegClosure(1) = 0
/// - NegClosure(0) = 1
/// - NegClosure(b) = !b
///
/// This rewriting implies that it is not possible to build an
/// LTL formula object that is SYNTACTICALLY equal to one of

View file

@ -179,9 +179,9 @@ run 0 ../equals '{b[=0to$]}' '{*}'
run 0 ../equals '{0[->10..100];b}' '0'
run 0 ../equals '{0[->1..];b}' '0'
run 0 ../equals '{0[->0,100];b}' '{b}'
run 0 ../equals '{0[->0..$];b}' '{b}'
run 0 ../equals '{1[->0];b}' '{b}'
run 0 ../equals '{0[->0,100];b}' 'b'
run 0 ../equals '{0[->0..$];b}' 'b'
run 0 ../equals '!{1[->0];b}' '!b'
run 0 ../equals '{1[->10,20];b}' '{[*10..20];b}'
run 0 ../equals '{1[->..];b}' '{[*1..];b}'
run 0 ../equals '{{a&!c}[->0];b}' '{b}'
run 0 ../equals '{{a&!c}[->0];b}' 'b'