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