3 <!--***********************************************************************-->
4 <!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
5 <!-- First draft: February 19 2000, Andrea Asperti, Irene Schena -->
6 <!-- Revised: March 3 2000, Irene Schena -->
7 <!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
8 <!-- Revised: March 21 2000, Irene Schena -->
9 <!--***********************************************************************-->
11 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12 xmlns:m="http://www.w3.org/1998/Math/MathML"
13 xmlns:helm="http://www.cs.unibo.it/helm">
15 <xsl:import href="mml2mmlv1_0.xsl"/>
17 <!--***********************************************************************-->
18 <!-- Parameter affecting line-breaking -->
19 <!--***********************************************************************-->
21 <xsl:variable name="framewidth" select="30"/>
23 <!--***********************************************************************-->
24 <!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
25 <!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
26 <!-- sono i termini: la presentation per un termine e' generata come primo -->
27 <!-- figlio di un semantics e l'originario content viene inserito nel -->
28 <!-- nel secondo figlio di semantics, annotation-xml -->
29 <!--***********************************************************************-->
31 <!--**********************-->
33 <!--**********************-->
37 <xsl:template match="Definition">
39 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
43 <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
50 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
51 <xsl:apply-templates select="type/*[1]"/>
65 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
66 <xsl:apply-templates select="body/*[1]"/>
76 <xsl:template match="Axiom">
78 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
82 <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
89 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
90 <xsl:apply-templates select="type/*[1]"/>
98 <!-- UNFINISHED PROOF -->
100 <xsl:template match="CurrentProof">
102 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
106 <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
113 <m:mtext>THESIS:</m:mtext>
120 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
121 <xsl:apply-templates select="type/*[1]"/>
128 <m:mtext>CONJECTURES:</m:mtext>
132 <xsl:for-each select="Conjecture">
136 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
137 <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
138 <xsl:apply-templates select="./*[1]"/>
146 <m:mtext>CORRESPONDING PROOF:</m:mtext>
153 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
154 <xsl:apply-templates select="body/*[1]"/>
162 <!-- MUTUAL INDUCTIVE DEFINITION -->
164 <xsl:template match="InductiveDefinition">
166 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
167 <xsl:for-each select="InductiveType">
172 <xsl:when test="position() = 1">
174 <xsl:when test="string(./@inductive) = "true"">
175 <m:mtext>INDUCTIVE DEFINITION</m:mtext>
178 <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
183 <m:mtext>AND</m:mtext>
186 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
187 <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
194 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
197 <xsl:when test="string(../Param) != """>
198 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
199 <xsl:for-each select="../Param">
203 <m:mi><xsl:value-of select="./@name"/></m:mi>
205 <xsl:apply-templates select="*"/>
229 <m:mtext>OF ARITY</m:mtext>
236 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
237 <xsl:apply-templates select="./arity/*[1]"/>
244 <m:mtext>BUILT FROM</m:mtext>
248 <xsl:for-each select="./Constructor">
253 <xsl:when test="position() = 1">
254 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
258 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
261 <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
262 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
263 <xsl:apply-templates select="./*[1]"/>
275 <xsl:template match="Variable">
277 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
281 <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
288 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
289 <xsl:apply-templates select="type/*[1]"/>
297 <!--**********************-->
299 <!--**********************-->
303 <xsl:template match="m:apply[m:csymbol]">
304 <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
305 <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
306 <m:mrow helm:xref="{@helm:xref}">
308 <xsl:when test="$name='prod'">
310 <xsl:when test="$charlength >= $framewidth">
311 <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>
312 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
316 <m:mo color="Blue">Π</m:mo>
317 <xsl:apply-templates select="m:bvar/m:ci"/>
319 <xsl:if test="$framewidth > $charlength">
320 <xsl:apply-templates select="m:bvar/m:type"/>
325 <xsl:if test="$charlength >= $framewidth">
329 <m:mphantom><m:mtext>.</m:mtext></m:mphantom>
330 <xsl:apply-templates select="m:bvar/m:type"/>
339 <xsl:apply-templates select="*[position()=3]"/>
346 <m:mo color="Blue">Π</m:mo>
347 <xsl:apply-templates select="m:bvar/m:ci"/>
349 <xsl:apply-templates select="m:bvar/m:type"/>
351 <xsl:apply-templates select="*[position()=3]"/>
355 <xsl:when test="$name='arrow'">
357 <xsl:when test="$charlength >= $framewidth">
358 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
362 <m:mo stretchy="false">(</m:mo>
363 <xsl:apply-templates select="*[position()=2]"/>
370 <m:mo color="Blue">→</m:mo>
371 <xsl:apply-templates select="*[position()=3]"/>
378 <m:mo stretchy="false">)</m:mo>
385 <m:mo stretchy="false">(</m:mo>
386 <xsl:apply-templates select="*[position()=2]"/>
387 <m:mo color="Blue">→</m:mo>
388 <xsl:apply-templates select="*[position()=3]"/>
389 <m:mo stretchy="false">)</m:mo>
393 <xsl:when test="$name='app'">
395 <xsl:when test="$charlength >= $framewidth">
396 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
400 <m:mo stretchy="false">(</m:mo>
401 <xsl:apply-templates select="*[position()=2]"/>
405 <xsl:for-each select="*[position()>2]">
409 <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
410 <xsl:apply-templates select="."/>
418 <m:mo stretchy="false">)</m:mo>
425 <m:mo stretchy="false">(</m:mo>
426 <xsl:apply-templates select="*[position()=2]"/>
427 <xsl:for-each select="*[position()>2]">
428 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
429 <xsl:apply-templates select="."/>
431 <m:mo stretchy="false">)</m:mo>
435 <xsl:when test="$name='cast'">
437 <xsl:when test="$charlength >= $framewidth">
438 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
442 <m:mo stretchy="false">(</m:mo>
443 <xsl:apply-templates select="*[position()=2]"/>
450 <m:mo color="Yellow">:></m:mo>
451 <xsl:apply-templates select="*[position()=3]"/>
458 <m:mo stretchy="false">)</m:mo>
465 <m:mo stretchy="false">(</m:mo>
466 <xsl:apply-templates select="*[position()=2]"/>
467 <m:mo color="Yellow">:></m:mo>
468 <xsl:apply-templates select="*[position()=3]"/>
469 <m:mo stretchy="false">)</m:mo>
473 <xsl:when test="$name='Prop'">
476 <xsl:when test="$name='Set'">
479 <xsl:when test="$name='Type'">
482 <xsl:when test="$name='mutcase'">
484 <xsl:when test="$charlength >= $framewidth">
485 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
486 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
491 <xsl:apply-templates select="*[position()=2]"/>
492 <xsl:if test="$framewidth > $charlength">
495 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
496 <xsl:apply-templates select="*[position()=3]"/>
501 <xsl:if test="$charlength >= $framewidth">
507 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
508 <xsl:apply-templates select="*[position()=3]"/>
520 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
521 <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
526 <xsl:when test="position() = 1">
527 <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
530 <m:mo stretchy="false">|</m:mo>
533 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
534 <xsl:apply-templates select="."/>
535 <xsl:if test="$framewidth > $charlength">
536 <m:mo color="Green">⇒</m:mo>
537 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
542 <xsl:if test="$charlength >= $framewidth">
546 <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
547 <m:mo color="Green">⇒</m:mo>
548 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
564 <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
566 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
567 <xsl:apply-templates select="*[position()=3]"/>
568 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
570 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
572 <xsl:when test="position() != 1">
573 <m:mo stretchy="false">|</m:mo>
576 <xsl:apply-templates select="."/>
577 <m:mo color="Green">⇒</m:mo>
578 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
580 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
585 <xsl:when test="$name='fix'">
587 <xsl:when test="$charlength >= $framewidth">
588 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
593 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
594 <m:mi><xsl:value-of select="m:ci"/></m:mi>
595 <m:mo stretchy="false">{</m:mo>
602 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
603 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
604 <xsl:for-each select="m:bvar">
605 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
609 <m:mi><xsl:value-of select="m:ci"/></m:mi>
611 <xsl:if test="$framewidth > $charlength">
612 <xsl:apply-templates select="m:type"/>
617 <xsl:if test="$charlength >= $framewidth">
621 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
622 <xsl:apply-templates select="m:type"/>
631 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
643 <m:mo stretchy="false">}</m:mo>
651 <m:mi><xsl:value-of select="m:ci"/></m:mi>
652 <m:mo stretchy="false">{</m:mo>
653 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
654 <xsl:for-each select="m:bvar">
658 <m:mi><xsl:value-of select="m:ci"/></m:mi>
660 <xsl:apply-templates select="m:type"/>
662 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
663 <xsl:if test="position()=last()">
664 <m:mo stretchy="false">}</m:mo>
674 <xsl:when test="$name='cofix'">
676 <xsl:when test="$charlength >= $framewidth">
677 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
682 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
683 <m:mi><xsl:value-of select="m:ci"/></m:mi>
684 <m:mo stretchy="false">{</m:mo>
691 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
692 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
693 <xsl:for-each select="m:bvar">
694 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
698 <m:mi><xsl:value-of select="m:ci"/></m:mi>
700 <xsl:if test="$framewidth > $charlength">
701 <xsl:apply-templates select="m:type"/>
706 <xsl:if test="$charlength >= $framewidth">
710 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
711 <xsl:apply-templates select="m:type"/>
720 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
732 <m:mo stretchy="false">}</m:mo>
740 <m:mi><xsl:value-of select="m:ci"/></m:mi>
741 <m:mo stretchy="false">{</m:mo>
742 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
743 <xsl:for-each select="m:bvar">
747 <m:mi><xsl:value-of select="m:ci"/></m:mi>
749 <xsl:apply-templates select="m:type"/>
751 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
752 <xsl:if test="position()=last()">
753 <m:mo stretchy="false">}</m:mo>
769 <xsl:template match="m:lambda">
770 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
771 <m:mrow helm:xref="{@helm:xref}">
773 <xsl:when test="$charlength >= $framewidth">
774 <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>
775 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
779 <m:mo color="Red">λ</m:mo>
780 <!--<xsl:text disable-output-escaping="yes">&lambda;</xsl:text>-->
781 <xsl:apply-templates select="m:bvar/m:ci"/>
783 <xsl:if test="$framewidth > $charlength">
784 <xsl:apply-templates select="m:bvar/m:type"/>
789 <xsl:if test="$charlength >= $framewidth">
793 <m:mphantom><m:mtext>.</m:mtext></m:mphantom>
794 <xsl:apply-templates select="m:bvar/m:type"/>
803 <xsl:apply-templates select="*[position()=2]"/>
810 <m:mo color="Red">λ</m:mo>
811 <xsl:apply-templates select="m:bvar/m:ci"/>
813 <xsl:apply-templates select="m:bvar/m:type"/>
815 <xsl:apply-templates select="*[position()=2]"/>
821 <!--**********************-->
823 <!--**********************-->
825 <xsl:template match="m:ci|m:csymbol" mode="charcount">
826 <xsl:param name="incurrent_length" select="0"/>
827 <xsl:param name="nosibling" select="0"/>
829 <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
830 <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>
832 <xsl:when test="string($siblength) = """>
833 <xsl:value-of select="$incurrent_length + string-length()"/>
836 <xsl:value-of select="number($siblength)"/>
841 <xsl:value-of select="$incurrent_length + string-length()"/>
846 <xsl:template match="*" mode="charcount">
847 <xsl:param name="incurrent_length" select="0"/>
848 <xsl:param name="nosibling" select="0"/>
849 <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>
851 <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
852 <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>
854 <xsl:when test="string($siblength) = """>
855 <xsl:value-of select="number($childlength)"/>
858 <xsl:value-of select="number($siblength)"/>
863 <xsl:value-of select="number($childlength)"/>