forgot to add sugar module + fix breakage due to sugar module
This commit is contained in:
parent
7002246850
commit
6075df175b
3 changed files with 33 additions and 4 deletions
29
mtl/sugar.py
Normal file
29
mtl/sugar.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from mtl import ast
|
||||
|
||||
|
||||
def alw(phi, *, lo=0, hi=float('inf')):
|
||||
return ast.G(ast.Interval(lo, hi), phi)
|
||||
|
||||
|
||||
def env(phi, *, lo=0, hi=float('inf')):
|
||||
return ~alw(~phi, lo=lo, hi=hi)
|
||||
|
||||
|
||||
def implies(x, y):
|
||||
return ~x | y
|
||||
|
||||
|
||||
def xor(x, y):
|
||||
return (x | y) & ~(x & y)
|
||||
|
||||
|
||||
def iff(x, y):
|
||||
return (x & y) | (~x & ~y)
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -55,5 +55,5 @@ def test_temporal_identity4(phi):
|
|||
|
||||
@given(MetricTemporalLogicStrategy)
|
||||
def test_temporal_identity5(phi):
|
||||
assert mtl.until(mtl.TOP, phi)(x, 0, quantitative=False) \
|
||||
== mtl.env(phi)(x, 0, quantitative=False)
|
||||
assert mtl.TOP.until(phi)(x, 0, quantitative=False) \
|
||||
== phi.eventually()(x, 0, quantitative=False)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ from math import isfinite
|
|||
from discrete_signals import signal
|
||||
import numpy as np
|
||||
|
||||
import mtl.ast
|
||||
from mtl.ast import (And, G, Interval, Neg, Next, WeakUntil,
|
||||
from mtl import ast
|
||||
from mtl.ast import (And, G, Neg, Next, WeakUntil,
|
||||
AtomicPred, _Bot)
|
||||
|
||||
oo = float('inf')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue