+
    
þÎj|  ã                   óÎ   € 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# )z�SymPy 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   & €ÚH/opt/data/home/.local/lib/python3.14/site-packages/sympy/unify/usympy.pyÚ	<genexpr>Ú$sympy_associative.<locals>.<genexpr>   s   øé € Ð8©i sŒz˜"˜c×"Ð"«iùó   ƒTF)r   r   r	   r   r   r   Úany)r   Ú	assoc_opss   f r   Úsympy_associativer       s>   ø€ Üœ&¤&¬%´¼yÐI€Iß‹3Ô8©iÓ8�3Œ3Ð8Š3Ð8ˆ3Ô8©iÓ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   øé € Ð7©h sŒz˜"˜c×"Ð"«hùr   TF)r   r   r   r   r   r   )r   Úcomm_opss   f r   Úsympy_commutativer'      s<   ø€ Ü”VœU¤L´)Ð<€Hß‹3Ô7©hÓ7�3Œ3Ð7Š3Ð7ˆ3Ô7©hÓ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   é € ÐC¹F°S”9˜S“>×0Ö0»Fùs   ‚"$N)r)   r   r'   r   r   r   ÚallÚargsr*   s   &r   r0   r0      sk   € Ü�aœ×"Ò"ÙÜ˜Ÿ™×ÒÙÜ�!—$‘$œ×Òß‹sÑC¸A¿FºFÓC�sŒsÐCŠsÐCˆsÑC¸A¿FºFÓ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<   ø€ Ü˜1˜cÓ"÷ Bð BÜ˜1œhÓ'×AÐA¬J°q·t±t¸SÓ,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Á¸#œ+ c¨9×5Ð5Ãùr   )	r   r)   r   r   Úis_Atomr   Ú	__class__Útupler4   )Úsr@   s   &fr   r?   r?   *   s‹   ø€ àˆI„~Ü˜‹{ÐÜ�!”h¤Ð-×.Ò.ØˆÜ�aœ×Ò 1§9§9 9ØˆÜ�A—K‘Kß”EÔHÀÇÂÓH—Eó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Œ:�a—d‘d˜C× Ð Ó,<ùó   ƒ#&TFÚevaluatec              3   óP   <"  € T F  p\        SP                  V4      x € K  	  R # 5ir   rH   rI   s   & €r   r   rL   =   s   øé € Ð>©o sŒZ˜Ÿ™˜c×"Ð"«oùrM   )r)   r   r   r1   r   r   Úeval_false_legalr   Úmapr/   r4   Úbasic_new_legalr   Ú__new__)rK   s   fr   r/   r/   5   sÐ   ø€ ä�!”h¤Ð-×.Ò.Ø�u‰uˆÜ�aœ×"Ò"Øˆß
ƒsÔ
=Õ,<Ó
=‡s‡s‚sÔ
=Õ,<Ó
=×=Ò=Ø�tŠt”Sœ A§F¡FÓ+Ð<°eÑ<Ð<ß	‹Ô>­oÓ>��ŠÔ>­oÓ>×	>Ò	>Ü�}Š}˜QŸT™TÐ;¤C¬	°1·6±6Ó$:Ó;Ð;à�tŠt”Sœ A§F¡FÓ+Ñ,Ð,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   ø€ ”{ 1 iÔ0r!   r,   r0   N)Úitemsr   Úunifyr,   r0   r/   )
r+   ÚyrE   r@   ÚkwargsÚdeconsÚkÚvÚdsÚds
   &&&f,     r   r[   r[   I   s¹   øé € ôT 1€FØ	�ˆˆR€AØ*+¯'©'¬)Ô4©)¡$ !‰�‹‘F˜1“IÒ	©)€AÑ4ä	�Š‘F˜1“I™v a›y¨!ñ 
/Ü4Bð
/ä4Bð
/ð (.ñ
/€Bó ˆØ67·g±g´iÔ@±i©d¨aŒy˜‹|œY q›\Ò)±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!   