�
��g9 � �8 � d Z ddlmZ ddlZddlmZ ddlmZ ddlm Z m
Z
mZ ddlm
Z
mZ ddlmZ dd lmZ dd
lmZ G d� de� � Z e� � Z G d
� de � � Z G d� de� � Z G d� de e�� � Z G d� de� � Zed� � � ZdS )z<A module which implements predicates and assumption context.� )�contextmanagerN)�Str)�_sympify)�Boolean�false�true)�
Dispatcher�
str_signature)�sympy_deprecation_warning)�is_sequence)� get_classc �( � � e Zd ZdZ� fd�Zd� Z� xZS )�AssumptionsContexta�
Set containing default assumptions which are applied to the ``ask()``
function.
Explanation
===========
This is used to represent global assumptions, but you can also use this
class to create your own local assumptions contexts. It is basically a thin
wrapper to Python's set, so see its documentation for advanced usage.
Examples
========
The default assumption context is ``global_assumptions``, which is initially empty:
>>> from sympy import ask, Q
>>> from sympy.assumptions import global_assumptions
>>> global_assumptions
AssumptionsContext()
You can add default assumptions:
>>> from sympy.abc import x
>>> global_assumptions.add(Q.real(x))
>>> global_assumptions
AssumptionsContext({Q.real(x)})
>>> ask(Q.real(x))
True
And remove them:
>>> global_assumptions.remove(Q.real(x))
>>> print(ask(Q.real(x)))
None
The ``clear()`` method removes every assumption:
>>> global_assumptions.add(Q.positive(x))
>>> global_assumptions
AssumptionsContext({Q.positive(x)})
>>> global_assumptions.clear()
>>> global_assumptions
AssumptionsContext()
See Also
========
assuming
c �T �� |D ]#}t � � � |� � �$dS )zAdd assumptions.N)�super�add)�self�assumptions�a� __class__s ��h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/assumptions/assume.pyr zAssumptionsContext.addC s1 �� �� � �A��G�G�K�K��N�N�N�N� � � c � � | sd| j j z S d� | j j |� | � � � � S )Nz%s()z{}({}))r �__name__�format�
_print_set)r �printers r � _sympystrzAssumptionsContext._sympystrH sA � �� 4��D�N�3�3�3����t�~�6��8J�8J�4�8P�8P�Q�Q�Qr )r �
__module__�__qualname__�__doc__r r �
__classcell__�r s @r r r sY �� � � � � �2� 2�h� � � � �
R� R� R� R� R� R� Rr r c � � � e Zd ZdZdZ� fd�Zed� � � Zed� � � Zed� � � Z d� Z
ed� � � Z� xZS ) �AppliedPredicatea�
The class of expressions resulting from applying ``Predicate`` to
the arguments. ``AppliedPredicate`` merely wraps its argument and
remain unevaluated. To evaluate it, use the ``ask()`` function.
Examples
========
>>> from sympy import Q, ask
>>> Q.integer(1)
Q.integer(1)
The ``function`` attribute returns the predicate, and the ``arguments``
attribute returns the tuple of arguments.
>>> type(Q.integer(1))
<class 'sympy.assumptions.assume.AppliedPredicate'>
>>> Q.integer(1).function
Q.integer
>>> Q.integer(1).arguments
(1,)
Applied predicates can be evaluated to a boolean value with ``ask``:
>>> ask(Q.integer(1))
True
� c � �� t |t � � st d|z � � �t t |� � } t � � j | |g|�R � S )Nz%s is not a Predicate.)�
isinstance� Predicate� TypeError�mapr r �__new__)�cls� predicate�argsr s �r r, zAppliedPredicate.__new__o sY �� ��)�Y�/�/� B��4�y�@�A�A�A��8�T�"�"���u�w�w��s�I�5��5�5�5�5r c �d � | j }t |� � dk r|d S t d� � �)z�
Return the expression used by this assumption.
Examples
========
>>> from sympy import Q, Symbol
>>> x = Symbol('x')
>>> a = Q.integer(x + 1)
>>> a.arg
x + 1
� � z4'arg' property is allowed only for unary predicates.)�_args�lenr* �r r/ s r �argzAppliedPredicate.argu s2 � � �z���t�9�9��>�>���7�N��N�O�O�Or c � � | j d S )z'
Return the predicate.
r �r3 �r s r �functionzAppliedPredicate.function� s � � �z�!�}�r c � � | j dd� S )zJ
Return the arguments which are applied to the predicate.
r2 Nr8 r9 s r � argumentszAppliedPredicate.arguments� s � � �z�!�"�"�~�r c �B � | j � | j |� � S �N)r: �evalr<