+
    ‹°³jm,  ã                   óº   € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt R tR tR tR t]R 4       tR# )z0Tools for constructing domains for expressions. )Úprod)Úsympify)Úpure_complex)Úordered)ÚZZÚQQÚZZ_IÚQQ_IÚEX)ÚComplexField)Ú	RealField)Úbuild_options)Úparallel_dict_from_basic)Úpublicc                óR  € R;p;p;rE. pVP                   RJ d   R pMR pV  EF1  pVP                  '       d   VP                  '       g   RpK,  K.  VP                  '       d!   V'       d    R# RpVP	                  V4       K`  \        V4      p	V	'       d¡   RpV	w  r«V
P                  '       d;   VP                  '       d)   V
P                  '       d   VP                  '       g   RpKÅ  RpV
P                  '       d   VP	                  V
4       VP                  '       d   VP	                  V4       EK  EK  V! V4      '       d   V'       d    R# RpEK1   R# 	  V'       d   \        R V 4       4      M^5pV'       d   \        W4      w  rÞWÞ3# V'       d   V'       d   \        VR7      pMXV'       d   \        VR7      pMCV'       g   VP                  '       d   V'       d   \        M\        pMV'       d   \        M\        pV  Uu. uF  q�P                  V4      NK  	  ppWÞ3# u upi )z?Handle simple domains, e.g.: ZZ, QQ, RR and algebraic domains. FTc                 óB   € V P                   ;'       d    V P                  # ©N©Ú	is_numberÚis_algebraic©Úcoeffs   &ÚX/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/polys/constructor.pyÚ<lambda>Ú#_construct_simple.<locals>.<lambda>   s   €  U§_¡_×%KÐ%K¸×9KÑ9KÐ%Kó    c                 ó   € R # )F© r   s   &r   r   r      s   € ¡Ur   Nc              3   ó8   "  € T F  qP                   x € K  	  R # 5ir   ©Ú_prec©Ú.0Úcs   & r   Ú	<genexpr>Ú$_construct_simple.<locals>.<genexpr>>   ó   é € Ð2¡M˜q—7–7£Mùó   ‚©Úprec)Ú	extensionÚis_RationalÚ
is_IntegerÚis_FloatÚappendr   ÚmaxÚ_construct_algebraicr   r   Úfieldr	   r   r   r   Ú
from_sympy)ÚcoeffsÚoptÚ	rationalsÚfloatsÚ	complexesÚ
algebraicsÚfloat_numbersr   r   Ú
is_complexÚxÚyÚmax_precÚdomainÚresults   &&             r   Ú_construct_simpler@      s«  € à27Ð7€IÐ7�Ð7˜Ø€Mà
‡}�}˜ÓÙK‰á*ˆäˆØ××ÐØ×#×#Ð#Ø ’	ñ $à�^�^ˆ^ßâà�Ø×$Ñ$ UÖ+ä% eÓ,ˆJßØ �	Ø!‘�Ø—=—=�= Q§]§] ]ØŸLŸL˜L¨Q¯\¯\¨\Ø$(˜	Ùà!�FØ—z—z�zØ%×,Ñ,¨QÔ/Ø—z—z�zØ%×,Ñ,¨Q×/ò "á˜e×$Ò$ßâ Ø!“
ò ñC ÷J 7DŒsÑ2¡MÓ2Ô2È€HçÜ-¨fÓ:‰ˆð ˆ>Ð÷ —iÜ! xÔ0‰FßÜ HÔ-‰Fß˜#Ÿ)Ÿ)˜)ß&•T¬B‰Fç&•T¬BˆFá8>Ó?¹¨u×#Ñ# EÖ*¹ˆÐ?àˆ>Ðùò @s   ÈH$c                ó  aaaaaa€ ^ RI Hp \        4       oVV3R loS! V 4      p\        \	        S4      4      oV! SRRR7      w  orE\        R \        VS4       4       4      p\        P                  ! SV34      SP                  P                  4       uooV Uu. uF$  pSP                  P                  VS\        4      NK&  	  pp\        \        SV4      4      oVVVV3R loV U	u. uF  p	S! V	4      NK  	  p
p	SV
3# u upi u up	i )zDWe know that coefficients are algebraic so construct the extension. )Úprimitive_elementc                 ó\  <€ . pV  F¢  pVP                   '       d   R \        P                  ! V4      3pMcVP                  '       d   RS! VP                  4      3pM<VP
                  '       d   RS! VP                  4      3pMRV3pSP                  V4       VP                  V4       K¤  	  V# )ÚQÚ+Ú*Úe)r+   r   r2   Úis_AddÚargsÚis_MulÚaddr.   )rI   ÚtreesÚaÚtreeÚbuild_treesÚextss   &   €€r   rO   Ú)_construct_algebraic.<locals>.build_treesW   s�   ø€ ØˆÛˆAØ�}�}ˆ}ØœRŸ]š]¨1Ó-Ð.‘Ø——�Ø™[¨¯©Ó0Ð1‘Ø——�Ø™[¨¯©Ó0Ð1‘à˜Q�x�Ø—‘˜”Ø�L‰L˜Öñ ð ˆr   T)ÚexÚpolysc              3   ó6   "  € T F  w  rW,          x € K  	  R # 5ir   r   )r"   ÚsÚexts   &  r   r$   Ú'_construct_algebraic.<locals>.<genexpr>j   s   é € Ð3¡?™˜ˆq�uŠu£?ùs   ‚c                 ó  <€ V w  rVR 8X  d#   SP                   P                  V.S\        4      # VR8X  d!   \        V3R lV 4       SP                  4      # VR8X  d   \        V3R lV 4       4      # VR8X  d
   SV,          # \        h)rD   rE   c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5ir   r   ©r"   rM   Úconvert_trees   & €r   r$   Ú=_construct_algebraic.<locals>.convert_tree.<locals>.<genexpr>v   ó   øé € Ð6±¨A™ QŸ˜³ùó   ƒrF   c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5ir   r   rZ   s   & €r   r$   r\   x   r]   r^   rG   )ÚdtypeÚ	from_listr   ÚsumÚzeror   ÚRuntimeError)rN   ÚoprI   r[   r>   Úexts_mapÚgs   &  €€€€r   r[   Ú*_construct_algebraic.<locals>.convert_treeq   sy   ø€ Ø‰ˆØ�Œ9Ø—<‘<×)Ñ)¨4¨&°!´RÓ8Ð8Ø�3ŒYÜÔ6±Ó6¸¿¹ÓDÐDØ�3ŒYÜÔ6±Ó6Ó6Ð6Ø�3ŒYØ˜D•>Ð!äÐr   )Úsympy.polys.numberfieldsrB   ÚsetÚlistr   rb   Úzipr   Úalgebraic_fieldÚrepÚto_listr`   ra   Údict)r3   r4   rB   rL   ÚspanÚHÚrootÚhÚexts_domrN   r?   rO   r[   r>   rP   rf   rg   s   &&         @@@@@@r   r0   r0   Q   sé   ý€ å:ä‹5€Döñ ˜Ó€EÜ”˜“Ó€Dá" 4¨D¸Ô=�J€A€tÜÑ3¤3 t¨T¤?Ó3Ó3€Dä×"Ò" A t 9Ó-¨q¯u©u¯}©}«€I€FˆAá:;Ó<¹!°Q�—‘×&Ñ& q¨!¬RÖ0¹!€HÐ<Ü”C˜˜hÓ'Ó(€H÷ð ñ .3Ó3©U T‰l˜4Ö ©U€FÐ3à�6ˆ>Ðùò% =ùò  4s   Â*D Ã)Dc                ó`	  € . . r2V  F7  pVP                  4       w  rVVP                  V4       VP                  V4       K9  	  \        W#,           4      w  rxV'       g   R# VP                  fu   \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   R# \        4       p	V F(  p
V
P                  pW›,          '       d    R# W›,          p	K*  	  \        V4      p\        V4      ^,          pVRV pW}R pVP                  '       d   RpM-RRV,          rþV F  p\        V4      ^8”  g	   Wö9  g   K  Rp M	  \        4       p V'       gV   \        W#4       FE  w  rVVX,          pVP                  4        F#  w  ppWF,          pV P                  V4       WEV&   K%  	  KG  	  Md\        W#4       FU  w  rVV P                  \        VP                  4       4      4       V P                  \        VP                  4       4      4       KW  	  R;p;pp. pV  EF  pVP                  '       d   VP                   '       g   RpK,  K.  VP"                  '       d   RpVP                  V4       KU  \%        V4      pVf   Kf  RpVw  ppVP                  '       d=   VP                  '       d+   VP                   '       d   VP                   '       g   RpK¹  K»  RpVP"                  '       d   VP                  V4       VP"                  '       g   Kô  VP                  V4       EK  	  V'       d   \'        R V 4       4      M^5pV'       d   V'       d   \)        VR7      pMHV'       d   \+        VR7      pM3V'       d   V'       d   \,        pM\.        pMV'       d   \0        pM\2        p. pV'       gc   VP4                  ! V!  pV FH  pVP                  4        F  w  ppVP7                  V4      VV&   K  	  VP                  V! V4      4       KJ  	  VV3# VP8                  ! V!  p\        W#4       Fy  w  rVVP                  4        F  w  ppVP7                  V4      VV&   K  	  VP                  4        F  w  ppVP7                  V4      VV&   K  	  VP                  V! WV34      4       K{  	  VV3# )z<Handle composite domains, e.g.: ZZ[X], QQ[X], ZZ(X), QQ(X). Nc              3   ó`   "  € T F$  qP                   ;'       d    VP                  x € K&  	  R # 5ir   r   )r"   Úgens   & r   r$   Ú'_construct_composite.<locals>.<genexpr>’   s#   é € ÐB¹T°c�}‰}×1Ð1 ×!1Ñ!1Ô1»Tùs   ‚.™.TFc              3   ó8   "  € T F  qP                   x € K  	  R # 5ir   r   r!   s   & r   r$   ry   ×   r&   r'   r(   )é    )Úas_numer_denomr.   r   Ú	compositeÚanyrj   Úfree_symbolsÚlenr1   rl   ÚitemsrK   Úupdaterk   Úvaluesr+   r,   r-   r   r/   r   r   r	   r   r   r   Ú	poly_ringr2   Ú
frac_field)r3   r4   ÚnumersÚdenomsr   ÚnumerÚdenomrS   ÚgensÚall_symbolsrx   ÚsymbolsÚnÚkÚ	fractionsÚzerosÚmonomr5   r6   r7   r9   r:   r;   r<   r=   Úgroundr?   r>   s   &&                          r   Ú_construct_compositer“   ƒ   sÖ  € à˜ˆFãˆØ×+Ñ+Ó-‰ˆà�‰�eÔØ�‰�eÖñ	 ô +¨6­?Ó;�K€EßÙà
‡}�}Òß‹3ÑB¹TÓB�3�3Š3ÑB¹TÓB×BÒBÙä“eˆãˆCØ×&Ñ&ˆGà×$Ô$ÚàÕ&’ñ ô 	ˆD‹	€AÜˆE‹
�A�€Aà�2�AˆY€FØ�2ˆY€Fà
‡y‡y€yØ‰	à  $ q¥&�5ãˆEÜ�5‹z˜AŒ~ Ö!3Ø �	Ùñ ô
 ‹U€FçÜ Ö/‰LˆEØ˜%•LˆEà %§¡¦‘��uØ•�Ø—
‘
˜5Ô!Ø$�e“ó !.ò 0ô   Ö/‰LˆEØ�M‰Mœ$˜uŸ|™|›~Ó.Ô/Ø�M‰Mœ$˜uŸ|™|›~Ó.Ö/ñ 0ð &+Ð*€IÐ*�˜Ø€MäˆØ××ÐØ×#×#Ð#Ø ’	ñ $à�^�^ˆ^ØˆFØ× Ñ  Ö'ä% eÓ,ˆJØÔ%Ø �	Ø!‘��1Ø—=—=�= Q§]§] ]ØŸLŸL˜L¨Q¯\¯\¨\Ø$(š	ñ .:ð "�FØ—z—z�zØ%×,Ñ,¨QÔ/Ø—z—z’zØ%×,Ñ,¨Q×/ñ) ÷, 7DŒsÑ2¡MÓ2Ô2È€Hç—)Ü 8Ô,‰ß	Ü Ô)‰ß	ßÜ‰Fä‰Fß	Ü‰äˆà€FçØ×!Ò! 4Ñ(ˆãˆEØ %§¡¦‘��uØ%×0Ñ0°Ó7��e“ñ !.ð �M‰M™& ›-Ö(ñ	 ð" �6ˆ>Ðð ×"Ò" DÑ)ˆä Ö/‰LˆEØ %§¡¦‘��uØ%×0Ñ0°Ó7��e“ñ !.ð !&§¡¦‘��uØ%×0Ñ0°Ó7��e“ñ !.ð �M‰M™& % Ó0Ö1ñ 0ð �6ˆ>Ðr   c                óh   € \         . r2V  F#  pVP                  VP                  V4      4       K%  	  W#3# )z6The last resort case, i.e. use the expression domain. )r
   r.   r2   )r3   r4   r>   r?   r   s   &&   r   Ú_construct_expressionr•      s4   € ä˜ˆFãˆØ�‰�f×'Ñ'¨Ó.Ö/ñ ð ˆ>Ðr   c           	     óx  € \        V4      p\        V R4      '       dR   \        V \        4      '       d9   V '       g   . . rCM2\	        \        \	        V P                  4       4      !  4      w  r4MT pMV .p\	        \        \        V4      4      p\        WB4      pVe   VRJd   Vw  rdMB\        WB4      w  rdM4VP                  RJ d   RpM\        WB4      pVe   Vw  rdM\        WB4      w  rd\        V R4      '       d:   \        V \        4      '       d!   V\        \	        \        XV4      4      4      3# Wd3# Wd^ ,          3# )ad  Construct a minimal domain for a list of expressions.

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

Given a list of normal SymPy expressions (of type :py:class:`~.Expr`)
``construct_domain`` will find a minimal :py:class:`~.Domain` that can
represent those expressions. The expressions will be converted to elements
of the domain and both the domain and the domain elements are returned.

Parameters
==========

obj: list or dict
    The expressions to build a domain for.

**args: keyword arguments
    Options that affect the choice of domain.

Returns
=======

(K, elements): Domain and list of domain elements
    The domain K that can represent the expressions and the list or dict
    of domain elements representing the same expressions as elements of K.

Examples
========

Given a list of :py:class:`~.Integer` ``construct_domain`` will return the
domain :ref:`ZZ` and a list of integers as elements of :ref:`ZZ`.

>>> from sympy import construct_domain, S
>>> expressions = [S(2), S(3), S(4)]
>>> K, elements = construct_domain(expressions)
>>> K
ZZ
>>> elements
[2, 3, 4]
>>> type(elements[0])  # doctest: +SKIP
<class 'int'>
>>> type(expressions[0])
<class 'sympy.core.numbers.Integer'>

If there are any :py:class:`~.Rational` then :ref:`QQ` is returned
instead.

>>> construct_domain([S(1)/2, S(3)/4])
(QQ, [1/2, 3/4])

If there are symbols then a polynomial ring :ref:`K[x]` is returned.

>>> from sympy import symbols
>>> x, y = symbols('x, y')
>>> construct_domain([2*x + 1, S(3)/4])
(QQ[x], [2*x + 1, 3/4])
>>> construct_domain([2*x + 1, y])
(ZZ[x,y], [2*x + 1, y])

If any symbols appear with negative powers then a rational function field
:ref:`K(x)` will be returned.

>>> construct_domain([y/x, x/(1 - y)])
(ZZ(x,y), [y/x, -x/(y - 1)])

Irrational algebraic numbers will result in the :ref:`EX` domain by
default. The keyword argument ``extension=True`` leads to the construction
of an algebraic number field :ref:`QQ(a)`.

>>> from sympy import sqrt
>>> construct_domain([sqrt(2)])
(EX, [EX(sqrt(2))])
>>> construct_domain([sqrt(2)], extension=True)  # doctest: +SKIP
(QQ<sqrt(2)>, [ANP([1, 0], [1, 0, -2], QQ)])

See also
========

Domain
Expr
Ú__iter__NF)r   ÚhasattrÚ
isinstancerp   rk   rl   r�   Úmapr   r@   r•   r}   r“   )ÚobjrI   r4   Úmonomsr3   r?   r>   s   &,     r   Úconstruct_domainr�   
  s  € ôf ˜Ó
€Cäˆs�J×ÒÜ�cœ4× Ò ßØ!# R™ä!%¤c¬4°·	±	³Ó+<Ñ&=Ó!>‘�˜à‰Fà�ˆä”#”g˜vÓ&Ó'€FÜ˜vÓ+€FàÒØ˜ÓØ#‰NˆF�Fä2°6Ó?‰NˆF�Fà�=‰=˜EÓ!Ø‰Fä)¨&Ó6ˆFàÒØ#‰NˆF�Fä2°6Ó?‰NˆFäˆs�J×ÒÜ�cœ4× Ò Øœ4¤¤S¨°Ó%8Ó 9Ó:Ð:Ð:à�>Ð!à˜a•yÐ Ð r   N)Ú__doc__Úmathr   Ú
sympy.corer   Úsympy.core.evalfr   Úsympy.core.sortingr   Úsympy.polys.domainsr   r   r   r	   r
   Ú sympy.polys.domains.complexfieldr   Úsympy.polys.domains.realfieldr   Úsympy.polys.polyoptionsr   Úsympy.polys.polyutilsr   Úsympy.utilitiesr   r@   r0   r“   r•   r�   r   r   r   Ú<module>r©      sW   ðÙ 6Ý å Ý )Ý &ß 6Õ 6Ý 9Ý 3Ý 1Ý :Ý "ò?òD/òdzòzð ñx!ó òx!r   