]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/mmlextension.xsl
Bug nat_double_ind solved.
[helm.git] / helm / style / mmlextension.xsl
index d467b77af79d18b15e7129e780ba83a35019c703..67859db656d243d62babbc0a06ecc6dea80cf792 100644 (file)
@@ -1,5 +1,29 @@
 <?xml version="1.0"?>
 
+<!-- Copyright (C) 2000, HELM Team                                     -->
+<!--                                                                   -->
+<!-- This file is part of HELM, an Hypertextual, Electronic            -->
+<!-- Library of Mathematics, developed at the Computer Science         -->
+<!-- Department, University of Bologna, Italy.                         -->
+<!--                                                                   -->
+<!-- HELM is free software; you can redistribute it and/or             -->
+<!-- modify it under the terms of the GNU General Public License       -->
+<!-- as published by the Free Software Foundation; either version 2    -->
+<!-- of the License, or (at your option) any later version.            -->
+<!--                                                                   -->
+<!-- HELM is distributed in the hope that it will be useful,           -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of    -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     -->
+<!-- GNU General Public License for more details.                      -->
+<!--                                                                   -->
+<!-- You should have received a copy of the GNU General Public License -->
+<!-- along with HELM; if not, write to the Free Software               -->
+<!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston,            -->
+<!-- MA  02111-1307, USA.                                              -->
+<!--                                                                   -->
+<!-- For details, see the HELM World-Wide-Web page,                    -->
+<!-- http://cs.unibo.it/helm/.                                         -->
+
 <!--***********************************************************************--> 
 <!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
 <!-- First draft: February 19 2000, Andrea Asperti, Irene Schena           -->
@@ -13,6 +37,7 @@
                               xmlns:helm="http://www.cs.unibo.it/helm">
 
 <xsl:import href="mml2mmlv1_0.xsl"/>
+<xsl:import href="mmltheoryextension.xsl"/>
 
 <!--***********************************************************************-->
 <!-- Parameter affecting line-breaking                                     -->
@@ -33,7 +58,9 @@
 <!--**********************-->
 
 <xsl:template match="/">
+ <!--
  <xsl:processing-instruction name="cocoon-format">type="text/xhtml"</xsl:processing-instruction>
+ -->
  <xsl:apply-templates select="*"/>
 </xsl:template>
 
         </m:mrow>
        </m:mtd>
       </m:mtr>
+      <xsl:if test="name(*[1])='body'">
+       <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>
+      </xsl:if>
      </m:mtable>
     </m:math>
 </xsl:template>
 <!-- CSYMBOL -->
 
 <xsl:template match="m:apply[m:csymbol]">
+<xsl:param name="nopar" select="0"/>
     <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:attribute name="helm:xref"><xsl:value-of select="@helm:xref"/></xsl:attribute>
      </xsl:if>
      <xsl:choose>
+      <xsl:when test="$name='forall'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+            <m:mo mathcolor="Blue"><m:mchar name="ForAll"/></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 mathcolor="Blue"><m:mchar name="ForAll"/></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='let_in'">
+       <xsl:choose>
+       <xsl:when test="$charlength >= $framewidth">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+            <m:mo>LET</m:mo>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <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:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mo>IN</m:mo>
+            <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+            <xsl:apply-templates select="*[position()=4]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mo>LET</m:mo>
+        <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+        <xsl:apply-templates select="m:bvar/m:ci"/>
+        <m:mo>=</m:mo>
+        <xsl:apply-templates select="*[position()=3]"/>
+        <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="*[position()=4]"/>
+       </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when> 
       <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>
+            <m:mo mathcolor="Blue">&#x03a0;</m:mo>
             <xsl:apply-templates select="m:bvar"/>
           </m:mtd>
          </m:mtr>
         </m:mtable>
        </xsl:when>
        <xsl:otherwise>
-        <m:mo color="Blue">&#x03a0;</m:mo>
+        <m:mo mathcolor="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:mtr>
           <m:mtd>
            <m:mrow>
-            <m:mo stretchy="false">(</m:mo>
+            <xsl:if test="$nopar=0">
+             <m:mo stretchy="false">(</m:mo>
+            </xsl:if>
             <xsl:apply-templates select="*[position()=2]"/>
            </m:mrow>
           </m:mtd>
          <m:mtr>
           <m:mtd>
            <m:mrow>
-            <m:mo color="Blue">&#x2192;</m:mo>
-            <xsl:apply-templates select="*[position()=3]"/>
+            <m:mo mathmathcolor="Blue">&#x2192;</m:mo>
+            <xsl:choose>
+            <xsl:when test="*[position()=3]/m:csymbol">
+             <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
+             <xsl:choose>
+             <xsl:when test="$nextp='arrow'">
+              <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
+             </xsl:when>
+             <xsl:otherwise>
+              <xsl:apply-templates select="*[position()=3]"/>
+             </xsl:otherwise>
+             </xsl:choose>
+            </xsl:when>
+            <xsl:otherwise>
+             <xsl:apply-templates select="*[position()=3]"/>
+            </xsl:otherwise>
+            </xsl:choose>
            </m:mrow>
           </m:mtd>
          </m:mtr>
+         <xsl:if test="$nopar=0">
          <m:mtr>
           <m:mtd>
            <m:mrow>
            </m:mrow>
           </m:mtd>
          </m:mtr>
+         </xsl:if>
         </m:mtable>
        </xsl:when>
        <xsl:otherwise>
-        <m:mo stretchy="false">(</m:mo>
+        <xsl:if test="$nopar=0">
+         <m:mo stretchy="false">(</m:mo>
+        </xsl:if>
         <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>
+        <m:mo mathcolor="Blue">&#x2192;</m:mo>
+        <xsl:choose>
+        <xsl:when test="*[position()=3]/m:csymbol">
+         <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
+         <xsl:choose>
+         <xsl:when test="$nextp='arrow'">
+          <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
+         </xsl:when>
+         <xsl:otherwise>
+          <xsl:apply-templates select="*[position()=3]"/>
+         </xsl:otherwise>
+         </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+         <xsl:apply-templates select="*[position()=3]"/>
+        </xsl:otherwise>
+        </xsl:choose>
+        <xsl:if test="$nopar=0">
+         <m:mo stretchy="false">)</m:mo>
+        </xsl:if>
        </xsl:otherwise>
        </xsl:choose>
       </xsl:when>
          <m:mtr>
           <m:mtd>
            <m:mrow>
-            <m:mo color="#b03060">:></m:mo>
+            <m:mo mathcolor="Maroon">:></m:mo>
             <xsl:apply-templates select="*[position()=3]"/>
            </m:mrow>
           </m:mtd>
        <xsl:otherwise>
         <m:mo stretchy="false">(</m:mo>
         <xsl:apply-templates select="*[position()=2]"/>
-        <m:mo color="#b03060">:></m:mo>
+        <m:mo mathcolor="Maroon">:></m:mo>
         <xsl:apply-templates select="*[position()=3]"/>
         <m:mo stretchy="false">)</m:mo>
        </xsl:otherwise>
             <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
             <xsl:apply-templates select="."/>
             <xsl:if test="$framewidth > $charlength">
-             <m:mo color="Green">&#x21d2;</m:mo>
+             <m:mo mathcolor="Green">&#x21d2;</m:mo>
              <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
             </xsl:if>
            </m:mrow>
           <m:mtd>
            <m:mrow>
             <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>  
-            <m:mo color="Green">&#x21d2;</m:mo>
+            <m:mo mathcolor="Green">&#x21d2;</m:mo>
             <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
            </m:mrow>
           </m:mtd>
          </xsl:when> 
          </xsl:choose>
          <xsl:apply-templates select="."/>
-         <m:mo color="Green">&#x21d2;</m:mo>
+         <m:mo mathcolor="Green">&#x21d2;</m:mo>
          <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
         </xsl:for-each>
         <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
          <m:mtr>
           <m:mtd>
            <m:mrow>
-            <m:mtext color="#b03060">we proved </m:mtext>
+            <m:mtext mathcolor="Maroon">we proved </m:mtext>
             <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
             <xsl:apply-templates select="*[position()=3]"/>
            </m:mrow>
          </m:mtr>
         </m:mtable>
       </xsl:when>
+      <xsl:when test="$name='letin1'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="*[2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="*[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')]"> -->
        <m:mtext>) </m:mtext>
        <xsl:apply-templates select="*[3]"/>
       </xsl:when>
-      <xsl:when test="$name='thread'">
+      <xsl:when test="$name='rw_step'">
         <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 test="name(*[2])='m:apply'">
+              <xsl:apply-templates select="*[2]"/>
              </xsl:when>
              <xsl:otherwise>
-              <m:mtext>Consider </m:mtext>
-              <xsl:apply-templates select="*[last()]"/>
+              <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>
-        <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]"/>
+            <xsl:apply-templates select="*[3]"/>
            <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]"/>
+            <xsl:apply-templates select="*[4]"/>
             <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>
+            <xsl:apply-templates select="*[5]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+      </xsl:when>
+      <!-- not existing any more
+      <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>
+              <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+              <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 align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <xsl:apply-templates select="*[2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>Then apply it to</m:mtext>
             <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
-            <xsl:apply-templates select="*[position()>3]"/>
+            <xsl:apply-templates select="*[position()>2]"/>
            </m:mrow>
           </m:mtd>
          </m:mtr>
        </m:mtable>
-      </xsl:when> 
+      </xsl:when>
+      <!-- NAT_IND -->
+      <xsl:when test="$name='nat_ind'">
+        <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+         <m:mtr>
+          <m:mtd>
+           <m:mtext>By induction</m:mtext>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>base case:</m:mtext>
+            <xsl:apply-templates select="*[2]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+         <m:mtr>
+          <m:mtd>
+           <m:mrow>
+            <m:mtext>inductive case:</m:mtext>
+            <xsl:apply-templates select="*[3]"/>
+           </m:mrow>
+          </m:mtd>
+         </m:mtr>
+        </m:mtable>
+      </xsl:when>
+      <!-- AND_IND -->
       <xsl:when test="$name='and_ind'">
         <m:mtable align="baseline 1" equalrows="false" columnalign="left">
          <m:mtr>
               <xsl:apply-templates select="*[2]"/>
              </xsl:when>
              <xsl:otherwise>
-              <m:mtext>Consider </m:mtext>
+              <m:mtext>Consider</m:mtext>
+              <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
               <xsl:apply-templates select="*[2]"/>
              </xsl:otherwise>
             </xsl:choose>
          </m:mtr>
         </m:mtable>
       </xsl:when>
+      <xsl:when test="$name='ex_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>Let</m:mtext>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <xsl:apply-templates select="*[3]"/>
+           <m:mtext>:</m:mtext>
+           <xsl:apply-templates select="*[4]"/>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <m:mtext>such that</m:mtext>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <m:mtext>(</m:mtext>
+            <xsl:apply-templates select="*[5]"/>
+           <m:mtext>)</m:mtext>
+           <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+           <xsl:apply-templates select="*[6]"/>
+          </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:otherwise>
        <m:ci>ERROR</m:ci>
       </xsl:otherwise>
     </m:mrow>
 </xsl:template>
 
+<!-- Il modo Thread non esiste piu' 
 <xsl:template match="*" mode="thread">
  <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
  <xsl:choose>
          <m:mtr>
           <m:mtd>
            <m:mrow>
-            <m:mtext color="#b03060">we get</m:mtext>
+            <m:mtext mathcolor="Maroon">we get</m:mtext>
             <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
             <xsl:apply-templates select="."/>
            </m:mrow>
          <m:mtr>
           <m:mtd>
            <m:mrow>
-            <m:mtext color="#b03060">we get</m:mtext>
+            <m:mtext mathcolor="Maroon">we get</m:mtext>
             <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
             <xsl:apply-templates select="."/>
            </m:mrow>
    </xsl:choose>
          <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
 </xsl:template>
-
+-->
 
 <!-- LAMBDA -->
 
       <m:mtable align="baseline 1" equalrows="false" columnalign="left">
         <m:mtr>
           <m:mtd>
-            <m:mo color="Red">&#x03bb;</m:mo>
+            <m:mo mathcolor="Red">&#x03bb;</m:mo>
             <xsl:apply-templates select="m:bvar"/>
           </m:mtd>
          </m:mtr>
       </m:mtable>
      </xsl:when>
      <xsl:otherwise>
-      <m:mo color="Red">&#x03bb;</m:mo>
+      <m:mo mathcolor="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:mtr>
       <m:mtd>
        <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
-       <m:mo helm:xref="m:in/@helm:xref"> 
-        =
-       </m:mo>
+       <m:mo helm:xref="{m:in/@helm:xref}">=</m:mo>
        <xsl:apply-templates select="."/>
       </m:mtd>
      </m:mtr>
      <xsl:otherwise>
       <xsl:value-of select="number($siblength)"/>
      </xsl:otherwise>
-     </xsl:choose>>
+     </xsl:choose>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="number($childlength)"/>
 
 </xsl:stylesheet> 
 
+
+