B
    ™‘[!  ã               @   sX   d dl mZmZ ddlmZ ddlmZmZmZ ddl	m
Z
 dd„ Zdd	„ Zd
d„ ZdS )é    )Úprint_functionÚdivisioné   )Úrl)Údo_oneÚexhaustÚswitch)Útop_downc             K   s4   | r(t tttjft|  ¡ Ž žŽ Ž f|ŽS dd„ S dS )aR   Full simultaneous exact substitution

    Examples
    ========

    >>> from sympy.strategies.tools import subs
    >>> from sympy import Basic
    >>> mapping = {1: 4, 4: 1, Basic(5): Basic(6, 7)}
    >>> expr = Basic(1, Basic(2, 3), Basic(4, Basic(5)))
    >>> subs(mapping)(expr)
    Basic(4, Basic(2, 3), Basic(1, Basic(6, 7)))
    c             S   s   | S )N© )Úxr
   r
   ú5lib/python3.7/site-packages/sympy/strategies/tools.pyÚ<lambda>   s    zsubs.<locals>.<lambda>N)r	   r   Úmapr   ÚsubsÚzipÚitems)ÚdÚkwargsr
   r
   r   r      s    $r   c              O   s   t tt t| Ž ƒf|ŽƒS )z¨ Strategy for canonicalization

    Apply each rule in a bottom_up fashion through the tree.
    Do each one in turn.
    Keep doing this until there is no change.
    )r   r	   r   )Zrulesr   r
   r
   r   Úcanon   s    r   c             C   s
   t t| ƒS )aQ   Apply rules based on the expression type

    inputs:
        ruletypes -- a dict mapping {Type: rule}

    >>> from sympy.strategies import rm_id, typed
    >>> from sympy import Add, Mul
    >>> rm_zeros = rm_id(lambda x: x==0)
    >>> rm_ones  = rm_id(lambda x: x==1)
    >>> remove_idents = typed({Add: rm_zeros, Mul: rm_ones})
    )r   Útype)Z	ruletypesr
   r
   r   Útyped"   s    r   N)Z
__future__r   r   Ú r   Zcorer   r   r   Ztraverser	   r   r   r   r
   r
   r
   r   Ú<module>   s   	