
    sg
                     L    d Z d Zd Zd ZddZd Zd Zd Zd	 Zd
 Z	d Z
d Zy)z& Generic SymPy-Independent Strategies c              #      K   |  y wN )xs    O/var/www/html/venv/lib/python3.12/site-packages/sympy/strategies/branch/core.pyidentityr      s     
Gs   c                       fdS )z: Apply a branching rule repeatedly until it has no effect c              3      K   | h} |       D ](  }||vs|j                  |        |      E d {    * || hk(  r|  y y 7 wr   )add)exprseennexprbruleexhaust_brls      r   r   zexhaust.<locals>.exhaust_brl
   s\     v4[ 	.ED &u---	. D6>J  .s   AAAAr   )r   r   s   `@r   exhaustr      s         c                       fd}|S )Nc              3   N   K    |       D ]  }|| k7  r
 | |       |  y wr   r   )r   resultr   fns     r   onaction_brlzonaction.<locals>.onaction_brl   s2     Dk 	F~5$'L	s   "%r   )r   r   r   s   `` r   onactionr      s    
 r   Nc                 :    sddl m} |fd}t        | |      S )zA Print the input and output expressions at each rule application     )stdoutc                 r    j                  d| j                  z         j                  d|d|d       y )Nz	Rule: %s
zIn: z
Out: z

)write__name__)brlr   r   files      r   r   zdebug.<locals>.write$   s)    

<#,,./

D&9:r   )sysr   r   )r   r   r   r   s    `  r   debugr!      s"    ; E5!!r   c                        fd}|S )z) Multiplex many branching rules into one c              3   ~   K   t               }D ])  } ||       D ]  }||vs|j                  |       |  + y wr   )setr
   )r   r   r   r   bruless       r   multiplex_brlz multiplex.<locals>.multiplex_brl-   sH     u 	 CT  $HHUOK 	 s   ==r   )r%   r&   s   ` r   	multiplexr'   +   s      r   c                       fd}|S )z0 Only apply branching rule if condition is true c              3   D   K    |       r |       E d {    y y 7 wr   r   )r   r   conds    r   conditioned_brlz"condition.<locals>.conditioned_brl9   s#     :T{"" #s     r   )r*   r   r+   s   `` r   	conditionr,   7   s    
 r   c                       fd}|S )z6 Yield only those results which satisfy the predicate c              3   F   K   t         |             E d {    y 7 wr   )filter)r   r   preds    r   filtered_brlzsfilter.<locals>.filtered_brlC   s     $d,,,s   !!r   )r0   r   r1   s   `` r   sfilterr2   A   s    -r   c                       fd}|S )Nc              3   F   K   d} |       D ]  }d}| 
 |s|  y y wNFTr   )r   yieldedr   r   s      r   notempty_brlznotempty.<locals>.notempty_brlI   s8     4[ 	EGK	 J s   !r   )r   r7   s   ` r   notemptyr8   H   s     r   c                        fd}|S )z$ Execute one of the branching rules c              3   N   K   d}D ]  } ||       D ]  }d}| 
 |s y  y wr5   r   )r   r6   r   r   r%   s       r   
do_one_brlzdo_one.<locals>.do_one_brlU   s@      	CT  	s   %%r   )r%   r;   s   ` r   do_oner<   S   s     r   c                        fd}|S )zR
    Compose a sequence of brules so that they apply to the expr sequentially
    c              3   z   K   s|  y d   dd  }} ||       D ]  } t        | |      E d {     y 7 w)Nr      )chain)r   headtailr   r%   s       r   	chain_brlzchain.<locals>.chain_brld   sO     JAYqr
d$Z 	+E#ud|E***	+*s   .;9;r   )r%   rC   s   ` r   r@   r@   `   s    + r   c                       fd}|S )z# Turn a rule into a branching rule c              3   "   K    |        y wr   r   )r   rls    r   r   zyieldify.<locals>.brlr   s     hs   r   )rF   r   s   ` r   yieldifyrG   p   s    Jr   r   )__doc__r   r   r   r!   r'   r,   r2   r8   r<   r@   rG   r   r   r   <module>rI      s?    ,

"	
 r   