ó
    Š*£hA+  ã                   óL   • S r SSKJr  SSKJr   " S S\5      r " S S\5      rg)	z-Computations with ideals of polynomial rings.é    )ÚCoercionFailed)ÚIntegerPowerablec                   óÚ   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r\rS r \ r!S r"S r#S  r$S! r%S"r&g#)$ÚIdealé   a*  
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                 ó   • [         e)z&Implementation of element containment.©ÚNotImplementedError©ÚselfÚxs     ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/agca/ideals.pyÚ_contains_elemÚIdeal._contains_elem*   ó   € ä!Ð!ó    c                 ó   • [         e)z$Implementation of ideal containment.r	   )r   ÚIs     r   Ú_contains_idealÚIdeal._contains_ideal.   r   r   c                 ó   • [         e)z!Implementation of ideal quotient.r	   ©r   ÚJs     r   Ú	_quotientÚIdeal._quotient2   r   r   c                 ó   • [         e)z%Implementation of ideal intersection.r	   r   s     r   Ú
_intersectÚIdeal._intersect6   r   r   c                 ó   • [         e)z*Return True if ``self`` is the whole ring.r	   ©r   s    r   Úis_whole_ringÚIdeal.is_whole_ring:   r   r   c                 ó   • [         e)z*Return True if ``self`` is the zero ideal.r	   r    s    r   Úis_zeroÚIdeal.is_zero>   r   r   c                 óT   • U R                  U5      =(       a    UR                  U 5      $ )z!Implementation of ideal equality.)r   r   s     r   Ú_equalsÚIdeal._equalsB   s#   € à×#Ñ# AÓ&×B¨1×+<Ñ+<¸TÓ+BÐBr   c                 ó   • [         e)z)Return True if ``self`` is a prime ideal.r	   r    s    r   Úis_primeÚIdeal.is_primeF   r   r   c                 ó   • [         e)z+Return True if ``self`` is a maximal ideal.r	   r    s    r   Ú
is_maximalÚIdeal.is_maximalJ   r   r   c                 ó   • [         e)z+Return True if ``self`` is a radical ideal.r	   r    s    r   Ú
is_radicalÚIdeal.is_radicalN   r   r   c                 ó   • [         e)z+Return True if ``self`` is a primary ideal.r	   r    s    r   Ú
is_primaryÚIdeal.is_primaryR   r   r   c                 ó   • [         e)z-Return True if ``self`` is a principal ideal.r	   r    s    r   Úis_principalÚIdeal.is_principalV   r   r   c                 ó   • [         e)z Compute the radical of ``self``.r	   r    s    r   ÚradicalÚIdeal.radicalZ   r   r   c                 ó   • [         e)zCompute the depth of ``self``.r	   r    s    r   ÚdepthÚIdeal.depth^   r   r   c                 ó   • [         e)zCompute the height of ``self``.r	   r    s    r   ÚheightÚIdeal.heightb   r   r   c                 ó   • Xl         g ©N©Úring)r   rD   s     r   Ú__init__ÚIdeal.__init__j   s   € Ø�	r   c                 óœ   • [        U[        5      (       a  UR                  U R                  :w  a  [        SU R                  < SU< 35      eg)z.Helper to check ``J`` is an ideal of our ring.zJ must be an ideal of z, got N)Ú
isinstancer   rD   Ú
ValueErrorr   s     r   Ú_check_idealÚIdeal._check_idealm   s>   € ä˜!œU×#Ñ# q§v¡v°·±Ó':ÝØ6:·i´iÂÐCóEð Eð (;r   c                 óV   • U R                  U R                  R                  U5      5      $ )zô
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   rD   Úconvert)r   Úelems     r   ÚcontainsÚIdeal.containss   s$   € ð ×"Ñ" 4§9¡9×#4Ñ#4°TÓ#:Ó;Ð;r   c                 óz   ^ • [        U[        5      (       a  T R                  U5      $ [        U 4S jU 5       5      $ )aS  
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   óF   >#   • U  H  nTR                  U5      v •  M     g 7frB   )r   )Ú.0r   r   s     €r   Ú	<genexpr>ÚIdeal.subset.<locals>.<genexpr>˜   s   øé € Ð9²5¨a�4×&Ñ& q×)Ð)²5ùs   ƒ!)rH   r   r   Úall)r   Úothers   ` r   ÚsubsetÚIdeal.subsetƒ   s4   ø€ ô& �eœU×#Ñ#Ø×'Ñ'¨Ó.Ð.ÜÔ9±5Ó9Ó9Ð9r   c                 óJ   • U R                  U5        U R                  " U40 UD6$ )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>
)rJ   r   ©r   r   Úoptss      r   ÚquotientÚIdeal.quotientš   s&   € ð  	×Ñ˜!ÔØ�~Š~˜aÑ( 4Ñ(Ð(r   c                 óF   • U R                  U5        U R                  U5      $ )zÆ
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>
)rJ   r   r   s     r   Ú	intersectÚIdeal.intersect­   s!   € ð 	×Ñ˜!ÔØ�‰˜qÓ!Ð!r   c                 ó   • [         e)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   ÚsaturateÚIdeal.saturate½   s
   € ô "Ð!r   c                 óF   • U R                  U5        U R                  U5      $ )a  
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
)rJ   Ú_unionr   s     r   ÚunionÚIdeal.unionÇ   s    € ð 	×Ñ˜!ÔØ�{‰{˜1‹~Ðr   c                 óF   • U R                  U5        U R                  U5      $ )a7  
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>
)rJ   Ú_productr   s     r   ÚproductÚIdeal.productÖ   s!   € ð 	×Ñ˜!ÔØ�}‰}˜QÓÐr   c                 ó   • U$ )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_elementÚIdeal.reduce_elementè   s	   € ð ˆr   c                 óX  • [        U[        5      (       dt  U R                  R                  U 5      n[        XR                  5      (       a  U$ [        XR                  R                  5      (       a  U" U5      $ UR                  U5      $ U R                  U5        U R                  U5      $ rB   )rH   r   rD   Úquotient_ringÚdtyperM   rJ   rg   )r   ÚeÚRs      r   Ú__add__ÚIdeal.__add__ñ   s}   € Ü˜!œU×#Ñ#Ø—	‘	×'Ñ'¨Ó-ˆAÜ˜!ŸW™W×%Ñ%Ø�Ü˜!ŸV™VŸ\™\×*Ñ*Ù˜“t�Ø—9‘9˜Q“<ÐØ×Ñ˜!ÔØ�z‰z˜!‹}Ðr   c                 óÔ   • [        U[        5      (       d   U R                  R                  U5      nU R                  U5        U R                  U5      $ ! [         a	    [
        s $ f = frB   )rH   r   rD   Úidealr   ÚNotImplementedrJ   rk   ©r   rt   s     r   Ú__mul__ÚIdeal.__mul__þ   s[   € Ü˜!œU×#Ñ#ð&Ø—I‘I—O‘O AÓ&�ð 	×Ñ˜!ÔØ�|‰|˜A‹Ðøô "ó &Ü%Ò%ð&ús   —A ÁA'Á&A'c                 ó8   • U R                   R                  S5      $ ©Né   )rD   ry   r    s    r   Ú_zeroth_powerÚIdeal._zeroth_power	  s   € Ø�y‰y�‰˜qÓ!Ð!r   c                 ó   • U S-  $ r   rn   r    s    r   Ú_first_powerÚIdeal._first_power  s   € ð �a‰xˆr   c                 ó„   • [        U[        5      (       a  UR                  U R                  :w  a  gU R                  U5      $ )NF)rH   r   rD   r'   r{   s     r   Ú__eq__ÚIdeal.__eq__  s/   € Ü˜!œU×#Ñ# q§v¡v°·±Ó':ØØ�|‰|˜A‹Ðr   c                 ó   • X:X  + $ rB   rn   r{   s     r   Ú__ne__ÚIdeal.__ne__  s
   € ØŠÐr   rC   N)'Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   r!   r$   r'   r*   r-   r0   r3   r6   r9   r<   r?   rE   rJ   rO   rX   r]   r`   rc   rg   rk   ro   rv   Ú__radd__r|   Ú__rmul__r�   r„   r‡   rŠ   Ú__static_attributes__rn   r   r   r   r      s³   † ñ òD"ò"ò"ò"ò"ò"òCò"ò"ò"ò"ò"ò"ò"ò"òòEò<ò :ò.)ò&"ò "òò ò$ò	ð €Hòð €Hò"òò
õ
r   r   c                   óp   • \ rS rSrSrS rS rS rS rS r	S r
\S	 5       rS
 rS rS rS rS rS rSrg)ÚModuleImplementedIdeali  zc
Ideal implementation relying on the modules code.

Attributes:

- _module - the underlying module
c                 ó:   • [         R                  X5        X l        g rB   )r   rE   Ú_module)r   rD   Úmodules      r   rE   ÚModuleImplementedIdeal.__init__#  s   € Ü�‰�tÔ"Ø�r   c                 ó:   • U R                   R                  U/5      $ rB   )r—   rO   r   s     r   r   Ú%ModuleImplementedIdeal._contains_elem'  s   € Ø�|‰|×$Ñ$ a SÓ)Ð)r   c                 ó‚   • [        U[        5      (       d  [        eU R                  R	                  UR                  5      $ rB   )rH   r•   r
   r—   Úis_submoduler   s     r   r   Ú&ModuleImplementedIdeal._contains_ideal*  s/   € Ü˜!Ô3×4Ñ4Ü%Ð%Ø�|‰|×(Ñ(¨¯©Ó3Ð3r   c                 ó¶   • [        U[        5      (       d  [        eU R                  U R                  U R
                  R                  UR
                  5      5      $ rB   )rH   r•   r
   Ú	__class__rD   r—   r`   r   s     r   r   Ú!ModuleImplementedIdeal._intersect/  s>   € Ü˜!Ô3×4Ñ4Ü%Ð%Ø�~‰~˜dŸi™i¨¯©×)?Ñ)?ÀÇ	Á	Ó)JÓKÐKr   c                 ó†   • [        U[        5      (       d  [        eU R                  R                  " UR                  40 UD6$ rB   )rH   r•   r
   r—   Úmodule_quotientr[   s      r   r   Ú ModuleImplementedIdeal._quotient4  s4   € Ü˜!Ô3×4Ñ4Ü%Ð%Ø�|‰|×+Ò+¨A¯I©IÑ>¸Ñ>Ð>r   c                 ó¶   • [        U[        5      (       d  [        eU R                  U R                  U R
                  R                  UR
                  5      5      $ rB   )rH   r•   r
   r    rD   r—   rg   r   s     r   rf   ÚModuleImplementedIdeal._union9  s>   € Ü˜!Ô3×4Ñ4Ü%Ð%Ø�~‰~˜dŸi™i¨¯©×);Ñ);¸A¿I¹IÓ)FÓGÐGr   c                 ó<   • S U R                   R                   5       $ )a  
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   ó*   #   • U  H	  oS    v •  M     g7f)r   Nrn   )rS   r   s     r   rT   Ú.ModuleImplementedIdeal.gens.<locals>.<genexpr>K  s   é € Ð0Ò/˜�!–Ò/ùs   ‚)r—   Úgensr    s    r   rª   ÚModuleImplementedIdeal.gens>  s   € ñ 1˜dŸl™l×/Ò/Ó0Ð0r   c                 ó6   • U R                   R                  5       $ )zÕ
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
)r—   r$   r    s    r   r$   ÚModuleImplementedIdeal.is_zeroM  s   € ð �|‰|×#Ñ#Ó%Ð%r   c                 ó6   • U R                   R                  5       $ )aL  
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
)r—   Úis_full_moduler    s    r   r!   Ú$ModuleImplementedIdeal.is_whole_ring]  s   € ð  �|‰|×*Ñ*Ó,Ð,r   c                 óÜ   ^• SSK Jm  U R                  R                   Vs/ s H  u  oR                  R                  U5      PM!     nnSSR                  U4S jU 5       5      -   S-   $ s  snf )Nr   )ÚsstrÚ<Ú,c              3   ó4   >#   • U  H  nT" U5      v •  M     g 7frB   rn   )rS   Úgr²   s     €r   rT   Ú2ModuleImplementedIdeal.__repr__.<locals>.<genexpr>r  s   øé € Ð4ªt¨!™d 1Ÿg˜gªtùs   ƒÚ>)Úsympy.printing.strr²   r—   rª   rD   Úto_sympyÚjoin)r   r   rª   r²   s      @r   Ú__repr__ÚModuleImplementedIdeal.__repr__o  sZ   ø€ Ý+Ø15·±×1BÒ1BÓCÒ1B©#¨1—	‘	×"Ñ" 1Ö%Ñ1BˆÐCØ�S—X‘XÔ4©tÓ4Ó4Ñ4°sÑ:Ð:ùò Ds    &A)c                 ó@  • [        U[        5      (       d  [        eU R                  U R                  U R
                  R                  " U R
                  R                   VVs/ s H)  u  o!R
                  R                    H
  u  o2U-  /PM     M+     snn6 5      $ s  snnf rB   )rH   r•   r
   r    rD   r—   Ú	submodulerª   )r   r   r   Úys       r   rj   ÚModuleImplementedIdeal._productu  sx   € Ü˜!Ô3×4Ñ4Ü%Ð%Ø�~‰~˜dŸi™i¨¯©×)?Ò)?Ø#Ÿ|™|×0Ò0ÔKÒ0™˜¿I¹I¿N½N±S°a�‰s‹e¹N‰eÑ0ÒKð*Mó Nð 	NùÛKs   Á!0Bc                 ó:   • U R                   R                  U/5      $ )a  
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)]
)r—   Úin_terms_of_generatorsr{   s     r   rÃ   Ú-ModuleImplementedIdeal.in_terms_of_generators{  s   € ð �|‰|×2Ñ2°A°3Ó7Ð7r   c                 óD   • U R                   R                  " U/40 UD6S   $ )Nr   )r—   ro   )r   r   Úoptionss      r   ro   Ú%ModuleImplementedIdeal.reduce_elementŠ  s#   € Ø�|‰|×*Ò*¨A¨3Ñ:°'Ñ:¸1Ñ=Ð=r   )r—   N)rŒ   r�   rŽ   r�   r�   rE   r   r   r   r   rf   Úpropertyrª   r$   r!   r¼   rj   rÃ   ro   r“   rn   r   r   r•   r•     sZ   † ñòò*ò4ò
Lò
?ò
Hð
 ñ1ó ð1ò&ò -ò$;òNò8õ>r   r•   N)r�   Úsympy.polys.polyerrorsr   Úsympy.polys.polyutilsr   r   r•   rn   r   r   Ú<module>rË      s,   ðÙ 3å 1Ý 2ôPÐô Pôfq>˜Uõ q>r   