ó
~9­\c           @  sV  d  d l  m Z m Z d d l m Z m Z d d l m Z d d l m	 Z	 d d l
 m Z d d l m Z d d l m Z d d	 l m Z d  d
 l m Z m Z d d d d d d d d d d d d d d f Z d „  Z d e e e f d „  ƒ  YZ e Z d e f d „  ƒ  YZ e Z d e f d „  ƒ  YZ e Z d e f d „  ƒ  YZ d e f d  „  ƒ  YZ d! e f d" „  ƒ  YZ d e f d# „  ƒ  YZ  e  Z! d e f d$ „  ƒ  YZ" e" Z# d e f d% „  ƒ  YZ$ e$ Z% d e f d& „  ƒ  YZ& e& Z' i e e( 6e d' 6e d( 6e d) 6e d* 6e d+ 6e  d, 6e  d- 6e" d. 6e" d/ 6e$ d0 6e$ d1 6e& d2 6e& d3 6e _) d4 S(5   iÿÿÿÿ(   t   print_functiont   divisioni   (   t   _unevaluated_Addt   Add(   t   S(   t   ordered(   t   Expr(   t
   EvalfMixin(   t   _sympify(   t   global_evaluate(   t   Booleant   BooleanAtomt   Relt   Eqt   Net   Ltt   Let   Gtt   Get
   Relationalt   Equalityt
   Unequalityt   StrictLessThant   LessThant   StrictGreaterThant   GreaterThanc         C  s&   d „  |  j  t ƒ Dƒ } |  j | ƒ S(   Nc         S  s   i  |  ] } | j  | “ q S(    (   t	   canonical(   t   .0t   r(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pys
   <dictcomp>   s   	 (   t   atomsR   t   xreplace(   t   condt   reps(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt
   _canonical   s    c           B  sÅ   e  Z d  Z g  Z e Z d d „ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z e d „  ƒ Z e d	 „ Z d
 „  Z d „  Z e Z d „  Z e d „  ƒ Z RS(   s)  Base class for all relation types.

    Subclasses of Relational should generally be instantiated directly, but
    Relational can be instantiated with a valid `rop` value to dispatch to
    the appropriate subclass.

    Parameters
    ==========
    rop : str or None
        Indicates what subclass to instantiate.  Valid values can be found
        in the keys of Relational.ValidRelationalOperator.

    Examples
    ========

    >>> from sympy import Rel
    >>> from sympy.abc import x, y
    >>> Rel(y, x + x**2, '==')
    Eq(y, x**2 + x)

    c   
      K  s  |  t  k	 r" t j |  | | |  SyÎ |  j | }  |  | | |  } t | t t f ƒ r\ n t | t  ƒ rë d d l m } d d l	 m
 } x] | j D]O } t | | ƒ r° q• n  t | | ƒ r• d d l m }	 t |	 d ƒ ƒ ‚ q• q• Wn  | SWn! t k
 rt d | ƒ ‚ n Xd  S(   Niÿÿÿÿ(   t   Symbol(   R
   (   t
   filldedentsÎ   
                            A Boolean argument can only be used in
                            Eq and Ne; all other relationals expect
                            real expressions.
                        s&   Invalid relational operator symbol: %r(   R   R   t   __new__t   ValidRelationOperatort
   isinstanceR   R   t   sympy.core.symbolR"   t   sympy.logic.boolalgR
   t   argst   sympy.utilities.miscR#   t	   TypeErrort   KeyErrort
   ValueError(
   t   clst   lhst   rhst   ropt   assumptionst   rvR"   R
   t   aR#   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR$   <   s*    c         C  s   |  j  d S(   s#   The left-hand side of the relation.i    (   t   _args(   t   self(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR/   ]   s    c         C  s   |  j  d S(   s$   The right-hand side of the relation.i   (   R5   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR0   b   s    c         C  sd   i t  t  6t t 6t t 6t t 6t t 6t t 6} |  j \ } } t j | j	 |  j
 |  j
 ƒ | | ƒ S(   s1  Return the relationship with sides reversed.

        Examples
        ========

        >>> from sympy import Eq
        >>> from sympy.abc import x
        >>> Eq(x, 1)
        Eq(x, 1)
        >>> _.reversed
        Eq(1, x)
        >>> x < 1
        x < 1
        >>> _.reversed
        1 > x
        (   R   R   R   R   R   R   R)   R   R$   t   gett   func(   R6   t   opsR4   t   b(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   reversedg   s    0c         C  sŒ   |  j  \ } } t | t ƒ p* t | t ƒ s„ i t t 6t t 6t t 6t t 6t t 6t t 6} t	 j
 | j |  j |  j ƒ | | ƒ S|  Sd S(   s=  Return the relationship with signs reversed.

        Examples
        ========

        >>> from sympy import Eq
        >>> from sympy.abc import x
        >>> Eq(x, 1)
        Eq(x, 1)
        >>> _.reversedsign
        Eq(-x, -1)
        >>> x < 1
        x < 1
        >>> _.reversedsign
        -x > -1
        N(   R)   R&   R   R   R   R   R   R   R   R   R$   R7   R8   (   R6   R4   R:   R9   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   reversedsign}   s
    0'c         C  sO   i t  t 6t t 6t t 6t t 6t t 6t t  6} t j | j |  j	 ƒ |  j
 Œ S(   sy  Return the negated relationship.

        Examples
        ========

        >>> from sympy import Eq
        >>> from sympy.abc import x
        >>> Eq(x, 1)
        Eq(x, 1)
        >>> _.negated
        Ne(x, 1)
        >>> x < 1
        x < 1
        >>> _.negated
        x >= 1

        Notes
        =====

        This works more or less identical to ``~``/``Not``. The difference is
        that ``negated`` returns the relationship even if `evaluate=False`.
        Hence, this is useful in code when checking for e.g. negated relations
        to exisiting ones as it will not be affected by the `evaluate` flag.

        (   R   R   R   R   R   R   R   R$   R7   R8   R)   (   R6   R9   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   negated–   s    0c         C  s,   |  j  g  |  j D] } | j | ƒ ^ q Œ  S(   N(   R8   R)   t   _evalf(   R6   t   prect   s(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   _eval_evalf¸   s    c         C  s1  |  j  } |  } | j j rT | j j r | j j r | j | j k r | j } q n< | j j rl | j } n$ t t | ƒ ƒ | k r | j } n  t | j t	 ƒ r¾ | j j
 ƒ  r¾ | j } no t | j t	 ƒ r-| j j r-| j j
 ƒ  r-t | j | j g ƒ \ } } | | j k r-| j j } q-n  | S(   sû  Return a canonical form of the relational by putting a
        Number on the rhs else ordering the args. The relation is also changed
        so that the left-hand side expression does not start with a `-`.
        No other simplification is attempted.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> x < 2
        x < 2
        >>> _.reversed.canonical
        x < 2
        >>> (-y < x).canonical
        x > -y
        >>> (-y > x).canonical
        x < -y
        (   R)   R0   t	   is_numbert	   is_NumberR/   R;   t   tupleR   R&   R   t   could_extract_minus_signR<   (   R6   R)   R   t   expr1t   _(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR   »   s$    	* c         C  s?  t  | t ƒ r;|  | k s* |  j | k r. t S|  | } } | j t t f k se | j t t f k rš| j | j k r{ t Sg  t | j	 | j	 ƒ D]! \ } } | j
 | d | ƒ^ q‘ \ } } | t k rÎ | S| t k rÞ | Sg  t | j	 | j j	 ƒ D]! \ } } | j
 | d | ƒ^ q÷ \ }	 }
 |	 t k r4|
 S|
 t k rD|	 S| | |	 |
 f } t d „  | Dƒ ƒ rpt SxÅ | D] } | t t f k rw| SqwWq;| j | j k r¸| j } n  | j | j k rÎt S| j j
 | j d | ƒ} | t k rùt S| j j
 | j d | ƒ} | t k r$t S| t k r4| S| Sn  d S(   sß   Return True if the sides of the relationship are mathematically
        identical and the type of relationship is the same.
        If failing_expression is True, return the expression whose truth value
        was unknown.t   failing_expressionc         s  s   |  ] } | t  k Vq d  S(   N(   t   False(   R   t   i(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pys	   <genexpr>  s    N(   R&   R   R;   t   TrueR8   R   R   RI   t   zipR)   t   equalst   allR/   R0   (   R6   t   otherRH   R4   R:   RJ   t   jt   leftt   rightt   lrt   rlt   e(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyRM   è   sP    *@C		c   	      C  sù   |  } | j  g  | j D]* } | j d | d | d | d | ƒ ^ q Œ  } | j rÈ | j | j } d  } | j rƒ | j d ƒ } n | j	 d ƒ rž t
 j } n  | d  k	 rÈ | j  j | t
 j ƒ } qÈ n  | j } | | ƒ | | |  ƒ k  rñ | S|  Sd  S(   Nt   ratiot   measuret   rationalt   inversei   i    (   R8   R)   t   simplifyt   is_RelationalR/   R0   t   Nonet   is_comparablet   nRM   R   t   Zerot   _eval_relationR   (	   R6   RV   RW   RX   RY   R   RJ   t   dift   v(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   _eval_simplify  s     	:			c         C  s   t  d ƒ ‚ d  S(   Ns*   cannot determine truth value of Relational(   R+   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   __nonzero__/  s    c         C  sP   d d l  m } |  j } t | ƒ d k s1 t ‚ | j ƒ  } | |  | d t ƒS(   Niÿÿÿÿ(   t   solve_univariate_inequalityi   t
   relational(   t   sympy.solvers.inequalitiesRe   t   free_symbolst   lent   AssertionErrort   popRI   (   R6   Re   t   symst   x(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   _eval_as_set4  s
    	c         C  s   t  ƒ  S(   N(   t   set(   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   binary_symbols<  s    N(   t   __name__t
   __module__t   __doc__t	   __slots__RK   R[   R\   R$   t   propertyR/   R0   R;   R<   R=   RA   R   RI   RM   Rc   Rd   t   __bool__Rn   Rp   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR      s"   !"	-0			c           B  s\   e  Z d  Z d Z g  Z e Z d d „ Z e d „  ƒ Z	 d „  Z
 e d „  ƒ Z d „  Z RS(   s°  An equal relation between two objects.

    Represents that two objects are equal.  If they can be easily shown
    to be definitively equal (or unequal), this will reduce to True (or
    False).  Otherwise, the relation is maintained as an unevaluated
    Equality object.  Use the ``simplify`` function on this object for
    more nontrivial evaluation of the equality relation.

    As usual, the keyword argument ``evaluate=False`` can be used to
    prevent any evaluation.

    Examples
    ========

    >>> from sympy import Eq, simplify, exp, cos
    >>> from sympy.abc import x, y
    >>> Eq(y, x + x**2)
    Eq(y, x**2 + x)
    >>> Eq(2, 5)
    False
    >>> Eq(2, 5, evaluate=False)
    Eq(2, 5)
    >>> _.doit()
    False
    >>> Eq(exp(x), exp(x).rewrite(cos))
    Eq(exp(x), sinh(x) + cosh(x))
    >>> simplify(_)
    True

    See Also
    ========

    sympy.logic.boolalg.Equivalent : for representing equality between two
        boolean expressions

    Notes
    =====

    This class is not the same as the == operator.  The == operator tests
    for exact structural equality between two expressions; this class
    compares expressions mathematically.

    If either object defines an `_eval_Eq` method, it can be used in place of
    the default algorithm.  If `lhs._eval_Eq(rhs)` or `rhs._eval_Eq(lhs)`
    returns anything other than None, that return value will be substituted for
    the Equality.  If None is returned by `_eval_Eq`, an Equality object will
    be created as usual.

    Since this object is already an expression, it does not respond to
    the method `as_expr` if one tries to create `x - y` from Eq(x, y).
    This can be done with the `rewrite(Add)` method.
    s   ==i    c         K  sÍ  d d l  m } d d l m } d d l m } d d l m } t | ƒ } t | ƒ } | j	 d t
 d ƒ } | r·t | d ƒ r¥ | j | ƒ }	 |	 d  k	 r¥ |	 Sn  t | d ƒ rÖ | j | ƒ }	 |	 d  k	 rÖ |	 Sn  | | k ré t j St d	 „  | | f Dƒ ƒ rt j S| j p| j rDt | t ƒ t | t ƒ k rDt j Sg  | | f D] }
 |
 j ^ qQ} \ } } d  | k r¹| | k rt j S| t k rç| | k r¯t j St j Sn. d  | k rçt | k rçt j |  | | |  St d
 „  | | f Dƒ ƒ r·| | } | j } | d  k	 rN| t k r>| j r>t j S| rNt j Sn  | | | ƒ } | d  k	 ryt | d k ƒ S| j ƒ  \ } } d  } | j r¦| j } nõ | j rp| j rÄt j } q›| j t k r›| j } | d  k rm| | t j ƒ \ } }	 g  | | f D] } | j | |	 ƒ ^ q} | | | g k rj| t  | Œ  ƒ } | t! k rgd  } qgqjqmq›n+ t" d „  | j# | ƒ Dƒ ƒ r›t j } n  | d  k	 r´t | ƒ Sq·n  t j |  | | |  S(   Niÿÿÿÿ(   R   (   t
   fuzzy_bool(   t   _n2(   t   clear_coefficientst   evaluatei    t   _eval_Eqc         s  s   |  ] } t  | t ƒ Vq d  S(   N(   R&   R   (   R   RJ   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pys	   <genexpr>˜  s    c         s  s   |  ] } t  | t ƒ Vq d  S(   N(   R&   R   (   R   RJ   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pys	   <genexpr>«  s    c         s  s   |  ] } | j  Vq d  S(   N(   t   is_infinite(   R   R4   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pys	   <genexpr>Ì  s    ($   t   sympy.core.addR   t   sympy.core.logicRw   t   sympy.core.exprRx   t   sympy.simplify.simplifyRy   R   Rk   R	   t   hasattrR{   R\   R   t   trueRN   t   falset	   is_SymbolR&   R
   t	   is_finiteRI   R   R$   t   is_zerot   is_commutativet   as_numer_denomt
   is_nonzeroR|   t   Infinityt   subsR   RK   t   anyt	   make_args(   R.   R/   R0   t   optionsR   Rw   Rx   Ry   Rz   R   RJ   t   fint   Lt   RRa   t   zt   n2R^   t   dR3   t   lRG   R)   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR$   €  s„    ,

	
				+c         C  s   t  | | k ƒ S(   N(   R   (   R.   R/   R0   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR`   Ô  s    c         O  sl   | \ } } | j  d t ƒ } | r, | | St j | ƒ t j | ƒ } | d k r_ t | Œ  St j | ƒ S(   sn  return Eq(L, R) as L - R. To control the evaluation of
        the result set pass `evaluate=True` to give L - R;
        if `evaluate=None` then terms in L and R will not cancel
        but they will be listed in canonical order; otherwise
        non-canonical args will be returned.

        Examples
        ========

        >>> from sympy import Eq, Add
        >>> from sympy.abc import b, x
        >>> eq = Eq(x + b, x - b)
        >>> eq.rewrite(Add)
        2*b
        >>> eq.rewrite(Add, evaluate=None).args
        (b, b, x, -x)
        >>> eq.rewrite(Add, evaluate=False).args
        (b, x, b, -x)
        Rz   N(   R7   RK   R   R   R\   R   t
   _from_args(   R6   R)   t   kwargsR   R‘   Rz   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   _eval_rewrite_as_AddØ  s    
c         C  sf   t  j |  j k s$ t  j |  j k r_ |  j j r@ t |  j g ƒ S|  j j r_ t |  j g ƒ Sn  t ƒ  S(   N(   R   R‚   R)   Rƒ   R/   R„   Ro   R0   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyRp   ø  s    $c         C  s  d d l  m } t t |  ƒ j | | | | ƒ } t | t ƒ sD | S|  j } t | ƒ d k ry™ | j ƒ  } | | j	 t
 d t ƒ| ƒ \ }	 }
 |	 j t k r» | j | |
 |	 ƒ } n | j |	 | |
 ƒ } | | ƒ | | | ƒ k r÷ | } n  Wqt k
 rqXn  | j S(   Niÿÿÿÿ(   t   linear_coeffsi   Rz   (   t   sympy.solvers.solvesetR™   t   superR   Rc   R&   Rh   Ri   Rk   t   rewriteR   RI   R†   R8   R-   R   (   R6   RV   RW   RX   RY   R™   RU   t   freeRm   t   mR:   t   enew(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyRc     s&    	!(   Rq   Rr   Rs   t   rel_opRt   RK   t   is_EqualityR$   t   classmethodR`   R˜   Ru   Rp   Rc   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR   E  s   4T	 	c           B  sJ   e  Z d  Z d Z g  Z d „  Z e d „  ƒ Z e d „  ƒ Z	 d „  Z
 RS(   s3  An unequal relation between two objects.

    Represents that two objects are not equal.  If they can be shown to be
    definitively equal, this will reduce to False; if definitively unequal,
    this will reduce to True.  Otherwise, the relation is maintained as an
    Unequality object.

    Examples
    ========

    >>> from sympy import Ne
    >>> from sympy.abc import x, y
    >>> Ne(y, x+x**2)
    Ne(y, x**2 + x)

    See Also
    ========
    Equality

    Notes
    =====
    This class is not the same as the != operator.  The != operator tests
    for exact structural equality between two expressions; this class
    compares expressions mathematically.

    This class is effectively the inverse of Equality.  As such, it uses the
    same algorithms, including any available `_eval_Eq` methods.

    s   !=c         K  sr   t  | ƒ } t  | ƒ } | j d t d ƒ } | r\ t | | ƒ } t | t ƒ r\ | j Sn  t j |  | | |  S(   NRz   i    (	   R   Rk   R	   R   R&   R   R=   R   R$   (   R.   R/   R0   RŽ   Rz   t   is_equal(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR$   >  s    
c         C  s   t  | | k ƒ S(   N(   R   (   R.   R/   R0   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR`   K  s    c         C  sf   t  j |  j k s$ t  j |  j k r_ |  j j r@ t |  j g ƒ S|  j j r_ t |  j g ƒ Sn  t ƒ  S(   N(   R   R‚   R)   Rƒ   R/   R„   Ro   R0   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyRp   O  s    $c         C  sG   t  |  j Œ  j | | | | ƒ } t | t  ƒ r@ |  j | j Œ  S| j S(   N(   R   R)   Rc   R&   R8   R=   (   R6   RV   RW   RX   RY   t   eq(    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyRc   X  s
    (   Rq   Rr   Rs   R    Rt   R$   R¢   R`   Ru   Rp   Rc   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR     s   		t   _Inequalityc           B  s   e  Z d  Z g  Z d „  Z RS(   s™   Internal base class for all *Than types.

    Each subclass must implement _eval_relation to provide the method for
    comparing two real numbers.

    c         K  so   t  | ƒ } t  | ƒ } | j d t d ƒ } | rY |  j | | ƒ } | d  k	 rY | Sn  t j |  | | |  S(   NRz   i    (   R   Rk   R	   R`   R\   R   R$   (   R.   R/   R0   RŽ   Rz   R   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR$   n  s    	(   Rq   Rr   Rs   Rt   R$   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR¥   e  s   t   _Greaterc           B  s2   e  Z d  Z d Z e d „  ƒ Z e d „  ƒ Z RS(   s   Not intended for general use

    _Greater is only used so that GreaterThan and StrictGreaterThan may
    subclass it for the .gts and .lts properties.

    c         C  s   |  j  d S(   Ni    (   R5   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   gts‘  s    c         C  s   |  j  d S(   Ni   (   R5   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   lts•  s    (    (   Rq   Rr   Rs   Rt   Ru   R§   R¨   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR¦   ˆ  s   t   _Lessc           B  s2   e  Z d  Z d Z e d „  ƒ Z e d „  ƒ Z RS(   s•   Not intended for general use.

    _Less is only used so that LessThan and StrictLessThan may subclass it for
    the .gts and .lts properties.

    c         C  s   |  j  d S(   Ni   (   R5   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR§   £  s    c         C  s   |  j  d S(   Ni    (   R5   (   R6   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR¨   §  s    (    (   Rq   Rr   Rs   Rt   Ru   R§   R¨   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR©   š  s   c           B  s)   e  Z d  Z d Z d Z e d „  ƒ Z RS(   sÆ  Class representations of inequalities.

    Extended Summary
    ================

    The ``*Than`` classes represent inequal relationships, where the left-hand
    side is generally bigger or smaller than the right-hand side.  For example,
    the GreaterThan class represents an inequal relationship where the
    left-hand side is at least as big as the right side, if not bigger.  In
    mathematical notation:

    lhs >= rhs

    In total, there are four ``*Than`` classes, to represent the four
    inequalities:

    +-----------------+--------+
    |Class Name       | Symbol |
    +=================+========+
    |GreaterThan      | (>=)   |
    +-----------------+--------+
    |LessThan         | (<=)   |
    +-----------------+--------+
    |StrictGreaterThan| (>)    |
    +-----------------+--------+
    |StrictLessThan   | (<)    |
    +-----------------+--------+

    All classes take two arguments, lhs and rhs.

    +----------------------------+-----------------+
    |Signature Example           | Math equivalent |
    +============================+=================+
    |GreaterThan(lhs, rhs)       |   lhs >= rhs    |
    +----------------------------+-----------------+
    |LessThan(lhs, rhs)          |   lhs <= rhs    |
    +----------------------------+-----------------+
    |StrictGreaterThan(lhs, rhs) |   lhs >  rhs    |
    +----------------------------+-----------------+
    |StrictLessThan(lhs, rhs)    |   lhs <  rhs    |
    +----------------------------+-----------------+

    In addition to the normal .lhs and .rhs of Relations, ``*Than`` inequality
    objects also have the .lts and .gts properties, which represent the "less
    than side" and "greater than side" of the operator.  Use of .lts and .gts
    in an algorithm rather than .lhs and .rhs as an assumption of inequality
    direction will make more explicit the intent of a certain section of code,
    and will make it similarly more robust to client code changes:

    >>> from sympy import GreaterThan, StrictGreaterThan
    >>> from sympy import LessThan,    StrictLessThan
    >>> from sympy import And, Ge, Gt, Le, Lt, Rel, S
    >>> from sympy.abc import x, y, z
    >>> from sympy.core.relational import Relational

    >>> e = GreaterThan(x, 1)
    >>> e
    x >= 1
    >>> '%s >= %s is the same as %s <= %s' % (e.gts, e.lts, e.lts, e.gts)
    'x >= 1 is the same as 1 <= x'

    Examples
    ========

    One generally does not instantiate these classes directly, but uses various
    convenience methods:

    >>> for f in [Ge, Gt, Le, Lt]:  # convenience wrappers
    ...     print(f(x, 2))
    x >= 2
    x > 2
    x <= 2
    x < 2

    Another option is to use the Python inequality operators (>=, >, <=, <)
    directly.  Their main advantage over the Ge, Gt, Le, and Lt counterparts,
    is that one can write a more "mathematical looking" statement rather than
    littering the math with oddball function calls.  However there are certain
    (minor) caveats of which to be aware (search for 'gotcha', below).

    >>> x >= 2
    x >= 2
    >>> _ == Ge(x, 2)
    True

    However, it is also perfectly valid to instantiate a ``*Than`` class less
    succinctly and less conveniently:

    >>> Rel(x, 1, ">")
    x > 1
    >>> Relational(x, 1, ">")
    x > 1

    >>> StrictGreaterThan(x, 1)
    x > 1
    >>> GreaterThan(x, 1)
    x >= 1
    >>> LessThan(x, 1)
    x <= 1
    >>> StrictLessThan(x, 1)
    x < 1

    Notes
    =====

    There are a couple of "gotchas" to be aware of when using Python's
    operators.

    The first is that what your write is not always what you get:

        >>> 1 < x
        x > 1

        Due to the order that Python parses a statement, it may
        not immediately find two objects comparable.  When "1 < x"
        is evaluated, Python recognizes that the number 1 is a native
        number and that x is *not*.  Because a native Python number does
        not know how to compare itself with a SymPy object
        Python will try the reflective operation, "x > 1" and that is the
        form that gets evaluated, hence returned.

        If the order of the statement is important (for visual output to
        the console, perhaps), one can work around this annoyance in a
        couple ways:

        (1) "sympify" the literal before comparison

        >>> S(1) < x
        1 < x

        (2) use one of the wrappers or less succinct methods described
        above

        >>> Lt(1, x)
        1 < x
        >>> Relational(1, x, "<")
        1 < x

    The second gotcha involves writing equality tests between relationals
    when one or both sides of the test involve a literal relational:

        >>> e = x < 1; e
        x < 1
        >>> e == e  # neither side is a literal
        True
        >>> e == x < 1  # expecting True, too
        False
        >>> e != x < 1  # expecting False
        x < 1
        >>> x < 1 != x < 1  # expecting False or the same thing as before
        Traceback (most recent call last):
        ...
        TypeError: cannot determine truth value of Relational

        The solution for this case is to wrap literal relationals in
        parentheses:

        >>> e == (x < 1)
        True
        >>> e != (x < 1)
        False
        >>> (x < 1) != (x < 1)
        False

    The third gotcha involves chained inequalities not involving
    '==' or '!='. Occasionally, one may be tempted to write:

        >>> e = x < y < z
        Traceback (most recent call last):
        ...
        TypeError: symbolic boolean expression has no truth value.

        Due to an implementation detail or decision of Python [1]_,
        there is no way for SymPy to create a chained inequality with
        that syntax so one must use And:

        >>> e = And(x < y, y < z)
        >>> type( e )
        And
        >>> e
        (x < y) & (y < z)

        Although this can also be done with the '&' operator, it cannot
        be done with the 'and' operarator:

        >>> (x < y) & (y < z)
        (x < y) & (y < z)
        >>> (x < y) and (y < z)
        Traceback (most recent call last):
        ...
        TypeError: cannot determine truth value of Relational

    .. [1] This implementation detail is that Python provides no reliable
       method to determine that a chained inequality is being built.
       Chained comparison operators are evaluated pairwise, using "and"
       logic (see
       http://docs.python.org/2/reference/expressions.html#notin). This
       is done in an efficient way, so that each object being compared
       is only evaluated once and the comparison can short-circuit. For
       example, ``1 > 2 > 3`` is evaluated by Python as ``(1 > 2) and (2
       > 3)``. The ``and`` operator coerces each side into a bool,
       returning the object itself when it short-circuits. The bool of
       the --Than operators will raise TypeError on purpose, because
       SymPy cannot determine the mathematical ordering of symbolic
       expressions. Thus, if we were to compute ``x > y > z``, with
       ``x``, ``y``, and ``z`` being Symbols, Python converts the
       statement (roughly) into these steps:

        (1) x > y > z
        (2) (x > y) and (y > z)
        (3) (GreaterThanObject) and (y > z)
        (4) (GreaterThanObject.__nonzero__()) and (y > z)
        (5) TypeError

       Because of the "and" added at step 2, the statement gets turned into a
       weak ternary statement, and the first object's __nonzero__ method will
       raise TypeError.  Thus, creating a chained inequality is not possible.

           In Python, there is no way to override the ``and`` operator, or to
           control how it short circuits, so it is impossible to make something
           like ``x > y > z`` work.  There was a PEP to change this,
           :pep:`335`, but it was officially closed in March, 2012.

    s   >=c         C  s   t  | j | ƒ ƒ S(   N(   R   t   __ge__(   R.   R/   R0   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR`   ‘  s    (    (   Rq   Rr   Rs   Rt   R    R¢   R`   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR   ¬  s   àc           B  s,   e  Z e j Z d Z d  Z e d „  ƒ Z RS(   s   <=c         C  s   t  | j | ƒ ƒ S(   N(   R   t   __le__(   R.   R/   R0   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR`      s    (    (   Rq   Rr   R   Rs   Rt   R    R¢   R`   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR   š  s   	c           B  s,   e  Z e j Z d Z d  Z e d „  ƒ Z RS(   t   >c         C  s   t  | j | ƒ ƒ S(   N(   R   t   __gt__(   R.   R/   R0   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR`   ¯  s    (    (   Rq   Rr   R   Rs   Rt   R    R¢   R`   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR   ©  s   	c           B  s,   e  Z e j Z d Z d  Z e d „  ƒ Z RS(   t   <c         C  s   t  | j | ƒ ƒ S(   N(   R   t   __lt__(   R.   R/   R0   (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR`   ¾  s    (    (   Rq   Rr   R   Rs   Rt   R    R¢   R`   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyR   ¸  s   	s   ==R¤   s   !=s   <>t   nes   >=t   ges   <=t   leR¬   t   gtR®   t   ltN(*   t
   __future__R    R   t   addR   R   t   basicR   t   compatibilityR   t   exprR   t   evalfR   t   sympifyR   Rz   R	   R(   R
   R   t   __all__R!   R   R   R   R   R   R   R¥   R¦   R©   R   R   R   R   R   R   R   R   R\   R%   (    (    (    s4   lib/python2.7/site-packages/sympy/core/relational.pyt   <module>   sZ   	ÿ $ÔF#ë