diff --git a/mtl/evaluator.py b/mtl/evaluator.py index 3f4b89f..5e57c85 100644 --- a/mtl/evaluator.py +++ b/mtl/evaluator.py @@ -125,7 +125,12 @@ def _min(val): return min(val[phi.arg]) def _eval(x): - return f(x).rolling(a, b).map(_min, tag=phi) + tmp = f(x) + assert b >= a + if b > a: + return tmp.rolling(a, b).map(_min, tag=phi) + + return tmp.retag({phi.arg: phi}) return _eval diff --git a/mtl/sugar.py b/mtl/sugar.py index 54db20d..05a0b0e 100644 --- a/mtl/sugar.py +++ b/mtl/sugar.py @@ -25,5 +25,11 @@ def until(phi, psi): return ast.WeakUntil(phi, psi) & env(psi) -def timed_until(phi, psi, lo, hi): - return env(psi, lo=lo, hi=hi) & alw(until(phi, psi), lo=0, hi=lo) +def timed_until(left, right, lo, hi): + assert 0 <= lo < hi + + expr = env(right, lo=lo, hi=hi) + expr &= alw(left, lo=0, hi=lo) + expr &= alw(until(left, right), lo=lo, hi=lo) + + return expr