]> matita.cs.unibo.it Git - helm.git/blob - helm/style/set.xsl
added support for compressed files
[helm.git] / helm / style / set.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 <!-- Basic Set Theory                                                 -->
29 <!-- First draft: April 3 2000                                        -->
30 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                 -->
31 <!--******************************************************************-->
32
33 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
34                               xmlns:m="http://www.w3.org/1998/Math/MathML"
35                               xmlns:helm="http://www.cs.unibo.it/helm">
36
37 <!--******************************************************************-->
38 <!-- Variable containing the absolute path of the CIC file            -->
39 <!--******************************************************************-->
40
41 <xsl:variable name="absPath">http://localhost:8081/getciconly?uri=</xsl:variable>
42
43 <!-- ************************* LOGIC *********************************-->
44
45
46
47 <xsl:template match="*" mode="set">
48     <xsl:choose>
49      <xsl:when test="name() = 'LAMBDA'">
50       <m:set>
51        <m:bvar>
52         <m:ci>
53          <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
54         </m:ci>
55         <m:type>
56          <xsl:apply-templates select="source" mode="noannot"/>
57         </m:type>
58        </m:bvar>
59        <m:condition>
60         <xsl:apply-templates select="target" mode="noannot"/>
61        </m:condition>
62       </m:set>
63      </xsl:when>
64      <xsl:otherwise>
65       <xsl:apply-templates select="." mode="noannot"/>
66      </xsl:otherwise>
67     </xsl:choose>
68 </xsl:template>
69
70
71 <!-- IN -->
72
73 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/In.con']]" mode="pure">
74     <xsl:variable name="no_params">
75      <xsl:call-template name="get_no_params">
76       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
77       <xsl:with-param name="second_uri" select="CONST/@uri"/>
78      </xsl:call-template>
79     </xsl:variable>
80     <xsl:choose>
81      <xsl:when test="(count(child::*) - number($no_params)) = 3">
82       <m:apply helm:xref="{@id}">
83        <m:in definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
84        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
85        <!-- <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/> -->
86        <xsl:apply-templates select="*[2+$no_params]" mode="set" /> 
87       </m:apply>
88      </xsl:when>
89      <xsl:otherwise>
90       <xsl:apply-imports/>
91      </xsl:otherwise>
92     </xsl:choose>
93 </xsl:template>
94
95
96 <!-- NOT-IN -->
97 <!-- NOT ha no parameters -->
98 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Logic/not.con']
99 and (count(child::*) = 2) and APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/In.con']]]" mode="pure">
100     <xsl:variable name="no_params">
101      <xsl:call-template name="get_no_params">
102       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
103       <xsl:with-param name="second_uri" select="APPLY/CONST/@uri"/>
104      </xsl:call-template>
105     </xsl:variable>
106     <xsl:choose>
107      <xsl:when test="(count(APPLY/child::*) - number($no_params)) = 3">
108       <m:apply helm:xref="{@id}">
109        <m:notin/>
110        <xsl:apply-templates select="*[2]/*[3+$no_params]" mode="noannot"/>
111   <!-- <xsl:apply-templates select="*[2]/*[2+$no_params]" mode="noannot"/> -->
112        <xsl:apply-templates select="*[2]/*[2+$no_params]" mode="set"/>  
113       </m:apply>
114      </xsl:when>
115      <xsl:otherwise>
116       <xsl:apply-imports/>
117      </xsl:otherwise>
118     </xsl:choose>
119 </xsl:template>
120
121 <!-- EMPTY SET -->
122
123 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Empty_set.ind']]" mode="pure">
124     <xsl:variable name="no_params">
125      <xsl:call-template name="get_no_params">
126       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
127       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
128      </xsl:call-template>
129     </xsl:variable>
130     <xsl:choose>
131      <xsl:when test="(count(child::*) - number($no_params)) = 1">
132       <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
133       </m:set>
134      </xsl:when>   
135      <xsl:when test="(count(child::*) - number($no_params)) = 2">
136       <m:apply helm:xref="{@id}">
137        <m:in definitionURL="cic:/Coq/Sets/Ensembles/Ensembles/In.con"/>
138        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
139        <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
140        </m:set>
141       </m:apply>
142      </xsl:when>
143      <xsl:otherwise>
144       <xsl:apply-imports/>
145      </xsl:otherwise>
146     </xsl:choose>
147 </xsl:template>
148
149 <!-- SINGLETON -->
150
151 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Singleton.ind']]" mode="pure">
152     <xsl:variable name="no_params">
153      <xsl:call-template name="get_no_params">
154       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
155       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
156      </xsl:call-template>
157     </xsl:variable>
158     <xsl:choose>
159      <xsl:when test="(count(child::*) - number($no_params)) = 2">
160       <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
161        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
162       </m:set>
163      </xsl:when>   
164      <xsl:when test="(count(child::*) - number($no_params)) = 3">
165       <m:apply helm:xref="{@id}">
166        <m:in definitionURL="cic:/Coq/Sets/Ensembles/Ensembles/In.con"/>
167        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
168        <m:set definitionURL="{MUTIND/@uri}">
169         <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
170        </m:set>
171       </m:apply>
172      </xsl:when>
173      <xsl:otherwise>
174       <xsl:apply-imports/>
175      </xsl:otherwise>
176     </xsl:choose>
177 </xsl:template>
178
179 <!-- COUPLE -->
180
181 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Couple.ind']]" mode="pure">
182     <xsl:variable name="no_params">
183      <xsl:call-template name="get_no_params">
184       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
185       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
186      </xsl:call-template>
187     </xsl:variable>
188     <xsl:choose>
189      <xsl:when test="(count(child::*) - number($no_params)) = 3">
190       <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
191        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
192        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
193       </m:set>
194      </xsl:when>   
195      <xsl:when test="(count(child::*) - number($no_params)) = 4">
196       <m:apply helm:xref="{@id}">
197        <m:in definitionURL="cic:/Coq/Sets/Ensembles/Ensembles/In.con"/>
198        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
199        <m:set definitionURL="{MUTIND/@uri}">
200         <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
201         <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
202        </m:set>
203       </m:apply>
204      </xsl:when>
205      <xsl:otherwise>
206       <xsl:apply-imports/>
207      </xsl:otherwise>
208     </xsl:choose>
209 </xsl:template>
210
211 <!-- TRIPLE -->
212
213 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Triple.ind'] and (count(child::*) = 5)]" mode="pure">
214     <xsl:variable name="no_params">
215      <xsl:call-template name="get_no_params">
216       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
217       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
218      </xsl:call-template>
219     </xsl:variable>
220     <xsl:choose>
221      <xsl:when test="(count(child::*) - number($no_params)) = 4">
222       <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
223        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
224        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
225        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
226       </m:set>
227      </xsl:when>   
228      <xsl:when test="(count(child::*) - number($no_params)) = 5">
229       <m:apply helm:xref="{@id}">
230        <m:in definitionURL="cic:/Coq/Sets/Ensembles/Ensembles/In.con"/>
231        <xsl:apply-templates select="*[5+$no_params]" mode="noannot"/>
232        <m:set definitionURL="{MUTIND/@uri}">
233         <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
234         <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
235         <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
236        </m:set>
237       </m:apply>
238      </xsl:when>
239      <xsl:otherwise>
240       <xsl:apply-imports/>
241      </xsl:otherwise>
242     </xsl:choose>
243 </xsl:template>
244
245 <!-- INTERSECTION -->
246
247 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Intersection.ind']]" mode="pure">
248     <xsl:variable name="no_params">
249      <xsl:call-template name="get_no_params">
250       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
251       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
252      </xsl:call-template>
253     </xsl:variable>
254     <xsl:choose>
255      <xsl:when test="(count(child::*) - number($no_params)) = 3">
256       <m:apply helm:xref="{@id}">
257        <m:intersect definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
258        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
259        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
260       </m:apply>
261      </xsl:when>
262      <xsl:when test="(count(child::*) - number($no_params)) = 4">
263       <m:apply helm:xref="{@id}">
264        <m:in/>
265        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
266        <m:apply>
267         <m:intersect definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
268         <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
269         <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
270        </m:apply>
271       </m:apply>
272      </xsl:when>
273      <xsl:otherwise>
274       <xsl:apply-imports/>
275      </xsl:otherwise>
276     </xsl:choose>
277 </xsl:template>
278
279
280 <!-- UNION -->
281
282 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Union.ind']]" mode="pure">
283     <xsl:variable name="no_params">
284      <xsl:call-template name="get_no_params">
285       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
286       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
287      </xsl:call-template>
288     </xsl:variable>
289     <xsl:choose>
290      <xsl:when test="(count(child::*) - number($no_params)) = 3">
291       <m:apply helm:xref="{@id}">
292        <m:union definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
293        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
294        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
295       </m:apply>
296      </xsl:when>
297      <xsl:when test="(count(child::*) - number($no_params)) = 4">
298       <m:apply helm:xref="{@id}">
299        <m:in/>
300        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
301        <m:apply>
302         <m:union definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
303         <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
304         <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
305        </m:apply>
306       </m:apply>
307      </xsl:when>
308      <xsl:otherwise>
309       <xsl:apply-imports/>
310      </xsl:otherwise>
311     </xsl:choose>
312 </xsl:template>
313
314 <!-- INCLUDED -->
315
316 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Included.con']]" mode="pure">
317     <xsl:variable name="no_params">
318      <xsl:call-template name="get_no_params">
319       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
320       <xsl:with-param name="second_uri" select="CONST/@uri"/>
321      </xsl:call-template>
322     </xsl:variable>
323     <xsl:choose>
324      <xsl:when test="(count(child::*) - number($no_params)) = 3">
325       <m:apply helm:xref="{@id}">
326        <m:subset definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
327        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
328        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
329       </m:apply>
330      </xsl:when>
331      <xsl:otherwise>
332       <xsl:apply-imports/>
333      </xsl:otherwise>
334     </xsl:choose>
335 </xsl:template>
336
337 <!-- STRICTLY INCLUDED -->
338
339 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Strict_Included.con']]" mode="pure">
340     <xsl:variable name="no_params">
341      <xsl:call-template name="get_no_params">
342       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
343       <xsl:with-param name="second_uri" select="CONST/@uri"/>
344      </xsl:call-template>
345     </xsl:variable>
346     <xsl:choose>
347      <xsl:when test="(count(child::*) - number($no_params)) = 3">
348       <m:apply helm:xref="{@id}">
349        <m:prsubset definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
350        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
351        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
352       </m:apply>
353      </xsl:when>
354      <xsl:otherwise>
355       <xsl:apply-imports/>
356      </xsl:otherwise>
357     </xsl:choose>
358 </xsl:template>
359
360 <!-- SET-DIFF -->
361
362 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Setminus.con']]" mode="pure">
363     <xsl:variable name="no_params">
364      <xsl:call-template name="get_no_params">
365       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
366       <xsl:with-param name="second_uri" select="CONST/@uri"/>
367      </xsl:call-template>
368     </xsl:variable>
369     <xsl:choose>
370      <xsl:when test="(count(child::*) - number($no_params)) = 3">
371       <m:apply helm:xref="{@id}">
372        <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
373        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
374        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
375       </m:apply>
376      </xsl:when>
377      <xsl:when test="(count(child::*) - number($no_params)) = 4">
378       <m:apply helm:xref="{@id}">
379        <m:in/>
380        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
381        <m:apply>
382         <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
383         <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
384         <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
385        </m:apply>
386       </m:apply>
387      </xsl:when>
388      <xsl:otherwise>
389       <xsl:apply-imports/>
390      </xsl:otherwise>
391     </xsl:choose>
392 </xsl:template>
393
394 <!-- ADD-ELEM -->
395
396 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Add.con']]" mode="pure">
397     <xsl:variable name="no_params">
398      <xsl:call-template name="get_no_params">
399       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
400       <xsl:with-param name="second_uri" select="CONST/@uri"/>
401      </xsl:call-template>
402     </xsl:variable>
403     <xsl:choose>
404      <xsl:when test="(count(child::*) - number($no_params)) = 3">
405       <m:apply helm:xref="{@id}">
406        <m:union definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
407        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
408        <m:set>
409         <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
410        </m:set>
411       </m:apply>
412      </xsl:when>
413      <xsl:when test="(count(child::*) - number($no_params)) = 4">
414       <m:apply helm:xref="{@id}">
415        <m:in/>
416        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
417        <m:apply>
418         <m:union definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
419         <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
420         <m:set>
421          <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
422         </m:set>
423        </m:apply>
424       </m:apply>
425      </xsl:when>
426      <xsl:otherwise>
427       <xsl:apply-imports/>
428      </xsl:otherwise>
429     </xsl:choose>
430 </xsl:template>
431
432 <!-- SUBTRACT-ELEM -->
433
434 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Sets/Ensembles/Ensembles/Subtract.con']]" mode="pure">
435     <xsl:variable name="no_params">
436      <xsl:call-template name="get_no_params">
437       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
438       <xsl:with-param name="second_uri" select="CONST/@uri"/>
439      </xsl:call-template>
440     </xsl:variable>
441     <xsl:choose>
442      <xsl:when test="(count(child::*) - number($no_params)) = 3">
443       <m:apply helm:xref="{@id}">
444        <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
445        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
446        <m:set>
447         <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
448        </m:set>
449       </m:apply>
450      </xsl:when>
451      <xsl:when test="(count(child::*) - number($no_params)) = 4">
452       <m:apply helm:xref="{@id}">
453        <m:in/>
454        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
455        <m:apply>
456         <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
457         <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
458         <m:set>
459          <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
460         </m:set>
461        </m:apply>
462       </m:apply>
463      </xsl:when>
464      <xsl:otherwise>
465       <xsl:apply-imports/>
466      </xsl:otherwise>
467     </xsl:choose>
468 </xsl:template>
469
470 <!-- CARD -->
471
472 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Sets/Finite_sets/Ensembles_finis/cardinal.ind']]" mode="pure">
473     <xsl:variable name="no_params">
474      <xsl:call-template name="get_no_params">
475       <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
476       <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
477      </xsl:call-template>
478     </xsl:variable>
479     <xsl:choose>
480      <xsl:when test="(count(child::*) - number($no_params)) = 3">
481       <m:apply helm:xref="{@id}">
482        <m:eq/>
483        <m:apply>
484         <m:card definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
485         <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
486        </m:apply>
487        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
488       </m:apply>
489      </xsl:when>
490      <xsl:otherwise>
491       <xsl:apply-imports/>
492      </xsl:otherwise>
493     </xsl:choose>
494 </xsl:template>
495
496 </xsl:stylesheet>