]> matita.cs.unibo.it Git - helm.git/blob - helm/style/content.xsl
f2f7b713a5e1bef33f48793fcdc74cdbfbe81a59
[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_pure"/>
92 </xsl:template>
93
94 <!-- Andrea: mode letin already exists in proofs.xsl, with a 
95     different meaning -->
96
97 <xsl:template match="def" mode="letin_pure">    
98     <m:apply helm:xref="{@id}">
99      <m:csymbol>let_in</m:csymbol>
100      <m:bvar>
101       <m:ci>
102        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
103       </m:ci>
104      </m:bvar>
105      <xsl:apply-templates select="*[1]" mode="noannot"/>
106      <xsl:apply-templates select="following-sibling::*[1]" mode="letin_pure"/>
107     </m:apply>
108 </xsl:template>
109
110
111 <xsl:template match="target" mode="letin_pure">
112         <xsl:apply-templates select="*[1]" mode="noannot"/>
113 </xsl:template>
114
115
116 <xsl:template match="PROD" mode="pure">
117         <xsl:apply-templates select="*[1]" mode="prod"/>
118 </xsl:template>
119
120
121 <xsl:template match="decl" mode="prod">
122      <m:apply helm:xref="{@id}">
123       <xsl:choose>
124        <xsl:when test="string(@binder)= &quot;&quot;">
125         <m:csymbol>arrow</m:csymbol>
126         <xsl:apply-templates select="*[1]" mode="noannot"/>
127        </xsl:when>
128        <xsl:otherwise>
129         <xsl:choose>
130          <xsl:when test="../@type = 'Prop'">
131           <m:csymbol>forall</m:csymbol>
132          </xsl:when>
133          <xsl:otherwise>
134           <m:csymbol>prod</m:csymbol>
135          </xsl:otherwise>
136         </xsl:choose>
137         <m:bvar>
138          <m:ci>
139           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
140          </m:ci>
141          <m:type>
142           <xsl:apply-templates select="*[1]" mode="noannot"/>
143          </m:type>
144         </m:bvar>
145        </xsl:otherwise>
146       </xsl:choose>
147      <xsl:apply-templates select="following-sibling::*[1]" mode="prod"/> 
148      </m:apply>
149 </xsl:template>
150
151          
152 <xsl:template match="target" mode="prod">
153         <xsl:apply-templates select="*[1]" mode="noannot"/>
154 </xsl:template>
155
156
157 <xsl:template match="CAST" mode="pure">
158     <m:apply helm:xref="{@id}">
159      <m:csymbol>cast</m:csymbol>
160      <xsl:apply-templates mode="noannot" select="*/*"/>
161     </m:apply>
162 </xsl:template>
163
164
165 <xsl:template match="REL" mode="pure">
166     <m:ci helm:xref="{@id}">
167      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
168     </m:ci>
169 </xsl:template>
170
171
172 <xsl:template match="SORT" mode="pure">
173     <m:apply helm:xref="{@id}">
174      <m:csymbol>
175       <xsl:value-of select="@value"/>
176      </m:csymbol>
177     </m:apply>
178 </xsl:template>
179
180
181 <xsl:template match="APPLY" mode="pure">
182       <m:apply helm:xref="{@id}">
183        <m:csymbol>app</m:csymbol>
184        <xsl:apply-templates mode="noannot" select="*"/>
185       </m:apply>
186 </xsl:template>
187
188
189 <!-- Gestione senza pre-processing -->
190 <!-- 
191 <xsl:template match="APPLY" mode="pure">
192      <xsl:apply-templates mode="coercion" select="."/>
193 </xsl:template>
194
195 <xsl:template match="APPLY" mode="no_coercion">
196       <m:apply helm:xref="{@id}">
197        <m:csymbol>app</m:csymbol>
198        <xsl:apply-templates mode="noannot" select="*"/>
199       </m:apply>
200 </xsl:template>
201 -->
202
203 <xsl:template match="VAR" mode="pure">
204     <m:ci helm:xref="{@id}">
205      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:call-template name="name_of_uri_bis">
206       <xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:with-param></xsl:call-template>
207     </m:ci>
208 </xsl:template>
209
210
211 <xsl:template match="META" mode="pure">
212    <m:apply helm:xref="{@id}">
213     <m:csymbol>meta</m:csymbol>
214     <m:ci>
215      <xsl:call-template name="insert_subscript">
216       <xsl:with-param name="node_value">
217        <xsl:text>?</xsl:text>
218        <xsl:value-of select="@no"/>
219       </xsl:with-param>
220      </xsl:call-template>
221     </m:ci>
222     <xsl:for-each select="substitution">
223      <xsl:choose>
224       <xsl:when test="*[1]">
225        <xsl:apply-templates select="*[1]" mode="noannot"/>
226       </xsl:when>
227       <xsl:otherwise>
228        <m:ci>_</m:ci>
229       </xsl:otherwise>
230      </xsl:choose>
231     </xsl:for-each>
232    </m:apply>
233 </xsl:template>
234
235
236 <xsl:template match="CONST" mode="pure">
237    <m:ci definitionURL="{@uri}" helm:xref="{@id}">
238       <xsl:call-template name="insert_subscript">
239          <xsl:with-param name="node_value">
240             <xsl:call-template name="name_of_uri">
241                <xsl:with-param name="uri" select="@uri"/>
242             </xsl:call-template>
243          </xsl:with-param>
244       </xsl:call-template>
245    </m:ci>
246 </xsl:template>
247
248
249 <xsl:template match="MUTIND" mode="pure">
250     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
251      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
252      <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
253      <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>
254     </m:ci>
255 </xsl:template>
256
257
258 <xsl:template match="MUTCONSTRUCT" mode="pure">
259     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
260      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
261      <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
262      <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
263      <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>
264     </m:ci>
265 </xsl:template>
266
267
268 <xsl:template match="MUTCASE" mode="pure">
269     <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
270     <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
271      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$Turi"/></xsl:call-template></xsl:variable>
272     <xsl:variable name="InductiveTypeDoc" select="document($InductiveTypeUrl)"/>
273     <m:apply helm:xref="{@id}">
274      <m:csymbol>mutcase</m:csymbol>
275      <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
276      <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
277      <xsl:variable name="nop"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/@noParams"/></xsl:variable>
278      <m:piecewise>
279       <xsl:for-each select="pattern">
280        <xsl:variable name="pos" select="position()"/>
281        <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>
282        <m:piece>
283         <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>
284         <xsl:choose>
285         <xsl:when test="$nopar = 0">
286          <m:ci>
287           <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>
288          </m:ci>
289         </xsl:when>
290         <xsl:otherwise>
291          <m:apply>
292           <m:csymbol>app</m:csymbol>
293           <m:ci>
294            <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>
295           </m:ci>
296           <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>
297           </m:apply>
298          </xsl:otherwise>
299          </xsl:choose>
300         </m:piece>
301       </xsl:for-each>
302      </m:piecewise> 
303     </m:apply>
304 </xsl:template>
305
306
307 <xsl:template match="FIX" mode="pure">
308     <m:apply helm:xref="{@id}">
309      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
310      <m:csymbol>fix</m:csymbol>
311      <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>
312      <xsl:apply-templates mode="pure" select="*"/>
313     </m:apply>
314 </xsl:template>
315
316
317 <xsl:template match="COFIX" mode="pure">
318    <m:apply helm:xref="{@id}">
319      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
320      <m:csymbol>cofix</m:csymbol>
321      <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>
322      <xsl:apply-templates mode="pure" select="*"/>
323     </m:apply>
324 </xsl:template>
325
326 <xsl:template match="instantiate" mode="pure">
327         <m:apply>
328          <xsl:if test="@id">
329           <xsl:attribute name="helm:xref" select="@id"/>
330          </xsl:if>
331          <m:csymbol>inst</m:csymbol>
332          <xsl:apply-templates mode="noannot" select="*[1]" />
333          <xsl:for-each select="arg">
334           <xsl:variable name="base_path">
335            <xsl:call-template name="path">
336             <xsl:with-param name="uri" select="../*[1]/@uri"/>
337            </xsl:call-template>
338           </xsl:variable>
339           <xsl:variable name="varUri" select="concat($base_path,@relUri)"/>
340           <m:ci definitionURL="{$varUri}">
341            <xsl:call-template name="insert_subscript">
342             <xsl:with-param name="node_value">
343              <xsl:call-template name="name_of_uri">
344               <xsl:with-param name="uri" select="$varUri"/>
345               <xsl:with-param name="extension" select="'.var'"/>
346              </xsl:call-template>
347             </xsl:with-param>
348            </xsl:call-template>
349           </m:ci>
350           <xsl:apply-templates mode ="noannot" select="*[1]" />
351          </xsl:for-each>
352         </m:apply>
353 </xsl:template>
354
355 <!-- ELEMENTS OF CIC TERMS -->
356
357 <xsl:template match="FixFunction" mode="pure">
358     <m:bvar>
359      <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>
360      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
361     </m:bvar> 
362     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
363 </xsl:template>
364
365
366 <xsl:template match="CofixFunction" mode="pure">
367     <m:bvar>
368      <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>
369      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
370     </m:bvar> 
371     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
372 </xsl:template>
373
374 </xsl:stylesheet>