U
    ˜9%e& ã                   @  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.   úT/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/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ÚvalueZ
childNodesÚlenZnodeTypeZ	TEXT_NODEr0   )	r)   r*   r+   r,   r-   ÚattrsZa_namesÚ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Ú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ÚNumberrk   ÚPowZMaxZMinZAbsÚAndÚOrZXorÚNotZImpliesÚSymbolÚMatrixSymbolZRandomSymbolÚIntegralÚSumrm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   Ú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_mulrQ   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²   ÚappendrQ   Ú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±   Ú	enumeraterQ   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 )NÚ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   ra   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.htmlra   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@   rQ   Ú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©rQ   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)   Úsymrj   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Ü   Údegreera   )Ú	_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×   r6  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cartesianproductr=  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/  r0  r3  r7  r9  Ú_print_ImpliesÚ
_print_NotÚ
_print_Xorr<  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;rm   rn   ro   rp   ry   rz   r{   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†   rk   rŒ   rŽ   r   rm   rn   ro   rp   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   rP  ú&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¦   rX  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  rQ   rÖ   ÚsetAttributer@   r²   r¶   r   r   r·   r¸   r<   r©   r^  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   re  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  rf  ú+)r6   r±   rÁ   r²   r@   r°   r<   )r)   rC   r   r  rÄ   rÅ   r¹   rd  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$   rZ  r   Úcloseú]Úopen)	r6   r±   rÏ   rÐ   rÑ   r²   r@   r  rb  )r)   rÒ   ÚtablerË   r¹   rÓ   rd  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   ra  rî   r  r  rf  )	r×   r6   r±   r  rb  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×   rm  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  rn  r  r¹   rÝ   Ú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  rJ  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  rf  )r6   r±   r²   r<   rë   )r)   r¥   r  rd  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  rK  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   ru  )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Ä   rv  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)rQ   )r  ro  r.   r.   r/   Ú	<genexpr>{  s     z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r  rL   rÜ   r  r  r   T©r\  rH  r   )r6   r±   rQ   rõ   Úallr²   r<   r)  r@   r^  rô   r   )	r)   rC   Z
intsymbolsr  r  ro  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  rI  rZ  )rM   rõ   r6   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 )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<   rQ   rb  )	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/   rA  ò  s    ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   ©r6   r±   rb  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²   r^  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 )NrZ  r_  ZlinethicknessÚ0r   rL   r‰  )r)   rC   r]  rc  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   re   r×   rÕ   r  r6   r±   r²   r@   r!  Zis_negativer^  r   rm  )r)   r¥   r¹   rc  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 )NrZ  rh  õ   âŸ©rj  õ   âŸ¨)r6   r±   rb  r²   r@   rd   rc   )r)   rË   r]  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Ò   Údimr  Únumr¹   Zxxrd  Zmnumr  rc  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€   rZ  )r6   r±   r©   r  r²   r<   rÄ   r@   )r)   r¥   r  r¹   rd  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   rg  rL   rG  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  rG  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   rZ  rL   rz  )r)   rC   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  rZ  ©r6   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  rZ  r;  )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  rZ  rh  Ú}rj  Ú{ú)ri  ú(r   )	r6   r±   ÚstartÚendrb  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  rZ  rh  ú|rj  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frakturrZ  )r6   r±   rb  r²   r<   r@   )r)   rÌ   rC   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)   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/   r0    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²   r^  rÄ   r<   )r)   rC   ÚsymbolÚprecr  rÅ   r¹   rd  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/   r<  :  s    z*MathMLPresentationPrinter._print_FiniteSetc                 C  sN   t |td}| j d¡}| dd¡ | dd¡ |D ]}| |  |¡¡ q4|S )N©ÚkeyrZ  rh  r¡  rj  r¢  )Úsortedr   r6   r±   rb  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   rZ  rL   r  )r6   r±   Ú
is_BooleanZis_Notr²   r@   r<   )r)   rÄ   r±  r  r]  rÅ   r¹   rd  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  rg  rÀ   rf  rZ  rS  )Zsympy.vectorrÀ  Úzeror@   rV  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/   rE  Ž  s    z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r¿  rÄ   r‘  r.   r.   r/   rC  ’  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   rZ  )r6   r±   r²   r<   rÄ   r¾  r@   )r)   r¥   r  r  r¹   r.   r.   r/   rD  ™  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   â€¦rZ  rh  r¡  rj  r¢  rÀ   r   rL   é   r  )r6   r±   rb  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  rZ  )r½  rÄ   r   r6   r±   r²   r<   rÖ   Úfuncr¤   r@   )r)   rC   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   )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@   r1  r<   r©   r2  ©r)   r¥   r  r¹   r.   r.   r/   r3  ç  s    
z+MathMLPresentationPrinter._print_Relationalc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r5   r#  r8  r.   r.   r/   r9  ð  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±   Ú_idrb  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ã  rb  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±   rb  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  rT  ©r6   r±   Z_expr1Z_expr2r²   r^  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;rT  r   ©r6   r±   r²   r<   r^  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±   rb  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  rZ  rh  r–  rj  r—  )rÄ   r6   r±   rb  r²   r@   )r)   rC   Úshiftrb   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   rL   r  rZ  )r6   r±   r²   r<   r@   rÄ   rQ   )r)   r¥   r  r  r  r  rd  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 )NrL  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  rq  ú~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  rZ  r  rt  ©	Úsympy.matricesr   rÅ   r6   r±   rV  r²   r@   r<   ©r)   rC   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  rZ  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  rZ  rÀ   )r  r   rÅ   r6   r±   rV  r²   r@   )r)   rC   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  rL   rÀ   r  rf  FrS  )Z!sympy.matrices.expressions.matmulr  r6   r±   rÄ   rV  r   r¸   rM   r°   r²   r<   r^  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  rZ  )	r  r   r!  r  r6   r±   rV  r²   r@   )r)   rC   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;)r6   r±   rÄ   r²   r^  r
   r<   )r)   rC   r¹   rÄ   rÅ   r  r.   r.   r/   Ú_print_HadamardProduct   s    ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  s"   | j  d¡}| | j  d¡¡ |S )NrG  z&#x1D7D8rä   ©r)   ÚZr¹   r.   r.   r/   Ú_print_ZeroMatrix-  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )NrG  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  rZ  rh  u   âŒ‹rj  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  rZ  rh  u   âŒ‰rj  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 )NrZ  r  r   rL   r  z&#x21A6;)r6   r±   rÄ   rQ   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 rY  r4  )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!  rQ   Ú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AtomTr~  rZ  rh  r$   rj  )	r6   r±   r²   r^  Úparentr   rb  r*  r@   )r)   r¥   r¹   r]  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;rZ  Ú
separatorsr¨  ©r6   r±   r²   r<   rb  rÄ   r@   ©r)   r¥   r¹   r  rd  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;rZ  r.  r¨  r/  r0  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;rZ  rÜ   r.  r¨  z;|)r6   r±   r²   r<   rQ   rÄ   rb  r@   r0  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Eirz  )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   rz  ©r)   r¥   r¹   rd  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ó   rz  r5  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  rL  r   rL   rÜ   rz  r5  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   rz  r5  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   rz  r5  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  r7  r   rL   rz  r5  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  r7  r   rL   rÜ   rz  r5  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   rz  r5  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Ü   rz  r5  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   rz  r5  r.   r.   r/   Ú_print_hermite  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)‹r1   r2   r3   rZ   r@  r©   r^  r³   rÆ   rÔ   rm  rÙ   rß   râ   ræ   rç   ré   rë   rò   rr  rã   rs  rw  rx  ry  r{  r|  rû   rü   r  rA  rB  r‹  rŽ  r’  r“  r•  r"  r$  r˜  r+  r.  r(  rž  r/  r   r§  r©  Z_print_Determinantrª  r®  r°  r0  r³  r¶  r·  r>  r¹  r?  r<  rº  Z_print_frozensetr¿  rÉ  rÌ  rÍ  rE  rC  rÎ  rD  rÒ  rï   rñ   rÓ  rÞ  rà  Z
_print_MinZ
_print_Maxrá  r3  r9  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-  r1  r2  r3  r4  r6  r8  r9  r:  r<  r=  r>  r?  r@  rB  r.   r.   r.   r/   rF  D  s  L	/		&6	60'			* 		
			rF  Ú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)rF  rE   r\   )rC   Úprinterr=   r.   r.   r/   Úmathml  s    rF  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>

    rD  N)rF  r\   r@   r   rX   ZtoprettyxmlrY   Úprint)rC   rE  r=   r  ÚxmlZ
pretty_xmlr.   r.   r/   Úprint_mathml(  s    
rI  N)rC  )rC  )$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\   rF  rF  rI  ZMathMLPrinterr.   r.   r.   r/   Ú<module>   s@   k   G           d

&