
    \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     O/var/www/auris/envauris/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&B1+<+<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##qvv':6:ii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$     ""499#4#4T#:;;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     95a4&&q))5s   !)rH   r   r   all)r   others   ` r   subsetIdeal.subset   s4    & eU##''..95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!WW%%!VV\\**t99Q<!zz!}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##&IIOOA& 	!||A " &%%&s   A A'&A'c                 8    U R                   R                  S5      $ N   )rD   ry   r    s    r   _zeroth_powerIdeal._zeroth_power	  s    yyq!!r   c                     U S-  $ r   rn   r    s    r   _first_powerIdeal._first_power  s     ax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##qvv':||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    ||$$aS))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%%~~dii)?)?		)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%%||++AII>>>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%%~~dii););AII)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     1dll//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     4t!d1ggts   >)sympy.printing.strr   r   r   rD   to_sympyjoin)r   r   r   r   s      @r   __repr__ModuleImplementedIdeal.__repr__o  sZ    +151B1BC1B#1		""1%1BCSXX4t444s:: 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%%~~dii)?)?#||00K0IINNSaseNe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2A3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#    ||**A3:':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   