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:mtext><xsl:value-of select="./@no"/>:</m:mtext>
187 <xsl:apply-templates select="./*[1]"/>
195 <m:mtext>CORRESPONDING PROOF:</m:mtext>
202 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
203 <xsl:apply-templates select="body/*[1]"/>
211 <!-- MUTUAL INDUCTIVE DEFINITION -->
213 <xsl:template match="InductiveDefinition">
215 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
216 <xsl:for-each select="InductiveType">
221 <xsl:when test="position() = 1">
223 <xsl:when test="string(./@inductive) = "true"">
224 <m:mtext>INDUCTIVE DEFINITION</m:mtext>
227 <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
232 <m:mtext>AND</m:mtext>
235 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
236 <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
243 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
246 <xsl:when test="string(../Param) != """>
247 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
248 <xsl:for-each select="../Param">
252 <m:mi><xsl:value-of select="./@name"/></m:mi>
254 <xsl:apply-templates select="*"/>
278 <m:mtext>OF ARITY</m:mtext>
285 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
286 <xsl:apply-templates select="./arity/*[1]"/>
293 <m:mtext>BUILT FROM</m:mtext>
297 <xsl:for-each select="./Constructor">
302 <xsl:when test="position() = 1">
303 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
307 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
310 <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
311 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
312 <xsl:apply-templates select="./*[1]"/>
324 <xsl:template match="Variable">
326 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
330 <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
337 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
338 <xsl:apply-templates select="type/*[1]"/>
342 <xsl:if test="name(*[1])='body'">
346 <m:mtext>AS</m:mtext>
353 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
354 <xsl:apply-templates select="body/*[1]"/>
363 <!--**********************-->
365 <!--**********************-->
367 <xsl:template match="m:bvar">
369 <xsl:when test="m:type">
370 <xsl:variable name="charlength">
371 <xsl:apply-templates select="m:ci" mode="charcount"/>
374 <xsl:when test="$charlength >= $framewidth">
375 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
379 <xsl:apply-templates select="m:ci"/>
387 <xsl:apply-templates select="m:type"/>
395 <xsl:apply-templates select="m:ci"/>
397 <xsl:apply-templates select="m:type"/>
403 <xsl:apply-templates select="m:ci"/>
411 <xsl:template match="m:apply[m:csymbol]">
412 <xsl:param name="nopar" select="0"/>
413 <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
414 <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
417 <xsl:attribute name="m:xref"><xsl:value-of select="@id"/></xsl:attribute>
419 <xsl:variable name="id" select="m:csymbol/@id"/>
422 <xsl:when test="$name='forall'">
424 <xsl:when test="$charlength >= $framewidth">
425 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
429 <m:mo mathcolor="Blue">∀</m:mo>
430 <xsl:apply-templates select="m:bvar"/>
438 <xsl:apply-templates select="*[position()=3]"/>
445 <m:mo mathcolor="Blue">∀</m:mo>
446 <xsl:apply-templates select="m:bvar/m:ci"/>
448 <xsl:apply-templates select="m:bvar/m:type"/>
450 <xsl:apply-templates select="*[position()=3]"/>
455 <xsl:when test="$name='let_in'">
457 <xsl:when test="$charlength >= $framewidth">
458 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
463 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
464 <xsl:apply-templates select="m:bvar"/>
472 <xsl:apply-templates select="*[position()=3]"/>
480 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
481 <xsl:apply-templates select="*[position()=4]"/>
489 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
490 <xsl:apply-templates select="m:bvar/m:ci"/>
492 <xsl:apply-templates select="*[position()=3]"/>
493 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
494 <m:mtext>IN</m:mtext>
495 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
496 <xsl:apply-templates select="*[position()=4]"/>
501 <xsl:when test="$name='prod'">
503 <xsl:when test="$charlength >= $framewidth">
504 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
508 <m:mo mathcolor="Blue">Π</m:mo>
509 <xsl:apply-templates select="m:bvar"/>
517 <xsl:apply-templates select="*[position()=3]"/>
524 <m:mo mathcolor="Blue">Π</m:mo>
525 <xsl:apply-templates select="m:bvar/m:ci"/>
527 <xsl:apply-templates select="m:bvar/m:type"/>
529 <xsl:apply-templates select="*[position()=3]"/>
534 <xsl:when test="$name='arrow'">
536 <xsl:when test="$charlength >= $framewidth">
537 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
541 <xsl:if test="$nopar=0">
542 <m:mo stretchy="false">(</m:mo>
544 <xsl:apply-templates select="*[position()=2]"/>
551 <m:mo mathmathcolor="Blue">→</m:mo>
553 <xsl:when test="*[position()=3]/m:csymbol">
554 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
556 <xsl:when test="$nextp='arrow'">
557 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
560 <xsl:apply-templates select="*[position()=3]"/>
565 <xsl:apply-templates select="*[position()=3]"/>
571 <xsl:if test="$nopar=0">
575 <m:mo stretchy="false">)</m:mo>
583 <xsl:if test="$nopar=0">
584 <m:mo stretchy="false">(</m:mo>
586 <xsl:apply-templates select="*[position()=2]"/>
587 <m:mo mathcolor="Blue">→</m:mo>
589 <xsl:when test="*[position()=3]/m:csymbol">
590 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
592 <xsl:when test="$nextp='arrow'">
593 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
596 <xsl:apply-templates select="*[position()=3]"/>
601 <xsl:apply-templates select="*[position()=3]"/>
604 <xsl:if test="$nopar=0">
605 <m:mo stretchy="false">)</m:mo>
611 <xsl:when test="$name='app'">
613 <xsl:when test="$charlength >= $framewidth">
614 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
618 <m:mo stretchy="false">(</m:mo>
619 <!-- added precedence to app = FUNCTION_PREC (99) -->
620 <xsl:apply-templates select="*[position()=2]">
621 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
622 </xsl:apply-templates>
626 <xsl:for-each select="*[position()>2]">
630 <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
631 <!-- added precedence to app = FUNCTION_PREC (99) -->
632 <xsl:apply-templates select=".">
633 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
634 </xsl:apply-templates>
642 <m:mo stretchy="false">)</m:mo>
649 <m:mo stretchy="false">(</m:mo>
650 <!-- added precedence to app = FUNCTION_PREC (99) -->
651 <xsl:apply-templates select="*[position()=2]">
652 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
653 </xsl:apply-templates>
654 <xsl:for-each select="*[position()>2]">
655 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
656 <!-- added precedence to app = FUNCTION_PREC (99) -->
657 <xsl:apply-templates select=".">
658 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
659 </xsl:apply-templates>
661 <m:mo stretchy="false">)</m:mo>
666 <xsl:when test="$name='cast'">
668 <xsl:when test="$charlength >= $framewidth">
669 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
673 <m:mo stretchy="false">(</m:mo>
674 <xsl:apply-templates select="*[position()=2]"/>
681 <m:mo mathcolor="Maroon">:></m:mo>
682 <xsl:apply-templates select="*[position()=3]"/>
689 <m:mo stretchy="false">)</m:mo>
696 <m:mo stretchy="false">(</m:mo>
697 <xsl:apply-templates select="*[position()=2]"/>
698 <m:mo mathcolor="Maroon">:></m:mo>
699 <xsl:apply-templates select="*[position()=3]"/>
700 <m:mo stretchy="false">)</m:mo>
705 <xsl:when test="$name='Prop'">
709 <xsl:when test="$name='Set'">
713 <xsl:when test="$name='Type'">
717 <xsl:when test="$name='mutcase'">
719 <xsl:when test="$charlength >= $framewidth">
720 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
721 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
726 <xsl:apply-templates select="*[position()=2]"/>
727 <xsl:if test="$framewidth > $charlength">
730 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
731 <xsl:apply-templates select="*[position()=3]"/>
736 <xsl:if test="$charlength >= $framewidth">
742 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
743 <xsl:apply-templates select="*[position()=3]"/>
755 <xsl:for-each select="piecewise/piece">
756 <xsl:variable name="charlength"><xsl:apply-templates select="./*[2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
761 <xsl:when test="position() = 1">
762 <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
765 <m:mo stretchy="false">|</m:mo>
768 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
769 <xsl:apply-templates select="./*[2]"/>
770 <xsl:if test="$framewidth > $charlength">
771 <m:mo mathcolor="Green">⇒</m:mo>
772 <xsl:apply-templates select="./*[1]"/>
777 <xsl:if test="$charlength >= $framewidth">
781 <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
782 <m:mo mathcolor="Green">⇒</m:mo>
783 <xsl:apply-templates select="./*[1]"/>
799 <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
801 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
802 <xsl:apply-templates select="*[position()=3]"/>
803 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
805 <xsl:for-each select="piecewise/piece">
807 <xsl:when test="position() != 1">
808 <m:mo stretchy="false">|</m:mo>
811 <xsl:apply-templates select="./*[2]"/>
812 <m:mo mathcolor="Green">⇒</m:mo>
813 <xsl:apply-templates select="./*[1]"/>
815 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
821 <xsl:when test="$name='fix'">
823 <xsl:when test="$charlength >= $framewidth">
824 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
829 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
830 <m:mi><xsl:value-of select="m:ci"/></m:mi>
831 <m:mo stretchy="false">{</m:mo>
838 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
839 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
840 <xsl:for-each select="m:bvar">
841 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
845 <m:mi><xsl:value-of select="m:ci"/></m:mi>
847 <xsl:if test="$framewidth > $charlength">
848 <xsl:apply-templates select="m:type"/>
853 <xsl:if test="$charlength >= $framewidth">
857 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
858 <xsl:apply-templates select="m:type"/>
867 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
879 <m:mo stretchy="false">}</m:mo>
887 <m:mi><xsl:value-of select="m:ci"/></m:mi>
888 <m:mo stretchy="false">{</m:mo>
889 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
890 <xsl:for-each select="m:bvar">
894 <m:mi><xsl:value-of select="m:ci"/></m:mi>
896 <xsl:apply-templates select="m:type"/>
898 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
899 <xsl:if test="position()=last()">
900 <m:mo stretchy="false">}</m:mo>
911 <xsl:when test="$name='cofix'">
913 <xsl:when test="$charlength >= $framewidth">
914 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
919 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
920 <m:mi><xsl:value-of select="m:ci"/></m:mi>
921 <m:mo stretchy="false">{</m:mo>
928 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
929 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
930 <xsl:for-each select="m:bvar">
931 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
935 <m:mi><xsl:value-of select="m:ci"/></m:mi>
937 <xsl:if test="$framewidth > $charlength">
938 <xsl:apply-templates select="m:type"/>
943 <xsl:if test="$charlength >= $framewidth">
947 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
948 <xsl:apply-templates select="m:type"/>
957 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
969 <m:mo stretchy="false">}</m:mo>
977 <m:mi><xsl:value-of select="m:ci"/></m:mi>
978 <m:mo stretchy="false">{</m:mo>
979 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
980 <xsl:for-each select="m:bvar">
984 <m:mi><xsl:value-of select="m:ci"/></m:mi>
986 <xsl:apply-templates select="m:type"/>
988 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
989 <xsl:if test="position()=last()">
990 <m:mo stretchy="false">}</m:mo>
1000 <!-- ***************************************** -->
1001 <!-- *********** PROOF ELEMENTS ************** -->
1002 <!-- ***************************************** -->
1004 <xsl:when test="$name='proof'">
1005 <!-- CSC: $explodeall until the annotationHelper can handle mactions -->
1006 <xsl:variable name="test" select="(not($explodeall)) and
1007 (not(preceding-sibling::*[1]/text()='letin1')) and
1008 (not(preceding-sibling::*[1]/text()='rw_step')) and
1009 (not(name(..)='m:lambda'))"/>
1010 <xsl:variable name="hidden_details">
1011 <xsl:if test="$test">
1012 <!-- Details hided (default) -->
1013 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1017 <m:mtext mathcolor="Red">We can prove</m:mtext>
1018 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1019 <xsl:apply-templates select="*[position()=3]"/>
1021 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1022 <m:mtext mathcolor="Green">(explain)</m:mtext>
1030 <xsl:variable name="shown_details">
1031 <!-- Show details -->
1032 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1036 <xsl:apply-templates select="*[position()=2]"/>
1043 <m:mtext mathcolor="Red">we proved</m:mtext>
1044 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1045 <xsl:apply-templates select="*[position()=3]"/>
1048 <m:mtext>_</m:mtext>
1050 <xsl:if test="$test">
1051 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1060 <xsl:when test="$test">
1061 <m:maction actiontype="toggle">
1062 <xsl:copy-of select="$hidden_details"/>
1063 <xsl:copy-of select="$shown_details"/>
1067 <xsl:copy-of select="$shown_details"/>
1072 <xsl:when test="$name='side_proof'">
1073 <xsl:variable name="test" select="(not($explodeall))"/>
1074 <xsl:variable name="hidden_details">
1075 <xsl:if test="$test">
1076 <!-- Details hided (default) -->
1077 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1081 <m:mtext mathcolor="Red">We can prove</m:mtext>
1082 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1083 <xsl:apply-templates select="*[position()=3]"/>
1085 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1086 <m:mtext mathcolor="Green">(explain)</m:mtext>
1094 <xsl:variable name="shown_details">
1095 <!-- Show details -->
1096 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1100 <xsl:apply-templates select="*[position()=2]"/>
1107 <m:mtext mathcolor="Red">we proved</m:mtext>
1108 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1109 <xsl:apply-templates select="*[position()=3]"/>
1112 <m:mtext>_</m:mtext>
1114 <xsl:if test="$test">
1115 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1124 <xsl:when test="$test">
1125 <m:maction actiontype="toggle">
1126 <xsl:copy-of select="$hidden_details"/>
1127 <xsl:copy-of select="$shown_details"/>
1131 <xsl:copy-of select="$shown_details"/>
1136 <xsl:when test="$name='letin1'">
1137 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1141 <xsl:apply-templates select="*[position()=2]"/>
1148 <xsl:apply-templates select="*[position()=3]"/>
1154 <xsl:when test="$name='by_induction'">
1155 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1159 <m:mtext mathcolor="Red">We prove</m:mtext>
1160 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1161 <xsl:apply-templates select="../*[3]"/>
1168 <m:mtext mathcolor="Red">by induction on</m:mtext>
1169 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1170 <xsl:apply-templates
1171 select="*[position()=last()]/*[position()=last()]"/>
1178 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1179 <xsl:for-each select="*[position()>3 and not(position()=last())]">
1183 <xsl:apply-templates select="."/>
1194 <!-- inductive_case -->
1195 <xsl:when test="$name='inductive_case'">
1196 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1200 <m:mtext mathcolor="Red">Case</m:mtext>
1201 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1202 <xsl:apply-templates select="*[2]"/>
1209 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1210 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1211 <xsl:if test="*[3]/*[position()>1]">
1215 <m:mtext mathcolor="Red">By induction hypothesis, we have:</m:mtext>
1222 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1223 <xsl:for-each select="*[3]/*[position()>1]">
1224 <m:mo stretchy="false">(</m:mo>
1225 <xsl:apply-templates select="m:ci"/>
1226 <m:mo stretchy="false">) </m:mo>
1227 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1228 <xsl:apply-templates select="m:type"/>
1237 <xsl:apply-templates select="*[4]"/>
1248 <xsl:when test="$name='case_lhs'">
1251 <xsl:when test="count(*)=2">
1252 <xsl:apply-templates select="*[2]"/>
1255 <m:mo stretchy="false">(</m:mo>
1256 <xsl:apply-templates select="*[2]"/>
1257 <xsl:for-each select="m:bvar">
1258 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1259 <xsl:apply-templates select="*[1]"/>
1260 <m:mtext>:</m:mtext>
1261 <xsl:apply-templates select="m:type/*[1]"/>
1263 <m:mo stretchy="false">)</m:mo>
1269 <xsl:when test="$name='false_ind'">
1270 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1274 <xsl:apply-templates select="*[3]"/>
1281 <m:mtext mathcolor="Red">Contradiction.</m:mtext>
1288 <xsl:when test="$name='letin'">
1289 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1290 <!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
1291 <xsl:for-each select="*[(last() > position()) and (position()>1)]">
1295 <xsl:apply-templates select="."/>
1303 <xsl:apply-templates select="*[position()=last()]"/>
1310 <xsl:when test="$name='let'">
1311 <m:mtext>(</m:mtext>
1312 <xsl:apply-templates select="m:ci"/>
1313 <m:mtext>) </m:mtext>
1314 <xsl:apply-templates select="*[3]"/>
1317 <xsl:when test="$name='rw_step'">
1318 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1323 <xsl:when test="name(*[2])='m:apply'">
1324 <xsl:apply-templates select="*[2]"/>
1327 <m:mtext>Consider</m:mtext>
1328 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1329 <xsl:apply-templates select="*[2]"/>
1338 <m:mtext>Rewrite</m:mtext>
1339 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1340 <xsl:apply-templates select="*[3]"/>
1341 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1342 <m:mtext>with</m:mtext>
1343 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1344 <xsl:apply-templates select="*[4]"/>
1345 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1346 <m:mtext>by</m:mtext>
1347 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1348 <xsl:apply-templates select="*[5]"/>
1354 <!-- not existing any more
1355 <xsl:when test="$name='thread'">
1356 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1361 <xsl:when test="name(*[last()])='m:apply'">
1362 <xsl:apply-templates select="*[last()]"/>
1365 <m:mtext>Consider</m:mtext>
1366 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1367 <xsl:apply-templates select="*[last()]"/>
1373 <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
1377 <!-- REWRITE_AND_APPLY -->
1378 <xsl:when test="$name='rewrite_and_apply'">
1379 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1383 <xsl:apply-templates select="*[2]"/>
1390 <m:mtext>Then apply it to</m:mtext>
1391 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1392 <xsl:apply-templates select="*[position()>2]"/>
1399 <xsl:when test="$name='and_ind'">
1400 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1405 <xsl:when test="name(*[2])='m:apply'">
1406 <xsl:apply-templates select="*[2]"/>
1409 <m:mtext>Consider</m:mtext>
1410 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1411 <xsl:apply-templates select="*[2]"/>
1420 <m:mtext>In particular, we have</m:mtext>
1427 <m:mtext>(</m:mtext>
1428 <xsl:apply-templates select="*[3]"/>
1429 <m:mtext>)</m:mtext>
1430 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1431 <xsl:apply-templates select="*[4]"/>
1438 <m:mtext>(</m:mtext>
1439 <xsl:apply-templates select="*[5]"/>
1440 <m:mtext>)</m:mtext>
1441 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1442 <xsl:apply-templates select="*[6]"/>
1449 <xsl:apply-templates select="*[7]"/>
1455 <!-- full_or_ind -->
1456 <xsl:when test="$name='full_or_ind'">
1457 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1462 <xsl:when test="name(*[2])='m:apply'">
1463 <xsl:apply-templates select="*[2]"/>
1466 <m:mtext>Consider</m:mtext>
1467 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1468 <xsl:apply-templates select="*[2]"/>
1477 <m:mtext>We proceed by cases to prove</m:mtext>
1478 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1479 <xsl:apply-templates select="*[3]"/>
1486 <m:mtext>Left: suppose</m:mtext>
1487 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1488 <m:mo stretchy="false">(</m:mo>
1489 <xsl:apply-templates select="*[4]/m:bvar/m:ci"/>
1490 <m:mo stretchy="false">)</m:mo>
1491 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1492 <xsl:apply-templates select="*[4]/m:bvar/m:type/*[1]"/>
1499 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1500 <xsl:apply-templates select="*[4]/*[3]"/>
1507 <m:mtext>Right: suppose</m:mtext>
1508 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1509 <m:mo stretchy="false">(</m:mo>
1510 <xsl:apply-templates select="*[5]/m:bvar/m:ci"/>
1511 <m:mo stretchy="false">)</m:mo>
1512 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1513 <xsl:apply-templates select="*[5]/m:bvar/m:type/*[1]"/>
1520 <xsl:apply-templates select="*[5]/*[3]"/>
1527 <xsl:when test="$name='or_ind'">
1528 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1533 <xsl:when test="name(*[2])='m:apply'">
1534 <xsl:apply-templates select="*[2]"/>
1537 <m:mtext>Consider</m:mtext>
1538 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1539 <xsl:apply-templates select="*[2]"/>
1548 <m:mtext>We prove</m:mtext>
1549 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1550 <xsl:apply-templates select="*[3]"/>
1551 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1552 <m:mtext>by cases:</m:mtext>
1559 <m:mtext>Left</m:mtext>
1560 <xsl:apply-templates select="*[4]"/>
1567 <m:mtext>Right</m:mtext>
1568 <xsl:apply-templates select="*[5]"/>
1575 <xsl:when test="$name='ex_ind'">
1576 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1581 <xsl:when test="name(*[2])='m:apply'">
1582 <xsl:apply-templates select="*[2]"/>
1585 <m:mtext>Consider</m:mtext>
1586 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1587 <xsl:apply-templates select="*[2]"/>
1596 <m:mtext>Let</m:mtext>
1597 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1598 <xsl:apply-templates select="*[3]"/>
1599 <m:mtext>:</m:mtext>
1600 <xsl:apply-templates select="*[4]"/>
1601 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1602 <m:mtext>such that</m:mtext>
1603 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1604 <m:mtext>(</m:mtext>
1605 <xsl:apply-templates select="*[5]"/>
1606 <m:mtext>)</m:mtext>
1607 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1608 <xsl:apply-templates select="*[6]"/>
1615 <xsl:apply-templates select="*[7]"/>
1622 <xsl:when test="$name='eq_chain'">
1623 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1627 <m:mtext mathcolor="Red">We have the following equality chain:</m:mtext>
1631 <xsl:for-each select="*[position() mod 2 = 0]">
1632 <xsl:variable name="pos" select="position()"/>
1637 <xsl:when test="$pos = 1">
1638 <xsl:apply-templates select="."/>
1639 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1644 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1645 <xsl:apply-templates select="."/>
1651 <xsl:if test="$pos != last()">
1655 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1656 <xsl:apply-templates select="../*[position()=2*$pos +1]"/>
1664 <!-- DISEQ_CHAIN -->
1665 <xsl:when test="$name='diseq_chain'">
1666 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1670 <m:mtext mathcolor="Red">We have the following disequality chain:</m:mtext>
1674 <xsl:for-each select="*[position() mod 3 = 2]">
1675 <xsl:variable name="pos" select="position()"/>
1680 <xsl:when test="$pos = 1">
1681 <xsl:apply-templates select="."/>
1682 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1683 <mo><xsl:apply-templates select="../*[position()=3*$pos]"/></mo>
1686 <mo><xsl:apply-templates select="../*[position()=3*($pos - 1)]"/></mo>
1687 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1688 <xsl:apply-templates select="."/>
1694 <xsl:if test="$pos != last()">
1698 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1699 <xsl:apply-templates select="../*[position()=3*$pos +1]"/>
1707 <!-- ***************************************** -->
1708 <!-- *********** NOTATIONS ******************* -->
1709 <!-- ***************************************** -->
1711 <xsl:when test="$name='subst'">
1712 <xsl:apply-templates select="*[3]"/>
1713 <!-- no font for ApplyFunction: <m:mo></m:mo> -->
1714 <m:mo stretchy="false">[</m:mo>
1715 <xsl:apply-templates select="*[4]"/>
1716 <m:mo mathcolor="Green">
1717 <xsl:if test="$id != ''">
1718 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1719 </xsl:if>←</m:mo>
1720 <xsl:apply-templates select="*[2]"/>
1721 <m:mo stretchy="false">]</m:mo>
1724 <xsl:when test="$name='lift'">
1726 <m:mo mathcolor="Green">
1727 <xsl:if test="$id != ''">
1728 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1729 </xsl:if>↑</m:mo>
1730 <xsl:apply-templates select="*[2]"/>
1733 <m:mo stretchy="false">(</m:mo>
1734 <xsl:apply-templates select="*[3]"/>
1735 <m:mo stretchy="false">)</m:mo>
1738 <!-- lift_with_base -->
1739 <xsl:when test="$name='lift_with_base'">
1741 <m:mo mathcolor="Green">
1742 <xsl:if test="$id != ''">
1743 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1744 </xsl:if>↑</m:mo>
1745 <xsl:apply-templates select="*[3]"/>
1746 <xsl:apply-templates select="*[4]"/>
1749 <m:mo stretchy="false">(</m:mo>
1750 <xsl:apply-templates select="*[2]"/>
1751 <m:mo stretchy="false">)</m:mo>
1755 <xsl:when test="$name='beta_red1'">
1756 <xsl:apply-templates select="*[2]"/>
1758 <m:mo mathcolor="Green">
1759 <xsl:if test="$id != ''">
1760 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1761 </xsl:if>→</m:mo>
1762 <m:mi mathcolor="Green">β</m:mi>
1764 <xsl:apply-templates select="*[3]"/>
1767 <xsl:when test="$name='beta_red'">
1768 <xsl:apply-templates select="*[2]"/>
1770 <m:mo mathcolor="Green">
1771 <xsl:if test="$id != ''">
1772 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1773 </xsl:if>→</m:mo>
1774 <m:mi mathcolor="Green">β</m:mi>
1775 <m:mi mathcolor="Green">*</m:mi>
1777 <xsl:apply-templates select="*[3]"/>
1779 <!-- par_beta_red1 -->
1780 <xsl:when test="$name='par_beta_red1'">
1781 <xsl:apply-templates select="*[2]"/>
1783 <m:mo mathcolor="Green">
1784 <xsl:if test="$id != ''">
1785 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1786 </xsl:if>⇒</m:mo>
1787 <m:mi mathcolor="Green">β</m:mi>
1789 <xsl:apply-templates select="*[3]"/>
1791 <!-- par_beta_red -->
1792 <xsl:when test="$name='par_beta_red'">
1793 <xsl:apply-templates select="*[2]"/>
1795 <m:mo mathcolor="Green">
1796 <xsl:if test="$id != ''">
1797 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1798 </xsl:if>⇒</m:mo>
1799 <m:mi mathcolor="Green">β</m:mi>
1800 <m:mi mathcolor="Green">*</m:mi>
1802 <xsl:apply-templates select="*[3]"/>
1805 <xsl:when test="$name='forgetful'">
1806 <m:mfenced open="|" close="|">
1807 <xsl:if test="$id != ''">
1808 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1810 <xsl:apply-templates select="*[2]"/>
1814 <xsl:when test="$name='isomorphic'">
1815 <xsl:apply-templates select="*[2]"/>
1816 <m:mo mathcolor="Green">
1817 <xsl:if test="$id != ''">
1818 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1819 </xsl:if>≅</m:mo>
1820 <xsl:apply-templates select="*[3]"/>
1823 <xsl:when test="$name='forgetful'">
1824 <m:mfenced open="[" close="]">
1825 <xsl:if test="$id != ''">
1826 <xsl:attribute name="m:xref"><xsl:value-of select="$id"/></xsl:attribute>
1828 <xsl:apply-templates select="*[2]"/>
1840 <!-- Il modo Thread non esiste piu'
1841 <xsl:template match="*" mode="thread">
1842 <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
1844 <xsl:when test="$name='rw_step'">
1848 <m:mtext>Rewrite</m:mtext>
1849 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1850 <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
1851 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1852 <m:mtext>with</m:mtext>
1853 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1854 <xsl:apply-templates select="following-sibling::*[position()=1]/*[3]"/>
1855 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1856 <m:mtext>by</m:mtext>
1857 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1858 <xsl:apply-templates select="following-sibling::*[position()=1]/*[4]"/>
1865 <m:mtext mathcolor="Red">we get</m:mtext>
1866 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1867 <xsl:apply-templates select="."/>
1876 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
1883 <m:mtext mathcolor="Red">we get</m:mtext>
1884 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1885 <xsl:apply-templates select="."/>
1891 <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
1897 <xsl:template match="m:lambda">
1898 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
1901 <xsl:attribute name="m:xref">
1902 <xsl:value-of select="@id"/>
1906 <xsl:when test="$charlength >= $framewidth">
1907 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1911 <m:mo mathcolor="Red">λ</m:mo>
1912 <xsl:apply-templates select="m:bvar"/>
1920 <xsl:apply-templates select="*[position()=2]"/>
1927 <m:mo mathcolor="Red">λ</m:mo>
1928 <xsl:apply-templates select="m:bvar/m:ci"/>
1930 <xsl:apply-templates select="m:bvar/m:type"/>
1932 <xsl:apply-templates select="*[position()=2]"/>
1939 <!--**********************-->
1941 <!--**********************-->
1943 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
1944 |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
1945 |m:plus|m:minus|m:times" mode="charcount">
1946 <xsl:param name="incurrent_length" select="0"/>
1948 <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
1949 <xsl:variable name="siblength">
1950 <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
1951 <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
1952 </xsl:apply-templates>
1955 <xsl:when test="string($siblength) = """>
1956 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
1959 <xsl:value-of select="number($siblength)"/>
1964 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
1969 <xsl:template match="m:ci|m:csymbol" mode="charcount">
1970 <xsl:param name="incurrent_length" select="0"/>
1971 <xsl:param name="nosibling" select="0"/>
1973 <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
1974 <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>
1976 <xsl:when test="string($siblength) = """>
1977 <xsl:value-of select="$incurrent_length + string-length()"/>
1980 <xsl:value-of select="number($siblength)"/>
1985 <xsl:value-of select="$incurrent_length + string-length()"/>
1990 <xsl:template match="*" mode="charcount">
1991 <xsl:param name="incurrent_length" select="0"/>
1992 <xsl:param name="nosibling" select="0"/>
1994 <xsl:when test="count(child::*) = 0">
1995 <xsl:value-of select="$incurrent_length"/>
1998 <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>
2000 <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
2001 <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>
2003 <xsl:when test="string($siblength) = """>
2004 <xsl:value-of select="number($childlength)"/>
2007 <xsl:value-of select="number($siblength)"/>
2012 <xsl:value-of select="number($childlength)"/>