�
��gp � �� � d dl mZ d dlmZ d dlmZ d dlmZmZ d dl m
Z
d dlmZ d dl
mZ d dlmZ d d lmZmZ d d
lmZmZmZ d dlmZ dd
lmZ ddlmZmZmZm Z ed� � Z! G d� 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 � � e Zd ZdZej fd�Z ed� � � Z ed� � � Z ed� � � Z
ed� � � Zed� � � Zd� Z
d � Zd
� Zd� ZdS )
�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 |� � rt d� � �t |� � }t |t
� � st
d|z � � �t �� � �t �t � � r0�}d� �D � � }t |� �t d|� d�� d�dd� � � t �� � ��t j u r|S �t j
u rt j S |t j u rt j S |D ]%}t |d
d� � st! d|z � � ��&|� �� � t j
u rt
d
��d|�d�� � �d }t |t � � rJt% |��fd�� � } | d rt | d � }t | d � }nt | d � S t |� � � �r(|j \ }
}}� fd�}
t) |
�|
f� � \ }}||k rt d� � �t+ t- t �g� � t |
g� � � � � � }|
�k rt �|� � �|}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 � ��|� � }|�|nt= ||� � S )NzDuplicate symbols detectedz'base set should be a Set object, not %sc 3 �6 K � | ]}t |d � � V � �dS )r Nr )�.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>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
�
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"