
    Ed]                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ d
dlmZmZ d
dlmZ d
dlmZmZ d
dlmZmZ d Z G d de          Zd Zed             ZddZ d Z!d Z"d Z#d Z$edd            Z%dS )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                     d}d}|                                  sd}n-|                                 sd}n|                                 sd}|t          ||z             dS )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      ?lib/python3.11/site-packages/sympy/polys/numberfields/primes.py*_check_formal_conditions_for_maximal_orderr      s     DFD--// N8((** N/((** NM ,Vd]+++, ,    c                       e Zd ZdZddZd Zed             ZddZd Z	d	 Z
d
 Zd ZeZd ZeZd Zd Zd Zd Zd Zd Zd ZdS )
PrimeIdealz8
    A prime ideal in a ring of algebraic integers.
    Nc                     t          |           || _        || _        || _        || _        d| _        ||n|                     ||z            | _        dS )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__zPrimeIdeal.__init__.   sZ    $ 	32666
 ?B)?)?r   c                 p    | j         rd| j         dS d| j         d| j                                         dS )N(), )is_inertr!   r"   as_exprr'   s    r   __str__zPrimeIdeal.__str__H   sE    = 	! tv=== 44644TZ//114444r   c                 ,    | j         | j        j        k    S )zv
        Say whether the rational prime we divide is inert, i.e. stays prime in
        our ring of integers.
        )r#   r    nr/   s    r   r-   zPrimeIdeal.is_inertM   s     v""r   Fc                 <   |p| j         j        j        j        }| j        | j        | j        | j        f\  }}}}t          |	                    |          
                                          }|j        dk    rd| d|j         }d| d| d}|r|S d| d| d	| d
S )a  
        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	numeratorr.   denom)	r'   	field_gen	just_gensr!   r"   r&   r#   	alpha_repgenss	            r   reprzPrimeIdeal.reprU   s    B 5!1!5	TVTV;5!Q)44<<>>??	;? 	76I6666I$1$$	$$$ 	K)D))Q))A))))r   c                 *    |                                  S N)r?   r/   s    r   __repr__zPrimeIdeal.__repr__   s    yy{{r   c                 `    | j         | j        z  | j        | j        z  z   }d|_        d|_        |S )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_submodulezPrimeIdeal.as_submodule   s6    n FTWtzDG33$#r   c                     t          |t                    r*|                                 |                                k    S t          S rA   )
isinstancer   rG   NotImplementedr'   others     r   __eq__zPrimeIdeal.__eq__   s=    eZ(( 	?$$&&%*<*<*>*>>>r   c                 0    |                                  |z   S )z
        Convert to a :py:class:`~.Submodule` and add to another
        :py:class:`~.Submodule`.

        See Also
        ========

        as_submodule

        rG   rK   s     r   __add__zPrimeIdeal.__add__          ""U**r   c                 0    |                                  |z  S )z
        Convert to a :py:class:`~.Submodule` and multiply by another
        :py:class:`~.Submodule` or a rational number.

        See Also
        ========

        as_submodule

        rO   rK   s     r   __mul__zPrimeIdeal.__mul__   rQ   r   c                     | j         S rA   )r    r/   s    r   _zeroth_powerzPrimeIdeal._zeroth_power   s	    wr   c                     | S rA    r/   s    r   _first_powerzPrimeIdeal._first_power   s    r   c                 j    | j         &t          | j        | j        g| j                  | _         | j         S )aO  
        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    r/   s    r   test_factorzPrimeIdeal.test_factor   s5       	T 4TVdj\47 S SD  r   c                 "    t          ||           S )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%   zPrimeIdeal.valuation   s      q$'''r   c                 P    |                                                      |          S )a  
        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

        )rG   reduce_element)r'   elts     r   r`   zPrimeIdeal.reduce_element  s$    2   ""11#666r   c                     | j         j                            |          }|                     |          }|                                S )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    r5   element_from_ANPr`   to_ANPr'   ara   reds       r   
reduce_ANPzPrimeIdeal.reduce_ANP*  s<    2 gn--a00!!#&&zz||r   c                     | j         j                            |          }|                     |          }|                    t          t          |j                                                                      S )a  
        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    r5   element_from_alg_numr`   field_elementlistreversedQQ_colflatre   s       r   reduce_alg_numzPrimeIdeal.reduce_alg_numG  s\    2 gn11!44!!#&&tHSZ__->->$?$?@@AAAr   rA   )NF)__name__
__module____qualname____doc__r(   r0   propertyr-   r?   rB   rG   rM   rP   __radd__rS   __rmul__rU   rX   r[   r%   r`   rh   rp   rW   r   r   r   r   )   s=        @ @ @ @45 5 5
 # # X#)* )* )* )*V  ; ; ;z  
+ + + H+ + + H    ! ! !(( ( ($7 7 76  :B B B B Br   r   c                 x    t          |           |                                 fd|D             } t          j        d|j        ft                               j        | }|                                dddf                                         }|	                    |j
        |z  |j                  }|S )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.)

    c                 b    g | ]+}                     |                                         ,S )modulus)inner_endomorphismmatrix).0gEr!   s     r   
<listcomp>z(_compute_test_factor.<locals>.<listcomp>  s8    HHHa$$Q''..q.99HHHr   r   Nr:   )r   endomorphism_ringr   zerosr2   r   vstack	nullspace	transposer5   r}   r:   )r!   r>   r    matricesBr4   betar   s   `      @r   rZ   rZ   e  s    < /r222
AHHHHH4HHHH3Art9bee,,3X>A 	
ad%%''A99RY]"(933DKr   c                    |j         |j        }}|j        |j        |j        }}}|                    t                                                    | j        z  |z  | j        z  }|                    t                    }|	                                }||z  dk    rdS |
                                }	||z  |	                                z  }
|
|z  dk    }d}	 ||z  }t          |          D ]n}|                    |dd|f         |          }||	z  }|                    |                                          }t          |          D ]}||         |||f<   o||dz
  |dz
  f         j        |z  dk    rnS||z  }|r,	 |                    t                    }n*# t           $ r Y n$w xY w|                    t                    }|dz  }|S )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   TNr   r   )r!   r    r2   r}   r:   
convert_tor   invr   detr[   ranger5   	representro   elementr   )r^   Pr!   r    r2   WdADr   r#   need_complete_testvjcis                   r   r]   r]     s   T CrAdBIrx!qA	R)A-7A 	
RA	A1uz q==??D	Q!%%''Aa%1*	A Eq 	 	A		!AAAqD'	++AIAQ$$&&A1XX  A$!Q$QUAE\?"Q&!+ 	E  		!LL$$!    R  A	Q78 Hs   >F 
F&%F&Nc                 f   t          |           |j        }|j        }t          fd| D                       r|                                S |A||z  }n9t          |                    |           j                                                  }|	                                }fd|dd         D             }|| z  }t          t          |          d          }	|	D ]Q}
t          d t          |
|          D                       }|                    |          |z  }|z  dk    r|z  c S RdS )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   H   K   | ]}|z                       d           V  dS )r   N)equiv)r~   r   r!   s     r   	<genexpr>z_two_elt_rep.<locals>.<genexpr>  s3      
*
*AE==
*
*
*
*
*
*r   Nc                     g | ]}|z  S rW   rW   )r~   omr!   s     r   r   z _two_elt_rep.<locals>.<listcomp>#  s    %%%RAbD%%%r   r   c              3   &   K   | ]\  }}||z  V  d S rA   rW   )r~   cibetais      r   r   z_two_elt_rep.<locals>.<genexpr>'  s*      ;;UBuH;;;;;;r   r   )r   r5   r6   allzeroabssubmodule_from_gensr}   r   basis_element_pullbacksr   lensumzipnorm)r>   r    r!   r#   Nppbr6   omegar   searchr   r"   r2   s     `          r   _two_elt_repr     sf   P /r222	B
A 
*
*
*
*T
*
*
*** wwyy	 @ 	@ABBR++D118<<>>??B&&((E%%%%59%%%DDLD#d))Q''F  ;;c!Tll;;;;; JJqMMRq5A: 	19	 r   c                 6    j         j        }t          |           }|                                \  }}t	          |          dk    rB|d         d         dk    r0t           j                                         j        d          gS  fd|D             S )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``.
    rz   r   r   c                     g | ]V\  }}t          j                            t          |t                               |                                |          WS domain)r   r5   element_from_polyr   r   degree)r~   tr&   r    r!   s      r   r   z+_prime_decomp_easy_case.<locals>.<listcomp>>  sj        1 r1y224"3E3E3EFFxxzz1& &   r   )r5   r6   r   factor_listr   r   r   r2   )r!   r    r6   T_barlcfls   ``    r   _prime_decomp_easy_caser   1  s     		AAE  FB
2ww!| >1aA >2q").."2"2BD!<<==        r   c                    | j         }|j        \  }}|dk    r|                    |t                    }n8|                    |                    |t                    dddf                   }|j        d         |k     rGt          |                    t                                                            t                    }|                    |          }|	                                 |
                    |          }t          |fd          }|                              }	|	                                sJ |	|fS )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                     | z  | z
  S rA   rW   )r4   r!   s    r   <lambda>z._prime_decomp_compute_kernel.<locals>.<lambda>s  s    !Q$( r   rz   )r}   shapeeyer   hstackr   r   r   submodule_from_matrixcompute_mult_tabdiscard_beforer   kernelr   )
r^   r!   r    r   r2   rr   GphiNs
    `        r   _prime_decomp_compute_kernelr   D  s)   2 	
A7DAq 	Av )EE!RLLHHQUU1b\\!!!Q$'((wqzA~ F!!,,r!uu"5"566AA"EE
  ##A
 	A
Q 2 2 2 2
3
3C

1
A     a4Kr   c                     | j         j        \  }}||z
  }j         | j         z  fdt          j        d                   D             }t          |||          }t	          |||          S )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

    c                 \    g | ](}                     d d |f         j                  )S )Nr   )r5   r:   )r~   r   r   r    s     r   r   z/_prime_decomp_maximal_ideal.<locals>.<listcomp>  s7    JJJ1BIIa1gRXI..JJJr   r   )r#   )r}   r   r   r   r   )	r^   r!   r    mr2   r#   r>   r"   r   s	     `     @r   _prime_decomp_maximal_idealr   y  s~    * 8>DAq	AA
	AHAJJJJJagaj8I8IJJJDr1***Eb!UA&&&r   c                     | j         |k    r|j         |u r	|j         |u sJ  |d                                          }|j        |u sJ g t          |t	                              }|                                \  }}|d         d         }	|                    |	          }
|	                    |
          \  }}}|dk    sJ t          t          t          ||	z  t                    j        j                            t          fdt          t                              D                       }d|z
  }||g}g }|D ]}|                                j        |u sJ  | j                            t	                              j        fd|                                D              }|                                                    t                    }|                    |          }|                    |           |S )z
    Perform the step in the prime decomposition algorithm where we have determined
    the 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   :   K   | ]}|         |         z  V  d S rA   rW   )r~   r   r   alpha_powerss     r   r   z,_prime_decomp_split_ideal.<locals>.<genexpr>  s0      ;;qtLO#;;;;;;r   c                 \    g | ](}|z                       t                               )S r   )columnr   )r~   r   r&   r!   s     r   r   z-_prime_decomp_split_ideal.<locals>.<listcomp>  s>     0
 0
 0
.0QVOO2a55O))0
 0
 0
r   )r5   	to_parentmoduler   r   r   quogcdexrl   rm   r   r   repr   r   r   r}   r   r   basis_elementscolumnspacer   append)r^   r!   r   r   r    r"   r   r   r   m1m2UVr   eps1eps2idempsfactorsepsr   r   Hr   r   r&   s    `                    @@@r   _prime_decomp_split_idealr     s    8r>>ah"n>Q>>>
 AaDDNNE<1LeRUU<888A ]]__FB	AqB	
rBhhrllGAq!6MMMXd1r6"---156677A;;;;;U3q66]];;;;;Dt8DD\FG  MMOOx2~-AH1&&- 0
 0
 0
 0
 0
464E4E4G4G0
 0
 0
  MMOO&&r**$$Q''qNr   c                 p   ||t          d          |t          |           ||j        j        }i }||t	          ||          \  }}|                                }||z  }|| z  dk    rt          | |          S |p$|                    |           pt          ||           }|g}g }	|r|	                                }
t          |
| |          \  }}|j        dk    r't          |
| |          }|	                    |           n-t          |
| |||          \  }}|                    ||g           ||	S )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.)

    Nz)At least one of T or ZK must be provided.)radicalsr   r   )
ValueErrorr   r5   r6   r   discriminantr   getr   popr   r2   r   r   r   extend)r!   r6   r    dKradicalr   dT	f_squaredstackprimesr^   r   r   r   I1I2s                   r   prime_decompr     s}   n 	 FR FDEEE	 722666 IKH	 1R 11x000B	
		BbI1} .&q"---CaC,<R,C,CGIEF
 #IIKK+Aq"5513!8 	#+Aq"55AMM!.q!Q2>>FBLL"b"""  # Mr   )NN)NNNN)&rt   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   rZ   r]   r   r   r   r   r   r   rW   r   r   <module>r     s   % % & & & & & & . . . . . . 0 0 0 0 0 0 . . . . . . : : : : : : 1 1 1 1 1 1 2 2 2 2 2 2 , , , , , , . . . . . . . . & & & & & & 6 6 6 6 6 6 6 6 : : : : : : : :, , ,0yB yB yB yB yB! yB yB yBx	+ + +\ U U UpB B B BJ  &2 2 2j' ' ':' ' 'T O O O O O Or   