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 <!-- First draft: April 3 2000 -->
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 <!--******************************************************************-->
38 <!-- Variable containing the absolute path of the CIC file -->
39 <!--******************************************************************-->
41 <xsl:variable name="absPath">http://localhost:8081/getciconly?uri=</xsl:variable>
43 <!-- ************************* LOGIC *********************************-->
45 <!-- Proof objects -->
47 <!-- <xsl:key name="typeid" use="@of" match="TYPE"/> -->
49 <!-- ALL this elements does not have inner type -->
50 <xsl:template match="LETIN|PROD|REL|SORT|VAR|META|CONST|MUTIND|MUTCONSTRUCT" mode="noannot">
51 <xsl:apply-templates select="." mode="pure"/>
54 <!-- LAMBDA has inner type only if it is not nested inside another lambda -->
55 <xsl:template match="LAMBDA" mode="noannot">
56 <xsl:variable name="id" select="@id"/>
58 <xsl:when test="//InnerTypes and @sort='Prop' and name(../..) != 'LAMBDA'">
59 <!-- <xsl:when test="@sort='Prop' and //InnerTypes/TYPE[@of=$id]"> -->
60 <xsl:call-template name="has_inner_type"/>
63 <xsl:apply-templates select="." mode="pure"/>
68 <!-- ALL this elements have inner type -->
69 <xsl:template match="CAST|APPLY|MUTCASE|FIX|COFIX" mode="noannot">
71 <!-- <xsl:when test="//InnerTypes and key('typeid',@id)"> -->
72 <!-- <xsl:when test="//InnerTypes/TYPE[@of=$id]"> -->
73 <xsl:when test="//InnerTypes and @sort='Prop'">
74 <xsl:call-template name="has_inner_type"/>
77 <xsl:apply-templates select="." mode="pure"/>
82 <xsl:template name="has_inner_type">
83 <xsl:variable name="id" select="@id"/>
85 <xsl:when test="name()= 'APPLY' and CONST[
86 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
87 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
88 <m:apply helm:xref="{@id}">
89 <m:csymbol>thread</m:csymbol>
90 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
92 <m:csymbol>rw_step</m:csymbol>
93 <xsl:apply-templates mode="pure" select="*[3]"/>
94 <xsl:apply-templates mode="pure" select="*[6]"/>
95 <xsl:apply-templates mode="pure" select="*[7]"/>
97 <xsl:apply-templates mode="thread" select="*[5]"/>
100 <!-- gestire meglio il caso di and_ind quando la prova
101 non e' della forma \x.\y.M -->
102 <xsl:when test="name()= 'APPLY' and CONST[
103 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']
104 and count(child::*) = 6
105 and name(*[5])='LAMBDA'
106 and name(*[5]/target/*[1])='LAMBDA'">
107 <m:apply helm:xref="{@id}">
108 <m:csymbol>and_ind</m:csymbol>
109 <xsl:apply-templates mode="noannot" select="*[6]"/>
110 <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>
111 <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
112 <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>
113 <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
114 <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
117 <xsl:when test="name()= 'APPLY' and CONST[
118 attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
119 and count(child::*) = 7">
120 <m:apply helm:xref="{@id}">
121 <m:csymbol>or_ind</m:csymbol>
122 <xsl:apply-templates mode="noannot" select="*[7]"/>
123 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
124 <xsl:apply-templates mode="pure" select="*[5]"/>
125 <xsl:apply-templates mode="pure" select="*[6]"/>
128 <!-- <xsl:when test="count(*[@id = //InnerTypes/TYPE/@of]) = 1"> -->
129 <xsl:when test="count(*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]) = 1">
130 <m:apply helm:xref="{@id}">
131 <m:csymbol>thread</m:csymbol>
132 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
134 <m:csymbol>app</m:csymbol>
135 <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
137 <xsl:apply-templates mode="thread" select="*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]"/>
141 <m:apply helm:xref="{@id}">
142 <m:csymbol>proof</m:csymbol>
143 <xsl:apply-templates select="." mode="pure"/>
144 <!-- <xsl:apply-templates select="key('typeid',@id)" mode="pure"/> -->
145 <xsl:apply-templates select="//InnerTypes/TYPE[@of=$id]/*" mode="pure"/>
151 <xsl:template match="*" mode="copy-of-no-prop">
153 <!-- <xsl:when test="@id = //InnerTypes/TYPE/@of"> -->
154 <xsl:when test="@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')">
155 <m:ci>previous</m:ci>
158 <xsl:apply-templates select="." mode="pure"/>
161 <xsl:apply-templates mode="copy-of-no-prop" select="following-sibling::*[1]"/>
164 <xsl:template match="*" mode="thread">
166 <xsl:when test="name()= 'APPLY' and CONST[
167 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
168 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
169 <xsl:variable name="id" select="@id"/>
170 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
172 <m:csymbol>rw_step</m:csymbol>
173 <xsl:apply-templates mode="pure" select="*[3]"/>
174 <xsl:apply-templates mode="pure" select="*[6]"/>
175 <xsl:apply-templates mode="pure" select="*[7]"/>
177 <xsl:apply-templates mode="thread" select="*[5]"/>
179 <!--**** Patch temporanea, per il problema dei threads ***-->
180 <xsl:when test="(name()= 'APPLY' and CONST[
181 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']
182 and count(child::*) = 6
183 and name(*[5])='LAMBDA'
184 and name(*[5]/target/*[1])='LAMBDA')
186 (name()= 'APPLY' and CONST[
187 attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
188 and count(child::*) = 7)">
189 <xsl:apply-templates mode="noannot" select="."/>
191 <!--**** Fine Patch temporanea, per il problema dei threads ***-->
192 <xsl:when test="//InnerTypes and count(*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]) = 1">
193 <xsl:variable name="id" select="@id"/>
194 <m:apply helm:xref="{@id}">
195 <m:csymbol>thread</m:csymbol>
196 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
198 <m:csymbol>app</m:csymbol>
199 <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
201 <!-- <xsl:apply-templates mode="thread" select="*[@id = //InnerTypes/TYPE/@of]"/> -->
202 <xsl:apply-templates mode="thread" select="*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]"/>
206 <xsl:apply-templates mode="noannot" select="."/>
212 <!-- Basic proof operators -->
214 <!-- non del tutto soddisfacente, ma .... -->
215 <xsl:template match="APPLY[CONST[
216 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
217 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con']]" mode="appflat">
219 <xsl:when test="count(child::*) > 7">
220 <xsl:variable name="id" select="@id"/>
221 <xsl:variable name="ideqp" select="*[7]/@id"/>
222 <xsl:variable name="idsubp" select="*[5]/@id"/>
224 <xsl:variable name="leteqp" select="boolean(//InnerTypes/TYPE[@of=$ideqp])"/>
225 <xsl:variable name="letsubp" select="boolean(//InnerTypes/TYPE[@of=$idsubp])"/>
227 <xsl:variable name="leteqp" select="boolean(*[7][@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')])"/>
228 <xsl:variable name="letsubp" select="boolean(*[5][@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')])"/>
229 <m:apply helm:xref="{@id}">
230 <m:csymbol>rewrite_and_apply</m:csymbol>
232 <m:csymbol>rw_step</m:csymbol>
233 <xsl:apply-templates mode="pure" select="*[3]"/>
234 <xsl:apply-templates mode="pure" select="*[6]"/>
236 <xsl:when test="$leteqp">
238 <xsl:when test="$letsubp">
240 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h2'"/></xsl:with-param></xsl:call-template>
245 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h1'"/></xsl:with-param></xsl:call-template>
251 <xsl:apply-templates mode="pure" select="*[7]"/>
256 <xsl:when test="$letsubp">
258 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h1'"/></xsl:with-param></xsl:call-template>
262 <xsl:apply-templates mode="pure" select="*[5]"/>
265 <xsl:apply-templates mode="flat" select="*[8]">
266 <xsl:with-param name="n">
267 <xsl:value-of select="1+$letsubp+$leteqp"/>
269 </xsl:apply-templates>
273 <m:apply helm:xref="{@id}">
274 <m:csymbol>app</m:csymbol>
275 <xsl:apply-templates mode="flat" select="*[1]"/>
281 <xsl:template match="APPLY[CONST[
282 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']]" mode="appflat">
284 <xsl:when test="count(child::*) > 4">
285 <m:apply helm:xref="{@id}">
286 <m:csymbol>app</m:csymbol>
287 <xsl:apply-templates mode="pure" select="*[1]"/>
291 <xsl:apply-templates mode="flat" select="*[5]"/>
295 <m:apply helm:xref="{@id}">
296 <m:csymbol>app</m:csymbol>
297 <xsl:apply-templates mode="flat" select="*[1]"/>