ó
    Š*£h°]  ã                   ó  • S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  S
SKJrJr  S
SKJr  S
SKJrJr  S
SKJrJr  S r " S S\5      rS r\S 5       rSS jr S r!S r"S r#S r$\SS j5       r%g)zPrime ideals in number fields. é    )ÚPoly)ÚFF)ÚQQ)ÚZZ)ÚDomainMatrix)ÚCoercionFailed)ÚIntegerPowerable)Úpublicé   )Ú	round_twoÚnilradical_mod_p)ÚStructureError)ÚModuleEndomorphismÚfind_min_poly)Úcoeff_searchÚsupplement_a_subspacec                 óº   • SnSnU R                  5       (       d  SnO/U R                  5       (       d  SnOU R                  5       (       d  SnUb  [        X-   5      eg)aä  
Several functions in this module accept an argument which is to be a
:py:class:`~.Submodule` representing the maximal order in a number field,
such as returned by the :py:func:`~sympy.polys.numberfields.basis.round_two`
algorithm.

We do not attempt to check that the given ``Submodule`` actually represents
a maximal order, but we do check a basic set of formal conditions that the
``Submodule`` must satisfy, at a minimum. The purpose is to catch an
obviously ill-formed argument.
z4The submodule representing the maximal order should Nz'be a direct submodule of a power basis.zhave 1 as its first generator.z<have square matrix, of maximal rank, in Hermite Normal Form.)Úis_power_basis_submoduleÚstarts_with_unityÚis_sq_maxrank_HNFr   )Ú	submoduleÚprefixÚconds      Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/numberfields/primes.pyÚ*_check_formal_conditions_for_maximal_orderr      sc   € ð D€FØ€DØ×-Ñ-×/Ñ/Ø8‰Ø×(Ñ(×*Ñ*Ø/‰Ø×(Ñ(×*Ñ*ØMˆØÑÜ˜V™]Ó+Ð+ð ó    c                   ó’   • \ rS rSrSrSS jrS r\S 5       rSS jr	S r
S	 rS
 rS r\rS r\rS rS rS rS rS rS rS rSrg)Ú
PrimeIdealé)   z0
A prime ideal in a ring of algebraic integers.
Nc                 óœ   • [        U5        Xl        X l        X0l        X@l        SU l        Ub  XPl        gU R                  X!-  5      U l        g)aŒ  
Parameters
==========

ZK : :py:class:`~.Submodule`
    The maximal order where this ideal lives.
p : int
    The rational prime this ideal divides.
alpha : :py:class:`~.PowerBasisElement`
    Such that the ideal is equal to ``p*ZK + alpha*ZK``.
f : int
    The inertia degree.
e : int, ``None``, optional
    The ramification index, if already known. If ``None``, we will
    compute it here.

N)r   ÚZKÚpÚalphaÚfÚ_test_factorÚ	valuationÚe)Úselfr!   r"   r#   r$   r'   s         r   Ú__init__ÚPrimeIdeal.__init__.   sB   € ô$ 	3°2Ô6ØŒØŒØŒ
ØŒØ ˆÔØ‘m��¨¯©¸¹Ó)?ˆ�r   c                 óš   • U R                   (       a  SU R                   S3$ SU R                   SU R                  R                  5        S3$ )NÚ(Ú)ú, )Úis_inertr"   r#   Úas_expr©r(   s    r   Ú__str__ÚPrimeIdeal.__str__H   sB   € Ø�=�=Ø�t—v‘v�h˜a�=Ð Ø�4—6‘6�(˜"˜TŸZ™Z×/Ñ/Ó1Ð2°!Ð4Ð4r   c                 óH   • U R                   U R                  R                  :H  $ )z^
Say whether the rational prime we divide is inert, i.e. stays prime in
our ring of integers.
)r$   r!   Únr1   s    r   r/   ÚPrimeIdeal.is_inertM   s   € ð �v‰v˜Ÿ™Ÿ™Ñ"Ð"r   c                 ó–  • U=(       d*    U R                   R                  R                  R                  nU R                  U R
                  U R                  U R                  4u  p4pV[        UR                  US9R                  5       5      nUR                  S:”  a  SU SUR                   3nSU SU S3nU(       a  U$ SU SU S	U S
3$ )a2  
Print a representation of this prime ideal.

Examples
========

>>> from sympy import cyclotomic_poly, QQ
>>> from sympy.abc import x, zeta
>>> T = cyclotomic_poly(7, x)
>>> K = QQ.algebraic_field((T, zeta))
>>> P = K.primes_above(11)
>>> print(P[0].repr())
[ (11, x**3 + 5*x**2 + 4*x - 1) e=1, f=3 ]
>>> print(P[0].repr(field_gen=zeta))
[ (11, zeta**3 + 5*zeta**2 + 4*zeta - 1) e=1, f=3 ]
>>> print(P[0].repr(field_gen=zeta, just_gens=True))
(11, zeta**3 + 5*zeta**2 + 4*zeta - 1)

Parameters
==========

field_gen : :py:class:`~.Symbol`, ``None``, optional (default=None)
    The symbol to use for the generator of the field. This will appear
    in our representation of ``self.alpha``. If ``None``, we use the
    variable of the defining polynomial of ``self.ZK``.
just_gens : bool, optional (default=False)
    If ``True``, just print the "(p, alpha)" part, showing "just the
    generators" of the prime ideal. Otherwise, print a string of the
    form "[ (p, alpha) e=..., f=... ]", giving the ramification index
    and inertia degree, along with the generators.

)Úxr   r,   z)/r.   r-   z[ z e=z, f=z ])r!   ÚparentÚTÚgenr"   r#   r'   r$   ÚstrÚ	numeratorr0   Údenom)	r(   Ú	field_genÚ	just_gensr"   r#   r'   r$   Ú	alpha_repÚgenss	            r   ÚreprÚPrimeIdeal.reprU   s»   € ðB ×5 §¡§¡×!1Ñ!1×!5Ñ!5ˆ	ØŸ™ §¡¨T¯V©V°T·V±VÐ;‰ˆ�!Ü˜Ÿ™¨)˜Ð4×<Ñ<Ó>Ó?ˆ	Ø�;‰;˜‹?Ø˜I˜; b¨¯©¨Ð6ˆIØ�1�#�R˜	�{ !Ð$ˆÞØˆKØ�D�6˜˜Q˜C˜t A 3 bÐ)Ð)r   c                 ó"   • U R                  5       $ ©N)rC   r1   s    r   Ú__repr__ÚPrimeIdeal.__repr__€   s   € Ø�y‰y‹{Ðr   c                 óˆ   • U R                   U R                  -  U R                  U R                  -  -   nSUl        SUl        U$ )a·  
Represent this prime ideal as a :py:class:`~.Submodule`.

Explanation
===========

The :py:class:`~.PrimeIdeal` class serves to bundle information about
a prime ideal, such as its inertia degree, ramification index, and
two-generator representation, as well as to offer helpful methods like
:py:meth:`~.PrimeIdeal.valuation` and
:py:meth:`~.PrimeIdeal.test_factor`.

However, in order to be added and multiplied by other ideals or
rational numbers, it must first be converted into a
:py:class:`~.Submodule`, which is a class that supports these
operations.

In many cases, the user need not perform this conversion deliberately,
since it is automatically performed by the arithmetic operator methods
:py:meth:`~.PrimeIdeal.__add__` and :py:meth:`~.PrimeIdeal.__mul__`.

Raising a :py:class:`~.PrimeIdeal` to a non-negative integer power is
also supported.

Examples
========

>>> from sympy import Poly, cyclotomic_poly, prime_decomp
>>> T = Poly(cyclotomic_poly(7))
>>> P0 = prime_decomp(7, T)[0]
>>> print(P0**6 == 7*P0.ZK)
True

Note that, on both sides of the equation above, we had a
:py:class:`~.Submodule`. In the next equation we recall that adding
ideals yields their GCD. This time, we need a deliberate conversion
to :py:class:`~.Submodule` on the right:

>>> print(P0 + 7*P0.ZK == P0.as_submodule())
True

Returns
=======

:py:class:`~.Submodule`
    Will be equal to ``self.p * self.ZK + self.alpha * self.ZK``.

See Also
========

__add__
__mul__

FT)r"   r!   r#   Ú_starts_with_unityÚ_is_sq_maxrank_HNF)r(   ÚMs     r   Úas_submoduleÚPrimeIdeal.as_submoduleƒ   s>   € ðn �F‰F�T—W‘WÑ˜tŸz™z¨D¯G©GÑ3Ñ3ˆà$ˆÔØ#ˆÔØˆr   c                 óz   • [        U[        5      (       a!  U R                  5       UR                  5       :H  $ [        $ rF   )Ú
isinstancer   rM   ÚNotImplemented©r(   Úothers     r   Ú__eq__ÚPrimeIdeal.__eq__À   s2   € Ü�eœZ×(Ñ(Ø×$Ñ$Ó&¨%×*<Ñ*<Ó*>Ñ>Ð>ÜÐr   c                 ó(   • U R                  5       U-   $ )zt
Convert to a :py:class:`~.Submodule` and add to another
:py:class:`~.Submodule`.

See Also
========

as_submodule

©rM   rR   s     r   Ú__add__ÚPrimeIdeal.__add__Å   ó   € ð × Ñ Ó" UÑ*Ð*r   c                 ó(   • U R                  5       U-  $ )zŽ
Convert to a :py:class:`~.Submodule` and multiply by another
:py:class:`~.Submodule` or a rational number.

See Also
========

as_submodule

rW   rR   s     r   Ú__mul__ÚPrimeIdeal.__mul__Ô   rZ   r   c                 ó   • U R                   $ rF   )r!   r1   s    r   Ú_zeroth_powerÚPrimeIdeal._zeroth_powerã   s   € Ø�w‰wˆr   c                 ó   • U $ rF   © r1   s    r   Ú_first_powerÚPrimeIdeal._first_poweræ   s   € Øˆr   c                 ó–   • U R                   c1  [        U R                  U R                  /U R                  5      U l         U R                   $ )a÷  
Compute a test factor for this prime ideal.

Explanation
===========

Write $\mathfrak{p}$ for this prime ideal, $p$ for the rational prime
it divides. Then, for computing $\mathfrak{p}$-adic valuations it is
useful to have a number $\beta \in \mathbb{Z}_K$ such that
$p/\mathfrak{p} = p \mathbb{Z}_K + \beta \mathbb{Z}_K$.

Essentially, this is the same as the number $\Psi$ (or the "reagent")
from Kummer's 1847 paper (*Ueber die Zerlegung...*, Crelle vol. 35) in
which ideal divisors were invented.
)r%   Ú_compute_test_factorr"   r#   r!   r1   s    r   Útest_factorÚPrimeIdeal.test_factoré   s;   € ð  ×ÑÑ$Ü 4°T·V±V¸d¿j¹j¸\È4Ï7É7Ó SˆDÔØ× Ñ Ð r   c                 ó   • [        X5      $ )z­
Compute the $\mathfrak{p}$-adic valuation of integral ideal I at this
prime ideal.

Parameters
==========

I : :py:class:`~.Submodule`

See Also
========

prime_valuation

)Úprime_valuation)r(   ÚIs     r   r&   ÚPrimeIdeal.valuationý   s   € ô  ˜qÓ'Ð'r   c                 ó@   • U R                  5       R                  U5      $ )aP  
Reduce a :py:class:`~.PowerBasisElement` to a "small representative"
modulo this prime ideal.

Parameters
==========

elt : :py:class:`~.PowerBasisElement`
    The element to be reduced.

Returns
=======

:py:class:`~.PowerBasisElement`
    The reduced element.

See Also
========

reduce_ANP
reduce_alg_num
.Submodule.reduce_element

)rM   Úreduce_element)r(   Úelts     r   rn   ÚPrimeIdeal.reduce_element  s   € ð2 × Ñ Ó"×1Ñ1°#Ó6Ð6r   c                 óŽ   • U R                   R                  R                  U5      nU R                  U5      nUR	                  5       $ )a+  
Reduce an :py:class:`~.ANP` to a "small representative" modulo this
prime ideal.

Parameters
==========

elt : :py:class:`~.ANP`
    The element to be reduced.

Returns
=======

:py:class:`~.ANP`
    The reduced element.

See Also
========

reduce_element
reduce_alg_num
.Submodule.reduce_element

)r!   r9   Úelement_from_ANPrn   Úto_ANP©r(   Úaro   Úreds       r   Ú
reduce_ANPÚPrimeIdeal.reduce_ANP*  s8   € ð2 �g‰g�n‰n×-Ñ-¨aÓ0ˆØ×!Ñ! #Ó&ˆØ�z‰z‹|Ðr   c                 óä   • U R                   R                  R                  U5      nU R                  U5      nUR	                  [        [        UR                  R                  5       5      5      5      $ )aK  
Reduce an :py:class:`~.AlgebraicNumber` to a "small representative"
modulo this prime ideal.

Parameters
==========

elt : :py:class:`~.AlgebraicNumber`
    The element to be reduced.

Returns
=======

:py:class:`~.AlgebraicNumber`
    The reduced element.

See Also
========

reduce_element
reduce_ANP
.Submodule.reduce_element

)	r!   r9   Úelement_from_alg_numrn   Úfield_elementÚlistÚreversedÚQQ_colÚflatrt   s       r   Úreduce_alg_numÚPrimeIdeal.reduce_alg_numG  sP   € ð2 �g‰g�n‰n×1Ñ1°!Ó4ˆØ×!Ñ! #Ó&ˆØ�‰œt¤H¨S¯Z©Z¯_©_Ó->Ó$?Ó@ÓAÐAr   )r!   r%   r#   r'   r$   r"   rF   )NF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r)   r2   Úpropertyr/   rC   rG   rM   rT   rX   Ú__radd__r\   Ú__rmul__r_   rc   rg   r&   rn   rw   r€   Ú__static_attributes__rb   r   r   r   r   )   sx   † ñô@ò45ð
 ñ#ó ð#ô)*òVò;òzò
+ð €Hò+ð €Hòòò!ò((ò$7ò6õ:Br   r   c                 óÐ  • [        U5        UR                  5       nU Vs/ s H   oCR                  U5      R                  U S9PM"     nn[        R
                  " SUR                  4[        U 5      5      R                  " U6 nUR                  5       SSS24   R                  5       nUR                  UR                  UR                  [        5      -  UR                  S9nU$ s  snf )a‘  
Compute the test factor for a :py:class:`~.PrimeIdeal` $\mathfrak{p}$.

Parameters
==========

p : int
    The rational prime $\mathfrak{p}$ divides

gens : list of :py:class:`PowerBasisElement`
    A complete set of generators for $\mathfrak{p}$ over *ZK*, EXCEPT that
    an element equivalent to rational *p* can and should be omitted (since
    it has no effect except to waste time).

ZK : :py:class:`~.Submodule`
    The maximal order where the prime ideal $\mathfrak{p}$ lives.

Returns
=======

:py:class:`~.PowerBasisElement`

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
(See Proposition 4.8.15.)

©Úmodulusr   N©r>   )r   Úendomorphism_ringÚinner_endomorphismÚmatrixr   Úzerosr5   r   ÚvstackÚ	nullspaceÚ	transposer9   Ú
convert_tor   r>   )	r"   rB   r!   ÚEÚgÚmatricesÚBr8   Úbetas	            r   rf   rf   e  sÀ   € ô< /¨rÔ2Ø
×ÑÓ€AÙCGÓHÂ4¸a×$Ñ$ QÓ'×.Ñ.°qÐ.Ó9Á4€HÐHÜ×Ò˜A˜rŸt™t˜9¤b¨£eÓ,×3Ò3°XÐ>€Að 	
�‰‹�aš�dÑ×%Ñ%Ó'€AØ�9‰9�R—Y‘Y §¡¬bÓ!1Ñ1¸¿¹ˆ9ÐB€DØ€Kùò Is    'C#c                 ób  • UR                   UR                  p2UR                  UR                  UR                  penUR                  [        5      R                  5       U R                  -  U-  U R                  -  nUR                  [        5      nUR                  5       nX‚-  S:w  a  gUR                  5       n	Xd-  UR                  5       -  n
X¢-  S:H  nSn XW-  n[        U5       HW  nUR                  USS2U4   US9nXé-  nUR                  U5      R                  5       n[        U5       H  nXï   XU4'   M     MY     XtS-
  US-
  4   R                  U-  S:w  a   U$ Xr-  nU(       a   UR                  [        5      nOUR                  [        5      nUS-  nMÈ  ! [          a     U$ f = f)aŽ  
Compute the *P*-adic valuation for an integral ideal *I*.

Examples
========

>>> from sympy import QQ
>>> from sympy.polys.numberfields import prime_valuation
>>> K = QQ.cyclotomic_field(5)
>>> P = K.primes_above(5)
>>> ZK = K.maximal_order()
>>> print(prime_valuation(25*ZK, P[0]))
8

Parameters
==========

I : :py:class:`~.Submodule`
    An integral ideal whose valuation is desired.

P : :py:class:`~.PrimeIdeal`
    The prime at which to compute the valuation.

Returns
=======

int

See Also
========

.PrimeIdeal.valuation

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithm 4.8.17.)

r   NrŽ   r   )r"   r!   r5   r‘   r>   r–   r   Úinvr   Údetrg   Úranger9   Ú	representr   Úelementr   )rk   ÚPr"   r!   r5   ÚWÚdÚAÚDr›   r$   Úneed_complete_testÚvÚjÚcÚis                   r   rj   rj   “  s¡  € ðT �C‰C�—‘€rØ�d‰d�B—I‘I˜rŸx™xˆ!€Aà	�‰”RÓ×ÑÓ §¡Ñ)¨AÑ-°·±Ñ7€Að 	
�‰”RÓ€AØ	�‰‹€AØ�u�ƒzØà�=‰=‹?€Dà	‰�!—%‘%“'Ñ€AØ™% 1™*ÐØ	€AØ
ð ‰Eˆä�q–ˆAØ—	‘	˜!šA˜q˜D™'¨�	Ð+ˆAØ‰IˆAà—‘˜Q“×$Ñ$Ó&ˆAÜ˜1–X�Ø™$��Q�$“ó ñ ð �‰U�A˜‘Eˆ\‰?×"Ñ" QÑ&¨!Ó+Øð €Hð ‰Eˆö ðØ—L‘L¤Ó$‘ð
 —‘œRÓ ˆAØ	ˆQ‰ˆñ7 øô, "ó Øð
 €Hðús   Å.F  Æ 
F.Æ-F.Nc                 ó8  ^• [        U5        UR                  nUR                  n[        U4S jU  5       5      (       a  UR	                  5       $ Uc;  Ub  TU-  nO2[        UR                  U 5      R                  R                  5       5      nUR                  5       nUSS  Vs/ s H  nTU-  PM
     n	nX�-  n	[        [        U	5      S5      n
U
 HB  n[        S [        X¹5       5       5      nUR                  U5      U-  nUT-  S:w  d  M=  UT-  s  $    gs  snf )a  
Given a set of *ZK*-generators of a prime ideal, compute a set of just two
*ZK*-generators for the same ideal, one of which is *p* itself.

Parameters
==========

gens : list of :py:class:`PowerBasisElement`
    Generators for the prime ideal over *ZK*, the ring of integers of the
    field $K$.

ZK : :py:class:`~.Submodule`
    The maximal order in $K$.

p : int
    The rational prime divided by the prime ideal.

f : int, optional
    The inertia degree of the prime ideal, if known.

Np : int, optional
    The norm $p^f$ of the prime ideal, if known.
    NOTE: There is no reason to supply both *f* and *Np*. Either one will
    save us from having to compute the norm *Np* ourselves. If both are known,
    *Np* is preferred since it saves one exponentiation.

Returns
=======

:py:class:`~.PowerBasisElement` representing a single algebraic integer
alpha such that the prime ideal is equal to ``p*ZK + alpha*ZK``.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
(See Algorithm 4.7.10.)

c              3   óJ   >#   • U  H  oT-  R                  S 5      v •  M     g7f)r   N)Úequiv)Ú.0r˜   r"   s     €r   Ú	<genexpr>Ú_two_elt_rep.<locals>.<genexpr>  s   øé € Ð
*¢T �‰E�=‰=˜×Ð¢Tùs   ƒ #Nr   c              3   ó.   #   • U  H  u  pX-  v •  M     g 7frF   rb   )r¯   ÚciÚbetais      r   r°   r±   '  s   é € Ð;ªl¡ �B–Hªlùs   ‚r   )r   r9   r:   ÚallÚzeroÚabsÚsubmodule_from_gensr‘   rž   Úbasis_element_pullbacksr   ÚlenÚsumÚzipÚnorm)rB   r!   r"   r$   ÚNpÚpbr:   ÚomegaÚomr›   Úsearchrª   r#   r5   s     `           r   Ú_two_elt_reprÃ   ì  s  ø€ ôP /¨rÔ2Ø	�‰€BØ
�‰€Aô Ô
*¡TÓ
*×*Ñ*Ø�w‰w‹yÐà	�zØ‰=Ø�A‘‰Bä�R×+Ñ+¨DÓ1×8Ñ8×<Ñ<Ó>Ó?ˆBà×&Ñ&Ó(€EØ   ™9Ó%š9�RˆAˆbŒD™9€DÐ%Ø�L€DÜœ#˜d›) QÓ'€FÛˆÜÑ;¬c°!¬lÓ;Ó;ˆð �J‰J�q‹M˜RÑˆØˆq‰5�A�:à˜1‘9Òò ùò &s   Â$Dc                 ó´  • UR                   R                  n[        X S9nUR                  5       u  pE[	        U5      S:X  a=  US   S   S:X  a1  [        XUR                   R                  5       UR                  S5      /$ U VVs/ s HF  u  pg[        XUR                   R                  [        U[        S95      UR                  5       U5      PMH     snn$ s  snnf )a'  
Compute the decomposition of rational prime *p* in the ring of integers
*ZK* (given as a :py:class:`~.Submodule`), in the "easy case", i.e. the
case where *p* does not divide the index of $\theta$ in *ZK*, where
$\theta$ is the generator of the ``PowerBasis`` of which *ZK* is a
``Submodule``.
rŒ   r   r   ©Údomain)r9   r:   r   Úfactor_listrº   r   r¶   r5   Úelement_from_polyr   Údegree)r"   r!   r:   ÚT_barÚlcÚflÚtr'   s           r   Ú_prime_decomp_easy_caserÎ   1  s¿   € ð 	�	‰	�‰€AÜ�Ñ€EØ×ÑÓ �F€BÜ
ˆ2ƒw�!ƒ|˜˜1™˜a™ A›Ü˜2 "§)¡)§.¡.Ó"2°B·D±D¸!Ó<Ð=Ð=ñ ôò ‘�ô �rØ—y‘y×2Ñ2´4¸Ä"Ñ3EÓFØ—x‘x“z 1ö&ñ òð ùó s   ÂACc                 ó2  ^• U R                   nUR                  u  pEUS:X  a  UR                  U[        5      nO,UR	                  UR                  U[        5      SS2S4   5      nUR                  S   U:  a6  [        UR                  [        T5      5      5      R                  [        5      nUR                  U5      nUR                  5         UR                  U5      n[        UU4S j5      nUR                  TS9n	U	R                  5       (       d   eX—4$ )aç  
Parameters
==========

I : :py:class:`~.Module`
    An ideal of ``ZK/pZK``.
p : int
    The rational prime being factored.
ZK : :py:class:`~.Submodule`
    The maximal order.

Returns
=======

Pair ``(N, G)``, where:

    ``N`` is a :py:class:`~.Module` representing the kernel of the map
    ``a |--> a**p - a`` on ``(O/pO)/I``, guaranteed to be a module with
    unity.

    ``G`` is a :py:class:`~.Module` representing a basis for the separable
    algebra ``A = O/I`` (see Cohen).

r   Nr   c                 ó   >• U T-  U -
  $ rF   rb   )r8   r"   s    €r   Ú<lambda>Ú._prime_decomp_compute_kernel.<locals>.<lambda>s  s   ø€ ¨!¨Q©$°ª(r   rŒ   )r‘   ÚshapeÚeyer   Úhstackr   r–   r   Úsubmodule_from_matrixÚcompute_mult_tabÚdiscard_beforer   Úkernelr   )
rk   r"   r!   r£   r5   Úrrš   ÚGÚphiÚNs
    `        r   Ú_prime_decomp_compute_kernelrÞ   D  sê   ø€ ð2 	
�‰€AØ�7‰7�D€Að 	ˆAƒvØ�E‰E�!”R‹L‰à�H‰H�Q—U‘U˜1œb“\¢! Q $Ñ'Ó(ˆØ‡w�wˆq�z�Aƒ~Ü! !§,¡,¬r°!«uÓ"5Ó6×AÑAÄ"ÓEˆà
× Ñ  Ó#€Að
 ×ÑÔØ	×Ñ˜Ó€Aä
˜QÔ 2Ó
3€CØ�
‰
˜1ˆ
Ð€AØ×Ñ× Ñ Ð Ð Øˆ4€Kr   c                 ó.  • U R                   R                  u  p4X4-
  nUR                   U R                   -  n[        UR                  S   5       Vs/ s H#  orR                  USS2U4   UR                  S9PM%     nn[        X‚XS9n	[        X!X•5      $ s  snf )a}  
We have reached the case where we have a maximal (hence prime) ideal *I*,
which we know because the quotient ``O/I`` is a field.

Parameters
==========

I : :py:class:`~.Module`
    An ideal of ``O/pO``.
p : int
    The rational prime being factored.
ZK : :py:class:`~.Submodule`
    The maximal order.

Returns
=======

:py:class:`~.PrimeIdeal` instance representing this prime

r   NrŽ   )r$   )r‘   rÓ   rŸ   r9   r>   rÃ   r   )
rk   r"   r!   Úmr5   r$   rÛ   r©   rB   r#   s
             r   Ú_prime_decomp_maximal_idealrá   y  s…   € ð* �8‰8�>‰>�D€AØ	‰€AØ
�	‰	�A—H‘HÑ€AÜ8=¸a¿g¹gÀa¹jÔ8IÓJÒ8I°1�I‰I�aš˜1˜‘g R§X¡XˆIÓ.Ñ8I€DÐJÜ˜ 1Ñ*€EÜ�b˜UÓ&Ð&ùò Ks   Á*Bc                 ó  ^^• U R                   U:X  a  UR                   UL a  UR                   UL d   eU" S5      R                  5       nUR                  UL d   e/ m[        U[	        U5      TS9nUR                  5       u  pxUS   S   n	UR                  U	5      n
U	R                  U
5      u  p¼nUS:X  d   e[        [        [        X¹-  [        S9R                  R                  5       5      5      m[        UU4S j[        [!        T5      5       5       5      nSU-
  nXï/n/ nU HÒ  nUR                  5       nUR                  UL d   eU R"                  R%                  [	        U5      5      R&                  " UR)                  5        Vs/ s H  nUU-  R+                  [	        U5      S9PM      sn6 nUR-                  5       R%                  [        5      nUR/                  U5      nUR1                  U5        MÔ     U$ s  snf )zá
Perform the step in the prime decomposition algorithm where we have determined
the quotient ``ZK/I`` is _not_ a field, and we want to perform a non-trivial
factorization of *I* by locating an idempotent element of ``ZK/I``.
r   )Úpowersr   rÅ   c              3   ó:   >#   • U  H  nTU   TU   -  v •  M     g 7frF   rb   )r¯   r«   r—   Úalpha_powerss     €€r   r°   Ú,_prime_decomp_split_ideal.<locals>.<genexpr>°  s   øé € Ð;ª]¨ˆq�‰t�L ‘OÖ#ª]ùs   ƒ)r9   Ú	to_parentÚmoduler   r   rÇ   ÚquoÚgcdexr|   r}   r   r   ÚrepÚto_listr»   rŸ   rº   r‘   r–   rÕ   Úbasis_elementsÚcolumnÚcolumnspacerÖ   Úappend)rk   r"   rÝ   rÛ   r!   r#   rà   rË   rÌ   Úm1Úm2ÚUÚVr˜   Úeps1Úeps2ÚidempsÚfactorsÚepsr'   rÁ   r¦   r£   ÚHr—   rå   s                           @@r   Ú_prime_decomp_split_idealrû   –  sº  ù€ ð �8‰8�r‹>˜aŸh™h¨"šn°·±¸Q²Ð>Ð>ñ
 ˆa‹D�N‰NÓ€EØ�<‰<˜1ÒÐÐà€LÜ�eœR ›U¨<Ñ8€Að �]‰]‹_�F€BØ	ˆA‰ˆq‰€BØ	
�‰ˆr‹€BØ�h‰h�r‹l�G€Aˆ!à�‹6€Mˆ6ÜŒX”d˜1™6¬"Ñ-×1Ñ1×9Ñ9Ó;Ó<Ó=€AÜÕ;¬U´3°q³6¬]Ó;Ó;€DØˆt‰8€DØˆ\€FØ€GÛˆØ�M‰M‹OˆØ�x‰x˜2Š~Ðˆ~Ø�H‰H×Ñ¤ 1£Ó&×-Ò-Ø46×4EÑ4EÔ4Gó0
Ú4G¨bˆQ�‰V�O‰O¤2 a£5ˆOÓ)Ñ4Gñ0
ð ˆð �M‰M‹O×&Ñ&¤rÓ*ˆØ×$Ñ$ QÓ'ˆØ�‰�qÖñ ð €Nùò0
s   Æ	%G=
c                 óF  • Uc  Uc  [        S5      eUb  [        U5        Uc  UR                  R                  n0 nUb  Uc  [	        XS9u  p#UR                  5       nXc-  nXp-  S:w  a  [        X5      $ U=(       d#    UR                  U 5      =(       d    [        X 5      nU/n/ n	U(       av  UR                  5       n
[        X U5      u  p¼UR                  S:X  a  [        X U5      nU	R                  U5        O![        X X¼U5      u  pïUR                  Xï/5        U(       a  Mv  U	$ )a  
Compute the decomposition of rational prime *p* in a number field.

Explanation
===========

Ordinarily this should be accessed through the
:py:meth:`~.AlgebraicField.primes_above` method of an
:py:class:`~.AlgebraicField`.

Examples
========

>>> from sympy import Poly, QQ
>>> from sympy.abc import x, theta
>>> T = Poly(x ** 3 + x ** 2 - 2 * x + 8)
>>> K = QQ.algebraic_field((T, theta))
>>> print(K.primes_above(2))
[[ (2, x**2 + 1) e=1, f=1 ], [ (2, (x**2 + 3*x + 2)/2) e=1, f=1 ],
 [ (2, (3*x**2 + 3*x)/2) e=1, f=1 ]]

Parameters
==========

p : int
    The rational prime whose decomposition is desired.

T : :py:class:`~.Poly`, optional
    Monic irreducible polynomial defining the number field $K$ in which to
    factor. NOTE: at least one of *T* or *ZK* must be provided.

ZK : :py:class:`~.Submodule`, optional
    The maximal order for $K$, if already known.
    NOTE: at least one of *T* or *ZK* must be provided.

dK : int, optional
    The discriminant of the field $K$, if already known.

radical : :py:class:`~.Submodule`, optional
    The nilradical mod *p* in the integers of $K$, if already known.

Returns
=======

List of :py:class:`~.PrimeIdeal` instances.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithm 6.2.9.)

z)At least one of T or ZK must be provided.)Úradicalsr   r   )Ú
ValueErrorr   r9   r:   r   ÚdiscriminantrÎ   Úgetr   ÚpoprÞ   r5   rá   rð   rû   Úextend)r"   r:   r!   ÚdKÚradicalrý   ÚdTÚ	f_squaredÚstackÚprimesrk   rÝ   rÛ   r¢   ÚI1ÚI2s                   r   Úprime_decompr  À  s  € ðn 	�y�R‘ZÜÐDÓEÐEØ	�~Ü2°2Ô6Ø�yØ�I‰I�K‰KˆØ€HØ	�z�R‘ZÜ˜1Ñ0‰ˆØ	
�‰Ó	€BØ‘€IØ�}˜ÓÜ& qÓ-Ð-Ø×C˜Ÿ™ a›×CÔ,<¸RÓ,C€GØˆI€EØ€FÞ
Ø�I‰I‹KˆÜ+¨A°"Ó5‰ˆØ�3‰3�!‹8Ü+¨A°"Ó5ˆAØ�M‰M˜!Õä.¨q°Q¸2Ó>‰FˆBØ�L‰L˜"˜Ô"÷ ˆ%ð €Mr   )NN)NNNN)&r†   Úsympy.polys.polytoolsr   Úsympy.polys.domains.finitefieldr   Ú!sympy.polys.domains.rationalfieldr   Úsympy.polys.domains.integerringr   Ú!sympy.polys.matrices.domainmatrixr   Úsympy.polys.polyerrorsr   Úsympy.polys.polyutilsr	   Úsympy.utilities.decoratorr
   Úbasisr   r   Ú
exceptionsr   Úmodulesr   r   Ú	utilitiesr   r   r   r   rf   rj   rÃ   rÎ   rÞ   rá   rû   r  rb   r   r   Ú<module>r     s“   ðÙ %å &Ý .Ý 0Ý .Ý :Ý 1Ý 2Ý ,ß .Ý &ß 6ß :ò,ô0yBÐ!ô yBòx	+ð\ ñUó ðUôpBòJò&2òj'ò:'ðT óOó ñOr   