def aso(self): from _or import OR from implies import IMPLIES from until import UNTIL from release import RELEASE from _finally import FINALLY from globally import GLOBALLY from next import NEXT result = list() if isinstance(self.operand1, (AND, OR, IMPLIES)) and not isinstance(self.operand1, AND): result += [self.operand1.__class__(self.operand1.operand1, AND(self.operand1.operand2, self.operand2))] if isinstance(self.operand2, (AND, OR, IMPLIES)) and not isinstance(self.operand2, AND): result += [self.operand2.__class__(AND(self.operand1, self.operand2.operand1), self.operand2.operand2)] if isinstance(self.operand1, (UNTIL, RELEASE)): result += [self.operand1.__class__(self.operand1.operand1, AND(self.operand1.operand2, self.operand2), self.operand1.lower_bound, self.operand1.upper_bound)] if isinstance(self.operand2, (UNTIL, RELEASE)): result += [self.operand2.__class__(AND(self.operand1, self.operand2.operand1), self.operand2.operand2, self.operand2.lower_bound, self.operand2.upper_bound)] if isinstance(self.operand1, (FINALLY, GLOBALLY)): result += [self.operand1.__class__(AND(self.operand1.operand1, self.operand2), self.operand1.lower_bound, self.operand1.upper_bound)] if isinstance(self.operand2, (FINALLY, GLOBALLY)): result += [self.operand2.__class__(AND(self.operand1, self.operand2.operand1), self.operand2.lower_bound, self.operand2.upper_bound)] if isinstance(self.operand1, NEXT): result += [NEXT(AND(self.operand1.operand1, self.operand2), self.operand1.lower_bound)] if isinstance(self.operand2, NEXT): result += [NEXT(AND(self.operand1, self.operand2.operand1), self.operand2.lower_bound)] return result + [AND(y, self.operand2) for y in self.operand1.aso() if not y == self.operand2] \ + [AND(self.operand1, y) for y in self.operand2.aso() if not y == self.operand1]
def lro(self): from _or import OR from implies import IMPLIES return [OR(self.operand1, self.operand2), OR(self.operand1, self.operand2), IMPLIES(self.operand1, self.operand2), IMPLIES(self.operand1, self.operand2)] \ + [AND(y, self.operand2) for y in self.operand1.lro() if not y == self.operand2] \ + [AND(self.operand1, y) for y in self.operand2.lro() if not y == self.operand1]
def lro(self): from _or import OR from _and import AND return [OR(self.operand1, self.operand2), OR(self.operand1, self.operand2), AND(self.operand1, self.operand2), AND(self.operand1, self.operand2)] \ + [IMPLIES(y, self.operand2) for y in self.operand1.lro() if not y == self.operand2] \ + [IMPLIES(self.operand1, y) for y in self.operand2.lro() if not y == self.operand1]
def ufc_minus(self): from until import UNTIL from _and import AND from _not import NOT return [UNTIL(AND(self.operand1, NOT(self.operand2)), AND(y, NOT(self.operand2)), self.lower_bound, self.upper_bound) for y in self.operand1.ufc_minus()] \ + [UNTIL(AND(self.operand1, NOT(self.operand2)), AND(y, NOT(UNTIL(self.operand1, self.operand2, self.lower_bound, self.upper_bound))), self.lower_bound, self.upper_bound) for y in self.operand2.ufc_minus()]
def nextnormalform(self, ininterval=0): from _or import OR from _and import AND from next import NEXT if self.lower_bound == 0 and self.upper_bound == 0: return self.operand2.nextnormalform(ininterval) elif (self.lower_bound == 0 and (not self.upper_bound == 0) and ininterval % 2 == 0): return OR(self.operand2.nextnormalform(ininterval), AND(self.operand1.nextnormalform(ininterval), AND( NEXT(self.operand1.nextnormalform(ininterval + 1), 0.5), OR(NEXT(self.operand2.nextnormalform(ininterval + 1), 0.5), NEXT(UNTIL(self.operand1, self.operand2, 0, self.upper_bound - 1).nextnormalform(ininterval), 1))))) elif (self.lower_bound == 0 and (not self.upper_bound == 0) and ininterval % 2 == 1): return OR(self.operand2.nextnormalform(ininterval), AND(self.operand1.nextnormalform(ininterval), OR( NEXT(self.operand2.nextnormalform(ininterval + 1), 0.5), AND(NEXT(self.operand1.nextnormalform(ininterval + 1), 0.5), AND(NEXT(self.operand1.nextnormalform(ininterval), 1), NEXT(UNTIL(self.operand1, self.operand2, 0, self.upper_bound - 1).nextnormalform(ininterval), 1)))))) elif ((not self.lower_bound == 0) and (not self.upper_bound == 0) and ininterval % 2 == 0): return AND(self.operand1.nextnormalform(ininterval), AND(NEXT(self.operand1.nextnormalform(ininterval + 1), 0.5), NEXT( UNTIL(self.operand1, self.operand2, self.lower_bound - 1, self.upper_bound - 1).nextnormalform(ininterval), 1))) elif ((not self.lower_bound == 0) and (not self.upper_bound == 0) and ininterval % 2 == 1): return AND(self.operand1.nextnormalform(ininterval), AND(NEXT(self.operand1.nextnormalform(ininterval + 1), 0.5), AND(NEXT(self.operand1.nextnormalform(ininterval), 1), NEXT( UNTIL(self.operand1, self.operand2, self.lower_bound - 1, self.upper_bound - 1).nextnormalform(ininterval), 1))))
def picc(self): from _and import AND from _not import NOT from _or import OR return [UNTIL(AND(self.operand1, NOT(self.operand2)), AND(y, OR(self.operand2, UNTIL(self.operand1, self.operand2, self.lower_bound, self.upper_bound))), self.lower_bound, self.upper_bound) for y in self.operand1.picc()] \ + [UNTIL(AND(self.operand1, NOT(self.operand2)), AND(y, OR(self.operand2, UNTIL(self.operand1, self.operand2, self.lower_bound, self.upper_bound))), self.lower_bound, self.upper_bound) for y in self.operand2.picc()]
def tio(self, lower_bound=None, upper_bound=None): from _finally import FINALLY from globally import GLOBALLY from next import NEXT return [AND(FINALLY(self.operand1, lower_bound, upper_bound), self.operand2), AND(self.operand1, FINALLY(self.operand2, lower_bound, upper_bound)), AND(GLOBALLY(self.operand1, lower_bound, upper_bound), self.operand2), AND(self.operand1, GLOBALLY(self.operand2, lower_bound, upper_bound)), AND(NEXT(self.operand1, upper_bound), self.operand2), AND(self.operand1, NEXT(self.operand2, upper_bound))] \ + [AND(y, self.operand2) for y in self.operand1.tio(lower_bound, upper_bound) if not y == self.operand2] \ + [AND(self.operand1, y) for y in self.operand2.tio(lower_bound, upper_bound) if not y == self.operand1]
def ufc_minus(self): from until import UNTIL from _not import NOT from _and import AND from globally import GLOBALLY return [ UNTIL( NOT(self.operand1), AND( y, GLOBALLY(NOT(self.operand1), self.lower_bound, self.upper_bound)), self.lower_bound, self.upper_bound) for y in self.operand1.ufc_minus() ]
def picc(self): from until import UNTIL from _not import NOT from _and import AND from _or import OR return [ UNTIL( NOT(self.operand1), AND( y, OR( self.operand1, FINALLY(self.operand1, self.lower_bound, self.upper_bound))), self.lower_bound, self.upper_bound) for y in self.operand1.picc() ]
def negationnormalform(self): from ap import ap_true, ap_false, AP from _or import OR from _and import AND from implies import IMPLIES from next import NEXT if isinstance(self.operand1, AP): if self.operand1 == ap_true: return ap_false elif self.operand1 == ap_false: return ap_true elif self.operand1.operator is None: # Boolean AP return self elif self.operand1.operator == ge: return AP(None, self.operand1.c, lt, self.operand1.b, self.operand1.variables) elif self.operand1.operator == gt: return AP(None, self.operand1.c, le, self.operand1.b, self.operand1.variables) elif self.operand1.operator == le: return AP(None, self.operand1.c, gt, self.operand1.b, self.operand1.variables) elif self.operand1.operator == lt: return AP(None, self.operand1.c, ge, self.operand1.b, self.operand1.variables) elif self.operand1.operator == eq: return AP(None, self.operand1.c, ne, self.operand1.b, self.operand1.variables) elif self.operand1.operator == ne: return AP(None, self.operand1.c, eq, self.operand1.b, self.operand1.variables) elif isinstance(self.operand1, AND): return OR( NOT(self.operand1.operand1).negationnormalform(), NOT(self.operand1.operand2).negationnormalform()) elif isinstance(self.operand1, OR): return AND( NOT(self.operand1.operand1).negationnormalform(), NOT(self.operand1.operand2).negationnormalform()) elif isinstance(self.operand1, IMPLIES): return NOT(self.operand1.negationnormalform()).negationnormalform() elif isinstance(self.operand1, NOT): return self.operand1.operand1.negationnormalform() elif isinstance(self.operand1, NEXT): return NEXT( NOT(self.operand1.operand1).negationnormalform(), self.operand1.lower_bound)
def mco(self): from ap import AP result = list() if isinstance(self.operand1, AP): result += [self.operand2] + [AND(y, self.operand2) for y in self.operand1.mco()] \ + [AND(self.operand1, y) for y in self.operand2.mco()] if isinstance(self.operand2, AP): result += [self.operand1] + [AND(y, self.operand2) for y in self.operand1.mco()] \ + [AND(self.operand1, y) for y in self.operand2.mco()] if not (isinstance(self.operand1, AP) or isinstance(self.operand2, AP)): result += [AND(y, self.operand2) for y in self.operand1.mco()] \ + [AND(self.operand1, y) for y in self.operand2.mco()] return result
def oro(self, atomic_props): return [AND(y, self.operand2) for y in self.operand1.oro(atomic_props) if not y == self.operand2] \ + [AND(self.operand1, y) for y in self.operand2.oro(atomic_props) if not y == self.operand1]
def ano(self): return [AND(y, self.operand2) for y in self.operand1.ano() if not y == self.operand2] \ + [AND(self.operand1, y) for y in self.operand2.ano() if not y == self.operand1]
def mto(self): return [AND(y, self.operand2) for y in self.operand1.mto()] \ + [AND(self.operand1, y) for y in self.operand2.mto()]
def ufc_minus(self): from _and import AND from _not import NOT return [AND(y, NOT(self.operand2)) for y in self.operand1.ufc_minus()] \ + [AND(NOT(self.operand1), y) for y in self.operand2.ufc_minus()]
def adjust(self, c): """ Adjusts formula to a given step width c by dividing all interval bounds by c. """ return AND(self.operand1.adjust(c), self.operand2.adjust(c))
def picc(self): from _and import AND from _not import NOT return [AND(y, NOT(self.operand2)) for y in self.operand1.picc()] \ + [AND(NOT(self.operand1), y) for y in self.operand2.picc()]
def ufc_minus(self): return [AND(y, self.operand2) for y in self.operand1.ufc_minus()] \ + [AND(self.operand1, y) for y in self.operand2.ufc_minus()]
def picc(self): from _and import AND return [AND(y, self.operand2) for y in self.operand1.picc()] \ + [AND(self.operand1, y) for y in self.operand2.picc()]
def eno(self): from _not import NOT return [NOT(self)] + [AND(y, self.operand2) for y in self.operand1.eno()] \ + [AND(self.operand1, y) for y in self.operand2.eno()]
def picc(self): from until import UNTIL from _and import AND return [UNTIL(self.operand1, AND(y, GLOBALLY(self.operand1, self.lower_bound, self.upper_bound)), self.lower_bound, self.upper_bound) for y in self.operand1.picc()]
def XOR(x1, x2): s1 = NAND(x1, x2) s2 = OR(x1, x2) y = AND(s1, s2) return y
def sto(self, onezero): return [AND(y, self.operand2) for y in self.operand1.sto(onezero) if not y == self.operand2] \ + [AND(self.operand1, y) for y in self.operand2.sto(onezero) if not y == self.operand1]