]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/mmlextension.xsl
Initial revision
[helm.git] / helm / style / mmlextension.xsl
diff --git a/helm/style/mmlextension.xsl b/helm/style/mmlextension.xsl
new file mode 100644 (file)
index 0000000..566ccdf
--- /dev/null
@@ -0,0 +1,1382 @@
+<?xml version="1.0"?>
+
+<!--***********************************************************************--> 
+<!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
+<!-- First draft: February 19 2000, Andrea Asperti, Irene Schena           -->
+<!-- Revised: March 3 2000, Irene Schena                                   -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena          -->
+<!-- Revised: March 21 2000, Irene Schena                                  -->
+<!--***********************************************************************--> 
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                              xmlns:m="http://www.w3.org/1998/Math/MathML"
+                              xmlns:helm="http://www.cs.unibo.it/helm">
+
+<xsl:import href="mml2mmlv1_0.xsl"/>
+
+<!--***********************************************************************-->
+<!-- Parameter affecting line-breaking                                     -->
+<!--***********************************************************************-->
+
+<xsl:variable name="framewidth" select="30"/>
+
+<!--***********************************************************************-->
+<!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
+<!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti  -->
+<!-- sono i termini: la presentation per un termine e' generata come primo -->
+<!-- figlio di un semantics e l'originario content viene inserito nel      -->
+<!-- nel secondo figlio di semantics, annotation-xml                       -->
+<!--***********************************************************************-->
+
+<!--**********************-->
+<!--        OBJECTS       -->
+<!--**********************-->
+
+<xsl:template match="/">
+ <xsl:processing-instruction name="cocoon-format">type="text/xhtml"</xsl:processing-instruction>
+ <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<!-- DEFINITION -->
+
+<xsl:template match="Definition">
+    <m:math>
+     <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != &quot;&quot;"><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="type/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>AS</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="body/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+     </m:mtable>
+    </m:math>
+</xsl:template>
+
+<!-- AXIOM -->
+
+<xsl:template match="Axiom">
+    <m:math>
+     <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != &quot;&quot;"><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="type/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+     </m:mtable>
+    </m:math>
+</xsl:template>
+
+<!-- UNFINISHED PROOF -->
+
+<xsl:template match="CurrentProof">
+    <m:math>
+     <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != &quot;&quot;"><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>THESIS:</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="type/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>CONJECTURES:</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <xsl:for-each select="Conjecture">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
+         <xsl:apply-templates select="./*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      </xsl:for-each>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>CORRESPONDING PROOF:</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="body/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+     </m:mtable>
+    </m:math>
+</xsl:template>
+
+<!-- MUTUAL INDUCTIVE DEFINITION -->
+
+<xsl:template match="InductiveDefinition">
+    <m:math>
+     <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+     <xsl:for-each select="InductiveType">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <xsl:choose>
+         <xsl:when test="position() = 1">
+          <xsl:choose>
+          <xsl:when test="string(./@inductive) = &quot;true&quot;">
+           <m:mtext>INDUCTIVE DEFINITION</m:mtext>
+          </xsl:when>
+          <xsl:otherwise>
+           <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
+          </xsl:otherwise>
+          </xsl:choose>  
+         </xsl:when>
+         <xsl:otherwise>
+          <m:mtext>AND</m:mtext>
+         </xsl:otherwise>
+         </xsl:choose>
+         <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+         <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != &quot;&quot;"><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow> 
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <m:mtext>[</m:mtext>
+         <xsl:choose>
+         <xsl:when test="string(../Param) != &quot;&quot;">         
+          <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+           <xsl:for-each select="../Param">
+            <m:mtr>
+             <m:mtd>
+              <m:mrow>   
+               <m:mi><xsl:value-of select="./@name"/></m:mi>
+               <m:mo>:</m:mo>
+               <xsl:apply-templates select="*"/>
+              </m:mrow>
+             </m:mtd>
+            </m:mtr>
+           </xsl:for-each>
+            <m:mtr>
+             <m:mtd>
+              <m:mrow>
+               <m:mtext>]</m:mtext>
+              </m:mrow>
+             </m:mtd>
+            </m:mtr>
+          </m:mtable>
+         </xsl:when>
+         <xsl:otherwise>
+          <m:mtext>]</m:mtext>
+         </xsl:otherwise>
+         </xsl:choose>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>OF ARITY</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="./arity/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>BUILT FROM</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <xsl:for-each select="./Constructor">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <xsl:choose>
+         <xsl:when test="position() = 1">
+          <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         </xsl:when>
+         <xsl:otherwise>
+          <m:mtext>|</m:mtext>
+          <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+         </xsl:otherwise>
+         </xsl:choose>
+         <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
+         <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+         <xsl:apply-templates select="./*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      </xsl:for-each>
+     </xsl:for-each>
+     </m:mtable>
+    </m:math>
+</xsl:template>
+
+<!-- VARIABLE -->
+
+<xsl:template match="Variable">
+    <m:math>
+     <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+        <m:mrow>
+         <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+         <xsl:apply-templates select="type/*[1]"/>
+        </m:mrow>
+       </m:mtd>
+      </m:mtr>
+     </m:mtable>
+    </m:math>
+</xsl:template>
+
+<!--**********************-->
+<!--        TERMS         -->
+<!--**********************-->
+
+<xsl:template match="m:bvar">
+ <xsl:choose>
+  <xsl:when test="m:type">
+   <xsl:variable name="charlength">
+    <xsl:apply-templates select="m:ci" mode="charcount"/>
+   </xsl:variable>
+   <xsl:choose>
+    <xsl:when test="$charlength >= $framewidth">
+     <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+      <m:mtr>
+       <m:mtd>
+        <xsl:apply-templates select="m:ci"/>
+        <m:mo>:</m:mo>
+       </m:mtd>
+      </m:mtr>
+      <m:mtr>
+       <m:mtd>
+         <xsl:apply-templates select="m:type"/>
+       </m:mtd>
+      </m:mtr>
+     </m:mtable>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:apply-templates select="m:ci"/>
+     <m:mo>:</m:mo>
+     <xsl:apply-templates select="m:type"/>
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:apply-templates select="m:ci"/>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- CSYMBOL -->
+
+<xsl:template match="m:apply[m:csymbol]">
+    <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
+    <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
+    <m:mrow>
+     <xsl:if test="@helm:xref">
+      <xsl:attribute name="helm:xref"><xsl:value-of select="@helm:xref"/></xsl:attribute>
+     </xsl:if>
+     <xsl:choose>
+      <xsl:when test="$name='prod'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+            <m:mo color="Blue">&#x03a0;</m:mo>
+            <xsl:apply-templates select="m:bvar"/>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>.</m:mo>
+            <xsl:apply-templates select="*[position()=3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo color="Blue">&#x03a0;</m:mo>
+        <xsl:apply-templates select="m:bvar/m:ci"/>
+        <m:mo>:</m:mo>
+        <xsl:apply-templates select="m:bvar/m:type"/>
+        <m:mo>.</m:mo>
+        <xsl:apply-templates select="*[position()=3]"/>
+       </xsl:otherwise>
+       </xsl:choose> 
+      </xsl:when>
+      <xsl:when test="$name='arrow'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">(</m:mo>
+            <xsl:apply-templates select="*[position()=2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo color="Blue">&#x2192;</m:mo>
+            <xsl:apply-templates select="*[position()=3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">)</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo stretchy="false">(</m:mo>
+        <xsl:apply-templates select="*[position()=2]"/>
+        <m:mo color="Blue">&#x2192;</m:mo>
+        <xsl:apply-templates select="*[position()=3]"/>
+        <m:mo stretchy="false">)</m:mo>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <xsl:when test="$name='app'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">(</m:mo>
+            <xsl:apply-templates select="*[position()=2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <xsl:for-each select="*[position()>2]">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
+            <xsl:apply-templates select="."/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         </xsl:for-each>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">)</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo stretchy="false">(</m:mo>
+        <xsl:apply-templates select="*[position()=2]"/>
+        <xsl:for-each select="*[position()>2]">
+         <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+         <xsl:apply-templates select="."/>
+        </xsl:for-each>
+        <m:mo stretchy="false">)</m:mo>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <xsl:when test="$name='cast'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">(</m:mo>
+            <xsl:apply-templates select="*[position()=2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo color="#b03060">:></m:mo>
+            <xsl:apply-templates select="*[position()=3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">)</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo stretchy="false">(</m:mo>
+        <xsl:apply-templates select="*[position()=2]"/>
+        <m:mo color="#b03060">:></m:mo>
+        <xsl:apply-templates select="*[position()=3]"/>
+        <m:mo stretchy="false">)</m:mo>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <xsl:when test="$name='Prop'">
+       <m:mo>Prop</m:mo>
+      </xsl:when>
+      <xsl:when test="$name='Set'">
+       <m:mo>Set</m:mo>
+      </xsl:when>
+      <xsl:when test="$name='Type'">
+       <m:mo>Type</m:mo>
+      </xsl:when>
+      <xsl:when test="$name='mutcase'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>&lt;</m:mo>
+            <xsl:apply-templates select="*[position()=2]"/>
+            <xsl:if test="$framewidth > $charlength">
+             <m:mo>&gt;</m:mo>
+             <m:mo>CASES</m:mo>
+             <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+             <xsl:apply-templates select="*[position()=3]"/>
+            </xsl:if>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <xsl:if test="$charlength >= $framewidth">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>&gt;</m:mo>
+            <m:mo>CASES</m:mo>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[position()=3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         </xsl:if>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>OF</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+         <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:choose>
+            <xsl:when test="position() = 1">
+              <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
+            </xsl:when>
+            <xsl:otherwise>
+             <m:mo stretchy="false">|</m:mo>
+            </xsl:otherwise>
+            </xsl:choose>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="."/>
+            <xsl:if test="$framewidth > $charlength">
+             <m:mo color="Green">&#x21d2;</m:mo>
+             <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+            </xsl:if>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <xsl:if test="$charlength >= $framewidth">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>  
+            <m:mo color="Green">&#x21d2;</m:mo>
+            <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         </xsl:if>
+        </xsl:for-each>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>END</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo>&lt;</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>&gt;</m:mo>
+        <m:mo>CASES</m:mo>
+        <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+        <xsl:apply-templates select="*[position()=3]"/>
+        <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+        <m:mo>OF</m:mo>
+        <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+         <xsl:choose>
+         <xsl:when test="position() != 1">
+          <m:mo stretchy="false">|</m:mo>
+         </xsl:when> 
+         </xsl:choose>
+         <xsl:apply-templates select="."/>
+         <m:mo color="Green">&#x21d2;</m:mo>
+         <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+        </xsl:for-each>
+        <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+        <m:mo>END</m:mo>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <xsl:when test="$name='fix'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>FIX</m:mo>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <m:mi><xsl:value-of select="m:ci"/></m:mi>
+            <m:mo stretchy="false">{</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+            <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+            <xsl:for-each select="m:bvar"> 
+             <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+             <m:mtr>
+              <m:mtd>
+               <m:mrow>
+                <m:mi><xsl:value-of select="m:ci"/></m:mi>
+                <m:mo>:</m:mo>
+                <xsl:if test="$framewidth > $charlength">
+                 <xsl:apply-templates select="m:type"/>
+                </xsl:if>
+               </m:mrow>
+              </m:mtd>
+             </m:mtr> 
+             <xsl:if test="$charlength >= $framewidth">
+             <m:mtr>
+              <m:mtd>
+               <m:mrow>
+                <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+                <xsl:apply-templates select="m:type"/>
+               </m:mrow>
+              </m:mtd>
+             </m:mtr>
+             </xsl:if>
+             <m:mtr>
+              <m:mtd>
+               <m:mrow>
+                <m:mo>:=</m:mo>
+                <xsl:apply-templates select="following-sibling::*[position()=1]"/>
+               </m:mrow>
+              </m:mtd>
+             </m:mtr> 
+            </xsl:for-each>
+            </m:mtable>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">}</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo>FIX</m:mo>
+        <m:mi><xsl:value-of select="m:ci"/></m:mi>
+        <m:mo stretchy="false">{</m:mo>
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+        <xsl:for-each select="m:bvar"> 
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mi><xsl:value-of select="m:ci"/></m:mi>
+            <m:mo>:</m:mo>
+            <xsl:apply-templates select="m:type"/>
+            <m:mo>:=</m:mo>
+            <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+            <xsl:if test="position()=last()">
+             <m:mo stretchy="false">}</m:mo>
+            </xsl:if>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         </xsl:for-each>
+        </m:mtable>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <xsl:when test="$name='cofix'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>COFIX</m:mo>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <m:mi><xsl:value-of select="m:ci"/></m:mi>
+            <m:mo stretchy="false">{</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+            <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+            <xsl:for-each select="m:bvar">
+             <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable> 
+             <m:mtr>
+              <m:mtd>
+               <m:mrow>
+                <m:mi><xsl:value-of select="m:ci"/></m:mi>
+                <m:mo>:</m:mo>
+                <xsl:if test="$framewidth > $charlength">
+                 <xsl:apply-templates select="m:type"/>
+                </xsl:if>
+               </m:mrow>
+              </m:mtd>
+             </m:mtr> 
+             <xsl:if test="$charlength >= $framewidth">
+             <m:mtr>
+              <m:mtd>
+               <m:mrow>
+                <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+                <xsl:apply-templates select="m:type"/>
+               </m:mrow>
+              </m:mtd>
+             </m:mtr>
+             </xsl:if>
+             <m:mtr>
+              <m:mtd>
+               <m:mrow>
+                <m:mo>:=</m:mo>
+                <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+               </m:mrow>
+              </m:mtd>
+             </m:mtr>
+            </xsl:for-each>
+            </m:mtable>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo stretchy="false">}</m:mo>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo>COFIX</m:mo>
+        <m:mi><xsl:value-of select="m:ci"/></m:mi>
+        <m:mo stretchy="false">{</m:mo>
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">  
+        <xsl:for-each select="m:bvar"> 
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mi><xsl:value-of select="m:ci"/></m:mi>
+            <m:mo>:</m:mo>
+            <xsl:apply-templates select="m:type"/>
+            <m:mo>:=</m:mo>
+            <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+            <xsl:if test="position()=last()">
+             <m:mo stretchy="false">}</m:mo>
+            </xsl:if>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         </xsl:for-each>
+        </m:mtable>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <!-- ***************************************** -->
+      <!-- *********** PROOF ELEMENTS ************** -->
+      <!-- ***************************************** -->
+      <xsl:when test="$name='proof'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="*[position()=2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext color="#b03060">we proved </m:mtext>
+            <xsl:apply-templates select="*[position()=3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+      </xsl:when>
+      <xsl:when test="$name='letin'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
+        <xsl:for-each select="*[(last() > position()) and (position()>1)]">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="."/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         </xsl:for-each>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="*[position()=last()]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+      </xsl:when>
+      <xsl:when test="$name='let'">
+       <m:mtext>(</m:mtext>
+       <xsl:apply-templates select="m:ci"/>
+       <m:mtext>) </m:mtext>
+       <xsl:apply-templates select="*[3]"/>
+      </xsl:when>
+      <xsl:when test="$name='thread'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:choose>
+             <xsl:when test="name(*[last()])='m:apply'">
+              <xsl:apply-templates select="*[last()]"/>
+             </xsl:when>
+             <xsl:otherwise>
+              <m:mtext>Consider </m:mtext>
+              <xsl:apply-templates select="*[last()]"/>
+             </xsl:otherwise>
+            </xsl:choose>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        <xsl:apply-templates mode="thread" select="*[(last()-2)]"/> 
+        </m:mtable>
+      </xsl:when> 
+      <xsl:when test="$name='rewrite_and_apply'">
+        <m:mtable>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>Rewrite</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[2]/*[2]"/>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <m:mtext>with</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[2]/*[3]"/>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <m:mtext>by</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[2]/*[4]"/>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <m:mtext>in</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[3]"/>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <m:mtext>and apply</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[position()>3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+       </m:mtable>
+      </xsl:when> 
+      <xsl:when test="$name='and_ind'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:choose>
+             <xsl:when test="name(*[2])='m:apply'">
+              <xsl:apply-templates select="*[2]"/>
+             </xsl:when>
+             <xsl:otherwise>
+              <m:mtext>Consider </m:mtext>
+              <xsl:apply-templates select="*[2]"/>
+             </xsl:otherwise>
+            </xsl:choose>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mtext>In particular, we have</m:mtext>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>(</m:mtext>
+            <xsl:apply-templates select="*[3]"/>
+            <m:mtext>)</m:mtext>
+            <xsl:apply-templates select="*[4]"/>
+            </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>(</m:mtext>
+            <xsl:apply-templates select="*[5]"/>
+            <m:mtext>)</m:mtext>
+            <xsl:apply-templates select="*[6]"/>
+            </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="*[7]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+      </xsl:when>
+      <xsl:when test="$name='or_ind'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:choose>
+             <xsl:when test="name(*[2])='m:apply'">
+              <xsl:apply-templates select="*[2]"/>
+             </xsl:when>
+             <xsl:otherwise>
+              <m:mtext>Consider</m:mtext>
+              <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+              <xsl:apply-templates select="*[2]"/>
+             </xsl:otherwise>
+            </xsl:choose>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mtext>We prove</m:mtext>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <xsl:apply-templates select="*[3]"/>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <m:mtext>by cases:</m:mtext>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>*</m:mtext>
+            <xsl:apply-templates select="*[4]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>*</m:mtext>
+            <xsl:apply-templates select="*[5]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+      </xsl:when>
+      <xsl:otherwise>
+       <m:ci>ERROR</m:ci>
+      </xsl:otherwise>
+     </xsl:choose>
+    </m:mrow>
+</xsl:template>
+
+<xsl:template match="*" mode="thread">
+ <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
+ <xsl:choose>
+  <xsl:when test="$name='rw_step'">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>Rewrite</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <m:mtext>with</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="following-sibling::*[position()=1]/*[3]"/>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <m:mtext>by</m:mtext>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="following-sibling::*[position()=1]/*[4]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="."/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+   </xsl:when>
+   <xsl:otherwise>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="following-sibling::*[position()=1]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="."/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+    </xsl:otherwise>
+   </xsl:choose>
+         <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
+</xsl:template>
+
+
+<!-- LAMBDA -->
+
+<xsl:template match="m:lambda">
+    <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
+    <m:mrow helm:xref="{@helm:xref}">
+     <xsl:choose>
+     <xsl:when test="$charlength >= $framewidth">
+      <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+        <m:mtr>
+          <m:mtd>
+            <m:mo color="Red">&#x03bb;</m:mo>
+            <xsl:apply-templates select="m:bvar"/>
+          </m:mtd>
+         </m:mtr>
+       <m:mtr>
+        <m:mtd>
+         <m:mrow>
+          <m:mo>.</m:mo>
+          <xsl:apply-templates select="*[position()=2]"/>
+         </m:mrow>
+        </m:mtd>
+       </m:mtr>
+      </m:mtable>
+     </xsl:when>
+     <xsl:otherwise>
+      <m:mo color="Red">&#x03bb;</m:mo>
+      <xsl:apply-templates select="m:bvar/m:ci"/>
+      <m:mo>:</m:mo>
+      <xsl:apply-templates select="m:bvar/m:type"/>
+      <m:mo>.</m:mo>
+      <xsl:apply-templates select="*[position()=2]"/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </m:mrow>
+</xsl:template>
+
+<!-- *********************************** -->
+<!-- BASE SET OF MATHML CONTENT ELEMENTS -->
+<!-- *********************************** -->
+
+<!-- Logic -->
+
+<xsl:template match = "m:apply[m:eq[1]]">
+ <xsl:variable name="charlength">
+  <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+  <xsl:when test="$charlength >= $framewidth">
+   <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+    <xsl:if test="@helm:xref">
+     <xsl:attribute name="helm:xref">
+      <xsl:value-of select="@helm:xref"/>
+     </xsl:attribute>
+    </xsl:if>    
+    <m:mtr>
+     <m:mtd>
+      <m:mo stretchy="false">(</m:mo>
+      <xsl:apply-templates select="*[position()=2]"/>
+     </m:mtd>
+    </m:mtr>
+    <xsl:for-each select = "*[position()>2]">
+     <m:mtr>
+      <m:mtd>
+       <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+       <m:mo helm:xref="m:in/@helm:xref"> 
+        =
+       </m:mo>
+       <xsl:apply-templates select="."/>
+      </m:mtd>
+     </m:mtr>
+    </xsl:for-each>
+    <m:mtr>
+     <m:mtd>
+      <m:mo stretchy="false">)</m:mo>
+     </m:mtd>
+    </m:mtr>
+   </m:mtable>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:apply-imports/>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<xsl:template match = "m:apply[m:and[1]|m:or[1]
+          |m:geq[1]|m:leq[1]|m:gt[1]|m:lt[1]
+          |m:in[1]|m:intesect[1]|m:union[1]|m:subset[1]
+          |m:prsubset|m:setdiff[1]]">
+ <xsl:variable name="symbol">
+  <xsl:choose>
+   <xsl:when test="m:and[1]">
+    <xsl:value-of select="'wedge'"/>
+   </xsl:when>
+   <xsl:when test="m:or[1]">
+    <xsl:value-of select="'vee'"/>
+   </xsl:when>
+   <xsl:when test="m:geq[1]">
+    <xsl:value-of select="'geq'"/>
+   </xsl:when>
+   <xsl:when test="m:leq[1]">
+    <xsl:value-of select="'leq'"/>
+   </xsl:when>
+   <xsl:when test="m:gt[1]">
+    <xsl:value-of select="'gt'"/>
+   </xsl:when>
+   <xsl:when test="m:lt[1]">
+    <xsl:value-of select="'lt'"/>
+   </xsl:when>
+   <xsl:when test="m:eq[1]">
+    <xsl:value-of select="'Equal'"/>
+   </xsl:when>
+   <xsl:when test="m:in[1]">
+    <xsl:value-of select="'Element'"/>
+   </xsl:when>
+   <xsl:when test="m:subset[1]">
+    <xsl:value-of select="'SubsetEqual'"/>
+   </xsl:when>
+   <xsl:when test="m:prsubset[1]">
+    <xsl:value-of select="'subset'"/>
+   </xsl:when>
+   <xsl:when test="m:intersect[1]">
+    <xsl:value-of select="'Intersection'"/>
+   </xsl:when>
+   <xsl:when test="m:union[1]">
+    <xsl:value-of select="'Union'"/>
+   </xsl:when>
+   <xsl:when test="m:setdiff[1]">
+    <xsl:value-of select="'Backslash'"/>
+   </xsl:when>
+  </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+  <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+  <xsl:when test="$charlength >= $framewidth">
+   <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+    <xsl:if test="@helm:xref">
+     <xsl:attribute name="helm:xref">
+      <xsl:value-of select="@helm:xref"/>
+     </xsl:attribute>
+    </xsl:if>    
+    <m:mtr>
+     <m:mtd>
+      <m:mo stretchy="false">(</m:mo>
+      <xsl:apply-templates select="*[position()=2]"/>
+     </m:mtd>
+    </m:mtr>
+    <xsl:for-each select = "*[position()>2]">
+     <m:mtr>
+      <m:mtd>
+       <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+       <m:mo helm:xref="{*[1]/@helm:xref}"> 
+        <m:mchar name="{$symbol}"/>
+       </m:mo>
+       <xsl:apply-templates select="."/>
+      </m:mtd>
+     </m:mtr>
+    </xsl:for-each>
+    <m:mtr>
+     <m:mtd>
+      <m:mo stretchy="false">)</m:mo>
+     </m:mtd>
+    </m:mtr>
+   </m:mtable>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:apply-imports/>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:set">
+ <xsl:choose>
+  <xsl:when test="count(child::*) = 0">
+   <m:mo> 
+    <m:mchar name="EmptySet"/>
+   </m:mo>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:variable name="charlength">
+    <xsl:apply-templates select="*[1]" mode="charcount"/>
+   </xsl:variable>
+   <xsl:choose>
+    <xsl:when test="$charlength >= $framewidth">
+     <xsl:choose>
+      <xsl:when test="name(*[1]) = 'm:bvar'">
+       <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+        <m:mtr>
+         <m:mtd>
+          <m:mo stretchy="false">{</m:mo>
+          <xsl:apply-templates select="*[position()=1]"/>
+         </m:mtd>
+        </m:mtr>
+        <m:mtr>
+         <m:mtd>
+          <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
+          <m:mo stretchy="false">|</m:mo>
+          <xsl:apply-templates select="m:condition/*[1]"/>
+         </m:mtd>
+        </m:mtr>
+        <m:mtr>
+         <m:mtd>
+          <m:mo stretchy="false">}</m:mo>
+         </m:mtd>
+        </m:mtr>
+       </m:mtable>
+      </xsl:when>
+      <xsl:otherwise>
+       <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+        <m:mtr>
+         <m:mtd>
+          <m:mo stretchy="false">{</m:mo>
+          <xsl:apply-templates select="*[position()=1]"/>
+          <xsl:if test="position() != last()">
+           <mo>,</mo>
+          </xsl:if>
+         </m:mtd>
+        </m:mtr>
+        <xsl:for-each select = "*[position()>2]">
+         <m:mtr>
+          <m:mtd>
+           <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
+           <xsl:apply-templates select="."/>
+           <xsl:if test="position() != last()">
+            <mo>,</mo>
+           </xsl:if>
+          </m:mtd>
+         </m:mtr>
+        </xsl:for-each>
+        <m:mtr>
+         <m:mtd>
+          <m:mo stretchy="false">}</m:mo>
+         </m:mtd>
+        </m:mtr>
+       </m:mtable>
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:apply-imports/>
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>      
+
+<xsl:template match = "m:apply[m:card[1]]">
+ <m:mo stretchy="false">|</m:mo>
+  <xsl:apply-templates select="*[2]"/>
+ <m:mo stretchy="false">|</m:mo>
+</xsl:template>
+
+<!-- *********************************** -->
+<!--          PROOF ELEMENTS             -->
+<!-- *********************************** -->
+
+
+
+<!--**********************-->
+<!--       COUNTING       -->
+<!--**********************-->
+
+<xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
+ |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
+ |m:plus|m:minus|m:times" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/> 
+    <xsl:choose>
+    <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
+     <xsl:variable name="siblength">
+      <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
+       <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
+      </xsl:apply-templates>
+     </xsl:variable>
+     <xsl:choose>
+     <xsl:when test="string($siblength) = &quot;&quot;">
+      <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:value-of select="number($siblength)"/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
+    </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template match="m:ci|m:csymbol" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/> 
+<xsl:param name="nosibling" select="0"/>
+    <xsl:choose>
+    <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
+     <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+     <xsl:choose>
+     <xsl:when test="string($siblength) = &quot;&quot;">
+      <xsl:value-of select="$incurrent_length + string-length()"/>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:value-of select="number($siblength)"/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:value-of select="$incurrent_length + string-length()"/>
+    </xsl:otherwise>
+    </xsl:choose>
+</xsl:template> 
+
+<xsl:template match="*" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:choose>
+  <xsl:when test="count(child::*) = 0">
+   <xsl:value-of select="$incurrent_length"/>
+  </xsl:when>
+  <xsl:otherwise>
+    <xsl:variable name="childlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/><xsl:with-param name="nosibling" select="0"/></xsl:apply-templates></xsl:variable>
+    <xsl:choose>
+    <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
+     <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$childlength"/></xsl:apply-templates></xsl:variable>
+     <xsl:choose>
+     <xsl:when test="string($siblength) = &quot;&quot;">
+      <xsl:value-of select="number($childlength)"/>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:value-of select="number($siblength)"/>
+     </xsl:otherwise>
+     </xsl:choose>>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:value-of select="number($childlength)"/>
+    </xsl:otherwise>
+    </xsl:choose>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet> 
+