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
def assignment(): var = yield variable yield spaces() yield regex(":=") yield spaces() val = yield try_choice(fol_expression, math_expression) return BiOp(var, ":=", val)
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)
def until(left: Formula, right: Formula): return BiOp(left, "U", right)
def iff(left: Formula, right: Formula): return BiOp(left, "<->", right)
def implies(left: Formula, right: Formula): return BiOp(left, "->", right)
def math_bi_expression(): left = yield math_expression << spaces() op = yield regex("(\+|%|\*|\/|=|>=|<=|>|<)") << spaces() right = yield math_expression << spaces() return BiOp(left, op, right)
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)