U
    ;qLe& ã                   @  sô   d Z ddlmZ ddlmZ ddlmZ ddl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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.
é    )Ú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                   @  s^   e Zd ZU dZddddddddddddi d	d
œZded< 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-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_numberszdict[str, Any]Ú_default_settingsc                   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 )Nz{}{}{})ÚdataÚwriteÚformat©ÚselfÚwriterÚindentÚ	addindentÚnewl© r3   úl/home/p21-0144/sympy/latex2sympy2solve-back-end/sympyEq/lib/python3.8/site-packages/sympy/printing/mathml.pyÚwritexml6   s    z4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r)   r)   r)   )Ú__name__Ú
__module__Ú__qualname__r5   r3   r3   r3   r4   ÚRawText5   s   r9   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r*   ÚdomZownerDocument)r*   Úr©r9   r.   r3   r4   ÚcreateRawTextNode:   s    z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Úxml.dom.minidomr'   r(   r;   ÚcreateTextNode)r.   Úsettingsr'   r(   r>   r3   r=   r4   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Úresr3   r3   r4   ÚdoprintB   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¡ q4| jrô|  d¡ t| jƒdkrª| jd j	ˆ j
krª| jd  |ddd¡ n4|  |¡ | jD ]}| ||| ||¡ qº|  |¡ |  d| j|f ¡ n|  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_NODEr5   )	r.   r/   r0   r1   r2   ÚattrsZa_namesZa_nameÚnode©rL   rM   r3   r4   r5   V   s2    
ÿ

   ÿ
z/MathMLPrinterBase.apply_patch.<locals>.writexmlc                   s   ˆ |d|| j |f ƒ d S )Nz%s%s%s)r*   r-   )rM   r3   r4   r5   u   s    )r)   r)   r)   )r)   r)   r)   )r@   rK   r(   rL   rM   r5   Ú_Element_writexml_oldÚ_Text_writexml_old)r.   rK   r(   r5   r3   rY   r4   Úapply_patchL   s    zMathMLPrinterBase.apply_patchc                 C  s$   ddl m}m} | j|_| j|_d S )Nr   )rK   r(   )r@   rK   r(   rZ   r5   r[   )r.   rK   r(   r3   r3   r4   Úrestore_patchz   s    zMathMLPrinterBase.restore_patch)N)
r6   r7   r8   Ú__doc__r&   Ú__annotations__r?   rJ   r\   r]   r3   r3   r3   r4   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              6   C  s¨   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d d!d"d!d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2œ5}|j jD ]}|j}||krx||   S qx|j j}| ¡ S )3ú)Returns the MathML tag for an expression.ÚplusÚtimesÚdiffÚcnÚpowerÚmaxÚminÚabsÚandÚorÚxorÚnotZimpliesÚciÚintÚsumÚsinÚcosÚtanÚcotÚcscÚsecÚsinhÚcoshÚtanhÚcothÚcschÚsechÚarcsinÚarcsinhÚarccosÚarccoshÚarctanÚarctanhÚarccotZarccothÚarcsecZarcsechÚarccscZarccschÚlnÚeqZneqZgeqZleqÚgtÚltÚunionÚ	intersect)5ÚAddr   Ú
DerivativeÚNumberro   ÚPowÚMaxÚMinÚAbsÚAndÚOrÚXorÚNotÚImpliesÚSymbolÚMatrixSymbolZRandomSymbolÚIntegralÚSumrq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   ÚasinÚasinhÚacosÚacoshÚatanÚatanhÚatan2ÚacotÚacothÚasecÚasechÚacscÚacschÚlogÚEqualityÚ
UnequalityÚGreaterThanÚLessThanÚStrictGreaterThanÚStrictLessThanÚUnionÚIntersection©Ú	__class__Ú__mro__r6   Úlower)r.   ÚeÚ	translateÚclsÚnr3   r3   r4   Ú
mathml_tag‡   sx    Ë8zMathMLContentPrinter.mathml_tagc           	      C  s@  |  ¡ r<| j d¡}| | j d¡¡ | |  | ¡¡ |S ddlm} ||ƒ\}}|tjk	r | j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tjkrÐt|ƒdkrÐ|  	|d ¡S | jdkrèt |¡ ¡ }| j d¡}| | j d¡¡ |dkr | |  	|¡¡ |D ]}| |  	|¡¡ q$|S )	NÚapplyÚminusr   ©ÚfractionÚdividerQ   Úoldrc   )Úcould_extract_minus_signr;   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyr¾   r   ÚOnerE   Úas_coeff_mulrV   r   r   Ú
_from_argsÚas_ordered_factors)	r.   rH   Úxr¾   ÚnumerÚdenomÚcoeffÚtermsÚtermr3   r3   r4   rÄ   É   s2    


zMathMLContentPrinter._print_MulNc                 C  s
  | j ||d}|  |d ¡}g }|dd … D ]’}| ¡ rŽ| j d¡}| | j d¡¡ | |¡ | |  | ¡¡ |}||d kr¾| |¡ q,| |¡ |  |¡}||d kr,| |  |¡¡ q,t|ƒdkrÐ|S | j d¡}| | j d¡¡ |r| | d¡¡ qî|S )N©r   r   rQ   r»   r¼   éÿÿÿÿrb   )	Ú_as_ordered_termsrE   rÁ   r;   rÂ   rÃ   ÚappendrV   Úpop)r.   rH   r   ÚargsZlastProcessedZ	plusNodesÚargrÊ   r3   r3   r4   Ú
_print_Addì   s.    


zMathMLContentPrinter._print_Addc                 C  s®   |j d jdkrtdƒ‚| j d¡}t|j ƒD ]z\}\}}|t|j ƒd krr|dkrr| 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.Ú	piecewiserQ   Ú	otherwiseÚpiece)	rÕ   ÚcondÚ
ValueErrorr;   rÂ   Ú	enumeraterV   rÃ   rE   )r.   rH   ÚrootÚir¶   ÚcrÚ   r3   r3   r4   Ú_print_Piecewise  s    z%MathMLContentPrinter._print_Piecewisec              	   C  s^   | j  d¡}t|jƒD ]B}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q0| |¡ q|S )NÚmatrixZ	matrixrow)r;   rÂ   ÚrangeÚrowsÚcolsrÃ   rE   )r.   ÚmrÊ   rß   Zx_rÚjr3   r3   r4   Ú_print_MatrixBase  s    z&MathMLContentPrinter._print_MatrixBasec                 C  s°   |j dkr2| j d¡}| | j t|jƒ¡¡ |S | j d¡}| | j d¡¡ | j d¡}| | j t|jƒ¡¡ | j d¡}| | j t|j ƒ¡¡ | |¡ | |¡ |S )NrQ   re   r»   r¿   )Úqr;   rÂ   rÃ   rA   ÚstrÚp)r.   r¶   rÊ   ÚxnumZxdenomr3   r3   r4   Ú_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ÚlowlimitrQ   é   r   )r;   rÂ   rÃ   rº   rE   rÕ   )r.   r¶   rÊ   Úx_1Úx_2r3   r3   r4   Ú_print_Limit8  s    

z!MathMLContentPrinter._print_Limitc                 C  s   | j  d¡S )NZ
imaginaryi©r;   rÂ   ©r.   r¶   r3   r3   r4   Ú_print_ImaginaryUnitF  s    z)MathMLContentPrinter._print_ImaginaryUnitc                 C  s   | j  d¡S )NZ
eulergammarô   rõ   r3   r3   r4   Ú_print_EulerGammaI  s    z&MathMLContentPrinter._print_EulerGammac                 C  s"   | j  d¡}| | j  d¡¡ |S )zwWe use unicode #x3c6 for Greek letter phi as defined here
        https://www.w3.org/2003/entities/2007doc/isogrk1.htmlre   u   Ï†©r;   rÂ   rÃ   rA   ©r.   r¶   rÊ   r3   r3   r4   Ú_print_GoldenRatioL  s    z'MathMLContentPrinter._print_GoldenRatioc                 C  s   | j  d¡S )NZexponentialerô   rõ   r3   r3   r4   Ú_print_Exp1S  s    z MathMLContentPrinter._print_Exp1c                 C  s   | j  d¡S )NÚpirô   rõ   r3   r3   r4   Ú	_print_PiV  s    zMathMLContentPrinter._print_Pic                 C  s   | j  d¡S )NÚinfinityrô   rõ   r3   r3   r4   Ú_print_InfinityY  s    z$MathMLContentPrinter._print_Infinityc                 C  s   | j  d¡S )NZ
notanumberrô   rõ   r3   r3   r4   Ú
_print_NaN\  s    zMathMLContentPrinter._print_NaNc                 C  s   | j  d¡S )NZemptysetrô   rõ   r3   r3   r4   Ú_print_EmptySet_  s    z$MathMLContentPrinter._print_EmptySetc                 C  s   | j  d¡S )NÚtruerô   rõ   r3   r3   r4   Ú_print_BooleanTrueb  s    z'MathMLContentPrinter._print_BooleanTruec                 C  s   | j  d¡S )NÚfalserô   rõ   r3   r3   r4   Ú_print_BooleanFalsee  s    z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr»   r¼   rþ   )r;   rÂ   rÃ   rù   r3   r3   r4   Ú_print_NegativeInfinityh  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¡¡ n| ˆ| dd … ƒ¡ |S )	Nr»   rî   r   é   rï   rQ   Zuplimitrð   )r;   rÂ   rÃ   rº   rE   rV   Úfunction)ÚlimitsrÊ   Z	bvar_elemÚlow_elemÚup_elem©r¶   Ú
lime_recurr.   r3   r4   r  o  s(    



z8MathMLContentPrinter._print_Integral.<locals>.lime_recur)rR   r	  Úreverse)r.   r¶   r	  r3   r  r4   Ú_print_Integraln  s    
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r:   )r  rõ   r3   r3   r4   Ú
_print_Sum‹  s    zMathMLContentPrinter._print_Sumc                   sB  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰t|jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j  d¡}| ˆ j  |¡¡ |sÌ|sœ| ˆ j  |¡¡ n.ˆ j  d	¡}| |¡ | ||ƒ¡ | |¡ nr|sˆ j  d
¡}	|	 |¡ |	 ||ƒ¡ | |	¡ n<ˆ j  d¡}
|
 |¡ |
 ||ƒ¡ |
 ||ƒ¡ | |
¡ |S )Nc                   s°   t | ƒdkr†ˆ j d¡}t| ƒD ]`\}}|dkrXˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q |S ˆ j d¡}| ˆ j | d ¡¡ |S d S )NrQ   zmml:mrowr   zmml:moú úmml:mi©rV   r;   rÂ   rÝ   rÃ   rA   ©ÚitemsÚmrowrß   ÚitemÚmoÚmi©r.   r3   r4   Újoin“  s    
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  s   | t krt  | ¡S | S d S r:   ©r   Úget©Úsr3   r3   r4   r·   ¥  s    
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r3   r3   ©Ú.0Úsup©r·   r3   r4   Ú
<listcomp>­  s     z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r3   r3   ©r!  Úsubr#  r3   r4   r$  ®  s     r  zmml:msubzmml:msupzmml:msubsup)r;   rÂ   rº   r   ÚnamerÃ   rA   )r.   Úsymrn   r  r'  ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr3   ©r.   r·   r4   Ú_print_Symbol  s6    



z"MathMLContentPrinter._print_Symbolc                 C  sô   | j d r¤|jjr¤|jjdkr¤| j d¡}| | j d¡¡ |jjdkrŽ| j d¡}| j d¡}| | j t	|jjƒ¡¡ | |¡ | |¡ | |  
|j¡¡ |S | j d¡}| j |  |¡¡}| |¡ | |  
|j¡¡ | |  
|j¡¡ |S )Nr#   rQ   r»   rÞ   rð   Údegreere   )Ú	_settingsÚexpÚis_Rationalrë   r;   rÂ   rÃ   ré   rA   rê   rE   Úbaserº   )r.   r¶   rÊ   ZxmldegZxmlcnrñ   r3   r3   r4   Ú
_print_PowË  s&    
ÿ


zMathMLContentPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r:   ©r;   rÂ   rº   rÃ   rA   rê   rù   r3   r3   r4   Ú_print_Numberâ  s    z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r:   )	r;   rÂ   rº   Úmlib_to_strÚ_mpf_r   Ú_precrÃ   rA   )r.   r¶   rÊ   Zrepr_er3   r3   r4   Ú_print_Floatç  s    z!MathMLContentPrinter._print_Floatc                 C  s¸   | j  d¡}|  |¡}t|jƒr$d}| | j  |¡¡ | j  d¡}t|jƒD ]J\}}| |  |¡¡ |dkrL| j  d¡}| |  t	|ƒ¡¡ | |¡ qL| |¡ | |  |j¡¡ |S )Nr»   Zpartialdiffrî   rQ   r1  )
r;   rÂ   rº   r	   rH   rÃ   ÚreversedÚvariable_countrE   r   )r.   r¶   rÊ   Údiff_symbolrñ   r(  rc   r1  r3   r3   r4   Ú_print_Derivativeí  s    


z&MathMLContentPrinter._print_Derivativec                 C  sD   | j  d¡}| | j  |  |¡¡¡ |jD ]}| |  |¡¡ q*|S ©Nr»   )r;   rÂ   rÃ   rº   rÕ   rE   ©r.   r¶   rÊ   rÖ   r3   r3   r4   Ú_print_Function   s
    
z$MathMLContentPrinter._print_Functionc                 C  s2   | j  |  |¡¡}|jD ]}| |  |¡¡ q|S r:   )r;   rÂ   rº   rÕ   rÃ   rE   rB  r3   r3   r4   Ú_print_Basic  s    
z!MathMLContentPrinter._print_Basicc                 C  sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]}| |  |¡¡ q.|S rA  )r;   rÂ   rº   rÃ   rÕ   rE   )r.   r¶   rÊ   rñ   rÖ   r3   r3   r4   Ú_print_AssocOp  s    

z#MathMLContentPrinter._print_AssocOpc                 C  sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S rA  )r;   rÂ   rÃ   rº   rE   ÚlhsÚrhsrù   r3   r3   r4   Ú_print_Relational  s
    z&MathMLContentPrinter._print_Relationalc                 C  s*   | j  d¡}|D ]}| |  |¡¡ q|S )zgMathML reference for the <list> element:
        https://www.w3.org/TR/MathML2/chapter4.html#contm.listrR   ©r;   rÂ   rÃ   rE   )r.   ÚseqÚdom_elementr  r3   r3   r4   Ú_print_list  s    z MathMLContentPrinter._print_listc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r:   r7  ©r.   rë   rK  r3   r3   r4   Ú
_print_int$  s    zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]}| |  |¡¡ q|S )NÚset©r;   rÂ   rÕ   rÃ   rE   rB  r3   r3   r4   Ú_print_FiniteSet-  s    
z%MathMLContentPrinter._print_FiniteSetc                 C  s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr»   Zsetdiff©r;   rÂ   rÃ   rÕ   rE   rB  r3   r3   r4   Ú_print_Complement3  s
    
z&MathMLContentPrinter._print_Complementc                 C  s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr»   ZcartesianproductrR  rB  r3   r3   r4   Ú_print_ProductSet:  s
    
z&MathMLContentPrinter._print_ProductSet)N),r6   r7   r8   r^   Úprintmethodrº   rÄ   r×   rá   rè   rí   ró   rö   r÷   rú   rû   rý   rÿ   r   r  r  r  r  r  r  r0  Ú_print_MatrixSymbolÚ_print_RandomSymbolr6  r8  r<  r@  rC  rD  rE  rH  rL  rN  Ú_print_ImpliesÚ
_print_NotÚ
_print_XorrQ  rS  rT  r3   r3   r3   r4   r`   €   sR   B#
	8r`   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              0     sº   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d d!d"d#d$d%d&d'd(d"d#d)d*d+œ/}‡ fd,d-„}|j jD ]}|j}||krx||   S qx|j jd.krª|ƒ S |j j}| ¡ S )/ra   Úmnz&#x2192;ú&dd;r  z&int;z&#x2211;rq   rr   rs   rt   r}   r~   r   r€   r   r‚   rƒ   ú=z&#x2260;z&#x2265;z&#x2264;rP   rN   ú&#x3A6;z&#x3B6;z&#x3B7;z&#x39A;ú&#x3B3;z&#x393;z&#x3D5;z&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;)/rŽ   ÚLimitr   ro   r˜   rš   r›   rq   rr   rs   rt   rœ   r   rž   rŸ   r    r¡   r£   r¢   rª   r«   r¬   r­   r®   r¯   ÚlerchphiÚzetaÚdirichlet_etaÚ
elliptic_kÚ
lowergammaÚ
uppergammaÚgammaÚtotientÚreduced_totientÚprimenuÚ
primeomegaÚfresnelsÚfresnelcÚLambertWÚ	HeavisideÚBooleanTrueÚBooleanFalseZNoneTypeÚmathieusÚmathieucÚmathieusprimeÚmathieucprimec                     sz   ˆ j d d ksˆ j d dkr dS ˆ j d dkr2dS ˆ j d dkrDdS ˆ j d dkrVd	S tˆ j d tƒslt‚n
ˆ j d S d S )
Nr"   re  ú&InvisibleTimes;rc   ú&#xD7;Údotr   Úldotz&#x2024;)r2  Ú
isinstancerê   Ú	TypeErrorr3   r  r3   r4   Úmul_symbol_selection  s    ÿzBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionr   r²   )r.   r¶   r·   r‚  r¸   r¹   r3   r  r4   rº   K  sr    Ñ2z$MathMLPresentationPrinter.mathml_tagFc                 C  sJ   t |ƒ}||k s|s<||kr<| j d¡}| |  |¡¡ |S |  |¡S d S ©NÚmfenced)r
   r;   rÂ   rÃ   rE   )r.   r  ÚlevelÚstrictÚprec_valÚbracr3   r3   r4   Úparenthesize—  s    z&MathMLPresentationPrinter.parenthesizec                   sd   ‡ fdd„}ˆ j  d¡}| ¡ rVˆ j  d¡}| ˆ j  d¡¡ | |¡ || |ƒ}n
|||ƒ}|S )Nc                   sŠ  ddl m} || ƒ\}}|tjk	rŠˆ j d¡}ˆ jd rTtt| ƒƒdk rT| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tjkrÄt|	ƒdkrÄ| ˆ  
|	d ¡¡ |S ˆ jd	krÜt |	¡ ¡ }	|dkr(ˆ  
|¡}
ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |
¡ | |¡ |	D ]X}| ˆ  |td ¡¡ ||	d ks,ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |¡ q,|S )Nr   r½   Úmfracr   é   Úbevelledr  rQ   rÀ   r  r   rÑ   )rÅ   r¾   r   rÆ   r;   rÂ   r2  rV   rê   ÚsetAttributerE   rÃ   rÇ   r   r   rÈ   rÉ   rA   rº   r‰  r   )rH   r  r¾   rË   rÌ   Úfracrì   ZxdenrÍ   rÎ   rÊ   ÚyrÏ   r  r3   r4   Úmultiply¢  s>    










z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyr  r  ú-)r;   rÂ   rÁ   rÃ   rA   )r.   rH   r  r  rÊ   r3   r  r4   rÄ      s    "

z$MathMLPresentationPrinter._print_MulNc                 C  s´   | j  d¡}| j||d}| |  |d ¡¡ |dd … D ]t}| ¡ rr| j  d¡}| | j  d¡¡ |  | ¡}n(| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ q:|S )Nr  rÐ   r   rQ   r  r‘  ú+)r;   rÂ   rÒ   rÃ   rE   rÁ   rA   )r.   rH   r   r  rÕ   rÖ   rÊ   r  r3   r3   r4   r×   Ï  s    

z$MathMLPresentationPrinter._print_Addc              	   C  sÂ   | j  d¡}t|jƒD ]X}| j  d¡}t|jƒD ]2}| j  d¡}| |  |||f ¡¡ | |¡ q0| |¡ q| jd dkr‚|S | j  d¡}| jd dkr´| dd	¡ | d
d¡ | |¡ |S )NZmtableZmtrZmtdr    r)   r„  r   Úcloseú]Úopen)	r;   rÂ   rã   rä   rå   rÃ   rE   r2  r  )r.   ræ   Útablerß   rÊ   rç   r  rˆ  r3   r3   r4   rè   ã  s     
z+MathMLPresentationPrinter._print_MatrixBasec                 C  s¶   |j dk r|j  }n|j }| j d¡}|s4| jd r@| dd¡ | |  |¡¡ | |  |j¡¡ |j dk r®| j d¡}| j d¡}| | j d¡¡ | |¡ | |¡ |S |S d S )	Nr   rŠ  r   rŒ  r  r  r  r‘  )	rë   r;   rÂ   r2  r  rÃ   rE   ré   rA   )r.   r¶   Úfoldedrë   rÊ   r  r  r3   r3   r4   Ú_get_printed_Rationalõ  s     




z/MathMLPresentationPrinter._get_printed_Rationalc                 C  s(   |j dkr|  |j¡S |  || jd ¡S )NrQ   r   )ré   rE   rë   r˜  r2  rõ   r3   r3   r4   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  ÚlimrQ   r  rð   r   )r;   rÂ   rÃ   rA   rE   rÕ   rº   )	r.   r¶   r  r™  r  rÊ   rñ   Úarrowrò   r3   r3   r4   ró     s"    





z&MathMLPresentationPrinter._print_Limitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&ImaginaryI;rø   rù   r3   r3   r4   rö   &  s    z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  r_  rø   rù   r3   r3   r4   rú   +  s    z,MathMLPresentationPrinter._print_GoldenRatioc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&ExponentialE;rø   rù   r3   r3   r4   rû   0  s    z%MathMLPresentationPrinter._print_Exp1c                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&pi;rø   rù   r3   r3   r4   rý   5  s    z#MathMLPresentationPrinter._print_Pic                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  ú&#x221E;rø   rù   r3   r3   r4   rÿ   :  s    z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nr  r  r‘  )r;   rÂ   rÃ   rA   rÿ   )r.   r¶   r  r  rÊ   r3   r3   r4   r  ?  s    


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x210F;rø   rù   r3   r3   r4   Ú_print_HBarH  s    z%MathMLPresentationPrinter._print_HBarc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  r`  rø   rù   r3   r3   r4   r÷   M  s    z+MathMLPresentationPrinter._print_EulerGammac                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  ÚTribonacciConstantrø   rù   r3   r3   r4   Ú_print_TribonacciConstantR  s    z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr-  r   ú&#x2020;©r;   rÂ   rÃ   rE   rÕ   rA   ©r.   r¶   r-  r3   r3   r4   Ú_print_DaggerW  s    z'MathMLPresentationPrinter._print_Daggerc                 C  sd   | j  d¡}| |  |jd ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ |S )Nr  r   r  z&#x2208;rQ   r¡  )r.   r¶   r  r  r3   r3   r4   Ú_print_Contains]  s    
z)MathMLPresentationPrinter._print_Containsc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x210B;rø   rù   r3   r3   r4   Ú_print_HilbertSpacef  s    z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr-  z	&#x1D49E;r   ©r;   rÂ   rÃ   rA   rE   rÕ   r¢  r3   r3   r4   Ú_print_ComplexSpacek  s    z-MathMLPresentationPrinter._print_ComplexSpacec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x2131;rø   rù   r3   r3   r4   Ú_print_FockSpaceq  s    z*MathMLPresentationPrinter._print_FockSpacec           	      C  s¸  ddddœ}| j  d¡}t|jƒdkrntdd„ |jD ƒƒrn| j  d	¡}| | j  |t|jƒ ¡¡ | |¡ nÜt|jƒD ]Ð}| j  d	¡}| | j  |d
 ¡¡ t|ƒd
kr´| |¡ t|ƒdkrô| j  d¡}| |¡ | |  |d
 ¡¡ | |¡ t|ƒdkrx| j  d¡}| |¡ | |  |d
 ¡¡ | |  |d ¡¡ | |¡ qx| | j	|j
td dd¡ t|jƒD ]B}| j  d	¡}| | j  d¡¡ | |¡ | |  |d ¡¡ qp|S )Nz&#x222B;z&#x222C;z&#x222D;)rQ   rð   r  r  r  c                 s  s   | ]}t |ƒd kV  qdS )rQ   N)rV   )r!  rš  r3   r3   r4   Ú	<genexpr>{  s     z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r  rQ   rð   r-  r.  r   T©r†  r]  r   )r;   rÂ   rV   r	  ÚallrÃ   rA   r=  rE   r‰  r  r   )	r.   rH   Z
intsymbolsr  r  rš  r-  r.  Údr3   r3   r4   r  w  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
¡¡ n(| j d¡}| |  |j
¡¡ |
 |¡ |
S )	NZ
munderoverr   rQ   rð   r  r  r^  r„  )rR   r	  r;   rÂ   rE   rÃ   rA   rº   rV   rê   r  )r.   r¶   r	  Zsubsupr
  r  ÚsummandÚlowÚvarZequalr  Zfencer3   r3   r4   r    s0    








z$MathMLPresentationPrinter._print_Sumr   c           	        s0  ‡ fdd„}dd„ ‰t |jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j d¡}| ˆ j |¡¡ t|ƒd	kr²t|ƒd	krŒ|}n$ˆ j d
¡}| |¡ | ||ƒ¡ ndt|ƒd	kräˆ j d¡}| |¡ | ||ƒ¡ n2ˆ j d¡}| |¡ | ||ƒ¡ | ||ƒ¡ |dkr,| dd¡ |S )Nc                   s°   t | ƒdkr†ˆ j d¡}t| ƒD ]`\}}|dkrXˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q |S ˆ j d¡}| ˆ j | d ¡¡ |S d S )NrQ   r  r   r  r  r  r  r  r  r3   r4   r  ½  s    
z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  s   | t krt  | ¡S | S d S r:   r  r  r3   r3   r4   r·   Ï  s    
z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r3   r3   r   r#  r3   r4   r$  ×  s     z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r3   r3   r%  r#  r3   r4   r$  Ø  s     r  r   r,  r-  r.  ÚboldÚmathvariant)r   r'  r;   rÂ   rÃ   rA   rV   r  )	r.   r(  Ústyler  r'  r)  r*  r+  rÊ   r3   r/  r4   r0  ¼  s2    



z'MathMLPresentationPrinter._print_Symbolc                 C  s   | j || jd dS )Nr!   )r²  )r0  r2  )r.   r(  r3   r3   r4   rV  ò  s    ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   ©r;   rÂ   r  rÃ   rE   rÕ   )r.   rH   Úencr3   r3   r4   Ú_print_conjugateø  s    z*MathMLPresentationPrinter._print_conjugatec                 C  sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nr  ÚFuncr  )r;   rÂ   rÃ   r‰  r   rA   )r.   ÚoprH   Úrowr  r3   r3   r4   Ú_print_operator_afterþ  s    
z/MathMLPresentationPrinter._print_operator_afterc                 C  s   |   d|jd ¡S )Nú!r   ©r»  rÕ   ©r.   rH   r3   r3   r4   Ú_print_factorial  s    z*MathMLPresentationPrinter._print_factorialc                 C  s   |   d|jd ¡S )Nz!!r   r½  r¾  r3   r3   r4   Ú_print_factorial2	  s    z+MathMLPresentationPrinter._print_factorial2c                 C  s^   | j  d¡}| j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | |¡ |S )Nr„  rŠ  ZlinethicknessÚ0r   rQ   rµ  )r.   rH   rˆ  rŽ  r3   r3   r4   Ú_print_binomial  s    
z)MathMLPresentationPrinter._print_binomialc                 C  sd  |j jrÐt|j jƒdkrÐ|j jdkrÐ| jd rÐ|j jdkrX| j d¡}| |  	|j
¡¡ |j jdkr–| j d¡}| |  	|j
¡¡ | |  	|j j¡¡ |j jdkrÌ| 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
¡¡ nB| j d¡}| |  |j
td	 ¡¡ | |  	|j  ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j ¡¡ |S )NrQ   r#   rð   ZmsqrtZmrootrÑ   rŠ  r-  r   r   )r3  r4  ri   rë   ré   r2  r;   rÂ   rÃ   rE   r5  Úis_negativer‰  r   r˜  )r.   r¶   rÊ   rŽ  r´  r3   r3   r4   r6    s^    $ÿ

ÿ
ÿ

z$MathMLPresentationPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r:   r7  rù   r3   r3   r4   r8  K  s    z'MathMLPresentationPrinter._print_Numberc                 C  sL   | j  d¡}| dd¡ | dd¡ | |  |j¡¡ | |  |j¡¡ |S )Nr„  r“  õ   âŸ©r•  õ   âŸ¨)r;   rÂ   r  rÃ   rE   rh   rg   )r.   rß   rˆ  r3   r3   r4   Ú_print_AccumulationBoundsP  s    z3MathMLPresentationPrinter._print_AccumulationBoundsc                 C  s   t |jƒrd}n
|  |¡}| j d¡}d}t|jƒD ]š\}}||7 }|dkr’| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ | |¡ |  	|¡}	| |	¡ q4| 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  rŠ  )
r	   rH   rº   r;   rÂ   r=  r>  rÃ   rA   rE   )r.   r¶   r¬  ræ   Údimr(  ÚnumrÊ   Úxxr  Zmnumr  rŽ  r3   r3   r4   r@  X  sF    










z+MathMLPresentationPrinter._print_Derivativec                 C  sœ   | j  d¡}| j  d¡}|  |¡dkrD| jd rD| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}|jD ]}| |  |¡¡ qn| |¡ | |¡ |S )Nr  r  r©   r   r†   r„  )r;   rÂ   rº   r2  rÃ   rA   rÕ   rE   )r.   r¶   r  rÊ   r  rÖ   r3   r3   r4   rC  ˆ  s    


z)MathMLPresentationPrinter._print_Functionc                 C  sh  t |jƒ}t|j|dd}| jd }| j d¡}d|kr| d¡\}}|d dkr`|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rB|  d ¡S | j d	¡}| | j 	|¡¡ |S d S )NT)Ústrip_zerosr%   r  r¶   r   r’  rQ   r\  r  r-  Z10z+infz-inf)r   r;  r9  r:  r2  r;   rÂ   ÚsplitrÃ   rA   rÿ   r  )r.   rH   ÚdpsÚstr_realÚ	separatorr  Úmantr3  r\  r  r-  r3   r3   r4   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  ÚLir   r„  rQ   r¦  )r.   rH   r  ræ   r  rˆ  r3   r3   r4   Ú_print_polylog½  s    


z(MathMLPresentationPrinter._print_polylogc                 C  sp   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | j  d¡}|jD ]}| |  |¡¡ qL| |¡ |S )Nr  r  r„  ©r;   rÂ   rÃ   rA   rº   rÕ   rE   )r.   r¶   r  r  rˆ  rÖ   r3   r3   r4   rD  Ë  s    


z&MathMLPresentationPrinter._print_Basicc                 C  sB   | j  d¡}| j  d¡}|jD ]}| |  |¡¡ q| |¡ |S )Nr  r„  rP  )r.   r¶   r  rÊ   rÖ   r3   r3   r4   Ú_print_TupleÖ  s    

z&MathMLPresentationPrinter._print_Tuplec                 C  sÂ   | j  d¡}| j  d¡}|j|jkrP| dd¡ | dd¡ | |  |j¡¡ nd|jrd| dd¡ n| dd¡ |jr„| dd	¡ n| dd
¡ | |  |j¡¡ | |  |j¡¡ | |¡ |S )Nr  r„  r“  Ú}r•  Ú{ú)r”  ú(r   )	r;   rÂ   ÚstartÚendr  rÃ   rE   Ú
right_openÚ	left_open)r.   rß   r  rˆ  r3   r3   r4   Ú_print_IntervalÞ  s     
z)MathMLPresentationPrinter._print_Intervalc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nr  r„  r“  ú|r•  r   rµ  )r.   rH   r3  r  rÊ   r3   r3   r4   Ú
_print_Absö  s    
z$MathMLPresentationPrinter._print_Absc                 C  sj   | j  d¡}| j  d¡}| dd¡ | | j  |¡¡ | |¡ | j  d¡}| |  |¡¡ | |¡ |S )Nr  r  r±  Zfrakturr„  )r;   rÂ   r  rÃ   rA   rE   )r.   rà   rH   r  r  rˆ  r3   r3   r4   Ú_print_re_im  s    

z&MathMLPresentationPrinter._print_re_imc                 C  s   |   d|jd ¡S )NÚRr   ©rß  rÕ   ©r.   rH   r3  r3   r3   r4   Ú	_print_re  s    z#MathMLPresentationPrinter._print_rec                 C  s   |   d|jd ¡S )NÚIr   rá  râ  r3   r3   r4   Ú	_print_im  s    z#MathMLPresentationPrinter._print_imc                 C  sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]}| |  |¡¡ q@|S )Nr  r  rÒ  )r.   r¶   r  r  rÖ   r3   r3   r4   rE    s    

z(MathMLPresentationPrinter._print_AssocOpc                 C  sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]B}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q2|S )Nr  r   rQ   r  )r;   rÂ   rÃ   r‰  rÕ   rA   )r.   rH   ÚsymbolÚprecr  rÖ   rÊ   r  r3   r3   r4   Ú_print_SetOp  s    
z&MathMLPresentationPrinter._print_SetOpc                 C  s   t d }|  |d|¡S )Nr°   z&#x222A;©r   rè  ©r.   rH   rç  r3   r3   r4   Ú_print_Union&  s    z&MathMLPresentationPrinter._print_Unionc                 C  s   t d }|  |d|¡S )Nr±   z&#x2229;ré  rê  r3   r3   r4   Ú_print_Intersection*  s    z-MathMLPresentationPrinter._print_Intersectionc                 C  s   t d }|  |d|¡S )NÚ
Complementz&#x2216;ré  rê  r3   r3   r4   rS  .  s    z+MathMLPresentationPrinter._print_Complementc                 C  s   t d }|  |d|¡S )NÚSymmetricDifferenceú&#x2206;ré  rê  r3   r3   r4   Ú_print_SymmetricDifference2  s    z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  s   t d }|  |d|¡S )NÚ
ProductSetz&#x00d7;ré  rê  r3   r3   r4   rT  6  s    z+MathMLPresentationPrinter._print_ProductSetc                 C  s   |   |j¡S r:   )Ú
_print_setrÕ   )r.   r  r3   r3   r4   rQ  :  s    z*MathMLPresentationPrinter._print_FiniteSetc                 C  sN   t |td}| j d¡}| dd¡ | dd¡ |D ]}| |  |¡¡ q4|S )N©Úkeyr„  r“  rÔ  r•  rÕ  )Úsortedr   r;   rÂ   r  rÃ   rE   )r.   r  r  rˆ  r  r3   r3   r4   rò  =  s    z$MathMLPresentationPrinter._print_setc                 C  sÜ   | j  d¡}|d jrL|d jsL| j  d¡}| |  |d ¡¡ | |¡ n| |  |d ¡¡ |dd … D ]j}| j  d¡}| | j  |¡¡ |jr¸|js¸| j  d¡}| |  |¡¡ n
|  |¡}| |¡ | |¡ ql|S )Nr  r   r„  rQ   r  )r;   rÂ   Ú
is_BooleanÚis_NotrÃ   rE   rA   )r.   rÕ   ræ  r  rˆ  rÖ   rÊ   r  r3   r3   r4   Ú_print_LogOpH  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\}}t	|j
 ¡ ƒ}|jdd„ d t|ƒD ]"\}\}	}
|
dkrØ|rÆ| j d¡}| | j d	¡¡ | |¡ | |  |	¡¡ q„|
d
kr| j d¡}| | j d¡¡ | |¡ | |  |	¡¡ q„|rJ| j d¡}| | j d	¡¡ | |¡ | j d¡}| |  |
¡¡ | |¡ | j d¡}| | j d¡¡ | |¡ | |  |	¡¡ q„qT|S )Nr   )ÚVectorr  c                 S  s   | d   ¡ S )Nr   )Ú__str__)rÊ   r3   r3   r4   Ú<lambda>j  ó    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>ró  rQ   r  r’  rÑ   r‘  r„  r|  )Úsympy.vectorrù  ÚzerorE   r€  Úseparater  r;   rÂ   rR   Ú
componentsrT   rÝ   rÃ   rA   )r.   rH   rù  r  r  ÚsystemÚvectÚ
inneritemsrß   ÚkÚvr  Zmbracr3   r3   r4   Ú_print_BasisDependent\  sD    








z/MathMLPresentationPrinter._print_BasisDependentc                 C  s   t |jtd}|  |d¡S )Nró  z&#x2227;©rõ  rÕ   r   rø  ©r.   rH   rÕ   r3   r3   r4   Ú
_print_And†  s    z$MathMLPresentationPrinter._print_Andc                 C  s   t |jtd}|  |d¡S )Nró  z&#x2228;r  r  r3   r3   r4   Ú	_print_OrŠ  s    z#MathMLPresentationPrinter._print_Orc                 C  s   t |jtd}|  |d¡S )Nró  z&#x22BB;r  r  r3   r3   r4   rZ  Ž  s    z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)rø  rÕ   r¾  r3   r3   r4   rX  ’  s    z(MathMLPresentationPrinter._print_Impliesc                 C  s   t |jtd}|  |d¡S )Nró  z&#x21D4;r  r  r3   r3   r4   Ú_print_Equivalent•  s    z+MathMLPresentationPrinter._print_Equivalentc                 C  s‚   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ |jd jrd| j  d¡}| |  |jd ¡¡ n|  |jd ¡}| |¡ |S )Nr  r  z&#xAC;r   r„  )r;   rÂ   rÃ   rA   rÕ   rö  rE   )r.   r¶   r  r  rÊ   r3   r3   r4   rY  ™  s    

z$MathMLPresentationPrinter._print_Notc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S ©Nr  ©r;   rÂ   rÃ   rA   rº   ©r.   r¶   r  r3   r3   r4   Ú_print_bool¦  s    z%MathMLPresentationPrinter._print_boolc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S r  r  r  r3   r3   r4   Ú_print_NoneType®  s    z)MathMLPresentationPrinter._print_NoneTypec                 C  s.  d}| j  d¡}| dd¡ | dd¡ |jjr`|jjr`|jjrP|ddd	|f}qÜ|d	dd|f}n||jjr‚||d |j |d f}nZ|jjr¦t|ƒ}t	|ƒt	|ƒ|f}n6t
|ƒd
krÔt|ƒ}t	|ƒt	|ƒ||d f}nt|ƒ}|D ]H}||kr| j  d¡}| | j  |¡¡ | |¡ qà| |  |¡¡ qà|S )Nu   â€¦r„  r“  rÔ  r•  rÕ  rÑ   r   rQ   é   r  )r;   rÂ   r  rØ  Úis_infiniteÚstopÚstepÚis_positiveÚiterÚnextrV   ÚtuplerÃ   rA   rE   )r.   r  Údotsrˆ  ÚprintsetÚitÚelr  r3   r3   r4   Ú_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  r„  )rõ  rÕ   r   r;   rÂ   rÃ   rA   rê   Úfuncrµ   rE   )r.   rH   rÕ   r  r  rˆ  ræ  r3   r3   r4   Ú_hprint_variadic_functionÓ  s    

z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr-  r   )r;   rÂ   rÃ   rû   rE   rÕ   )r.   rH   r-  r3   r3   r4   Ú
_print_expá  s    z$MathMLPresentationPrinter._print_expc                 C  sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nr  r  )r;   rÂ   rÃ   rE   rF  rA   rº   rG  ©r.   r¶   r  rÊ   r3   r3   r4   rH  ç  s    
z+MathMLPresentationPrinter._print_Relationalc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r:   r7  rM  r3   r3   r4   rN  ð  s    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±  r°  )r;   rÂ   Ú_idr  rÃ   rA   Z_variable_namesÚ_name)r.   r¶   r,  Úindexr  r  r3   r3   r4   Ú_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±  r°  r  ú^)r;   rÂ   r"  r  rÃ   rA   Z_vector_namesr#  )r.   r¶   r,  r$  r  r&  r  r  r3   r3   r4   Ú_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±  r°  rÁ  r  r'  ©r;   rÂ   r  rÃ   rA   )r.   r¶   r&  r  r  r3   r3   r4   Ú_print_VectorZero  s    

z+MathMLPresentationPrinter._print_VectorZeroc                 C  sp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nr  r   r  r}  ©r;   rÂ   Ú_expr1Ú_expr2rÃ   r‰  r   rA   ©r.   rH   r  Úvec1Úvec2r  r3   r3   r4   Ú_print_Cross  s    
z&MathMLPresentationPrinter._print_Crossc                 C  sx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  ú&#x2207;r}  r   ©r;   rÂ   rÃ   rA   r‰  Ú_exprr   ©r.   rH   r  r  r3   r3   r4   Ú_print_Curl*  s    

z%MathMLPresentationPrinter._print_Curlc                 C  sx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  r2  r   r   r3  r5  r3   r3   r4   Ú_print_Divergence5  s    

z+MathMLPresentationPrinter._print_Divergencec                 C  sp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nr  r   r  r   r+  r.  r3   r3   r4   Ú
_print_Dot@  s    
z$MathMLPresentationPrinter._print_Dotc                 C  sP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  r2  r   r3  r5  r3   r3   r4   Ú_print_GradientK  s    
z)MathMLPresentationPrinter._print_Gradientc                 C  sP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  rï  r   r3  r5  r3   r3   r4   Ú_print_LaplacianS  s    
z*MathMLPresentationPrinter._print_Laplacianc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r±  Únormalz&#x2124;r)  rù   r3   r3   r4   Ú_print_Integers[  s    z)MathMLPresentationPrinter._print_Integersc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r±  r;  z&#x2102;r)  rù   r3   r3   r4   Ú_print_Complexesa  s    z*MathMLPresentationPrinter._print_Complexesc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r±  r;  z&#x211D;r)  rù   r3   r3   r4   Ú_print_Realsg  s    z&MathMLPresentationPrinter._print_Realsc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r±  r;  ú&#x2115;r)  rù   r3   r3   r4   Ú_print_Naturalsm  s    z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr,  r  r±  r;  r?  )r;   rÂ   r  rÃ   rA   rE   r   ÚZero)r.   r¶   r&  rÊ   r3   r3   r4   Ú_print_Naturals0s  s    
z*MathMLPresentationPrinter._print_Naturals0c                 C  s|   |j d |j d  }|j d }| j d¡}| j d¡}| dd¡ | dd	¡ | |  |¡¡ | |¡ | |  |¡¡ |S )
Nr   rQ   rð   r-  r„  r“  rÄ  r•  rÅ  )rÕ   r;   rÂ   r  rÃ   rE   )r.   rH   Úshiftrf   r"  rˆ  r3   r3   r4   Ú_print_SingularityFunction|  s    

z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  ÚNaNrø   rù   r3   r3   r4   r   ˆ  s    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 ]}| |  |¡¡ q‚| |¡ | |¡ |S )Nr,  r  r   rQ   r  r„  )r;   rÂ   rÃ   rA   rE   rÕ   rV   )r.   r¶   r'  r&  r  r  r  rÖ   r3   r3   r4   Ú_print_number_function  s    


z0MathMLPresentationPrinter._print_number_functionc                 C  s   |   |d¡S )NÚB©rF  rõ   r3   r3   r4   Ú_print_bernoulli   s    z*MathMLPresentationPrinter._print_bernoullic                 C  s   |   |d¡S )Nra  rH  rõ   r3   r3   r4   Ú_print_catalan¥  s    z(MathMLPresentationPrinter._print_catalanc                 C  s   |   |d¡S )NÚErH  rõ   r3   r3   r4   Ú_print_euler¨  s    z&MathMLPresentationPrinter._print_eulerc                 C  s   |   |d¡S )NÚFrH  rõ   r3   r3   r4   Ú_print_fibonacci«  s    z*MathMLPresentationPrinter._print_fibonaccic                 C  s   |   |d¡S )NÚLrH  rõ   r3   r3   r4   Ú_print_lucas®  s    z&MathMLPresentationPrinter._print_lucasc                 C  s   |   |d¡S )Nz&#x03B3;rH  rõ   r3   r3   r4   Ú_print_stieltjes±  s    z*MathMLPresentationPrinter._print_stieltjesc                 C  s   |   |d¡S )NÚTrH  rõ   r3   r3   r4   Ú_print_tribonacci´  s    z+MathMLPresentationPrinter._print_tribonaccic                 C  s`   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )Nr&  r  rœ  ú~rø   )r.   r¶   rÊ   r  r3   r3   r4   Ú_print_ComplexInfinity·  s    

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x2205;rø   rù   r3   r3   r4   r  Á  s    z)MathMLPresentationPrinter._print_EmptySetc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z	&#x1D54C;rø   rù   r3   r3   r4   Ú_print_UniversalSetÆ  s    z-MathMLPresentationPrinter._print_UniversalSetc                 C  sŒ   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | j d¡}| | j d¡¡ | |¡ |S )Nr   ©r™   r-  r„  r  r   ©	Úsympy.matricesr™   rÖ   r;   rÂ   r€  rÃ   rE   rA   ©r.   rH   r™   Úmatr"  rˆ  r  r3   r3   r4   Ú_print_AdjointË  s    

z(MathMLPresentationPrinter._print_Adjointc                 C  sŒ   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | j d¡}| | j d¡¡ | |¡ |S )Nr   rW  r-  r„  r  rR  rX  rZ  r3   r3   r4   Ú_print_TransposeÚ  s    

z*MathMLPresentationPrinter._print_Transposec                 C  st   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   rW  r-  r„  rÑ   )rY  r™   rÖ   r;   rÂ   r€  rÃ   rE   )r.   rH   r™   r[  r"  rˆ  r3   r3   r4   Ú_print_Inverseé  s    
z(MathMLPresentationPrinter._print_Inversec                 C  s&  ddl m} | j d¡}|j}t|d tƒrJ|d  ¡ t|dd … ƒ }nt|ƒ}t||ƒr´| 	¡ r´|d dkr~|dd … }n|d  |d< | j d¡}| 
| j d¡¡ | 
|¡ |d d… D ]D}| 
|  |t|ƒd¡¡ | j d¡}| 
| j d	¡¡ | 
|¡ qÀ| 
|  |d t|ƒd¡¡ |S )
Nr   )ÚMatMulr  rQ   rÑ   r  r‘  Fr|  )Ú!sympy.matrices.expressions.matmulr_  r;   rÂ   rÕ   r€  r   rÉ   rR   rÁ   rÃ   rA   r‰  r
   )r.   rH   r_  rÊ   rÕ   r  rÖ   r3   r3   r4   Ú_print_MatMulö  s0    
ÿÿz'MathMLPresentationPrinter._print_MatMulc                 C  s|   ddl m} |j|j }}| j d¡}t||ƒsX| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  |¡¡ |S )Nr   rW  r-  r„  )	rY  r™   r5  r3  r;   rÂ   r€  rÃ   rE   )r.   rH   r™   r5  r3  r"  rˆ  r3   r3   r4   Ú_print_MatPow  s    
z'MathMLPresentationPrinter._print_MatPowc                 C  s„   | j  d¡}|j}|d d… D ]D}| |  |t|ƒd¡¡ | j  d¡}| | j  d¡¡ | |¡ q| |  |d t|ƒd¡¡ |S )Nr  rÑ   Fr  z&#x2218;)r;   rÂ   rÕ   rÃ   r‰  r
   rA   )r.   rH   rÊ   rÕ   rÖ   r  r3   r3   r4   Ú_print_HadamardProduct   s    ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr\  z&#x1D7D8rø   ©r.   ÚZrÊ   r3   r3   r4   Ú_print_ZeroMatrix-  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr\  z&#x1D7D9rø   rd  r3   r3   r4   Ú_print_OneMatrix2  s    z*MathMLPresentationPrinter._print_OneMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z	&#x1D540;rø   )r.   rä  rÊ   r3   r3   r4   Ú_print_Identity7  s    z)MathMLPresentationPrinter._print_Identityc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nr  r„  r“  u   âŒ‹r•  u   âŒŠr   rµ  r!  r3   r3   r4   Ú_print_floor<  s    
z&MathMLPresentationPrinter._print_floorc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nr  r„  r“  u   âŒ‰r•  u   âŒˆr   rµ  r!  r3   r3   r4   Ú_print_ceilingE  s    
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 )Nr„  r  r   rQ   r  z&#x21A6;)r;   rÂ   rÕ   rV   rE   rÃ   rA   )r.   r¶   rÊ   r  Úsymbolsr  r3   r3   r4   Ú_print_LambdaN  s    




z'MathMLPresentationPrinter._print_Lambdac                 C  s*   | j  d¡}|D ]}| |  |¡¡ q|S rƒ  rI  )r.   r¶   rÊ   rß   r3   r3   r4   Ú_print_tuple^  s    z&MathMLPresentationPrinter._print_tuplec                 C  s   |   |j¡S r:   )rE   Úlabelrõ   r3   r3   r4   Ú_print_IndexedBased  s    z,MathMLPresentationPrinter._print_IndexedBasec                 C  s\   | j  d¡}| |  |j¡¡ t|jƒdkrF| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr,  rQ   r   )r;   rÂ   rÃ   rE   r5  rV   Úindicesrù   r3   r3   r4   Ú_print_Indexedg  s    z(MathMLPresentationPrinter._print_Indexedc                 C  sv   | j  d¡}| | j|jtd dd¡ | j  d¡}| dd¡ | dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )	Nr,  ÚAtomTrª  r„  r“  r)   r•  )	r;   rÂ   rÃ   r‰  Úparentr   r  rp  rE   )r.   r¶   rÊ   rˆ  rß   r3   r3   r4   Ú_print_MatrixElementp  s    

z.MathMLPresentationPrinter._print_MatrixElementc                 C  sv   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )Nr  r  z	&#x1d5a5;r„  Ú
separatorsrÝ  ©r;   rÂ   rÃ   rA   r  rÕ   rE   ©r.   r¶   rÊ   r  r  rß   r3   r3   r4   Ú_print_elliptic_f{  s    


z+MathMLPresentationPrinter._print_elliptic_fc                 C  sv   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )Nr  r  z	&#x1d5a4;r„  ru  rÝ  rv  rw  r3   r3   r4   Ú_print_elliptic_e‡  s    


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 ]}| |  |¡¡ qn| |¡ |S )	Nr  r  z	&#x1d6f1;r„  rð   ru  rÝ  z;|)r;   rÂ   rÃ   rA   rV   rÕ   r  rE   rw  r3   r3   r4   Ú_print_elliptic_pi“  s    


z,MathMLPresentationPrinter._print_elliptic_pic                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |j¡¡ |S )Nr  r  ÚEir¦  )r.   r¶   rÊ   r  r3   r3   r4   Ú	_print_Ei¢  s    
z#MathMLPresentationPrinter._print_Eic                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r,  r  rK  r   rQ   r¦  ©r.   r¶   rÊ   r  r  r3   r3   r4   Ú_print_expintª  s    

z'MathMLPresentationPrinter._print_expintc                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r.  r  ÚPr   rQ   r  r¦  r}  r3   r3   r4   Ú_print_jacobiµ  s    

z'MathMLPresentationPrinter._print_jacobic                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r.  r  ra  r   rQ   rð   r¦  r}  r3   r3   r4   Ú_print_gegenbauerÁ  s    

z+MathMLPresentationPrinter._print_gegenbauerc                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r,  r  rR  r   rQ   r¦  r}  r3   r3   r4   Ú_print_chebyshevtÍ  s    

z+MathMLPresentationPrinter._print_chebyshevtc                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r,  r  ÚUr   rQ   r¦  r}  r3   r3   r4   Ú_print_chebyshevuØ  s    

z+MathMLPresentationPrinter._print_chebyshevuc                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r,  r  r  r   rQ   r¦  r}  r3   r3   r4   Ú_print_legendreã  s    

z)MathMLPresentationPrinter._print_legendrec                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r.  r  r  r   rQ   rð   r¦  r}  r3   r3   r4   Ú_print_assoc_legendreî  s    

z/MathMLPresentationPrinter._print_assoc_legendrec                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r,  r  rO  r   rQ   r¦  r}  r3   r3   r4   Ú_print_laguerreú  s    

z)MathMLPresentationPrinter._print_laguerrec                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r.  r  rO  r   rQ   rð   r¦  r}  r3   r3   r4   Ú_print_assoc_laguerre  s    

z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r,  r  ÚHr   rQ   r¦  r}  r3   r3   r4   Ú_print_hermite  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)‹r6   r7   r8   r^   rU  rº   r‰  rÄ   r×   rè   r˜  rí   ró   rö   rú   rû   rý   rÿ   r  r  r÷   rŸ  r£  r¤  r¥  r§  r¨  r  r  r0  rV  rW  r·  r»  r¿  rÀ  rÂ  r6  r8  rÆ  r@  rC  r<  rÑ  rD  rÓ  rÜ  rÞ  Ú_print_Determinantrß  rã  rå  rE  rè  rë  rì  rS  rð  rT  rQ  rò  Ú_print_frozensetrø  r  r	  r
  rZ  rX  r  rY  r  r  r  r  r  r  Ú
_print_MinÚ
_print_Maxr   rH  rN  r%  r(  r*  r1  r6  r7  r8  r9  r:  r<  r=  r>  r@  rB  rD  r   rF  rI  Ú_print_bellrJ  rL  rN  rP  rQ  rS  rU  r  rV  r\  r]  r^  ra  rb  rc  rf  rg  rh  ri  rj  rl  rm  ro  rq  rt  rx  ry  rz  r|  r~  r€  r  r‚  r„  r…  r†  r‡  rˆ  rŠ  r3   r3   r3   r4   r[  D  s  L	/		&6	60'			* 		
			r[  Úcontentc                 K  s(   |dkrt |ƒ | ¡S t|ƒ | ¡S dS )zŠReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    ÚpresentationN)r[  rJ   r`   )rH   ÚprinterrB   r3   r3   r4   Úmathml  s    r“  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 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>

    r‘  N)r[  r`   rE   r   r\   Ztoprettyxmlr]   Úprint)rH   r’  rB   r  ZxmlZ
pretty_xmlr3   r3   r4   Úprint_mathml(  s    
r•  N)r  )r  )$r^   Ú
__future__r   Útypingr   Zsympy.core.mulr   Úsympy.core.singletonr   Úsympy.core.sortingr   Úsympy.core.sympifyr   Úsympy.printing.conventionsr   r	   Úsympy.printing.precedencer
   r   r   Z&sympy.printing.pretty.pretty_symbologyr   Úsympy.printing.printerr   r   Zmpmath.libmpr   r   r   r9  r   r`   r[  r“  r•  ZMathMLPrinterr3   r3   r3   r4   Ú<module>   s@   k   G           d

&