Exemplo n.º 1
0
 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]
Exemplo n.º 2
0
 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]
Exemplo n.º 3
0
 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))))
Exemplo n.º 4
0
 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()]
Exemplo n.º 5
0
 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()
     ]
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
def XOR(x1, x2):
    s1 = NAND(x1, x2)
    s2 = OR(x1, x2)
    y = AND(s1, s2)
    return y
Exemplo n.º 8
0
 def negationnormalform(self):
     from _or import OR
     from _not import NOT
     return OR(NOT(self.operand1), self.operand2).negationnormalform()
Exemplo n.º 9
0
 def picc(self):
     from _or import OR
     from _not import NOT
     return OR(NOT(self.operand1), self.operand2).picc()
Exemplo n.º 10
0
 def ufc_minus(self):
     from _or import OR
     from _not import NOT
     return OR(NOT(self.operand1), self.operand2).ufc_minus()