o
    ¦ƒðjÚ  ã                   @   s´  d Z ddlmZmZmZ ddlmZmZ ddlm	Z	m
Z
mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZ ddlmZ dd	lmZmZ G d
d„ dƒZG dd„ deƒZe e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e!¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ e e¡dd„ ƒZ dd„ Z"dd„ Z#d d!„ Z$d"S )#zj
This module defines base class for handlers and some core handlers:
``Q.commutative`` and ``Q.is_true``.
é    )ÚQÚaskÚAppliedPredicate)ÚBasicÚSymbol)Ú_fuzzy_groupÚ	fuzzy_andÚfuzzy_or)ÚNaNÚNumber)ÚAndÚBooleanTrueÚBooleanFalseÚ	conjunctsÚ
EquivalentÚImpliesÚNotÚOr)Úsympy_deprecation_warningé   )ÚCommutativePredicateÚIsTruePredicatec                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
AskHandlerz.Base class that all Ask Handlers must inherit.c                    s(   t dddd� tƒ j| g|¢R i |¤ŽS )Nz¡
            The AskHandler system is deprecated. The AskHandler class should
            be replaced with the multipledispatch handler of Predicate
            z1.8zdeprecated-askhandler)Údeprecated_since_versionÚactive_deprecations_target)r   ÚsuperÚ__new__)ÚclsÚargsÚkwargs©Ú	__class__© ú£/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/assumptions/handlers/common.pyr      s   úzAskHandler.__new__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__r"   r"   r    r#   r      s    r   c                   @   s8   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZeZdS )	ÚCommonHandlerz5Defines some useful methods common to most Handlers. c                 C   ó   dS ©NTr"   ©ÚexprÚassumptionsr"   r"   r#   Ú
AlwaysTrue#   ó   zCommonHandler.AlwaysTruec                 C   r*   ©NFr"   r,   r"   r"   r#   ÚAlwaysFalse'   r0   zCommonHandler.AlwaysFalsec                 C   s   d S ©Nr"   r,   r"   r"   r#   Ú
AlwaysNone+   r0   zCommonHandler.AlwaysNoneN)	r$   r%   r&   r'   Ústaticmethodr/   r2   r4   r
   r"   r"   r"   r#   r)      s    


r)   c                 C   sR   t |ƒ}| jdur| jot | ¡ |vS t | ¡|v rdS t | ¡ |v r'dS dS )z>Objects are expected to be commutative unless otherwise statedNTF)r   Úis_commutativer   Úcommutative)r-   r.   Úassumpsr"   r"   r#   Ú_4   s   
r9   c                 C   s&   | j D ]}tt |¡|ƒs dS qdS )NFT)r   r   r   r7   )r-   r.   Úargr"   r"   r#   r9   @   s
   
ÿc                 C   r*   r+   r"   r,   r"   r"   r#   r9   G   r0   c                 C   r*   r+   r"   r,   r"   r"   r#   r9   K   r0   c                 C   s   | S r3   r"   r,   r"   r"   r#   r9   R   r0   c                 C   r*   r+   r"   r,   r"   r"   r#   r9   V   r0   c                 C   r*   r1   r"   r,   r"   r"   r#   r9   Z   r0   c                 C   s
   t | |ƒS r3   ©r   r,   r"   r"   r#   r9   ^   s   
c                 C   s2   | j d }|jr
d S t||d�}|dv r| S d S )Nr   ©r.   )TF)r   Ú	is_Symbolr   )r-   r.   r:   Úvaluer"   r"   r#   r9   b   s   
c                 C   ó:   d}| j D ]}t||d�}|du r dS |d u rd }q|S )NFr<   T©r   r   ©r-   r.   Úresultr:   Úpr"   r"   r#   r9   n   ó   
€c                 C   r?   )NTr<   Fr@   rA   r"   r"   r#   r9   y   rD   c                 C   s   | j \}}t| |B |d�S ©Nr<   r@   )r-   r.   rC   Úqr"   r"   r#   r9   „   s   
c                 C   sB   | j \}}t||d�}|d u rd S t||d�}|d u rd S ||kS rE   r@   )r-   r.   rC   rF   ÚptÚqtr"   r"   r#   r9   ‰   s   
c                    s   t ‡ ‡fdd„| jD ƒdd�S )zS
    Test for membership in a group with respect
    to the current operation.
    c                 3   s   � | ]
}t ˆ|ƒˆ ƒV  qd S r3   r;   )Ú.0Úa©r.   Úkeyr"   r#   Ú	<genexpr>œ   s   € z$test_closed_group.<locals>.<genexpr>T)Ú
quick_exit)r   r   )r-   r.   rL   r"   rK   r#   Útest_closed_group–   s   ÿrO   c                    ó   t ‡ fdd„|D ƒƒS )Nc                 3   ó   � | ]}t |ˆ ƒV  qd S r3   r;   ©rI   Úqueryr<   r"   r#   rM       ó   € zask_all.<locals>.<genexpr>)r   ©r.   Úqueriesr"   r<   r#   Úask_allž   ó   ÿrW   c                    rP   )Nc                 3   rQ   r3   r;   rR   r<   r"   r#   rM   ¤   rT   zask_any.<locals>.<genexpr>)r	   rU   r"   r<   r#   Úask_any¢   rX   rY   N)%r'   Úsympy.assumptionsr   r   r   Ú
sympy.corer   r   Úsympy.core.logicr   r   r	   Úsympy.core.numbersr
   r   Úsympy.logic.boolalgr   r   r   r   r   r   r   r   Úsympy.utilities.exceptionsr   Úpredicates.commonr   r   r   r)   Úregisterr9   ÚboolrO   rW   rY   r"   r"   r"   r#   Ú<module>   sN    (














