o
    GZh
                     @   sb   d Z dd Zdd Zdd Zddd	Zd
d Zdd Zdd Zdd Zdd Z	dd Z
dd ZdS )z& Generic SymPy-Independent Strategies c                 c   s    | V  d S N )xr   r   K/var/www/auris/lib/python3.10/site-packages/sympy/strategies/branch/core.pyidentity   s   
r   c                    s    fddS )z: Apply a branching rule repeatedly until it has no effect c                 3   sN    | h} | D ]}||vr| | |E d H  q|| hkr%| V  d S d S r   )add)exprseennexprbruleexhaust_brlr   r   r   
   s   


zexhaust.<locals>.exhaust_brlr   r   r   r
   r   exhaust   s   r   c                        fdd}|S )Nc                 3   s.     | D ]}|| kr | | |V  qd S r   r   )r   resultr   fnr   r   onaction_brl   s   zonaction.<locals>.onaction_brlr   )r   r   r   r   r   r   onaction   s   r   Nc                    s*    s
ddl m} |  fdd}t| |S )zA Print the input and output expressions at each rule application     )stdoutc                    s&     d| j    d||f  d S )Nz	Rule: %s
zIn: %s
Out: %s

)write__name__)brlr   r   filer   r   r   $   s   zdebug.<locals>.write)sysr   r   )r   r   r   r   r   r   r   debug   s
   
r   c                         fdd}|S )z) Multiplex many branching rules into one c                 3   s<    t  } D ]}|| D ]}||vr|| |V  qqd S r   )setr   )r   r   r   r	   brulesr   r   multiplex_brl-   s   
z multiplex.<locals>.multiplex_brlr   )r!   r"   r   r    r   	multiplex+   s   r#   c                    r   )z0 Only apply branching rule if condition is true c                 3   s"    | r | E d H  d S 	 d S r   r   r   r   condr   r   conditioned_brl9   s   z"condition.<locals>.conditioned_brlr   )r&   r   r'   r   r%   r   	condition7   s   r(   c                    r   )z6 Yield only those results which satisfy the predicate c                 3   s    t  | E d H  d S r   )filterr$   r   predr   r   filtered_brlC   s   zsfilter.<locals>.filtered_brlr   )r+   r   r,   r   r*   r   sfilterA   s   r-   c                    r   )Nc                 3   s0    d} | D ]}d}|V  q|s| V  d S d S NFTr   )r   yieldedr	   r   r   r   notempty_brlI   s   
znotempty.<locals>.notempty_brlr   )r   r0   r   r   r   notemptyH   s   r1   c                     r   )z$ Execute one of the branching rules c                 3   s6    d} D ]}|| D ]}d}|V  q|r d S qd S r.   r   )r   r/   r   r	   r    r   r   
do_one_brlU   s   zdo_one.<locals>.do_one_brlr   )r!   r2   r   r    r   do_oneS   s   r3   c                     r   )zR
    Compose a sequence of brules so that they apply to the expr sequentially
    c                 3   sJ     s| V  d S  d  dd  }}|| D ]}t | |E d H  qd S )Nr      )chain)r   headtailr	   r    r   r   	chain_brld   s   zchain.<locals>.chain_brlr   )r!   r8   r   r    r   r5   `   s   	r5   c                    r   )z# Turn a rule into a branching rule c                 3   s     | V  d S r   r   r$   rlr   r   r   r   s   zyieldify.<locals>.brlr   )r:   r   r   r9   r   yieldifyp   s   r;   r   )__doc__r   r   r   r   r#   r(   r-   r1   r3   r5   r;   r   r   r   r   <module>   s    
	
