o
    à8Va¼% ã                   @   sô   d Z ddlmZmZ ddlmZmZmZ ddlm	Z	 ddl
mZ ddlmZmZ ddlmZmZmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZmZmZ G dd„ deƒZG dd„ deƒZ G dd„ deƒZ!eeƒddd„ƒZ"ddd„Z#e Z$d
S )z
A MathML printer.
é    )ÚAnyÚDict)ÚsympifyÚSÚMul)Údefault_sort_key)Ú_coeff_isneg)Úsplit_super_subÚrequires_partial)Úprecedence_traditionalÚ
PRECEDENCEÚPRECEDENCE_TRADITIONAL)Úgreek_unicode)ÚPrinterÚprint_functionN)Úprec_to_dpsÚrepr_dpsÚto_strc                   @   sT   e Zd ZdZddddddddddddi d	d
œZddd„Zdd„ Zdd„ Zdd„ ZdS )ÚMathMLPrinterBasez^Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    Nzutf-8FZabbreviatedú[ÚplainTú&#xB7;)ÚorderÚencodingÚfold_frac_powersZfold_func_bracketsÚfold_short_fracZinv_trig_styleÚln_notationZlong_frac_ratioÚ	mat_delimÚmat_symbol_styleÚ
mul_symbolÚroot_notationZsymbol_namesÚmul_symbol_mathml_numbersc                    sN   t  ˆ|¡ ddlm}m} |ƒ ˆ_G dd„ d|ƒ‰ ‡ ‡fdd„}|ˆj_d S )Nr   )ÚDocumentÚTextc                   @   s   e Zd Zddd„ZdS )z+MathMLPrinterBase.__init__.<locals>.RawTextÚ c                 S   s$   | j r| d || j |¡¡ d S d S )Nz{}{}{})ÚdataÚwriteÚformat©ÚselfÚwriterÚindentÚ	addindentÚnewl© r.   ú7/usr/lib/python3/dist-packages/sympy/printing/mathml.pyÚwritexml5   s   ÿz4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN©r$   r$   r$   )Ú__name__Ú
__module__Ú__qualname__r0   r.   r.   r.   r/   ÚRawText4   s    r5   c                    s   ˆ ƒ }| |_ ˆj|_|S ©N)r%   ÚdomZownerDocument)r%   Úr©r5   r)   r.   r/   ÚcreateRawTextNode9   s   z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Úxml.dom.minidomr"   r#   r7   ÚcreateTextNode)r)   Úsettingsr"   r#   r:   r.   r9   r/   r;   *   s   zMathMLPrinterBase.__init__c                 C   s,   t  | |¡}| ¡ }| dd¡}| ¡ }|S )z2
        Prints the expression as MathML.
        ÚasciiÚxmlcharrefreplace)r   Ú_printZtoxmlÚencodeÚdecode)r)   ÚexprZmathMLZunistrZxmlbstrÚresr.   r.   r/   ÚdoprintA   s
   zMathMLPrinterBase.doprintc                    sV   ddl m}m}m‰ m‰ d‡ ‡fdd„	}|j| _||_d‡fdd„	}|j| _||_d S )Nr   )ÚElementr#   ÚNodeÚ_write_datar$   c           	         s  |  |d | j ¡ |  ¡ }t| ¡ ƒ}| ¡  |D ]}|  d| ¡ ˆ||| jƒ |  d¡ q| jr{|  d¡ t| jƒdkrU| jd j	ˆ j
krU| jd  |ddd¡ n|  |¡ | jD ]}| ||| ||¡ q]|  |¡ |  d| j|f ¡ d S |  d	| ¡ d S )
Nú<z %s="ú"ú>é   r   r$   z</%s>%sz/>%s)r&   ZtagNameZ_get_attributesÚlistÚkeysÚsortÚvalueZ
childNodesÚlenZnodeTypeZ	TEXT_NODEr0   )	r)   r*   r+   r,   r-   ZattrsZa_namesZa_nameZnode©rH   rI   r.   r/   r0   U   s,   
ÿ

ÿ
z/MathMLPrinterBase.apply_patch.<locals>.writexmlc                    s   ˆ |d|| j |f ƒ d S )Nz%s%s%s)r%   r(   )rI   r.   r/   r0   t   s   r1   )r<   rG   r#   rH   rI   r0   Ú_Element_writexml_oldÚ_Text_writexml_old)r)   rG   r#   r0   r.   rS   r/   Úapply_patchK   s   
zMathMLPrinterBase.apply_patchc                 C   s$   ddl m}m} | j|_| j|_d S )Nr   )rG   r#   )r<   rG   r#   rT   r0   rU   )r)   rG   r#   r.   r.   r/   Úrestore_patchy   s   zMathMLPrinterBase.restore_patchr6   )	r2   r3   r4   Ú__doc__Z_default_settingsr;   rF   rV   rW   r.   r.   r.   r/   r      s*    ò

.r   c                   @   s:  e Zd ZdZdZdd„ Zdd„ ZdHdd	„Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ ZeZeZd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Z d8d9„ Z!d:d;„ Z"d<d=„ Z#d>d?„ Z$d@dA„ Z%e"Z&e"Z'e"Z(dBdC„ Z)dDdE„ Z*dFdG„ Z+dS )IÚMathMLContentPrinterz}Prints an expression to the Content MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter4.html
    Z_mathml_contentc                 C   s€  i dd“dd“dd“dd“d	d“d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“i d d	“d!d"“d#d#“d$d$“d%d%“d&d&“d'd'“d(d(“d)d)“d*d*“d+d+“d,d,“d-d-“d.d.“d/d0“d1d2“d3d4“¥i d5d6“d7d8“d9d:“d;d8“d<d=“d>d?“d@dA“dBdC“dDdE“dFdG“dHdI“dJdK“dLdM“dNdO“dPdQ“dRdS“dTdU“¥dVdWdXœ¥}|j jD ]}|j}||v r·||   S q¨|j j}| ¡ S )Yú)Returns the MathML tag for an expression.ZAddÚplusr   ÚtimesÚ
DerivativeZdiffÚNumberÚcnÚintÚPowÚpowerZMaxÚmaxZMinÚminZAbsÚabsZAndÚandZOrÚorZXorÚxorZNotÚnotZImpliesZimpliesÚSymbolÚciÚMatrixSymbolZRandomSymbolÚIntegralÚSumÚsumÚsinÚcosÚtanÚcotZcscZsecZsinhZcoshZtanhZcothZcschZsechÚasinÚarcsinÚasinhÚarcsinhÚacosÚarccosÚacoshÚarccoshÚatanÚarctanÚatanhÚarctanhÚatan2ÚacotÚarccotZacothZarccothZasecZarcsecZasechZarcsechZacscZarccscZacschZarccschÚlogÚlnÚEqualityÚeqÚ
UnequalityZneqÚGreaterThanZgeqÚLessThanZleqÚStrictGreaterThanÚgtÚStrictLessThanÚltÚunionZ	intersect)ÚUnionÚIntersection©Ú	__class__Ú__mro__r2   Úlower)r)   ÚeÚ	translateÚclsÚnr.   r.   r/   Ú
mathml_tag†   sâ   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù(Ø)×*Ö+Õ,Ô-Ó.Ò/Ñ0Ð1Ï2Î3Í4Ë8ÿzMathMLContentPrinter.mathml_tagc           	      C   s<  t |ƒr| j d¡}| | j d¡¡ | |  | ¡¡ |S ddlm} ||ƒ\}}|tjurP| j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tju rht|ƒdkrh|  	|d ¡S | jdkrtt |¡ ¡ }| j d¡}| | j d¡¡ |dkr| |  	|¡¡ |D ]
}| |  	|¡¡ q‘|S )	NÚapplyÚminusr   ©ÚfractionÚdividerM   Úoldr\   )r   r7   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyr   r   ÚOnerA   Úas_coeff_mulrR   r   r   Ú
_from_argsÚas_ordered_factors)	r)   rD   Úxr   ÚnumerÚdenomÚcoeffÚtermsÚtermr.   r.   r/   r¢   È   s2   

zMathMLContentPrinter._print_MulNc                 C   s
  | j ||d}|  |d ¡}g }|dd … D ]I}t|ƒrG| j d¡}| | j d¡¡ | |¡ | |  | ¡¡ |}||d krF| |¡ q| |¡ |  |¡}||d kr_| |  |¡¡ qt|ƒdkrh|S | j d¡}| | j d¡¡ |rƒ| | d¡¡ |sy|S )N©r   r   rM   rš   r›   éÿÿÿÿr[   )	Ú_as_ordered_termsrA   r   r7   r    r¡   ÚappendrR   Úpop)r)   rD   r   ÚargsZlastProcessedZ	plusNodesÚargr¨   r.   r.   r/   Ú
_print_Addë   s4   

€

€ÿzMathMLContentPrinter._print_Addc                 C   s®   |j d jdkrtdƒ‚| j d¡}t|j ƒD ]=\}\}}|t|j ƒd kr9|dkr9| j d¡}| |  |¡¡ n| j d¡}| |  |¡¡ | |  |¡¡ | |¡ q|S )Nr¯   Tz¼All 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.Z	piecewiserM   Z	otherwiseÚpiece)	r³   ZcondÚ
ValueErrorr7   r    Ú	enumeraterR   r¡   rA   )r)   rD   ÚrootÚir•   Úcr¶   r.   r.   r/   Ú_print_Piecewise  s   z%MathMLContentPrinter._print_Piecewisec              	   C   s^   | j  d¡}t|jƒD ]!}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q| |¡ q|S )NZmatrixZ	matrixrow)r7   r    ÚrangeÚrowsÚcolsr¡   rA   )r)   Úmr¨   rº   Zx_rÚjr.   r.   r/   Ú_print_MatrixBase  s   z&MathMLContentPrinter._print_MatrixBasec                 C   s°   |j dkr| j d¡}| | j t|jƒ¡¡ |S | j d¡}| | j d¡¡ | j d¡}| | j t|jƒ¡¡ | j d¡}| | j t|j ƒ¡¡ | |¡ | |¡ |S )NrM   r_   rš   rž   )Úqr7   r    r¡   r=   ÚstrÚp)r)   r•   r¨   ÚxnumZxdenomr.   r.   r/   Ú_print_Rational%  s   


z$MathMLContentPrinter._print_Rationalc                 C   s–   | j  d¡}| | j  |  |¡¡¡ | j  d¡}| j  d¡}| |  |jd ¡¡ | |  |jd ¡¡ | |¡ | |¡ | |  |jd ¡¡ |S )Nrš   ÚbvarÚlowlimitrM   é   r   )r7   r    r¡   r™   rA   r³   )r)   r•   r¨   Úx_1Úx_2r.   r.   r/   Ú_print_Limit7  s   

z!MathMLContentPrinter._print_Limitc                 C   ó   | j  d¡S )NZ
imaginaryi©r7   r    ©r)   r•   r.   r.   r/   Ú_print_ImaginaryUnitE  ó   z)MathMLContentPrinter._print_ImaginaryUnitc                 C   rÎ   )NZ
eulergammarÏ   rÐ   r.   r.   r/   Ú_print_EulerGammaH  rÒ   z&MathMLContentPrinter._print_EulerGammac                 C   ó"   | j  d¡}| | j  d¡¡ |S )zvWe use unicode #x3c6 for Greek letter phi as defined here
        http://www.w3.org/2003/entities/2007doc/isogrk1.htmlr_   u   Ï†©r7   r    r¡   r=   ©r)   r•   r¨   r.   r.   r/   Ú_print_GoldenRatioK  s   z'MathMLContentPrinter._print_GoldenRatioc                 C   rÎ   )NZexponentialerÏ   rÐ   r.   r.   r/   Ú_print_Exp1R  rÒ   z MathMLContentPrinter._print_Exp1c                 C   rÎ   )NZpirÏ   rÐ   r.   r.   r/   Ú	_print_PiU  rÒ   zMathMLContentPrinter._print_Pic                 C   rÎ   )NÚinfinityrÏ   rÐ   r.   r.   r/   Ú_print_InfinityX  rÒ   z$MathMLContentPrinter._print_Infinityc                 C   rÎ   )NZ
notanumberrÏ   rÐ   r.   r.   r/   Ú
_print_NaN[  rÒ   zMathMLContentPrinter._print_NaNc                 C   rÎ   )NZemptysetrÏ   rÐ   r.   r.   r/   Ú_print_EmptySet^  rÒ   z$MathMLContentPrinter._print_EmptySetc                 C   rÎ   )NÚtruerÏ   rÐ   r.   r.   r/   Ú_print_BooleanTruea  rÒ   z'MathMLContentPrinter._print_BooleanTruec                 C   rÎ   )NZfalserÏ   rÐ   r.   r.   r/   Ú_print_BooleanFalsed  rÒ   z(MathMLContentPrinter._print_BooleanFalsec                 C   s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nrš   r›   rÚ   )r7   r    r¡   rÖ   r.   r.   r/   Ú_print_NegativeInfinityg  s   z,MathMLContentPrinter._print_NegativeInfinityc                    s*   ‡ ‡‡fdd„‰t ˆ jƒ}| ¡  ˆ|ƒS )Nc                    s8  ˆj  d¡}| ˆj  ˆ ˆ ¡¡¡ ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| d ƒdkr_ˆj  d¡}| ˆ | d d ¡¡ | |¡ ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| d ƒdkr~ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| ƒdkr| ˆ ˆ j¡¡ |S | ˆ| dd … ƒ¡ |S )	Nrš   rÈ   r   é   rÉ   rM   ZuplimitrÊ   )r7   r    r¡   r™   rA   rR   Úfunction)Úlimitsr¨   Z	bvar_elemÚlow_elemÚup_elem©r•   Ú
lime_recurr)   r.   r/   rè   n  s*   



ÿz8MathMLContentPrinter._print_Integral.<locals>.lime_recur)rN   rä   Úreverse)r)   r•   rä   r.   rç   r/   Ú_print_Integralm  s   
z$MathMLContentPrinter._print_Integralc                 C   s
   |   |¡S r6   )rê   rÐ   r.   r.   r/   Ú
_print_SumŠ  s   
zMathMLContentPrinter._print_Sumc                    sF  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰t|jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j  d¡}| ˆ j  |¡¡ |sh|sO| ˆ j  |¡¡ |S ˆ j  d	¡}| |¡ | ||ƒ¡ | |¡ |S |sƒˆ j  d
¡}	|	 |¡ |	 ||ƒ¡ | |	¡ |S ˆ j  d¡}
|
 |¡ |
 ||ƒ¡ |
 ||ƒ¡ | |
¡ |S )Nc                    ó¬   t | ƒdkrCˆ j d¡}t| ƒD ]0\}}|dkr,ˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q|S ˆ j d¡}| ˆ j | d ¡¡ |S )NrM   zmml:mrowr   zmml:moú úmml:mi©rR   r7   r    r¸   r¡   r=   ©ÚitemsÚmrowrº   ÚitemÚmoÚmi©r)   r.   r/   Újoin’  ó   
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S   ó   | t v r	t  | ¡S | S r6   ©r   Úget©Úsr.   r.   r/   r–   ¤  ó   
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                    ó   g | ]}ˆ |ƒ‘qS r.   r.   ©Ú.0Úsup©r–   r.   r/   Ú
<listcomp>¬  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                    rÿ   r.   r.   ©r  Úsubr  r.   r/   r  ­  r  rî   zmml:msubzmml:msupzmml:msubsup)r7   r    r™   r	   Únamer¡   r=   )r)   Úsymrk   r÷   r  ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr.   ©r)   r–   r/   Ú_print_Symbol  s<   ð

õ

û

z"MathMLContentPrinter._print_Symbolc                 C   sô   | j d rR|jjrR|jjdkrR| j d¡}| | j d¡¡ |jjdkrG| j d¡}| j d¡}| | j t	|jjƒ¡¡ | |¡ | |¡ | |  
|j¡¡ |S | j d¡}| j |  |¡¡}| |¡ | |  
|j¡¡ | |  
|j¡¡ |S )Nr    rM   rš   r¹   rÊ   Údegreer_   )Ú	_settingsÚexpÚis_RationalrÅ   r7   r    r¡   rÃ   r=   rÄ   rA   Úbaser™   )r)   r•   r¨   ZxmldegZxmlcnrË   r.   r.   r/   Ú
_print_PowÊ  s&   
ÿ


zMathMLContentPrinter._print_Powc                 C   ó,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r6   ©r7   r    r™   r¡   r=   rÄ   rÖ   r.   r.   r/   Ú_print_Numberá  ó   z"MathMLContentPrinter._print_Numberc                 C   s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r6   )	r7   r    r™   Úmlib_to_strÚ_mpf_r   Ú_precr¡   r=   )r)   r•   r¨   Zrepr_er.   r.   r/   Ú_print_Floatæ  s   z!MathMLContentPrinter._print_Floatc                 C   s¸   | j  d¡}|  |¡}t|jƒrd}| | j  |¡¡ | j  d¡}t|jƒD ]%\}}| |  |¡¡ |dkrK| j  d¡}| |  t	|ƒ¡¡ | |¡ q&| |¡ | |  |j¡¡ |S )Nrš   ZpartialdiffrÈ   rM   r  )
r7   r    r™   r
   rD   r¡   ÚreversedÚvariable_countrA   r   )r)   r•   r¨   Zdiff_symbolrË   r	  r\   r  r.   r.   r/   Ú_print_Derivativeì  s    


€
z&MathMLContentPrinter._print_Derivativec                 C   sD   | j  d¡}| | j  |  |¡¡¡ |jD ]
}| |  |¡¡ q|S ©Nrš   )r7   r    r¡   r™   r³   rA   ©r)   r•   r¨   r´   r.   r.   r/   Ú_print_Functionÿ  s
   
z$MathMLContentPrinter._print_Functionc                 C   s2   | j  |  |¡¡}|jD ]
}| |  |¡¡ q|S r6   )r7   r    r™   r³   r¡   rA   r$  r.   r.   r/   Ú_print_Basic  s   
z!MathMLContentPrinter._print_Basicc                 C   sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]
}| |  |¡¡ q|S r#  )r7   r    r™   r¡   r³   rA   )r)   r•   r¨   rË   r´   r.   r.   r/   Ú_print_AssocOp  s   

z#MathMLContentPrinter._print_AssocOpc                 C   sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S r#  )r7   r    r¡   r™   rA   ÚlhsÚrhsrÖ   r.   r.   r/   Ú_print_Relational  s
   z&MathMLContentPrinter._print_Relationalc                 C   ó*   | j  d¡}|D ]
}| |  |¡¡ q|S )zfMathML reference for the <list> element:
        http://www.w3.org/TR/MathML2/chapter4.html#contm.listrN   ©r7   r    r¡   rA   )r)   ÚseqÚdom_elementró   r.   r.   r/   Ú_print_list  s   z MathMLContentPrinter._print_listc                 C   r  r6   r  ©r)   rÅ   r.  r.   r.   r/   Ú
_print_int#  r  zMathMLContentPrinter._print_intc                 C   s,   | j  d¡}|jD ]
}| |  |¡¡ q	|S )NÚset©r7   r    r³   r¡   rA   r$  r.   r.   r/   Ú_print_FiniteSet,  s   
z%MathMLContentPrinter._print_FiniteSetc                 C   ó>   | j  d¡}| | j  d¡¡ |jD ]
}| |  |¡¡ q|S )Nrš   Zsetdiff©r7   r    r¡   r³   rA   r$  r.   r.   r/   Ú_print_Complement2  ó
   
z&MathMLContentPrinter._print_Complementc                 C   r5  )Nrš   Zcartesianproductr6  r$  r.   r.   r/   Ú_print_ProductSet9  r8  z&MathMLContentPrinter._print_ProductSetr6   ),r2   r3   r4   rX   Úprintmethodr™   r¢   rµ   r¼   rÂ   rÇ   rÍ   rÑ   rÓ   r×   rØ   rÙ   rÛ   rÜ   rÝ   rß   rà   rá   rê   rë   r  Ú_print_MatrixSymbolÚ_print_RandomSymbolr  r  r  r"  r%  r&  r'  r*  r/  r1  Ú_print_ImpliesÚ
_print_NotÚ
_print_Xorr4  r7  r9  r.   r.   r.   r/   rY      sT    B
#	8rY   c                   @   sD  e Zd ZdZdZdd„ Zddd„Zdd	„ Zddd„Zdd„ Z	ddd„Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zdd6d7„Zd8d9„ ZeZd:d;„ Z d<d=„ Z!d>d?„ Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)dNdO„ Z*dPdQ„ Z+dRdS„ Z,dTdU„ Z-dVdW„ Z.ddXdY„Z/e/Z0dZd[„ Z1dd\d]„Z2dd^d_„Z3d`da„ Z4dbdc„ Z5ddde„ Z6dfdg„ Z7dhdi„ Z8djdk„ Z9dldm„ Z:dndo„ Z;dpdq„ Z<e<Z=drds„ Z>dtdu„ Z?dvdw„ Z@dxdy„ ZAdzd{„ ZBd|d}„ ZCd~d„ ZDd€d„ ZEd‚dƒ„ ZFeFZGeFZHd„d…„ ZId†d‡„ ZJdˆd‰„ ZKeK ZLZMdŠd‹„ ZNdŒd„ ZOdŽd„ ZPdd‘„ ZQd’d“„ ZRd”d•„ ZSd–d—„ ZTd˜d™„ ZUdšd›„ ZVdœd„ ZWdždŸ„ ZXd d¡„ ZYd¢d£„ ZZd¤d¥„ Z[d¦d§„ Z\d¨d©„ Z]dªd«„ Z^d¬d­„ Z_d®d¯„ Z`d°d±„ Zad²d³„ ZbebZcd´dµ„ Zdd¶d·„ Zed¸d¹„ Zfdºd»„ Zgd¼d½„ Zhd¾d¿„ ZidÀdÁ„ ZjdÂdÃ„ ZkdÄdÅ„ ZldÆdÇ„ ZmdÈdÉ„ ZndÊdË„ ZodÌdÍ„ ZpdÎdÏ„ ZqdÐdÑ„ ZrdÒdÓ„ ZsdÔdÕ„ ZtdÖd×„ ZudØdÙ„ ZvdÚdÛ„ ZwdÜdÝ„ ZxdÞdß„ Zydàdá„ Zzdâdã„ Z{dädå„ Z|dædç„ Z}dèdé„ Z~dêdë„ Zdìdí„ Z€dîdï„ Zdðdñ„ Z‚dòdó„ Zƒdôdõ„ Z„död÷„ Z…dødù„ Z†dúdû„ Z‡düdý„ Zˆdþdÿ„ Z‰d d„ ZŠd
S (  ÚMathMLPresentationPrinterz‚Prints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    Z_mathml_presentationc                    sJ  i dd“dd“dd“dd“dd	“d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“i dd“d d“d!d"“d#d$“d%d&“d'd(“d)d*“d+d,“d-d.“d/d0“d1d2“d3d4“d5d6“d7d8“d9d8“d:d;“d<d=“¥d>d?d@dAdBdCdDdEdFd@dAdGdHdIœ¥}‡ fdJdK„}|j jD ]}|j}||v r“||   S q„|j jdLkr|ƒ S |j j}| ¡ S )MrZ   r^   ÚmnZLimitz&#x2192;r]   ú&dd;r`   rj   rõ   rm   z&int;rn   z&#x2211;rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r‚   r€   r…   ú=r‡   z&#x2260;rˆ   z&#x2265;r‰   z&#x2264;rŠ   rL   rŒ   rJ   Zlerchphiú&#x3A6;Zzetaz&#x3B6;Zdirichlet_etaz&#x3B7;Z
elliptic_kz&#x39A;Z
lowergammaú&#x3B3;Z
uppergammaz&#x393;ZgammaZtotientz&#x3D5;Zreduced_totientz&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;)ZprimenuZ
primeomegaZfresnelsZfresnelcZLambertWZ	HeavisideZBooleanTrueZBooleanFalseÚNoneTypeZmathieusZmathieucZmathieusprimeZmathieucprimec                      st   ˆ j d d u sˆ j d dkrdS ˆ j d dkrdS ˆ j d dkr"dS ˆ j d dkr+d	S tˆ j d tƒs5t‚ˆ j d S )
Nr   rJ  ú&InvisibleTimes;r\   ú&#xD7;Údotr   Zldotz&#x2024;)r  Ú
isinstancerÄ   Ú	TypeErrorr.   rö   r.   r/   Úmul_symbol_selection~  s   ÿ
zBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionr   r‘   )r)   r•   r–   rQ  r—   r˜   r.   rö   r/   r™   J  sº   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ñ2ÿz$MathMLPresentationPrinter.mathml_tagFc                 C   sF   t |ƒ}||k s|s||kr| j d¡}| |  |¡¡ |S |  |¡S ©NÚmfenced)r   r7   r    r¡   rA   )r)   ró   ÚlevelÚstrictZprec_valÚbracr.   r.   r/   Úparenthesize–  s   
z&MathMLPresentationPrinter.parenthesizec                    sf   ‡ fdd„}ˆ j  d¡}t|ƒr,ˆ j  d¡}| ˆ j  d¡¡ | |¡ || |ƒ}|S |||ƒ}|S )Nc                    s„  ddl m} || ƒ\}}|tjurEˆ j d¡}ˆ jd r*tt| ƒƒdk r*| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tju rbt|	ƒdkrb| ˆ  
|	d ¡¡ |S ˆ jd	krnt |	¡ ¡ }	|dkr“ˆ  
|¡}
ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |
¡ | |¡ |	D ]*}| ˆ  |td ¡¡ ||	d ks¿ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |¡ q•|S )Nr   rœ   Úmfracr   é   ÚbevelledrÞ   rM   rŸ   rô   r   r¯   )r£   r   r   r¤   r7   r    r  rR   rÄ   ÚsetAttributerA   r¡   r¥   r   r   r¦   r§   r=   r™   rW  r   )rD   rò   r   r©   rª   ÚfracrÆ   Zxdenr«   r¬   r¨   Úyr­   rö   r.   r/   Úmultiply¡  s@   










€z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyrò   rô   ú-)r7   r    r   r¡   r=   )r)   rD   r^  rò   r¨   r.   rö   r/   r¢   Ÿ  s   "

þz$MathMLPresentationPrinter._print_MulNc                 C   s´   | j  d¡}| j||d}| |  |d ¡¡ |dd … D ]:}t|ƒr9| j  d¡}| | j  d¡¡ |  | ¡}n| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ q|S )Nrò   r®   r   rM   rô   r_  ú+)r7   r    r°   r¡   rA   r   r=   )r)   rD   r   rò   r³   r´   r¨   r]  r.   r.   r/   rµ   Î  s   

z$MathMLPresentationPrinter._print_Addc              	   C   sÂ   | j  d¡}t|jƒD ],}| j  d¡}t|jƒD ]}| j  d¡}| |  |||f ¡¡ | |¡ q| |¡ q| jd dkrA|S | j  d¡}| jd dkrZ| dd	¡ | d
d¡ | |¡ |S )NZmtableZmtrZmtdr   r$   rS  r   Úcloseú]Úopen)	r7   r    r½   r¾   r¿   r¡   rA   r  r[  )r)   rÀ   Útablerº   r¨   rÁ   r]  rV  r.   r.   r/   rÂ   â  s    
z+MathMLPresentationPrinter._print_MatrixBasec                 C   s²   |j dk r
|j  }n|j }| j d¡}|s| jd r | dd¡ | |  |¡¡ | |  |j¡¡ |j dk rW| j d¡}| j d¡}| | j d¡¡ | |¡ | |¡ |S |S )	Nr   rX  r   rZ  rÞ   rò   rô   r_  )	rÅ   r7   r    r  r[  r¡   rA   rÃ   r=   )r)   r•   ZfoldedrÅ   r¨   rò   rô   r.   r.   r/   Ú_get_printed_Rationalô  s    




z/MathMLPresentationPrinter._get_printed_Rationalc                 C   s(   |j dkr|  |j¡S |  || jd ¡S )NrM   r   )rÃ   rA   rÅ   re  r  rÐ   r.   r.   r/   rÇ     s   
z)MathMLPresentationPrinter._print_Rationalc           	      C   sÜ   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | j  d¡}|  |jd ¡}| j  d¡}| | j  |  |¡¡¡ |  |jd ¡}| |¡ | |¡ | |¡ | |¡ | |¡ | |¡ | |  |jd ¡¡ |S )	Nrò   Úmunderrõ   ÚlimrM   rô   rÊ   r   )r7   r    r¡   r=   rA   r³   r™   )	r)   r•   rò   rf  rõ   r¨   rË   ZarrowrÌ   r.   r.   r/   rÍ     s"   





z&MathMLPresentationPrinter._print_Limitc                 C   rÔ   )Nrõ   z&ImaginaryI;rÕ   rÖ   r.   r.   r/   rÑ   %  ó   z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C   rÔ   )Nrõ   rD  rÕ   rÖ   r.   r.   r/   r×   *  rh  z,MathMLPresentationPrinter._print_GoldenRatioc                 C   rÔ   )Nrõ   z&ExponentialE;rÕ   rÖ   r.   r.   r/   rØ   /  rh  z%MathMLPresentationPrinter._print_Exp1c                 C   rÔ   )Nrõ   z&pi;rÕ   rÖ   r.   r.   r/   rÙ   4  rh  z#MathMLPresentationPrinter._print_Pic                 C   rÔ   )Nrõ   ú&#x221E;rÕ   rÖ   r.   r.   r/   rÛ   9  rh  z)MathMLPresentationPrinter._print_Infinityc                 C   sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nrò   rô   r_  )r7   r    r¡   r=   rÛ   )r)   r•   rò   r]  r¨   r.   r.   r/   rá   >  s   


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C   rÔ   )Nrõ   z&#x210F;rÕ   rÖ   r.   r.   r/   Ú_print_HBarG  rh  z%MathMLPresentationPrinter._print_HBarc                 C   rÔ   )Nrõ   rE  rÕ   rÖ   r.   r.   r/   rÓ   L  rh  z+MathMLPresentationPrinter._print_EulerGammac                 C   rÔ   )Nrõ   ZTribonacciConstantrÕ   rÖ   r.   r.   r/   Ú_print_TribonacciConstantQ  rh  z3MathMLPresentationPrinter._print_TribonacciConstantc                 C   s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr  r   ú&#x2020;©r7   r    r¡   rA   r³   r=   ©r)   r•   r  r.   r.   r/   Ú_print_DaggerV  s   z'MathMLPresentationPrinter._print_Daggerc                 C   sd   | j  d¡}| |  |jd ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ |S )Nrò   r   rô   z&#x2208;rM   rm  )r)   r•   rò   rô   r.   r.   r/   Ú_print_Contains\  s   
z)MathMLPresentationPrinter._print_Containsc                 C   rÔ   )Nrõ   z&#x210B;rÕ   rÖ   r.   r.   r/   Ú_print_HilbertSpacee  rh  z-MathMLPresentationPrinter._print_HilbertSpacec                 C   s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr  z	&#x1D49E;r   ©r7   r    r¡   r=   rA   r³   rn  r.   r.   r/   Ú_print_ComplexSpacej  s   z-MathMLPresentationPrinter._print_ComplexSpacec                 C   rÔ   )Nrõ   z&#x2131;rÕ   rÖ   r.   r.   r/   Ú_print_FockSpacep  rh  z*MathMLPresentationPrinter._print_FockSpacec           	      C   s¶  ddddœ}| j  d¡}t|jƒdkr7tdd„ |jD ƒƒr7| j  d	¡}| | j  |t|jƒ ¡¡ | |¡ nnt|jƒD ]h}| j  d	¡}| | j  |d
 ¡¡ t|ƒd
krZ| |¡ t|ƒdkrz| j  d¡}| |¡ | |  |d
 ¡¡ | |¡ t|ƒdkr¤| j  d¡}| |¡ | |  |d
 ¡¡ | |  |d ¡¡ | |¡ q<| | j	|j
td dd¡ t|jƒD ] }| j  d	¡}| | j  d¡¡ | |¡ | |  |d ¡¡ q¸|S )Nz&#x222B;z&#x222C;z&#x222D;)rM   rÊ   râ   rò   râ   c                 s   s    | ]	}t |ƒd kV  qdS )rM   N)rR   )r  rg  r.   r.   r/   Ú	<genexpr>z  s   € z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>rô   rM   rÊ   r  r  r   T©rU  rB  r   )r7   r    rR   rä   Úallr¡   r=   r   rA   rW  rã   r   )	r)   rD   Z
intsymbolsrò   rô   rg  r  r  Údr.   r.   r/   rê   v  s@   "




€ÿ
z)MathMLPresentationPrinter._print_Integralc                 C   s@  t |jƒ}| j d¡}|  |d d ¡}|  |d d ¡}| j d¡}| | j |  |¡¡¡ | j d¡}|  |d d ¡}| j d¡}	|	 | j d¡¡ | |¡ | |	¡ | |¡ | |¡ | |¡ | |¡ | j d¡}
|
 |¡ tt	|j
ƒƒdkrŠ|
 |  |j
¡¡ |
S | j d¡}| |  |j
¡¡ |
 |¡ |
S )	NZ
munderoverr   rM   rÊ   rô   rò   rC  rS  )rN   rä   r7   r    rA   r¡   r=   r™   rR   rÄ   rã   )r)   r•   rä   Zsubsuprå   ræ   ZsummandZlowÚvarZequalrò   Zfencer.   r.   r/   rë   œ  s2   







ü
z$MathMLPresentationPrinter._print_Sumr   c           	         s.  ‡ fdd„}dd„ ‰t |jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j d¡}| ˆ j |¡¡ t|ƒd	krYt|ƒd	krF|}nEˆ j d
¡}| |¡ | ||ƒ¡ n2t|ƒd	krrˆ j d¡}| |¡ | ||ƒ¡ nˆ j d¡}| |¡ | ||ƒ¡ | ||ƒ¡ |dkr•| dd¡ |S )Nc                    rì   )NrM   rò   r   rô   rí   rõ   rï   rð   rö   r.   r/   r÷   ¼  rø   z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S   rù   r6   rú   rü   r.   r.   r/   r–   Î  rþ   z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                    rÿ   r.   r.   r   r  r.   r/   r  Ö  r  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                    rÿ   r.   r.   r  r  r.   r/   r  ×  r  rõ   r   r  r  r  ÚboldÚmathvariant)r	   r  r7   r    r¡   r=   rR   r[  )	r)   r	  Ústyler÷   r  r
  r  r  r¨   r.   r  r/   r  »  s2   


z'MathMLPresentationPrinter._print_Symbolc                 C   s   | j || jd dS )Nr   )r|  )r  r  )r)   r	  r.   r.   r/   r;  ñ  s   ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C   s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseZnotationÚtopr   ©r7   r    r[  r¡   rA   r³   )r)   rD   Úencr.   r.   r/   Ú_print_conjugate÷  s   z*MathMLPresentationPrinter._print_conjugatec                 C   sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nrò   ZFuncrô   )r7   r    r¡   rW  r   r=   )r)   ÚoprD   Úrowrô   r.   r.   r/   Ú_print_operator_afterý  s   
z/MathMLPresentationPrinter._print_operator_afterc                 C   ó   |   d|jd ¡S )Nú!r   ©rƒ  r³   ©r)   rD   r.   r.   r/   Ú_print_factorial  ó   z*MathMLPresentationPrinter._print_factorialc                 C   r„  )Nz!!r   r†  r‡  r.   r.   r/   Ú_print_factorial2  r‰  z+MathMLPresentationPrinter._print_factorial2c                 C   s^   | j  d¡}| j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | |¡ |S )NrS  rX  ZlinethicknessÚ0r   rM   r~  )r)   rD   rV  r\  r.   r.   r/   Ú_print_binomial  s   
z)MathMLPresentationPrinter._print_binomialc                 C   s^  |j jrht|j jƒdkrh|j jdkrh| jd rh|j jdkr,| j d¡}| |  	|j
¡¡ |j jdkrK| j d¡}| |  	|j
¡¡ | |  	|j j¡¡ |j jdkrf| j d¡}| |  	d¡¡ | |¡ |S |S |j jrÌ|j jdkrÌ|j jr«| j d¡}| |  	d¡¡ | j d¡}| |  |j
td	 ¡¡ | |  |j  | jd
 ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  |j | jd
 ¡¡ |S |j jr| j d¡}| |  	d¡¡ |j dkrï| |  	|j
¡¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j  ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j ¡¡ |S )NrM   r    rÊ   ZmsqrtZmrootr¯   rX  r  ra   r   )r  r  re   rÅ   rÃ   r  r7   r    r¡   rA   r  Zis_negativerW  r   re  )r)   r•   r¨   r\  r}  r.   r.   r/   r    s`   $ÿ
ÿ
ÿ

ü
z$MathMLPresentationPrinter._print_Powc                 C   r  r6   r  rÖ   r.   r.   r/   r  J  r  z'MathMLPresentationPrinter._print_Numberc                 C   sL   | j  d¡}| dd¡ | dd¡ | |  |j¡¡ | |  |j¡¡ |S )NrS  ra  õ   âŸ©rc  õ   âŸ¨)r7   r    r[  r¡   rA   rd   rc   )r)   rº   rV  r.   r.   r/   Ú_print_AccumulationBoundsO  s   z3MathMLPresentationPrinter._print_AccumulationBoundsc                 C   sž  t |jƒrd}n|  |¡}| j d¡}d}t|jƒD ]M\}}||7 }|dkrI| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ | |¡ |  	|¡}	| |	¡ q| j d¡}
|dkr•| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ |
 |¡ | j d¡}| j d¡}| |
¡ | |¡ | |¡ | |  	|j¡¡ |S )Nz&#x2202;rò   r   rÊ   r  rô   rX  )
r
   rD   r™   r7   r    r   r!  r¡   r=   rA   )r)   r•   rx  rÀ   Zdimr	  Znumr¨   Zxxr]  Zmnumrò   r\  r.   r.   r/   r"  W  sF   









z+MathMLPresentationPrinter._print_Derivativec                 C   sœ   | j  d¡}| j  d¡}|  |¡dkr"| jd r"| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}|jD ]
}| |  |¡¡ q7| |¡ | |¡ |S )Nrò   rõ   rƒ   r   r„   rS  )r7   r    r™   r  r¡   r=   r³   rA   )r)   r•   rò   r¨   r]  r´   r.   r.   r/   r%  ‡  s   


z)MathMLPresentationPrinter._print_Functionc                 C   s`  t |jƒ}tj|j|dd}| jd }| j d¡}d|v r| d¡\}}|d dkr0|dd … }| j d	¡}| 	| j 
|¡¡ | 	|¡ | j d
¡}	|	 	| j 
|¡¡ | 	|	¡ | j d¡}
| j d	¡}| 	| j 
d¡¡ |
 	|¡ | j d	¡}| 	| j 
|¡¡ |
 	|¡ | 	|
¡ |S |dkr–|  d ¡S |dkrŸ|  d ¡S | j d	¡}| 	| j 
|¡¡ |S )NT)Zstrip_zerosr!   rò   r•   r   r`  rM   rA  rô   r  Z10z+infz-inf)r   r  Úmlibr   r  r  r7   r    Úsplitr¡   r=   rÛ   rá   )r)   rD   ZdpsZstr_realZ	separatorrò   Zmantr  rA  rô   r  r.   r.   r/   r  •  s<   








z&MathMLPresentationPrinter._print_Floatc                 C   s   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | j  d¡}| |  |jd ¡¡ | |¡ |S )Nrò   r  rõ   ZLir   rS  rM   rr  )r)   rD   rò   rÀ   rõ   rV  r.   r.   r/   Ú_print_polylog¼  s   


z(MathMLPresentationPrinter._print_polylogc                 C   sp   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | j  d¡}|jD ]
}| |  |¡¡ q&| |¡ |S )Nrò   rõ   rS  ©r7   r    r¡   r=   r™   r³   rA   )r)   r•   rò   rõ   rV  r´   r.   r.   r/   r&  Ê  s   


z&MathMLPresentationPrinter._print_Basicc                 C   sB   | j  d¡}| j  d¡}|jD ]
}| |  |¡¡ q| |¡ |S )Nrò   rS  r3  )r)   r•   rò   r¨   r´   r.   r.   r/   Ú_print_TupleÕ  s   

z&MathMLPresentationPrinter._print_Tuplec                 C   sÂ   | j  d¡}| j  d¡}|j|jkr(| dd¡ | dd¡ | |  |j¡¡ n2|jr2| dd¡ n| dd¡ |jrB| dd	¡ n| dd
¡ | |  |j¡¡ | |  |j¡¡ | |¡ |S )Nrò   rS  ra  ú}rc  ú{ú)rb  ú(r   )	r7   r    ÚstartÚendr[  r¡   rA   Z
right_openZ	left_open)r)   rº   rò   rV  r.   r.   r/   Ú_print_IntervalÝ  s    
z)MathMLPresentationPrinter._print_Intervalc                 C   sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrò   rS  ra  ú|rc  r   r~  )r)   rD   r  rò   r¨   r.   r.   r/   Ú
_print_Absõ  ó   
z$MathMLPresentationPrinter._print_Absc                 C   sj   | j  d¡}| j  d¡}| dd¡ | | j  |¡¡ | |¡ | j  d¡}| |  |¡¡ | |¡ |S )Nrò   rõ   r{  ZfrakturrS  )r7   r    r[  r¡   r=   rA   )r)   r»   rD   rò   rõ   rV  r.   r.   r/   Ú_print_re_im   s   

z&MathMLPresentationPrinter._print_re_imc                 C   r„  )NÚRr   ©rŸ  r³   ©r)   rD   r  r.   r.   r/   Ú	_print_re  r‰  z#MathMLPresentationPrinter._print_rec                 C   r„  )NÚIr   r¡  r¢  r.   r.   r/   Ú	_print_im  r‰  z#MathMLPresentationPrinter._print_imc                 C   sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]
}| |  |¡¡ q |S )Nrò   rõ   r“  )r)   r•   rò   rõ   r´   r.   r.   r/   r'    s   

z(MathMLPresentationPrinter._print_AssocOpc                 C   sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]!}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q|S )Nrò   r   rM   rô   )r7   r    r¡   rW  r³   r=   )r)   rD   ÚsymbolÚprecrò   r´   r¨   r]  r.   r.   r/   Ú_print_SetOp  s   
z&MathMLPresentationPrinter._print_SetOpc                 C   ó   t d }|  |d|¡S )Nr   z&#x222A;©r   r¨  ©r)   rD   r§  r.   r.   r/   Ú_print_Union%  ó   z&MathMLPresentationPrinter._print_Unionc                 C   r©  )Nr   z&#x2229;rª  r«  r.   r.   r/   Ú_print_Intersection)  r­  z-MathMLPresentationPrinter._print_Intersectionc                 C   r©  )NZ
Complementz&#x2216;rª  r«  r.   r.   r/   r7  -  r­  z+MathMLPresentationPrinter._print_Complementc                 C   r©  )NZSymmetricDifferenceú&#x2206;rª  r«  r.   r.   r/   Ú_print_SymmetricDifference1  r­  z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C   r©  )NZ
ProductSetz&#x00d7;rª  r«  r.   r.   r/   r9  5  r­  z+MathMLPresentationPrinter._print_ProductSetc                 C   ó   |   |j¡S r6   )Ú
_print_setr³   )r)   rý   r.   r.   r/   r4  9  rÒ   z*MathMLPresentationPrinter._print_FiniteSetc                 C   sN   t |td}| j d¡}| dd¡ | dd¡ |D ]
}| |  |¡¡ q|S )N©ÚkeyrS  ra  r•  rc  r–  )Úsortedr   r7   r    r[  r¡   rA   )r)   rý   rñ   rV  ró   r.   r.   r/   r²  <  s   z$MathMLPresentationPrinter._print_setc                 C   sÜ   | j  d¡}|d jr&|d js&| j  d¡}| |  |d ¡¡ | |¡ n
| |  |d ¡¡ |dd … D ]5}| j  d¡}| | j  |¡¡ |jr\|js\| j  d¡}| |  |¡¡ n|  |¡}| |¡ | |¡ q6|S )Nrò   r   rS  rM   rô   )r7   r    Ú
is_BooleanZis_Notr¡   rA   r=   )r)   r³   r¦  rò   rV  r´   r¨   r]  r.   r.   r/   Ú_print_LogOpG  s    

z&MathMLPresentationPrinter._print_LogOpc                 C   s¨  ddl m} ||jkr|  |j¡S t||ƒr| ¡  ¡ }nd|fg}| j d¡}|D ]§\}}t	|j
 ¡ ƒ}|jdd„ d t|ƒD ]\}\}	}
|
dkrj|ra| j d¡}| | j d	¡¡ | |¡ | |  |	¡¡ qA|
d
kr‹| j d¡}| | j d¡¡ | |¡ | |  |	¡¡ qA|r¡| j d¡}| | j d	¡¡ | |¡ | j d¡}| |  |
¡¡ | |¡ | j d¡}| | j d¡¡ | |¡ | |  |	¡¡ qAq*|S )Nr   )ÚVectorrò   c                 S   s   | d   ¡ S )Nr   )Ú__str__)r¨   r.   r.   r/   Ú<lambda>i  s    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>r³  rM   rô   r`  r¯   r_  rS  rL  )Zsympy.vectorr¸  ZzerorA   rO  Zseparaterñ   r7   r    rN   Z
componentsrP   r¸   r¡   r=   )r)   rD   r¸  rñ   rò   ÚsystemZvectZ
inneritemsrº   ÚkÚvrô   Zmbracr.   r.   r/   Ú_print_BasisDependent[  sF   







éz/MathMLPresentationPrinter._print_BasisDependentc                 C   ó   t |jtd}|  |d¡S )Nr³  z&#x2227;©rµ  r³   r   r·  ©r)   rD   r³   r.   r.   r/   Ú
_print_And…  ó   z$MathMLPresentationPrinter._print_Andc                 C   r¿  )Nr³  z&#x2228;rÀ  rÁ  r.   r.   r/   Ú	_print_Or‰  rÃ  z#MathMLPresentationPrinter._print_Orc                 C   r¿  )Nr³  z&#x22BB;rÀ  rÁ  r.   r.   r/   r?    rÃ  z$MathMLPresentationPrinter._print_Xorc                 C   s   |   |jd¡S )Nz&#x21D2;)r·  r³   r‡  r.   r.   r/   r=  ‘  s   z(MathMLPresentationPrinter._print_Impliesc                 C   r¿  )Nr³  z&#x21D4;rÀ  rÁ  r.   r.   r/   Ú_print_Equivalent”  rÃ  z+MathMLPresentationPrinter._print_Equivalentc                 C   s‚   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ |jd jr2| j  d¡}| |  |jd ¡¡ n|  |jd ¡}| |¡ |S )Nrò   rô   z&#xAC;r   rS  )r7   r    r¡   r=   r³   r¶  rA   )r)   r•   rò   rô   r¨   r.   r.   r/   r>  ˜  s   

z$MathMLPresentationPrinter._print_Notc                 C   ó(   | j  d¡}| | j  |  |¡¡¡ |S ©Nrõ   ©r7   r    r¡   r=   r™   ©r)   r•   rõ   r.   r.   r/   Ú_print_bool¥  ó   z%MathMLPresentationPrinter._print_boolc                 C   rÆ  rÇ  rÈ  rÉ  r.   r.   r/   Ú_print_NoneType­  rË  z)MathMLPresentationPrinter._print_NoneTypec                 C   s,  d}| j  d¡}| dd¡ | dd¡ |jjr0|jjr0|jjr(|ddd	|f}nF|d	dd|f}n>|jjrA||d |j |d f}n-|jjrSt|ƒ}t	|ƒt	|ƒ|f}nt
|ƒd
krjt|ƒ}t	|ƒt	|ƒ||d f}nt|ƒ}|D ]#}||kr‹| j  d¡}| | j  |¡¡ | |¡ qp| |  |¡¡ qp|S )Nu   â€¦rS  ra  r•  rc  r–  r¯   r   rM   é   rõ   )r7   r    r[  r™  Zis_infiniteÚstopÚstepZis_positiveÚiterÚnextrR   Útupler¡   r=   rA   )r)   rý   ZdotsrV  ZprintsetÚitÚelrõ   r.   r.   r/   Ú_print_Range²  s0   z&MathMLPresentationPrinter._print_Rangec                 C   s€   t |jtd}| j d¡}| j d¡}| | j t|jƒ 	¡ ¡¡ | |¡ | j d¡}|D ]
}| |  
|¡¡ q.| |¡ |S )Nr³  rò   rô   rS  )rµ  r³   r   r7   r    r¡   r=   rÄ   Úfuncr”   rA   )r)   rD   r³   rò   rô   rV  r¦  r.   r.   r/   Ú_hprint_variadic_functionÒ  s   

z3MathMLPresentationPrinter._hprint_variadic_functionc                 C   s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr  r   )r7   r    r¡   rØ   rA   r³   )r)   rD   r  r.   r.   r/   Ú
_print_expà  s   z$MathMLPresentationPrinter._print_expc                 C   sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nrò   rô   )r7   r    r¡   rA   r(  r=   r™   r)  ©r)   r•   rò   r¨   r.   r.   r/   r*  æ  s   
z+MathMLPresentationPrinter._print_Relationalc                 C   r  r6   r  r0  r.   r.   r/   r1  ï  r  z$MathMLPresentationPrinter._print_intc                 C   sŠ   | j  d¡}|j\}}| j  d¡}| dd¡ | | j  |j| ¡¡ | |¡ | j  d¡}| dd¡ | | j  |j¡¡ | |¡ |S )Nr  rõ   r{  rz  )r7   r    Ú_idr[  r¡   r=   Z_variable_namesÚ_name)r)   r•   r  Úindexr»  rõ   r.   r.   r/   Ú_print_BaseScalarô  s   


z+MathMLPresentationPrinter._print_BaseScalarc                 C   sÈ   | j  d¡}|j\}}| j  d¡}| j  d¡}| dd¡ | | j  |j| ¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |¡ | j  d¡}| dd¡ | | j  |j¡¡ | |¡ |S )Nr  Úmoverrõ   r{  rz  rô   ú^)r7   r    rÚ  r[  r¡   r=   Z_vector_namesrÛ  )r)   r•   r  rÜ  r»  rÞ  rõ   rô   r.   r.   r/   Ú_print_BaseVector  s    




z+MathMLPresentationPrinter._print_BaseVectorc                 C   sl   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )NrÞ  rõ   r{  rz  r‹  rô   rß  ©r7   r    r[  r¡   r=   )r)   r•   rÞ  rõ   rô   r.   r.   r/   Ú_print_VectorZero  s   

z+MathMLPresentationPrinter._print_VectorZeroc                 C   óp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nrò   r   rô   rM  ©r7   r    Z_expr1Z_expr2r¡   rW  r   r=   ©r)   rD   rò   Zvec1Zvec2rô   r.   r.   r/   Ú_print_Cross  ó   
z&MathMLPresentationPrinter._print_Crossc                 C   óx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrò   rô   ú&#x2207;rM  r   ©r7   r    r¡   r=   rW  Z_exprr   ©r)   rD   rò   rô   r.   r.   r/   Ú_print_Curl)  ó   

z%MathMLPresentationPrinter._print_Curlc                 C   rè  )Nrò   rô   ré  r   r   rê  rë  r.   r.   r/   Ú_print_Divergence4  rí  z+MathMLPresentationPrinter._print_Divergencec                 C   rã  )Nrò   r   rô   r   rä  rå  r.   r.   r/   Ú
_print_Dot?  rç  z$MathMLPresentationPrinter._print_Dotc                 C   óP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrò   rô   ré  r   rê  rë  r.   r.   r/   Ú_print_GradientJ  ó   
z)MathMLPresentationPrinter._print_Gradientc                 C   rð  )Nrò   rô   r¯  r   rê  rë  r.   r.   r/   Ú_print_LaplacianR  rò  z*MathMLPresentationPrinter._print_Laplacianc                 C   ó.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nrõ   r{  Únormalz&#x2124;rá  rÖ   r.   r.   r/   Ú_print_IntegersZ  ó   z)MathMLPresentationPrinter._print_Integersc                 C   rô  )Nrõ   r{  rõ  z&#x2102;rá  rÖ   r.   r.   r/   Ú_print_Complexes`  r÷  z*MathMLPresentationPrinter._print_Complexesc                 C   rô  )Nrõ   r{  rõ  z&#x211D;rá  rÖ   r.   r.   r/   Ú_print_Realsf  r÷  z&MathMLPresentationPrinter._print_Realsc                 C   rô  )Nrõ   r{  rõ  ú&#x2115;rá  rÖ   r.   r.   r/   Ú_print_Naturalsl  r÷  z)MathMLPresentationPrinter._print_Naturalsc                 C   sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr  rõ   r{  rõ  rú  )r7   r    r[  r¡   r=   rA   r   ZZero)r)   r•   r  r¨   r.   r.   r/   Ú_print_Naturals0r  s   
z*MathMLPresentationPrinter._print_Naturals0c                 C   s|   |j d |j d  }|j d }| j d¡}| j d¡}| dd¡ | dd	¡ | |  |¡¡ | |¡ | |  |¡¡ |S )
Nr   rM   rÊ   r  rS  ra  r  rc  rŽ  )r³   r7   r    r[  r¡   rA   )r)   rD   Úshiftrb   r  rV  r.   r.   r/   Ú_print_SingularityFunction{  s   

z4MathMLPresentationPrinter._print_SingularityFunctionc                 C   rÔ   )Nrõ   ZNaNrÕ   rÖ   r.   r.   r/   rÜ   ‡  rh  z$MathMLPresentationPrinter._print_NaNc                 C   s°   | j  d¡}| j  d¡}| | j  |¡¡ | |¡ | |  |jd ¡¡ t|jƒdkr.|S | j  d¡}| j  d¡}|jdd … D ]
}| |  |¡¡ qA| |¡ | |¡ |S )Nr  rõ   r   rM   rò   rS  )r7   r    r¡   r=   rA   r³   rR   )r)   r•   r  r  rõ   rò   r]  r´   r.   r.   r/   Ú_print_number_functionŒ  s   


z0MathMLPresentationPrinter._print_number_functionc                 C   ó   |   |d¡S )NÚB©rÿ  rÐ   r.   r.   r/   Ú_print_bernoulliŸ  rÒ   z*MathMLPresentationPrinter._print_bernoullic                 C   r   )NrF  r  rÐ   r.   r.   r/   Ú_print_catalan¤  rÒ   z(MathMLPresentationPrinter._print_catalanc                 C   r   )NÚEr  rÐ   r.   r.   r/   Ú_print_euler§  rÒ   z&MathMLPresentationPrinter._print_eulerc                 C   r   )NÚFr  rÐ   r.   r.   r/   Ú_print_fibonacciª  rÒ   z*MathMLPresentationPrinter._print_fibonaccic                 C   r   )NÚLr  rÐ   r.   r.   r/   Ú_print_lucas­  rÒ   z&MathMLPresentationPrinter._print_lucasc                 C   r   )Nz&#x03B3;r  rÐ   r.   r.   r/   Ú_print_stieltjes°  rÒ   z*MathMLPresentationPrinter._print_stieltjesc                 C   r   )NÚTr  rÐ   r.   r.   r/   Ú_print_tribonacci³  rÒ   z+MathMLPresentationPrinter._print_tribonaccic                 C   s`   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )NrÞ  rô   ri  ú~rÕ   )r)   r•   r¨   rô   r.   r.   r/   Ú_print_ComplexInfinity¶  s   

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C   rÔ   )Nrô   z&#x2205;rÕ   rÖ   r.   r.   r/   rÝ   À  rh  z)MathMLPresentationPrinter._print_EmptySetc                 C   rÔ   )Nrô   z	&#x1D54C;rÕ   rÖ   r.   r.   r/   Ú_print_UniversalSetÅ  rh  z-MathMLPresentationPrinter._print_UniversalSetc                 C   óŒ   ddl m} |j}| j d¡}t||ƒs(| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | j d¡}| | j d¡¡ | |¡ |S )Nr   ©rl   r  rS  rô   rl  ©	Úsympy.matricesrl   r´   r7   r    rO  r¡   rA   r=   ©r)   rD   rl   Úmatr  rV  rô   r.   r.   r/   Ú_print_AdjointÊ  ó   

z(MathMLPresentationPrinter._print_Adjointc                 C   r  )Nr   r  r  rS  rô   r  r  r  r.   r.   r/   Ú_print_TransposeÙ  r  z*MathMLPresentationPrinter._print_Transposec                 C   st   ddl m} |j}| j d¡}t||ƒs(| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   r  r  rS  r¯   )r  rl   r´   r7   r    rO  r¡   rA   )r)   rD   rl   r  r  rV  r.   r.   r/   Ú_print_Inverseè  s   
z(MathMLPresentationPrinter._print_Inversec                 C   s&  ddl m} | j d¡}|j}t|d tƒr%|d  ¡ t|dd … ƒ }nt|ƒ}t||ƒrZt	|ƒrZ|d dkr?|dd … }n|d  |d< | j d¡}| 
| j d¡¡ | 
|¡ |d d… D ]"}| 
|  |t|ƒd¡¡ | j d¡}| 
| j d	¡¡ | 
|¡ q`| 
|  |d t|ƒd¡¡ |S )
Nr   )ÚMatMulrò   rM   r¯   rô   r_  FrL  )Úsympyr  r7   r    r³   rO  r   r§   rN   r   r¡   r=   rW  r   )r)   rD   r  r¨   r³   rô   r´   r.   r.   r/   Ú_print_MatMulõ  s0   
ÿÿz'MathMLPresentationPrinter._print_MatMulc                 C   s|   ddl m} |j|j}}| j d¡}t||ƒs,| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  |¡¡ |S )Nr   r  r  rS  )	r  rl   r  r  r7   r    rO  r¡   rA   )r)   rD   rl   r  r  r  rV  r.   r.   r/   Ú_print_MatPow  s   
z'MathMLPresentationPrinter._print_MatPowc                 C   s„   | j  d¡}|j}|d d… D ]"}| |  |t|ƒd¡¡ | j  d¡}| | j  d¡¡ | |¡ q| |  |d t|ƒd¡¡ |S )Nrò   r¯   Frô   z&#x2218;)r7   r    r³   r¡   rW  r   r=   )r)   rD   r¨   r³   r´   rô   r.   r.   r/   Ú_print_HadamardProduct  s   ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C   rÔ   )NrA  z&#x1D7D8rÕ   ©r)   ÚZr¨   r.   r.   r/   Ú_print_ZeroMatrix,  rh  z+MathMLPresentationPrinter._print_ZeroMatrixc                 C   rÔ   )NrA  z&#x1D7D9rÕ   r   r.   r.   r/   Ú_print_OneMatrix1  rh  z*MathMLPresentationPrinter._print_OneMatrixc                 C   rÔ   )Nrõ   z	&#x1D540;rÕ   )r)   r¤  r¨   r.   r.   r/   Ú_print_Identity6  rh  z)MathMLPresentationPrinter._print_Identityc                 C   óT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrò   rS  ra  u   âŒ‹rc  u   âŒŠr   r~  rÙ  r.   r.   r/   Ú_print_floor;  rž  z&MathMLPresentationPrinter._print_floorc                 C   r%  )Nrò   rS  ra  u   âŒ‰rc  u   âŒˆr   r~  rÙ  r.   r.   r/   Ú_print_ceilingD  rž  z(MathMLPresentationPrinter._print_ceilingc                 C   sž   | j  d¡}| j  d¡}|jd }t|ƒdkr|  |d ¡}n|  |¡}| |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ |S )NrS  rò   r   rM   rô   z&#x21A6;)r7   r    r³   rR   rA   r¡   r=   )r)   r•   r¨   rò   Úsymbolsrô   r.   r.   r/   Ú_print_LambdaM  s   




z'MathMLPresentationPrinter._print_Lambdac                 C   r+  rR  r,  )r)   r•   r¨   rº   r.   r.   r/   Ú_print_tuple]  s   z&MathMLPresentationPrinter._print_tuplec                 C   r±  r6   )rA   ZlabelrÐ   r.   r.   r/   Ú_print_IndexedBasec  rÒ   z,MathMLPresentationPrinter._print_IndexedBasec                 C   s\   | j  d¡}| |  |j¡¡ t|jƒdkr#| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr  rM   r   )r7   r    r¡   rA   r  rR   ÚindicesrÖ   r.   r.   r/   Ú_print_Indexedf  s   z(MathMLPresentationPrinter._print_Indexedc                 C   sv   | j  d¡}| | j|jtd dd¡ | j  d¡}| dd¡ | dd¡ |jD ]
}| |  |¡¡ q)| |¡ |S )	Nr  ZAtomTrv  rS  ra  r$   rc  )	r7   r    r¡   rW  Úparentr   r[  r,  rA   )r)   r•   r¨   rV  rº   r.   r.   r/   Ú_print_MatrixElemento  s   

z.MathMLPresentationPrinter._print_MatrixElementc                 C   óv   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| dd¡ |jD ]
}| |  |¡¡ q)| |¡ |S )Nrò   rõ   z	&#x1d5a5;rS  Ú
separatorsrœ  ©r7   r    r¡   r=   r[  r³   rA   ©r)   r•   r¨   rõ   r]  rº   r.   r.   r/   Ú_print_elliptic_fz  ó   


z+MathMLPresentationPrinter._print_elliptic_fc                 C   r0  )Nrò   rõ   z	&#x1d5a4;rS  r1  rœ  r2  r3  r.   r.   r/   Ú_print_elliptic_e†  r5  z+MathMLPresentationPrinter._print_elliptic_ec                 C   s’   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}t|jƒdkr.| dd¡ n| dd¡ |jD ]
}| |  |¡¡ q7| |¡ |S )	Nrò   rõ   z	&#x1d6f1;rS  rÊ   r1  rœ  z;|)r7   r    r¡   r=   rR   r³   r[  rA   r3  r.   r.   r/   Ú_print_elliptic_pi’  s   


z,MathMLPresentationPrinter._print_elliptic_pic                 C   sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |j¡¡ |S )Nrò   rõ   ZEirr  )r)   r•   r¨   rõ   r.   r.   r/   Ú	_print_Ei¡  s   
z#MathMLPresentationPrinter._print_Eic                 C   ó~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrò   r  rô   r  r   rM   rr  ©r)   r•   r¨   r]  rô   r.   r.   r/   Ú_print_expint©  ó   

z'MathMLPresentationPrinter._print_expintc                 C   ó˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrò   r  rô   ÚPr   rM   râ   rr  r:  r.   r.   r/   Ú_print_jacobi´  ó   

z'MathMLPresentationPrinter._print_jacobic                 C   r=  )Nrò   r  rô   rF  r   rM   rÊ   rr  r:  r.   r.   r/   Ú_print_gegenbauerÀ  r@  z+MathMLPresentationPrinter._print_gegenbauerc                 C   r9  )Nrò   r  rô   r  r   rM   rr  r:  r.   r.   r/   Ú_print_chebyshevtÌ  r<  z+MathMLPresentationPrinter._print_chebyshevtc                 C   r9  )Nrò   r  rô   ÚUr   rM   rr  r:  r.   r.   r/   Ú_print_chebyshevu×  r<  z+MathMLPresentationPrinter._print_chebyshevuc                 C   r9  )Nrò   r  rô   r>  r   rM   rr  r:  r.   r.   r/   Ú_print_legendreâ  r<  z)MathMLPresentationPrinter._print_legendrec                 C   r=  )Nrò   r  rô   r>  r   rM   rÊ   rr  r:  r.   r.   r/   Ú_print_assoc_legendreí  r@  z/MathMLPresentationPrinter._print_assoc_legendrec                 C   r9  )Nrò   r  rô   r	  r   rM   rr  r:  r.   r.   r/   Ú_print_laguerreù  r<  z)MathMLPresentationPrinter._print_laguerrec                 C   r=  )Nrò   r  rô   r	  r   rM   rÊ   rr  r:  r.   r.   r/   Ú_print_assoc_laguerre  r@  z/MathMLPresentationPrinter._print_assoc_laguerrec                 C   r9  )Nrò   r  rô   ÚHr   rM   rr  r:  r.   r.   r/   Ú_print_hermite  r<  z(MathMLPresentationPrinter._print_hermite)Fr6   )r   )‹r2   r3   r4   rX   r:  r™   rW  r¢   rµ   rÂ   re  rÇ   rÍ   rÑ   r×   rØ   rÙ   rÛ   rá   rj  rÓ   rk  ro  rp  rq  rs  rt  rê   rë   r  r;  r<  r€  rƒ  rˆ  rŠ  rŒ  r  r  r  r"  r%  r  r’  r&  r”  r›  r  Z_print_DeterminantrŸ  r£  r¥  r'  r¨  r¬  r®  r7  r°  r9  r4  r²  Z_print_frozensetr·  r¾  rÂ  rÄ  r?  r=  rÅ  r>  rÊ  rß   rà   rÌ  rÕ  r×  Z
_print_MinZ
_print_MaxrØ  r*  r1  rÝ  rà  râ  ræ  rì  rî  rï  rñ  ró  rö  rø  rù  rû  rü  rþ  rÜ   rÿ  r  Z_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/  r4  r6  r7  r8  r;  r?  rA  rB  rD  rE  rF  rG  rH  rJ  r.   r.   r.   r/   r@  C  s   L	/		&6	60'			* 		
			r@  Úcontentc                 K   s$   |dkrt |ƒ | ¡S t|ƒ | ¡S )zŠReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    Úpresentation)r@  rF   rY   )rD   Úprinterr>   r.   r.   r/   Úmathml  s   rN  c                 K   sL   |dkr	t |ƒ}nt|ƒ}| t| ƒ¡}| ¡  | ¡ }| ¡  t|ƒ dS )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.printing.mathml 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>

    rL  N)r@  rY   rA   r   rV   ZtoprettyxmlrW   Úprint)rD   rM  r>   rý   ZxmlZ
pretty_xmlr.   r.   r/   Úprint_mathml'  s   
rP  )rK  )%rX   Útypingr   r   r  r   r   r   Zsympy.core.compatibilityr   Zsympy.core.functionr   Zsympy.printing.conventionsr	   r
   Zsympy.printing.precedencer   r   r   Z&sympy.printing.pretty.pretty_symbologyr   Zsympy.printing.printerr   r   Zmpmath.libmpZlibmpr  r   r   r   r  r   rY   r@  rN  rP  ZMathMLPrinterr.   r.   r.   r/   Ú<module>   s@    k   G           d

&