K iA+LdZddlmZddlmZGddeZGddeZy) z-Computations with ideals of polynomial rings.)CoercionFailed)IntegerPowerableceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZeZdZeZ dZ!dZ"dZ#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) 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 ct)z&Implementation of element containment.NotImplementedErrorselfxs ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/polys/agca/ideals.py_contains_elemzIdeal._contains_elem*!!ct)z$Implementation of ideal containment.r)r Is r _contains_idealzIdeal._contains_ideal.rrct)z!Implementation of ideal quotient.rr Js r _quotientzIdeal._quotient2rrct)z%Implementation of ideal intersection.rrs r _intersectzIdeal._intersect6rrct)z*Return True if ``self`` is the whole ring.rr s r is_whole_ringzIdeal.is_whole_ring:rrct)z*Return True if ``self`` is the zero ideal.rrs r is_zeroz Ideal.is_zero>rrcJ|j|xr|j|S)z!Implementation of ideal equality.)rrs r _equalsz Ideal._equalsBs###A&B1+<+>> 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 )rr3convert)r elems r containszIdeal.containsss$""499#4#4T#:;;rcnt|trj|Stfd|DS)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 c3@K|]}j|ywr2)r).0r r s r zIdeal.subset..s9a4&&q)9s)r6rrall)r others` r subsetz Ideal.subsets1& eU #''. .95999rc J|j||j|fi|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)) )r8rr roptss r quotientzIdeal.quotients( !t~~a(4((rcF|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)) )r8rrs r intersectzIdeal.intersects! !q!!rct)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\}`. rrs r saturatezIdeal.saturates "!rcF|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_unionrs r unionz Ideal.unions  !{{1~rcF|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)) )r8_productrs r productz Ideal.products! !}}Qrc|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_elementzIdeal.reduce_elements rc>t|tsl|jj|}t||jr|St||jjr||S|j |S|j ||j|Sr2)r6rr3 quotient_ringdtyper:r8rN)r eRs r __add__z Ideal.__add__sx!U# ''-A!QWW%!QVV\\*t 99Q<  !zz!}rct|ts |jj|}|j ||j|S#t$r t cYSwxYwr2)r6rr3idealrNotImplementedr8rQr rXs r __mul__z Ideal.__mul__sX!U# &IIOOA& !||A" &%% &sAA! A!c8|jjdSN)r3r\rs r _zeroth_powerzIdeal._zeroth_power syyq!!rc |dzSrarSrs r _first_powerzIdeal._first_power s axrcxt|tr|j|jk7ry|j|S)NF)r6rr3r r^s r __eq__z Ideal.__eq__s,!U#qvv':||Arc||k( Sr2rSr^s r __ne__z Ideal.__ne__sAIrN)%__name__ __module__ __qualname____doc__rrrrrrr r"r$r&r(r*r,r.r0r4r8r<rCrGrIrKrNrQrTrZ__radd__r___rmul__rcrergrirSrr rrs D""""""C""""""""E < :.)&" "  $ HH"  rrcheZdZdZdZdZdZdZdZdZ e dZ d Z d Z d Zd Zd ZdZy)ModuleImplementedIdealzs Ideal implementation relying on the modules code. Attributes: - _module - the underlying module c>tj||||_yr2)rr4_module)r r3modules r r4zModuleImplementedIdeal.__init__#s tT" rc:|jj|gSr2)rsr<r s r rz%ModuleImplementedIdeal._contains_elem's||$$aS))rcxt|tst|jj |jSr2)r6rqr rs is_submodulers r rz&ModuleImplementedIdeal._contains_ideal*s,!34% %||((33rct|tst|j|j|j j |j Sr2)r6rqr __class__r3rsrIrs r rz!ModuleImplementedIdeal._intersect/s;!34% %~~dii)?)? )JKKrc |t|tst|jj|jfi|Sr2)r6rqr rsmodule_quotientrEs r rz ModuleImplementedIdeal._quotient4s3!34% %+t||++AII>>>rct|tst|j|j|j j |j Sr2)r6rqr ryr3rsrNrs r rMzModuleImplementedIdeal._union9s;!34% %~~dii););AII)FGGrc<d|jjDS)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)] c3&K|] }|d yw)rNrS)r?r s r r@z.ModuleImplementedIdeal.gens..Ks0!0s)rsgensrs r rzModuleImplementedIdeal.gens>s1dll//00rc6|jjS)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 )rsrrs r rzModuleImplementedIdeal.is_zeroMs||##%%rc6|jjS)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 )rsis_full_modulers r rz$ModuleImplementedIdeal.is_whole_ring]s ||**,,rcddlm|jjDcgc]\}|jj |!}}ddj fd|DzdzScc}w)Nr)sstr<,c3.K|] }|ywr2rS)r?grs r r@z2ModuleImplementedIdeal.__repr__..rs4!d1g4s>)sympy.printing.strrrsrr3to_sympyjoin)r r rrs @r __repr__zModuleImplementedIdeal.__repr__osY+151B1BC#1 ""1%CCSXX4t444s::Ds$A&c .t|tst|j|j|j j |j jDcgc]'\}|j jD] \}||zg )c}}Scc}}wr2)r6rqr ryr3rs submoduler)r rr ys r rPzModuleImplementedIdeal._productusz!34% %~~dii)?)?)?#||00 KAIINN KSaqse Ke K*MN N Ks,Bc:|jj|gS)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)] )rsin_terms_of_generatorsr^s r rz-ModuleImplementedIdeal.in_terms_of_generators{s||22A377rc D|jj|gfi|dS)Nr)rsrT)r r optionss r rTz%ModuleImplementedIdeal.reduce_elements%*t||**A3:':1==rN)rjrkrlrmr4rrrrrMpropertyrrrrrPrrTrSrr rqrqsZ*4 L ? H  1 1& -$; N 8>rrqN)rmsympy.polys.polyerrorsrsympy.polys.polyutilsrrrqrSrr rs,312P Pfq>Uq>r