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 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 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 XOR(x1, x2): s1 = NAND(x1, x2) s2 = OR(x1, x2) y = AND(s1, s2) return y
def negationnormalform(self): from _or import OR from _not import NOT return OR(NOT(self.operand1), self.operand2).negationnormalform()
def picc(self): from _or import OR from _not import NOT return OR(NOT(self.operand1), self.operand2).picc()
def ufc_minus(self): from _or import OR from _not import NOT return OR(NOT(self.operand1), self.operand2).ufc_minus()