Skip to content

Commit

Permalink
fix timed until
Browse files Browse the repository at this point in the history
  • Loading branch information
mvcisback committed Apr 6, 2020
1 parent 31c3d3b commit 74f6efa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion mtl/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions mtl/sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 74f6efa

Please sign in to comment.