]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/content.xsl
This commit was manufactured by cvs2svn to create branch
[helm.git] / helm / style / content.xsl
index 5aafef63f6bfb347b801b74fd3d35dbe2acb0916..9aea96b3c5fa41b239b1a5c3c82881ca42c90f9b 100644 (file)
@@ -37,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" 
@@ -60,63 +62,96 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
 
 <!-- CIC TERMS -->
 
+
 <xsl:template match="LAMBDA" mode="pure">
-    <m:lambda helm:xref="{@id}">
-     <m:bvar>
-      <m:ci>
-       <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"/>
-      </m:type>
-     </m:bvar>
-     <xsl:apply-templates select="target/*[1]" mode="noannot"/>
-    </m:lambda>
+       <xsl:apply-templates select="*[1]" mode="lambda"/>
+</xsl:template>
+
+<xsl:template match="decl" mode="lambda">
+       <m:lambda helm:xref="{@id}">
+        <m:bvar>
+         <m:ci>
+          <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>
+         <m:type>
+          <xsl:apply-templates select="*[1]" mode="noannot"/>
+          </m:type>
+        </m:bvar>
+       <xsl:apply-templates select="following-sibling::*[1]" mode="lambda"/>
+       </m:lambda>
+</xsl:template>
+
+
+<xsl:template match="target" mode="lambda">
+       <xsl:apply-templates select="*[1]" mode="noannot"/>
 </xsl:template>
 
+
 <xsl:template match="LETIN" mode="pure">
+       <xsl:apply-templates select="*[1]" mode="letin"/>
+</xsl:template>
+
+
+<xsl:template match="def" mode="letin">        
     <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>
+       <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>
      </m:bvar>
      <xsl:apply-templates select="*[1]" mode="noannot"/>
-     <xsl:apply-templates select="letintarget/*[1]" mode="noannot"/>
+     <xsl:apply-templates select="following-sibling::*[1]" mode="letin"/>
     </m:apply>
 </xsl:template>
 
+
+<xsl:template match="target" mode="letin">
+       <xsl:apply-templates select="*[1]" mode="noannot"/>
+</xsl:template>
+
+
 <xsl:template match="PROD" mode="pure">
-    <m:apply helm:xref="{@id}">
-     <xsl:choose>
-     <xsl:when test="string(target/@binder)= &quot;&quot;">
-      <m:csymbol>arrow</m:csymbol>
-      <xsl:apply-templates select="source/*[1]" mode="noannot"/>
-     </xsl:when>
-     <xsl:otherwise>
+       <xsl:apply-templates select="*[1]" mode="prod"/>
+</xsl:template>
+
+
+<xsl:template match="decl" mode="prod">
+     <m:apply helm:xref="{@id}">
       <xsl:choose>
-       <xsl:when test="@type = 'Prop'">
-        <m:csymbol>forall</m:csymbol>
+       <xsl:when test="string(@binder)= &quot;&quot;">
+        <m:csymbol>arrow</m:csymbol>
+        <xsl:apply-templates select="*[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:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
+         </m:ci>
+         <m:type>
+          <xsl:apply-templates select="*[1]" mode="noannot"/>
+         </m:type>
+        </m:bvar>
        </xsl:otherwise>
       </xsl:choose>
-       <m:bvar>
-        <m:ci>
-         <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"/>
-        </m:type>
-       </m:bvar>
-     </xsl:otherwise>
-     </xsl:choose>
-     <xsl:apply-templates select="target/*[1]" mode="noannot"/>
-    </m:apply>
+     <xsl:apply-templates select="following-sibling::*[1]" mode="prod"/> 
+     </m:apply>
+</xsl:template>
+
+        
+<xsl:template match="target" mode="prod">
+       <xsl:apply-templates select="*[1]" mode="noannot"/>
 </xsl:template>
 
+
 <xsl:template match="CAST" mode="pure">
     <m:apply helm:xref="{@id}">
      <m:csymbol>cast</m:csymbol>
@@ -124,12 +159,14 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
     </m:apply>
 </xsl:template>
 
+
 <xsl:template match="REL" mode="pure">
     <m:ci helm:xref="{@id}">
      <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>
 
+
 <xsl:template match="SORT" mode="pure">
     <m:apply helm:xref="{@id}">
      <m:csymbol>
@@ -138,6 +175,7 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
     </m:apply>
 </xsl:template>
 
+
 <xsl:template match="APPLY" mode="pure">
       <m:apply helm:xref="{@id}">
        <m:csymbol>app</m:csymbol>
@@ -145,74 +183,125 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
       </m:apply>
 </xsl:template>
 
+
+<!-- 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: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>
+     <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:call-template name="name_of_uri_bis">
+      <xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:with-param></xsl:call-template>
     </m:ci>
 </xsl:template>
 
+
 <xsl:template match="META" mode="pure">
-    <m:ci helm:xref="{@id}">
-     <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@no"/></xsl:with-param></xsl:call-template>
+   <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="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>
-     <!-- <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:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/></xsl:with-param></xsl:call-template>
+     <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:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/></xsl:with-param></xsl:call-template>
+     <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:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document(concat(string($absPath),$Turi))/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="document(concat(string($absPath),$Turi))/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>
-      <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>
 
+
 <xsl:template match="FIX" mode="pure">
     <m:apply helm:xref="{@id}">
      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
@@ -222,6 +311,7 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
     </m:apply>
 </xsl:template>
 
+
 <xsl:template match="COFIX" mode="pure">
    <m:apply helm:xref="{@id}">
      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
@@ -231,6 +321,17 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
     </m:apply>
 </xsl:template>
 
+<xsl:template match="instantiate" mode="pure">
+       <m:apply helm:xref="{@id}">
+        <m:csymbol>inst</m:csymbol>
+        <xsl:apply-templates mode="noannot" select="*[1]" />
+        <xsl:for-each select="arg">
+         <m:ci><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:apply-templates mode ="noannot" select="*[1]" />
+        </xsl:for-each>
+       </m:apply>
+</xsl:template>
+
 <!-- ELEMENTS OF CIC TERMS -->
 
 <xsl:template match="FixFunction" mode="pure">
@@ -241,6 +342,7 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
 </xsl:template>
 
+
 <xsl:template match="CofixFunction" mode="pure">
     <m:bvar>
      <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>
@@ -250,8 +352,3 @@ Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
 </xsl:template>
 
 </xsl:stylesheet>
-
-
-
-
-