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"/>
41 <!-- <xsl:variable name="absPath">http://localhost:8081/getciconly?uri=</xsl:variable>-->
42 <xsl:variable name="header" select="document('http://localhost:8081/conf')/html_link"/>
44 <xsl:variable name="showcast" select="0"/>
47 <!--***********************************************************************-->
48 <!-- HTML Head and Body -->
49 <!--***********************************************************************-->
51 <xsl:output method="html"/>
53 <xsl:variable name="framewidth" select="36"/>
55 <xsl:template match="/">
56 <xsl:param name="current_indent" select="0"/>
61 <xsl:with-param name="current_indent" select="0"/>
62 </xsl:apply-templates>
67 <!--***********************************************************************-->
69 <!--***********************************************************************-->
71 <xsl:template name="make_indent">
72 <xsl:param name="current_indent" select="0"/>
73 <xsl:if test="$current_indent > 0">
74 <xsl:text> </xsl:text>
75 <xsl:call-template name="make_indent">
76 <xsl:with-param name="current_indent" select="$current_indent - 1"/>
81 <!-- Syntactic Sugar -->
83 <xsl:template match="m:type">
84 <xsl:param name="current_indent" select="0"/>
86 <xsl:with-param name="current_indent"
87 select="$current_indent"/>
88 </xsl:apply-templates>
91 <xsl:template match="m:condition">
92 <xsl:param name="current_indent" select="0"/>
94 <xsl:with-param name="current_indent"
95 select="$current_indent"/>
96 </xsl:apply-templates>
99 <xsl:template match="m:math">
100 <xsl:param name="current_indent" select="0"/>
101 <xsl:apply-templates>
102 <xsl:with-param name="current_indent"
103 select="$current_indent"/>
104 </xsl:apply-templates>
109 <xsl:template match="m:apply[m:csymbol]">
110 <xsl:param name="current_indent" select="0"/>
111 <xsl:param name="width" select="$framewidth"/>
112 <xsl:variable name="name">
113 <xsl:value-of select="m:csymbol"/>
115 <xsl:variable name="charlength">
116 <xsl:apply-templates select="m:csymbol" mode="charcount"/>
118 <!-- <xsl:value-of select="$current_indent"/> -->
119 <!-- <xsl:value-of select="$charlength"/> -->
121 <xsl:when test="$name='prod'">
123 <xsl:when test="$charlength > $framewidth">
125 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">P</FONT>
126 <xsl:apply-templates select="m:bvar/m:ci"/>
127 <xsl:text>:</xsl:text>
128 <xsl:apply-templates select="m:bvar/m:type">
129 <xsl:with-param name="current_indent"
130 select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
131 </xsl:apply-templates><BR/>
132 <xsl:call-template name="make_indent">
133 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
135 <xsl:text>.</xsl:text>
136 <xsl:apply-templates select="*[position()=3]">
137 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
138 </xsl:apply-templates>
142 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">P</FONT>
143 <xsl:apply-templates select="m:bvar/m:ci"/>
144 <xsl:text>:</xsl:text>
145 <xsl:apply-templates select="m:bvar/m:type"/>
146 <xsl:text>.</xsl:text>
147 <xsl:apply-templates select="*[position()=3]"/>
151 <xsl:when test="$name='arrow'">
153 <xsl:when test="$charlength > $framewidth">
154 <xsl:text>(</xsl:text>
155 <xsl:apply-templates select="*[position()=2]">
156 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
157 </xsl:apply-templates>
159 <xsl:call-template name="make_indent">
160 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
163 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">®</FONT>
164 <xsl:apply-templates select="*[position()=3]">
165 <xsl:with-param name="current_indent" select="$current_indent + 5"/>
166 </xsl:apply-templates>
167 <xsl:text>)</xsl:text>
170 <xsl:text>(</xsl:text>
171 <xsl:apply-templates select="*[position()=2]"/>
173 <FONT FACE="symbol" SIZE="+2" mathcolor="blue">®</FONT>
174 <xsl:apply-templates select="*[position()=3]"/>
175 <xsl:text>)</xsl:text>
179 <xsl:when test="$name='app'">
181 <xsl:when test="$charlength > $framewidth">
182 <xsl:text>(</xsl:text>
183 <xsl:apply-templates select="*[position()=2]">
184 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
185 </xsl:apply-templates>
186 <xsl:for-each select="*[position()>2]">
188 <xsl:call-template name="make_indent">
189 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
191 <xsl:apply-templates select=".">
192 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
193 </xsl:apply-templates>
195 <xsl:text>)</xsl:text>
198 <xsl:text>(</xsl:text>
199 <xsl:apply-templates select="*[position()=2]"/>
200 <xsl:for-each select="*[position()>2]">
201 <xsl:text> </xsl:text>
202 <xsl:apply-templates select="."/>
204 <xsl:text>)</xsl:text>
208 <xsl:when test="$name='cast'">
210 <xsl:when test="$showcast = 1">
212 <xsl:when test="$charlength > $framewidth">
213 <xsl:text>(</xsl:text>
214 <xsl:apply-templates select="*[position()=2]">
215 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
216 </xsl:apply-templates><BR/>
217 <xsl:call-template name="make_indent">
218 <xsl:with-param name="current_indent" select="$current_indent + 2"/> </xsl:call-template>
219 <xsl:text>:></xsl:text>
220 <xsl:apply-templates select="*[position()=3]">
221 <xsl:with-param name="current_indent" select="$current_indent + 3"/>
222 </xsl:apply-templates>
223 <xsl:text>)</xsl:text>
226 <xsl:text>(</xsl:text>
227 <xsl:apply-templates select="*[position()=2]"/>
228 <xsl:text>:></xsl:text>
229 <xsl:apply-templates select="*[position()=3]"/>
230 <xsl:text>)</xsl:text>
235 <xsl:apply-templates select="*[position()=2]">
236 <xsl:with-param name="current_indent" select="$current_indent"/>
237 </xsl:apply-templates>
241 <xsl:when test="$name='Prop'">
242 <xsl:text>Prop</xsl:text>
244 <xsl:when test="$name='Set'">
245 <xsl:text>Set</xsl:text>
247 <xsl:when test="$name='Type'">
248 <xsl:text>Type</xsl:text>
250 <xsl:when test="$name='mutcase'">
252 <xsl:when test="$charlength > $framewidth">
253 <xsl:text><</xsl:text>
254 <xsl:apply-templates select="*[position()=2]">
255 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
256 </xsl:apply-templates>
257 <xsl:text>> </xsl:text>
258 <xsl:text>CASE </xsl:text>
259 <xsl:apply-templates select="*[position()=3]">
260 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
261 </xsl:apply-templates>
262 <xsl:text> OF </xsl:text>
263 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
265 <xsl:call-template name="make_indent">
266 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
269 <xsl:when test="position() = 1">
270 <xsl:text>  </xsl:text>
273 <xsl:text>| </xsl:text>
276 <xsl:apply-templates select="."/>
277 <FONT FACE="symbol" SIZE="+2" mathcolor="green">Þ</FONT>
278 <xsl:apply-templates select="following-sibling::*[position()= 1]">
279 <xsl:with-param name="current_indent" select="$current_indent + 4 + string-length()"/>
280 </xsl:apply-templates>
284 <xsl:text><</xsl:text>
285 <xsl:apply-templates select="*[position()=2]"/>
286 <xsl:text>> </xsl:text>
287 <xsl:text>CASE </xsl:text>
288 <xsl:apply-templates select="*[position()=3]"/>
289 <xsl:text> OF </xsl:text>
290 <xsl:for-each select="*[position() mod 2 = 0 and position()>3]">
292 <xsl:when test="not(position() = 1)">
293 <xsl:text> | </xsl:text>
296 <xsl:apply-templates select="."/>
297 <FONT FACE="symbol" SIZE="+2" mathcolor="green">Þ</FONT>
298 <xsl:apply-templates select="following-sibling::*[position()= 1]">
299 <xsl:with-param name="current_indent" select="$current_indent + 2 + string-length()"/>
300 </xsl:apply-templates>
305 <xsl:when test="$name='fix'">
307 <xsl:when test="$charlength > $framewidth">
308 <xsl:text>FIX</xsl:text>
309 <xsl:value-of select="m:ci"/>
310 <xsl:text>{</xsl:text>
311 <xsl:for-each select="m:bvar">
313 <xsl:call-template name="make_indent">
314 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
316 <xsl:value-of select="m:ci"/>
317 <xsl:text>:</xsl:text>
318 <xsl:apply-templates select="m:type">
319 <xsl:with-param name="current_indent"
320 select="$current_indent + 5 + string-length(m:ci)"/>
321 </xsl:apply-templates>
323 <xsl:call-template name="make_indent">
324 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
326 <xsl:text>:=</xsl:text>
327 <xsl:apply-templates select="following-sibling::*[position() = 1]">
328 <xsl:with-param name="current_indent" select="$current_indent +2"/>
329 </xsl:apply-templates>
332 <xsl:call-template name="make_indent">
333 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
335 <xsl:text>}</xsl:text>
338 <xsl:text>FIX</xsl:text>
339 <xsl:value-of select="m:ci"/>
340 <xsl:text>{</xsl:text>
341 <xsl:for-each select="m:bvar">
342 <xsl:value-of select="m:ci"/>
343 <xsl:text>:</xsl:text>
344 <xsl:apply-templates select="m:type"/>
345 <xsl:text>:=</xsl:text>
346 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
348 <xsl:when test="position()=last()">
349 <xsl:text>}</xsl:text>
352 <xsl:text>;</xsl:text>
359 <xsl:when test="$name='cofix'">
361 <xsl:when test="($charlength + 10) > $framewidth">
362 <xsl:text>COFIX</xsl:text>
363 <xsl:value-of select="m:ci"/>
364 <xsl:text>{</xsl:text>
366 <xsl:call-template name="make_indent">
367 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
369 <xsl:for-each select="m:bvar">
370 <xsl:value-of select="m:ci"/>
371 <xsl:text>:</xsl:text>
372 <xsl:apply-templates select="m:type">
373 <xsl:with-param name="current_indent"
374 select="$current_indent + 5 + string-length(m:ci)"/>
375 </xsl:apply-templates>
377 <xsl:call-template name="make_indent">
378 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
380 <xsl:text>:=</xsl:text>
381 <xsl:apply-templates select="following-sibling::*[position() = 1]">
382 <xsl:with-param name="current_indent" select="$current_indent + 3"/>
383 </xsl:apply-templates>
387 <xsl:call-template name="make_indent">
388 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
390 <xsl:text>}</xsl:text>
393 <xsl:text>COFIX</xsl:text>
394 <xsl:value-of select="m:ci"/>
395 <xsl:text>{</xsl:text>
396 <xsl:for-each select="m:bvar">
397 <xsl:value-of select="m:ci"/>
398 <xsl:text>:</xsl:text>
399 <xsl:apply-templates select="m:type"/>
400 <xsl:text>:=</xsl:text>
401 <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
403 <xsl:when test="position()=last()">
404 <xsl:text>}</xsl:text>
407 <xsl:text>;</xsl:text>
420 <xsl:template match="m:lambda">
421 <xsl:param name="current_indent" select="0"/>
422 <xsl:variable name="charlength">
423 <xsl:apply-templates select="*[position()=1]" mode="charcount"/>
424 <!-- <xsl:apply-templates select="." mode="charcount"/> -->
426 <!-- <xsl:value-of select="$charlength"/> -->
428 <xsl:when test="$charlength > $framewidth">
430 <FONT FACE="symbol" SIZE="+2" mathcolor="red">l</FONT>
431 <xsl:apply-templates select="m:bvar/m:ci"/>
432 <xsl:text>:</xsl:text>
433 <xsl:apply-templates select="m:bvar/m:type">
434 <xsl:with-param name="current_indent"
435 select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
436 </xsl:apply-templates><BR/>
437 <xsl:call-template name="make_indent">
438 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
440 <xsl:text>.</xsl:text>
441 <xsl:apply-templates select="*[position()=2]">
442 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
443 </xsl:apply-templates>
447 <FONT FACE="symbol" SIZE="+2" mathcolor="red">l</FONT>
448 <xsl:apply-templates select="m:bvar/m:ci"/>
449 <xsl:text>:</xsl:text>
450 <xsl:apply-templates select="m:bvar/m:type"/>
451 <xsl:text>.</xsl:text>
452 <xsl:apply-templates select="*[position()=2]"/>
458 <xsl:template match="m:ci">
460 <xsl:when test="boolean(@definitionURL)">
461 <!-- CSC: non bisogna piu' utilizzare la url, bensi' la uri -->
462 <!-- <xsl:variable name="url">
463 <xsl:value-of select="concat(string($absPath),
467 <xsl:attribute name="href">
468 <xsl:value-of select="concat(string($header),string(@definitionURL))"/>
470 <xsl:apply-templates/>
474 <xsl:value-of select="."/>
481 <xsl:template match="m:ci|m:csymbol" mode="charcount">
482 <xsl:param name="incurrent_length" select="0"/>
484 <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
485 <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>
487 <xsl:when test="string($siblength) = """>
488 <xsl:value-of select="$incurrent_length + string-length()"/>
491 <xsl:value-of select="number($siblength)"/>
496 <xsl:value-of select="$incurrent_length + string-length()"/>
501 <xsl:template match="*" mode="charcount">
502 <xsl:param name="incurrent_length" select="0"/>
504 <xsl:when test="count(child::*) = 0">
505 <xsl:value-of select="$incurrent_length"/>
508 <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>
510 <xsl:when test="$framewidth >= number($childlength)">
511 <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>
513 <xsl:when test="string($siblength) = """>
514 <xsl:value-of select="number($childlength)"/>
517 <xsl:value-of select="number($siblength)"/>
522 <xsl:value-of select="number($childlength)"/>
530 <!--***********************************************************************-->
532 <!--***********************************************************************-->
536 <xsl:template match="Definition">
537 <xsl:param name="current_indent" select="0"/>
539 DEFINITION <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
541 <xsl:call-template name="make_indent">
542 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
544 <xsl:apply-templates select="type/*[1]">
545 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
546 </xsl:apply-templates><BR/>
548 <xsl:call-template name="make_indent">
549 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
551 <xsl:apply-templates select="body/*[1]">
552 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
553 </xsl:apply-templates>
559 <xsl:template match="Axiom">
560 <xsl:param name="current_indent" select="0"/>
562 AXIOM <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
563 TYPE = <xsl:apply-templates select="type/*[1]">
564 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
565 </xsl:apply-templates>
569 <!-- UNFINISHED PROOF -->
571 <xsl:template match="CurrentProof">
572 <xsl:param name="current_indent" select="0"/>
574 UNFINISHED PROOF <xsl:value-of select="@name"/>(<xsl:if test="string(./Params) != """><xsl:value-of select="Params"/></xsl:if>)<BR/>
575 THESIS: <xsl:apply-templates select="type/*[1]">
576 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
577 </xsl:apply-templates><BR/>
579 <xsl:for-each select="Conjecture">
581 <xsl:call-template name="make_indent">
582 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
584 <xsl:value-of select="./@no"/> :
585 <xsl:apply-templates select="./*[1]">
586 <xsl:with-param name="current_indent" select="$current_indent + 11"/>
587 </xsl:apply-templates>
591 <xsl:apply-templates select="body/*[1]">
592 <xsl:with-param name="current_indent" select="$current_indent + 8"/>
593 </xsl:apply-templates>
597 <!-- MUTUAL INDUCTIVE DEFINITION -->
599 <xsl:template match="InductiveDefinition">
600 <xsl:param name="current_indent" select="0"/>
602 <xsl:for-each select="InductiveType">
604 <xsl:when test="position() = 1">
606 <xsl:when test="string(./@inductive) = "true"">
610 COINDUCTIVE DEFINITION
618 <xsl:value-of select="./@name"/>(<xsl:if test="string(../Params) != """><xsl:value-of select="../Params"/></xsl:if>)
620 <xsl:if test="string(../Param) != """>
621 <xsl:for-each select="../Param">
622 <xsl:value-of select="./@name"/>
624 <xsl:apply-templates select="*"/>
629 <xsl:apply-templates select="./arity/*[1]">
630 <xsl:with-param name="current_indent" select="$current_indent + 9"/>
631 </xsl:apply-templates> <BR/>
633 <xsl:for-each select="./Constructor">
635 <xsl:call-template name="make_indent">
636 <xsl:with-param name="current_indent" select="$current_indent + 3"/>
639 <xsl:when test="position() = 1">
640 <xsl:text>  </xsl:text>
643 <xsl:text>| </xsl:text>
646 <xsl:value-of select="./@name"/>
647 <xsl:text>: </xsl:text>
648 <xsl:apply-templates select="./*[1]">
649 <xsl:with-param name="current_indent" select="$current_indent + string-length(./@name) + 4"/>
650 </xsl:apply-templates>
658 <xsl:template match="Variable">
659 <xsl:param name="current_indent" select="0"/>
661 VARIABLE <xsl:value-of select="@name"/><BR/>
662 TYPE = <xsl:apply-templates select="type/*[1]">
663 <xsl:with-param name="current_indent" select="$current_indent + 7"/>
664 </xsl:apply-templates>
668 <!--***********************************************************************-->
670 <!--***********************************************************************-->
674 <xsl:template match="SECTION">
675 <xsl:param name="current_indent" select="0"/>
676 <h1>BEGIN OF SECTION</h1>
677 <xsl:apply-templates/>
678 <h1>END OF SECTION</h1>