<!-- http://cs.unibo.it/helm/. -->
<!--******************************************************************-->
-<!-- Arithmetics -->
+<!-- Arithmetics -->
<!-- First draft: March 20 2001, Ferruccio Guidi -->
+<!-- Zarith: July 2001, Andrea Asperti -->
<!--******************************************************************-->
<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"
- xmlns:xlink="http://www.w3.org/1999/xlink">
+ xmlns:helm="http://www.cs.unibo.it/helm">
<!-- ************************** 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:ci helm:xref="{$iden}"><xsl:value-of select="$n"/></m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{$iden}">
+ <m:plus/>
+ <m:ci><xsl:value-of select="$n"/></m:ci>
+ <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-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="MUTIND"/>
<xsl:with-param name="m-tag" select="'leq'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Init/Peano/lt.con']" mode="pure">
- <xsl:call-template name="mk-mml-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="CONST"/>
<xsl:with-param name="m-tag" select="'lt'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Init/Peano/ge.con']" mode="pure">
- <xsl:call-template name="mk-mml-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="CONST"/>
- <xsl:with-param name="m-tag" select="'geg'"/>
+ <xsl:with-param name="m-tag" select="'geq'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Init/Peano/gt.con']" mode="pure">
- <xsl:call-template name="mk-mml-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="CONST"/>
<xsl:with-param name="m-tag" select="'gt'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Init/Peano/plus.con']" mode="pure">
- <xsl:call-template name="mk-mml-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="CONST"/>
<xsl:with-param name="m-tag" select="'plus'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Arith/Minus/minus.con']" mode="pure">
- <xsl:call-template name="mk-mml-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="CONST"/>
<xsl:with-param name="m-tag" select="'minus'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Init/Peano/mult.con']" mode="pure">
- <xsl:call-template name="mk-mml-infix">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
<xsl:with-param name="c-tag" select="CONST"/>
<xsl:with-param name="m-tag" select="'times'"/>
</xsl:call-template>
</xsl:template>
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/Arith/Min/min.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'min'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<!-- **************************** Zarith ******************************** -->
+
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/Zle.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'leq'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/Zlt.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'lt'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/Zge.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'geq'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/Zgt.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'gt'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/fast_integer/fast_integers/Zplus.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'plus'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/Zminus.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'minus'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/fast_integer/fast_integers/Zopp.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="1"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'minus'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/fast_integer/fast_integers/Zmult.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'times'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/Zmin.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="2"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'min'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST/@uri='cic:/Coq/ZArith/zarith_aux/absolu.con']" mode="pure">
+ <xsl:call-template name="mk-mml-op-noannot">
+ <xsl:with-param name="arity" select="1"/>
+ <xsl:with-param name="c-tag" select="CONST"/>
+ <xsl:with-param name="m-tag" select="'abs'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<!-- POS, NEG e ZERO -->
+
+<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:with-param name="iden" select="*[2]/@id"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<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">
+ <xsl:with-param name="base" select="0"/>
+ <xsl:with-param name="exp" select="1"/>
+ <xsl:with-param name="iden" select="*[2]/@id"/>
+ </xsl:apply-templates>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="MUTCONSTRUCT[@uri='cic:/Coq/ZArith/fast_integer/fast_integers/Z.ind' and @noConstr='1']" mode="pure">
+ <m:ci definitionURL="{@uri}" helm:xref="{@id}">0</m:ci>
+</xsl:template>
+
+<!-- prova di notazione per positive -->
+
+<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:with-param name="iden" select="@id"/>
+ </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 *[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 *[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:with-param name="iden" select="$iden"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="name()='MUTCONSTRUCT' and @uri='cic:/Coq/ZArith/fast_integer/fast_integers/positive.ind' and @noConstr='3'">
+ <m:ci helm:xref="{$iden}"><xsl:value-of select="$base + $exp"/></m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$base = 0">
+ <xsl:choose>
+ <xsl:when test="$exp = 1">
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{$iden}">
+ <m:times/>
+ <m:ci><xsl:value-of select="$exp"/></m:ci>
+ <xsl:apply-templates select="." mode="pure"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{$iden}">
+ <m:plus/>
+ <m:ci><xsl:value-of select="$base"/></m:ci>
+ <xsl:choose>
+ <xsl:when test="$exp = 1">
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{$iden}">
+ <m:times/>
+ <m:ci><xsl:value-of select="$exp"/></m:ci>
+ <xsl:apply-templates select="." mode="pure"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
</xsl:stylesheet>