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 <!--***********************************************************************-->
48 <!-- Parameter affecting line-breaking -->
49 <!--***********************************************************************-->
51 <xsl:variable name="framewidth" select="35"/>
53 <!--***********************************************************************-->
54 <!-- Gli oggetti sono stampati come mtext all'interno di una marca toplevel-->
55 <!-- math ma al di fuori di semantics. Ora vi sono tanti semantics quanti -->
56 <!-- sono i termini: la presentation per un termine e' generata come primo -->
57 <!-- figlio di un semantics e l'originario content viene inserito nel -->
58 <!-- nel secondo figlio di semantics, annotation-xml -->
59 <!--***********************************************************************-->
61 <!--**********************-->
63 <!--**********************-->
65 <xsl:param name="type" select="'standalone'"/>
67 <xsl:template match="/">
69 <xsl:when test="$type = 'standalone'">
70 <xsl:apply-templates select="*"/>
74 <xsl:apply-templates select="*"/>
82 <xsl:template match="Definition">
84 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
88 <m:mtext>DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
95 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
96 <xsl:apply-templates select="type/*[1]"/>
103 <m:mtext>AS</m:mtext>
110 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
111 <xsl:apply-templates select="body/*[1]"/>
121 <xsl:template match="Axiom">
123 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
127 <m:mtext>AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>) OF TYPE</m:mtext>
134 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
135 <xsl:apply-templates select="type/*[1]"/>
143 <!-- UNFINISHED PROOF -->
145 <xsl:template match="CurrentProof">
147 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
151 <m:mtext>UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)</m:mtext>
158 <m:mtext>THESIS:</m:mtext>
165 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
166 <xsl:apply-templates select="type/*[1]"/>
173 <m:mtext>CONJECTURES:</m:mtext>
177 <xsl:for-each select="Conjecture">
181 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
182 <m:mtext><xsl:value-of select="./@no"/>:</m:mtext>
183 <xsl:apply-templates select="./*[1]"/>
191 <m:mtext>CORRESPONDING PROOF:</m:mtext>
198 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
199 <xsl:apply-templates select="body/*[1]"/>
207 <!-- MUTUAL INDUCTIVE DEFINITION -->
209 <xsl:template match="InductiveDefinition">
211 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
212 <xsl:for-each select="InductiveType">
217 <xsl:when test="position() = 1">
219 <xsl:when test="string(./@inductive) = "true"">
220 <m:mtext>INDUCTIVE DEFINITION</m:mtext>
223 <m:mtext>COINDUCTIVE DEFINITION</m:mtext>
228 <m:mtext>AND</m:mtext>
231 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
232 <m:mtext><xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)</m:mtext>
239 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
242 <xsl:when test="string(../Param) != """>
243 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
244 <xsl:for-each select="../Param">
248 <m:mi><xsl:value-of select="./@name"/></m:mi>
250 <xsl:apply-templates select="*"/>
274 <m:mtext>OF ARITY</m:mtext>
281 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
282 <xsl:apply-templates select="./arity/*[1]"/>
289 <m:mtext>BUILT FROM</m:mtext>
293 <xsl:for-each select="./Constructor">
298 <xsl:when test="position() = 1">
299 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
303 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
306 <m:mtext><xsl:value-of select="./@name"/> OF</m:mtext>
307 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
308 <xsl:apply-templates select="./*[1]"/>
320 <xsl:template match="Variable">
322 <m:mtable align="baseline 1" equalrows="false" columnalign="left" helm:xref="{@helm:xref}">
326 <m:mtext>VARIABLE <xsl:value-of select="@name"/> OF TYPE</m:mtext>
333 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
334 <xsl:apply-templates select="type/*[1]"/>
338 <xsl:if test="name(*[1])='body'">
342 <m:mtext>AS</m:mtext>
349 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
350 <xsl:apply-templates select="body/*[1]"/>
359 <!--**********************-->
361 <!--**********************-->
363 <xsl:template match="m:bvar">
365 <xsl:when test="m:type">
366 <xsl:variable name="charlength">
367 <xsl:apply-templates select="m:ci" mode="charcount"/>
370 <xsl:when test="$charlength >= $framewidth">
371 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
374 <xsl:apply-templates select="m:ci"/>
380 <xsl:apply-templates select="m:type"/>
386 <xsl:apply-templates select="m:ci"/>
388 <xsl:apply-templates select="m:type"/>
393 <xsl:apply-templates select="m:ci"/>
401 <xsl:template match="m:apply[m:csymbol]">
402 <xsl:param name="nopar" select="0"/>
403 <xsl:variable name="name"><xsl:value-of select="m:csymbol"/></xsl:variable>
404 <xsl:variable name="charlength"><xsl:apply-templates select="m:csymbol" mode="charcount"/></xsl:variable>
406 <xsl:if test="@helm:xref">
407 <xsl:attribute name="m:xref"><xsl:value-of select="@id"/></xsl:attribute>
411 <xsl:when test="$name='forall'">
413 <xsl:when test="$charlength >= $framewidth">
414 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
418 <m:mo mathcolor="Blue"><m:mchar name="ForAll"/></m:mo>
419 <xsl:apply-templates select="m:bvar"/>
427 <xsl:apply-templates select="*[position()=3]"/>
434 <m:mo mathcolor="Blue"><m:mchar name="ForAll"/></m:mo>
435 <xsl:apply-templates select="m:bvar/m:ci"/>
437 <xsl:apply-templates select="m:bvar/m:type"/>
439 <xsl:apply-templates select="*[position()=3]"/>
444 <xsl:when test="$name='let_in'">
446 <xsl:when test="$charlength >= $framewidth">
447 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
452 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
453 <xsl:apply-templates select="m:bvar"/>
461 <xsl:apply-templates select="*[position()=3]"/>
469 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
470 <xsl:apply-templates select="*[position()=4]"/>
478 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
479 <xsl:apply-templates select="m:bvar/m:ci"/>
481 <xsl:apply-templates select="*[position()=3]"/>
482 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
483 <m:mtext>IN</m:mtext>
484 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
485 <xsl:apply-templates select="*[position()=4]"/>
490 <xsl:when test="$name='prod'">
492 <xsl:when test="$charlength >= $framewidth">
493 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
497 <m:mo mathcolor="Blue">Π</m:mo>
498 <xsl:apply-templates select="m:bvar"/>
506 <xsl:apply-templates select="*[position()=3]"/>
513 <m:mo mathcolor="Blue">Π</m:mo>
514 <xsl:apply-templates select="m:bvar/m:ci"/>
516 <xsl:apply-templates select="m:bvar/m:type"/>
518 <xsl:apply-templates select="*[position()=3]"/>
523 <xsl:when test="$name='arrow'">
525 <xsl:when test="$charlength >= $framewidth">
526 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
530 <xsl:if test="$nopar=0">
531 <m:mo stretchy="false">(</m:mo>
533 <xsl:apply-templates select="*[position()=2]"/>
540 <m:mo mathmathcolor="Blue">→</m:mo>
542 <xsl:when test="*[position()=3]/m:csymbol">
543 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
545 <xsl:when test="$nextp='arrow'">
546 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
549 <xsl:apply-templates select="*[position()=3]"/>
554 <xsl:apply-templates select="*[position()=3]"/>
560 <xsl:if test="$nopar=0">
564 <m:mo stretchy="false">)</m:mo>
572 <xsl:if test="$nopar=0">
573 <m:mo stretchy="false">(</m:mo>
575 <xsl:apply-templates select="*[position()=2]"/>
576 <m:mo mathcolor="Blue">→</m:mo>
578 <xsl:when test="*[position()=3]/m:csymbol">
579 <xsl:variable name="nextp"><xsl:value-of select="*[position()=3]/m:csymbol"/></xsl:variable>
581 <xsl:when test="$nextp='arrow'">
582 <xsl:apply-templates select="*[position()=3]"><xsl:with-param name="nopar" select="1"/></xsl:apply-templates>
585 <xsl:apply-templates select="*[position()=3]"/>
590 <xsl:apply-templates select="*[position()=3]"/>
593 <xsl:if test="$nopar=0">
594 <m:mo stretchy="false">)</m:mo>
600 <xsl:when test="$name='app'">
602 <xsl:when test="$charlength >= $framewidth">
603 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
607 <m:mo stretchy="false">(</m:mo>
608 <xsl:apply-templates select="*[position()=2]"/>
612 <xsl:for-each select="*[position()>2]">
616 <m:mphantom><m:mtext>(</m:mtext></m:mphantom>
617 <xsl:apply-templates select="."/>
625 <m:mo stretchy="false">)</m:mo>
632 <m:mo stretchy="false">(</m:mo>
633 <xsl:apply-templates select="*[position()=2]"/>
634 <xsl:for-each select="*[position()>2]">
635 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
636 <xsl:apply-templates select="."/>
638 <m:mo stretchy="false">)</m:mo>
643 <xsl:when test="$name='cast'">
645 <xsl:when test="$charlength >= $framewidth">
646 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
650 <m:mo stretchy="false">(</m:mo>
651 <xsl:apply-templates select="*[position()=2]"/>
658 <m:mo mathcolor="Maroon">:></m:mo>
659 <xsl:apply-templates select="*[position()=3]"/>
666 <m:mo stretchy="false">)</m:mo>
673 <m:mo stretchy="false">(</m:mo>
674 <xsl:apply-templates select="*[position()=2]"/>
675 <m:mo mathcolor="Maroon">:></m:mo>
676 <xsl:apply-templates select="*[position()=3]"/>
677 <m:mo stretchy="false">)</m:mo>
682 <xsl:when test="$name='Prop'">
686 <xsl:when test="$name='Set'">
690 <xsl:when test="$name='Type'">
694 <xsl:when test="$name='mutcase'">
696 <xsl:when test="$charlength >= $framewidth">
697 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=2]" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
698 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
703 <xsl:apply-templates select="*[position()=2]"/>
704 <xsl:if test="$framewidth > $charlength">
707 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
708 <xsl:apply-templates select="*[position()=3]"/>
713 <xsl:if test="$charlength >= $framewidth">
719 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
720 <xsl:apply-templates select="*[position()=3]"/>
732 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
733 <xsl:variable name="charlength"><xsl:apply-templates select="." mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
738 <xsl:when test="position() = 1">
739 <m:mphantom><m:mtext>|</m:mtext></m:mphantom>
742 <m:mo stretchy="false">|</m:mo>
745 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
746 <xsl:apply-templates select="."/>
747 <xsl:if test="$framewidth > $charlength">
748 <m:mo mathcolor="Green">⇒</m:mo>
749 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
754 <xsl:if test="$charlength >= $framewidth">
758 <m:mphantom><m:mtext>|_</m:mtext></m:mphantom>
759 <m:mo mathcolor="Green">⇒</m:mo>
760 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
776 <m:mo><</m:mo><xsl:apply-templates select="*[position()=2]"/><m:mo>></m:mo>
778 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
779 <xsl:apply-templates select="*[position()=3]"/>
780 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
782 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
784 <xsl:when test="position() != 1">
785 <m:mo stretchy="false">|</m:mo>
788 <xsl:apply-templates select="."/>
789 <m:mo mathcolor="Green">⇒</m:mo>
790 <xsl:apply-templates select="following-sibling::*[position()= 1]"/>
792 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
798 <xsl:when test="$name='fix'">
800 <xsl:when test="$charlength >= $framewidth">
801 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
806 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
807 <m:mi><xsl:value-of select="m:ci"/></m:mi>
808 <m:mo stretchy="false">{</m:mo>
815 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
816 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
817 <xsl:for-each select="m:bvar">
818 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
822 <m:mi><xsl:value-of select="m:ci"/></m:mi>
824 <xsl:if test="$framewidth > $charlength">
825 <xsl:apply-templates select="m:type"/>
830 <xsl:if test="$charlength >= $framewidth">
834 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
835 <xsl:apply-templates select="m:type"/>
844 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
856 <m:mo stretchy="false">}</m:mo>
864 <m:mi><xsl:value-of select="m:ci"/></m:mi>
865 <m:mo stretchy="false">{</m:mo>
866 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
867 <xsl:for-each select="m:bvar">
871 <m:mi><xsl:value-of select="m:ci"/></m:mi>
873 <xsl:apply-templates select="m:type"/>
875 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
876 <xsl:if test="position()=last()">
877 <m:mo stretchy="false">}</m:mo>
888 <xsl:when test="$name='cofix'">
890 <xsl:when test="$charlength >= $framewidth">
891 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
896 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
897 <m:mi><xsl:value-of select="m:ci"/></m:mi>
898 <m:mo stretchy="false">{</m:mo>
905 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
906 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
907 <xsl:for-each select="m:bvar">
908 <xsl:variable name="charlength"><xsl:apply-templates select="m:type" mode="charcount"><xsl:with-param name="nosibling" select="1"/></xsl:apply-templates></xsl:variable>
912 <m:mi><xsl:value-of select="m:ci"/></m:mi>
914 <xsl:if test="$framewidth > $charlength">
915 <xsl:apply-templates select="m:type"/>
920 <xsl:if test="$charlength >= $framewidth">
924 <m:mphantom><m:mtext>:=</m:mtext></m:mphantom>
925 <xsl:apply-templates select="m:type"/>
934 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
946 <m:mo stretchy="false">}</m:mo>
954 <m:mi><xsl:value-of select="m:ci"/></m:mi>
955 <m:mo stretchy="false">{</m:mo>
956 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
957 <xsl:for-each select="m:bvar">
961 <m:mi><xsl:value-of select="m:ci"/></m:mi>
963 <xsl:apply-templates select="m:type"/>
965 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
966 <xsl:if test="position()=last()">
967 <m:mo stretchy="false">}</m:mo>
977 <!-- ***************************************** -->
978 <!-- *********** PROOF ELEMENTS ************** -->
979 <!-- ***************************************** -->
981 <xsl:when test="$name='proof'">
982 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
986 <xsl:apply-templates select="*[position()=2]"/>
993 <m:mtext mathcolor="Maroon">we proved </m:mtext>
994 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
995 <xsl:apply-templates select="*[position()=3]"/>
1002 <xsl:when test="$name='letin1'">
1003 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1007 <xsl:apply-templates select="*[2]"/>
1014 <xsl:apply-templates select="*[3]"/>
1021 <!-- CSC: Il caso che segue e' stato buttato li' giusto per vedere -->
1022 <!-- qualche cosa. Irene, appena puoi, risistemalo. -->
1023 <xsl:when test="$name='by_induction'">
1024 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1028 <m:mtext mathcolor="red">We prove </m:mtext>
1029 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1030 <xsl:apply-templates select="../*[3]"/>
1037 <m:mtext mathcolor="red">by induction on </m:mtext>
1038 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1039 <xsl:apply-templates
1040 select="*[position()=last()]/*[position()=last()]"/>
1047 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1048 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1049 <xsl:for-each select="*[position()>3 and not(position()=last())]">
1052 <xsl:apply-templates select="."/>
1062 <!-- inductive_case -->
1063 <xsl:when test="$name='inductive_case'">
1064 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1068 <m:mtext mathcolor="red">Case </m:mtext>
1069 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1070 <xsl:apply-templates select="*[2]"/>
1077 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1078 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1079 <xsl:if test="*[3]/*[position()>1]">
1082 <m:mtext mathcolor="red">By induction hypothesis, we have:</m:mtext>
1088 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1089 <xsl:for-each select="*[3]/*[position()>1]">
1090 <m:mo stretchy="false">(</m:mo>
1091 <xsl:apply-templates select="m:ci"/>
1092 <m:mo stretchy="false">) </m:mo>
1093 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1094 <xsl:apply-templates select="m:type"/>
1102 <xsl:apply-templates select="*[4]"/>
1112 <xsl:when test="$name='case_lhs'">
1115 <xsl:when test="count(*)=2">
1116 <xsl:apply-templates select="*[2]"/>
1119 <m:mo stretchy="false">(</m:mo>
1120 <xsl:apply-templates select="*[2]"/>
1121 <xsl:for-each select="m:bvar">
1122 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1123 <xsl:apply-templates select="*[1]"/>
1124 <m:mtext>:</m:mtext>
1125 <xsl:apply-templates select="m:type/*[1]"/>
1127 <m:mo stretchy="false">)</m:mo>
1132 <xsl:when test="$name='false_ind'">
1133 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1137 <xsl:apply-templates select="*[3]"/>
1144 <m:mtext mathcolor="Red">Contradiction.</m:mtext>
1150 <!--CSC fine della parte da risistemare -->
1153 <xsl:when test="$name='letin'">
1154 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1155 <!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
1156 <xsl:for-each select="*[(last() > position()) and (position()>1)]">
1160 <xsl:apply-templates select="."/>
1168 <xsl:apply-templates select="*[position()=last()]"/>
1175 <xsl:when test="$name='let'">
1176 <m:mtext>(</m:mtext>
1177 <xsl:apply-templates select="m:ci"/>
1178 <m:mtext>) </m:mtext>
1179 <xsl:apply-templates select="*[3]"/>
1182 <xsl:when test="$name='rw_step'">
1183 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1188 <xsl:when test="name(*[2])='m:apply'">
1189 <xsl:apply-templates select="*[2]"/>
1192 <m:mtext>Consider</m:mtext>
1193 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1194 <xsl:apply-templates select="*[2]"/>
1203 <m:mtext>Rewrite</m:mtext>
1204 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1205 <xsl:apply-templates select="*[3]"/>
1206 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1207 <m:mtext>with</m:mtext>
1208 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1209 <xsl:apply-templates select="*[4]"/>
1210 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1211 <m:mtext>by</m:mtext>
1212 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1213 <xsl:apply-templates select="*[5]"/>
1219 <!-- not existing any more
1220 <xsl:when test="$name='thread'">
1221 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1226 <xsl:when test="name(*[last()])='m:apply'">
1227 <xsl:apply-templates select="*[last()]"/>
1230 <m:mtext>Consider</m:mtext>
1231 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1232 <xsl:apply-templates select="*[last()]"/>
1238 <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
1242 <!-- REWRITE_AND_APPLY -->
1243 <xsl:when test="$name='rewrite_and_apply'">
1244 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1248 <xsl:apply-templates select="*[2]"/>
1255 <m:mtext>Then apply it to</m:mtext>
1256 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1257 <xsl:apply-templates select="*[position()>2]"/>
1264 <xsl:when test="$name='and_ind'">
1265 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1270 <xsl:when test="name(*[2])='m:apply'">
1271 <xsl:apply-templates select="*[2]"/>
1274 <m:mtext>Consider</m:mtext>
1275 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1276 <xsl:apply-templates select="*[2]"/>
1285 <m:mtext>In particular, we have</m:mtext>
1292 <m:mtext>(</m:mtext>
1293 <xsl:apply-templates select="*[3]"/>
1294 <m:mtext>)</m:mtext>
1295 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1296 <xsl:apply-templates select="*[4]"/>
1303 <m:mtext>(</m:mtext>
1304 <xsl:apply-templates select="*[5]"/>
1305 <m:mtext>)</m:mtext>
1306 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1307 <xsl:apply-templates select="*[6]"/>
1314 <xsl:apply-templates select="*[7]"/>
1320 <!-- CSC: Il caso che segue e' stato buttato li' giusto per vedere -->
1321 <!-- qualche cosa. Irene, appena puoi, risistemalo. -->
1322 <!-- full_or_ind -->
1323 <xsl:when test="$name='full_or_ind'">
1324 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1329 <xsl:when test="name(*[2])='m:apply'">
1330 <xsl:apply-templates select="*[2]"/>
1333 <m:mtext>Consider</m:mtext>
1334 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1335 <xsl:apply-templates select="*[2]"/>
1344 <m:mtext>We proceed by cases to prove</m:mtext>
1345 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1346 <xsl:apply-templates select="*[3]"/>
1353 <m:mtext>Left: suppose</m:mtext>
1354 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1355 <m:mo stretchy="false">(</m:mo>
1356 <xsl:apply-templates select="*[4]/m:bvar/m:ci"/>
1357 <m:mo stretchy="false">)</m:mo>
1358 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1359 <xsl:apply-templates select="*[4]/m:bvar/m:type/*[1]"/>
1365 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1367 <xsl:apply-templates select="*[4]/*[3]"/>
1374 <m:mtext>Right: suppose</m:mtext>
1375 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1376 <m:mo stretchy="false">(</m:mo>
1377 <xsl:apply-templates select="*[5]/m:bvar/m:ci"/>
1378 <m:mo stretchy="false">)</m:mo>
1379 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1380 <xsl:apply-templates select="*[5]/m:bvar/m:type/*[1]"/>
1387 <xsl:apply-templates select="*[5]/*[3]"/>
1393 <!--CSC fine della parte da risistemare -->
1395 <xsl:when test="$name='or_ind'">
1396 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1401 <xsl:when test="name(*[2])='m:apply'">
1402 <xsl:apply-templates select="*[2]"/>
1405 <m:mtext>Consider</m:mtext>
1406 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1407 <xsl:apply-templates select="*[2]"/>
1416 <m:mtext>We prove</m:mtext>
1417 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1418 <xsl:apply-templates select="*[3]"/>
1419 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1420 <m:mtext>by cases:</m:mtext>
1427 <m:mtext>Left</m:mtext>
1428 <xsl:apply-templates select="*[4]"/>
1435 <m:mtext>Right</m:mtext>
1436 <xsl:apply-templates select="*[5]"/>
1443 <xsl:when test="$name='ex_ind'">
1444 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1449 <xsl:when test="name(*[2])='m:apply'">
1450 <xsl:apply-templates select="*[2]"/>
1453 <m:mtext>Consider</m:mtext>
1454 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1455 <xsl:apply-templates select="*[2]"/>
1464 <m:mtext>Let</m:mtext>
1465 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1466 <xsl:apply-templates select="*[3]"/>
1467 <m:mtext>:</m:mtext>
1468 <xsl:apply-templates select="*[4]"/>
1469 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1470 <m:mtext>such that</m:mtext>
1471 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1472 <m:mtext>(</m:mtext>
1473 <xsl:apply-templates select="*[5]"/>
1474 <m:mtext>)</m:mtext>
1475 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1476 <xsl:apply-templates select="*[6]"/>
1483 <xsl:apply-templates select="*[7]"/>
1497 <!-- Il modo Thread non esiste piu'
1498 <xsl:template match="*" mode="thread">
1499 <xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
1501 <xsl:when test="$name='rw_step'">
1505 <m:mtext>Rewrite</m:mtext>
1506 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1507 <xsl:apply-templates select="following-sibling::*[position()=1]/*[2]"/>
1508 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1509 <m:mtext>with</m:mtext>
1510 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1511 <xsl:apply-templates select="following-sibling::*[position()=1]/*[3]"/>
1512 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1513 <m:mtext>by</m:mtext>
1514 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1515 <xsl:apply-templates select="following-sibling::*[position()=1]/*[4]"/>
1522 <m:mtext mathcolor="Maroon">we get</m:mtext>
1523 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1524 <xsl:apply-templates select="."/>
1533 <xsl:apply-templates select="following-sibling::*[position()=1]"/>
1540 <m:mtext mathcolor="Maroon">we get</m:mtext>
1541 <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
1542 <xsl:apply-templates select="."/>
1548 <xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
1554 <xsl:template match="m:lambda">
1555 <xsl:variable name="charlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"/></xsl:variable>
1556 <m:mrow m:xref="{@id}">
1558 <xsl:when test="$charlength >= $framewidth">
1559 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1563 <m:mo mathcolor="Red">λ</m:mo>
1564 <xsl:apply-templates select="m:bvar"/>
1572 <xsl:apply-templates select="*[position()=2]"/>
1579 <m:mo mathcolor="Red">λ</m:mo>
1580 <xsl:apply-templates select="m:bvar/m:ci"/>
1582 <xsl:apply-templates select="m:bvar/m:type"/>
1584 <xsl:apply-templates select="*[position()=2]"/>
1590 <!-- *********************************** -->
1591 <!-- BASE SET OF MATHML CONTENT ELEMENTS -->
1592 <!-- *********************************** -->
1596 <xsl:template match = "m:apply[m:eq[1]]">
1597 <xsl:variable name="charlength">
1598 <xsl:apply-templates select="*[1]" mode="charcount"/>
1601 <xsl:when test="$charlength >= $framewidth">
1602 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1603 <xsl:if test="@helm:xref">
1604 <xsl:attribute name="m:xref">
1605 <xsl:value-of select="@id"/>
1611 <m:mo stretchy="false">(</m:mo>
1612 <xsl:apply-templates select="*[position()=2]"/>
1616 <xsl:for-each select = "*[position()>2]">
1620 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1621 <m:mo m:xref="{m:in/@id}">=</m:mo>
1622 <xsl:apply-templates select="."/>
1630 <m:mo stretchy="false">)</m:mo>
1637 <xsl:apply-imports/>
1643 <xsl:template match = "m:apply[m:and[1]|m:or[1]
1644 |m:geq[1]|m:leq[1]|m:gt[1]|m:lt[1]
1645 |m:in[1]|m:intesect[1]|m:union[1]|m:subset[1]
1646 |m:prsubset|m:setdiff[1]]">
1647 <xsl:variable name="symbol">
1649 <xsl:when test="m:and[1]">
1650 <xsl:value-of select="'wedge'"/>
1652 <xsl:when test="m:or[1]">
1653 <xsl:value-of select="'vee'"/>
1655 <xsl:when test="m:geq[1]">
1656 <xsl:value-of select="'geq'"/>
1658 <xsl:when test="m:leq[1]">
1659 <xsl:value-of select="'leq'"/>
1661 <xsl:when test="m:gt[1]">
1662 <xsl:value-of select="'gt'"/>
1664 <xsl:when test="m:lt[1]">
1665 <xsl:value-of select="'lt'"/>
1667 <xsl:when test="m:eq[1]">
1668 <xsl:value-of select="'Equal'"/>
1670 <xsl:when test="m:in[1]">
1671 <xsl:value-of select="'Element'"/>
1673 <xsl:when test="m:subset[1]">
1674 <xsl:value-of select="'SubsetEqual'"/>
1676 <xsl:when test="m:prsubset[1]">
1677 <xsl:value-of select="'subset'"/>
1679 <xsl:when test="m:intersect[1]">
1680 <xsl:value-of select="'Intersection'"/>
1682 <xsl:when test="m:union[1]">
1683 <xsl:value-of select="'Union'"/>
1685 <xsl:when test="m:setdiff[1]">
1686 <xsl:value-of select="'Backslash'"/>
1690 <xsl:variable name="charlength">
1691 <xsl:apply-templates select="*[1]" mode="charcount"/>
1694 <xsl:when test="$charlength >= $framewidth">
1695 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1696 <xsl:if test="@helm:xref">
1697 <xsl:attribute name="m:xref">
1698 <xsl:value-of select="@id"/>
1704 <m:mo stretchy="false">(</m:mo>
1705 <xsl:apply-templates select="*[position()=2]"/>
1709 <xsl:for-each select = "*[position()>2]">
1713 <m:mphantom><m:mtext>__</m:mtext></m:mphantom>
1714 <m:mo m:xref="{*[1]/@id}">
1715 <m:mchar name="{$symbol}"/>
1717 <xsl:apply-templates select="."/>
1725 <m:mo stretchy="false">)</m:mo>
1732 <xsl:apply-imports/>
1737 <xsl:template match = "m:set">
1739 <xsl:when test="count(child::*) = 0">
1741 <m:mchar name="emptyset"/>
1745 <xsl:variable name="charlength">
1746 <xsl:apply-templates select="*[1]" mode="charcount"/>
1749 <xsl:when test="$charlength >= $framewidth">
1751 <xsl:when test="name(*[1]) = 'm:bvar'">
1752 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1756 <m:mo stretchy="false">{</m:mo>
1757 <xsl:apply-templates select="*[position()=1]"/>
1764 <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
1765 <m:mo stretchy="false">|</m:mo>
1766 <xsl:apply-templates select="m:condition/*[1]"/>
1773 <m:mo stretchy="false">}</m:mo>
1780 <m:mtable align="baseline 1" equalrows="false" columnalign="left">
1784 <m:mo stretchy="false">{</m:mo>
1785 <xsl:apply-templates select="*[position()=1]"/>
1786 <xsl:if test="position() != last()">
1792 <xsl:for-each select = "*[position()>2]">
1796 <m:mphantom><m:mtext>{</m:mtext></m:mphantom>
1797 <xsl:apply-templates select="."/>
1798 <xsl:if test="position() != last()">
1808 <m:mo stretchy="false">}</m:mo>
1817 <xsl:apply-imports/>
1824 <xsl:template match = "m:apply[m:card[1]]">
1825 <m:mfenced open="|" close="|" stretchy="false">
1826 <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1827 <xsl:attribute name="m:xref">
1828 <xsl:value-of select="@id"/>
1831 <xsl:apply-templates select="*[2]"/>
1835 <!-- *********************************** -->
1836 <!-- PROOF ELEMENTS -->
1837 <!-- *********************************** -->
1841 <!--**********************-->
1843 <!--**********************-->
1845 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:lt|m:leq|m:gt|m:geq
1846 |m:in|m:notin|m:intersect|m:union|m:subset|m:prsubset|m:card|m:setdiff
1847 |m:plus|m:minus|m:times" mode="charcount">
1848 <xsl:param name="incurrent_length" select="0"/>
1850 <xsl:when test="$framewidth > ($incurrent_length + 3 + string-length())">
1851 <xsl:variable name="siblength">
1852 <xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount">
1853 <xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/>
1854 </xsl:apply-templates>
1857 <xsl:when test="string($siblength) = """>
1858 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
1861 <xsl:value-of select="number($siblength)"/>
1866 <xsl:value-of select="$incurrent_length + 3 + string-length()"/>
1871 <xsl:template match="m:ci|m:csymbol" mode="charcount">
1872 <xsl:param name="incurrent_length" select="0"/>
1873 <xsl:param name="nosibling" select="0"/>
1875 <xsl:when test="$framewidth > ($incurrent_length + string-length()) and ($nosibling = 0)">
1876 <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>
1878 <xsl:when test="string($siblength) = """>
1879 <xsl:value-of select="$incurrent_length + string-length()"/>
1882 <xsl:value-of select="number($siblength)"/>
1887 <xsl:value-of select="$incurrent_length + string-length()"/>
1892 <xsl:template match="*" mode="charcount">
1893 <xsl:param name="incurrent_length" select="0"/>
1894 <xsl:param name="nosibling" select="0"/>
1896 <xsl:when test="count(child::*) = 0">
1897 <xsl:value-of select="$incurrent_length"/>
1900 <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>
1902 <xsl:when test="$framewidth > number($childlength) and ($nosibling = 0)">
1903 <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>
1905 <xsl:when test="string($siblength) = """>
1906 <xsl:value-of select="number($childlength)"/>
1909 <xsl:value-of select="number($siblength)"/>
1914 <xsl:value-of select="number($childlength)"/>