+
    i|                         R t ^ RIHtHtHtHt ^ RIHtHt ^ RI	H
t
HtHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHt ].t]]].t].tR tR tR	 tR
 tR tRR ltR t R t!RR lt"R# )zSymPy interface to Unification engine

See sympy.unify for module level docstring
See sympy.unify.core for algorithmic docstring )BasicAddMulPow)AssocOp	LatticeOp)MatAddMatMul
MatrixExpr)UnionIntersection	FiniteSet)CompoundVariableCondVariable)corec                    a  \         \        \        \        \        \
        3p\        ;QJ d    V 3R  lV 4       F  '       g   K   R# 	  R# ! V 3R  lV 4       4      # )c              3   <   <"   T F  p\        SV4      x  K  	  R # 5iN
issubclass).0aopops   & r/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/unify/usympy.py	<genexpr>$sympy_associative.<locals>.<genexpr>   s     8isz"c""i   TF)r   r   r	   r   r   r   any)r   	assoc_opss   f r   sympy_associativer       s>    &&%yII38i83383838i888    c                    a  \         \        \        \        \        3p\
        ;QJ d    V 3R  lV 4       F  '       g   K   R# 	  R# ! V 3R  lV 4       4      # )c              3   <   <"   T F  p\        SV4      x  K  	  R # 5ir   r   )r   copr   s   & r   r   $sympy_commutative.<locals>.<genexpr>   s     7hsz"c""hr   TF)r   r   r   r   r   r   )r   comm_opss   f r   sympy_commutativer'      s<    VUL)<H37h73373737h777r!   c                 \    \        V \        4      ;'       d    \        V P                  4      # r   )
isinstancer   r    r   xs   &r   is_associativer,      s!    a">>'8'>>r!   c                 @   \        V \        4      '       g   R # \        V P                  4      '       d   R# \	        V P                  \
        4      '       dI   \        ;QJ d&    R V P                   4       F  '       d   K   R # 	  R# ! R V P                   4       4      # R# )FTc              3   L   "   T F  p\        V4      P                  x  K  	  R # 5ir   )	constructis_commutative)r   args   & r   r   !is_commutative.<locals>.<genexpr>"   s     CFS9S>00Fs   "$N)r)   r   r'   r   r   r   allargsr*   s   &r   r0   r0      sk    a""!$$sCAFFCssCsCsCAFFCCC r!   c                    a  V 3R  lpV# )c                    < \        V S4      ;'       g/    \        V \        4      ;'       d    \        V P                  S4      # r   )r)   r   r   r   )r+   typs   &r   	matchtypemk_matchtype.<locals>.matchtype%   s<    1c" B B1h'AAJqttS,A	Cr!    )r7   r8   s   f r   mk_matchtyper;   $   s    C r!   c                t  a V S9   d   \        V 4      # \        V \         \        34      '       d   V # \        V \        4      '       d   V P                  '       d   V # \        V P                  \        ;QJ d%    . V3R lV P                   4       F  NK  	  54      # ! V3R lV P                   4       4      4      # )z$Turn a SymPy object into a Compound c              3   <   <"   T F  p\        VS4      x  K  	  R # 5ir   deconstruct)r   r1   	variabless   & r   r   deconstruct.<locals>.<genexpr>3   s     H#+c955r   )	r   r)   r   r   is_Atomr   	__class__tupler4   )sr@   s   &fr   r?   r?   *   s    I~{!h-..a1999AKKEHHEJ JHHHJ Jr!   c                  a  \        S \        \        34      '       d   S P                  # \        S \        4      '       g   S # \
        ;QJ d#    V 3R l\         4       F  '       g   K   RM	  RM! V 3R l\         4       4      '       d+   S P                  ! \        \        S P                  4      RR/ # \
        ;QJ d#    V 3R l\         4       F  '       g   K   RM	  RM! V 3R l\         4       4      '       d;   \        P                  ! S P                  .\        \        S P                  4      O5!  # S P                  ! \        \        S P                  4      !  # )z$Turn a Compound into a SymPy object c              3   P   <"   T F  p\        SP                  V4      x  K  	  R # 5ir   r   r   r   clsts   & r   r   construct.<locals>.<genexpr>;   s!     
=,<S:addC  ,<   #&TFevaluatec              3   P   <"   T F  p\        SP                  V4      x  K  	  R # 5ir   rH   rI   s   & r   r   rL   =   s     >osZc""orM   )r)   r   r   r1   r   r   eval_false_legalr   mapr/   r4   basic_new_legalr   __new__)rK   s   fr   r/   r/   5   s    !h-..uua""
s
=,<
=sss
=,<
===ttSAFF+<e<<	>o>>o>	>	>}}QTT;C	166$:;;ttSAFF+,,r!   c                *    \        \        V 4      4      # )zRRebuild a SymPy expression.

This removes harm caused by Expr-Rules interactions.
)r/   r?   )rE   s   &r   rebuildrU   B   s    
 [^$$r!   Nc           	   +    a"   V3R lpT;'       g    / pVP                  4        UUu/ uF  w  rgV! V4      V! V4      bK  	  ppp\        P                  ! V! V 4      V! V4      V3R\        R\        /VB pV F<  p	V	P                  4        UUu/ uF  w  rg\        V4      \        V4      bK  	  uppx  K>  	  R# u uppi u uppi 5i)a  Structural unification of two expressions/patterns.

Examples
========

>>> from sympy.unify.usympy import unify
>>> from sympy import Basic, S
>>> from sympy.abc import x, y, z, p, q

>>> next(unify(Basic(S(1), S(2)), Basic(S(1), x), variables=[x]))
{x: 2}

>>> expr = 2*x + y + z
>>> pattern = 2*p + q
>>> next(unify(expr, pattern, {}, variables=(p, q)))
{p: x, q: y + z}

Unification supports commutative and associative matching

>>> expr = x + y + z
>>> pattern = p + q
>>> len(list(unify(expr, pattern, {}, variables=(p, q))))
12

Symbols not indicated to be variables are treated as literal,
else they are wild-like and match anything in a sub-expression.

>>> expr = x*y*z + 3
>>> pattern = x*y + 3
>>> next(unify(expr, pattern, {}, variables=[x, y]))
{x: y, y: x*z}

The x and y of the pattern above were in a Mul and matched factors
in the Mul of expr. Here, a single symbol matches an entire term:

>>> expr = x*y + 3
>>> pattern = p + 3
>>> next(unify(expr, pattern, {}, variables=[p]))
{p: x*y}

c                    < \        V S4      # r   r>   )r+   r@   s   &r   <lambda>unify.<locals>.<lambda>s   s    {1i0r!   r,   r0   N)itemsr   unifyr,   r0   r/   )
r+   yrE   r@   kwargsdeconskvdsds
   &&&f,     r   r[   r[   I   s     T 1F	RA*+'')4)$!F1I	)A4	F1Ivay! 
/4B
/4B
/ (.
/B 67ggi@iday|Yq\)i@@  	5 As   &CB;AC C/C)r:   )Nr:   )#__doc__
sympy.corer   r   r   r   sympy.core.operationsr   r   sympy.matricesr   r	   r
   sympy.sets.setsr   r   r   sympy.unify.corer   r   r   sympy.unifyr   rR   rP   illegalr    r'   r,   r0   r;   r?   r/   rU   r[   r:   r!   r   <module>rk      su   3
 , + 4 5 5 : : = = ,S), +98?D	J-%3Ar!   