
    \hZ+                      S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  SS	K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   " S S\5      r " S S\5      r " S S\5      r \" \5      SS j5       r!SS jr"\r#g)z
A MathML printer.
    )annotations)Any)Mul)S)default_sort_key)sympify)split_super_subrequires_partial)precedence_traditional
PRECEDENCEPRECEDENCE_TRADITIONAL)greek_unicode)Printerprint_function)prec_to_dpsrepr_dpsto_strc                  ^    \ rS rSr% SrSSSSSSSSSSSS	0 S
SS.rS\S'   SS jrS rS r	Sr
g)MathMLPrinterBase   zVContains common code required for MathMLContentPrinter and
MathMLPresentationPrinter.
Nzutf-8Fabbreviated[plainT&#xB7;)orderencodingfold_frac_powersfold_func_bracketsfold_short_fracinv_trig_styleln_notationlong_frac_ratio	mat_delimmat_symbol_style
mul_symbolroot_notationsymbol_namesmul_symbol_mathml_numbersdisable_split_super_subzdict[str, Any]_default_settingsc                   ^ ^ [         R                  " T U5        SSKJnJn  U" 5       T l         " S SU5      mUU 4S jnUT R
                  l        g )Nr   )DocumentTextc                      \ rS rSrSS jrSrg)+MathMLPrinterBase.__init__.<locals>.RawText6   c                ~    U R                   (       a,  UR                  SR                  X R                   U5      5        g g )Nz{}{}{})datawriteformat)selfwriterindent	addindentnewls        M/var/www/auris/envauris/lib/python3.13/site-packages/sympy/printing/mathml.pywritexml4MathMLPrinterBase.__init__.<locals>.RawText.writexml7   s)    99LLD!IJ      N) r?   r?   )__name__
__module____qualname____firstlineno__r;   __static_attributes__r>   r=   r:   RawTextr/   6   s    Kr=   rE   c                D   > T" 5       nXl         TR                  Ul        U$ N)r2   domownerDocument)r2   rrE   r5   s     r:   createRawTextNode5MathMLPrinterBase.__init__.<locals>.createRawTextNode;   s    	AF"hhAOHr=   )r   __init__xml.dom.minidomr,   r-   rH   createTextNode)r5   settingsr,   r-   rK   rE   s   `    @r:   rM   MathMLPrinterBase.__init__,   s@    x(2:	Kd 	K
	 #4r=   c                    [         R                  " X5      nUR                  5       nUR                  SS5      nUR	                  5       nU$ )z"
Prints the expression as MathML.
asciixmlcharrefreplace)r   _printtoxmlencodedecode)r5   exprmathMLunistrxmlbstrress         r:   doprintMathMLPrinterBase.doprintC   s?     +--)<=nn
r=   c                J    U R                   S   (       a  U/ / 4$ [        U5      $ )Nr)   )	_settingsr	   )r5   names     r:   _split_super_sub"MathMLPrinterBase._split_super_subM   s&    >>34"b>!"4((r=   )rH   rG   )r@   rA   rB   rC   __doc__r*   __annotations__rM   r^   rc   rD   r>   r=   r:   r   r      sT    
 !#'#%-#()~ $4.)r=   r   c                     \ rS rSrSrSrS rS rS)S 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\r\rS rS rS rS r S r!S r"S  r#S! r$S" r%S# r&\#r'\#r(\#r)S$ r*S% r+S& r,S' r-S(r.g)*MathMLContentPrinterT   zuPrints an expression to the Content MathML markup language.

References: https://www.w3.org/TR/MathML2/chapter4.html
_mathml_contentc                   0 SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 S S	_S!S"_S#S#_S$S$_S%S%_S&S&_S'S'_S(S(_S)S)_S*S*_S+S+_S,S,_S-S-_S.S._S/S0_S1S2_S3S4_E0 S5S6_S7S8_S9S:_S;S8_S<S=_S>S?_S@SA_SBSC_SDSE_SFSG_SHSI_SJSK_SLSM_SNSO_SPSQ_SRSS_STSU_ESVSWSX.EnUR                   R                   H  nUR                  nXB;   d  M  X$   s  $    UR                   R                  nUR                  5       $ )Y)Returns the MathML tag for an expression.Addplusr   times
DerivativediffNumbercnintPowpowerMaxmaxMinminAbsabsAndandOrorXorxorNotnotImpliesimpliesSymbolciMatrixSymbolRandomSymbolIntegralSumsumsincostancotcscsecsinhcoshtanhcothcschsechasinarcsinasinharcsinhacosarccosacosharccoshatanarctanatanharctanhatan2acotarccotacotharccothasecarcsecasecharcsechacscarccscacscharccschloglnEqualityeq
UnequalityneqGreaterThangeqLessThanleqStrictGreaterThangtStrictLessThanltunion	intersect)UnionIntersection	__class____mro__r@   lower)r5   e	translateclsns        r:   
mathml_tagMathMLContentPrinter.mathml_tag[   s   6
66
76
 &6
 d	6

 46
 76
 56
 56
 56
 56
 $6
 56
 56
 y6
 d6
  D!6
" D#6
$ %6
& 5'6
( 5)6
* 5+6
, 5-6
. 5/6
0 516
2 536
4 F56
6 F76
8 F96
: F;6
< F=6
> F?6
@ HA6
B YC6
D HE6
F YG6
H HI6
J YK6
L XM6
N HO6
P YQ6
R HS6
T YU6
V HW6
X YY6
Z 4[6
\ ]6
^ %_6
` 5a6
b c6
d  e6
f dg6
h 'k6
	p ;;&&CA~ |# '
 KK  wwyr=   c                t   UR                  5       (       ah  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U R	                  U* 5      5        U$ SSKJn  U" U5      u  pEU[        R                  La  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U R                  U5      5        UR                  U R                  U5      5        U$ UR                  5       u  pgU[        R                  L a#  [        U5      S:X  a  U R                  US   5      $ U R                  S:w  a$  [        R                  " U5      R                  5       nU R                  R                  S5      nUR                  U R                  R                  S5      5        US:w  a   UR                  U R                  U5      5        U H#  nUR                  U R                  U5      5        M%     U$ )	Napplyminusr   fractiondivide   oldro   )could_extract_minus_signrH   createElementappendChild
_print_Mulsympy.simplifyr   r   OnerU   as_coeff_mullenr   r   
_from_argsas_ordered_factors)	r5   rY   xr   numerdenomcoefftermsterms	            r:   r   MathMLContentPrinter._print_Mul   s   ((**&&w/AMM$((009:MM$//4%01H+~&&w/AMM$((00:;MM$++e,-MM$++e,-H((*AEE>c%jAo ;;uQx((::NN5)<<>EHH""7+	dhh,,W56A:MM$++e,-DMM$++d+, r=   Nc                b   U R                  XS9nU R                  US   5      n/ nUSS   H  nUR                  5       (       a  U R                  R	                  S5      nUR                  U R                  R	                  S5      5        UR                  U5        UR                  U R                  U* 5      5        UnXcS   :X  a  UR                  U5        M  M  UR                  U5        U R                  U5      nXcS   :X  d  M  UR                  U R                  U5      5        M     [        U5      S:X  a  U$ U R                  R	                  S5      nUR                  U R                  R	                  S5      5        U(       a)  UR                  UR                  S5      5        U(       a  M)  U$ )Nr   r   r   r   r   rn   )	_as_ordered_termsrU   r   rH   r   r   appendr   pop)r5   rY   r   argslastProcessed	plusNodesargr   s           r:   
_print_AddMathMLContentPrinter._print_Add   sc   %%d%8DG,	8C++--HH**73dhh44W=>m,dkk3$/0 !r(?$$]3 #   / $C 0r(?$$T[[%56   y>Q  HH""7+	dhh,,V45MM)--*+ ir=   c                b   UR                   S   R                  S:w  a  [        S5      eU R                  R	                  S5      n[        UR                   5       H  u  nu  pEU[        UR                   5      S-
  :X  aB  US:X  a<  U R                  R	                  S5      nUR                  U R                  U5      5        O[U R                  R	                  S5      nUR                  U R                  U5      5        UR                  U R                  U5      5        UR                  U5        M     U$ )Nr   TzAll Piecewise expressions must contain an (expr, True) statement to be used as a default condition. Without one, the generated expression may not evaluate to anything under some condition.	piecewiser   	otherwisepiece)	r   cond
ValueErrorrH   r   	enumerater   r   rU   )r5   rY   rootir   cr   s          r:   _print_Piecewise%MathMLContentPrinter._print_Piecewise   s    99R=%  / 0 0
 xx%%k2"499-IAvC		NQ&&19..{;!!$++a.1..w7!!$++a.1!!$++a.1U# . r=   c           	     L   U R                   R                  S5      n[        UR                  5       Ho  nU R                   R                  S5      n[        UR                  5       H'  nUR                  U R                  XU4   5      5        M)     UR                  U5        Mq     U$ )Nmatrix	matrixrow)rH   r   rangerowscolsr   rU   )r5   mr   r   x_rjs         r:   _print_MatrixBase&MathMLContentPrinter._print_MatrixBase   s|    HH""8,qvvA((((5C166]AdG 45 #MM#	 
 r=   c                   UR                   S:X  aZ  U R                  R                  S5      nUR                  U R                  R	                  [        UR                  5      5      5        U$ U R                  R                  S5      nUR                  U R                  R                  S5      5        U R                  R                  S5      nUR                  U R                  R	                  [        UR                  5      5      5        U R                  R                  S5      nUR                  U R                  R	                  [        UR                   5      5      5        UR                  U5        UR                  U5        U$ )Nr   rs   r   r   )qrH   r   r   rO   strp)r5   r   r   xnumxdenoms        r:   _print_Rational$MathMLContentPrinter._print_Rational   s   33!8&&t,AMM$((11#acc(;<HHH""7+	dhh,,X67xx%%d+00QSS:;''-488223qss8<=	d	fr=   c                l   U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        U R                   R                  S5      nU R                   R                  S5      nUR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U5        UR                  U R	                  UR
                  S   5      5        U$ )Nr   bvarlowlimitr      r   )rH   r   r   r   rU   r   )r5   r   r   x_1x_2s        r:   _print_Limit!MathMLContentPrinter._print_Limit  s    HH""7+	dhh,,T__Q-?@Ahh$$V,hh$$Z0AFF1I./AFF1I./	c	c	dkk!&&),-r=   c                8    U R                   R                  S5      $ )N
imaginaryirH   r   r5   r   s     r:   _print_ImaginaryUnit)MathMLContentPrinter._print_ImaginaryUnit      xx%%l33r=   c                8    U R                   R                  S5      $ )N
eulergammar  r  s     r:   _print_EulerGamma&MathMLContentPrinter._print_EulerGamma  r!  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )zoWe use unicode #x3c6 for Greek letter phi as defined here
https://www.w3.org/2003/entities/2007doc/isogrk1.htmlrs   u   φrH   r   r   rO   r5   r   r   s      r:   _print_GoldenRatio'MathMLContentPrinter._print_GoldenRatio   s9     HH""4(	dhh--.JKLr=   c                8    U R                   R                  S5      $ )Nexponentialer  r  s     r:   _print_Exp1 MathMLContentPrinter._print_Exp1'  s    xx%%n55r=   c                8    U R                   R                  S5      $ )Npir  r  s     r:   	_print_PiMathMLContentPrinter._print_Pi*  s    xx%%d++r=   c                8    U R                   R                  S5      $ )Ninfinityr  r  s     r:   _print_Infinity$MathMLContentPrinter._print_Infinity-      xx%%j11r=   c                8    U R                   R                  S5      $ )N
notanumberr  r  s     r:   
_print_NaNMathMLContentPrinter._print_NaN0  r!  r=   c                8    U R                   R                  S5      $ )Nemptysetr  r  s     r:   _print_EmptySet$MathMLContentPrinter._print_EmptySet3  r7  r=   c                8    U R                   R                  S5      $ )Ntruer  r  s     r:   _print_BooleanTrue'MathMLContentPrinter._print_BooleanTrue6  s    xx%%f--r=   c                8    U R                   R                  S5      $ )Nfalser  r  s     r:   _print_BooleanFalse(MathMLContentPrinter._print_BooleanFalse9  s    xx%%g..r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U R                   R                  S5      5        U$ )Nr   r   r4  )rH   r   r   r(  s      r:   _print_NegativeInfinity,MathMLContentPrinter._print_NegativeInfinity<  sQ    HH""7+	dhh,,W56	dhh,,Z89r=   c                r   ^ ^^ UUU 4S jm[        TR                  5      nUR                  5         T" U5      $ )Nc                2  > TR                   R                  S5      nUR                  TR                   R                  TR                  T5      5      5        TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        [        U S   5      S:X  a  TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        [        U S   5      S:X  aR  TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        [        U 5      S:X  a,  UR                  TR	                  TR                  5      5        U$ UR                  T" U SS  5      5        U$ )	Nr   r  r      r  r   uplimitr  )rH   r   r   r   rU   r   function)limitsr   	bvar_elemlow_elemup_elemr   
lime_recurr5   s        r:   rT  8MathMLContentPrinter._print_Integral.<locals>.lime_recurC  s   &&w/AMM$((001CDE..v6I!!$++fQil";<MM)$6!9~"8811*=$$T[[1%>?h'((00;##DKKq	!$=>g&6!9~"((00;##DKKq	!$=>g&6{adkk!**56 H j45Hr=   )listrP  reverse)r5   r   rP  rT  s   `` @r:   _print_Integral$MathMLContentPrinter._print_IntegralB  s,    	0 ahh&!!r=   c                $    U R                  U5      $ rG   )rX  r  s     r:   
_print_SumMathMLContentPrinter._print_Sum_  s     ##A&&r=   c                f  ^  T R                   R                  T R                  U5      5      nU 4S jnS nT R                  UR                  5      u  pVnU" U5      nU Vs/ s H
  o" U5      PM     nnU V	s/ s H
  o" U	5      PM     nn	T R                   R                  S5      n
U
R                  T R                   R                  U5      5        U(       d  U(       d,  UR                  T R                   R                  U5      5        U$ T R                   R                  S5      nUR                  U
5        UR                  U" U5      5        UR                  U5         U$ U(       dV  T R                   R                  S5      nUR                  U
5        UR                  U" U5      5        UR                  U5        U$ T R                   R                  S5      nUR                  U
5        UR                  U" U5      5        UR                  U" U5      5        UR                  U5        U$ s  snf s  sn	f )Nc                |  > [        U 5      S:  a  TR                  R                  S5      n[        U 5       H  u  p#US:  aV  TR                  R                  S5      nUR	                  TR                  R                  S5      5        UR	                  U5        TR                  R                  S5      nUR	                  TR                  R                  U5      5        UR	                  U5        M     U$ TR                  R                  S5      nUR	                  TR                  R                  U S   5      5        U$ )Nr   zmml:mrowr   zmml:mo mml:mir   rH   r   r   r   rO   itemsmrowr   itemmomir5   s         r:   join0MathMLContentPrinter._print_Symbol.<locals>.joing  s    5zA~xx--j9(/GA1u!XX33H=txx'>'>s'CD((,//9BNN488#:#:4#@A$$R(  0 XX++H5txx66uQx@A	r=   c                F    U [         ;   a  [         R                  " U 5      $ U $ rG   r   getss    r:   r   5MathMLContentPrinter._print_Symbol.<locals>.translatey       M!$((++r=   r`  zmml:msubzmml:msupzmml:msubsup)rH   r   r   rc   rb   r   rO   )r5   symr   rh  r   rb   superssubssupsubmnamemsubmsupmsubsups   `             r:   _print_Symbol"MathMLContentPrinter._print_Symbold  s   XX##DOOC$89	$	 "22388<d,23FS)C.F3*./$3	#$/&&x0$((11$78txx66t<=$ 	! xx--j9  '  d,t$ 	 xx--j9  '  f.t$ 	 ((00?##E*##DJ/##DL1w'	3 4/s   H)6H.c                F   U R                   S   (       Gaa  UR                  R                  (       GaE  UR                  R                  S:X  Ga*  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  R                  S:w  a  U R                  R                  S5      nU R                  R                  S5      nUR                  U R                  R                  [        UR                  R                  5      5      5        UR                  U5        UR                  U5        UR                  U R                  UR                  5      5        U$ U R                  R                  S5      nU R                  R                  U R                  U5      5      nUR                  U5        UR                  U R                  UR                  5      5        UR                  U R                  UR                  5      5        U$ )Nr&   r   r   r   r  degreers   )ra   expis_Rationalr  rH   r   r   r  rO   r  rU   baser   )r5   r   r   xmldegxmlcnr  s         r:   
_print_PowMathMLContentPrinter._print_Pow  sl    NN?++0A0A0AEEGGqL&&w/AMM$((0089uuww!|//9..t4!!$(("9"9#aeegg,"GH""5)f%MM$++aff-.HHH""7+hh$$T__Q%78	c	dkk!&&)*	dkk!%%()r=   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rG   rH   r   r   r   rO   r  r(  s      r:   _print_Number"MathMLContentPrinter._print_Number  C    HH""4??1#56	dhh--c!f56r=   c                    U R                   R                  U R                  U5      5      n[        UR                  [        UR                  5      5      nUR                  U R                   R                  U5      5        U$ rG   )	rH   r   r   mlib_to_str_mpf_r   _precr   rO   )r5   r   r   repr_es       r:   _print_Float!MathMLContentPrinter._print_Float  sX    HH""4??1#56QWWhqww&78	dhh--f56r=   c                   U R                   R                  S5      nU R                  U5      n[        UR                  5      (       a  SnUR                  U R                   R                  U5      5        U R                   R                  S5      n[        UR                  5       H  u  pVUR                  U R                  U5      5        US:  d  M-  U R                   R                  S5      nUR                  U R                  [        U5      5      5        UR                  U5        M     UR                  U5        UR                  U R                  UR                  5      5        U$ )Nr   partialdiffr  r   r}  )
rH   r   r   r
   rY   r   reversedvariable_countrU   r   )r5   r   r   diff_symbolr  rq  ro   r}  s           r:   _print_Derivative&MathMLContentPrinter._print_Derivative  s   HH""7+ooa(AFF##'K	dhh,,[9:hh$$V,"1#3#34JCOODKK,-qy//9""4;;wu~#>?' 5 	
c	dkk!&&)*r=   c                   U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        UR                   H#  nUR                  U R                  U5      5        M%     U$ Nr   )rH   r   r   r   r   rU   r5   r   r   r   s       r:   _print_Function$MathMLContentPrinter._print_Function  sb    HH""7+	dhh,,T__Q-?@A66CMM$++c*+ r=   c                    U R                   R                  U R                  U5      5      nUR                   H#  nUR	                  U R                  U5      5        M%     U$ rG   )rH   r   r   r   r   rU   r  s       r:   _print_Basic!MathMLContentPrinter._print_Basic  sG    HH""4??1#5666CMM$++c*+ r=   c                   U R                   R                  S5      nU R                   R                  U R                  U5      5      nUR                  U5        UR                   H#  nUR                  U R                  U5      5        M%     U$ r  )rH   r   r   r   r   rU   )r5   r   r   r  r   s        r:   _print_AssocOp#MathMLContentPrinter._print_AssocOp  sg    HH""7+hh$$T__Q%78	c66CMM$++c*+ r=   c                V   U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        UR                  U R	                  UR
                  5      5        UR                  U R	                  UR                  5      5        U$ r  )rH   r   r   r   rU   lhsrhsr(  s      r:   _print_Relational&MathMLContentPrinter._print_Relational  sq    HH""7+	dhh,,T__Q-?@A	dkk!%%()	dkk!%%()r=   c                    U R                   R                  S5      nU H#  nUR                  U R                  U5      5        M%     U$ )z_MathML reference for the <list> element:
https://www.w3.org/TR/MathML2/chapter4.html#contm.listrV  )rH   r   r   rU   )r5   seqdom_elementre  s       r:   _print_list MathMLContentPrinter._print_list  s?     hh,,V4D##DKK$56 r=   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rG   r  r5   r  r  s      r:   
_print_intMathMLContentPrinter._print_int  F    hh,,T__Q-?@ 7 7A ?@r=   c                    U R                   R                  S5      nUR                   H#  nUR                  U R	                  U5      5        M%     U$ )Nset)rH   r   r   r   rU   r  s       r:   _print_FiniteSet%MathMLContentPrinter._print_FiniteSet  s>    HH""5)66CMM$++c*+ r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                   H#  nUR                  U R	                  U5      5        M%     U$ )Nr   setdiffrH   r   r   r   rU   r  s       r:   _print_Complement&MathMLContentPrinter._print_Complement  sY    HH""7+	dhh,,Y7866CMM$++c*+ r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                   H#  nUR                  U R	                  U5      5        M%     U$ )Nr   cartesianproductr  r  s       r:   _print_ProductSet&MathMLContentPrinter._print_ProductSet  sZ    HH""7+	dhh,,-?@A66CMM$++c*+ r=   c                l   U R                   R                  U R                  U5      5      nUR                   HO  nU R                   R                  S5      nUR	                  U R                  U5      5        UR	                  U5        MQ     UR	                  U R                  UR                  5      5        U$ )Nr  )rH   r   r   	signaturer   rU   rY   )r5   r   r   r   r  s        r:   _print_Lambda"MathMLContentPrinter._print_Lambda  s     HH""4??1#56;;C((((0COODKK,-MM#  	
dkk!&&)*r=   r>   rG   )/r@   rA   rB   rC   re   printmethodr   r   r   r   r	  r  r  r  r$  r)  r-  r1  r5  r:  r>  rB  rF  rI  rX  r[  rz  _print_MatrixSymbol_print_RandomSymbolr  r  r  r  r  r  r  r  r  r  _print_Implies
_print_Not
_print_Xorr  r  r  r  rD   r>   r=   r:   rh   rh   T   s     $K@D!F8*$446,242./":'
6p ('.
&
 $NJJ	r=   rh   c                     \ 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SS jrS rSS jrS rSS 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&SS& jr'S' r(\'r)S( r*S) r+S* r,S+ r-S, r.S- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6 r8SS7 jr9\9r:S8 r;SS9 jr<SS: jr=S; r>S< r?S= r@S> rAS? rBS@ rCSA rDSB rESC rF\FrGSD rHSE rISF rJSG rKSH rLSI rMSJ rNSK rOSL rP\PrQ\PrRSM rSSN rTSO rU\U=rVrWSP rXSQ rYSR rZSS r[ST r\SU r]SV r^SW r_SX r`SY raSZ rbS[ rcS\ rdS] reS^ rfS_ rgS` rhSa riSb rjSc rkSd rl\lrmSe rnSf roSg rpSh rqSi rrSj rsSk rtSl ruSm rvSn rwSo rxSp rySq rzSr r{Ss r|St r}Su r~Sv rSw rSx rSy rSz rS{ rS| rS} rS~ rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)MathMLPresentationPrinteri#  zzPrints an expression to the Presentation MathML markup language.

References: https://www.w3.org/TR/MathML2/chapter3.html
_mathml_presentationc                  ^  0 SS_SS_SS_SS_SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_S S_S!S"_S#S$_S%S&_S'S(_S)S*_S+S,_S-S._S/S0_S1S2_S3S4_S5S6_S7S8_S9S8_S:S;_S<S=_ES>S?S@SASBSCSDSESFS@SASGSHSISJ.EnU 4SK jnUR                   R                   H  nUR                  nXR;   d  M  X%   s  $    UR                   R                  SL:X  a  U" 5       $ UR                   R                  nUR                  5       $ )Mrl   rr   mnLimitz&#x2192;rp   &dd;rt   r   rg  r   z&int;r   z&#x2211;r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   =r   z&#x2260;r   z&#x2265;r   z&#x2264;r   >r   <lerchphi&#x3A6;zetaz&#x3B6;dirichlet_etaz&#x3B7;
elliptic_kz&#x39A;
lowergamma&#x3B3;
uppergammaz&#x393;gammatotientz&#x3D5;reduced_totientz&#x3BB;z&#x3BD;z&#x3A9;r   CWz&#x398;TrueFalseNonez	S&#x2032;z	C&#x2032;lambda)primenu
primeomegafresnelsfresnelcLambertW	HeavisideBooleanTrueBooleanFalseNoneTypemathieusmathieucmathieusprimemathieucprimeLambdac                 2  > T R                   S   b  T R                   S   S:X  a  gT R                   S   S:X  a  gT R                   S   S:X  a  gT R                   S   S:X  a  g	[        T R                   S   [        5      (       d  [        eT R                   S   $ )
Nr%   r  &InvisibleTimes;ro   &#xD7;dotr   ldotz&#x2024;)ra   
isinstancer  	TypeError)r5   s   r:   mul_symbol_selectionBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selection_  s    |,4NN<0F:)-8-6-7!| <cBB~~l33r=   r   r   )r5   r   r   r  r   r   s   `     r:   r   $MathMLPresentationPrinter.mathml_tag*  sA   1
d1
Z1
 &1
 4	1

 d1
 1
 :1
 51
 51
 51
 51
 H1
 Y1
 H1
 Y1
  H!1
" Y#1
$ H%1
& X'1
( )1
* *+1
, :-1
. 
/1
0  11
2 c31
4 	51
6 I71
8 Y91
: );1
< )=1
> )?1
@ YA1
B yC1
D yE1
F !#"!#((a1
	f	4 ;;&&CA~ |# '
 ;;5('))KK  wwyr=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  (r'  r5   rf  s     r:   _l_paren"MathMLPresentationPrinter._l_parenw  6    XX##D)
txx..s34	r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  )r'  r  s     r:   _r_paren"MathMLPresentationPrinter._r_paren|  r  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  {r'  r  s     r:   _l_brace"MathMLPresentationPrinter._l_brace  r  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  }r'  r  s     r:   _r_brace"MathMLPresentationPrinter._r_brace  r  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  ,r'  r  s     r:   _comma MathMLPresentationPrinter._comma  r  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  |r'  r  s     r:   _barMathMLPresentationPrinter._bar  r  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  ;r'  r  s     r:   
_semicolon$MathMLPresentationPrinter._semicolon  r  r=   c                l   U R                   R                  S5      nUR                  U R                  5       5        [	        U5       HK  u  p4U(       a  UR                  U R                  5       5        UR                  U R                  U5      5        MM     UR                  U R                  5       5        U$ Nrd  )rH   r   r   r  r   r  rU   r  r5   r   rd  r   r   s        r:   _paren_comma_separated0MathMLPresentationPrinter._paren_comma_separated  s    xx%%f-)oFA  /T[[-. & 	)r=   c                l   U R                   R                  S5      nUR                  U R                  5       5        [	        U5       HK  u  p4U(       a  UR                  U R                  5       5        UR                  U R                  U5      5        MM     UR                  U R                  5       5        U$ r  )rH   r   r   r  r   r  rU   r  r  s        r:   _paren_bar_separated.MathMLPresentationPrinter._paren_bar_separated  s    xx%%f-)oFA  -T[[-. & 	)r=   c                R   [        U5      nXB:  d  U(       d  XB::  a{  U R                  R                  S5      nUR                  U R	                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        U$ U R                  U5      $ r  )r   rH   r   r   r  rU   r  )r5   re  levelstrictprec_valrd  s         r:   parenthesize&MathMLPresentationPrinter.parenthesize  s    )$/v83D88))&1DT]]_-T[[./T]]_-K{{4  r=   c                H  ^  U 4S jnT R                   R                  S5      nUR                  5       (       ab  T R                   R                  S5      nUR                  T R                   R	                  S5      5        UR                  U5        U" U* U5      nU$ U" X5      nU$ )Nc                "  > SSK Jn  U" U 5      u  p4U[        R                  La  TR                  R                  S5      nTR                  S   (       a*  [        [        U 5      5      S:  a  UR                  SS5        TR                  U5      nTR                  U5      nUR                  U5        UR                  U5        UR                  U5        U$ U R                  5       u  pU[        R                  L a4  [        U	5      S:X  a%  UR                  TR                  U	S   5      5        U$ TR                  S	:w  a$  [        R                  " U	5      R!                  5       n	US:w  a  TR                  U5      n
TR                  R                  S
5      nUR                  TR                  R#                  TR%                  U 5      5      5        UR                  U
5        UR                  U5        U	 H  nUR                  TR'                  U[(        S   5      5        XS   :X  a  M5  TR                  R                  S
5      nUR                  TR                  R#                  TR%                  U 5      5      5        UR                  U5        M     U$ )Nr   r   mfracr      bevelledrA  r   r   rf  r   r   )r   r   r   r   rH   r   ra   r   r  setAttributerU   r   r   r   r   r   r   rO   r   r&  r   )rY   rd  r   r   r   fracr  xdenr   r   r   yr   r5   s                r:   multiply6MathMLPresentationPrinter._print_Mul.<locals>.multiply  s   /#D>LEAEE!xx--g6>>"34SY!9K%%j&9{{5){{5)  &  &  &,,.LE~#e*/  U1X!67zzU"u-@@BzKK&HH**40dhh55dood6KLM  #  #  !2!24E9J!KLRy(..t4AMM$(("9"9$//$:O"PQ$$Q'  Kr=   rd  rf  -)rH   r   r   r   rO   )r5   rY   r1  rd  r   s   `    r:   r   $MathMLPresentationPrinter._print_Mul  s    !	D xx%%f-((**&&t,AMM$((11#67QTE4(D  D'Dr=   Nc                   U R                   R                  S5      nU R                  XS9nUR                  U R	                  US   5      5        USS   H  nUR                  5       (       aX  U R                   R                  S5      nUR                  U R                   R                  S5      5        U R	                  U* 5      nOVU R                   R                  S5      nUR                  U R                   R                  S5      5        U R	                  U5      nUR                  U5        UR                  U5        M     U$ )Nrd  r   r   r   rf  r3  +)rH   r   r   r   rU   r   rO   )r5   rY   r   rd  r   r   r   r0  s           r:   r   $MathMLPresentationPrinter._print_Add  s   xx%%f-%%d%8T!W-.8C++--HH**40dhh55c:;KK% HH**40dhh55c:;KK$QQ  r=   c           	     8   U R                   R                  S5      n[        UR                  5       H  nU R                   R                  S5      n[        UR                  5       HS  nU R                   R                  S5      nUR                  U R                  XU4   5      5        UR                  U5        MU     UR                  U5        M     U R                  S   nUS:X  a  U$ U R                   R                  S5      nU R                   R                  S5      n	US:X  aU  UR                  U R                   R                  S5      5        U	R                  U R                   R                  S5      5        OTUR                  U R                   R                  S	5      5        U	R                  U R                   R                  S
5      5        U R                   R                  S5      n
U
R                  U5        U
R                  U5        U
R                  U	5        U
$ )Nmtablemtrmtdr#   r?   rf  r   ]r  r  rd  )	rH   r   r  r  r  r   rU   ra   rO   )r5   r  tabler   r   r  r0  r#   leftrightrd  s              r:   r	  +MathMLPresentationPrinter._print_MatrixBase  s   &&x0qvvA&&u-A166]HH**51dkk!qD'23a  # a   NN;/	?Lxx%%d+&&t,TXX44S9:dhh55c:;TXX44S9:dhh55c:;xx%%f-r=   c                   UR                   S:  a  UR                   * nOUR                   nU R                  R                  S5      nU(       d  U R                  S   (       a  UR	                  SS5        UR                  U R                  U5      5        UR                  U R                  UR                  5      5        UR                   S:  a  U R                  R                  S5      nU R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        UR                  U5        U$ U$ )	Nr   r*  r   r,  rA  rd  rf  r3  )	r  rH   r   ra   r-  r   rU   r  rO   )r5   r   foldedr  r   rd  rf  s          r:   _get_printed_Rational/MathMLPresentationPrinter._get_printed_Rational  s    337AAHH""7+T^^$56NN:v.	dkk!n%	dkk!##&'33788))&1D''-BNN48822378R QKHr=   c                    UR                   S:X  a  U R                  UR                  5      $ U R                  XR                  S   5      $ )Nr   r   )r  rU   r  rC  ra   r  s     r:   r  )MathMLPresentationPrinter._print_Rational)  s;    33!8;;qss##))!^^<M-NOOr=   c                x   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nU R	                  UR
                  S   5      nU R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        U R	                  UR
                  S   5      nUR                  U5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        UR                  U R	                  UR
                  S   5      5        U$ )	Nrd  munderrg  limr   rf  r  r   )rH   r   r   rO   rU   r   r   )	r5   r   rd  rH  rg  r   r  arrowr  s	            r:   r  &MathMLPresentationPrinter._print_Limit0  sE   xx%%f-''1XX##D)
txx..u56HH""6*kk!&&)$&&t,$((11$//!2DEFkk!&&)$	c	e	c21 QVVAY/0r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z&ImaginaryI;r'  r(  s      r:   r  .MathMLPresentationPrinter._print_ImaginaryUnitF  s6    HH""4(	dhh--n=>r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  r  r'  r(  s      r:   r)  ,MathMLPresentationPrinter._print_GoldenRatioK  6    HH""4(	dhh--i89r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z&ExponentialE;r'  r(  s      r:   r-  %MathMLPresentationPrinter._print_Exp1P  s7    HH""4(	dhh--.>?@r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z&pi;r'  r(  s      r:   r1  #MathMLPresentationPrinter._print_PiU  s6    HH""4(	dhh--f56r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  &#x221E;r'  r(  s      r:   r5  )MathMLPresentationPrinter._print_InfinityZ  6    HH""4(	dhh--j9:r=   c                ,   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        U R	                  U5      nUR                  U5        UR                  U5        U$ )Nrd  rf  r3  )rH   r   r   rO   r5  )r5   r   rd  r0  r   s        r:   rI  1MathMLPresentationPrinter._print_NegativeInfinity_  sv    xx%%f-HH""4(	dhh--c23  #r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z&#x210F;r'  r(  s      r:   _print_HBar%MathMLPresentationPrinter._print_HBarh  rX  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  r  r'  r(  s      r:   r$  +MathMLPresentationPrinter._print_EulerGammam  rP  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  TribonacciConstantr'  r(  s      r:   _print_TribonacciConstant3MathMLPresentationPrinter._print_TribonacciConstantr  s7    HH""4(	dhh--.BCDr=   c                    U R                   R                  S5      nUR                  U R                  UR                  S   5      5        UR                  U R                   R                  S5      5        U$ )Nrx  r   &#x2020;rH   r   r   rU   r   rO   r5   r   rx  s      r:   _print_Dagger'MathMLPresentationPrinter._print_Daggerw  sW    xx%%f-QVVAY/000<=r=   c                   U R                   R                  S5      nUR                  U R                  UR                  S   5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R                  UR                  S   5      5        U$ )Nrd  r   rf  z&#x2208;r   rf  )r5   r   rd  rf  s       r:   _print_Contains)MathMLPresentationPrinter._print_Contains}  s    xx%%f-QVVAY/0XX##D)
txx..z:;QVVAY/0r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z&#x210B;r'  r(  s      r:   _print_HilbertSpace-MathMLPresentationPrinter._print_HilbertSpace  rX  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U R	                  UR
                  S   5      5        U$ )Nrx  z	&#x1D49E;r   rH   r   r   rO   rU   r   rg  s      r:   _print_ComplexSpace-MathMLPresentationPrinter._print_ComplexSpace  sW    xx%%f-00=>QVVAY/0r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z&#x2131;r'  r(  s      r:   _print_FockSpace*MathMLPresentationPrinter._print_FockSpace  rX  r=   c                6   SSSS.nU R                   R                  S5      n[        UR                  5      S::  a  [	        S UR                   5       5      (       an  U R                   R                  S5      nUR                  U R                   R                  U[        UR                  5         5      5        UR                  U5        GO[        UR                  5       GHo  nU R                   R                  S5      nUR                  U R                   R                  US	   5      5        [        U5      S	:X  a  UR                  U5        [        U5      S
:X  a`  U R                   R                  S5      nUR                  U5        UR                  U R                  US	   5      5        UR                  U5        [        U5      S:X  d  M  U R                   R                  S5      nUR                  U5        UR                  U R                  US	   5      5        UR                  U R                  US
   5      5        UR                  U5        GMr     UR                  U R                  UR                  [        S   SS95        [        UR                  5       H|  nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R                  US   5      5        M~     U$ )Nz&#x222B;z&#x222C;z&#x222D;)r   r  rM  rd  rM  c              3  >   #    U  H  n[        U5      S :H  v   M     g7f)r   N)r   ).0rI  s     r:   	<genexpr><MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>  s     (N+3SQ+s   rf  r   r  rx  ry  r   Tr$  r  r   )rH   r   r   rP  allr   rO   r  rU   r&  rO  r   )	r5   rY   
intsymbolsrd  rf  rI  rx  ry  ds	            r:   rX  )MathMLPresentationPrinter._print_Integral  s`   #
zB
xx%%f-t{{q S(N$++(N%N%N''-BNN48822:c$++>N3OPQR   ,XX++D1txx66z!}EFs8q=$$R(s8q=8811&9D$$R($$T[[Q%89$$T*s8q="hh44Y?G''+''CF(;<''CF(;<$$W- -" 	**4==*U:K26 + 8 	9 DKK(C&&t,AMM$((11&9:QT[[Q01	 )
 r=   c                   [        UR                  5      nU R                  R                  S5      nU R	                  US   S   5      nU R	                  US   S   5      nU R                  R                  S5      nUR                  U R                  R                  U R                  U5      5      5        U R                  R                  S5      nU R	                  US   S   5      nU R                  R                  S5      n	U	R                  U R                  R                  S5      5        UR                  U5        UR                  U	5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        U R                  R                  S5      n
U
R                  U5        U
R                  U R                  UR                  [        U5      5      5        U
$ )N
munderoverr   r   r  rf  rd  r  )rV  rP  rH   r   rU   r   rO   r   r&  rO  r   )r5   r   rP  subsuprR  rS  summandlowvarequalrd  s              r:   r[  $MathMLPresentationPrinter._print_Sum  s~   ahh''5;;vay|,++fQil+((((.DHH33DOOA4FGHhh$$V,kk&)A,'&&t,$((11#67!7#37#xx%%f- **1::7Ma7PQRr=   c                  ^  U 4S jnS nT R                  UR                  5      u  pVnU" U5      nU Vs/ s H
  o" U5      PM     nnU V	s/ s H
  o" U	5      PM     nn	T R                  R                  S5      n
U
R	                  T R                  R                  U5      5        [        U5      S:X  aV  [        U5      S:X  a  U
nOT R                  R                  S5      nUR	                  U
5        UR	                  U" U5      5        O[        U5      S:X  aD  T R                  R                  S5      nUR	                  U
5        UR	                  U" U5      5        OZT R                  R                  S5      nUR	                  U
5        UR	                  U" U5      5        UR	                  U" U5      5        US:X  a  UR                  S	S5        U$ s  snf s  sn	f )
Nc                |  > [        U 5      S:  a  TR                  R                  S5      n[        U 5       H  u  p#US:  aV  TR                  R                  S5      nUR	                  TR                  R                  S5      5        UR	                  U5        TR                  R                  S5      nUR	                  TR                  R                  U5      5        UR	                  U5        M     U$ TR                  R                  S5      nUR	                  TR                  R                  U S   5      5        U$ )Nr   rd  r   rf  r_  rg  ra  rb  s         r:   rh  5MathMLPresentationPrinter._print_Symbol.<locals>.join  s    5zA~xx--f5(/GA1u!XX33D9txx'>'>s'CD((,//5BNN488#:#:4#@A$$R(  0 XX++D1txx66uQx@A	r=   c                F    U [         ;   a  [         R                  " U 5      $ U $ rG   rk  rm  s    r:   r   :MathMLPresentationPrinter._print_Symbol.<locals>.translate  rp  r=   rg  r   rw  rx  ry  boldmathvariant)rc   rb   rH   r   r   rO   r   r-  )r5   rq  stylerh  r   rb   rr  rs  rt  ru  rv  r   s   `           r:   rz  'MathMLPresentationPrinter._print_Symbol  s{   	$	 "22388<d,23FS)C.F3*./$3	#$/&&t,$((11$78v;!4yA~HH**62e$d4j)4yA~HH**62e$d6l+HH**95e$d4j)d6l+F?NN=&13 4/s   GGc                <    U R                  UU R                  S   S9$ )Nr$   )r  )rz  ra   )r5   rq  s     r:   r  -MathMLPresentationPrinter._print_MatrixSymbol  s+    !!#(,7I(J " L 	Lr=   c                    U R                   R                  S5      nUR                  SS5        UR                  U R	                  UR
                  S   5      5        U$ )Nmenclosenotationtopr   )rH   r   r-  r   rU   r   )r5   rY   encs      r:   _print_conjugate*MathMLPresentationPrinter._print_conjugate  sH    hh$$Z0U+DIIaL12
r=   c                8   U R                   R                  S5      nUR                  U R                  U[        S   5      5        U R                   R                  S5      nUR                  U R                   R                  U5      5        UR                  U5        U$ )Nrd  Funcrf  )rH   r   r   r&  r   rO   )r5   oprY   rowrf  s        r:   _print_operator_after/MathMLPresentationPrinter._print_operator_after  st    hh$$V,))$
60BCDXX##D)
txx..r23
r=   c                @    U R                  SUR                  S   5      $ )N!r   r  r   r5   rY   s     r:   _print_factorial*MathMLPresentationPrinter._print_factorial   s    ))#tyy|<<r=   c                @    U R                  SUR                  S   5      $ )Nz!!r   r  r  s     r:   _print_factorial2+MathMLPresentationPrinter._print_factorial2#  s    ))$		!==r=   c                   U R                   R                  S5      nUR                  SS5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  S   5      5        U R                   R                  S5      nUR                  U R                  5       5        UR                  U5        UR                  U R                  5       5        U$ )Nr*  linethickness0r   r   rd  )rH   r   r-  r   rU   r   r  r  )r5   rY   r.  bracs       r:   _print_binomial)MathMLPresentationPrinter._print_binomial&  s    xx%%g./3/TYYq\23TYYq\23xx%%f-))r=   c                "
   UR                   R                  (       Ga  [        UR                   R                  5      S:X  Ga  UR                   R                  S:w  Gaq  U R
                  S   (       Ga\  UR                   R                  S:X  aE  U R                  R                  S5      nUR                  U R                  UR                  5      5        UR                   R                  S:w  ay  U R                  R                  S5      nUR                  U R                  UR                  5      5        UR                  U R                  UR                   R                  5      5        UR                   R                  S:X  aN  U R                  R                  S5      nUR                  U R                  S5      5        UR                  W5        U$ W$ UR                   R                  (       Ga  UR                   R                  S:w  Gav  UR                   R                  (       a  U R                  R                  S5      nUR                  U R                  S5      5        U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   * U R
                  S
   5      5        UR                  U5        U$ U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   U R
                  S
   5      5        U$ UR                   R                  (       Ga  U R                  R                  S5      nUR                  U R                  S5      5        UR                   S:X  a,  UR                  U R                  UR                  5      5        U$ U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   * 5      5        UR                  U5        U$ U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   5      5        U$ )Nr   r&   r  msqrtmrootr   r*  rx  ru   r   )r~  r  r|   r  r  ra   rH   r   r   rU   r  is_negativer&  r   rC  )r5   r   r   r.  r  s        r:   r  $MathMLPresentationPrinter._print_Pow1  sx    EE#aeegg,!"31//uuww!|HH**73dkk!&&12uuww!|HH**73dkk!&&12dkk!%%''23uuww"}xx--g6  Q0  #55Auu  hh,,W5A/HH**62d//
58IJKd88!%%$(NN3E$FH I"
HH**62d//
58IJKd88$(NN3E$FH I55hh,,W5A/55B;OODKK$78 
	 ..v6AMM$"3"3AFFJu<M"NOMM$++quuf"56OOA&
HH""6*	d''
50ABC	dkk!%%()r=   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rG   r  r(  s      r:   r  'MathMLPresentationPrinter._print_Numberg  r  r=   c                z   U R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nUR                  U5        UR                  U R	                  UR
                  5      5        UR                  U R                  5       5        UR                  U R	                  UR                  5      5        UR                  U5        U$ )Nrf     ⟨   ⟩rd  )rH   r   r   rO   rU   rz   r  rx   )r5   r   r>  r?  r  s        r:   _print_AccumulationBounds3MathMLPresentationPrinter._print_AccumulationBoundsl  s    xx%%d+00:;&&t,$((11(;<xx%%f-QUU+,'QUU+,r=   c                <   [        UR                  5      (       a  SnOU R                  U5      nU R                  R	                  S5      nSn[        UR                  5       GH  u  pVXF-  nUS:  a  U R                  R	                  S5      nU R                  R	                  S5      nUR                  U R                  R                  U5      5        UR                  U5        UR                  U R                  U5      5        OEU R                  R	                  S5      nUR                  U R                  R                  U5      5        UR                  U5        U R                  U5      n	UR                  U	5        GM     U R                  R	                  S5      n
US:  a  U R                  R	                  S5      nU R                  R	                  S5      nUR                  U R                  R                  U5      5        UR                  U5        UR                  U R                  U5      5        OEU R                  R	                  S5      nUR                  U R                  R                  U5      5        U
R                  U5        U R                  R	                  S5      nU R                  R	                  S5      nUR                  U
5        UR                  U5        UR                  U5        UR                  U R                  UR                  5      5        U$ )Nz&#x2202;rd  r   r  rx  rf  r*  )
r
   rY   r   rH   r   r  r  r   rO   rU   )r5   r   r  r  dimrq  numr   xxr0  mnumrd  r.  s                r:   r  +MathMLPresentationPrinter._print_Derivativey  sO   AFF##A"A HH""6* !1!12HCJCaxHH**62XX++D1txx66q9:b!dkk#./HH**40dhh55a89MM!C AMM! 3 xx%%f-!8&&v.A''-BNN48822156MM"MM$++c*+&&t,AMM$((11!45xx%%f-xx%%g. 	QVV,-r=   c                   U R                   R                  S5      nU R                  U5      S:X  a?  U R                  S   (       a+  UR	                  U R                   R                  S5      5        O9UR	                  U R                   R                  U R                  U5      5      5        U R                   R                  S5      nUR	                  U5        UR	                  U R                  " UR                  6 5        U$ )Nrg  r   r!   r   rd  )rH   r   r   ra   r   rO   r  r   )r5   r   r   rd  s       r:   r  )MathMLPresentationPrinter._print_Function  s    HH""4(??1&4>>-+HMM$((11$78MM$((11$//!2DEFxx%%f-44aff=>r=   c                   [        UR                  5      n[        UR                  USS9nU R                  S   nU R
                  R                  S5      nSU;   Ga  UR                  S5      u  pgUS   S:X  a  USS  nU R
                  R                  S	5      nUR                  U R
                  R                  U5      5        UR                  U5        U R
                  R                  S
5      n	U	R                  U R
                  R                  U5      5        UR                  U	5        U R
                  R                  S5      n
U R
                  R                  S	5      nUR                  U R
                  R                  S5      5        U
R                  U5        U R
                  R                  S	5      nUR                  U R
                  R                  U5      5        U
R                  U5        UR                  U
5        U$ US:X  a  U R                  S 5      $ US:X  a  U R                  S 5      $ U R
                  R                  S	5      nUR                  U R
                  R                  U5      5        U$ )NT)strip_zerosr(   rd  r   r   r6  r   r  rf  rx  10z+infz-inf)r   r  r  r  ra   rH   r   splitr   rO   r5  rI  )r5   rY   dpsstr_real	separatorrd  mantr~  r  rf  rx  s              r:   r  &MathMLPresentationPrinter._print_Float  s   $**%tzz3DA NN#>?	xx%%f-(?"..-KT1v}!"g''-BNN48822489R ''-BNN488229=>R 88))&1D''-BNN48822489R ''-BNN48822378R T"K''--//55''-BNN488228<=Ir=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U R                   R                  S5      nUR                  U R                  5       5        UR                  U R	                  UR
                  S   5      5        UR                  U R                  5       5        UR                  U5        U$ )Nrd  rw  rg  Lir   r   )rH   r   r   rO   rU   r   r  r  )r5   rY   rd  r  rg  r  s         r:   _print_polylog(MathMLPresentationPrinter._print_polylog  s    xx%%f-HH""6*XX##D)
txx..t45	b	dkk$))A,/0xx%%f-)TYYq\23)r=   c                V   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        UR                  U5        UR                  U R
                  " UR                  6 5        U$ Nrd  rg  )rH   r   r   rO   r   r  r   )r5   r   rd  rg  s       r:   r  &MathMLPresentationPrinter._print_Basic  s~    xx%%f-XX##D)
txx..tq/ABC44aff=>r=   c                4    U R                   " UR                  6 $ rG   )r  r   r  s     r:   _print_Tuple&MathMLPresentationPrinter._print_Tuple  s    **AFF33r=   c                j   U R                   R                  S5      nUR                  (       a+  UR                  U R                   R	                  S5      5        O*UR                  U R                   R	                  S5      5        U R                   R                  S5      nUR
                  (       a+  UR                  U R                   R	                  S5      5        O*UR                  U R                   R	                  S5      5        U R                   R                  S5      nUR                  U5        UR                  U R                  UR                  5      5        UR                  U R                  5       5        UR                  U R                  UR                  5      5        UR                  U5        U$ )Nrf  r  r<  r  r   rd  )
rH   r   
right_openr   rO   	left_openrU   startr  end)r5   r   r?  r>  rd  s        r:   _print_Interval)MathMLPresentationPrinter._print_Interval  s+   &&t,<<dhh55c:;dhh55c:;xx%%d+;;TXX44S9:TXX44S9:xx%%f-QWW-.'QUU+,r=   c                   U R                   R                  S5      nUR                  U R                  5       5        UR                  U R	                  UR
                  S   5      5        UR                  U R                  5       5        U$ )Nrd  r   )rH   r   r   r  rU   r   )r5   rY   r~  rd  s       r:   
_print_Abs$MathMLPresentationPrinter._print_Abs	  sb    xx%%f-%TYYq\23%r=   c                   U R                   R                  S5      nUR                  U R                  5       5        UR                  U R	                  U5      5        UR                  U R                  5       5        U R                   R                  S5      nUR                  U R                   R                  U5      5        U R                   R                  S5      nUR                  U5        UR                  U5        U$ r  )rH   r   r   r  rU   r  rO   )r5   r   rY   r  rg  rd  s         r:   _print_re_im&MathMLPresentationPrinter._print_re_im  s    xx%%f-)T*+)XX##D)
txx..q12xx%%f-r=   c                @    U R                  SUR                  S   5      $ )Nu   ℜr   r  r   r5   rY   r~  s      r:   	_print_re#MathMLPresentationPrinter._print_re        499Q<88r=   c                @    U R                  SUR                  S   5      $ )Nu   ℑr   r  r  s      r:   	_print_im#MathMLPresentationPrinter._print_im!  r  r=   c                l   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        UR                  U5        UR
                   H#  nUR                  U R                  U5      5        M%     U$ r  )rH   r   r   rO   r   r   rU   )r5   r   rd  rg  r   s        r:   r  (MathMLPresentationPrinter._print_AssocOp$  s    xx%%f-XX##D)
txx..tq/ABC66CT[[-. r=   c                   U R                   R                  S5      nUR                  U R                  UR                  S   U5      5        UR                  SS   H{  nU R                   R                  S5      nUR                  U R                   R                  U5      5        U R                  XS5      nUR                  U5        UR                  U5        M}     U$ Nrd  r   r   rf  )rH   r   r   r&  r   rO   )r5   rY   symbolprecrd  r   r   r0  s           r:   _print_SetOp&MathMLPresentationPrinter._print_SetOp-  s    xx%%f-**499Q<>?99QR=C&&t,AMM$((11&9:!!#,AQQ ! r=   c                :    [         S   nU R                  USU5      $ )Nr   z&#x222A;r   r  r5   rY   r  s      r:   _print_Union&MathMLPresentationPrinter._print_Union8  s!    %g.  z488r=   c                :    [         S   nU R                  USU5      $ )Nr   z&#x2229;r  r  s      r:   _print_Intersection-MathMLPresentationPrinter._print_Intersection<  s!    %n5  z488r=   c                :    [         S   nU R                  USU5      $ )N
Complementz&#x2216;r  r  s      r:   r  +MathMLPresentationPrinter._print_Complement@  !    %l3  z488r=   c                :    [         S   nU R                  USU5      $ )NSymmetricDifference&#x2206;r  r  s      r:   _print_SymmetricDifference4MathMLPresentationPrinter._print_SymmetricDifferenceD  s"    %&;<  z488r=   c                :    [         S   nU R                  USU5      $ )N
ProductSetz&#x00d7;r  r  s      r:   r  +MathMLPresentationPrinter._print_ProductSetH  r   r=   c                8    U R                  UR                  5      $ rG   )
_print_setr   )r5   rn  s     r:   r  *MathMLPresentationPrinter._print_FiniteSetL  s    qvv&&r=   c                   [        U[        S9nU R                  R                  S5      nUR	                  U R                  5       5        [        U5       HK  u  pEU(       a  UR	                  U R                  5       5        UR	                  U R                  U5      5        MM     UR	                  U R                  5       5        U$ )Nkeyrd  )
sortedr   rH   r   r   r  r   r  rU   r  )r5   rn  rc  r  r   re  s         r:   r
  $MathMLPresentationPrinter._print_setO  s    q./xx%%f-) 'GA  /T[[./ ( 	)r=   c                2   U R                   R                  S5      nUS   R                  (       a  US   R                  (       d  U R                   R                  S5      nUR	                  U R                  5       5        UR	                  U R                  US   5      5        UR	                  U R                  5       5        UR	                  U5        O#UR	                  U R                  US   5      5        USS   GH  nU R                   R                  S5      nUR	                  U R                   R                  U5      5        UR                  (       a  UR                  (       dz  U R                   R                  S5      nUR	                  U R                  5       5        UR	                  U R                  U5      5        UR	                  U R                  5       5        OU R                  U5      nUR	                  U5        UR	                  U5        GM     U$ r  )	rH   r   
is_Booleanis_Notr   r  rU   r  rO   )r5   r   r  rd  r  r   r   r0  s           r:   _print_LogOp&MathMLPresentationPrinter._print_LogOp\  sw   xx%%f-7d1gnn88))&1DT]]_-T[[a12T]]_-T"T[[a128C&&t,AMM$((11&9:~~cjjHH**62dmmo.dkk#./dmmo.KK$QQ  r=   c                x   SSK Jn  XR                  :X  a  U R                  UR                  5      $ [	        X5      (       a  UR                  5       R                  5       nOSU4/nU R                  R                  S5      nU GH  u  pV[        UR                  R                  5       5      nUR                  S S9  [        U5       GHj  u  nu  pU
S:X  a  U(       aV  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        UR                  U R                  U	5      5        M  U
S	:X  ay  U R                  R                  S5      nUR                  U R                  R                  S
5      5        UR                  U5        UR                  U R                  U	5      5        GM  U(       aV  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        U R                  R                  S5      nUR                  U R                  5       5        UR                  U R                  U
5      5        UR                  U R!                  5       5        UR                  U5        U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        UR                  U R                  U	5      5        GMm     GM     U$ )Nr   )Vectorrd  c                (    U S   R                  5       $ )Nr   )__str__)r   s    r:   <lambda>AMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>  s    1Q4<<>r=   r  r   rf  r6  r   r3  r  )sympy.vectorr  zerorU   r  separaterc  rH   r   rV  
componentssortr   r   rO   r  r  )r5   rY   r  rc  rd  systemvect
inneritemsr   kvrf  mbracs                r:   _print_BasisDependent/MathMLPresentationPrinter._print_BasisDependentt  sY   '99;;tyy))d##MMO))+EYKExx%%f-!LFdoo3356JOO"9O:&z2	6A6!XX33D9txx'>'>s'CD((,$$T[[^4"W//5BNN488#:#:3#?@$$R($$T[[^4!XX33D9txx'>'>s'CD((, HH226:E%%dmmo6%%dkk!n5%%dmmo6$$U+//5BNN488#:#:;M#NO$$R($$T[[^43 3 ": r=   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x2227;r  r   r   r  r5   rY   r   s      r:   
_print_And$MathMLPresentationPrinter._print_And  &    dii%56  z22r=   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x2228;r*  r+  s      r:   	_print_Or#MathMLPresentationPrinter._print_Or  r.  r=   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x22BB;r*  r+  s      r:   r  $MathMLPresentationPrinter._print_Xor  r.  r=   c                :    U R                  UR                  S5      $ )Nz&#x21D2;)r  r   r  s     r:   r  (MathMLPresentationPrinter._print_Implies  s      J77r=   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x21D4;r*  r+  s      r:   _print_Equivalent+MathMLPresentationPrinter._print_Equivalent  r.  r=   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  S   R
                  (       a  U R                   R                  S5      nUR                  U R                  5       5        UR                  U R                  UR                  S   5      5        UR                  U R                  5       5        OU R                  UR                  S   5      nUR                  U5        U$ )Nrd  rf  z&#xAC;r   )	rH   r   r   rO   r   r  r  rU   r  )r5   r   rd  rf  r   s        r:   r  $MathMLPresentationPrinter._print_Not  s    xx%%f-XX##D)
txx..x89FF1I  &&v.AMM$--/*MM$++affQi01MM$--/*AFF1I&Ar=   c                    U R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        U$ Nrg  rH   r   r   rO   r   r5   r   rg  s      r:   _print_bool%MathMLPresentationPrinter._print_bool  ?    XX##D)
txx..tq/ABC	r=   c                    U R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        U$ r<  r=  r>  s      r:   _print_NoneType)MathMLPresentationPrinter._print_NoneType  rA  r=   c                N   SnUR                   R                  (       aF  UR                  R                  (       a+  UR                  R                  (       a  USSSU4nOUSSSU4nOUR                   R                  (       a  X!S   UR                  -
  US   4nO~UR                  R                  (       a#  [        U5      n[        U5      [        U5      U4nO@[        U5      S:  a&  [        U5      n[        U5      [        U5      X!S   4nO[        U5      nU R                  R                  S5      nUR                  U R                  5       5        [        U5       H  u  pgU(       a  UR                  U R                  5       5        Xr:X  aX  U R                  R                  S5      nUR                  U R                  R                  U5      5        UR                  U5        M  UR                  U R!                  U5      5        M     UR                  U R#                  5       5        U$ )Nu   …r   r   r      rd  rg  )r  is_infinitestopstepis_positiveiternextr   tuplerH   r   r   r  r   r  rO   rU   r  )	r5   rn  dotsprintsetitr  r   elrg  s	            r:   _print_Range&MathMLPresentationPrinter._print_Range  s   77166#5#5vv!!Q4/Ar4/WW  rUQVV^QrU2HVVaBBxb4/HVaZaBBxb426HQxHxx%%f-)x(EA  /zXX++D1txx66t<=  $  R1 ) 	)r=   c                   [        UR                  [        S9nU R                  R	                  S5      nU R                  R	                  S5      nUR                  U R                  R                  [        UR                  5      R                  5       5      5        UR                  U5        UR                  U R                  " U6 5        U$ )Nr  rd  rf  )r  r   r   rH   r   r   rO   r  funcr   r  )r5   rY   r   rd  rf  s        r:   _hprint_variadic_function3MathMLPresentationPrinter._hprint_variadic_function  s    dii%56xx%%f-XX##D)
txx..DII/E/E/GHI44d;<r=   c                    U R                   R                  S5      nUR                  U R                  S 5      5        UR                  U R	                  UR
                  S   5      5        U$ )Nrx  r   )rH   r   r   r-  rU   r   )r5   rY   rx  s      r:   
_print_exp$MathMLPresentationPrinter._print_exp  sS    xx%%f-))$/0TYYq\23r=   c                   U R                   R                  S5      nUR                  U R                  UR                  5      5        U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        UR                  U5        UR                  U R                  UR                  5      5        U$ )Nrd  rf  )rH   r   r   rU   r  rO   r   r  )r5   r   rd  r   s       r:   r  +MathMLPresentationPrinter._print_Relational  s    xx%%f-QUU+,HH""4(	dhh--dooa.@ABQUU+,r=   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rG   r  r  s      r:   r  $MathMLPresentationPrinter._print_int  r  r=   c                &   U R                   R                  S5      nUR                  u  p4U R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  U   5      5        UR	                  U5        U R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  5      5        UR	                  U5        U$ )Nrw  rg  r  r  )rH   r   _idr-  r   rO   _variable_names_name)r5   r   rw  indexr!  rg  s         r:   _print_BaseScalar+MathMLPresentationPrinter._print_BaseScalar  s    xx%%f-XX##D)
v.
txx..v/E/Ee/LMNXX##D)
v.
txx..v||<=r=   c                *   U R                   R                  S5      nUR                  u  p4U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  U   5      5        UR	                  U5        U R                   R                  S5      nUR	                  U R                   R                  S5      5        UR	                  U5        UR	                  U5        U R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  5      5        UR	                  U5        U$ )Nrw  moverrg  r  r  rf  ^)rH   r   r`  r-  r   rO   _vector_namesrb  )r5   r   rw  rc  r!  rg  rg  rf  s           r:   _print_BaseVector+MathMLPresentationPrinter._print_BaseVector  s*   xx%%f-&&w/XX##D)
v.
txx..v/C/CE/JKL"XX##D)
txx..s34"XX##D)
v.
txx..v||<=r=   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R	                  S5      5        UR                  U5        U$ )Nrg  rg  r  r  r  rf  rh  rH   r   r-  r   rO   )r5   r   rg  rg  rf  s        r:   _print_VectorZero+MathMLPresentationPrinter._print_VectorZero,  s    &&w/XX##D)
v.
txx..s34"XX##D)
txx..s34"r=   c                   U R                   R                  S5      nUR                  nUR                  nUR	                  U R                  U[        S   5      5        U R                   R                  S5      nUR	                  U R                   R                  S5      5        UR	                  U5        UR	                  U R                  U[        S   5      5        U$ )Nrd  r   rf  r  rH   r   _expr1_expr2r   r&  r   rO   r5   rY   rd  vec1vec2rf  s         r:   _print_Cross&MathMLPresentationPrinter._print_Cross7      xx%%f-{{{{**4E1BCDXX##D)
txx..x89**4E1BCDr=   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nrd  rf  &#x2207;r  r   rH   r   r   rO   r&  _exprr   r5   rY   rd  rf  s       r:   _print_Curl%MathMLPresentationPrinter._print_CurlB      xx%%f-XX##D)
txx..z:;XX##D)
txx..x89**4::z%7HIJr=   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nrd  rf  r{  r   r   r|  r~  s       r:   _print_Divergence+MathMLPresentationPrinter._print_DivergenceM  r  r=   c                   U R                   R                  S5      nUR                  nUR                  nUR	                  U R                  U[        S   5      5        U R                   R                  S5      nUR	                  U R                   R                  S5      5        UR	                  U5        UR	                  U R                  U[        S   5      5        U$ )Nrd  r   rf  r   rq  rt  s         r:   
_print_Dot$MathMLPresentationPrinter._print_DotX  ry  r=   c                L   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nrd  rf  r{  r   r|  r~  s       r:   _print_Gradient)MathMLPresentationPrinter._print_Gradientc  |    xx%%f-XX##D)
txx..z:;**4::z%7HIJr=   c                L   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nrd  rf  r  r   r|  r~  s       r:   _print_Laplacian*MathMLPresentationPrinter._print_Laplaciank  r  r=   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nrg  r  normalz&#x2124;rm  r(  s      r:   _print_Integers)MathMLPresentationPrinter._print_Integerss  D    HH""4(	}h/	dhh--j9:r=   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nrg  r  r  z&#x2102;rm  r(  s      r:   _print_Complexes*MathMLPresentationPrinter._print_Complexesy  r  r=   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nrg  r  r  z&#x211D;rm  r(  s      r:   _print_Reals&MathMLPresentationPrinter._print_Reals  r  r=   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nrg  r  r  &#x2115;rm  r(  s      r:   _print_Naturals)MathMLPresentationPrinter._print_Naturals  r  r=   c                h   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        UR                  U5        UR                  U R                  [        R                  5      5        U$ )Nrw  rg  r  r  r  )rH   r   r-  r   rO   rU   r   Zero)r5   r   ru  r   s       r:   _print_Naturals0*MathMLPresentationPrinter._print_Naturals0  s}    hh$$V,HH""4(	}h/	dhh--j9:AFF+,
r=   c                   UR                   S   UR                   S   -
  nUR                   S   nU R                  R                  S5      nUR                  U R                  R	                  S5      5        U R                  R                  S5      nUR                  U R                  R	                  S5      5        U R                  R                  S5      nUR                  U5        UR                  U R                  U5      5        UR                  U5        U R                  R                  S5      nUR                  U5        UR                  U R                  U5      5        U$ )	Nr   r   r  rf  r  r  rd  rx  )r   rH   r   r   rO   rU   )r5   rY   shiftrv   r>  r?  r  rt  s           r:   _print_SingularityFunction4MathMLPresentationPrinter._print_SingularityFunction  s   		!tyy|+		!xx%%d+00:;&&t,$((11(;<xx%%f-U+,hh$$V,E*+
r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  NaNr'  r(  s      r:   r:  $MathMLPresentationPrinter._print_NaN  s6    HH""4(	dhh--e45r=   c                &   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  U5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        [        UR
                  5      S:X  a  U$ U R                   R                  S5      nUR                  U5        UR                  U R                  " UR
                  SS  6 5        U$ )Nrw  rg  r   r   rd  )rH   r   r   rO   rU   r   r   r  )r5   r   rb   ru  rg  rd  s         r:   _print_number_function0MathMLPresentationPrinter._print_number_function  s     hh$$V,XX##D)
txx..t45AFF1I./qvv;!Jxx%%f-44affQRjABr=   c                &    U R                  US5      $ )NBr  r  s     r:   _print_bernoulli*MathMLPresentationPrinter._print_bernoulli      **1c22r=   c                &    U R                  US5      $ )Nr  r  r  s     r:   _print_catalan(MathMLPresentationPrinter._print_catalan  r  r=   c                &    U R                  US5      $ )NEr  r  s     r:   _print_euler&MathMLPresentationPrinter._print_euler  r  r=   c                &    U R                  US5      $ )NFr  r  s     r:   _print_fibonacci*MathMLPresentationPrinter._print_fibonacci  r  r=   c                &    U R                  US5      $ )NLr  r  s     r:   _print_lucas&MathMLPresentationPrinter._print_lucas  r  r=   c                &    U R                  US5      $ )Nz&#x03B3;r  r  s     r:   _print_stieltjes*MathMLPresentationPrinter._print_stieltjes  s    **1j99r=   c                &    U R                  US5      $ )NTr  r  s     r:   _print_tribonacci+MathMLPresentationPrinter._print_tribonacci  r  r=   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U$ )Nrg  rf  rV  ~r'  )r5   r   r   rf  s       r:   _print_ComplexInfinity0MathMLPresentationPrinter._print_ComplexInfinity  s    HH""7+XX##D)
txx..z:;	bXX##D)
txx..s34	br=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  z&#x2205;r'  r(  s      r:   r>  )MathMLPresentationPrinter._print_EmptySet  rX  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrf  z	&#x1D54C;r'  r(  s      r:   _print_UniversalSet-MathMLPresentationPrinter._print_UniversalSet  6    HH""4(	dhh--k:;r=   c                   SSK Jn  UR                  nU R                  R	                  S5      n[        X25      (       d  U R                  R	                  S5      nUR                  U R                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        UR                  U5        O UR                  U R                  U5      5        U R                  R	                  S5      nUR                  U R                  R                  S5      5        UR                  U5        U$ )Nr   r   rx  rd  rf  re  sympy.matricesr   r   rH   r   r  r   r  rU   r  rO   r5   rY   r   matrt  r  rf  s          r:   _print_Adjoint(MathMLPresentationPrinter._print_Adjoint  s    /hhhh$$V,#,,88))&1DT]]_-T[[-.T]]_-OOD!OODKK,-XX##D)
txx..z:;
r=   c                   SSK Jn  UR                  nU R                  R	                  S5      n[        X25      (       d  U R                  R	                  S5      nUR                  U R                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        UR                  U5        O UR                  U R                  U5      5        U R                  R	                  S5      nUR                  U R                  R                  S5      5        UR                  U5        U$ )Nr   r  rx  rd  rf  r  r  r  s          r:   _print_Transpose*MathMLPresentationPrinter._print_Transpose  s    /hhhh$$V,#,,88))&1DT]]_-T[[-.T]]_-OOD!OODKK,-XX##D)
txx..s34
r=   c                   SSK Jn  UR                  nU R                  R	                  S5      n[        X25      (       d  U R                  R	                  S5      nUR                  U R                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        UR                  U5        O UR                  U R                  U5      5        UR                  U R                  S5      5        U$ )Nr   r  rx  rd  r   )
r  r   r   rH   r   r  r   r  rU   r  )r5   rY   r   r  rt  r  s         r:   _print_Inverse(MathMLPresentationPrinter._print_Inverse  s    /hhhh$$V,#,,88))&1DT]]_-T[[-.T]]_-OOD!OODKK,-B(
r=   c           	        SSK Jn  U R                  R                  S5      nUR                  n[        US   [        5      (       a#  US   R                  5       [        USS  5      -   nO[        U5      n[        X5      (       a  UR                  5       (       an  US   S:X  a  USS  nO	US   * US'   U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        US S  H  nUR                  U R                  U[        U5      S5      5        U R                  R                  S5      nUR                  U R                  R                  S	5      5        UR                  U5        M     UR                  U R                  US   [        U5      S5      5        U$ )
Nr   )MatMulrd  r   r   rf  r3  Fr  )!sympy.matrices.expressions.matmulr  rH   r   r   r  r   r   rV  r   r   rO   r&  r   )r5   rY   r  r   r   rf  r   s          r:   _print_MatMul'MathMLPresentationPrinter._print_MatMul  sy   <HH""6*yyd1gs##7--/$tABx.@D:Dd##(E(E(G(GAw"}ABx7(Q''-BNN48822378MM"9CMM$++C1G1M,13 4''-BNN488223EFGMM"  	
d''R2H2N(-/ 	0r=   c                ,   SSK Jn  UR                  UR                  pCU R                  R                  S5      n[        X25      (       d  U R                  R                  S5      nUR                  U R                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        UR                  U5        O UR                  U R                  U5      5        UR                  U R                  U5      5        U$ )Nr   r  rx  rd  )r  r   r  r~  rH   r   r  r   r  rU   r  )r5   rY   r   r  r~  rt  r  s          r:   _print_MatPow'MathMLPresentationPrinter._print_MatPow1  s    /IItxxchh$$V,$--88))&1DT]]_-T[[./T]]_-OOD!OODKK-.C()
r=   c           	        U R                   R                  S5      nUR                  nUS S  H  nUR                  U R	                  U[        U5      S5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        M     UR                  U R	                  US   [        U5      S5      5        U$ )Nrd  r   Frf  z&#x2218;)rH   r   r   r   r&  r   rO   )r5   rY   r   r   r   rf  s         r:   _print_HadamardProduct0MathMLPresentationPrinter._print_HadamardProduct@  s    HH""6*yy9CMM!!#'=d'CUKM''-BNN48822:>?MM"  	
d2h(>t(DeL	Nr=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nr  z&#x1D7D8r'  r5   Zr   s      r:   _print_ZeroMatrix+MathMLPresentationPrinter._print_ZeroMatrixM  rX  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nr  z&#x1D7D9r'  r  s      r:   _print_OneMatrix*MathMLPresentationPrinter._print_OneMatrixR  rX  r=   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nrg  z	&#x1D540;r'  )r5   Ir   s      r:   _print_Identity)MathMLPresentationPrinter._print_IdentityW  r  r=   c                   U R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nUR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nrf  u   ⌊u   ⌋rd  r   rq  r5   r   r>  r?  rd  s        r:   _print_floor&MathMLPresentationPrinter._print_floor\      xx%%d+00:;&&t,$((11(;<xx%%f-QVVAY/0r=   c                   U R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nUR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nrf  u   ⌈u   ⌉rd  r   rq  r  s        r:   _print_ceiling(MathMLPresentationPrinter._print_ceilingg  r  r=   c                h   U R                   R                  S5      nUR                  S   n[        U5      S:X  a  U R	                  US   5      nOU R	                  U5      nUR                  U R                  5       5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR                  S   5      5        UR                  U R                  5       5        U$ )Nrd  r   r   rf  z&#x21A6;)	rH   r   r   r   rU   r   r  rO   r  )r5   r   rd  symbolsrf  s        r:   r  'MathMLPresentationPrinter._print_Lambdar  s    xx%%f-&&)w<1kk'!*-Gkk'*G)!XX##D)
txx..z:;QVVAY/0)r=   c                     U R                   " U6 $ rG   )r  r  s     r:   _print_tuple&MathMLPresentationPrinter._print_tuple  s    **A..r=   c                8    U R                  UR                  5      $ rG   )rU   labelr  s     r:   _print_IndexedBase,MathMLPresentationPrinter._print_IndexedBase  s    {{177##r=   c                t   U R                   R                  S5      nUR                  U R                  UR                  5      5        [        UR                  5      S:X  a/  UR                  U R                  UR                  S   5      5        U$ UR                  U R                  UR                  5      5        U$ )Nrw  r   r   )rH   r   r   rU   r  r   indicesr(  s      r:   _print_Indexed(MathMLPresentationPrinter._print_Indexed  s    HH""6*	dkk!&&)*qyy>QMM$++aiil34H	dkk!)),-r=   c                   U R                   R                  S5      nUR                  U R                  UR                  [
        S   SS95        U R                   R                  S5      n[        UR                  5       HK  u  pEU(       a  UR                  U R                  5       5        UR                  U R                  U5      5        MM     UR                  U5        U$ )Nrw  AtomTr|  rd  )
rH   r   r   r&  parentr   r   r
  r  rU   )r5   r   r   r  r   r   s         r:   _print_MatrixElement.MathMLPresentationPrinter._print_MatrixElement  s    HH""6*	d''*V2Dt'TUxx%%f-		*FA  /T[[-. + 	
dr=   c                8   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R                  " UR
                  6 5        U$ )Nrd  rg  z	&#x1d5a5;rH   r   r   rO   r   r   r5   r   r   rg  s       r:   _print_elliptic_f+MathMLPresentationPrinter._print_elliptic_f  q    HH""6*XX##D)
txx..{;<	b	d//89r=   c                8   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R                  " UR
                  6 5        U$ )Nrd  rg  z	&#x1d5a4;r  r  s       r:   _print_elliptic_e+MathMLPresentationPrinter._print_elliptic_e  r  r=   c                $   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R	                  5       5        [        UR                  5      S:X  an  UR                  u  pVUR                  U R                  U5      5        UR                  U R                  5       5        UR                  U R                  U5      5        OUR                  u  pVnUR                  U R                  U5      5        UR                  U R                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        UR                  U R                  U5      5        UR                  U R                  5       5        UR                  U5        U$ )Nrd  rg  z	&#x1d6f1;r  )rH   r   r   rO   r  r   r   rU   r  r  r  )r5   r   r   rg  r0  r   r  zs           r:   _print_elliptic_pi,MathMLPresentationPrinter._print_elliptic_pi  s]   HH""6*XX##D)
txx..{;<	bHH""6*	dmmo&qvv;!66DAMM$++a.)MM$))+&MM$++a.)ffGA!MM$++a.)MM$//+,MM$++a.)MM$))+&MM$++a.)	dmmo&	ar=   c                <   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  5      5        U$ )Nrd  rg  Eirq  r  s       r:   	_print_Ei#MathMLPresentationPrinter._print_Ei  so    HH""6*XX##D)
txx..t45	b	dkk!&&)*r=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  rw  rf  r  r   r   rq  r5   r   r   r0  rf  s        r:   _print_expint'MathMLPresentationPrinter._print_expint      HH""6*HH""6*XX##D)
txx..s34	b	dkk!&&),-	a	dkk!&&*-.r=   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  ry  rf  Pr   r   rM  rq  r$  s        r:   _print_jacobi'MathMLPresentationPrinter._print_jacobi      HH""6*HH""9-XX##D)
txx..s34	b	dkk!&&),-	dkk!&&1+./	a	dkk!&&*-.r=   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  ry  rf  r  r   r   r  rq  r$  s        r:   _print_gegenbauer+MathMLPresentationPrinter._print_gegenbauer  r,  r=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  rw  rf  r  r   r   rq  r$  s        r:   _print_chebyshevt+MathMLPresentationPrinter._print_chebyshevt  r'  r=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  rw  rf  Ur   r   rq  r$  s        r:   _print_chebyshevu+MathMLPresentationPrinter._print_chebyshevu  r'  r=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  rw  rf  r)  r   r   rq  r$  s        r:   _print_legendre)MathMLPresentationPrinter._print_legendre  r'  r=   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  ry  rf  r)  r   r   r  rq  r$  s        r:   _print_assoc_legendre/MathMLPresentationPrinter._print_assoc_legendre  r,  r=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  rw  rf  r  r   r   rq  r$  s        r:   _print_laguerre)MathMLPresentationPrinter._print_laguerre  r'  r=   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  ry  rf  r  r   r   r  rq  r$  s        r:   _print_assoc_laguerre/MathMLPresentationPrinter._print_assoc_laguerre&  r,  r=   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nrd  rw  rf  Hr   r   rq  r$  s        r:   _print_hermite(MathMLPresentationPrinter._print_hermite2  r'  r=   r>   )FrG   )r   )r@   rA   rB   rC   re   r  r   r  r  r  r  r  r  r  r  r   r&  r   r   r	  rC  r  r  r  r)  r-  r1  r5  rI  r\  r$  rb  rh  rk  rn  rr  ru  rX  r[  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  _print_Determinantr  r  r  r  r  r  r  r  r  r  r  r
  _print_frozensetr  r'  r,  r0  r  r  r7  r  r?  rB  rF  rC  rR  rV  
_print_Min
_print_MaxrY  r  r  rd  rj  rn  rw  r  r  r  r  r  r  r  r  r  r  r  r:  r  r  _print_bellr  r  r  r  r  r  r  r>  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r%  r*  r.  r1  r5  r8  r;  r>  rA  rE  rD   r>   r=   r:   r  r  #  s    )KKZ






!-^(4(P,








$L24lL (=>	4l
.`	%N 4& $
99	99999'	 "0)X33383
 %%
> 87J
$					 
3 #K3333:3

"":


		 /$	.	

			
	
	r=   r  c                v    US:X  a  [        U5      R                  U 5      $ [        U5      R                  U 5      $ )zReturns the MathML representation of expr. If printer is presentation
then prints Presentation MathML else prints content MathML.
presentation)r  r^   rh   )rY   printerrP   s      r:   mathmlrO  >  s8    
 . (2::4@@#H-55d;;r=   c                    US:X  a  [        U5      nO[        U5      nUR                  [        U 5      5      nUR	                  5       n[        U5        g)a  
Prints a pretty representation of the MathML code for expr. If printer is
presentation then prints Presentation MathML else prints content MathML.

Examples
========

>>> ##
>>> from sympy import print_mathml
>>> from sympy.abc import x
>>> print_mathml(x+1) #doctest: +NORMALIZE_WHITESPACE
<apply>
    <plus/>
    <ci>x</ci>
    <cn>1</cn>
</apply>
>>> print_mathml(x+1, printer='presentation')
<mrow>
    <mi>x</mi>
    <mo>+</mo>
    <mn>1</mn>
</mrow>

rM  N)r  rh   rU   r   toprettyxmlprint)rY   rN  rP   rn  xml
pretty_xmls         r:   print_mathmlrU  I  sF    2 . %h/ *
((74=
!C"J	*r=   N)content)$re   
__future__r   typingr   sympy.core.mulr   sympy.core.singletonr   sympy.core.sortingr   sympy.core.sympifyr   sympy.printing.conventionsr	   r
   sympy.printing.precedencer   r   r   &sympy.printing.pretty.pretty_symbologyr   sympy.printing.printerr   r   mpmath.libmpr   r   r   r  r   rh   r  rO  rU  MathMLPrinterr>   r=   r:   <module>rc     s    #   " / & H? ? @ : E E<) <)~J, J^X 1 Xv0 !"< #< H %r=   