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">
185 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
186 <m:msub><m:mi>?</m:mi><m:mn><xsl:value-of select="@no"/></m:mn></m:msub>
188 <xsl:apply-templates select="./*[1]"/>
196 <m:mtext>PROOF:</m:mtext>
203 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
204 <xsl:apply-templates select="body/*[1]"/>
212 <!-- MUTUAL INDUCTIVE DEFINITION -->
214 <xsl:template match="InductiveDefinition">
216 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
217 <xsl:for-each select="InductiveType">
222 <xsl:when test="position() = 1">
224 <xsl:when test="string(./@inductive) = "true"">
225 <m:mtext>INDUCTIVE DEFINITION</m:mtext>
228 <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
233 <m:mtext>AND</m:mtext>
236 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
237 <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
244 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
247 <xsl:when test="string(../Param) != """>
248 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
249 <xsl:for-each select="../Param">
253 <m:mi><xsl:value-of select="./@name"/></m:mi>
255 <xsl:apply-templates select="*"/>
279 <m:mtext>OF ARITY</m:mtext>
286 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
287 <xsl:apply-templates select="./arity/*[1]"/>
294 <m:mtext>BUILT FROM</m:mtext>
298 <xsl:for-each select="./Constructor">
303 <xsl:when test="position() = 1">
304 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
308 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
311 <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
312 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
313 <xsl:apply-templates select="./*[1]"/>
325 <xsl:template match="Variable">
327 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
331 <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
338 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
339 <xsl:apply-templates select="type/*[1]"/>
343 <xsl:if test="name(*[1])='body'">
347 <m:mtext>AS</m:mtext>
354 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
355 <xsl:apply-templates select="body/*[1]"/>
366 <xsl:template match="Sequent">
367 <xsl:variable name="rowlines">
368 <xsl:for-each select="Decl|Def">
369 <xsl:if test="position() != last()">
370 <xsl:text>none </xsl:text>
373 <xsl:text>solid</xsl:text>
376 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}" rowlines="{$rowlines}">
377 <xsl:for-each select="Decl|Def">
381 <m:mi><xsl:value-of select="@name"/></m:mi>
383 <xsl:when test="name(.) = 'Decl'">
390 <xsl:apply-templates select="*[1]"/>
395 <xsl:if test="not(Decl|Def)">
399 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
407 <xsl:apply-templates select="Goal/*[1]"/>
415 <!--**********************-->
417 <!--**********************-->
419 <xsl:template match="m:bvar">
421 <xsl:when test="m:type">
422 <xsl:variable name="charlength">
423 <xsl:apply-templates select="m:ci" mode="charcount"/>
426 <xsl:when test="$charlength >= $framewidth">
427 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
431 <xsl:apply-templates select="m:ci"/>
439 <xsl:apply-templates select="m:type"/>
447 <xsl:apply-templates select="m:ci"/>
449 <xsl:apply-templates select="m:type"/>
455 <xsl:apply-templates select="m:ci"/>
463 <xsl:template match="m:apply[m:csymbol]">
464 <xsl:param name="nopar" select="0"/>
465 <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
466 <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
469 <xsl:attribute name="xref"><xsl:value-of select="@id"/></xsl:attribute>
471 <xsl:variable name="id" select="m:csymbol/@id"/>
474 <xsl:when test="$name='forall'">
476 <xsl:when test="$charlength >= $framewidth">
477 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
481 <m:mo mathcolor="Blue">∀</m:mo>
482 <xsl:apply-templates select="m:bvar"/>
490 <xsl:apply-templates select="*[position()=3]"/>
497 <m:mo mathcolor="Blue">∀</m:mo>
498 <xsl:apply-templates select="m:bvar/m:ci"/>
500 <xsl:apply-templates select="m:bvar/m:type"/>
502 <xsl:apply-templates select="*[position()=3]"/>
507 <xsl:when test="$name='let_in'">
509 <xsl:when test="$charlength >= $framewidth">
510 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
515 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
516 <xsl:apply-templates select="m:bvar"/>
524 <xsl:apply-templates select="*[position()=3]"/>
532 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
533 <xsl:apply-templates select="*[position()=4]"/>
541 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
542 <xsl:apply-templates select="m:bvar/m:ci"/>
544 <xsl:apply-templates select="*[position()=3]"/>
545 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
546 <m:mtext>IN</m:mtext>
547 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
548 <xsl:apply-templates select="*[position()=4]"/>
553 <xsl:when test="$name='prod'">
555 <xsl:when test="$charlength >= $framewidth">
556 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
560 <m:mo mathcolor="Blue">Π</m:mo>
561 <xsl:apply-templates select="m:bvar"/>
569 <xsl:apply-templates select="*[position()=3]"/>
576 <m:mo mathcolor="Blue">Π</m:mo>
577 <xsl:apply-templates select="m:bvar/m:ci"/>
579 <xsl:apply-templates select="m:bvar/m:type"/>
581 <xsl:apply-templates select="*[position()=3]"/>
586 <xsl:when test="$name='arrow'">
588 <xsl:when test="$charlength >= $framewidth">
589 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
593 <xsl:if test="$nopar=0">
594 <m:mo stretchy="false">(</m:mo>
596 <xsl:apply-templates select="*[position()=2]"/>
603 <m:mo mathmathcolor="Blue">→</m:mo>
605 <xsl:when test="*[position()=3]/m:csymbol">
606 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
608 <xsl:when test="$nextp='arrow'">
609 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
612 <xsl:apply-templates select="*[position()=3]"/>
617 <xsl:apply-templates select="*[position()=3]"/>
623 <xsl:if test="$nopar=0">
627 <m:mo stretchy="false">)</m:mo>
635 <xsl:if test="$nopar=0">
636 <m:mo stretchy="false">(</m:mo>
638 <xsl:apply-templates select="*[position()=2]"/>
639 <m:mo mathcolor="Blue">→</m:mo>
641 <xsl:when test="*[position()=3]/m:csymbol">
642 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
644 <xsl:when test="$nextp='arrow'">
645 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
648 <xsl:apply-templates select="*[position()=3]"/>
653 <xsl:apply-templates select="*[position()=3]"/>
656 <xsl:if test="$nopar=0">
657 <m:mo stretchy="false">)</m:mo>
663 <xsl:when test="$name='app'">
665 <xsl:when test="$charlength >= $framewidth">
666 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
670 <m:mo stretchy="false">(</m:mo>
671 <!-- added precedence to app = FUNCTION_PREC (99) -->
672 <xsl:apply-templates select="*[position()=2]">
673 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
674 </xsl:apply-templates>
678 <xsl:for-each select="*[position()>2]">
682 <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
683 <!-- added precedence to app = FUNCTION_PREC (99) -->
684 <xsl:apply-templates select=".">
685 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
686 </xsl:apply-templates>
694 <m:mo stretchy="false">)</m:mo>
701 <m:mo stretchy="false">(</m:mo>
702 <!-- added precedence to app = FUNCTION_PREC (99) -->
703 <xsl:apply-templates select="*[position()=2]">
704 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
705 </xsl:apply-templates>
706 <xsl:for-each select="*[position()>2]">
707 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
708 <!-- added precedence to app = FUNCTION_PREC (99) -->
709 <xsl:apply-templates select=".">
710 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
711 </xsl:apply-templates>
713 <m:mo stretchy="false">)</m:mo>
718 <xsl:when test="$name='cast'">
720 <xsl:when test="$charlength >= $framewidth">
721 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
725 <m:mo stretchy="false">(</m:mo>
726 <xsl:apply-templates select="*[position()=2]"/>
733 <m:mo mathcolor="Maroon">:></m:mo>
734 <xsl:apply-templates select="*[position()=3]"/>
741 <m:mo stretchy="false">)</m:mo>
748 <m:mo stretchy="false">(</m:mo>
749 <xsl:apply-templates select="*[position()=2]"/>
750 <m:mo mathcolor="Maroon">:></m:mo>
751 <xsl:apply-templates select="*[position()=3]"/>
752 <m:mo stretchy="false">)</m:mo>
757 <xsl:when test="$name='Prop'">
761 <xsl:when test="$name='Set'">
765 <xsl:when test="$name='Type'">
769 <xsl:when test="$name='mutcase'">
771 <xsl:when test="$charlength >= $framewidth">
772 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
773 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
778 <xsl:apply-templates select="*[position()=2]"/>
779 <xsl:if test="$framewidth > $charlength">
782 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
783 <xsl:apply-templates select="*[position()=3]"/>
788 <xsl:if test="$charlength >= $framewidth">
794 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
795 <xsl:apply-templates select="*[position()=3]"/>
807 <xsl:for-each select="piecewise/piece">
808 <xsl:variable name="charlength"><xsl:apply-templates select="./*[2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
813 <xsl:when test="position() = 1">
814 <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
817 <m:mo stretchy="false">|</m:mo>
820 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
821 <xsl:apply-templates select="./*[2]"/>
822 <xsl:if test="$framewidth > $charlength">
823 <m:mo mathcolor="Green">⇒</m:mo>
824 <xsl:apply-templates select="./*[1]"/>
829 <xsl:if test="$charlength >= $framewidth">
833 <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
834 <m:mo mathcolor="Green">⇒</m:mo>
835 <xsl:apply-templates select="./*[1]"/>
851 <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
853 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
854 <xsl:apply-templates select="*[position()=3]"/>
855 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
857 <xsl:for-each select="piecewise/piece">
859 <xsl:when test="position() != 1">
860 <m:mo stretchy="false">|</m:mo>
863 <xsl:apply-templates select="./*[2]"/>
864 <m:mo mathcolor="Green">⇒</m:mo>
865 <xsl:apply-templates select="./*[1]"/>
867 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
873 <xsl:when test="$name='fix'">
875 <xsl:when test="$charlength >= $framewidth">
876 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
881 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
882 <m:mi><xsl:value-of select="m:ci"/></m:mi>
883 <m:mo stretchy="false">{</m:mo>
890 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
891 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
892 <xsl:for-each select="m:bvar">
893 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
897 <m:mi><xsl:value-of select="m:ci"/></m:mi>
899 <xsl:if test="$framewidth > $charlength">
900 <xsl:apply-templates select="m:type"/>
905 <xsl:if test="$charlength >= $framewidth">
909 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
910 <xsl:apply-templates select="m:type"/>
919 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
931 <m:mo stretchy="false">}</m:mo>
939 <m:mi><xsl:value-of select="m:ci"/></m:mi>
940 <m:mo stretchy="false">{</m:mo>
941 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
942 <xsl:for-each select="m:bvar">
946 <m:mi><xsl:value-of select="m:ci"/></m:mi>
948 <xsl:apply-templates select="m:type"/>
950 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
951 <xsl:if test="position()=last()">
952 <m:mo stretchy="false">}</m:mo>
963 <xsl:when test="$name='cofix'">
965 <xsl:when test="$charlength >= $framewidth">
966 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
971 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
972 <m:mi><xsl:value-of select="m:ci"/></m:mi>
973 <m:mo stretchy="false">{</m:mo>
980 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
981 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
982 <xsl:for-each select="m:bvar">
983 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
987 <m:mi><xsl:value-of select="m:ci"/></m:mi>
989 <xsl:if test="$framewidth > $charlength">
990 <xsl:apply-templates select="m:type"/>
995 <xsl:if test="$charlength >= $framewidth">
999 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
1000 <xsl:apply-templates select="m:type"/>
1009 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
1021 <m:mo stretchy="false">}</m:mo>
1029 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1030 <m:mo stretchy="false">{</m:mo>
1031 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1032 <xsl:for-each select="m:bvar">
1036 <m:mi><xsl:value-of select="m:ci"/></m:mi>
1038 <xsl:apply-templates select="m:type"/>
1040 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
1041 <xsl:if test="position()=last()">
1042 <m:mo stretchy="false">}</m:mo>
1052 <!-- ***************************************** -->
1053 <!-- *********** PROOF ELEMENTS ************** -->
1054 <!-- ***************************************** -->
1056 <xsl:when test="$name='proof'">
1057 <!-- CSC: $explodeall until the annotationHelper can handle mactions -->
1058 <xsl:variable name="test" select="(not($explodeall)) and
1059 (not(preceding-sibling::*[1]/text()='letin1')) and
1060 (not(preceding-sibling::*[1]/text()='rw_step')) and
1061 (not(name(..)='m:lambda'))"/>
1062 <xsl:variable name="hidden_details">
1063 <xsl:if test="$test">
1064 <!-- Details hided (default) -->
1065 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1069 <m:mtext mathcolor="Red">We can prove</m:mtext>
1070 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1071 <xsl:apply-templates select="*[position()=3]"/>
1073 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1074 <m:mtext mathcolor="Green">(explain)</m:mtext>
1082 <xsl:variable name="shown_details">
1083 <!-- Show details -->
1084 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1088 <xsl:apply-templates select="*[position()=2]"/>
1095 <m:mtext mathcolor="Red">we proved</m:mtext>
1096 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1097 <xsl:apply-templates select="*[position()=3]"/>
1100 <m:mtext>_</m:mtext>
1102 <xsl:if test="$test">
1103 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1112 <xsl:when test="$test">
1113 <m:maction actiontype="toggle">
1114 <xsl:copy-of select="$hidden_details"/>
1115 <xsl:copy-of select="$shown_details"/>
1119 <xsl:copy-of select="$shown_details"/>
1124 <xsl:when test="$name='side_proof'">
1125 <xsl:variable name="test" select="(not($explodeall))"/>
1126 <xsl:variable name="hidden_details">
1127 <xsl:if test="$test">
1128 <!-- Details hided (default) -->
1129 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1133 <m:mtext mathcolor="Red">We can prove</m:mtext>
1134 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1135 <xsl:apply-templates select="*[position()=3]"/>
1137 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1138 <m:mtext mathcolor="Green">(explain)</m:mtext>
1146 <xsl:variable name="shown_details">
1147 <!-- Show details -->
1148 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1152 <xsl:apply-templates select="*[position()=2]"/>
1159 <m:mtext mathcolor="Red">we proved</m:mtext>
1160 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1161 <xsl:apply-templates select="*[position()=3]"/>
1164 <m:mtext>_</m:mtext>
1166 <xsl:if test="$test">
1167 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1176 <xsl:when test="$test">
1177 <m:maction actiontype="toggle">
1178 <xsl:copy-of select="$hidden_details"/>
1179 <xsl:copy-of select="$shown_details"/>
1183 <xsl:copy-of select="$shown_details"/>
1188 <xsl:when test="$name='letin1'">
1189 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1193 <xsl:apply-templates select="*[position()=2]"/>
1200 <xsl:apply-templates select="*[position()=3]"/>
1206 <xsl:when test="$name='by_induction'">
1207 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1211 <m:mtext mathcolor="Red">We prove</m:mtext>
1212 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1213 <xsl:apply-templates select="../*[3]"/>
1220 <m:mtext mathcolor="Red">by induction on</m:mtext>
1221 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1222 <xsl:apply-templates
1223 select="*[position()=last()]/*[position()=last()]"/>
1230 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1231 <xsl:for-each select="*[position()>3 and not(position()=last())]">
1235 <xsl:apply-templates select="."/>
1246 <!-- inductive_case -->
1247 <xsl:when test="$name='inductive_case'">
1248 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1252 <m:mtext mathcolor="Red">Case</m:mtext>
1253 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1254 <xsl:apply-templates select="*[2]"/>
1261 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1262 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1263 <xsl:if test="*[3]/*[position()>1]">
1267 <m:mtext mathcolor="Red">By induction hypothesis, we have:</m:mtext>
1274 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1275 <xsl:for-each select="*[3]/*[position()>1]">
1276 <m:mo stretchy="false">(</m:mo>
1277 <xsl:apply-templates select="m:ci"/>
1278 <m:mo stretchy="false">) </m:mo>
1279 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1280 <xsl:apply-templates select="m:type"/>
1289 <xsl:apply-templates select="*[4]"/>
1300 <xsl:when test="$name='case_lhs'">
1303 <xsl:when test="count(*)=2">
1304 <xsl:apply-templates select="*[2]"/>
1307 <m:mo stretchy="false">(</m:mo>
1308 <xsl:apply-templates select="*[2]"/>
1309 <xsl:for-each select="m:bvar">
1310 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1311 <xsl:apply-templates select="*[1]"/>
1312 <m:mtext>:</m:mtext>
1313 <xsl:apply-templates select="m:type/*[1]"/>
1315 <m:mo stretchy="false">)</m:mo>
1321 <xsl:when test="$name='false_ind'">
1322 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1326 <xsl:apply-templates select="*[3]"/>
1333 <m:mtext mathcolor="Red">Contradiction.</m:mtext>
1340 <xsl:when test="$name='letin'">
1341 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1342 <!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
1343 <xsl:for-each select="*[(last() > position()) and (position()>1)]">
1347 <xsl:apply-templates select="."/>
1355 <xsl:apply-templates select="*[position()=last()]"/>
1362 <xsl:when test="$name='let'">
1363 <m:mtext>(</m:mtext>
1364 <xsl:apply-templates select="m:ci"/>
1365 <m:mtext>) </m:mtext>
1366 <xsl:apply-templates select="*[3]"/>
1369 <xsl:when test="$name='rw_step'">
1370 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1375 <xsl:when test="name(*[2])='m:apply'">
1376 <xsl:apply-templates select="*[2]"/>
1379 <m:mtext>Consider</m:mtext>
1380 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1381 <xsl:apply-templates select="*[2]"/>
1390 <m:mtext>Rewrite</m:mtext>
1391 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1392 <xsl:apply-templates select="*[3]"/>
1393 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1394 <m:mtext>with</m:mtext>
1395 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1396 <xsl:apply-templates select="*[4]"/>
1397 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1398 <m:mtext>by</m:mtext>
1399 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1400 <xsl:apply-templates select="*[5]"/>
1406 <!-- not existing any more
1407 <xsl:when test="$name='thread'">
1408 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1413 <xsl:when test="name(*[last()])='m:apply'">
1414 <xsl:apply-templates select="*[last()]"/>
1417 <m:mtext>Consider</m:mtext>
1418 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1419 <xsl:apply-templates select="*[last()]"/>
1425 <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
1429 <!-- REWRITE_AND_APPLY -->
1430 <xsl:when test="$name='rewrite_and_apply'">
1431 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1435 <xsl:apply-templates select="*[2]"/>
1442 <m:mtext>Then apply it to</m:mtext>
1443 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1444 <xsl:apply-templates select="*[position()>2]"/>
1451 <xsl:when test="$name='and_ind'">
1452 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1457 <xsl:when test="name(*[2])='m:apply'">
1458 <xsl:apply-templates select="*[2]"/>
1461 <m:mtext>Consider</m:mtext>
1462 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1463 <xsl:apply-templates select="*[2]"/>
1472 <m:mtext>In particular, we have</m:mtext>
1479 <m:mtext>(</m:mtext>
1480 <xsl:apply-templates select="*[3]"/>
1481 <m:mtext>)</m:mtext>
1482 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1483 <xsl:apply-templates select="*[4]"/>
1490 <m:mtext>(</m:mtext>
1491 <xsl:apply-templates select="*[5]"/>
1492 <m:mtext>)</m:mtext>
1493 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1494 <xsl:apply-templates select="*[6]"/>
1501 <xsl:apply-templates select="*[7]"/>
1507 <!-- full_or_ind -->
1508 <xsl:when test="$name='full_or_ind'">
1509 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1514 <xsl:when test="name(*[2])='m:apply'">
1515 <xsl:apply-templates select="*[2]"/>
1518 <m:mtext>Consider</m:mtext>
1519 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1520 <xsl:apply-templates select="*[2]"/>
1529 <m:mtext>We proceed by cases to prove</m:mtext>
1530 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1531 <xsl:apply-templates select="*[3]"/>
1538 <m:mtext>Left: suppose</m:mtext>
1539 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1540 <m:mo stretchy="false">(</m:mo>
1541 <xsl:apply-templates select="*[4]/m:bvar/m:ci"/>
1542 <m:mo stretchy="false">)</m:mo>
1543 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1544 <xsl:apply-templates select="*[4]/m:bvar/m:type/*[1]"/>
1551 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1552 <xsl:apply-templates select="*[4]/*[3]"/>
1559 <m:mtext>Right: suppose</m:mtext>
1560 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1561 <m:mo stretchy="false">(</m:mo>
1562 <xsl:apply-templates select="*[5]/m:bvar/m:ci"/>
1563 <m:mo stretchy="false">)</m:mo>
1564 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1565 <xsl:apply-templates select="*[5]/m:bvar/m:type/*[1]"/>
1572 <xsl:apply-templates select="*[5]/*[3]"/>
1579 <xsl:when test="$name='or_ind'">
1580 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1585 <xsl:when test="name(*[2])='m:apply'">
1586 <xsl:apply-templates select="*[2]"/>
1589 <m:mtext>Consider</m:mtext>
1590 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1591 <xsl:apply-templates select="*[2]"/>
1600 <m:mtext>We prove</m:mtext>
1601 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1602 <xsl:apply-templates select="*[3]"/>
1603 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1604 <m:mtext>by cases:</m:mtext>
1611 <m:mtext>Left</m:mtext>
1612 <xsl:apply-templates select="*[4]"/>
1619 <m:mtext>Right</m:mtext>
1620 <xsl:apply-templates select="*[5]"/>
1627 <xsl:when test="$name='ex_ind'">
1628 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1633 <xsl:when test="name(*[2])='m:apply'">
1634 <xsl:apply-templates select="*[2]"/>
1637 <m:mtext>Consider</m:mtext>
1638 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1639 <xsl:apply-templates select="*[2]"/>
1648 <m:mtext>Let</m:mtext>
1649 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1650 <xsl:apply-templates select="*[3]"/>
1651 <m:mtext>:</m:mtext>
1652 <xsl:apply-templates select="*[4]"/>
1653 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1654 <m:mtext>such that</m:mtext>
1655 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1656 <m:mtext>(</m:mtext>
1657 <xsl:apply-templates select="*[5]"/>
1658 <m:mtext>)</m:mtext>
1659 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1660 <xsl:apply-templates select="*[6]"/>
1667 <xsl:apply-templates select="*[7]"/>
1674 <xsl:when test="$name='eq_chain'">
1675 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1679 <m:mtext mathcolor="Red">We have the following equality chain:</m:mtext>
1683 <xsl:for-each select="*[position() mod 2 = 0]">
1684 <xsl:variable name="pos" select="position()"/>
1689 <xsl:when test="$pos = 1">
1690 <xsl:apply-templates select="."/>
1691 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1696 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1697 <xsl:apply-templates select="."/>
1703 <xsl:if test="$pos != last()">
1707 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1708 <xsl:apply-templates select="../*[position()=2*$pos +1]"/>
1716 <!-- DISEQ_CHAIN -->
1717 <xsl:when test="$name='diseq_chain'">
1718 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1722 <m:mtext mathcolor="Red">We have the following disequality chain:</m:mtext>
1726 <xsl:for-each select="*[position() mod 3 = 2]">
1727 <xsl:variable name="pos" select="position()"/>
1732 <xsl:when test="$pos = 1">
1733 <xsl:apply-templates select="."/>
1734 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1735 <mo><xsl:apply-templates select="../*[position()=3*$pos]"/></mo>
1738 <mo><xsl:apply-templates select="../*[position()=3*($pos - 1)]"/></mo>
1739 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1740 <xsl:apply-templates select="."/>
1746 <xsl:if test="$pos != last()">
1750 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1751 <xsl:apply-templates select="../*[position()=3*$pos +1]"/>
1759 <!-- ***************************************** -->
1760 <!-- *********** NOTATIONS ******************* -->
1761 <!-- ***************************************** -->
1763 <xsl:when test="$name='subst'">
1764 <xsl:apply-templates select="*[3]"/>
1765 <!-- no font for ApplyFunction: <m:mo></m:mo> -->
1766 <m:mo stretchy="false">[</m:mo>
1767 <xsl:apply-templates select="*[4]"/>
1768 <m:mo mathcolor="Green">
1769 <xsl:if test="$id != ''">
1770 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1771 </xsl:if>←</m:mo>
1772 <xsl:apply-templates select="*[2]"/>
1773 <m:mo stretchy="false">]</m:mo>
1776 <xsl:when test="$name='lift'">
1778 <m:mo mathcolor="Green">
1779 <xsl:if test="$id != ''">
1780 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1781 </xsl:if>↑</m:mo>
1782 <xsl:apply-templates select="*[2]"/>
1785 <m:mo stretchy="false">(</m:mo>
1786 <xsl:apply-templates select="*[3]"/>
1787 <m:mo stretchy="false">)</m:mo>
1790 <!-- lift_with_base -->
1791 <xsl:when test="$name='lift_with_base'">
1793 <m:mo mathcolor="Green">
1794 <xsl:if test="$id != ''">
1795 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1796 </xsl:if>↑</m:mo>
1797 <xsl:apply-templates select="*[3]"/>
1798 <xsl:apply-templates select="*[4]"/>
1801 <m:mo stretchy="false">(</m:mo>
1802 <xsl:apply-templates select="*[2]"/>
1803 <m:mo stretchy="false">)</m:mo>
1807 <xsl:when test="$name='beta_red1'">
1808 <xsl:apply-templates select="*[2]"/>
1810 <m:mo mathcolor="Green">
1811 <xsl:if test="$id != ''">
1812 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1813 </xsl:if>→</m:mo>
1814 <m:mi mathcolor="Green">β</m:mi>
1816 <xsl:apply-templates select="*[3]"/>
1819 <xsl:when test="$name='beta_red'">
1820 <xsl:apply-templates select="*[2]"/>
1822 <m:mo mathcolor="Green">
1823 <xsl:if test="$id != ''">
1824 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1825 </xsl:if>→</m:mo>
1826 <m:mi mathcolor="Green">β</m:mi>
1827 <m:mi mathcolor="Green">*</m:mi>
1829 <xsl:apply-templates select="*[3]"/>
1831 <!-- par_beta_red1 -->
1832 <xsl:when test="$name='par_beta_red1'">
1833 <xsl:apply-templates select="*[2]"/>
1835 <m:mo mathcolor="Green">
1836 <xsl:if test="$id != ''">
1837 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1838 </xsl:if>⇒</m:mo>
1839 <m:mi mathcolor="Green">β</m:mi>
1841 <xsl:apply-templates select="*[3]"/>
1843 <!-- par_beta_red -->
1844 <xsl:when test="$name='par_beta_red'">
1845 <xsl:apply-templates select="*[2]"/>
1847 <m:mo mathcolor="Green">
1848 <xsl:if test="$id != ''">
1849 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1850 </xsl:if>⇒</m:mo>
1851 <m:mi mathcolor="Green">β</m:mi>
1852 <m:mi mathcolor="Green">*</m:mi>
1854 <xsl:apply-templates select="*[3]"/>
1857 <xsl:when test="$name='forgetful'">
1858 <m:mfenced open="|" close="|">
1859 <xsl:if test="$id != ''">
1860 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1862 <xsl:apply-templates select="*[2]"/>
1866 <xsl:when test="$name='isomorphic'">
1867 <xsl:apply-templates select="*[2]"/>
1868 <m:mo mathcolor="Green">
1869 <xsl:if test="$id != ''">
1870 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1871 </xsl:if>≅</m:mo>
1872 <xsl:apply-templates select="*[3]"/>
1875 <xsl:when test="$name='forgetful'">
1876 <m:mfenced open="[" close="]">
1877 <xsl:if test="$id != ''">
1878 <xsl:attribute name="xref"><xsl:value-of select="$id"/></xsl:attribute>
1880 <xsl:apply-templates select="*[2]"/>
1892 <!-- Il modo Thread non esiste piu'
1893 <xsl:template match="*" mode="thread">
1894 <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
1896 <xsl:when test="$name='rw_step'">
1900 <m:mtext>Rewrite</m:mtext>
1901 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1902 <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
1903 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1904 <m:mtext>with</m:mtext>
1905 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1906 <xsl:apply-templates select="following-sibling::*[position()=1]/*[3]"/>
1907 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1908 <m:mtext>by</m:mtext>
1909 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1910 <xsl:apply-templates select="following-sibling::*[position()=1]/*[4]"/>
1917 <m:mtext mathcolor="Red">we get</m:mtext>
1918 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1919 <xsl:apply-templates select="."/>
1928 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
1935 <m:mtext mathcolor="Red">we get</m:mtext>
1936 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1937 <xsl:apply-templates select="."/>
1943 <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
1949 <xsl:template match="m:lambda">
1950 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
1953 <xsl:attribute name="xref">
1954 <xsl:value-of select="@id"/>
1958 <xsl:when test="$charlength >= $framewidth">
1959 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1963 <m:mo mathcolor="Red">λ</m:mo>
1964 <xsl:apply-templates select="m:bvar"/>
1972 <xsl:apply-templates select="*[position()=2]"/>
1979 <m:mo mathcolor="Red">λ</m:mo>
1980 <xsl:apply-templates select="m:bvar/m:ci"/>
1982 <xsl:apply-templates select="m:bvar/m:type"/>
1984 <xsl:apply-templates select="*[position()=2]"/>
1991 <!--**********************-->
1993 <!--**********************-->
1995 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
1996 |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
1997 |m:plus|m:minus|m:times" mode="charcount">
1998 <xsl:param name="incurrent_length" select="0"/>
2000 <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
2001 <xsl:variable name="siblength">
2002 <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
2003 <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
2004 </xsl:apply-templates>
2007 <xsl:when test="string($siblength) = """>
2008 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
2011 <xsl:value-of select="number($siblength)"/>
2016 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
2021 <xsl:template match="m:ci|m:csymbol" mode="charcount">
2022 <xsl:param name="incurrent_length" select="0"/>
2023 <xsl:param name="nosibling" select="0"/>
2025 <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
2026 <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>
2028 <xsl:when test="string($siblength) = """>
2029 <xsl:value-of select="$incurrent_length + string-length()"/>
2032 <xsl:value-of select="number($siblength)"/>
2037 <xsl:value-of select="$incurrent_length + string-length()"/>
2042 <xsl:template match="*" mode="charcount">
2043 <xsl:param name="incurrent_length" select="0"/>
2044 <xsl:param name="nosibling" select="0"/>
2046 <xsl:when test="count(child::*) = 0">
2047 <xsl:value-of select="$incurrent_length"/>
2050 <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>
2052 <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
2053 <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>
2055 <xsl:when test="string($siblength) = """>
2056 <xsl:value-of select="number($childlength)"/>
2059 <xsl:value-of select="number($siblength)"/>
2064 <xsl:value-of select="number($childlength)"/>