Fix trivial identity (0 => Exp) == 1, and add rewritings for =>.

The new rewriting are (Exp => Exp) = 1, (Exp <=> Exp) == 1,
and (Exp ^ Exp) == 0.

* src/ltlast/binop.hh: Fix documentation.
* src/ltlast/binop.cc: Fix implementation.
* src/ltltest/equals.test: More tests.
* src/tgbatest/emptchk.test: Remove a useless test.
This commit is contained in:
Alexandre Duret-Lutz 2010-10-16 17:24:50 +02:00
parent f2732dd8cc
commit 473cf77144
4 changed files with 30 additions and 5 deletions

View file

@ -158,6 +158,12 @@ namespace spot
return unop::instance(unop::Not, second);
if (first == constant::false_instance())
return second;
if (first == second)
{
first->destroy();
second->destroy();
return constant::false_instance();
}
// We expect constants to appear first, because they are
// instantiated first.
assert(second != constant::false_instance());
@ -172,10 +178,17 @@ namespace spot
}
// - (0 <=> Exp) = !Exp
// - (1 <=> Exp) = Exp
// - (Exp <=> Exp) = 1
if (first == constant::false_instance())
return unop::instance(unop::Not, second);
if (first == constant::true_instance())
return second;
if (first == second)
{
first->destroy();
second->destroy();
return constant::true_instance();
}
// We expect constants to appear first, because they are
// instantiated first.
assert(second != constant::false_instance());
@ -183,15 +196,16 @@ namespace spot
break;
case Implies:
// - (1 => Exp) = Exp
// - (0 => Exp) = 0
// - (0 => Exp) = 1
// - (Exp => 1) = 1
// - (Exp => 0) = !Exp
// - (Exp => Exp) = 1
if (first == constant::true_instance())
return second;
if (first == constant::false_instance())
{
second->destroy();
return first;
return constant::true_instance();
}
if (second == constant::true_instance())
{
@ -200,6 +214,12 @@ namespace spot
}
if (second == constant::false_instance())
return unop::instance(unop::Not, first);
if (first == second)
{
first->destroy();
second->destroy();
return constant::true_instance();
}
break;
case U:
// - (Exp U 1) = 1

View file

@ -70,13 +70,16 @@ namespace spot
/// performed (the left formula is rewritten as the right
/// formula):
/// - (1 => Exp) = Exp
/// - (0 => Exp) = 0
/// - (0 => Exp) = 1
/// - (Exp => 1) = 1
/// - (Exp => 0) = !Exp
/// - (Exp => Exp) = 1
/// - (1 ^ Exp) = !Exp
/// - (0 ^ Exp) = Exp
/// - (Exp ^ Exp) = 0
/// - (0 <=> Exp) = !Exp
/// - (1 <=> Exp) = Exp
/// - (Exp <=> Exp) = Exp
/// - (Exp U 1) = 1
/// - (Exp U 0) = 0
/// - (0 U Exp) = Exp