ó
    ‰*£h­ã  ã                   óˆ  • S SK JrJrJrJrJr  S SKJrJr  S SK	J
r
  S SKJrJrJr  S SKJr  S SKJrJrJrJrJrJrJr  S SKJr  S SKJrJr  S S	KJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)  S S
K*J+r+J,r,J-r-  S SK.J/r/J0r0  S SK1J2r2  \Rf                  r4 " S S\5      r5 " S S\
5      r6SS jr7S r8S r9S r:S r;S r<S r=S r>SSS.S jr?g)é    )ÚSÚdiffÚTupleÚDummyÚMul)ÚBasicÚas_Basic)ÚDefinedFunction)ÚRationalÚNumberSymbolÚ_illegal)Úglobal_parameters)ÚLtÚGtÚEqÚNeÚ
RelationalÚ
_canonicalÚ_canonical_coeff)Úordered)ÚMaxÚMin)ÚAndÚBooleanÚdistribute_and_over_orÚNotÚtrueÚfalseÚOrÚITEÚsimplify_logicÚto_cnfÚdistribute_or_over_and)ÚuniqÚsiftÚcommon_prefix)Ú
filldedentÚ	func_name)Úproductc                   óZ   • \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	S r
S rS	rg
)ÚExprCondPairé   z)Represents an expression, condition pair.c                 óü  • [        U5      nUS:X  a  [        R                  " X[        5      $ US:X  a  [        R                  " X[        5      $ [        U[        5      (       aO  UR                  [        5      (       a5  [        U5      n[        U[        5      (       a  UR                  [        5      n[        U[        5      (       d   [        [        S[        U5      -  5      5      e[        R                  " XU5      $ )NTFzL
                Second argument must be a Boolean,
                not `%s`)r	   r   Ú__new__r   r   Ú
isinstancer   ÚhasÚ	PiecewiseÚpiecewise_foldÚrewriter    r   Ú	TypeErrorr'   r(   )ÚclsÚexprÚconds      Úa/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/functions/elementary/piecewise.pyr.   ÚExprCondPair.__new__   sÀ   € Ü˜‹~ˆØ�4‹<Ü—=’= ¬DÓ1Ð1Ø�U‹]Ü—=’= ¬EÓ2Ð2Ü˜œe×$Ñ$¨¯©´)×)<Ñ)<Ü! $Ó'ˆDÜ˜$¤	×*Ñ*Ø—|‘|¤CÓ(�ä˜$¤×(Ñ(ÜœJð (ä'¨›oñ(.ó /ó 0ð 0ô �}Š}˜S¨Ó-Ð-ó    c                 ó    • U R                   S   $ )z&
Returns the expression of this pair.
r   ©Úargs©Úselfs    r8   r6   ÚExprCondPair.expr'   ó   € ð
 �y‰y˜‰|Ðr:   c                 ó    • U R                   S   $ )z%
Returns the condition of this pair.
é   r<   r>   s    r8   r7   ÚExprCondPair.cond.   rA   r:   c                 ó.   • U R                   R                  $ ©N)r6   Úis_commutativer>   s    r8   rG   ÚExprCondPair.is_commutative5   s   € à�y‰y×'Ñ'Ð'r:   c              #   óD   #   • U R                   v •  U R                  v •  g 7frF   )r6   r7   r>   s    r8   Ú__iter__ÚExprCondPair.__iter__9   s   é € Ø�i‰iŠØ�i‰i‹ùs   ‚ c           
      ó~   • U R                   " U R                   Vs/ s H  o"R                  " S0 UD6PM     sn6 $ s  snf )N© )Úfuncr=   Úsimplify)r?   ÚkwargsÚas      r8   Ú_eval_simplifyÚExprCondPair._eval_simplify=   s1   € Ø�yŠy¸¿ºÓCº°AŸ:š:Ñ/¨Ô/¹ÑCÐDÐDùÒCs   ›:rM   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r.   Úpropertyr6   r7   rG   rJ   rR   Ú__static_attributes__rM   r:   r8   r+   r+      sQ   † Ù3ò.ð" ñó ðð ñó ðð ñ(ó ð(òõEr:   r+   c                   ód  ^ • \ rS rSrSrSrSrS r\S 5       r	S r
S rS	 rS
 rS rS rS rS rS rS rS3S jrS3U 4S jjrS4S jrS5S jrS rS rS rS rS rS rS rS rS r S r!S r"S  r#S! r$S" r%S# r&S$ r'S% r(S& r)S' r*S( r+S) r,S* r-S+ r.S, r/S- r0\S. 5       r1S6S/ jr2S0 r3S1 r4S2r5U =r6$ )7r1   éA   aÞ  
Represents a piecewise function.

Usage:

  Piecewise( (expr,cond), (expr,cond), ... )
    - Each argument is a 2-tuple defining an expression and condition
    - The conds are evaluated in turn returning the first that is True.
      If any of the evaluated conds are not explicitly False,
      e.g. ``x < 1``, the function is returned in symbolic form.
    - If the function is evaluated at a place where all conditions are False,
      nan will be returned.
    - Pairs where the cond is explicitly False, will be removed and no pair
      appearing after a True condition will ever be retained. If a single
      pair with a True condition remains, it will be returned, even when
      evaluation is False.

Examples
========

>>> from sympy import Piecewise, log, piecewise_fold
>>> from sympy.abc import x, y
>>> f = x**2
>>> g = log(x)
>>> p = Piecewise((0, x < -1), (f, x <= 1), (g, True))
>>> p.subs(x,1)
1
>>> p.subs(x,5)
log(5)

Booleans can contain Piecewise elements:

>>> cond = (x < y).subs(x, Piecewise((2, x < 0), (3, True))); cond
Piecewise((2, x < 0), (3, True)) < y

The folded version of this results in a Piecewise whose
expressions are Booleans:

>>> folded_cond = piecewise_fold(cond); folded_cond
Piecewise((2 < y, x < 0), (3 < y, True))

When a Boolean containing Piecewise (like cond) or a Piecewise
with Boolean expressions (like folded_cond) is used as a condition,
it is converted to an equivalent :class:`~.ITE` object:

>>> Piecewise((1, folded_cond))
Piecewise((1, ITE(x < 0, y > 2, y > 3)))

When a condition is an ``ITE``, it will be converted to a simplified
Boolean expression:

>>> piecewise_fold(_)
Piecewise((1, ((x >= 0) | (y > 2)) & ((y > 3) | (x < 0))))

See Also
========

piecewise_fold
piecewise_exclusive
ITE
NTc                 óæ  • [        U5      S:X  a  [        S5      e/ nU HI  n[        [        USU5      6 nUR                  nU[
        L a  M-  UR                  U5        U[        L d  MI    O   UR                  S[        R                  5      nU(       a  U R                  " U6 nUb  U$ O1[        U5      S:X  a"  US   R                  S:X  a  US   R                  $ [        R                  " U /UQ70 UD6$ )Nr   z(At least one (expr, cond) pair expected.r=   ÚevaluaterC   T)Úlenr4   r+   Úgetattrr7   r   Úappendr   Úpopr   r^   Úevalr6   r   r.   )	r5   r=   ÚoptionsÚnewargsÚecÚpairr7   rc   Úrs	            r8   r.   ÚPiecewise.__new__ƒ   sß   € Üˆt‹9˜‹>ÜÐFÓGÐGàˆÛˆBä¤¨¨V°RÓ!8Ð9ˆDØ—9‘9ˆDØ”uŠ}ÙØ�N‰N˜4Ô Ø”tŒ|Ùñ ð �{‰{˜:Ô'8×'AÑ'AÓBˆÞØ—’˜'Ð"ˆAØ‰}Ø�ð ä�‹\˜QÓ 7¨1¡:§?¡?°dÓ#:Ø˜1‘:—?‘?Ð"ä�}Š}˜SÐ6 7Ò6¨gÑ6Ð6r:   c                 ó:  • U(       d  [         $ [        U5      S:X  a  US   S   S:X  a  US   S   $ [        U5      n[        U5      [        U5      :g  n[        S [	        X!5       5       5      nU(       d  [        [        S5      5      eU(       d  U(       d  U " U6 $ g)aô  Either return a modified version of the args or, if no
modifications were made, return None.

Modifications that are made here:

1. relationals are made canonical
2. any False conditions are dropped
3. any repeat of a previous condition is ignored
4. any args past one with a true condition are dropped

If there are no args left, nan will be returned.
If there is a single arg with a True condition, its
corresponding expression will be returned.

EXAMPLES
========

>>> from sympy import Piecewise
>>> from sympy.abc import x
>>> cond = -x < -1
>>> args = [(1, cond), (4, cond), (3, False), (2, True), (5, x < 1)]
>>> Piecewise(*args, evaluate=False)
Piecewise((1, -x < -1), (4, -x < -1), (2, True))
>>> Piecewise(*args)
Piecewise((1, x > 1), (2, True))
rC   r   éÿÿÿÿTc              3   ó.   #   • U  H  u  pX:H  v •  M     g 7frF   rM   )Ú.0rQ   Úbs      r8   Ú	<genexpr>Ú!Piecewise.eval.<locals>.<genexpr>Ã   s   é € Ð:Ò&9™d˜a�1–6Ò&9ùs   ‚zˆ
                There are no conditions (or none that
                are not trivially false) to define an
                expression.N)Ú	Undefinedr_   Ú_piecewise_collapse_argumentsÚallÚzipÚ
ValueErrorr'   )r5   Ú_argsre   ÚmissingÚsames        r8   rc   ÚPiecewise.evalœ   sœ   € ö8 ÜÐäˆu‹:˜‹?˜u Q™x¨™|¨tÓ3Ø˜‘8˜A‘;Ðä/°Ó6ˆô �g“,¤# e£*Ñ,ˆäÑ:¤c¨'Ô&9Ó:Ó:ˆö ÜœZð )ó  ó !ð !ö ž$Ù˜�=Ð ð r:   c                 óJ  • / nU R                    Hƒ  u  p4UR                  SS5      (       aU  [        U[        5      (       a  UR                  " S0 UD6nXP:w  a  Un[        U[        5      (       a  UR                  " S0 UD6nUR                  X445        M…     U R                  " U6 $ )z#
Evaluate this piecewise function.
ÚdeepTrM   )r=   Úgetr/   r   Údoitra   rN   )r?   Úhintsre   ÚeÚcÚnewes         r8   r}   ÚPiecewise.doitÎ   s‹   € ð ˆØ—I”I‰DˆAØ�y‰y˜ ×&Ñ&Ü˜a¤×'Ñ'ØŸ6š6™? E™?�DØ“|Ø ˜Ü˜a¤×'Ñ'ØŸš™ ™�AØ�N‰N˜A˜6Ö"ñ ð �yŠy˜'Ð"Ð"r:   c                 ó   • [        U 40 UD6$ rF   )Úpiecewise_simplify)r?   rP   s     r8   rR   ÚPiecewise._eval_simplifyÞ   s   € Ü! $Ñ1¨&Ñ1Ð1r:   c                 óŒ   • U R                    H4  u  pEUS:X  d  UR                  US5      S:X  d  M#  UR                  U5      s  $    g )NTr   )r=   ÚsubsÚas_leading_term)r?   ÚxÚlogxÚcdirr   r€   s         r8   Ú_eval_as_leading_termÚPiecewise._eval_as_leading_termá   s;   € Ø—I”I‰DˆAØ�D‹y˜AŸF™F 1 a›L¨DÕ0Ø×(Ñ(¨Ó+Ò+ò r:   c                 óŠ   • U R                   " U R                   VVs/ s H  u  pUR                  5       U4PM     snn6 $ s  snnf rF   )rN   r=   Úadjoint©r?   r   r€   s      r8   Ú_eval_adjointÚPiecewise._eval_adjointæ   s4   € Ø�yŠy¸¿	º	ÔBº	±°˜AŸI™I›K¨Ó+¹	ÒBÐCÐCùÓBó   œ?
c                 óŠ   • U R                   " U R                   VVs/ s H  u  pUR                  5       U4PM     snn6 $ s  snnf rF   )rN   r=   Ú	conjugater�   s      r8   Ú_eval_conjugateÚPiecewise._eval_conjugateé   ó4   € Ø�yŠy¸$¿)º)ÔDº)±$°!˜AŸK™K›M¨1Ó-¹)ÒDÐEÐEùÓDr“   c           
      ó€   • U R                   " U R                   VVs/ s H  u  p#[        X!5      U4PM     snn6 $ s  snnf rF   )rN   r=   r   )r?   r‰   r   r€   s       r8   Ú_eval_derivativeÚPiecewise._eval_derivativeì   s1   € Ø�yŠy°t·y²yÔA²y©t¨qœD ›J¨›?±yÒAÐBÐBùÓAs   œ:
c           	      óŒ   • U R                   " U R                   VVs/ s H  u  p#UR                  U5      U4PM     snn6 $ s  snnf rF   )rN   r=   Ú_evalf)r?   Úprecr   r€   s       r8   Ú_eval_evalfÚPiecewise._eval_evalfï   s6   € Ø�yŠy¸4¿9º9ÔEº9±4°1˜AŸH™H T›N¨AÓ.¹9ÒEÐFÐFùÓEs   œA 
c                 ó  • UR                   (       d  g U R                   Hb  u  p4UR                  X5      nUR                  (       a    g X$R	                  5       R
                  ;   a    g U(       d  MQ  UR                  X5      s  $    g rF   )Úis_realr=   r‡   Úis_RelationalÚas_setÚboundaryÚ_eval_is_meromorphic)r?   r‰   rQ   r   r€   r7   s         r8   r¦   ÚPiecewise._eval_is_meromorphicò   sd   € ð �y�yØð —I”I‰DˆAØ—6‘6˜!“<ˆDà×!×!ÙØ—H‘H“J×'Ñ'Ó'ÙçˆtØ×-Ñ-¨aÓ3Ò3ò r:   c                 óˆ   • SSK Jn  U R                  " U R                   VVs/ s H  u  pEU" XA40 UD6U4PM     snn6 $ s  snnf )a+  Return the Piecewise with each expression being
replaced with its antiderivative. To obtain a continuous
antiderivative, use the :func:`~.integrate` function or method.

Examples
========

>>> from sympy import Piecewise
>>> from sympy.abc import x
>>> p = Piecewise((0, x < 0), (1, x < 1), (2, True))
>>> p.piecewise_integrate(x)
Piecewise((0, x < 0), (x, x < 1), (2*x, True))

Note that this does not give a continuous function, e.g.
at x = 1 the 3rd condition applies and the antiderivative
there is 2*x so the value of the antiderivative is 2:

>>> anti = _
>>> anti.subs(x, 1)
2

The continuous derivative accounts for the integral *up to*
the point of interest, however:

>>> p.integrate(x)
Piecewise((0, x < 0), (x, x < 1), (2*x - 1, True))
>>> _.subs(x, 1)
1

See Also
========
Piecewise._eval_integral
r   ©Ú	integrate)Úsympy.integralsrª   rN   r=   )r?   r‰   rP   rª   r   r€   s         r8   Úpiecewise_integrateÚPiecewise.piecewise_integrate  s>   € õD 	.Ø�yŠyÀdÇiÂiÔPÂi¹d¸a™I aÑ5¨fÑ5°qÓ9ÁiÒPÐQÐQùÓPs   ¢>
c                 óô  • U R                  [        5      n[        [        U Vs/ s H<  oAUR                  ;  d  M  U[
        R                  [
        R                  4;  d  M:  UPM>     sn5      5      nU(       Ga±  0 n/ n[        S[        U5      S9 GHC  n[        [        XX5      5      n	SU;  a  Sn
O|[        U	 Vs/ s H  o¹U   (       d  M  UPM     sn6 n[        UR                  5      n[        U5      S:X  a  SSKJnJn   U" XÍS   5      nO[%        U6 nU[
        R                  L a  M›  Un
U" U R'                  U	5      5      n[)        UU R*                  5      (       a<  [        UR,                  5      S:X  a#  UR,                  S   u  nn[%        UU
c  SOU
5      n
U
c  GM  UR/                  U/ 5      R1                  U
5        UR1                  U5        GMF     U H  n[3        UU   6 UU'   M     [5        U5       Vs/ s H
  nUUU   4PM     nnUR1                  WS45        [7        U6 $ gs  snf s  snf ! [         ["        4 a,    [%        U Vs/ s H  nU" UUS   SS9PM     Os  snf sn6 n GNZf = fs  snf )	a'  Return either None (if the conditions of self depend only on x) else
a Piecewise expression whose expressions (handled by the handler that
was passed) are paired with the governing x-independent relationals,
e.g. Piecewise((A, a(x) & b(y)), (B, c(x) | c(y)) ->
Piecewise(
    (handler(Piecewise((A, a(x) & True), (B, c(x) | True)), b(y) & c(y)),
    (handler(Piecewise((A, a(x) & True), (B, c(x) | False)), b(y)),
    (handler(Piecewise((A, a(x) & False), (B, c(x) | True)), c(y)),
    (handler(Piecewise((A, a(x) & False), (B, c(x) | False)), True))
)rC   r   )ÚrepeatrC   Nr   )Úreduce_inequalitiesÚ_solve_inequalityT)Úlinear)Úatomsr   Úlistr   Úfree_symbolsr   r   r   r)   r_   Údictrt   r   Úsympy.solvers.inequalitiesr°   r±   ru   ÚNotImplementedErrorr   Úxreplacer/   rN   r=   Ú
setdefaultra   r   r$   r1   )r?   r‰   ÚhandlerÚrelrh   Úirelr=   ÚexprinorderÚtruthÚrepsr7   ÚiÚandargsÚfreer°   r±   ÚtrQ   r6   ÚecondÚkr   s                         r8   Ú_handle_irelÚPiecewise._handle_irel*  sP  € ð �j‰jœÓ$ˆÜ”G©ó ,ª 1¸¿¹Ñ/F›QØœ!Ÿ&™&¤!§'¡'Ð*Ñ*÷ ©ñ ,ó -ó .ˆçØˆDØˆKÜ  ´°D³	Õ:�ÜœC Ó,Ó-�ð ˜E“>Ø‘Dä#±Ó%A²¨A¸a½§a±Ñ%AÐB�GÜ × 4Ñ 4Ó5�DÜ˜4“y A“~÷Dð3Ù 3°GÀ!¹WÓ E™Aô   ˜M˜ØœAŸG™G’|Ù Ø�DÙ˜tŸ}™}¨TÓ2Ó3�Ü˜d D§I¡I×.Ñ.´3°t·y±y³>ÀQÓ3FØ"&§)¡)¨A¡,‘K�D˜%Ü˜u¨d©l¡dÀÓE�Dð
 Ô#Ø—O‘O D¨"Ó-×4Ñ4°TÔ:ð  ×&Ñ& t×,ñO ;óR �Ü˜d 1™g˜,��Q“ñ ô +/¨{Ô*;Ó<Ò*; Q�Q˜˜Q™“LÑ*;ˆDÐ<à�K‰K˜˜t˜Ô%Ü˜dÐ#Ð#ðe ùò,ùò &Bøô !+Ô,?Ð@ó 3ä #á)0ó&2â)0 Añ '8Ø ! 4¨¡7°4ô'9â)0ùô&2ð !3›Að3üò8 =s@   ¤H,»"H,Á!H,Â;H1
ÃH1
ÄH6Ç=I5È6I2ÉI%É$
I2É1I2c           	      óê  ^ ^^• SSK Jn  U(       a  UU U4S jnT R                  TU5      nUb  U$ T R                  T5      u  pxU(       d  SSK Jn	  U	" T T5      $ U V
VVs/ s H
  u  p«  oÊU4PM     nnn
n[
        R                  nU* US4/n[        U5       Hˆ  u  nnUU* U4:X  a)  [        U5       H  u  nu  p«nUS:X  d  M  X«U4UU'   M       OT[        U5      S-
  n[        [        U5      5       H*  u  nu  p«nUS:X  d  M  UU-
  n[        UX«4U5      UUUS-   & M,     MŠ     U V
VVs/ s H  u  p«nX«:w  d  M  X«U4PM     nnn
n[        S U 5       5      (       a  UR                  U* U[        S45        / nSnU Hà  u  p«nU" UU   S	   T40 TD6nUc  UnO]UR                  TU
5      nUR                  TU
T5      nUR                   " ["        6 (       d  UR                   " ["        6 (       a  UnOUU-  nU[
        R                  L a  S
nO>T R$                  UU   S      R&                  R                  TU5      S:X  a  TU:  nOTU:*  nUR                  UU45        Mâ     [)        U6 $ s  snnn
f s  snnn
f )ak  Return the indefinite integral of the
Piecewise such that subsequent substitution of x with a
value will give the value of the integral (not including
the constant of integration) up to that point. To only
integrate the individual parts of Piecewise, use the
``piecewise_integrate`` method.

Examples
========

>>> from sympy import Piecewise
>>> from sympy.abc import x
>>> p = Piecewise((0, x < 0), (1, x < 1), (2, True))
>>> p.integrate(x)
Piecewise((0, x < 0), (x, x < 1), (2*x - 1, True))
>>> p.piecewise_integrate(x)
Piecewise((0, x < 0), (x, x < 1), (2*x, True))

See Also
========
Piecewise.piecewise_integrate
r   r©   c                 óŠ   >• [        U TR                  5      (       a  U R                  " T4SS0TD6$ U R                  " T40 TD6$ )NÚ_firstF)r/   rN   Ú_eval_integralrª   )ÚipwrP   r?   r‰   s    €€€r8   r»   Ú)Piecewise._eval_integral.<locals>.handler‡  sC   ø€ Ü˜c 4§9¡9×-Ñ-Ø×-Ò-¨aÑH¸ÐHÀÑHÐHàŸ=š=¨Ñ5¨fÑ5Ð5r:   N©ÚIntegralrk   rC   c              3   ó0   #   • U  H  u  po3S :H  v •  M     g7f)rk   NrM   )rm   rQ   rn   rÁ   s       r8   ro   Ú+Piecewise._eval_integral.<locals>.<genexpr>ª  s   é € Ð-ª™9˜A !�BŽwªùó   ‚éþÿÿÿTF)Úsympy.integrals.integralsrª   rÇ   Ú
_intervalsrÐ   r   ÚInfinityÚ	enumerater_   ÚreversedÚ_clipÚanyra   rq   r‡   Ú_eval_intervalr0   r   r=   r7   r1   )r?   r‰   rË   rP   rª   r»   ÚirvÚokÚabeirÐ   rQ   rn   Ú_ÚpiecesÚooÚdonerÆ   ÚpÚjrÁ   ÚNr=   ÚsumÚantir   r7   s   `` `                      r8   rÌ   ÚPiecewise._eval_integralm  ss  ú€ õ. 	8æ÷6ð
 ×#Ñ# A wÓ/ˆCØ‰Ø�
ð —?‘? 1Ó%‰ˆÞÝ:Ù˜D !Ó$Ð$á+/Õ0ª4™Z˜Q 1 a�a“&©4ˆÒ0Ü�Z‰ZˆØ��b˜"�ˆˆÜ˜fÖ%‰DˆAˆqØ�b�S˜"�I‹~ä$-¨d¦O‘L�A‘y˜˜aØ˜B•wØ"#¨ '˜˜Q›ñ %4ñ Ü�D“	˜A‘ˆAÜ )¬(°4«.Ö 9‘�‘9�A˜!Ø˜•7Ø˜A™�AÜ%*¨1¨q¨f°aÓ%8�D˜˜A ™E’Nó !:ñ &ñ *.Õ8ª™g˜a A°±“	��q“	©ˆÒ8ô Ñ-©Ó-×-Ñ-Ø�K‰K˜"˜˜b¤)¨RÐ0Ô1ð ˆØˆÛ‰GˆA�!Ù˜T !™W R™[¨!Ñ6¨vÑ6ˆDØ‰{Ø‘à—h‘h˜q !“n�Ø×'Ñ'¨¨1¨aÓ0�Ø—7’7œHÖ%¨¯ª´Ö)9Ø‘Cà˜1‘H�Cð ”A—J‘JŠØ‘Ø—‘˜4 ™7 2™;Ñ'×,Ñ,×1Ñ1°!°QÓ7¸5Ó@Ø˜A™‘à˜Q™�Ø�K‰K˜˜d˜Ö$ñ' ô( ˜$ÐÐùô[ 1ùô 9s   ÁI'Ä(I.Ä8I.c           	      ó–	  >^ ^^^• Ub  Uc  [         T T ]  XU5      $ [        [        XU45      u  mmmU(       Gaí  UUU U4S jnT R	                  TU5      nUb  U$ TT:  [
        R                  L d&  T[
        R                  L d  T[
        R                  L aX  T R                  TTTSS9n[        U[        5      (       a,  [        UR                   VV	s/ s H
  u  p‰U* U	4PM     sn	n6 nU$ U* nU$ TT:  [
        R                  L d&  T[
        R                  L d  T[
        R                  L a  GOû[        S5      n
[        S5      nTR                  (       a  TOU
nTR                  (       a  TOUnT R                  TX#SS9nX*:X  a0  X;:X  a+  UR                  U
TUT05      * UR                  U
TUT05      pÍO'T R                  TTTSS9* UR                  U
TUT05      pÍ[        SSS	9nTR                   (       aU  UR                  TTU-
  05      R                  UTT-
  05      nUR                  TTU-   05      R                  UTT-
  05      nOeTR                   (       aT  UR                  TTU-   05      R                  UTT-
  05      nUR                  TTU-
  05      R                  UTT-
  05      nS
 nU" U5      nU" U5      nX*:X  a  [        UTT:  4US45      nO[        UTT:  4US45      nU["        :X  a  [%        S5      e['        S XÍ4 5       5      (       a  [)        U5      nU$ T R+                  T5      u  nnU(       d!  SSKJn  U" T R1                  T5      TTT45      $ U VVVs/ s H
  u  p#  nX#4PM     nnnnTTS4/n[
        R                  n[3        U5       H‹  u  nnUSS U* U4:X  a)  [3        U5       H  u  nu  p#nUS:X  d  M  X#U4UU'   M       OT[5        U5      S-
  n[3        [7        U5      5       H*  u  nu  p#nUS:X  d  M  UU-
  n[9        XâU4U5      UUUS-   & M,     M�     U VVVs/ s H  u  p#nX#:w  d  M  X#U4PM     nnnn[
        R:                  nSnU HM  u  p#nUS:X  a$  Uc  ["        s  $ [        UTU:*  4["        S45      s  $ UUU   S   R                  TX#5      -  nUnMO     U$ s  sn	nf s  snnnf s  snnnf )z?Evaluates the function along the sym in a given interval [a, b]Nc                 ó„   >• [        U TR                  5      (       a  U R                  TTTS S9$ U R                  TTT5      $ )N©rË   )r/   rN   rÜ   )rÍ   ÚhiÚlor?   r‰   s    €€€€r8   r»   Ú)Piecewise._eval_interval.<locals>.handlerÕ  sC   ø€ Ü˜c 4§9¡9×-Ñ-Ø×-Ñ-¨a°°RÀÐ-ÐEÐEà×-Ñ-¨a°°RÓ8Ð8r:   Frì   rî   rí   Ú T)Úpositivec                 ó*   • U R                  S S 5      $ )Nc                 ó.   • [        U [        [        45      $ rF   )r/   r   r   ©r‰   s    r8   Ú<lambda>Ú<Piecewise._eval_interval.<locals>.<lambda>.<locals>.<lambda>  s   € œj¨¬S´#¨JÔ7r:   c                 ó4   • U R                   " U R                  6 $ rF   ©rN   r=   rô   s    r8   rõ   rö     s   € ˜aŸfšf a§f¡f™or:   )Úreplace©rà   s    r8   rõ   Ú*Piecewise._eval_interval.<locals>.<lambda>  s   €  !§)¡)Ù7Ù-ô#/r:   z(Can't integrate across undefined region.c              3   óB   #   • U  H  n[        U[        5      v •  M     g 7frF   )r/   r1   )rm   rÁ   s     r8   ro   Ú+Piecewise._eval_interval.<locals>.<genexpr>  s   é € ÐDº°A”z !¤Y×/Ð/ºùs   ‚r   rÏ   rk   é   rC   rÔ   )ÚsuperrÜ   Úmapr	   rÇ   r   r   r×   ÚNegativeInfinityr/   r1   r=   r   r   Úis_comparabler¹   Ú	is_Symbolrq   ru   rÛ   r2   rÖ   rÕ   rÐ   r   rØ   r_   rÙ   rÚ   ÚZero)!r?   ÚsymrQ   rn   rË   r»   rÝ   Úrvr   r€   Ú_aÚ_bÚposÚnegrä   ÚtouchrÞ   rß   rÐ   rà   rá   rã   râ   rÆ   rå   rÁ   ræ   rç   Úuptorí   rî   r‰   Ú	__class__s!   `                            @@@€r8   rÜ   ÚPiecewise._eval_intervalÆ  sð  ü€ ð ‰9˜™	ä‘7Ñ)¨#°!Ó4Ð4äœH s¨q kÓ2‰IˆAˆr�2ç÷9ð 9ð
 ×#Ñ# A wÓ/ˆCØ‰Ø�
à�R‘œAŸG™GÒ#Øœ!Ÿ*™*Ò$¨¬a×.@Ñ.@Ò(@Ø×(Ñ(¨¨B°¸5Ð(ÐA�Ü˜b¤)×,Ñ,Ü"¸¿ºÔ$Aº±° q b¨!£W¹Ò$AÐB�Bð �	ð ˜�BØ�	à�R‘œAŸF™FÒ"Øœ!Ÿ*™*Ò$¨¬a×.@Ñ.@Ò(@Ùä˜4“[�Ü˜4“[�Ø×*×*‘B°�Ø×*×*‘B°�Ø×)Ñ)¨!¨Q¸%Ð)Ð@�Ø“7˜q›wð "%§¡¨r°2°r¸2Ð.>Ó!?Ð ?ØŸ™ b¨"¨b°"Ð%5Ó6ñ ð "&×!4Ñ!4°Q¸¸BÀuÐ!4Ð!MÐ MØŸ™ b¨"¨b°"Ð%5Ó6ð ô ˜" tÑ,�Ø—<—<ØŸ,™,¨¨B°©F |Ó4×=Ñ=¸qÀ"ÀrÁ'¸lÓK�CØŸ,™,¨¨B°©F |Ó4×=Ñ=¸qÀ"ÀrÁ'¸lÓK‘CØ—\—\ØŸ,™,¨¨B°©F |Ó4×=Ñ=¸qÀ"ÀrÁ'¸lÓK�CØŸ,™,¨¨B°©F |Ó4×=Ñ=¸qÀ"ÀrÁ'¸lÓK�Cñ/�ñ ˜C“j�Ù˜C“j�ð “7Ü"ØØ ™Gð%àØ ð"ó#‘Bô #ØØ ™Gð%àØ ð"ó#�Bð œ“?Ü$Ð%OÓPÐPÜÑD¸#¹ÓD×DÑDÜ'¨Ó+�BØ�	ð —?‘? 1Ó%‰ˆˆDÞÝ:ñ ˜DŸI™I a›L¨1¨b°"¨+Ó6Ð6á+/Õ0ª4™Z˜Q 1 a�1“&©4ˆÒ0Ø�R˜�ˆ~ˆÜ�Z‰ZˆÜ˜fÖ%‰DˆAˆqØ��!ˆu˜"˜˜b˜	Ó!ä$-¨d¦O‘L�A‘y˜˜aØ˜B•wØ"#¨ '˜˜Q›ñ %4ñ Ü�D“	˜A‘ˆAÜ )¬(°4«.Ö 9‘�‘9�A˜!Ø˜•7Ø˜A™�AÜ%*¨1°!¨f°aÓ%8�D˜˜A ™E’Nó !:ñ &ñ *.Õ8ª™g˜a A°±“	��q“	©ˆÒ8ô �f‰fˆØˆÛ‰GˆA�!Ø�B‹wØ‘<Ü$Ò$ä  # r¨T¡zÐ!2´YÀÐ4EÓFÒFØ�4˜‘7˜2‘;×-Ñ-¨a°Ó6Ñ6ˆCØŠDñ ð ˆ
ùóI %BùôP 1ùô 9s   ÃR7
Í)R=Ð4SÑSc                 ó°
  ^^^• SSK Jm  [        U [        5      (       d   eU4S jmUUU4S jn[	        U R
                  5      nU R                  [        5      n0 nU H  nU" U5      u  p‰US:w  a  SU4s  $ X–U'   M     U R
                   V
s/ s H  oªR                  U5      PM     nn
/ nS=pÍ[        U5       GH'  u  n
u  pïU[        R                  L a  M  U[        R                  L a  UnU
n  Oõ[        U[        5      (       a  U(       a	  SSU-  4s  $ M^  [        U5      n[        U[        5      (       a  [!        U5      n[        U["        5      (       aG  UR%                  UR
                   Vs/ s H  n[        U[        5      (       a  M  X®U4PM      sn5        Må  U[        R                  La  UR'                  X®U45        GM  U[        R                  L d  GM$  UnU
n  O   / nU GH  u  npï[        U[        5      (       Ga  [        R(                  n[        R*                  n/ nUR
                   Hú  n[        U[        5      (       d      g	[        U[        5      (       a  UnU(       a      g
  OÀ[        U[,        5      (       aM  UR
                  u  nnUT:X  a  UR'                  U5        O$UT:X  a  UR'                  U5        OT" U5      s  s  $ M   UR.                  T:X  a  [1        UR2                  U5      nMÈ  UR2                  T:X  a  [5        UR.                  U5      nMð  T" U5      s  s  $    U(       aç  [	        [7        U5      5      n/ n[        U5       HZ  u  n
nUUs=:  a  S:X  d  O  UUs=:”  a  S:X  a  O  OM'  U(       d  UR'                  SU45        UR'                  US   S   U45        M\     UR'                  US   S   U45        UR9                  S5        UR%                  U V
s/ s H  n
UU[        U
S   T:  TU
S   :  5      4PM      sn
5        GM7  O’[        U[        5      (       at  UR:                  S:w  ad  UR.                  UR2                  nnUR.                  T:X  a  [        R(                  nO4UR2                  T:X  a  [        R*                  nOT" U5      s  $ SSU-  4s  $ [5        UU5      nU(       a  UU:X  a    gUU:¬  [        R                  Ld  GMþ  UR'                  UUUU45        GM     Ub0  UR'                  [        R(                  [        R*                  XÍ45        S[	        [=        U5      5      4$ s  sn
f s  snf s  sn
f )aï  Return a bool and a message (when bool is False), else a
list of unique tuples, (a, b, e, i), where a and b
are the lower and upper bounds in which the expression e of
argument i in self is defined and $a < b$ (when involving
numbers) or $a \le b$ when involving symbols.

If there are any relationals not involving sym, or any
relational cannot be solved for sym, the bool will be False
a message be given as the second return value. The calling
routine should have removed such relationals before calling
this routine.

The evaluated conditions will be returned as ranges.
Discontinuous ranges will be returned separately with
identical expressions. The first condition that evaluates to
True will be returned as the last tuple with a, b = -oo, oo.
r   )r±   c                 ó.   >• S[        ST< SU < 35      4$ )NFz;
                A condition not involving
                z appeared: )r'   )r7   r  s    €r8   Ú
nonsymfailÚ(Piecewise._intervals.<locals>.nonsymfail^  s!   ø€ Ø�*ã&)ª4ð&1ó 2ð 2ð 2r:   c                 ó¶  >• TU R                   ;  a  T" U 5      $  T" U T5      n[        U[        5      (       a£  UR                  S   R                   nUR                  S   T:w  d  TU;   a  SSU < ST< S34$ UR
                  S:X  a  [        R                  nS	U4$ UR
                  S:X  a+   [        TUR                  :  TUR                  :„  5      nS	U4$  S	U4$ U[        R                  T:  T[        R                  :  -  :X  a  [        R                  nS	U4$ ! [         a    SSU < ST< S34s $ f = f! [         a    [        R                  n S	U4$ f = f)
NFzUnable to solve relational z for Ú.rC   r   z==ú!=T)rµ   r¸   r/   r   r=   Úrel_opr   r   r   Úrhsr4   r   r  r×   )rh   r  rÃ   r±   r  r  s      €€€r8   Ú_solve_relationalÚ/Piecewise._intervals.<locals>._solve_relationalc  s\  ø€ Ø˜!Ÿ.™.Ó(Ù! !“}Ð$ðQÙ& q¨#Ó.�ô ˜"œj×)Ñ)Ø—w‘w˜q‘z×.Ñ.�Ø—7‘7˜1‘: Ó$¨¨t«Ù ËQÓPSÐ"TÐTÐTØ—9‘9 Ó$ô Ÿ™�Bð ˜�8ˆOð —Y‘Y $Ó&ð$Ü  b§f¡f¡¨c°B·F±F©lÓ;˜ð ˜�8ˆOð 'ð ˜�8ˆOð œ×*Ñ*¨SÑ0°S¼1¿:¹:Ñ5EÑFÓFÜ—V‘V�Ø˜�8ˆOøô+ 'ó QÙËËCÐPÐPÒPðQûô  %ó $äŸV™V™ð ˜�8ˆOð$ús#   ›	D Â-&D8 ÄD5Ä4D5Ä8EÅETFNzencountered Eq condition: %s)Fzexpecting only Relationals)Fz"encountered secondary Eq conditionrk   rC   r  zunrecognized condition: %s)Fzencountered Eq condition)r·   r±   r/   r1   r´   r=   r³   r   r¹   rØ   r   r   r   r   r"   r   r#   r   Úextendra   r  r×   r   Últsr   Úgtsr   r   rb   r  r$   )r?   r  Ú	err_on_Eqr  r=   ÚkeysrÀ   rh   rÞ   ÚsrÁ   Ú	expr_condÚdefaultÚidefaultr6   r7   ÚoÚint_exprÚiargÚlowerÚupperÚexcludeÚcond2ÚlÚnewcondr   r±   r  s    `                        @@r8   rÖ   ÚPiecewise._intervalsH  sŽ  ú€ õ$ 	Aä˜$¤	×*Ñ*Ð*Ð*õ	2÷
	ô8 �D—I‘I‹ˆà�z‰zœ*Ó%ˆØˆÛˆAÙ% aÓ(‰EˆBØ�T‹zØ˜b�yÒ Ø�‹Gñ	 ð +/¯)ª)Ó4ª) Q—
‘
˜4Ö ©)ˆÐ4ð ˆ	Ø!Ð!ˆÜ(¨Ÿ‰OˆA‰|�Ø”q—w‘wŠÙØ”q—v‘vŠ~Ø�Ø�ÙÜ˜$¤×#Ñ#ö Ø Ð"@À4Ñ"GÐGÒGÙä˜$“<ˆDÜ˜$¤×$Ñ$Ü-¨dÓ3�ä˜$¤×#Ñ#Ø× Ñ Ø+/¯9ª9ó .ª9 aÜ% a¬×,ó "�a˜q“\©9ñ .ö/ð œQŸW™WÒ$Ø× Ñ  !¨4 ×1ØœŸ™•Ø�Ø�Ùñ7  /ð< ˆÜ )ÑˆD�$Ü˜$¤×$Ò$Ü×*Ñ*�ÜŸ
™
�Ø�Ø!ŸYœY�EÜ% e¬Z×8Ñ8ÚBÜ! %¬×,Ñ,Ø %˜Þ$Ú#NÙÜ# E¬2×.Ñ.Ø$Ÿz™z™˜˜1Ø ›8Ø#ŸN™N¨1Õ-Ø #›XØ#ŸN™N¨1Õ-á#-¨eÓ#4Ô4Ù ØŸ™ cÓ)Ü # E§I¡I¨uÓ 5šØŸ™ cÓ)Ü # E§I¡I¨uÓ 5šá)¨%Ó0Ô0ñ- 'ö. Ü"¤7¨7Ó#3Ó4�GØ �GÜ )¨'Ö 2™˜˜1Ø˜uÕ,¨Õ,°°EÕ0A¸TÖ0AÙ$Þ&Ø#ŸN™N¨D°%¨=Ô9ØŸ™¨°©°A©¸Ð':Ö;ñ !3ð —N‘N G¨B¡K°¡N°EÐ#:Ô;Ø—K‘K ”NØ×$Ñ$ÑY`Ó%aÒY`ÐTU t¨T´3°q¸±t¸c±zÀ3ÈÈ1ÉÁ:Ó3NÓ&OÑY`Ñ%aÔbÚð ô ˜D¤*×-Ñ-°$·+±+ÀÓ2EØ#Ÿx™x¨¯©�u�Ø—8‘8˜s“?Ü×.Ñ.‘EØ—X‘X “_ÜŸJ™J‘Eá% dÓ+Ò+àÐ:¸TÑAÐAÒAä˜˜uÓ%ˆEÞ˜U e›^Ù8Ø˜‘¤q§v¡vÕ-Ø—‘ ¨¨t°TÐ :×;ñq !*ðt ÑØ�O‰OÜ×#Ñ#¤Q§Z¡Z°ÐCôEð ”Tœ$˜x›.Ó)Ð)Ð)ùòE 5ùò2.ùòd &bs   ÂU	Å/U
ÆU
Ï0%U
c                 ó¬   • U R                    Vs/ s H*  oUR                  R                  XU5      UR                  4PM,     nnU R                  " U6 $ s  snf rF   )r=   r6   Ú_eval_nseriesr7   rN   )r?   r‰   ÚnrŠ   r‹   rf   r=   s          r8   r.  ÚPiecewise._eval_nseriesî  sG   € ØGKÇyÂyÓQÂyÀ—‘×&Ñ& q¨TÓ2°B·G±GÓ<ÁyˆÐQØ�yŠy˜$ÐÐùò Rs   �1Ac                 ór   • U R                   " U R                   VVs/ s H  u  p#X!-  U4PM     snn6 $ s  snnf rF   rø   )r?   r  r   r€   s       r8   Ú_eval_powerÚPiecewise._eval_powerò  s/   € Ø�yŠy°·²Ô;²©¨˜A™D !›9±Ò;Ð<Ð<ùÓ;s   œ3
c                 ó
  • [        U R                  5      nSn[        U5       H?  u  nu  pgUR                  X5      nUS:w  a  SnUR                  X5      nXg4X5'   US:X  d  M?    O   U(       d	  [        S44nU R
                  " U6 $ )NFT)r´   r=   rØ   Ú_subsrq   rN   )r?   ÚoldÚnewr=   Ú
args_existrÁ   r   r€   s           r8   Ú
_eval_subsÚPiecewise._eval_subsõ  s†   € ô �D—I‘I‹ˆØˆ
Ü" 4ž‰IˆA‰v�Ø—‘˜Ó!ˆAØ�E‹zØ!�
Ø—G‘G˜CÓ%�Ø�fˆD‰GØ�D�yÙñ )ö Ü Ð%Ð'ˆDØ�yŠy˜$ÐÐr:   c                 óŠ   • U R                   " U R                   VVs/ s H  u  pUR                  5       U4PM     snn6 $ s  snnf rF   )rN   r=   Ú	transposer�   s      r8   Ú_eval_transposeÚPiecewise._eval_transpose	  r˜   r“   c                 ón   • S nU R                    H"  u  p4[        X15      nUc    g Uc  UnM  X%Ld  M"    g    U$ rF   )r=   r`   )r?   Úis_attrrn   r6   rà   rQ   s         r8   Ú_eval_template_is_attrÚ Piecewise._eval_template_is_attr  sB   € ØˆØ—y”y‰GˆDÜ˜Ó&ˆAØ‰yÙØ‰yØ’Ø”Ùñ !ð ˆr:   c                 ó$   • U R                  S5      $ )NÚ	is_finite©rA  r>   s    r8   rõ   ÚPiecewise.<lambda>  s   €  4×#>Ñ#>Øô$r:   c                 ó$   • U R                  S5      $ )NÚ
is_complexrE  r>   s    r8   rõ   rF    ó   €  D×$?Ñ$?ÀÔ$Mr:   c                 ó$   • U R                  S5      $ )NÚis_evenrE  r>   s    r8   rõ   rF    ó   €  ×!<Ñ!<¸YÔ!Gr:   c                 ó$   • U R                  S5      $ )NÚis_imaginaryrE  r>   s    r8   rõ   rF    s   €  d×&AÑ&AØô'r:   c                 ó$   • U R                  S5      $ )NÚ
is_integerrE  r>   s    r8   rõ   rF    rI  r:   c                 ó$   • U R                  S5      $ )NÚis_irrationalrE  r>   s    r8   rõ   rF    s   €  t×'BÑ'BØô(r:   c                 ó$   • U R                  S5      $ )NÚis_negativerE  r>   s    r8   rõ   rF  !  ó   €  T×%@Ñ%@ÀÔ%Or:   c                 ó$   • U R                  S5      $ )NÚis_nonnegativerE  r>   s    r8   rõ   rF  "  ó   € ¨×(CÑ(CØô)r:   c                 ó$   • U R                  S5      $ )NÚis_nonpositiverE  r>   s    r8   rõ   rF  $  rX  r:   c                 ó$   • U R                  S5      $ )NÚ
is_nonzerorE  r>   s    r8   rõ   rF  &  s   €  D×$?Ñ$?Øô%r:   c                 ó$   • U R                  S5      $ )NÚis_oddrE  r>   s    r8   rõ   rF  (  s   €  × ;Ñ ;¸HÔ Er:   c                 ó$   • U R                  S5      $ )NÚis_polarrE  r>   s    r8   rõ   rF  )  s   €  $×"=Ñ"=¸jÔ"Ir:   c                 ó$   • U R                  S5      $ )NÚis_positiverE  r>   s    r8   rõ   rF  *  rU  r:   c                 ó$   • U R                  S5      $ )NÚis_extended_realrE  r>   s    r8   rõ   rF  +  s   € ¨$×*EÑ*EØô+ r:   c                 ó$   • U R                  S5      $ )NÚis_extended_positiverE  r>   s    r8   rõ   rF  -  ó   € ¨d×.IÑ.IØ"ô/$r:   c                 ó$   • U R                  S5      $ )NÚis_extended_negativerE  r>   s    r8   rõ   rF  /  rg  r:   c                 ó$   • U R                  S5      $ )NÚis_extended_nonzerorE  r>   s    r8   rõ   rF  1  s   € ¨T×-HÑ-HØ!ô.#r:   c                 ó$   • U R                  S5      $ )NÚis_extended_nonpositiverE  r>   s    r8   rõ   rF  3  ó   € °×1LÑ1LØ%ô2'r:   c                 ó$   • U R                  S5      $ )NÚis_extended_nonnegativerE  r>   s    r8   rõ   rF  5  rn  r:   c                 ó$   • U R                  S5      $ )Nr¢   rE  r>   s    r8   rõ   rF  7  rL  r:   c                 ó$   • U R                  S5      $ )NÚis_zerorE  r>   s    r8   rõ   rF  8  s   €  ×!<Ñ!<Øô"r:   c                 óÌ   • US:X  a  g[        U[        5      (       a8   UR                  UR                  -
  nUR                  (       a  UR
                  $ gg! [         a     gf = f)z(Return the truth value of the condition.TN)r/   r   Úlhsr  rG   rs  r4   )r5   r7   r   s      r8   Ú__eval_condÚPiecewise.__eval_cond;  sc   € ð �4‹<ØÜ�dœB×ÑðØ—x‘x $§(¡(Ñ*�Ø×&×&ØŸ<™<Ð'ð 'ð  øô
 ó Ùðús   ž5A Á
A#Á"A#c                 óV  • Uc  [         R                  n/ nUnUR                  [         R                  5      (       + n[        5       nU R                   HÓ  u  pgXWR
                  -  n[        U5      S:”  a  [        [        S5      5      eU(       aK  UR                  [        5       H2  n[        U[        [        45      (       a  M   [        [        S5      5      e   UR                  UR!                  5       5      n	X9-
  nU	[         R"                  :w  d  MÁ  UR%                  Xi45        MÕ     U$ )a¨  Return tuples for each argument of self that give
the expression and the interval in which it is valid
which is contained within the given domain.
If a condition cannot be converted to a set, an error
will be raised. The variable of the conditions is
assumed to be real; sets of real values are returned.

Examples
========

>>> from sympy import Piecewise, Interval
>>> from sympy.abc import x
>>> p = Piecewise(
...     (1, x < 2),
...     (2,(x > 0) & (x < 4)),
...     (3, True))
>>> p.as_expr_set_pairs()
[(1, Interval.open(-oo, 2)),
 (2, Interval.Ropen(2, 4)),
 (3, Interval(4, oo))]
>>> p.as_expr_set_pairs(Interval(0, 3))
[(1, Interval.Ropen(0, 2)),
 (2, Interval(2, 3))]
rC   z=
                    multivariate conditions are not handled.z¸
                            Inequalities in the complex domain are
                            not supported. Try the real domain by
                            setting domain=S.Reals)r   ÚRealsÚ	is_subsetÚsetr=   rµ   r_   r¸   r'   r³   r   r/   r   r   ru   Ú	intersectr¤   ÚEmptySetra   )
r?   ÚdomainÚexp_setsÚUÚcomplexÚ	cond_freer6   r7   rÁ   Úcond_ints
             r8   Úas_expr_set_pairsÚPiecewise.as_expr_set_pairsH  s   € ð2 ‰>Ü—W‘WˆFØˆØˆØ×&Ñ&¤q§w¡wÓ/Ô/ˆÜ“Eˆ	ØŸ)œ)‰JˆDØ×*Ñ*Ñ*ˆIÜ�9‹~ Ó!Ü)¬*ð 6@ó +Aó Bð BæØŸ™¤JÖ/�AÜ% a¬"¬b¨×2Ó2Ü(¬ð 56ó *7ó 8ð 8ñ 0ð —{‘{ 4§;¡;£=Ó1ˆHØ‘ˆAØœ1Ÿ:™:Õ%Ø—‘ Ð 0Ö1ñ $ð  ˆr:   c           	      ó�  • 0 n[        U5      n[        S U 5       5      n[        U5       GH  u  nu  pg[        U[        5      (       d&  US:w  a   [        [        S[        U5      -  5      5      eUS:X  a    OÔ[        U[        5      (       a  UR                  OU/ HŸ  nUR                  nUR                  5       n	 UR                  U	[        R                  5      R                  UR!                  5       5      X9'   X9   [        R$                  [        R&                  4;   d  M‡  [        X   5      X'   S=oqU   S'     O   US:X  d  GM    O   WS:w  a  [)        [        S5      5      eUW   u  p«[+        US U 5       H  u  pÇ[-        X|U
5      n
M     [/        U
5      $ ! ["         a!    U(       d  [#        [        SU-  5      5      e NÊf = f)Nc              3   ó0   #   • U  H  u  pUS :H  v •  M     g7f)TNrM   )rm   rn   r€   s      r8   ro   Ú1Piecewise._eval_rewrite_as_ITE.<locals>.<genexpr>|  s   é € Ð1ªD¡D A�a˜4–iªDùrÓ   TzP
                    Expecting Boolean or bool but got `%s`
                    aÚ  
                            A method to determine whether a multivariate
                            conditional is consistent with a complete coverage
                            of all variables has not been implemented so the
                            rewrite is being stopped after encountering `%s`.
                            This error would not occur if a default expression
                            like `(foo, True)` were given.
                            rC   z‹
                Conditions must cover all reals or a final default
                condition `(foo, True)` must be given.
                )r´   rÛ   rØ   r/   r   r4   r'   r(   r   r=   rµ   rb   rº   r   r}  Úunionr¤   r¸   ÚUniversalSetry  ru   rÙ   r    r   )r?   r=   rP   Úbyfreer!  rÁ   rn   r€   rÃ   r‰   Úlastrà   rQ   s                r8   Ú_eval_rewrite_as_ITEÚPiecewise._eval_rewrite_as_ITEy  s½  € ØˆÜ�D‹zˆÜÑ1©DÓ1Ó1ˆÜ" 4Ÿ‰IˆA‰v�Ü˜a¤×)Ñ)¨a°4«iÜ¤
ð ,ä# A›,ñ,'ó !(ó )ð )ð �D‹yÙä)¨!¬R×0Ñ0�Q—V’V°q°cÒ9�Ø—~‘~�Ø—H‘H“J�ð&Ø &× 1Ñ 1Øœ1Ÿ:™:ó!'ß',¡u¨Q¯X©X«ZÓ'8ð ‘Ið ‘9¤§¡´·±Ð 9Õ9ä" 4¡7›m�D‘GØ%)Ð)�A˜Q™ ™
Ùñ) :ð* �DŽyÙñ= )ð> �‹9ÜœZð )ó ó ð ð �q‘'‰ˆÜ˜T " 1˜XÖ&‰DˆAÜ�q˜T“?ŠDñ 'ä˜$ÓÐøô3 +ó 	&Þ"Ü1´*ð > ð #$ñ>$ó 3%ó &ð &ñ #ð	&ús   Â;?FÆ(GÇGc                 ó®  ^	^
^^• SSK Jm	  [        SS/[        SS/[        SS/[
        S S /[        S S /0m " S S[        5      m
U	U
UU4S jm/ nS nU HD  u  pV[        U5      T;   a  UR                  XV45        M(  U[        R                  L a	  Uc  UnMB  MD    g    Ub+  UnUS S S2    H  u  pV T" U5      nX…-  S	U-
  U-  -   nM     U$ g ! T
 a       g f = f)
Nr   )ÚKroneckerDeltaFTc                   ó   • \ rS rSrSrg)ÚHPiecewise._eval_rewrite_as_KroneckerDelta.<locals>.UnrecognizedConditioni±  rM   N)rT   rU   rV   rW   rZ   rM   r:   r8   ÚUnrecognizedConditionr’  ±  s   † Úr:   r“  c           	      ó°  >• [        U [        5      (       a  T" U R                  6 $ [        U [        5      (       a  ST" U R                  6 -
  $ [	        U 5      U R                  p!UT
;  a  T" U5      eT
U   u  p4U(       a"  [        U Vs/ s H  nST	" U5      -
  PM     sn6 O[        U Vs/ s H  nT	" U5      PM     sn6 nU(       a  SU-
  $ U$ s  snf s  snf )NrC   )r/   r   r=   r   Útyper   )r7   r5   r=   Úb1Úb2r€   rÆ   r�  r“  r3   Úruless          €€€€r8   r3   Ú:Piecewise._eval_rewrite_as_KroneckerDelta.<locals>.rewrite´  sÇ   ø€ Ü˜$¤×#Ñ#Ù% t§y¡yÐ1Ð1Ü˜$¤×#Ñ#Ø™>¨4¯9©9Ð5Ñ5Ð5ä˜T›
 D§I¡I�Ø˜%ÓÙ+¨CÓ0Ð0à˜3‘Z‰FˆBÞ8:”©dÓ3ªd¨�a™' !›*”n©dÑ3Ñ4ÄÑZ^ÓE_ÒZ^ÐUVÁgÈaÆjÑZ^ÑE_Ð@`ˆAæØ˜1‘u�ØˆHùò	 4ùÒE_s   ÂCÂ*Crk   rC   )Ú(sympy.functions.special.tensor_functionsr�  r   r   r   r   r   Ú	Exceptionr•  ra   r   r   )r?   r=   rP   Ú
conditionsÚ
true_valueÚvaluer7   ÚresultrÆ   r�  r“  r3   r˜  s            @@@@r8   Ú_eval_rewrite_as_KroneckerDeltaÚ)Piecewise._eval_rewrite_as_KroneckerDelta¦  s  û€ ÝKô �%˜�Ü��t�Ü�$˜�Ü��t�Ü��t�ð
ˆô	¤Iô 	÷	ð 	ð" ˆ
Øˆ
Û‰KˆEÜ�D‹z˜UÓ"Ø×!Ñ! 5 -Ö0ØœŸ™’ØÑ%Ø!&’Jñ &ñ ñ  ð Ñ!ØˆFà)©$¨B¨$Ô/‘�ðÙ ›�AØ™Y¨!¨a©%°6Ñ)9Ñ9’Fñ  0ð ˆMð "øð -ó Úðús   Â.C
Ã
CÃCrM   ©T)F)r   rF   )7rT   rU   rV   rW   rX   ÚnargsÚis_Piecewiser.   Úclassmethodrc   r}   rR   rŒ   r‘   r–   rš   rŸ   r¦   r¬   rÇ   rÌ   rÜ   rÖ   r.  r2  r9  r=  rA  Ú_eval_is_finiteÚ_eval_is_complexÚ_eval_is_evenÚ_eval_is_imaginaryÚ_eval_is_integerÚ_eval_is_irrationalÚ_eval_is_negativeÚ_eval_is_nonnegativeÚ_eval_is_nonpositiveÚ_eval_is_nonzeroÚ_eval_is_oddÚ_eval_is_polarÚ_eval_is_positiveÚ_eval_is_extended_realÚ_eval_is_extended_positiveÚ_eval_is_extended_negativeÚ_eval_is_extended_nonzeroÚ_eval_is_extended_nonpositiveÚ_eval_is_extended_nonnegativeÚ_eval_is_realÚ_eval_is_zeroÚ_Piecewise__eval_condr„  r�  r   rZ   Ú__classcell__)r  s   @r8   r1   r1   A   sT  ø† ñ<ð| €EØ€Lò7ð2 ñ/!ó ð/!òb#ò 2ò,ò
DòFòCòGò4ò&#RòJA$ôFW ÷r@ôDd*ôL ò=ò ò(Fò
ñ€OáMÐÙG€MñÐáMÐñÐáOÐñÐñÐñÐáE€LÙI€NÙOÐñ Ðñ"$Ðñ"$Ðñ!#Ðñ%'Ð!ñ%'Ð!áG€Mñ€Mð ñ
ó ð
ô/òb+ ÷Z4ð 4r:   r1   Tc                 óö	  • [        U [        5      (       a  U R                  [        5      (       d  U $ / n[        U [        [        45      (       aï  U R
                   HÝ  u  p4[        U[        5      (       d  [        U5      nUR                  [        5      (       a   e[        U[        5      (       a  UR                  5       n[        USS9n[        U[        5      (       aF  UR                  UR
                   VVs/ s H  u  pV[        U5      [        Xd5      4PM     snn5        MË  UR                  X445        Mß     GO¤U R                  (       d$  U R                  (       Gaä  U R                  (       GaÒ  [!        U R
                  S SS9u  px[!        US 5      n	[#        [%        U	5      5       GH“  n['        X”   5      S:”  Gaj  X”    V
s/ s H  n
[#        U
R
                  5      PM     nn
[)        U VV
s/ s H  oÌ V
s/ s H  oªR*                  PM     sn
PM      sn
n6 n['        U5      n/ n[-        U5       HC  n
UR                  U R.                  " U Vs/ s H  nUU
   R0                  PM     sn6 XÚ   45        ME     / nU Hd  nU['        U5      :X  a  M  UU   R*                  S:X  a   UR                  UU   R0                  5        MG  UR                  [        UUS S	S
065        Mf     U(       a   UR                  U R.                  " U6 S45        UR                  [        US	S
065        GM€  UR                  X”   5        GM–     OU R
                  n[#        [3        [        U5      5      n[5        U V
s/ s H-  n
[        U
[        5      (       a  U
R
                  OU
[6        4/PM/     sn
6  H3  n[9        U6 u  p4UR                  U R.                  " U6 [        U6 45        M5     UcV  [#        [;        [;        U5       VVs0 s H  u  p4XC_M	     snnR=                  5        VVs/ s H  u  pCX44PM
     snn5      5      n[        US	U06nUcO  ['        UR
                  5      S:X  a6  UR
                  S   R*                  S:X  a  UR
                  S   R0                  $ [?        S URA                  [        5       5       5      (       a  [        U5      $ U$ s  snnf s  sn
f s  sn
f s  sn
nf s  snf s  sn
f s  snnf s  snnf )a¡  
Takes an expression containing a piecewise function and returns the
expression in piecewise form. In addition, any ITE conditions are
rewritten in negation normal form and simplified.

The final Piecewise is evaluated (default) but if the raw form
is desired, send ``evaluate=False``; if trivial evaluation is
desired, send ``evaluate=None`` and duplicate conditions and
processing of True and False will be handled.

Examples
========

>>> from sympy import Piecewise, piecewise_fold, S
>>> from sympy.abc import x
>>> p = Piecewise((x, x < 1), (1, S(1) <= x))
>>> piecewise_fold(x*p)
Piecewise((x**2, x < 1), (x, True))

See Also
========

Piecewise
piecewise_exclusive
Úcnf)Úformc                 ó   • U R                   $ rF   )r¤  rô   s    r8   rõ   Ú piecewise_fold.<locals>.<lambda>  s   € °·²r:   T©Úbinaryc                 ób   • [        U R                   VVs/ s H  u  pUPM	     snn5      $ s  snnf rF   )Útupler=   )r‰   r   r€   s      r8   rõ   rÁ    s!   € ¤5°q·v²vÔ)>²v±°«!±vÒ)>Ô#?ùÓ)>s   •+
rC   Nr^   Fr   c              3   ó„   #   • U  H6  oR                     H#  o"R                  R                  [        5      v •  M%     M8     g 7frF   )r=   r6   r0   r1   )rm   rä   r  s      r8   ro   Ú!piecewise_fold.<locals>.<genexpr>G  s+   é € Ð
NÒ*= QÇvÅvÀ!�6‰6�:‰:”i× Ð ÁvÑ Ò*=ùs   ‚>A )!r/   r   r0   r1   r+   r=   r2   r    Úto_nnfr!   r  r   ra   Úis_AddÚis_MulrG   r%   r´   r   r_   r&   r7   ÚrangerN   r6   r   r)   r   rt   rÙ   ÚitemsrÛ   r³   )r6   r^   Únew_argsr   r€   ÚeiÚcirä   r=   ÚpcrÁ   Úpargsrå   Úcomr/  Ú	collectedÚaiÚremainsrQ   Úfoldedrf   r  s                         r8   r2   r2   Ý  s3  € ô4 �dœE×"Ñ"¨$¯(©(´9×*=Ñ*=Øˆà€HÜ�$œ¤yÐ1×2Ñ2Ø—I”I‰DˆAÜ˜a¤×+Ñ+Ü" 1Ó%�ð —u‘uœY×'Ñ'Ð'Ð'Ü˜!œS×!Ñ!Ø—H‘H“J�Ü" 1¨5Ñ1�Ü˜!œY×'Ñ'Ø—‘Ø"#§&¢&ô!*Ú"(™˜ô #1°Ó"4´c¸"³jÓ!AÙ"(ò!*ö +ð —‘  Ö'ó ð: �;�;˜$Ÿ+Ÿ+˜+¨$×*=×*=Ð*=Ü˜4Ÿ9™9Ñ&>ÀtÑL‰GˆAÜ�aÑ?Ó@ˆBÜœ' "›+×&�Ü�r‘u“: ”>Ø35²5Ó9²5¨aœT !§&¡&ž\±5�EÐ9ä'Ù5:ô*<Ú5:°¨Ó+ª AŸœ©Ô+±Uò*<ð =�Cä˜C›�AØ "�IÜ" 1žX˜Ø!×(Ñ(Ø ŸIšI¹UÓ'CºU°r¨¨1©¯
¬
¹UÑ'CÐDØ™Fð*$ö %ñ &ð !�GÛ"˜Ø¤ A£›;Ù$Ø˜Q™4Ÿ9™9¨Ó,Ø#ŸN™N¨1¨Q©4¯9©9Ö5à#ŸN™NÜ )¨1¨Q¨R¨5Ð A¸5Ñ AöCñ #ö Ø!×(Ñ(¨$¯)ª)°WÐ*=¸tÐ)DÔEØ—K‘K¤	¨9Ð E¸uÑ EÔFÚØ—‘˜B™E×"ò3 'ð6 —9‘9ˆDä”cœ.¨$Ó/Ó0ˆÜá'-ó/â'- !ô & a¬×3Ñ3�—’Ø”d�)�òÙ'-ñ/ó 0ˆBô ˜�8‰DˆAØ�O‰O˜TŸYšY¨˜]¬C°¨GÐ4Ö5ñ	0ð ÑäœÜ% hÔ/ô61Ú/‘T�QˆAŠDÑ/ò61ß16±³ð69ô ":ò 69©T¨Q 1£&ñ 69ò ":ó ;ó <ˆä	�HÐ	0 xÑ	0€BØÑœC §¡›L¨AÓ-°"·'±'¸!±*·/±/ÀTÓ2IØ�w‰w�q‰z�‰ÐÜ
Ñ
N¨"¯(©(´9Ô*=Ó
N×NÑNÜ˜bÓ!Ð!Ø€IùóE!*ùò. :ùò ,ùó*<ùò (Dùò(/ùó61ùó ":s<   Ã:"SÇSÇ3	SÇ<SÈSÉS%Í34S*Ï=S/Ð S5ÓSc                 ór  • Uu  p4U u  pV[        [        XS5      U5      [        [        Xc5      U5      pe[        X45      n/ nX5:w  a  UR                  X5S45        O XV:w  a  UR                  XVU45        O XF:w  a>  Xe:X  a#  U(       a  US   S   S:X  a  US   S   US4US'   U$ UR                  XdS45         U$  U$ )a¡  Return interval B as intervals that are covered by A (keyed
to k) and all other intervals of B not covered by A keyed to -1.

The reference point of each interval is the rhs; if the lhs is
greater than the rhs then an interval of zero width interval will
result, e.g. (4, 1) is treated like (1, 1).

Examples
========

>>> from sympy.functions.elementary.piecewise import _clip
>>> from sympy import Tuple
>>> A = Tuple(1, 3)
>>> B = Tuple(2, 4)
>>> _clip(A, B, 0)
[(2, 3, 0), (3, 4, -1)]

Interpretation: interval portion (2, 3) of interval (2, 4) is
covered by interval (1, 3) and is keyed to 0 as requested;
interval (3, 4) was not covered by (1, 3) and is keyed to -1.
rk   r   )r   r   ra   )ÚAÚBrÆ   rQ   rn   r€   Údrä   s           r8   rÚ   rÚ   L  sÈ   € ð, �D€AØ�D€AÜŒs�1‹y˜!Óœc¤# a£)¨QÓ/€qÜˆA‹	€AØ
€AØƒvØ	�‰�!˜�ÕàØƒvØ	�‰�!˜�ÕàØƒvØ‹6–a˜A˜b™E "™I¨›OØ�b‘E˜!‘H˜a �OˆAˆb‰Eð €Hð	 �H‰H�a˜B�ZÕ ð €Hð 	à€Hr:   c                 ó‚  • SSK Jn  U R                  S   R                  R                  nS n[        U5      S:X  Ga¨  U R                  [        5      (       Gd�  UR                  5       nU R                  USS9u  pgS nU(       Ga`  / n[        R                  n	SSKJn
  U GH  u  p¼pÞU R                  U   R                  nU" XõU5      nU" XõU5      nU
" X¼U(       + U(       + 5      nUU	-
  nU(       d  MT   UR                  nU" XõU5      nU(       a–  U(       a�  UR                   (       a"  UR                   (       a  [        R"                  nOèUR                   (       a  X¹;   a  X[:„  OX[:¬  nOÉUR                   (       a  X\:*  nO³X¹;   a  [%        Xµ:  X\:*  5      nO�[%        Xµ:*  X\:*  5      nOŒU(       a=  UR                   (       a  X\:  nOoX¹;   a  [%        Xµ:  X\:  5      nOY[%        Xµ:*  X\:  5      nOHU(       a'  UR                   (       a  X[:„  nO+[%        Xµ:  X\:*  5      nOX¹;   a  X\:  nO[%        Xµ:  X\:  5      nU	U-  n	U[        R&                  L a  U(       a  U	[        R&                  1-  n	U[        R(                  L a  U(       a  U	[        R(                  1-  n	UR+                  Xß45        GM	     [        R,                  R/                  U	5      (       d  UR+                  [0        S45        UcY  [3        U R                  5      n[5        [        U5      5       H,  nXN   u  pß[7        U[8        5      (       a	  U" U40 UD6nXß4XN'   M.     UR                  SS 5      n[5        [        U5      5       H6  nXN   u  pß[7        U[8        5      (       a  U" U4SS	0UD6nUU:w  a  UnXß4XN'   M8     Ub  UUS'   [;        U6 $ ! [         a     GNµf = f)
Nr   )rO   rC   T)r  c                 óL   •  U R                  X5      S:H  $ ! [         a     gf = f)z/return True if c.subs(x, a) is True, else FalseTF)r‡   r4   )r€   r‰   rQ   s      r8   ÚincludeÚ-piecewise_simplify_arguments.<locals>.include†  s,   € ðØ—v‘v˜a“| tÑ+Ð+øÜó Ùðús   ‚ –
#¢#)ÚIntervalr}   F)Úsympy.simplify.simplifyrO   r=   r7   rµ   r_   r³   r   rb   rÖ   r   r}  Úsympy.sets.setsrß  Úinfr¸   Úis_infiniter   r   r  r×   ra   ry  rz  rq   r´   rË  r/   r   r1   )r6   rP   rO   Úf1r=   r‰   rÞ   Úabe_rÝ  Úcoveredrß  rQ   rn   r   rÁ   r€   Úincl_aÚincl_bÚivÚcsetr}   r�   s                         r8   Úpiecewise_simplify_argumentsrë  z  s0  € Ý0ð 
�‰�1‰×	Ñ	×	'Ñ	'€BØ€DÜ
ˆ2ƒw�!„|˜DŸJ™J¤rŸNšNØ�F‰F‹Hˆð —?‘? 1°�?Ð5‰ˆò	÷ ØˆDÜ—j‘jˆGÝ0Ü"‘
��aØ—I‘I˜a‘L×%Ñ%�Ù   qÓ)�Ù   qÓ)�Ù˜a¨¤J°F´
Ó;�Ø˜G‘|�ÞÙð.ØŸ™�Añ % Q¨1Ó-�FÞžfØ—}—}¨¯¯ÜŸF™F™ØŸŸØ'(£|˜QšU¸!¹&™ØŸŸØ™V™Ø›Ü ¡ q¡vÓ.™ä ¡¨©Ó/™ÞØ—}—}Ø™U™Ø›Ü ¡ q¡uÓ-™ä ¡¨©Ó.™ÞØ—}—}Ø™U™ä ¡ q¡vÓ.™à“|Ø™U™ä ¡ q¡uÓ-˜Ø˜2‘�Øœ×*Ñ*Ò*®vØ¤× 2Ñ 2Ð3Ñ3�GØœŸ
™
’?¦vØ¤§
¡
˜|Ñ+�GØ—‘˜Q˜F×#ñ_ #ô` —7‘7×$Ñ$ W×-Ñ-Ø—‘œY¨Ð-Ô.Ø�|Ü�D—I‘I‹ˆÜ”s˜4“yÖ!ˆAØ‘G‰DˆAÜ˜!œU×#Ñ#Ù˜QÑ) &Ñ)�Ø�fˆD‹Gñ	 "ð �:‰:�f˜dÓ#€DÜ”3�t“9ÖˆØ‘‰ˆÜ�aœ×Ññ ˜AÑ4 EÐ4¨VÑ4ˆDØ�q‹yØ�Ø�&ˆ‹ñ ð ÑØˆˆv‰ä�dÐÐøôA +ó Úðús   Ã3N0Î0
N>Î=N>c                 ó  • / n[        5       nU  GHq  u  p4UR                  S [        5      n[        U[        5      (       a`  / n[        UR                  5       HE  u  nu  pxX‚;   a  M  X„:X  a  US:w  a  U(       a  [	        XWU4/-   6 nOUn  OUR                  Xx45        MG     Sn	U/[        U[        5      (       a  [        UR                  5      O/ -    H  nXb;   d  M
  Sn	  O   U	(       a  MÝ  [        U[        5      (       a–  / n
UR                   Ht  n[        U[        5      (       aK  UR                  R                  U;   a  M4  [        U[        [        45      (       a  UR                  U;   a  Sn  OdU
R                  U5        Mv     UR                   " U
6 nO?[        U[        5      (       a*  UR                  R                  U;   a  ["        R$                  nUR'                  U5        U(       ax  US   R(                  U:X  aO  [+        XAS   R,                  5      n[        U[        [*        45      (       a  [/        U5      n[1        X;5      US'   GMA  US   R,                  U:X  a  GMW  UR                  [1        X45      5        GMt     U$ )Nc                 ó   • U R                   $ rF   )r£   rú   s    r8   rõ   Ú/_piecewise_collapse_arguments.<locals>.<lambda>â  s   € �a—o’or:   TFrk   )r{  rù   r   r/   r1   rØ   r=   ra   r   r´   r   ÚnegatedÚ	canonicalr   r   ÚweakrN   r   r   Úaddr6   r   r7   r   r+   )rv   re   Úcurrent_condr6   r7   Ú
unmatchingrÁ   r   r€   ÚgotÚnonredundantÚorconds               r8   rr   rr   Ý  s6  € Ø€GÜ“5€LÜ‰
ˆØ�|‰|Ù%Ô'7ó9ˆô �dœI×&Ñ&ØˆJÜ& t§y¡yÖ1‘	�‘6�AØÓ$áØ“9Ø˜D“yö
 &Ü#,Ø *°!¨f¨XÑ 5ð$8™Dð $%˜DÙà×%Ñ% q fÖ-ñ# 2ð( ˆð �&Ü&0°´s×&;Ñ&;”4˜Ÿ	™	”?ØôˆAð Õ Ø�Ùñö Ùô �dœC× Ñ ØˆLØ—Y”Y�Ü˜a¤×,Ñ,Ø—y‘y×*Ñ*¨lÓ:Ù ô " !¤b¬" X×.Ñ.ØŸ™ ,Ó.Ø$˜ÙØ×#Ñ# AÖ&ñ ð —y’y ,Ð/‘Ü˜œj×)Ñ)Ø�|‰|×%Ñ%¨Ó5Ü—v‘v�à×Ñ˜Ôö Ø�r‰{×Ñ 4Ó'Ü˜D¨"¡+×"2Ñ"2Ó3�Ü˜f¤s¬B i×0Ñ0Ü3°FÓ;�FÜ*¨4Ó8�˜‘ÚØ˜‘×!Ñ! TÓ)ÚØ�‰”| DÓ/×0ño ðp €Nr:   c                 óº   • [        U R                  SS5      =(       a>    [        U R                  SS 5      =(       d     [        U R                  [        [
        45      $ )NÚ	_diff_wrtF)r`   ru  r  r/   r   r   )r   s    r8   rõ   rõ   ;  sC   € ”W˜QŸU™U K°Ó7÷ 1ÜˆA�E‰E�; Ó%÷ 0Üˆq�u‰u”x¤Ð.Ó/ð1r:   c                 ó®   • [        U 40 UD6n [        U [        5      (       d  U $ [        U R                  5      n[        U5      n[        U5      n[        U6 $ rF   )rë  r/   r1   r´   r=   Ú_piecewise_simplify_eq_andÚ)_piecewise_simplify_equal_to_next_segment)r6   rP   r=   s      r8   r„   r„   @  sO   € Ü'¨Ñ7°Ñ7€DÜ�dœI×&Ñ&ØˆÜ�—	‘	‹?€Dä% dÓ+€DÜ4°TÓ:€DÜ�dÐÐr:   c                 óX  • Sn[        [        [        U 5      5      5       GH  u  nu  p4Ub÷  [        U[        5      (       a  [        UR                  S SS9u  pVO[        U[        5      (       a  U// peO/ =pVUnUnU(       aw  U(       dp  [        [        U5      5      nU HV  n	[        U 5      S:X  d  [        U	5      (       d  M$  UR                  " U	R                  6 nUR                  " U	R                  6 nMX     Xx:X  a   X   R                  XS-      S   U5      X'   Mþ  UnGM  UnGM     U $ )z­
See if expressions valid for an Equal expression happens to evaluate
to the same function as in the next piecewise segment, see:
https://github.com/sympy/sympy/issues/8458
Nc                 ó"   • [        U [        5      $ rF   ©r/   r   ©rÁ   s    r8   rõ   Ú;_piecewise_simplify_equal_to_next_segment.<locals>.<lambda>V  s   € ¬J°q¼"Ô,=r:   TrÂ  rþ   rC   r   )rÙ   r´   rØ   r/   r   r%   r=   r   r   r_   Ú_blessedr‡   rN   )
r=   ÚprevexprrÁ   r6   r7   ÚeqsÚotherÚ	_prevexprÚ_exprr   s
             r8   rü  rü  K  s  € ð €HÜ#¤D¬°4«Ó$9×:‰ˆ‰<ˆDØÑÜ˜$¤×$Ñ$Ü! $§)¡)Ù"=ÀdñL‘
��Uä˜D¤"×%Ñ%Ø"˜V R‘Uà Ð �Ø ˆIØˆEÞž5Üœ7 3›<Ó(�Û�Aô ˜4“y A“~¬°!¯«Ø$-§N¢N°A·F±FÐ$;˜	Ø %§
¢
¨A¯F©FÐ 3šñ ð Ó!ð ™'Ÿ,™, t°©E¡{°1¡~°tÓ<�“ð  “à‹Hñ= ;ð> €Kr:   c                 óŽ  • [        U 5       GH*  u  nu  p#[        U[        5      (       a  [        UR                  S SS9u  pEO[        U[
        5      (       a  U// pTO/ =pEU(       d  M]  [        [        U5      5      n[        U5       H‹  u  pg[        U5      (       d  M  UR                  " UR                  6 nXFS-   S  Vs/ s H  oˆR                  " UR                  6 PM     snXFS-   S& U Vs/ s H  oˆR                  " UR                  6 PM     nnM�     [        XE-   6 nX   R                  X#5      X'   GM-     U $ s  snf s  snf )zÏ
Try to simplify conditions and the expression for
equalities that are part of the condition, e.g.
Piecewise((n, And(Eq(n,0), Eq(n + m, 0))), (1, True))
-> Piecewise((0, And(Eq(n, 0), Eq(m, 0))), (1, True))
c                 ó"   • [        U [        5      $ rF   rÿ  r   s    r8   rõ   Ú,_piecewise_simplify_eq_and.<locals>.<lambda>~  s   € ¬
°1´bÔ(9r:   TrÂ  rC   N)rØ   r/   r   r%   r=   r   r´   r   r  r‡   rN   )	r=   rÁ   r6   r7   r  r  rå   r   rÎ  s	            r8   rû  rû  t  s  € ô % TŸ?‰ˆ‰<ˆDÜ�dœC× Ñ Ü˜dŸi™iÙ9À$ñH‰JˆC�ä˜œb×!Ñ!Ø˜ ‘àÐˆCßˆ3Ü”w˜s“|Ó$ˆCÜ! #ž‘�ô ˜A—;“;ØŸ9š9 a§f¡fÐ-�DØ>AÀaÁ%À&¹kÓ"Jºk¸§7¢7¨A¯F©FÓ#3¹kÑ"J�C˜A™˜�KÙ8=Ó>º°"ŸWšW a§f¡fÓ-¹�EÐ>‘Eñ 'ô ˜™Ð&ˆDØ‘g—l‘l 4Ó.ˆDŒGñ% +ð& €Kùò	 #KùÚ>s   Ã"D=Ã/"EF)Úskip_nanr{   c                ó–   ^• U4S jnU(       a  U R                  [        U5      $ [        U [        5      (       a  U" U R                  6 $ U $ )aŸ  
Rewrite :class:`Piecewise` with mutually exclusive conditions.

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

SymPy represents the conditions of a :class:`Piecewise` in an
"if-elif"-fashion, allowing more than one condition to be simultaneously
True. The interpretation is that the first condition that is True is the
case that holds. While this is a useful representation computationally it
is not how a piecewise formula is typically shown in a mathematical text.
The :func:`piecewise_exclusive` function can be used to rewrite any
:class:`Piecewise` with more typical mutually exclusive conditions.

Note that further manipulation of the resulting :class:`Piecewise`, e.g.
simplifying it, will most likely make it non-exclusive. Hence, this is
primarily a function to be used in conjunction with printing the Piecewise
or if one would like to reorder the expression-condition pairs.

If it is not possible to determine that all possibilities are covered by
the different cases of the :class:`Piecewise` then a final
:class:`~sympy.core.numbers.NaN` case will be included explicitly. This
can be prevented by passing ``skip_nan=True``.

Examples
========

>>> from sympy import piecewise_exclusive, Symbol, Piecewise, S
>>> x = Symbol('x', real=True)
>>> p = Piecewise((0, x < 0), (S.Half, x <= 0), (1, True))
>>> piecewise_exclusive(p)
Piecewise((0, x < 0), (1/2, Eq(x, 0)), (1, x > 0))
>>> piecewise_exclusive(Piecewise((2, x > 1)))
Piecewise((2, x > 1), (nan, x <= 1))
>>> piecewise_exclusive(Piecewise((2, x > 1)), skip_nan=True)
Piecewise((2, x > 1))

Parameters
==========

expr: a SymPy expression.
    Any :class:`Piecewise` in the expression will be rewritten.
skip_nan: ``bool`` (default ``False``)
    If ``skip_nan`` is set to ``True`` then a final
    :class:`~sympy.core.numbers.NaN` case will not be included.
deep:  ``bool`` (default ``True``)
    If ``deep`` is ``True`` then :func:`piecewise_exclusive` will rewrite
    any :class:`Piecewise` subexpressions in ``expr`` rather than just
    rewriting ``expr`` itself.

Returns
=======

An expression equivalent to ``expr`` but where all :class:`Piecewise` have
been rewritten with mutually exclusive conditions.

See Also
========

Piecewise
piecewise_fold
c                  ó  >• [         n/ nU S S  HS  u  p4[        U[        U5      5      R                  5       n[	        XA5      R                  5       nUR                  X545        MU     U S   u  pg[        U[        U5      5      R                  5       nUR                  Xh45        T	(       dP  [	        Xq5      R                  5       nU[        La.  UR                  [        [        U5      R                  5       45        [        USS06$ )Nrk   r^   F)	r   r   r   rO   r   ra   r   rq   r1   )
ÚpwargsÚcumcondre   Úexpr_iÚcond_iÚcancondÚexpr_nÚcond_nÚ	cancond_nr  s
            €r8   Úmake_exclusiveÚ+piecewise_exclusive.<locals>.make_exclusiveÑ  sÝ   ø€ äˆØˆð % S b›k‰NˆFÜ˜&¤# g£,Ó/×8Ñ8Ó:ˆGÜ˜Ó)×2Ñ2Ó4ˆGØ�N‰N˜FÐ,Ö-ñ *ð   ™‰ˆÜ˜¤ G£Ó-×6Ñ6Ó8ˆ	Ø�‰˜Ð*Ô+æÜ˜Ó)×2Ñ2Ó4ˆGØœdÒ"Ø—‘¤	¬3¨w«<×+@Ñ+@Ó+BÐCÔDä˜'Ð2¨EÑ2Ð2r:   )rù   r1   r/   r=   )r6   r  r{   r  s    `  r8   Úpiecewise_exclusiver  ‘  s@   ø€ õ@3ö. Ø�|‰|œI ~Ó6Ð6Ü	�Dœ)×	$Ñ	$Ù˜tŸy™yÐ)Ð)àˆr:   Nr¢  )@Ú
sympy.corer   r   r   r   r   Úsympy.core.basicr   r	   Úsympy.core.functionr
   Úsympy.core.numbersr   r   r   Úsympy.core.parametersr   Úsympy.core.relationalr   r   r   r   r   r   r   Úsympy.core.sortingr   Ú(sympy.functions.elementary.miscellaneousr   r   Úsympy.logic.boolalgr   r   r   r   r   r   r   r    r!   r"   r#   Úsympy.utilities.iterablesr$   r%   r&   Úsympy.utilities.miscr'   r(   Ú	itertoolsr)   ÚNaNrq   r+   r1   r2   rÚ   rë  rr   r  r„   rü  rû  r  rM   r:   r8   Ú<module>r&     s¹   ðß 1Õ 1ß ,Ý /ß ?Ñ ?Ý 3÷"÷ "ñ "å &ß =÷J÷ J÷ Jñ Jç ?Ñ ?ß 6å à�E‰E€	ô+E�5ô +Eô\Y�ô Yôxlò^+ò\`òF[ñ|1€ò
ò&òRð: +0°dö \r:   