+
    i.                     
   R t ^ RIt^ RIHtHtHtHtHt ^ RIH	t	 ^ RI
Ht ^ RIHtHtHtHtHtHtHtHtHtHt ^ RIHtHtHtHtHtHtHtHtH t H!t!H"t"H#t# ^ RI$H%t%H&t&H't'H(t(H)t)H*t* ^ RI+H,t,H-t-H.t.H/t/H0t0 ^ R	I1H2t2 ^ R
I3H4t4 ^ RI5H6t6 ^ RI7H8t8 ^ RI9H:t: ^ RI;H<t<H=t= ^ RI>H?t? ^ RI@HAtA ^ RIBHCtC ^ RIDHEtE ^ RIFHGtG ]! R4      tHR-R./tI]H'       Ed   ^ RIHHJtJHKtKHLtLHMtM ^ RINHOtOHPtPHQtQ ]JP                  ! ]C4       ]JP                  ! ]:4       ]MP                  ! ]:4       ]JP                  ! ]24       ]MP                  ! ]24       ]KP                  ! ]24       ]LP                  ! ]24       ]JP                  ! ]84       ]MP                  ! ]84       ]KP                  ! ]84       ]LP                  ! ]84       ]JP                  ! ]<4       ]KP                  ! ]<4       ]JP                  ! ]=4       ]KP                  ! ]=4       ]JP                  ! ]A4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]-4       ]JP                  ! ],4       ]JP                  ! ]4       ]JP                  ! ]04       ]JP                  ! ].4       ]JP                  ! ]/4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ] 4       ]JP                  ! ]!4       ]JP                  ! ]#4       ]JP                  ! ]"4       ]JP                  ! ]'4       ]JP                  ! ])4       ]JP                  ! ]%4       ]JP                  ! ](4       ]JP                  ! ]&4       ]JP                  ! ]*4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]JP                  ! ]4       ]OP                  ! ]C4      R 4       tS]OP                  ! ]44      R 4       tS]QP                  ! ]C4      R 4       tS]QP                  ! ]44      R 4       tS]PP                  ! ]44      R.R l4       tT]H'       d   ^ RIHHUtU M
 ! R R4      tU]G! R/R7       ! R  R!]U]?4      4       tV]G! R/R7       ! R" R#]V4      4       tW]G! R/R7       ! R$ R%]V4      4       tX]G! R/R7       ! R& R']V4      4       tYR( tZ ! R) R*]4      t[]G! R/R7       ! R+ R,4      4       t\R# )0zj
The objects in this module allow the usage of the MatchPy pattern matching
library on SymPy expressions.
N)ListCallable
NamedTupleAnyDict)_sympify)import_module)
logsincostancotcscsecerfgamma
uppergamma)acoshasinhatanhacothacschasechcoshsinhtanhcothsechcsch)atanacscasinacotacosasec)fresnelcfresnelserfcerfiEi)Add)Basic)Expr)Mul)Pow)Equality
Unequality)Symbol)exp)Integral)srepr)doctest_depends_onmatchpy)	OperationCommutativeOperationAssociativeOperationOneIdentityOperation)op_itercreate_operation_expressionop_lenc                 l    \        V P                  ^ ,          3V P                  ^,          ,           4      # )    iter_args	operations   &_/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/utilities/matchpy_connector.py_rF   [   s'    Y__Q')IOOA,>>??    c                 ,    \        V P                  4      # Nr@   rC   s   &rE   rF   rF   _   s    IOO$$rG   c                 H    ^\        V P                  ^,          4      ,           # )   lenrB   rC   s   &rE   rF   rF   c   s    3yq)***rG   c                 ,    \        V P                  4      # rI   rL   rC   s   &rE   rF   rF   g   s    9??##rG   c                      \        V 4      ! V!  # rI   )type)old_operationnew_operandsvariable_names   &&&rE   sympy_op_factoryrT   k   s    M"L11rG   )Wildcardc                   &   a  ] tR t^st o R tRtV tR# )rU   c                6    Wn         W n        W0n        W@n        R # rI   )	min_count
fixed_sizerS   optional)self
min_lengthrY   rS   rZ   s   &&&&&rE   __init__Wildcard.__init__t   s    'N(O!.$MrG   )rY   rX   rZ   rS   N)__name__
__module____qualname____firstlineno__r]   __static_attributes____classdictcell____classdict__s   @rE   rU   rU   s   s     	% 	%rG   rU   )modulesc                      a a ] tR t^{t oRR ltR tRR ltR t]RR l4       t	V 3R lt
V3R lR ltR	 tR
 tV3R ltRtVtV ;t# )_WildAbstractc                    V P                   pV P                  pVe   \        V4      p\        P                  ! WV\        V4      V4       R # rI   )r\   rY   r   rU   r]   str)r[   rS   rZ   assumptionsr\   rY   s   &&&,  rE   r]   _WildAbstract.__init__   s=    __
__
)H$JM8JHUrG   c           
     ~    R V P                   RV P                  RV P                  RV P                  RV P                  /# r\   rY   rX   rS   rZ   ro   r[   s   &rE   __getstate___WildAbstract.__getstate__   s;    $//$//T//
 	
rG   c                T    V P                  W04       \        P                  ! WV3/ VB # rI   )	_sanitizeri   __xnew__)clsrS   rZ   rl   s   &&&,rE   __new___WildAbstract.__new__   s&    k'%%c(RkRRrG   c                2    V P                   V P                  3# rI   rS   rZ   rp   s   &rE   __getnewargs___WildAbstract.__getnewargs__   s    !!4==00rG   c                4    \         P                  ! W3/ VB pV# rI   )r1   ru   )rv   rS   rZ   rl   objs   &&&, rE   ru   _WildAbstract.__xnew__   s    ooc@K@
rG   c                  < V P                   '       dB   \        SV `	  4       V P                  V P                  V P
                  V P                   3,           # \        SV `	  4       V P                  V P                  V P
                  3,           # rI   )rZ   super_hashable_contentrX   rY   rS   )r[   	__class__s   &rE   r   _WildAbstract._hashable_content   sg    ===7,.$..$//SWSeSegkgtgt1uuu7,.$..$//SWSeSe1fffrG   c                   < V ^8  d   QhRR/# )   returnri    )formatrf   s   "rE   __annotate___WildAbstract.__annotate__   s     T T/ TrG   c                P    \        V 4      ! V P                  V P                  R 7      # )rz   )rP   rS   rZ   rp   s   &rE   __copy___WildAbstract.__copy__   s    Dz(:(:T]]SSrG   c                    \        V 4      # rI   )rk   rp   s   &rE   __repr___WildAbstract.__repr__   s    4yrG   c                    V P                   # rI   namerp   s   &rE   __str___WildAbstract.__str__   s    yyrG   c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )r   r\   rY   )intbool)r   rf   s   "rE   r   r   {   s     O   rG   r   )NN)r_   r`   ra   rb   r]   rq   rw   r{   staticmethodru   r   r   r   r   __annotate_func__rc   rd   __classcell__)r   rf   s   @@rE   ri   ri   {   sS     
V
S1  gT T[  rG   ri   c                       ] tR t^t^tRtRtR# )WildDotTr   Nr_   r`   ra   rb   r\   rY   rc   r   rG   rE   r   r      s    JJrG   r   c                       ] tR t^t^tRtRtR# )WildPlusFr   Nr   r   rG   rE   r   r          JJrG   r   c                       ] tR t^t^ tRtRtR# )WildStarFr   Nr   r   rG   rE   r   r      r   rG   r   c                     \        V 4      p\        P                  ! R RV4      p\        P                  ! RRV4      p\        P                  ! RRV4      pV# )zWildDot\('(\w+)'\)z\1zWildPlus\('(\w+)'\)z*\1zWildStar\('(\w+)'\))r4   resub)exprss   & rE   
_get_sreprr      sI    dA
$eQ/A
%vq1A
%vq1AHrG   c                   ,   a  ] tR t^t o V 3R ltRtV tR# )ReplacementInfoc                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )r   replacementinfo)r   )r   rf   s   "rE   r   ReplacementInfo.__annotate__   s      
I rG   r   N)r_   r`   ra   rb   r   rc   rd   re   s   @rE   r   r      s      rG   r   c                      a  ] tR t^t o Rt. RR3V 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	. . R3V 3R lR llt
RV 3R lR lltRtV tR# )Replacerak  
Replacer object to perform multiple pattern matching and subexpression
replacements in SymPy expressions.

Examples
========

Example to construct a simple first degree equation solver:

>>> from sympy.utilities.matchpy_connector import WildDot, Replacer
>>> from sympy import Equality, Symbol
>>> x = Symbol("x")
>>> a_ = WildDot("a_", optional=1)
>>> b_ = WildDot("b_", optional=0)

The lines above have defined two wildcards, ``a_`` and ``b_``, the
coefficients of the equation `a x + b = 0`. The optional values specified
indicate which expression to return in case no match is found, they are
necessary in equations like `a x = 0` and `x + b = 0`.

Create two constraints to make sure that ``a_`` and ``b_`` will not match
any expression containing ``x``:

>>> from matchpy import CustomConstraint
>>> free_x_a = CustomConstraint(lambda a_: not a_.has(x))
>>> free_x_b = CustomConstraint(lambda b_: not b_.has(x))

Now create the rule replacer with the constraints:

>>> replacer = Replacer(common_constraints=[free_x_a, free_x_b])

Add the matching rule:

>>> replacer.add(Equality(a_*x + b_, 0), -b_/a_)

Let's try it:

>>> replacer.replace(Equality(3*x + 4, 0))
-4/3

Notice that it will not match equations expressed with other patterns:

>>> eq = Equality(3*x, 4)
>>> replacer.replace(eq)
Eq(3*x, 4)

In order to extend the matching patterns, define another one (we also need
to clear the cache, because the previous result has already been memorized
and the pattern matcher will not iterate again if given the same expression)

>>> replacer.add(Equality(a_*x, b_), b_/a_)
>>> replacer._matcher.clear()
>>> replacer.replace(eq)
4/3
Fc                ,   < V ^8  d   QhRS[ RS[RS[/# )r   common_constraintslambdifyr   )listr   )r   rf   s   "rE   r   Replacer.__annotate__  s#     2 24 2 2TX 2rG   c                j    \         P                  4       V n        Wn        W n        W0n        / V n        R # rI   )r6   ManyToOneMatcher_matcher_common_constraint	_lambdify_info
_wildcards)r[   r   r   r   s   &&&&rE   r]   Replacer.__init__  s)    002"4!
/1rG   c                :   < V ^8  d   QhRS[ RS[RS[3,          /# )r   
lambda_strr   .)rk   r   r,   )r   rf   s   "rE   r   r     s$     * *c *hsDy.A *rG   c                @    \        R 4       \        V\        4       4      # )zfrom sympy import *)execevallocals)r[   r   s   &&rE   _get_lambdaReplacer._get_lambda  s    "#J))rG   c                @   < V ^8  d   QhRS[ RS[RS[RS[ 3,          /# )r   constraint_exprcondition_templater   .)r,   rk   r   )r   rf   s   "rE   r   r     s5     E Ed EPS EX`adfjajXk ErG   c           	        VP                  \        4       Uu. uF  q3P                  NK  	  ppR P                  V4      p\	        V4      pVP                  V4      p\        P                  V P                  RV RV R24      4      # u upi ), lambda z: ())	atomsri   r   joinr   r   r6   CustomConstraintr   )r[   r   r   xwilds
lambdaargsfullexpr	conditions   &&&     rE   _get_custom_constraintReplacer._get_custom_constraint  s    !0!6!6}!EF!EA!EFYYu%
o.&--h7	''wzl#i[BCE 	E	 Gs   Bc                :   < V ^8  d   QhRS[ RS[RS[ 3,          /# r   r   r   .r,   r   )r   rf   s   "rE   r   r     s+     M Mt MQTVZQZH[ MrG   c                &    V P                  VR 4      # )z({}) != Falser   r[   r   s   &&rE   _get_custom_constraint_nonfalse(Replacer._get_custom_constraint_nonfalse  s    **?OLLrG   c                :   < V ^8  d   QhRS[ RS[RS[ 3,          /# r   r   )r   rf   s   "rE   r   r     s)     L L4 LHSRVYDW LrG   c                &    V P                  VR 4      # )z({}) == Truer   r   s   &&rE   _get_custom_constraint_true$Replacer._get_custom_constraint_true  s    **?NKKrG   Nc          
      V   < V ^8  d   QhRS[ RS[S[ ,          RS[S[ ,          RS[RR/# )r   r   conditions_trueconditions_nonfalser   r   N)r,   r   r   )r   rf   s   "rE   r   r     s;     0 0 0DJ 0!%d08;0GK0rG   c                &   \        V4      p\        V4      pV P                  R ,          pV Uu. uF  qpP                  V4      NK  	  ppV Uu. uF  qpP                  V4      NK  	  p	pVP	                  V4       VP	                  V	4       \
        P                  ! V.VO5!  p
V P                  '       dO   RRP                  R VP                  \        4       4       4       R\        V4       2pV P                  V4      pTpMHV P                  P                  VP                  \        4       Uu/ uF  p\!        V4      VbK  	  up4       V P"                  '       d   \%        W%4      pV P&                  P)                  W4       R# u upi u upi u upi ):NNNr   r   c              3   8   "   T F  qP                   x  K  	  R # 5irI   r   ).0r   s   & rE   	<genexpr>Replacer.add.<locals>.<genexpr>+  s     -X>Wff>Ws   z: N)r   r   r   r   extendr6   Patternr   r   r   ri   r   r   r   updaterU   rk   r   r   r   add)r[   r   r   r   r   r   constraintscondconstraint_conditions_trueconstraint_conditions_nonfalsepatternr   lambda_expris   &&&&&&        rE   r   Replacer.add  sf   ~{+--a0?N&P?Nt,,T2 	# &P DW*XCV4006CV 	' *X569://$55>>>"499-Xdjj>W-X#Y"ZZ\]ghs]t\uvJ**:6K%KOO""tzz(7K#L7K!CFAI7K#LM:::)+<K'/&P*X $Ms   FF	.Fc                    < V ^8  d   QhRS[ /# )r   	max_count)r   )r   rf   s   "rE   r   r   4  s        S  rG   c           	        . pR p^ pV'       Ed)   V^ 8  g   WR8  Ed   Rp\         P                  V4       F  w  rg \        \        V P                  P                  V4      4      4      w  rV P                  '       d)   VP                  p
VP                  VP                  4       MTp
V P                  '       d
   V
! R/ V	B pMET
P                  V	P                  4        UUu/ uF  w  rV P                  V,          VbK  	  upp4      p\         P                  P                  WV4      pR p M	  V^,          pEK1  V P                  '       d   W3# V# u uppi   \          d     EK/  i ; i)TFr   )r6   preorder_iter_with_positionnextrA   r   matchr   r   appendr   r   xreplaceitemsr   	functionsreplaceStopIteration)r[   
expressionr   infosreplacedreplace_countsubexprposreplacement_datasubstr   resultkvs   &&&           rE   r  Replacer.replace4  sD    hIM]-FH ' C CJ O.248K8KG8T3U.V+$zzz&6&B&B%5%:%:;&6~~~!,!5u!5!,!5!5Y^YdYdYf6gYfQUQRtq7I17LYf6g!h!(!2!2!:!::F!SJ#H! !P& QM:::$$ 7h
 % s*   A<E8'EE>*EEE%$E%)r   r   r   r   r   ))r_   r`   ra   rb   __doc__r]   r   r   r   r   r   r  rc   rd   re   s   @rE   r   r      sr     6p 35u[` 2 2* *E EM ML L JL.0d0 0,     rG   r   )*)T)r6   )]r  r   typingr   r   r   r   r   sympy.core.sympifyr   sympy.externalr   sympy.functionsr	   r
   r   r   r   r   r   r   r   r   %sympy.functions.elementary.hyperbolicr   r   r   r   r   r   r   r   r   r   r   r   (sympy.functions.elementary.trigonometricr   r    r!   r"   r#   r$   'sympy.functions.special.error_functionsr%   r&   r'   r(   r)   sympy.core.addr*   sympy.core.basicr+   sympy.core.exprr,   sympy.core.mulr-   sympy.core.powerr.   sympy.core.relationalr/   r0   sympy.core.symbolr1   &sympy.functions.elementary.exponentialr2   sympy.integrals.integralsr3   sympy.printing.reprr4   sympy.utilities.decoratorr5   r6   __doctest_requires__r7   r8   r9   r:   matchpy.expressions.functionsr;   r<   r=   registerrF   rT   rU   ri   r   r   r   r   r   r   r   rG   rE   <module>r)     s   
 8 8 ' ( W W W ~ ~ ~ ~ W W V V  "      8 $ 6 . % 8 	
" ,  7ccZZx s!!#&s!!#&!!#&!!#&s!!#&!!#&!!#&x !!(+z"!!*-ssuz"x x srttssssssttttttttttttuuuuuuh@  @ e% % __X+ + __U$ $ !))%02 12  % % L)-Hf - *-` L)m  *
 L)}  *
 L)}  *
j 
 L)H H *HrG   