+
    iA+                     N    R t ^ RIHt ^ RIHt  ! R R]4      t ! R R]4      tR# )z-Computations with ideals of polynomial rings.)CoercionFailed)IntegerPowerablec                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t]tR t ] t!R t"R t#R t$R  t%R!t&V t'R"# )#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                    \         h)z&Implementation of element containment.NotImplementedErrorselfxs   &&w/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/agca/ideals.py_contains_elemIdeal._contains_elem*       !!    c                    \         h)z$Implementation of ideal containment.r   )r
   Is   &&r   _contains_idealIdeal._contains_ideal.   r   r   c                    \         h)z!Implementation of ideal quotient.r   r
   Js   &&r   	_quotientIdeal._quotient2   r   r   c                    \         h)z%Implementation of ideal intersection.r   r   s   &&r   
_intersectIdeal._intersect6   r   r   c                    \         h)z*Return True if ``self`` is the whole ring.r   r
   s   &r   is_whole_ringIdeal.is_whole_ring:   r   r   c                    \         h)z*Return True if ``self`` is the zero ideal.r   r   s   &r   is_zeroIdeal.is_zero>   r   r   c                V    V P                  V4      ;'       d    VP                  V 4      # )z!Implementation of ideal equality.)r   r   s   &&r   _equalsIdeal._equalsB   s&    ##A&BB1+<+<T+BBr   c                    \         h)z)Return True if ``self`` is a prime ideal.r   r   s   &r   is_primeIdeal.is_primeF   r   r   c                    \         h)z+Return True if ``self`` is a maximal ideal.r   r   s   &r   
is_maximalIdeal.is_maximalJ   r   r   c                    \         h)z+Return True if ``self`` is a radical ideal.r   r   s   &r   
is_radicalIdeal.is_radicalN   r   r   c                    \         h)z+Return True if ``self`` is a primary ideal.r   r   s   &r   
is_primaryIdeal.is_primaryR   r   r   c                    \         h)z-Return True if ``self`` is a principal ideal.r   r   s   &r   is_principalIdeal.is_principalV   r   r   c                    \         h)z Compute the radical of ``self``.r   r   s   &r   radicalIdeal.radicalZ   r   r   c                    \         h)zCompute the depth of ``self``.r   r   s   &r   depthIdeal.depth^   r   r   c                    \         h)zCompute the height of ``self``.r   r   s   &r   heightIdeal.heightb   r   r   c                    Wn         R # Nring)r
   rB   s   &&r   __init__Ideal.__init__j   s    	r   c                    \        V\        4      '       d   VP                  V P                  8w  d   \        RV P                  : RV: 24      hR# )z.Helper to check ``J`` is an ideal of our ring.zJ must be an ideal of z, got N)
isinstancer   rB   
ValueErrorr   s   &&r   _check_idealIdeal._check_idealm   s>    !U##qvv':6:iiCE E (;r   c                V    V P                  V P                  P                  V4      4      # )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   rB   convert)r
   elems   &&r   containsIdeal.containss   s$     ""499#4#4T#:;;r   c                   a  \        V\        4      '       d   S P                  V4      # \        ;QJ d    V 3R lV 4       F  '       d   K   R# 	  R# ! V 3R lV 4       4      # )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   <"   T F  pSP                  V4      x  K  	  R # 5ir@   )r   ).0r   r
   s   & r   	<genexpr>Ideal.subset.<locals>.<genexpr>   s     95a4&&q))5s   !FT)rF   r   r   all)r
   others   f&r   subsetIdeal.subset   sL    & eU##''..s959ss9s9s95999r   c                J    V P                  V4       V P                  ! V3/ VB # )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>
)rH   r   r
   r   optss   &&,r   quotientIdeal.quotient   s&      	!~~a(4((r   c                F    V P                  V4       V P                  V4      # )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>
)rH   r   r   s   &&r   	intersectIdeal.intersect   s!     	!q!!r   c                    \         h)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    V P                  V4       V P                  V4      # )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
)rH   _unionr   s   &&r   unionIdeal.union   s      	!{{1~r   c                F    V P                  V4       V P                  V4      # )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>
)rH   _productr   s   &&r   productIdeal.product   s!     	!}}Qr   c                    V# )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                ^   \        V\        4      '       gw   V P                  P                  V 4      p\        WP                  4      '       d   V# \        WP                  P                  4      '       d	   V! V4      # VP                  V4      # V P                  V4       V P                  V4      # r@   )rF   r   rB   quotient_ringdtyperK   rH   re   )r
   eRs   && r   __add__Ideal.__add__   s}    !U##		''-A!WW%%!VV\\**t99Q<!zz!}r   c                    \        V\        4      '       g    V P                  P                  V4      pV P                  V4       V P                  V4      #   \         d
    \
        u # i ; ir@   )rF   r   rB   idealr   NotImplementedrH   ri   r
   rr   s   &&r   __mul__Ideal.__mul__   s[    !U##&IIOOA& 	!||A " &%%&s   A A)(A)c                8    V P                   P                  ^4      #    )rB   rw   r   s   &r   _zeroth_powerIdeal._zeroth_power	  s    yyq!!r   c                    V ^,          # r}   rl   r   s   &r   _first_powerIdeal._first_power  s     axr   c                    \        V\        4      '       d   VP                  V P                  8w  d   R # V P                  V4      # )F)rF   r   rB   r%   ry   s   &&r   __eq__Ideal.__eq__  s/    !U##qvv':||Ar   c                    W8X  * # r@   rl   ry   s   &&r   __ne__Ideal.__ne__  s
    r   rA   N)(__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r"   r%   r(   r+   r.   r1   r4   r7   r:   r=   rC   rH   rM   rV   r[   r^   ra   re   ri   rm   rt   __radd__rz   __rmul__r   r   r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s      D""""""C""""""""E< :.)&" " $	 H H"

 r   r   c                   |   a  ] tR tRt o RtR tR tR tR tR t	R t
]R	 4       tR
 tR tR tR tR tR tRtV tR# )ModuleImplementedIdeali  zc
Ideal implementation relying on the modules code.

Attributes:

- _module - the underlying module
c                <    \         P                  W4       W n        R # r@   )r   rC   _module)r
   rB   modules   &&&r   rC   ModuleImplementedIdeal.__init__#  s    t"r   c                :    V P                   P                  V.4      # r@   )r   rM   r	   s   &&r   r   %ModuleImplementedIdeal._contains_elem'  s    ||$$aS))r   c                    \        V\        4      '       g   \        hV P                  P	                  VP                  4      # r@   )rF   r   r   r   is_submoduler   s   &&r   r   &ModuleImplementedIdeal._contains_ideal*  s/    !344%%||((33r   c                    \        V\        4      '       g   \        hV P                  V P                  V P
                  P                  VP
                  4      4      # r@   )rF   r   r   	__class__rB   r   r^   r   s   &&r   r   !ModuleImplementedIdeal._intersect/  s>    !344%%~~dii)?)?		)JKKr   c                    \        V\        4      '       g   \        hV P                  P                  ! VP                  3/ VB # r@   )rF   r   r   r   module_quotientrY   s   &&,r   r    ModuleImplementedIdeal._quotient4  s4    !344%%||++AII>>>r   c                    \        V\        4      '       g   \        hV P                  V P                  V P
                  P                  VP
                  4      4      # r@   )rF   r   r   r   rB   r   re   r   s   &&r   rd   ModuleImplementedIdeal._union9  s>    !344%%~~dii););AII)FGGr   c                <    R V P                   P                   4       # )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   2   "   T F  q^ ,          x  K  	  R# 5i)    Nrl   )rQ   r   s   & r   rR   .ModuleImplementedIdeal.gens.<locals>.<genexpr>K  s     0/!/s   )r   gensr   s   &r   r   ModuleImplementedIdeal.gens>  s     1dll//00r   c                6    V P                   P                  4       # )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    V P                   P                  4       # )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                   a ^ RI Ho V P                  P                   Uu. uF  w  qP                  P                  V4      NK!  	  ppRRP                  V3R lV 4       4      ,           R,           # u upi )r   )sstr<,c              3   4   <"   T F  pS! V4      x  K  	  R # 5ir@   rl   )rQ   gr   s   & r   rR   2ModuleImplementedIdeal.__repr__.<locals>.<genexpr>r  s     4t!d1ggts   >)sympy.printing.strr   r   r   rB   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   %A0c                H   \        V\        4      '       g   \        hT P                  V P                  V P
                  P                  ! V P
                  P                   UUu. uF,  w  q!P
                  P                   F  w  q2V,          .NK  	  K.  	  upp!  4      # u uppi r@   )rF   r   r   r   rB   r   	submoduler   )r
   r   r   ys   &&  r   rh   ModuleImplementedIdeal._productu  sx    !344%%~~dii)?)?#||00K0IINNSaseNe0K*M N 	NKs   "2Bc                :    V P                   P                  V.4      # )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_generatorsry   s   &&r   r   -ModuleImplementedIdeal.in_terms_of_generators{  s     ||22A377r   c                L    V P                   P                  ! V.3/ VB ^ ,          # )r   )r   rm   )r
   r   optionss   &&,r   rm   %ModuleImplementedIdeal.reduce_element  s#    ||**A3:':1==r   )r   N)r   r   r   r   r   rC   r   r   r   r   rd   propertyr   r"   r   r   rh   r   rm   r   r   r   s   @r   r   r     sb     *4
L
?
H
 1 1& -$;N8> >r   r   N)r   sympy.polys.polyerrorsr   sympy.polys.polyutilsr   r   r   rl   r   r   <module>r      s,    3 1 2P Pfq>U q>r   