a
    Ÿ¬<b& ã                   @   sì   d Z ddlmZ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.
é    )ÚAnyÚDict)Ú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                   @   sT   e Zd ZdZddddddddddddi d	d
œZddd„Zdd„ Zdd„ Zdd„ ZdS )ÚMathMLPrinterBasez^Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    Nzutf-8FZabbreviatedú[ÚplainTú&#xB7;)ÚorderÚencodingÚfold_frac_powersZfold_func_bracketsÚfold_short_fracZinv_trig_styleÚln_notationZlong_frac_ratioÚ	mat_delimÚmat_symbol_styleÚ
mul_symbolÚroot_notationZsymbol_namesÚmul_symbol_mathml_numbersc                    sN   t  ˆ|¡ ddlm}m} |ƒ ˆ_G dd„ d|ƒ‰ ‡ ‡fdd„}|ˆj_d S )Nr   )ÚDocumentÚTextc                   @   s   e Zd Zddd„ZdS )z+MathMLPrinterBase.__init__.<locals>.RawTextÚ c                 S   s    | j r| d || j |¡¡ d S )Nz{}{}{})ÚdataÚwriteÚformat©ÚselfÚwriterÚindentÚ	addindentÚnewl© r-   úe/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/sympy/printing/mathml.pyÚwritexml5   s    z4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r#   r#   r#   )Ú__name__Ú
__module__Ú__qualname__r/   r-   r-   r-   r.   ÚRawText4   s   r3   c                    s   ˆ ƒ }| |_ ˆj|_|S ©N)r$   ÚdomZownerDocument)r$   Úr©r3   r(   r-   r.   ÚcreateRawTextNode9   s    z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Úxml.dom.minidomr!   r"   r5   ÚcreateTextNode)r(   Úsettingsr!   r"   r8   r-   r7   r.   r9   *   s    zMathMLPrinterBase.__init__c                 C   s,   t  | |¡}| ¡ }| dd¡}| ¡ }|S )z2
        Prints the expression as MathML.
        ÚasciiÚxmlcharrefreplace)r   Ú_printZtoxmlÚencodeÚdecode)r(   ÚexprZmathMLZunistrZxmlbstrÚresr-   r-   r.   ÚdoprintA   s
    zMathMLPrinterBase.doprintc                    sV   ddl m}m}m‰ m‰ d‡ ‡fdd„	}|j| _||_d‡fdd„	}|j| _||_d S )	Nr   )ÚElementr"   ÚNodeÚ_write_datar#   c           	         s  |  |d | j ¡ |  ¡ }t| ¡ ƒ}| ¡  |D ],}|  d| ¡ ˆ||| jƒ |  d¡ 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_NODEr/   )	r(   r)   r*   r+   r,   ÚattrsZa_namesZa_nameÚnode©rF   rG   r-   r.   r/   U   s,    
ÿ

ÿ
z/MathMLPrinterBase.apply_patch.<locals>.writexmlc                    s   ˆ |d|| j |f ƒ d S )Nz%s%s%s)r$   r'   )rG   r-   r.   r/   t   s    )r#   r#   r#   )r#   r#   r#   )r:   rE   r"   rF   rG   r/   Ú_Element_writexml_oldÚ_Text_writexml_old)r(   rE   r"   r/   r-   rT   r.   Úapply_patchK   s    zMathMLPrinterBase.apply_patchc                 C   s$   ddl m}m} | j|_| j|_d S )Nr   )rE   r"   )r:   rE   r"   rU   r/   rV   )r(   rE   r"   r-   r-   r.   Úrestore_patchy   s    zMathMLPrinterBase.restore_patch)N)	r0   r1   r2   Ú__doc__Z_default_settingsr9   rD   rW   rX   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}||v 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arccothZarcsecZarcsechZarccscZarccschÚlnÚeqZneqZgeqZleqÚgtÚltÚunionZ	intersect)5ÚAddr   Ú
DerivativeÚNumberri   ÚPowZMaxZMinZAbsÚAndÚOrZXorÚNotZImpliesÚSymbolÚMatrixSymbolZRandomSymbolÚIntegralÚSumrk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   ÚasinÚasinhÚacosÚacoshÚatanÚatanhÚatan2ÚacotZacothZasecZasechZacscZacschÚlogÚEqualityÚ
UnequalityÚGreaterThanÚLessThanÚStrictGreaterThanÚStrictLessThanÚUnionÚIntersection©Ú	__class__Ú__mro__r0   Ú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ur | j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tju 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ÚdividerK   Úoldr]   )Úcould_extract_minus_signr5   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyr«   r   ÚOner?   Úas_coeff_mulrQ   r   r   Ú
_from_argsÚas_ordered_factors)	r(   rB   Ú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   rK   r¨   r©   éÿÿÿÿr\   )	Ú_as_ordered_termsr?   r®   r5   r¯   r°   ÚappendrQ   Úpop)r(   rB   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	piecewiserK   Z	otherwiseÚpiece)	rÂ   ZcondÚ
ValueErrorr5   r¯   Ú	enumeraterQ   r°   r?   )r(   rB   Ú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)r5   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 )NrK   r_   r¨   r¬   )Úqr5   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ÚlowlimitrK   é   r   )r5   r¯   r°   r§   r?   rÂ   )r(   r£   r·   Úx_1Úx_2r-   r-   r.   Ú_print_Limit7  s    

z!MathMLContentPrinter._print_Limitc                 C   s   | j  d¡S )NZ
imaginaryi©r5   r¯   ©r(   r£   r-   r-   r.   Ú_print_ImaginaryUnitE  s    z)MathMLContentPrinter._print_ImaginaryUnitc                 C   s   | j  d¡S )NZ
eulergammarÝ   rÞ   r-   r-   r.   Ú_print_EulerGammaH  s    z&MathMLContentPrinter._print_EulerGammac                 C   s"   | j  d¡}| | j  d¡¡ |S )zvWe use unicode #x3c6 for Greek letter phi as defined here
        http://www.w3.org/2003/entities/2007doc/isogrk1.htmlr_   u   Ï†©r5   r¯   r°   r;   ©r(   r£   r·   r-   r-   r.   Ú_print_GoldenRatioK  s    z'MathMLContentPrinter._print_GoldenRatioc                 C   s   | j  d¡S )NZexponentialerÝ   rÞ   r-   r-   r.   Ú_print_Exp1R  s    z MathMLContentPrinter._print_Exp1c                 C   s   | j  d¡S )NÚpirÝ   rÞ   r-   r-   r.   Ú	_print_PiU  s    zMathMLContentPrinter._print_Pic                 C   s   | j  d¡S )NÚinfinityrÝ   rÞ   r-   r-   r.   Ú_print_InfinityX  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_BooleanTruea  s    z'MathMLContentPrinter._print_BooleanTruec                 C   s   | j  d¡S )NÚfalserÝ   rÞ   r-   r-   r.   Ú_print_BooleanFalsed  s    z(MathMLContentPrinter._print_BooleanFalsec                 C   s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr¨   r©   rç   )r5   r¯   r°   râ   r-   r-   r.   Ú_print_NegativeInfinityg  s    z,MathMLContentPrinter._print_NegativeInfinityc                    s*   ‡ ‡‡fdd„‰t ˆ jƒ}| ¡  ˆ|ƒS )Nc                    s8  ˆj  d¡}| ˆj  ˆ ˆ ¡¡¡ ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| d ƒdkr¾ˆj  d¡}| ˆ | d d ¡¡ | |¡ ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| d ƒdkrüˆj  d¡}| ˆ | d d ¡¡ | |¡ t| ƒdkr| ˆ ˆ j¡¡ n| ˆ| dd … ƒ¡ |S )	Nr¨   r×   r   é   rØ   rK   ZuplimitrÙ   )r5   r¯   r°   r§   r?   rQ   Úfunction)Úlimitsr·   Z	bvar_elemÚlow_elemÚup_elem©r£   Ú
lime_recurr(   r-   r.   rö   n  s(    



z8MathMLContentPrinter._print_Integral.<locals>.lime_recur)rL   rò   Úreverse)r(   r£   rò   r-   rõ   r.   Ú_print_Integralm  s    
z$MathMLContentPrinter._print_Integralc                 C   s
   |   |¡S r4   )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 )NrK   zmml:mrowr   zmml:moú úmml:mi©rQ   r5   r¯   rÇ   r°   r;   ©ÚitemsÚmrowrÉ   ÚitemÚmoÚmi©r(   r-   r.   Újoin’  s    
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S   s   | t v rt  | ¡S | S d S r4   ©r   Úget©Úsr-   r-   r.   r¤   ¤  s    
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                    s   g | ]}ˆ |ƒ‘qS r-   r-   ©Ú.0Úsup©r¤   r-   r.   Ú
<listcomp>¬  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                    s   g | ]}ˆ |ƒ‘qS r-   r-   ©r
  Úsubr  r-   r.   r  ­  r  rû   zmml:msubzmml:msupzmml:msubsup)r5   r¯   r§   r   Únamer°   r;   )r(   Úsymrh   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   rK   r¨   rÈ   rÙ   Údegreer_   )Ú	_settingsÚexpÚis_RationalrÔ   r5   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 r4   ©r5   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 r4   )	r5   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×   rK   r  )
r5   r¯   r§   r	   rB   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¨   )r5   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 r4   )r5   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*  )r5   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*  )r5   r¯   r°   r§   r?   ÚlhsÚrhsrâ   r-   r-   r.   Ú_print_Relational  s
    z&MathMLContentPrinter._print_Relationalc                 C   s*   | j  d¡}|D ]}| |  |¡¡ q|S )zfMathML reference for the <list> element:
        http://www.w3.org/TR/MathML2/chapter4.html#contm.listrL   ©r5   r¯   r°   r?   )r(   ÚseqÚdom_elementr   r-   r-   r.   Ú_print_list  s    z MathMLContentPrinter._print_listc                 C   s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r4   r!  ©r(   rÔ   r4  r-   r-   r.   Ú
_print_int#  s    zMathMLContentPrinter._print_intc                 C   s,   | j  d¡}|jD ]}| |  |¡¡ q|S )NÚset©r5   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©r5   r¯   r°   rÂ   r?   r+  r-   r-   r.   Ú_print_Complement2  s
    
z&MathMLContentPrinter._print_Complementc                 C   s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr¨   Zcartesianproductr;  r+  r-   r-   r.   Ú_print_ProductSet9  s
    
z&MathMLContentPrinter._print_ProductSet)N),r0   r1   r2   rY   Ú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.  r1  r5  r7  Ú_print_ImpliesÚ
_print_NotÚ
_print_Xorr:  r<  r=  r-   r-   r-   r.   rZ      sR   B#
	8rZ   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}||v rx||   S qx|j jd.krª|ƒ S |j j}| ¡ S )/r[   Úmnz&#x2192;ú&dd;r  z&int;z&#x2211;rk   rl   rm   rn   rw   rx   ry   rz   r{   r|   r}   ú=z&#x2260;z&#x2265;z&#x2264;rJ   rH   ú&#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„   ri   rŠ   rŒ   r   rk   rl   rm   rn   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 u 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   rN  ú&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¤   rV  r¥   r¦   r-   r  r.   r§   J  sr    Ñ2z$MathMLPresentationPrinter.mathml_tagFc                 C   sJ   t |ƒ}||k s|s<||kr<| j d¡}| |  |¡¡ |S |  |¡S d S ©NÚmfenced)r
   r5   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urŠˆ j d¡}ˆ jd rTtt| ƒƒdk rT| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tju 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ë   rK   r­   r  r   r¾   )r²   r«   r   r³   r5   r¯   r  rQ   rÓ   ÚsetAttributer?   r°   r´   r   r   rµ   r¶   r;   r§   r\  r   )rB   rÿ   r«   r¸   r¹   ÚfracrÕ   Zxdenrº   r»   r·   Úyr¼   r  r-   r.   Úmultiply¡  s>    










z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyrÿ   r  ú-)r5   r¯   r®   r°   r;   )r(   rB   rc  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   rK   r  rd  ú+)r5   r¯   r¿   r°   r?   r®   r;   )r(   rB   r   rÿ   rÂ   rÃ   r·   rb  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#   rX  r   Úcloseú]Úopen)	r5   r¯   rÌ   rÍ   rÎ   r°   r?   r  r`  )r(   rÏ   ÚtablerÉ   r·   rÐ   rb  r[  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  rd  )	rÔ   r5   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 )NrK   r   )rÒ   r?   rÔ   rk  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  ÚlimrK   r  rÙ   r   )r5   r¯   r°   r;   r?   rÂ   r§   )	r(   r£   rÿ   rl  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  rH  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ä   /  s    z%MathMLPresentationPrinter._print_Exp1c                 C   s"   | j  d¡}| | j  d¡¡ |S )Nr  z&pi;rá   râ   r-   r-   r.   ræ   4  s    z#MathMLPresentationPrinter._print_Pic                 C   s"   | j  d¡}| | j  d¡¡ |S )Nr  ú&#x221E;rá   râ   r-   r-   r.   rè   9  s    z)MathMLPresentationPrinter._print_Infinityc                 C   sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nrÿ   r  rd  )r5   r¯   r°   r;   rè   )r(   r£   rÿ   rb  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_HBarG  s    z%MathMLPresentationPrinter._print_HBarc                 C   s"   | j  d¡}| | j  d¡¡ |S )Nr  rI  rá   râ   r-   r-   r.   rà   L  s    z+MathMLPresentationPrinter._print_EulerGammac                 C   s"   | j  d¡}| | j  d¡¡ |S )Nr  ZTribonacciConstantrá   râ   r-   r-   r.   Ú_print_TribonacciConstantQ  s    z3MathMLPresentationPrinter._print_TribonacciConstantc                 C   s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr  r   ú&#x2020;©r5   r¯   r°   r?   rÂ   r;   ©r(   r£   r  r-   r-   r.   Ú_print_DaggerV  s    z'MathMLPresentationPrinter._print_Daggerc                 C   sd   | j  d¡}| |  |jd ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ |S )Nrÿ   r   r  z&#x2208;rK   rr  )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_HilbertSpacee  s    z-MathMLPresentationPrinter._print_HilbertSpacec                 C   s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr  z	&#x1D49E;r   ©r5   r¯   r°   r;   r?   rÂ   rs  r-   r-   r.   Ú_print_ComplexSpacej  s    z-MathMLPresentationPrinter._print_ComplexSpacec                 C   s"   | j  d¡}| | j  d¡¡ |S )Nr  z&#x2131;rá   râ   r-   r-   r.   Ú_print_FockSpacep  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;)rK   rÙ   rð   rÿ   rð   c                 s   s   | ]}t |ƒd kV  qdS )rK   N)rQ   )r
  rm  r-   r-   r.   Ú	<genexpr>z  r  z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r  rK   rÙ   r  r  r   T©rZ  rF  r   )r5   r¯   rQ   rò   Úallr°   r;   r'  r?   r\  rñ   r   )	r(   rB   Z
intsymbolsrÿ   r  rm  r  r  Údr-   r-   r.   rø   v  s>    "



ÿ
z)MathMLPresentationPrinter._print_Integralc                 C   s@  t |jƒ}| j d¡}|  |d d ¡}|  |d d ¡}| j d¡}| | j |  |¡¡¡ | j d¡}|  |d d ¡}| j d¡}	|	 | j d¡¡ | |¡ | |	¡ | |¡ | |¡ | |¡ | |¡ | j d¡}
|
 |¡ tt	|j
ƒƒdkr|
 |  |j
¡¡ n(| j d¡}| |  |j
¡¡ |
 |¡ |
S )	NZ
munderoverr   rK   rÙ   r  rÿ   rG  rX  )rL   rò   r5   r¯   r?   r°   r;   r§   rQ   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 )NrK   rÿ   r   r  rú   r  rü   rý   r  r-   r.   r  ¼  s    
z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S   s   | t v rt  | ¡S | S d S r4   r  r  r-   r-   r.   r¤   Î  s    
z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                    s   g | ]}ˆ |ƒ‘qS r-   r-   r	  r  r-   r.   r  Ö  r  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                    s   g | ]}ˆ |ƒ‘qS r-   r-   r  r  r-   r.   r  ×  r  r  r   r  r  r  ÚboldÚmathvariant)r   r  r5   r¯   r°   r;   rQ   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   ©r5   r¯   r`  r°   r?   rÂ   )r(   rB   Úencr-   r-   r.   Ú_print_conjugate÷  s    z*MathMLPresentationPrinter._print_conjugatec                 C   sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nrÿ   ZFuncr  )r5   r¯   r°   r\  r   r;   )r(   ÚoprB   Úrowr  r-   r-   r.   Ú_print_operator_afterý  s    
z/MathMLPresentationPrinter._print_operator_afterc                 C   s   |   d|jd ¡S )Nú!r   ©r‹  rÂ   ©r(   rB   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 )NrX  r]  ZlinethicknessÚ0r   rK   r†  )r(   rB   r[  ra  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 )NrK   r   rÙ   ZmsqrtZmrootr¾   r]  r  r†   r   )r  r  rc   rÔ   rÒ   r  r5   r¯   r°   r?   r  Zis_negativer\  r   rk  )r(   r£   r·   ra  r…  r-   r-   r.   r     s^    $ÿ

ÿ
ÿ

z$MathMLPresentationPrinter._print_Powc                 C   s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r4   r!  râ   r-   r-   r.   r"  J  s    z'MathMLPresentationPrinter._print_Numberc                 C   sL   | j  d¡}| dd¡ | dd¡ | |  |j¡¡ | |  |j¡¡ |S )NrX  rf  õ   âŸ©rh  õ   âŸ¨)r5   r¯   r`  r°   r?   rb   ra   )r(   rÉ   r[  r-   r-   r.   Ú_print_AccumulationBoundsO  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	   rB   r§   r5   r¯   r'  r(  r°   r;   r?   )r(   r£   r}  rÏ   Zdimr  Únumr·   Úxxrb  Zmnumrÿ   ra  r-   r-   r.   r)  W  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~   rX  )r5   r¯   r§   r  r°   r;   rÂ   r?   )r(   r£   rÿ   r·   rb  rÃ   r-   r-   r.   r,  ‡  s    


z)MathMLPresentationPrinter._print_Functionc                 C   sh  t |jƒ}t|j|dd}| jd }| j d¡}d|v 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   re  rK   rE  r  r  Ú10z+infz-inf)r   r%  r#  r$  r  r5   r¯   Úsplitr°   r;   rè   rï   )r(   rB   ZdpsZstr_realÚ	separatorrÿ   Zmantr  rE  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   rX  rK   rw  )r(   rB   rÿ   rÏ   r  r[  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  rX  ©r5   r¯   r°   r;   r§   rÂ   r?   )r(   r£   rÿ   r  r[  rÃ   r-   r-   r.   r-  Ê  s    


z&MathMLPresentationPrinter._print_Basicc                 C   sB   | j  d¡}| j  d¡}|jD ]}| |  |¡¡ q| |¡ |S )Nrÿ   rX  r9  )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ÿ   rX  rf  Ú}rh  Ú{ú)rg  ú(r   )	r5   r¯   ÚstartÚendr`  r°   r?   Z
right_openZ	left_open)r(   rÉ   rÿ   r[  r-   r-   r.   Ú_print_IntervalÝ  s     
z)MathMLPresentationPrinter._print_Intervalc                 C   sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrÿ   rX  rf  ú|rh  r   r†  )r(   rB   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frakturrX  )r5   r¯   r`  r°   r;   r?   )r(   rÊ   rB   rÿ   r  r[  r-   r-   r.   Ú_print_re_im   s    

z&MathMLPresentationPrinter._print_re_imc                 C   s   |   d|jd ¡S )NÚRr   ©r§  rÂ   ©r(   rB   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   rK   r  )r5   r¯   r°   r\  rÂ   r;   )r(   rB   ÚsymbolÚprecrÿ   rÃ   r·   rb  r-   r-   r.   Ú_print_SetOp  s    
z&MathMLPresentationPrinter._print_SetOpc                 C   s   t d }|  |d|¡S )Nr   z&#x222A;©r   r°  ©r(   rB   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_SymmetricDifference1  s    z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C   s   t d }|  |d|¡S )NZ
ProductSetz&#x00d7;r±  r²  r-   r-   r.   r=  5  s    z+MathMLPresentationPrinter._print_ProductSetc                 C   s   |   |j¡S r4   )Ú
_print_setrÂ   )r(   r  r-   r-   r.   r:  9  s    z*MathMLPresentationPrinter._print_FiniteSetc                 C   sN   t |td}| j d¡}| dd¡ | dd¡ |D ]}| |  |¡¡ q4|S )N©ÚkeyrX  rf  rž  rh  rŸ  )Úsortedr   r5   r¯   r`  r°   r?   )r(   r  rþ   r[  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   rX  rK   r  )r5   r¯   Ú
is_BooleanZis_Notr°   r?   r;   )r(   rÂ   r®  rÿ   r[  rÃ   r·   rb  r-   r-   r.   Ú_print_LogOpG  s     

z&MathMLPresentationPrinter._print_LogOpc                 C   s°  ddl m} ||jkr"|  |j¡S t||ƒr:| ¡  ¡ }n
d|fg}| j d¡}|D ]T\}}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>i  r  zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>r¸  rK   r  re  r¾   rd  rX  rQ  )Zsympy.vectorr½  Zzeror?   rT  Zseparaterþ   r5   r¯   rL   Ú
componentsrN   rÇ   r°   r;   )r(   rB   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(   rB   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.   rC    s    z$MathMLPresentationPrinter._print_Xorc                 C   s   |   |jd¡S )Nz&#x21D2;)r¼  rÂ   rŽ  r-   r-   r.   rA  ‘  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   rX  )r5   r¯   r°   r;   rÂ   r»  r?   )r(   r£   rÿ   r  r·   r-   r-   r.   rB  ˜  s    

z$MathMLPresentationPrinter._print_Notc                 C   s(   | j  d¡}| | j  |  |¡¡¡ |S ©Nr  ©r5   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   â€¦rX  rf  rž  rh  rŸ  r¾   r   rK   é   r  )r5   r¯   r`  r¢  Úis_infiniteÚstopÚstepZis_positiveÚiterÚnextrQ   Útupler°   r;   r?   )r(   r  Údotsr[  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  rX  )rº  rÂ   r   r5   r¯   r°   r;   rÓ   Úfuncr¢   r?   )r(   rB   rÂ   rÿ   r  r[  r®  r-   r-   r.   Ú_hprint_variadic_functionÒ  s    

z3MathMLPresentationPrinter._hprint_variadic_functionc                 C   s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr  r   )r5   r¯   r°   rä   r?   rÂ   )r(   rB   r  r-   r-   r.   Ú
_print_expà  s    z$MathMLPresentationPrinter._print_expc                 C   sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nrÿ   r  )r5   r¯   r°   r?   r/  r;   r§   r0  ©r(   r£   rÿ   r·   r-   r-   r.   r1  æ  s    
z+MathMLPresentationPrinter._print_Relationalc                 C   s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r4   r!  r6  r-   r-   r.   r7  ï  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  )r5   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  ú^)r5   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ã  ©r5   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  rR  ©r5   r¯   Z_expr1Z_expr2r°   r\  r   r;   ©r(   rB   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;rR  r   ©r5   r¯   r°   r;   r\  Z_exprr   ©r(   rB   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_Divergence4  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_GradientJ  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_LaplacianR  s    
z*MathMLPresentationPrinter._print_Laplacianc                 C   s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r‚  Únormalz&#x2124;rå  râ   r-   r-   r.   Ú_print_IntegersZ  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_Complexes`  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_Realsf  s    z&MathMLPresentationPrinter._print_Realsc                 C   s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r‚  rò  ú&#x2115;rå  râ   r-   r-   r.   Ú_print_Naturalsl  s    z)MathMLPresentationPrinter._print_Naturalsc                 C   sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr  r  r‚  rò  rö  )r5   r¯   r`  r°   r;   r?   r   ZZero)r(   r£   r  r·   r-   r-   r.   Ú_print_Naturals0r  s    
z*MathMLPresentationPrinter._print_Naturals0c                 C   s|   |j d |j d  }|j d }| j d¡}| j d¡}| dd¡ | dd	¡ | |  |¡¡ | |¡ | |  |¡¡ |S )
Nr   rK   rÙ   r  rX  rf  r“  rh  r”  )rÂ   r5   r¯   r`  r°   r?   )r(   rB   Úshiftr`   r  r[  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   rK   rÿ   rX  )r5   r¯   r°   r;   r?   rÂ   rQ   )r(   r£   r  r  r  rÿ   rb  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 )NrJ  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  rn  ú~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  rX  r  rq  ©	Úsympy.matricesr‹   rÃ   r5   r¯   rT  r°   r?   r;   ©r(   rB   r‹   Úmatr  r[  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  rX  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  rX  r¾   )r  r‹   rÃ   r5   r¯   rT  r°   r?   )r(   rB   r‹   r  r  r[  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ÿ   rK   r¾   r  rd  FrQ  )Z!sympy.matrices.expressions.matmulr  r5   r¯   rÂ   rT  r   r¶   rL   r®   r°   r;   r\  r
   )r(   rB   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  rX  )	r  r‹   r  r  r5   r¯   rT  r°   r?   )r(   rB   r‹   r  r  r  r[  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;)r5   r¯   rÂ   r°   r\  r
   r;   )r(   rB   r·   rÂ   rÃ   r  r-   r-   r.   Ú_print_HadamardProduct  s    ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C   s"   | j  d¡}| | j  d¡¡ |S )NrE  z&#x1D7D8rá   ©r(   ÚZr·   r-   r-   r.   Ú_print_ZeroMatrix,  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C   s"   | j  d¡}| | j  d¡¡ |S )NrE  z&#x1D7D9rá   r  r-   r-   r.   Ú_print_OneMatrix1  s    z*MathMLPresentationPrinter._print_OneMatrixc                 C   s"   | j  d¡}| | j  d¡¡ |S )Nr  z	&#x1D540;rá   )r(   r¬  r·   r-   r-   r.   Ú_print_Identity6  s    z)MathMLPresentationPrinter._print_Identityc                 C   sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrÿ   rX  rf  u   âŒ‹rh  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ÿ   rX  rf  u   âŒ‰rh  u   âŒˆr   r†  rÝ  r-   r-   r.   Ú_print_ceilingD  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 )NrX  rÿ   r   rK   r  z&#x21A6;)r5   r¯   rÂ   rQ   r?   r°   r;   )r(   r£   r·   rÿ   Úsymbolsr  r-   r-   r.   Ú_print_LambdaM  s    




z'MathMLPresentationPrinter._print_Lambdac                 C   s*   | j  d¡}|D ]}| |  |¡¡ q|S rW  r2  )r(   r£   r·   rÉ   r-   r-   r.   Ú_print_tuple]  s    z&MathMLPresentationPrinter._print_tuplec                 C   s   |   |j¡S r4   )r?   ÚlabelrÞ   r-   r-   r.   Ú_print_IndexedBasec  s    z,MathMLPresentationPrinter._print_IndexedBasec                 C   s\   | j  d¡}| |  |j¡¡ t|jƒdkrF| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr  rK   r   )r5   r¯   r°   r?   r  rQ   Úindicesrâ   r-   r-   r.   Ú_print_Indexedf  s    z(MathMLPresentationPrinter._print_Indexedc                 C   sv   | j  d¡}| | j|jtd dd¡ | j  d¡}| dd¡ | dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )	Nr  ZAtomTr{  rX  rf  r#   rh  )	r5   r¯   r°   r\  Úparentr   r`  r%  r?   )r(   r£   r·   r[  rÉ   r-   r-   r.   Ú_print_MatrixElemento  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;rX  Ú
separatorsr¥  ©r5   r¯   r°   r;   r`  rÂ   r?   ©r(   r£   r·   r  rb  rÉ   r-   r-   r.   Ú_print_elliptic_fz  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;rX  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;rX  rÙ   r)  r¥  z;|)r5   r¯   r°   r;   rQ   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Eirw  )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   rK   rw  ©r(   r£   r·   rb  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   rK   rð   rw  r0  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  rJ  r   rK   rÙ   rw  r0  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   rK   rw  r0  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   rK   rw  r0  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  r2  r   rK   rw  r0  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  r2  r   rK   rÙ   rw  r0  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   rK   rw  r0  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   rK   rÙ   rw  r0  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   rK   rw  r0  r-   r-   r.   Ú_print_hermite  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)‹r0   r1   r2   rY   r>  r§   r\  r±   rÄ   rÑ   rk  rÖ   rÜ   rß   rã   rä   ræ   rè   rï   ro  rà   rp  rt  ru  rv  rx  ry  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=  r:  r·  Z_print_frozensetr¼  rÄ  rÇ  rÈ  rC  rA  rÉ  rB  rÍ  rì   rî   rÎ  rÙ  rÛ  Z
_print_MinZ
_print_MaxrÜ  r1  r7  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/  r1  r3  r4  r5  r7  r8  r9  r:  r;  r=  r-   r-   r-   r.   rD  C  s  L	/		&6	60'			* 		
			rD  Ú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)rD  rD   rZ   )rB   Úprinterr<   r-   r-   r.   Úmathml  s    rA  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)rD  rZ   r?   r   rW   ZtoprettyxmlrX   Úprint)rB   r@  r<   r  ÚxmlZ
pretty_xmlr-   r-   r.   Úprint_mathml'  s    
rD  N)r>  )r>  )$rY   Útypingr   r   ZtDictZ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   rZ   rD  rA  rD  ZMathMLPrinterr-   r-   r-   r.   Ú<module>   s>   k   G           d

&