U
    §me& ã                   @  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-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_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© r.   ú9/tmp/pip-unpacked-wheel-rdz2gdd2/sympy/printing/mathml.pyÚwritexml6   s    z4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r$   r$   r$   )Ú__name__Ú
__module__Ú__qualname__r0   r.   r.   r.   r/   ÚRawText5   s   r4   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r%   ÚdomZownerDocument)r%   Úr©r4   r)   r.   r/   ÚcreateRawTextNode:   s    z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Úxml.dom.minidomr"   r#   r6   ÚcreateTextNode)r)   Úsettingsr"   r#   r9   r.   r8   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/   Ú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ÚvalueÚ
childNodesÚlenZnodeTypeZ	TEXT_NODEr0   )	r)   r*   r+   r,   r-   ÚattrsZa_namesZa_nameÚnode©rG   rH   r.   r/   r0   V   s2    
ÿ

   ÿ
z/MathMLPrinterBase.apply_patch.<locals>.writexmlc                   s   ˆ |d|| j |f ƒ d S )Nz%s%s%s)r%   r(   )rH   r.   r/   r0   u   s    )r$   r$   r$   )r$   r$   r$   )r;   rF   r#   rG   rH   r0   Ú_Element_writexml_oldÚ_Text_writexml_old)r)   rF   r#   r0   r.   rU   r/   Úapply_patchL   s    zMathMLPrinterBase.apply_patchc                 C  s$   ddl m}m} | j|_| j|_d S )Nr   )rF   r#   )r;   rF   r#   rV   r0   rW   )r)   rF   r#   r.   r.   r/   Úrestore_patchz   s    zMathMLPrinterBase.restore_patch)N)
r1   r2   r3   Ú__doc__r!   Ú__annotations__r:   rE   rX   rY   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              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ÚtimesZ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arccothZarcsecZarcsechZarccscZarccschÚlnÚeqZneqZgeqZleqÚgtÚltÚunionZ	intersect)5ZAddr   Ú
DerivativeÚNumberrj   ÚPowZMaxZMinZAbsÚAndÚOrZXorZNotZImpliesÚSymbolÚMatrixSymbolZRandomSymbolÚIntegralÚSumrl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   ÚasinÚasinhÚacosÚacoshÚatanÚatanhÚatan2ÚacotZacothZasecZasechZacscZacschÚlogÚEqualityÚ
UnequalityÚGreaterThanÚLessThanÚStrictGreaterThanÚStrictLessThanÚUnionÚIntersection©Ú	__class__Ú__mro__r1   Úlower)r)   ÚeÚ	translateÚclsÚnr.   r.   r/   Ú
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ÚdividerL   Úoldr_   )Úcould_extract_minus_signr6   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyrª   r   ÚOner@   Úas_coeff_mulrR   r   r   Ú
_from_argsÚas_ordered_factors)	r)   rC   Úxrª   ÚnumerÚdenomÚcoeffÚtermsÚtermr.   r.   r/   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   rL   r§   r¨   éÿÿÿÿr^   )	Ú_as_ordered_termsr@   r­   r6   r®   r¯   ÚappendrR   Úpop)r)   rC   r   ÚargsZlastProcessedZ	plusNodesÚargr¶   r.   r.   r/   Ú
_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.Z	piecewiserL   Z	otherwiseÚpiece)	rÁ   ZcondÚ
ValueErrorr6   r®   Ú	enumeraterR   r¯   r@   )r)   rC   ÚrootÚir¢   ÚcrÄ   r.   r.   r/   Ú_print_Piecewise  s    z%MathMLContentPrinter._print_Piecewisec              	   C  s^   | j  d¡}t|jƒD ]B}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q0| |¡ q|S )NZmatrixZ	matrixrow)r6   r®   ÚrangeÚrowsÚcolsr¯   r@   )r)   Úmr¶   rÈ   Zx_rÚjr.   r.   r/   Ú_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 )NrL   r`   r§   r«   )Úqr6   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ÚlowlimitrL   é   r   )r6   r®   r¯   r¦   r@   rÁ   )r)   r¢   r¶   Úx_1Úx_2r.   r.   r/   Ú_print_Limit8  s    

z!MathMLContentPrinter._print_Limitc                 C  s   | j  d¡S )NZ
imaginaryi©r6   r®   ©r)   r¢   r.   r.   r/   Ú_print_ImaginaryUnitF  s    z)MathMLContentPrinter._print_ImaginaryUnitc                 C  s   | j  d¡S )NZ
eulergammarÜ   rÝ   r.   r.   r/   Ú_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.htmlr`   u   Ï†©r6   r®   r¯   r<   ©r)   r¢   r¶   r.   r.   r/   Ú_print_GoldenRatioL  s    z'MathMLContentPrinter._print_GoldenRatioc                 C  s   | j  d¡S )NZexponentialerÜ   rÝ   r.   r.   r/   Ú_print_Exp1S  s    z MathMLContentPrinter._print_Exp1c                 C  s   | j  d¡S )NÚpirÜ   rÝ   r.   r.   r/   Ú	_print_PiV  s    zMathMLContentPrinter._print_Pic                 C  s   | j  d¡S )NÚinfinityrÜ   rÝ   r.   r.   r/   Ú_print_InfinityY  s    z$MathMLContentPrinter._print_Infinityc                 C  s   | j  d¡S )NZ
notanumberrÜ   rÝ   r.   r.   r/   Ú
_print_NaN\  s    zMathMLContentPrinter._print_NaNc                 C  s   | j  d¡S )NZemptysetrÜ   rÝ   r.   r.   r/   Ú_print_EmptySet_  s    z$MathMLContentPrinter._print_EmptySetc                 C  s   | j  d¡S )NÚtruerÜ   rÝ   r.   r.   r/   Ú_print_BooleanTrueb  s    z'MathMLContentPrinter._print_BooleanTruec                 C  s   | j  d¡S )NÚfalserÜ   rÝ   r.   r.   r/   Ú_print_BooleanFalsee  s    z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr§   r¨   ræ   )r6   r®   r¯   rá   r.   r.   r/   Ú_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×   rL   ZuplimitrØ   )r6   r®   r¯   r¦   r@   rR   Úfunction)Úlimitsr¶   Z	bvar_elemÚlow_elemÚup_elem©r¢   Ú
lime_recurr)   r.   r/   rõ   o  s(    



z8MathMLContentPrinter._print_Integral.<locals>.lime_recur)rM   rñ   Úreverse)r)   r¢   rñ   r.   rô   r/   Ú_print_Integraln  s    
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r5   )r÷   rÝ   r.   r.   r/   Ú
_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 )NrL   zmml:mrowr   zmml:moú úmml:mi©rR   r6   r®   rÆ   r¯   r<   ©ÚitemsÚmrowrÈ   ÚitemÚmoÚmi©r)   r.   r/   Újoin“  s    
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  s   | t krt  | ¡S | S d S r5   ©r   Úget©Úsr.   r.   r/   r£   ¥  s    
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r.   r.   ©Ú.0Úsup©r£   r.   r/   Ú
<listcomp>­  s     z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r.   r.   ©r	  Úsubr  r.   r/   r  ®  s     rú   zmml:msubzmml:msupzmml:msubsup)r6   r®   r¦   r   Únamer¯   r<   )r)   Úsymri   r  r  ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr.   ©r)   r£   r/   Ú_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   rL   r§   rÇ   rØ   Údegreer`   )Ú	_settingsÚexpÚis_RationalrÓ   r6   r®   r¯   rÑ   r<   rÒ   r@   Úbaser¦   )r)   r¢   r¶   ZxmldegZxmlcnrÙ   r.   r.   r/   Ú
_print_PowË  s&    
ÿ


zMathMLContentPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r5   ©r6   r®   r¦   r¯   r<   rÒ   rá   r.   r.   r/   Ú_print_Numberâ  s    z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r5   )	r6   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 ]J\}}| |  |¡¡ |dkrL| j  d¡}| |  t	|ƒ¡¡ | |¡ qL| |¡ | |  |j¡¡ |S )Nr§   ZpartialdiffrÖ   rL   r  )
r6   r®   r¦   r	   rC   r¯   ÚreversedÚvariable_countr@   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§   )r6   r®   r¯   r¦   rÁ   r@   ©r)   r¢   r¶   rÂ   r.   r.   r/   Ú_print_Function   s
    
z$MathMLContentPrinter._print_Functionc                 C  s2   | j  |  |¡¡}|jD ]}| |  |¡¡ q|S r5   )r6   r®   r¦   rÁ   r¯   r@   r)  r.   r.   r/   Ú_print_Basic  s    
z!MathMLContentPrinter._print_Basicc                 C  sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]}| |  |¡¡ q.|S r(  )r6   r®   r¦   r¯   rÁ   r@   )r)   r¢   r¶   rÙ   rÂ   r.   r.   r/   Ú_print_AssocOp  s    

z#MathMLContentPrinter._print_AssocOpc                 C  sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S r(  )r6   r®   r¯   r¦   r@   ÚlhsÚrhsrá   r.   r.   r/   Ú_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.listrM   ©r6   r®   r¯   r@   )r)   ÚseqÚdom_elementrÿ   r.   r.   r/   Ú_print_list  s    z MathMLContentPrinter._print_listc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r5   r  ©r)   rÓ   r2  r.   r.   r/   Ú
_print_int$  s    zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]}| |  |¡¡ q|S )NÚset©r6   r®   rÁ   r¯   r@   r)  r.   r.   r/   Ú_print_FiniteSet-  s    
z%MathMLContentPrinter._print_FiniteSetc                 C  s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr§   Zsetdiff©r6   r®   r¯   rÁ   r@   r)  r.   r.   r/   Ú_print_Complement3  s
    
z&MathMLContentPrinter._print_Complementc                 C  s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr§   Zcartesianproductr9  r)  r.   r.   r/   Ú_print_ProductSet:  s
    
z&MathMLContentPrinter._print_ProductSet)N),r1   r2   r3   rZ   Ú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/  r3  r5  Ú_print_ImpliesÚ
_print_NotÚ
_print_Xorr8  r:  r;  r.   r.   r.   r/   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 )/r]   Úmnz&#x2192;ú&dd;r  z&int;z&#x2211;rl   rm   rn   ro   rx   ry   rz   r{   r|   r}   r~   ú=z&#x2260;z&#x2265;z&#x2264;rK   rI   ú&#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…   ZLimitr„   rj   r‰   r‹   rŒ   rl   rm   rn   ro   r   rŽ   r   r   r‘   r’   r”   r“   r–   r—   r˜   r™   rš   r›   ZlerchphiÚzetaZdirichlet_etaZ
elliptic_kZ
lowergammaZ
uppergammaÚgammaZtotientZreduced_totientZprimenuZ
primeomegaZfresnelsZfresnelcZLambertWZ	HeavisideZBooleanTrueZBooleanFalseZNoneTypeZmathieusZmathieucZmathieusprimeZ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   rL  ú&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£   rT  r¤   r¥   r.   r  r/   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
   r6   r®   r¯   r@   )r)   rÿ   ÚlevelÚstrictZprec_valÚbracr.   r.   r/   Ú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ê   rL   r¬   r   r   r½   )r±   rª   r   r²   r6   r®   r  rR   rÒ   ÚsetAttributer@   r¯   r³   r   r   r´   rµ   r<   r¦   rZ  r   )rC   rþ   rª   r·   r¸   ÚfracrÔ   Zxdenr¹   rº   r¶   Úyr»   r  r.   r/   Úmultiply¢  s>    










z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyrþ   r   ú-)r6   r®   r­   r¯   r<   )r)   rC   ra  rþ   r¶   r.   r  r/   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   rL   r   rb  ú+)r6   r®   r¾   r¯   r@   r­   r<   )r)   rC   r   rþ   rÁ   rÂ   r¶   r`  r.   r.   r/   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$   rV  r   Úcloseú]Úopen)	r6   r®   rË   rÌ   rÍ   r¯   r@   r  r^  )r)   rÎ   ÚtablerÈ   r¶   rÏ   r`  rY  r.   r.   r/   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   rb  )	rÓ   r6   r®   r  r^  r¯   r@   rÑ   r<   )r)   r¢   Ú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 )NrL   r   )rÑ   r@   rÓ   ri  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  ÚlimrL   r   rØ   r   )r6   r®   r¯   r<   r@   rÁ   r¦   )	r)   r¢   rþ   rj  r  r¶   rÙ   ZarrowrÚ   r.   r.   r/   rÛ     s"    





z&MathMLPresentationPrinter._print_Limitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&ImaginaryI;rà   rá   r.   r.   r/   rÞ   &  s    z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  rF  rà   rá   r.   r.   r/   râ   +  s    z,MathMLPresentationPrinter._print_GoldenRatioc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&ExponentialE;rà   rá   r.   r.   r/   rã   0  s    z%MathMLPresentationPrinter._print_Exp1c                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&pi;rà   rá   r.   r.   r/   rå   5  s    z#MathMLPresentationPrinter._print_Pic                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  ú&#x221E;rà   rá   r.   r.   r/   rç   :  s    z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nrþ   r   rb  )r6   r®   r¯   r<   rç   )r)   r¢   rþ   r`  r¶   r.   r.   r/   rî   ?  s    


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x210F;rà   rá   r.   r.   r/   Ú_print_HBarH  s    z%MathMLPresentationPrinter._print_HBarc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  rG  rà   rá   r.   r.   r/   rß   M  s    z+MathMLPresentationPrinter._print_EulerGammac                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  ZTribonacciConstantrà   rá   r.   r.   r/   Ú_print_TribonacciConstantR  s    z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr  r   ú&#x2020;©r6   r®   r¯   r@   rÁ   r<   ©r)   r¢   r  r.   r.   r/   Ú_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;rL   rp  )r)   r¢   rþ   r   r.   r.   r/   Ú_print_Contains]  s    
z)MathMLPresentationPrinter._print_Containsc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x210B;rà   rá   r.   r.   r/   Ú_print_HilbertSpacef  s    z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr  z	&#x1D49E;r   ©r6   r®   r¯   r<   r@   rÁ   rq  r.   r.   r/   Ú_print_ComplexSpacek  s    z-MathMLPresentationPrinter._print_ComplexSpacec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x2131;rà   rá   r.   r.   r/   Ú_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;)rL   rØ   rï   rþ   rï   c                 s  s   | ]}t |ƒd kV  qdS )rL   N)rR   )r	  rk  r.   r.   r/   Ú	<genexpr>{  s     z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r   rL   rØ   r  r  r   T©rX  rD  r   )r6   r®   rR   rñ   Úallr¯   r<   r%  r@   rZ  rð   r   )	r)   rC   Z
intsymbolsrþ   r   rk  r  r  Údr.   r.   r/   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   rL   rØ   r   rþ   rE  rV  )rM   rñ   r6   r®   r@   r¯   r<   r¦   rR   rÒ   rð   )r)   r¢   rñ   Zsubsuprò   ró   ZsummandÚlowÚvarÚequalrþ   Zfencer.   r.   r/   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 )NrL   rþ   r   r   rù   r  rû   rü   r  r.   r/   r  ½  s    
z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  s   | t krt  | ¡S | S d S r5   r  r  r.   r.   r/   r£   Ï  s    
z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r.   r.   r  r  r.   r/   r  ×  s     z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r.   r.   r  r  r.   r/   r  Ø  s     r  r   r  r  r  ÚboldÚmathvariant)r   r  r6   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mencloseÚnotationÚtopr   ©r6   r®   r^  r¯   r@   rÁ   )r)   rC   Úencr.   r.   r/   Ú_print_conjugateø  s    z*MathMLPresentationPrinter._print_conjugatec                 C  sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nrþ   ZFuncr   )r6   r®   r¯   rZ  r   r<   )r)   ÚoprC   Úrowr   r.   r.   r/   Ú_print_operator_afterþ  s    
z/MathMLPresentationPrinter._print_operator_afterc                 C  s   |   d|jd ¡S )Nú!r   ©r‰  rÁ   ©r)   rC   r.   r.   r/   Ú_print_factorial  s    z*MathMLPresentationPrinter._print_factorialc                 C  s   |   d|jd ¡S )Nz!!r   r‹  rŒ  r.   r.   r/   Ú_print_factorial2	  s    z+MathMLPresentationPrinter._print_factorial2c                 C  s^   | j  d¡}| j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | |¡ |S )NrV  r[  ZlinethicknessÚ0r   rL   r„  )r)   rC   rY  r_  r.   r.   r/   Ú_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 )NrL   r   rØ   ZmsqrtZmrootr½   r[  r  r†   r   )r  r  rd   rÓ   rÑ   r  r6   r®   r¯   r@   r  Zis_negativerZ  r   ri  )r)   r¢   r¶   r_  rƒ  r.   r.   r/   r    s^    $ÿ

ÿ
ÿ

z$MathMLPresentationPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r5   r  rá   r.   r.   r/   r   K  s    z'MathMLPresentationPrinter._print_Numberc                 C  sL   | j  d¡}| dd¡ | dd¡ | |  |j¡¡ | |  |j¡¡ |S )NrV  rd  õ   âŸ©rf  õ   âŸ¨)r6   r®   r^  r¯   r@   rc   rb   )r)   rÈ   rY  r.   r.   r/   Ú_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	   rC   r¦   r6   r®   r%  r&  r¯   r<   r@   )r)   r¢   r{  rÎ   Zdimr  Únumr¶   Zxxr`  Zmnumrþ   r_  r.   r.   r/   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   rV  )r6   r®   r¦   r  r¯   r<   rÁ   r@   )r)   r¢   rþ   r¶   r`  rÂ   r.   r.   r/   r*  ˆ  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)Zstrip_zerosr    rþ   r¢   r   rc  rL   rC  r   r  Ú10z+infz-inf)r   r#  r!  r"  r  r6   r®   Úsplitr¯   r<   rç   rî   )r)   rC   ZdpsZstr_realÚ	separatorrþ   Zmantr  rC  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   rV  rL   ru  )r)   rC   rþ   rÎ   r  rY  r.   r.   r/   Ú_print_polylog½  s    


z(MathMLPresentationPrinter._print_polylogc                 C  sp   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | j  d¡}|jD ]}| |  |¡¡ qL| |¡ |S )Nrþ   r  rV  ©r6   r®   r¯   r<   r¦   rÁ   r@   )r)   r¢   rþ   r  rY  rÂ   r.   r.   r/   r+  Ë  s    


z&MathMLPresentationPrinter._print_Basicc                 C  sB   | j  d¡}| j  d¡}|jD ]}| |  |¡¡ q| |¡ |S )Nrþ   rV  r7  )r)   r¢   rþ   r¶   rÂ   r.   r.   r/   Ú_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þ   rV  rd  Ú}rf  Ú{ú)re  ú(r   )	r6   r®   ÚstartÚendr^  r¯   r@   Z
right_openZ	left_open)r)   rÈ   rþ   rY  r.   r.   r/   Ú_print_IntervalÞ  s     
z)MathMLPresentationPrinter._print_Intervalc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrþ   rV  rd  ú|rf  r   r„  )r)   rC   r  rþ   r¶   r.   r.   r/   Ú
_print_Absö  s    
z$MathMLPresentationPrinter._print_Absc                 C  sj   | j  d¡}| j  d¡}| dd¡ | | j  |¡¡ | |¡ | j  d¡}| |  |¡¡ | |¡ |S )Nrþ   r  r€  ZfrakturrV  )r6   r®   r^  r¯   r<   r@   )r)   rÉ   rC   rþ   r  rY  r.   r.   r/   Ú_print_re_im  s    

z&MathMLPresentationPrinter._print_re_imc                 C  s   |   d|jd ¡S )NÚRr   ©r¤  rÁ   ©r)   rC   r  r.   r.   r/   Ú	_print_re  s    z#MathMLPresentationPrinter._print_rec                 C  s   |   d|jd ¡S )NÚIr   r¦  r§  r.   r.   r/   Ú	_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Â   r.   r.   r/   r,    s    

z(MathMLPresentationPrinter._print_AssocOpc                 C  sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]B}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q2|S )Nrþ   r   rL   r   )r6   r®   r¯   rZ  rÁ   r<   )r)   rC   ÚsymbolÚprecrþ   rÂ   r¶   r`  r.   r.   r/   Ú_print_SetOp  s    
z&MathMLPresentationPrinter._print_SetOpc                 C  s   t d }|  |d|¡S )Nrœ   z&#x222A;©r   r­  ©r)   rC   r¬  r.   r.   r/   Ú_print_Union&  s    z&MathMLPresentationPrinter._print_Unionc                 C  s   t d }|  |d|¡S )Nr   z&#x2229;r®  r¯  r.   r.   r/   Ú_print_Intersection*  s    z-MathMLPresentationPrinter._print_Intersectionc                 C  s   t d }|  |d|¡S )NZ
Complementz&#x2216;r®  r¯  r.   r.   r/   r:  .  s    z+MathMLPresentationPrinter._print_Complementc                 C  s   t d }|  |d|¡S )NZSymmetricDifferenceú&#x2206;r®  r¯  r.   r.   r/   Ú_print_SymmetricDifference2  s    z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  s   t d }|  |d|¡S )NZ
ProductSetz&#x00d7;r®  r¯  r.   r.   r/   r;  6  s    z+MathMLPresentationPrinter._print_ProductSetc                 C  s   |   |j¡S r5   )Ú
_print_setrÁ   )r)   r  r.   r.   r/   r8  :  s    z*MathMLPresentationPrinter._print_FiniteSetc                 C  sN   t |td}| j d¡}| dd¡ | dd¡ |D ]}| |  |¡¡ q4|S )N©ÚkeyrV  rd  r›  rf  rœ  )Úsortedr   r6   r®   r^  r¯   r@   )r)   r  rý   rY  rÿ   r.   r.   r/   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   rV  rL   r   )r6   r®   Ú
is_BooleanZis_Notr¯   r@   r<   )r)   rÁ   r«  rþ   rY  rÂ   r¶   r`  r.   r.   r/   Ú_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¶   r.   r.   r/   Ú<lambda>j  ó    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>rµ  rL   r   rc  r½   rb  rV  rO  )Zsympy.vectorrº  Zzeror@   rR  Zseparaterý   r6   r®   rM   Ú
componentsrO   rÆ   r¯   r<   )r)   rC   rº  rý   rþ   ÚsystemZvectZ
inneritemsrÈ   ÚkÚvr   Zmbracr.   r.   r/   Ú_print_BasisDependent\  sD    








z/MathMLPresentationPrinter._print_BasisDependentc                 C  s   t |jtd}|  |d¡S )Nrµ  z&#x2227;©r·  rÁ   r   r¹  ©r)   rC   rÁ   r.   r.   r/   Ú
_print_And†  s    z$MathMLPresentationPrinter._print_Andc                 C  s   t |jtd}|  |d¡S )Nrµ  z&#x2228;rÃ  rÄ  r.   r.   r/   Ú	_print_OrŠ  s    z#MathMLPresentationPrinter._print_Orc                 C  s   t |jtd}|  |d¡S )Nrµ  z&#x22BB;rÃ  rÄ  r.   r.   r/   rA  Ž  s    z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r¹  rÁ   rŒ  r.   r.   r/   r?  ’  s    z(MathMLPresentationPrinter._print_Impliesc                 C  s   t |jtd}|  |d¡S )Nrµ  z&#x21D4;rÃ  rÄ  r.   r.   r/   Ú_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   rV  )r6   r®   r¯   r<   rÁ   r¸  r@   )r)   r¢   rþ   r   r¶   r.   r.   r/   r@  ™  s    

z$MathMLPresentationPrinter._print_Notc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S ©Nr  ©r6   r®   r¯   r<   r¦   ©r)   r¢   r  r.   r.   r/   Ú_print_bool¦  s    z%MathMLPresentationPrinter._print_boolc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S rÈ  rÉ  rÊ  r.   r.   r/   Ú_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   â€¦rV  rd  r›  rf  rœ  r½   r   rL   é   r  )r6   r®   r^  rŸ  Úis_infiniteÚstopÚstepZis_positiveÚiterÚnextrR   Útupler¯   r<   r@   )r)   r  ÚdotsrY  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   rV  )r·  rÁ   r   r6   r®   r¯   r<   rÒ   Úfuncr¡   r@   )r)   rC   rÁ   rþ   r   rY  r«  r.   r.   r/   Ú_hprint_variadic_functionÓ  s    

z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr  r   )r6   r®   r¯   rã   r@   rÁ   )r)   rC   r  r.   r.   r/   Ú
_print_expá  s    z$MathMLPresentationPrinter._print_expc                 C  sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nrþ   r   )r6   r®   r¯   r@   r-  r<   r¦   r.  ©r)   r¢   rþ   r¶   r.   r.   r/   r/  ç  s    
z+MathMLPresentationPrinter._print_Relationalc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r5   r  r4  r.   r.   r/   r5  ð  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  )r6   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€  r  r   ú^)r6   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€  r  r  r   rá  ©r6   r®   r^  r¯   r<   )r)   r¢   rà  r  r   r.   r.   r/   Ú_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   rP  ©r6   r®   Z_expr1Z_expr2r¯   rZ  r   r<   ©r)   rC   rþ   Zvec1Zvec2r   r.   r.   r/   Ú_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;rP  r   ©r6   r®   r¯   r<   rZ  Z_exprr   ©r)   rC   rþ   r   r.   r.   r/   Ú_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   rè  r   r   ré  rê  r.   r.   r/   Ú_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æ  r.   r.   r/   Ú
_print_Dot@  s    
z$MathMLPresentationPrinter._print_Dotc                 C  sP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrþ   r   rè  r   ré  rê  r.   r.   r/   Ú_print_GradientK  s    
z)MathMLPresentationPrinter._print_Gradientc                 C  sP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrþ   r   r²  r   ré  rê  r.   r.   r/   Ú_print_LaplacianS  s    
z*MathMLPresentationPrinter._print_Laplacianc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r€  Únormalz&#x2124;rã  rá   r.   r.   r/   Ú_print_Integers[  s    z)MathMLPresentationPrinter._print_Integersc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r€  rð  z&#x2102;rã  rá   r.   r.   r/   Ú_print_Complexesa  s    z*MathMLPresentationPrinter._print_Complexesc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r€  rð  z&#x211D;rã  rá   r.   r.   r/   Ú_print_Realsg  s    z&MathMLPresentationPrinter._print_Realsc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r€  rð  ú&#x2115;rã  rá   r.   r.   r/   Ú_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ô  )r6   r®   r^  r¯   r<   r@   r   ZZero)r)   r¢   r  r¶   r.   r.   r/   Ú_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   rL   rØ   r  rV  rd  r‘  rf  r’  )rÁ   r6   r®   r^  r¯   r@   )r)   rC   Úshiftra   r
  rY  r.   r.   r/   Ú_print_SingularityFunction|  s    

z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  ÚNaNrà   rá   r.   r.   r/   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   rL   rþ   rV  )r6   r®   r¯   r<   r@   rÁ   rR   )r)   r¢   r  r  r  rþ   r`  rÂ   r.   r.   r/   Ú_print_number_function  s    


z0MathMLPresentationPrinter._print_number_functionc                 C  s   |   |d¡S )NÚB©rú  rÝ   r.   r.   r/   Ú_print_bernoulli   s    z*MathMLPresentationPrinter._print_bernoullic                 C  s   |   |d¡S )NrH  rü  rÝ   r.   r.   r/   Ú_print_catalan¥  s    z(MathMLPresentationPrinter._print_catalanc                 C  s   |   |d¡S )NÚErü  rÝ   r.   r.   r/   Ú_print_euler¨  s    z&MathMLPresentationPrinter._print_eulerc                 C  s   |   |d¡S )NÚFrü  rÝ   r.   r.   r/   Ú_print_fibonacci«  s    z*MathMLPresentationPrinter._print_fibonaccic                 C  s   |   |d¡S )NÚLrü  rÝ   r.   r.   r/   Ú_print_lucas®  s    z&MathMLPresentationPrinter._print_lucasc                 C  s   |   |d¡S )Nz&#x03B3;rü  rÝ   r.   r.   r/   Ú_print_stieltjes±  s    z*MathMLPresentationPrinter._print_stieltjesc                 C  s   |   |d¡S )NÚTrü  rÝ   r.   r.   r/   Ú_print_tribonacci´  s    z+MathMLPresentationPrinter._print_tribonaccic                 C  s`   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )Nrà  r   rl  ú~rà   )r)   r¢   r¶   r   r.   r.   r/   Ú_print_ComplexInfinity·  s    

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr   z&#x2205;rà   rá   r.   r.   r/   ré   Á  s    z)MathMLPresentationPrinter._print_EmptySetc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr   z	&#x1D54C;rà   rá   r.   r.   r/   Ú_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  rV  r   ro  ©	Úsympy.matricesrŠ   rÂ   r6   r®   rR  r¯   r@   r<   ©r)   rC   rŠ   Úmatr
  rY  r   r.   r.   r/   Ú_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   r  r  rV  r   r  r  r  r.   r.   r/   Ú_print_TransposeÚ  s    

z*MathMLPresentationPrinter._print_Transposec                 C  st   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   r  r  rV  r½   )r  rŠ   rÂ   r6   r®   rR  r¯   r@   )r)   rC   rŠ   r  r
  rY  r.   r.   r/   Ú_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þ   rL   r½   r   rb  FrO  )Z!sympy.matrices.expressions.matmulr  r6   r®   rÁ   rR  r   rµ   rM   r­   r¯   r<   rZ  r
   )r)   rC   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||ƒsX| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  |¡¡ |S )Nr   r  r  rV  )	r  rŠ   r  r  r6   r®   rR  r¯   r@   )r)   rC   rŠ   r  r  r
  rY  r.   r.   r/   Ú_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;)r6   r®   rÁ   r¯   rZ  r
   r<   )r)   rC   r¶   rÁ   rÂ   r   r.   r.   r/   Ú_print_HadamardProduct   s    ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  s"   | j  d¡}| | j  d¡¡ |S )NrC  z&#x1D7D8rà   ©r)   ÚZr¶   r.   r.   r/   Ú_print_ZeroMatrix-  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )NrC  z&#x1D7D9rà   r  r.   r.   r/   Ú_print_OneMatrix2  s    z*MathMLPresentationPrinter._print_OneMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr  z	&#x1D540;rà   )r)   r©  r¶   r.   r.   r/   Ú_print_Identity7  s    z)MathMLPresentationPrinter._print_Identityc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrþ   rV  rd  u   âŒ‹rf  u   âŒŠr   r„  rÛ  r.   r.   r/   Ú_print_floor<  s    
z&MathMLPresentationPrinter._print_floorc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrþ   rV  rd  u   âŒ‰rf  u   âŒˆr   r„  rÛ  r.   r.   r/   Ú_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 )NrV  rþ   r   rL   r   z&#x21A6;)r6   r®   rÁ   rR   r@   r¯   r<   )r)   r¢   r¶   rþ   Úsymbolsr   r.   r.   r/   Ú_print_LambdaN  s    




z'MathMLPresentationPrinter._print_Lambdac                 C  s*   | j  d¡}|D ]}| |  |¡¡ q|S rU  r0  )r)   r¢   r¶   rÈ   r.   r.   r/   Ú_print_tuple^  s    z&MathMLPresentationPrinter._print_tuplec                 C  s   |   |j¡S r5   )r@   ÚlabelrÝ   r.   r.   r/   Ú_print_IndexedBased  s    z,MathMLPresentationPrinter._print_IndexedBasec                 C  s\   | j  d¡}| |  |j¡¡ t|jƒdkrF| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr  rL   r   )r6   r®   r¯   r@   r  rR   Úindicesrá   r.   r.   r/   Ú_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  ZAtomTry  rV  rd  r$   rf  )	r6   r®   r¯   rZ  Úparentr   r^  r#  r@   )r)   r¢   r¶   rY  rÈ   r.   r.   r/   Ú_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;rV  Ú
separatorsr¢  ©r6   r®   r¯   r<   r^  rÁ   r@   ©r)   r¢   r¶   r  r`  rÈ   r.   r.   r/   Ú_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;rV  r'  r¢  r(  r)  r.   r.   r/   Ú_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;rV  rØ   r'  r¢  z;|)r6   r®   r¯   r<   rR   rÁ   r^  r@   r)  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Eiru  )r)   r¢   r¶   r  r.   r.   r/   Ú	_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   rÿ  r   rL   ru  ©r)   r¢   r¶   r`  r   r.   r.   r/   Ú_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   rL   rï   ru  r.  r.   r.   r/   Ú_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   rH  r   rL   rØ   ru  r.  r.   r.   r/   Ú_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   r  r   rL   ru  r.  r.   r.   r/   Ú_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   rL   ru  r.  r.   r.   r/   Ú_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   r0  r   rL   ru  r.  r.   r.   r/   Ú_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   r0  r   rL   rØ   ru  r.  r.   r.   r/   Ú_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   r  r   rL   ru  r.  r.   r.   r/   Ú_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   r  r   rL   rØ   ru  r.  r.   r.   r/   Ú_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   rL   ru  r.  r.   r.   r/   Ú_print_hermite  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)‹r1   r2   r3   rZ   r<  r¦   rZ  r°   rÃ   rÐ   ri  rÕ   rÛ   rÞ   râ   rã   rå   rç   rî   rm  rß   rn  rr  rs  rt  rv  rw  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±  r:  r³  r;  r8  r´  Z_print_frozensetr¹  rÂ  rÅ  rÆ  rA  r?  rÇ  r@  rË  rë   rí   rÌ  r×  rÙ  Z
_print_MinZ
_print_MaxrÚ  r/  r5  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&  r*  r+  r,  r-  r/  r1  r2  r3  r5  r6  r7  r8  r9  r;  r.   r.   r.   r/   rB  D  s  L	/		&6	60'			* 		
			rB  Ú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)rB  rE   r\   )rC   Úprinterr=   r.   r.   r/   Ú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)rB  r\   r@   r   rX   ZtoprettyxmlrY   Úprint)rC   r>  r=   r  ÚxmlZ
pretty_xmlr.   r.   r/   Úprint_mathml(  s    
rB  N)r<  )r<  )$rZ   Ú
__future__r   Útypingr   Zsympy.core.mulr   Zsympy.core.singletonr   Zsympy.core.sortingr   Zsympy.core.sympifyr   Zsympy.printing.conventionsr   r	   Zsympy.printing.precedencer
   r   r   Z&sympy.printing.pretty.pretty_symbologyr   Zsympy.printing.printerr   r   Zmpmath.libmpr   r   r   r!  r   r\   rB  r?  rB  ZMathMLPrinterr.   r.   r.   r/   Ú<module>   s@   k   G           d

&