]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/arith.xsl
Modified Files:
[helm.git] / helm / style / arith.xsl
index e436df28c5cc6a72c62b40a765a803f88a19df8f..5c46c390f5187579052df6a58800ddd2b1350163 100644 (file)
 
 <!-- ************************** ARITHMETICS ****************************** -->
 
+<!-- S and O -->
+<xsl:template match="APPLY[*[position()=1 and name()='MUTCONSTRUCT' and @uri='cic:/Coq/Init/Datatypes/nat.ind' and @noConstr='2'] and count(*)=2]" mode="pure">
+   <xsl:apply-templates select="*[2]" mode="succ">
+    <xsl:with-param name="n" select="1"/>
+    <xsl:with-param name="iden" select="@id"/>
+   </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="*" mode="succ">
+ <xsl:param name="n" select="0"/>
+ <xsl:param name="iden" select="''"/>
+ <xsl:choose>
+  <xsl:when test="name()='APPLY' and *[position()=1 and name()='MUTCONSTRUCT'
+and @uri='cic:/Coq/Init/Datatypes/nat.ind' and @noConstr='2']">
+   <xsl:apply-templates select="*[2]" mode="succ">
+    <xsl:with-param name="n" select="$n +1"/>
+    <xsl:with-param name="iden" select="$iden"/>
+   </xsl:apply-templates>
+  </xsl:when>
+  <xsl:when test="name()='MUTCONSTRUCT' and @uri='cic:/Coq/Init/Datatypes/nat.ind' and @noConstr='1'">
+   <m:cn helm:xref="{$iden}"><xsl:value-of select="$n"/></m:cn>
+  </xsl:when>
+  <xsl:otherwise>
+   <m:apply helm:xref="{$iden}">
+    <m:plus/>
+    <m:cn><xsl:value-of select="$n"/></m:cn>
+    <xsl:apply-templates select="." mode="pure"/>
+   </m:apply>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
 <xsl:template match="APPLY[MUTIND/@uri='cic:/Coq/Init/Peano/le.ind']" mode="pure">
    <xsl:call-template name="mk-mml-op-noannot">
       <xsl:with-param name="arity" select="2"/>
 
 <!-- POS, NEG e ZERO -->
 
-<xsl:template match="APPLY[MUTCONSTRUCT[position()=1 and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/Z.ind' and @noConstr='2'] and count(*)=2]" mode="pure">
+<xsl:template match="APPLY[*[position()=1 and name()='MUTCONSTRUCT' and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/Z.ind' and @noConstr='2'] and count(*)=2]" mode="pure">
    <xsl:apply-templates select="*[2]" mode="Zpositive">
     <xsl:with-param name="base" select="0"/>
     <xsl:with-param name="exp" select="1"/>
    </xsl:apply-templates>
 </xsl:template>
  
-<xsl:template match="APPLY[MUTCONSTRUCT[position()=1 and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/Z.ind' and @noConstr='3'] and count(*)=2]" mode="pure">
+<xsl:template match="APPLY[*[position()=1 and name()='MUTCONSTRUCT' and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/Z.ind' and @noConstr='3'] and count(*)=2]" mode="pure">
    <m:apply helm:xref="{@id}">
     <m:minus definitionURL="{*[1]/@uri}" helm:xref="{*[1]/@id}"/>
     <xsl:apply-templates select="*[2]" mode="Zpositive">
 
 <!-- prova di notazione per positive -->
 
-<xsl:template match="APPLY[MUTCONSTRUCT[position()=1 and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind']]" mode="pure">
+<xsl:template match="APPLY[*[position()=1 and name()='MUTCONSTRUCT' and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind']]" mode="pure">
    <xsl:apply-templates select="." mode="Zpositive">
     <xsl:with-param name="base" select="0"/>
     <xsl:with-param name="exp" select="1"/>
    </xsl:apply-templates>
 </xsl:template>
 
+<xsl:template match="MUTCONSTRUCT[@uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind' and @noConstr='3']" mode="pure">
+ <m:ci definitionURL="{@uri}" helm:xref="{@id}">1</m:ci>
+</xsl:template> 
+
 <xsl:template match="*" mode="Zpositive">
  <xsl:param name="base" select="0"/>
  <xsl:param name="exp" select="1"/>
  <xsl:param name="iden" select="''"/>
  <xsl:choose>
-  <xsl:when test="name()='APPLY' and MUTCONSTRUCT[position()=1 and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind' and @noConstr='1']">
+  <xsl:when test="name()='APPLY' and *[position()=1 and name()='MUTCONSTRUCT'
+and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind' and @noConstr='1']">
    <xsl:apply-templates select="*[2]" mode="Zpositive">
     <xsl:with-param name="base" select="$base + $exp"/>
     <xsl:with-param name="exp" select="2 * $exp"/>
     <xsl:with-param name="iden" select="$iden"/>
    </xsl:apply-templates>
   </xsl:when>
-  <xsl:when test="name()='APPLY' and MUTCONSTRUCT[position()=1 and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind' and @noConstr='2']">
+  <xsl:when test="name()='APPLY' and *[position()=1 and name()='MUTCONSTRUCT' 
+and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind' and @noConstr='2']">
    <xsl:apply-templates select="*[2]" mode="Zpositive">
     <xsl:with-param name="base" select="$base"/>
     <xsl:with-param name="exp" select="2 * $exp"/>
     <xsl:when test="$base = 0">
      <xsl:choose>
       <xsl:when test="$exp = 1">
-       <m:ci helm:xref="{$iden}"><xsl:value-of select="$exp"/></m:ci>
+       <xsl:apply-templates select="." mode="pure"/>
       </xsl:when>
       <xsl:otherwise>
        <m:apply helm:xref="{$iden}">
       <m:ci><xsl:value-of select="$base"/></m:ci>
       <xsl:choose>
        <xsl:when test="$exp = 1">
-        <m:ci><xsl:value-of select="$exp"/></m:ci>
+        <xsl:apply-templates select="." mode="pure"/>
        </xsl:when>
        <xsl:otherwise>
         <m:apply helm:xref="{$iden}">