add helper function for going to an MTL formula
This commit is contained in:
parent
014110cf90
commit
078eb11b5c
1 changed files with 10 additions and 0 deletions
10
stl/utils.py
10
stl/utils.py
|
|
@ -4,6 +4,7 @@ from lenses import lens, Lens
|
|||
import funcy as fn
|
||||
import sympy
|
||||
|
||||
import stl.ast
|
||||
from stl.ast import LinEq, And, Or, NaryOpSTL, F, G, Interval, Neg
|
||||
|
||||
def walk(stl, bfs=False):
|
||||
|
|
@ -108,3 +109,12 @@ def f_neg_or_canonical_form(phi):
|
|||
return Neg(F(phi.interval, children[0]))
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def to_mtl(phi):
|
||||
focus = lineq_lens(phi)
|
||||
to_ap = lambda i: stl.ast.AtomicPred("AP{}".format(i))
|
||||
ap_map = {to_ap(i): leq for i, leq in enumerate(focus.get_all())}
|
||||
lineq_map = {v:k for k,v in ap_map.items()}
|
||||
return focus.modify(lineq_map.get), ap_map
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue