Fix trivial rules for b₁:b₂ and b&f.

* src/ltlast/multop.cc (instance): Here.
* src/ltlast/multop.hh, doc/tl/tl.tex: Adjust documentation.
* src/ltltest/equals.test: Adjust test cases.
This commit is contained in:
Alexandre Duret-Lutz 2012-04-17 18:33:39 +02:00
parent a4353d3985
commit 866384b423
4 changed files with 38 additions and 33 deletions

View file

@ -692,7 +692,7 @@ $b_1$, $b_2$ are assumed to be Boolean formul\ae.
\end{align*} \end{align*}
\noindent \noindent
The following rules are all valid with the two arguments swapped, except the one marked with $\equivM$. The following rules are all valid with the two arguments swapped.
%(Even for the non-commutative operators \samp{$\CONCAT$} and %(Even for the non-commutative operators \samp{$\CONCAT$} and
%\samp{$\FUSION$}.) %\samp{$\FUSION$}.)
@ -721,7 +721,7 @@ The following rules are all valid with the two arguments swapped, except the one
b_1 \AND b_2 &\equiv b_1\ANDALT b_2 & b_1 \AND b_2 &\equiv b_1\ANDALT b_2 &
&& &&
&& &&
b:f &\equivM b\AND f\\ b_1:b_2 &\equiv b_1\ANDALT b_2\\
\end{align*} \end{align*}
\section{SERE-LTL Binding Operators} \section{SERE-LTL Binding Operators}

View file

@ -196,9 +196,9 @@ namespace spot
// pointers that we must ignore. // pointers that we must ignore.
if ((*i) == 0) if ((*i) == 0)
{ {
// FIXME: We should replace the pointer by the // FIXME: For commutative operators we should replace
// first non-null value at the end of the array // the pointer by the first non-null value at the end
// instead of calling erase. // of the array instead of calling erase.
i = v->erase(i); i = v->erase(i);
continue; continue;
} }
@ -271,9 +271,12 @@ namespace spot
++i; ++i;
} }
} }
// - AndNLM(Exps1...,Bool1,Exps2...,Bool2,Exp3...) = // - AndNLM(Exps1...,Bool1,Exps2...,Bool2,Exps3...) =
// AndNLM(Exps1...,Exps2...,Exp3...,And(Bool1,Bool2)) // AndNLM(Exps1...,Exps2...,Exps3...,And(Bool1,Bool2))
if (!b->empty())
v->push_back(instance(And, b)); v->push_back(instance(And, b));
else
delete b;
} }
break; break;
case Or: case Or:
@ -297,38 +300,39 @@ namespace spot
abs2 = constant::empty_word_instance(); abs2 = constant::empty_word_instance();
weak_abs = 0; weak_abs = 0;
// Make a first pass to gather Boolean formulae. // Make a first pass to group adjacent Boolean formulae.
// - Fusion(Exps1...,BoolExp1...BoolExpN,Exps2,Exps3...) = // - Fusion(Exps1...,BoolExp1...BoolExpN,Exps2,Exps3...) =
// Fusion(Exps1...,AndNLM(And(BoolExp1...BoolExpN),Exps2),Exps3...) // Fusion(Exps1...,And(BoolExp1...BoolExpN),Exps2,Exps3...)
{ {
vec* b = 0;
vec::iterator i = v->begin(); vec::iterator i = v->begin();
while (i != v->end()) while (i != v->end())
{ {
if ((*i)->is_boolean()) if ((*i)->is_boolean())
{ {
if (!b) vec::iterator first = i;
b = new vec; ++i;
b->push_back(*i); if (i == v->end())
i = v->erase(i); break;
if (!(*i)->is_boolean())
{
++i;
continue;
}
do
++i;
while (i != v->end() && (*i)->is_boolean());
// We have at least two adjacent Boolean formulae.
// Replace the first one by the conjunction of all.
vec* b = new vec;
b->insert(b->begin(), first, i);
i = v->erase(first + 1, i);
*first = instance(And, b);
} }
else else
{ {
if (b)
{
// We have found a non-Boolean Exp. "AndNLM" it
// with all the previous Boolean formulae.
*i = instance(AndNLM, instance(And, b), *i);
b = 0;
}
++i; ++i;
} }
} }
if (b)
{
// Group all trailing Boolean formulae.
v->push_back(instance(And, b));
}
} }
break; break;

View file

@ -90,8 +90,8 @@ namespace spot
/// - AndNLM(Exps1...,0,Exps2...) = 0 /// - AndNLM(Exps1...,0,Exps2...) = 0
/// - AndNLM(Exps1...,[*0],Exps2...) = AndNLM(Exps1...,Exps2...) /// - AndNLM(Exps1...,[*0],Exps2...) = AndNLM(Exps1...,Exps2...)
/// - AndNLM(Exp) = Exp /// - AndNLM(Exp) = Exp
/// - AndNLM(Exps1...,BoolExp1,Exps2...,BoolExp2,Exp3...) = /// - AndNLM(Exps1...,BoolExp1,Exps2...,BoolExp2,Exps3...) =
/// AndNLM(Exps1...,Exps2...,Exp3...,And(BoolExp1,BoolExp2)) /// AndNLM(Exps1...,Exps2...,Exps3...,And(BoolExp1,BoolExp2))
/// - Or(Exps1...,1,Exps2...) = 1 /// - Or(Exps1...,1,Exps2...) = 1
/// - Or(Exps1...,0,Exps2...) = And(Exps1...,Exps2...) /// - Or(Exps1...,0,Exps2...) = And(Exps1...,Exps2...)
/// - Or(Exp) = Exp /// - Or(Exp) = Exp
@ -103,7 +103,7 @@ namespace spot
/// - Fusion(Exps1...,[*0],Exps2...) = 0 /// - Fusion(Exps1...,[*0],Exps2...) = 0
/// - Fusion(Exp) = Exp /// - Fusion(Exp) = Exp
/// - Fusion(Exps1...,BoolExp1...BoolExpN,Exps2,Exps3...) = /// - Fusion(Exps1...,BoolExp1...BoolExpN,Exps2,Exps3...) =
/// Fusion(Exps1...,AndNLM(And(BoolExp1...BoolExpN),Exps2),Exps3...) /// Fusion(Exps1...,And(BoolExp1...BoolExpN),Exps2,Exps3...)
static formula* instance(type op, vec* v); static formula* instance(type op, vec* v);
virtual void accept(visitor& v); virtual void accept(visitor& v);

View file

@ -145,9 +145,10 @@ run 0 ../equals '{a*}!' '{a*}<>->1'
run 0 ../equals '{a -> b} (c)' '!(a->b)|c' run 0 ../equals '{a -> b} (c)' '!(a->b)|c'
run 0 ../equals '{a & !b}!' 'a & !b' run 0 ../equals '{a & !b}!' 'a & !b'
run 0 ../equals '{a;[*0]}|->!Xb' '!a | !Xb' run 0 ../equals '{a;[*0]}|->!Xb' '!a | !Xb'
run 0 ../equals '{{a;b}:b:c:d*:e:f}!' '{{a;b}:{{b && c } & d[*]}:{e && f}}!' run 0 ../equals '{{a;b}:b:c:d*:e:f}!' '{{a;b}:{b && c }:d[*]:{e && f}}!'
run 0 ../equals '{a:b:c}|->!Xb' '!(a&b&c) | !Xb' run 0 ../equals '{a:b:c}|->!Xb' '!(a&&b&&c) | !Xb'
run 0 ../equals '{a:b:c*}|->!Xb' '{(a&&b)&c*}|-> !Xb' run 0 ../equals '{a:b:c*}|->!Xb' '{(a&&b):c*}|-> !Xb'
run 0 ../equals '{a&b&c*}|->!Xb' '{(a&&b)&c*}|-> !Xb'
run 0 ../equals '{a[*0]}' '{[*0]}' run 0 ../equals '{a[*0]}' '{[*0]}'
run 0 ../equals '{a[*..]}' '{a[*]}' run 0 ../equals '{a[*..]}' '{a[*]}'