]> matita.cs.unibo.it Git - helm.git/blob - helm/style/basic.xsl
added LICENSE
[helm.git] / helm / style / basic.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 Logic                                                      -->
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 <!-- AND -->
46
47 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic/Conjunction/and.ind'] and (count(child::*) = 3)]" mode="pure">
48     <m:apply helm:xref="{@id}">
49     <m:and definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
50      <xsl:apply-templates select="*[2]" mode="noannot"/>
51      <xsl:apply-templates select="*[3]" mode="noannot"/>
52     </m:apply>
53 </xsl:template>
54
55 <!-- OR -->
56
57 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic/Disjunction/or.ind'] and (count(child::*) = 3)]" mode="pure">
58     <m:apply helm:xref="{@id}">
59     <m:or definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
60      <xsl:apply-templates select="*[2]" mode="noannot"/>
61      <xsl:apply-templates select="*[3]" mode="noannot"/>
62     </m:apply>
63 </xsl:template>
64
65 <!-- NOT -->
66
67 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Logic/not.con'] and (count(child::*) = 2)]" mode="pure">
68     <m:apply helm:xref="{@id}">
69     <m:not definitionURL="{CONST/@uri}" helm:xref="{MUTIND/@id}"/>
70      <xsl:apply-templates select="*[2]" mode="noannot"/>
71     </m:apply>
72 </xsl:template>
73
74 <!-- IFF -->
75 <!--
76 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Logic/Equivalence/iff.ind'] and (count(child::*) = 3)]" mode="pure">
77     <m:apply helm:xref="{@id}">
78     <m:iff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
79      <xsl:apply-templates select="*[2]" mode="noannot"/>
80      <xsl:apply-templates select="*[3]" mode="noannot"/>
81     </m:apply>
82 </xsl:template>
83 -->
84
85 <!-- EXISTS -->
86
87 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex.ind' or attribute::uri='cic:/Coq/Init/Logic_Type/exT.ind'] and (count(child::*) = 3)]" mode="pure">
88     <m:apply helm:xref="{@id}">
89      <m:exists definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
90      <xsl:choose>
91       <xsl:when test="name(*[3]) = 'LAMBDA'">
92        <m:bvar>
93         <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="LAMBDA/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
94        </m:bvar>
95        <xsl:apply-templates select="LAMBDA/target" mode="noannot"/>
96       </xsl:when>
97       <xsl:otherwise>
98        <m:bvar>
99         <m:ci>$x</m:ci>
100        </m:bvar>
101        <m:apply>
102         <m:csymbol>app</m:csymbol>
103         <xsl:apply-templates select="*[3]" mode="noannot"/>
104         <m:ci>$x</m:ci>
105        </m:apply>
106       </xsl:otherwise>
107      </xsl:choose>
108     </m:apply>
109 </xsl:template>
110
111 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex2.ind' or attribute::uri='cic:/Coq/Init/Logic_Type/exT2.ind'] and (count(child::*) = 4)]" mode="pure">
112     <m:apply helm:xref="{@id}">
113     <m:exists definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
114      <xsl:choose>
115       <xsl:when test="name(*[3]) = 'LAMBDA'">
116        <xsl:variable name="bvarname" select="*[3]/target/@binder"/>
117        <m:bvar>
118         <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$bvarname"/></xsl:with-param></xsl:call-template></m:ci>
119        </m:bvar>
120        <m:condition>
121         <xsl:apply-templates select="LAMBDA[1]/target" mode="noannot"/>
122        </m:condition>
123        <xsl:choose>
124         <xsl:when test="(name(*[4]) = 'LAMBDA') and 
125            ($bvarname = *[4]/target/@binder)">
126          <xsl:apply-templates select="LAMBDA[2]/target" mode="noannot"/>
127         </xsl:when>
128         <xsl:otherwise>
129          <m:apply>
130           <m:csymbol>app</m:csymbol>
131           <xsl:apply-templates select="*[4]" mode="noannot"/>
132           <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$bvarname"/></xsl:with-param></xsl:call-template></m:ci>
133          </m:apply>
134         </xsl:otherwise>
135        </xsl:choose>
136       </xsl:when>
137       <xsl:otherwise>
138        <xsl:choose>
139         <xsl:when test="name(*[4]) = 'LAMBDA'">
140          <xsl:variable name="bvarname" select="*[4]/target/@binder"/>
141          <m:bvar>
142           <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$bvarname"/></xsl:with-param></xsl:call-template></m:ci>
143          </m:bvar>
144          <m:condition>
145           <m:apply>
146            <m:csymbol>app</m:csymbol>
147            <xsl:apply-templates select="*[3]" mode="noannot"/>
148            <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$bvarname"/></xsl:with-param></xsl:call-template></m:ci>
149           </m:apply>
150          </m:condition>
151          <xsl:apply-templates select="*[4]/target" mode="noannot"/>
152         </xsl:when>
153         <xsl:otherwise>
154          <m:bvar>
155           <m:ci>x</m:ci>
156          </m:bvar>
157          <m:condition>
158           <m:apply>
159            <m:csymbol>app</m:csymbol>
160            <xsl:apply-templates select="*[3]" mode="noannot"/>
161            <m:ci>x</m:ci>
162           </m:apply>
163          </m:condition>
164          <m:apply>
165           <m:csymbol>app</m:csymbol>
166           <xsl:apply-templates select="*[4]" mode="noannot"/>
167           <m:ci>x</m:ci>
168          </m:apply>
169         </xsl:otherwise>
170        </xsl:choose>
171       </xsl:otherwise>
172      </xsl:choose>
173     </m:apply>
174 </xsl:template>
175
176 <!-- EQUALITY -->
177
178 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic/Equality/eq.ind'] and (count(child::*) = 4)]" mode="pure">
179     <m:apply helm:xref="{@id}">
180     <m:eq definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
181      <xsl:apply-templates select="*[3]" mode="noannot"/>
182      <xsl:apply-templates select="*[4]" mode="noannot"/>
183     </m:apply>
184 </xsl:template>
185
186
187 <!-- TYPE EQUALITY -->
188
189 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic_Type/eqT.ind'] and (count(child::*) = 4)]" mode="pure">
190     <m:apply helm:xref="{@id}">
191     <m:eq definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
192      <xsl:apply-templates select="*[3]" mode="noannot"/>
193      <xsl:apply-templates select="*[4]" mode="noannot"/>
194     </m:apply>
195 </xsl:template>
196
197 <!-- NOT-EQ -->
198 <!-- NOT and EQ have no parameters -->
199 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Logic/not.con']
200 and (count(child::*) = 2) and APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic/Equality/eq.ind']]]" mode="pure">
201     <xsl:choose>
202      <xsl:when test="count(APPLY/child::*) = 4">
203       <m:apply helm:xref="{@id}">
204        <m:neq/>
205        <xsl:apply-templates select="*[2]/*[3]" mode="noannot"/>
206        <xsl:apply-templates select="*[2]/*[4]" mode="set"/>  
207       </m:apply>
208      </xsl:when>
209      <xsl:otherwise>
210       <xsl:apply-imports/>
211      </xsl:otherwise>
212     </xsl:choose>
213 </xsl:template>
214
215 <!-- NOT-EQT -->
216 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Logic/not.con']
217 and (count(child::*) = 2) and APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Logic_Type/eqT.ind']]]" mode="pure">
218     <xsl:choose>
219      <xsl:when test="count(APPLY/child::*) = 4">
220       <m:apply helm:xref="{@id}">
221        <m:neq/>
222        <xsl:apply-templates select="*[2]/*[3]" mode="noannot"/>
223        <xsl:apply-templates select="*[2]/*[4]" mode="set"/>  
224       </m:apply>
225      </xsl:when>
226      <xsl:otherwise>
227       <xsl:apply-imports/>
228      </xsl:otherwise>
229     </xsl:choose>
230 </xsl:template>
231
232 <!-- ************************ DATATYPES ******************************* -->
233
234 <!-- no datatypes in MathML content -->
235
236
237 <!-- *************************** PEANO ********************************* -->
238
239 <xsl:template match="APPLY[MUTIND[attribute::uri='cic:/Coq/Init/Peano/le.ind'] and (count(child::*) = 3)]" mode="pure">
240     <m:apply helm:xref="{@id}">
241     <m:leq definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
242      <xsl:apply-templates select="*[2]" mode="noannot"/>
243      <xsl:apply-templates select="*[3]" mode="noannot"/>
244     </m:apply>
245 </xsl:template>
246
247 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Peano/lt.con'] and (count(child::*) = 3)]" mode="pure">
248     <m:apply helm:xref="{@id}">
249     <m:lt definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
250      <xsl:apply-templates select="*[2]" mode="noannot"/>
251      <xsl:apply-templates select="*[3]" mode="noannot"/>
252     </m:apply>
253 </xsl:template>
254
255 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Peano/ge.con'] and (count(child::*) = 3)]" mode="pure">
256     <m:apply helm:xref="{@id}">
257     <m:geq definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
258      <xsl:apply-templates select="*[2]" mode="noannot"/>
259      <xsl:apply-templates select="*[3]" mode="noannot"/>
260     </m:apply>
261 </xsl:template>
262
263 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Peano/gt.con'] and (count(child::*) = 3)]" mode="pure">
264     <m:apply helm:xref="{@id}">
265     <m:gt definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
266      <xsl:apply-templates select="*[2]" mode="noannot"/>
267      <xsl:apply-templates select="*[3]" mode="noannot"/>
268     </m:apply>
269 </xsl:template>
270
271 </xsl:stylesheet>
272
273
274
275
276
277