§
    OŠtjA+  ã                   óZ   — d Z ddlmZ ddlmZ  G d„ de¦  «        Z G d„ de¦  «        ZdS )	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$d!S )"Ú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/html/CA-Chatbot/venv/lib/python3.11/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                 óV   — |                       |¦  «        o|                      | ¦  «        S )z!Implementation of ideal equality.)r   r   s     r   Ú_equalszIdeal._equalsB   s)   € à×#Ò# AÑ&Ô&ÐB¨1×+<Ò+<¸TÑ+BÔ+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                 ó   — || _         d S ©N)Úring)r   r3   s     r   Ú__init__zIdeal.__init__j   s   € ØˆŒ	ˆ	ˆ	r   c                 ó„   — t          |t          ¦  «        r|j        | j        k    rt          d| j        ›d|›�¦  «        ‚dS )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   sR   € å˜!�UÑ#Ô#ð 	E q¤v°´Ò':Ð':Ý�*Ø6:´i°i°iÀÀÐCñEô Eð Eð (;Ð':r   c                 ó\   — |                       | 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×#4Ò#4°TÑ#:Ô#:Ñ;Ô;Ð;r   c                 óŽ   ‡ — t          |t          ¦  «        r‰                      |¦  «        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   óB   •K  — | ]}‰                      |¦  «        V — Œd S r2   )r   ©Ú.0r   r   s     €r   ú	<genexpr>zIdeal.subset.<locals>.<genexpr>˜   s1   øè è € Ð9Ð9¨a�4×&Ò& qÑ)Ô)Ð9Ð9Ð9Ð9Ð9Ð9r   )r6   r   r   Úall)r   Úothers   ` r   ÚsubsetzIdeal.subsetƒ   sN   ø€ õ& �e�UÑ#Ô#ð 	/Ø×'Ò'¨Ñ.Ô.Ð.ÝÐ9Ð9Ð9Ð9°5Ð9Ñ9Ô9Ñ9Ô9Ð9r   c                 óH   — |                       |¦  «          | 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š   s2   € ð  	×Ò˜!ÑÔÐØˆtŒ~˜aÐ(Ð( 4Ð(Ð(Ð(r   c                 óV   — |                       |¦  «         |                      |¦  «        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                 óV   — |                       |¦  «         |                      |¦  «        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                 óV   — |                       |¦  «         |                      |¦  «        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                 óV  — t          |t          ¦  «        sk| j                             | ¦  «        }t          ||j        ¦  «        r|S t          ||j        j        ¦  «        r ||¦  «        S |                     |¦  «        S |                      |¦  «         |                      |¦  «        S r2   )r6   r   r3   Úquotient_ringÚdtyper:   r8   rO   )r   ÚeÚRs      r   Ú__add__zIdeal.__add__ñ   s™   € Ý˜!�UÑ#Ô#ð 	 Ø”	×'Ò'¨Ñ-Ô-ˆAÝ˜!˜QœWÑ%Ô%ð Ø�Ý˜!˜QœVœ\Ñ*Ô*ð Ø�q˜‘t”t�Ø—9’9˜Q‘<”<ÐØ×Ò˜!ÑÔÐØ�zŠz˜!‰}Œ}Ðr   c                 óæ   — t          |t          ¦  «        s3	 | j                             |¦  «        }n# t          $ r
 t
          cY S w xY w|                      |¦  «         |                      |¦  «        S r2   )r6   r   r3   Úidealr   ÚNotImplementedr8   rR   ©r   rY   s     r   Ú__mul__zIdeal.__mul__þ   sy   € Ý˜!�UÑ#Ô#ð 	&ð&Ø”I—O’O AÑ&Ô&��øÝ!ð &ð &ð &Ý%Ð%Ð%Ð%ð&øøøà×Ò˜!ÑÔÐØ�|Š|˜A‰ŒÐs   —2 ²AÁAc                 ó6   — | j                              d¦  «        S ©Né   )r3   r]   r   s    r   Ú_zeroth_powerzIdeal._zeroth_power	  s   € ØŒy�Š˜qÑ!Ô!Ð!r   c                 ó   — | dz  S rb   rT   r   s    r   Ú_first_powerzIdeal._first_power  s   € ð �a‰xˆr   c                 óz   — t          |t          ¦  «        r|j        | j        k    rdS |                      |¦  «        S )NF)r6   r   r3   r    r_   s     r   Ú__eq__zIdeal.__eq__  s7   € Ý˜!�UÑ#Ô#ð 	 q¤v°´Ò':Ð':Ø�5Ø�|Š|˜A‰ŒÐr   c                 ó   — | |k     S r2   rT   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<   rD   rH   rJ   rL   rO   rR   rU   r[   Ú__radd__r`   Ú__rmul__rd   rf   rh   rj   rT   r   r   r   r      s  € € € € € ð ð  ðD"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ðCð Cð Cð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ðð ð ðEð Eð Eð<ð <ð <ð :ð :ð :ð.)ð )ð )ð&"ð "ð "ð "ð "ð "ðð ð ð ð  ð  ð$ð ð ð	ð 	ð 	ð €Hðð ð ð €Hð"ð "ð "ðð ð ð
ð ð ð
ð ð ð ð r   r   c                   óp   — 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dS )ÚModuleImplementedIdealzs
    Ideal implementation relying on the modules code.

    Attributes:

    - _module - the underlying module
    c                 óJ   — t                                | |¦  «         || _        d S r2   )r   r4   Ú_module)r   r3   Úmodules      r   r4   zModuleImplementedIdeal.__init__#  s!   € Ý�Š�t˜TÑ"Ô"Ð"ØˆŒˆˆr   c                 ó8   — | j                              |g¦  «        S r2   )rt   r<   r
   s     r   r   z%ModuleImplementedIdeal._contains_elem'  s   € ØŒ|×$Ò$ a SÑ)Ô)Ð)r   c                 óx   — t          |t          ¦  «        st          ‚| j                             |j        ¦  «        S r2   )r6   rr   r	   rt   Úis_submoduler   s     r   r   z&ModuleImplementedIdeal._contains_ideal*  s3   € Ý˜!Õ3Ñ4Ô4ð 	&Ý%Ð%ØŒ|×(Ò(¨¬Ñ3Ô3Ð3r   c                 óª   — t          |t          ¦  «        st          ‚|                      | j        | j                             |j        ¦  «        ¦  «        S r2   )r6   rr   r	   Ú	__class__r3   rt   rJ   r   s     r   r   z!ModuleImplementedIdeal._intersect/  sC   € Ý˜!Õ3Ñ4Ô4ð 	&Ý%Ð%Ø�~Š~˜dœi¨¬×)?Ò)?ÀÄ	Ñ)JÔ)JÑKÔKÐKr   c                 ój   — t          |t          ¦  «        st          ‚ | j        j        |j        fi |¤ŽS r2   )r6   rr   r	   rt   Úmodule_quotientrF   s      r   r   z ModuleImplementedIdeal._quotient4  s:   € Ý˜!Õ3Ñ4Ô4ð 	&Ý%Ð%Ø+ˆtŒ|Ô+¨A¬IÐ>Ð>¸Ð>Ð>Ð>r   c                 óª   — t          |t          ¦  «        st          ‚|                      | j        | j                             |j        ¦  «        ¦  «        S r2   )r6   rr   r	   rz   r3   rt   rO   r   s     r   rN   zModuleImplementedIdeal._union9  sC   € Ý˜!Õ3Ñ4Ô4ð 	&Ý%Ð%Ø�~Š~˜dœi¨¬×);Ò);¸A¼IÑ)FÔ)FÑGÔ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          V — ŒdS )r   NrT   )r@   r   s     r   rA   z.ModuleImplementedIdeal.gens.<locals>.<genexpr>K  s&   è è € Ð0Ð0˜��!”Ð0Ð0Ð0Ð0Ð0Ð0r   ©rt   Úgensr   s    r   r�   zModuleImplementedIdeal.gens>  s   € ð 1Ð0˜dœlÔ/Ð0Ñ0Ô0Ð0r   c                 ó4   — | 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
        )rt   r   r   s    r   r   zModuleImplementedIdeal.is_zeroM  s   € ð Œ|×#Ò#Ñ%Ô%Ð%r   c                 ó4   — | 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
        )rt   Úis_full_moduler   s    r   r   z$ModuleImplementedIdeal.is_whole_ring]  s   € ð  Œ|×*Ò*Ñ,Ô,Ð,r   c                 ó�   ‡ ‡— ddl mŠ ˆ fd„‰ j        j        D ¦   «         }dd                     ˆfd„|D ¦   «         ¦  «        z   dz   S )Nr   )Ússtrc                 óH   •— g | ]\  }‰j                              |¦  «        ‘ŒS rT   )r3   Úto_sympyr?   s     €r   ú
<listcomp>z3ModuleImplementedIdeal.__repr__.<locals>.<listcomp>q  s+   ø€ ÐCÐCÐC©#¨1�”	×"Ò" 1Ñ%Ô%ÐCÐCÐCr   ú<ú,c              3   ó.   •K  — | ]} ‰|¦  «        V — Œd S r2   rT   )r@   Úgr†   s     €r   rA   z2ModuleImplementedIdeal.__repr__.<locals>.<genexpr>r  s+   øè è € Ð4Ð4¨!˜d˜d 1™gœgÐ4Ð4Ð4Ð4Ð4Ð4r   ú>)Úsympy.printing.strr†   rt   r�   Újoin)r   r�   r†   s   ` @r   Ú__repr__zModuleImplementedIdeal.__repr__o  se   øø€ Ø+Ð+Ð+Ð+Ð+Ð+ØCÐCÐCÐC°´Ô1BÐCÑCÔCˆØ�S—X’XÐ4Ð4Ð4Ð4¨tÐ4Ñ4Ô4Ñ4Ô4Ñ4°sÑ:Ð:r   c                 ó¸   ‡— t          ‰t          ¦  «        st          ‚|                      | j         | j        j        ˆfd„| j        j        D ¦   «         Ž ¦  «        S )Nc                 óB   •— g | ]\  }‰j         j        D ]
\  }||z  g‘ŒŒS rT   r€   )r@   r   Úyr   s      €r   r‰   z3ModuleImplementedIdeal._product.<locals>.<listcomp>y  s4   ø€ ÐKÐKÐK™˜¸A¼I¼NÐKÐK±S°aˆq�‰sˆeÐKÐKÐKÐKr   )r6   rr   r	   rz   r3   rt   Ú	submoduler�   r   s    `r   rQ   zModuleImplementedIdeal._productu  se   ø€ Ý˜!Õ3Ñ4Ô4ð 	&Ý%Ð%Ø�~Š~˜dœiÐ)?¨¬Ô)?ØKÐKÐKÐK˜tœ|Ô0ÐKÑKÔKð*Mñ Nô Nð 	Nr   c                 ó8   — | 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)]
        )rt   Úin_terms_of_generatorsr_   s     r   r—   z-ModuleImplementedIdeal.in_terms_of_generators{  s   € ð Œ|×2Ò2°A°3Ñ7Ô7Ð7r   c                 ó6   —  | j         j        |gfi |¤Žd         S )Nr   )rt   rU   )r   r   Úoptionss      r   rU   z%ModuleImplementedIdeal.reduce_elementŠ  s&   € Ø*ˆtŒ|Ô*¨A¨3Ð:Ð:°'Ð:Ð:¸1Ô=Ð=r   N)rk   rl   rm   rn   r4   r   r   r   r   rN   Úpropertyr�   r   r   r‘   rQ   r—   rU   rT   r   r   rr   rr     sö   € € € € € ðð ðð ð ð*ð *ð *ð4ð 4ð 4ð
Lð Lð Lð
?ð ?ð ?ð
Hð Hð Hð
 ð1ð 1ñ „Xð1ð&ð &ð &ð -ð -ð -ð$;ð ;ð ;ðNð Nð Nð8ð 8ð 8ð>ð >ð >ð >ð >r   rr   N)rn   Úsympy.polys.polyerrorsr   Úsympy.polys.polyutilsr   r   rr   rT   r   r   ú<module>r�      s¡   ðØ 3Ð 3à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2ðPð Pð Pð Pð PÐñ Pô Pð Pðfq>ð q>ð q>ð q>ð q>˜Uñ q>ô q>ð q>ð q>ð q>r   