§
    OŠtjp  ã                   óð   — 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"dS )é    )Ú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dS )Ú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                 óP  ‡ ‡‡— t          ‰¦  «        Št          ‰g¦  «        }t          |¦  «        rt          d¦  «        ‚t          |¦  «        }t	          |t
          ¦  «        st          d|z  ¦  «        ‚t          ‰¦  «        Št	          ‰t          ¦  «        r0‰}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¦  «        st!          d|z  ¦  «        ‚Œ&|                     ‰¦  «        t          j        u rt          d‰›d|›d�¦  «        ‚d }t	          |t          ¦  «        rJt%          |ˆˆfd„¦  «        }	|	d          rt          |	d         Ž }t          |	d          Ž }nt          |	d         Ž S t	          |‰ ¦  «        �r(|j        \  }
}}ˆ fd„}t)          |‰|
f¦  «        \  }}||k    rt          d¦  «        ‚t+          t-          t          ‰g¦  «        t          |
g¦  «        ¦  «        ¦  «        }|
‰k    rt          ‰|¦  «        Š|}nœ|j        ‰j        z  sDd„ |                     ¦   «         D ¦   «         }t          ‰|                     |¦  «        ¦  «        Š|}nI‰j        |
j        z  s:‰                     |¦  «        Št          ‰                     |¦  «        |¦  «        Š|}t	          ‰t4          ¦  «        rQ‰‰j        d         k    r@t	          ‰j        d         t
          ¦  «        r ‰j        d                              |¦  «        S t9          j        ‰ ‰‰|¦  «        }|€|nt=          ||¦  «        S )NzDuplicate symbols detectedz'base set should be a Set object, not %sc              3   ó6   K  — | ]}t          |d ¦  «        V — ŒdS )r   Nr	   )Ú.0Úlhss     úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/sets/conditionset.pyú	<genexpr>z'ConditionSet.__new__.<locals>.<genexpr>e   s*   è è € Ð4Ð4 3•B�s˜A‘J”JÐ4Ð4Ð4Ð4Ð4Ð4ó    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                 óJ   •— t          ‰                     ‰| ¦  «        ¦  «        S ©N)r   Úsubs)Ú_Ú	conditionÚsyms    €€r    ú<lambda>z&ConditionSet.__new__.<locals>.<lambda>Ž   s   ø€ ¥J¨y¯~ª~¸cÀ1Ñ/EÔ/EÑ$FÔ$F€ r"   Tc                 óp   •—  ‰| t          t          d¦  «        ¦  «                             ¦   «         j        S ©Nr   )r
   ÚadummyÚas_dummyr-   )ÚsÚclss    €r    Úsigz!ConditionSet.__new__.<locals>.sig—   s,   ø€ Ø�s˜1�b¥¨™mœmÑ,Ô,×5Ò5Ñ7Ô7Ô;Ð;r"   z"sym does not match sym of base setc                 ó   — i | ]\  }}||“Œ	S © r7   )r   ÚkÚvs      r    ú
<dictcomp>z(ConditionSet.__new__.<locals>.<dictcomp>¡   s   € Ð6Ð6Ð6¡  A˜˜1Ð6Ð6Ð6r"   r   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Úrvs   ```               r    rK   zConditionSet.__new__X   sþ  øøø€ Ý�s‰mŒmˆÝ˜�u‰~Œ~ˆÝ�D‰>Œ>ð 	BÝ#Ð$@ÑAÔAÐAÝ˜HÑ%Ô%ˆÝ˜(¥CÑ(Ô(ð 	FÝØ9¸HÑDñFô Fð Få˜YÑ'Ô'ˆ	å�i¥Ñ+Ô+ð 	Ø&ˆNØ4Ð4¨)Ð4Ñ4Ô4ˆDÝ˜T˜
ˆIÝ%ðð ðð ð ðð ð ð */Ø+Hðñ ô ð õ" ˜yÑ)Ô)ˆ	à�œÐÐØˆOà�œÐÐÝ”:Ðà•q”zÐ!Ð!Ý”:Ðð ð 	@ð 	@ˆAÝ˜1˜k¨5Ñ1Ô1ð @Ý Ð!:¸QÑ!>Ñ?Ô?Ð?ð@ð ×Ò˜SÑ!Ô!¥Q¤WÐ,Ð,Ý�)À#À#À#ÀxÀxÀxÐPÑQÔQÐQàˆÝ�h¥	Ñ*Ô*ð 	0ÝØÐFÐFÐFÐFÐFñHô HˆFà�dŒ|ð 0Ý  &¨¤,Ð/�Ý$ f¨T¤lÐ3��å  &¨¤,Ð/Ð/å�h Ñ$Ô$ñ 	Ø”m‰GˆAˆq�!ð<ð <ð <ð <ð <å˜˜s A˜hÑ'Ô'‰FˆB�Ø�RŠxˆxÝ'Ð(LÑMÔMÐMÝ��G S E™NœN­G°Q°C©L¬LÑ9Ô9Ñ:Ô:ˆDØ�CŠxˆxÝ 	¨1Ñ-Ô-�	Ø��Ø”^ cÔ&6Ñ6ð Ø6Ð6¨¯ª©¬Ð6Ñ6Ô6�Ý 	¨1¯:ª:°dÑ+;Ô+;Ñ<Ô<�	Ø��ØÔ+¨a¬nÑ<ð Ø—l’l 4Ñ(Ô(�Ý 	× 2Ò 2°4Ñ 8Ô 8¸!Ñ<Ô<�	Ø�õ �i¥Ñ*Ô*ð 	=°°y´~ÀaÔ7HÒ0HÐ0HÝ˜)œ.¨Ô+­SÑ1Ô1ð =Ø ”~ aÔ(×2Ò2°8Ñ<Ô<Ð<åŒ]˜3  Y°Ñ9Ô9ˆØ�\ˆrˆr¥u¨T°2¡¤Ð6r"   c                 ó   — | j         d         S r0   ©rC   ©Úselfs    r    r.   zConditionSet.<lambda>±   s   €  ¤	¨!¤€ r"   c                 ó   — | j         d         S )Nr   rZ   r[   s    r    r.   zConditionSet.<lambda>²   s   €  d¤i°¤l€ r"   c                 ó   — | j         d         S )Né   rZ   r[   s    r    r.   zConditionSet.<lambda>³   s   €  T¤Y¨q¤\€ r"   c                 óR   — | j         j        | j        j        z
  }|| j        j        z  S r)   )r,   rG   r-   rL   )r\   Ú	cond_symss     r    rG   zConditionSet.free_symbolsµ   s&   € à”NÔ/°$´(Ô2GÑGˆ	Ø˜4œ=Ô5Ñ5Ð5r"   c                 ó,   — t          | j        g¦  «        S r)   )r   r-   r[   s    r    Úbound_symbolszConditionSet.bound_symbolsº   s   € å˜œ�zÑ"Ô"Ð"r"   c                 ó6  ‡— ˆ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 d S w xY w)Nc                 óü   •— d„ | |fD ¦   «         }|                      d¦  «        }|dk    rdS |dk    rdS t          | ¦  «        t          |¦  «        k    o(t          ˆfd„t          | |¦  «        D ¦   «         ¦  «        S )Nc                 ó8   — g | ]}t          |t          ¦  «        ‘ŒS r7   )r;   r   )r   rP   s     r    ú
<listcomp>z:ConditionSet._contains.<locals>.ok_sig.<locals>.<listcomp>À   s"   € Ð;Ð;Ð;¨q•j ¥EÑ*Ô*Ð;Ð;Ð;r"   Tr   Fr   c              3   ó6   •K  — | ]\  }} ‰||¦  «        V — Œd S r)   r7   )r   rP   ÚjÚok_sigs      €r    r!   z9ConditionSet._contains.<locals>.ok_sig.<locals>.<genexpr>Æ   sB   øè è € ð ,4ð ,4Ù!%  A���q˜!‘”ð,4ð ,4ð ,4ð ,4ð ,4ð ,4r"   )ÚcountÚlenÚallrF   )ÚarT   ÚtuplesrS   rj   s       €r    rj   z&ConditionSet._contains.<locals>.ok_sig¿   sŸ   ø€ Ø;Ð;°Q¸°FÐ;Ñ;Ô;ˆFØ—’˜TÑ"Ô"ˆAØ�AŠvˆvØ�uØ�AŠvˆvØ�tÝ�q‘6”6�S ™VœVÒ#ð 4­ð ,4ð ,4ð ,4ð ,4Ý),¨Q°©¬ð,4ñ ,4ô ,4ñ )4ô )4ð 4r"   )	r-   r   r>   r   rL   r   r,   r   r<   )r\   ÚotherÚ	base_condÚlamdaÚlambda_condrj   s        @r    Ú	_containszConditionSet._contains¾   sÁ   ø€ ð	4ð 	4ð 	4ð 	4ð 	4ð ˆv�d”h Ñ&Ô&ð 	Ý”7ˆNõ ˜U D¤MÑ2Ô2ˆ	Ø�œÐÐÝ”7ˆNõ ˜œ�{ D¤NÑ3Ô3ˆð	/Ø˜% ™,œ,ˆKõ �y +Ñ.Ô.Ð.øõ ð 	ð 	ð 	Ø�4�4ð	øøøs   Á/B
 Â

BÂBc                 óÜ   — t          | j        | j        ¦  «        }t          | j        t          ¦  «        r ||Ž }n ||¦  «        }t          || j                             |¦  «        ¦  «        S r)   )r   r-   r,   r;   r   r   rL   rB   )r\   rp   Úfs      r    Úas_relationalzConditionSet.as_relationalÛ   sc   € Ý�4”8˜Tœ^Ñ,Ô,ˆÝ�d”h¥Ñ&Ô&ð 	Ø��5�	ˆAˆAà��%‘”ˆAÝ�1�d”m×,Ò,¨UÑ3Ô3Ñ4Ô4Ð4r"   c                 óž  — | j         \  }}}|                     |t          ¦  «        }|                     t          ¦  «        }|                     ||¦  «        }||k    r/|s|                     ||¦  «        }|                      |||¦  «        S |rn)t          |dd¦  «        r|                     ||¦  «        }n	 |                      |||¦  «        S )Nr&   F)rC   r*   r1   ÚhasÚfuncr@   )	r\   Ú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Ð0Øð 	ØÝ�S˜+ uÑ-Ô-ð 	Ø—9’9˜S #Ñ&Ô&ˆDˆDàØ�yŠy˜˜d DÑ)Ô)Ð)r"   c                 ó4   — t          | j        j        ¦  «        S r)   )r   r-   Úkindr[   s    r    Ú_kindzConditionSet._kindõ   s   € Ý�t”x”}Ñ%Ô%Ð%r"   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚUniversalSetrK   Úpropertyr-   r,   rL   rG   rc   rt   rw   r‚   r…   r7   r"   r    r   r      sì   € € € € € ðCð CðH /0¬nð W7ð W7ð W7ð W7ðr ˆ(Ð,Ð,Ñ
-Ô
-€CØ�Ð2Ð2Ñ3Ô3€IØˆxÐ1Ð1Ñ2Ô2€Hàð6ð 6ñ „Xð6ð ð#ð #ñ „Xð#ð/ð /ð /ð:5ð 5ð 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   rB   r   Úsetsr   r   r   r   r1   r   r7   r"   r    ú<module>r˜      sh  ðØ "Ð "Ð "Ð "Ð "Ð "Ø "Ð "Ð "Ð "Ð "Ð "Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø $Ð $Ð $Ð $Ð $Ð $Ø #Ð #Ð #Ð #Ð #Ð #Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø @Ð @Ð @Ð @Ð @Ð @Ø Ð Ð Ð Ð Ð Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0ð 
ˆˆ~Ñ	Ô	€ðc&ð c&ð c&ð c&ð c&�3ñ c&ô c&ð c&ð c&ð c&r"   