o
    Ð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 d S )Nz{}{}{})ÚdataÚwriteÚformat©ÚselfÚwriterÚindentÚ	addindentÚnewl© r.   úED:\Projects\ConvertPro\env\Lib\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    r5   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r%   ÚdomZownerDocument)r%   Úr©r5   r)   r.   r/   ÚcreateRawTextNode:   s   z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Úxml.dom.minidomr"   r#   r7   ÚcreateTextNode)r)   Úsettingsr"   r#   r:   r.   r9   r/   r;   +   s   zMathMLPrinterBase.__init__c                 C  s,   t  | |¡}| ¡ }| dd¡}| ¡ }|S )z2
        Prints the expression as MathML.
        ÚasciiÚxmlcharrefreplace)r   Ú_printZtoxmlÚencodeÚdecode)r)   ÚexprZmathMLZunistrZxmlbstrÚresr.   r.   r/   Ú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¡ q| jr{|  d¡ t| jƒdkrU| jd j	ˆ j
krU| jd  |ddd¡ n|  |¡ | jD ]}| ||| ||¡ q]|  |¡ |  d| j|f ¡ d S |  d	| ¡ d S )
Nú<z %s="ú"ú>é   r   r$   z</%s>%sz/>%s)r&   ZtagNameZ_get_attributesÚlistÚkeysÚsortÚvalueZ
childNodesÚlenZnodeTypeZ	TEXT_NODEr0   )	r)   r*   r+   r,   r-   ÚattrsZa_namesÚa_nameÚnode©rH   rI   r.   r/   r0   V   s*   


ÿ
z/MathMLPrinterBase.apply_patch.<locals>.writexmlc                   s   ˆ |d|| j |f ƒ d S )Nz%s%s%s)r%   r(   )rI   r.   r/   r0   u   s   r1   )r<   rG   r#   rH   rI   r0   Ú_Element_writexml_oldÚ_Text_writexml_old)r)   rG   r#   r0   r.   rV   r/   Úapply_patchL   s   
zMathMLPrinterBase.apply_patchc                 C  s$   ddl m}m} | j|_| j|_d S )Nr   )rG   r#   )r<   rG   r#   rW   r0   rX   )r)   rG   r#   r.   r.   r/   Úrestore_patchz   s   zMathMLPrinterBase.restore_patchr6   )
r2   r3   r4   Ú__doc__r!   Ú__annotations__r;   rF   rY   rZ   r.   r.   r.   r/   r      s*   
 ò

.r   c                   @  s:  e Zd ZdZdZdd„ Zdd„ ZdHdd	„Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ ZeZeZd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Z d8d9„ Z!d:d;„ Z"d<d=„ Z#d>d?„ Z$d@dA„ Z%e"Z&e"Z'e"Z(dBdC„ Z)dDdE„ Z*dFdG„ Z+dS )IÚMathMLContentPrinterz}Prints an expression to the Content MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter4.html
    Z_mathml_contentc                 C  s€  i dd“dd“dd“dd“d	d“d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“i d d	“d!d"“d#d#“d$d$“d%d%“d&d&“d'd'“d(d(“d)d)“d*d*“d+d+“d,d,“d-d-“d.d.“d/d0“d1d2“d3d4“¥i d5d6“d7d8“d9d:“d;d8“d<d=“d>d?“d@dA“dBdC“dDdE“dFdG“dHdI“dJdK“dLdM“dNdO“dPdQ“dRdS“dTdU“¥dVdWdXœ¥}|j jD ]}|j}||v r·||   S q¨|j j}| ¡ S )Yú)Returns the MathML tag for an expression.ÚAddÚplusr   ÚtimesÚ
DerivativeÚdiffÚNumberÚcnÚintÚPowÚpowerZMaxÚmaxZMinÚminZAbsÚabsÚAndÚandÚOrÚorZXorÚxorÚNotÚnotZImpliesZimpliesÚSymbolÚciÚMatrixSymbolZRandomSymbolÚIntegralÚSumÚsumÚsinÚcosÚtanÚcotZcscÚsecÚsinhÚcoshÚtanhZcothZcschZsechÚasinÚarcsinÚasinhÚarcsinhÚacosÚarccosÚacoshÚarccoshÚatanÚarctanÚatanhÚarctanhÚatan2ÚacotÚarccotZacothZarccothZasecZarcsecZasechZarcsechZacscZarccscZacschZarccschÚlogÚlnÚEqualityÚeqÚ
UnequalityZneqÚGreaterThanZgeqÚLessThanZleqÚStrictGreaterThanÚgtÚStrictLessThanÚltÚunionZ	intersect)ÚUnionÚIntersection©Ú	__class__Ú__mro__r2   Úlower)r)   ÚeÚ	translateÚclsÚnr.   r.   r/   Ú
mathml_tag‡   sâ   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù(Ø)×*Ö+Õ,Ô-Ó.Ò/Ñ0Ð1Ï2Î3Í4Ë8ÿzMathMLContentPrinter.mathml_tagc           	      C  s<  |  ¡ r| j d¡}| | j d¡¡ | |  | ¡¡ |S ddlm} ||ƒ\}}|tjurP| j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tju rht|ƒdkrh|  	|d ¡S | jdkrtt |¡ ¡ }| j d¡}| | j d¡¡ |dkr| |  	|¡¡ |D ]
}| |  	|¡¡ q‘|S )	NÚapplyÚminusr   ©ÚfractionÚdividerM   Úoldra   )Úcould_extract_minus_signr7   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyrª   r   ÚOnerA   Úas_coeff_mulrR   r   r   Ú
_from_argsÚas_ordered_factors)	r)   rD   Úxrª   ÚnumerÚdenomÚcoeffÚtermsÚtermr.   r.   r/   r°   É   s2   

zMathMLContentPrinter._print_MulNc                 C  s
  | j ||d}|  |d ¡}g }|dd … D ]I}| ¡ rG| j d¡}| | j d¡¡ | |¡ | |  | ¡¡ |}||d krF| |¡ q| |¡ |  |¡}||d kr_| |  |¡¡ qt|ƒdkrh|S | j d¡}| | j d¡¡ |rƒ| | d¡¡ |sy|S )N©r   r   rM   r§   r¨   éÿÿÿÿr`   )	Ú_as_ordered_termsrA   r­   r7   r®   r¯   ÚappendrR   Úpop)r)   rD   r   ÚargsZlastProcessedZ	plusNodesÚargr¶   r.   r.   r/   Ú
_print_Addì   s4   

€

€ÿzMathMLContentPrinter._print_Addc                 C  s®   |j d jdkrtdƒ‚| j d¡}t|j ƒD ]=\}\}}|t|j ƒd kr9|dkr9| j d¡}| |  |¡¡ n| j d¡}| |  |¡¡ | |  |¡¡ | |¡ q|S )Nr½   Tz¼All Piecewise expressions must contain an (expr, True) statement to be used as a default condition. Without one, the generated expression may not evaluate to anything under some condition.Z	piecewiserM   Z	otherwiseÚpiece)	rÁ   ZcondÚ
ValueErrorr7   r®   Ú	enumeraterR   r¯   rA   )r)   rD   ÚrootÚir¢   ÚcrÄ   r.   r.   r/   Ú_print_Piecewise  s   z%MathMLContentPrinter._print_Piecewisec              	   C  s^   | j  d¡}t|jƒD ]!}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q| |¡ q|S )NÚmatrixZ	matrixrow)r7   r®   ÚrangeÚrowsÚcolsr¯   rA   )r)   Úmr¶   rÈ   Zx_rÚjr.   r.   r/   Ú_print_MatrixBase  s   z&MathMLContentPrinter._print_MatrixBasec                 C  s°   |j dkr| j d¡}| | j t|jƒ¡¡ |S | j d¡}| | j d¡¡ | j d¡}| | j t|jƒ¡¡ | j d¡}| | j t|j ƒ¡¡ | |¡ | |¡ |S )NrM   re   r§   r«   )Úqr7   r®   r¯   r=   ÚstrÚp)r)   r¢   r¶   ÚxnumZxdenomr.   r.   r/   Ú_print_Rational&  s   


z$MathMLContentPrinter._print_Rationalc                 C  s–   | j  d¡}| | j  |  |¡¡¡ | j  d¡}| j  d¡}| |  |jd ¡¡ | |  |jd ¡¡ | |¡ | |¡ | |  |jd ¡¡ |S )Nr§   ÚbvarÚlowlimitrM   é   r   )r7   r®   r¯   r¦   rA   rÁ   )r)   r¢   r¶   Úx_1Úx_2r.   r.   r/   Ú_print_Limit8  s   

z!MathMLContentPrinter._print_Limitc                 C  ó   | j  d¡S )NZ
imaginaryi©r7   r®   ©r)   r¢   r.   r.   r/   Ú_print_ImaginaryUnitF  ó   z)MathMLContentPrinter._print_ImaginaryUnitc                 C  rÝ   )NZ
eulergammarÞ   rß   r.   r.   r/   Ú_print_EulerGammaI  rá   z&MathMLContentPrinter._print_EulerGammac                 C  ó"   | j  d¡}| | j  d¡¡ |S )zwWe use unicode #x3c6 for Greek letter phi as defined here
        https://www.w3.org/2003/entities/2007doc/isogrk1.htmlre   u   Ï†©r7   r®   r¯   r=   ©r)   r¢   r¶   r.   r.   r/   Ú_print_GoldenRatioL  s   z'MathMLContentPrinter._print_GoldenRatioc                 C  rÝ   )NZexponentialerÞ   rß   r.   r.   r/   Ú_print_Exp1S  rá   z MathMLContentPrinter._print_Exp1c                 C  rÝ   )NÚpirÞ   rß   r.   r.   r/   Ú	_print_PiV  rá   zMathMLContentPrinter._print_Pic                 C  rÝ   )NÚinfinityrÞ   rß   r.   r.   r/   Ú_print_InfinityY  rá   z$MathMLContentPrinter._print_Infinityc                 C  rÝ   )NZ
notanumberrÞ   rß   r.   r.   r/   Ú
_print_NaN\  rá   zMathMLContentPrinter._print_NaNc                 C  rÝ   )NZemptysetrÞ   rß   r.   r.   r/   Ú_print_EmptySet_  rá   z$MathMLContentPrinter._print_EmptySetc                 C  rÝ   )NÚtruerÞ   rß   r.   r.   r/   Ú_print_BooleanTrueb  rá   z'MathMLContentPrinter._print_BooleanTruec                 C  rÝ   )NÚfalserÞ   rß   r.   r.   r/   Ú_print_BooleanFalsee  rá   z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr§   r¨   rê   )r7   r®   r¯   rå   r.   r.   r/   Ú_print_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¡¡ |S | ˆ| dd … ƒ¡ |S )	Nr§   r×   r   é   rØ   rM   ZuplimitrÙ   )r7   r®   r¯   r¦   rA   rR   Úfunction)Úlimitsr¶   Z	bvar_elemÚlow_elemÚup_elem©r¢   Ú
lime_recurr)   r.   r/   rù   o  s*   



ÿz8MathMLContentPrinter._print_Integral.<locals>.lime_recur)rN   rõ   Úreverse)r)   r¢   rõ   r.   rø   r/   Ú_print_Integraln  s   
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r6   )rû   rß   r.   r.   r/   Ú
_print_Sum‹  s   
zMathMLContentPrinter._print_Sumc                   sF  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰t|jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j  d¡}| ˆ j  |¡¡ |sh|sO| ˆ j  |¡¡ |S ˆ j  d	¡}| |¡ | ||ƒ¡ | |¡ |S |sƒˆ j  d
¡}	|	 |¡ |	 ||ƒ¡ | |	¡ |S ˆ j  d¡}
|
 |¡ |
 ||ƒ¡ |
 ||ƒ¡ | |
¡ |S )Nc                   ó¬   t | ƒdkrCˆ j d¡}t| ƒD ]0\}}|dkr,ˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q|S ˆ j d¡}| ˆ j | d ¡¡ |S )NrM   zmml:mrowr   zmml:moú úmml:mi©rR   r7   r®   rÆ   r¯   r=   ©ÚitemsÚmrowrÈ   ÚitemÚmoÚmi©r)   r.   r/   Újoin“  ó   
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  ó   | t v r	t  | ¡S | S r6   ©r   Úget©Úsr.   r.   r/   r£   ¥  ó   
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   ó   g | ]}ˆ |ƒ‘qS r.   r.   ©Ú.0Úsup©r£   r.   r/   Ú
<listcomp>­  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   r  r.   r.   ©r  Úsubr  r.   r/   r  ®  r  rÿ   zmml:msubzmml:msupzmml:msubsup)r7   r®   r¦   r   Únamer¯   r=   )r)   Úsymrt   r  r  ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr.   ©r)   r£   r/   Ú_print_Symbol  s<   ð

õ

û

z"MathMLContentPrinter._print_Symbolc                 C  sô   | j d rR|jjrR|jjdkrR| j d¡}| | j d¡¡ |jjdkrG| j d¡}| j d¡}| | j t	|jjƒ¡¡ | |¡ | |¡ | |  
|j¡¡ |S | j d¡}| j |  |¡¡}| |¡ | |  
|j¡¡ | |  
|j¡¡ |S )Nr   rM   r§   rÇ   rÙ   Údegreere   )Ú	_settingsÚexpÚis_RationalrÔ   r7   r®   r¯   rÒ   r=   rÓ   rA   Úbaser¦   )r)   r¢   r¶   ZxmldegZxmlcnrÚ   r.   r.   r/   Ú
_print_PowË  s$   


zMathMLContentPrinter._print_Powc                 C  ó,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r6   ©r7   r®   r¦   r¯   r=   rÓ   rå   r.   r.   r/   Ú_print_Numberâ  ó   z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r6   )	r7   r®   r¦   Úmlib_to_strÚ_mpf_r   Ú_precr¯   r=   )r)   r¢   r¶   Zrepr_er.   r.   r/   Ú_print_Floatç  s   z!MathMLContentPrinter._print_Floatc                 C  s¸   | j  d¡}|  |¡}t|jƒrd}| | j  |¡¡ | j  d¡}t|jƒD ]%\}}| |  |¡¡ |dkrK| j  d¡}| |  t	|ƒ¡¡ | |¡ q&| |¡ | |  |j¡¡ |S )Nr§   Zpartialdiffr×   rM   r#  )
r7   r®   r¦   r	   rD   r¯   ÚreversedÚvariable_countrA   r   )r)   r¢   r¶   Zdiff_symbolrÚ   r  ra   r#  r.   r.   r/   Ú_print_Derivativeí  s    


€
z&MathMLContentPrinter._print_Derivativec                 C  sD   | j  d¡}| | j  |  |¡¡¡ |jD ]
}| |  |¡¡ q|S ©Nr§   )r7   r®   r¯   r¦   rÁ   rA   ©r)   r¢   r¶   rÂ   r.   r.   r/   Ú_print_Function   s
   
z$MathMLContentPrinter._print_Functionc                 C  s2   | j  |  |¡¡}|jD ]
}| |  |¡¡ q|S r6   )r7   r®   r¦   rÁ   r¯   rA   r5  r.   r.   r/   Ú_print_Basic  s   
z!MathMLContentPrinter._print_Basicc                 C  sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]
}| |  |¡¡ q|S r4  )r7   r®   r¦   r¯   rÁ   rA   )r)   r¢   r¶   rÚ   rÂ   r.   r.   r/   Ú_print_AssocOp  s   

z#MathMLContentPrinter._print_AssocOpc                 C  sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S r4  )r7   r®   r¯   r¦   rA   ÚlhsÚrhsrå   r.   r.   r/   Ú_print_Relational  s
   z&MathMLContentPrinter._print_Relationalc                 C  ó*   | j  d¡}|D ]
}| |  |¡¡ q|S )zgMathML reference for the <list> element:
        https://www.w3.org/TR/MathML2/chapter4.html#contm.listrN   ©r7   r®   r¯   rA   )r)   ÚseqÚdom_elementr  r.   r.   r/   Ú_print_list  s   z MathMLContentPrinter._print_listc                 C  r)  r6   r*  ©r)   rÔ   r?  r.   r.   r/   Ú
_print_int$  r,  zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]
}| |  |¡¡ q	|S )NÚset©r7   r®   rÁ   r¯   rA   r5  r.   r.   r/   Ú_print_FiniteSet-  s   
z%MathMLContentPrinter._print_FiniteSetc                 C  ó>   | j  d¡}| | j  d¡¡ |jD ]
}| |  |¡¡ q|S )Nr§   Zsetdiff©r7   r®   r¯   rÁ   rA   r5  r.   r.   r/   Ú_print_Complement3  ó
   
z&MathMLContentPrinter._print_Complementc                 C  rF  )Nr§   ZcartesianproductrG  r5  r.   r.   r/   Ú_print_ProductSet:  rI  z&MathMLContentPrinter._print_ProductSetr6   ),r2   r3   r4   r[   Ú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+  r0  r3  r6  r7  r8  r;  r@  rB  Ú_print_ImpliesÚ
_print_NotÚ
_print_XorrE  rH  rJ  r.   r.   r.   r/   r]   €   sT    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                   sJ  i dd“dd“dd“dd“dd	“d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“i dd“d d“d!d"“d#d$“d%d&“d'd(“d)d*“d+d,“d-d.“d/d0“d1d2“d3d4“d5d6“d7d8“d9d8“d:d;“d<d=“¥d>d?d@dAdBdCdDdEdFd@dAdGdHdIœ¥}‡ fdJdK„}|j jD ]}|j}||v r“||   S q„|j jdLkr|ƒ S |j j}| ¡ S )Mr^   rd   ÚmnZLimitz&#x2192;rb   ú&dd;rf   rs   r  rv   z&int;rw   z&#x2211;ry   rz   r{   r|   r   r‚   rƒ   r„   r…   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   rŽ   r   r   r’   ú=r”   z&#x2260;r•   z&#x2265;r–   z&#x2264;r—   rL   r™   rJ   Zlerchphiú&#x3A6;Úzetaz&#x3B6;Zdirichlet_etaz&#x3B7;Z
elliptic_kz&#x39A;Z
lowergammaú&#x3B3;Z
uppergammaz&#x393;ÚgammaZtotientz&#x3D5;Zreduced_totientz&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;)ZprimenuZ
primeomegaZfresnelsZfresnelcZLambertWZ	HeavisideZBooleanTrueZBooleanFalseÚNoneTypeZmathieusZmathieucZmathieusprimeZmathieucprimec                     st   ˆ j d d u sˆ j d dkrdS ˆ j d dkrdS ˆ j d dkr"dS ˆ j d dkr+d	S tˆ j d tƒs5t‚ˆ j d S )
Nr   r]  ú&InvisibleTimes;ra   ú&#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£   rd  r¤   r¥   r.   r  r/   r¦   K  sº   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ñ2ÿz$MathMLPresentationPrinter.mathml_tagFc                 C  sF   t |ƒ}||k s|s||kr| j d¡}| |  |¡¡ |S |  |¡S ©NÚmfenced)r
   r7   r®   r¯   rA   )r)   r  ÚlevelÚstrictZprec_valÚbracr.   r.   r/   Úparenthesize—  s   
z&MathMLPresentationPrinter.parenthesizec                   sf   ‡ fdd„}ˆ j  d¡}| ¡ r,ˆ j  d¡}| ˆ j  d¡¡ | |¡ || |ƒ}|S |||ƒ}|S )Nc                   s„  ddl m} || ƒ\}}|tjurEˆ j d¡}ˆ jd r*tt| ƒƒdk r*| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tju rbt|	ƒdkrb| ˆ  
|	d ¡¡ |S ˆ jd	krnt |	¡ ¡ }	|dkr“ˆ  
|¡}
ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |
¡ | |¡ |	D ]*}| ˆ  |td ¡¡ ||	d ks¿ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |¡ q•|S )Nr   r©   Úmfracr   é   Úbevelledrî   rM   r¬   r  r   r½   )r±   rª   r   r²   r7   r®   r$  rR   rÓ   ÚsetAttributerA   r¯   r³   r   r   r´   rµ   r=   r¦   rj  r   )rD   r  rª   r·   r¸   ÚfracrÕ   Zxdenr¹   rº   r¶   Úyr»   r  r.   r/   Úmultiply¢  s@   










€z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyr  r  ú-)r7   r®   r­   r¯   r=   )r)   rD   rq  r  r¶   r.   r  r/   r°      s   "

þz$MathMLPresentationPrinter._print_MulNc                 C  s´   | j  d¡}| j||d}| |  |d ¡¡ |dd … D ]:}| ¡ r9| j  d¡}| | j  d¡¡ |  | ¡}n| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ q|S )Nr  r¼   r   rM   r  rr  ú+)r7   r®   r¾   r¯   rA   r­   r=   )r)   rD   r   r  rÁ   rÂ   r¶   rp  r.   r.   r/   rÃ   Ï  s   

z$MathMLPresentationPrinter._print_Addc              	   C  sÂ   | j  d¡}t|jƒD ],}| j  d¡}t|jƒD ]}| j  d¡}| |  |||f ¡¡ | |¡ q| |¡ q| jd dkrA|S | j  d¡}| jd dkrZ| dd	¡ | d
d¡ | |¡ |S )NZmtableZmtrZmtdr   r$   rf  r   Úcloseú]Úopen)	r7   r®   rÌ   rÍ   rÎ   r¯   rA   r$  rn  )r)   rÏ   ÚtablerÈ   r¶   rÐ   rp  ri  r.   r.   r/   rÑ   ã  s    
z+MathMLPresentationPrinter._print_MatrixBasec                 C  s²   |j dk r
|j  }n|j }| j d¡}|s| jd r | dd¡ | |  |¡¡ | |  |j¡¡ |j dk rW| j d¡}| j d¡}| | j d¡¡ | |¡ | |¡ |S |S )	Nr   rk  r   rm  rî   r  r  rr  )	rÔ   r7   r®   r$  rn  r¯   rA   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 )NrM   r   )rÒ   rA   rÔ   ry  r$  rß   r.   r.   r/   rÖ   	  s   
z)MathMLPresentationPrinter._print_Rationalc           	      C  sÜ   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | j  d¡}|  |jd ¡}| j  d¡}| | j  |  |¡¡¡ |  |jd ¡}| |¡ | |¡ | |¡ | |¡ | |¡ | |¡ | |  |jd ¡¡ |S )	Nr  Úmunderr  ÚlimrM   r  rÙ   r   )r7   r®   r¯   r=   rA   rÁ   r¦   )	r)   r¢   r  rz  r  r¶   rÚ   ÚarrowrÛ   r.   r.   r/   rÜ     s"   





z&MathMLPresentationPrinter._print_Limitc                 C  rã   )Nr  z&ImaginaryI;rä   rå   r.   r.   r/   rà   &  ó   z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  rã   )Nr  rU  rä   rå   r.   r.   r/   ræ   +  r}  z,MathMLPresentationPrinter._print_GoldenRatioc                 C  rã   )Nr  z&ExponentialE;rä   rå   r.   r.   r/   rç   0  r}  z%MathMLPresentationPrinter._print_Exp1c                 C  rã   )Nr  z&pi;rä   rå   r.   r.   r/   ré   5  r}  z#MathMLPresentationPrinter._print_Pic                 C  rã   )Nr  ú&#x221E;rä   rå   r.   r.   r/   rë   :  r}  z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nr  r  rr  )r7   r®   r¯   r=   rë   )r)   r¢   r  rp  r¶   r.   r.   r/   rò   ?  s   


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  rã   )Nr  z&#x210F;rä   rå   r.   r.   r/   Ú_print_HBarH  r}  z%MathMLPresentationPrinter._print_HBarc                 C  rã   )Nr  rW  rä   rå   r.   r.   r/   râ   M  r}  z+MathMLPresentationPrinter._print_EulerGammac                 C  rã   )Nr  ZTribonacciConstanträ   rå   r.   r.   r/   Ú_print_TribonacciConstantR  r}  z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr  r   ú&#x2020;©r7   r®   r¯   rA   rÁ   r=   ©r)   r¢   r  r.   r.   r/   Ú_print_DaggerW  s   z'MathMLPresentationPrinter._print_Daggerc                 C  sd   | j  d¡}| |  |jd ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ |S )Nr  r   r  z&#x2208;rM   r‚  )r)   r¢   r  r  r.   r.   r/   Ú_print_Contains]  s   
z)MathMLPresentationPrinter._print_Containsc                 C  rã   )Nr  z&#x210B;rä   rå   r.   r.   r/   Ú_print_HilbertSpacef  r}  z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr  z	&#x1D49E;r   ©r7   r®   r¯   r=   rA   rÁ   rƒ  r.   r.   r/   Ú_print_ComplexSpacek  s   z-MathMLPresentationPrinter._print_ComplexSpacec                 C  rã   )Nr  z&#x2131;rä   rå   r.   r.   r/   Ú_print_FockSpaceq  r}  z*MathMLPresentationPrinter._print_FockSpacec           	      C  s¶  ddddœ}| j  d¡}t|jƒdkr7tdd„ |jD ƒƒr7| j  d	¡}| | j  |t|jƒ ¡¡ | |¡ nnt|jƒD ]h}| j  d	¡}| | j  |d
 ¡¡ t|ƒd
krZ| |¡ t|ƒdkrz| j  d¡}| |¡ | |  |d
 ¡¡ | |¡ t|ƒdkr¤| j  d¡}| |¡ | |  |d
 ¡¡ | |  |d ¡¡ | |¡ q<| | j	|j
td dd¡ t|jƒD ] }| j  d	¡}| | j  d¡¡ | |¡ | |  |d ¡¡ q¸|S )Nz&#x222B;z&#x222C;z&#x222D;)rM   rÙ   ró   r  ró   c                 s  s    | ]	}t |ƒd kV  qdS )rM   N)rR   )r  r{  r.   r.   r/   Ú	<genexpr>{  s   € z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r  rM   rÙ   r  r   r   T©rh  rS  r   )r7   r®   rR   rõ   Úallr¯   r=   r1  rA   rj  rô   r   )	r)   rD   Z
intsymbolsr  r  r{  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
¡¡ |
S | j d¡}| |  |j
¡¡ |
 |¡ |
S )	NZ
munderoverr   rM   rÙ   r  r  rT  rf  )rN   rõ   r7   r®   rA   r¯   r=   r¦   rR   rÓ   rô   )r)   r¢   rõ   Zsubsuprö   r÷   ZsummandÚlowÚvarÚequalr  Zfencer.   r.   r/   rü     s2   







ü
z$MathMLPresentationPrinter._print_Sumr   c           	        s.  ‡ fdd„}dd„ ‰t |jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j d¡}| ˆ j |¡¡ t|ƒd	krYt|ƒd	krF|}nEˆ j d
¡}| |¡ | ||ƒ¡ n2t|ƒd	krrˆ j d¡}| |¡ | ||ƒ¡ nˆ j d¡}| |¡ | ||ƒ¡ | ||ƒ¡ |dkr•| dd¡ |S )Nc                   rý   )NrM   r  r   r  rþ   r  r   r  r  r.   r/   r  ½  r	  z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  r
  r6   r  r  r.   r.   r/   r£   Ï  r  z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   r  r.   r.   r  r  r.   r/   r  ×  r  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   r  r.   r.   r  r  r.   r/   r  Ø  r  r  r   r  r  r   ÚboldÚmathvariant)r   r  r7   r®   r¯   r=   rR   rn  )	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/   rL  ò  s   ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   ©r7   r®   rn  r¯   rA   rÁ   )r)   rD   Úencr.   r.   r/   Ú_print_conjugateø  s   z*MathMLPresentationPrinter._print_conjugatec                 C  sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nr  ZFuncr  )r7   r®   r¯   rj  r   r=   )r)   ÚoprD   Úrowr  r.   r.   r/   Ú_print_operator_afterþ  s   
z/MathMLPresentationPrinter._print_operator_afterc                 C  ó   |   d|jd ¡S )Nú!r   ©r›  rÁ   ©r)   rD   r.   r.   r/   Ú_print_factorial  ó   z*MathMLPresentationPrinter._print_factorialc                 C  rœ  )Nz!!r   rž  rŸ  r.   r.   r/   Ú_print_factorial2	  r¡  z+MathMLPresentationPrinter._print_factorial2c                 C  s^   | j  d¡}| j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | |¡ |S )Nrf  rk  ZlinethicknessÚ0r   rM   r–  )r)   rD   ri  ro  r.   r.   r/   Ú_print_binomial  s   
z)MathMLPresentationPrinter._print_binomialc                 C  s^  |j jrht|j jƒdkrh|j jdkrh| jd rh|j jdkr,| j d¡}| |  	|j
¡¡ |j jdkrK| j d¡}| |  	|j
¡¡ | |  	|j j¡¡ |j jdkrf| j d¡}| |  	d¡¡ | |¡ |S |S |j jrÌ|j jdkrÌ|j jr«| j d¡}| |  	d¡¡ | j d¡}| |  |j
td	 ¡¡ | |  |j  | jd
 ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  |j | jd
 ¡¡ |S |j jr| j d¡}| |  	d¡¡ |j dkrï| |  	|j
¡¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j  ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j ¡¡ |S )NrM   r   rÙ   ZmsqrtZmrootr½   rk  r  rg   r   )r%  r&  rk   rÔ   rÒ   r$  r7   r®   r¯   rA   r'  Zis_negativerj  r   ry  )r)   r¢   r¶   ro  r•  r.   r.   r/   r(    s`   $ÿ
ÿ
ÿ

ü
z$MathMLPresentationPrinter._print_Powc                 C  r)  r6   r*  rå   r.   r.   r/   r+  K  r,  z'MathMLPresentationPrinter._print_Numberc                 C  sL   | j  d¡}| dd¡ | dd¡ | |  |j¡¡ | |  |j¡¡ |S )Nrf  rt  õ   âŸ©rv  õ   âŸ¨)r7   r®   rn  r¯   rA   rj   ri   )r)   rÈ   ri  r.   r.   r/   Ú_print_AccumulationBoundsP  s   z3MathMLPresentationPrinter._print_AccumulationBoundsc                 C  sž  t |jƒrd}n|  |¡}| j d¡}d}t|jƒD ]M\}}||7 }|dkrI| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ | |¡ |  	|¡}	| |	¡ q| j d¡}
|dkr•| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ |
 |¡ | j d¡}| j d¡}| |
¡ | |¡ | |¡ | |  	|j¡¡ |S )Nz&#x2202;r  r   rÙ   r  r  rk  )
r	   rD   r¦   r7   r®   r1  r2  r¯   r=   rA   )r)   r¢   r  rÏ   Údimr  Únumr¶   Úxxrp  Zmnumr  ro  r.   r.   r/   r3  X  sF   









z+MathMLPresentationPrinter._print_Derivativec                 C  sœ   | j  d¡}| j  d¡}|  |¡dkr"| jd r"| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}|jD ]
}| |  |¡¡ q7| |¡ | |¡ |S )Nr  r  r   r   r‘   rf  )r7   r®   r¦   r$  r¯   r=   rÁ   rA   )r)   r¢   r  r¶   rp  rÂ   r.   r.   r/   r6  ˆ  s   


z)MathMLPresentationPrinter._print_Functionc                 C  s^  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rž|  d ¡S | j d	¡}| | j 	|¡¡ |S )NT)Zstrip_zerosr    r  r¢   r   rs  rM   rR  r  r  Ú10z+infz-inf)r   r/  r-  r.  r$  r7   r®   Úsplitr¯   r=   rë   rò   )r)   rD   ZdpsZstr_realÚ	separatorr  Zmantr%  rR  r  r  r.   r.   r/   r0  –  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   rf  rM   r‡  )r)   rD   r  rÏ   r  ri  r.   r.   r/   Ú_print_polylog½  s   


z(MathMLPresentationPrinter._print_polylogc                 C  sp   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | j  d¡}|jD ]
}| |  |¡¡ q&| |¡ |S )Nr  r  rf  ©r7   r®   r¯   r=   r¦   rÁ   rA   )r)   r¢   r  r  ri  rÂ   r.   r.   r/   r7  Ë  s   


z&MathMLPresentationPrinter._print_Basicc                 C  sB   | j  d¡}| j  d¡}|jD ]
}| |  |¡¡ q| |¡ |S )Nr  rf  rD  )r)   r¢   r  r¶   rÂ   r.   r.   r/   Ú_print_TupleÖ  s   

z&MathMLPresentationPrinter._print_Tuplec                 C  sÂ   | j  d¡}| j  d¡}|j|jkr(| dd¡ | dd¡ | |  |j¡¡ n2|jr2| dd¡ n| dd¡ |jrB| dd	¡ n| dd
¡ | |  |j¡¡ | |  |j¡¡ | |¡ |S )Nr  rf  rt  Ú}rv  Ú{ú)ru  ú(r   )	r7   r®   ÚstartÚendrn  r¯   rA   Z
right_openZ	left_open)r)   rÈ   r  ri  r.   r.   r/   Ú_print_IntervalÞ  s    
z)MathMLPresentationPrinter._print_Intervalc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nr  rf  rt  ú|rv  r   r–  )r)   rD   r%  r  r¶   r.   r.   r/   Ú
_print_Absö  ó   
z$MathMLPresentationPrinter._print_Absc                 C  sj   | j  d¡}| j  d¡}| dd¡ | | j  |¡¡ | |¡ | j  d¡}| |  |¡¡ | |¡ |S )Nr  r  r’  Zfrakturrf  )r7   r®   rn  r¯   r=   rA   )r)   rÉ   rD   r  r  ri  r.   r.   r/   Ú_print_re_im  s   

z&MathMLPresentationPrinter._print_re_imc                 C  rœ  )NÚRr   ©r»  rÁ   ©r)   rD   r%  r.   r.   r/   Ú	_print_re  r¡  z#MathMLPresentationPrinter._print_rec                 C  rœ  )NÚIr   r½  r¾  r.   r.   r/   Ú	_print_im  r¡  z#MathMLPresentationPrinter._print_imc                 C  sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]
}| |  |¡¡ q |S )Nr  r  r¯  )r)   r¢   r  r  rÂ   r.   r.   r/   r8    s   

z(MathMLPresentationPrinter._print_AssocOpc                 C  sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]!}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q|S )Nr  r   rM   r  )r7   r®   r¯   rj  rÁ   r=   )r)   rD   ÚsymbolÚprecr  rÂ   r¶   rp  r.   r.   r/   Ú_print_SetOp  s   
z&MathMLPresentationPrinter._print_SetOpc                 C  ó   t d }|  |d|¡S )Nrœ   z&#x222A;©r   rÄ  ©r)   rD   rÃ  r.   r.   r/   Ú_print_Union&  ó   z&MathMLPresentationPrinter._print_Unionc                 C  rÅ  )Nr   z&#x2229;rÆ  rÇ  r.   r.   r/   Ú_print_Intersection*  rÉ  z-MathMLPresentationPrinter._print_Intersectionc                 C  rÅ  )NZ
Complementz&#x2216;rÆ  rÇ  r.   r.   r/   rH  .  rÉ  z+MathMLPresentationPrinter._print_Complementc                 C  rÅ  )NZSymmetricDifferenceú&#x2206;rÆ  rÇ  r.   r.   r/   Ú_print_SymmetricDifference2  rÉ  z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  rÅ  )NZ
ProductSetz&#x00d7;rÆ  rÇ  r.   r.   r/   rJ  6  rÉ  z+MathMLPresentationPrinter._print_ProductSetc                 C  ó   |   |j¡S r6   )Ú
_print_setrÁ   )r)   r  r.   r.   r/   rE  :  rá   z*MathMLPresentationPrinter._print_FiniteSetc                 C  sN   t |td}| j d¡}| dd¡ | dd¡ |D ]
}| |  |¡¡ q|S )N©Úkeyrf  rt  r±  rv  r²  )Úsortedr   r7   r®   rn  r¯   rA   )r)   r  r  ri  r  r.   r.   r/   rÎ  =  s   z$MathMLPresentationPrinter._print_setc                 C  sÜ   | j  d¡}|d jr&|d js&| j  d¡}| |  |d ¡¡ | |¡ n
| |  |d ¡¡ |dd … D ]5}| j  d¡}| | j  |¡¡ |jr\|js\| j  d¡}| |  |¡¡ n|  |¡}| |¡ | |¡ q6|S )Nr  r   rf  rM   r  )r7   r®   Ú
is_BooleanZis_Notr¯   rA   r=   )r)   rÁ   rÂ  r  ri  rÂ   r¶   rp  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	|j
 ¡ ƒ}|jdd„ d t|ƒD ]\}\}	}
|
dkrj|ra| j d¡}| | j d	¡¡ | |¡ | |  |	¡¡ qA|
d
kr‹| j d¡}| | j d¡¡ | |¡ | |  |	¡¡ qA|r¡| j d¡}| | j d	¡¡ | |¡ | j d¡}| |  |
¡¡ | |¡ | j d¡}| | j d¡¡ | |¡ | |  |	¡¡ qAq*|S )Nr   )ÚVectorr  c                 S  s   | d   ¡ S )Nr   )Ú__str__)r¶   r.   r.   r/   Ú<lambda>j  s    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>rÏ  rM   r  rs  r½   rr  rf  r_  )Zsympy.vectorrÔ  ÚzerorA   rb  Zseparater  r7   r®   rN   Ú
componentsrP   rÆ   r¯   r=   )r)   rD   rÔ  r  r  ÚsystemZvectZ
inneritemsrÈ   ÚkÚvr  Zmbracr.   r.   r/   Ú_print_BasisDependent\  sF   







éz/MathMLPresentationPrinter._print_BasisDependentc                 C  ó   t |jtd}|  |d¡S )NrÏ  z&#x2227;©rÑ  rÁ   r   rÓ  ©r)   rD   rÁ   r.   r.   r/   Ú
_print_And†  ó   z$MathMLPresentationPrinter._print_Andc                 C  rÝ  )NrÏ  z&#x2228;rÞ  rß  r.   r.   r/   Ú	_print_OrŠ  rá  z#MathMLPresentationPrinter._print_Orc                 C  rÝ  )NrÏ  z&#x22BB;rÞ  rß  r.   r.   r/   rP  Ž  rá  z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)rÓ  rÁ   rŸ  r.   r.   r/   rN  ’  s   z(MathMLPresentationPrinter._print_Impliesc                 C  rÝ  )NrÏ  z&#x21D4;rÞ  rß  r.   r.   r/   Ú_print_Equivalent•  rá  z+MathMLPresentationPrinter._print_Equivalentc                 C  s‚   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ |jd jr2| j  d¡}| |  |jd ¡¡ n|  |jd ¡}| |¡ |S )Nr  r  z&#xAC;r   rf  )r7   r®   r¯   r=   rÁ   rÒ  rA   )r)   r¢   r  r  r¶   r.   r.   r/   rO  ™  s   

z$MathMLPresentationPrinter._print_Notc                 C  ó(   | j  d¡}| | j  |  |¡¡¡ |S ©Nr  ©r7   r®   r¯   r=   r¦   ©r)   r¢   r  r.   r.   r/   Ú_print_bool¦  ó   z%MathMLPresentationPrinter._print_boolc                 C  rä  rå  ræ  rç  r.   r.   r/   Ú_print_NoneType®  ré  z)MathMLPresentationPrinter._print_NoneTypec                 C  s,  d}| j  d¡}| dd¡ | dd¡ |jjr0|jjr0|jjr(|ddd	|f}nF|d	dd|f}n>|jjrA||d |j |d f}n-|jjrSt|ƒ}t	|ƒt	|ƒ|f}nt
|ƒd
krjt|ƒ}t	|ƒt	|ƒ||d f}nt|ƒ}|D ]#}||kr‹| j  d¡}| | j  |¡¡ | |¡ qp| |  |¡¡ qp|S )Nu   â€¦rf  rt  r±  rv  r²  r½   r   rM   é   r  )r7   r®   rn  rµ  Úis_infiniteÚstopÚstepZis_positiveÚiterÚnextrR   Útupler¯   r=   rA   )r)   r  Údotsri  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  rf  )rÑ  rÁ   r   r7   r®   r¯   r=   rÓ   Úfuncr¡   rA   )r)   rD   rÁ   r  r  ri  rÂ  r.   r.   r/   Ú_hprint_variadic_functionÓ  s   

z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr  r   )r7   r®   r¯   rç   rA   rÁ   )r)   rD   r  r.   r.   r/   Ú
_print_expá  s   z$MathMLPresentationPrinter._print_expc                 C  sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nr  r  )r7   r®   r¯   rA   r9  r=   r¦   r:  ©r)   r¢   r  r¶   r.   r.   r/   r;  ç  s   
z+MathMLPresentationPrinter._print_Relationalc                 C  r)  r6   r*  rA  r.   r.   r/   rB  ð  r,  z$MathMLPresentationPrinter._print_intc                 C  sŠ   | j  d¡}|j\}}| j  d¡}| dd¡ | | j  |j| ¡¡ | |¡ | j  d¡}| dd¡ | | j  |j¡¡ | |¡ |S )Nr  r  r’  r‘  )r7   r®   Ú_idrn  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  ú^)r7   r®   rú  rn  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ÿ  ©r7   r®   rn  r¯   r=   )r)   r¢   rþ  r  r  r.   r.   r/   Ú_print_VectorZero  s   

z+MathMLPresentationPrinter._print_VectorZeroc                 C  óp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nr  r   r  r`  ©r7   r®   Z_expr1Z_expr2r¯   rj  r   r=   ©r)   rD   r  Zvec1Zvec2r  r.   r.   r/   Ú_print_Cross  ó   
z&MathMLPresentationPrinter._print_Crossc                 C  óx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  ú&#x2207;r`  r   ©r7   r®   r¯   r=   rj  Z_exprr   ©r)   rD   r  r  r.   r.   r/   Ú_print_Curl*  ó   

z%MathMLPresentationPrinter._print_Curlc                 C  r  )Nr  r  r	  r   r   r
  r  r.   r.   r/   Ú_print_Divergence5  r  z+MathMLPresentationPrinter._print_Divergencec                 C  r  )Nr  r   r  r   r  r  r.   r.   r/   Ú
_print_Dot@  r  z$MathMLPresentationPrinter._print_Dotc                 C  óP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  r	  r   r
  r  r.   r.   r/   Ú_print_GradientK  ó   
z)MathMLPresentationPrinter._print_Gradientc                 C  r  )Nr  r  rË  r   r
  r  r.   r.   r/   Ú_print_LaplacianS  r  z*MathMLPresentationPrinter._print_Laplacianc                 C  ó.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  r’  Únormalz&#x2124;r  rå   r.   r.   r/   Ú_print_Integers[  ó   z)MathMLPresentationPrinter._print_Integersc                 C  r  )Nr  r’  r  z&#x2102;r  rå   r.   r.   r/   Ú_print_Complexesa  r  z*MathMLPresentationPrinter._print_Complexesc                 C  r  )Nr  r’  r  z&#x211D;r  rå   r.   r.   r/   Ú_print_Realsg  r  z&MathMLPresentationPrinter._print_Realsc                 C  r  )Nr  r’  r  ú&#x2115;r  rå   r.   r.   r/   Ú_print_Naturalsm  r  z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr  r  r’  r  r  )r7   r®   rn  r¯   r=   rA   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   rM   rÙ   r  rf  rt  r¥  rv  r¦  )rÁ   r7   r®   rn  r¯   rA   )r)   rD   Úshiftrh   r  ri  r.   r.   r/   Ú_print_SingularityFunction|  s   

z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  rã   )Nr  ÚNaNrä   rå   r.   r.   r/   rì   ˆ  r}  z$MathMLPresentationPrinter._print_NaNc                 C  s°   | j  d¡}| j  d¡}| | j  |¡¡ | |¡ | |  |jd ¡¡ t|jƒdkr.|S | j  d¡}| j  d¡}|jdd … D ]
}| |  |¡¡ qA| |¡ | |¡ |S )Nr  r  r   rM   r  rf  )r7   r®   r¯   r=   rA   rÁ   rR   )r)   r¢   r  r  r  r  rp  rÂ   r.   r.   r/   Ú_print_number_function  s   


z0MathMLPresentationPrinter._print_number_functionc                 C  ó   |   |d¡S )NÚB©r   rß   r.   r.   r/   Ú_print_bernoulli   rá   z*MathMLPresentationPrinter._print_bernoullic                 C  r!  )NrY  r#  rß   r.   r.   r/   Ú_print_catalan¥  rá   z(MathMLPresentationPrinter._print_catalanc                 C  r!  )NÚEr#  rß   r.   r.   r/   Ú_print_euler¨  rá   z&MathMLPresentationPrinter._print_eulerc                 C  r!  )NÚFr#  rß   r.   r.   r/   Ú_print_fibonacci«  rá   z*MathMLPresentationPrinter._print_fibonaccic                 C  r!  )NÚLr#  rß   r.   r.   r/   Ú_print_lucas®  rá   z&MathMLPresentationPrinter._print_lucasc                 C  r!  )Nz&#x03B3;r#  rß   r.   r.   r/   Ú_print_stieltjes±  rá   z*MathMLPresentationPrinter._print_stieltjesc                 C  r!  )NÚTr#  rß   r.   r.   r/   Ú_print_tribonacci´  rá   z+MathMLPresentationPrinter._print_tribonaccic                 C  s`   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )Nrþ  r  r~  ú~rä   )r)   r¢   r¶   r  r.   r.   r/   Ú_print_ComplexInfinity·  s   

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  rã   )Nr  z&#x2205;rä   rå   r.   r.   r/   rí   Á  r}  z)MathMLPresentationPrinter._print_EmptySetc                 C  rã   )Nr  z	&#x1D54C;rä   rå   r.   r.   r/   Ú_print_UniversalSetÆ  r}  z-MathMLPresentationPrinter._print_UniversalSetc                 C  óŒ   ddl m} |j}| j d¡}t||ƒs(| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | j d¡}| | j d¡¡ | |¡ |S )Nr   ©ru   r  rf  r  r  ©	Úsympy.matricesru   rÂ   r7   r®   rb  r¯   rA   r=   ©r)   rD   ru   Úmatr  ri  r  r.   r.   r/   Ú_print_AdjointË  ó   

z(MathMLPresentationPrinter._print_Adjointc                 C  r2  )Nr   r3  r  rf  r  r-  r4  r6  r.   r.   r/   Ú_print_TransposeÚ  r9  z*MathMLPresentationPrinter._print_Transposec                 C  st   ddl m} |j}| j d¡}t||ƒs(| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   r3  r  rf  r½   )r5  ru   rÂ   r7   r®   rb  r¯   rA   )r)   rD   ru   r7  r  ri  r.   r.   r/   Ú_print_Inverseé  s   
z(MathMLPresentationPrinter._print_Inversec                 C  s&  ddl m} | j d¡}|j}t|d tƒr%|d  ¡ t|dd … ƒ }nt|ƒ}t||ƒrZ| 	¡ rZ|d dkr?|dd … }n|d  |d< | j d¡}| 
| j d¡¡ | 
|¡ |d d… D ]"}| 
|  |t|ƒd¡¡ | j d¡}| 
| j d	¡¡ | 
|¡ q`| 
|  |d t|ƒd¡¡ |S )
Nr   )ÚMatMulr  rM   r½   r  rr  Fr_  )Z!sympy.matrices.expressions.matmulr<  r7   r®   rÁ   rb  r   rµ   rN   r­   r¯   r=   rj  r
   )r)   rD   r<  r¶   rÁ   r  rÂ   r.   r.   r/   Ú_print_MatMulö  s0   
ÿÿz'MathMLPresentationPrinter._print_MatMulc                 C  s|   ddl m} |j|j}}| j d¡}t||ƒs,| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  |¡¡ |S )Nr   r3  r  rf  )	r5  ru   r'  r%  r7   r®   rb  r¯   rA   )r)   rD   ru   r'  r%  r  ri  r.   r.   r/   Ú_print_MatPow  s   
z'MathMLPresentationPrinter._print_MatPowc                 C  s„   | j  d¡}|j}|d d… D ]"}| |  |t|ƒd¡¡ | j  d¡}| | j  d¡¡ | |¡ q| |  |d t|ƒd¡¡ |S )Nr  r½   Fr  z&#x2218;)r7   r®   rÁ   r¯   rj  r
   r=   )r)   rD   r¶   rÁ   rÂ   r  r.   r.   r/   Ú_print_HadamardProduct   s   ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  rã   )NrR  z&#x1D7D8rä   ©r)   ÚZr¶   r.   r.   r/   Ú_print_ZeroMatrix-  r}  z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  rã   )NrR  z&#x1D7D9rä   r@  r.   r.   r/   Ú_print_OneMatrix2  r}  z*MathMLPresentationPrinter._print_OneMatrixc                 C  rã   )Nr  z	&#x1D540;rä   )r)   rÀ  r¶   r.   r.   r/   Ú_print_Identity7  r}  z)MathMLPresentationPrinter._print_Identityc                 C  óT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nr  rf  rt  u   âŒ‹rv  u   âŒŠr   r–  rù  r.   r.   r/   Ú_print_floor<  rº  z&MathMLPresentationPrinter._print_floorc                 C  rE  )Nr  rf  rt  u   âŒ‰rv  u   âŒˆr   r–  rù  r.   r.   r/   Ú_print_ceilingE  rº  z(MathMLPresentationPrinter._print_ceilingc                 C  sž   | j  d¡}| j  d¡}|jd }t|ƒdkr|  |d ¡}n|  |¡}| |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ |S )Nrf  r  r   rM   r  z&#x21A6;)r7   r®   rÁ   rR   rA   r¯   r=   )r)   r¢   r¶   r  Úsymbolsr  r.   r.   r/   Ú_print_LambdaN  s   




z'MathMLPresentationPrinter._print_Lambdac                 C  r<  re  r=  )r)   r¢   r¶   rÈ   r.   r.   r/   Ú_print_tuple^  s   z&MathMLPresentationPrinter._print_tuplec                 C  rÍ  r6   )rA   Úlabelrß   r.   r.   r/   Ú_print_IndexedBased  rá   z,MathMLPresentationPrinter._print_IndexedBasec                 C  s\   | j  d¡}| |  |j¡¡ t|jƒdkr#| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr  rM   r   )r7   r®   r¯   rA   r'  rR   Úindicesrå   r.   r.   r/   Ú_print_Indexedg  s   z(MathMLPresentationPrinter._print_Indexedc                 C  sv   | j  d¡}| | j|jtd dd¡ | j  d¡}| dd¡ | dd¡ |jD ]
}| |  |¡¡ q)| |¡ |S )	Nr  ZAtomTr‹  rf  rt  r$   rv  )	r7   r®   r¯   rj  Úparentr   rn  rM  rA   )r)   r¢   r¶   ri  rÈ   r.   r.   r/   Ú_print_MatrixElementp  s   

z.MathMLPresentationPrinter._print_MatrixElementc                 C  óv   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| dd¡ |jD ]
}| |  |¡¡ q)| |¡ |S )Nr  r  z	&#x1d5a5;rf  Ú
separatorsr¸  ©r7   r®   r¯   r=   rn  rÁ   rA   ©r)   r¢   r¶   r  rp  rÈ   r.   r.   r/   Ú_print_elliptic_f{  ó   


z+MathMLPresentationPrinter._print_elliptic_fc                 C  rQ  )Nr  r  z	&#x1d5a4;rf  rR  r¸  rS  rT  r.   r.   r/   Ú_print_elliptic_e‡  rV  z+MathMLPresentationPrinter._print_elliptic_ec                 C  s’   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}t|jƒdkr.| dd¡ n| dd¡ |jD ]
}| |  |¡¡ q7| |¡ |S )	Nr  r  z	&#x1d6f1;rf  rÙ   rR  r¸  z;|)r7   r®   r¯   r=   rR   rÁ   rn  rA   rT  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Eir‡  )r)   r¢   r¶   r  r.   r.   r/   Ú	_print_Ei¢  s   
z#MathMLPresentationPrinter._print_Eic                 C  ó~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r  r  r&  r   rM   r‡  ©r)   r¢   r¶   rp  r  r.   r.   r/   Ú_print_expintª  ó   

z'MathMLPresentationPrinter._print_expintc                 C  ó˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r   r  ÚPr   rM   ró   r‡  r[  r.   r.   r/   Ú_print_jacobiµ  ó   

z'MathMLPresentationPrinter._print_jacobic                 C  r^  )Nr  r   r  rY  r   rM   rÙ   r‡  r[  r.   r.   r/   Ú_print_gegenbauerÁ  ra  z+MathMLPresentationPrinter._print_gegenbauerc                 C  rZ  )Nr  r  r  r-  r   rM   r‡  r[  r.   r.   r/   Ú_print_chebyshevtÍ  r]  z+MathMLPresentationPrinter._print_chebyshevtc                 C  rZ  )Nr  r  r  ÚUr   rM   r‡  r[  r.   r.   r/   Ú_print_chebyshevuØ  r]  z+MathMLPresentationPrinter._print_chebyshevuc                 C  rZ  )Nr  r  r  r_  r   rM   r‡  r[  r.   r.   r/   Ú_print_legendreã  r]  z)MathMLPresentationPrinter._print_legendrec                 C  r^  )Nr  r   r  r_  r   rM   rÙ   r‡  r[  r.   r.   r/   Ú_print_assoc_legendreî  ra  z/MathMLPresentationPrinter._print_assoc_legendrec                 C  rZ  )Nr  r  r  r*  r   rM   r‡  r[  r.   r.   r/   Ú_print_laguerreú  r]  z)MathMLPresentationPrinter._print_laguerrec                 C  r^  )Nr  r   r  r*  r   rM   rÙ   r‡  r[  r.   r.   r/   Ú_print_assoc_laguerre  ra  z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  rZ  )Nr  r  r  ÚHr   rM   r‡  r[  r.   r.   r/   Ú_print_hermite  r]  z(MathMLPresentationPrinter._print_hermite)Fr6   )r   )‹r2   r3   r4   r[   rK  r¦   rj  r°   rÃ   rÑ   ry  rÖ   rÜ   rà   ræ   rç   ré   rë   rò   r  râ   r€  r„  r…  r†  rˆ  r‰  rû   rü   r"  rL  rM  r˜  r›  r   r¢  r¤  r(  r+  r§  r3  r6  r0  r®  r7  r°  r·  r¹  Z_print_Determinantr»  r¿  rÁ  r8  rÄ  rÈ  rÊ  rH  rÌ  rJ  rE  rÎ  Z_print_frozensetrÓ  rÜ  rà  râ  rP  rN  rã  rO  rè  rï   rñ   rê  rõ  r÷  Z
_print_MinZ
_print_Maxrø  r;  rB  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.  r0  rí   r1  r8  r:  r;  r=  r>  r?  rB  rC  rD  rF  rG  rI  rJ  rL  rN  rP  rU  rW  rX  rY  r\  r`  rb  rc  re  rf  rg  rh  ri  rk  r.   r.   r.   r/   rQ  D  s   L	/		&6	60'			* 		
			rQ  Úcontentc                 K  s$   |dkrt |ƒ | ¡S t|ƒ | ¡S )zŠReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    Úpresentation)rQ  rF   r]   )rD   Úprinterr>   r.   r.   r/   Úmathml  s   ro  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>

    rm  N)rQ  r]   rA   r   rY   ZtoprettyxmlrZ   Úprint)rD   rn  r>   r  ÚxmlZ
pretty_xmlr.   r.   r/   Úprint_mathml(  s   
rr  N)rl  )$r[   Ú
__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]   rQ  ro  rr  ZMathMLPrinterr.   r.   r.   r/   Ú<module>   sB    k   G           d

&