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 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28 xmlns:m="http://www.w3.org/1998/Math/MathML">
30 <!--***********************************************************************-->
31 <!-- From MathML content to HTML -->
32 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
33 <!--***********************************************************************-->
36 <xsl:include href="html_init.xsl"/>
37 <xsl:include href="html_set.xsl"/>
38 <xsl:include href="html_reals.xsl"/>
40 <xsl:variable name="showcast" select="0"/>
43 <!--***********************************************************************-->
44 <!-- HTML Head and Body -->
45 <!--***********************************************************************-->
47 <xsl:output method="html"/>
49 <xsl:variable name="framewidth" select="36"/>
51 <xsl:template match="/">
52 <xsl:param name="current_indent" select="0"/>
57 <xsl:with-param name="current_indent" select="0"/>
58 </xsl:apply-templates>
63 <!--***********************************************************************-->
65 <!--***********************************************************************-->
67 <xsl:template name="make_indent">
68 <xsl:param name="current_indent" select="0"/>
69 <xsl:if test="$current_indent > 0">
70 <xsl:text> </xsl:text>
71 <xsl:call-template name="make_indent">
72 <xsl:with-param name="current_indent" select="$current_indent - 1"/>
77 <!-- Syntactic Sugar -->
79 <xsl:template match="m:type">
80 <xsl:param name="current_indent" select="0"/>
82 <xsl:with-param name="current_indent"
83 select="$current_indent"/>
84 </xsl:apply-templates>
87 <xsl:template match="m:condition">
88 <xsl:param name="current_indent" select="0"/>
90 <xsl:with-param name="current_indent"
91 select="$current_indent"/>
92 </xsl:apply-templates>
95 <xsl:template match="m:math">
96 <xsl:param name="current_indent" select="0"/>
98 <xsl:with-param name="current_indent"
99 select="$current_indent"/>
100 </xsl:apply-templates>
105 <xsl:template match="m:apply[m:csymbol]">
106 <xsl:param name="current_indent" select="0"/>
107 <xsl:param name="width" select="$framewidth"/>
108 <xsl:variable name="name">
109 <xsl:value-of select="m:csymbol"/>
111 <xsl:variable name="charlength">
112 <xsl:apply-templates select="m:csymbol" mode="charcount"/>
114 <!-- <xsl:value-of select="$current_indent"/> -->
115 <!-- <xsl:value-of select="$charlength"/> -->
117 <xsl:when test="$name='prod'">
119 <xsl:when test="$charlength > $framewidth">
121 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">P</FONT>
122 <xsl:apply-templates select="m:bvar/m:ci"/>
123 <xsl:text>:</xsl:text>
124 <xsl:apply-templates select="m:bvar/m:type">
125 <xsl:with-param name="current_indent"
126 select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
127 </xsl:apply-templates><BR/>
128 <xsl:call-template name="make_indent">
129 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
131 <xsl:text>.</xsl:text>
132 <xsl:apply-templates select="*[position()=3]">
133 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
134 </xsl:apply-templates>
138 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">P</FONT>
139 <xsl:apply-templates select="m:bvar/m:ci"/>
140 <xsl:text>:</xsl:text>
141 <xsl:apply-templates select="m:bvar/m:type"/>
142 <xsl:text>.</xsl:text>
143 <xsl:apply-templates select="*[position()=3]"/>
147 <xsl:when test="$name='arrow'">
149 <xsl:when test="$charlength > $framewidth">
150 <xsl:text>(</xsl:text>
151 <xsl:apply-templates select="*[position()=2]">
152 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
153 </xsl:apply-templates>
155 <xsl:call-template name="make_indent">
156 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
159 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">®</FONT>
160 <xsl:apply-templates select="*[position()=3]">
161 <xsl:with-param name="current_indent" select="$current_indent + 5"/>
162 </xsl:apply-templates>
163 <xsl:text>)</xsl:text>
166 <xsl:text>(</xsl:text>
167 <xsl:apply-templates select="*[position()=2]"/>
169 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">®</FONT>
170 <xsl:apply-templates select="*[position()=3]"/>
171 <xsl:text>)</xsl:text>
175 <xsl:when test="$name='app'">
177 <xsl:when test="$charlength > $framewidth">
178 <xsl:text>(</xsl:text>
179 <xsl:apply-templates select="*[position()=2]">
180 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
181 </xsl:apply-templates>
182 <xsl:for-each select="*[position()>2]">
184 <xsl:call-template name="make_indent">
185 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
187 <xsl:apply-templates select=".">
188 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
189 </xsl:apply-templates>
191 <xsl:text>)</xsl:text>
194 <xsl:text>(</xsl:text>
195 <xsl:apply-templates select="*[position()=2]"/>
196 <xsl:for-each select="*[position()>2]">
197 <xsl:text> </xsl:text>
198 <xsl:apply-templates select="."/>
200 <xsl:text>)</xsl:text>
204 <xsl:when test="$name='cast'">
206 <xsl:when test="$showcast = 1">
208 <xsl:when test="$charlength > $framewidth">
209 <xsl:text>(</xsl:text>
210 <xsl:apply-templates select="*[position()=2]">
211 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
212 </xsl:apply-templates><BR/>
213 <xsl:call-template name="make_indent">
214 <xsl:with-param name="current_indent" select="$current_indent + 2"/> </xsl:call-template>
215 <xsl:text>:></xsl:text>
216 <xsl:apply-templates select="*[position()=3]">
217 <xsl:with-param name="current_indent" select="$current_indent + 3"/>
218 </xsl:apply-templates>
219 <xsl:text>)</xsl:text>
222 <xsl:text>(</xsl:text>
223 <xsl:apply-templates select="*[position()=2]"/>
224 <xsl:text>:></xsl:text>
225 <xsl:apply-templates select="*[position()=3]"/>
226 <xsl:text>)</xsl:text>
231 <xsl:apply-templates select="*[position()=2]">
232 <xsl:with-param name="current_indent" select="$current_indent"/>
233 </xsl:apply-templates>
237 <xsl:when test="$name='Prop'">
238 <xsl:text>Prop</xsl:text>
240 <xsl:when test="$name='Set'">
241 <xsl:text>Set</xsl:text>
243 <xsl:when test="$name='Type'">
244 <xsl:text>Type</xsl:text>
246 <xsl:when test="$name='mutcase'">
248 <xsl:when test="$charlength > $framewidth">
249 <xsl:text><</xsl:text>
250 <xsl:apply-templates select="*[position()=2]">
251 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
252 </xsl:apply-templates>
253 <xsl:text>> </xsl:text>
254 <xsl:text>CASE </xsl:text>
255 <xsl:apply-templates select="*[position()=3]">
256 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
257 </xsl:apply-templates>
258 <xsl:text> OF </xsl:text>
259 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
261 <xsl:call-template name="make_indent">
262 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
265 <xsl:when test="position() = 1">
266 <xsl:text>  </xsl:text>
269 <xsl:text>| </xsl:text>
272 <xsl:apply-templates select="."/>
273 <FONT FACE="symbol" SIZE="+2" mathcolor="green">Þ</FONT>
274 <xsl:apply-templates select="following-sibling::*[position()= 1]">
275 <xsl:with-param name="current_indent" select="$current_indent + 4 + string-length()"/>
276 </xsl:apply-templates>
280 <xsl:text><</xsl:text>
281 <xsl:apply-templates select="*[position()=2]"/>
282 <xsl:text>> </xsl:text>
283 <xsl:text>CASE </xsl:text>
284 <xsl:apply-templates select="*[position()=3]"/>
285 <xsl:text> OF </xsl:text>
286 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
288 <xsl:when test="not(position() = 1)">
289 <xsl:text> | </xsl:text>
292 <xsl:apply-templates select="."/>
293 <FONT FACE="symbol" SIZE="+2" mathcolor="green">Þ</FONT>
294 <xsl:apply-templates select="following-sibling::*[position()= 1]">
295 <xsl:with-param name="current_indent" select="$current_indent + 2 + string-length()"/>
296 </xsl:apply-templates>
301 <xsl:when test="$name='fix'">
303 <xsl:when test="$charlength > $framewidth">
304 <xsl:text>FIX</xsl:text>
305 <xsl:value-of select="m:ci"/>
306 <xsl:text>{</xsl:text>
307 <xsl:for-each select="m:bvar">
309 <xsl:call-template name="make_indent">
310 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
312 <xsl:value-of select="m:ci"/>
313 <xsl:text>:</xsl:text>
314 <xsl:apply-templates select="m:type">
315 <xsl:with-param name="current_indent"
316 select="$current_indent + 5 + string-length(m:ci)"/>
317 </xsl:apply-templates>
319 <xsl:call-template name="make_indent">
320 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
322 <xsl:text>:=</xsl:text>
323 <xsl:apply-templates select="following-sibling::*[position() = 1]">
324 <xsl:with-param name="current_indent" select="$current_indent +2"/>
325 </xsl:apply-templates>
328 <xsl:call-template name="make_indent">
329 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
331 <xsl:text>}</xsl:text>
334 <xsl:text>FIX</xsl:text>
335 <xsl:value-of select="m:ci"/>
336 <xsl:text>{</xsl:text>
337 <xsl:for-each select="m:bvar">
338 <xsl:value-of select="m:ci"/>
339 <xsl:text>:</xsl:text>
340 <xsl:apply-templates select="m:type"/>
341 <xsl:text>:=</xsl:text>
342 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
344 <xsl:when test="position()=last()">
345 <xsl:text>}</xsl:text>
348 <xsl:text>;</xsl:text>
355 <xsl:when test="$name='cofix'">
357 <xsl:when test="($charlength + 10) > $framewidth">
358 <xsl:text>COFIX</xsl:text>
359 <xsl:value-of select="m:ci"/>
360 <xsl:text>{</xsl:text>
362 <xsl:call-template name="make_indent">
363 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
365 <xsl:for-each select="m:bvar">
366 <xsl:value-of select="m:ci"/>
367 <xsl:text>:</xsl:text>
368 <xsl:apply-templates select="m:type">
369 <xsl:with-param name="current_indent"
370 select="$current_indent + 5 + string-length(m:ci)"/>
371 </xsl:apply-templates>
373 <xsl:call-template name="make_indent">
374 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
376 <xsl:text>:=</xsl:text>
377 <xsl:apply-templates select="following-sibling::*[position() = 1]">
378 <xsl:with-param name="current_indent" select="$current_indent + 3"/>
379 </xsl:apply-templates>
383 <xsl:call-template name="make_indent">
384 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
386 <xsl:text>}</xsl:text>
389 <xsl:text>COFIX</xsl:text>
390 <xsl:value-of select="m:ci"/>
391 <xsl:text>{</xsl:text>
392 <xsl:for-each select="m:bvar">
393 <xsl:value-of select="m:ci"/>
394 <xsl:text>:</xsl:text>
395 <xsl:apply-templates select="m:type"/>
396 <xsl:text>:=</xsl:text>
397 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
399 <xsl:when test="position()=last()">
400 <xsl:text>}</xsl:text>
403 <xsl:text>;</xsl:text>
416 <xsl:template match="m:lambda">
417 <xsl:param name="current_indent" select="0"/>
418 <xsl:variable name="charlength">
419 <xsl:apply-templates select="*[position()=1]" mode="charcount"/>
420 <!-- <xsl:apply-templates select="." mode="charcount"/> -->
422 <!-- <xsl:value-of select="$charlength"/> -->
424 <xsl:when test="$charlength > $framewidth">
426 <FONT FACE="symbol" SIZE="+2" mathcolor="red">l</FONT>
427 <xsl:apply-templates select="m:bvar/m:ci"/>
428 <xsl:text>:</xsl:text>
429 <xsl:apply-templates select="m:bvar/m:type">
430 <xsl:with-param name="current_indent"
431 select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
432 </xsl:apply-templates><BR/>
433 <xsl:call-template name="make_indent">
434 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
436 <xsl:text>.</xsl:text>
437 <xsl:apply-templates select="*[position()=2]">
438 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
439 </xsl:apply-templates>
443 <FONT FACE="symbol" SIZE="+2" mathcolor="red">l</FONT>
444 <xsl:apply-templates select="m:bvar/m:ci"/>
445 <xsl:text>:</xsl:text>
446 <xsl:apply-templates select="m:bvar/m:type"/>
447 <xsl:text>.</xsl:text>
448 <xsl:apply-templates select="*[position()=2]"/>
454 <xsl:template match="m:ci">
456 <xsl:when test="boolean(@definitionURL)">
457 <!-- CSC: non bisogna piu' utilizzare la url, bensi' la uri -->
458 <!-- <xsl:variable name="url">
459 <xsl:value-of select="concat(string($absPath),
463 <xsl:attribute name="href">
464 <xsl:value-of select="concat(string($header),string(@definitionURL))"/>
466 <xsl:apply-templates/>
470 <xsl:value-of select="."/>
477 <xsl:template match="m:ci|m:csymbol" mode="charcount">
478 <xsl:param name="incurrent_length" select="0"/>
480 <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
481 <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>
483 <xsl:when test="string($siblength) = """>
484 <xsl:value-of select="$incurrent_length + string-length()"/>
487 <xsl:value-of select="number($siblength)"/>
492 <xsl:value-of select="$incurrent_length + string-length()"/>
497 <xsl:template match="*" mode="charcount">
498 <xsl:param name="incurrent_length" select="0"/>
500 <xsl:when test="count(child::*) = 0">
501 <xsl:value-of select="$incurrent_length"/>
504 <xsl:variable name="childlength"><xsl:apply-templates select="*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length"/></xsl:apply-templates></xsl:variable>
506 <xsl:when test="$framewidth >= number($childlength)">
507 <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>
509 <xsl:when test="string($siblength) = """>
510 <xsl:value-of select="number($childlength)"/>
513 <xsl:value-of select="number($siblength)"/>
518 <xsl:value-of select="number($childlength)"/>
526 <!--***********************************************************************-->
528 <!--***********************************************************************-->
532 <xsl:template match="Definition">
533 <xsl:param name="current_indent" select="0"/>
535 DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
537 <xsl:call-template name="make_indent">
538 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
540 <xsl:apply-templates select="type/*[1]">
541 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
542 </xsl:apply-templates><BR/>
544 <xsl:call-template name="make_indent">
545 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
547 <xsl:apply-templates select="body/*[1]">
548 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
549 </xsl:apply-templates>
555 <xsl:template match="Axiom">
556 <xsl:param name="current_indent" select="0"/>
558 AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
559 TYPE = <xsl:apply-templates select="type/*[1]">
560 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
561 </xsl:apply-templates>
565 <!-- UNFINISHED PROOF -->
567 <xsl:template match="CurrentProof">
568 <xsl:param name="current_indent" select="0"/>
570 UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
571 THESIS: <xsl:apply-templates select="type/*[1]">
572 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
573 </xsl:apply-templates><BR/>
575 <xsl:for-each select="Conjecture">
577 <xsl:call-template name="make_indent">
578 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
580 <xsl:value-of select="./@no"/> :
581 <xsl:apply-templates select="./*[1]">
582 <xsl:with-param name="current_indent" select="$current_indent + 11"/>
583 </xsl:apply-templates>
587 <xsl:apply-templates select="body/*[1]">
588 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
589 </xsl:apply-templates>
593 <!-- MUTUAL INDUCTIVE DEFINITION -->
595 <xsl:template match="InductiveDefinition">
596 <xsl:param name="current_indent" select="0"/>
598 <xsl:for-each select="InductiveType">
600 <xsl:when test="position() = 1">
602 <xsl:when test="string(./@inductive) = "true"">
606 COINDUCTIVE DEFINITION
614 <xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)
616 <xsl:if test="string(../Param) != """>
617 <xsl:for-each select="../Param">
618 <xsl:value-of select="./@name"/>
620 <xsl:apply-templates select="*"/>
625 <xsl:apply-templates select="./arity/*[1]">
626 <xsl:with-param name="current_indent" select="$current_indent + 9"/>
627 </xsl:apply-templates> <BR/>
629 <xsl:for-each select="./Constructor">
631 <xsl:call-template name="make_indent">
632 <xsl:with-param name="current_indent" select="$current_indent + 3"/>
635 <xsl:when test="position() = 1">
636 <xsl:text>  </xsl:text>
639 <xsl:text>| </xsl:text>
642 <xsl:value-of select="./@name"/>
643 <xsl:text>: </xsl:text>
644 <xsl:apply-templates select="./*[1]">
645 <xsl:with-param name="current_indent" select="$current_indent + string-length(./@name) + 4"/>
646 </xsl:apply-templates>
654 <xsl:template match="Variable">
655 <xsl:param name="current_indent" select="0"/>
657 VARIABLE <xsl:value-of select="@name"/><BR/>
658 TYPE = <xsl:apply-templates select="type/*[1]">
659 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
660 </xsl:apply-templates>
664 <!--***********************************************************************-->
666 <!--***********************************************************************-->
670 <xsl:template match="SECTION">
671 <xsl:param name="current_indent" select="0"/>
672 <h1>BEGIN OF SECTION</h1>
673 <xsl:apply-templates/>
674 <h1>END OF SECTION</h1>