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"/> -->
43 <xsl:import href="mmlctop.xsl-0.14"/>
45 <xsl:import href="mmltheoryextension.xsl"/>
47 <xsl:param name="explodeall" select="false()"/>
49 <!--***********************************************************************-->
50 <!-- Parameter affecting line-breaking -->
51 <!--***********************************************************************-->
53 <xsl:variable name="framewidth" select="35"/>
55 <!--***********************************************************************-->
56 <!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
57 <!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
58 <!-- sono i termini: la presentation per un termine e' generata come primo -->
59 <!-- figlio di un semantics e l'originario content viene inserito nel -->
60 <!-- nel secondo figlio di semantics, annotation-xml -->
61 <!--***********************************************************************-->
63 <!--**********************-->
65 <!--**********************-->
67 <xsl:param name="type" select="'standalone'"/>
69 <xsl:template match="/">
71 <xsl:when test="$type = 'standalone'">
72 <xsl:apply-templates select="*"/>
76 <xsl:apply-templates select="*"/>
84 <xsl:template match="Definition">
86 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
90 <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
97 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
98 <xsl:apply-templates select="type/*[1]"/>
105 <m:mtext>AS</m:mtext>
112 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
113 <xsl:apply-templates select="body/*[1]"/>
123 <xsl:template match="Axiom">
125 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
129 <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
136 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
137 <xsl:apply-templates select="type/*[1]"/>
145 <!-- UNFINISHED PROOF -->
147 <xsl:template match="CurrentProof">
149 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
153 <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
160 <m:mtext>THESIS:</m:mtext>
167 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
168 <xsl:apply-templates select="type/*[1]"/>
175 <m:mtext>CONJECTURES:</m:mtext>
179 <xsl:for-each select="Conjecture">
183 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
184 <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
185 <xsl:apply-templates select="./*[1]"/>
193 <m:mtext>CORRESPONDING PROOF:</m:mtext>
200 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
201 <xsl:apply-templates select="body/*[1]"/>
209 <!-- MUTUAL INDUCTIVE DEFINITION -->
211 <xsl:template match="InductiveDefinition">
213 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
214 <xsl:for-each select="InductiveType">
219 <xsl:when test="position() = 1">
221 <xsl:when test="string(./@inductive) = "true"">
222 <m:mtext>INDUCTIVE DEFINITION</m:mtext>
225 <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
230 <m:mtext>AND</m:mtext>
233 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
234 <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
241 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
244 <xsl:when test="string(../Param) != """>
245 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
246 <xsl:for-each select="../Param">
250 <m:mi><xsl:value-of select="./@name"/></m:mi>
252 <xsl:apply-templates select="*"/>
276 <m:mtext>OF ARITY</m:mtext>
283 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
284 <xsl:apply-templates select="./arity/*[1]"/>
291 <m:mtext>BUILT FROM</m:mtext>
295 <xsl:for-each select="./Constructor">
300 <xsl:when test="position() = 1">
301 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
305 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
308 <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
309 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
310 <xsl:apply-templates select="./*[1]"/>
322 <xsl:template match="Variable">
324 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
328 <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
335 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
336 <xsl:apply-templates select="type/*[1]"/>
340 <xsl:if test="name(*[1])='body'">
344 <m:mtext>AS</m:mtext>
351 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
352 <xsl:apply-templates select="body/*[1]"/>
361 <!--**********************-->
363 <!--**********************-->
365 <xsl:template match="m:bvar">
367 <xsl:when test="m:type">
368 <xsl:variable name="charlength">
369 <xsl:apply-templates select="m:ci" mode="charcount"/>
372 <xsl:when test="$charlength >= $framewidth">
373 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
376 <xsl:apply-templates select="m:ci"/>
382 <xsl:apply-templates select="m:type"/>
388 <xsl:apply-templates select="m:ci"/>
390 <xsl:apply-templates select="m:type"/>
395 <xsl:apply-templates select="m:ci"/>
403 <xsl:template match="m:apply[m:csymbol]">
404 <xsl:param name="nopar" select="0"/>
405 <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
406 <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
408 <xsl:if test="@helm:xref">
409 <xsl:attribute name="m:xref"><xsl:value-of select="@id"/></xsl:attribute>
413 <xsl:when test="$name='forall'">
415 <xsl:when test="$charlength >= $framewidth">
416 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
420 <m:mo mathcolor="Blue"><m:mchar name="ForAll"/></m:mo>
421 <xsl:apply-templates select="m:bvar"/>
429 <xsl:apply-templates select="*[position()=3]"/>
436 <m:mo mathcolor="Blue"><m:mchar name="ForAll"/></m:mo>
437 <xsl:apply-templates select="m:bvar/m:ci"/>
439 <xsl:apply-templates select="m:bvar/m:type"/>
441 <xsl:apply-templates select="*[position()=3]"/>
446 <xsl:when test="$name='let_in'">
448 <xsl:when test="$charlength >= $framewidth">
449 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
454 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
455 <xsl:apply-templates select="m:bvar"/>
463 <xsl:apply-templates select="*[position()=3]"/>
471 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
472 <xsl:apply-templates select="*[position()=4]"/>
480 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
481 <xsl:apply-templates select="m:bvar/m:ci"/>
483 <xsl:apply-templates select="*[position()=3]"/>
484 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
485 <m:mtext>IN</m:mtext>
486 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
487 <xsl:apply-templates select="*[position()=4]"/>
492 <xsl:when test="$name='prod'">
494 <xsl:when test="$charlength >= $framewidth">
495 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
499 <m:mo mathcolor="Blue">Π</m:mo>
500 <xsl:apply-templates select="m:bvar"/>
508 <xsl:apply-templates select="*[position()=3]"/>
515 <m:mo mathcolor="Blue">Π</m:mo>
516 <xsl:apply-templates select="m:bvar/m:ci"/>
518 <xsl:apply-templates select="m:bvar/m:type"/>
520 <xsl:apply-templates select="*[position()=3]"/>
525 <xsl:when test="$name='arrow'">
527 <xsl:when test="$charlength >= $framewidth">
528 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
532 <xsl:if test="$nopar=0">
533 <m:mo stretchy="false">(</m:mo>
535 <xsl:apply-templates select="*[position()=2]"/>
542 <m:mo mathmathcolor="Blue">→</m:mo>
544 <xsl:when test="*[position()=3]/m:csymbol">
545 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
547 <xsl:when test="$nextp='arrow'">
548 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
551 <xsl:apply-templates select="*[position()=3]"/>
556 <xsl:apply-templates select="*[position()=3]"/>
562 <xsl:if test="$nopar=0">
566 <m:mo stretchy="false">)</m:mo>
574 <xsl:if test="$nopar=0">
575 <m:mo stretchy="false">(</m:mo>
577 <xsl:apply-templates select="*[position()=2]"/>
578 <m:mo mathcolor="Blue">→</m:mo>
580 <xsl:when test="*[position()=3]/m:csymbol">
581 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
583 <xsl:when test="$nextp='arrow'">
584 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
587 <xsl:apply-templates select="*[position()=3]"/>
592 <xsl:apply-templates select="*[position()=3]"/>
595 <xsl:if test="$nopar=0">
596 <m:mo stretchy="false">)</m:mo>
602 <xsl:when test="$name='app'">
604 <xsl:when test="$charlength >= $framewidth">
605 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
609 <m:mo stretchy="false">(</m:mo>
610 <xsl:apply-templates select="*[position()=2]"/>
614 <xsl:for-each select="*[position()>2]">
618 <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
619 <xsl:apply-templates select="."/>
627 <m:mo stretchy="false">)</m:mo>
634 <m:mo stretchy="false">(</m:mo>
635 <xsl:apply-templates select="*[position()=2]"/>
636 <xsl:for-each select="*[position()>2]">
637 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
638 <xsl:apply-templates select="."/>
640 <m:mo stretchy="false">)</m:mo>
645 <xsl:when test="$name='cast'">
647 <xsl:when test="$charlength >= $framewidth">
648 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
652 <m:mo stretchy="false">(</m:mo>
653 <xsl:apply-templates select="*[position()=2]"/>
660 <m:mo mathcolor="Maroon">:></m:mo>
661 <xsl:apply-templates select="*[position()=3]"/>
668 <m:mo stretchy="false">)</m:mo>
675 <m:mo stretchy="false">(</m:mo>
676 <xsl:apply-templates select="*[position()=2]"/>
677 <m:mo mathcolor="Maroon">:></m:mo>
678 <xsl:apply-templates select="*[position()=3]"/>
679 <m:mo stretchy="false">)</m:mo>
684 <xsl:when test="$name='Prop'">
688 <xsl:when test="$name='Set'">
692 <xsl:when test="$name='Type'">
696 <xsl:when test="$name='mutcase'">
698 <xsl:when test="$charlength >= $framewidth">
699 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
700 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
705 <xsl:apply-templates select="*[position()=2]"/>
706 <xsl:if test="$framewidth > $charlength">
709 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
710 <xsl:apply-templates select="*[position()=3]"/>
715 <xsl:if test="$charlength >= $framewidth">
721 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
722 <xsl:apply-templates select="*[position()=3]"/>
734 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
735 <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
740 <xsl:when test="position() = 1">
741 <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
744 <m:mo stretchy="false">|</m:mo>
747 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
748 <xsl:apply-templates select="."/>
749 <xsl:if test="$framewidth > $charlength">
750 <m:mo mathcolor="Green">⇒</m:mo>
751 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
756 <xsl:if test="$charlength >= $framewidth">
760 <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
761 <m:mo mathcolor="Green">⇒</m:mo>
762 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
778 <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
780 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
781 <xsl:apply-templates select="*[position()=3]"/>
782 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
784 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
786 <xsl:when test="position() != 1">
787 <m:mo stretchy="false">|</m:mo>
790 <xsl:apply-templates select="."/>
791 <m:mo mathcolor="Green">⇒</m:mo>
792 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
794 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
800 <xsl:when test="$name='fix'">
802 <xsl:when test="$charlength >= $framewidth">
803 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
808 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
809 <m:mi><xsl:value-of select="m:ci"/></m:mi>
810 <m:mo stretchy="false">{</m:mo>
817 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
818 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
819 <xsl:for-each select="m:bvar">
820 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
824 <m:mi><xsl:value-of select="m:ci"/></m:mi>
826 <xsl:if test="$framewidth > $charlength">
827 <xsl:apply-templates select="m:type"/>
832 <xsl:if test="$charlength >= $framewidth">
836 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
837 <xsl:apply-templates select="m:type"/>
846 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
858 <m:mo stretchy="false">}</m:mo>
866 <m:mi><xsl:value-of select="m:ci"/></m:mi>
867 <m:mo stretchy="false">{</m:mo>
868 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
869 <xsl:for-each select="m:bvar">
873 <m:mi><xsl:value-of select="m:ci"/></m:mi>
875 <xsl:apply-templates select="m:type"/>
877 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
878 <xsl:if test="position()=last()">
879 <m:mo stretchy="false">}</m:mo>
890 <xsl:when test="$name='cofix'">
892 <xsl:when test="$charlength >= $framewidth">
893 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
898 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
899 <m:mi><xsl:value-of select="m:ci"/></m:mi>
900 <m:mo stretchy="false">{</m:mo>
907 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
908 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
909 <xsl:for-each select="m:bvar">
910 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
914 <m:mi><xsl:value-of select="m:ci"/></m:mi>
916 <xsl:if test="$framewidth > $charlength">
917 <xsl:apply-templates select="m:type"/>
922 <xsl:if test="$charlength >= $framewidth">
926 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
927 <xsl:apply-templates select="m:type"/>
936 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
948 <m:mo stretchy="false">}</m:mo>
956 <m:mi><xsl:value-of select="m:ci"/></m:mi>
957 <m:mo stretchy="false">{</m:mo>
958 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
959 <xsl:for-each select="m:bvar">
963 <m:mi><xsl:value-of select="m:ci"/></m:mi>
965 <xsl:apply-templates select="m:type"/>
967 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
968 <xsl:if test="position()=last()">
969 <m:mo stretchy="false">}</m:mo>
979 <!-- ***************************************** -->
980 <!-- *********** PROOF ELEMENTS ************** -->
981 <!-- ***************************************** -->
983 <xsl:when test="$name='proof'">
984 <m:maction actiontype="toggle">
985 <!-- CSC: next if until the annotationHelper can handle mactions -->
986 <xsl:if test="not($explodeall)">
987 <!-- Details hided (default) -->
989 <m:mtext mathcolor="Maroon">We can prove</m:mtext>
990 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
991 <xsl:apply-templates select="*[position()=3]"/>
996 <m:mtext mathcolor="Green">(explain)</m:mtext>
1000 <!-- Show details -->
1001 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1005 <xsl:apply-templates select="*[position()=2]"/>
1012 <m:mtext mathcolor="Maroon">we proved </m:mtext>
1013 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1014 <xsl:apply-templates select="*[position()=3]"/>
1017 <m:mtext>_</m:mtext>
1019 <m:mtext mathcolor="Green">(hide details)</m:mtext>
1028 <xsl:when test="$name='letin1'">
1029 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1033 <xsl:apply-templates select="*[2]"/>
1040 <xsl:apply-templates select="*[3]"/>
1047 <!-- CSC: Il caso che segue e' stato buttato li' giusto per vedere -->
1048 <!-- qualche cosa. Irene, appena puoi, risistemalo. -->
1049 <xsl:when test="$name='by_induction'">
1050 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1054 <m:mtext mathcolor="red">We prove </m:mtext>
1055 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1056 <xsl:apply-templates select="../*[3]"/>
1063 <m:mtext mathcolor="red">by induction on </m:mtext>
1064 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1065 <xsl:apply-templates
1066 select="*[position()=last()]/*[position()=last()]"/>
1073 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1074 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1075 <xsl:for-each select="*[position()>3 and not(position()=last())]">
1078 <xsl:apply-templates select="."/>
1088 <!-- inductive_case -->
1089 <xsl:when test="$name='inductive_case'">
1090 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1094 <m:mtext mathcolor="red">Case </m:mtext>
1095 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1096 <xsl:apply-templates select="*[2]"/>
1103 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1104 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1105 <xsl:if test="*[3]/*[position()>1]">
1108 <m:mtext mathcolor="red">By induction hypothesis, we have:</m:mtext>
1114 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1115 <xsl:for-each select="*[3]/*[position()>1]">
1116 <m:mo stretchy="false">(</m:mo>
1117 <xsl:apply-templates select="m:ci"/>
1118 <m:mo stretchy="false">) </m:mo>
1119 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1120 <xsl:apply-templates select="m:type"/>
1128 <xsl:apply-templates select="*[4]"/>
1138 <xsl:when test="$name='case_lhs'">
1141 <xsl:when test="count(*)=2">
1142 <xsl:apply-templates select="*[2]"/>
1145 <m:mo stretchy="false">(</m:mo>
1146 <xsl:apply-templates select="*[2]"/>
1147 <xsl:for-each select="m:bvar">
1148 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1149 <xsl:apply-templates select="*[1]"/>
1150 <m:mtext>:</m:mtext>
1151 <xsl:apply-templates select="m:type/*[1]"/>
1153 <m:mo stretchy="false">)</m:mo>
1158 <xsl:when test="$name='false_ind'">
1159 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1163 <xsl:apply-templates select="*[3]"/>
1170 <m:mtext mathcolor="Red">Contradiction.</m:mtext>
1176 <!--CSC fine della parte da risistemare -->
1179 <xsl:when test="$name='letin'">
1180 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1181 <!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
1182 <xsl:for-each select="*[(last() > position()) and (position()>1)]">
1186 <xsl:apply-templates select="."/>
1194 <xsl:apply-templates select="*[position()=last()]"/>
1201 <xsl:when test="$name='let'">
1202 <m:mtext>(</m:mtext>
1203 <xsl:apply-templates select="m:ci"/>
1204 <m:mtext>) </m:mtext>
1205 <xsl:apply-templates select="*[3]"/>
1208 <xsl:when test="$name='rw_step'">
1209 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1214 <xsl:when test="name(*[2])='m:apply'">
1215 <xsl:apply-templates select="*[2]"/>
1218 <m:mtext>Consider</m:mtext>
1219 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1220 <xsl:apply-templates select="*[2]"/>
1229 <m:mtext>Rewrite</m:mtext>
1230 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1231 <xsl:apply-templates select="*[3]"/>
1232 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1233 <m:mtext>with</m:mtext>
1234 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1235 <xsl:apply-templates select="*[4]"/>
1236 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1237 <m:mtext>by</m:mtext>
1238 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1239 <xsl:apply-templates select="*[5]"/>
1245 <!-- not existing any more
1246 <xsl:when test="$name='thread'">
1247 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1252 <xsl:when test="name(*[last()])='m:apply'">
1253 <xsl:apply-templates select="*[last()]"/>
1256 <m:mtext>Consider</m:mtext>
1257 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1258 <xsl:apply-templates select="*[last()]"/>
1264 <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
1268 <!-- REWRITE_AND_APPLY -->
1269 <xsl:when test="$name='rewrite_and_apply'">
1270 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1274 <xsl:apply-templates select="*[2]"/>
1281 <m:mtext>Then apply it to</m:mtext>
1282 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1283 <xsl:apply-templates select="*[position()>2]"/>
1290 <xsl:when test="$name='and_ind'">
1291 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1296 <xsl:when test="name(*[2])='m:apply'">
1297 <xsl:apply-templates select="*[2]"/>
1300 <m:mtext>Consider</m:mtext>
1301 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1302 <xsl:apply-templates select="*[2]"/>
1311 <m:mtext>In particular, we have</m:mtext>
1318 <m:mtext>(</m:mtext>
1319 <xsl:apply-templates select="*[3]"/>
1320 <m:mtext>)</m:mtext>
1321 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1322 <xsl:apply-templates select="*[4]"/>
1329 <m:mtext>(</m:mtext>
1330 <xsl:apply-templates select="*[5]"/>
1331 <m:mtext>)</m:mtext>
1332 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1333 <xsl:apply-templates select="*[6]"/>
1340 <xsl:apply-templates select="*[7]"/>
1346 <!-- CSC: Il caso che segue e' stato buttato li' giusto per vedere -->
1347 <!-- qualche cosa. Irene, appena puoi, risistemalo. -->
1348 <!-- full_or_ind -->
1349 <xsl:when test="$name='full_or_ind'">
1350 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1355 <xsl:when test="name(*[2])='m:apply'">
1356 <xsl:apply-templates select="*[2]"/>
1359 <m:mtext>Consider</m:mtext>
1360 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1361 <xsl:apply-templates select="*[2]"/>
1370 <m:mtext>We proceed by cases to prove</m:mtext>
1371 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1372 <xsl:apply-templates select="*[3]"/>
1379 <m:mtext>Left: suppose</m:mtext>
1380 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1381 <m:mo stretchy="false">(</m:mo>
1382 <xsl:apply-templates select="*[4]/m:bvar/m:ci"/>
1383 <m:mo stretchy="false">)</m:mo>
1384 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1385 <xsl:apply-templates select="*[4]/m:bvar/m:type/*[1]"/>
1391 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1393 <xsl:apply-templates select="*[4]/*[3]"/>
1400 <m:mtext>Right: suppose</m:mtext>
1401 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1402 <m:mo stretchy="false">(</m:mo>
1403 <xsl:apply-templates select="*[5]/m:bvar/m:ci"/>
1404 <m:mo stretchy="false">)</m:mo>
1405 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1406 <xsl:apply-templates select="*[5]/m:bvar/m:type/*[1]"/>
1413 <xsl:apply-templates select="*[5]/*[3]"/>
1419 <!--CSC fine della parte da risistemare -->
1421 <xsl:when test="$name='or_ind'">
1422 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1427 <xsl:when test="name(*[2])='m:apply'">
1428 <xsl:apply-templates select="*[2]"/>
1431 <m:mtext>Consider</m:mtext>
1432 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1433 <xsl:apply-templates select="*[2]"/>
1442 <m:mtext>We prove</m:mtext>
1443 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1444 <xsl:apply-templates select="*[3]"/>
1445 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1446 <m:mtext>by cases:</m:mtext>
1453 <m:mtext>Left</m:mtext>
1454 <xsl:apply-templates select="*[4]"/>
1461 <m:mtext>Right</m:mtext>
1462 <xsl:apply-templates select="*[5]"/>
1469 <xsl:when test="$name='ex_ind'">
1470 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1475 <xsl:when test="name(*[2])='m:apply'">
1476 <xsl:apply-templates select="*[2]"/>
1479 <m:mtext>Consider</m:mtext>
1480 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1481 <xsl:apply-templates select="*[2]"/>
1490 <m:mtext>Let</m:mtext>
1491 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1492 <xsl:apply-templates select="*[3]"/>
1493 <m:mtext>:</m:mtext>
1494 <xsl:apply-templates select="*[4]"/>
1495 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1496 <m:mtext>such that</m:mtext>
1497 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1498 <m:mtext>(</m:mtext>
1499 <xsl:apply-templates select="*[5]"/>
1500 <m:mtext>)</m:mtext>
1501 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1502 <xsl:apply-templates select="*[6]"/>
1509 <xsl:apply-templates select="*[7]"/>
1523 <!-- Il modo Thread non esiste piu'
1524 <xsl:template match="*" mode="thread">
1525 <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
1527 <xsl:when test="$name='rw_step'">
1531 <m:mtext>Rewrite</m:mtext>
1532 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1533 <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
1534 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1535 <m:mtext>with</m:mtext>
1536 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1537 <xsl:apply-templates select="following-sibling::*[position()=1]/*[3]"/>
1538 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1539 <m:mtext>by</m:mtext>
1540 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1541 <xsl:apply-templates select="following-sibling::*[position()=1]/*[4]"/>
1548 <m:mtext mathcolor="Maroon">we get</m:mtext>
1549 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1550 <xsl:apply-templates select="."/>
1559 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
1566 <m:mtext mathcolor="Maroon">we get</m:mtext>
1567 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1568 <xsl:apply-templates select="."/>
1574 <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
1580 <xsl:template match="m:lambda">
1581 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
1582 <m:mrow m:xref="{@id}">
1584 <xsl:when test="$charlength >= $framewidth">
1585 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1589 <m:mo mathcolor="Red">λ</m:mo>
1590 <xsl:apply-templates select="m:bvar"/>
1598 <xsl:apply-templates select="*[position()=2]"/>
1605 <m:mo mathcolor="Red">λ</m:mo>
1606 <xsl:apply-templates select="m:bvar/m:ci"/>
1608 <xsl:apply-templates select="m:bvar/m:type"/>
1610 <xsl:apply-templates select="*[position()=2]"/>
1616 <!-- *********************************** -->
1617 <!-- BASE SET OF MATHML CONTENT ELEMENTS -->
1618 <!-- *********************************** -->
1622 <xsl:template match = "m:apply[m:eq[1]]">
1623 <xsl:variable name="charlength">
1624 <xsl:apply-templates select="*[1]" mode="charcount"/>
1627 <xsl:when test="$charlength >= $framewidth">
1628 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1629 <xsl:if test="@helm:xref">
1630 <xsl:attribute name="m:xref">
1631 <xsl:value-of select="@id"/>
1637 <m:mo stretchy="false">(</m:mo>
1638 <xsl:apply-templates select="*[position()=2]"/>
1642 <xsl:for-each select = "*[position()>2]">
1646 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1647 <m:mo m:xref="{m:in/@id}">=</m:mo>
1648 <xsl:apply-templates select="."/>
1656 <m:mo stretchy="false">)</m:mo>
1663 <xsl:apply-imports/>
1669 <xsl:template match = "m:apply[m:and[1]|m:or[1]
1670 |m:geq[1]|m:leq[1]|m:gt[1]|m:lt[1]
1671 |m:in[1]|m:intesect[1]|m:union[1]|m:subset[1]
1672 |m:prsubset|m:setdiff[1]]">
1673 <xsl:variable name="symbol">
1675 <xsl:when test="m:and[1]">
1676 <xsl:value-of select="'wedge'"/>
1678 <xsl:when test="m:or[1]">
1679 <xsl:value-of select="'vee'"/>
1681 <xsl:when test="m:geq[1]">
1682 <xsl:value-of select="'geq'"/>
1684 <xsl:when test="m:leq[1]">
1685 <xsl:value-of select="'leq'"/>
1687 <xsl:when test="m:gt[1]">
1688 <xsl:value-of select="'gt'"/>
1690 <xsl:when test="m:lt[1]">
1691 <xsl:value-of select="'lt'"/>
1693 <xsl:when test="m:eq[1]">
1694 <xsl:value-of select="'Equal'"/>
1696 <xsl:when test="m:in[1]">
1697 <xsl:value-of select="'Element'"/>
1699 <xsl:when test="m:subset[1]">
1700 <xsl:value-of select="'SubsetEqual'"/>
1702 <xsl:when test="m:prsubset[1]">
1703 <xsl:value-of select="'subset'"/>
1705 <xsl:when test="m:intersect[1]">
1706 <xsl:value-of select="'Intersection'"/>
1708 <xsl:when test="m:union[1]">
1709 <xsl:value-of select="'Union'"/>
1711 <xsl:when test="m:setdiff[1]">
1712 <xsl:value-of select="'Backslash'"/>
1716 <xsl:variable name="charlength">
1717 <xsl:apply-templates select="*[1]" mode="charcount"/>
1720 <xsl:when test="$charlength >= $framewidth">
1721 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1722 <xsl:if test="@helm:xref">
1723 <xsl:attribute name="m:xref">
1724 <xsl:value-of select="@id"/>
1730 <m:mo stretchy="false">(</m:mo>
1731 <xsl:apply-templates select="*[position()=2]"/>
1735 <xsl:for-each select = "*[position()>2]">
1739 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1740 <m:mo m:xref="{*[1]/@id}">
1741 <m:mchar name="{$symbol}"/>
1743 <xsl:apply-templates select="."/>
1751 <m:mo stretchy="false">)</m:mo>
1758 <xsl:apply-imports/>
1763 <xsl:template match = "m:set">
1765 <xsl:when test="count(child::*) = 0">
1767 <m:mchar name="emptyset"/>
1771 <xsl:variable name="charlength">
1772 <xsl:apply-templates select="*[1]" mode="charcount"/>
1775 <xsl:when test="$charlength >= $framewidth">
1777 <xsl:when test="name(*[1]) = 'm:bvar'">
1778 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1782 <m:mo stretchy="false">{</m:mo>
1783 <xsl:apply-templates select="*[position()=1]"/>
1790 <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
1791 <m:mo stretchy="false">|</m:mo>
1792 <xsl:apply-templates select="m:condition/*[1]"/>
1799 <m:mo stretchy="false">}</m:mo>
1806 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1810 <m:mo stretchy="false">{</m:mo>
1811 <xsl:apply-templates select="*[position()=1]"/>
1812 <xsl:if test="position() != last()">
1818 <xsl:for-each select = "*[position()>2]">
1822 <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
1823 <xsl:apply-templates select="."/>
1824 <xsl:if test="position() != last()">
1834 <m:mo stretchy="false">}</m:mo>
1843 <xsl:apply-imports/>
1850 <xsl:template match = "m:apply[m:card[1]]">
1851 <m:mfenced open="|" close="|" stretchy="false">
1852 <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1853 <xsl:attribute name="m:xref">
1854 <xsl:value-of select="@id"/>
1857 <xsl:apply-templates select="*[2]"/>
1861 <!-- *********************************** -->
1862 <!-- PROOF ELEMENTS -->
1863 <!-- *********************************** -->
1867 <!--**********************-->
1869 <!--**********************-->
1871 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
1872 |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
1873 |m:plus|m:minus|m:times" mode="charcount">
1874 <xsl:param name="incurrent_length" select="0"/>
1876 <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
1877 <xsl:variable name="siblength">
1878 <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
1879 <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
1880 </xsl:apply-templates>
1883 <xsl:when test="string($siblength) = """>
1884 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
1887 <xsl:value-of select="number($siblength)"/>
1892 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
1897 <xsl:template match="m:ci|m:csymbol" mode="charcount">
1898 <xsl:param name="incurrent_length" select="0"/>
1899 <xsl:param name="nosibling" select="0"/>
1901 <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
1902 <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>
1904 <xsl:when test="string($siblength) = """>
1905 <xsl:value-of select="$incurrent_length + string-length()"/>
1908 <xsl:value-of select="number($siblength)"/>
1913 <xsl:value-of select="$incurrent_length + string-length()"/>
1918 <xsl:template match="*" mode="charcount">
1919 <xsl:param name="incurrent_length" select="0"/>
1920 <xsl:param name="nosibling" select="0"/>
1922 <xsl:when test="count(child::*) = 0">
1923 <xsl:value-of select="$incurrent_length"/>
1926 <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>
1928 <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
1929 <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>
1931 <xsl:when test="string($siblength) = """>
1932 <xsl:value-of select="number($childlength)"/>
1935 <xsl:value-of select="number($siblength)"/>
1940 <xsl:value-of select="number($childlength)"/>