3 <!-- Copyright (C) 2000, HELM Team -->
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. -->
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. -->
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. -->
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. -->
24 <!-- For details, see the HELM World-Wide-Web page, -->
25 <!-- http://cs.unibo.it/helm/. -->
27 <!--******************************************************************-->
29 <!-- (completely) Revisited: february 2001, Andrea Asperti -->
30 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
31 <!--******************************************************************-->
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">
37 <!-- ************************* LOGIC *********************************-->
39 <!-- Proof objects -->
41 <!-- <xsl:key name="typeid" use="@of" match="TYPE"/> -->
43 <!-- ALL this elements does not have inner type -->
44 <xsl:template match="LETIN|PROD|REL|SORT|VAR|META|CONST|MUTIND|MUTCONSTRUCT" mode="noannot">
45 <xsl:apply-templates select="." mode="pure"/>
48 <!-- ALL ELEMENTS WITH A TYPE ARE TRANSLATED AS A PROOF-ELEMENT -->
50 <!-- LAMBDA has inner type only if it is not nested inside another lambda -->
51 <xsl:template match="LAMBDA" mode="noannot">
52 <xsl:variable name="id" select="@id"/>
54 <xsl:when test="//InnerTypes and @sort='Prop' and name(../..) != 'LAMBDA'">
55 <m:apply helm:xref="{@id}">
56 <m:csymbol>proof</m:csymbol>
57 <xsl:apply-templates mode="proof_transform" select="."/>
58 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
62 <xsl:apply-templates select="." mode="pure"/>
67 <!-- ALL these elements have inner type -->
68 <xsl:template match="CAST|APPLY|MUTCASE|FIX|COFIX" mode="noannot">
69 <xsl:variable name="id" select="@id"/>
71 <xsl:when test="//InnerTypes and @sort='Prop'">
72 <m:apply helm:xref="{@id}">
73 <m:csymbol>proof</m:csymbol>
74 <xsl:apply-templates mode="proof_transform" select="."/>
75 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
80 <xsl:when test="name()='APPLY'">
81 <xsl:apply-templates select="." mode="letin"/>
84 <xsl:apply-templates select="." mode="pure"/>
91 <xsl:template mode="proof_transform" match="*">
92 <xsl:variable name="id" select="@id"/>
94 <!-- NATIND 3 parametri -->
95 <xsl:when test="name()='APPLY' and CONST[
96 attribute::uri='cic:/Coq/Init/Datatypes/nat_ind.con'] and count(child::*) = 4">
98 <m:csymbol>nat_ind</m:csymbol>
99 <xsl:apply-templates mode="noannot" select="*[3]"/>
100 <xsl:apply-templates mode="noannot" select="*[4]"/>
103 <!-- NATIND 4 parametri -->
104 <xsl:when test="name()='APPLY' and CONST[
105 attribute::uri='cic:/Coq/Init/Datatypes/nat_ind.con'] and count(child::*) = 5">
107 <m:csymbol>nat_ind</m:csymbol>
108 <xsl:apply-templates mode="noannot" select="*[3]"/>
109 <xsl:apply-templates mode="noannot" select="*[4]"/>
113 <xsl:when test="name()= 'APPLY' and CONST[
114 attribute::uri='cic:/Coq/Init/Logic/Equality/eq_ind.con' or
115 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
116 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
118 <m:csymbol>rw_step</m:csymbol>
119 <xsl:apply-templates mode="noannot" select="*[5]"/>
120 <xsl:apply-templates mode="pure" select="*[3]"/>
121 <xsl:apply-templates mode="pure" select="*[6]"/>
122 <xsl:apply-templates mode="pure" select="*[7]"/>
125 <!-- EQUALITY with extra-parameters -->
126 <xsl:when test="name()= 'APPLY' and CONST[
127 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
128 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) > 7">
129 <xsl:variable name="no_extraproofs" select="count(*[position()>7 and @sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')])"/>
131 <xsl:when test="$no_extraproofs=0">
133 <m:csymbol>rewrite_and_apply</m:csymbol>
135 <m:csymbol>rw_step</m:csymbol>
136 <xsl:apply-templates mode="noannot" select="*[5]"/>
137 <xsl:apply-templates mode="pure" select="*[3]"/>
138 <xsl:apply-templates mode="pure" select="*[6]"/>
139 <xsl:apply-templates mode="pure" select="*[7]"/>
141 <xsl:apply-templates mode="noannot" select="*[position()>7]"/>
146 <xsl:when test="*[5]/@sort='Prop'">
147 <m:apply helm:xref="{@id}">
148 <m:csymbol>letin</m:csymbol>
150 <m:csymbol>let</m:csymbol>
152 <xsl:call-template name="insert_subscript">
153 <xsl:with-param name="node_value" select="'h1'"/>
156 <xsl:apply-templates mode="noannot" select="*[5]"/>
158 <xsl:call-template name="gen_let">
159 <xsl:with-param name="init_pos" select="1"/>
160 <xsl:with-param name="from" select="7"/>
163 <m:csymbol>rewrite_and_apply</m:csymbol>
165 <m:csymbol>rw_step</m:csymbol>
167 <xsl:call-template name="insert_subscript">
168 <xsl:with-param name="node_value" select="'h1'"/>
171 <xsl:apply-templates mode="pure" select="*[3]"/>
172 <xsl:apply-templates mode="pure" select="*[6]"/>
173 <xsl:apply-templates mode="pure" select="*[7]"/>
175 <xsl:apply-templates mode="flat" select="*[8]">
176 <xsl:with-param name="n">
177 <xsl:value-of select="2"/>
179 </xsl:apply-templates>
184 <m:apply helm:xref="{@id}">
185 <m:csymbol>letin</m:csymbol>
186 <xsl:call-template name="gen_let">
187 <xsl:with-param name="init_pos" select="0"/>
188 <xsl:with-param name="form" select="7"/>
191 <m:csymbol>rewrite_and_apply</m:csymbol>
193 <m:csymbol>rw_step</m:csymbol>
194 <xsl:apply-templates mode="pure" select="*[5]"/>
195 <xsl:apply-templates mode="pure" select="*[3]"/>
196 <xsl:apply-templates mode="pure" select="*[6]"/>
197 <xsl:apply-templates mode="pure" select="*[7]"/>
199 <xsl:apply-templates mode="flat" select="*[8]">
200 <xsl:with-param name="n">
201 <xsl:value-of select="1"/>
203 </xsl:apply-templates>
211 <!-- gestire meglio il caso di and_ind quando la prova
212 non e' della forma \x.\y.M -->
213 <xsl:when test="name()= 'APPLY' and CONST[
214 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']
215 and count(child::*) = 6
216 and name(*[5])='LAMBDA'
217 and name(*[5]/target/*[1])='LAMBDA'">
218 <m:apply helm:xref="{@id}">
219 <m:csymbol>and_ind</m:csymbol>
220 <xsl:apply-templates mode="noannot" select="*[6]"/>
221 <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
222 <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
223 <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/target/LAMBDA/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
224 <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
225 <xsl:apply-templates mode="proof_transform" select="*[5]/target/LAMBDA/target/*"/>
228 <xsl:when test="name()= 'APPLY' and CONST[
229 attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
230 and count(child::*) = 7">
231 <m:apply helm:xref="{@id}">
232 <m:csymbol>or_ind</m:csymbol>
233 <xsl:apply-templates mode="noannot" select="*[7]"/>
234 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
235 <xsl:apply-templates mode="pure" select="*[5]"/>
236 <xsl:apply-templates mode="pure" select="*[6]"/>
239 <!-- ex_ind, exT_ind -->
240 <xsl:when test="name()= 'APPLY'
241 and (CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
242 CONST[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex_ind.con'])
243 and count(child::*) = 6
244 and name(*[5])='LAMBDA'
245 and name(*[5]/target/*[1])='LAMBDA'">
246 <m:apply helm:xref="{@id}">
247 <m:csymbol>ex_ind</m:csymbol>
248 <xsl:apply-templates mode="noannot" select="*[6]"/>
249 <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
250 <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
251 <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/target/LAMBDA/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
252 <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
253 <xsl:apply-templates mode="proof_transform" select="*[5]/target/LAMBDA/target/*"/>
258 <xsl:when test="name()='APPLY'">
259 <xsl:apply-templates select="." mode="letin"/>
262 <xsl:apply-templates select="." mode="pure"/>
270 <xsl:template match="APPLY" mode="letin">
271 <xsl:variable name="no_subproofs" select="count(*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')])"/>
272 <!-- <m:cn><xsl:value-of select="$no_subproofs"/></m:cn> -->
274 <xsl:when test="//InnerTypes and ($no_subproofs = 1)">
275 <m:apply helm:xref="{@id}">
276 <m:csymbol>letin1</m:csymbol>
277 <xsl:apply-templates mode="noannot" select="*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]"/>
278 <!-- now re-process the application -->
279 <m:apply helm:xref="{@id}">
280 <m:csymbol>app</m:csymbol>
281 <!-- mode previous looks for siblings:
282 call with the first child -->
283 <xsl:apply-templates mode="previous" select="*[1]"/>
287 <xsl:when test="//InnerTypes and ($no_subproofs > 1)">
288 <m:apply helm:xref="{@id}">
289 <m:csymbol>letin</m:csymbol>
290 <!-- first process all subproofs (let-in) -->
291 <xsl:call-template name="gen_let"/>
292 <!-- now re-process the application -->
293 <m:apply helm:xref="{@id}">
294 <m:csymbol>app</m:csymbol>
295 <!-- mode flat looks for siblings: call with the first child -->
296 <xsl:apply-templates mode="flat" select="*[1]"/>
301 <xsl:apply-templates mode="pure" select="."/>
306 <xsl:template name="gen_let">
307 <xsl:param name="init_pos" select="0"/>
308 <xsl:param name="from" select="0"/>
309 <xsl:for-each select="*[position()>$from and @sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]">
311 <m:csymbol>let</m:csymbol>
312 <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="concat('h',position()+$init_pos)"/></xsl:with-param></xsl:call-template></m:ci>
313 <xsl:apply-templates mode="noannot" select="."/>
318 <xsl:template match="*" mode="previous">
320 <xsl:when test="//InnerTypes and(@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX'))">
321 <m:ci>previous</m:ci>
324 <xsl:apply-templates select="." mode="pure"/>
327 <xsl:apply-templates mode="previous" select="following-sibling::*[1]"/>
330 <xsl:template match="*" mode="flat">
331 <xsl:param name="n" select="1"/>
332 <xsl:variable name="id" select="@id"/>
334 <!-- <xsl:when test="key('typeid',@id)"> -->
335 <!-- <xsl:when test="//InnerTypes/TYPE[@of=$id]"> -->
336 <xsl:when test="//InnerTypes and @sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')">
338 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="concat('h',$n)"/></xsl:with-param></xsl:call-template>
340 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
341 <xsl:with-param name="n" select="$n+1"/>
342 </xsl:apply-templates>
345 <xsl:apply-templates mode="pure" select="."/>
346 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
347 <xsl:with-param name="n" select="$n"/>
348 </xsl:apply-templates>
354 <!-- <xsl:template match="APPLY[CONST[
355 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']]" mode="appflat">
357 <xsl:when test="count(child::*) > 4">
358 <m:apply helm:xref="{@id}">
359 <m:csymbol>app</m:csymbol>
360 <xsl:apply-templates mode="pure" select="*[1]"/>
364 <xsl:apply-templates mode="flat" select="*[5]"/>
368 <m:apply helm:xref="{@id}">
369 <m:csymbol>app</m:csymbol>
370 <xsl:apply-templates mode="flat" select="*[1]"/>