Beispiel #1
0
def kiss_events_to_date_events(inputs: bool,
                               kiss_events: str) -> Tuple[bool, Formula]:
    notreq = []
    req = []
    i = 0
    while i < len(kiss_events):
        if kiss_events[i] != "-":
            event = vars.in_act[i] if inputs else vars.out_act[i]
            if kiss_events[i] == "0":
                notreq.append(event)
            else:
                req.append(event)
        i = i + 1
    atom = None
    if len(notreq) > 0:
        for a in notreq:
            if atom is None:
                atom = UniOp("!", a)
            else:
                atom = BiOp(atom, "&", UniOp("!", a))

    if len(req) > 0:
        for a in notreq:
            if atom is None:
                atom = Atom(a)
            else:
                atom = BiOp(atom, "&", Atom(a))

    if vars.end_act is not None:
        if vars.end_act in req:
            return True, vars.end_act

    return False, atom
Beispiel #2
0
def assignment():
    var = yield variable
    yield spaces()
    yield regex(":=")
    yield spaces()
    val = yield try_choice(fol_expression, math_expression)
    return BiOp(var, ":=", val)
Beispiel #3
0
def andd(left: Formula, right: Formula):
    if isinstance(left, Atom):
        if left.name.lower() == "true" or left.name.lower == "tt":
            return right
    if isinstance(right, Atom):
        if right.name.lower() == "true" or right.name.lower == "tt":
            return left

    if isinstance(left, Atom):
        if left.name.lower() == "false" or left.name.lower == "ff":
            return left
    if isinstance(right, Atom):
        if right.name.lower() == "false" or right.name.lower == "ff":
            return right

    return BiOp(left, "&&", right)
Beispiel #4
0
def until(left: Formula, right: Formula):
    return BiOp(left, "U", right)
Beispiel #5
0
def iff(left: Formula, right: Formula):
    return BiOp(left, "<->", right)
Beispiel #6
0
def implies(left: Formula, right: Formula):
    return BiOp(left, "->", right)
Beispiel #7
0
def math_bi_expression():
    left = yield math_expression << spaces()
    op = yield regex("(\+|%|\*|\/|=|>=|<=|>|<)") << spaces()
    right = yield math_expression << spaces()
    return BiOp(left, op, right)
Beispiel #8
0
def boolean_bi_expression():
    left = yield unit_fol_expression << spaces()
    op = yield regex("(&+|\|+|=+|\-+>|<\-+>)") << spaces()
    right = yield unit_fol_expression << spaces()
    return BiOp(left, op, right)