Ë
    7^(hp  ã                   óâ   — 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 d dlmZ d dlmZ d d	lmZmZ d d
lmZmZmZ d dlmZ ddlmZ ddlmZmZmZm Z   ed«      Z! G d„ de«      Z"y)é    )ÚS)ÚBasic)ÚTuple)ÚLambdaÚBadSignatureError)Ú
fuzzy_bool©ÚEq)ÚDummy)Ú_sympify)ÚAndÚ
as_Boolean)ÚsiftÚflattenÚhas_dups)Úsympy_deprecation_warningé   )ÚContains)ÚSetÚUnionÚ	FiniteSetÚSetKindÚconditionsetc                   óœ   — e Zd ZdZej
                  fd„Z ed„ «      Z ed„ «      Z	 ed„ «      Z
ed„ «       Zed„ «       Zd„ Zd	„ Zd
„ Zd„ Zy)ÚConditionSeta¾  
    Set of elements which satisfies a given condition.

    .. math:: \{x \mid \textrm{condition}(x) = \texttt{True}, x \in S\}

    Examples
    ========

    >>> from sympy import Symbol, S, ConditionSet, pi, Eq, sin, Interval
    >>> from sympy.abc import x, y, z

    >>> sin_sols = ConditionSet(x, Eq(sin(x), 0), Interval(0, 2*pi))
    >>> 2*pi in sin_sols
    True
    >>> pi/2 in sin_sols
    False
    >>> 3*pi in sin_sols
    False
    >>> 5 in ConditionSet(x, x**2 > 4, S.Reals)
    True

    If the value is not in the base set, the result is false:

    >>> 5 in ConditionSet(x, x**2 > 4, Interval(2, 4))
    False

    Notes
    =====

    Symbols with assumptions should be avoided or else the
    condition may evaluate without consideration of the set:

    >>> n = Symbol('n', negative=True)
    >>> cond = (n > 0); cond
    False
    >>> ConditionSet(n, cond, S.Integers)
    EmptySet

    Only free symbols can be changed by using `subs`:

    >>> c = ConditionSet(x, x < 1, {x, z})
    >>> c.subs(x, y)
    ConditionSet(x, x < 1, {y, z})

    To check if ``pi`` is in ``c`` use:

    >>> pi in c
    False

    If no base set is specified, the universal set is implied:

    >>> ConditionSet(x, x < 1).base_set
    UniversalSet

    Only symbols or symbol-like expressions can be used:

    >>> ConditionSet(x + 1, x + 1 < 1, S.Integers)
    Traceback (most recent call last):
    ...
    ValueError: non-symbol dummy not recognized in condition

    When the base set is a ConditionSet, the symbols will be
    unified if possible with preference for the outermost symbols:

    >>> ConditionSet(x, x < y, ConditionSet(z, z + y < 2, S.Integers))
    ConditionSet(x, (x < y) & (x + y < 2), Integers)

    c                 ó”  ‡ ‡‡— t        ‰«      Št        ‰g«      }t        |«      rt        d«      ‚t        |«      }t	        |t
        «      st        d|z  «      ‚t        ‰«      Št	        ‰t        «      r(‰}d„ ‰D «       }t        |Ž Št        d|› d‰› d�dd¬	«       t        ‰«      Š‰t        j                  u r|S ‰t        j                  u rt        j                  S |t        j                  u rt        j                  S |D ]  }t        |d
d«      rŒt!        d|z  «      ‚ |j#                  ‰«      t        j                  u rt        d‰›d|›d�«      ‚d }t	        |t        «      r7t%        |ˆˆfd„«      }	|	d    rt        |	d   Ž }t        |	d    Ž }nt        |	d   Ž S t	        |‰ «      �r|j&                  \  }
}}ˆ fd„}t)        |‰|
f«      \  }}||k7  rt        d«      ‚t+        t-        t        ‰g«      t        |
g«      «      «      }|
‰k(  rt        ‰|«      Š|}n¡|j.                  ‰j.                  z  sA|j1                  «       D ��ci c]  \  }}||“Œ
 }}}t        ‰|j3                  |«      «      Š|}nG‰j.                  |
j.                  z  s.‰j3                  |«      Št        ‰j3                  |«      |«      Š|}t	        ‰t4        «      rM‰‰j&                  d   k(  r;t	        ‰j&                  d   t
        «      r‰j&                  d   j7                  |«      S t9        j:                  ‰ ‰‰|«      }|€|S t=        ||«      S c c}}w )NzDuplicate symbols detectedz'base set should be a Set object, not %sc              3   ó4   K  — | ]  }t        |d «      –— Œ y­w)r   Nr	   )Ú.0Úlhss     úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/sets/conditionset.pyú	<genexpr>z'ConditionSet.__new__.<locals>.<genexpr>e   s   è ø€ Ò4 3”B�s˜A—JÑ4ùs   ‚zq
Using a set for the condition in ConditionSet is deprecated. Use a boolean
instead.

In this case, replace

    z

with

    ú
z1.5zdeprecated-conditionset-set)Údeprecated_since_versionÚactive_deprecations_targetÚ	_diff_wrtFz`%s` is not symbol-likezsym `z` is not in base_set `ú`c                 ó:   •— t        ‰j                  ‰| «      «      S ©N)r   Úsubs)Ú_Ú	conditionÚsyms    €€r    ú<lambda>z&ConditionSet.__new__.<locals>.<lambda>Ž   s   ø€ ¤J¨y¯~©~¸cÀ1Ó/EÓ$F€ ó    Tc                 ób   •—  ‰| t        t        d«      «      j                  «       j                  S ©Nr   )r
   ÚadummyÚas_dummyr,   )ÚsÚclss    €r    Úsigz!ConditionSet.__new__.<locals>.sig—   s%   ø€ Ù˜1œb¤¨›mÓ,×5Ñ5Ó7×;Ñ;Ð;r.   z"sym does not match sym of base setr   r   )r   r   r   r   Ú
isinstancer   Ú	TypeErrorr   r   r   r   r   ÚtrueÚfalseÚEmptySetÚgetattrÚ
ValueErrorÚcontainsr   ÚargsÚmapÚdictÚzipÚfree_symbolsÚitemsÚxreplacer   Ú	intersectr   Ú__new__r   )r4   r,   r+   Úbase_setÚflatÚcondition_origÚtempÚiÚknowÚsiftedr3   ÚcÚbr5   ÚsaÚsbÚrepsÚkÚvÚrvs   ```                 r    rF   zConditionSet.__new__X   s"  ú€ Ü�s‹mˆÜ˜�u‹~ˆÜ�DŒ>Ü#Ð$@ÓAÐAÜ˜HÓ%ˆÜ˜(¤CÔ(ÜØ9¸HÑDóFð Fä˜YÓ'ˆ	ä�i¤Ô+Ø&ˆNÙ4¨)Ô4ˆDÜ˜T˜
ˆIÜ%ðð Ðð ð €Kð ðð */Ø+Hõô" ˜yÓ)ˆ	àœŸ™ÑØˆOàœŸ™ÑÜ—:‘:Ðà”q—z‘zÑ!Ü—:‘:Ðð ò 	@ˆAÜ˜1˜k¨5Õ1Ü Ð!:¸QÑ!>Ó?Ð?ð	@ð ×Ñ˜SÓ!¤Q§W¡WÑ,ÝÂ#ÂxÐPÓQÐQàˆÜ�h¤	Ô*ÜØÔFóHˆFà�dŠ|Ü  &¨¡,Ð/�Ü$ f¨T¡lÐ3‘ä  &¨¡,Ð/Ð/ä�h Õ$Ø—m‘m‰GˆAˆq�!ô<ä˜˜s A˜hÓ'‰FˆB�Ø�RŠxÜ'Ð(LÓMÐMÜœœG S E›N¬G°Q°C«LÓ9Ó:ˆDØ�CŠxÜ 	¨1Ó-�	Ø‘Ø—^‘^ c×&6Ñ&6Ò6Ø)-¯©«×6¡  A˜˜1™Ð6�Ñ6Ü 	¨1¯:©:°dÓ+;Ó<�	Ø‘Ø×+Ñ+¨a¯n©nÒ<Ø—l‘l 4Ó(�Ü 	× 2Ñ 2°4Ó 8¸!Ó<�	Ø�ô �i¤Ô*°°y·~±~ÀaÑ7HÒ0HÜ˜)Ÿ.™.¨Ñ+¬SÔ1Ø —~‘~ aÑ(×2Ñ2°8Ó<Ð<ä�]‰]˜3  Y°Ó9ˆØ�\ˆrÐ6¤u¨T°2£Ð6ùó 7s   É
Mc                 ó    — | j                   d   S r0   ©r>   ©Úselfs    r    r-   zConditionSet.<lambda>±   s   €  §	¡	¨!¡€ r.   c                 ó    — | j                   d   S )Nr   rW   rX   s    r    r-   zConditionSet.<lambda>²   s   €  d§i¡i°¡l€ r.   c                 ó    — | j                   d   S )Né   rW   rX   s    r    r-   zConditionSet.<lambda>³   s   €  T§Y¡Y¨q¡\€ r.   c                 óŽ   — | j                   j                  | j                  j                  z
  }|| j                  j                  z  S r(   )r+   rB   r,   rG   )rY   Ú	cond_symss     r    rB   zConditionSet.free_symbolsµ   s5   € à—N‘N×/Ñ/°$·(±(×2GÑ2GÑGˆ	Ø˜4Ÿ=™=×5Ñ5Ñ5Ð5r.   c                 ó.   — t        | j                  g«      S r(   )r   r,   rX   s    r    Úbound_symbolszConditionSet.bound_symbolsº   s   € ä˜Ÿ™�zÓ"Ð"r.   c                 óN  ‡— ˆfd„Š ‰| j                   |«      st        j                  S t        || j                  «      }|t        j                  u rt        j                  S t        | j                   f| j                  «      }	  ||«      }t        ||«      S # t        $ r Y y w xY w)Nc                 óô   •— | |fD �cg c]  }t        |t        «      ‘Œ }}|j                  d«      }|dk(  ry|dk(  ryt        | «      t        |«      k(  xr t	        ˆfd„t        | |«      D «       «      S c c}w )NTr   Fr   c              3   ó6   •K  — | ]  \  }} ‰||«      –— Œ y ­wr(   © )r   rK   ÚjÚok_sigs      €r    r!   z9ConditionSet._contains.<locals>.ok_sig.<locals>.<genexpr>Æ   s    øè ø€ ò ,4Ù!%  A‘�q˜!—ñ,4ùs   ƒ)r6   r   ÚcountÚlenÚallrA   )ÚarO   rK   ÚtuplesrN   rf   s        €r    rf   z&ConditionSet._contains.<locals>.ok_sig¿   s|   ø€ Ø56¸°FÖ;¨q”j ¤EÕ*Ð;ˆFÐ;Ø—‘˜TÓ"ˆAØ�AŠvØØ�AŠvØÜ�q“6œS ›VÑ#ò 4¬ó ,4Ü),¨Q°«ô,4ó )4ð 4ùò <s   ˆA5)	r,   r   r9   r   rG   r   r+   r   r7   )rY   ÚotherÚ	base_condÚlamdaÚlambda_condrf   s        @r    Ú	_containszConditionSet._contains¾   s‘   ø€ ô	4ñ �d—h‘h Ô&Ü—7‘7ˆNô ˜U D§M¡MÓ2ˆ	ØœŸ™ÑÜ—7‘7ˆNô ˜Ÿ™�{ D§N¡NÓ3ˆð	/Ù ›,ˆKô �y +Ó.Ð.øô ò 	Ùð	ús   ÂB Â	B$Â#B$c                 óÜ   — t        | j                  | j                  «      }t        | j                  t        «      r ||Ž }n ||«      }t        || j                  j                  |«      «      S r(   )r   r,   r+   r6   r   r   rG   r=   )rY   rl   Úfs      r    Úas_relationalzConditionSet.as_relationalÛ   sR   € Ü�4—8‘8˜TŸ^™^Ó,ˆÜ�d—h‘h¤Ô&Ù�5�	‰Aá�%“ˆAÜ�1�d—m‘m×,Ñ,¨UÓ3Ó4Ð4r.   c                 ób  — | j                   \  }}}|j                  |t        «      }|j                  t        «      }|j                  ||«      }||k7  r'|s|j                  ||«      }| j	                  |||«      S |rn!t        |dd«      r|j                  ||«      }n	 | j	                  |||«      S )Nr%   F)r>   r)   r1   ÚhasÚfuncr;   )	rY   ÚoldÚnewr,   ÚcondÚbaseÚdsymÚinsymÚnewbases	            r    Ú
_eval_subszConditionSet._eval_subsã   s¤   € ØŸ)™)‰ˆˆT�4Ø�x‰x˜œVÓ$ˆØ—‘œÓ ˆà—)‘)˜C Ó%ˆØ�dŠ?ÙØ—y‘y  cÓ*�Ø—9‘9˜S $¨Ó0Ð0ÙØÜ�S˜+ uÔ-Ø—9‘9˜S #Ó&‰DàØ�y‰y˜˜d DÓ)Ð)r.   c                 ó@   — t        | j                  j                  «      S r(   )r   r,   ÚkindrX   s    r    Ú_kindzConditionSet._kindõ   s   € Ü�t—x‘x—}‘}Ó%Ð%r.   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚUniversalSetrF   Úpropertyr,   r+   rG   rB   r`   rp   rs   r~   r�   rd   r.   r    r   r      sv   „ ñCðH /0¯n©nó W7ñr Ñ,Ó
-€CÙÑ2Ó3€IÙÑ1Ó2€Hàñ6ó ð6ð ñ#ó ð#ò/ò:5ò*ó$&r.   r   N)#Úsympy.core.singletonr   Úsympy.core.basicr   Úsympy.core.containersr   Úsympy.core.functionr   r   Úsympy.core.logicr   Úsympy.core.relationalr
   Úsympy.core.symbolr   Úsympy.core.sympifyr   Úsympy.logic.boolalgr   r   Úsympy.utilities.iterablesr   r   r   Úsympy.utilities.exceptionsr   r=   r   Úsetsr   r   r   r   r1   r   rd   r.   r    ú<module>r”      sL   ðÝ "Ý "Ý 'ß 9Ý 'Ý $Ý #Ý 'ß /ß =Ñ =Ý @Ý ß 0Ó 0ñ 
ˆ~Ó	€ôc&�3õ c&r.   