Ë
    7^(hA+  ã                   óL   — d Z ddlmZ ddlmZ  G d„ de«      Z G d„ de«      Zy)	z-Computations with ideals of polynomial rings.é    )ÚCoercionFailed)ÚIntegerPowerablec                   óÒ   — e 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d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZeZd„ ZeZ d„ Z!d„ Z"d„ Z#d „ Z$y!)"ÚIdealaŠ  
    Abstract base class for ideals.

    Do not instantiate - use explicit constructors in the ring class instead:

    >>> from sympy import QQ
    >>> from sympy.abc import x
    >>> QQ.old_poly_ring(x).ideal(x+1)
    <x + 1>

    Attributes

    - ring - the ring this ideal belongs to

    Non-implemented methods:

    - _contains_elem
    - _contains_ideal
    - _quotient
    - _intersect
    - _union
    - _product
    - is_whole_ring
    - is_zero
    - is_prime, is_maximal, is_primary, is_radical
    - is_principal
    - height, depth
    - radical

    Methods that likely should be overridden in subclasses:

    - reduce_element
    c                 ó   — t         ‚)z&Implementation of element containment.©ÚNotImplementedError©ÚselfÚxs     úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/polys/agca/ideals.pyÚ_contains_elemzIdeal._contains_elem*   ó   € ä!Ð!ó    c                 ó   — t         ‚)z$Implementation of ideal containment.r   )r   ÚIs     r   Ú_contains_idealzIdeal._contains_ideal.   r   r   c                 ó   — t         ‚)z!Implementation of ideal quotient.r   ©r   ÚJs     r   Ú	_quotientzIdeal._quotient2   r   r   c                 ó   — t         ‚)z%Implementation of ideal intersection.r   r   s     r   Ú
_intersectzIdeal._intersect6   r   r   c                 ó   — t         ‚)z*Return True if ``self`` is the whole ring.r   ©r   s    r   Úis_whole_ringzIdeal.is_whole_ring:   r   r   c                 ó   — t         ‚)z*Return True if ``self`` is the zero ideal.r   r   s    r   Úis_zerozIdeal.is_zero>   r   r   c                 óJ   — | j                  |«      xr |j                  | «      S )z!Implementation of ideal equality.)r   r   s     r   Ú_equalszIdeal._equalsB   s#   € à×#Ñ# AÓ&ÒB¨1×+<Ñ+<¸TÓ+BÐBr   c                 ó   — t         ‚)z)Return True if ``self`` is a prime ideal.r   r   s    r   Úis_primezIdeal.is_primeF   r   r   c                 ó   — t         ‚)z+Return True if ``self`` is a maximal ideal.r   r   s    r   Ú
is_maximalzIdeal.is_maximalJ   r   r   c                 ó   — t         ‚)z+Return True if ``self`` is a radical ideal.r   r   s    r   Ú
is_radicalzIdeal.is_radicalN   r   r   c                 ó   — t         ‚)z+Return True if ``self`` is a primary ideal.r   r   s    r   Ú
is_primaryzIdeal.is_primaryR   r   r   c                 ó   — t         ‚)z-Return True if ``self`` is a principal ideal.r   r   s    r   Úis_principalzIdeal.is_principalV   r   r   c                 ó   — t         ‚)z Compute the radical of ``self``.r   r   s    r   ÚradicalzIdeal.radicalZ   r   r   c                 ó   — t         ‚)zCompute the depth of ``self``.r   r   s    r   ÚdepthzIdeal.depth^   r   r   c                 ó   — t         ‚)zCompute the height of ``self``.r   r   s    r   ÚheightzIdeal.heightb   r   r   c                 ó   — || _         y ©N)Úring)r   r3   s     r   Ú__init__zIdeal.__init__j   s	   € Øˆ�	r   c                 óŒ   — t        |t        «      r|j                  | j                  k7  rt        d| j                  ›d|›�«      ‚y)z.Helper to check ``J`` is an ideal of our ring.zJ must be an ideal of z, got N)Ú
isinstancer   r3   Ú
ValueErrorr   s     r   Ú_check_idealzIdeal._check_idealm   s;   € ä˜!œUÔ# q§v¡v°·±Ò':ÝØ6:·i³iÁÐCóEð Eð (;r   c                 óV   — | j                  | j                  j                  |«      «      S )aD  
        Return True if ``elem`` is an element of this ideal.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x).ideal(x+1, x-1).contains(3)
        True
        >>> QQ.old_poly_ring(x).ideal(x**2, x**3).contains(x)
        False
        )r   r3   Úconvert)r   Úelems     r   ÚcontainszIdeal.containss   s$   € ð ×"Ñ" 4§9¡9×#4Ñ#4°TÓ#:Ó;Ð;r   c                 ón   ‡ — t        |t        «      r‰ j                  |«      S t        ˆ fd„|D «       «      S )aÃ  
        Returns True if ``other`` is is a subset of ``self``.

        Here ``other`` may be an ideal.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> I = QQ.old_poly_ring(x).ideal(x+1)
        >>> I.subset([x**2 - 1, x**2 + 2*x + 1])
        True
        >>> I.subset([x**2 + 1, x + 1])
        False
        >>> I.subset(QQ.old_poly_ring(x).ideal(x**2 - 1))
        True
        c              3   ó@   •K  — | ]  }‰j                  |«      –— Œ y ­wr2   )r   )Ú.0r   r   s     €r   ú	<genexpr>zIdeal.subset.<locals>.<genexpr>˜   s   øè ø€ Ò9¨a�4×&Ñ& q×)Ñ9ùs   ƒ)r6   r   r   Úall)r   Úothers   ` r   ÚsubsetzIdeal.subsetƒ   s1   ø€ ô& �eœUÔ#Ø×'Ñ'¨Ó.Ð.ÜÓ9°5Ô9Ó9Ð9r   c                 óJ   — | j                  |«        | j                  |fi |¤ŽS )a~  
        Compute the ideal quotient of ``self`` by ``J``.

        That is, if ``self`` is the ideal `I`, compute the set
        `I : J = \{x \in R | xJ \subset I \}`.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy import QQ
        >>> R = QQ.old_poly_ring(x, y)
        >>> R.ideal(x*y).quotient(R.ideal(x))
        <y>
        )r8   r   ©r   r   Úoptss      r   ÚquotientzIdeal.quotientš   s(   € ð  	×Ñ˜!ÔØˆt�~‰~˜aÑ( 4Ñ(Ð(r   c                 óF   — | j                  |«       | j                  |«      S )a  
        Compute the intersection of self with ideal J.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy import QQ
        >>> R = QQ.old_poly_ring(x, y)
        >>> R.ideal(x).intersect(R.ideal(y))
        <x*y>
        )r8   r   r   s     r   Ú	intersectzIdeal.intersect­   s!   € ð 	×Ñ˜!ÔØ�‰˜qÓ!Ð!r   c                 ó   — t         ‚)zÏ
        Compute the ideal saturation of ``self`` by ``J``.

        That is, if ``self`` is the ideal `I`, compute the set
        `I : J^\infty = \{x \in R | xJ^n \subset I \text{ for some } n\}`.
        r   r   s     r   ÚsaturatezIdeal.saturate½   s
   € ô "Ð!r   c                 óF   — | j                  |«       | j                  |«      S )aD  
        Compute the ideal generated by the union of ``self`` and ``J``.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x).ideal(x**2 - 1).union(QQ.old_poly_ring(x).ideal((x+1)**2)) == QQ.old_poly_ring(x).ideal(x+1)
        True
        )r8   Ú_unionr   s     r   ÚunionzIdeal.unionÇ   s    € ð 	×Ñ˜!ÔØ�{‰{˜1‹~Ðr   c                 óF   — | j                  |«       | j                  |«      S )a‡  
        Compute the ideal product of ``self`` and ``J``.

        That is, compute the ideal generated by products `xy`, for `x` an element
        of ``self`` and `y \in J`.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x, y).ideal(x).product(QQ.old_poly_ring(x, y).ideal(y))
        <x*y>
        )r8   Ú_productr   s     r   ÚproductzIdeal.productÖ   s!   € ð 	×Ñ˜!ÔØ�}‰}˜QÓÐr   c                 ó   — |S )zâ
        Reduce the element ``x`` of our ring modulo the ideal ``self``.

        Here "reduce" has no specific meaning: it could return a unique normal
        form, simplify the expression a bit, or just do nothing.
        © r
   s     r   Úreduce_elementzIdeal.reduce_elementè   s	   € ð ˆr   c                 ó>  — t        |t        «      sl| j                  j                  | «      }t        ||j                  «      r|S t        ||j                  j                  «      r ||«      S |j                  |«      S | j                  |«       | j                  |«      S r2   )r6   r   r3   Úquotient_ringÚdtyper:   r8   rN   )r   ÚeÚRs      r   Ú__add__zIdeal.__add__ñ   sx   € Ü˜!œUÔ#Ø—	‘	×'Ñ'¨Ó-ˆAÜ˜!˜QŸW™WÔ%Ø�Ü˜!˜QŸV™VŸ\™\Ô*Ù˜“t�Ø—9‘9˜Q“<ÐØ×Ñ˜!ÔØ�z‰z˜!‹}Ðr   c                 óÈ   — t        |t        «      s	 | j                  j                  |«      }| j                  |«       | j                  |«      S # t        $ r	 t
        cY S w xY wr2   )r6   r   r3   Úidealr   ÚNotImplementedr8   rQ   ©r   rX   s     r   Ú__mul__zIdeal.__mul__þ   sX   € Ü˜!œUÔ#ð&Ø—I‘I—O‘O AÓ&�ð 	×Ñ˜!ÔØ�|‰|˜A‹Ðøô "ò &Ü%Ò%ð&ús   ’A ÁA!Á A!c                 ó8   — | j                   j                  d«      S ©Né   )r3   r\   r   s    r   Ú_zeroth_powerzIdeal._zeroth_power	  s   € Ø�y‰y�‰˜qÓ!Ð!r   c                 ó   — | dz  S ra   rS   r   s    r   Ú_first_powerzIdeal._first_power  s   € ð �a‰xˆr   c                 óx   — t        |t        «      r|j                  | j                  k7  ry| j                  |«      S )NF)r6   r   r3   r    r^   s     r   Ú__eq__zIdeal.__eq__  s,   € Ü˜!œUÔ# q§v¡v°·±Ò':ØØ�|‰|˜A‹Ðr   c                 ó   — | |k(   S r2   rS   r^   s     r   Ú__ne__zIdeal.__ne__  s   € Ø˜A‘IˆÐr   N)%Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r    r"   r$   r&   r(   r*   r,   r.   r0   r4   r8   r<   rC   rG   rI   rK   rN   rQ   rT   rZ   Ú__radd__r_   Ú__rmul__rc   re   rg   ri   rS   r   r   r   r      s³   „ ñ òD"ò"ò"ò"ò"ò"òCò"ò"ò"ò"ò"ò"ò"ò"òòEò<ò :ò.)ò&"ò "òò ò$ò	ð €Hòð €Hò"òò
ó
r   r   c                   óh   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	e
d„ «       Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zy)ÚModuleImplementedIdealzs
    Ideal implementation relying on the modules code.

    Attributes:

    - _module - the underlying module
    c                 ó>   — t         j                  | |«       || _        y r2   )r   r4   Ú_module)r   r3   Úmodules      r   r4   zModuleImplementedIdeal.__init__#  s   € Ü�‰�t˜TÔ"Øˆ�r   c                 ó:   — | j                   j                  |g«      S r2   )rs   r<   r
   s     r   r   z%ModuleImplementedIdeal._contains_elem'  s   € Ø�|‰|×$Ñ$ a SÓ)Ð)r   c                 óx   — t        |t        «      st        ‚| j                  j	                  |j                  «      S r2   )r6   rq   r	   rs   Úis_submoduler   s     r   r   z&ModuleImplementedIdeal._contains_ideal*  s,   € Ü˜!Ô3Ô4Ü%Ð%Ø�|‰|×(Ñ(¨¯©Ó3Ð3r   c                 ó¬   — t        |t        «      st        ‚| j                  | j                  | j
                  j                  |j
                  «      «      S r2   )r6   rq   r	   Ú	__class__r3   rs   rI   r   s     r   r   z!ModuleImplementedIdeal._intersect/  s;   € Ü˜!Ô3Ô4Ü%Ð%Ø�~‰~˜dŸi™i¨¯©×)?Ñ)?ÀÇ	Á	Ó)JÓKÐKr   c                 ó|   — t        |t        «      st        ‚ | j                  j                  |j                  fi |¤ŽS r2   )r6   rq   r	   rs   Úmodule_quotientrE   s      r   r   z ModuleImplementedIdeal._quotient4  s3   € Ü˜!Ô3Ô4Ü%Ð%Ø+ˆt�|‰|×+Ñ+¨A¯I©IÑ>¸Ñ>Ð>r   c                 ó¬   — t        |t        «      st        ‚| j                  | j                  | j
                  j                  |j
                  «      «      S r2   )r6   rq   r	   ry   r3   rs   rN   r   s     r   rM   zModuleImplementedIdeal._union9  s;   € Ü˜!Ô3Ô4Ü%Ð%Ø�~‰~˜dŸi™i¨¯©×);Ñ);¸A¿I¹IÓ)FÓGÐGr   c                 ó<   — d„ | j                   j                  D «       S )aB  
        Return generators for ``self``.

        Examples
        ========

        >>> from sympy import QQ
        >>> from sympy.abc import x, y
        >>> list(QQ.old_poly_ring(x, y).ideal(x, y, x**2 + y).gens)
        [DMP_Python([[1], []], QQ), DMP_Python([[1, 0]], QQ), DMP_Python([[1], [], [1, 0]], QQ)]
        c              3   ó&   K  — | ]	  }|d    –— Œ y­w)r   NrS   )r?   r   s     r   r@   z.ModuleImplementedIdeal.gens.<locals>.<genexpr>K  s   è ø€ Ò0˜��!•Ñ0ùs   ‚)rs   Úgensr   s    r   r   zModuleImplementedIdeal.gens>  s   € ñ 1˜dŸl™l×/Ñ/Ô0Ð0r   c                 ó6   — | j                   j                  «       S )a%  
        Return True if ``self`` is the zero ideal.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x).ideal(x).is_zero()
        False
        >>> QQ.old_poly_ring(x).ideal().is_zero()
        True
        )rs   r   r   s    r   r   zModuleImplementedIdeal.is_zeroM  s   € ð �|‰|×#Ñ#Ó%Ð%r   c                 ó6   — | j                   j                  «       S )a¬  
        Return True if ``self`` is the whole ring, i.e. one generator is a unit.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy import QQ, ilex
        >>> QQ.old_poly_ring(x).ideal(x).is_whole_ring()
        False
        >>> QQ.old_poly_ring(x).ideal(3).is_whole_ring()
        True
        >>> QQ.old_poly_ring(x, order=ilex).ideal(2 + x).is_whole_ring()
        True
        )rs   Úis_full_moduler   s    r   r   z$ModuleImplementedIdeal.is_whole_ring]  s   € ð  �|‰|×*Ñ*Ó,Ð,r   c                 óÖ   ‡— ddl mŠ | j                  j                  D �cg c]  \  }| j                  j                  |«      ‘Œ! }}ddj                  ˆfd„|D «       «      z   dz   S c c}w )Nr   )Ússtrú<ú,c              3   ó.   •K  — | ]  } ‰|«      –— Œ y ­wr2   rS   )r?   Úgr„   s     €r   r@   z2ModuleImplementedIdeal.__repr__.<locals>.<genexpr>r  s   øè ø€ Ò4¨!™d 1ŸgÑ4ùs   ƒú>)Úsympy.printing.strr„   rs   r   r3   Úto_sympyÚjoin)r   r   r   r„   s      @r   Ú__repr__zModuleImplementedIdeal.__repr__o  sY   ø€ Ý+Ø15·±×1BÑ1BÖC©#¨1�—	‘	×"Ñ" 1Õ%ÐCˆÐCØ�S—X‘XÓ4¨tÔ4Ó4Ñ4°sÑ:Ð:ùò Ds    $A&c                 ó.  — t        |t        «      st        ‚| j                  | j                   | j
                  j                  | j
                  j                  D ��cg c]'  \  }|j
                  j                  D ]
  \  }||z  g‘Œ Œ) c}}Ž «      S c c}}w r2   )r6   rq   r	   ry   r3   rs   Ú	submoduler   )r   r   r   Úys       r   rP   zModuleImplementedIdeal._productu  sz   € Ü˜!Ô3Ô4Ü%Ð%Ø�~‰~˜dŸi™iÐ)?¨¯©×)?Ñ)?Ø#Ÿ|™|×0Ñ0×K™˜¸A¿I¹I¿N¹NÒK±S°aˆq�‰sŠeÐKˆeÓKð*Mó Nð 	NùÛKs   Á,Bc                 ó:   — | j                   j                  |g«      S )aX  
        Express ``e`` in terms of the generators of ``self``.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> I = QQ.old_poly_ring(x).ideal(x**2 + 1, x)
        >>> I.in_terms_of_generators(1)  # doctest: +SKIP
        [DMP_Python([1], QQ), DMP_Python([-1, 0], QQ)]
        )rs   Úin_terms_of_generatorsr^   s     r   r’   z-ModuleImplementedIdeal.in_terms_of_generators{  s   € ð �|‰|×2Ñ2°A°3Ó7Ð7r   c                 óD   —  | j                   j                  |gfi |¤Žd   S )Nr   )rs   rT   )r   r   Úoptionss      r   rT   z%ModuleImplementedIdeal.reduce_elementŠ  s%   € Ø*ˆt�|‰|×*Ñ*¨A¨3Ñ:°'Ñ:¸1Ñ=Ð=r   N)rj   rk   rl   rm   r4   r   r   r   r   rM   Úpropertyr   r   r   r�   rP   r’   rT   rS   r   r   rq   rq     sZ   „ ñòò*ò4ò
Lò
?ò
Hð
 ñ1ó ð1ò&ò -ò$;òNò8ó>r   rq   N)rm   Úsympy.polys.polyerrorsr   Úsympy.polys.polyutilsr   r   rq   rS   r   r   ú<module>r˜      s,   ðÙ 3å 1Ý 2ôPÐô Pôfq>˜Uõ q>r   