tl: fix the definition of ##[i:j]

Reported by Victor Khomenko.

* NEWS, doc/tl/tl.tex, spot/tl/formula.cc: Fix the definition.
* tests/core/ltl2tgba.test: Add some test cases.
This commit is contained in:
Alexandre Duret-Lutz 2019-05-19 09:12:59 +02:00
parent 60bdf5de19
commit 66a3b6f7cb
4 changed files with 53 additions and 21 deletions

View file

@ -1776,16 +1776,29 @@ namespace spot
formula formula::sugar_delay(const formula& a, const formula& b,
unsigned min, unsigned max)
{
// In general
// a ##[min:max] b = a:(1[*min:max];b)
// however if min>=1 we prefer the following rule
// If min>=1
// a ##[min:max] b = a;1[*min-1:max-1];b
if (min == 0)
return Fusion({a, Concat({Star(tt(), min, max), b})});
--min;
// If min==0 we can use
// a ##[min:max] b = a:(1[*0:max];b) if a rejects [*0]
// a ##[min:max] b = (a;1[*0:max]):b if b rejects [*0]
// a ##[min:max] b = (a:b)|(a;[*0:max-1];b) else
if (min > 0)
{
--min;
if (max != unbounded())
--max;
return Concat({a, Star(tt(), min, max), b});
}
if (!a.accepts_eword())
return Fusion({a, Concat({Star(tt(), 0, max), b})});
if (!b.accepts_eword())
return Fusion({Concat({a, Star(tt(), 0, max)}), b});
if (max != unbounded())
--max;
return Concat({a, Star(tt(), min, max), b});
formula left = Fusion({a, b});
formula right = Concat({a, Star(tt(), 0, max), b});
return OrRat({left, right});
}
int atomic_prop_cmp(const fnode* f, const fnode* g)