o
    8Vac                     @   s  d Z ddlmZmZmZ ddlmZmZ ddl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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)NaNNumber)AndBooleanTrueBooleanFalse	conjuncts
EquivalentImpliesNotOr)SymPyDeprecationWarning   )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d  t j| g|R i |S )NzAskHandler() classzmultipledispatch handleriQ  z1.8)ZfeatureZ
useinsteadZissueZdeprecated_since_version)r   warnsuper__new__)clsargskwargs	__class__ C/usr/lib/python3/dist-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%   r-   zCommonHandler.AlwaysFalsec                 C   s   d S Nr   r)   r   r   r    
AlwaysNone)   r-   zCommonHandler.AlwaysNoneN)	r!   r"   r#   r$   staticmethodr,   r/   r1   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   Zis_commutativer   commutative)r*   r+   Zassumpsr   r   r    _2   s   
r4   c                 C   s&   | j D ]}tt||s dS qdS )NFT)r   r   r   r3   )r*   r+   argr   r   r    r4   >   s
   
c                 C   r'   r(   r   r)   r   r   r    r4   E   r-   c                 C   r'   r(   r   r)   r   r   r    r4   I   r-   c                 C   s   | S r0   r   r)   r   r   r    r4   P   r-   c                 C   r'   r(   r   r)   r   r   r    r4   T   r-   c                 C   r'   r.   r   r)   r   r   r    r4   X   r-   c                 C   s
   t | |S r0   r   r)   r   r   r    r4   \   s   
c                 C   s2   | j d }|jr
d S t||d}|dv r| S d S )Nr   r+   )TF)r   Z	is_Symbolr   )r*   r+   r5   valuer   r   r    r4   `   s   
c                 C   :   d}| j D ]}t||d}|du r dS |d u rd }q|S )NFr7   Tr   r   r*   r+   resultr5   pr   r   r    r4   l      
c                 C   r9   )NTr7   Fr:   r;   r   r   r    r4   w   r>   c                 C   s   | j \}}t| |B |dS Nr7   r:   )r*   r+   r=   qr   r   r    r4      s   
c                 C   sB   | j \}}t||d}|d u rd S t||d}|d u rd S ||kS r?   r:   )r*   r+   r=   r@   ptZqtr   r   r    r4      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 r0   r6   ).0ar+   keyr   r    	<genexpr>   s    z$test_closed_group.<locals>.<genexpr>T)Z
quick_exit)r   r   )r*   r+   rE   r   rD   r    test_closed_group   s   rG   N)!r$   Zsympy.assumptionsr   r   r   Z
sympy.corer   r   Zsympy.core.logicr   Zsympy.core.numbersr   r	   Zsympy.logic.boolalgr
   r   r   r   r   r   r   r   Zsympy.utilities.exceptionsr   Zpredicates.commonr   r   r   r&   registerr4   boolrG   r   r   r   r    <module>   sJ    (














