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">
38 <!-- ************************* LOGIC *********************************-->
40 <!-- Proof objects -->
42 <!-- <xsl:key name="typeid" use="@of" match="TYPE"/> -->
44 <!-- ALL this elements does not have inner type -->
45 <xsl:template match="LETIN|PROD|REL|SORT|VAR|META|CONST|MUTIND|MUTCONSTRUCT" mode="noannot">
46 <xsl:apply-templates select="." mode="pure"/>
49 <!-- LAMBDA has inner type only if it is not nested inside another lambda -->
50 <xsl:template match="LAMBDA" mode="noannot">
51 <xsl:variable name="id" select="@id"/>
53 <xsl:when test="//InnerTypes and @sort='Prop' and name(../..) != 'LAMBDA'">
54 <!-- <xsl:when test="@sort='Prop' and //InnerTypes/TYPE[@of=$id]"> -->
55 <xsl:call-template name="has_inner_type"/>
58 <xsl:apply-templates select="." mode="pure"/>
63 <!-- ALL this elements have inner type -->
64 <xsl:template match="CAST|APPLY|MUTCASE|FIX|COFIX" mode="noannot">
66 <!-- <xsl:when test="//InnerTypes and key('typeid',@id)"> -->
67 <!-- <xsl:when test="//InnerTypes/TYPE[@of=$id]"> -->
68 <xsl:when test="//InnerTypes and @sort='Prop'">
69 <xsl:call-template name="has_inner_type"/>
72 <xsl:apply-templates select="." mode="pure"/>
77 <xsl:template name="has_inner_type">
78 <xsl:variable name="id" select="@id"/>
80 <xsl:when test="name()= 'APPLY' and CONST[
81 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
82 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
83 <m:apply helm:xref="{@id}">
84 <m:csymbol>thread</m:csymbol>
85 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
87 <m:csymbol>rw_step</m:csymbol>
88 <xsl:apply-templates mode="pure" select="*[3]"/>
89 <xsl:apply-templates mode="pure" select="*[6]"/>
90 <xsl:apply-templates mode="pure" select="*[7]"/>
92 <xsl:apply-templates mode="thread" select="*[5]"/>
95 <!-- gestire meglio il caso di and_ind quando la prova
96 non e' della forma \x.\y.M -->
97 <xsl:when test="name()= 'APPLY' and CONST[
98 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']
99 and count(child::*) = 6
100 and name(*[5])='LAMBDA'
101 and name(*[5]/target/*[1])='LAMBDA'">
102 <m:apply helm:xref="{@id}">
103 <m:csymbol>and_ind</m:csymbol>
104 <xsl:apply-templates mode="noannot" select="*[6]"/>
105 <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>
106 <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
107 <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>
108 <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
109 <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
112 <xsl:when test="name()= 'APPLY' and CONST[
113 attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
114 and count(child::*) = 7">
115 <m:apply helm:xref="{@id}">
116 <m:csymbol>or_ind</m:csymbol>
117 <xsl:apply-templates mode="noannot" select="*[7]"/>
118 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
119 <xsl:apply-templates mode="pure" select="*[5]"/>
120 <xsl:apply-templates mode="pure" select="*[6]"/>
123 <!-- ex_ind, exT_ind -->
124 <xsl:when test="name()= 'APPLY'
125 and (CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
126 CONST[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex_ind.con'])
127 and count(child::*) = 6
128 and name(*[5])='LAMBDA'
129 and name(*[5]/target/*[1])='LAMBDA'">
130 <m:apply helm:xref="{@id}">
131 <m:csymbol>ex_ind</m:csymbol>
132 <xsl:apply-templates mode="noannot" select="*[6]"/>
133 <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>
134 <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
135 <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>
136 <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
137 <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
141 <!-- <xsl:when test="count(*[@id = //InnerTypes/TYPE/@of]) = 1"> -->
142 <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">
143 <m:apply helm:xref="{@id}">
144 <m:csymbol>thread</m:csymbol>
145 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
147 <m:csymbol>app</m:csymbol>
148 <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
150 <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')]"/>
154 <m:apply helm:xref="{@id}">
155 <m:csymbol>proof</m:csymbol>
156 <xsl:apply-templates select="." mode="pure"/>
157 <!-- <xsl:apply-templates select="key('typeid',@id)" mode="pure"/> -->
158 <xsl:apply-templates select="//InnerTypes/TYPE[@of=$id]/*" mode="pure"/>
164 <xsl:template match="*" mode="copy-of-no-prop">
166 <!-- <xsl:when test="@id = //InnerTypes/TYPE/@of"> -->
167 <xsl:when test="@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')">
168 <m:ci>previous</m:ci>
171 <xsl:apply-templates select="." mode="pure"/>
174 <xsl:apply-templates mode="copy-of-no-prop" select="following-sibling::*[1]"/>
177 <xsl:template match="*" mode="thread">
179 <xsl:when test="name()= 'APPLY' and CONST[
180 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
181 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
182 <xsl:variable name="id" select="@id"/>
183 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
185 <m:csymbol>rw_step</m:csymbol>
186 <xsl:apply-templates mode="pure" select="*[3]"/>
187 <xsl:apply-templates mode="pure" select="*[6]"/>
188 <xsl:apply-templates mode="pure" select="*[7]"/>
190 <xsl:apply-templates mode="thread" select="*[5]"/>
192 <!--**** Patch temporanea, per il problema dei threads ***-->
193 <xsl:when test="(name()= 'APPLY' and
194 (CONST[attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con'] or
195 CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
196 CONST[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex_ind.con'])
197 and count(child::*) = 6
198 and name(*[5])='LAMBDA'
199 and name(*[5]/target/*[1])='LAMBDA')
201 (name()= 'APPLY' and CONST[
202 attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
203 and count(child::*) = 7)">
204 <xsl:apply-templates mode="noannot" select="."/>
206 <!--**** Fine Patch temporanea, per il problema dei threads ***-->
207 <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">
208 <xsl:variable name="id" select="@id"/>
209 <m:apply helm:xref="{@id}">
210 <m:csymbol>thread</m:csymbol>
211 <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
213 <m:csymbol>app</m:csymbol>
214 <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
216 <!-- <xsl:apply-templates mode="thread" select="*[@id = //InnerTypes/TYPE/@of]"/> -->
217 <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')]"/>
221 <xsl:apply-templates mode="noannot" select="."/>
227 <!-- Basic proof operators -->
229 <!-- non del tutto soddisfacente, ma .... -->
230 <xsl:template match="APPLY[CONST[
231 attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
232 attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con']]" mode="appflat">
234 <xsl:when test="count(child::*) > 7">
235 <xsl:variable name="id" select="@id"/>
236 <xsl:variable name="ideqp" select="*[7]/@id"/>
237 <xsl:variable name="idsubp" select="*[5]/@id"/>
239 <xsl:variable name="leteqp" select="boolean(//InnerTypes/TYPE[@of=$ideqp])"/>
240 <xsl:variable name="letsubp" select="boolean(//InnerTypes/TYPE[@of=$idsubp])"/>
242 <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')])"/>
243 <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')])"/>
244 <m:apply helm:xref="{@id}">
245 <m:csymbol>rewrite_and_apply</m:csymbol>
247 <m:csymbol>rw_step</m:csymbol>
248 <xsl:apply-templates mode="pure" select="*[3]"/>
249 <xsl:apply-templates mode="pure" select="*[6]"/>
251 <xsl:when test="$leteqp">
253 <xsl:when test="$letsubp">
255 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h2'"/></xsl:with-param></xsl:call-template>
260 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h1'"/></xsl:with-param></xsl:call-template>
266 <xsl:apply-templates mode="pure" select="*[7]"/>
271 <xsl:when test="$letsubp">
273 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h1'"/></xsl:with-param></xsl:call-template>
277 <xsl:apply-templates mode="pure" select="*[5]"/>
280 <xsl:apply-templates mode="flat" select="*[8]">
281 <xsl:with-param name="n">
282 <xsl:value-of select="1+$letsubp+$leteqp"/>
284 </xsl:apply-templates>
288 <m:apply helm:xref="{@id}">
289 <m:csymbol>app</m:csymbol>
290 <xsl:apply-templates mode="flat" select="*[1]"/>
296 <xsl:template match="APPLY[CONST[
297 attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']]" mode="appflat">
299 <xsl:when test="count(child::*) > 4">
300 <m:apply helm:xref="{@id}">
301 <m:csymbol>app</m:csymbol>
302 <xsl:apply-templates mode="pure" select="*[1]"/>
306 <xsl:apply-templates mode="flat" select="*[5]"/>
310 <m:apply helm:xref="{@id}">
311 <m:csymbol>app</m:csymbol>
312 <xsl:apply-templates mode="flat" select="*[1]"/>