Example #1
0
 def applyTransitivity(self, other, assumptions=USE_DEFAULTS):
     '''
     Apply a transitivity rule to derive from this x<=y expression 
     and something of the form y<z, y<=z, z>y, z>=y, or y=z to
     obtain x<z or x<=z as appropriate.  In the special case
     of x<=y and y<=x (or x>=y), derive x=z.
     '''
     from _theorems_ import transitivityLessEqLess, transitivityLessEqLessEq, symmetricLessEq
     from greater_than import Greater, GreaterEq
     other = asExpression(other)
     if isinstance(other, Equals):
         return OrderingRelation.applyTransitivity(
             self, other, assumptions)  # handles this special case
     if isinstance(other, Greater) or isinstance(other, GreaterEq):
         other = other.deriveReversed(assumptions)
     if other.lhs == self.rhs and other.rhs == self.lhs:
         # x >= y and y >= x implies that x=y
         return symmetricLessEq.specialize({
             x: self.lhs,
             y: self.rhs
         },
                                           assumptions=assumptions)
     elif other.lhs == self.rhs:
         if isinstance(other, Less):
             return transitivityLessEqLess.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.rhs
                 },
                 assumptions=assumptions)
         elif isinstance(other, LessEq):
             return transitivityLessEqLessEq.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.rhs
                 },
                 assumptions=assumptions)
     elif other.rhs == self.lhs:
         if isinstance(other, Less):
             return transitivityLessEqLess.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.lhs
                 },
                 assumptions=assumptions)
         elif isinstance(other, LessEq):
             return transitivityLessEqLessEq.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.lhs
                 },
                 assumptions=assumptions)
     else:
         raise ValueError("Cannot perform transitivity with %s and %s!" %
                          (self, other))
Example #2
0
 def applyTransitivity(self, other, assumptions=USE_DEFAULTS):
     '''
     Apply a transitivity rule to derive from this x<y expression 
     and something of the form y<z, y<=z, z>y, z>=y, or y=z to
     obtain x<z.
     '''
     from _axioms_ import transitivityLessLess
     from _theorems_ import transitivityLessLessEq
     from greater_than import Greater, GreaterEq
     other = asExpression(other)
     if isinstance(other, Equals):
         return OrderingRelation.applyTransitivity(
             self, other, assumptions)  # handles this special case
     if isinstance(other, Greater) or isinstance(other, GreaterEq):
         other = other.deriveReversed(assumptions)
     elif other.lhs == self.rhs:
         if isinstance(other, Less):
             return transitivityLessLess.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.rhs
                 },
                 assumptions=assumptions)
         elif isinstance(other, LessEq):
             return transitivityLessLessEq.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.rhs
                 },
                 assumptions=assumptions)
     elif other.rhs == self.lhs:
         if isinstance(other, Less):
             return transitivityLessLess.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.lhs
                 },
                 assumptions=assumptions)
         elif isinstance(other, LessEq):
             return transitivityLessLessEq.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.lhs
                 },
                 assumptions=assumptions)
     else:
         raise ValueError("Cannot perform transitivity with %s and %s!" %
                          (self, other))
Example #3
0
 def applyTransitivity(self, other, assumptions=USE_DEFAULTS):
     from _theorems_ import transitivityGreaterGreater, transitivityGreaterGreaterEq
     from less_than import Less, LessEq
     other = asExpression(other)
     if isinstance(other, Equals):
         return OrderingRelation.applyTransitivity(
             self, other, assumptions)  # handles this special case
     if isinstance(other, Less) or isinstance(other, LessEq):
         other = other.deriveReversed(assumptions)
     if other.lhs == self.rhs:
         if isinstance(other, Greater):
             return transitivityGreaterGreater.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.rhs
                 },
                 assumptions=assumptions)
         elif isinstance(other, GreaterEq):
             return transitivityGreaterGreaterEq.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.rhs
                 },
                 assumptions=assumptions)
     elif other.rhs == self.lhs:
         if isinstance(other, Greater):
             return transitivityGreaterGreater.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.lhs
                 },
                 assumptions=assumptions)
         elif isinstance(other, GreaterEq):
             return transitivityGreaterGreaterEq.specialize(
                 {
                     x: self.lhs,
                     y: self.rhs,
                     z: other.lhs
                 },
                 assumptions=assumptions)
     else:
         raise ValueError("Cannot perform transitivity with %s and %s!" %
                          (self, other))
Example #4
0
 def __init__(self, operator, lhs, rhs):
     OrderingRelation.__init__(self, operator, lhs, rhs)
Example #5
0
 def __init__(self, lhs, rhs):
     r'''
     See if second number is at bigger than first.
     '''
     OrderingRelation.__init__(self, Less._operator_, lhs, rhs)
Example #6
0
 def __init__(self, lhs, rhs):
     r'''
     See if first number is at least as big as second.
     '''
     OrderingRelation.__init__(self, Greater._operator_, lhs, rhs)