§
    OŠtj¤M  ã                   ób  — d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
mZ ddlmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z.m/Z/ d„ Z0d	„ Z1d
„ Z2d„ Z3d„ Z4d„ Z5d„ Z6d„ Z7d„ Z8d„ Z9d„ Z:d„ Z;dd„Z<dd„Z=dd„Z>dd„Z?dd„Z@dd„ZAd„ ZBd„ ZCdS )z8Square-free decomposition algorithms and related tools. é    )
Údup_negÚdmp_negÚdup_subÚdmp_subÚdup_mulÚdmp_mulÚdup_quoÚdmp_quoÚdup_mul_groundÚdmp_mul_ground)Ú	dup_stripÚdup_LCÚdmp_ground_LCÚ
dmp_zero_pÚ
dmp_groundÚ
dup_degreeÚ
dmp_degreeÚdmp_degree_inÚdmp_degree_listÚ	dmp_raiseÚ
dmp_injectÚdup_convert)	Údup_diffÚdmp_diffÚdmp_diff_inÚ	dup_shiftÚ	dmp_shiftÚ	dup_monicÚdmp_ground_monicÚdup_primitiveÚdmp_ground_primitive)Údup_inner_gcdÚdmp_inner_gcdÚdup_gcdÚdmp_gcdÚdmp_resultantÚdmp_primitive)Úgf_sqf_listÚgf_sqf_part)ÚMultivariatePolynomialErrorÚDomainErrorc                 ób   — t          d„ |D ¦   «         ¦  «        }|t          | ¦  «        k    sJ ‚dS )z=Sanity check the degrees of a computed factorization in K[x].c              3   ó@   K  — | ]\  }}|t          |¦  «        z  V — Œd S )N)r   )Ú.0ÚfacÚks      úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/polys/sqfreetools.pyú	<genexpr>z%_dup_check_degrees.<locals>.<genexpr>$   s1   è è € Ð9Ð9¡h s¨Aˆa•*˜S‘/”/Ñ!Ð9Ð9Ð9Ð9Ð9Ð9ó    N)Úsumr   )ÚfÚresultÚdegs      r1   Ú_dup_check_degreesr8   "   s;   € å
Ð9Ð9°&Ð9Ñ9Ô9Ñ
9Ô
9€CØ•*˜Q‘-”-ÒÐÐÐÐÐr3   c                 óÈ   ‡— dg|dz   z  }|D ]1\  }Št          ||¦  «        }ˆfd„t          ||¦  «        D ¦   «         }Œ2t          |¦  «        t          | |¦  «        k    sJ ‚dS )z=Sanity check the degrees of a computed factorization in K[X].r   é   c                 ó&   •— g | ]\  }}|‰|z  z   ‘ŒS © r<   )r.   Úd1Úd2r0   s      €r1   ú
<listcomp>z&_dmp_check_degrees.<locals>.<listcomp>-   s%   ø€ Ð>Ð>Ð>¡  B��Q˜‘V‘Ð>Ð>Ð>r3   N)r   ÚzipÚtuple)r5   Úur6   Údegsr/   Údegs_facr0   s         @r1   Ú_dmp_check_degreesrE   (   s€   ø€ àˆ3�!�a‘%‰=€DØð ?ð ?‰ˆˆQÝ" 3¨Ñ*Ô*ˆØ>Ð>Ð>Ð>­#¨d°HÑ*=Ô*=Ð>Ñ>Ô>ˆˆÝ�‰;Œ;�/¨!¨QÑ/Ô/Ò/Ð/Ð/Ð/Ð/Ð/r3   c           
      óf   — | sdS t          t          | t          | d|¦  «        |¦  «        ¦  «         S )a  
    Return ``True`` if ``f`` is a square-free polynomial in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_sqf_p(x**2 - 2*x + 1)
    False
    >>> R.dup_sqf_p(x**2 - 1)
    True

    Tr:   )r   r$   r   )r5   ÚKs     r1   Ú	dup_sqf_prH   1   s;   € ð  ð @Øˆtå�g a­°!°Q¸Ñ):Ô):¸AÑ>Ô>Ñ?Ô?Ð?Ð?r3   c                 óð   — t          | |¦  «        rdS t          |dz   ¦  «        D ]P}t          | d|||¦  «        }t          ||¦  «        rŒ&t          | |||¦  «        }t	          |||¦  «        dk    r dS ŒQdS )a  
    Return ``True`` if ``f`` is a square-free polynomial in ``K[X]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    >>> R.dmp_sqf_p(x**2 + 2*x*y + y**2)
    False
    >>> R.dmp_sqf_p(x**2 + y**2)
    True

    Tr:   r   F)r   Úranger   r%   r   )r5   rB   rG   ÚiÚfpÚgcds         r1   Ú	dmp_sqf_prN   G   s›   € õ  �!�QÑÔð Øˆtå�1�Q‘3‰ZŒZð 
ð 
ˆå˜˜A˜q ! QÑ'Ô'ˆå�b˜!ÑÔð 	Øå�a˜˜Q Ñ"Ô"ˆå˜˜a Ñ#Ô# qÒ(Ð(Ø�5�5ð )ð ˆ4r3   c                 óZ  — |j         st          d¦  «        ‚dt          |j                             ¦   «         dd|j        ¦  «        }}	 t          | d|d¬¦  «        \  }}t          ||d|j        ¦  «        }t          ||j        ¦  «        rnt          | |j
         |¦  «        |dz   }} Œ`|| |fS )ag  
    Find a shift of `f` in `K[x]` that has square-free norm.

    The domain `K` must be an algebraic number field `k(a)` (see :ref:`QQ(a)`).

    Returns `(s,g,r)`, such that `g(x)=f(x-sa)`, `r(x)=\text{Norm}(g(x))` and
    `r` is a square-free polynomial over `k`.

    Examples
    ========

    We first create the algebraic number field `K=k(a)=\mathbb{Q}(\sqrt{3})`
    and rings `K[x]` and `k[x]`:

    >>> from sympy.polys import ring, QQ
    >>> from sympy import sqrt

    >>> K = QQ.algebraic_field(sqrt(3))
    >>> R, x = ring("x", K)
    >>> _, X = ring("x", QQ)

    We can now find a square free norm for a shift of `f`:

    >>> f = x**2 - 1
    >>> s, g, r = R.dup_sqf_norm(f)

    The choice of shift `s` is arbitrary and the particular values returned for
    `g` and `r` are determined by `s`.

    >>> s == 1
    True
    >>> g == x**2 - 2*sqrt(3)*x + 2
    True
    >>> r == X**4 - 8*X**2 + 4
    True

    The invariants are:

    >>> g == f.shift(-s*K.unit)
    True
    >>> g.norm() == r
    True
    >>> r.is_squarefree
    True

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

    This is part of Trager's algorithm for factorizing polynomials over
    algebraic number fields. In particular this function is algorithm
    ``sqfr_norm`` from [Trager76]_.

    See Also
    ========

    dmp_sqf_norm:
        Analogous function for multivariate polynomials over ``k(a)``.
    dmp_norm:
        Computes the norm of `f` directly without any shift.
    dup_ext_factor:
        Function implementing Trager's algorithm that uses this.
    sympy.polys.polytools.sqf_norm:
        High-level interface for using this function.
    úground domain must be algebraicr   r:   T©Úfront)Úis_Algebraicr+   r   ÚmodÚto_listÚdomr   r&   rH   r   Úunit)r5   rG   ÚsÚgÚhÚ_Úrs          r1   Údup_sqf_normr]   i   s»   € ðB Œ>ð =ÝÐ;Ñ<Ô<Ð<à�i˜œŸš™œ¨¨A¨q¬uÑ5Ô5€q€Að3Ý˜!˜Q ¨Ð.Ñ.Ô.‰ˆˆ1Ý˜!˜Q  1¤5Ñ)Ô)ˆå�Q˜œÑÔð 	3Øå˜Q ¤ ¨Ñ+Ô+¨Q°©UˆqˆAð3ð ˆa�ˆ7€Nr3   c           
   #   ó°  ‡K  — |dz   }dg|z  }|| fV — |j         Št          | |¦  «        }d„ t          t          |t	          |dz   ¦  «        ¦  «        ¦  «        D ¦   «         }|D ]A}|                     ¦   «         }d||<   ˆfd„|D ¦   «         }	t          | |	||¦  «        }
||
fV — ŒBd}	 |dz  }|g|z  }‰ |z  g|z  }t          | |||¦  «        }||fV — Œ.)z9Generate a sequence of candidate shifts for dmp_sqf_norm.r:   r   c                 ó$   — g | ]\  }}|d k    ¯|‘ŒS )r   r<   )r.   ÚdirK   s      r1   r?   z(_dmp_sqf_norm_shifts.<locals>.<listcomp>Ï   s!   € ÐGÐGÐG™˜˜QÀÀQÂÀ�1ÀÀÀr3   c                 ó   •— g | ]}‰ |z  ‘Œ	S r<   r<   )r.   Ús1iÚas     €r1   r?   z(_dmp_sqf_norm_shifts.<locals>.<listcomp>Õ   s   ø€ Ð#Ð#Ð#˜ˆqˆb�‰fÐ#Ð#Ð#r3   )rW   r   Úsortedr@   rJ   Úcopyr   )r5   rB   rG   ÚnÚs0ÚdÚvar_indicesrK   Ús1Úa1Úf1ÚjÚsjÚajÚfjrc   s                  @r1   Ú_dmp_sqf_norm_shiftsrq   »   s+  øè è € ð 	
ˆA‰€AØ
ˆˆq‰€BØ
ˆaˆ%€K€K€Kð 	
Œ€Aõ 	˜˜1ÑÔ€AØGÐG¥&­¨Qµ°a¸±c±
´
Ñ);Ô);Ñ"<Ô"<ÐGÑGÔG€Kð ð ð ˆØ�WŠW‰YŒYˆØˆˆ1‰Ø#Ð#Ð#Ð# Ð#Ñ#Ô#ˆÝ�q˜"˜a Ñ#Ô#ˆØ�"ˆfˆˆˆˆð 	
€AðØ	ˆQ‰ˆØˆS�1‰WˆØˆb�‰dˆV�a‰ZˆÝ�q˜"˜a Ñ#Ô#ˆØ�"ˆfˆˆˆðr3   c                 ó�  — |st          | |¦  «        \  }}}|g||fS |j        st          d¦  «        ‚t          |j                             ¦   «         |dz   d|j        ¦  «        }t          | ||¦  «        D ]M\  }} t          | ||d¬¦  «        \  }}t          |||dz   |j        ¦  «        }t          |||j        ¦  «        r nŒN|| |fS )a  
    Find a shift of ``f`` in ``K[X]`` that has square-free norm.

    The domain `K` must be an algebraic number field `k(a)` (see :ref:`QQ(a)`).

    Returns `(s,g,r)`, such that `g(x_1,x_2,\cdots)=f(x_1-s_1 a, x_2 - s_2 a,
    \cdots)`, `r(x)=\text{Norm}(g(x))` and `r` is a square-free polynomial over
    `k`.

    Examples
    ========

    We first create the algebraic number field `K=k(a)=\mathbb{Q}(i)` and rings
    `K[x,y]` and `k[x,y]`:

    >>> from sympy.polys import ring, QQ
    >>> from sympy import I

    >>> K = QQ.algebraic_field(I)
    >>> R, x, y = ring("x,y", K)
    >>> _, X, Y = ring("x,y", QQ)

    We can now find a square free norm for a shift of `f`:

    >>> f = x*y + y**2
    >>> s, g, r = R.dmp_sqf_norm(f)

    The choice of shifts ``s`` is arbitrary and the particular values returned
    for ``g`` and ``r`` are determined by ``s``.

    >>> s
    [0, 1]
    >>> g == x*y - I*x + y**2 - 2*I*y - 1
    True
    >>> r == X**2*Y**2 + X**2 + 2*X*Y**3 + 2*X*Y + Y**4 + 2*Y**2 + 1
    True

    The required invariants are:

    >>> g == f.shift_list([-si*K.unit for si in s])
    True
    >>> g.norm() == r
    True
    >>> r.is_squarefree
    True

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

    This is part of Trager's algorithm for factorizing polynomials over
    algebraic number fields. In particular this function is a multivariate
    generalization of algorithm ``sqfr_norm`` from [Trager76]_.

    See Also
    ========

    dup_sqf_norm:
        Analogous function for univariate polynomials over ``k(a)``.
    dmp_norm:
        Computes the norm of `f` directly without any shift.
    dmp_ext_factor:
        Function implementing Trager's algorithm that uses this.
    sympy.polys.polytools.sqf_norm:
        High-level interface for using this function.
    rP   r:   r   TrQ   )r]   rS   r+   r   rT   rU   rV   rq   r   r&   rN   )r5   rB   rG   rX   rY   r\   rZ   r[   s           r1   Údmp_sqf_normrs   ã   së   € ðD ð Ý˜q !Ñ$Ô$‰ˆˆ1ˆaØˆs�A�qˆyÐàŒ>ð =ÝÐ;Ñ<Ô<Ð<å�!”%—-’-‘/”/ 1 q¡5¨!¨Q¬UÑ3Ô3€Aå$ Q¨¨1Ñ-Ô-ð ð ‰ˆˆ1å˜!˜Q ¨Ð.Ñ.Ô.‰ˆˆ1Ý˜!˜Q  A¡ q¤uÑ-Ô-ˆå�Q˜˜1œ5Ñ!Ô!ð 	ØˆEð	ð ˆa�ˆ7€Nr3   c                 óð   — |j         st          d¦  «        ‚t          |j                             ¦   «         |dz   d|j        ¦  «        }t          | ||d¬¦  «        \  }}t          |||dz   |j        ¦  «        S )aE	  
    Norm of ``f`` in ``K[X]``, often not square-free.

    The domain `K` must be an algebraic number field `k(a)` (see :ref:`QQ(a)`).

    Examples
    ========

    We first define the algebraic number field `K = k(a) = \mathbb{Q}(\sqrt{2})`:

    >>> from sympy import QQ, sqrt
    >>> from sympy.polys.sqfreetools import dmp_norm
    >>> k = QQ
    >>> K = k.algebraic_field(sqrt(2))

    We can now compute the norm of a polynomial `p` in `K[x,y]`:

    >>> p = [[K(1)], [K(1),K.unit]]                  # x + y + sqrt(2)
    >>> N = [[k(1)], [k(2),k(0)], [k(1),k(0),k(-2)]] # x**2 + 2*x*y + y**2 - 2
    >>> dmp_norm(p, 1, K) == N
    True

    In higher level functions that is:

    >>> from sympy import expand, roots, minpoly
    >>> from sympy.abc import x, y
    >>> from math import prod
    >>> a = sqrt(2)
    >>> e = (x + y + a)
    >>> e.as_poly([x, y], extension=a).norm()
    Poly(x**2 + 2*x*y + y**2 - 2, x, y, domain='QQ')

    This is equal to the product of the expressions `x + y + a_i` where the
    `a_i` are the conjugates of `a`:

    >>> pa = minpoly(a)
    >>> pa
    _x**2 - 2
    >>> rs = roots(pa, multiple=True)
    >>> rs
    [sqrt(2), -sqrt(2)]
    >>> n = prod(e.subs(a, r) for r in rs)
    >>> n
    (x + y - sqrt(2))*(x + y + sqrt(2))
    >>> expand(n)
    x**2 + 2*x*y + y**2 - 2

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

    Given an algebraic number field `K = k(a)` any element `b` of `K` can be
    represented as polynomial function `b=g(a)` where `g` is in `k[x]`. If the
    minimal polynomial of `a` over `k` is `p_a` then the roots `a_1`, `a_2`,
    `\cdots` of `p_a(x)` are the conjugates of `a`. The norm of `b` is the
    product `g(a1) \times g(a2) \times \cdots` and is an element of `k`.

    As in [Trager76]_ we extend this norm to multivariate polynomials over `K`.
    If `b(x)` is a polynomial in `k(a)[X]` then we can think of `b` as being
    alternately a function `g_X(a)` where `g_X` is an element of `k[X][y]` i.e.
    a polynomial function with coefficients that are elements of `k[X]`. Then
    the norm of `b` is the product `g_X(a1) \times g_X(a2) \times \cdots` and
    will be an element of `k[X]`.

    See Also
    ========

    dmp_sqf_norm:
        Compute a shift of `f` so that the `\text{Norm}(f)` is square-free.
    sympy.polys.polytools.Poly.norm:
        Higher-level function that calls this.
    rP   r:   r   TrQ   )rS   r+   r   rT   rU   rV   r   r&   )r5   rB   rG   rY   rZ   r[   s         r1   Údmp_normru   9  su   € ðP Œ>ð =ÝÐ;Ñ<Ô<Ð<å�!”%—-’-‘/”/ 1 q¡5¨!¨Q¬UÑ3Ô3€AÝ�a˜˜A TÐ*Ñ*Ô*�D€A€qå˜˜A˜q 1™u a¤eÑ,Ô,Ð,r3   c                 ó�   — t          | ||j        ¦  «        } t          | |j        |j        ¦  «        }t          ||j        |¦  «        S )z3Compute square-free part of ``f`` in ``GF(p)[x]``. )r   rV   r)   rT   )r5   rG   rY   s      r1   Údup_gf_sqf_partrw   Š  s>   € å�A�q˜!œ%Ñ Ô €AÝ�A�q”u˜aœeÑ$Ô$€AÝ�q˜!œ% Ñ#Ô#Ð#r3   c                 ó    — t          d¦  «        ‚)z3Compute square-free part of ``f`` in ``GF(p)[X]``. ú+multivariate polynomials over finite fields©ÚNotImplementedError©r5   rB   rG   s      r1   Údmp_gf_sqf_partr}   ‘  ó   € å
ÐKÑ
LÔ
LÐLr3   c                 óZ  — |j         rt          | |¦  «        S | s| S |                     t          | |¦  «        ¦  «        rt	          | |¦  «        } t          | t          | d|¦  «        |¦  «        }t          | ||¦  «        }|j        rt          ||¦  «        S t          ||¦  «        d         S )a  
    Returns square-free part of a polynomial in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_sqf_part(x**3 - 3*x - 2)
    x**2 - x - 2

    See Also
    ========

    sympy.polys.polytools.Poly.sqf_part
    r:   )Úis_FiniteFieldrw   Úis_negativer   r   r$   r   r	   Úis_Fieldr   r    )r5   rG   rM   Úsqfs       r1   Údup_sqf_partr„   –  s²   € ð$ 	Ôð %Ý˜q !Ñ$Ô$Ð$àð Øˆà‡}‚}•V˜A˜q‘\”\Ñ"Ô"ð Ý�A�q‰MŒMˆå
�!•X˜a  AÑ&Ô&¨Ñ
*Ô
*€CÝ
�!�S˜!Ñ
Ô
€Cà„zð (Ý˜˜aÑ Ô Ð å˜S !Ñ$Ô$ QÔ'Ð'r3   c                 óÚ  — |st          | |¦  «        S |j        rt          | ||¦  «        S t          | |¦  «        r| S |                     t          | ||¦  «        ¦  «        rt          | ||¦  «        } | }t          |dz   ¦  «        D ]%}t          |t          | d|||¦  «        ||¦  «        }Œ&t          | |||¦  «        }|j        rt          |||¦  «        S t          |||¦  «        d         S )zç
    Returns square-free part of a polynomial in ``K[X]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    >>> R.dmp_sqf_part(x**3 + 2*x**2*y + x*y**2)
    x**2 + x*y

    r:   )r„   r€   r}   r   r�   r   r   rJ   r%   r   r
   r‚   r   r!   )r5   rB   rG   rM   rK   rƒ   s         r1   Údmp_sqf_partr†   º  s
  € ð ð "Ý˜A˜qÑ!Ô!Ð!àÔð (Ý˜q ! QÑ'Ô'Ð'å�!�QÑÔð Øˆà‡}‚}•] 1 a¨Ñ+Ô+Ñ,Ô,ð Ý�A�q˜!ÑÔˆà
€CÝ�1�Q‘3‰ZŒZð =ð =ˆÝ�c�; q¨!¨Q°°1Ñ5Ô5°q¸!Ñ<Ô<ˆˆÝ
�!�S˜!˜QÑ
Ô
€Cà„zð 2Ý  Q¨Ñ*Ô*Ð*å# C¨¨AÑ.Ô.¨qÔ1Ð1r3   Fc                 ó2  — | }t          | ||j        ¦  «        } t          | |j        |j        |¬¦  «        \  }}t	          |¦  «        D ]#\  }\  } }t          | |j        |¦  «        |f||<   Œ$t          ||¦  «         |                     ||j        ¦  «        |fS )z<Compute square-free decomposition of ``f`` in ``GF(p)[x]``. ©Úall)r   rV   r(   rT   Ú	enumerater8   Úconvert)r5   rG   r‰   Úf_origÚcoeffÚfactorsrK   r0   s           r1   Údup_gf_sqf_listr�   ß  s    € à€Få�A�q˜!œ%Ñ Ô €Aå   A¤E¨1¬5°cÐ:Ñ:Ô:�N€Eˆ7å˜wÑ'Ô'ð 3ð 3‰	ˆ‰6ˆAˆqÝ! ! Q¤U¨AÑ.Ô.°Ð2ˆ�‰
ˆ
å�v˜wÑ'Ô'Ð'à�9Š9�U˜AœEÑ"Ô" GÐ+Ð+r3   c                 ó    — t          d¦  «        ‚)z<Compute square-free decomposition of ``f`` in ``GF(p)[X]``. ry   rz   )r5   rB   rG   r‰   s       r1   Údmp_gf_sqf_listr‘   ï  r~   r3   c                 óÌ  — |j         rt          | ||¬¦  «        S | }|j        r!t          | |¦  «        }t	          | |¦  «        } nIt          | |¦  «        \  }} |                     t          | |¦  «        ¦  «        rt          | |¦  «        } | }t          | ¦  «        dk    r|g fS g d}}t          | d|¦  «        }t          | ||¦  «        \  }}	}
	 t          |	d|¦  «        }t          |
||¦  «        }|s|                     |	|f¦  «         nGt          |	||¦  «        \  }}	}
|st          |¦  «        dk    r|                     ||f¦  «         |dz  }Œƒt          ||¦  «         ||fS )a÷  
    Return square-free decomposition of a polynomial in ``K[x]``.

    Uses Yun's algorithm from [Yun76]_.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> f = 2*x**5 + 16*x**4 + 50*x**3 + 76*x**2 + 56*x + 16

    >>> R.dup_sqf_list(f)
    (2, [(x + 1, 2), (x + 2, 3)])
    >>> R.dup_sqf_list(f, all=True)
    (2, [(1, 1), (x + 1, 2), (x + 2, 3)])

    See Also
    ========

    dmp_sqf_list:
        Corresponding function for multivariate polynomials.
    sympy.polys.polytools.sqf_list:
        High-level function for square-free factorization of expressions.
    sympy.polys.polytools.Poly.sqf_list:
        Analogous method on :class:`~.Poly`.

    References
    ==========

    [Yun76]_
    rˆ   r   r:   )r€   r�   r‚   r   r   r    r�   r   r   r   r"   r   Úappendr8   )r5   rG   r‰   rŒ   r�   r6   rK   rZ   rY   ÚpÚqrh   s               r1   Údup_sqf_listr–   ô  s–  € ðD 	Ôð .Ý˜q !¨Ð-Ñ-Ô-Ð-à€Fà„zð Ý�q˜!‘”ˆÝ�a˜‰OŒOˆˆå   AÑ&Ô&‰ˆˆqà�=Š=�  1™œÑ&Ô&ð 	Ý˜˜1‘”ˆAØ�FˆEå�!�}„}˜ÒÐØ�bˆyÐà�AˆA€Få��A�qÑÔ€AÝ˜A˜q !Ñ$Ô$�G€A€qˆ!ðÝ�Q˜˜1ÑÔˆÝ�A�q˜!ÑÔˆàð 	Ø�MŠM˜1˜a˜&Ñ!Ô!Ð!Øå  1 aÑ(Ô(‰ˆˆ1ˆaàð 	"•*˜Q‘-”- !Ò#Ð#Ø�MŠM˜1˜a˜&Ñ!Ô!Ð!à	ˆQ‰ˆðõ �v˜vÑ&Ô&Ð&à�&ˆ=Ðr3   c                 óÞ   — t          | ||¬¦  «        \  }}|r?|d         d         dk    r-t          |d         d         ||¦  «        }|dfg|dd…         z   S t          |g¦  «        }|dfg|z   S )a�  
    Return square-free decomposition of a polynomial in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> f = 2*x**5 + 16*x**4 + 50*x**3 + 76*x**2 + 56*x + 16

    >>> R.dup_sqf_list_include(f)
    [(2, 1), (x + 1, 2), (x + 2, 3)]
    >>> R.dup_sqf_list_include(f, all=True)
    [(2, 1), (x + 1, 2), (x + 2, 3)]

    rˆ   r   r:   N)r–   r   r   )r5   rG   r‰   r�   rŽ   rY   s         r1   Údup_sqf_list_includer˜   A  sˆ   € õ$ " ! Q¨CÐ0Ñ0Ô0�N€Eˆ7àð "�7˜1”:˜a”= AÒ%Ð%Ý˜7 1œ: aœ=¨%°Ñ3Ô3ˆØ�A�ˆx˜' ! " "œ+Ñ%Ð%å�u�gÑÔˆØ�A�ˆx˜'Ñ!Ð!r3   c                 óð  ‡— |st          | ||¬¦  «        S |j        rt          | |||¬¦  «        S | }|j        r#t	          | ||¦  «        }t          | ||¦  «        } nLt          | ||¦  «        \  }} |                     t	          | ||¦  «        ¦  «        rt          | ||¦  «        } | }t          | |¦  «        }|dk     r|g fS t          | ||¦  «        \  }} i Š|dk    rœt          | d||¦  «        }t          | |||¦  «        \  }	}
}d}	 t          |
d||¦  «        }t          ||||¦  «        }t          ||¦  «        r|
‰|<   n7t          |
|||¦  «        \  }	}
}|st          |	|¦  «        dk    r|	‰|<   |dz  }Œqt          ||dz
  ||¬¦  «        \  }}||z  }|D ]-\  }}|g}|‰v rt!          ‰|         |||¦  «        ‰|<   Œ(|‰|<   Œ.ˆfd„t#          ‰¦  «        D ¦   «         Št%          ||‰¦  «         |‰fS )a1  
    Return square-free decomposition of a polynomial in `K[X]`.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    >>> f = x**5 + 2*x**4*y + x**3*y**2

    >>> R.dmp_sqf_list(f)
    (1, [(x + y, 2), (x, 3)])
    >>> R.dmp_sqf_list(f, all=True)
    (1, [(1, 1), (x + y, 2), (x, 3)])

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

    Uses Yun's algorithm for univariate polynomials from [Yun76]_ recursively.
    The multivariate polynomial is treated as a univariate polynomial in its
    leading variable. Then Yun's algorithm computes the square-free
    factorization of the primitive and the content is factored recursively.

    It would be better to use a dedicated algorithm for multivariate
    polynomials instead.

    See Also
    ========

    dup_sqf_list:
        Corresponding function for univariate polynomials.
    sympy.polys.polytools.sqf_list:
        High-level function for square-free factorization of expressions.
    sympy.polys.polytools.Poly.sqf_list:
        Analogous method on :class:`~.Poly`.
    rˆ   r   r:   Tc                 ó$   •— g | ]}‰|         |f‘ŒS r<   r<   )r.   rK   r6   s     €r1   r?   z dmp_sqf_list.<locals>.<listcomp>Â  s!   ø€ Ð5Ð5Ð5 ˆv�aŒy˜!ˆnÐ5Ð5Ð5r3   )r–   r€   r‘   r‚   r   r   r!   r�   r   r   r'   r   r#   r   r   Údmp_sqf_listr   rd   rE   )r5   rB   rG   r‰   rŒ   r�   r7   ÚcontentrZ   rY   r”   r•   rK   rh   Úcoeff_contentÚresult_contentr/   r6   s                    @r1   r›   r›   ]  s…  ø€ ðL ð +Ý˜A˜q cÐ*Ñ*Ô*Ð*àÔð 1Ý˜q ! Q¨CÐ0Ñ0Ô0Ð0à€Fà„zð Ý˜a  AÑ&Ô&ˆÝ˜Q  1Ñ%Ô%ˆˆå'¨¨1¨aÑ0Ô0‰ˆˆqà�=Š=� q¨!¨QÑ/Ô/Ñ0Ô0ð 	Ý˜˜1˜aÑ Ô ˆAØ�FˆEå
�Q˜Ñ
Ô
€CØ
ˆQ‚w€wØ�bˆyÐõ ˜q ! QÑ'Ô'�J€GˆQà€Fà
ˆa‚x€xå�Q˜˜1˜aÑ Ô ˆÝ  1 a¨Ñ+Ô+‰ˆˆ1ˆaàˆð	Ý˜˜A˜q !Ñ$Ô$ˆAÝ˜˜1˜a Ñ#Ô#ˆAå˜!˜QÑÔð Ø��q‘	Øå# A q¨!¨QÑ/Ô/‰GˆAˆq�!àð •j  AÑ&Ô&¨Ò*Ð*Ø��q‘	à�‰FˆAð	õ %1°¸!¸A¹#¸qÀcÐ$JÑ$JÔ$JÑ!€M�>à	ˆ]Ñ€Eð !ð ð ‰ˆˆQØˆeˆØ�ˆ;ˆ;Ý  q¤	¨3°°1Ñ5Ô5ˆF�1‰IˆIàˆF�1‰IˆIà5Ð5Ð5Ð5¥f¨V¡n¤nÐ5Ñ5Ô5€Få�v˜q &Ñ)Ô)Ð)à�&ˆ=Ðr3   c                 ó
  — |st          | ||¬¦  «        S t          | |||¬¦  «        \  }}|r@|d         d         dk    r.t          |d         d         |||¦  «        }|dfg|dd…         z   S t          ||¦  «        }|dfg|z   S )ah  
    Return square-free decomposition of a polynomial in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    >>> f = x**5 + 2*x**4*y + x**3*y**2

    >>> R.dmp_sqf_list_include(f)
    [(1, 1), (x + y, 2), (x, 3)]
    >>> R.dmp_sqf_list_include(f, all=True)
    [(1, 1), (x + y, 2), (x, 3)]

    rˆ   r   r:   N)r˜   r›   r   r   )r5   rB   rG   r‰   r�   rŽ   rY   s          r1   Údmp_sqf_list_includer    É  s©   € ð$ ð 3Ý# A q¨cÐ2Ñ2Ô2Ð2å! ! Q¨¨sÐ3Ñ3Ô3�N€Eˆ7àð "�7˜1”:˜a”= AÒ%Ð%Ý˜7 1œ: aœ=¨%°°AÑ6Ô6ˆØ�A�ˆx˜' ! " "œ+Ñ%Ð%å�u˜aÑ Ô ˆØ�A�ˆx˜'Ñ!Ð!r3   c           
      ó¼  — | st          d¦  «        ‚t          | |¦  «        } t          | ¦  «        sg S t          | t	          | |j        |¦  «        |¦  «        }t          ||¦  «        }t          |¦  «        D ]<\  }\  }}t          |t	          | ||¦  «         |¦  «        |¦  «        }||dz   f||<   Œ=t          | ||¦  «        } t          | ¦  «        s|S | dfg|z   S )zû
    Compute greatest factorial factorization of ``f`` in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_gff_list(x**5 + 2*x**4 - x**3 - 2*x**2)
    [(x, 1), (x + 2, 4)]

    zDgreatest factorial factorization doesn't exist for a zero polynomialr:   )
Ú
ValueErrorr   r   r$   r   ÚoneÚdup_gff_listrŠ   r   r	   )r5   rG   rY   ÚHrK   rZ   r0   s          r1   r¤   r¤   è  sõ   € ð ð aÝÐ_Ñ`Ô`Ð`å�!�Q‰Œ€Aå�a‰=Œ=ð  Øˆ	å�A•y  A¤E¨1Ñ-Ô-¨qÑ1Ô1ˆÝ˜˜AÑÔˆå" 1™œð 	ð 	‰IˆA‰v��1Ý˜�9 Q¨¨¨1©¬¨¨qÑ1Ô1°1Ñ5Ô5ˆAØ�q˜1‘u�:ˆAˆa‰DˆDå�A�q˜!ÑÔˆå˜!‰}Œ}ð 	 ØˆHà˜�F�8˜a‘<Ðr3   c                 óD   — |st          | |¦  «        S t          | ¦  «        ‚)z¯
    Compute greatest factorial factorization of ``f`` in ``K[X]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    )r¤   r*   r|   s      r1   Údmp_gff_listr§     s*   € ð ð -Ý˜A˜qÑ!Ô!Ð!å)¨!Ñ,Ô,Ð,r3   N)F)DÚ__doc__Úsympy.polys.densearithr   r   r   r   r   r   r	   r
   r   r   Úsympy.polys.densebasicr   r   r   r   r   r   r   r   r   r   r   r   Úsympy.polys.densetoolsr   r   r   r   r   r   r   r    r!   Úsympy.polys.euclidtoolsr"   r#   r$   r%   r&   r'   Úsympy.polys.galoistoolsr(   r)   Úsympy.polys.polyerrorsr*   r+   r8   rE   rH   rN   r]   rq   rs   ru   rw   r}   r„   r†   r�   r‘   r–   r˜   r›   r    r¤   r§   r<   r3   r1   ú<module>r¯      s–  ðØ >Ð >ð$ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð)ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð )ð
"ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ðð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð
 ð  ð  ð0ð 0ð 0ð@ð @ð @ð,ð ð ðDOð Oð Oðd%ð %ð %ðPSð Sð SðlN-ð N-ð N-ðb$ð $ð $ðMð Mð Mð
!(ð !(ð !(ðH"2ð "2ð "2ðJ,ð ,ð ,ð ,ð Mð Mð Mð Mð
Jð Jð Jð JðZ"ð "ð "ð "ð8ið ið ið iðX"ð "ð "ð "ð>" ð " ð " ðJ-ð -ð -ð -ð -r3   