--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of annotated MathML content to MathML presentation: -->
+<!-- First draft: March 29 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<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">
+
+<xsl:import href="objcontent.xsl"/>
+
+<xsl:key name="id" use="@id" match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX|Definition|Axiom|CurrentProof|InductiveDefinition|Variable"/>
+
+<xsl:key name="annid" use="@of" match="Annotation"/>
+
+<xsl:template match="Definition|Axiom|CurrentProof|InductiveDefinition|Variable">
+ <xsl:choose>
+ <xsl:when test="key('annid',@id)">
+ <annotation helm:xref="{@id}">
+ <xsl:apply-templates select="key('annid',@id)"/>
+ </annotation>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="noannot"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX">
+ <xsl:choose>
+ <xsl:when test="key('annid',@id)">
+ <annotation helm:xref="{@id}">
+ <xsl:apply-templates select="key('annid',@id)"/>
+ </annotation>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:math>
+ <xsl:apply-templates select="." mode="noannot"/>
+ </m:math>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="node">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:apply-templates select="key('id',$id)"/>
+</xsl:template>
+
+<xsl:template match="attribute">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="name" select="@name"/>
+ <xsl:variable name="child" select="@child"/>
+ <xsl:variable name="grandchild" select="@grandchild"/>
+ <xsl:choose>
+ <xsl:when test="$child">
+ <xsl:choose>
+ <xsl:when test="$grandchild">
+ <xsl:value-of select="key('id',$id)/*[position() = $child]/*[position() = $grandchild]/attribute::*[name() = $name]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="key('id',$id)/*[position() = $child]/attribute::*[name() = $name]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="key('id',$id)/attribute::*[name() = $name]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of annotated MathML content to MathML presentation: -->
+<!-- First draft: March 29 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<xsl:import href="objcontent.xsl"/>
+
+<xsl:template match="Definition|Axiom|CurrentProof|InductiveDefinition|Variable">
+ <xsl:choose>
+ <xsl:when test="'annotation' != name(*[1])">
+ <xsl:apply-templates select="." mode="noannot"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <annotation>
+ <xsl:apply-templates select="annotation"/>
+ </annotation>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX">
+ <xsl:param name="backpointer" select="''"/>
+ <xsl:choose>
+ <xsl:when test="'Annotation' != name(*[1])">
+ <m:math>
+ <xsl:apply-templates select="." mode="noannot">
+ <xsl:with-param name="backpointer" select="$backpointer"/>
+ </xsl:apply-templates>
+ </m:math>
+ </xsl:when>
+ <xsl:otherwise>
+ <annotation>
+ <xsl:apply-templates select="Annotation"/>
+ </annotation>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- DA MODIFICARE PER GESTIRE I RIFERIMENTI A SOTTOANNOTAZIONI O NODI MATH -->
+
+<xsl:template match="nephew">
+ <xsl:variable name="select" select="@no"/>
+ <xsl:apply-templates select="../../*[2]/*[number($select)]"/>
+</xsl:template>
+
+<xsl:template match="brother">
+ <xsl:variable name="select" select="@no"/>
+ <xsl:apply-templates select="../../*[number($select) + 1]"/>
+</xsl:template>
+
+<xsl:template match="name">
+ <xsl:value-of select="../../*[2]/@name"/>
+</xsl:template>
+
+<xsl:template match="nephew-name">
+ <xsl:variable name="select" select="@no"/>
+ <xsl:value-of select="../../*[2]/*[number($select)]/@name"/>
+</xsl:template>
+
+</xsl:stylesheet>
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of annotated MathML content to MathML presentation: -->
+<!-- First draft: March 29 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<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">
+
+<xsl:import href="mmlextension.xsl"/>
+
+<!-- ANNOTATION -->
+
+<xsl:template match="annotation">
+ <xsl:choose>
+ <xsl:when test=". = /">
+ <m:math><m:mrow helm:xref="{@helm:xref}"><xsl:apply-templates/></m:mrow></m:math>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow helm:xref="{@helm:xref}"><xsl:apply-templates/></m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="text()">
+ <xsl:variable name="text" select="normalize-space(.)"/>
+ <xsl:if test="$text != ''">
+ <m:mtext><xsl:value-of select="$text"/></m:mtext>
+ </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- Basic Logic -->
+<!-- First draft: April 3 2000 -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- ************************* LOGIC *********************************-->
+
+<!-- AND -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic/Conjunction/and.ind'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:and definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<!-- OR -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic/Disjunction/or.ind'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:or definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<!-- NOT -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Logic/not.con'] and (count(child::*) = 2)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:not definitionURL="{CONST/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<!-- IFF -->
+<!--
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Logic/Equivalence/iff.ind'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:iff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+-->
+
+<!-- EXISTS -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic/First_order_quantifiers/ex.ind' or attribute::uri='cic:/coq/INIT/Logic_Type/exT.ind'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:exists definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:choose>
+ <xsl:when test="name(*[3]) = 'LAMBDA'">
+ <m:bvar>
+ <m:ci><xsl:value-of select="LAMBDA/target/@binder"/></m:ci>
+ </m:bvar>
+ <xsl:apply-templates select="LAMBDA/target" mode="noannot"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:bvar>
+ <m:ci>$x</m:ci>
+ </m:bvar>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ <m:ci>$x</m:ci>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic/First_order_quantifiers/ex2.ind' or attribute::uri='cic:/coq/INIT/Logic_Type/exT2.ind'] and (count(child::*) = 4)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:exists definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:choose>
+ <xsl:when test="name(*[3]) = 'LAMBDA'">
+ <xsl:variable name="bvarname" select="*[3]/target/@binder"/>
+ <m:bvar>
+ <m:ci><xsl:value-of select="$bvarname"/></m:ci>
+ </m:bvar>
+ <m:condition>
+ <xsl:apply-templates select="LAMBDA[1]/target" mode="noannot"/>
+ </m:condition>
+ <xsl:choose>
+ <xsl:when test="(name(*[4]) = 'LAMBDA') and
+ ($bvarname = *[4]/target/@binder)">
+ <xsl:apply-templates select="LAMBDA[2]/target" mode="noannot"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[4]" mode="noannot"/>
+ <m:ci><xsl:value-of select="$bvarname"/></m:ci>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="name(*[4]) = 'LAMBDA'">
+ <xsl:variable name="bvarname" select="*[4]/target/@binder"/>
+ <m:bvar>
+ <m:ci><xsl:value-of select="$bvarname"/></m:ci>
+ </m:bvar>
+ <m:condition>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ <m:ci><xsl:value-of select="$bvarname"/></m:ci>
+ </m:apply>
+ </m:condition>
+ <xsl:apply-templates select="*[4]/target" mode="noannot"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:bvar>
+ <m:ci>x</m:ci>
+ </m:bvar>
+ <m:condition>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ <m:ci>x</m:ci>
+ </m:apply>
+ </m:condition>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[4]" mode="noannot"/>
+ <m:ci>x</m:ci>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:apply>
+</xsl:template>
+
+<!-- EQUALITY -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic/Equality/eq.ind'] and (count(child::*) = 4)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:eq definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ <xsl:apply-templates select="*[4]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+
+<!-- TYPE EQUALITY -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic_Type/eqT.ind'] and (count(child::*) = 4)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:eq definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ <xsl:apply-templates select="*[4]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<!-- NOT-EQ -->
+<!-- NOT and EQ have no parameters -->
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Logic/not.con']
+and (count(child::*) = 2) and APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic/Equality/eq.ind']]]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(APPLY/child::*) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:neq/>
+ <xsl:apply-templates select="*[2]/*[3]" mode="noannot"/>
+ <xsl:apply-templates select="*[2]/*[4]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- NOT-EQT -->
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Logic/not.con']
+and (count(child::*) = 2) and APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Logic_Type/eqT.ind']]]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(APPLY/child::*) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:neq/>
+ <xsl:apply-templates select="*[2]/*[3]" mode="noannot"/>
+ <xsl:apply-templates select="*[2]/*[4]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- ************************ DATATYPES ******************************* -->
+
+<!-- no datatypes in MathML content -->
+
+
+<!-- *************************** PEANO ********************************* -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/INIT/Peano/le.ind'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:leq definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Peano/lt.con'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:lt definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Peano/ge.con'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:geq definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Peano/gt.con'] and (count(child::*) = 3)]" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:gt definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- XSLT version 0.1 of CIC objects to MathML content: -->
+<!-- First draft: February 14 2000, Andrea Asperti, Irene Schena -->
+<!-- Revised: March 3 2000, Irene Schena -->
+<!-- Revised: March 10 2000, Irene Schena -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<xsl:include href="params.xsl"/>
+
+<!--<xsl:output
+ method="xml"
+ version="1.0"
+ encoding="ISO-8859-1"
+ omit-xml-declaration="no"
+ standalone="no"
+ doctype-public="http://www.w3.org/TR/REC-MathML"
+ indent="yes"
+ media-type="text/mathml" /> -->
+
+<!-- DA FARE:
+1)risolvere nella fase di pre-processing le uri relative, 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 -->
+
+<xsl:template match="LAMBDA" mode="pure">
+ <m:lambda helm:xref="{@id}">
+ <m:bvar>
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </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:template>
+
+<xsl:template match="PROD" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <xsl:choose>
+ <xsl:when test="string(target/@binder)= """>
+ <m:csymbol>arrow</m:csymbol>
+ <xsl:apply-templates select="source/*[1]" mode="noannot"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:csymbol>prod</m:csymbol>
+ <m:bvar>
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </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:template>
+
+<xsl:template match="CAST" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>cast</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*/*"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="REL" mode="pure">
+ <m:ci helm:xref="{@id}">
+ <xsl:value-of select="@binder"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="SORT" mode="pure">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>
+ <xsl:value-of select="@value"/>
+ </m:csymbol>
+ </m:apply>
+</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]"/>
+ </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>
+</xsl:template>
+
+<xsl:template match="VAR" mode="pure">
+ <m:ci helm:xref="{@id}">
+ <xsl:value-of select="substring-after(@relUri,",")"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="META" mode="pure">
+ <m:ci helm:xref="{@id}">
+ <xsl:value-of select="@no"/>
+ </m:ci>
+</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>
+</xsl:template>
+
+<xsl:template match="MUTIND" mode="pure">
+ <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+ <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"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="MUTCONSTRUCT" mode="pure">
+ <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+ <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"/>
+ </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>
+ <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>
+ </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>
+ <m:csymbol>fix</m:csymbol>
+ <m:ci><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></m:ci>
+ <xsl:apply-templates mode="noannot" select="*"/>
+ </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>
+ <m:csymbol>cofix</m:csymbol>
+ <m:ci><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></m:ci>
+ <xsl:apply-templates mode="noannot" select="*"/>
+ </m:apply>
+</xsl:template>
+
+<!-- ELEMENTS OF CIC TERMS -->
+
+<xsl:template match="FixFunction" mode="pure">
+ <m:bvar>
+ <m:ci><xsl:value-of select="@name"/></m:ci>
+ <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
+ </m:bvar>
+ <xsl:apply-templates select="body/*[1]" mode="noannot"/>
+</xsl:template>
+
+<xsl:template match="CofixFunction" mode="pure">
+ <m:bvar>
+ <m:ci><xsl:value-of select="@name"/></m:ci>
+ <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
+ </m:bvar>
+ <xsl:apply-templates select="body/*[1]" mode="noannot"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- XSLT version 0.1 of CIC objects to MathML content: -->
+<!-- First draft: February 14 2000, Andrea Asperti, Irene Schena -->
+<!-- Revised: March 3 2000, Irene Schena -->
+<!-- Revised: March 10 2000, Irene Schena -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--******************************************************************-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<xsl:include href="params.xsl"/>
+
+<!--<xsl:output
+ method="xml"
+ version="1.0"
+ encoding="ISO-8859-1"
+ omit-xml-declaration="no"
+ standalone="no"
+ doctype-public="http://www.w3.org/TR/REC-MathML"
+ indent="yes"
+ media-type="text/mathml" /> -->
+
+<!-- DA FARE:
+1)risolvere nella fase di pre-processing le uri relative, 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 -->
+
+<xsl:template match="LAMBDA" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:lambda>
+ <m:bvar>
+ <m:ci>
+ [[<xsl:value-of select="$backpointer"/>]]
+ <xsl:value-of select="target/@binder"/>
+ </m:ci>
+ <m:type>
+ <xsl:apply-templates select="source/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[1]/*[1]')"/>
+ </xsl:apply-templates>
+ </m:type>
+ </m:bvar>
+ <xsl:apply-templates select="target/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[2]/*[1]')"/>
+ </xsl:apply-templates>
+ </m:lambda>
+</xsl:template>
+
+<xsl:template match="PROD" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:apply>
+ <xsl:choose>
+ <xsl:when test="string(target/@binder)= """>
+ <m:csymbol>arrow</m:csymbol>
+ <xsl:apply-templates select="source/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[1]/*[1]')"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:csymbol>prod</m:csymbol>
+ <m:bvar>
+ <m:ci>
+ [[<xsl:value-of select="$backpointer"/>]]
+ <xsl:value-of select="target/@binder"/>
+ </m:ci>
+ <m:type>
+ <xsl:apply-templates select="source/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[1]/*[1]')"/>
+ </xsl:apply-templates>
+ </m:type>
+ </m:bvar>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="target/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[2]/*[1]')"/>
+ </xsl:apply-templates>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="CAST" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:apply>
+ <m:csymbol>cast</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[1]/*[1]">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[1]/*[1]')"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates mode="noannot" select="*[2]/*[1]">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[2]/*[1]')"/>
+ </xsl:apply-templates>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="REL" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:ci>
+ [[<xsl:value-of select="$backpointer"/>]]
+ <xsl:value-of select="@binder"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="SORT" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:apply>
+ <m:csymbol>
+ <xsl:value-of select="@value"/>
+ </m:csymbol>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="APPLY" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:for-each select="*">
+ <xsl:apply-templates mode="noannot" select=".">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[',position(),']')"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="VAR" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:ci>
+ [[<xsl:value-of select="$backpointer"/>]]
+ <xsl:value-of select="substring-after(@relUri,",")"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="META" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:ci>
+ [[<xsl:value-of select="$backpointer"/>]]
+ <xsl:value-of select="@no"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="CONST" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:ci definitionURL="{@uri}">
+ [[<xsl:value-of select="$backpointer"/>]]
+ <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>
+</xsl:template>
+
+<xsl:template match="MUTIND" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:ci definitionURL="{@uri}">
+ <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
+ [[<xsl:value-of select="$backpointer"/>]]
+ <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="MUTCONSTRUCT" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:ci definitionURL="{@uri}">
+ <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="$backpointer"/>]]
+ <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="MUTCASE" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
+ <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
+ <m:apply>
+ <m:csymbol>mutcase</m:csymbol>
+ <xsl:apply-templates select="patternsType/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[1]/*[1]')"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot">
+ <xsl:with-param name="backpointer" select="concat($backpointer,'/*[2]/*[1]')"/>
+ </xsl:apply-templates>
+ <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>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="FIX" mode="noannot">
+ <xsl:param name="backpointer" select="''"/>
+ <m:apply>
+ <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>
+ <xsl:apply-templates mode="noannot" select="*"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="COFIX" mode="noannot">
+ <m:apply>
+ <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>
+ <xsl:apply-templates mode="noannot" select="*"/>
+ </m:apply>
+</xsl:template>
+
+<!-- ELEMENTS OF CIC TERMS -->
+
+<xsl:template match="FixFunction" mode="noannot">
+ <m:bvar>
+ <m:ci><xsl:value-of select="@name"/></m:ci>
+ <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
+ </m:bvar>
+ <xsl:apply-templates select="body/*[1]" mode="noannot"/>
+</xsl:template>
+
+<xsl:template match="CofixFunction" mode="noannot">
+ <m:bvar>
+ <m:ci><xsl:value-of select="@name"/></m:ci>
+ <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
+ </m:bvar>
+ <xsl:apply-templates select="body/*[1]" mode="noannot"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- XSLT version 0.1 of CIC objects to MathML content: -->
+<!-- First draft: February 14 2000, Andrea Asperti, Irene Schena -->
+<!-- Revised: March 3 2000, Irene Schena -->
+<!-- Revised: March 10 2000, Irene Schena -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<xsl:include href="params.xsl"/>
+
+<!--<xsl:output
+ method="xml"
+ version="1.0"
+ encoding="ISO-8859-1"
+ omit-xml-declaration="no"
+ standalone="no"
+ doctype-public="http://www.w3.org/TR/REC-MathML"
+ indent="yes"
+ media-type="text/mathml" /> -->
+
+<!-- DA FARE:
+1)risolvere nella fase di pre-processing le uri relative, 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 -->
+
+<xsl:template match="LAMBDA" mode="noannot">
+ <m:lambda helm:xref="{@id}">
+ <m:bvar>
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </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:template>
+
+<xsl:template match="PROD" mode="noannot">
+ <m:apply helm:xref="{@id}">
+ <xsl:choose>
+ <xsl:when test="string(target/@binder)= """>
+ <m:csymbol>arrow</m:csymbol>
+ <xsl:apply-templates select="source/*[1]" mode="noannot"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:csymbol>prod</m:csymbol>
+ <m:bvar>
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </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:template>
+
+<xsl:template match="CAST" mode="noannot">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>cast</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*/*"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="REL" mode="noannot">
+ <m:ci helm:xref="{@id}">
+ <xsl:value-of select="@binder"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="SORT" mode="noannot">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>
+ <xsl:value-of select="@value"/>
+ </m:csymbol>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="APPLY" mode="noannot">
+ <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="noannot">
+ <m:ci helm:xref="{@id}">
+ <xsl:value-of select="substring-after(@relUri,",")"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="META" mode="noannot">
+ <m:ci helm:xref="{@id}">
+ <xsl:value-of select="@no"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="CONST" mode="noannot">
+ <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>
+</xsl:template>
+
+<xsl:template match="MUTIND" mode="noannot">
+ <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+ <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"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="MUTCONSTRUCT" mode="noannot">
+ <m:ci definitionURL="{@uri}" helm:xref="{@id}">
+ <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"/>
+ </m:ci>
+</xsl:template>
+
+<xsl:template match="MUTCASE" mode="noannot">
+ <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
+ <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
+ <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>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="FIX" mode="noannot">
+ <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>
+ <xsl:apply-templates mode="noannot" select="*"/>
+ </m:apply>
+</xsl:template>
+
+<xsl:template match="COFIX" mode="noannot">
+ <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>
+ <xsl:apply-templates mode="noannot" select="*"/>
+ </m:apply>
+</xsl:template>
+
+<!-- ELEMENTS OF CIC TERMS -->
+
+<xsl:template match="FixFunction" mode="noannot">
+ <m:bvar>
+ <m:ci><xsl:value-of select="@name"/></m:ci>
+ <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
+ </m:bvar>
+ <xsl:apply-templates select="body/*[1]" mode="noannot"/>
+</xsl:template>
+
+<xsl:template match="CofixFunction" mode="noannot">
+ <m:bvar>
+ <m:ci><xsl:value-of select="@name"/></m:ci>
+ <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
+ </m:bvar>
+ <xsl:apply-templates select="body/*[1]" mode="noannot"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!--***********************************************************************-->
+<!-- From MathML content to HTML -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--***********************************************************************-->
+
+
+<xsl:include href="html_init.xsl"/>
+<xsl:include href="html_set.xsl"/>
+<xsl:include href="html_reals.xsl"/>
+
+
+<!-- <xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>-->
+<xsl:variable name="header" select="document('http://localhost:8081/conf')/html_link"/>
+
+<xsl:variable name="showcast" select="0"/>
+
+
+<!--***********************************************************************-->
+<!-- HTML Head and Body -->
+<!--***********************************************************************-->
+
+<xsl:output method="html"/>
+
+<xsl:variable name="framewidth" select="36"/>
+
+<xsl:template match="/">
+ <xsl:param name="current_indent" select="0"/>
+ <html>
+ <head></head>
+ <body>
+ <xsl:apply-templates>
+ <xsl:with-param name="current_indent" select="0"/>
+ </xsl:apply-templates>
+ </body>
+ </html>
+</xsl:template>
+
+<!--***********************************************************************-->
+<!-- Indentation -->
+<!--***********************************************************************-->
+
+<xsl:template name="make_indent">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:if test="$current_indent > 0">
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent - 1"/>
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+<!-- Syntactic Sugar -->
+
+<xsl:template match="m:type">
+<xsl:param name="current_indent" select="0"/>
+<xsl:apply-templates>
+ <xsl:with-param name="current_indent"
+ select="$current_indent"/>
+</xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="m:condition">
+<xsl:param name="current_indent" select="0"/>
+<xsl:apply-templates>
+ <xsl:with-param name="current_indent"
+ select="$current_indent"/>
+</xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="m:math">
+<xsl:param name="current_indent" select="0"/>
+<xsl:apply-templates>
+ <xsl:with-param name="current_indent"
+ select="$current_indent"/>
+</xsl:apply-templates>
+</xsl:template>
+
+<!-- CSYMBOL -->
+
+<xsl:template match="m:apply[m:csymbol]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <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>
+ <!-- <xsl:value-of select="$current_indent"/> -->
+ <!-- <xsl:value-of select="$charlength"/> -->
+ <xsl:choose>
+ <xsl:when test="$name='prod'">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <!-- Π -->
+ <FONT FACE="symbol" SIZE="+2" color="blue">P</FONT>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:type">
+ <xsl:with-param name="current_indent"
+ select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
+ </xsl:apply-templates><BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="*[position()=3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- Π -->
+ <FONT FACE="symbol" SIZE="+2" color="blue">P</FONT>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='arrow'">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[position()=2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <!-- -> -->
+ <FONT FACE="symbol" SIZE="+2" color="blue">®</FONT>
+ <xsl:apply-templates select="*[position()=3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <!-- -> -->
+ <FONT FACE="symbol" SIZE="+2" color="blue">®</FONT>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='app'">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[position()=2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:for-each select="*[position()>2]">
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:for-each select="*[position()>2]">
+ <xsl:text> </xsl:text>
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cast'">
+ <xsl:choose>
+ <xsl:when test="$showcast = 1">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[position()=2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates><BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/> </xsl:call-template>
+ <xsl:text>:></xsl:text>
+ <xsl:apply-templates select="*[position()=3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 3"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:text>:></xsl:text>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="*[position()=2]">
+ <xsl:with-param name="current_indent" select="$current_indent"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='Prop'">
+ <xsl:text>Prop</xsl:text>
+ </xsl:when>
+ <xsl:when test="$name='Set'">
+ <xsl:text>Set</xsl:text>
+ </xsl:when>
+ <xsl:when test="$name='Type'">
+ <xsl:text>Type</xsl:text>
+ </xsl:when>
+ <xsl:when test="$name='mutcase'">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text><</xsl:text>
+ <xsl:apply-templates select="*[position()=2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>> </xsl:text>
+ <xsl:text>CASE </xsl:text>
+ <xsl:apply-templates select="*[position()=3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 8"/>
+ </xsl:apply-templates>
+ <xsl:text> OF </xsl:text>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <xsl:text>  </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>| </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="."/>
+ <FONT FACE="symbol" SIZE="+2" color="green">Þ</FONT>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 4 + string-length()"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text><</xsl:text>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:text>> </xsl:text>
+ <xsl:text>CASE </xsl:text>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <xsl:text> OF </xsl:text>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:choose>
+ <xsl:when test="not(position() = 1)">
+ <xsl:text> | </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="."/>
+ <FONT FACE="symbol" SIZE="+2" color="green">Þ</FONT>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2 + string-length()"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='fix'">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>FIX</xsl:text>
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>{</xsl:text>
+ <xsl:for-each select="m:bvar">
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:type">
+ <xsl:with-param name="current_indent"
+ select="$current_indent + 5 + string-length(m:ci)"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>:=</xsl:text>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]">
+ <xsl:with-param name="current_indent" select="$current_indent +2"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>FIX</xsl:text>
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>{</xsl:text>
+ <xsl:for-each select="m:bvar">
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:type"/>
+ <xsl:text>:=</xsl:text>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:choose>
+ <xsl:when test="position()=last()">
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>;</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cofix'">
+ <xsl:choose>
+ <xsl:when test="($charlength + 10) > $framewidth">
+ <xsl:text>COFIX</xsl:text>
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>{</xsl:text>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:for-each select="m:bvar">
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:type">
+ <xsl:with-param name="current_indent"
+ select="$current_indent + 5 + string-length(m:ci)"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>:=</xsl:text>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 3"/>
+ </xsl:apply-templates>
+
+ </xsl:for-each>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>COFIX</xsl:text>
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>{</xsl:text>
+ <xsl:for-each select="m:bvar">
+ <xsl:value-of select="m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:type"/>
+ <xsl:text>:=</xsl:text>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:choose>
+ <xsl:when test="position()=last()">
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>;</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ <!-- </m:mrow> -->
+</xsl:template>
+
+<!-- LAMBDA -->
+
+<xsl:template match="m:lambda">
+<xsl:param name="current_indent" select="0"/>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[position()=1]" mode="charcount"/>
+ <!-- <xsl:apply-templates select="." mode="charcount"/> -->
+ </xsl:variable>
+ <!-- <xsl:value-of select="$charlength"/> -->
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <!-- λ -->
+ <FONT FACE="symbol" SIZE="+2" color="red">l</FONT>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:type">
+ <xsl:with-param name="current_indent"
+ select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
+ </xsl:apply-templates><BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="*[position()=2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- λ -->
+ <FONT FACE="symbol" SIZE="+2" color="red">l</FONT>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- href -->
+<xsl:template match="m:ci">
+ <xsl:choose>
+ <xsl:when test="boolean(@definitionURL)">
+<!-- CSC: non bisogna piu' utilizzare la url, bensi' la uri -->
+<!-- <xsl:variable name="url">
+ <xsl:value-of select="concat(string($absPath),
+ @definitionURL)"/>
+ </xsl:variable>-->
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string(@definitionURL))"/>
+ </xsl:attribute>
+ <xsl:apply-templates/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- COUNTING -->
+
+<xsl:template match="m:ci|m:csymbol" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="charcount">
+ <xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 0">
+ <xsl:value-of select="$incurrent_length"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="childlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$framewidth >= number($childlength)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$childlength"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!--***********************************************************************-->
+<!-- OBJECTS -->
+<!--***********************************************************************-->
+
+<!-- DEFINITION -->
+
+<xsl:template match="Definition">
+<xsl:param name="current_indent" select="0"/>
+<p>
+DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
+TYPE =<BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 7"/>
+ </xsl:call-template>
+ <xsl:apply-templates select="type/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 7"/>
+ </xsl:apply-templates><BR/>
+BODY =<BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 7"/>
+ </xsl:call-template>
+ <xsl:apply-templates select="body/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 7"/>
+ </xsl:apply-templates>
+</p>
+</xsl:template>
+
+<!-- AXIOM -->
+
+<xsl:template match="Axiom">
+<xsl:param name="current_indent" select="0"/>
+<p>
+AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
+TYPE = <xsl:apply-templates select="type/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 7"/>
+ </xsl:apply-templates>
+</p>
+</xsl:template>
+
+<!-- UNFINISHED PROOF -->
+
+<xsl:template match="CurrentProof">
+<xsl:param name="current_indent" select="0"/>
+<p>
+UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
+THESIS: <xsl:apply-templates select="type/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 8"/>
+ </xsl:apply-templates><BR/>
+CONJECTURES:
+ <xsl:for-each select="Conjecture">
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 8"/>
+ </xsl:call-template>
+ <xsl:value-of select="./@no"/> :
+ <xsl:apply-templates select="./*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 11"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ <BR/>
+PROOF:
+ <xsl:apply-templates select="body/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 8"/>
+ </xsl:apply-templates>
+</p>
+</xsl:template>
+
+<!-- MUTUAL INDUCTIVE DEFINITION -->
+
+<xsl:template match="InductiveDefinition">
+<xsl:param name="current_indent" select="0"/>
+<p>
+ <xsl:for-each select="InductiveType">
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <xsl:choose>
+ <xsl:when test="string(./@inductive) = "true"">
+ INDUCTIVE DEFINITION
+ </xsl:when>
+ <xsl:otherwise>
+ COINDUCTIVE DEFINITION
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ AND
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)
+ [
+ <xsl:if test="string(../Param) != """>
+ <xsl:for-each select="../Param">
+ <xsl:value-of select="./@name"/>
+ :
+ <xsl:apply-templates select="*"/>
+ </xsl:for-each>
+ </xsl:if>
+ ] <BR/>
+ OF ARITY
+ <xsl:apply-templates select="./arity/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 9"/>
+ </xsl:apply-templates> <BR/>
+ BUILT FROM:
+ <xsl:for-each select="./Constructor">
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 3"/>
+ </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <xsl:text>  </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>| </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of select="./@name"/>
+ <xsl:text>: </xsl:text>
+ <xsl:apply-templates select="./*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + string-length(./@name) + 4"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:for-each>
+</p>
+</xsl:template>
+
+<!-- VARIABLE -->
+
+<xsl:template match="Variable">
+<xsl:param name="current_indent" select="0"/>
+<p>
+VARIABLE <xsl:value-of select="@name"/><BR/>
+TYPE = <xsl:apply-templates select="type/*[1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 7"/>
+ </xsl:apply-templates>
+</p>
+</xsl:template>
+
+<!--***********************************************************************-->
+<!-- SECTIONS -->
+<!--***********************************************************************-->
+
+<!-- SECTION -->
+
+<xsl:template match="SECTION">
+<xsl:param name="current_indent" select="0"/>
+ <h1>BEGIN OF SECTION</h1>
+ <xsl:apply-templates/>
+ <h1>END OF SECTION</h1>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!--***********************************************************************-->
+<!-- INIT style for HTML -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--***********************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+
+<!-- BASIC OPERATORS -->
+
+ <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
+ |m:geq|m:gt|m:plus|m:times]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="*[1]/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:variable name="symbol">
+ <xsl:choose>
+ <xsl:when test="m:and">
+ <xsl:value-of select="'Ù'"/>
+ </xsl:when>
+ <xsl:when test="m:or">
+ <xsl:value-of select="'Ú'"/>
+ </xsl:when>
+ <xsl:when test="m:eq">
+ <xsl:value-of select="'='"/>
+ </xsl:when>
+ <xsl:when test="m:neq">
+ <xsl:value-of select="'¹'"/>
+ </xsl:when>
+ <xsl:when test="m:leq">
+ <xsl:value-of select="'£'"/>
+ </xsl:when>
+ <xsl:when test="m:lt">
+ <xsl:value-of select="'<'"/>
+ </xsl:when>
+ <xsl:when test="m:geq">
+ <xsl:value-of select="'³'"/>
+ </xsl:when>
+ <xsl:when test="m:gt">
+ <xsl:value-of select="'>'"/>
+ </xsl:when>
+ <xsl:when test="m:plus">
+ <xsl:value-of select="'+'"/>
+ </xsl:when>
+ <xsl:when test="m:times">
+ <xsl:value-of select="'*'"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" color="blue">
+ <xsl:value-of select="$symbol"/>
+ </FONT>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" color="blue">
+ <xsl:value-of select="$symbol"/>
+ </FONT>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- MINUS (can be unary!) -->
+
+<xsl:template match="m:apply[m:minus]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="*[1]/@definitionURL"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="count(child::*)=2">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>-</xsl:text>
+ </a>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 1"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>-</xsl:text>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>-</xsl:text>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- NOT -->
+
+ <xsl:template match="m:apply[m:not]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:not/@definitionURL"/>
+ </xsl:variable>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" color="blue">Ø</FONT>
+ </a>
+ <xsl:apply-templates select="*[2]"/>
+ </xsl:template>
+
+<!-- EXISTS -->
+
+ <xsl:template match="m:apply[m:exists]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:exists/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:exists" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" color="blue">$</FONT>
+ </a>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:condition">
+ <xsl:with-param name="current_indent" select="$current_indent + 2 +
+ string-length(bvar/ci)"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="*[last()]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" color="blue">$</FONT>
+ </a>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:condition"/>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="*[last()]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+<!-- COUNTING -->
+
+<xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:neq
+ |m:lt|m:leq|m:gt|m:geq|m:plus|m:minus|m:times" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!--***********************************************************************-->
+<!-- INIT style for HTML -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--***********************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- LIMIT -->
+
+<xsl:template match="m:apply[m:limit]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:limit/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:limit" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>lim</xsl:text>
+ </a>
+ <SUB>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <FONT FACE="symbol" color="blue">®</FONT>
+ <xsl:apply-templates select="m:lowlimit"/>
+ </SUB>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:call-template>
+ <xsl:apply-templates select="*[4]">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>lim</xsl:text>
+ </a>
+ <SUB>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <FONT FACE="symbol" color="blue">®</FONT>
+ <xsl:apply-templates select="m:lowlimit"/>
+ </SUB>
+ <xsl:apply-templates select="*[4]">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- DIFFERENTIATION -->
+
+<xsl:template match="m:apply[m:diff]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:diff/@definitionURL"/>
+ </xsl:variable>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <SUP>d</SUP>
+ <xsl:text>/</xsl:text>
+ <SUB>
+ <xsl:text>d</xsl:text>
+ <xsl:value-of select="m:bvar/m:ci"/>
+ </SUB>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+<!-- ABSOLUTE VALUE -->
+<xsl:template match="m:apply[m:abs]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:abs/@definitionURL"/>
+ </xsl:variable>
+ <xsl:text>|</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>|</xsl:text>
+ </xsl:template>
+
+<!-- FACTORIAL -->
+
+<xsl:template match="m:apply[m:fact]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:abs/@definitionURL"/>
+ </xsl:variable>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>!</xsl:text>
+ </xsl:template>
+
+<!-- SQUARE ROOT -->
+
+<xsl:template match="m:apply[m:root]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:abs/@definitionURL"/>
+ </xsl:variable>
+ <xsl:text>(sqr</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:template>
+
+<!-- POWER -->
+
+<xsl:template match="m:apply[m:power]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:power/@definitionURL"/>
+ </xsl:variable>
+ <xsl:apply-templates select="*[2]"/>
+ <SUP>
+ <xsl:apply-templates select="*[3]"/>
+ </SUP>
+ </xsl:template>
+
+<!-- MIN and MAX (binari: estendere) -->
+
+ <xsl:template match="m:apply[m:min|m:max]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="*[1]/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:variable name="symbol">
+ <xsl:choose>
+ <xsl:when test="m:min">
+ <xsl:value-of select="'min'"/>
+ </xsl:when>
+ <xsl:when test="m:max">
+ <xsl:value-of select="'max'"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:value-of select="$symbol"/>
+ </a>
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>,</xsl:text>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+ </xsl:call-template>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:value-of select="$symbol"/>
+ </a>
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <xsl:text>, </xsl:text>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>}</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- COUNTING -->
+
+<xsl:template match="m:abs|m:fact|m:root
+ |m:limit|m:diff|m:min|m:max" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!--***********************************************************************-->
+<!-- INIT style for HTML -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--***********************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- IN -->
+
+ <xsl:template match="m:apply[m:in]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:in/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:in" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Î</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Î</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- NOTIN -->
+
+ <xsl:template match="m:apply[m:notin]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:notin/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:notin" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Ï</FONT>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Ï</FONT>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- SET -->
+
+ <xsl:template match="m:set">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="concat(string($absPath), @definitionURL)"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 0">
+ <FONT FACE="symbol" color="blue">Æ</FONT>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="." mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="name(*[1]) = 'm:bvar'">
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:type">
+ <xsl:with-param name="current_indent"
+ select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
+ </xsl:apply-templates><BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:text>|</xsl:text>
+ <xsl:apply-templates select="m:condition">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ <xsl:text>|</xsl:text>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:text>}</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="*[position()=1]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:for-each select="*[position()>1]">
+ <xsl:text>,</xsl:text>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>{</xsl:text>
+ <xsl:for-each select="*">
+ <xsl:apply-templates select="."/>
+ <xsl:choose>
+ <xsl:when test="position() = last()">
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>,</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+<!-- INTERSECTION -->
+
+<xsl:template match="m:apply[m:intersect]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:intersect/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:intersect" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Ç</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Ç</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- UNION -->
+
+<xsl:template match="m:apply[m:union]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:union/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:union" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">È</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">È</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- SUBSET -->
+<xsl:template match="m:apply[m:subset]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:subset/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:subset" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Í</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Í</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- PRSUBSET -->
+<xsl:template match="m:apply[m:prsubset]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:prsubset/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:prsubset" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Ì</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <FONT FACE="symbol" SIZE="+2" color="blue">Ì</FONT>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+<!-- SETDIFF -->
+
+<xsl:template match="m:apply[m:setdiff]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:setdiff/@definitionURL"/>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:setdiff" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength > $framewidth">
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <BR/>
+ <xsl:call-template name="make_indent">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:call-template>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>/</xsl:text>
+ </a>
+ <xsl:apply-templates select="*[3]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(</xsl:text>
+ <xsl:apply-templates select="*[2]"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(string($header),string($uri))"/>
+ </xsl:attribute>
+ <xsl:text>/</xsl:text>
+ </a>
+ <xsl:apply-templates select="*[3]"/>
+ <xsl:text>)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- CARD -->
+<xsl:template match="m:apply[m:card]">
+ <xsl:param name="current_indent" select="0"/>
+ <xsl:param name="width" select="$framewidth"/>
+ <xsl:variable name="uri">
+ <xsl:value-of select="m:card/@definitionURL"/>
+ </xsl:variable>
+ <xsl:text>|</xsl:text>
+ <xsl:apply-templates select="*[2]">
+ <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+ </xsl:apply-templates>
+ <xsl:text>|</xsl:text>
+ </xsl:template>
+
+<!-- COUNTING -->
+
+<xsl:template match="m:in|m:notin|m:intersect|m:union
+ |m:subset|m:prsubset|m:setdiff|m:card" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!-- ====================================================== -->
+<!-- XSL Transform of MathML content to MathML presentation -->
+<!-- By Igor Rodionov, Computer Science Department of -->
+<!-- the University of Western Ontario, London, Canada -->
+<!-- Complies with the W3C Working Draft from Dec.3, 1999 -->
+<!-- Version x.xx from Feb. 18, 2000 -->
+<!-- Comments to: igor@csd.uwo.ca -->
+<!-- -->
+<!-- (C) Copyright 1999, 2000 Symbolic Computation -->
+<!-- Laboratory, University of Western Ontario. -->
+<!-- ====================================================== -->
+
+<!-- ====================================================== -->
+<!-- May 11, 2000 - HELM group: -->
+<!-- Added the namespace prefix to all the output elements -->
+<!-- Changed the mml prefix into m -->
+<!-- Swapped math element out of the semantic element -->
+<!-- Added the declaration of the xlink namespace -->
+<!-- ====================================================== -->
+
+<xsl:stylesheet id="mml2mml"
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:helm="http://www.cs.unibo.it/helm">
+
+<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
+
+<!-- ***************************************************** -->
+<!-- Parameters affectin' stylesheet's run-time behavior -->
+<!-- ***************************************************** -->
+
+<!-- SEM_SW: -1 - strip off all semantics
+ 0 - pass semantics "as is" (default)
+ 1 - add semantics at top level only
+ 2 - add semantics at all levels
+ 3 - semantics at top level with cross-references
+-->
+<!-- HELM: SEM_SW was 0 -->
+<xsl:param name="SEM_SW" select="1"/>
+
+<!-- Miscellaneous Variable Definitions -->
+
+<xsl:variable name="NO" select="0"/>
+<xsl:variable name="YES" select="1"/>
+<xsl:variable name="PAR_NO" select="-7"/>
+<xsl:variable name="PAR_YES" select="-5"/>
+<xsl:variable name="PAR_SAME" select="-3"/>
+<xsl:variable name="NO_PARAM" select="-1"/>
+
+<!-- Operator Precedence Definitions -->
+
+<xsl:variable name="NO_PREC" select="0"/>
+<xsl:variable name="UNION_PREC" select="1"/>
+<xsl:variable name="SETDIFF_PREC" select="1"/>
+<xsl:variable name="INTERSECT_PREC" select="3"/>
+<xsl:variable name="OR_PREC" select="5"/>
+<xsl:variable name="XOR_PREC" select="5"/>
+<xsl:variable name="AND_PREC" select="7"/>
+<xsl:variable name="PLUS_PREC" select="9"/>
+<xsl:variable name="MINUS_PREC" select="9"/>
+<xsl:variable name="MUL_PREC" select="11"/>
+<xsl:variable name="DIV_PREC" select="11"/>
+<xsl:variable name="NEG_PREC" select="13"/>
+<xsl:variable name="FUNCTION_PREC" select="99"/>
+
+<!-- AUXILIARY FUNCTIONS FOR BACKWARD POINTERS AND REFS (by andrea) -->
+
+<xsl:template name = "insert_xref">
+ <xsl:if test="@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name = "insert">
+ <xsl:if test="@definitionURL">
+ <xsl:attribute name="xlink:href">
+ <xsl:value-of select="@definitionURL"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<!-- for use inside m:apply -->
+<xsl:template name = "insert1">
+ <xsl:if test="*[1]/@definitionURL">
+ <xsl:attribute name="xlink:href">
+ <xsl:value-of select="*[1]/@definitionURL"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="*[1]/@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="*[1]/@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<!-- For use inside "for-each" -->
+<xsl:template name = "insert2">
+ <xsl:if test="../*[1]/@definitionURL">
+ <xsl:attribute name="xlink:href">
+ <xsl:value-of select="../*[1]/@definitionURL"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="../*[1]/@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="../*[1]/@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<!-- THE TOPMOST ELEMENT: MATH -->
+
+<xsl:template match = "m:math">
+ <xsl:choose>
+ <xsl:when test="$SEM_SW>0">
+<!-- HELM: deleted math (we have already inserted at object level) -->
+ <!--<m:math>-->
+ <m:semantics>
+ <xsl:apply-templates mode = "semantics"/>
+ <m:annotation-xml encoding="MathML">
+ <xsl:copy-of select = "*"/>
+ </m:annotation-xml>
+ </m:semantics>
+ <!--</m:math>-->
+ </xsl:when>
+ <xsl:otherwise>
+ <!--<m:math>-->
+ <xsl:apply-templates mode = "semantics"/>
+ <!--</m:math>-->
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- SEMANTICS -->
+
+<xsl:template match = "m:*" mode = "semantics">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$SEM_SW=-1 and self::m:semantics">
+ <xsl:apply-templates select="*[1]">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="$SEM_SW=0 and self::m:semantics">
+ <m:semantics>
+ <xsl:apply-templates select="*[1]">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:copy-of select="m:annotation-xml"/>
+ </m:semantics>
+ </xsl:when>
+ <xsl:when test="$SEM_SW=2">
+ <m:semantics>
+ <xsl:choose>
+ <xsl:when test="self::m:semantics">
+ <xsl:apply-templates select="*[1]">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:copy-of select="m:annotation-xml"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <m:annotation-xml encoding="MathML">
+ <xsl:copy-of select="."/>
+ </m:annotation-xml>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:semantics>
+ </xsl:when>
+ <xsl:when test="$SEM_SW=3 and @id">
+ <m:mrow idref="{@id}">
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:semantics">
+ <xsl:apply-templates select="*[1]" mode = "semantics"/>
+</xsl:template>
+
+
+<!-- BASIC ELEMENTS -->
+
+<xsl:template match = "m:cn">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test=". < 0 and $IN_PREC > 0 and $PAREN=$PAR_NO and $PAR_NO_IGNORE=$NO">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="cn"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="cn"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:cn" mode="cn">
+ <xsl:choose>
+ <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
+ <m:msub>
+ <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <xsl:apply-templates select="text()[2]" mode = "semantics"/>
+ </xsl:if>
+ <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
+ <m:mo>i</m:mo>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@type='complex' and @base and child::m:sep[1]">
+ <m:msub>
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </xsl:if>
+ <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
+ <m:mo>i</m:mo>
+ </m:mfenced>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
+ <m:mrow>
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mo>/</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mrow>
+ </xsl:when>
+ <xsl:when test="@type='rational' and @base and child::m:sep[1]">
+ <m:msub>
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mo>/</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mfenced>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
+ <m:mrow>
+ <m:mo>Polar</m:mo>
+ <m:mfenced separators=",">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mfenced>
+ </m:mrow>
+ </xsl:when>
+ <xsl:when test="@type='polar' and @base and child::m:sep[1]">
+ <m:msub>
+ <m:mrow>
+ <m:mo>Polar</m:mo>
+ <m:mfenced separators=",">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mfenced>
+ </m:mrow>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mn>
+ <xsl:call-template name="insert"/>
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mn>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:ci">
+ <xsl:choose>
+ <xsl:when test="@type='vector' or @type=matrix or @type=set">
+ <m:mi fontweight="bold"> <xsl:apply-templates mode = "semantics"/> </m:mi>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mi>
+ <xsl:call-template name="insert"/>
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mi>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:csymbol">
+ <xsl:choose>
+ <xsl:when test="*[1]">
+ <xsl:copy-of select = "*"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo> <xsl:apply-templates mode = "semantics"/> </m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- BASIC CONTENT ELEMENTS -->
+
+<xsl:template match = "m:apply[m:fn[1]]">
+ <m:mrow>
+ <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
+ <m:mfenced separators=",">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:fn">
+ <xsl:apply-templates select = "*[1]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:interval">
+ <xsl:choose>
+ <xsl:when test="@closure='closed'">
+ <m:mfenced open="[" close="]" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@closure='open'">
+ <m:mfenced separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@closure='open-closed'">
+ <m:mfenced open="(" close="]" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@closure='closed-open'">
+ <m:mfenced open="[" close=")" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mfenced open="[" close="]" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
+ <m:mrow>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <m:mfenced separators=",">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<!-- These "semantical" Transformations are REALLY questionable.
+ Andrea -->
+
+<xsl:template match = "m:apply[*[1][self::m:inverse]]">
+ <xsl:choose>
+ <xsl:when test="*[2]=m:exp">
+ <m:mo>ln</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:ln | m:log">
+ <m:mo>exp</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sin">
+ <m:mo>arcsin</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:cos">
+ <m:mo>arccos</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:tan">
+ <m:mo>arctan</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sec">
+ <m:mo>arcsec</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:csc">
+ <m:mo>arccsc</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:cot">
+ <m:mo>arccot</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sinh">
+ <m:mo>arcsinh</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:cosh">
+ <m:mo>arccosh</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:tanh">
+ <m:mo>arctanh</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sech">
+ <m:mo>arcsech</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:csch">
+ <m:mo>arccsch</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:coth">
+ <m:mo>arccoth</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:arcsin">
+ <m:mo>sin</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:arccos">
+ <m:mo>cos</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:arctan">
+ <m:mo>tan</m:mo>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mfenced>
+ <m:mn>-1</m:mn>
+ </m:mfenced>
+ </m:msup>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:sep"/>
+
+<xsl:template match = "m:condition">
+ <xsl:choose>
+ <xsl:when test="parent::m:apply[m:forall[1]]"/>
+ <xsl:otherwise>
+ <xsl:if test="not(*[2])">
+ <xsl:apply-templates mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="*[2]">
+ <m:mrow>
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mrow>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:declare"/>
+
+<xsl:template match = "m:lambda">
+ <m:mrow>
+ <m:mo> Λ </m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*">
+ <xsl:choose>
+ <xsl:when test="self::m:ci or self::m:cn">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:*[1][self::m:apply[m:compose[1]]]]">
+ <m:mrow>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <m:mfenced separators=",">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:compose]]">
+ <m:mfenced separators="">
+ <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] | self::m:fn]" mode="semantics"/>
+ <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] | self::m:fn]">
+ <m:mo> <xsl:call-template name="insert2"/> <mchar name="SmallCircle"/> </m:mo>
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:ident">
+ <m:mo>id</m:mo>
+</xsl:template>
+
+
+<!-- ARITHMETIC, ALGEBRA & LOGIC -->
+
+<xsl:template match = "m:apply[m:quotient[1]]">
+ <m:mfenced open="⌊" close="⌋" separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ <m:mo><xsl:call-template name="insert1"/>/</m:mo>
+ <xsl:apply-templates select="*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:exp]]">
+ <m:msup>
+ <m:mo>e</m:mo>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:msup>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:factorial[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ <m:mo><xsl:call-template name="insert1"/>!</m:mo>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:max[1] | m:min[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="*[2]=m:bvar">
+ <m:munder>
+ <xsl:if test="*[1]=m:max">
+ <m:mo><xsl:call-template name="insert1"/>max</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:min">
+ <m:mo>min</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </m:munder>
+ <xsl:if test="*[3]=m:condition">
+ <m:mfenced open="{{" close="}}" separators="">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*[position()>3]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:if>
+ <xsl:if test="not(*[3]=m:condition)">
+ <m:mfenced open="{{" close="}}" separators=",">
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </xsl:if>
+ </xsl:if>
+ <xsl:if test="*[2]=m:condition">
+ <xsl:if test="*[1]=m:max">
+ <m:mo>max</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:min">
+ <m:mo>min</m:mo>
+ </xsl:if>
+ <m:mfenced open="{{" close="}}" separators="">
+ <xsl:if test="*[3]">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mo>|</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
+ <xsl:if test="*[1]=m:max">
+ <m:mo>max</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:min">
+ <m:mo><xsl:call-template name="insert1"/>min</m:mo>
+ </xsl:if>
+ <m:mfenced open="{{" close="}}" separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </xsl:if>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $MINUS_PREC or $IN_PREC=$MINUS_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="minus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="minus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="minus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]" mode="minus">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:if test="not(*[3])">
+ <m:mo><xsl:call-template name="insert1"/>-</m:mo>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:if test="*[3]">
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <m:mo><xsl:call-template name="insert1"/>-</m:mo>
+ <xsl:apply-templates select="*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+ <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $PLUS_PREC or $IN_PREC=$PLUS_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="plus">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="plus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="plus">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]" mode="plus">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:if test="*[2]">
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:choose>
+ <xsl:when test=". < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-."/> </m:mn>
+ </xsl:when>
+ <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo><xsl:call-template name="insert2"/>+</m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:power[1]]">
+ <xsl:choose>
+ <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] | m:gcd[1] | m:sin[1] | m:cos[1] | m:tan[1] | m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] | m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] | m:coth[1] | m:arcsin[1] | m:arccos[1] | m:arctan[1]]">
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $DIV_PREC or $IN_PREC=$DIV_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="remdiv">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="remdiv">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="remdiv">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:if test="m:rem">
+ <m:mo><xsl:call-template name="insert1"/>%</m:mo>
+ </xsl:if>
+ <xsl:if test="m:divide">
+ <m:mo><xsl:call-template name="insert1"/>/</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+ <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $MUL_PREC or $IN_PREC=$MUL_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="times">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="times">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="times">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]" mode="times">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:if test="*[3]">
+ <xsl:for-each select = "*[position()>2]">
+<!-- MODIFICA PROVVISORIA -->
+<!-- <m:mo><xsl:call-template name="insert2"/>
+ <mchar name="InvisibleTimes"/> </m:mo> -->
+ <m:mo><xsl:call-template name="insert2"/>*</m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:if>
+</xsl:template>
+
+<!-- COMMENTO : dove metto la uri della definizione di radice ???? -->
+
+<xsl:template match = "m:apply[m:root[1]]">
+ <m:msqrt>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="*[2]=m:degree">
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:degree)">
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ <m:mn>2</m:mn>
+ </xsl:if>
+ </m:msqrt>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:gcd[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <m:mo><xsl:call-template name="insert1"/>gcd</m:mo>
+ </xsl:if>
+ <xsl:if test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <m:mo><xsl:call-template name="insert1"/>gcd</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $AND_PREC">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="and">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="and">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="and">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]" mode="and">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="wedge"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $OR_PREC">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="or">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="or">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="or">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]" mode="or">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="vee"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $XOR_PREC">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="xor">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="xor">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="xor">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]" mode="xor">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="xor"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:not[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/>not</m:mo>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:forall[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/>for all</m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "m:bvar">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <xsl:if test="m:condition">
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+ <m:mo>,</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:exists[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="Exists"/> </m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "m:bvar">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <xsl:if test="m:condition">
+ <m:mo>,</m:mo>
+ <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+ </xsl:if>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:abs[1]]">
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <m:mfenced open="|" close="|" separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:if>
+ <xsl:if test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <m:mfenced open="|" close="|" separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:conjugate[1]]">
+ <m:mover>
+ <m:mrow>
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mrow>
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="UnderBar"/> </m:mo>
+ </m:mover>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:choose>
+ <xsl:when test="m:arg">
+ <m:mo><xsl:call-template name="insert1"/>arg</m:mo>
+ </xsl:when>
+ <xsl:when test="m:real">
+ <m:mo><xsl:call-template name="insert1"/>Real</m:mo>
+ </xsl:when>
+ <xsl:when test="m:imaginary">
+ <m:mo><xsl:call-template name="insert1"/>Imaginary</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <m:mfenced separators="">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- RELATIONS -->
+
+<xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies | m:in | m:notin | m:notsubset | m:notprsubset | m:subset | m:prsubset | m:eq | m:gt | m:lt | m:geq | m:leq | m:equivalent]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:tendsto or *[1]=m:implies or *[1]=m:in or *[1]=m:notin or *[1]=m:notsubset or *[1]=m:notprsubset">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <xsl:if test="*[1]=m:neq">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="NotEqual"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:approx">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="approxeq"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:tendsto">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="RightArrow"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:implies">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="DoubleRightArrow"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:in">
+ <m:mo><xsl:call-template name="insert1"/>
+ <mchar name="Element"/>
+ </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notin">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="NotElement"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notsubset">
+ <m:mo> <xsl:call-template name="insert1"/> <mchar name="NotSubset"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notprsubset">
+ <m:mo> <xsl:call-template name="insert1"/> <mchar name="NotSubsetEqual"/> </m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
+ <m:mo><xsl:call-template name="insert1"/>-</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
+ <m:mo><xsl:call-template name="insert1"/>+</m:mo>
+ </xsl:if>
+ </xsl:if>
+ <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
+ <xsl:apply-templates select = "*[2]" mode="semantics"/>
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:if test="../*[self::m:subset][1]">
+ <m:mo> <xsl:call-template name="insert2"/> <mchar name="SubsetEqual"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:prsubset][1]">
+ <m:mo> <xsl:call-template name="insert2"/><mchar name="subset"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:eq][1]">
+ <m:mo><xsl:call-template name="insert2"/>=</m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:gt][1]">
+ <m:mo><xsl:call-template name="insert2"/>></m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:lt][1]">
+ <m:mo><xsl:call-template name="insert2"/><</m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:geq][1]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="geq"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:leq][1]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="leq"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:equivalent][1]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="Congruent"/> </m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </xsl:if>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- CALCULUS -->
+
+<xsl:template match = "m:apply[*[1][self::m:ln]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:choose>
+ <xsl:when test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <m:mo><xsl:call-template name="insert1"/>ln</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo><xsl:call-template name="insert1"/>ln</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:log[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:choose>
+ <xsl:when test="parent::m:apply[m:power[1]]">
+ <xsl:if test="not(*[2]=m:logbase)">
+ <m:msup>
+ <m:mo><xsl:call-template name="insert1"/>log</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <xsl:if test="*[2]=m:logbase">
+ <m:msubsup>
+ <m:mo><xsl:call-template name="insert1"/>log</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+ </m:msubsup>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="not(*[2]=m:logbase)">
+ <m:mo><xsl:call-template name="insert1"/>log</m:mo>
+ </xsl:if>
+ <xsl:if test="*[2]=m:logbase">
+ <m:msub>
+ <m:mo><xsl:call-template name="insert1"/>log</m:mo>
+ <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+ </m:msub>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="*[2]=m:logbase">
+ <xsl:apply-templates select = "*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:logbase)">
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:diff[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
+ <m:mfrac><xsl:call-template name="insert1"/>
+ <m:msup>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+ </m:msup>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <m:msup>
+ <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+ <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+ </m:msup>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
+ <m:mfrac><xsl:call-template name="insert1"/>
+ <m:mo>d</m:mo>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:partialdiff[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:for-each select = "m:bvar">
+ <xsl:if test="*[last()]=m:degree">
+ <m:mfrac><xsl:call-template name="insert1"/>
+ <m:msup>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+ </m:msup>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <m:msup>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+ </m:msup>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ <xsl:if test="not(*[last()]=m:degree)">
+ <m:mfrac><xsl:call-template name="insert1"/>
+ <m:mo>d</m:mo>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
+ <xsl:apply-templates mode = "semantics"/>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="*[1]=m:divergence">
+ <m:mo><xsl:call-template name="insert1"/>div</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:grad">
+ <m:mo><xsl:call-template name="insert1"/>grad</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:curl">
+ <m:mo><xsl:call-template name="insert1"/>curl</m:mo>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="*[2]=m:ci">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mfenced separators="">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:laplacian[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:msup><xsl:call-template name="insert1"/>
+ <m:mo> Δ </m:mo>
+ <m:mn>2</m:mn>
+ </m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- SET THEORY -->
+
+<xsl:template match = "m:set | m:list">
+ <m:mfenced open="{{" close="}}" separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
+ <xsl:apply-templates select="m:bvar" mode = "semantics"/>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="m:condition" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="m:condition" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </xsl:if>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $UNION_PREC or $IN_PREC=$UNION_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="" helm:xref="{@helm:xref}">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="union">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="union">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="union">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]" mode="union">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="Union"/> </m:mo>
+ <xsl:apply-templates select = "." mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $INTERSECT_PREC">
+ <m:mfenced separators="" helm:xref="{@helm:xref}">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="intersect">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="intersect">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="intersect">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo><xsl:call-template name="insert2"/> <mchar name="Intersection"/> </m:mo>
+ <xsl:apply-templates select = "." mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="setdiff">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="setdiff">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="." mode="setdiff">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <m:mo><xsl:call-template name="insert1"/>\</m:mo>
+ <xsl:apply-templates select = "*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+ <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:card[1]]">
+ <m:mfenced open="|" close="|" separators=",">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+</xsl:template>
+
+
+<!-- SEQUENCES AND SERIES -->
+
+<xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:choose>
+ <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
+ <m:munderover>
+ <xsl:if test="*[1]=m:sum">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="Sum"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:product">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="Product"/> </m:mo>
+ </xsl:if>
+ <m:mrow>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo>=</m:mo>
+ <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
+ </m:mrow>
+ <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
+ </m:munderover>
+ <xsl:apply-templates select = "*[5]" mode = "semantics"/>
+ </xsl:when>
+ <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
+ <m:munder>
+ <xsl:if test="*[1]=m:sum">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="Sum"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:product">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="Product"/> </m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </m:munder>
+ <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+ </xsl:when>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:limit[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:munder>
+ <m:mo><xsl:call-template name="insert1"/>lim</m:mo>
+ <m:mrow>
+ <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo> <mchar name="RightArrow"/> </m:mo>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </xsl:if>
+ </m:mrow>
+ </m:munder>
+ <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- TRIGONOMETRY -->
+
+<xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos | self::m:tan | self::m:sec | self::m:csc | self::m:cot | self::m:sinh | self::m:cosh | self::m:tanh | self::m:sech | self::m:csch | self::m:coth | self::m:arcsin | self::m:arccos | self::m:arctan]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+ </xsl:if>
+ <xsl:if test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:*" mode = "trigonometry">
+ <xsl:choose>
+ <xsl:when test="self::m:sin">
+ <m:mo>sin</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:cos">
+ <m:mo>cos</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:tan">
+ <m:mo>tan</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:sec">
+ <m:mo>sec</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:csc">
+ <m:mo>csc</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:cot">
+ <m:mo>cot</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:sinh">
+ <m:mo>sinh</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:cosh">
+ <m:mo>cosh</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:tanh">
+ <m:mo>tanh</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:sech">
+ <m:mo>sech</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:csch">
+ <m:mo>csch</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:coth">
+ <m:mo>coth</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:arcsin">
+ <m:mo>arcsin</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:arccos">
+ <m:mo>arccos</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:arctan">
+ <m:mo>arctan</m:mo>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- STATISTICS -->
+
+<xsl:template match = "m:apply[m:mean[1]]">
+ <m:mfenced open="<" close=">" separators=",">
+ <xsl:call-template name="insert_xref"/>
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:sdev[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/> σ </m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:variance[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/> σ </m:mo>
+ <m:msup>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mn>2</m:mn>
+ </m:msup>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:median[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/>median</m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:mode[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/>mode</m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:moment[1]]">
+ <xsl:call-template name="insert_xref"/>
+ <m:mfenced open="<" close=">" separators="">
+ <xsl:if test="*[2]=m:degree">
+ <m:msup>
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:degree)">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </xsl:if>
+ </m:mfenced>
+</xsl:template>
+
+
+<!-- LINEAR ALGEBRA -->
+
+<xsl:template match="m:vector">
+ <m:mfenced separators="">
+ <m:mtable>
+ <xsl:for-each select="*">
+ <m:mtd>
+ <xsl:apply-templates select="." mode = "semantics"/>
+ </m:mtd>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrix">
+ <m:mfenced separators="">
+ <m:mtable>
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mtable>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrixrow">
+ <m:mtr>
+ <xsl:for-each select="*">
+ <m:mtd>
+ <xsl:apply-templates select="." mode = "semantics"/>
+ </m:mtd>
+ </xsl:for-each>
+ </m:mtr>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:determinant[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <m:mo><xsl:call-template name="insert1"/>det</m:mo>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:transpose[1]]">
+ <m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo>T</m:mo>
+ </m:msup>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:selector[1]]">
+ <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
+ <xsl:variable name="m" select = "*[3]"/>
+ <xsl:choose>
+ <xsl:when test="*[4]=m:cn">
+ <xsl:variable name="n" select = "*[4]"/>
+ <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
+ <xsl:variable name="m" select = "*[3]"/>
+ <xsl:copy-of select = "*[2]/*[position()=$m]"/>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:vectorproduct[1] | m:scalarproduct[1] | m:outerproduct[1]]">
+ <m:mrow>
+ <xsl:call-template name="insert_xref"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ <xsl:choose>
+ <xsl:when test="m:vectorproduct[1]">
+ <m:mo><xsl:call-template name="insert1"/> <mchar name="Cross"/> </m:mo>
+ </xsl:when>
+ <xsl:when test="m:scalarproduct[1] | m:outerproduct[1]">
+ <m:mo><xsl:call-template name="insert1"/>.</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!-- ====================================================== -->
+<!-- XSL Transform of MathML content to MathML presentation -->
+<!-- By Igor Rodionov, Computer Science Department of -->
+<!-- the University of Western Ontario, London, Canada -->
+<!-- Complies with the W3C Working Draft from Dec.3, 1999 -->
+<!-- Version x.xx from Feb. 18, 2000 -->
+<!-- Comments to: igor@csd.uwo.ca -->
+<!-- -->
+<!-- (C) Copyright 1999, 2000 Symbolic Computation -->
+<!-- Laboratory, University of Western Ontario. -->
+<!-- ====================================================== -->
+
+<!-- ====================================================== -->
+<!-- May 11, 2000 - HELM group: -->
+<!-- Added the namespace prefix to all the output elements -->
+<!-- Changed the mml prefix into m -->
+<!-- Swapped math element out of the semantic element -->
+<!-- Added the declaration of the xlink namespace -->
+<!-- ====================================================== -->
+
+<xsl:stylesheet id="mml2mml"
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+
+<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
+
+<!-- ***************************************************** -->
+<!-- Parameters affectin' stylesheet's run-time behavior -->
+<!-- ***************************************************** -->
+
+<!-- SEM_SW: -1 - strip off all semantics
+ 0 - pass semantics "as is" (default)
+ 1 - add semantics at top level only
+ 2 - add semantics at all levels
+ 3 - semantics at top level with cross-references
+-->
+<!-- HELM: SEM_SW was 0 -->
+<xsl:param name="SEM_SW" select="1"/>
+
+<!-- Miscellaneous Variable Definitions -->
+
+<xsl:variable name="NO" select="0"/>
+<xsl:variable name="YES" select="1"/>
+<xsl:variable name="PAR_NO" select="-7"/>
+<xsl:variable name="PAR_YES" select="-5"/>
+<xsl:variable name="PAR_SAME" select="-3"/>
+<xsl:variable name="NO_PARAM" select="-1"/>
+
+<!-- Operator Precedence Definitions -->
+
+<xsl:variable name="NO_PREC" select="0"/>
+<xsl:variable name="UNION_PREC" select="1"/>
+<xsl:variable name="SETDIFF_PREC" select="1"/>
+<xsl:variable name="INTERSECT_PREC" select="3"/>
+<xsl:variable name="OR_PREC" select="5"/>
+<xsl:variable name="XOR_PREC" select="5"/>
+<xsl:variable name="AND_PREC" select="7"/>
+<xsl:variable name="PLUS_PREC" select="9"/>
+<xsl:variable name="MINUS_PREC" select="9"/>
+<xsl:variable name="MUL_PREC" select="11"/>
+<xsl:variable name="DIV_PREC" select="11"/>
+<xsl:variable name="NEG_PREC" select="13"/>
+<xsl:variable name="FUNCTION_PREC" select="99"/>
+
+
+<!-- THE TOPMOST ELEMENT: MATH -->
+
+<xsl:template match = "m:math">
+ <xsl:choose>
+ <xsl:when test="$SEM_SW>0">
+<!-- HELM: deleted math (we have already inserted at object level) -->
+ <!--<m:math>-->
+ <m:semantics>
+ <xsl:apply-templates mode = "semantics"/>
+ <m:annotation-xml encoding="MathML">
+ <xsl:copy-of select = "*"/>
+ </m:annotation-xml>
+ </m:semantics>
+ <!--</m:math>-->
+ </xsl:when>
+ <xsl:otherwise>
+ <!--<m:math>-->
+ <xsl:apply-templates mode = "semantics"/>
+ <!--</m:math>-->
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- SEMANTICS -->
+
+<xsl:template match = "m:*" mode = "semantics">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$SEM_SW=-1 and self::m:semantics">
+ <xsl:apply-templates select="*[1]">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="$SEM_SW=0 and self::m:semantics">
+ <m:semantics>
+ <xsl:apply-templates select="*[1]">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:copy-of select="m:annotation-xml"/>
+ </m:semantics>
+ </xsl:when>
+ <xsl:when test="$SEM_SW=2">
+ <m:semantics>
+ <xsl:choose>
+ <xsl:when test="self::m:semantics">
+ <xsl:apply-templates select="*[1]">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:copy-of select="m:annotation-xml"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <m:annotation-xml encoding="MathML">
+ <xsl:copy-of select="."/>
+ </m:annotation-xml>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:semantics>
+ </xsl:when>
+ <xsl:when test="$SEM_SW=3 and @id">
+ <m:mrow idref="{@id}">
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:semantics">
+ <xsl:apply-templates select="*[1]" mode = "semantics"/>
+</xsl:template>
+
+
+<!-- BASIC ELEMENTS -->
+
+<xsl:template match = "m:cn">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test=". < 0 and $IN_PREC > 0 and $PAREN=$PAR_NO and $PAR_NO_IGNORE=$NO">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="cn"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="cn"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:cn" mode="cn">
+ <xsl:choose>
+ <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
+ <m:msub>
+ <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <xsl:apply-templates select="text()[2]" mode = "semantics"/>
+ </xsl:if>
+ <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
+ <m:mo>i</m:mo>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@type='complex' and @base and child::m:sep[1]">
+ <m:msub>
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </xsl:if>
+ <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
+ <m:mo>i</m:mo>
+ </m:mfenced>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
+ <m:mrow>
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mo>/</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mrow>
+ </xsl:when>
+ <xsl:when test="@type='rational' and @base and child::m:sep[1]">
+ <m:msub>
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mo>/</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mfenced>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
+ <m:mrow>
+ <m:mo>Polar</m:mo>
+ <m:mfenced separators=",">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mfenced>
+ </m:mrow>
+ </xsl:when>
+ <xsl:when test="@type='polar' and @base and child::m:sep[1]">
+ <m:msub>
+ <m:mrow>
+ <m:mo>Polar</m:mo>
+ <m:mfenced separators=",">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
+ </m:mfenced>
+ </m:mrow>
+ <m:mn> <xsl:value-of select="@base"/> </m:mn>
+ </m:msub>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:ci">
+ <xsl:choose>
+ <xsl:when test="@type='vector' or @type=matrix or @type=set">
+ <m:mi fontweight="bold"> <xsl:apply-templates mode = "semantics"/> </m:mi>
+ </xsl:when>
+ <xsl:otherwise>
+<!-- HELM: aggiunta choose temporanea per HREF invece di:
+<m:mi> <xsl:apply-templates mode = "semantics"/> </m:mi>-->
+ <xsl:choose>
+ <xsl:when test="string(@definitionURL) = """>
+ <m:mi> <xsl:apply-templates mode = "semantics"/> </m:mi>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mi xlink:href="{@definitionURL}"> <xsl:apply-templates mode = "semantics"/> </m:mi>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:csymbol">
+ <xsl:choose>
+ <xsl:when test="*[1]">
+ <xsl:copy-of select = "*"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo> <xsl:apply-templates mode = "semantics"/> </m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- BASIC CONTENT ELEMENTS -->
+
+<xsl:template match = "m:apply[m:fn[1]]">
+ <m:mrow>
+ <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
+ <m:mfenced separators=",">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:fn">
+ <xsl:apply-templates select = "*[1]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:interval">
+ <xsl:choose>
+ <xsl:when test="@closure='closed'">
+ <m:mfenced open="[" close="]" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@closure='open'">
+ <m:mfenced separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@closure='open-closed'">
+ <m:mfenced open="(" close="]" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="@closure='closed-open'">
+ <m:mfenced open="[" close=")" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mfenced open="[" close="]" separators=",">
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mfenced>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
+ <m:mrow>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <m:mfenced separators=",">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:inverse]]">
+ <xsl:choose>
+ <xsl:when test="*[2]=m:exp">
+ <m:mo>ln</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:ln | m:log">
+ <m:mo>exp</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sin">
+ <m:mo>arcsin</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:cos">
+ <m:mo>arccos</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:tan">
+ <m:mo>arctan</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sec">
+ <m:mo>arcsec</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:csc">
+ <m:mo>arccsc</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:cot">
+ <m:mo>arccot</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sinh">
+ <m:mo>arcsinh</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:cosh">
+ <m:mo>arccosh</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:tanh">
+ <m:mo>arctanh</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:sech">
+ <m:mo>arcsech</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:csch">
+ <m:mo>arccsch</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:coth">
+ <m:mo>arccoth</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:arcsin">
+ <m:mo>sin</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:arccos">
+ <m:mo>cos</m:mo>
+ </xsl:when>
+ <xsl:when test="*[2]=m:arctan">
+ <m:mo>tan</m:mo>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mfenced>
+ <m:mn>-1</m:mn>
+ </m:mfenced>
+ </m:msup>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:sep"/>
+
+<xsl:template match = "m:condition">
+ <xsl:choose>
+ <xsl:when test="parent::m:apply[m:forall[1]]"/>
+ <xsl:otherwise>
+ <xsl:if test="not(*[2])">
+ <xsl:apply-templates mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="*[2]">
+ <m:mrow>
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mrow>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:declare"/>
+
+<xsl:template match = "m:lambda">
+ <m:mrow>
+ <m:mo> Λ </m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*">
+ <xsl:choose>
+ <xsl:when test="self::m:ci or self::m:cn">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:*[1][self::m:apply[m:compose[1]]]]">
+ <m:mrow>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <m:mfenced separators=",">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:compose]]">
+ <m:mfenced separators="">
+ <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] | self::m:fn]" mode="semantics"/>
+ <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] | self::m:fn]">
+ <m:mo> <mchar name="SmallCircle"/> </m:mo>
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:ident">
+ <m:mo>id</m:mo>
+</xsl:template>
+
+
+<!-- ARITHMETIC, ALGEBRA & LOGIC -->
+
+<xsl:template match = "m:apply[m:quotient[1]]">
+ <m:mfenced open="⌊" close="⌋" separators="">
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ <m:mo>/</m:mo>
+ <xsl:apply-templates select="*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:exp]]">
+ <m:msup>
+ <m:mo>e</m:mo>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:msup>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:factorial[1]]">
+ <m:mrow>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ <m:mo>!</m:mo>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:max[1] | m:min[1]]">
+ <m:mrow>
+ <xsl:if test="*[2]=m:bvar">
+ <m:munder>
+ <xsl:if test="*[1]=m:max">
+ <m:mo>max</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:min">
+ <m:mo>min</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </m:munder>
+ <xsl:if test="*[3]=m:condition">
+ <m:mfenced open="{{" close="}}" separators="">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*[position()>3]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:if>
+ <xsl:if test="not(*[3]=m:condition)">
+ <m:mfenced open="{{" close="}}" separators=",">
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </xsl:if>
+ </xsl:if>
+ <xsl:if test="*[2]=m:condition">
+ <xsl:if test="*[1]=m:max">
+ <m:mo>max</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:min">
+ <m:mo>min</m:mo>
+ </xsl:if>
+ <m:mfenced open="{{" close="}}" separators="">
+ <xsl:if test="*[3]">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mo>|</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
+ <xsl:if test="*[1]=m:max">
+ <m:mo>max</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:min">
+ <m:mo>min</m:mo>
+ </xsl:if>
+ <m:mfenced open="{{" close="}}" separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </xsl:if>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $MINUS_PREC or $IN_PREC=$MINUS_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="minus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="minus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="minus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]" mode="minus">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:if test="not(*[3])">
+ <m:mo>-</m:mo>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:if test="*[3]">
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <m:mo>-</m:mo>
+ <xsl:apply-templates select="*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+ <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $PLUS_PREC or $IN_PREC=$PLUS_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="plus">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="plus">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="plus">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]" mode="plus">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:if test="*[2]">
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:choose>
+ <xsl:when test=". < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-."/> </m:mn>
+ </xsl:when>
+ <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>+</m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:power[1]]">
+ <xsl:choose>
+ <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] | m:gcd[1] | m:sin[1] | m:cos[1] | m:tan[1] | m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] | m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] | m:coth[1] | m:arcsin[1] | m:arccos[1] | m:arctan[1]]">
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $DIV_PREC or $IN_PREC=$DIV_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="remdiv">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="remdiv">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="remdiv">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:if test="m:rem">
+ <m:mo>%</m:mo>
+ </xsl:if>
+ <xsl:if test="m:divide">
+ <m:mo>/</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+ <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $MUL_PREC or $IN_PREC=$MUL_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="times">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="times">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="times">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]" mode="times">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:if test="*[3]">
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:root[1]]">
+ <m:msqrt>
+ <xsl:if test="*[2]=m:degree">
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:degree)">
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ <m:mn>2</m:mn>
+ </xsl:if>
+ </m:msqrt>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:gcd[1]]">
+ <m:mrow>
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <m:mo>gcd</m:mo>
+ </xsl:if>
+ <xsl:if test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <m:mo>gcd</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $AND_PREC">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="and">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="and">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="and">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]" mode="and">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo> <mchar name="wedge"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $OR_PREC">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="or">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="or">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="or">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]" mode="or">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo> <mchar name="vee"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $XOR_PREC">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="xor">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAR_YES"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="xor">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="xor">
+ <xsl:with-param name="PARAM" select="$IN_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]" mode="xor">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo> <mchar name="xor"/> </m:mo>
+ <xsl:apply-templates select="." mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:not[1]]">
+ <m:mrow>
+ <m:mo>not</m:mo>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:forall[1]]">
+ <m:mrow>
+ <m:mo>for all</m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "m:bvar">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <xsl:if test="m:condition">
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+ <m:mo>,</m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:exists[1]]">
+ <m:mrow>
+ <m:mo> <mchar name="Exists"/> </m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "m:bvar">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <xsl:if test="m:condition">
+ <m:mo>,</m:mo>
+ <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+ </xsl:if>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:abs[1]]">
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <m:mfenced open="|" close="|" separators="">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:if>
+ <xsl:if test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <m:mfenced open="|" close="|" separators="">
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mfenced>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:conjugate[1]]">
+ <m:mover>
+ <m:mrow>
+ <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+ </m:mrow>
+ <m:mo> <mchar name="UnderBar"/> </m:mo>
+ </m:mover>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="m:arg">
+ <m:mo>arg</m:mo>
+ </xsl:when>
+ <xsl:when test="m:real">
+ <m:mo>Real</m:mo>
+ </xsl:when>
+ <xsl:when test="m:imaginary">
+ <m:mo>Imaginary</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <m:mfenced separators="">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- RELATIONS -->
+
+<xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies | m:in | m:notin | m:notsubset | m:notprsubset | m:subset | m:prsubset | m:eq | m:gt | m:lt | m:geq | m:leq | m:equivalent]">
+ <m:mrow>
+ <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:tendsto or *[1]=m:implies or *[1]=m:in or *[1]=m:notin or *[1]=m:notsubset or *[1]=m:notprsubset">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <xsl:if test="*[1]=m:neq">
+ <m:mo> <mchar name="NotEqual"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:approx">
+ <m:mo> <mchar name="approxeq"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:tendsto">
+ <m:mo> <mchar name="RightArrow"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:implies">
+ <m:mo> <mchar name="DoubleRightArrow"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:in">
+ <m:mo> <mchar name="Element"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notin">
+ <m:mo> <mchar name="NotElement"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notsubset">
+ <m:mo> <mchar name="NotSubset"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notprsubset">
+ <m:mo> <mchar name="NotSubsetEqual"/> </m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
+ <m:mo>-</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
+ <m:mo>+</m:mo>
+ </xsl:if>
+ </xsl:if>
+ <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
+ <xsl:apply-templates select = "*[2]" mode="semantics"/>
+ <xsl:for-each select = "*[position()>2]">
+ <xsl:if test="../*[self::m:subset][1]">
+ <m:mo> <mchar name="SubsetEqual"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:prsubset][1]">
+ <m:mo> <mchar name="subset"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:eq][1]">
+ <m:mo>=</m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:gt][1]">
+ <m:mo>></m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:lt][1]">
+ <m:mo><</m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:geq][1]">
+ <m:mo> <mchar name="geq"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:leq][1]">
+ <m:mo> <mchar name="leq"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="../*[self::m:equivalent][1]">
+ <m:mo> <mchar name="Congruent"/> </m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </xsl:if>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- CALCULUS -->
+
+<xsl:template match = "m:apply[*[1][self::m:ln]]">
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <m:mo>ln</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>ln</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:log[1]]">
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="parent::m:apply[m:power[1]]">
+ <xsl:if test="not(*[2]=m:logbase)">
+ <m:msup>
+ <m:mo>log</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <xsl:if test="*[2]=m:logbase">
+ <m:msubsup>
+ <m:mo>log</m:mo>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+ </m:msubsup>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="not(*[2]=m:logbase)">
+ <m:mo>log</m:mo>
+ </xsl:if>
+ <xsl:if test="*[2]=m:logbase">
+ <m:msub>
+ <m:mo>log</m:mo>
+ <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+ </m:msub>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="*[2]=m:logbase">
+ <xsl:apply-templates select = "*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:logbase)">
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:diff[1]]">
+ <m:mrow>
+ <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
+ <m:mfrac>
+ <m:msup>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+ </m:msup>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <m:msup>
+ <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+ <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+ </m:msup>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
+ <m:mfrac>
+ <m:mo>d</m:mo>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:partialdiff[1]]">
+ <m:mrow>
+ <xsl:for-each select = "m:bvar">
+ <xsl:if test="*[last()]=m:degree">
+ <m:mfrac>
+ <m:msup>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+ </m:msup>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <m:msup>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+ </m:msup>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ <xsl:if test="not(*[last()]=m:degree)">
+ <m:mfrac>
+ <m:mo>d</m:mo>
+ <m:mrow>
+ <m:mo>d</m:mo>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ </m:mrow>
+ </m:mfrac>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
+ <xsl:apply-templates mode = "semantics"/>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
+ <m:mrow>
+ <xsl:if test="*[1]=m:divergence">
+ <m:mo>div</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:grad">
+ <m:mo>grad</m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:curl">
+ <m:mo>curl</m:mo>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="*[2]=m:ci">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mfenced separators="">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mfenced>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:laplacian[1]]">
+ <m:mrow>
+ <m:msup>
+ <m:mo> Δ </m:mo>
+ <m:mn>2</m:mn>
+ </m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- SET THEORY -->
+
+<xsl:template match = "m:set | m:list">
+ <m:mfenced open="{{" close="}}" separators="">
+ <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
+ <xsl:apply-templates select="m:bvar" mode = "semantics"/>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="m:condition" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="m:condition" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
+ <m:mfenced open="" close="" separators=",">
+ <xsl:for-each select = "*">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </xsl:if>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $UNION_PREC or $IN_PREC=$UNION_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="union">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="union">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="union">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]" mode="union">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo> <mchar name="Union"/> </m:mo>
+ <xsl:apply-templates select = "." mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $INTERSECT_PREC">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="intersect">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="intersect">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="intersect">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mo> <mchar name="Intersection"/> </m:mo>
+ <xsl:apply-templates select = "." mode="semantics">
+ <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]">
+ <xsl:param name="IN_PREC" select="$NO_PREC"/>
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:choose>
+ <xsl:when test="$IN_PREC > $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC and $PARAM=$PAR_SAME">
+ <m:mfenced separators="">
+ <xsl:apply-templates select="." mode="setdiff">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mfenced>
+ </xsl:when>
+ <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
+ <xsl:apply-templates select="." mode="setdiff">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:apply-templates select="." mode="setdiff">
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
+ <xsl:param name="PARAM" select="$NO_PARAM"/>
+ <xsl:param name="PAREN" select="$PAR_NO"/>
+ <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+ <xsl:with-param name="PARAM" select="$PARAM"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+ </xsl:apply-templates>
+ <m:mo>\</m:mo>
+ <xsl:apply-templates select = "*[3]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+ <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+ <xsl:with-param name="PAREN" select="$PAREN"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:card[1]]">
+ <m:mfenced open="|" close="|" separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+</xsl:template>
+
+
+<!-- SEQUENCES AND SERIES -->
+
+<xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
+ <m:munderover>
+ <xsl:if test="*[1]=m:sum">
+ <m:mo> <mchar name="Sum"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:product">
+ <m:mo> <mchar name="Product"/> </m:mo>
+ </xsl:if>
+ <m:mrow>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo>=</m:mo>
+ <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
+ </m:mrow>
+ <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
+ </m:munderover>
+ <xsl:apply-templates select = "*[5]" mode = "semantics"/>
+ </xsl:when>
+ <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
+ <m:munder>
+ <xsl:if test="*[1]=m:sum">
+ <m:mo> <mchar name="Sum"/> </m:mo>
+ </xsl:if>
+ <xsl:if test="*[1]=m:product">
+ <m:mo> <mchar name="Product"/> </m:mo>
+ </xsl:if>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </m:munder>
+ <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+ </xsl:when>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:limit[1]]">
+ <m:mrow>
+ <m:munder>
+ <m:mo>lim</m:mo>
+ <m:mrow>
+ <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo> <mchar name="RightArrow"/> </m:mo>
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </xsl:if>
+ <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
+ <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+ </xsl:if>
+ </m:mrow>
+ </m:munder>
+ <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- TRIGONOMETRY -->
+
+<xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos | self::m:tan | self::m:sec | self::m:csc | self::m:cot | self::m:sinh | self::m:cosh | self::m:tanh | self::m:sech | self::m:csch | self::m:coth | self::m:arcsin | self::m:arccos | self::m:arctan]]">
+ <m:mrow>
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+ </xsl:if>
+ <xsl:if test="parent::m:apply[m:power[1]]">
+ <m:msup>
+ <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+ <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <xsl:apply-templates select = "*[2]" mode = "semantics">
+ <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+ <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+ </xsl:apply-templates>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:*" mode = "trigonometry">
+ <xsl:choose>
+ <xsl:when test="self::m:sin">
+ <m:mo>sin</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:cos">
+ <m:mo>cos</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:tan">
+ <m:mo>tan</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:sec">
+ <m:mo>sec</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:csc">
+ <m:mo>csc</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:cot">
+ <m:mo>cot</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:sinh">
+ <m:mo>sinh</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:cosh">
+ <m:mo>cosh</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:tanh">
+ <m:mo>tanh</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:sech">
+ <m:mo>sech</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:csch">
+ <m:mo>csch</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:coth">
+ <m:mo>coth</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:arcsin">
+ <m:mo>arcsin</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:arccos">
+ <m:mo>arccos</m:mo>
+ </xsl:when>
+ <xsl:when test="self::m:arctan">
+ <m:mo>arctan</m:mo>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- STATISTICS -->
+
+<xsl:template match = "m:apply[m:mean[1]]">
+ <m:mfenced open="<" close=">" separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:sdev[1]]">
+ <m:mrow>
+ <m:mo> σ </m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:variance[1]]">
+ <m:mrow>
+ <m:mo> σ </m:mo>
+ <m:msup>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ <m:mn>2</m:mn>
+ </m:msup>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:median[1]]">
+ <m:mrow>
+ <m:mo>median</m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:mode[1]]">
+ <m:mrow>
+ <m:mo>mode</m:mo>
+ <m:mfenced separators=",">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:moment[1]]">
+ <m:mfenced open="<" close=">" separators="">
+ <xsl:if test="*[2]=m:degree">
+ <m:msup>
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ </m:msup>
+ </xsl:if>
+ <xsl:if test="not(*[2]=m:degree)">
+ <xsl:for-each select = "*[position()>1]">
+ <xsl:apply-templates select = "." mode="semantics"/>
+ </xsl:for-each>
+ </xsl:if>
+ </m:mfenced>
+</xsl:template>
+
+
+<!-- LINEAR ALGEBRA -->
+
+<xsl:template match="m:vector">
+ <m:mfenced separators="">
+ <m:mtable>
+ <xsl:for-each select="*">
+ <m:mtd>
+ <xsl:apply-templates select="." mode = "semantics"/>
+ </m:mtd>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrix">
+ <m:mfenced separators="">
+ <m:mtable>
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mtable>
+ </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrixrow">
+ <m:mtr>
+ <xsl:for-each select="*">
+ <m:mtd>
+ <xsl:apply-templates select="." mode = "semantics"/>
+ </m:mtd>
+ </xsl:for-each>
+ </m:mtr>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:determinant[1]]">
+ <m:mrow>
+ <m:mo>det</m:mo>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:transpose[1]]">
+ <m:msup>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo>T</m:mo>
+ </m:msup>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:selector[1]]">
+ <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
+ <xsl:variable name="m" select = "*[3]"/>
+ <xsl:choose>
+ <xsl:when test="*[4]=m:cn">
+ <xsl:variable name="n" select = "*[4]"/>
+ <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
+ <xsl:variable name="m" select = "*[3]"/>
+ <xsl:copy-of select = "*[2]/*[position()=$m]"/>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:vectorproduct[1] | m:scalarproduct[1] | m:outerproduct[1]]">
+ <m:mrow>
+ <xsl:apply-templates select="*[2]" mode = "semantics"/>
+ <xsl:choose>
+ <xsl:when test="m:vectorproduct[1]">
+ <m:mo> <mchar name="Cross"/> </m:mo>
+ </xsl:when>
+ <xsl:when test="m:scalarproduct[1] | m:outerproduct[1]">
+ <m:mo>.</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="*[3]" mode = "semantics"/>
+ </m:mrow>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
+<!-- First draft: February 19 2000, Andrea Asperti, Irene Schena -->
+<!-- Revised: March 3 2000, Irene Schena -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!-- Revised: March 21 2000, Irene Schena -->
+<!--***********************************************************************-->
+
+<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">
+
+<xsl:import href="mml2mmlv1_0.xsl"/>
+
+<!--***********************************************************************-->
+<!-- Parameter affecting line-breaking -->
+<!--***********************************************************************-->
+
+<xsl:variable name="framewidth" select="30"/>
+
+<!--***********************************************************************-->
+<!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
+<!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
+<!-- sono i termini: la presentation per un termine e' generata come primo -->
+<!-- figlio di un semantics e l'originario content viene inserito nel -->
+<!-- nel secondo figlio di semantics, annotation-xml -->
+<!--***********************************************************************-->
+
+<!--**********************-->
+<!-- OBJECTS -->
+<!--**********************-->
+
+<xsl:template match="/">
+ <xsl:processing-instruction name="cocoon-format">type="text/xhtml"</xsl:processing-instruction>
+ <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<!-- DEFINITION -->
+
+<xsl:template match="Definition">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <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>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- AXIOM -->
+
+<xsl:template match="Axiom">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- UNFINISHED PROOF -->
+
+<xsl:template match="CurrentProof">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>THESIS:</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>CONJECTURES:</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="Conjecture">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
+ <xsl:apply-templates select="./*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>CORRESPONDING PROOF:</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>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- MUTUAL INDUCTIVE DEFINITION -->
+
+<xsl:template match="InductiveDefinition">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <xsl:for-each select="InductiveType">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <xsl:choose>
+ <xsl:when test="string(./@inductive) = "true"">
+ <m:mtext>INDUCTIVE DEFINITION</m:mtext>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>AND</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtext>[</m:mtext>
+ <xsl:choose>
+ <xsl:when test="string(../Param) != """>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="../Param">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="./@name"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="*"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>]</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>]</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>OF ARITY</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="./arity/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>BUILT FROM</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="./Constructor">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>|</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="./*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </xsl:for-each>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- VARIABLE -->
+
+<xsl:template match="Variable">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!--**********************-->
+<!-- TERMS -->
+<!--**********************-->
+
+<xsl:template match="m:bvar">
+ <xsl:choose>
+ <xsl:when test="m:type">
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:ci" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <xsl:apply-templates select="m:ci"/>
+ <m:mo>:</m:mo>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <xsl:apply-templates select="m:type"/>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="m:ci"/>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="m:ci"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- CSYMBOL -->
+
+<xsl:template match="m:apply[m:csymbol]">
+ <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:if test="@helm:xref">
+ <xsl:attribute name="helm:xref"><xsl:value-of select="@helm:xref"/></xsl:attribute>
+ </xsl:if>
+ <xsl:choose>
+ <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">Π</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 color="Blue">Π</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='arrow'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="Blue">→</m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <m:mo color="Blue">→</m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='app'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:for-each select="*[position()>2]">
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cast'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="#b03060">:></m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <m:mo color="#b03060">:></m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='Prop'">
+ <m:mo>Prop</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='Set'">
+ <m:mo>Set</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='Type'">
+ <m:mo>Type</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='mutcase'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo><</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:if test="$framewidth > $charlength">
+ <m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>OF</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">|</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ <xsl:if test="$framewidth > $charlength">
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>END</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mo>OF</m:mo>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:choose>
+ <xsl:when test="position() != 1">
+ <m:mo stretchy="false">|</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="."/>
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </xsl:for-each>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mo>END</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='fix'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>FIX</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()=1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>FIX</m:mo>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:if test="position()=last()">
+ <m:mo stretchy="false">}</m:mo>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cofix'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>COFIX</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>COFIX</m:mo>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:if test="position()=last()">
+ <m:mo stretchy="false">}</m:mo>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!-- ***************************************** -->
+ <!-- *********** PROOF ELEMENTS ************** -->
+ <!-- ***************************************** -->
+ <xsl:when test="$name='proof'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext color="#b03060">we proved </m:mtext>
+ <xsl:apply-templates select="*[position()=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')]"> -->
+ <xsl:for-each select="*[(last() > position()) and (position()>1)]">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="*[position()=last()]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:when test="$name='let'">
+ <m:mtext>(</m:mtext>
+ <xsl:apply-templates select="m:ci"/>
+ <m:mtext>) </m:mtext>
+ <xsl:apply-templates select="*[3]"/>
+ </xsl:when>
+ <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>
+ <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>
+ <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]"/>
+ <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]"/>
+ <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>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()>3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:when test="$name='and_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>
+ <xsl:apply-templates select="*[2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mtext>In particular, we have</m:mtext>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>(</m:mtext>
+ <xsl:apply-templates select="*[3]"/>
+ <m:mtext>)</m:mtext>
+ <xsl:apply-templates select="*[4]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>(</m:mtext>
+ <xsl:apply-templates select="*[5]"/>
+ <m:mtext>)</m:mtext>
+ <xsl:apply-templates select="*[6]"/>
+ </m:mrow>
+ </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:when test="$name='or_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>We prove</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>by cases:</m:mtext>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>*</m:mtext>
+ <xsl:apply-templates select="*[4]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>*</m:mtext>
+ <xsl:apply-templates select="*[5]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:ci>ERROR</m:ci>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match="*" mode="thread">
+ <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$name='rw_step'">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>Rewrite</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
+ <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="following-sibling::*[position()=1]/*[3]"/>
+ <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="following-sibling::*[position()=1]/*[4]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="following-sibling::*[position()=1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
+</xsl:template>
+
+
+<!-- LAMBDA -->
+
+<xsl:template match="m:lambda">
+ <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
+ <m:mrow helm:xref="{@helm:xref}">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo color="Red">λ</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()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo color="Red">λ</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()=2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<!-- *********************************** -->
+<!-- BASE SET OF MATHML CONTENT ELEMENTS -->
+<!-- *********************************** -->
+
+<!-- Logic -->
+
+<xsl:template match = "m:apply[m:eq[1]]">
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:if test="@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mo helm:xref="m:in/@helm:xref">
+ =
+ </m:mo>
+ <xsl:apply-templates select="."/>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<xsl:template match = "m:apply[m:and[1]|m:or[1]
+ |m:geq[1]|m:leq[1]|m:gt[1]|m:lt[1]
+ |m:in[1]|m:intesect[1]|m:union[1]|m:subset[1]
+ |m:prsubset|m:setdiff[1]]">
+ <xsl:variable name="symbol">
+ <xsl:choose>
+ <xsl:when test="m:and[1]">
+ <xsl:value-of select="'wedge'"/>
+ </xsl:when>
+ <xsl:when test="m:or[1]">
+ <xsl:value-of select="'vee'"/>
+ </xsl:when>
+ <xsl:when test="m:geq[1]">
+ <xsl:value-of select="'geq'"/>
+ </xsl:when>
+ <xsl:when test="m:leq[1]">
+ <xsl:value-of select="'leq'"/>
+ </xsl:when>
+ <xsl:when test="m:gt[1]">
+ <xsl:value-of select="'gt'"/>
+ </xsl:when>
+ <xsl:when test="m:lt[1]">
+ <xsl:value-of select="'lt'"/>
+ </xsl:when>
+ <xsl:when test="m:eq[1]">
+ <xsl:value-of select="'Equal'"/>
+ </xsl:when>
+ <xsl:when test="m:in[1]">
+ <xsl:value-of select="'Element'"/>
+ </xsl:when>
+ <xsl:when test="m:subset[1]">
+ <xsl:value-of select="'SubsetEqual'"/>
+ </xsl:when>
+ <xsl:when test="m:prsubset[1]">
+ <xsl:value-of select="'subset'"/>
+ </xsl:when>
+ <xsl:when test="m:intersect[1]">
+ <xsl:value-of select="'Intersection'"/>
+ </xsl:when>
+ <xsl:when test="m:union[1]">
+ <xsl:value-of select="'Union'"/>
+ </xsl:when>
+ <xsl:when test="m:setdiff[1]">
+ <xsl:value-of select="'Backslash'"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:if test="@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mo helm:xref="{*[1]/@helm:xref}">
+ <m:mchar name="{$symbol}"/>
+ </m:mo>
+ <xsl:apply-templates select="."/>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:set">
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 0">
+ <m:mo>
+ <m:mchar name="EmptySet"/>
+ </m:mo>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:choose>
+ <xsl:when test="name(*[1]) = 'm:bvar'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">{</m:mo>
+ <xsl:apply-templates select="*[position()=1]"/>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
+ <m:mo stretchy="false">|</m:mo>
+ <xsl:apply-templates select="m:condition/*[1]"/>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">{</m:mo>
+ <xsl:apply-templates select="*[position()=1]"/>
+ <xsl:if test="position() != last()">
+ <mo>,</mo>
+ </xsl:if>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ <xsl:if test="position() != last()">
+ <mo>,</mo>
+ </xsl:if>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:card[1]]">
+ <m:mo stretchy="false">|</m:mo>
+ <xsl:apply-templates select="*[2]"/>
+ <m:mo stretchy="false">|</m:mo>
+</xsl:template>
+
+<!-- *********************************** -->
+<!-- PROOF ELEMENTS -->
+<!-- *********************************** -->
+
+
+
+<!--**********************-->
+<!-- COUNTING -->
+<!--**********************-->
+
+<xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
+ |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
+ |m:plus|m:minus|m:times" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
+ <xsl:variable name="siblength">
+ <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
+ <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
+ </xsl:apply-templates>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="m:ci|m:csymbol" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 0">
+ <xsl:value-of select="$incurrent_length"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="childlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/><xsl:with-param name="nosibling" select="0"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$childlength"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
+<!-- First draft: February 19 2000, Andrea Asperti, Irene Schena -->
+<!-- Revised: March 3 2000, Irene Schena -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!-- Revised: March 21 2000, Irene Schena -->
+<!--***********************************************************************-->
+
+<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">
+
+<xsl:import href="mml2mmlv1_0.xsl"/>
+
+<!--***********************************************************************-->
+<!-- Parameter affecting line-breaking -->
+<!--***********************************************************************-->
+
+<xsl:variable name="framewidth" select="15"/>
+
+<!--***********************************************************************-->
+<!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
+<!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
+<!-- sono i termini: la presentation per un termine e' generata come primo -->
+<!-- figlio di un semantics e l'originario content viene inserito nel -->
+<!-- nel secondo figlio di semantics, annotation-xml -->
+<!--***********************************************************************-->
+
+<!--**********************-->
+<!-- OBJECTS -->
+<!--**********************-->
+
+<xsl:template match="/">
+ <xsl:processing-instruction name="cocoon-format">type="text/xhtml"</xsl:processing-instruction>
+ <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<!-- DEFINITION -->
+
+<xsl:template match="Definition">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <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>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- AXIOM -->
+
+<xsl:template match="Axiom">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- UNFINISHED PROOF -->
+
+<xsl:template match="CurrentProof">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>THESIS:</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>CONJECTURES:</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="Conjecture">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
+ <xsl:apply-templates select="./*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>CORRESPONDING PROOF:</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>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- MUTUAL INDUCTIVE DEFINITION -->
+
+<xsl:template match="InductiveDefinition">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <xsl:for-each select="InductiveType">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <xsl:choose>
+ <xsl:when test="string(./@inductive) = "true"">
+ <m:mtext>INDUCTIVE DEFINITION</m:mtext>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>AND</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtext>[</m:mtext>
+ <xsl:choose>
+ <xsl:when test="string(../Param) != """>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="../Param">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="./@name"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="*"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>]</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>]</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>OF ARITY</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="./arity/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>BUILT FROM</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="./Constructor">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>|</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="./*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </xsl:for-each>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- VARIABLE -->
+
+<xsl:template match="Variable">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!--**********************-->
+<!-- TERMS -->
+<!--**********************-->
+
+<xsl:template match="m:bvar">
+ <xsl:choose>
+ <xsl:when test="m:type">
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="m:ci" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <xsl:apply-templates select="m:ci"/>
+ <m:mo>:</m:mo>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <xsl:apply-templates select="m:type"/>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="m:ci"/>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="m:ci"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- CSYMBOL -->
+
+<xsl:template match="m:apply[m:csymbol]">
+ <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:if test="@helm:xref">
+ <xsl:attribute name="helm:xref"><xsl:value-of select="@helm:xref"/></xsl:attribute>
+ </xsl:if>
+ <xsl:choose>
+ <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">Π</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 color="Blue">Π</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='arrow'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="Blue">→</m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <m:mo color="Blue">→</m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='app'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:for-each select="*[position()>2]">
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cast'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="#b03060">:></m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <m:mo color="#b03060">:></m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='Prop'">
+ <m:mo>Prop</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='Set'">
+ <m:mo>Set</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='Type'">
+ <m:mo>Type</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='mutcase'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo><</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:if test="$framewidth > $charlength">
+ <m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>OF</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">|</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ <xsl:if test="$framewidth > $charlength">
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>END</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mo>OF</m:mo>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:choose>
+ <xsl:when test="position() != 1">
+ <m:mo stretchy="false">|</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="."/>
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </xsl:for-each>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mo>END</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='fix'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>FIX</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()=1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>FIX</m:mo>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:if test="position()=last()">
+ <m:mo stretchy="false">}</m:mo>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cofix'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>COFIX</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>COFIX</m:mo>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:if test="position()=last()">
+ <m:mo stretchy="false">}</m:mo>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<!-- LAMBDA -->
+
+<xsl:template match="m:lambda">
+ <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
+ <m:mrow helm:xref="{@helm:xref}">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo color="Blue">λ</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()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo color="Red">λ</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()=2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<!-- *********************************** -->
+<!-- BASE SET OF MATHML CONTENT ELEMENTS -->
+<!-- *********************************** -->
+
+<!-- Logic -->
+
+<xsl:template match = "m:apply[m:and[1]|m:or[1]
+ |m:geq[1]|m:leq[1]|m:gt[1]|m:lt[1]|m:eq[1]
+ |m:intesect[1]|m:union[1]|m:subset[1]|m:prsubset]">
+ <xsl:variable name="symbol">
+ <xsl:choose>
+ <xsl:when test="m:and[1]">
+ <xsl:value-of select="'wedge'"/>
+ </xsl:when>
+ <xsl:when test="m:or[1]">
+ <xsl:value-of select="'vee'"/>
+ </xsl:when>
+ <xsl:when test="m:geq[1]">
+ <xsl:value-of select="'geq'"/>
+ </xsl:when>
+ <xsl:when test="m:leq[1]">
+ <xsl:value-of select="'leq'"/>
+ </xsl:when>
+ <xsl:when test="m:gt[1]">
+ <xsl:value-of select="'gt'"/>
+ </xsl:when>
+ <xsl:when test="m:lt[1]">
+ <xsl:value-of select="'lt'"/>
+ </xsl:when>
+ <xsl:when test="m:eq[1]">
+ <xsl:value-of select="'eq'"/>
+ </xsl:when>
+ <xsl:when test="m:subset[1]">
+ <xsl:value-of select="'SubsetEqual'"/>
+ </xsl:when>
+ <xsl:when test="m:prsubset[1]">
+ <xsl:value-of select="'subset'"/>
+ </xsl:when>
+ <xsl:when test="m:intersect[1]">
+ <xsl:value-of select="'Intersection'"/>
+ </xsl:when>
+ <xsl:when test="m:union[1]">
+ <xsl:value-of select="'Union'"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="*[1]" mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select = "*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mo>
+ <m:mchar name="{$symbol}"/>
+ </m:mo>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:set">
+ <xsl:variable name="charlength">
+ <xsl:apply-templates select="." mode="charcount"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:choose>
+ <xsl:when test="name(*[1]) = 'm:bvar'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">{</m:mo>
+ <xsl:apply-templates select="m:bvar"/>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mo>|</m:mo>
+ <xsl:apply-templates select="m:condition"/>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">{</m:mo>
+ <xsl:apply-templates select="*[1]"/>
+ <xsl:if test="count(child::*) != 1">
+ <m:mo>,</m:mo>
+ </xsl:if>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select = "*[position()>1]">
+ <m:mtr>
+ <m:mtd>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ <xsl:if test="position() != last()">
+ <m:mo>,</m:mo>
+ </xsl:if>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!--**********************-->
+<!-- COUNTING -->
+<!--**********************-->
+
+<xsl:template match="m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
+ |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
+ <xsl:variable name="siblength">
+ <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
+ <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
+ </xsl:apply-templates>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="m:ci|m:csymbol" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:variable name="childlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/><xsl:with-param name="nosibling" select="0"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$childlength"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
+<!-- First draft: February 19 2000, Andrea Asperti, Irene Schena -->
+<!-- Revised: March 3 2000, Irene Schena -->
+<!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!-- Revised: March 21 2000, Irene Schena -->
+<!--***********************************************************************-->
+
+<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">
+
+<xsl:import href="mml2mmlv1_0.xsl"/>
+
+<!--***********************************************************************-->
+<!-- Parameter affecting line-breaking -->
+<!--***********************************************************************-->
+
+<xsl:variable name="framewidth" select="30"/>
+
+<!--***********************************************************************-->
+<!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
+<!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
+<!-- sono i termini: la presentation per un termine e' generata come primo -->
+<!-- figlio di un semantics e l'originario content viene inserito nel -->
+<!-- nel secondo figlio di semantics, annotation-xml -->
+<!--***********************************************************************-->
+
+<!--**********************-->
+<!-- OBJECTS -->
+<!--**********************-->
+
+<!-- DEFINITION -->
+
+<xsl:template match="Definition">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <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>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- AXIOM -->
+
+<xsl:template match="Axiom">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- UNFINISHED PROOF -->
+
+<xsl:template match="CurrentProof">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>THESIS:</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>CONJECTURES:</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="Conjecture">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
+ <xsl:apply-templates select="./*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>CORRESPONDING PROOF:</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>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- MUTUAL INDUCTIVE DEFINITION -->
+
+<xsl:template match="InductiveDefinition">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <xsl:for-each select="InductiveType">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <xsl:choose>
+ <xsl:when test="string(./@inductive) = "true"">
+ <m:mtext>INDUCTIVE DEFINITION</m:mtext>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>AND</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtext>[</m:mtext>
+ <xsl:choose>
+ <xsl:when test="string(../Param) != """>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="../Param">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="./@name"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="*"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>]</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>]</m:mtext>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>OF ARITY</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="./arity/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>BUILT FROM</m:mtext>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="./Constructor">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>|</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="./*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </xsl:for-each>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!-- VARIABLE -->
+
+<xsl:template match="Variable">
+ <m:math>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</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="type/*[1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </m:math>
+</xsl:template>
+
+<!--**********************-->
+<!-- TERMS -->
+<!--**********************-->
+
+<!-- CSYMBOL -->
+
+<xsl:template match="m:apply[m:csymbol]">
+ <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 helm:xref="{@helm:xref}">
+ <xsl:choose>
+ <xsl:when test="$name='prod'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:bvar/m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="Blue">Π</m:mo>
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>.</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <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 color="Blue">Π</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='arrow'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="Blue">→</m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <m:mo color="Blue">→</m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='app'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="*[position()>2]">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:for-each select="*[position()>2]">
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ </xsl:for-each>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cast'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="#b03060">:></m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">)</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">(</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <m:mo color="#b03060">:></m:mo>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mo stretchy="false">)</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='Prop'">
+ <m:mo>Prop</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='Set'">
+ <m:mo>Set</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='Type'">
+ <m:mo>Type</m:mo>
+ </xsl:when>
+ <xsl:when test="$name='mutcase'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo><</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ <xsl:if test="$framewidth > $charlength">
+ <m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>OF</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="position() = 1">
+ <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo stretchy="false">|</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="."/>
+ <xsl:if test="$framewidth > $charlength">
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ </xsl:for-each>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>END</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
+ <m:mo>CASES</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[position()=3]"/>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mo>OF</m:mo>
+ <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
+ <xsl:choose>
+ <xsl:when test="position() != 1">
+ <m:mo stretchy="false">|</m:mo>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="."/>
+ <m:mo color="Green">⇒</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
+ </xsl:for-each>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mo>END</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='fix'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>FIX</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position()=1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>FIX</m:mo>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:if test="position()=last()">
+ <m:mo stretchy="false">}</m:mo>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$name='cofix'">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>COFIX</m:mo>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo stretchy="false">}</m:mo>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>COFIX</m:mo>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo stretchy="false">{</m:mo>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <xsl:for-each select="m:bvar">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mi><xsl:value-of select="m:ci"/></m:mi>
+ <m:mo>:</m:mo>
+ <xsl:apply-templates select="m:type"/>
+ <m:mo>:=</m:mo>
+ <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
+ <xsl:if test="position()=last()">
+ <m:mo stretchy="false">}</m:mo>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:for-each>
+ </m:mtable>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<!-- LAMBDA -->
+
+<xsl:template match="m:lambda">
+ <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
+ <m:mrow helm:xref="{@helm:xref}">
+ <xsl:choose>
+ <xsl:when test="$charlength >= $framewidth">
+ <xsl:variable name="charlength"><xsl:apply-templates select="m:bvar/m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo color="Red">λ</m:mo>
+<!--<xsl:text disable-output-escaping="yes">&lambda;</xsl:text>-->
+ <xsl:apply-templates select="m:bvar/m:ci"/>
+ <m:mo>:</m:mo>
+ <xsl:if test="$framewidth > $charlength">
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ </xsl:if>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:if test="$charlength >= $framewidth">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mphantom><m:mtext>.</m:mtext></m:mphantom>
+ <xsl:apply-templates select="m:bvar/m:type"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </xsl:if>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mo>.</m:mo>
+ <xsl:apply-templates select="*[position()=2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo color="Red">λ</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()=2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+</xsl:template>
+
+<!--**********************-->
+<!-- COUNTING -->
+<!--**********************-->
+
+<xsl:template match="m:ci|m:csymbol" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$incurrent_length + string-length()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/>
+<xsl:param name="nosibling" select="0"/>
+ <xsl:variable name="childlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/><xsl:with-param name="nosibling" select="0"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
+ <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$childlength"/></xsl:apply-templates></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="string($siblength) = """>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($siblength)"/>
+ </xsl:otherwise>
+ </xsl:choose>>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="number($childlength)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- XSLT version 0.1 of CIC objects to objects and MathML content: -->
+<!-- First draft: March 21 2000, Irene Schena -->
+<!--******************************************************************-->
+
+<!--******************************************************************-->
+<!-- MANCA: gestione annotation e linking -->
+<!--******************************************************************-->
+
+<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">
+
+<xsl:import href="content.xsl"/>
+
+<!-- ROOT -->
+
+<xsl:template match="cicxml">
+ <xsl:variable name="url"><xsl:value-of select="@baseurl"/></xsl:variable>
+ <xsl:variable name="stylesheet"><xsl:value-of select="@stylesheet"/></xsl:variable>
+ <xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>
+ <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select='concat($url,$stylesheet)'/>" type="text/xsl"</xsl:processing-instruction>
+ <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
+ <xsl:apply-templates select="*[1]"/>
+</xsl:template>
+
+<!-- CIC OBJECTS -->
+
+<xsl:template match="Definition" mode="noannot">
+ <Definition name="{@name}" helm:xref="{@id}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+<!-- <xsl:choose>
+ <xsl:when test="$showproof=0">
+ <body>
+ <m:mi>Here</m:mi>
+ </body>
+ </xsl:when>
+ <xsl:otherwise>
+ <body>
+ <xsl:apply-templates select="body"/>
+ </body>
+ </xsl:otherwise>
+ </xsl:choose> -->
+ <body>
+ <xsl:apply-templates select="body"/>
+ </body>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Definition>
+</xsl:template>
+
+<xsl:template match="Axiom" mode="noannot">
+ <Axiom name="{@name}" helm:xref="{@id}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Axiom>
+</xsl:template>
+
+<xsl:template match="CurrentProof" mode="noannot">
+ <CurrentProof name="{@name}" helm:xref="{@id}">
+ <xsl:for-each select="Conjecture">
+ <Conjecture no="./{@no}">
+ <xsl:apply-templates select="."/>
+ </Conjecture>
+ </xsl:for-each>
+ <body>
+ <xsl:apply-templates select="body"/>
+ </body>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </CurrentProof>
+</xsl:template>
+
+<xsl:template match="InductiveDefinition" mode="noannot">
+ <InductiveDefinition helm:xref="{@id}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <xsl:if test="string(@noParams) != 0">
+ <xsl:apply-templates select="InductiveType/arity/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="@noParams"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:for-each select="InductiveType">
+ <InductiveType name="{./@name}" inductive="{./@inductive}">
+ <arity>
+ <xsl:apply-templates select="./arity/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="../@noParams"/>
+ <xsl:with-param name="target" select="1"/>
+ </xsl:apply-templates>
+ </arity>
+ <xsl:for-each select="./Constructor">
+ <Constructor name="{./@name}">
+ <xsl:apply-templates select="./*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="../../@noParams"/>
+ <xsl:with-param name="target" select="1"/>
+ </xsl:apply-templates>
+ </Constructor>
+ </xsl:for-each>
+ </InductiveType>
+ </xsl:for-each>
+ </InductiveDefinition>
+</xsl:template>
+
+<xsl:template match="Variable" mode="noannot">
+ <Variable name="{@name}" helm:xref="{@id}">
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Variable>
+</xsl:template>
+
+<!--*******************************************-->
+<!-- ABSTRACTING PARAMETERS AND COUNTING -->
+<!--*******************************************-->
+<!-- Si dimentica i CAST dei termini che astrae. Nel caso dell'astrazione -->
+<!-- dei lambda dei pattern del CASE, qualora i lambda non si trovino -->
+<!-- nella forma weak-head, astrae solo i lambda che trova e restituisce -->
+<!-- un corpo depurato da tutti i primi cast che precedono il termine -->
+<!-- restituito. -->
+
+<xsl:template match="*" mode="abstparams">
+<xsl:param name="noparams" select="0"/>
+<xsl:param name="target" select="0"/>
+<xsl:param name="binder">PROD</xsl:param>
+ <xsl:choose>
+ <xsl:when test="($noparams != 0) and ((name(.)=string($binder)) or (name(.)="CAST"))">
+ <xsl:choose>
+ <xsl:when test="name(.) = string($binder)">
+ <xsl:if test="$target = 0">
+ <xsl:choose>
+ <xsl:when test="string($binder) = "LAMBDA"">
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <Param name="{target/@binder}">
+ <xsl:apply-templates select="source" mode="noannot"/>
+ </Param>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:apply-templates select="target/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="$noparams - 1"/>
+ <xsl:with-param name="target" select="$target"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="term/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="target" select="$target"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="($target = 1) and ($noparams != 0)">
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="." mode="noannot"/>
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$noparams != 0">
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$target = 1">
+ <xsl:apply-templates select="." mode="noannot"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="printparam">
+<xsl:param name="noleft" select="0"/>
+<xsl:param name="number" select="1"/>
+ <xsl:if test="$noleft != 0">
+ <m:ci>$<xsl:value-of select="$number"/></m:ci>
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noleft - 1"/><xsl:with-param name="number" select="$number + 1"/></xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="*" mode="counting">
+<xsl:param name="noparams" select="0"/>
+<xsl:param name="count" select="0"/>
+ <xsl:choose>
+ <xsl:when test="name(.) = "PROD"">
+ <xsl:apply-templates select="target/*[1]" mode="counting">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="count" select="$count + 1"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="name(.) = "CAST"">
+ <xsl:apply-templates select="term/*[1]" mode="counting">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="count" select="$count"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$count - $noparams"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- XSLT version 0.1 of CIC objects to objects and MathML content: -->
+<!-- First draft: March 21 2000, Irene Schena -->
+<!--******************************************************************-->
+
+<!--******************************************************************-->
+<!-- MANCA: gestione annotation e linking -->
+<!--******************************************************************-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<xsl:import href="content.xsl"/>
+
+<!-- ROOT -->
+
+<xsl:template match="cicxml">
+ <xsl:variable name="url"><xsl:value-of select="@baseurl"/></xsl:variable>
+ <xsl:variable name="stylesheet"><xsl:value-of select="@stylesheet"/></xsl:variable>
+ <xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>
+ <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select='concat($url,$stylesheet)'/>" type="text/xsl"</xsl:processing-instruction>
+ <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- CIC OBJECTS -->
+
+<xsl:template match="Definition" mode="noannot">
+ <Definition name="{@name}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <body>
+ <xsl:apply-templates select="body/*[1]">
+ <xsl:with-param name="backpointer" select=""*[1]""/>
+ </xsl:apply-templates>
+ </body>
+ <type>
+ <xsl:apply-templates select="type/*[1]">
+ <xsl:with-param name="backpointer" select=""*[2]""/>
+ </xsl:apply-templates>
+ </type>
+ </Definition>
+</xsl:template>
+
+<xsl:template match="Axiom" mode="noannot">
+ <Axiom name="{@name}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Axiom>
+</xsl:template>
+
+<xsl:template match="CurrentProof" mode="noannot">
+ <CurrentProof name="{@name}">
+ <xsl:for-each select="Conjecture">
+ <Conjecture no="./{@no}">
+ <xsl:apply-templates select="."/>
+ </Conjecture>
+ </xsl:for-each>
+ <body>
+ <xsl:apply-templates select="body"/>
+ </body>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </CurrentProof>
+</xsl:template>
+
+<xsl:template match="InductiveDefinition" mode="noannot">
+ <InductiveDefinition>
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <xsl:if test="string(@noParams) != 0">
+ <xsl:apply-templates select="InductiveType/arity/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="@noParams"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:for-each select="InductiveType">
+ <InductiveType name="{./@name}" inductive="{./@inductive}">
+ <arity>
+ <xsl:apply-templates select="./arity/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="../@noParams"/>
+ <xsl:with-param name="target" select="1"/>
+ </xsl:apply-templates>
+ </arity>
+ <xsl:for-each select="./Constructor">
+ <Constructor name="{./@name}">
+ <xsl:apply-templates select="./*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="../../@noParams"/>
+ <xsl:with-param name="target" select="1"/>
+ </xsl:apply-templates>
+ </Constructor>
+ </xsl:for-each>
+ </InductiveType>
+ </xsl:for-each>
+ </InductiveDefinition>
+</xsl:template>
+
+<xsl:template match="Variable" mode="noannot">
+ <Variable name="{@name}">
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Variable>
+</xsl:template>
+
+<!--*******************************************-->
+<!-- ABSTRACTING PARAMETERS AND COUNTING -->
+<!--*******************************************-->
+<!-- Si dimentica i CAST dei termini che astrae. Nel caso dell'astrazione -->
+<!-- dei lambda dei pattern del CASE, qualora i lambda non si trovino -->
+<!-- nella forma weak-head, astrae solo i lambda che trova e restituisce -->
+<!-- un corpo depurato da tutti i primi cast che precedono il termine -->
+<!-- restituito. -->
+
+<xsl:template match="*" mode="abstparams">
+<xsl:param name="noparams" select="0"/>
+<xsl:param name="target" select="0"/>
+<xsl:param name="binder">PROD</xsl:param>
+ <xsl:choose>
+ <xsl:when test="($noparams != 0) and ((name(.)=string($binder)) or (name(.)="CAST"))">
+ <xsl:choose>
+ <xsl:when test="name(.) = string($binder)">
+ <xsl:if test="$target = 0">
+ <xsl:choose>
+ <xsl:when test="string($binder) = "LAMBDA"">
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <Param name="{target/@binder}">
+ <xsl:apply-templates select="source" mode="noannot"/>
+ </Param>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:apply-templates select="target/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="$noparams - 1"/>
+ <xsl:with-param name="target" select="$target"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="term/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="target" select="$target"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="($target = 1) and ($noparams != 0)">
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="." mode="noannot"/>
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$noparams != 0">
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$target = 1">
+ <xsl:apply-templates select="." mode="noannot"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="printparam">
+<xsl:param name="noleft" select="0"/>
+<xsl:param name="number" select="1"/>
+ <xsl:if test="$noleft != 0">
+ <m:ci>$<xsl:value-of select="$number"/></m:ci>
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noleft - 1"/><xsl:with-param name="number" select="$number + 1"/></xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="*" mode="counting">
+<xsl:param name="noparams" select="0"/>
+<xsl:param name="count" select="0"/>
+ <xsl:choose>
+ <xsl:when test="name(.) = "PROD"">
+ <xsl:apply-templates select="target/*[1]" mode="counting">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="count" select="$count + 1"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="name(.) = "CAST"">
+ <xsl:apply-templates select="term/*[1]" mode="counting">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="count" select="$count"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$count - $noparams"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- XSLT version 0.1 of CIC objects to objects and MathML content: -->
+<!-- First draft: March 21 2000, Irene Schena -->
+<!--******************************************************************-->
+
+<!--******************************************************************-->
+<!-- MANCA: gestione annotation e linking -->
+<!--******************************************************************-->
+
+<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">
+
+<xsl:import href="content.xsl"/>
+
+<!-- ROOT -->
+
+<xsl:template match="cicxml">
+ <xsl:variable name="url"><xsl:value-of select="@baseurl"/></xsl:variable>
+ <xsl:variable name="stylesheet"><xsl:value-of select="@stylesheet"/></xsl:variable>
+ <xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>
+ <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select='concat($url,$stylesheet)'/>" type="text/xsl"</xsl:processing-instruction>
+ <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
+ <xsl:apply-templates select="*[1]"/>
+</xsl:template>
+
+<!-- CIC OBJECTS -->
+
+<xsl:template match="Definition" mode="noannot">
+ <Definition name="{@name}" helm:xref="{@id}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <body>
+ <xsl:apply-templates select="body"/>
+ </body>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Definition>
+</xsl:template>
+
+<xsl:template match="Axiom" mode="noannot">
+ <Axiom name="{@name}" helm:xref="{@id}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Axiom>
+</xsl:template>
+
+<xsl:template match="CurrentProof" mode="noannot">
+ <CurrentProof name="{@name}" helm:xref="{@id}">
+ <xsl:for-each select="Conjecture">
+ <Conjecture no="./{@no}">
+ <xsl:apply-templates select="."/>
+ </Conjecture>
+ </xsl:for-each>
+ <body>
+ <xsl:apply-templates select="body"/>
+ </body>
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </CurrentProof>
+</xsl:template>
+
+<xsl:template match="InductiveDefinition" mode="noannot">
+ <InductiveDefinition helm:xref="{@id}">
+ <xsl:if test="string(@params) != """>
+ <Params>
+ <xsl:value-of select="@params"/>
+ </Params>
+ </xsl:if>
+ <xsl:if test="string(@noParams) != 0">
+ <xsl:apply-templates select="InductiveType/arity/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="@noParams"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ <xsl:for-each select="InductiveType">
+ <InductiveType name="{./@name}" inductive="{./@inductive}">
+ <arity>
+ <xsl:apply-templates select="./arity/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="../@noParams"/>
+ <xsl:with-param name="target" select="1"/>
+ </xsl:apply-templates>
+ </arity>
+ <xsl:for-each select="./Constructor">
+ <Constructor name="{./@name}">
+ <xsl:apply-templates select="./*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="../../@noParams"/>
+ <xsl:with-param name="target" select="1"/>
+ </xsl:apply-templates>
+ </Constructor>
+ </xsl:for-each>
+ </InductiveType>
+ </xsl:for-each>
+ </InductiveDefinition>
+</xsl:template>
+
+<xsl:template match="Variable" mode="noannot">
+ <Variable name="{@name}" helm:xref="{@id}">
+ <type>
+ <xsl:apply-templates select="type"/>
+ </type>
+ </Variable>
+</xsl:template>
+
+<!--*******************************************-->
+<!-- ABSTRACTING PARAMETERS AND COUNTING -->
+<!--*******************************************-->
+<!-- Si dimentica i CAST dei termini che astrae. Nel caso dell'astrazione -->
+<!-- dei lambda dei pattern del CASE, qualora i lambda non si trovino -->
+<!-- nella forma weak-head, astrae solo i lambda che trova e restituisce -->
+<!-- un corpo depurato da tutti i primi cast che precedono il termine -->
+<!-- restituito. -->
+
+<xsl:template match="*" mode="abstparams">
+<xsl:param name="noparams" select="0"/>
+<xsl:param name="target" select="0"/>
+<xsl:param name="binder">PROD</xsl:param>
+ <xsl:choose>
+ <xsl:when test="($noparams != 0) and ((name(.)=string($binder)) or (name(.)="CAST"))">
+ <xsl:choose>
+ <xsl:when test="name(.) = string($binder)">
+ <xsl:if test="$target = 0">
+ <xsl:choose>
+ <xsl:when test="string($binder) = "LAMBDA"">
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <Param name="{target/@binder}">
+ <xsl:apply-templates select="source" mode="noannot"/>
+ </Param>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:apply-templates select="target/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="$noparams - 1"/>
+ <xsl:with-param name="target" select="$target"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="term/*[1]" mode="abstparams">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="target" select="$target"/>
+ <xsl:with-param name="binder" select="$binder"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="($target = 1) and ($noparams != 0)">
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="." mode="noannot"/>
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$noparams != 0">
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$target = 1">
+ <xsl:apply-templates select="." mode="noannot"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="printparam">
+<xsl:param name="noleft" select="0"/>
+<xsl:param name="number" select="1"/>
+ <xsl:if test="$noleft != 0">
+ <m:ci>$<xsl:value-of select="$number"/></m:ci>
+ <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noleft - 1"/><xsl:with-param name="number" select="$number + 1"/></xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="*" mode="counting">
+<xsl:param name="noparams" select="0"/>
+<xsl:param name="count" select="0"/>
+ <xsl:choose>
+ <xsl:when test="name(.) = "PROD"">
+ <xsl:apply-templates select="target/*[1]" mode="counting">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="count" select="$count + 1"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="name(.) = "CAST"">
+ <xsl:apply-templates select="term/*[1]" mode="counting">
+ <xsl:with-param name="noparams" select="$noparams"/>
+ <xsl:with-param name="count" select="$count"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$count - $noparams"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!--***********************************************************************-->
+<!-- auxiliary functions -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--***********************************************************************-->
+
+<!--***********************************************************************-->
+<!-- get the name from a URI -->
+<!--***********************************************************************-->
+
+<!-- CSC: PROBLEMA: URI CHE NON CONTENGONO / ED INIZIANO CON cic: -->
+<xsl:template name="name_of_uri">
+ <xsl:param name="uri" select=""""/>
+ <xsl:variable name="suffix" select="substring-after($uri, "/")"/>
+ <xsl:choose>
+ <xsl:when test="$suffix = """>
+ <!-- CSC: PROBLEMA: .con PUO' APPARIRE ALL'INTERNO DELLE URI ===>
+ SCRIVERE UNA FUNZIONE RICORSIVA CHE RISOLVA -->
+ <xsl:value-of select="substring-before($uri,".con")"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="name_of_uri">
+ <xsl:with-param name="uri" select="$suffix"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!--***********************************************************************-->
+<!-- erase common prefix from two uris -->
+<!--***********************************************************************-->
+
+<xsl:template name="common_prefix">
+ <xsl:param name="first_uri" select=""""/>
+ <xsl:param name="second_uri" select=""""/>
+ <xsl:choose>
+ <xsl:when test="(substring-before($first_uri,"/") =
+ substring-before($second_uri,"/") and
+ substring-after($second_uri,"/") != "")">
+ <xsl:call-template name="common_prefix">
+ <xsl:with-param
+ name="first_uri" select="substring-after($first_uri,"/")"/>
+ <xsl:with-param
+ name="second_uri" select="substring-after($second_uri,"/")"/> </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="slash_counting">
+ <xsl:with-param name="uri" select="$second_uri"/>
+ <xsl:with-param name="counter" select="0"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="slash_counting">
+ <xsl:param name="uri" select=""""/>
+ <xsl:param name="counter" select="0"/>
+ <xsl:choose>
+ <xsl:when test="(substring-after($uri,"/") != "")">
+ <xsl:call-template name="slash_counting">
+ <xsl:with-param
+ name="uri" select="substring-after($uri,"/")"/>
+ <xsl:with-param
+ name="counter" select="$counter +1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$counter"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="blank_counting">
+ <xsl:param name="string" select=""""/>
+ <xsl:param name="counter" select="0"/>
+ <xsl:choose>
+ <xsl:when test="(substring-after($string," ") != "")">
+ <xsl:call-template name="blank_counting">
+ <xsl:with-param
+ name="string" select="substring-after($string," ")"/>
+ <xsl:with-param
+ name="counter" select="$counter +1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$counter + 1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="double_point_counting">
+ <xsl:param name="string" select=""""/>
+ <xsl:param name="counter" select="0"/>
+ <xsl:choose>
+ <xsl:when test="(substring-after($string,":") != "")">
+ <xsl:call-template name="double_point_counting">
+ <xsl:with-param
+ name="string" select="substring-after($string,":")"/>
+ <xsl:with-param
+ name="counter" select="$counter +1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$counter"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="min">
+ <xsl:param name="string" select=""""/>
+ <xsl:param name="counter" select="0"/>
+ <xsl:choose>
+ <xsl:when test="contains($string,concat($counter,":"))
+ or (0 > $counter)">
+ <xsl:value-of select="$counter"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="min">
+ <xsl:with-param
+ name="string" select="$string"/>
+ <xsl:with-param
+ name="counter" select="$counter -1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="get_no_params">
+ <xsl:param name="first_uri" select=""""/>
+ <xsl:param name="second_uri" select=""""/>
+ <xsl:variable name="offset">
+ <xsl:call-template name="common_prefix">
+ <xsl:with-param name="first_uri" select="$first_uri"/>
+ <xsl:with-param name="second_uri" select="$second_uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$offset > 0">
+ <xsl:variable name="params">
+ <xsl:value-of
+ select="document(concat(string($absPath),$second_uri))/*/@params"/>
+ </xsl:variable>
+ <xsl:variable name="minimum">
+ <xsl:call-template name="min">
+ <xsl:with-param name="string" select="$params"/>
+ <xsl:with-param name="counter" select="$offset - 1"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="0 > $minimum">
+ 0
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="relevant_params">
+ <!-- the blank after : in the next line is essential -->
+ <xsl:value-of
+ select="substring-after($params,concat($minimum,": "))"/>
+ </xsl:variable>
+ <xsl:variable name="tokens">
+ <xsl:call-template name="blank_counting">
+ <xsl:with-param name="string" select="$relevant_params"/>
+ <xsl:with-param name="counter" select="0"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="separators">
+ <xsl:call-template name="double_point_counting">
+ <xsl:with-param name="string" select="$relevant_params"/>
+ <xsl:with-param name="counter" select="0"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="$tokens - $separators"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ 0
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- Basic Logic -->
+<!-- First draft: April 3 2000 -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- ************************* LOGIC *********************************-->
+
+<!-- Proof objects -->
+
+<!-- <xsl:key name="typeid" use="@id" match="TYPE"/> -->
+
+<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX" mode="noannot">
+ <xsl:choose>
+ <xsl:when test="@id">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:choose>
+ <!-- <xsl:when test="//ALLTYPES and key('typeid',@id)"> -->
+ <xsl:when test="//ALLTYPES/TYPE[@id=$id]">
+ <xsl:choose>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>rewrite</m:csymbol>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </m:apply>
+ <xsl:apply-templates mode="rewrite" select="*[5]"/>
+ </m:apply>
+ </xsl:when>
+ <!-- aggiungere la verifica dell'esistenza dei lambda per and_ind -->
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic/Conjunction/and_ind.con']
+ and count(child::*) = 6">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>and_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[6]"/>
+ <m:ci><xsl:value-of select="*[5]/target/@binder"/></m:ci>
+ <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
+ <m:ci><xsl:value-of select="*[5]/target/LAMBDA/target/@binder"/></m:ci>
+ <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
+ <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic/Disjunction/or_ind.con']
+ and count(child::*) = 7">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>or_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[7]"/>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <xsl:apply-templates mode="pure" select="*[5]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>proof</m:csymbol>
+ <xsl:apply-templates select="." mode="pure"/>
+ <!-- <xsl:apply-templates select="key('typeid',@id)" mode="pure"/> -->
+ <xsl:apply-templates select="//ALLTYPES/TYPE[@id=$id]" mode="pure"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="rewrite">
+ <xsl:choose>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </m:apply>
+ <xsl:apply-templates mode="rewrite" select="*[5]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="noannot" select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- Basic proof operators -->
+
+<!-- non del tutto soddisfacente, ma .... -->
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con']]" mode="appflat">
+ <xsl:choose>
+ <xsl:when test="count(child::*) > 7">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="ideqp" select="*[7]/@id"/>
+ <xsl:variable name="idsubp" select="*[5]/@id"/>
+ <xsl:variable name="leteqp" select="boolean(//ALLTYPES/TYPE[@id=$ideqp])"/>
+ <xsl:variable name="letsubp" select="boolean(//ALLTYPES/TYPE[@id=$idsubp])"/>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>rewrite_and_apply</m:csymbol>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:choose>
+ <xsl:when test="$leteqp">
+ <xsl:choose>
+ <xsl:when test="$letsubp">
+ <m:ci>
+ <xsl:value-of select="'h2'"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:ci>
+ <xsl:value-of select="'h1'"/>
+ </m:ci>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:apply>
+ <xsl:choose>
+ <xsl:when test="$letsubp">
+ <m:ci>
+ <xsl:value-of select="'h1'"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="pure" select="*[5]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates mode="flat" select="*[8]">
+ <xsl:with-param name="n">
+ <xsl:value-of select="1+$letsubp+$leteqp"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="flat" select="*[1]"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/INIT/Logic/Conjunction/and_ind.con']]" mode="appflat">
+ <xsl:choose>
+ <xsl:when test="count(child::*) > 4">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[1]"/>
+ <m:ci>*</m:ci>
+ <m:ci>*</m:ci>
+ <m:ci>*</m:ci>
+ <xsl:apply-templates mode="flat" select="*[5]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="flat" select="*[1]"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- Basic Logic -->
+<!-- First draft: April 3 2000 -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- ************************* LOGIC *********************************-->
+
+<!-- Proof objects -->
+
+<!-- <xsl:key name="typeid" use="@id" match="TYPE"/> -->
+
+<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX" mode="noannot">
+ <xsl:choose>
+ <xsl:when test="@id">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:choose>
+ <!-- <xsl:when test="//ALLTYPES and key('typeid',@id)"> -->
+ <xsl:when test="//ALLTYPES/TYPE[@id=$id]">
+ <xsl:choose>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>thread</m:csymbol>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </m:apply>
+ <xsl:apply-templates mode="thread" select="*[5]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="count(*[@id = //ALLTYPES/TYPE/@id]) = 1">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>thread</m:csymbol>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
+ </m:apply>
+ <xsl:apply-templates mode="thread" select="*[@id = //ALLTYPES/TYPE/@id]"/>
+ </m:apply>
+ </xsl:when>
+ <!-- aggiungere la verifica dell'esistenza dei lambda per and_ind -->
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic/Conjunction/and_ind.con']
+ and count(child::*) = 6">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>and_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[6]"/>
+ <m:ci><xsl:value-of select="*[5]/target/@binder"/></m:ci>
+ <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
+ <m:ci><xsl:value-of select="*[5]/target/LAMBDA/target/@binder"/></m:ci>
+ <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
+ <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic/Disjunction/or_ind.con']
+ and count(child::*) = 7">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>or_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[7]"/>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <xsl:apply-templates mode="pure" select="*[5]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>proof</m:csymbol>
+ <xsl:apply-templates select="." mode="pure"/>
+ <!-- <xsl:apply-templates select="key('typeid',@id)" mode="pure"/> -->
+ <xsl:apply-templates select="//ALLTYPES/TYPE[@id=$id]" mode="pure"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="copy-of-no-prop">
+ <xsl:choose>
+ <xsl:when test="@id = //ALLTYPES/TYPE/@id">
+ <m:ci>prev</m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates mode="copy-of-no-prop" select="following-sibling::*[1]"/>
+</xsl:template>
+
+<xsl:template match="*" mode="thread">
+ <xsl:choose>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </m:apply>
+ <xsl:apply-templates mode="thread" select="*[5]"/>
+ </xsl:when>
+ <xsl:when test="count(*[@id = //ALLTYPES/TYPE/@id]) = 1">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>thread</m:csymbol>
+ <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
+ <m:apply>
+ <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
+ </m:apply>
+ <xsl:apply-templates mode="thread" select="*[@id = //ALLTYPES/TYPE/@id]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="noannot" select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- Basic proof operators -->
+
+<!-- non del tutto soddisfacente, ma .... -->
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con']]" mode="appflat">
+ <xsl:choose>
+ <xsl:when test="count(child::*) > 7">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="ideqp" select="*[7]/@id"/>
+ <xsl:variable name="idsubp" select="*[5]/@id"/>
+ <xsl:variable name="leteqp" select="boolean(//ALLTYPES/TYPE[@id=$ideqp])"/>
+ <xsl:variable name="letsubp" select="boolean(//ALLTYPES/TYPE[@id=$idsubp])"/>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>rewrite_and_apply</m:csymbol>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:choose>
+ <xsl:when test="$leteqp">
+ <xsl:choose>
+ <xsl:when test="$letsubp">
+ <m:ci>
+ <xsl:value-of select="'h2'"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:ci>
+ <xsl:value-of select="'h1'"/>
+ </m:ci>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:apply>
+ <xsl:choose>
+ <xsl:when test="$letsubp">
+ <m:ci>
+ <xsl:value-of select="'h1'"/>
+ </m:ci>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="pure" select="*[5]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates mode="flat" select="*[8]">
+ <xsl:with-param name="n">
+ <xsl:value-of select="1+$letsubp+$leteqp"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="flat" select="*[1]"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/INIT/Logic/Conjunction/and_ind.con']]" mode="appflat">
+ <xsl:choose>
+ <xsl:when test="count(child::*) > 4">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[1]"/>
+ <m:ci>*</m:ci>
+ <m:ci>*</m:ci>
+ <m:ci>*</m:ci>
+ <xsl:apply-templates mode="flat" select="*[5]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates mode="flat" select="*[1]"/>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- Reals -->
+<!-- First draft: April 3 2000 -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- ************************* LOGIC *********************************-->
+
+<!-- REALS -->
+
+<!--
+<xsl:template match="CONST[attribute::uri='cic:/coq/REALS/Raxioms/R.con']" mode="pure">
+ <m:reals/>
+</xsl:template>
+-->
+
+<!-- 0 e 1 -->
+
+<xsl:template match="CONST[attribute::uri='cic:/coq/REALS/Raxioms/R0.con']" mode="pure">
+ <m:cn definitionURL="{@uri}" helm:xref="{@id}">0</m:cn>
+</xsl:template>
+
+<xsl:template match="CONST[attribute::uri='cic:/coq/REALS/Raxioms/R1.con']" mode="pure">
+ <m:cn definitionURL="{@uri}" helm:xref="{@id}">1</m:cn>
+</xsl:template>
+
+
+
+<!-- Unary Operations -->
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/REALS/Raxioms/Ropp.con' or
+ attribute::uri='cic:/coq/REALS/Rbasic_fun/Rabsolu.con' or
+ attribute::uri='cic:/coq/REALS/Rfunctions/fact.con' or
+ attribute::uri='cic:/coq/REALS/Rbase/Rsqr.con']]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 2">
+ <xsl:variable name="elem">
+ <xsl:choose>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Ropp.con'">
+ <xsl:value-of select="'minus'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Rbasic_fun/Rabsolu.con'">
+ <xsl:value-of select="'abs'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Rfunctions/fact.con'">
+ <xsl:value-of select="'factorial'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Rbase/Rsqr.con'">
+ <xsl:value-of select="'root'"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <m:apply helm:xref="{@id}">
+ <xsl:element name="{concat('m:',$elem)}">
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="CONST/@uri"/>
+ </xsl:attribute>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="CONST/@id"/>
+ </xsl:attribute>
+ </xsl:element>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/REALS/Raxioms/Rinv.con']]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 2">
+ <m:apply helm:xref="{@id}">
+ <m:power/>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <m:apply>
+ <m:minus>
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="CONST/@uri"/>
+ </xsl:attribute>
+ </m:minus>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="CONST/@id"/>
+ </xsl:attribute>
+ <m:cn>1</m:cn>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Binary Operations and Relations -->
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/REALS/Raxioms/Rplus.con' or
+ attribute::uri='cic:/coq/REALS/Raxioms/Rminus.con' or
+ attribute::uri='cic:/coq/REALS/Raxioms/Rmult.con' or
+ attribute::uri='cic:/coq/REALS/Raxioms/Rle.con' or
+ attribute::uri='cic:/coq/REALS/Raxioms/Rlt.con' or
+ attribute::uri='cic:/coq/REALS/Raxioms/Rge.con' or
+ attribute::uri='cic:/coq/REALS/Raxioms/Rgt.con' or
+ attribute::uri='cic:/coq/REALS/Rbasic_fun/Rmin.con' or
+ attribute::uri='cic:/coq/REALS/Rfunctions/pow.con']]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 3">
+ <xsl:variable name="elem">
+ <xsl:choose>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rplus.con'">
+ <xsl:value-of select="'plus'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rminus.con'">
+ <xsl:value-of select="'minus'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rmult.con'">
+ <xsl:value-of select="'times'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rle.con'">
+ <xsl:value-of select="'leq'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rlt.con'">
+ <xsl:value-of select="'lt'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rge.con'">
+ <xsl:value-of select="'geq'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Raxioms/Rgt.con'">
+ <xsl:value-of select="'gt'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Rbasic_fun/Rmin.con'">
+ <xsl:value-of select="'min'"/>
+ </xsl:when>
+ <xsl:when test="CONST/@uri='cic:/coq/REALS/Rfunctions/pow.con'">
+ <xsl:value-of select="'power'"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <m:apply helm:xref="{@id}">
+ <xsl:element name="{concat('m:',$elem)}">
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="CONST/@uri"/>
+ </xsl:attribute>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="CONST/@id"/>
+ </xsl:attribute>
+ </xsl:element>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <xsl:apply-templates select="*[3]" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- LIMIT -->
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/REALS/Rlimit/limit1_in.con']]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 5">
+ <m:apply>
+ <m:eq/>
+ <xsl:choose>
+ <xsl:when test="name(*[2]) = 'LAMBDA'">
+ <m:apply helm:xref="{@id}">
+ <m:limit>
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="CONST/@uri"/>
+ </xsl:attribute>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="CONST/@id"/>
+ </xsl:attribute>
+ </m:limit>
+ <m:bvar>
+ <m:ci><xsl:value-of select="LAMBDA/target/@binder"/></m:ci>
+ </m:bvar>
+ <m:lowlimit>
+ <xsl:apply-templates select="*[5]" mode="noannot"/>
+ </m:lowlimit>
+ <xsl:apply-templates select="*[2]/target" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:limit/>
+ <m:bvar>
+ <m:ci>$x</m:ci>
+ </m:bvar>
+ <m:lowlimit>
+ <xsl:apply-templates select="*[5]" mode="noannot"/>
+ </m:lowlimit>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <m:ci>$x</m:ci>
+ </m:apply>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="*[4]" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- DIFFERENTIATION -->
+
+<xsl:template match="APPLY[CONST[
+ attribute::uri='cic:/coq/REALS/Rderiv/D_in.con']]" mode="pure">
+ <xsl:choose>
+ <xsl:when test="count(child::*) = 4">
+ <m:apply>
+ <m:eq/>
+ <xsl:choose>
+ <xsl:when test="name(*[2]) = 'LAMBDA'">
+ <m:apply helm:xref="{@id}">
+ <m:diff >
+ <xsl:attribute name="definitionURL">
+ <xsl:value-of select="CONST/@uri"/>
+ </xsl:attribute>
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="CONST/@id"/>
+ </xsl:attribute>
+ </m:diff>
+ <m:bvar>
+ <m:ci><xsl:value-of select="LAMBDA[1]/target/@binder"/></m:ci>
+ </m:bvar>
+ <xsl:apply-templates select="*[2]/target" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:diff/>
+ <m:bvar>
+ <m:ci>$x</m:ci>
+ </m:bvar>
+ <m:apply>
+ <m:csymbol>app</m:csymbol>
+ <xsl:apply-templates select="*[2]" mode="noannot"/>
+ <m:ci>$x</m:ci>
+ </m:apply>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="*[4]" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+
+<xsl:stylesheet version="0.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="html"/>
+
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<xsl:template match="/">
+ <html>
+ <head></head>
+ <body>
+ <xsl:apply-templates select="Theory"/>
+ </body>
+ </html>
+</xsl:template>
+
+
+<!-- CIC TERMS -->
+
+
+
+<xsl:template match="MUTIND[string(@uri)='cic:/coq/INIT/Logic/Equality/eq.ind']" mode="search" >
+<!-- <xsl:param name="current_uri" select=""/> -->
+<!-- <h1><xsl:value-of select="string(@uri)"/></h1> -->
+<!-- <xsl:if test="string(@uri)='cic:/coq/INIT/Logic/Equality/eq.ind'"> -->
+ <xsl:value-of select="$current_uri"/><BR/>
+<!-- </xsl:if> -->
+</xsl:template>
+
+<!-- AGGIUNGERE cic: alle uri nei file Theory -->
+
+<xsl:template match="Theory">
+<!-- <xsl:param name="current_uri" select=""/> -->
+ <xsl:apply-templates>
+ <xsl:with-param name="current_uri" select="string(@uri)"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="VARIABLE">
+<!-- <xsl:param name="current_uri" select=""/> -->
+<xsl:variable name="found"
+ select="boolean(document(concat(string($absPath),string($current_uri),"/",string(@uri)))//MUTIND[string(@uri)='cic:/coq/INIT/Logic/Equality/eq.ind'])"/>
+<xsl:if test="$found">
+ <xsl:value-of select="concat(string($current_uri),"/",string(@uri),".xml")"/><BR/>
+</xsl:if>
+
+<!-- <xsl:with-param name="current_uri" select="concat(string($absPath),string($current_uri),"/",string(@uri))"/>
+ </xsl:apply-templates> -->
+</xsl:template>
+
+<xsl:template match="DEFINITION">
+<!-- <xsl:param name="current_uri" select=""/> -->
+<!-- <xsl:apply-templates select="document(concat(string($absPath),string($current_uri),"/",string(@uri)))" mode="search">
+ <xsl:with-param name="current_uri" select="concat(string($absPath),string($current_uri),"/",string(@uri))"/>
+ </xsl:apply-templates> -->
+<xsl:variable name="found"
+ select="boolean(document(concat(string($absPath),string($current_uri),"/",string(@uri)))//MUTIND[string(@uri)='cic:/coq/INIT/Logic/Equality/eq.ind'])"/>
+<xsl:if test="$found">
+ <xsl:value-of select="concat(string($current_uri),"/",string(@uri),".xml")"/><BR/>
+</xsl:if>
+</xsl:template>
+
+<xsl:template match="THEOREM">
+<!-- <xsl:param name="current_uri" select=""/> -->
+<!-- <xsl:apply-templates select="document(concat(string($absPath),string($current_uri),"/",string(@uri)))" mode="search">
+ <xsl:with-param name="current_uri" select="concat(string($absPath),string($current_uri),"/",string(@uri))"/>
+ </xsl:apply-templates> -->
+<xsl:variable name="found"
+ select="boolean(document(concat(string($absPath),string($current_uri),"/",string(@uri)))//MUTIND[string(@uri)='cic:/coq/INIT/Logic/Equality/eq.ind'])"/>
+<xsl:if test="$found">
+ <xsl:value-of select="concat(string($current_uri),"/",string(@uri),".xml")"/><BR/>
+</xsl:if>
+</xsl:template>
+
+
+<xsl:template match="SECTION">
+<!-- <xsl:param name="current_uri" select=""/> -->
+ <xsl:apply-templates>
+ <xsl:with-param name="current_uri" select="concat($current_uri,"/",string(@uri))"/>
+ </xsl:apply-templates>
+
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of the stylesheet to accomplish the right inclusion -->
+<!-- of the content stylesheets: -->
+<!-- First draft: May 26 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<!-- Schema of stylesheet precedences (from highest to lowest): -->
+<!-- set -> basic -> annotatedcont -->
+<!-- because theory_content is imported and has lower precendence than -->
+<!-- the templates of rootcontent (i.e. the templates of set and basic). -->
+<!-- annotatedcont -> objcontent -> content -->
+<!-- because theory_content generates an import precedence tree. -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+
+<xsl:import href="annotatedcont.xsl"/>
+<xsl:key name="id" use="@id" match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX|Definition|Axiom|CurrentProof|InductiveDefinition|Variable"/>
+<xsl:include href="basic.xsl"/>
+<!-- <xsl:include href="set.xsl"/> -->
+<xsl:include href="reals.xsl"/>
+<xsl:include href="proofs.xsl"/>
+
+<xsl:variable name="showproof" select="0"/>
+</xsl:stylesheet>
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of the stylesheet to accomplish the right inclusion -->
+<!-- of the content stylesheets: -->
+<!-- First draft: May 26 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<!-- Schema of stylesheet precedences (from highest to lowest): -->
+<!-- set -> basic -> annotatedcont -->
+<!-- because theory_content is imported and has lower precendence than -->
+<!-- the templates of rootcontent (i.e. the templates of set and basic). -->
+<!-- annotatedcont -> objcontent -> content -->
+<!-- because theory_content generates an import precedence tree. -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+
+<xsl:import href="annotatedcont.xsl"/>
+<xsl:key name="id" use="@id" match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX|Definition|Axiom|CurrentProof|InductiveDefinition|Variable"/>
+<xsl:include href="basic.xsl"/>
+<xsl:include href="set.xsl"/>
+<xsl:include href="reals.xsl"/>
+
+<xsl:variable name="showproof" select="1"/>
+</xsl:stylesheet>
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of the stylesheet to accomplish the right inclusion -->
+<!-- of the theory content stylesheets: -->
+<!-- First draft: May 26 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<!-- Schema of stylesheet precedences (from highest to lowest): -->
+<!-- set -> basic -> theory_content -->
+<!-- because theory_content is imported and has lower precendence than -->
+<!-- the templates of rootcontent (i.e. the templates of set and basic). -->
+<!-- theory_content -> annotatedcont -> objcontent -> content -->
+<!-- because theory_content generates an import precedence tree. -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:import href="theory_content.xsl"/>
+<xsl:include href="basic.xsl"/>
+<xsl:include href="set.xsl"/>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--******************************************************************-->
+<!-- Basic Set Theory -->
+<!-- First draft: April 3 2000 -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
+<!--******************************************************************-->
+
+<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">
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- ************************* LOGIC *********************************-->
+
+
+
+<xsl:template match="*" mode="set">
+ <xsl:choose>
+ <xsl:when test="name() = 'LAMBDA'">
+ <m:set>
+ <m:bvar>
+ <m:ci>
+ <xsl:value-of select="target/@binder"/>
+ </m:ci>
+ <m:type>
+ <xsl:apply-templates select="source" mode="noannot"/>
+ </m:type>
+ </m:bvar>
+ <m:condition>
+ <xsl:apply-templates select="target" mode="noannot"/>
+ </m:condition>
+ </m:set>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="noannot"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- IN -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/In.con']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:in definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ <!-- <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/> -->
+ <xsl:apply-templates select="*[2+$no_params]" mode="set" />
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- NOT-IN -->
+<!-- NOT ha no parameters -->
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Logic/not.con']
+and (count(child::*) = 2) and APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/In.con']]]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="APPLY/CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(APPLY/child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:notin/>
+ <xsl:apply-templates select="*[2]/*[3+$no_params]" mode="noannot"/>
+ <!-- <xsl:apply-templates select="*[2]/*[2+$no_params]" mode="noannot"/> -->
+ <xsl:apply-templates select="*[2]/*[2+$no_params]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- EMPTY SET -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Empty_set.ind']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 1">
+ <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+ </m:set>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 2">
+ <m:apply helm:xref="{@id}">
+ <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+ </m:set>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- SINGLETON -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Singleton.ind']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 2">
+ <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ </m:set>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ <m:set definitionURL="{MUTIND/@uri}">
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- COUPLE -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Couple.ind']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:set>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ <m:set definitionURL="{MUTIND/@uri}">
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- TRIPLE -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Triple.ind'] and (count(child::*) = 5)]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ </m:set>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 5">
+ <m:apply helm:xref="{@id}">
+ <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+ <xsl:apply-templates select="*[5+$no_params]" mode="noannot"/>
+ <m:set definitionURL="{MUTIND/@uri}">
+ <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- INTERSECTION -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Intersection.ind']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:intersect definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:in/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ <m:apply>
+ <m:intersect definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- UNION -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Union.ind']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:union definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:in/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ <m:apply>
+ <m:union definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- INCLUDED -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Included.con']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:subset definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- STRICTLY INCLUDED -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Strict_Included.con']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:prsubset definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- SET-DIFF -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Setminus.con']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:in/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ <m:apply>
+ <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- ADD-ELEM -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Add.con']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:union definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <m:set>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:in/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ <m:apply>
+ <m:union definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <m:set>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- SUBTRACT-ELEM -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Subtract.con']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="CONST/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <m:set>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </xsl:when>
+ <xsl:when test="(count(child::*) - number($no_params)) = 4">
+ <m:apply helm:xref="{@id}">
+ <m:in/>
+ <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+ <m:apply>
+ <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ <m:set>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:set>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- CARD -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Finite_sets/Ensembles_finis/cardinal.ind']]" mode="noannot">
+ <xsl:variable name="no_params">
+ <xsl:call-template name="get_no_params">
+ <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+ <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(count(child::*) - number($no_params)) = 3">
+ <m:apply helm:xref="{@id}">
+ <m:eq/>
+ <m:apply>
+ <m:card definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+ <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+ </m:apply>
+ <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of theory objects to theory sections: -->
+<!-- First draft: May 08 2000, Claudio Sacerdoti Coen, Irene Schena -->
+<!--***********************************************************************-->
+
+<xsl:stylesheet version="0.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:import href="rootcontent.xsl"/>
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- THEORY -->
+
+<xsl:template match="Theory">
+ <SECTION>
+ <xsl:apply-templates><xsl:with-param name="current_uri" select="string(@uri)"/></xsl:apply-templates>
+ </SECTION>
+</xsl:template>
+
+<!-- SUBTHEORY -->
+
+<xsl:template match="SECTION">
+<xsl:param name="current_uri"/>
+ <SECTION>
+ <xsl:apply-templates><xsl:with-param name="current_uri" select="concat($current_uri,"/",string(@uri))"/></xsl:apply-templates>
+ </SECTION>
+</xsl:template>
+
+<!-- THEORY ELEMENTS -->
+
+<xsl:template match="DEFINITION">
+<xsl:param name="current_uri"/>
+ <xsl:apply-templates select="document(concat(string($absPath),string($current_uri),"/",string(@uri)))"/>
+</xsl:template>
+
+<xsl:template match="AXIOM">
+<xsl:param name="current_uri"/>
+ <xsl:apply-templates select="document(concat(string($absPath),string($current_uri),"/",string(@uri)))"/>
+</xsl:template>
+
+<xsl:template match="THEOREM">
+<xsl:param name="current_uri"/>
+ <xsl:apply-templates select="document(concat(string($absPath),string($current_uri),"/",string(@uri)))"/>
+</xsl:template>
+
+<xsl:template match="VARIABLE">
+<xsl:param name="current_uri"/>
+ <xsl:apply-templates select="document(concat(string($absPath),string($current_uri),"/",string(@uri)))"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--***********************************************************************-->
+<!-- XSLT version 0.1 of theory sections to HTML: -->
+<!-- First draft: May 10 2000, Irene Schena -->
+<!--***********************************************************************-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<xsl:include href="annotatedpres.xsl"/>
+
+<xsl:template match="SECTION">
+<xsl:param name="subsect" select="0"/>
+ <xsl:choose>
+ <xsl:when test="$subsect = 0">
+ <html>
+ <head></head>
+ <body>
+ <m:math><m:mtext>BEGIN SECTION</m:mtext></m:math>
+ <xsl:apply-templates select="*"><xsl:with-param name="subsect" select="1"/></xsl:apply-templates>
+ <m:math><m:mtext>END SECTION</m:mtext></m:math>
+ </body>
+ </html>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:math><m:mtext>BEGIN SECTION</m:mtext></m:math>
+ <xsl:apply-templates select="*"><xsl:with-param name="subsect" select="1"/></xsl:apply-templates>
+ <m:math><m:mtext>END SECTION</m:mtext></m:math>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>