+
    	þÎjŽ&  ã                   ó  € R 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IHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ R	IHt ]R
 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]RR l4       t R# )z¥
This module implements sums and products containing the Kronecker Delta function.

References
==========

.. [1] https://mathworld.wolfram.com/KroneckerDelta.html

)Úproduct)ÚSumÚ	summation)ÚAddÚMulÚSÚDummy)Úcacheit)Údefault_sort_key)ÚKroneckerDeltaÚ	PiecewiseÚpiecewise_fold)Úfactor)ÚInterval)Úsolvec                óŽ  € V P                   '       g   V # Rp\        p\        P                  .pV P                   Fy  pVf\   VP
                  '       dJ   \        WQ4      '       d9   RpVP                  pVP                   Uu. uF  qd^ ,          V,          NK  	  ppKb  V Uu. uF  qfV,          NK  	  ppK{  	  V! V!  # u upi u upi )z:
Expand the first Add containing a simple KroneckerDelta.
NT)Úis_Mulr   r   ÚOneÚargsÚis_AddÚ_has_simple_deltaÚfunc)ÚexprÚindexÚdeltar   ÚtermsÚhÚts   &&     ÚJ/opt/data/home/.local/lib/python3.14/site-packages/sympy/concrete/delta.pyÚ_expand_deltar      s«   € ð
 �;�;ˆ;ØˆØ€EÜ€DÜ�U‰UˆG€EØ�YŒYˆØŠ=˜QŸXŸX˜XÔ*;¸A×*EÒ*EØˆEØ—6‘6ˆDØ)*¯ªÓ0© A˜1•X˜a—Z�Z©ˆEÐ0‰Eá"'Ó(¡%˜Q�q—S�S¡%ˆEÐ(‰Eñ ñ �‰<Ðùò 1ùâ(s   Â B=Â Cc                óZ  € \        W4      '       g   RV 3# \        V \        4      '       d   V \        P                  3# V P
                  '       g   \        R4      hRp. pV P                   F-  pVf   \        WA4      '       d   TpK  VP                  V4       K/  	  W P                  ! V!  3# )a8  
Extract a simple KroneckerDelta from the expression.

Explanation
===========

Returns the tuple ``(delta, newexpr)`` where:

  - ``delta`` is a simple KroneckerDelta expression if one was found,
    or ``None`` if no simple KroneckerDelta expression was found.

  - ``newexpr`` is a Mul containing the remaining terms; ``expr`` is
    returned unchanged if no simple KroneckerDelta expression was found.

Examples
========

>>> from sympy import KroneckerDelta
>>> from sympy.concrete.delta import _extract_delta
>>> from sympy.abc import x, y, i, j, k
>>> _extract_delta(4*x*y*KroneckerDelta(i, j), i)
(KroneckerDelta(i, j), 4*x*y)
>>> _extract_delta(4*x*y*KroneckerDelta(i, j), k)
(None, 4*x*y*KroneckerDelta(i, j))

See Also
========

sympy.functions.special.tensor_functions.KroneckerDelta
deltaproduct
deltasummation
NzIncorrect expr)r   Ú
isinstancer   r   r   r   Ú
ValueErrorr   Ú_is_simple_deltaÚappendr   )r   r   r   r   Úargs   &&   r   Ú_extract_deltar&   )   s—   € ôD ˜T×)Ò)Ø�dˆ|ÐÜ�$œ×'Ò'Ø”a—e‘eˆ}ÐØ�;�;ˆ;ÜÐ)Ó*Ð*Ø€EØ€Eà�yŒyˆØŠ=Ô-¨c×9Ò9ØŠEà�L‰L˜Öñ	 ð
 —9’9˜eÑ$Ð%Ð%ó    c                óJ  a€ V P                  \        4      '       d‡   \        V S4      '       d   R# V P                  '       g   V P                  '       dO   \
        ;QJ d)    V3R lV P                   4       F  '       g   K   R# 	  R# ! V3R lV P                   4       4      # R# )zÈ
Returns True if ``expr`` is an expression that contains a KroneckerDelta
that is simple in the index ``index``, meaning that this KroneckerDelta
is nonzero for a single value of the index ``index``.
Tc              3   ó<   <"  € T F  p\        VS4      x € K  	  R # 5i)N)r   )Ú.0r%   r   s   & €r   Ú	<genexpr>Ú$_has_simple_delta.<locals>.<genexpr>g   s   øé € ÐJÁ	¸Ô(¨¨e×4Ð4Ã	ùs   ƒF)Úhasr   r#   r   r   Úanyr   )r   r   s   &fr   r   r   \   si   ø€ ð ‡x�x”×ÒÜ˜D %×(Ò(ÙØ�;�;ˆ;˜$Ÿ+Ÿ+˜+ß“3ÔJÀÇ	Â	ÓJ—3”3ÐJ’3ÐJ�3ÔJÀÇ	Â	ÓJÓJÐJÙr'   c                ó
  € \        V \        4      '       dm   V P                  V4      '       dV   V P                  ^ ,          V P                  ^,          ,
          P	                  V4      pV'       d   VP                  4       ^8H  # R# )zi
Returns True if ``delta`` is a KroneckerDelta and is nonzero for a single
value of the index ``index``.
F)r!   r   r-   r   Úas_polyÚdegree)r   r   Úps   && r   r#   r#   k   sZ   € ô �%œ×(Ò(¨U¯Y©Y°u×-=Ò-=Ø�Z‰Z˜�]˜UŸZ™Z¨�]Õ*×3Ñ3°EÓ:ˆßØ—8‘8“: ‘?Ð"Ùr'   c           	     óø  € V P                   '       d2   V P                  ! \        \        \        V P
                  4      4      !  # V P                  '       g   V # . p. pV P
                   Ff  p\        V\        4      '       d=   VP                  VP
                  ^ ,          VP
                  ^,          ,
          4       KU  VP                  V4       Kh  	  V'       g   V # \        VRR7      p\        V4      ^ 8X  d   \        P                  # \        V4      ^8X  d\   Y$^ ,          P                  4        UUu. uF  w  rV\        WV4      NK  	  upp,          pV P                  ! V!  pW8w  d   \	        V4      # V # u uppi )z(
Evaluate products of KroneckerDelta's.
T©Údict)r   r   ÚlistÚmapÚ_remove_multiple_deltar   r   r!   r   r$   r   Úlenr   ÚZeroÚitems)r   ÚeqsÚnewargsr%   ÚsolnsÚkÚvÚexpr2s   &       r   r8   r8   x   s  € ð
 ‡{‡{€{Ø�yŠyœ$œsÔ#9¸4¿9¹9ÓEÓFÑGÐGØ�;�;ˆ;ØˆØ
€CØ€GØ�yŒyˆÜ�cœ>×*Ò*Ø�J‰J�s—x‘x •{ S§X¡X¨a¥[Õ0Ö1à�N‰N˜3Öñ	 ÷
 ØˆÜ�#˜DÔ!€EÜ
ˆ5ƒz�Q„Ü�v‰vˆÜ	ˆU‹�qŒØ¸1µX·^±^Ô5EÔFÑ5E©T¨Q”N 1Ö(Ñ5EÒFÕFˆØ—	’	˜7Ñ#ˆØŒ=Ü)¨%Ó0Ð0Ø€Kùó	 Gs   Ä3E6c           
     óx  € \        V \        4      '       dŒ    \        V P                  ^ ,          V P                  ^,          ,
          RR7      pV'       dK   \	        V4      ^8X  d;   \        V^ ,          P                  4        UUu. uF  w  r#\        W#3!  NK  	  upp!  # V # V # u uppi   \         d     T # i ; i)z:
Rewrite a KroneckerDelta's indices in its simplest form.
Tr4   )r!   r   r   r   r9   r   r;   ÚNotImplementedError)r   ÚslnsÚkeyÚvalues   &   r   Ú_simplify_deltarG   •   s¨   € ô
 �$œ×'Ò'ð	Ü˜Ÿ™ 1�¨¯	©	°!­Õ4¸4Ô@ˆDßœ˜D›	 QœÜØ.2°1­g¯m©m¬oô?Ù.=¡
 ô ,¨c¨\Ô:Ù.=ò?ñ @ð @ð €Kˆ4€Kùó	?øä"ô 	ØØ€Kð	ús$   ˜A-B* ÂB$
ÂB* Â$B* Â*B9Â8B9c                óZ  aaa	€ S^,          S^,          ,
          ^ 8  R8X  d   \         P                  # V P                  \        4      '       g   \	        V S4      # V P
                  '       Ed¿   Ro. p\        V P                  \        R7       F5  pSf   \        VS^ ,          4      '       d   VoK$  VP                  V4       K7  	  V P                  ! V!  o	\        RRR7      p\        S^,          \        4      '       dx   \        S^,          \        4      '       d[   \        S	S4      \!        VVV	3R l\#        \        S^,          4      \        S^,          ^,           4      4       4       4      ,           pMª\        S	S4      \%        \        S	S^ ,          S^,          V^,
          34      SP'                  S^ ,          V4      ,          \        S	S^ ,          V^,           S^,          34      ,          VS^,          S^,          3\        S	S^ ,          4      R7      ,           p\)        V4      # \+        V S^ ,          4      w  opS'       g<   \-        V S^ ,          4      pW8w  d    \/        \        VS4      4      # \	        V S4      # \)        V P'                  S^ ,          S^,          4      \        S^,          S^,          4      ,          4      \         P                  \3        \        S^,          S^,          ^,
          4      4      ,          ,           #   \0         d    \        TS4      u # i ; i)z©
Handle products containing a KroneckerDelta.

See Also
========

deltasummation
sympy.functions.special.tensor_functions.KroneckerDelta
sympy.concrete.products.product
TN)rE   Úkprime)Úintegerc           	   3   óú   <"  € T Fp  p\        SS^ ,          S^,          V^,
          34      SP                  S^ ,          V4      ,          \        SS^ ,          V^,           S^,          34      ,          x € Kr  	  R# 5i)é    N)ÚdeltaproductÚsubs)r*   Úikr   ÚlimitÚnewexprs   & €€€r   r+   Údeltaproduct.<locals>.<genexpr>Ã   sz   øé € ð 8áNuÈô 9EÀWÈuÐUVÍxÐY^Ð_`ÕYaÐceÐhiÕciÐNjÓ8kØ—
‘
˜5 �8 RÓ(õ9)ä˜W u¨Q¥x°°aµ¸¸q½Ð&BÓC÷9Dò 9DãNuùs   ƒA8A;)Úno_piecewise)r   r   r-   r   r   r   Úsortedr   r
   r   r$   r   r   r!   ÚintrM   ÚsumÚrangeÚdeltasummationrN   r8   r&   r   r   ÚAssertionErrorrG   )
ÚfrP   r   r%   r?   ÚresultÚ_Úgr   rQ   s
   &f      @@r   rM   rM   ¥   s�  ú€ ð 
ˆq��E˜!•HÕ	 Ñ! dÔ*Ü�u‰uˆà�5‰5”× Ò Ü�q˜%Ó Ð à‡x‡x�xàˆØˆÜ˜!Ÿ&™&Ô&6×7ˆCØŠ}Ô!2°3¸¸a½×!AÒ!AØ’à—‘˜SÖ!ñ	 8ð
 —&’&˜%‘.ˆÜ�( DÔ)ˆÜ�e˜A•h¤×$Ò$¬°E¸!µH¼c×)BÒ)BÜ! '¨5Ó1´Cö 8äNSÔTWÐX]Ð^_ÕX`ÓTaÔcfÐglÐmnÕgoÐrsÕgsÓctÔNuó8ó 5õ ‰Fô
 " '¨5Ó1´NÜ˜W u¨Q¥x°°qµ¸1¸q½5Ð&AÓBØ—
‘
˜5 �8 QÓ'õ(ä˜W u¨Q¥x°°Qµ¸¸a½Ð&AÓBõCð �E˜!•H˜e A�hÐ'Ü.¨w¸¸a½ÓAô5õ ˆFô & fÓ-Ð-ä˜a  q¥Ó*�H€Eˆ1çÜ˜!˜U 1�XÓ&ˆØŒ6ð.Üœl¨1¨eÓ4Ó5Ð5ô �q˜%Ó Ð ä! !§&¡&¨¨q­°5¸µ8Ó"<¼^ÈEÐRSÍHÐV[Ð\]ÕV^Ó=_Õ"_Ó`Ü	�‰Œoœn¨U°1­X°u¸QµxÀ!µ|ÓDÓEÕEõFð Føô	 "ô .Ü# A uÓ-Ò-ð.ús   É#L ÌL*Ì)L*c                ó  € V^,          V^,          ,
          ^ 8  R8X  d   \         P                  # V P                  \        4      '       g   \	        W4      # V^ ,          p\        W4      pVP                  '       d>   \        VP                  ! VP                   Uu. uF  p\        WQV4      NK  	  up!  4      # \        WC4      w  rgVeO   VP                  eA   VP                  w  r‰V^,          V,
          ^ 8*  R8X  d   V^,          V	,
          ^ 8¬  R8X  d   RpV'       g   \	        W4      # \        VP                  ^ ,          VP                  ^,          ,
          V4      p
\        V
4      ^ 8X  d   \         P                  # \        V
4      ^8w  d   \        W4      # V
^ ,          pV'       d   VP!                  W;4      # \#        VP!                  W;4      \%        VR,          !  P'                  V4      3\         P                  R34      # u upi )a·  
Handle summations containing a KroneckerDelta.

Explanation
===========

The idea for summation is the following:

- If we are dealing with a KroneckerDelta expression, i.e. KroneckerDelta(g(x), j),
  we try to simplify it.

  If we could simplify it, then we sum the resulting expression.
  We already know we can sum a simplified expression, because only
  simple KroneckerDelta expressions are involved.

  If we could not simplify it, there are two cases:

  1) The expression is a simple expression: we return the summation,
     taking care if we are dealing with a Derivative or with a proper
     KroneckerDelta.

  2) The expression is not simple (i.e. KroneckerDelta(cos(x))): we can do
     nothing at all.

- If the expr is a multiplication expr having a KroneckerDelta term:

  First we expand it.

  If the expansion did work, then we try to sum the expansion.

  If not, we try to extract a simple KroneckerDelta term, then we have two
  cases:

  1) We have a simple KroneckerDelta term, so we return the summation.

  2) We did not have a simple term, but we do have an expression with
     simplified KroneckerDelta terms, so we sum this expression.

Examples
========

>>> from sympy import oo, symbols
>>> from sympy.abc import k
>>> i, j = symbols('i, j', integer=True, finite=True)
>>> from sympy.concrete.delta import deltasummation
>>> from sympy import KroneckerDelta
>>> deltasummation(KroneckerDelta(i, k), (k, -oo, oo))
1
>>> deltasummation(KroneckerDelta(i, k), (k, 0, oo))
Piecewise((1, i >= 0), (0, True))
>>> deltasummation(KroneckerDelta(i, k), (k, 1, 3))
Piecewise((1, (i >= 1) & (i <= 3)), (0, True))
>>> deltasummation(k*KroneckerDelta(i, j)*KroneckerDelta(j, k), (k, -oo, oo))
j*KroneckerDelta(i, j)
>>> deltasummation(j*KroneckerDelta(i, j), (j, -oo, oo))
i
>>> deltasummation(i*KroneckerDelta(i, j), (i, -oo, oo))
j

See Also
========

deltaproduct
sympy.functions.special.tensor_functions.KroneckerDelta
sympy.concrete.sums.summation
T:é   é   N)r   r:   r-   r   r   r   r   r   r   r   rX   r&   Údelta_ranger   r9   r   rN   r   r   Úas_relational)rZ   rP   rS   Úxr]   r   r   r   ÚdinfÚdsupr>   rF   s   &&&         r   rX   rX   à   s£  € ðH 
ˆq��E˜!•HÕ	 Ñ! dÔ*Ü�v‰vˆà�5‰5”× Ò Ü˜Ó"Ð"àˆa�€Aä�aÓ€AØ‡x‡x€xÜØ�FŠFÀQÇVÂVÓLÁVÀ”^ A¨lÖ;ÁVÑLÑMóOð 	Oô ! Ó&�K€EàÒ × 1Ñ 1Ò =Ø×&Ñ&‰
ˆØ�!�H�t�O˜qÑ  TÔ)¨u°Q­x¸$­À!Ñ/CÈÔ.LØˆLçÜ˜Ó"Ð"ä�%—*‘*˜Q•- %§*¡*¨Q¥-Õ/°Ó3€EÜ
ˆ5ƒz�Q„Ü�v‰vˆÜ	ˆU‹�qŒÜ�1‹}ÐØ�!�H€EßØ�y‰y˜Ó"Ð"ÜØ	�‰�1Ó	œh¨¨c­
Ñ3×AÑAÀ%ÓHÐIÜ	
�‰�ˆóð ùò+ Ms   ÂHN)F)!Ú__doc__Úproductsr   Ú
summationsr   r   Ú
sympy.corer   r   r   r   Úsympy.core.cacher	   Úsympy.core.sortingr
   Úsympy.functionsr   r   r   Úsympy.polys.polytoolsr   Úsympy.sets.setsr   Úsympy.solvers.solversr   r   r&   r   r#   r8   rG   rM   rX   © r'   r   Ú<module>rq      sÓ   ðñõ ß &ß )Ó )Ý $Ý /ß EÑ EÝ (Ý $Ý 'ð 	ñó 	ðð& 	ñ/&ó 	ð/&ðd 	ñó 	ðð 	ñ	ó 	ð	ð 	ñó 	ðð8 	ñó 	ðð 	ñ7Fó 	ð7Fðt 	ófó 	òfr'   