
    g                        d 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mZmZmZ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!m"Z" ddl#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z* ddl+m,Z, ddl-m!Z.  ed      Z/d Z0d Z1dede.ee2f   fdZ3dede.eef   fdZ4 G d d      Z5 G d d       Z6d(d!Z7d)d"Z8d# Z9d*d$Z:d+d&Z;d' Z<y%),z9Tools for manipulating of large commutative expressions.    )Add)Mul_keep_coeff)Pow)Basic)Expr)expand_power_expsympify)RationalIntegerNumberIequal_valued)S)default_sort_keyorderedDummy)preorder_traversal)NonCommutativeExpression)TupleDict    )
SYMPY_INTS)common_prefixcommon_suffix
variationsiterableis_sequence)defaultdict)r   Tpositivec                 J    t        | t        t        f      xs | j                  S N)
isinstancer   float	is_Number)is    I/var/www/openai/venv/lib/python3.12/site-packages/sympy/core/exprtools.py	_isnumberr+      s    a*e,-<<    c                 l   | j                   sy|  j                  rt        |        }||S | S | j                  sU| j	                         d   j
                  r7| }|j                  r"|j                  rt        d      S t        d      S |j                  r"|j                  rt        d      S t        d      S |j                  rR|j                  r$|j                  du rt        d      S t        d      S |j                  rt        j                  S t        S |j                   r:|j                  rt        d      S |j                  rt        j"                  S t         S |j$                  s|j&                  s|j(                  rt        j*                  S y| j,                  }t/        |      dk(  r| j1                         rd	d
lm} d	dlm} d	dlm} |j?                         }t        |      t        t         fv rt        j*                  g| jA                  |      }|j
                  rg }	n		  ||      }	| jE                  |      }|jF                  rtI        fd|	D              r|jF                  r6|j                  r*|r|j                  r|S tK        dd      S tK        dd      S |jL                  r|jN                  r|r|jN                  r|S tK        dd      S tK        dd      S |jL                  r|tI        fd|	D              rh|jF                  r(|jN                  r|rtK        dd      S tK        dd      S |jL                  r(|j                  r|rtK        dd      S tK        dd      S y| j	                         \  }}d}|j
                  rt        |      }n"|j
                  st        |      t        |      }||j                  s|jN                  ri||z  }|j                  rtK        dd      S |jF                  rtK        dd      S |jN                  rtK        dd      S |jL                  rtK        dd      S y| jQ                         \  }}d}|j1                         s|j	                         \  }}|j
                  s|j
                  sy|jR                  s|jT                  rc|jV                  rVtI        d |jY                  tZ              D              r0|j                  s|jN                  rt        j                  }t]        j^                  |      D ]Q  }|j
                  r||z  }i }|j,                  D ]  }t        |      ||<   ||     y ||jE                  |      z  }S n|rta        d |jY                  tZ              D              sv|jL                  s|jF                  r^tc        |j,                        }i }|D ]1  }t        |      }| y|xs |jF                  rt        nt         ||<   3 |je                  |      }|c||z   }|jF                  r"|j                  r|jE                  t        d	      S |jL                  r#|jN                  r|jE                  t        d	      S yyy# |tB        f$ r-  |||      D 
cg c]  }
|
j                   s|
 nc c}
w }	}
Y }w xY w)a  Return the value closest to 0 that ``self`` may have if all symbols
    are signed and the result is uniformly the same sign for all values of symbols.
    If a symbol is only signed but not known to be an
    integer or the result is 0 then a symbol representative of the sign of self
    will be returned. Otherwise, None is returned if a) the sign could be positive
    or negative or b) self is not in one of the following forms:

    - L(x, y, ...) + A: a function linear in all symbols x, y, ... with an
      additive constant; if A is zero then the function can be a monomial whose
      sign is monotonic over the range of the variables, e.g. (x + 1)**3 if x is
      nonnegative.
    - A/L(x, y, ...) + B: the inverse of a function linear in all symbols x, y, ...
      that does not have a sign change from positive to negative for any set
      of values for the variables.
    - M(x, y, ...) + A: a monomial M whose factors are all signed and a constant, A.
    - A/M(x, y, ...) + B: the inverse of a monomial and constants A and B.
    - P(x): a univariate polynomial

    Examples
    ========

    >>> from sympy.core.exprtools import _monotonic_sign as F
    >>> from sympy import Dummy
    >>> nn = Dummy(integer=True, nonnegative=True)
    >>> p = Dummy(integer=True, positive=True)
    >>> p2 = Dummy(integer=True, positive=True)
    >>> F(nn + 1)
    1
    >>> F(p - 1)
    _nneg
    >>> F(nn*p + 1)
    1
    >>> F(p2*p + 1)
    2
    >>> F(nn - 1)  # could be negative, zero or positive
    Nr         	      Fr   )
real_roots)roots)PolynomialErrorc              3   <   K   | ]  }|z
  j                     y wr%   )is_nonpositive.0rx0s     r*   	<genexpr>z"_monotonic_sign.<locals>.<genexpr>   s       ,G9EAR//   posTr"   nneg)nonnegativeneg)negativenpos)nonpositivec              3   <   K   | ]  }|z
  j                     y wr%   )is_nonnegativer8   s     r*   r<   z"_monotonic_sign.<locals>.<genexpr>   s       .G9EAR//r=   c              3   b   K   | ]'  }|j                   s|j                  j                   ) y wr%   )is_Powexp
is_Integerr9   ps     r*   r<   z"_monotonic_sign.<locals>.<genexpr>   s!     GlahhAEE$$ls   //c              3   :   K   | ]  }|j                   r|  y wr%   )	is_numberrK   s     r*   r<   z"_monotonic_sign.<locals>.<genexpr>   s     >l!++1ls   )3is_extended_real	is_Symbol_monotonic_signis_Addas_numer_denomrN   is_primeis_oddr   is_compositeis_positiveis_even
is_integerr   One_epsis_extended_negativeNegativeOneis_zerois_extended_nonpositiveis_extended_nonnegativeZerofree_symbolslenis_polynomialsympy.polys.polytoolsr3   sympy.polys.polyrootsr4   sympy.polys.polyerrorsr5   popdiffNotImplementedErrorsubsrF   allr   r7   is_negativeas_coeff_Addis_MulrH   is_rationalatomsr   r   	make_argsanylistxreplace)selfrvsfreer3   r4   r5   xdcurrentrootsr:   yndenvcaairepsrL   r)   r;   s                        @r*   rQ   rQ       s   J   	dU#Zr(bS(;;4..03==::xxqz!qz!^^xxqz!qz!]]yy::&"1:%"1:%uu##yyr{"}}$u9911Q5N5N66M D
4yA~83>
A #BdTE]"VV~IIaL;;#%LV'1!} IIa$## ,G9E,G )G''AMM()1V5QU;VV#(T#BB''AMM()1V5QU;VV#(T#BB%%# .G9E.G +G''AMM#(#>>#(T#BB''AMM#(#>>#(T#BB& # &&(DAqC{{%a([["1%1)!,CCOOscE== 66%% T::]] 66%% T:: DAqA??!1q{{AHHGaggclGG!--AmmA&<<GAA-a0DGAw ) RWWT]" ' 
>aggcl>>ADTDTXYXhXh'DA#A&9AQ%5%5TD5!	 
 

1A}U774##774## !/	 e ,-@A V38A;'U;a!BTBT;'U'UVs$   -Y; ;Z3Z(#Z('Z32Z3exprreturnc                    | j                         \  }}|j                  rP|j                  r<|j                  s t	        |t        d|j                              }|j                  }||fS | d}}||fS |j                  d      \  }}|t        j                  u rt	        ||      d}}||fS |t        j                  ur<t        t        d|j                        |      }t	        ||      |j                  }}||fS | d}}||fS )a_  
    Decompose power into symbolic base and integer exponent.

    Examples
    ========

    >>> from sympy.core.exprtools import decompose_power
    >>> from sympy.abc import x, y
    >>> from sympy import exp

    >>> decompose_power(x)
    (x, 1)
    >>> decompose_power(x**2)
    (x, 2)
    >>> decompose_power(exp(2*y/3))
    (exp(y/3), 2)

    r   T)rational)as_base_expr(   is_RationalrJ   r   r   qrL   as_coeff_Mulr   r]   rZ   r   )r   baserI   etails        r*   decompose_powerr      s   &   "ID#
}}??>>4!SUU!34A  7N A!D 7N $$d$3	T!--$or!D 7N  x355148D$osuu!D 7N A!D7Nr,   c                 ^    | j                         x}\  }}|j                  r|S t        |       S )a  
    Decompose power into symbolic base and rational exponent;
    if the exponent is not a Rational, then separate only the
    integer coefficient.

    Examples
    ========

    >>> from sympy.core.exprtools import decompose_power_rat
    >>> from sympy.abc import x
    >>> from sympy import sqrt, exp

    >>> decompose_power_rat(sqrt(x))
    (x, 1/2)
    >>> decompose_power_rat(exp(-3*x/2))
    (exp(x/2), -3)

    )r   r   r   )r   _r   rI   s       r*   decompose_power_ratr     s1    & $$&&A	c1:_T%::r,   c                       e Zd ZdZdZddZd Zd Zed        Z	ed        Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)Factorsz0Efficient representation of ``f_1*f_2*...*f_n``.)factorsgensNc                 
   t        |t        t        f      rt        |      }t        |t              r|j
                  j                         }n|dt        j                  fv ri }n|t        j                  u s|dk(  r"t        j                  t        j                  i}nvt        |t              r|}i }|dk  r$t        j                  |t        j                  <   | }|t        j                  ur&|j                  s|j                  s|t        j                  u rt        j                  ||<   n|j                  r]|j                  dk7  r&t        j                  |t!        |j                        <   t        j                  |t!        |j"                        <   n~t%        d|z        t        |t&              r |j(                  s|t        j                  i}n@t        |t*              r|j-                         \  }}|j/                  t0              }t3        |      D ]  }|j5                  t0                t7        t9        j:                  |      j=                               }t?        |jA                               D ]  }t        |tB              st        |t               r%t!        |j                        t!        |j"                        }	}||v r||   nt        j                  ||   z   ||<   |	|v r||	   nt        j                  ||   z
  ||	<   |jE                  |        |r.|jG                  t0        t        j                        |z   |t0        <   |rt        j                  |t9        |ddi<   n|j                         }|D 
cg c]  }
|
t0        u s|
dv s|
 }}
|rwt        j                  }|D ](  }
tI        ||
         s||
|jE                  |
      z  z  }* |t        j                  ur'|jJ                  r|j(                  n|gD ]  }|t        j                  u rt        j                  ||<   *|t0        u rt        j                  |t0        <   J|jL                  rE|jG                  |jN                  t        j                        |jP                  z   ||jN                  <   tS        |d      rt        j                  ||<   tS        |d      r6t        j                  || <   t        j                  |t        j                  <   t%        d	|z         || _        tU        |d
d      }|tW        d      tY         |             | _-        yc c}
w )a  Initialize Factors from dict or expr.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x
        >>> from sympy import I
        >>> e = 2*x**3
        >>> Factors(e)
        Factors({2: 1, x: 3})
        >>> Factors(e.as_powers_dict())
        Factors({2: 1, x: 3})
        >>> f = _
        >>> f.factors  # underlying dictionary
        {2: 1, x: 3}
        >>> f.gens  # base of each factor
        frozenset({2, x})
        >>> Factors(0)
        Factors({0: 1})
        >>> Factors(I)
        Factors({I: 1})

        Notes
        =====

        Although a dictionary can be passed, only minimal checking is
        performed: powers of -1 and I are made canonical.

        Nr   r   z'Expected Float|Rational|Integer, not %sevaluateF)r   r   r   zunexpected factor in i1: %skeyszexpecting Expr or dictionary).r&   r   r'   r   r   r   copyrZ   ra   r   r]   is_FloatrJ   Infinityr   rL   r   r   
ValueErrorr   argsr   args_cnccountr   rangeremovedictr   
_from_argsas_powers_dictrt   r   r   rh   getr+   ro   rH   r   rI   r   getattr	TypeError	frozensetr   )rv   r   r~   r   ncr)   r   frL   r   khandlei1r   r   s                  r*   __init__zFactors.__init__!  s   > g
E23jGgw'oo**,Gquu%G'Q,vvquuoG(AG1u)*&B~::ajj!"GAJ]] ssax01-,-MMGGACCL)$%NQR%RSS'&G&$$&EAr
A1X 3>>!,;;=>G',,.)a*:a3I"133<qA01W'!*!&&GTUJ!VGAJ01W'!*!&&GTUJ!VGAJKKN * $[[AFF3a7
45EER0%01llnG ")CAAFa7laFCUUA$WQZ0 !W[[^++B   QUU?(*		RWWt;-)*GAJ!V)*GAJXX.5kk!&&!&&.IAEE.QGAFFO)!Q/)*GAJ)!R0*+%%GQBK56UUGAMM2",-JQ-N"OO < w-<:;;df%	7 Ds   UUc                     t        t        | j                  j                                     }|D cg c]  }| j                  |    }}t	        ||f      S c c}w r%   )tupler   r   r   hash)rv   r   r   valuess       r*   __hash__zFactors.__hash__  sN    WT\\..012+/04a$,,q/40T6N## 1s   Ac           
          ddj                  t        | j                  j                               D cg c]  \  }}|d| c}}      z  S c c}}w )NzFactors({%s}), z: )joinr   r   items)rv   r   r   s      r*   __repr__zFactors.__repr__  sO    +24<<3E3E3G+HI+H41aA+HI"K K 	KIs   Ac                 ^    | j                   }t        |      dk(  xr t        j                  |v S )zj
        >>> from sympy.core.exprtools import Factors
        >>> Factors(0).is_zero
        True
        r   )r   rc   r   ra   )rv   r   s     r*   r^   zFactors.is_zero  s(     LL1v{*qvv{*r,   c                     | j                    S )zi
        >>> from sympy.core.exprtools import Factors
        >>> Factors(1).is_one
        True
        )r   rv   s    r*   is_onezFactors.is_one  s     <<r,   c                 8   g }| j                   j                         D ]t  \  }}|dk7  rYt        |t              r4|j	                         \  }}t        ||      }|j                  ||z         O|j                  ||z         d|j                  |       v t        | S )zReturn the underlying expression.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y
        >>> Factors((x*y**2).as_powers_dict()).as_expr()
        x*y**2

        r   )r   r   r&   r   r   r   appendr   )rv   r   factorrI   br   s         r*   as_exprzFactors.as_expr  s     <<--/KFCaxc7+!--/DAq#C+AKK1%KK,F# 0 Dzr,   c                 D   t        |t              st        |      }t        d | |fD              rt        t        j                        S t        | j                        }|j                  j                         D ]  \  }}||v r||   |z   }|s||= |||<    t        |      S )a  Return Factors of ``self * other``.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y, z
        >>> a = Factors((x*y**2).as_powers_dict())
        >>> b = Factors((x*y/z).as_powers_dict())
        >>> a.mul(b)
        Factors({x: 2, y: 3, z: -1})
        >>> a*b
        Factors({x: 2, y: 3, z: -1})
        c              3   4   K   | ]  }|j                     y wr%   r^   r9   r   s     r*   r<   zFactors.mul.<locals>.<genexpr>  s     0-Qqyy-   )r&   r   rs   r   ra   r   r   r   rv   otherr   r   rI   s        r*   mulzFactors.mul  s     %)ENE04-00166?"t||$ ==..0KFC fo+!GFO 1 wr,   c                    t        |t              sit        |      }|j                  r#t               t        t        j                        fS | j                  r#t        t        j                        t               fS t        | j                        }t        |j                        }| j                  j                         D ]  \  }}	 |j                  |   }||z
  }|s||= ||= $t        |      r|dkD  r	|||<   ||= =||= | ||<   G|j                  |      }||r	|||<   ||= e||= ||= l|j                         \  }	}
|	rY|j                         \  }}|	|z
  }|dkD  r||xx   |z  cc<   |}n,|dk  r ||xx   |	z  cc<   ||xx   |	z  cc<   ||z
  }n|
||<   |}|r|||<   ||=  t        |      t        |      fS # t        $ r Y 	w xY w)aL  Return ``self`` and ``other`` with ``gcd`` removed from each.
        The only differences between this and method ``div`` is that this
        is 1) optimized for the case when there are few factors in common and
        2) this does not raise an error if ``other`` is zero.

        See Also
        ========
        div

        r   )r&   r   r^   r   ra   r   r   r   KeyErrorr+   extract_additivelyrn   )rv   r   self_factorsother_factorsr   self_exp	other_exprI   r:   scsaocoari   s                 r*   normalzFactors.normal  s    %)ENE}}	7166?33||33DLL)U]]+ $ 2 2 4FH!MM&1	 Y&C (!&)37+.L(%f-$V,-0DM&)//	:=/0V,)&1(0)&1%224FB!*!7!7!9B!Bw!8(0B60(*I!AX(0B60)&1R71(*T	I35L0(*I 09f-)&1[ !5^ |$gm&<<<Y  s   F;;	GGc                    t        | j                        i }}t        |t              sLt        |      }|j                  rt
        | j                  r#t        t        j                        t               fS |j                  j                         D ]  \  }}||v r||   |z
  }t        |      r|dk  r||= |dk\  r|r|||<   2| }n||   j                  |      }||r|||<   nx||= nt|}||   j                         \  }	}
|	rL|j                         \  }}|	|z
  }|dkD  r||xx   |z  cc<   |}n|dk  r||xx   |	z  cc<   ||z
  }n|
||<   |}|r|||<   n||vsJ |||<    t        |      t        |      fS )a  Return ``self`` and ``other`` with ``gcd`` removed from each.
        This is optimized for the case when there are many factors in common.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y, z
        >>> from sympy import S

        >>> a = Factors((x*y**2).as_powers_dict())
        >>> a.div(a)
        (Factors({}), Factors({}))
        >>> a.div(x*z)
        (Factors({y: 2}), Factors({z: 1}))

        The ``/`` operator only gives ``quo``:

        >>> a/x
        Factors({y: 2})

        Factors treats its factors as though they are all in the numerator, so
        if you violate this assumption the results will be correct but will
        not strictly correspond to the numerator and denominator of the ratio:

        >>> a.div(x/z)
        (Factors({y: 2}), Factors({z: -1}))

        Factors is also naive about bases: it does not attempt any denesting
        of Rational-base terms, for example the following does not become
        2**(2*x)/2.

        >>> Factors(2**(2*x + 2)).div(S(8))
        (Factors({2: 2*x + 2}), Factors({8: 1}))

        factor_terms can clean up such Rational-bases powers:

        >>> from sympy import factor_terms
        >>> n, d = Factors(2**(2*x + 2)).div(S(8))
        >>> n.as_expr()/d.as_expr()
        2**(2*x + 2)/8
        >>> factor_terms(_)
        2**(2*x)/2

        r   )r   r   r&   r   r^   ZeroDivisionErrorr   ra   r   r+   r   rn   )rv   r   quoremr   rI   r{   r:   r   r   r   r   r   ri   s                 r*   divzFactors.div,  s   \ %rS%)ENE}}''||33 ==..0KFC}K#%Q<AvKAv*+CK "C F66s;A}*+CK #F$'	!$V!9!9!;B%.%;%;%=FB#%7D#ax #Fr 1,.	!% #Fr 1,.I	.0F,.	$*3CK#)#44#4CKW 1Z s|WS\))r,   c                 *    | j                  |      d   S )aY  Return numerator Factor of ``self / other``.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y, z
        >>> a = Factors((x*y**2).as_powers_dict())
        >>> b = Factors((x*y/z).as_powers_dict())
        >>> a.quo(b)  # same as a/b
        Factors({y: 1})
        r   r   rv   r   s     r*   r   zFactors.quo  s     xxq!!r,   c                 *    | j                  |      d   S )aw  Return denominator Factors of ``self / other``.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y, z
        >>> a = Factors((x*y**2).as_powers_dict())
        >>> b = Factors((x*y/z).as_powers_dict())
        >>> a.rem(b)
        Factors({z: -1})
        >>> a.rem(a)
        Factors({})
        r   r   r   s     r*   r   zFactors.rem  s     xxq!!r,   c                 (   t        |t              r'|j                         }|j                  rt	        |      }t        |t
              r>|dk\  r9i }|r*| j                  j                         D ]  \  }}||z  ||<    t        |      S t        d|z        )a  Return self raised to a non-negative integer power.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y
        >>> a = Factors((x*y**2).as_powers_dict())
        >>> a**2
        Factors({x: 2, y: 4})

        r   z%expected non-negative integer, got %s)	r&   r   r   rJ   intr   r   r   r   r   s        r*   powzFactors.pow  s     eW%MMOEE
eZ(UaZG#'<<#5#5#7KFC&)%iGFO $8 7##DuLMMr,   c                    t        |t              s,t        |      }|j                  rt        | j                        S i }| j                  j	                         D ]i  \  }}t        |      t        |      }}||j                  v s+||j                  |   z
  j                  }|dk(  r|||<   R|dk(  sX|j                  |   ||<   k t        |      S )a  Return Factors of ``gcd(self, other)``. The keys are
        the intersection of factors with the minimum exponent for
        each factor.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y, z
        >>> a = Factors((x*y**2).as_powers_dict())
        >>> b = Factors((x*y/z).as_powers_dict())
        >>> a.gcd(b)
        Factors({x: 1, y: 1})
        TF)r&   r   r^   r   r   r   rm   )rv   r   r   r   rI   lts         r*   gcdzFactors.gcd  s     %)ENE}}t||,,<<--/KFC!&/73<CF&EMM&11>>:&)GFO5[&+mmF&;GFO 0 wr,   c                 F   t        |t              s8t        |      }t        d | |fD              rt        t        j                        S t        | j                        }|j                  j                         D ]  \  }}||v rt        |||         }|||<    t        |      S )a  Return Factors of ``lcm(self, other)`` which are
        the union of factors with the maximum exponent for
        each factor.

        Examples
        ========

        >>> from sympy.core.exprtools import Factors
        >>> from sympy.abc import x, y, z
        >>> a = Factors((x*y**2).as_powers_dict())
        >>> b = Factors((x*y/z).as_powers_dict())
        >>> a.lcm(b)
        Factors({x: 1, y: 2, z: -1})
        c              3   4   K   | ]  }|j                     y wr%   r   r   s     r*   r<   zFactors.lcm.<locals>.<genexpr>   s     4m199mr   )	r&   r   rs   r   ra   r   r   r   maxr   s        r*   lcmzFactors.lcm  s     %)ENE4tUm44qvv&t||$ ==..0KFC #wv/!GFO	 1 wr,   c                 $    | j                  |      S r%   )r   r   s     r*   __mul__zFactors.__mul__      xxr,   c                 $    | j                  |      S r%   r   r   s     r*   
__divmod__zFactors.__divmod__  r   r,   c                 $    | j                  |      S r%   )r   r   s     r*   __truediv__zFactors.__truediv__  r   r,   c                 $    | j                  |      S r%   )r   r   s     r*   __mod__zFactors.__mod__  r   r,   c                 $    | j                  |      S r%   )r   r   s     r*   __pow__zFactors.__pow__  r   r,   c                 j    t        |t              st        |      }| j                  |j                  k(  S r%   )r&   r   r   r   s     r*   __eq__zFactors.__eq__  s(    %)ENE||u}},,r,   c                     | |k(   S r%    r   s     r*   __ne__zFactors.__ne__!      5=  r,   r%   )__name__
__module____qualname____doc__	__slots__r   r   r   propertyr^   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r,   r*   r   r     s    :#Il&\$
K + +    4 BD=Ld*L"""N8 B <-
!r,   r   c                   p    e Zd ZdZdZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)Termz5Efficient representation of ``coeff*(numer/denom)``. coeffnumerdenomNc                    |||j                   st        d      |j                         \  }}t        t              t        t              }}|D ]X  }t        |      \  }}|j                  r|j                         \  }	}||	|z  z  }|dkD  r||xx   |z  cc<   K||xx   | z  cc<   Z t        |      }t        |      }n|}|
t               }|
t               }|| _	        || _
        || _        y )Nzcommutative expression expectedr   )is_commutativer   as_coeff_mulr!   r   r   rR   	primitiver   r  r  r  )
rv   termr  r  r  r   r   r   rI   conts
             r*   r   zTerm.__init__*  s    =U]&&.57 7 "..0NE7&s+[-=5E!+F3	c;;!%!1JD$T3Y&E7$K3&K$KC4'K " ENEENEE}	}	


r,   c                 Z    t        | j                  | j                  | j                  f      S r%   )r   r  r  r  r   s    r*   r   zTerm.__hash__N  s     TZZTZZ899r,   c                 V    d| j                   d| j                  d| j                  dS )NzTerm(r   )r  r   s    r*   r   zTerm.__repr__Q  s    %)ZZTZZHHr,   c                     | j                   | j                  j                         | j                  j                         z  z  S r%   )r  r  r   r  r   s    r*   r   zTerm.as_exprT  s0    zz4::--/

0B0B0DDEEr,   c                 
   | j                   |j                   z  }| j                  j                  |j                        }| j                  j                  |j                        }|j	                  |      \  }}t        |||      S r%   )r  r  r   r  r   r  )rv   r   r  r  r  s        r*   r   zTerm.mulW  sa    

5;;&

u{{+

u{{+||E*uE5%((r,   c                 ^    t        d| j                  z  | j                  | j                        S )Nr   )r  r  r  r  r   s    r*   invzTerm.inv`  s!    AdjjL$**djj99r,   c                 @    | j                  |j                               S r%   )r   r  r   s     r*   r   zTerm.quoc  s    xx		$$r,   c                     |dk  r | j                         j                  |       S t        | j                  |z  | j                  j                  |      | j
                  j                  |            S )Nr   )r  r   r  r  r  r  r   s     r*   r   zTerm.powf  sX    1988:>>5&))

e+

u-

u-/ /r,   c                     t        | j                  j                  |j                        | j                  j                  |j                        | j                  j                  |j                              S r%   )r  r  r   r  r  r   s     r*   r   zTerm.gcdn  J    DJJNN5;;/JJNN5;;/JJNN5;;/1 	1r,   c                     t        | j                  j                  |j                        | j                  j                  |j                        | j                  j                  |j                              S r%   )r  r  r   r  r  r   s     r*   r   zTerm.lcms  r  r,   c                 P    t        |t              r| j                  |      S t        S r%   )r&   r  r   NotImplementedr   s     r*   r   zTerm.__mul__x       eT"88E?"!!r,   c                 P    t        |t              r| j                  |      S t        S r%   )r&   r  r   r  r   s     r*   r   zTerm.__truediv__~  r  r,   c                 P    t        |t              r| j                  |      S t        S r%   )r&   r   r   r  r   s     r*   r   zTerm.__pow__  s     eZ(88E?"!!r,   c                     | j                   |j                   k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S r%   r  r   s     r*   r   zTerm.__eq__  sA    

ekk) *

ekk)*

ekk)	+r,   c                     | |k(   S r%   r   r   s     r*   r   zTerm.__ne__  r   r,   )NN)r   r   r   r   r  r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r,   r*   r  r  %  sX    ?+I"H:IF):%/1
1
"""+
!r,   r  c           	         t        | t              r%t        | t              st        j                  |       } t        t        t        | D cg c]  }|s|	 c}            } t        |       dk(  r/t        j                  t        j                  t        j                  fS t        |       dk(  rK| d   j                  }| d   j                  j                         }| d   j                  j                         }nO| d   }| dd D ]  }|j!                  |      } t#        |       D ]  \  }}|j%                  |      | |<    |r| d   j                  }| dd D ]  }|j'                  |j                        } g }	| D ]b  }|j                  j)                  |j%                  |j                              }|	j+                  |j                  |j                         z         d n@| D cg c]  }|j                          }	}t        t        j                        j                  }|j                         }t        |	 }|j                         }|s$|j,                  r|j/                         \  }
}||
z  }|||fS c c}w c c}w )a  Helper function for :func:`gcd_terms`.

    Parameters
    ==========

    isprimitive : boolean, optional
        If ``isprimitive`` is True then the call to primitive
        for an Add will be skipped. This is useful when the
        content has already been extracted.

    fraction : boolean, optional
        If ``fraction`` is True then the expression will appear over a common
        denominator, the lcm of all term denominators.
    r   r   N)r&   r   r   r   rr   rt   mapr  rc   r   ra   rZ   r  r  r   r  r   	enumerater   r   r   r   rR   r  )termsisprimitivefractiontr  r  r  r  r)   numers_conts              r*   
_gcd_termsr+    s     %
5%(@e$Tu2u!Au234E
 5zQvvqvvquu$$
5zQQx~~a&&(a&&( Qx!"ID88D>D  !'GAtxx~E!H ( !HNNEab			$**- " F

uyy'<=djj89  ,115aaiik5F1K%%E||~V5<<(uW 3@ 2s   	I0I0!I5c                 J   d }t        | t              }|xs7 t        | t               xr$ t        | t              xr t        | t
               }|r|rt        | j                        } nt        |       }  ||       \  } }t        |       \  }}	}
|	j                  |      }	|j                         \  }}sh|j                         \  }}|j                  sIsG|	j                  r;|j                         \  }}|	|z  }t        d |j                  D              r|}	||z  }t!        |||	z  |
z        S t        | t              s| S | j"                  r| S | j$                  rA| j'                         \  }}t!        |t)        |D cg c]  }t+        |       c}       S fdt        | t
              r-t        | j                  D cg c]  \  }}| |      f c}} S  | j,                  | j                  D cg c]
  } |       c} S c c}w c c}}w c c}w )a  Compute the GCD of ``terms`` and put them together.

    Parameters
    ==========

    terms : Expr
        Can be an expression or a non-Basic sequence of expressions
        which will be handled as though they are terms from a sum.

    isprimitive : bool, optional
        If ``isprimitive`` is True the _gcd_terms will not run the primitive
        method on the terms.

    clear : bool, optional
        It controls the removal of integers from the denominator of an Add
        expression. When True (default), all numerical denominator will be cleared;
        when False the denominators will be cleared only if all terms had numerical
        denominators other than 1.

    fraction : bool, optional
        When True (default), will put the expression over a common
        denominator.

    Examples
    ========

    >>> from sympy import gcd_terms
    >>> from sympy.abc import x, y

    >>> gcd_terms((x + 1)**2*y + (x + 1)*y**2)
    y*(x + 1)*(x + y + 1)
    >>> gcd_terms(x/2 + 1)
    (x + 2)/2
    >>> gcd_terms(x/2 + 1, clear=False)
    x/2 + 1
    >>> gcd_terms(x/2 + y/2, clear=False)
    (x + y)/2
    >>> gcd_terms(x/2 + 1/x)
    (x**2 + 2)/(2*x)
    >>> gcd_terms(x/2 + 1/x, fraction=False)
    (x + 2/x)/2
    >>> gcd_terms(x/2 + 1/x, fraction=False, clear=False)
    x/2 + 1/x

    >>> gcd_terms(x/2/y + 1/x/y)
    (x**2 + 2)/(2*x*y)
    >>> gcd_terms(x/2/y + 1/x/y, clear=False)
    (x**2/2 + 1)/(x*y)
    >>> gcd_terms(x/2/y + 1/x/y, clear=False, fraction=False)
    (x/2 + 1/x)/y

    The ``clear`` flag was ignored in this case because the returned
    expression was a rational expression, not a simple sum.

    See Also
    ========

    factor_terms, sympy.polys.polytools.terms_gcd

    c                 B   | D cg c]"  }|j                   r|g fn|j                         $ }}g }t        |      D ]Q  \  }\  }}|rBt        | }t	               }|j                  ||f       |j                  |       t        | ||<   M|||<   S |t        |      fS c c}w )zpreplace nc portions of each term with a unique Dummy symbols
        and return the replacements to restore them)r
  r   r$  r   r   r   r   )r%  r   r   r   r)   r   r   r{   s           r*   maskzgcd_terms.<locals>.mask  s     HMMu!1++B=uM#D/JAw2"XGQG$q'QQ * T$Z Ns   'B)includec              3   V   K   | ]!  }|j                         d    j                   # ywr   N)r   rJ   r9   r   s     r*   r<   zgcd_terms.<locals>.<genexpr>4  s*      .!,A ~~'*55!,s   '))clearc                 4   t        | t              spt        | t              r;| j                  s| S  | j                  | j                  D cg c]
  } |       c} S  t        |       | D cg c]
  } |       c}      S t        |       S c c}w c c}w r%   )r&   r   r   r   functype	gcd_terms)r   r)   r3  r'  r   r&  s     r*   r   zgcd_terms.<locals>.handleE  s    !T"!U#vvHqvv166:6aq	6:;;47q1q!F1Iq122K99  ;1s   
B,B)r&   r   r   r    setr   rt   r   r   r+  ru   r   rJ   rR   rS   rs   r   is_Atomro   r  r   r7  r5  )r%  r&  r3  r'  r.  isaddaddliker   r  r  r  r  r   r   _coeffr~   r{   _numerr   r)   r   r   r   s    ```                  @r*   r7  r7    s   z   uc"E $:eU33 $E3'$ud##  $EENE5kt'{HEeUt$**,w**,IAv<<%,,'')1q .!'. ."EfHE5'%-"5UCCeU#}}||$$&41c$ %.aeX$N$ #(* 	*: %<Aq&)n<==5::5::6:aq	:677$ =6s   HH
H c                 z   | j                   }|dk(  rt        j                  S | j                  }|D ch c]  }|j                  d    }}t        |fi |} |j                  | \  }}t        |t              r*| | j                  dg| z   | j                  |g| z   S | | j                  |g| z  S c c}w )a  Return Sum or Integral object with factors that are not
    in the wrt variables removed. In cases where there are additive
    terms in the function of the object that are independent, the
    object will be separated into two objects.

    Examples
    ========

    >>> from sympy import Sum, factor_terms
    >>> from sympy.abc import x, y
    >>> factor_terms(Sum(x + y, (x, 1, 3)))
    y*Sum(1, (x, 1, 3)) + Sum(x, (x, 1, 3))
    >>> factor_terms(Sum(x*y, (x, 1, 3)))
    y*Sum(x, (x, 1, 3))

    Notes
    =====

    If a function in the summand or integrand is replaced
    with a symbol, then this simplification should not be
    done or else an incorrect result will be obtained when
    the symbol is replaced with an expression that depends
    on the variables of summation/integration:

    >>> eq = Sum(y, (x, 1, 3))
    >>> factor_terms(eq).subs(y, x).doit()
    3*x
    >>> eq.subs(y, x).doit()
    6
    r   r   )
functionr   ra   limitsr   factor_termsas_independentr&   r   r5  )r   kwargsresultr@  r)   wrtr   r{   s           r*   _factor_sum_intrF  T  s    > ]]F{vv[[F %
%f166!9fC
% 	V&v&A1S!DAq!S9499Q(((9499Q+@+@@@9499Q(((( &s   B8c                 D    fdt        |       }  |       S )a  Remove common factors from terms in all arguments without
    changing the underlying structure of the expr. No expansion or
    simplification (and no processing of non-commutatives) is performed.

    Parameters
    ==========

    radical: bool, optional
        If radical=True then a radical common to all terms will be factored
        out of any Add sub-expressions of the expr.

    clear : bool, optional
        If clear=False (default) then coefficients will not be separated
        from a single Add if they can be distributed to leave one or more
        terms with integer coefficients.

    fraction : bool, optional
        If fraction=True (default is False) then a common denominator will be
        constructed for the expression.

    sign : bool, optional
        If sign=True (default) then even if the only factor in common is a -1,
        it will be factored out of the expression.

    Examples
    ========

    >>> from sympy import factor_terms, Symbol
    >>> from sympy.abc import x, y
    >>> factor_terms(x + x*(2 + 4*y)**3)
    x*(8*(2*y + 1)**3 + 1)
    >>> A = Symbol('A', commutative=False)
    >>> factor_terms(x*A + x*A + x*y*A)
    x*(y*A + 2*A)

    When ``clear`` is False, a rational will only be factored out of an
    Add expression if all terms of the Add have coefficients that are
    fractions:

    >>> factor_terms(x/2 + 1, clear=False)
    x/2 + 1
    >>> factor_terms(x/2 + 1, clear=True)
    (x + 2)/2

    If a -1 is all that can be factored out, to *not* factor it out, the
    flag ``sign`` must be False:

    >>> factor_terms(-x - y)
    -(x + y)
    >>> factor_terms(-x - y, sign=False)
    -x - y
    >>> factor_terms(-2*x - 2*y, sign=False)
    -2*(x + y)

    See Also
    ========

    gcd_terms, sympy.polys.polytools.terms_gcd

    c                    ddl m} ddlm} t	        |       }t        | t              r| j                  r)|r% t        |       | D cg c]
  } |       c}      S | S | j                  s| j                  s|st        | d      sA| j                  }t        |D cg c]
  } |       c}      }||k(  r| S  | j                  | S t        | ||f      rt        |       S | j!                        \  }}|j"                  rt%        j&                  |      D 	cg c]
  }	 |	       }
}	t)        d |
D              s| }|
D 	cg c]  }	|	  }
}	i }t+        |
      D ]P  \  }}	|	j-                         \  }}|j.                  s&|t1        |j                   k7  s<t3               |
|<   |	||
|   <   R t%        j4                  |
      }t7        |d	      j9                  |      }n9|j                  r- |j                  |j                  D 	cg c]
  }	 |	       c}	 }t;        ||
      }|S c c}w c c}w c c}	w c c}	w c c}	w )Nr   )Sum)Integralr   )radicalr3  r'  sign)rK  r3  c              3   d   K   | ](  }|j                         d    j                  d      du  * yw)r   r   N)r   extract_multiplicativelyr2  s     r*   r<   z+factor_terms.<locals>.do.<locals>.<genexpr>  s4      + )1 ~~'*CCBG4O )s   .0T)r&  r3  r'  )r3  rL  )sympy.concrete.summationsrI  sympy.integrals.integralsrJ  r   r&   r   r9  r6  rH   is_Functionhasattrr   r   r5  rF  as_content_primitiverR   r   rr   rs   r$  r   ro   r   r   r   r7  ru   r   )r   rI  rJ  is_iterabler)   r   newargsr  rL   r   	list_argsspecialr   r   rw   r3  dor'  rK  rL  s                  r*   rX  zfactor_terms.<locals>.do  s6   16tn$&$,,!tDz$"7$Q2a5$"788K;;$**74#<99DD1DqRUD12G$499g&&dS(O,"4u!. . ++G5+Ia88(+a(89(81A(8I9 + )+ +u)23AaR	3G!),1}}188S!&&\ 1#(7IaL,-GIaL)	 - y)A! !# $,8G#4  VV!"(A"Q%(*AqD9	S #8 2 :
 4  )s   H0H5H:
H?Ir
   )r   rK  r3  r'  rL  rX  s    ````@r*   rA  rA    s#    z0 0b 4=Dd8Or,   Nc                 &   xs dfd} |       fd}| }|j                   r| i g fS g }t               }t               }t        |t              }t	        |      D ]  \  }	t        fd|D              r|j                          +j                   r8j                  r"|j                         |j                          fj                  rsj                  rj                  r|j                         |j                           t        |      dk(  r)|s'|j                  |j                          |       f       n6t        |      dk(  r(|s&|j                  |j                          |       f       t        |t              }|D ]/  }
 |d	      }|j                  |
|f       |j                  |       1 |j!                  |      }t#        |      }|j%                  t               ||D ci c]  \  }}||
 c}}|fS c c}}w )
a  
    Return ``eq`` with non-commutative objects replaced with Dummy
    symbols. A dictionary that can be used to restore the original
    values is returned: if it is None, the expression is noncommutative
    and cannot be made commutative. The third value returned is a list
    of any non-commutative symbols that appear in the returned equation.

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

    All non-commutative objects other than Symbols are replaced with
    a non-commutative Symbol. Identical objects will be identified
    by identical symbols.

    If there is only 1 non-commutative object in an expression it will
    be replaced with a commutative symbol. Otherwise, the non-commutative
    entities are retained and the calling routine should handle
    replacements in this case since some care must be taken to keep
    track of the ordering of symbols when they occur within Muls.

    Parameters
    ==========

    name : str
        ``name``, if given, is the name that will be used with numbered Dummy
        variables that will replace the non-commutative objects and is mainly
        used for doctesting purposes.

    Examples
    ========

    >>> from sympy.physics.secondquant import Commutator, NO, F, Fd
    >>> from sympy import symbols
    >>> from sympy.core.exprtools import _mask_nc
    >>> from sympy.abc import x, y
    >>> A, B, C = symbols('A,B,C', commutative=False)

    One nc-symbol:

    >>> _mask_nc(A**2 - x**2, 'd')
    (_d0**2 - x**2, {_d0: A}, [])

    Multiple nc-symbols:

    >>> _mask_nc(A**2 - B**2, 'd')
    (A**2 - B**2, {}, [A, B])

    An nc-object with nc-symbols but no others outside of it:

    >>> _mask_nc(1 + x*Commutator(A, B), 'd')
    (_d0*x + 1, {_d0: Commutator(A, B)}, [])
    >>> _mask_nc(NO(Fd(x)*F(y)), 'd')
    (_d0, {_d0: NO(CreateFermion(x)*AnnihilateFermion(y))}, [])

    Multiple nc-objects:

    >>> eq = x*Commutator(A, B) + x*Commutator(A, C)*Commutator(A, B)
    >>> _mask_nc(eq, 'd')
    (x*_d0 + x*_d1*_d0, {_d0: Commutator(A, B), _d1: Commutator(A, C)}, [_d0, _d1])

    Multiple nc-objects and nc-symbols:

    >>> eq = A*Commutator(A, B) + B*Commutator(A, C)
    >>> _mask_nc(eq, 'd')
    (A*_d0 + B*_d1, {_d0: Commutator(A, B), _d1: Commutator(A, C)}, [_d0, _d1, A, B])

    r.  c               3   >   K   d} 	 t        |       z    | dz  } w)Nr   r   )str)r)   names    r*   numbered_namesz _mask_nc.<locals>.numbered_names=  s+     Q-FA s   c                  :    ddl m}  |t              g| i |S )Nr   r   )symbolr   next)r   rC  r   namess      r*   r   z_mask_nc.<locals>.DummyE  s    !T%[242622r,   )r   c              3   .   K   | ]  }|d    k(    ywr1  r   )r9   r:   r   s     r*   r<   z_mask_nc.<locals>.<genexpr>S  s     &#QqAaDy#s   r   keyF)commutative)r
  r8  r   r   r$  rs   skip	is_symboladdrR   ro   rH   rc   r   rh   sortedrk   rt   sort)eqr\  r]  r   r   repnc_objnc_symspotr)   r~   r   r   r   r   ra  s    `            @@r*   _mask_ncrp    s   H >6D E3 D2rz CUFeG
T(8
9C#1&#&&HHJ!!{{A
hh!((ahh

1
  6{a

FJJL%'*+	W	6

GKKM57+, F 01Fu%

Ar7B  99S>D7mGLL%L&3'341a!Q$3'00's   :Hc           
         t        |       } t        | t              r| j                  s| S | j                  s0 | j
                  | j                  D cg c]  }t        |       c} S  | j
                  | j                  D cg c]  }t        |       c} } ddlm	}m
} t        |       \  } }}|r ||       j                  |      S t        j                  |       D cg c]  }|j                          }}t         j"                  x}x}	x}
}d}t%        |      D ]X  \  }}|dk(  rt'        j(                  |d         }$|d   r  ||t'        j(                  |d               }It         j"                  }Z |t         j"                  urd}|j+                         \  }}	|	t         j"                  ur[t%        |      D ]M  \  }\  }}t-        t'        j                  t'        j(                  t-        |            |	z              }|||   d<   O t%        |      D ]$  \  }\  }}|r|d   |z  |d<   nd|z  g}|||   d<   & t%        |      D ]  \  }}|dk(  r	|d   dd }nt/        |d         }|r&|d   d   s n|d   d   d   j1                         \  }}d}|j2                  ro|D ]A  }|d   s nc|d   d   j1                         \  }}|j2                  r||k(  rt5        ||      }A n* dx}}||z  }
|| z  }|D ]  }||d   d   z  |d   d<     n-|r n( d}t7              }t'        | }
|D ]  }|d   |d |d<    t%        |      D ]  \  }}|dk(  r	|d   dd }nt9        ||d         }|r&|d   d   s n|d   d   d   j1                         \  }}d}|j2                  ro|D ]A  }|d   s nc|d   d   j1                         \  }}|j2                  r||k(  rt5        ||      }A n* dx}}||z  }|| z  }|D ]  }|d   d   |z  |d   d<     n<|r n7 d}t7        |      }t'        | }|D ]  }|d   dt7        |d         |z
   |d<    |r+t        |D cg c]  \  }}t'        | t'        | z   c}} }n| }ddlm} t?        |t@        	      D cg c]  }|tC               f }}|D cg c]	  \  }}||f }}}|jE                          t        |j                  |            \  }} } | ||            }|j                  |       j                  |      }|jF                  rtI        ||	|
z  |z  |z        S |jJ                  rd
 }!g }"g }#|j                  D ]f  }$|$jL                  r|"jO                  |$       !|$j1                         \  }}|j2                  r|#jQ                  |g|z         V|#jO                  |$       h |	t'        |" z  |
z  }% |!| |z        }&tS        |#t7        |#            D ])  }'|%t'        |' z  |z  } |!|      |&k(  stI        ||      c S  tI        ||	|
z  |z  |z        S c c}w c c}w c c}w c c}}w c c}w c c}}w )a  Return the factored form of ``expr`` while handling non-commutative
    expressions.

    Examples
    ========

    >>> from sympy import factor_nc, Symbol
    >>> from sympy.abc import x
    >>> A = Symbol('A', commutative=False)
    >>> B = Symbol('B', commutative=False)
    >>> factor_nc((x**2 + 2*A*x + A**2).expand())
    (x + A)**2
    >>> factor_nc(((x + A)*(x + B)).expand())
    (x + A)*(x + B)
    r   )r   r   FTr   Nr   )powsimprc  c           	      2    | j                  ddddddd      S )zCExpand with the minimal set of hints necessary to check the result.TF)deepr   	power_exp
power_basebasicmultinomiallog)expand)r   s    r*   
_pemexpandzfactor_nc.<locals>._pemexpand  s)    {{$$$Et # P Pr,   )*r   r&   r   r   rR   r5  	factor_ncr	   re   r   r   rp  rk   r   rr   r   r   rZ   r$  r   r   r   rt   r   r   rJ   minrc   r   sympy.simplify.powsimprr  ri  r   r   reverserH   r   ro   r
  r   extendr   )(r   r   r)   r   r   rl  
nc_symbolsr   r   glr:   hitccr   r~   r   r   okr(  btetillennr   midrr  rep1r   r   unrep1new_midr2r{  cfacncfacr   pre_midtargetrx   s(                                           r*   r|  r|  r  sd     4=DdD!;;tyy;A9Q<;<<499DII>Iq'*I>?D1$TND#z
d|  %%&)mmD&9:&9

&9:AAdODAqAvNN1Q4(13>>!A$/0EE $ AEE>C>>#DAq~"+D/JAwAcmmCNN48,DQ,FGHB!#DGAJ #2 (o
7BqE!GBqEA#BQ
 . dODAqAvaDG!!QqT*AwqzAwqz!}0021<<! t!!"1a!4!4!6B==R1W #Ar
A! " $(SqDU!%A&(1ajAaDG "&9 $< Cq6DQAtDE{!  dODAqAvaDG!!QqT*AwqzAwqz"~1131<<! t!!"1b!5!5!7B==R1W #Ar
A! " $(SqDU!%A'(tBx{AaDH "&9 $< Cq6DQAt-S1Y-.! =fb"Rb)=>CC2 '-Z=M&NO&NEG&NO%)*TTQ1a&T*!#((4.1Q&/*,,r"''/>>q!A#g+a-00>>P DE\\##KKN==?DAq||aSU+Q " T
l1nGQ'Fs5z2S!W_Q&b>V+&q"-- 3 1ac#gai((w <> ;B > P*s$   X2 X7X<Y
Y-Y)FT)FTT)FFFTr%   )=r   rh  r   r   r   r   powerr   rw  r   r   r   r?  r	   r   numbersr   r   r   r   r   	singletonr   sortingr   r   r_  r   	traversalr   
coreerrorsr   
containersr   r   sympy.external.gmpyr   sympy.utilities.iterablesr   r   r   r   r    collectionsr!   typingtTupler[   r+   rQ   r   r   r   r   r  r+  r7  rF  rA  rp  r|  r   r,   r*   <module>r     s    ?  !    &  ? ?  .  ) 0 # *+ + $ " d=v$r)$ )6$)#4 )X;d ;vdHn'= ;.F! F!Rk! k!\>B}8@-)`ody1xo)r,   