]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/content.xsl
Initial revision
[helm.git] / helm / style / content.xsl
index ae4a1a812c27c94909f768f3a1e42f42296ba423..e60a85051453d42bcc491199c66231210ffe0776 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/.                                         -->
+
 <!--******************************************************************--> 
 <!-- XSLT version 0.1 of CIC objects to MathML content:               -->
 <!-- First draft: February 14 2000, Andrea Asperti, Irene Schena      -->
@@ -13,6 +37,8 @@
                               xmlns:helm="http://www.cs.unibo.it/helm">
 
 <xsl:include href="params.xsl"/>
+<!-- adesso sono preprocessate -->
+<!-- <xsl:include href="coercions.xsl"/> -->
 
 <!--<xsl:output
            method="xml" 
            media-type="text/mathml" /> -->
 
 <!-- DA FARE: 
-1)risolvere nella fase di pre-processing le uri relative, settando l'attributo
+1)risolvere nella fase di pre-processing le uri relative delle var, settando 
+l'attributo
 definitionURL dell'oggetto corrispondente (alcuni punteranno a nulla! -quelli 
 che non hanno il file di definizione corrispondente-); [le uri assolute hanno
 la forma cic:/.../ in definitionURL e questo schema di uri verra' risolto da
 Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
-2)aggiungere nei file xml gli ID, affinche' nello stylesheet si setti
-l'attributo xref di ogni oggetto per puntare (tramite ID) al suo corrispondente
-della rappresentazione interna. 
 -->
 
-<!--******************************************************************-->
-<!-- Variable containing the absolute path of the CIC file            -->
-<!--******************************************************************-->
-
-<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
 
 <!-- CIC TERMS -->
 
@@ -47,7 +66,7 @@ della rappresentazione interna.
     <m:lambda helm:xref="{@id}">
      <m:bvar>
       <m:ci>
-       <xsl:value-of select="target/@binder"/>
+       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
       </m:ci>
       <m:type>
        <xsl:apply-templates select="source/*[1]" mode="noannot"/>
@@ -57,6 +76,19 @@ della rappresentazione interna.
     </m:lambda>
 </xsl:template>
 
+<xsl:template match="LETIN" mode="pure">
+    <m:apply helm:xref="{@id}">
+     <m:csymbol>let_in</m:csymbol>
+     <m:bvar>
+      <m:ci>
+       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="letintarget/@binder"/></xsl:with-param></xsl:call-template>
+      </m:ci>
+     </m:bvar>
+     <xsl:apply-templates select="*[1]" mode="noannot"/>
+     <xsl:apply-templates select="letintarget/*[1]" mode="noannot"/>
+    </m:apply>
+</xsl:template>
+
 <xsl:template match="PROD" mode="pure">
     <m:apply helm:xref="{@id}">
      <xsl:choose>
@@ -65,10 +97,17 @@ della rappresentazione interna.
       <xsl:apply-templates select="source/*[1]" mode="noannot"/>
      </xsl:when>
      <xsl:otherwise>
-      <m:csymbol>prod</m:csymbol>
+      <xsl:choose>
+       <xsl:when test="@type = 'Prop'">
+        <m:csymbol>forall</m:csymbol>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:csymbol>prod</m:csymbol>
+       </xsl:otherwise>
+      </xsl:choose>
        <m:bvar>
         <m:ci>
-         <xsl:value-of select="target/@binder"/>
+         <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
         </m:ci>
         <m:type>
          <xsl:apply-templates select="source/*[1]" mode="noannot"/>
@@ -89,7 +128,7 @@ della rappresentazione interna.
 
 <xsl:template match="REL" mode="pure">
     <m:ci helm:xref="{@id}">
-     <xsl:value-of select="@binder"/>
+     <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
     </m:ci>
 </xsl:template>
 
@@ -102,136 +141,120 @@ della rappresentazione interna.
 </xsl:template>
 
 <xsl:template match="APPLY" mode="pure">
-   <xsl:choose>
-    <!-- <xsl:when test="//ALLTYPES and boolean(key('typeid',*/@id))"> -->
-    <!-- start looking for subproofs -->
-    <xsl:when test="((*/@id) = (//ALLTYPES/TYPE/@id))"> 
-     <m:apply helm:xref="{@id}">
-      <m:csymbol>letin</m:csymbol>
-      <!-- <xsl:for-each select="*[boolean(key('typeid',@id))]"> -->
-      <!-- first process all subproofs (let-in) -->
-      <xsl:for-each select="*[@id = (//ALLTYPES/TYPE/@id)]">
-       <m:apply>
-        <m:csymbol>let</m:csymbol>
-        <m:ci><xsl:value-of select="concat('h',position())"/></m:ci>
-        <xsl:apply-templates mode="noannot" select="."/>
-       </m:apply>
-      </xsl:for-each>
-      <!-- now re-process the application in mode appflat -->
-      <xsl:apply-templates mode="appflat" select="."/> 
-     </m:apply>
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:apply-templates mode="appflat" select="."/>
-    </xsl:otherwise>
-   </xsl:choose>
-</xsl:template>
-
-<xsl:template match="APPLY" mode="appflat">
       <m:apply helm:xref="{@id}">
        <m:csymbol>app</m:csymbol>
-       <!-- mode flat looks for siblings: call with the first child -->
-       <xsl:apply-templates mode="flat" select="*[1]"/>
+       <xsl:apply-templates mode="noannot" select="*"/>
       </m:apply>
 </xsl:template>
 
-<xsl:template match="*" mode="flat">
- <xsl:param name="n" select="1"/>
- <xsl:choose>
-  <xsl:when test="@id">
-   <xsl:variable name="id" select="@id"/>
-   <xsl:choose>
-    <!-- <xsl:when test="key('typeid',@id)"> -->
-    <xsl:when test="//ALLTYPES/TYPE[@id=$id]">
-     <m:ci>
-      <xsl:value-of select="concat('h',$n)"/>
-     </m:ci>
-     <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
-      <xsl:with-param name="n" select="$n+1"/>
-     </xsl:apply-templates>
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:apply-templates mode="pure" select="."/>
-     <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
-      <xsl:with-param name="n" select="$n"/>
-     </xsl:apply-templates>
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:apply-templates mode="pure" select="."/>
-   <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
-    <xsl:with-param name="n" select="$n"/>
-   </xsl:apply-templates>
-  </xsl:otherwise>
- </xsl:choose>
+<!-- Gestione senza pre-processing -->
+<!-- 
+<xsl:template match="APPLY" mode="pure">
+     <xsl:apply-templates mode="coercion" select="."/>
 </xsl:template>
 
+<xsl:template match="APPLY" mode="no_coercion">
+      <m:apply helm:xref="{@id}">
+       <m:csymbol>app</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*"/>
+      </m:apply>
+</xsl:template>
+-->
+
 <xsl:template match="VAR" mode="pure">
     <m:ci helm:xref="{@id}">
-     <xsl:value-of select="substring-after(@relUri,&quot;,&quot;)"/>
+     <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="substring-after(@relUri,&quot;,&quot;)"/></xsl:with-param></xsl:call-template>
     </m:ci>
 </xsl:template>
 
 <xsl:template match="META" mode="pure">
-    <m:ci helm:xref="{@id}">
-     <xsl:value-of select="@no"/>
+   <m:apply helm:xref="{@id}">
+    <m:csymbol>meta</m:csymbol>
+    <m:ci>
+     <xsl:call-template name="insert_subscript">
+      <xsl:with-param name="node_value">
+       <xsl:text>?</xsl:text>
+       <xsl:value-of select="@no"/>
+      </xsl:with-param>
+     </xsl:call-template>
     </m:ci>
+    <xsl:for-each select="substitution">
+     <xsl:choose>
+      <xsl:when test="*[1]">
+       <xsl:apply-templates select="*[1]" mode="noannot"/>
+      </xsl:when>
+      <xsl:otherwise>
+       <m:ci>_</m:ci>
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:for-each>
+   </m:apply>
 </xsl:template>
 
 <xsl:template match="CONST" mode="pure">
-    <m:ci definitionURL="{@uri}" helm:xref="{@id}">
-     <xsl:call-template name="name_of_uri">
-      <xsl:with-param name="uri" select="@uri"/>
-     </xsl:call-template>
-     <!-- <xsl:value-of select="document(concat(string($absPath),@uri))/*/@name"/> -->
-    </m:ci>
+   <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+      <xsl:call-template name="insert_subscript">
+         <xsl:with-param name="node_value">
+            <xsl:call-template name="name_of_uri">
+               <xsl:with-param name="uri" select="@uri"/>
+            </xsl:call-template>
+         </xsl:with-param>
+      </xsl:call-template>
+   </m:ci>
 </xsl:template>
 
 <xsl:template match="MUTIND" mode="pure">
     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+     <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
      <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
-     <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/>
+     <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document($InductiveTypeUrl)/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/></xsl:with-param></xsl:call-template>
     </m:ci>
 </xsl:template>
 
 <xsl:template match="MUTCONSTRUCT" mode="pure">
     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+     <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
      <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
      <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
-     <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/>
+     <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document($InductiveTypeUrl)/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/></xsl:with-param></xsl:call-template>
     </m:ci>
 </xsl:template>
 
 <xsl:template match="MUTCASE" mode="pure">
     <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
     <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
+     <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$Turi"/></xsl:call-template></xsl:variable>
+    <xsl:variable name="InductiveTypeDoc" select="document($InductiveTypeUrl)"/>
     <m:apply helm:xref="{@id}">
      <m:csymbol>mutcase</m:csymbol>
      <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
      <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
-     <xsl:variable name="nop"><xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/@noParams"/></xsl:variable>
-     <xsl:for-each select="pattern">
-      <xsl:variable name="pos" select="position()"/>
-      <xsl:variable name="nopar"><xsl:apply-templates select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/*[1]" mode="counting"><xsl:with-param name="noparams" select="$nop"/></xsl:apply-templates></xsl:variable>
-      <xsl:choose>
-      <xsl:when test="$nopar = 0">
-       <m:ci>
-        <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
-       </m:ci>
-      </xsl:when>
-      <xsl:otherwise>
-       <m:apply>
-        <m:csymbol>app</m:csymbol>
-        <m:ci>
-         <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
-        </m:ci>
-        <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
-        </m:apply>
-       </xsl:otherwise>
-       </xsl:choose>
-      <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="target" select="1"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
-     </xsl:for-each> 
+     <xsl:variable name="nop"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/@noParams"/></xsl:variable>
+     <m:piecewise>
+      <xsl:for-each select="pattern">
+       <xsl:variable name="pos" select="position()"/>
+       <xsl:variable name="nopar"><xsl:apply-templates select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/*[1]" mode="counting"><xsl:with-param name="noparams" select="$nop"/></xsl:apply-templates></xsl:variable>
+       <m:piece>
+        <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="target" select="1"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
+        <xsl:choose>
+        <xsl:when test="$nopar = 0">
+         <m:ci>
+          <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/></xsl:with-param></xsl:call-template>
+         </m:ci>
+        </xsl:when>
+        <xsl:otherwise>
+         <m:apply>
+          <m:csymbol>app</m:csymbol>
+          <m:ci>
+           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/></xsl:with-param></xsl:call-template>
+          </m:ci>
+          <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
+          </m:apply>
+         </xsl:otherwise>
+         </xsl:choose>
+        </m:piece>
+      </xsl:for-each>
+     </m:piecewise> 
     </m:apply>
 </xsl:template>
 
@@ -239,7 +262,7 @@ della rappresentazione interna.
     <m:apply helm:xref="{@id}">
      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
      <m:csymbol>fix</m:csymbol>
-     <m:ci><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></m:ci>
+     <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></xsl:with-param></xsl:call-template></m:ci>
      <xsl:apply-templates mode="pure" select="*"/>
     </m:apply>
 </xsl:template>
@@ -248,7 +271,7 @@ della rappresentazione interna.
    <m:apply helm:xref="{@id}">
      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
      <m:csymbol>cofix</m:csymbol>
-     <m:ci><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></m:ci>
+     <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></xsl:with-param></xsl:call-template></m:ci>
      <xsl:apply-templates mode="pure" select="*"/>
     </m:apply>
 </xsl:template>
@@ -257,7 +280,7 @@ della rappresentazione interna.
 
 <xsl:template match="FixFunction" mode="pure">
     <m:bvar>
-     <m:ci><xsl:value-of select="@name"/></m:ci>
+     <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template></m:ci>
      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
     </m:bvar> 
     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
@@ -265,7 +288,7 @@ della rappresentazione interna.
 
 <xsl:template match="CofixFunction" mode="pure">
     <m:bvar>
-     <m:ci><xsl:value-of select="@name"/></m:ci>
+     <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template></m:ci>
      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
     </m:bvar> 
     <xsl:apply-templates select="body/*[1]" mode="noannot"/>