� ��gp����ddlmZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZddlmZdd lmZmZdd lmZmZmZdd lmZd d lmZd dlmZmZmZm Z ed��Z!Gd�de��Z"dS)�)�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��eZdZdZejfd�Zed���Zed���Z ed���Z ed���Z ed���Z d�Z d �Zd �Zd �Zd 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|��rtd���t|��}t |t ��st d|z���t����t �t��r0�}d��D��}t|��td|�d��d�dd� ��t�����tj ur|S�tj ur tjS|tjur tjS|D]%}t|d d ��st!d |z����&|����tj urt d ��d|�d����d}t |t��rJt%|��fd���} | drt| d�}t| d�}nt| d�St |����r(|j\} } } �fd�} t)| �| f��\}}||krtd���t+t-t�g��t| g������}| �krt�| ���| }n�| j�jzsDd�|���D��}t�| �|�����| }nI�j| jzs:��|���t��|��| ���| }t �t4��rQ��jdkr@t �jdt ��r �jd�|��St9j���|��}|�|nt=||��S)NzDuplicate symbols detectedz'base set should be a Set object, not %sc3�6K�|]}t|d��V��dS)rNr )�.0�lhss �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/sets/conditionset.py� <genexpr>z'ConditionSet.__new__.<locals>.<genexpr>es*����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 � z1.5zdeprecated-conditionset-set)�deprecated_since_version�active_deprecations_target� _diff_wrtFz`%s` is not symbol-likezsym `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���|ttd�������jS�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"rr)r rrr� isinstancer� TypeErrorrr rrr�true�false�EmptySet�getattr� ValueError�containsr�args�map�dict�zip� free_symbols�items�xreplacer� intersectr�__new__r)r4r-r,�base_set�flat�condition_orig�temp�i�know�siftedr3�c�br5�sa�sb�reps�rvs``` r rKzConditionSet.__new__Xs�������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��|jdSr0�rC��selfs r r.zConditionSet.<lambda>�s ��� �!� �r"c��|jdS)NrrZr[s r r.zConditionSet.<lambda>�s ��d�i��l�r"c��|jdS)N�rZr[s r r.zConditionSet.<lambda>�s ��T�Y�q�\�r"c�R�|jj|jjz }||jjzSr))r,rGr-rL)r\� cond_symss r rGzConditionSet.free_symbols�s&���N�/�$�(�2G�G� ��4�=�5�5�5r"c�,�t|jg��Sr))rr-r[s r � bound_symbolszConditionSet.bound_symbols�s�����z�"�"�"r"c�6���fd���|j|��s tjSt||j��}|tjur tjSt |jf|j��} ||��}t||��S#t$rYdSwxYw)Nc����d�||fD��}|�d��}|dkrdS|dkrdSt|��t|��ko(t�fd�t||��D����S)Nc�8�g|]}t|t����Sr7)r;r)rrPs r � <listcomp>z:ConditionSet._contains.<locals>.ok_sig.<locals>.<listcomp>�s"��;�;�;�q�j��E�*�*�;�;�;r"TrFrc3�6�K�|]\}}�||��V��dSr)r7)rrP�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�tuplesrSrjs �r rjz&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-rr>rrLrr,r r<)r\�other� base_cond�lamda� lambda_condrjs @r � _containszConditionSet._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�Bc���t|j|j��}t|jt��r||�}n ||��}t ||j�|����Sr))rr-r,r;rr rLrB)r\rp�fs r � as_relationalzConditionSet.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��}|�||��}||kr/|s|�||��}|�|||��S|rn)t |dd��r|�||��}n |�|||��S)Nr&F)rCr*r1�has�funcr@) r\�old�newr-�cond�base�dsym�insym�newbases r � _eval_subszConditionSet._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|jj��Sr))rr-�kindr[s r �_kindzConditionSet._kind�s���t�x�}�%�%�%r"N)�__name__� __module__� __qualname__�__doc__r� UniversalSetrK�propertyr-r,rLrGrcrtrwr�r�r7r"r rrs�������C�C�H/0�n�W7�W7�W7�W7�r �(�,�,� -� -�C���2�2�3�3�I��x�1�1�2�2�H� �6�6��X�6��#�#��X�#�/�/�/�:5�5�5�*�*�*�$&�&�&�&�&r"rN)#�sympy.core.singletonr�sympy.core.basicr�sympy.core.containersr�sympy.core.functionrr�sympy.core.logicr�sympy.core.relationalr �sympy.core.symbolr �sympy.core.sympifyr �sympy.logic.boolalgr r�sympy.utilities.iterablesrrr�sympy.utilities.exceptionsrrBr�setsrrrrr1rr7r"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"
Memory