Add trivial identities for &&, <>->, []-> and Boolean arguments.
* src/ltlast/binop.cc (EConcat, UConcat): Rewrite "{b}<>-> f"
as "b && f", and rewrite "{b}[]->f" as "b->f".
* src/ltlast/binop.hh (binop::instance): Document trivial
identities for <>-> and []->.
* src/ltlast/multop.cc (multop::instance): Rewrite "b1 & b2"
as "b1 && b2" when b1 and b2 are Boolean.
(multop::multop): Always disable is.boolean for AndNLM.
* src/ltlast/multop.hh: Document the rewriting.
* src/ltltest/equals.cc: Show the two formulas if the exit_code
is 1, to help debugging.
* src/ltltest/equals.test: Add more tests.
* src/ltltest/kind.test: Adjust tests.
This commit is contained in:
parent
0e4e2a79b2
commit
a2da5184b5
7 changed files with 63 additions and 13 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <utility>
|
||||
#include "binop.hh"
|
||||
#include "unop.hh"
|
||||
#include "multop.hh"
|
||||
#include "constant.hh"
|
||||
#include "visitor.hh"
|
||||
#include <iostream>
|
||||
|
|
@ -365,6 +366,7 @@ namespace spot
|
|||
// - 1 <>-> Exp = Exp
|
||||
// - [*0] <>-> Exp = 0
|
||||
// - Exp <>-> 0 = 0
|
||||
// - boolExp <>-> Exp = boolExp & Exp
|
||||
if (first == constant::true_instance())
|
||||
return second;
|
||||
if (first == constant::false_instance()
|
||||
|
|
@ -378,12 +380,15 @@ namespace spot
|
|||
first->destroy();
|
||||
return second;
|
||||
}
|
||||
if (first->is_boolean())
|
||||
return multop::instance(multop::And, first, second);
|
||||
break;
|
||||
case UConcat:
|
||||
// - 0 []-> Exp = 1
|
||||
// - 1 []-> Exp = Exp
|
||||
// - [*0] []-> Exp = 1
|
||||
// - Exp []-> 1 = 1
|
||||
// - boolExp []-> Exp = boolExp -> Exp
|
||||
if (first == constant::true_instance())
|
||||
return second;
|
||||
if (first == constant::false_instance()
|
||||
|
|
@ -397,6 +402,8 @@ namespace spot
|
|||
first->destroy();
|
||||
return second;
|
||||
}
|
||||
if (first->is_boolean())
|
||||
return binop::instance(binop::Implies, first, second);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
@ -96,6 +96,16 @@ namespace spot
|
|||
/// - (1 M Exp) = Exp
|
||||
/// - (0 M Exp) = 0
|
||||
/// - (Exp M Exp) = Exp
|
||||
/// - 0 <>-> Exp = 0
|
||||
/// - 1 <>-> Exp = Exp
|
||||
/// - [*0] <>-> Exp = 0
|
||||
/// - Exp <>-> 0 = 0
|
||||
/// - boolExp <>-> Exp = boolExp & Exp
|
||||
/// - 0 []-> Exp = 1
|
||||
/// - 1 []-> Exp = Exp
|
||||
/// - [*0] []-> Exp = 1
|
||||
/// - Exp []-> 1 = 1
|
||||
/// - boolExp <>-> Exp = boolExp -> Exp
|
||||
static formula* instance(type op, formula* first, formula* second);
|
||||
|
||||
virtual void accept(visitor& v);
|
||||
|
|
|
|||
|
|
@ -45,18 +45,18 @@ namespace spot
|
|||
{
|
||||
case Concat:
|
||||
case Fusion:
|
||||
case AndNLM:
|
||||
// Note: AndNLM(p1,p2) is a Boolean formula, but it is
|
||||
// actually rewritten as And(p1,p2) by trivial identities
|
||||
// before this constructor is called. So at this point,
|
||||
// AndNLM is always used with at most one Boolean argument,
|
||||
// and the result is therefore NOT Boolean.
|
||||
is.boolean = false;
|
||||
is.ltl_formula = false;
|
||||
is.eltl_formula = false;
|
||||
is.psl_formula = false;
|
||||
is.eventual = false;
|
||||
is.universal = false;
|
||||
// fall through
|
||||
case AndNLM:
|
||||
// The non-matching-length-And (&) can only appear in the
|
||||
// rational parts of PSL formula. We don't remove the
|
||||
// Boolean flag, because applied to atomic propositions a&b
|
||||
// has the same effect as a&&b.
|
||||
case And:
|
||||
for (unsigned i = 1; i < s; ++i)
|
||||
props &= (*v)[i]->get_props();
|
||||
|
|
@ -229,6 +229,27 @@ namespace spot
|
|||
abs = constant::false_instance();
|
||||
abs2 = 0;
|
||||
weak_abs = 0;
|
||||
|
||||
// Make a first pass to gather all boolean terms.
|
||||
{
|
||||
vec* b = new vec;
|
||||
vec::iterator i = v->begin();
|
||||
while (i != v->end())
|
||||
{
|
||||
if ((*i)->is_boolean())
|
||||
{
|
||||
b->push_back(*i);
|
||||
i = v->erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
// - AndNLM(Exps1...,Bool1,Exps2...,Bool2,Exp3...) =
|
||||
// AndNLM(Exps1...,Exps2...,Exp3...,And(Bool1,Bool2))
|
||||
v->push_back(instance(And, b));
|
||||
}
|
||||
break;
|
||||
case Or:
|
||||
neutral = constant::false_instance();
|
||||
|
|
@ -291,6 +312,7 @@ namespace spot
|
|||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// We have a* & [*0] & c = 0
|
||||
// and a* & [*0] & c* = [*0]
|
||||
// So if [*0] has been seen, check if alls term recognize the
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ namespace spot
|
|||
/// - AndNLM(Exps1...,0,Exps2...) = 0
|
||||
/// - AndNLM(Exps1...,[*0],Exps2...) = AndNLM(Exps1...,Exps2...)
|
||||
/// - AndNLM(Exp) = Exp
|
||||
/// - AndNLM(Exps1...,BoolExp1,Exps2...,BoolExp2,Exp3...) =
|
||||
/// AndNLM(Exps1...,Exps2...,Exp3...,And(BoolExp1,BoolExp2))
|
||||
/// - Or(Exps1...,1,Exps2...) = 1
|
||||
/// - Or(Exps1...,0,Exps2...) = And(Exps1...,Exps2...)
|
||||
/// - Or(Exp) = Exp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue