+
    
þÎj%  ã                   óä   € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHtHt ^ RIHtHtHtHt ^ RI H!t! R.t"R t#R t$R t%R t&R# )z}Logic for applying operators to states.

Todo:
* Sometimes the final result needs to be expanded, we should do this by hand.
)ÚSum)ÚAdd)Ú
NumberKind)ÚMul)ÚPow)ÚS)ÚsympifyÚ_sympify)ÚAntiCommutator)Ú
Commutator)ÚDagger)ÚInnerProduct)ÚOuterProductÚOperator)ÚStateÚKetBaseÚBraBaseÚWavefunction)ÚTensorProductÚqapplyc                ó0   € V P                  \        R 4      # )zETransform the inner products in an expression by calling ``.doit()``.c                  ó0   € \        V !  P                  4       # ©N)r   Údoit©Úargss   *ÚR/opt/data/home/.local/lib/python3.14/site-packages/sympy/physics/quantum/qapply.pyÚ<lambda>Úip_doit_func.<locals>.<lambda>#   s   € ´¸tÑ1D×1IÑ1IÔ1Kó    )Úreplacer   ©Úes   &r   Úip_doit_funcr#   !   s   € à�9‰9”\Ñ#KÓLÐLr   c                ó0   € V P                  \        R 4      # )z;Transform the sums in an expression by calling ``.doit()``.c                  ó0   € \        V !  P                  4       # r   )r   r   r   s   *r   r   Úsum_doit_func.<locals>.<lambda>(   s   € ¬¨T©
¯©Ô(9r   )r    r   r!   s   &r   Úsum_doit_funcr'   &   s   € à�9‰9”SÑ9Ó:Ð:r   c           
     óâ  € ^ RI Hp VP                  RR4      pVP                  RR4      pVP                  RR4      p\        V 4      p V P                  \
        8X  d   V'       d   \        V 4      # T # V P                  RRR7      p \        V \        4      '       d   V # \        V \        4      '       d9   ^ pV P                   F  pV\        V3/ VB ,          pK  	  VP                  4       # \        W4      '       d3   V P                   UU	u. uF  w  pp	\        V3/ VB V	3NK  	  p
pp	V! V
!  # \        V \        4      '       d.   \        V P                   Uu. uF  p\        V3/ VB NK  	  up!  # \        V \        4      '       dE   \        \        V P                  3/ VB .V P                   O5!  pV'       d   \#        V4      pV# TpV# \        V \$        4      '       d(   \        V P&                  3/ VB V P(                  ,          # \        V \*        4      '       dÇ   V P-                  4       w  rÍ\+        V!  p\+        V!  pV'       g   TpM=\        V\*        4      '       d   V\/        V3/ VB ,          pMV\        V3/ VB ,          pW`8X  d'   V'       d   \1        \/        \1        V 4      3/ VB 4      pV'       d   \        V4      MTpV'       d   \#        V4      pV# TpV# V # u up	pi u upi )a]  Apply operators to states in a quantum expression.

Parameters
==========

e : Expr
    The expression containing operators and states. This expression tree
    will be walked to find operators acting on states symbolically.
options : dict
    A dict of key/value pairs that determine how the operator actions
    are carried out.

    The following options are valid:

    * ``dagger``: try to apply Dagger operators to the left
      (default: False).
    * ``ip_doit``: call ``.doit()`` in inner products when they are
      encountered (default: True).
    * ``sum_doit``: call ``.doit()`` on sums when they are encountered
      (default: False). This is helpful for collapsing sums over Kronecker
      delta's that are created when calling ``qapply``.

Returns
=======

e : Expr
    The original expression, but with the operators applied to states.

Examples
========

    >>> from sympy.physics.quantum import qapply, Ket, Bra
    >>> b = Bra('b')
    >>> k = Ket('k')
    >>> A = k * b
    >>> A
    |k><b|
    >>> qapply(A * b.dual / (b * b.dual))
    |k>
    >>> qapply(k.dual * A / (k.dual * k))
    <b|
)ÚDensityÚdaggerFÚsum_doitÚip_doitT)Ú
commutatorÚtensorproduct)Úsympy.physics.quantum.densityr)   Úgetr	   Úkindr   r#   ÚexpandÚ
isinstancer   r   r   r   r   r   ÚfunctionÚlimitsr'   r   ÚbaseÚexpr   Úargs_cncÚ
qapply_Mulr   )r"   Úoptionsr)   r*   r+   r,   ÚresultÚargÚstateÚprobÚnew_argsÚtÚc_partÚnc_partÚc_mulÚnc_muls   &,              r   r   r   +   s•  € õV 6à�[‰[˜ 5Ó)€FØ�{‰{˜: uÓ-€HØ�k‰k˜) TÓ*€Gä�‹€Að 	‡v�v”Ôß")Œ|˜A‹Ð0¨qÐ0ð 	
�‰˜D°ˆÓ5€Aô �!”W×ÒØˆô 
�A”s×	Ò	ØˆØ—6”6ˆCØ”f˜SÑ, GÑ,Õ,ŠFñ à�}‰}‹Ðô 
�A×	Ò	àŸfšfô&Ù$ñ:¸%Øô ˜EÑ- WÑ-¨tÓ4Ù$ð 	ñ &á˜Ñ!Ð!ô 
�A”}×	%Ò	%Ü¸Q¿VºVÓD¹V¸œv aÑ3¨7Ô3¹VÑDÑEÐEô 
�A”s×	Ò	Ü”V˜AŸJ™JÑ2¨'Ñ2Ð>°Q·X±XÓ>ˆß*2”˜vÓ&ˆØˆð 9?ˆØˆô 
�A”s×	Ò	Ü�a—f‘fÑ( Ñ(¨!¯%©%Õ/Ð/ô 
�A”s×	Ò	ØŸ*™*›,‰ˆÜ�V‘ˆÜ�g‘ˆßØ‰FÜ˜¤×$Ò$Øœ: fÑ8°Ñ8Õ8‰Fàœ6 &Ñ4¨GÑ4Õ4ˆFØŒ;Ÿ6ÜœJ¤v¨a£yÑ<°GÑ<Ó=ˆFß)0”˜fÔ%°fˆß*2”˜vÓ&ˆØˆð 9?ˆØˆð
 ˆùóM&ùò Es   ÄK&ÅK,c           
      óz  € \        V P                  4      p\        P                  pR p\	        V4      ^8:  g   \        V \        4      '       g   V # VP                  4       pVP                  4       p\        V\        4      '       g   \        V4      P                  '       g2   \        V\        4      '       g   \        V4      P                  '       d   V # \        V\        4      '       d\   VP                  P                  '       d@   VP                  VP                  VP                  ^,
          ,          4       VP                  p\        V\         4      '       d(   VP                  VP"                  4       VP$                  p\        V\         4      '       d   VP$                  pVP"                  p\        V\&        \(        34      '       d¾   VP+                  4       p\        V\,        4      '       di   \/        V P0                  ! W'P                  ^ ,          V.,           !  V P0                  ! W'P                  ^,          V.,           !  ,           3/ VB V,          # \/        V P0                  ! V!  V,          V,          3/ VB V,          # \        V\2        4      '       Ed‚   \4        ;QJ d&    R VP                   4       F  '       d   K   RM	  RM! R VP                   4       4      '       Ed3   \        V\2        4      '       Ed   \4        ;QJ d&    R VP                   4       F  '       d   K   RM	  RM! R VP                   4       4      '       dÎ   \	        VP                  4      \	        VP                  4      8X  d¡   \3        \7        \	        VP                  4      4       Uu. uF8  p\/        VP                  V,          VP                  V,          ,          3/ VB NK:  	  up!  P9                  RR7      p\;        V P0                  ! V!  3/ VB V,          V,          # \        V\<        4      '       Ed!   \        V\<        4      '       d¹   \?        VP@                  4      PC                  \?        VP@                  4      4      '       d   \E        R4      hVPF                  VPF                  ,           p	\=        \/        VPH                  VPH                  ,          3/ VB .V	O5!  p\;        V P0                  ! V!  V,          3/ VB # \=        \/        WePH                  ,          3/ VB .VPF                  O5!  p\;        V P0                  ! V!  V,          3/ VB # \        V\<        4      '       dT   \=        \/        VPH                  V,          3/ VB .VPF                  O5!  p\;        V P0                  ! V!  V,          3/ VB # \K        VRR 4      p
V
e    V
! V3/ VB pMR pVf   \K        VRR 4      pVe    V! V3/ VB pVf8   \        V\N        4      '       d"   \        V\P        4      '       d   \S        We4      p\        V\T        \V        \X        34      '       d   \[        V4      # VfB   \	        V4      ^ 8X  d   V # \;        V P0                  ! W&.,           !  3/ VB V,          V,          # \        V\R        4      '       d)   V\;        V P0                  ! V!  3/ VB ,          V,          # \/        V P0                  ! V!  V,          3/ VB V,          # u upi   \L         d    R p ELFi ; i  \L         d    R p EL;i ; i)	Nc              3   ó|   "  € T F2  p\        V\        \        \        \        34      ;'       g    V^8H  x € K4  	  R# 5i©é   N©r3   r   r   r   r   ©Ú.0r<   s   & r   Ú	<genexpr>Úqapply_Mul.<locals>.<genexpr>Ï   s7   é € Ð-{ÑrzÐkn¬j¸¼xÌÔPSÔUXÐ>YÓ.Z×.fÐ.fÐ^aÐefÑ^fÔ.fÓrzùó   ‚+<®<FTc              3   ó|   "  € T F2  p\        V\        \        \        \        34      ;'       g    V^8H  x € K4  	  R# 5irG   rI   rJ   s   & r   rL   rM   Ð   s:   é € ð  3AÑwÐps´:¸cÄHÌeÔUXÔZ]ÐC^Ó3_×3kÐ3kÐcfÐjkÑckÔ3kÓwùrN   )r.   z4Duplicated dummy indices in separate sums in qapply.Ú_apply_operatorÚ_apply_from_right_to).Úlistr   r   ÚOneÚlenr3   r   Úpopr   r   Úis_commutativer   r7   Ú
is_IntegerÚappendr6   r   ÚketÚbrar   r
   r   r   r   Úfuncr   ÚallÚranger2   r9   r   ÚsetÚ	variablesÚintersectionÚ
ValueErrorr5   r4   ÚgetattrÚNotImplementedErrorr   r   r   ÚintÚcomplexÚfloatr	   )r"   r:   r   Úextrar;   ÚrhsÚlhsÚcommÚnr5   Ú_applyÚ_apply_rights   &,          r   r9   r9   ¢   s‘  € ä�—‘‹<€DÜ�E‰E€EØ€Fô ˆ4ƒy�A„~œZ¨¬3×/Ò/ØˆØ
�(‰(‹*€CØ
�(‰(‹*€Cô �sœL×)Ò)¬g°c«l×.I×.IÐ.IÜ˜C¤×.Ò.´7¸3³<×3N×3NÐ3NØˆô �#”s×Ò §¡× 2× 2Ð 2Ø�‰�C—H‘H˜sŸw™w¨�{Õ+Ô,Ø�h‰hˆô �#”|×$Ò$Ø�‰�C—G‘GÔØ�g‰gˆä�#”|×$Ò$Ø—‘ˆØ�g‰gˆô �#œ
¤NÐ3×4Ò4Ø�x‰x‹zˆÜ�dœC× Ò ÜØ—’˜§¡¨1¥¨sÐ 3Õ3Ñ5Ø—’˜§¡¨1¥¨sÐ 3Õ3Ñ5õ6ñð ñð õ	ð ô ˜!Ÿ&š& $™-¨Õ,¨SÕ0Ñ<°GÑ<¸UÕBÐBô �#”}×%Ó%¯#«#Ñ-{Ðru×rzÒrzÓ-{¯#¯#ª#Ñ-{Ðru×rzÒrzÓ-{×*{Ó*{Ü�sœM×*Ó*¯s«sñ  3AÐwz×wÒwó  3A¯s¯sªsñ  3AÐwz×wÒwó  3A÷  0Aò  0AÜ�—‘‹MœS §¡›]Ô*ÜÔUZÔ[^Ð_b×_gÑ_gÓ[hÔUiÓ jÑUiÐPQ¤¨¯©°­°C·H±H¸QµKÕ(?Ñ!KÀ7Ô!KÑUiÑ jÑk×rÑrð  BFÐró  GˆÜ˜!Ÿ&š& $™-Ñ3¨7Ñ3°FÕ:¸5Õ@Ð@ô �#”s×ÓÜ�cœ3×ÒÜ�3—=‘=Ó!×.Ñ.¬s°3·=±=Ó/A×BÒBÜ Ð!WÓXÐXØ—Z‘Z #§*¡*Õ,ˆFÜœ §¡¨S¯\©\Õ 9ÑE¸WÑEÐOÈÓOˆFÜ˜aŸfšf d™m¨FÕ2Ñ>°gÑ>Ð>äœ §L¡LÕ 0Ñ<°GÑ<ÐJ¸s¿z¹zÓJˆFÜ˜aŸfšf d™m¨FÕ2Ñ>°gÑ>Ð>ä�#”s×ÒÜ”V˜CŸL™L¨Õ,Ñ8°Ñ8ÐF¸3¿:¹:ÓFˆÜ˜!Ÿ&š& $™-¨Õ.Ñ:°'Ñ:Ð:ô �SÐ+¨TÓ2€FØÒð	Ù˜CÑ+ 7Ñ+‰Fð ˆà‚~Ü˜sÐ$:¸DÓAˆØÒ#ðÙ% cÑ5¨WÑ5�ð ‚~Ü�cœ7×#Ò#¬
°3¼×(@Ò(@Ü! #Ó+ˆFô �&œ3¤¬Ð/×0Ò0Ü˜ÓÐØ	ŠÜˆt‹9˜Œ>àˆHä˜aŸfšf t¨e¥|Ñ5ÑA¸ÑAÀ#ÕEÀeÕKÐKÜ	�FœL×	)Ò	)Ø”j §¢¨¡Ñ:°'Ñ:Õ:¸5Õ@Ð@ä�a—f’f˜d‘m FÕ*Ñ6¨gÑ6°uÕ<Ð<ùòk !køô0 #ô 	Ø‹Fð	ûô 'ô Ø“ðús*   Î&>\×	\ ×5	\) Ü\&Ü%\&Ü)\:Ü9\:N)'Ú__doc__Úsympy.concreter   Úsympy.core.addr   Úsympy.core.kindr   Úsympy.core.mulr   Úsympy.core.powerr   Úsympy.core.singletonr   Úsympy.core.sympifyr   r	   Ú$sympy.physics.quantum.anticommutatorr
   Ú sympy.physics.quantum.commutatorr   Úsympy.physics.quantum.daggerr   Ú"sympy.physics.quantum.innerproductr   Úsympy.physics.quantum.operatorr   r   Úsympy.physics.quantum.stater   r   r   r   Ú#sympy.physics.quantum.tensorproductr   Ú__all__r#   r'   r   r9   © r   r   Ú<module>r      s]   ðñõ Ý Ý &Ý Ý  Ý "ß 0å ?Ý 7Ý /Ý ;ß Aß MÓ MÝ =ð ð€òMò
;ò
tône=r   