]> matita.cs.unibo.it Git - helm.git/blob - helm/style/content.xsl
...
[helm.git] / helm / style / content.xsl
1 <?xml version="1.0"?>
2
3 <!-- Copyright (C) 2000, HELM Team                                     -->
4 <!--                                                                   -->
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.                         -->
8 <!--                                                                   -->
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.            -->
13 <!--                                                                   -->
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.                      -->
18 <!--                                                                   -->
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.                                              -->
23 <!--                                                                   -->
24 <!-- For details, see the HELM World-Wide-Web page,                    -->
25 <!-- http://cs.unibo.it/helm/.                                         -->
26
27 <!--******************************************************************--> 
28 <!-- XSLT version 0.1 of CIC objects to MathML content:               -->
29 <!-- First draft: February 14 2000, Andrea Asperti, Irene Schena      -->
30 <!-- Revised: March 3 2000, Irene Schena                              -->
31 <!-- Revised: March 10 2000, Irene Schena                             -->
32 <!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena     -->
33 <!--******************************************************************-->
34
35 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
36                               xmlns:m="http://www.w3.org/1998/Math/MathML"
37                               xmlns:helm="http://www.cs.unibo.it/helm">
38
39 <xsl:include href="params.xsl"/>
40 <xsl:include href="ite.xsl"/>
41 <!-- adesso sono preprocessate -->
42 <!-- <xsl:include href="coercions.xsl"/> -->
43
44 <!--<xsl:output
45            method="xml" 
46            version="1.0" 
47            encoding="ISO-8859-1" 
48            omit-xml-declaration="no"
49            standalone="no" 
50            doctype-public="http://www.w3.org/TR/REC-MathML" 
51            indent="yes"
52            media-type="text/mathml" /> -->
53
54 <!-- DA FARE: 
55 1)risolvere nella fase di pre-processing le uri relative delle var, settando 
56 l'attributo
57 definitionURL dell'oggetto corrispondente (alcuni punteranno a nulla! -quelli 
58 che non hanno il file di definizione corrispondente-); [le uri assolute hanno
59 la forma cic:/.../ in definitionURL e questo schema di uri verra' risolto da
60 Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
61 -->
62
63
64 <!-- CIC TERMS -->
65
66
67 <xsl:template match="LAMBDA" mode="pure">
68         <xsl:apply-templates select="*[1]" mode="lambda"/>
69 </xsl:template>
70
71 <xsl:template match="decl" mode="lambda">
72         <m:lambda helm:xref="{@id}">
73          <m:bvar>
74           <m:ci>
75            <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
76           </m:ci>
77           <m:type>
78            <xsl:apply-templates select="*[1]" mode="noannot"/>
79           </m:type>
80          </m:bvar>
81         <xsl:apply-templates select="following-sibling::*[1]" mode="lambda"/>
82         </m:lambda>
83 </xsl:template>
84
85
86 <xsl:template match="target" mode="lambda">
87         <xsl:apply-templates select="*[1]" mode="noannot"/>
88 </xsl:template>
89
90
91 <xsl:template match="LETIN" mode="pure">
92         <xsl:apply-templates select="*[1]" mode="letin_pure"/>
93 </xsl:template>
94
95 <!-- Andrea: mode letin already exists in proofs.xsl, with a 
96     different meaning -->
97
98 <xsl:template match="def" mode="letin_pure">    
99     <m:apply helm:xref="{@id}">
100      <m:csymbol>let_in</m:csymbol>
101      <m:bvar>
102       <m:ci>
103        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
104       </m:ci>
105      </m:bvar>
106      <xsl:apply-templates select="*[1]" mode="noannot"/>
107      <xsl:apply-templates select="following-sibling::*[1]" mode="letin_pure"/>
108     </m:apply>
109 </xsl:template>
110
111
112 <xsl:template match="target" mode="letin_pure">
113         <xsl:apply-templates select="*[1]" mode="noannot"/>
114 </xsl:template>
115
116
117 <xsl:template match="PROD" mode="pure">
118         <xsl:apply-templates select="*[1]" mode="prod"/>
119 </xsl:template>
120
121
122 <xsl:template match="decl" mode="prod">
123      <m:apply helm:xref="{@id}">
124       <xsl:choose>
125        <xsl:when test="string(@binder)= &quot;&quot;">
126         <m:csymbol>arrow</m:csymbol>
127         <xsl:apply-templates select="*[1]" mode="noannot"/>
128        </xsl:when>
129        <xsl:otherwise>
130         <xsl:choose>
131          <xsl:when test="../@type = 'Prop'">
132           <m:csymbol>forall</m:csymbol>
133          </xsl:when>
134          <xsl:otherwise>
135           <m:csymbol>prod</m:csymbol>
136          </xsl:otherwise>
137         </xsl:choose>
138         <m:bvar>
139          <m:ci>
140           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
141          </m:ci>
142          <m:type>
143           <xsl:apply-templates select="*[1]" mode="noannot"/>
144          </m:type>
145         </m:bvar>
146        </xsl:otherwise>
147       </xsl:choose>
148      <xsl:apply-templates select="following-sibling::*[1]" mode="prod"/> 
149      </m:apply>
150 </xsl:template>
151
152          
153 <xsl:template match="target" mode="prod">
154         <xsl:apply-templates select="*[1]" mode="noannot"/>
155 </xsl:template>
156
157
158 <xsl:template match="CAST" mode="pure">
159     <m:apply helm:xref="{@id}">
160      <m:csymbol>cast</m:csymbol>
161      <xsl:apply-templates mode="noannot" select="*/*"/>
162     </m:apply>
163 </xsl:template>
164
165
166 <xsl:template match="REL" mode="pure">
167     <m:ci helm:xref="{@id}">
168      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
169     </m:ci>
170 </xsl:template>
171
172
173 <xsl:template match="SORT" mode="pure">
174     <m:apply helm:xref="{@id}">
175      <m:csymbol>
176       <xsl:value-of select="@value"/>
177      </m:csymbol>
178     </m:apply>
179 </xsl:template>
180
181
182 <xsl:template match="APPLY" mode="pure">
183       <m:apply helm:xref="{@id}">
184        <m:csymbol>app</m:csymbol>
185        <xsl:apply-templates mode="noannot" select="*"/>
186       </m:apply>
187 </xsl:template>
188
189
190 <!-- Gestione senza pre-processing -->
191 <!-- 
192 <xsl:template match="APPLY" mode="pure">
193      <xsl:apply-templates mode="coercion" select="."/>
194 </xsl:template>
195
196 <xsl:template match="APPLY" mode="no_coercion">
197       <m:apply helm:xref="{@id}">
198        <m:csymbol>app</m:csymbol>
199        <xsl:apply-templates mode="noannot" select="*"/>
200       </m:apply>
201 </xsl:template>
202 -->
203
204 <xsl:template match="VAR" mode="pure">
205     <m:ci helm:xref="{@id}">
206      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:call-template name="name_of_uri_bis">
207       <xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:with-param></xsl:call-template>
208     </m:ci>
209 </xsl:template>
210
211
212 <xsl:template match="META" mode="pure">
213    <m:apply helm:xref="{@id}">
214     <m:csymbol>meta</m:csymbol>
215     <m:ci>
216      <xsl:call-template name="insert_subscript">
217       <xsl:with-param name="node_value">
218        <xsl:text>?</xsl:text>
219        <xsl:value-of select="@no"/>
220       </xsl:with-param>
221      </xsl:call-template>
222     </m:ci>
223     <xsl:for-each select="substitution">
224      <xsl:choose>
225       <xsl:when test="*[1]">
226        <xsl:apply-templates select="*[1]" mode="noannot"/>
227       </xsl:when>
228       <xsl:otherwise>
229        <m:ci>_</m:ci>
230       </xsl:otherwise>
231      </xsl:choose>
232     </xsl:for-each>
233    </m:apply>
234 </xsl:template>
235
236
237 <xsl:template match="CONST" mode="pure">
238    <m:ci definitionURL="{@uri}" helm:xref="{@id}">
239       <xsl:call-template name="insert_subscript">
240          <xsl:with-param name="node_value">
241             <xsl:call-template name="name_of_uri">
242                <xsl:with-param name="uri" select="@uri"/>
243             </xsl:call-template>
244          </xsl:with-param>
245       </xsl:call-template>
246    </m:ci>
247 </xsl:template>
248
249
250 <xsl:template match="MUTIND" mode="pure">
251     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
252      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
253      <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
254      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document($InductiveTypeUrl)/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/></xsl:with-param></xsl:call-template>
255     </m:ci>
256 </xsl:template>
257
258
259 <xsl:template match="MUTCONSTRUCT" mode="pure">
260     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
261      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
262      <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
263      <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
264      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document($InductiveTypeUrl)/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/></xsl:with-param></xsl:call-template>
265     </m:ci>
266 </xsl:template>
267
268
269 <xsl:template match="MUTCASE" mode="pure">
270     <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
271     <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
272      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$Turi"/></xsl:call-template></xsl:variable>
273     <xsl:variable name="InductiveTypeDoc" select="document($InductiveTypeUrl)"/>
274     <m:apply helm:xref="{@id}">
275      <m:csymbol>mutcase</m:csymbol>
276      <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
277      <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
278      <xsl:variable name="nop"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/@noParams"/></xsl:variable>
279      <m:piecewise>
280       <xsl:for-each select="pattern">
281        <xsl:variable name="pos" select="position()"/>
282        <xsl:variable name="nopar"><xsl:apply-templates select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/*[1]" mode="counting"><xsl:with-param name="noparams" select="$nop"/></xsl:apply-templates></xsl:variable>
283        <m:piece>
284         <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="target" select="1"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
285         <xsl:choose>
286         <xsl:when test="$nopar = 0">
287          <m:ci>
288           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/></xsl:with-param></xsl:call-template>
289          </m:ci>
290         </xsl:when>
291         <xsl:otherwise>
292          <m:apply>
293           <m:csymbol>app</m:csymbol>
294           <m:ci>
295            <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/></xsl:with-param></xsl:call-template>
296           </m:ci>
297           <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
298           </m:apply>
299          </xsl:otherwise>
300          </xsl:choose>
301         </m:piece>
302       </xsl:for-each>
303      </m:piecewise> 
304     </m:apply>
305 </xsl:template>
306
307
308 <xsl:template match="FIX" mode="pure">
309     <m:apply helm:xref="{@id}">
310      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
311      <m:csymbol>fix</m:csymbol>
312      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></xsl:with-param></xsl:call-template></m:ci>
313      <xsl:apply-templates mode="pure" select="*"/>
314     </m:apply>
315 </xsl:template>
316
317
318 <xsl:template match="COFIX" mode="pure">
319    <m:apply helm:xref="{@id}">
320      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
321      <m:csymbol>cofix</m:csymbol>
322      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></xsl:with-param></xsl:call-template></m:ci>
323      <xsl:apply-templates mode="pure" select="*"/>
324     </m:apply>
325 </xsl:template>
326
327 <xsl:template match="instantiate" mode="pure">
328         <m:apply>
329          <xsl:if test="@id">
330           <xsl:attribute name="helm:xref">
331            <xsl:value-of select="@id"/>
332           </xsl:attribute>
333          </xsl:if>
334          <m:csymbol>inst</m:csymbol>
335          <xsl:apply-templates mode="noannot" select="*[1]" />
336          <xsl:for-each select="arg">
337           <xsl:variable name="base_path">
338            <xsl:call-template name="path">
339             <xsl:with-param name="uri" select="../*[1]/@uri"/>
340            </xsl:call-template>
341           </xsl:variable>
342           <xsl:variable name="varUri" select="concat($base_path,@relUri)"/>
343           <m:ci definitionURL="{$varUri}">
344            <xsl:call-template name="insert_subscript">
345             <xsl:with-param name="node_value">
346              <xsl:call-template name="name_of_uri">
347               <xsl:with-param name="uri" select="$varUri"/>
348               <xsl:with-param name="extension" select="'.var'"/>
349              </xsl:call-template>
350             </xsl:with-param>
351            </xsl:call-template>
352           </m:ci>
353           <xsl:apply-templates mode ="noannot" select="*[1]" />
354          </xsl:for-each>
355         </m:apply>
356 </xsl:template>
357
358 <!-- ELEMENTS OF CIC TERMS -->
359
360 <xsl:template match="FixFunction" mode="pure">
361     <m:bvar>
362      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template></m:ci>
363      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
364     </m:bvar> 
365     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
366 </xsl:template>
367
368
369 <xsl:template match="CofixFunction" mode="pure">
370     <m:bvar>
371      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template></m:ci>
372      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
373     </m:bvar> 
374     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
375 </xsl:template>
376
377 </xsl:stylesheet>