ó
”¼\c           @  s£  d  d l  m Z m Z d  d l m Z d  d l m Z m Z m Z 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	 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 Z d  d l Z  d  d l! Z! d d  Z# d e$ d d  Z% d e e f d     YZ& d e& f d     YZ' d e& f d     YZ( e  j) d  Z* d   Z+ d   Z, d   Z- d S(   i’’’’(   t   print_functiont   division(   t	   StdFactKB(   t   string_typest   ranget   is_sequencet   orderedi   (   t   Basic(   t   sympify(   t   S(   t   Exprt
   AtomicExpr(   t   cacheit(   t   FunctionClass(   t
   fuzzy_bool(   t   Boolean(   t   cartes(   t   TupleNc         K  sX   t  |  t  r5 | r( | j |  k r( | St |  |  St  |  t  rH |  St d   d S(   sż  Return s if s is a Symbol, else if s is a string, return either
    the matching_symbol if the names are the same or else a new symbol
    with the same assumptions as the matching symbol (or the
    assumptions as provided).

    Examples
    ========

    >>> from sympy import Symbol, Dummy
    >>> from sympy.core.symbol import _symbol
    >>> _symbol('y')
    y
    >>> _.is_real is None
    True
    >>> _symbol('y', real=True).is_real
    True

    >>> x = Symbol('x')
    >>> _symbol(x, real=True)
    x
    >>> _.is_real is None  # ignore attribute if s is a Symbol
    True

    Below, the variable sym has the name 'foo':

    >>> sym = Symbol('foo', real=True)

    Since 'x' is not the same as sym's name, a new symbol is created:

    >>> _symbol('x', sym).name
    'x'

    It will acquire any assumptions give:

    >>> _symbol('x', sym, real=False).is_real
    False

    Since 'foo' is the same as sym's name, sym is returned

    >>> _symbol('foo', sym)
    foo

    Any assumptions given are ignored:

    >>> _symbol('foo', sym, real=False).is_real
    True

    NB: the symbol here may not be the same as a symbol with the same
    name defined elsewhere as a result of different assumptions.

    See Also
    ========

    sympy.core.symbol.Symbol

    s/   symbol must be string for symbol name or SymbolN(   t
   isinstanceR   t   namet   Symbolt
   ValueError(   t   st   matching_symbolt   assumptions(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   _symbol   s    9c           sŻ   d } t |   r! |  \ }  } n  t |    | sC t  | |  St |  s[ | g } n  t   j g  | D] } | j ^ qk   } | d k r d   } n  x/ t    f d   | D  rĢ |    q Wt  | |  S(   sø  Return a symbol which, when printed, will have a name unique
    from any other already in the expressions given. The name is made
    unique by prepending underscores (default) but this can be
    customized with the keyword 'modify'.

    Parameters
    ==========

        xname : a string or a Symbol (when symbol xname <- str(xname))
        compare : a single arg function that takes a symbol and returns
            a string to be compared with xname (the default is the str
            function which indicates how the name will look when it
            is printed, e.g. this includes underscores that appear on
            Dummy symbols)
        modify : a single arg function that changes its string argument
            in some way (the default is to preppend underscores)

    Examples
    ========

    >>> from sympy.core.symbol import _uniquely_named_symbol as usym, Dummy
    >>> from sympy.abc import x
    >>> usym('x', x)
    _x
    c         S  s   d |  S(   Nt   _(    (   R   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   <lambda>}   t    c         3  s!   |  ] }    |  k Vq d  S(   N(    (   t   .0R   (   t   comparet   x(    s0   lib/python2.7/site-packages/sympy/core/symbol.pys	   <genexpr>~   s    N(   t   NoneR   t   strR   t   sett   uniont   free_symbolst   any(   t   xnamet   exprsR   t   modifyR   t   defaultt   et   syms(    (   R   R   s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   _uniquely_named_symbolY   s    ("R   c           B  s  e  Z d  Z e Z d g Z e Z e Z e	 d    Z
 e d d   Z d   Z d   Z e e  Z e e e   Z d   Z d   Z d   Z d	   Z e	 d
    Z e d d   Z d   Z e d  Z d   Z d   Z e	 d    Z e Z d   Z RS(   sC  
    Assumptions:
       commutative = True

    You can override the default assumptions in the constructor:

    >>> from sympy import symbols
    >>> A,B = symbols('A,B', commutative = False)
    >>> bool(A*B != B*A)
    True
    >>> bool(A*B*2 == 2*A*B) == True # multiplication by scalars is commutative
    True

    R   c         C  s   t  S(   sĮ   Allow derivatives wrt Symbols.

        Examples
        ========

            >>> from sympy import Symbol
            >>> x = Symbol('x')
            >>> x._diff_wrt
            True
        (   t   True(   t   self(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt	   _diff_wrt   s    c   	   
   C  sb  t  |  j d t   } | d k rP | r7 d | j n d } t d |   n  xt |  j    D]÷ } d d l m	 } d d l
 m } | d    } | j i d	 d
 6d d 6d d 6 | | r!| d d | d d | | d d d d  j   |  | |  | | <|  j |  | | } n  |  | } | d k rJ|  j |  qc n  t |  |  | <qc Wd S(   sL   Remove None, covert values to bool, check commutativity *in place*.
        t   commutatives   %s R   s&   %scommutativity must be True or False.i’’’’(   t   defaultdict(   t   SymPyDeprecationWarningc           S  s   d  S(   N(   R    (    (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR   ø   R   t   finitet   boundedt   infinitet	   unboundedt   zerot   infinitesimalt   features   %s assumptiont
   useinsteads   %st   issuei  t   deprecated_since_versions   0.7.6N(   R   t   getR-   R    t   __name__R   t   listt   keyst   collectionsR1   t   sympy.utilities.exceptionsR2   t   updatet   warnt   popt   bool(	   R   t   objt   is_commutativet   whoset   keyR1   R2   t   keymapt   v(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt	   _sanitizeØ   s0    "


c         K  s#   |  j  | |   t j |  | |  S(   są   Symbols are identified by name and assumptions::

        >>> from sympy import Symbol
        >>> Symbol("x") == Symbol("x")
        True
        >>> Symbol("x", real=True) == Symbol("x", real=False)
        False

        (   RM   R   t   _Symbol__xnew_cached_(   t   clsR   R   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   __new__Ź   s    
c         K  s   t  | t  s. t d t t |     n  t j |   } | | _ | j   } t	 | j
 d t   } | | d <t |  | _ | | j _ | S(   Ns   name should be a string, not %sR0   (   R   R   t	   TypeErrort   reprt   typeR
   RP   R   t   copyR   R=   R-   R   t   _assumptionst
   _generator(   RO   R   R   RG   t   tmp_asm_copyRH   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   __new_stage2__×   s    	

c         C  s
   |  j  f S(   N(   R   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   __getnewargs__ō   s    c         C  s   i |  j  d 6S(   NRU   (   RU   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   __getstate__÷   s    c         C  s#   |  j  f t t |  j j     S(   N(   R   t   tuplet   sortedt   assumptions0t   items(   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   _hashable_contentś   s    c         C  s?   d d l  m } | j r; | |  t j d t j | |  Sd  S(   Ni’’’’(   t   Powt   evaluate(   t   sympy.core.powerR`   t   is_PowR	   t   Onet   Falset
   _eval_subs(   R.   t   oldt   newR`   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRf   ž   s    	c         C  s   t  d   |  j j   D  S(   Nc         s  s-   |  ]# \ } } | d  k	 r | | f Vq d  S(   N(   R    (   R   RJ   t   value(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pys	   <genexpr>  s    	(   t   dictRU   R^   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR]     s    	c         C  s1   |  j    d t |   f f t j j   t j f S(   Ni   (   t	   class_keyR!   R	   Rd   t   sort_key(   R.   t   order(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRl     s    c         C  s   t  |  j  S(   N(   t   DummyR   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   as_dummy  s    c         K  sI   d d l  m } m } | j d  |  k r/ d  S| |   | |   f Sd  S(   Ni’’’’(   t   imt   ret   ignore(   t   sympyRp   Rq   R=   R    (   R.   t   deept   hintsRp   Rq   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   as_real_imag  s    c         C  s   d d  l  j } | j |  j  S(   Ni’’’’(   t   sage.allt   allt   varR   (   R.   t   sage(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   _sage_  s    c         O  s   | s
 t  S|  | k S(   N(   Re   (   R.   t   wrtt   flags(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   is_constant  s    c         C  s   |  h S(   N(    (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR$     s    c         C  s   t  j S(   N(   R	   t   UniversalSet(   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   as_set%  s    N(    R>   t
   __module__t   __doc__Re   t   is_comparablet	   __slots__R-   t	   is_Symbolt	   is_symbolt   propertyR/   t   staticmethodR    RM   RP   RX   t   __xnew__R   RN   RY   RZ   R_   Rf   R]   Rl   Ro   Rv   R{   R~   R$   t   binary_symbolsR   (    (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR      s8   	!										Rn   c           B  sx   e  Z d  Z d Z e j   Z e j d
 d d  Z d g Z	 e
 Z d d d  Z d   Z e d d   Z d	   Z RS(   s  Dummy symbols are each unique, even if they have the same name:

    >>> from sympy import Dummy
    >>> Dummy("x") == Dummy("x")
    False

    If a name is not supplied then a string value of an internal count will be
    used. This is useful when a temporary variable is needed and the name
    of the variable used in the expression is not important.

    >>> Dummy() #doctest: +SKIP
    _Dummy_10

    i    i
   i   i	   t   dummy_indexc         K  s©   | d  k	 r' | d  k	 s' t d   n  | d  k rI d t t j  } n  | d  k rw t j t j } t j d 7_ n  |  j | |   t j |  | |  } | | _	 | S(   Ns:   If you specify a dummy_index, you must also provide a namet   Dummy_i   (
   R    t   AssertionErrorR!   Rn   t   _countt   _base_dummy_indexRM   R   R   R   (   RO   R   R   R   RG   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRP   L  s    	c         C  s   i |  j  d 6|  j d 6S(   NRU   R   (   RU   R   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRZ   ^  s    c         C  s7   |  j    d t |   |  j f f t j j   t j f S(   Ni   (   Rk   R!   R   R	   Rd   Rl   (   R.   Rm   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRl   a  s    	c         C  s   t  j |   |  j f S(   N(   R   R_   R   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR_   f  s    i@B i@B N(   R>   R   R   R   t   randomt   Randomt   _prngt   randintR   R   R-   t   is_DummyR    RP   RZ   R   Rl   R_   (    (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRn   )  s   		t   Wildc           B  se   e  Z d  Z e Z d d g Z d d	 d  Z d   Z e e	 d     Z
 d   Z i  e d  Z RS(
   s	  
    A Wild symbol matches anything, or anything
    without whatever is explicitly excluded.

    Parameters
    ==========

    name : str
        Name of the Wild instance.
    exclude : iterable, optional
        Instances in ``exclude`` will not be matched.
    properties : iterable of functions, optional
        Functions, each taking an expressions as input
        and returns a ``bool``. All functions in ``properties``
        need to return ``True`` in order for the Wild instance
        to match the expression.

    Examples
    ========

    >>> from sympy import Wild, WildFunction, cos, pi
    >>> from sympy.abc import x, y, z
    >>> a = Wild('a')
    >>> x.match(a)
    {a_: x}
    >>> pi.match(a)
    {a_: pi}
    >>> (3*x**2).match(a*x)
    {a_: 3*x}
    >>> cos(x).match(a)
    {a_: cos(x)}
    >>> b = Wild('b', exclude=[x])
    >>> (3*x**2).match(b*x)
    >>> b.match(a)
    {a_: b_}
    >>> A = WildFunction('A')
    >>> A.match(a)
    {a_: A_}

    Tips
    ====

    When using Wild, be sure to use the exclude
    keyword to make the pattern more precise.
    Without the exclude pattern, you may get matches
    that are technically correct, but not what you
    wanted. For example, using the above without
    exclude:

    >>> from sympy import symbols
    >>> a, b = symbols('a b', cls=Wild)
    >>> (2 + 3*y).match(a*x + b*y)
    {a_: 2/x, b_: 3}

    This is technically correct, because
    (2/x)*x + 3*y == 2 + 3*y, but you probably
    wanted it to not match at all. The issue is that
    you really didn't want a and b to include x and y,
    and the exclude parameter lets you specify exactly
    this.  With the exclude parameter, the pattern will
    not match.

    >>> a = Wild('a', exclude=[x, y])
    >>> b = Wild('b', exclude=[x, y])
    >>> (2 + 3*y).match(a*x + b*y)

    Exclude also helps remove ambiguity from matches.

    >>> E = 2*x**3*y*z
    >>> a, b = symbols('a b', cls=Wild)
    >>> E.match(a*b)
    {a_: 2*y*z, b_: x**3}
    >>> a = Wild('a', exclude=[x, y])
    >>> E.match(a*b)
    {a_: z, b_: 2*x**3*y}
    >>> a = Wild('a', exclude=[x, y, z])
    >>> E.match(a*b)
    {a_: 2, b_: x**3*y*z}

    Wild also accepts a ``properties`` parameter:

    >>> a = Wild('a', properties=[lambda k: k.is_Integer])
    >>> E.match(a*b)
    {a_: 2, b_: x**3*y*z}

    t   excludet
   propertiesc         K  sZ   t  g  | D] } t |  ^ q
  } t  |  } |  j | |   t j |  | | | |  S(   N(   R[   R   RM   R   R   (   RO   R   R   R   R   R   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRP   Å  s    %c         C  s   |  j  |  j |  j f S(   N(   R   R   R   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRY   Ė  s    c         K  s+   t  j |  | |  } | | _ | | _ | S(   N(   R   R   R   R   (   RO   R   R   R   R   RG   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR   Ī  s    		c         C  s#   t  t |   j   |  j |  j f S(   N(   t   superR   R_   R   R   (   R.   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR_   Ö  s    c           s`   t    f d   |  j D  r# d  St    f d   |  j D  rF d  S| j   }   | |  <| S(   Nc         3  s   |  ] }   j  |  Vq d  S(   N(   t   has(   R   R   (   t   expr(    s0   lib/python2.7/site-packages/sympy/core/symbol.pys	   <genexpr>Ū  s    c         3  s   |  ] } |    Vq d  S(   N(    (   R   t   f(   R   (    s0   lib/python2.7/site-packages/sympy/core/symbol.pys	   <genexpr>Ż  s    (   R%   R   R    R   RT   (   R.   R   t	   repl_dictRg   (    (   R   s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   matchesŚ  s    
(    (    (   R>   R   R   R-   t   is_WildR   RP   RY   R   R   R   R_   Re   R   (    (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR   j  s   V		s"   ([0-9]*:[0-9]+|[a-zA-Z]?:[a-zA-Z])c           s>  g  } t  |  t  rd } d d d g   x t t     D] }   j d  } | |  k r= x  t |  |  k r | d 7} qa Wt |  } | d 7} |  j | |  }    j | | d f  q= q= W  f d   } |  j   }  |  j	 d  } | r
|  d  j
   }  n  |  st d	   n  g  |  j d  D] }	 |	 j   ^ q/}  t d
   |  D  slt d   n  x? t t |   d d d  D]! } |  | j   |  | | d +qW| j d t  }
 | j d |  } xł|  D]ń} | sōt d   n  d | k r(|
 | |  |  } | j |  qŁn  t j |  } x© t t |  d  D] } | rNd | | k rN| | d k rN| | d j	 d  rN| | d j d  rN| | d d  | | d <| | d d | | d <qNqNWxät |  D](\ } } d | k r| d j	 d  r*t d   n  | j d  \ } } | d t j k r„| s^d n	 t |  } t |  } g  t | |  D] } t |  ^ q| | <nU | p®d } g  t t j j |  t j j |  d  D] } t j | ^ qŻ| | <| | sPqqš| g | | <qšWt } t |  d k rA| d }  n( g  t |   D] } d j |  ^ qN}    r”| j g  |  D] } |
 | |  |  ^ q| qŁ| j g  |  D] } |
 | |  ^ q® qŁW| rłt |  d k rł| sńd S| d St |  Sx$ |  D] } | j t | |   q
Wt |   |  Sd S(   s1  
    Transform strings into instances of :class:`Symbol` class.

    :func:`symbols` function returns a sequence of symbols with names taken
    from ``names`` argument, which can be a comma or whitespace delimited
    string, or a sequence of strings::

        >>> from sympy import symbols, Function

        >>> x, y, z = symbols('x,y,z')
        >>> a, b, c = symbols('a b c')

    The type of output is dependent on the properties of input arguments::

        >>> symbols('x')
        x
        >>> symbols('x,')
        (x,)
        >>> symbols('x,y')
        (x, y)
        >>> symbols(('a', 'b', 'c'))
        (a, b, c)
        >>> symbols(['a', 'b', 'c'])
        [a, b, c]
        >>> symbols({'a', 'b', 'c'})
        {a, b, c}

    If an iterable container is needed for a single symbol, set the ``seq``
    argument to ``True`` or terminate the symbol name with a comma::

        >>> symbols('x', seq=True)
        (x,)

    To reduce typing, range syntax is supported to create indexed symbols.
    Ranges are indicated by a colon and the type of range is determined by
    the character to the right of the colon. If the character is a digit
    then all contiguous digits to the left are taken as the nonnegative
    starting value (or 0 if there is no digit left of the colon) and all
    contiguous digits to the right are taken as 1 greater than the ending
    value::

        >>> symbols('x:10')
        (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9)

        >>> symbols('x5:10')
        (x5, x6, x7, x8, x9)
        >>> symbols('x5(:2)')
        (x50, x51)

        >>> symbols('x5:10,y:5')
        (x5, x6, x7, x8, x9, y0, y1, y2, y3, y4)

        >>> symbols(('x5:10', 'y:5'))
        ((x5, x6, x7, x8, x9), (y0, y1, y2, y3, y4))

    If the character to the right of the colon is a letter, then the single
    letter to the left (or 'a' if there is none) is taken as the start
    and all characters in the lexicographic range *through* the letter to
    the right are used as the range::

        >>> symbols('x:z')
        (x, y, z)
        >>> symbols('x:c')  # null range
        ()
        >>> symbols('x(:c)')
        (xa, xb, xc)

        >>> symbols(':c')
        (a, b, c)

        >>> symbols('a:d, x:z')
        (a, b, c, d, x, y, z)

        >>> symbols(('a:d', 'x:z'))
        ((a, b, c, d), (x, y, z))

    Multiple ranges are supported; contiguous numerical ranges should be
    separated by parentheses to disambiguate the ending number of one
    range from the starting number of the next::

        >>> symbols('x:2(1:3)')
        (x01, x02, x11, x12)
        >>> symbols(':3:2')  # parsing is from left to right
        (00, 01, 10, 11, 20, 21)

    Only one pair of parentheses surrounding ranges are removed, so to
    include parentheses around ranges, double them. And to include spaces,
    commas, or colons, escape them with a backslash::

        >>> symbols('x((a:b))')
        (x(a), x(b))
        >>> symbols(r'x(:1\,:2)')  # or r'x((:1)\,(:2))'
        (x(0,0), x(0,1))

    All newly created symbols have assumptions set according to ``args``::

        >>> a = symbols('a', integer=True)
        >>> a.is_integer
        True

        >>> x, y, z = symbols('x,y,z', real=True)
        >>> x.is_real and y.is_real and z.is_real
        True

    Despite its name, :func:`symbols` can create symbol-like objects like
    instances of Function or Wild classes. To achieve this, set ``cls``
    keyword argument to the desired type::

        >>> symbols('f,g,h', cls=Function)
        (f, g, h)

        >>> type(_[0])
        <class 'sympy.core.function.UndefinedFunction'>

    i    s   \,s   \:s   \ i   c           s6     r2 x)   D] \ } } |  j  | |  }  q Wn  |  S(   N(   t   replace(   R   t   ct   l(   t   literals(    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   literalh  s    t   ,i’’’’s   no symbols givenc         s  s   |  ] } | Vq d  S(   N(    (   R   t   n(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pys	   <genexpr>w  s    s   missing symbol between commasRO   t   seqs   missing symbolt   :t   (t   )s   missing end ranget   aR   N(    (   R   R   R   t   lenRE   t   chrR   t   appendt   stript   endswitht   rstripR   t   splitRx   R   t   _ranget
   startswitht	   enumeratet   stringt   digitst   intR!   t   ascii_letterst   indexR-   R   t   joint   extendR[   t   symbolsRS   (   t   namest   argst   resultt   markert   it   litt   lit_charR£   t   as_seqR„   RO   R¦   R   t   symbolR±   R   RŖ   t   bR    (    (   R¢   s0   lib/python2.7/site-packages/sympy/core/symbol.pyR¼   ę  s    t
(#&!/4
(2-
c           s©     f d     d d l  m } |   j } zs t |  |  } | d k	 r t | t  rk | | j | j <q t | t	  r | | j | j
 <q   | |  n  Wd ~ X| S(   s}  
    Create symbols and inject them into the global namespace.

    This calls :func:`symbols` with the same arguments and puts the results
    into the *global* namespace. It's recommended not to use :func:`var` in
    library code, where :func:`symbols` has to be used::

    Examples
    ========

    >>> from sympy import var

    >>> var('x')
    x
    >>> x
    x

    >>> var('a,ab,abc')
    (a, ab, abc)
    >>> abc
    abc

    >>> var('x,y', real=True)
    (x, y)
    >>> x.is_real and y.is_real
    True

    See :func:`symbol` documentation for more details on what kinds of
    arguments can be passed to :func:`var`.

    c           sf   x_ |  D]W } t  | t  r/ | | j | j <q t  | t  rQ | | j | j <q   | |  q Wd S(   s4   Recursively inject symbols to the global namespace. N(   R   R   t	   f_globalsR   R   R>   (   R¼   t   frameRÅ   (   t   traverse(    s0   lib/python2.7/site-packages/sympy/core/symbol.pyRÉ   Ū  s    i’’’’(   t   currentframeN(   t   inspectRŹ   t   f_backR¼   R    R   R   RĒ   R   R   R>   (   R½   R¾   RŹ   RČ   R+   (    (   RÉ   s0   lib/python2.7/site-packages/sympy/core/symbol.pyRy   »  s     
c          G  sU  t  |    } d   } t | j d | } i  } x6 | D]. } | j t |  j d  g   j |  q7 Wi  } xÖ | D]Ī } t d | | | d j  } | | k r» | | | | d <n  d }	 x t	 d t
 | |   D]e }
 x8 t rd | |
 |	 f } | | k rPn  |	 d 7}	 qä W| | |
 } t | | j  | | <qŪ Wqv W| j |  S(   sę  
    Return a Tuple containing the passed expressions with symbols
    that appear the same when printed replaced with numerically
    subscripted symbols, and all Dummy symbols replaced with Symbols.

    Parameters
    ==========

    iter: list of symbols or expressions.

    Examples
    ========

    >>> from sympy.core.symbol import disambiguate
    >>> from sympy import Dummy, Symbol, Tuple
    >>> from sympy.abc import y

    >>> tup = Symbol('_x'), Dummy('x'), Dummy('x')
    >>> disambiguate(*tup)
    (x_2, x, x_1)

    >>> eqs = Tuple(Symbol('x')/y, Dummy('x')/y)
    >>> disambiguate(*eqs)
    (x_1/y, x/y)

    >>> ix = Symbol('x', integer=True)
    >>> vx = Symbol('x')
    >>> disambiguate(vx + ix)
    (x + x_1,)

    To make your own mapping of symbols to use, pass only the free symbols
    of the expressions and create a dictionary:

    >>> free = eqs.free_symbols
    >>> mapping = dict(zip(free, disambiguate(*free)))
    >>> eqs.xreplace(mapping)
    (x_1/y, x/y)

    c         S  s   t  t |  j j     S(   N(   R[   R\   R]   R^   (   R   (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyR      R   R@   R   s   %si    i   s   %s_%i(   R   R   R$   t
   setdefaultR!   t   lstripR­   R   R]   R   R«   R-   t   xreplace(   t   itert   new_iterRJ   R+   t   mappingR   t   repst   kt   k0t   skipRĮ   R   t   ki(    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   disambiguate÷  s*    (	, 	(    (.   t
   __future__R    R   t   sympy.core.assumptionsR   t   sympy.core.compatibilityR   R   R   R   t   basicR   R   t	   singletonR	   R   R
   R   t   cacheR   t   functionR   t   sympy.core.logicR   t   sympy.logic.boolalgR   t   sympy.utilities.iterablesR   t   sympy.core.containersR   Rµ   Rq   t   _reR   R    R   R!   R,   R   Rn   R   t   compileR²   R¼   Ry   RŲ   (    (    (    s0   lib/python2.7/site-packages/sympy/core/symbol.pyt   <module>   s0   "C*¦Az	Õ	<