
    \h|t                       S SK Jr  SSKJrJr  SSKJrJr  SSKJ	r	  SSK
Jr  SSKJrJr  SSKJrJr  SS	KJrJr  SS
KJr  SSKJr  SSKJr  SSKJr  S SKJr  S SKJrJ r   S SK!J"r"  S SK#r#S SK$r%S SK&r&S SK'J(r(  S SK)J*r*   " S S\5      r+S r,S%S jr-S\.S4S jr/\/r0 " S S\\5      r1 " S S\15      r2 " S S\15      r3\%Rh                  " S 5      r5\1S!.S&S" jjr6S# r7S$ r8g)'    )annotations   )	StdFactKB_assume_defined)BasicAtom)cacheit)Tuple)Expr
AtomicExpr)AppliedUndefFunctionClass)
NumberKindUndefinedKind)
fuzzy_bool)S)ordered)sympify)Boolean)siftis_sequence)
filldedentN)product)Anyc                  .    \ rS rSrSrSrS rS rS rSr	g)	Str   a  
Represents string in SymPy.

Explanation
===========

Previously, ``Symbol`` was used where string is needed in ``args`` of SymPy
objects, e.g. denoting the name of the instance. However, since ``Symbol``
represents mathematical scalar, this class should be used instead.

namec                    [        U[        5      (       d   [        S[        [	        U5      5      -  5      e[
        R                  " U 40 UD6nXl        U$ )Nname should be a string, not %s)
isinstancestr	TypeErrorreprtyper   __new__r   )clsr   kwargsobjs       I/var/www/auris/envauris/lib/python3.13/site-packages/sympy/core/symbol.pyr'   Str.__new__(   sF    $$$=T$Z@PPQQll3)&)
    c                    U R                   4$ Nr   selfs    r+   __getnewargs__Str.__getnewargs__/       		|r-   c                    U R                   4$ r/   r   r0   s    r+   _hashable_contentStr._hashable_content2   r4   r-    N)
__name__
__module____qualname____firstlineno____doc__	__slots__r'   r2   r6   __static_attributes__r8   r-   r+   r   r      s    
 Ir-   r   c           	         [        [        [        U R                  5       S SS95      u  p[        R                  U5        X4$ )zSplit the given dict into assumptions and non-assumptions.
Keys are taken as assumptions if they correspond to an
entry in ``_assume_defined``.
c                    U S   [         ;   $ )Nr   )r   )is    r+   <lambda>%_filter_assumptions.<locals>.<lambda><   s    !A$/)r-   T)binary)mapdictr   itemsSymbol	_sanitize)r)   assumptionsnonassumptionss      r+   _filter_assumptionsrM   6   sA    
 #&dD)- #K [!&&r-   c                    [        U [        5      (       a%  U(       a  UR                  U :X  a  U$ [        U 40 UD6$ [        U [        5      (       a  U $ [	        S5      e)a^  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
>>> 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

z/symbol must be string for symbol name or Symbol)r"   r#   r   rI   
ValueError)smatching_symbolrK   s      r+   _symbolrR   A   sV    r !S33q8""a';''	Av		JKKr-   r8   c           
       ^^
 SS jnSn[        U 5      (       a  U u  pT" U 5      m
U(       d  [        T
U40 UD6$ [        U5      (       d  U/n[        5       R                  U VVs/ s H*  owR	                  [
        5        H  oR                  PM     M,     snnU VVs/ s H4  owR	                  [        5        H  oR                  R                  PM     M6     snn-   5      n	Uc  Un[        UU
4S jU	 5       5      (       a%  U" T
5      m
[        UU
4S jU	 5       5      (       a  M%  [        T
U40 UD6$ s  snnf s  snnf )a  
Return a symbol whose name is derivated from *xname* but is unique
from any other symbols in *exprs*.

*xname* and symbol names in *exprs* are passed to *compare* to be
converted to comparable forms. If ``compare(xname)`` is not unique,
it is recursively passed to *modify* until unique name is acquired.

Parameters
==========

xname : str or Symbol
    Base name for the new symbol.

exprs : Expr or iterable of Expr
    Expressions whose symbols are compared to *xname*.

compare : function
    Unary function which transforms *xname* and symbol names from
    *exprs* to comparable form.

modify : function
    Unary function which modifies the string. Default is appending
    the number, or increasing the number if exists.

Examples
========

By default, a number is appended to *xname* to generate unique name.
If the number already exists, it is recursively increased.

>>> from sympy.core.symbol import uniquely_named_symbol, Symbol
>>> uniquely_named_symbol('x', Symbol('x'))
x0
>>> uniquely_named_symbol('x', (Symbol('x'), Symbol('x0')))
x1
>>> uniquely_named_symbol('x0', (Symbol('x1'), Symbol('x0')))
x2

Name generation can be controlled by passing *modify* parameter.

>>> from sympy.abc import x
>>> uniquely_named_symbol('x', x, modify=lambda s: 2*s)
xx

c                    U (       d  [        U5      $ [        U 5      S-
  nUS:w  a%  X   R                  5       (       d  OUS-  nUS:w  a  M%  [        [        XS-   S  =(       d    US-
  5      S-   5      nU S US-    U-   $ )Nr   )r#   lenisdigitint)rP   startrB   ns       r+   numbered_string_incr3uniquely_named_symbol.<locals>.numbered_string_incr   s    u:FQJ2g4<<>>FA 2g A!efI*+a/0!a%y1}r-   Nc              3  :   >#    U  H  nTT" U5      :H  v   M     g 7fr/   r8   ).0rP   comparexs     r+   	<genexpr>(uniquely_named_symbol.<locals>.<genexpr>   s     -u!a71:ous   )r   )
r   rR   setunionatomsrI   r   r   funcany)xnameexprsr_   modifyrK   r[   defaulterB   namesr`   s     `       @r+   uniquely_named_symbolrn      s   ^	 G5Aq'1[11uEKK8A18#CeWW\-B-BeC	DEE ~%
-u-
-
-1I -u-
-
-1g--- 	9Cs   %1D5
;D;c                  *   \ rS rSr% SrSrSrS\S'   SrSr	\
S 5       r\
S	 5       r\SS j5       rS rS r\\S 5       5       r\S 5       r\\S 5       5       rS rS rS rS rS r\
S 5       r\SS j5       rS rSS jrS r\
S 5       r\r S r!Sr"g
) rI      ux  
Symbol class is used to create symbolic variables.

Explanation
===========

Symbolic variables are placeholders for mathematical symbols that can represent numbers, constants, or any other mathematical entities and can be used in mathematical expressions and to perform symbolic computations.

Assumptions:

commutative = True
positive = True
real = True
imaginary = True
complex = True
complete list of more assumptions- :ref:`predicates`

You can override the default assumptions in the constructor.

Examples
========

>>> from sympy import Symbol
>>> x = Symbol("x", positive=True)
>>> x.is_positive
True
>>> x.is_negative
False

passing in greek letters:

>>> from sympy import Symbol
>>> alpha = Symbol('alpha')
>>> alpha #doctest: +SKIP
α

Trailing digits are automatically treated like subscripts of what precedes them in the name.
General format to add subscript to a symbol :
``<var_name> = Symbol('<symbol_name>_<subscript>')``

>>> from sympy import Symbol
>>> alpha_i = Symbol('alpha_i')
>>> alpha_i #doctest: +SKIP
αᵢ

Parameters
==========

AtomicExpr: variable name
Boolean: Assumption with a boolean value(True or False)
F)r   _assumptions_orig_assumptions0r#   r   Tc                <    U R                   (       a  [        $ [        $ r/   )is_commutativer   r   r0   s    r+   kindSymbol.kind  s    r-   c                    g)zyAllow derivatives wrt Symbols.

Examples
========

>>> from sympy import Symbol
>>> x = Symbol('x')
>>> x._diff_wrt
True
Tr8   r0   s    r+   	_diff_wrtSymbol._diff_wrt  s     r-   Nc                   [        U R                  SS5      5      nUc&  U(       a  SUR                  -  OSn[        SU-  5      e[	        U R                  5       5       H*  nX   nUc  U R                  U5        M  [        U5      X'   M,     g)zMRemove None, convert values to bool, check commutativity *in place*.
        commutativeTNz%s  z&%scommutativity must be True or False.)r   getr9   rO   listkeyspopbool)rK   r*   rt   whosekeyvs         r+   rJ   Symbol._sanitize&  s     $KOOM4$HI!,/ECLL(RE85@B B ((*+C Ay$#AwK ,r-   c                    U R                   n[        U5      [        U5      -   H1  nX   X#   :w  d  M  [        [        SU< SX#   < SX   < 35      5      e   UR	                  U5        U$ )Nz2
                    non-matching assumptions for z(: existing value
                    is z and new value is )assumptions0rc   rO   r   update)r1   rK   baseks       r+   _mergeSymbol._merge:  sj      [!CI-A~(  tw-0 "1 2 2 . 	K r-   c                R    U R                  X 5        [        R                  " X40 UD6$ )zSymbols are identified by name and assumptions::

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

)rJ   rI   _Symbol__xnew_cached_r(   r   rK   s      r+   r'   Symbol.__new__E  s&     	k'$$S>+>>r-   c                 z    U R                  5       nU R                  SS5        [        U 5      n[        U5      nX!U4$ )Nr{   T)copy
setdefaultr   rG   )rK   assumptions_origassumptions_kbr   s       r+   _canonical_assumptionsSymbol._canonical_assumptionsS  sD     '++- 	}d3";/N+==r-   c                @   [        U[        5      (       d   [        S[        [	        U5      5      -  5      e[
        R                  " U 5      nXl        [        R                  " S0 UD6u  pEnXCl
        XSl        [        [        UR                  5       5      5      Ul        U$ )Nr!   r8   )r"   r#   r$   r%   r&   r   r'   r   rI   r   _assumptionsrq   tuplesortedrH   rr   )r(   r   rK   r*   r   r   r   s          r+   __xnew__Symbol.__xnew__g  s    $$$=T$Z@PPQQ ll39?9V9V9eYd9e6,) 0!&););)=">?& 
r-   c                0    [         R                  " X40 UD6$ r/   )rI   r   r   s      r+   __xnew_cached_Symbol.__xnew_cached_  s     s8K88r-   c                4    U R                   4U R                  4$ r/   )r   rq   r0   s    r+   __getnewargs_ex__Symbol.__getnewargs_ex__  s    d4455r-   c                N    UR                  5        H  u  p#[        XU5        M     g r/   )rH   setattr)r1   stater   values       r+   __setstate__Symbol.__setstate__  s     ;;=KDD& )r-   c                6    U R                   4U R                  -   $ r/   )r   rr   r0   s    r+   r6   Symbol._hashable_content  s    		|d0000r-   c                |    UR                   (       a+  SSKJn  U" U [        R                  SS9R                  X5      $ g )Nr   )PowF)evaluate)is_Powsympy.core.powerr   r   One
_eval_subs)r1   oldnewr   s       r+   r   Symbol._eval_subs  s/    ::,tQUUU3>>sHH r-   c                    U $ r/   r8   )r1   rK   s     r+   _eval_refineSymbol._eval_refine  s    r-   c                ,    [        U R                  5      $ r/   )rG   rr   r0   s    r+   r   Symbol.assumptions0  s    D&&''r-   c                    U R                  5       SU R                  44[        R                  R	                  5       [        R                  4$ )Nr   )	class_keyr   r   r   sort_keyr1   orders     r+   r   Symbol.sort_key  s2    ~~!dii\!2AEENN4DaeeKKr-   c                    U R                   SLa  [        U R                  5      $ [        U R                  U R                   S9$ )NF)r{   )rt   Dummyr   r0   s    r+   as_dummySymbol.as_dummy  s;    #'#6#6e#CuTYY 	Ctyyd.A.AB	Cr-   c                ^    UR                  S5      U :X  a  g SSKJnJn  U" U 5      U" U 5      4$ )Nignorer   )imre)r}   $sympy.functions.elementary.complexesr   r   )r1   deephintsr   r   s        r+   as_real_imagSymbol.as_real_imag  s,    99X$&CtHbh''r-   c                    U(       d  gX;  $ NFr8   )r1   wrtflagss      r+   is_constantSymbol.is_constant  s    r-   c                    U 1$ r/   r8   r0   s    r+   free_symbolsSymbol.free_symbols  s	    vr-   c                "    [         R                  $ r/   )r   UniversalSetr0   s    r+   as_setSymbol.as_set  s    ~~r-   r8   r/   )T)#r9   r:   r;   r<   r=   is_comparabler>   __annotations__	is_Symbol	is_symbolpropertyru   rx   staticmethodrJ   r   r'   r	   r   r   r   r   r   r6   r   r   r   r   r   r   r   r   binary_symbolsr   r?   r8   r-   r+   rI   rI      s(   2h M>I
III 
   ' '&	? >  >$  B 9  96'1I
 ( ( L LC
(
   "Nr-   rI   c                      \ rS rSrSrSr\R                  " 5       r\R                  SS5      r
SrSrSS	 jrS
 r\SS j5       rS rSrg)r   i  a  Dummy symbols are each unique, even if they have the same name:

Examples
========

>>> 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

r   i@B i@T )dummy_indexTNc                4   Ub
  Uc   S5       eUc  S[        [        R                  5      -   nUc:  [        R                  [        R                  -   n[        =R                  S-  sl        U R	                  X05        [
        R                  " X40 UD6nX$l        U$ )Nz:If you specify a dummy_index, you must also provide a nameDummy_r   )r#   r   _count_base_dummy_indexrJ   rI   r   r   )r(   r   r   rK   r*   s        r+   r'   Dummy.__new__  s    "#a%aa#<c%,,//D11ELL@KLLALk'ooc7;7%
r-   c                J    U R                   U R                  4U R                  4$ r/   )r   r   rq   r0   s    r+   r   Dummy.__getnewargs_ex__   s"    D,,-t/E/EFFr-   c                    U R                  5       SU R                  U R                  44[        R                  R                  5       [        R                  4$ )N   )r   r   r   r   r   r   r   s     r+   r   Dummy.sort_key  sE    ~~		4++,"./0uu~~/?G 	Gr-   c                H    [         R                  U 5      U R                  4-   $ r/   )rI   r6   r   r0   s    r+   r6   Dummy._hashable_content  s!    ''-1A1A0CCCr-   r8   )NNr/   )r9   r:   r;   r<   r=   r   randomRandom_prngrandintr   r>   is_Dummyr'   r   r	   r   r6   r?   r8   r-   r+   r   r     s[    : FMMOEeW5 IH$G G GDr-   r   c                  h   ^  \ rS rSrSrSrSrSS jrS r\	\
S 5       5       rU 4S	 jrSS
 jrSrU =r$ )Wildi  a  
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 did not 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)exclude
propertiesr8   c                    [        U Vs/ s H  n[        U5      PM     sn5      n[        U5      nU R                  X@5        [        R                  " XX#40 UD6$ s  snf r/   )r   r   rJ   r   r   )r(   r   r   r   rK   r`   s         r+   r'   Wild.__new__i  sP    W5WW56:&
k'}}SK{KK 6s   Ac                H    U R                   U R                  U R                  4$ r/   )r   r   r   r0   s    r+   r2   Wild.__getnewargs__o  s    		4<<99r-   c                L    [         R                  " X40 UD6nX%l        X5l        U$ r/   )rI   r   r   r   )r(   r   r   r   rK   r*   s         r+   r   Wild.__xnew__r  s&     ooc7;7#
r-   c                R   > [         TU ]  5       U R                  U R                  4-   $ r/   )superr6   r   r   )r1   	__class__s    r+   r6   Wild._hashable_contentz  s#    w(*dllDOO-LLLr-   c                   ^ [        U4S jU R                   5       5      (       a  g [        U4S jU R                   5       5      (       d  g Uc  0 nOUR	                  5       nTX '   U$ )Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr/   )has)r^   r`   exprs     r+   ra   Wild.matches.<locals>.<genexpr>  s     1Lqtxx{{Ls   !c              3  2   >#    U  H  o" T5      v   M     g 7fr/   r8   )r^   fr  s     r+   ra   r    s     4Oq1T77Os   )rg   r   allr   r   )r1   r  	repl_dictr   s    `  r+   matchesWild.matches~  sW    1DLL1114DOO444I!(I	r-   )r8   r8   r   )r9   r:   r;   r<   r=   is_Wildr>   r'   r2   r   r	   r   r6   r  r?   __classcell__)r  s   @r+   r   r     sM    Wp G)IL:   M
 
r-   r   z"([0-9]*:[0-9]+|[a-zA-Z]?:[a-zA-Z]))r(   c               	  ^ / n[        U [        5      (       Gau  SnSn/ mU He  nX`;   d  M
  [        U5      U ;   a  US-  n[        U5      U ;   a  M  [        U5      nUS-  nU R                  Xg5      n TR	                  XvSS 45        Mg     U4S jnU R                  5       n U R                  S5      n	U	(       a  U SS R                  5       n U (       d  [        S5      eU R                  S5       V
s/ s H  oR                  5       PM     n n
[        S	 U  5       5      (       d  [        S
5      e[        [        U 5      S-
  SS5       H  nX   R                  5       XUS-   & M     UR                  SU	5      nU  GH  nU(       d  [        S5      eSU;  a"  U" U" U5      40 UD6nUR	                  U5        M>  [        R                  U5      n/ n[        [        U5      S-
  5       Hx  nU(       d  M  SX   ;   d  M  X   S:w  d  M   XS-
     R                  S5      (       d  M=  XS-      R                  S5      (       d  MZ  XS-
     SS XS-
  '   XS-      SS XS-   '   Mz     U GHT  nSU;   Ga7  UR                  S5      (       a  [        S5      eUR                  S5      u  nnUS   [         R"                  ;   aU  U(       d  SO
[%        U5      n[%        U5      nUR	                  [        UU5       Vs/ s H  n[        U5      PM     sn5        OU=(       d    SnUR	                  [        [         R&                  R)                  U5      [         R&                  R)                  U5      S-   5       Vs/ s H  n[         R&                  U   PM     sn5        US   (       d    GM)  GMB  UR	                  U/5        GMW     Sn[        U5      S:X  a  US   n O'[+        U6  Vs/ s H  nSR-                  U5      PM     n nT(       a2  UR/                  U  Vs/ s H  nU" U" U5      40 UD6PM     sn5        GM  UR/                  U  Vs/ s H  nU" U40 UD6PM     sn5        GM     U(       d  [        U5      S::  a  U(       d  gUS   $ [1        U5      $ U  H   nUR	                  [3        U4SU0UD65        M"     [5        U 5      " U5      $ s  sn
f s  snf s  snf s  snf s  snf s  snf )a  
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'>

r   )z\,z\:z\ r   Nc                N   > T(       a  T H  u  pU R                  X5      n M     U $ r/   )replace)rP   clliteralss      r+   literalsymbols.<locals>.literal  s$    $DA		!A %Hr-   ,rU   zno symbols givenc              3  $   #    U  H  ov   M     g 7fr/   r8   )r^   rZ   s     r+   ra   symbols.<locals>.<genexpr>  s     $e1es   zmissing symbol between commasseqzmissing symbol:()zmissing end rangeaTr|   r8   r(   )r"   r#   chrr  appendstripendswithrstriprO   splitr
  rangerV   r   _range
startswithstringdigitsrX   ascii_lettersindexr   joinextendr   symbolsr&   )rm   r(   argsresultmarker	splitterssplitterlit_charr  as_seqrZ   rB   r  r   symbolr%  
split_listrP   r  ba_ib_ir  r  s                          @r+   r/  r/    sj   h F%'	*,!H &kU*aKF &kU*v;!h9AB< 89 "	 $#2J%%'E/00 %*KK$45$4q$45$e$$$<==s5zA~r2.A#hnn.EQUO / hhuf%D !122$WT]3d3f%%||D1E*,J3u:>*1UX_!e--c22!e//44#(Q<#4Ea%L#(Q<#3Ea%L + !8zz#()<==773<DAqu-'(ac!f!!f"))5c?*K?a3q6?*KLH"))E"0066q9"0066q9A=M? +@ M?q6+?+?+B M? +@ A &b> * %%qc*# & z?a'&qME18*1EF1EARWWQZ1EEFMME"JEq3wqz#:T#:E"JKMM5"A5a3q>D>5"AB[ ^ s6{a'!9V}DMM'$8C8489  E{6""E 6F +L+@ G"J"As$   1S2S0SSS
S
c                8  ^ U4S jmSSK Jn  U" 5       R                  n [        U 40 UD6nUbd  [	        U[
        5      (       a  XCR                  UR                  '   O6[	        U[        5      (       a  XCR                  UR                  '   OT" XC5        AU$ ! Af = f)af  
Create symbols and inject them into the global namespace.

Explanation
===========

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 # noqa: F821
x

>>> var('a,ab,abc')
(a, ab, abc)
>>> abc # noqa: F821
abc

>>> var('x,y', real=True)
(x, y)
>>> x.is_real and y.is_real # noqa: F821
True

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

c                   > U  Hi  n[        U[        5      (       a  X!R                  UR                  '   M2  [        U[        5      (       a  X!R                  UR
                  '   Ma  T" X!5        Mk     g)z4Recursively inject symbols to the global namespace. N)r"   r   	f_globalsr   r   r9   )r/  framer7  traverses      r+   r@  var.<locals>.traverse  sO    F&%((/5,FM22390' r-   r   )currentframe)
inspectrB  f_backr/  r"   r   r>  r   r   r9   )rm   r0  rB  r?  symsr@  s        @r+   varrF  c  s    F( %N!!Eu%%$&&-1		*D-0015.%K s   A3B Bc                    [        U 6 nS n[        UR                  US9n0 nU H<  nUR                  [	        U5      R                  S5      / 5      R                  U5        M>     0 nU H  n[        SU-  40 XG   S   R                  D6nXG   S   U:w  a	  XXG   S   '   Sn	[        S[        XG   5      5       H9  n
 SXzU	-   4-  nX;  a  OU	S-  n	M  XG   U
   n[        U40 UR                  D6Xl'   M;     M     UR                  U5      $ )av  
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                Z    [        [        U R                  R                  5       5      5      $ r/   )r   r   r   rH   )r`   s    r+   rC   disambiguate.<locals>.<lambda>  s    5 4 4 678r-   )r   _z%sr   r   z%s_%i)r
   r   r   r   r#   lstripr!  rI   r   r&  rV   xreplace)iternew_iterr   rE  mappingrP   repsr   mapk0skiprB   r   kis                r+   disambiguaterT    s#   P d|H
8C8((s3DG3q6==-r299!< D tqz@WZ]%?%?@:a=E!"'Aq#gj/*A!X.&		 
 ABd6boo6DH +   T""r-   r/   )returnr   )9
__future__r   rK   r   r   basicr   r   cacher	   
containersr
   r  r   r   functionr   r   ru   r   r   logicr   	singletonr   sortingr   r   sympy.logic.boolalgr   sympy.utilities.iterablesr   r   sympy.utilities.miscr   r)  r   _rer   	itertoolsr   typingr   r   rM   rR   r#   rn   _uniquely_named_symbolrI   r   r   compiler'  r/  rF  rT  r8   r-   r+   <module>rf     s    " 4    " 1 +     ' 7 +     $ 8	'@LD (*3t I.T / qZ qhADF ADH|6 |~ 
9	: ! R#j=~?#r-   