o
     ôjZ+ ã                   @  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                   @  sX   e Zd ZU dZddddddddddddi d	dd
œZded< ddd„Zdd„ Zdd„ ZdS )ÚMathMLPrinterBasez^Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    Nzutf-8FÚabbreviatedÚ[ÚplainTú&#xB7;)ÚorderÚencodingÚfold_frac_powersÚfold_func_bracketsÚfold_short_fracÚinv_trig_styleÚln_notationÚlong_frac_ratioÚ	mat_delimÚmat_symbol_styleÚ
mul_symbolÚroot_notationÚsymbol_namesÚmul_symbol_mathml_numbersÚdisable_split_super_subz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ÚindentZ	addindentZnewl© r1   úh/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/sympy/printing/mathml.pyÚwritexml7   s   ÿz4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r*   r*   r*   )Ú__name__Ú
__module__Ú__qualname__r3   r1   r1   r1   r2   ÚRawText6   s    r7   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r+   ÚdomZownerDocument)r+   Úr©r7   r.   r1   r2   ÚcreateRawTextNode;   s   z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Zxml.dom.minidomr(   r)   r9   ÚcreateTextNode)r.   Úsettingsr(   r)   r<   r1   r;   r2   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Úresr1   r1   r2   ÚdoprintC   s
   zMathMLPrinterBase.doprintc                 C  s   | j d r
|g g fS t|ƒS )Nr&   )Ú	_settingsr   )r.   Únamer1   r1   r2   Ú_split_super_subM   s   

z"MathMLPrinterBase._split_super_subr8   )	r4   r5   r6   Ú__doc__r'   Ú__annotations__r=   rG   rJ   r1   r1   r1   r2   r      s*   
 ñ

r   c                   @  sB  e Zd ZdZdZdd„ Zdd„ ZdJd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+dHdI„ Z,dS )KÚ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ÚpowerÚMaxÚmaxÚMinÚminÚAbsÚabsÚAndÚandÚOrÚorÚXorÚxorÚNotÚnotÚImpliesZimpliesÚSymbolÚciÚMatrixSymbolZRandomSymbolÚIntegralÚSumÚsumÚsinÚcosÚtanÚcotÚcscÚsecÚsinhÚcoshÚtanhÚcothÚcschÚsechÚasinÚarcsinÚasinhÚarcsinhÚacosÚarccosÚacoshÚarccoshÚatanÚarctanÚatanhÚarctanhÚatan2ÚacotÚarccotÚacothZarccothÚasecZarcsecÚasechZarcsechÚacscZarccscÚacschZarccschÚlogÚlnÚEqualityÚeqÚ
UnequalityZneqÚGreaterThanZgeqÚLessThanZleqÚStrictGreaterThanÚgtÚStrictLessThanÚltÚunionZ	intersect)ÚUnionÚIntersection©Ú	__class__Ú__mro__r4   Úlower)r.   ÚeÚ	translateÚclsÚnr1   r1   r2   Ú
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Údivideé   ÚoldrQ   )Úcould_extract_minus_signr9   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyr¨   r   ÚOnerB   Úas_coeff_mulÚlenr   r   Ú
_from_argsÚas_ordered_factors)	r.   rE   Úxr¨   ÚnumerÚdenomÚcoeffÚtermsÚtermr1   r1   r2   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   rª   r¥   r¦   éÿÿÿÿrP   )	Ú_as_ordered_termsrB   r¬   r9   r­   r®   Úappendr³   Úpop)r.   rE   r   ÚargsZlastProcessedZ	plusNodesÚargr¶   r1   r1   r2   Ú
_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.Ú	piecewiserª   Ú	otherwiseÚpiece)	rÁ   ÚcondÚ
ValueErrorr9   r­   Ú	enumerater³   r®   rB   )r.   rE   ÚrootÚir    ÚcrÆ   r1   r1   r2   Ú_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)r9   r­   ÚrangeÚrowsÚcolsr®   rB   )r.   Úmr¶   rË   Zx_rÚjr1   r1   r2   Ú_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 )Nrª   rU   r¥   r©   )Úqr9   r­   r®   r>   ÚstrÚp)r.   r    r¶   ÚxnumZxdenomr1   r1   r2   Ú_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Úlowlimitrª   é   r   )r9   r­   r®   r¤   rB   rÁ   )r.   r    r¶   Úx_1Úx_2r1   r1   r2   Ú_print_Limit  s   

z!MathMLContentPrinter._print_Limitc                 C  ó   | j  d¡S )NZ
imaginaryi©r9   r­   ©r.   r    r1   r1   r2   Ú_print_ImaginaryUnit  ó   z)MathMLContentPrinter._print_ImaginaryUnitc                 C  rà   )NZ
eulergammará   râ   r1   r1   r2   Ú_print_EulerGamma  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.htmlrU   u   Ï†©r9   r­   r®   r>   ©r.   r    r¶   r1   r1   r2   Ú_print_GoldenRatio   s   z'MathMLContentPrinter._print_GoldenRatioc                 C  rà   )NZexponentialerá   râ   r1   r1   r2   Ú_print_Exp1'  rä   z MathMLContentPrinter._print_Exp1c                 C  rà   )NÚpirá   râ   r1   r1   r2   Ú	_print_Pi*  rä   zMathMLContentPrinter._print_Pic                 C  rà   )NÚinfinityrá   râ   r1   r1   r2   Ú_print_Infinity-  rä   z$MathMLContentPrinter._print_Infinityc                 C  rà   )NZ
notanumberrá   râ   r1   r1   r2   Ú
_print_NaN0  rä   zMathMLContentPrinter._print_NaNc                 C  rà   )NZemptysetrá   râ   r1   r1   r2   Ú_print_EmptySet3  rä   z$MathMLContentPrinter._print_EmptySetc                 C  rà   )NÚtruerá   râ   r1   r1   r2   Ú_print_BooleanTrue6  rä   z'MathMLContentPrinter._print_BooleanTruec                 C  rà   )NÚfalserá   râ   r1   r1   r2   Ú_print_BooleanFalse9  rä   z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr¥   r¦   rí   )r9   r­   r®   rè   r1   r1   r2   Ú_print_NegativeInfinity<  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Û   rª   ZuplimitrÜ   )r9   r­   r®   r¤   rB   r³   Úfunction)Úlimitsr¶   Z	bvar_elemÚlow_elemÚup_elem©r    Ú
lime_recurr.   r1   r2   rü   C  s*   



ÿz8MathMLContentPrinter._print_Integral.<locals>.lime_recur)Úlistrø   Úreverse)r.   r    rø   r1   rû   r2   Ú_print_IntegralB  s   
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r8   )rÿ   râ   r1   r1   r2   Ú
_print_Sum_  s   
zMathMLContentPrinter._print_Sumc                   sH  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰ˆ  |j¡\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j  d¡}| ˆ j  |¡¡ |si|sP| ˆ 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 )Nrª   zmml:mrowr   zmml:moú úmml:mi©r³   r9   r­   rÉ   r®   r>   ©ÚitemsÚmrowrË   ÚitemÚmoÚmi©r.   r1   r2   Újoing  ó   
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  ó   | t v r	t  | ¡S | S r8   ©r   Úget©Úsr1   r1   r2   r¡   y  ó   
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   ó   g | ]}ˆ |ƒ‘qS r1   r1   ©Ú.0Úsup©r¡   r1   r2   Ú
<listcomp>�  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   r  r1   r1   ©r  Úsubr  r1   r2   r  ‚  r  r  zmml:msubzmml:msupzmml:msubsup)r9   r­   r¤   rJ   rI   r®   r>   )r.   Úsymri   r  rI   ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr1   ©r.   r¡   r2   Ú_print_Symbold  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#   rª   r¥   rÊ   rÜ   ÚdegreerU   )rH   ÚexpÚis_Rationalr×   r9   r­   r®   rÕ   r>   rÖ   rB   Úbaser¤   )r.   r    r¶   ZxmldegZxmlcnrÝ   r1   r1   r2   Ú
_print_PowŸ  s$   


zMathMLContentPrinter._print_Powc                 C  ó,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r8   ©r9   r­   r¤   r®   r>   rÖ   rè   r1   r1   r2   Ú_print_Number¶  ó   z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r8   )	r9   r­   r¤   Úmlib_to_strÚ_mpf_r   Ú_precr®   r>   )r.   r    r¶   Zrepr_er1   r1   r2   Ú_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Ú   rª   r&  )
r9   r­   r¤   r	   rE   r®   ÚreversedÚvariable_countrB   r   )r.   r    r¶   Údiff_symbolrÝ   r  rQ   r&  r1   r1   r2   Ú_print_DerivativeÁ  s    


€
z&MathMLContentPrinter._print_Derivativec                 C  sD   | j  d¡}| | j  |  |¡¡¡ |jD ]
}| |  |¡¡ q|S ©Nr¥   )r9   r­   r®   r¤   rÁ   rB   ©r.   r    r¶   rÂ   r1   r1   r2   Ú_print_FunctionÔ  s
   
z$MathMLContentPrinter._print_Functionc                 C  s2   | j  |  |¡¡}|jD ]
}| |  |¡¡ q|S r8   )r9   r­   r¤   rÁ   r®   rB   r8  r1   r1   r2   Ú_print_BasicÛ  s   
z!MathMLContentPrinter._print_Basicc                 C  sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]
}| |  |¡¡ q|S r7  )r9   r­   r¤   r®   rÁ   rB   )r.   r    r¶   rÝ   rÂ   r1   r1   r2   Ú_print_AssocOpá  s   

z#MathMLContentPrinter._print_AssocOpc                 C  sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S r7  )r9   r­   r®   r¤   rB   ÚlhsÚrhsrè   r1   r1   r2   Ú_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.listrý   )r9   r­   r®   rB   )r.   ÚseqÚdom_elementr  r1   r1   r2   Ú_print_listð  s   z MathMLContentPrinter._print_listc                 C  r+  r8   r,  ©r.   r×   r@  r1   r1   r2   Ú
_print_intø  r.  zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]
}| |  |¡¡ q	|S )NÚset)r9   r­   rÁ   r®   rB   r8  r1   r1   r2   Ú_print_FiniteSet  s   
z%MathMLContentPrinter._print_FiniteSetc                 C  ó>   | j  d¡}| | j  d¡¡ |jD ]
}| |  |¡¡ q|S )Nr¥   Zsetdiff©r9   r­   r®   rÁ   rB   r8  r1   r1   r2   Ú_print_Complement  ó
   
z&MathMLContentPrinter._print_Complementc                 C  rF  )Nr¥   ZcartesianproductrG  r8  r1   r1   r2   Ú_print_ProductSet  rI  z&MathMLContentPrinter._print_ProductSetc                 C  sZ   | j  |  |¡¡}|jD ]}| j  d¡}| |  |¡¡ | |¡ q| |  |j¡¡ |S )NrÚ   )r9   r­   r¤   Ú	signaturer®   rB   rE   )r.   r    r¶   rÂ   rÝ   r1   r1   r2   Ú_print_Lambda  s   
z"MathMLContentPrinter._print_Lambdar8   )-r4   r5   r6   rK   Ú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-  r2  r6  r9  r:  r;  r>  rA  rC  Ú_print_ImpliesÚ
_print_NotÚ
_print_XorrE  rH  rJ  rL  r1   r1   r1   r2   rM   T   sV    B
#	8rM   c                   @  s°  e Zd ZdZ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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/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%�ddHdI„Z&dJdK„ Z'e&Z(dLdM„ Z)dNdO„ Z*dPdQ„ Z+dRdS„ Z,dTdU„ Z-dVdW„ Z.dXdY„ Z/dZd[„ Z0d\d]„ Z1d^d_„ Z2d`da„ Z3dbdc„ Z4ddde„ Z5dfdg„ Z6dhdi„ Z7�ddjdk„Z8e8Z9dldm„ Z:�ddndo„Z;�ddpdq„Z<drds„ Z=dtdu„ Z>dvdw„ Z?dxdy„ Z@dzd{„ ZAd|d}„ ZBd~d„ ZCd€d�„ ZDd‚dƒ„ ZEeEZFd„d…„ ZGd†d‡„ ZHdˆd‰„ ZIdŠd‹„ ZJdŒd�„ ZKdŽd�„ ZLd�d‘„ ZMd’d“„ ZNd”d•„ ZOeOZPeOZQd–d—„ ZRd˜d™„ ZSdšd›„ ZTeT ZUZVdœ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³„ Zbd´dµ„ Zcd¶d·„ Zdd¸d¹„ Zedºd»„ Zfd¼d½„ Zgd¾d¿„ ZhdÀdÁ„ ZidÂdÃ„ ZjdÄdÅ„ ZkekZldÆ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ï„ 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“dS (  ÚMathMLPresentationPrinterz‚Prints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    Z_mathml_presentationc                   sL  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@dAdGdHdIdJœ¥}‡ fdKdL„}|j jD ]}|j}||v r”||   S q…|j jdMkrž|ƒ S |j j}| ¡ S )NrN   rT   ÚmnÚLimitz&#x2192;rR   ú&dd;rV   rh   r
  rk   z&int;rl   z&#x2211;rn   ro   rp   rq   rz   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•   ú>r—   ú<Úlerchphiú&#x3A6;Úzetaz&#x3B6;Údirichlet_etaz&#x3B7;Ú
elliptic_kz&#x39A;Ú
lowergammaú&#x3B3;Ú
uppergammaz&#x393;ÚgammaÚtotientz&#x3D5;Úreduced_totientz&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;Úlambda)ÚprimenuÚ
primeomegaÚfresnelsÚfresnelcÚLambertWÚ	HeavisideÚBooleanTrueÚBooleanFalseÚNoneTypeÚmathieusÚmathieucÚmathieusprimeÚmathieucprimeÚLambdac                     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"   ri  ú&InvisibleTimes;rQ   ú&#xD7;Údotr   Úldotz&#x2024;)rH   Ú
isinstancerÖ   Ú	TypeErrorr1   r  r1   r2   Úmul_symbol_selection_  s   
zBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionr   rœ   )r.   r    r¡   r  r¢   r£   r1   r  r2   r¤   *  s¼   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ð3ÿz$MathMLPresentationPrinter.mathml_tagc                 C  ó"   | j  d¡}| | j  d¡¡ |S )Nr	  ú(rç   ©r.   r	  r1   r1   r2   Ú_l_parenw  ó   z"MathMLPresentationPrinter._l_parenc                 C  r€  )Nr	  ú)rç   r‚  r1   r1   r2   Ú_r_paren|  r„  z"MathMLPresentationPrinter._r_parenc                 C  r€  )Nr	  Ú{rç   r‚  r1   r1   r2   Ú_l_brace�  r„  z"MathMLPresentationPrinter._l_bracec                 C  r€  )Nr	  Ú}rç   r‚  r1   r1   r2   Ú_r_brace†  r„  z"MathMLPresentationPrinter._r_bracec                 C  r€  )Nr	  ú,rç   r‚  r1   r1   r2   Ú_comma‹  r„  z MathMLPresentationPrinter._commac                 C  r€  )Nr	  ú|rç   r‚  r1   r1   r2   Ú_bar�  r„  zMathMLPresentationPrinter._barc                 C  r€  )Nr	  ú;rç   r‚  r1   r1   r2   Ú
_semicolon•  r„  z$MathMLPresentationPrinter._semicolonc                 G  ó`   | j  d¡}| |  ¡ ¡ t|ƒD ]\}}|r| |  ¡ ¡ | |  |¡¡ q| |  ¡ ¡ |S ©Nr  )r9   r­   r®   rƒ  rÉ   rŒ  rB   r†  ©r.   rÁ   r  rË   rÂ   r1   r1   r2   Ú_paren_comma_separatedš  ó   z0MathMLPresentationPrinter._paren_comma_separatedc                 G  r‘  r’  )r9   r­   r®   rƒ  rÉ   rŽ  rB   r†  r“  r1   r1   r2   Ú_paren_bar_separated¤  r•  z.MathMLPresentationPrinter._paren_bar_separatedFc                 C  sb   t |ƒ}||k s|s,||kr,| j d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ |S |  |¡S r’  )r
   r9   r­   r®   rƒ  rB   r†  )r.   r  ÚlevelÚstrictÚprec_valr  r1   r1   r2   Ú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ñ   rª   r«   r	  r   r½   )r°   r¨   r   r±   r9   r­   rH   r³   rÖ   ÚsetAttributerB   r®   r²   r   r   r´   rµ   r>   r¤   rš  r   )rE   r  r¨   r·   r¸   ÚfracrØ   Zxdenr¹   rº   r¶   Úyr»   r  r1   r2   Úmultiplyº  s@   










€z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyr  r	  ú-)r9   r­   r¬   r®   r>   )r.   rE   r¡  r  r¶   r1   r  r2   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   rª   r	  r¢  ú+)r9   r­   r¾   r®   rB   r¬   r>   )r.   rE   r   r  rÁ   rÂ   r¶   r   r1   r1   r2   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rC|S | j  d¡}| j  d¡}	|dkrf| | j  d¡¡ |	 | j  d¡¡ n| | j  d	¡¡ |	 | j  d
¡¡ | j  d¡}
|
 |¡ |
 |¡ |
 |	¡ |
S )NZmtableZmtrZmtdr    r*   r	  r   Ú]r�  r…  r  )	r9   r­   rÏ   rÐ   rÑ   r®   rB   rH   r>   )r.   rÒ   ÚtablerË   r¶   rÓ   r   r    ÚleftÚrightr  r1   r1   r2   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   r›  r   r�  rñ   r  r	  r¢  )	r×   r9   r­   rH   rž  r®   rB   rÕ   r>   )r.   r    Úfoldedr×   r¶   r  r	  r1   r1   r2   Ú_get_printed_Rational  s    




z/MathMLPresentationPrinter._get_printed_Rationalc                 C  s(   |j dkr|  |j¡S |  || jd ¡S )Nrª   r   )rÕ   rB   r×   r©  rH   râ   r1   r1   r2   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
  Úlimrª   r	  rÜ   r   )r9   r­   r®   r>   rB   rÁ   r¤   )	r.   r    r  rª  r
  r¶   rÝ   ÚarrowrÞ   r1   r1   r2   rß   0  s"   





z&MathMLPresentationPrinter._print_Limitc                 C  ræ   )Nr
  z&ImaginaryI;rç   rè   r1   r1   r2   rã   F  r„  z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  ræ   )Nr
  r[  rç   rè   r1   r1   r2   ré   K  r„  z,MathMLPresentationPrinter._print_GoldenRatioc                 C  ræ   )Nr
  z&ExponentialE;rç   rè   r1   r1   r2   rê   P  r„  z%MathMLPresentationPrinter._print_Exp1c                 C  ræ   )Nr
  z&pi;rç   rè   r1   r1   r2   rì   U  r„  z#MathMLPresentationPrinter._print_Pic                 C  ræ   )Nr
  ú&#x221E;rç   rè   r1   r1   r2   rî   Z  r„  z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nr  r	  r¢  )r9   r­   r®   r>   rî   )r.   r    r  r   r¶   r1   r1   r2   rõ   _  s   


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  ræ   )Nr
  z&#x210F;rç   rè   r1   r1   r2   Ú_print_HBarh  r„  z%MathMLPresentationPrinter._print_HBarc                 C  ræ   )Nr
  r`  rç   rè   r1   r1   r2   rå   m  r„  z+MathMLPresentationPrinter._print_EulerGammac                 C  ræ   )Nr
  ÚTribonacciConstantrç   rè   r1   r1   r2   Ú_print_TribonacciConstantr  r„  z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr"  r   ú&#x2020;©r9   r­   r®   rB   rÁ   r>   ©r.   r    r"  r1   r1   r2   Ú_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;rª   r²  )r.   r    r  r	  r1   r1   r2   Ú_print_Contains}  s   
z)MathMLPresentationPrinter._print_Containsc                 C  ræ   )Nr
  z&#x210B;rç   rè   r1   r1   r2   Ú_print_HilbertSpace†  r„  z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr"  z	&#x1D49E;r   ©r9   r­   r®   r>   rB   rÁ   r³  r1   r1   r2   Ú_print_ComplexSpace‹  s   z-MathMLPresentationPrinter._print_ComplexSpacec                 C  ræ   )Nr
  z&#x2131;rç   rè   r1   r1   r2   Ú_print_FockSpace‘  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;)rª   rÜ   rö   r  rö   c                 s  s   � | ]	}t |ƒd kV  qdS )rª   N)r³   )r  r«  r1   r1   r2   Ú	<genexpr>›  s   € z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r	  rª   rÜ   r"  r#  r   T©r˜  rV  r   )r9   r­   r³   rø   Úallr®   r>   r3  rB   rš  r÷   r   )	r.   rE   Z
intsymbolsr  r	  r«  r"  r#  Údr1   r1   r2   rÿ   —  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¡}
|
 |¡ |
 |  |j	t
|ƒ¡¡ |
S )NZ
munderoverr   rª   rÜ   r	  r  rW  )rý   rø   r9   r­   rB   r®   r>   r¤   rš  r÷   r
   )r.   r    rø   Zsubsuprù   rú   ÚsummandÚlowÚvarÚequalr  r1   r1   r2   r   ½  s(   







z$MathMLPresentationPrinter._print_Sumr   c           	        s0  ‡ fdd„}dd„ ‰ˆ   |j¡\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j d¡}| ˆ j |¡¡ t|ƒd	krZt|ƒd	krG|}nEˆ j d
¡}| |¡ | ||ƒ¡ n2t|ƒd	krsˆ j d¡}| |¡ | ||ƒ¡ nˆ j d¡}| |¡ | ||ƒ¡ | ||ƒ¡ |dkr–| dd¡ |S )Nc                   r  )Nrª   r  r   r	  r  r
  r  r  r  r1   r2   r  ×  r  z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  r  r8   r  r  r1   r1   r2   r¡   é  r  z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   r  r1   r1   r  r  r1   r2   r  ñ  r  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   r  r1   r1   r  r  r1   r2   r  ò  r  r
  r   r!  r"  r#  ÚboldÚmathvariant)rJ   rI   r9   r­   r®   r>   r³   rž  )	r.   r  Ústyler  rI   r  r  r   r¶   r1   r$  r2   r%  Ö  s2   


z'MathMLPresentationPrinter._print_Symbolc                 C  s   | j || jd d�S )Nr!   )rÄ  )r%  rH   )r.   r  r1   r1   r2   rN    s   ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   )r9   r­   rž  r®   rB   rÁ   )r.   rE   Úencr1   r1   r2   Ú_print_conjugate  s   z*MathMLPresentationPrinter._print_conjugatec                 C  sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nr  ÚFuncr	  )r9   r­   r®   rš  r   r>   )r.   ÚoprE   Úrowr	  r1   r1   r2   Ú_print_operator_after  s   
z/MathMLPresentationPrinter._print_operator_afterc                 C  ó   |   d|jd ¡S )Nú!r   ©rÌ  rÁ   ©r.   rE   r1   r1   r2   Ú_print_factorial   ó   z*MathMLPresentationPrinter._print_factorialc                 C  rÍ  )Nz!!r   rÏ  rÐ  r1   r1   r2   Ú_print_factorial2#  rÒ  z+MathMLPresentationPrinter._print_factorial2c                 C  sz   | j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | j  d¡}| |  ¡ ¡ | |¡ | |  ¡ ¡ |S )Nr›  ZlinethicknessÚ0r   rª   r  )r9   r­   rž  r®   rB   rÁ   rƒ  r†  )r.   rE   rŸ  Úbracr1   r1   r2   Ú_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 )Nrª   r#   rÜ   ZmsqrtZmrootr½   r›  r"  rW   r   )r'  r(  r^   r×   rÕ   rH   r9   r­   r®   rB   r)  Úis_negativerš  r   r©  )r.   r    r¶   rŸ  rÆ  r1   r1   r2   r*  1  s`   $ÿ
ÿ
ÿ

ü
z$MathMLPresentationPrinter._print_Powc                 C  r+  r8   r,  rè   r1   r1   r2   r-  g  r.  z'MathMLPresentationPrinter._print_Numberc                 C  s’   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |j¡¡ | |  ¡ ¡ | |  |j¡¡ | |¡ |S )Nr	  õ   âŸ¨õ   âŸ©r  )r9   r­   r®   r>   rB   r\   rŒ  rZ   )r.   rË   r¦  r§  rÕ  r1   r1   r2   Ú_print_AccumulationBoundsl  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	  r›  )
r	   rE   r¤   r9   r­   r3  r4  r®   r>   rB   )r.   r    r½  rÒ   Údimr  Únumr¶   Úxxr   Zmnumr  rŸ  r1   r1   r2   r6  y  sF   









z+MathMLPresentationPrinter._print_Derivativec                 C  s|   | j  d¡}|  |¡dkr| jd r| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}| |¡ | | j|jŽ ¡ |S )Nr
  rŽ   r   r�   r  )r9   r­   r¤   rH   r®   r>   r”  rÁ   )r.   r    r¶   r  r1   r1   r2   r9  ©  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)Ústrip_zerosr%   r  r    r   r£  rª   rT  r	  r"  Ú10z+infz-inf)r   r1  r/  r0  rH   r9   r­   Úsplitr®   r>   rî   rõ   )r.   rE   ÚdpsÚstr_realÚ	separatorr  Úmantr'  rT  r	  r"  r1   r1   r2   r2  ´  s<   








z&MathMLPresentationPrinter._print_Floatc                 C  s¬   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ | |¡ |S )Nr  r!  r
  ÚLir   rª   )r9   r­   r®   r>   rB   rÁ   rƒ  r†  )r.   rE   r  rÒ   r
  rÕ  r1   r1   r2   Ú_print_polylogÛ  s   


z(MathMLPresentationPrinter._print_polylogc                 C  sP   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | | j|jŽ ¡ |S ©Nr  r
  )r9   r­   r®   r>   r¤   r”  rÁ   )r.   r    r  r
  r1   r1   r2   r:  ë  s   
z&MathMLPresentationPrinter._print_Basicc                 C  s   | j |jŽ S r8   )r”  rÁ   râ   r1   r1   r2   Ú_print_Tupleó  rä   z&MathMLPresentationPrinter._print_Tuplec                 C  sÆ   | j  d¡}|jr| | j  d¡¡ n	| | j  d¡¡ | j  d¡}|jr/| | j  d¡¡ n	| | j  d¡¡ | j  d¡}| |¡ | |  |j¡¡ | |  ¡ ¡ | |  |j	¡¡ | |¡ |S )Nr	  r…  r¤  r�  r   r  )
r9   r­   Ú
right_openr®   r>   Ú	left_openrB   ÚstartrŒ  Úend)r.   rË   r§  r¦  r  r1   r1   r2   Ú_print_Intervalö  s   

z)MathMLPresentationPrinter._print_Intervalc                 C  sB   | j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nr  r   )r9   r­   r®   rŽ  rB   rÁ   )r.   rE   r'  r  r1   r1   r2   Ú
_print_Abs	  s
   z$MathMLPresentationPrinter._print_Absc                 C  sz   | j  d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ | j  d¡}| | j  |¡¡ | j  d¡}| |¡ | |¡ |S rç  )r9   r­   r®   rƒ  rB   r†  r>   )r.   rÌ   rE   rÕ  r
  r  r1   r1   r2   Ú_print_re_im  s   

z&MathMLPresentationPrinter._print_re_imc                 C  rÍ  )Nu   â„œr   ©rï  rÁ   ©r.   rE   r'  r1   r1   r2   Ú	_print_re  rÒ  z#MathMLPresentationPrinter._print_rec                 C  rÍ  )Nu   â„‘r   rð  rñ  r1   r1   r2   Ú	_print_im!  rÒ  z#MathMLPresentationPrinter._print_imc                 C  sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]
}| |  |¡¡ q |S rç  )r9   r­   r®   r>   r¤   rÁ   rB   )r.   r    r  r
  rÂ   r1   r1   r2   r;  $  s   

z(MathMLPresentationPrinter._print_AssocOpc                 C  sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]!}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q|S ©Nr  r   rª   r	  )r9   r­   r®   rš  rÁ   r>   )r.   rE   ÚsymbolÚprecr  rÂ   r¶   r   r1   r1   r2   Ú_print_SetOp-  s   
z&MathMLPresentationPrinter._print_SetOpc                 C  ó   t d }|  |d|¡S )Nrš   z&#x222A;©r   r÷  ©r.   rE   rö  r1   r1   r2   Ú_print_Union8  ó   z&MathMLPresentationPrinter._print_Unionc                 C  rø  )Nr›   z&#x2229;rù  rú  r1   r1   r2   Ú_print_Intersection<  rü  z-MathMLPresentationPrinter._print_Intersectionc                 C  rø  )NÚ
Complementz&#x2216;rù  rú  r1   r1   r2   rH  @  rü  z+MathMLPresentationPrinter._print_Complementc                 C  rø  )NÚSymmetricDifferenceú&#x2206;rù  rú  r1   r1   r2   Ú_print_SymmetricDifferenceD  rü  z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  rø  )NÚ
ProductSetz&#x00d7;rù  rú  r1   r1   r2   rJ  H  rü  z+MathMLPresentationPrinter._print_ProductSetc                 C  ó   |   |j¡S r8   )Ú
_print_setrÁ   )r.   r  r1   r1   r2   rE  L  rä   z*MathMLPresentationPrinter._print_FiniteSetc                 C  sl   t |td�}| j d¡}| |  ¡ ¡ t|ƒD ]\}}|r$| |  ¡ ¡ | |  |¡¡ q| |  	¡ ¡ |S )N©Úkeyr  )
Úsortedr   r9   r­   r®   rˆ  rÉ   rŒ  rB   rŠ  )r.   r  r  rÕ  rË   r  r1   r1   r2   r  O  s   z$MathMLPresentationPrinter._print_setc                 C  s  | j  d¡}|d jr4|d js4| j  d¡}| |  ¡ ¡ | |  |d ¡¡ | |  ¡ ¡ | |¡ n
| |  |d ¡¡ |dd … D ]C}| j  d¡}| | j  |¡¡ |jrx|jsx| j  d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ n|  |¡}| |¡ | |¡ qD|S rô  )	r9   r­   Ú
is_BooleanÚis_Notr®   rƒ  rB   r†  r>   )r.   rÁ   rõ  r  rÕ  rÂ   r¶   r   r1   r1   r2   Ú_print_LogOp\  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¶   r1   r1   r2   Ú<lambda>‚  s    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>r  rª   r	  r£  r½   r¢  ry  )Úsympy.vectorr  ÚzerorB   r}  Úseparater  r9   r­   rý   Ú
componentsÚsortrÉ   r®   r>   rƒ  r†  )r.   rE   r  r  r  ÚsystemÚvectÚ
inneritemsrË   ÚkÚvr	  Zmbracr1   r1   r2   Ú_print_BasisDependentt  sJ   







çz/MathMLPresentationPrinter._print_BasisDependentc                 C  ó   t |jtd�}|  |d¡S )Nr  z&#x2227;©r  rÁ   r   r
  ©r.   rE   rÁ   r1   r1   r2   Ú
_print_And   ó   z$MathMLPresentationPrinter._print_Andc                 C  r  )Nr  z&#x2228;r  r  r1   r1   r2   Ú	_print_Or¤  r  z#MathMLPresentationPrinter._print_Orc                 C  r  )Nr  z&#x22BB;r  r  r1   r1   r2   rR  ¨  r  z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r
  rÁ   rÐ  r1   r1   r2   rP  ¬  s   z(MathMLPresentationPrinter._print_Impliesc                 C  r  )Nr  z&#x21D4;r  r  r1   r1   r2   Ú_print_Equivalent¯  r  z+MathMLPresentationPrinter._print_Equivalentc                 C  sž   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ |jd jr@| j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ n|  |jd ¡}| |¡ |S )Nr  r	  z&#xAC;r   )	r9   r­   r®   r>   rÁ   r  rƒ  rB   r†  )r.   r    r  r	  r¶   r1   r1   r2   rQ  ³  s   

z$MathMLPresentationPrinter._print_Notc                 C  ó(   | j  d¡}| | j  |  |¡¡¡ |S ©Nr
  ©r9   r­   r®   r>   r¤   ©r.   r    r
  r1   r1   r2   Ú_print_boolÂ  ó   z%MathMLPresentationPrinter._print_boolc                 C  r   r!  r"  r#  r1   r1   r2   Ú_print_NoneTypeÊ  r%  z)MathMLPresentationPrinter._print_NoneTypec           	      C  sJ  d}|j jr|jjr|jjr|ddd|f}nF|ddd|f}n>|j jr/||d |j |d f}n-|jjrAt|ƒ}t|ƒt|ƒ|f}nt|ƒdkrXt|ƒ}t|ƒt|ƒ||d f}nt|ƒ}| j	 
d¡}| |  ¡ ¡ t|ƒD ].\}}|rz| |  ¡ ¡ ||kr“| j	 
d¡}| | j	 |¡¡ | |¡ qm| |  |¡¡ qm| |  ¡ ¡ |S )Nu   â€¦r½   r   rª   é   r  r
  )rë  Úis_infiniteÚstopÚstepÚis_positiveÚiterÚnextr³   Útupler9   r­   r®   rˆ  rÉ   rŒ  r>   rB   rŠ  )	r.   r  ÚdotsÚprintsetÚitrÕ  rË   Úelr
  r1   r1   r2   Ú_print_RangeÏ  s4   z&MathMLPresentationPrinter._print_Rangec                 C  s`   t |jtd�}| j d¡}| j d¡}| | j t|jƒ 	¡ ¡¡ | |¡ | | j
|Ž ¡ |S )Nr  r  r	  )r  rÁ   r   r9   r­   r®   r>   rÖ   ÚfuncrŸ   r”  )r.   rE   rÁ   r  r	  r1   r1   r2   Ú_hprint_variadic_functionî  s   
z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr"  r   )r9   r­   r®   rê   rB   rÁ   )r.   rE   r"  r1   r1   r2   Ú
_print_expù  s   z$MathMLPresentationPrinter._print_expc                 C  sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nr  r	  )r9   r­   r®   rB   r<  r>   r¤   r=  )r.   r    r  r¶   r1   r1   r2   r>  ÿ  s   
z+MathMLPresentationPrinter._print_Relationalc                 C  r+  r8   r,  rB  r1   r1   r2   rC    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Â  )r9   r­   Ú_idrž  r®   r>   Z_variable_namesÚ_name)r.   r    r!  Úindexr  r
  r1   r1   r2   Ú_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	  ú^)r9   r­   r7  rž  r®   r>   Z_vector_namesr8  )r.   r    r!  r9  r  r;  r
  r	  r1   r1   r2   Ú_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<  ©r9   r­   rž  r®   r>   )r.   r    r;  r
  r	  r1   r1   r2   Ú_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	  rz  ©r9   r­   Ú_expr1Ú_expr2r®   rš  r   r>   ©r.   rE   r  Úvec1Úvec2r	  r1   r1   r2   Ú_print_Cross7  ó   
z&MathMLPresentationPrinter._print_Crossc                 C  óx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r	  ú&#x2207;rz  r   ©r9   r­   r®   r>   rš  Ú_exprr   ©r.   rE   r  r	  r1   r1   r2   Ú_print_CurlB  ó   

z%MathMLPresentationPrinter._print_Curlc                 C  rI  )Nr  r	  rJ  r   r   rK  rM  r1   r1   r2   Ú_print_DivergenceM  rO  z+MathMLPresentationPrinter._print_Divergencec                 C  r@  )Nr  r   r	  r   rA  rD  r1   r1   r2   Ú
_print_DotX  rH  z$MathMLPresentationPrinter._print_Dotc                 C  óP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r	  rJ  r   rK  rM  r1   r1   r2   Ú_print_Gradientc  ó   
z)MathMLPresentationPrinter._print_Gradientc                 C  rR  )Nr  r	  r   r   rK  rM  r1   r1   r2   Ú_print_Laplaciank  rT  z*MathMLPresentationPrinter._print_Laplacianc                 C  ó.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr
  rÃ  Únormalz&#x2124;r>  rè   r1   r1   r2   Ú_print_Integerss  ó   z)MathMLPresentationPrinter._print_Integersc                 C  rV  )Nr
  rÃ  rW  z&#x2102;r>  rè   r1   r1   r2   Ú_print_Complexesy  rY  z*MathMLPresentationPrinter._print_Complexesc                 C  rV  )Nr
  rÃ  rW  z&#x211D;r>  rè   r1   r1   r2   Ú_print_Reals  rY  z&MathMLPresentationPrinter._print_Realsc                 C  rV  )Nr
  rÃ  rW  ú&#x2115;r>  rè   r1   r1   r2   Ú_print_Naturals…  rY  z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr!  r
  rÃ  rW  r\  )r9   r­   rž  r®   r>   rB   r   ÚZero)r.   r    r  r¶   r1   r1   r2   Ú_print_Naturals0‹  s   
z*MathMLPresentationPrinter._print_Naturals0c                 C  s´   |j d |j d  }|j d }| j d¡}| | j d¡¡ | j d¡}| | j d¡¡ | j d¡}| |¡ | |  |¡¡ | |¡ | j d¡}| |¡ | |  |¡¡ |S )	Nr   rª   rÜ   r	  rØ  rÙ  r  r"  )rÁ   r9   r­   r®   r>   rB   )r.   rE   ÚshiftrX   r¦  r§  rÕ  r  r1   r1   r2   Ú_print_SingularityFunction”  s   



z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  ræ   )Nr
  ÚNaNrç   rè   r1   r1   r2   rï   ¤  r„  z$MathMLPresentationPrinter._print_NaNc                 C  s�   | j  d¡}| j  d¡}| | j  |¡¡ | |¡ | |  |jd ¡¡ t|jƒdkr.|S | j  d¡}| |¡ | | j|jdd … Ž ¡ |S )Nr!  r
  r   rª   r  )r9   r­   r®   r>   rB   rÁ   r³   r”  )r.   r    rI   r  r
  r  r1   r1   r2   Ú_print_number_function©  s   

z0MathMLPresentationPrinter._print_number_functionc                 C  ó   |   |d¡S )NÚB©rc  râ   r1   r1   r2   Ú_print_bernoulli¸  rä   z*MathMLPresentationPrinter._print_bernoullic                 C  rd  )Nre  rf  râ   r1   r1   r2   Ú_print_catalan½  rä   z(MathMLPresentationPrinter._print_catalanc                 C  rd  )NÚErf  râ   r1   r1   r2   Ú_print_eulerÀ  rä   z&MathMLPresentationPrinter._print_eulerc                 C  rd  )NÚFrf  râ   r1   r1   r2   Ú_print_fibonacciÃ  rä   z*MathMLPresentationPrinter._print_fibonaccic                 C  rd  )NÚLrf  râ   r1   r1   r2   Ú_print_lucasÆ  rä   z&MathMLPresentationPrinter._print_lucasc                 C  rd  )Nz&#x03B3;rf  râ   r1   r1   r2   Ú_print_stieltjesÉ  rä   z*MathMLPresentationPrinter._print_stieltjesc                 C  rd  )NÚTrf  râ   r1   r1   r2   Ú_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	  r1   r1   r2   Ú_print_ComplexInfinityÏ  s   

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  ræ   )Nr	  z&#x2205;rç   rè   r1   r1   r2   rð   Ù  r„  z)MathMLPresentationPrinter._print_EmptySetc                 C  ræ   )Nr	  z	&#x1D54C;rç   rè   r1   r1   r2   Ú_print_UniversalSetÞ  r„  z-MathMLPresentationPrinter._print_UniversalSetc                 C  ó¨   ddl m} |j}| j d¡}t||ƒs6| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | j d¡}| | j 
d¡¡ | |¡ |S )Nr   ©rj   r"  r  r	  r±  ©Úsympy.matricesrj   rÂ   r9   r­   r}  r®   rƒ  rB   r†  r>   ©r.   rE   rj   Úmatr  rÕ  r	  r1   r1   r2   Ú_print_Adjointã  ó   

z(MathMLPresentationPrinter._print_Adjointc                 C  ru  )Nr   rv  r"  r  r	  rp  rw  ry  r1   r1   r2   Ú_print_Transposeô  r|  z*MathMLPresentationPrinter._print_Transposec                 C  s�   ddl m} |j}| j d¡}t||ƒs6| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   rv  r"  r  r½   )
rx  rj   rÂ   r9   r­   r}  r®   rƒ  rB   r†  )r.   rE   rj   rz  r  rÕ  r1   r1   r2   Ú_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  rª   r½   r	  r¢  Fry  )Ú!sympy.matrices.expressions.matmulr  r9   r­   rÁ   r}  r   rµ   rý   r¬   r®   r>   rš  r
   )r.   rE   r  r¶   rÁ   r	  rÂ   r1   r1   r2   Ú_print_MatMul  s0   
ÿÿz'MathMLPresentationPrinter._print_MatMulc                 C  s˜   ddl m} |j|j}}| j d¡}t||ƒs:| j d¡}| |  ¡ ¡ | |  	|¡¡ | |  
¡ ¡ | |¡ n| |  	|¡¡ | |  	|¡¡ |S )Nr   rv  r"  r  )rx  rj   r)  r'  r9   r­   r}  r®   rƒ  rB   r†  )r.   rE   rj   r)  r'  r  rÕ  r1   r1   r2   Ú_print_MatPow1  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;)r9   r­   rÁ   r®   rš  r
   r>   )r.   rE   r¶   rÁ   rÂ   r	  r1   r1   r2   Ú_print_HadamardProduct@  s   ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  ræ   )NrT  z&#x1D7D8rç   ©r.   ÚZr¶   r1   r1   r2   Ú_print_ZeroMatrixM  r„  z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  ræ   )NrT  z&#x1D7D9rç   r„  r1   r1   r2   Ú_print_OneMatrixR  r„  z*MathMLPresentationPrinter._print_OneMatrixc                 C  ræ   )Nr
  z	&#x1D540;rç   )r.   ÚIr¶   r1   r1   r2   Ú_print_IdentityW  r„  z)MathMLPresentationPrinter._print_Identityc                 C  óv   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |jd ¡¡ | |¡ |S )Nr	  u   âŒŠu   âŒ‹r  r   r·  ©r.   r    r¦  r§  r  r1   r1   r2   Ú_print_floor\  ó   

z&MathMLPresentationPrinter._print_floorc                 C  rŠ  )Nr	  u   âŒˆu   âŒ‰r  r   r·  r‹  r1   r1   r2   Ú_print_ceilingg  r�  z(MathMLPresentationPrinter._print_ceilingc                 C  s¤   | j  d¡}|jd }t|ƒdkr|  |d ¡}n|  |¡}| |  ¡ ¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nr  r   rª   r	  z&#x21A6;)	r9   r­   rÁ   r³   rB   r®   rƒ  r>   r†  )r.   r    r  Úsymbolsr	  r1   r1   r2   rL  r  s   



z'MathMLPresentationPrinter._print_Lambdac                 C  s
   | j |Ž S r8   )r”  râ   r1   r1   r2   Ú_print_tuple‚  s   
z&MathMLPresentationPrinter._print_tuplec                 C  r  r8   )rB   Úlabelrâ   r1   r1   r2   Ú_print_IndexedBase…  rä   z,MathMLPresentationPrinter._print_IndexedBasec                 C  s\   | j  d¡}| |  |j¡¡ t|jƒdkr#| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr!  rª   r   )r9   r­   r®   rB   r)  r³   Úindicesrè   r1   r1   r2   Ú_print_Indexedˆ  s   z(MathMLPresentationPrinter._print_Indexedc                 C  sx   | j  d¡}| | j|jtd dd�¡ | j  d¡}t|jƒD ]\}}|r,| |  ¡ ¡ | |  	|¡¡ q| |¡ |S )Nr!  ÚAtomTr»  r  )
r9   r­   r®   rš  Úparentr   rÉ   r“  rŒ  rB   )r.   r    r¶   rÕ  rË   rÂ   r1   r1   r2   Ú_print_MatrixElement‘  s   
z.MathMLPresentationPrinter._print_MatrixElementc                 C  óJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | | j|jŽ ¡ |S )Nr  r
  z	&#x1d5a5;©r9   r­   r®   r>   r–  rÁ   ©r.   r    r¶   r
  r1   r1   r2   Ú_print_elliptic_fœ  ó   
z+MathMLPresentationPrinter._print_elliptic_fc                 C  r˜  )Nr  r
  z	&#x1d5a4;r™  rš  r1   r1   r2   Ú_print_elliptic_e¤  rœ  z+MathMLPresentationPrinter._print_elliptic_ec                 C  s
  | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| |  ¡ ¡ t|jƒdkrK|j\}}| |  |¡¡ | |  ¡ ¡ | |  |¡¡ n,|j\}}}| |  |¡¡ | |  	¡ ¡ | |  |¡¡ | |  ¡ ¡ | |  |¡¡ | |  
¡ ¡ | |¡ |S )Nr  r
  z	&#x1d6f1;rÜ   )r9   r­   r®   r>   rƒ  r³   rÁ   rB   rŽ  r�  r†  )r.   r    r¶   r
  r   r£   rÒ   Úzr1   r1   r2   Ú_print_elliptic_pi¬  s(   


z,MathMLPresentationPrinter._print_elliptic_pic                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |j¡¡ |S )Nr  r
  ÚEir·  rš  r1   r1   r2   Ú	_print_EiÃ  rœ  z#MathMLPresentationPrinter._print_Eic                 C  ó~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r!  r	  ri  r   rª   r·  ©r.   r    r¶   r   r	  r1   r1   r2   Ú_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   rª   rö   r·  r£  r1   r1   r2   Ú_print_jacobiÖ  ó   

z'MathMLPresentationPrinter._print_jacobic                 C  r¦  )Nr  r#  r	  re  r   rª   rÜ   r·  r£  r1   r1   r2   Ú_print_gegenbauerâ  r©  z+MathMLPresentationPrinter._print_gegenbauerc                 C  r¢  )Nr  r!  r	  rp  r   rª   r·  r£  r1   r1   r2   Ú_print_chebyshevtî  r¥  z+MathMLPresentationPrinter._print_chebyshevtc                 C  r¢  )Nr  r!  r	  ÚUr   rª   r·  r£  r1   r1   r2   Ú_print_chebyshevuù  r¥  z+MathMLPresentationPrinter._print_chebyshevuc                 C  r¢  )Nr  r!  r	  r§  r   rª   r·  r£  r1   r1   r2   Ú_print_legendre  r¥  z)MathMLPresentationPrinter._print_legendrec                 C  r¦  )Nr  r#  r	  r§  r   rª   rÜ   r·  r£  r1   r1   r2   Ú_print_assoc_legendre  r©  z/MathMLPresentationPrinter._print_assoc_legendrec                 C  r¢  )Nr  r!  r	  rm  r   rª   r·  r£  r1   r1   r2   Ú_print_laguerre  r¥  z)MathMLPresentationPrinter._print_laguerrec                 C  r¦  )Nr  r#  r	  rm  r   rª   rÜ   r·  r£  r1   r1   r2   Ú_print_assoc_laguerre&  r©  z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  r¢  )Nr  r!  r	  ÚHr   rª   r·  r£  r1   r1   r2   Ú_print_hermite2  r¥  z(MathMLPresentationPrinter._print_hermite)Fr8   )r   )”r4   r5   r6   rK   rM  r¤   rƒ  r†  rˆ  rŠ  rŒ  rŽ  r�  r”  r–  rš  r¯   rÃ   rÔ   r©  rÙ   rß   rã   ré   rê   rì   rî   rõ   r®  rå   r°  r´  rµ  r¶  r¸  r¹  rÿ   r   r%  rN  rO  rÈ  rÌ  rÑ  rÓ  rÖ  r*  r-  rÚ  r6  r9  r2  ræ  r:  rè  rí  rî  Ú_print_Determinantrï  rò  ró  r;  r÷  rû  rý  rH  r  rJ  rE  r  Ú_print_frozensetr
  r  r  r  rR  rP  r  rQ  r$  rò   rô   r&  r3  r5  Ú
_print_MinÚ
_print_Maxr6  r>  rC  r:  r=  r?  rG  rN  rP  rQ  rS  rU  rX  rZ  r[  r]  r_  ra  rï   rc  rg  Ú_print_bellrh  rj  rl  rn  ro  rq  rs  rð   rt  r{  r}  r~  r�  r‚  rƒ  r†  r‡  r‰  rŒ  rŽ  rL  r�  r’  r”  r—  r›  r�  rŸ  r¡  r¤  r¨  rª  r«  r­  r®  r¯  r°  r±  r³  r1   r1   r1   r2   rS  #  s"   M


/		&660'	,			
	rS  Ú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)rS  rG   rM   )rE   Úprinterr?   r1   r1   r2   Úmathml>  s   r¼  c                 K  s<   |dkr	t |ƒ}nt|ƒ}| t| ƒ¡}| ¡ }t|ƒ dS )a  
    Prints a pretty representation of the MathML code for expr. If printer is
    presentation then prints Presentation MathML else prints content MathML.

    Examples
    ========

    >>> ##
    >>> from sympy import print_mathml
    >>> from sympy.abc import x
    >>> print_mathml(x+1) #doctest: +NORMALIZE_WHITESPACE
    <apply>
        <plus/>
        <ci>x</ci>
        <cn>1</cn>
    </apply>
    >>> print_mathml(x+1, printer='presentation')
    <mrow>
        <mi>x</mi>
        <mo>+</mo>
        <mn>1</mn>
    </mrow>

    rº  N)rS  rM   rB   r   ZtoprettyxmlÚprint)rE   r»  r?   r  ÚxmlZ
pretty_xmlr1   r1   r2   Úprint_mathmlI  s   
r¿  N)r¹  )$rK   Ú
__future__r   Útypingr   Zsympy.core.mulr   Úsympy.core.singletonr   Úsympy.core.sortingr   Úsympy.core.sympifyr   Úsympy.printing.conventionsr   r	   Úsympy.printing.precedencer
   r   r   Z&sympy.printing.pretty.pretty_symbologyr   Úsympy.printing.printerr   r   Zmpmath.libmpr   r   r   r/  r   rM   rS  r¼  r¿  ZMathMLPrinterr1   r1   r1   r2   Ú<module>   sD    ?   R            '

$