3 <!-- Copyright (C) 2000, HELM Team -->
5 <!-- This file is part of HELM, an Hypertextual, Electronic -->
6 <!-- Library of Mathematics, developed at the Computer Science -->
7 <!-- Department, University of Bologna, Italy. -->
9 <!-- HELM is free software; you can redistribute it and/or -->
10 <!-- modify it under the terms of the GNU General Public License -->
11 <!-- as published by the Free Software Foundation; either version 2 -->
12 <!-- of the License, or (at your option) any later version. -->
14 <!-- HELM is distributed in the hope that it will be useful, -->
15 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
16 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
17 <!-- GNU General Public License for more details. -->
19 <!-- You should have received a copy of the GNU General Public License -->
20 <!-- along with HELM; if not, write to the Free Software -->
21 <!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, -->
22 <!-- MA 02111-1307, USA. -->
24 <!-- For details, see the HELM World-Wide-Web page, -->
25 <!-- http://cs.unibo.it/helm/. -->
27 <!--***********************************************************************-->
28 <!-- Extension to the XSLT version 0.07 of MathML content to presentation: -->
29 <!-- First draft: February 19 2000, Andrea Asperti, Irene Schena -->
30 <!-- Revised: March 3 2000, Irene Schena -->
31 <!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena -->
32 <!-- Revised: March 21 2000, Irene Schena -->
33 <!--***********************************************************************-->
35 <!-- NOTE: the namespace declaration has to be done in the stylesheets
36 which generates the toplevel element (see for instance xlink) -->
37 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
38 xmlns:m="http://www.w3.org/1998/Math/MathML"
39 xmlns:helm="http://www.cs.unibo.it/helm"
40 xmlns:xlink="http://www.w3.org/1999/xlink">
42 <!-- OLD: <xsl:import href="mml2mmlv1_0.xsl"/> -->
44 <xsl:import href="mmlnotation.xsl"/>
46 <xsl:import href="mmltheoryextension.xsl"/>
49 <xsl:param name="explodeall" select="false()"/>
51 <!--***********************************************************************-->
52 <!-- Parameter affecting line-breaking -->
53 <!--***********************************************************************-->
55 <xsl:variable name="framewidth" select="35"/>
57 <!--***********************************************************************-->
58 <!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
59 <!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
60 <!-- sono i termini: la presentation per un termine e' generata come primo -->
61 <!-- figlio di un semantics e l'originario content viene inserito nel -->
62 <!-- nel secondo figlio di semantics, annotation-xml -->
63 <!--***********************************************************************-->
65 <!--**********************-->
67 <!--**********************-->
69 <xsl:param name="type" select="'standalone'"/>
71 <xsl:template match="/">
73 <xsl:when test="$type = 'standalone'">
74 <xsl:apply-templates select="*"/>
78 <xsl:apply-templates select="*"/>
86 <xsl:template match="Definition">
88 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
92 <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
99 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
100 <xsl:apply-templates select="type/*[1]"/>
107 <m:mtext>AS</m:mtext>
114 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
115 <xsl:apply-templates select="body/*[1]"/>
125 <xsl:template match="Axiom">
127 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
131 <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
138 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
139 <xsl:apply-templates select="type/*[1]"/>
147 <!-- UNFINISHED PROOF -->
149 <xsl:template match="CurrentProof">
151 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
155 <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
162 <m:mtext>THESIS:</m:mtext>
169 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
170 <xsl:apply-templates select="type/*[1]"/>
177 <m:mtext>CONJECTURES:</m:mtext>
181 <xsl:for-each select="Conjecture">
184 <m:mrow helm:xref="{@helm:xref}">
185 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
186 <xsl:for-each select="Decl|Def|Hidden">
188 <xsl:when test="name(.)='Decl'">
189 <m:mrow helm:xref="{@helm:xref}">
191 <xsl:when test="@name">
192 <m:mi><xsl:value-of select="@name"/></m:mi>
199 <xsl:apply-templates select="./*[1]"/>
202 <xsl:when test="name(.)='Def'">
203 <m:mrow helm:xref="{@helm:xref}">
205 <xsl:when test="@name">
206 <m:mi><xsl:value-of select="@name"/></m:mi>
213 <xsl:apply-templates select="./*[1]"/>
217 <m:mrow helm:xref="{@helm:xref}">
224 <xsl:if test="not (position() = last())">
229 <m:msub><m:mi>?</m:mi><m:mn><xsl:value-of select="@no"/></m:mn></m:msub>
231 <xsl:apply-templates select="./Goal/*[1]"/>
239 <m:mtext>PROOF:</m:mtext>
246 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
247 <xsl:apply-templates select="body/*[1]"/>
255 <!-- MUTUAL INDUCTIVE DEFINITION -->
257 <xsl:template match="InductiveDefinition">
259 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
260 <xsl:for-each select="InductiveType">
265 <xsl:when test="position() = 1">
267 <xsl:when test="string(./@inductive) = "true"">
268 <m:mtext>INDUCTIVE DEFINITION</m:mtext>
271 <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
276 <m:mtext>AND</m:mtext>
279 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
280 <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
287 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
290 <xsl:when test="string(../Param) != """>
291 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
292 <xsl:for-each select="../Param">
296 <m:mi><xsl:value-of select="./@name"/></m:mi>
298 <xsl:apply-templates select="*"/>
322 <m:mtext>OF ARITY</m:mtext>
329 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
330 <xsl:apply-templates select="./arity/*[1]"/>
337 <m:mtext>BUILT FROM</m:mtext>
341 <xsl:for-each select="./Constructor">
346 <xsl:when test="position() = 1">
347 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
351 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
354 <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
355 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
356 <xsl:apply-templates select="./*[1]"/>
368 <xsl:template match="Variable">
370 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
374 <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
381 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
382 <xsl:apply-templates select="type/*[1]"/>
386 <xsl:if test="name(*[1])='body'">
390 <m:mtext>AS</m:mtext>
397 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
398 <xsl:apply-templates select="body/*[1]"/>
409 <xsl:template match="Sequent">
410 <xsl:variable name="rowlines">
411 <xsl:for-each select="Decl|Def">
412 <xsl:if test="position() != last()">
413 <xsl:text>none </xsl:text>
416 <xsl:text>solid</xsl:text>
418 <xsl:variable name="no" select="@no"/>
420 <m:mi><xsl:text>?</xsl:text><xsl:value-of select="$no"/></m:mi>
422 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
423 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}" rowlines="{$rowlines}">
424 <xsl:for-each select="Decl|Def">
427 <m:mrow helm:xref="{@helm:xref}">
428 <m:mi><xsl:value-of select="@name"/></m:mi>
430 <xsl:when test="name(.) = 'Decl'">
437 <xsl:apply-templates select="*[1]"/>
442 <xsl:if test="not(Decl|Def)">
446 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
454 <xsl:apply-templates select="Goal/*[1]"/>
462 <!--**********************-->
464 <!--**********************-->
466 <xsl:template match="m:bvar">
468 <xsl:when test="m:type">
469 <xsl:variable name="charlength">
470 <xsl:apply-templates select="m:ci" mode="charcount"/>
473 <xsl:when test="$charlength >= $framewidth">
474 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
478 <xsl:apply-templates select="m:ci"/>
486 <xsl:apply-templates select="m:type"/>
494 <xsl:apply-templates select="m:ci"/>
496 <xsl:apply-templates select="m:type"/>
502 <xsl:apply-templates select="m:ci"/>
510 <xsl:template match="m:apply[m:csymbol]">
511 <xsl:param name="nopar" select="0"/>
512 <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
513 <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
516 <xsl:attribute name="xref"><xsl:value-of select="@id"/></xsl:attribute>
518 <xsl:variable name="id" select="m:csymbol/@id"/>
521 <xsl:when test="$name='meta'">
523 <xsl:apply-templates select="*[position()=2]"/>
524 <m:mfenced open="[" close="]" separators=";">
525 <xsl:apply-templates select="*[position()>2]"/>
530 <xsl:when test="$name='forall'">
532 <xsl:when test="$charlength >= $framewidth">
533 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
537 <m:mo mathcolor="Blue">∀</m:mo>
538 <xsl:apply-templates select="m:bvar"/>
546 <xsl:apply-templates select="*[position()=3]"/>
553 <m:mo mathcolor="Blue">∀</m:mo>
554 <xsl:apply-templates select="m:bvar/m:ci"/>
556 <xsl:apply-templates select="m:bvar/m:type"/>
558 <xsl:apply-templates select="*[position()=3]"/>
563 <xsl:when test="$name='let_in'">
565 <xsl:when test="$charlength >= $framewidth">
566 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
571 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
572 <xsl:apply-templates select="m:bvar"/>
580 <xsl:apply-templates select="*[position()=3]"/>
588 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
589 <xsl:apply-templates select="*[position()=4]"/>
597 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
598 <xsl:apply-templates select="m:bvar/m:ci"/>
600 <xsl:apply-templates select="*[position()=3]"/>
601 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
602 <m:mtext>IN</m:mtext>
603 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
604 <xsl:apply-templates select="*[position()=4]"/>
609 <xsl:when test="$name='prod'">
611 <xsl:when test="$charlength >= $framewidth">
612 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
616 <m:mo mathcolor="Blue">Π</m:mo>
617 <xsl:apply-templates select="m:bvar"/>
625 <xsl:apply-templates select="*[position()=3]"/>
632 <m:mo mathcolor="Blue">Π</m:mo>
633 <xsl:apply-templates select="m:bvar/m:ci"/>
635 <xsl:apply-templates select="m:bvar/m:type"/>
637 <xsl:apply-templates select="*[position()=3]"/>
642 <xsl:when test="$name='arrow'">
644 <xsl:when test="$charlength >= $framewidth">
645 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
649 <xsl:if test="$nopar=0">
650 <m:mo stretchy="false">(</m:mo>
652 <xsl:apply-templates select="*[position()=2]"/>
659 <m:mo mathmathcolor="Blue">→</m:mo>
661 <xsl:when test="*[position()=3]/m:csymbol">
662 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
664 <xsl:when test="$nextp='arrow'">
665 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
668 <xsl:apply-templates select="*[position()=3]"/>
673 <xsl:apply-templates select="*[position()=3]"/>
679 <xsl:if test="$nopar=0">
683 <m:mo stretchy="false">)</m:mo>
691 <xsl:if test="$nopar=0">
692 <m:mo stretchy="false">(</m:mo>
694 <xsl:apply-templates select="*[position()=2]"/>
695 <m:mo mathcolor="Blue">→</m:mo>
697 <xsl:when test="*[position()=3]/m:csymbol">
698 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
700 <xsl:when test="$nextp='arrow'">
701 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
704 <xsl:apply-templates select="*[position()=3]"/>
709 <xsl:apply-templates select="*[position()=3]"/>
712 <xsl:if test="$nopar=0">
713 <m:mo stretchy="false">)</m:mo>
719 <xsl:when test="$name='app'">
721 <xsl:when test="$charlength >= $framewidth">
722 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
726 <m:mo stretchy="false">(</m:mo>
727 <!-- added precedence to app = FUNCTION_PREC (99) -->
728 <xsl:apply-templates select="*[position()=2]">
729 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
730 </xsl:apply-templates>
734 <xsl:for-each select="*[position()>2]">
738 <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
739 <!-- added precedence to app = FUNCTION_PREC (99) -->
740 <xsl:apply-templates select=".">
741 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
742 </xsl:apply-templates>
750 <m:mo stretchy="false">)</m:mo>
757 <m:mo stretchy="false">(</m:mo>
758 <!-- added precedence to app = FUNCTION_PREC (99) -->
759 <xsl:apply-templates select="*[position()=2]">
760 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
761 </xsl:apply-templates>
762 <xsl:for-each select="*[position()>2]">
763 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
764 <!-- added precedence to app = FUNCTION_PREC (99) -->
765 <xsl:apply-templates select=".">
766 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
767 </xsl:apply-templates>
769 <m:mo stretchy="false">)</m:mo>
774 <xsl:when test="$name='cast'">
776 <xsl:when test="$charlength >= $framewidth">
777 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
781 <m:mo stretchy="false">(</m:mo>
782 <xsl:apply-templates select="*[position()=2]"/>
789 <m:mo mathcolor="Maroon">:></m:mo>
790 <xsl:apply-templates select="*[position()=3]"/>
797 <m:mo stretchy="false">)</m:mo>
804 <m:mo stretchy="false">(</m:mo>
805 <xsl:apply-templates select="*[position()=2]"/>
806 <m:mo mathcolor="Maroon">:></m:mo>
807 <xsl:apply-templates select="*[position()=3]"/>
808 <m:mo stretchy="false">)</m:mo>
813 <xsl:when test="$name='Prop'">
817 <xsl:when test="$name='Set'">
821 <xsl:when test="$name='Type'">
825 <xsl:when test="$name='mutcase'">
827 <xsl:when test="$charlength >= $framewidth">
828 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
829 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
834 <xsl:apply-templates select="*[position()=2]"/>
835 <xsl:if test="$framewidth > $charlength">
838 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
839 <xsl:apply-templates select="*[position()=3]"/>
844 <xsl:if test="$charlength >= $framewidth">
850 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
851 <xsl:apply-templates select="*[position()=3]"/>
863 <xsl:for-each select="m:piecewise/m:piece">
864 <xsl:variable name="charlength"><xsl:apply-templates select="./*[2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
869 <xsl:when test="position() = 1">
870 <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
873 <m:mo stretchy="false">|</m:mo>
876 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
877 <xsl:apply-templates select="./*[2]"/>
878 <xsl:if test="$framewidth > $charlength">
879 <m:mo mathcolor="Green">⇒</m:mo>
880 <xsl:apply-templates select="./*[1]"/>
885 <xsl:if test="$charlength >= $framewidth">
889 <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
890 <m:mo mathcolor="Green">⇒</m:mo>
891 <xsl:apply-templates select="./*[1]"/>
907 <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
909 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
910 <xsl:apply-templates select="*[position()=3]"/>
911 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
913 <xsl:for-each select="m:piecewise/m:piece">
915 <xsl:when test="position() != 1">
916 <m:mo stretchy="false">|</m:mo>
919 <xsl:apply-templates select="./*[2]"/>
920 <m:mo mathcolor="Green">⇒</m:mo>
921 <xsl:apply-templates select="./*[1]"/>
923 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
929 <xsl:when test="$name='fix'">
931 <xsl:when test="$charlength >= $framewidth">
932 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
937 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
938 <m:mi><xsl:value-of select="m:ci"/></m:mi>
939 <m:mo stretchy="false">{</m:mo>
946 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
947 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
948 <xsl:for-each select="m:bvar">
949 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
953 <m:mi><xsl:value-of select="m:ci"/></m:mi>
955 <xsl:if test="$framewidth > $charlength">
956 <xsl:apply-templates select="m:type"/>
961 <xsl:if test="$charlength >= $framewidth">
965 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
966 <xsl:apply-templates select="m:type"/>
975 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
987 <m:mo stretchy="false">}</m:mo>
995 <m:mi><xsl:value-of select="m:ci"/></m:mi>
996 <m:mo stretchy="false">{</m:mo>
997 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
998 <xsl:for-each select="m:bvar">
1002 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1004 <xsl:apply-templates select="m:type"/>
1006 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
1007 <xsl:if test="position()=last()">
1008 <m:mo stretchy="false">}</m:mo>
1019 <xsl:when test="$name='cofix'">
1021 <xsl:when test="$charlength >= $framewidth">
1022 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1027 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1028 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1029 <m:mo stretchy="false">{</m:mo>
1036 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1037 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1038 <xsl:for-each select="m:bvar">
1039 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
1043 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1045 <xsl:if test="$framewidth > $charlength">
1046 <xsl:apply-templates select="m:type"/>
1051 <xsl:if test="$charlength >= $framewidth">
1055 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
1056 <xsl:apply-templates select="m:type"/>
1065 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
1077 <m:mo stretchy="false">}</m:mo>
1085 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1086 <m:mo stretchy="false">{</m:mo>
1087 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1088 <xsl:for-each select="m:bvar">
1092 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1094 <xsl:apply-templates select="m:type"/>
1096 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
1097 <xsl:if test="position()=last()">
1098 <m:mo stretchy="false">}</m:mo>
1109 <xsl:when test="$name='inst'">
1111 <xsl:if test="$id != ''">
1112 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1114 <xsl:apply-templates select="*[2]"/>
1115 <m:mo stretchy="false">{</m:mo>
1116 <xsl:for-each select="*[(position()>2) and (position() mod 2 = 1)]">
1117 <xsl:apply-templates select="."/>
1118 <m:mo stretchy="false">:=</m:mo>
1119 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
1121 <m:mo stretchy="false">}</m:mo>
1125 <xsl:when test="$name='append'">
1127 <xsl:when test="$charlength >= $framewidth">
1128 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1132 <xsl:apply-templates select="*[2]"/>
1140 <xsl:apply-templates select="*[3]"/>
1148 <xsl:apply-templates select="*[2]"/>
1150 <xsl:apply-templates select="*[3]"/>
1156 <xsl:when test="$name='ite'">
1158 <xsl:when test="$charlength >= $framewidth">
1159 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1164 <xsl:apply-templates select="*[2]"/>
1172 <xsl:apply-templates select="*[3]"/>
1180 <xsl:apply-templates select="*[4]"/>
1189 <xsl:apply-templates select="*[2]"/>
1191 <xsl:apply-templates select="*[3]"/>
1193 <xsl:apply-templates select="*[4]"/>
1198 <!-- ***************************************** -->
1199 <!-- *********** PROOF ELEMENTS ************** -->
1200 <!-- ***************************************** -->
1202 <xsl:when test="$name='proof'">
1203 <!-- CSC: $explodeall until the annotationHelper can handle mactions -->
1204 <xsl:variable name="test" select="(not($explodeall)) and
1205 (not(preceding-sibling::*[1]/text()='letin1')) and
1206 (not(preceding-sibling::*[1]/text()='rw_step')) and
1207 (not(name(..)='m:lambda'))"/>
1208 <xsl:variable name="hidden_details">
1209 <xsl:if test="$test">
1210 <!-- Details hided (default) -->
1211 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1215 <m:mtext mathcolor="Red">We can prove</m:mtext>
1216 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1217 <!-- the last child is either the expected type, if provided,-->
1218 <!-- or the synthesized type. -->
1219 <xsl:apply-templates select="*[position()=last()]"/>
1221 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1222 <m:mtext mathcolor="Green">(explain)</m:mtext>
1230 <xsl:variable name="shown_details">
1231 <!-- Show details -->
1232 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1236 <xsl:apply-templates select="*[position()=2]"/>
1240 <xsl:variable name="hidedetails">
1243 <m:mtext>_</m:mtext>
1245 <xsl:if test="$test">
1246 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1253 <m:mtext mathcolor="Red">we proved</m:mtext>
1254 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1255 <xsl:apply-templates select="*[position()=3]"/>
1256 <xsl:if test="not(*[4])">
1257 <xsl:copy-of select="$hidedetails"/>
1262 <xsl:if test="*[4]">
1266 <m:mtext mathcolor="Red">that is equivalent to</m:mtext>
1267 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1268 <xsl:apply-templates select="*[position()=4]"/>
1269 <xsl:copy-of select="$hidedetails"/>
1277 <xsl:when test="$test">
1278 <m:maction actiontype="toggle">
1279 <xsl:copy-of select="$hidden_details"/>
1280 <xsl:copy-of select="$shown_details"/>
1284 <xsl:copy-of select="$shown_details"/>
1289 <xsl:when test="$name='side_proof'">
1290 <xsl:variable name="test" select="(not($explodeall))"/>
1291 <xsl:variable name="hidden_details">
1292 <xsl:if test="$test">
1293 <!-- Details hided (default) -->
1294 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1298 <m:mtext mathcolor="Red">We can prove</m:mtext>
1299 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1300 <!-- the last child is either the expected type, if provided,-->
1301 <!-- or the synthesized type. -->
1302 <xsl:apply-templates select="*[position()=last()]"/>
1304 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1305 <m:mtext mathcolor="Green">(explain)</m:mtext>
1313 <xsl:variable name="shown_details">
1314 <!-- Show details -->
1315 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1319 <xsl:apply-templates select="*[position()=2]"/>
1323 <xsl:variable name="hidedetails">
1326 <m:mtext>_</m:mtext>
1328 <xsl:if test="$test">
1329 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1336 <m:mtext mathcolor="Red">we proved</m:mtext>
1337 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1338 <xsl:apply-templates select="*[position()=3]"/>
1339 <xsl:if test="not(*[4])">
1340 <xsl:copy-of select="$hidedetails"/>
1345 <xsl:if test="*[4]">
1349 <m:mtext mathcolor="Red">that is equivalent to</m:mtext>
1350 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1351 <xsl:apply-templates select="*[position()=4]"/>
1352 <xsl:copy-of select="$hidedetails"/>
1360 <xsl:when test="$test">
1361 <m:maction actiontype="toggle">
1362 <xsl:copy-of select="$hidden_details"/>
1363 <xsl:copy-of select="$shown_details"/>
1367 <xsl:copy-of select="$shown_details"/>
1372 <xsl:when test="$name='letin1'">
1373 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1377 <xsl:apply-templates select="*[position()=2]"/>
1384 <xsl:apply-templates select="*[position()=3]"/>
1390 <xsl:when test="$name='by_induction'">
1391 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1395 <m:mtext mathcolor="Red">We prove</m:mtext>
1396 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1397 <xsl:apply-templates select="../*[3]"/>
1404 <m:mtext mathcolor="Red">by induction on</m:mtext>
1405 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1406 <xsl:apply-templates
1407 select="*[position()=last()]/*[position()=last()]"/>
1414 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1415 <xsl:for-each select="*[position()>3 and not(position()=last())]">
1419 <xsl:apply-templates select="."/>
1430 <!-- inductive_case -->
1431 <xsl:when test="$name='inductive_case'">
1432 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1436 <m:mtext mathcolor="Red">Case</m:mtext>
1437 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1438 <xsl:apply-templates select="*[2]"/>
1445 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1446 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1447 <xsl:if test="*[3]/*[position()>1]">
1451 <m:mtext mathcolor="Red">By induction hypothesis, we have:</m:mtext>
1458 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1459 <xsl:for-each select="*[3]/*[position()>1]">
1460 <m:mo stretchy="false">(</m:mo>
1461 <xsl:apply-templates select="m:ci"/>
1462 <m:mo stretchy="false">) </m:mo>
1463 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1464 <xsl:apply-templates select="m:type"/>
1473 <xsl:apply-templates select="*[4]"/>
1484 <xsl:when test="$name='case_lhs'">
1487 <xsl:when test="count(*)=2">
1488 <xsl:apply-templates select="*[2]"/>
1491 <m:mo stretchy="false">(</m:mo>
1492 <xsl:apply-templates select="*[2]"/>
1493 <xsl:for-each select="m:bvar">
1494 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1495 <xsl:apply-templates select="*[1]"/>
1496 <m:mtext>:</m:mtext>
1497 <xsl:apply-templates select="m:type/*[1]"/>
1499 <m:mo stretchy="false">)</m:mo>
1505 <xsl:when test="$name='false_ind'">
1506 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1510 <xsl:apply-templates select="*[3]"/>
1517 <m:mtext mathcolor="Red">Contradiction.</m:mtext>
1524 <xsl:when test="$name='letin'">
1525 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1526 <!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
1527 <xsl:for-each select="*[(last() > position()) and (position()>1)]">
1531 <xsl:apply-templates select="."/>
1539 <xsl:apply-templates select="*[position()=last()]"/>
1546 <xsl:when test="$name='let'">
1547 <m:mtext>(</m:mtext>
1548 <xsl:apply-templates select="m:ci"/>
1549 <m:mtext>) </m:mtext>
1550 <xsl:apply-templates select="*[3]"/>
1553 <xsl:when test="$name='rw_step'">
1554 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1559 <xsl:when test="name(*[2])='m:apply'">
1560 <xsl:apply-templates select="*[2]"/>
1563 <m:mtext>Consider</m:mtext>
1564 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1565 <xsl:apply-templates select="*[2]"/>
1571 <xsl:variable name="charlength1">
1572 <xsl:apply-templates select="*[3]" mode="root_charcount"/>
1574 <xsl:variable name="charlength2">
1575 <xsl:apply-templates select="*[4]" mode="root_charcount"/>
1577 <xsl:variable name="charlength3">
1578 <xsl:apply-templates select="*[5]" mode="root_charcount"/>
1580 <xsl:variable name="split1"
1581 select="($charlength1 + $charlength2) >= $framewidth"/>
1582 <xsl:variable name="split2"
1583 select="($charlength2 + $charlength3) >= $framewidth"/>
1585 <xsl:when test="$split1">
1589 <m:mtext>Rewrite</m:mtext>
1590 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1591 <xsl:apply-templates select="*[3]"/>
1596 <xsl:when test="$split2">
1600 <m:mtext>with</m:mtext>
1601 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1602 <xsl:apply-templates select="*[4]"/>
1609 <m:mtext>by</m:mtext>
1610 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1611 <xsl:apply-templates select="*[5]"/>
1620 <m:mtext>with</m:mtext>
1621 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1622 <xsl:apply-templates select="*[4]"/>
1623 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1624 <m:mtext>by</m:mtext>
1625 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1626 <xsl:apply-templates select="*[5]"/>
1633 <xsl:when test="$split2">
1637 <m:mtext>Rewrite</m:mtext>
1638 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1639 <xsl:apply-templates select="*[3]"/>
1640 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1641 <m:mtext>with</m:mtext>
1642 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1643 <xsl:apply-templates select="*[4]"/>
1650 <m:mtext>by</m:mtext>
1651 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1652 <xsl:apply-templates select="*[5]"/>
1661 <m:mtext>Rewrite</m:mtext>
1662 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1663 <xsl:apply-templates select="*[3]"/>
1664 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1665 <m:mtext>with</m:mtext>
1666 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1667 <xsl:apply-templates select="*[4]"/>
1668 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1669 <m:mtext>by</m:mtext>
1670 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1671 <xsl:apply-templates select="*[5]"/>
1679 <!-- not existing any more
1680 <xsl:when test="$name='thread'">
1681 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1686 <xsl:when test="name(*[last()])='m:apply'">
1687 <xsl:apply-templates select="*[last()]"/>
1690 <m:mtext>Consider</m:mtext>
1691 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1692 <xsl:apply-templates select="*[last()]"/>
1698 <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
1702 <!-- REWRITE_AND_APPLY -->
1703 <xsl:when test="$name='rewrite_and_apply'">
1704 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1708 <xsl:apply-templates select="*[2]"/>
1715 <m:mtext>Then apply it to</m:mtext>
1716 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1717 <xsl:apply-templates select="*[position()>2]"/>
1724 <xsl:when test="$name='and_ind'">
1725 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1730 <xsl:when test="name(*[2])='m:apply'">
1731 <xsl:apply-templates select="*[2]"/>
1734 <m:mtext>Consider</m:mtext>
1735 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1736 <xsl:apply-templates select="*[2]"/>
1745 <m:mtext>In particular, we have</m:mtext>
1752 <m:mtext>(</m:mtext>
1753 <xsl:apply-templates select="*[3]"/>
1754 <m:mtext>)</m:mtext>
1755 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1756 <xsl:apply-templates select="*[4]"/>
1763 <m:mtext>(</m:mtext>
1764 <xsl:apply-templates select="*[5]"/>
1765 <m:mtext>)</m:mtext>
1766 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1767 <xsl:apply-templates select="*[6]"/>
1774 <xsl:apply-templates select="*[7]"/>
1780 <!-- full_or_ind -->
1781 <xsl:when test="$name='full_or_ind'">
1782 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1787 <xsl:when test="name(*[2])='m:apply'">
1788 <xsl:apply-templates select="*[2]"/>
1791 <m:mtext>Consider</m:mtext>
1792 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1793 <xsl:apply-templates select="*[2]"/>
1802 <m:mtext>We proceed by cases to prove</m:mtext>
1803 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1804 <xsl:apply-templates select="*[3]"/>
1811 <m:mtext>Left: suppose</m:mtext>
1812 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1813 <m:mo stretchy="false">(</m:mo>
1814 <xsl:apply-templates select="*[4]/m:bvar/m:ci"/>
1815 <m:mo stretchy="false">)</m:mo>
1816 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1817 <xsl:apply-templates select="*[4]/m:bvar/m:type/*[1]"/>
1824 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1825 <xsl:apply-templates select="*[4]/*[3]"/>
1832 <m:mtext>Right: suppose</m:mtext>
1833 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1834 <m:mo stretchy="false">(</m:mo>
1835 <xsl:apply-templates select="*[5]/m:bvar/m:ci"/>
1836 <m:mo stretchy="false">)</m:mo>
1837 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1838 <xsl:apply-templates select="*[5]/m:bvar/m:type/*[1]"/>
1845 <xsl:apply-templates select="*[5]/*[3]"/>
1852 <xsl:when test="$name='or_ind'">
1853 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1858 <xsl:when test="name(*[2])='m:apply'">
1859 <xsl:apply-templates select="*[2]"/>
1862 <m:mtext>Consider</m:mtext>
1863 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1864 <xsl:apply-templates select="*[2]"/>
1873 <m:mtext>We prove</m:mtext>
1874 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1875 <xsl:apply-templates select="*[3]"/>
1876 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1877 <m:mtext>by cases:</m:mtext>
1884 <m:mtext>Left</m:mtext>
1885 <xsl:apply-templates select="*[4]"/>
1892 <m:mtext>Right</m:mtext>
1893 <xsl:apply-templates select="*[5]"/>
1900 <xsl:when test="$name='ex_ind'">
1901 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1906 <xsl:when test="name(*[2])='m:apply'">
1907 <xsl:apply-templates select="*[2]"/>
1910 <m:mtext>Consider</m:mtext>
1911 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1912 <xsl:apply-templates select="*[2]"/>
1921 <m:mtext>Let</m:mtext>
1922 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1923 <xsl:apply-templates select="*[3]"/>
1924 <m:mtext>:</m:mtext>
1925 <xsl:apply-templates select="*[4]"/>
1926 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1927 <m:mtext>such that</m:mtext>
1928 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1929 <m:mtext>(</m:mtext>
1930 <xsl:apply-templates select="*[5]"/>
1931 <m:mtext>)</m:mtext>
1932 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1933 <xsl:apply-templates select="*[6]"/>
1940 <xsl:apply-templates select="*[7]"/>
1947 <xsl:when test="$name='eq_chain'">
1948 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1952 <m:mtext mathcolor="Red">We have the following equality chain:</m:mtext>
1956 <xsl:for-each select="*[position() mod 2 = 0]">
1957 <xsl:variable name="pos" select="position()"/>
1962 <xsl:when test="$pos = 1">
1963 <xsl:apply-templates select="."/>
1964 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1969 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1970 <xsl:apply-templates select="."/>
1976 <xsl:if test="$pos != last()">
1980 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1981 <xsl:apply-templates select="../*[position()=2*$pos +1]"/>
1989 <!-- DISEQ_CHAIN -->
1990 <xsl:when test="$name='diseq_chain'">
1991 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1995 <m:mtext mathcolor="Red">We have the following disequality chain:</m:mtext>
1999 <xsl:for-each select="*[position() mod 3 = 2]">
2000 <xsl:variable name="pos" select="position()"/>
2005 <xsl:when test="$pos = 1">
2006 <xsl:apply-templates select="."/>
2007 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2008 <mo><xsl:apply-templates select="../*[position()=3*$pos]"/></mo>
2011 <mo><xsl:apply-templates select="../*[position()=3*($pos - 1)]"/></mo>
2012 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2013 <xsl:apply-templates select="."/>
2019 <xsl:if test="$pos != last()">
2023 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
2024 <xsl:apply-templates select="../*[position()=3*$pos +1]"/>
2032 <!-- ***************************************** -->
2033 <!-- *********** NOTATIONS ******************* -->
2034 <!-- ***************************************** -->
2036 <xsl:when test="$name='subst'">
2037 <xsl:apply-templates select="*[3]"/>
2038 <!-- no font for ApplyFunction: <m:mo></m:mo> -->
2039 <m:mo stretchy="false">[</m:mo>
2040 <xsl:apply-templates select="*[4]"/>
2041 <m:mo mathcolor="Green">
2042 <xsl:if test="$id != ''">
2043 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2044 </xsl:if>←</m:mo>
2045 <xsl:apply-templates select="*[2]"/>
2046 <m:mo stretchy="false">]</m:mo>
2049 <xsl:when test="$name='lift'">
2051 <m:mo mathcolor="Green">
2052 <xsl:if test="$id != ''">
2053 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2054 </xsl:if>↑</m:mo>
2055 <xsl:apply-templates select="*[2]"/>
2058 <m:mo stretchy="false">(</m:mo>
2059 <xsl:apply-templates select="*[3]"/>
2060 <m:mo stretchy="false">)</m:mo>
2063 <!-- lift_with_base -->
2064 <xsl:when test="$name='lift_with_base'">
2066 <m:mo mathcolor="Green">
2067 <xsl:if test="$id != ''">
2068 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2069 </xsl:if>↑</m:mo>
2070 <xsl:apply-templates select="*[3]"/>
2071 <xsl:apply-templates select="*[4]"/>
2074 <m:mo stretchy="false">(</m:mo>
2075 <xsl:apply-templates select="*[2]"/>
2076 <m:mo stretchy="false">)</m:mo>
2080 <xsl:when test="$name='beta_red1'">
2081 <xsl:apply-templates select="*[2]"/>
2083 <m:mo mathcolor="Green">
2084 <xsl:if test="$id != ''">
2085 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2086 </xsl:if>→</m:mo>
2087 <m:mi mathcolor="Green">β</m:mi>
2089 <xsl:apply-templates select="*[3]"/>
2092 <xsl:when test="$name='beta_red'">
2093 <xsl:apply-templates select="*[2]"/>
2095 <m:mo mathcolor="Green">
2096 <xsl:if test="$id != ''">
2097 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2098 </xsl:if>→</m:mo>
2099 <m:mi mathcolor="Green">β</m:mi>
2100 <m:mi mathcolor="Green">*</m:mi>
2102 <xsl:apply-templates select="*[3]"/>
2104 <!-- par_beta_red1 -->
2105 <xsl:when test="$name='par_beta_red1'">
2106 <xsl:apply-templates select="*[2]"/>
2108 <m:mo mathcolor="Green">
2109 <xsl:if test="$id != ''">
2110 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2111 </xsl:if>⇒</m:mo>
2112 <m:mi mathcolor="Green">β</m:mi>
2114 <xsl:apply-templates select="*[3]"/>
2116 <!-- par_beta_red -->
2117 <xsl:when test="$name='par_beta_red'">
2118 <xsl:apply-templates select="*[2]"/>
2120 <m:mo mathcolor="Green">
2121 <xsl:if test="$id != ''">
2122 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2123 </xsl:if>⇒</m:mo>
2124 <m:mi mathcolor="Green">β</m:mi>
2125 <m:mi mathcolor="Green">*</m:mi>
2127 <xsl:apply-templates select="*[3]"/>
2130 <xsl:when test="$name='forgetful'">
2131 <m:mfenced open="|" close="|">
2132 <xsl:if test="$id != ''">
2133 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2135 <xsl:apply-templates select="*[2]"/>
2139 <xsl:when test="$name='isomorphic'">
2140 <xsl:apply-templates select="*[2]"/>
2141 <m:mo mathcolor="Green">
2142 <xsl:if test="$id != ''">
2143 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2144 </xsl:if>≅</m:mo>
2145 <xsl:apply-templates select="*[3]"/>
2148 <xsl:when test="$name='interp'">
2149 <m:mfenced open="[" close="]">
2150 <xsl:if test="$id != ''">
2151 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
2153 <xsl:apply-templates select="*[2]"/>
2159 <m:mi>ERROR("<xsl:value-of select="$name"/>")</m:mi>
2165 <!-- Il modo Thread non esiste piu'
2166 <xsl:template match="*" mode="thread">
2167 <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
2169 <xsl:when test="$name='rw_step'">
2173 <m:mtext>Rewrite</m:mtext>
2174 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2175 <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
2176 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2177 <m:mtext>with</m:mtext>
2178 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2179 <xsl:apply-templates select="following-sibling::*[position()=1]/*[3]"/>
2180 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2181 <m:mtext>by</m:mtext>
2182 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2183 <xsl:apply-templates select="following-sibling::*[position()=1]/*[4]"/>
2190 <m:mtext mathcolor="Red">we get</m:mtext>
2191 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2192 <xsl:apply-templates select="."/>
2201 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
2208 <m:mtext mathcolor="Red">we get</m:mtext>
2209 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
2210 <xsl:apply-templates select="."/>
2216 <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
2222 <xsl:template match="m:lambda">
2223 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
2226 <xsl:attribute name="xref">
2227 <xsl:value-of select="@id"/>
2231 <xsl:when test="$charlength >= $framewidth">
2232 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
2236 <m:mo mathcolor="Red">λ</m:mo>
2237 <xsl:apply-templates select="m:bvar"/>
2245 <xsl:apply-templates select="*[position()=2]"/>
2252 <m:mo mathcolor="Red">λ</m:mo>
2253 <xsl:apply-templates select="m:bvar/m:ci"/>
2255 <xsl:apply-templates select="m:bvar/m:type"/>
2257 <xsl:apply-templates select="*[position()=2]"/>
2264 <!--**********************-->
2266 <!--**********************-->
2268 <!-- enter this counting mode selecting the root -->
2269 <xsl:template match="*" mode="root_charcount">
2270 <xsl:param name="incurrent_length" select="0"/>
2272 <xsl:when test="count(*)=0">
2273 <xsl:value-of select="0"/>
2275 <xsl:when test="name()='m:ci'">
2276 <xsl:value-of select="string-length()"/>
2279 <xsl:apply-templates select="*[1]" mode="charcount">
2280 <xsl:with-param name="incurrent_length" select="$incurrent_length"/>
2281 </xsl:apply-templates>
2286 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
2287 |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
2288 |m:plus|m:minus|m:times" mode="charcount">
2289 <xsl:param name="incurrent_length" select="0"/>
2291 <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
2292 <xsl:variable name="siblength">
2293 <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
2294 <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
2295 </xsl:apply-templates>
2298 <xsl:when test="string($siblength) = """>
2299 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
2302 <xsl:value-of select="number($siblength)"/>
2307 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
2312 <xsl:template match="m:ci|m:csymbol" mode="charcount">
2313 <xsl:param name="incurrent_length" select="0"/>
2314 <xsl:param name="nosibling" select="0"/>
2315 <xsl:variable name="mylength">
2317 <!-- special notation -->
2318 <xsl:when test="text()='append'">3</xsl:when>
2319 <!-- no notation -->
2321 <xsl:value-of select="string-length()"/>
2326 <xsl:when test="$framewidth > ($incurrent_length + $mylength) and ($nosibling = 0)">
2327 <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + $mylength"/></xsl:apply-templates></xsl:variable>
2329 <xsl:when test="string($siblength) = """>
2330 <xsl:value-of select="$incurrent_length + $mylength"/>
2333 <xsl:value-of select="number($siblength)"/>
2338 <xsl:value-of select="$incurrent_length + $mylength"/>
2343 <xsl:template match="*" mode="charcount">
2344 <xsl:param name="incurrent_length" select="0"/>
2345 <xsl:param name="nosibling" select="0"/>
2347 <xsl:when test="count(child::*) = 0">
2348 <!-- tremendous bug fixed. An empty element can still have siblings!!! -->
2349 <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/></xsl:apply-templates></xsl:variable>
2351 <xsl:when test="string($siblength) = """>
2352 <xsl:value-of select="$incurrent_length"/>
2355 <xsl:value-of select="number($siblength)"/>
2360 <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>
2362 <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
2363 <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>
2365 <xsl:when test="string($siblength) = """>
2366 <xsl:value-of select="number($childlength)"/>
2369 <xsl:value-of select="number($siblength)"/>
2374 <xsl:value-of select="number($childlength)"/>