]> matita.cs.unibo.it Git - helm.git/blob - helm/style/proofs.xsl
&CSCbr; replaced with 
 to make libxslt stop complaining.
[helm.git] / helm / style / proofs.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 <!-- (completely) Revisited: february 2001, Andrea Asperti            -->
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 <!-- ************************* LOGIC *********************************-->
38
39 <!-- Proof objects -->
40
41 <!-- <xsl:key name="typeid" use="@of" match="TYPE"/> -->
42 <xsl:key name="typeid" use="@of" match="TYPE"/>
43
44 <!-- These elements do not have inner type -->
45 <xsl:template match="PROD|SORT|MUTIND|instantiate" mode="noannot">
46  <xsl:apply-templates select="." mode="pure"/>
47 </xsl:template>
48
49 <!-- Atomic elements that have an inner type iff the expected type -->
50 <!-- is different from the synthesized type.                       -->
51 <xsl:template match="REL|VAR|META|CONST|MUTCONSTRUCT" mode="noannot">
52  <xsl:variable name="id" select="@id"/>
53  <xsl:variable name="innertype_available">
54   <xsl:for-each select="$InnerTypes">
55    <xsl:if test="key('typeid',$id)/*">
56     <xsl:text>yes</xsl:text>
57    </xsl:if>
58   </xsl:for-each>
59  </xsl:variable>
60  <xsl:choose>
61   <xsl:when test="$naturalLanguage='yes' and @sort='Prop' and $innertype_available='yes'">
62    <!--xsl:when test="@sort='Prop'"-->
63    <m:apply helm:xref="{@id}">
64     <m:csymbol>proof</m:csymbol>
65     <xsl:apply-templates mode="proof_transform" select="."/>
66     <xsl:for-each select="$InnerTypes">
67      <xsl:apply-templates mode="pure" select="key('typeid',$id)/*"/>
68     </xsl:for-each>
69    </m:apply>
70   </xsl:when>
71   <xsl:otherwise>
72    <xsl:apply-templates select="." mode="pure"/>
73   </xsl:otherwise>
74  </xsl:choose>
75 </xsl:template>
76
77 <!-- ALL ELEMENTS WITH A TYPE ARE TRANSLATED AS A PROOF-ELEMENT -->
78
79 <!-- LAMBDA has inner type only if it is not nested inside another lambda -->
80 <xsl:template match="LAMBDA" mode="noannot">
81  <xsl:variable name="id" select="decl/@id"/>
82  <xsl:variable name="innertype_available">
83   <xsl:for-each select="$InnerTypes">
84    <xsl:if test="key('typeid',$id)/*">
85     <xsl:text>yes</xsl:text>
86    </xsl:if>
87   </xsl:for-each>
88  </xsl:variable>
89  <!--xsl:value-of select="concat('NL: ',$naturalLanguage,'  IA:  ',$innertype_available)"/-->
90  <xsl:choose>
91   <xsl:when test="$naturalLanguage='yes' and @sort='Prop' and $innertype_available='yes'">
92    <m:apply helm:xref="{decl/@id}">
93     <m:csymbol>proof</m:csymbol>
94     <xsl:apply-templates mode="proof_transform" select="."/>
95     <xsl:for-each select="$InnerTypes">
96      <xsl:apply-templates mode="pure" select="key('typeid',$id)/*"/>
97     </xsl:for-each>
98    </m:apply>
99   </xsl:when>
100   <xsl:otherwise>
101    <xsl:apply-templates select="." mode="pure"/>
102   </xsl:otherwise>
103  </xsl:choose>
104 </xsl:template>
105
106 <!-- ALL these elements have inner type -->
107 <xsl:template match="LETIN|CAST|APPLY|MUTCASE|FIX|COFIX" mode="noannot">
108  <xsl:variable name="id" select="@id"/>
109  <xsl:choose>
110   <xsl:when test="$naturalLanguage='yes' and @sort='Prop'">
111    <m:apply helm:xref="{@id}">
112     <m:csymbol>proof</m:csymbol>
113     <xsl:apply-templates mode="proof_transform" select="."/>
114     <xsl:for-each select="$InnerTypes">
115      <xsl:apply-templates mode="pure" select="key('typeid',$id)/*"/>
116     </xsl:for-each>
117    </m:apply>
118   </xsl:when>
119   <xsl:otherwise>
120    <xsl:choose>
121     <xsl:when test="name()='APPLY'">
122      <!-- This is the case of an applicative expression wich is not
123           a proof but could contains proofs...
124           MODE LETIN OR MODE PURE ??? Big question -->
125      <xsl:apply-templates select="." mode="pure"/>
126     </xsl:when>
127     <xsl:otherwise>
128      <xsl:apply-templates select="." mode="pure"/>
129     </xsl:otherwise>
130    </xsl:choose>
131   </xsl:otherwise>
132  </xsl:choose>
133 </xsl:template>
134
135 <!-- si presuppone che il tipo induttivo non sia mutuamente 
136      induttivo. Bisognerebbe andare a vedere l'ultimo parametro
137      del presunto "principio di induzione", tirare fuori il tipo induttivo
138      e vedere se il suo nome coincide con il prefisso di _ind. 
139      Ad esempio nat_double_ind e' definito dall'utente. L'ultimo
140      parametro di nat_double_ind e' di tipo nat, e nat e' diverso
141      da nat_double. Per ora, verifico solo l'esistenza di nat_double,
142      ma questo, benche' non porti ad errore, non copre tutti i
143      casi per quelli mutuamente induttivi -->
144
145 <xsl:template mode="try_inductive" match="APPLY">
146    <xsl:variable name="id" select="@id"/>
147    <xsl:choose>
148     <xsl:when test="CONST[1]">
149      <xsl:variable name="uri" select="CONST[1]/@uri"/>
150      <xsl:choose>
151       <xsl:when test="contains($uri,'_ind.con')">
152        <xsl:variable name="ind_uri" 
153          select="concat(substring-before($uri,'_ind.con'),'.ind')"/>
154        <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$ind_uri"/></xsl:call-template></xsl:variable>
155        <xsl:variable name="inductive_def" 
156      select="document($InductiveTypeUrl)/InductiveDefinition"/>
157        <!-- check if the corresponding inductive definition actually
158             exists -->
159        <xsl:choose>
160         <xsl:when test="$inductive_def">
161          <xsl:variable name="ind_name">
162           <xsl:call-template name="get_name">
163            <xsl:with-param name="uri" select="$uri"/>
164           </xsl:call-template>
165          </xsl:variable>
166          <xsl:variable name="no_params">
167           <xsl:call-template name="get_no_params">
168            <xsl:with-param name="first_uri" select="$CICURI"/>
169            <xsl:with-param name="second_uri" select="$uri"/>
170           </xsl:call-template>
171          </xsl:variable>
172          <xsl:apply-templates mode="inductive" select=".">
173           <xsl:with-param name="inductive_def_uri" 
174            select="$ind_uri"/>
175           <xsl:with-param name="inductive_def" 
176            select="$inductive_def"/>
177           <xsl:with-param name="section_params" select="$no_params"/>
178           <xsl:with-param name="inductive_def_index" select="1"/>
179           <xsl:with-param name="inductive_def_name" select="$ind_name"/>
180          </xsl:apply-templates>
181         </xsl:when>
182         <xsl:otherwise>
183          <xsl:apply-templates mode="letin" select="."/>
184         </xsl:otherwise>
185        </xsl:choose>
186       </xsl:when>
187       <xsl:otherwise>
188        <xsl:apply-templates mode="letin" select="."/>
189       </xsl:otherwise>
190      </xsl:choose>
191     </xsl:when>
192     <xsl:otherwise>
193      <xsl:apply-templates mode="letin" select="."/>
194     </xsl:otherwise>
195    </xsl:choose>
196 </xsl:template>
197
198 <xsl:template mode="eq_transitive" match="*">
199  <!-- <m:ci>eccomi-1: <xsl:value-of select="name()"/></m:ci> -->
200  <xsl:choose>
201   <xsl:when test="name()='APPLY'">
202    <!-- <m:ci>eccomi-2: <xsl:value-of select="CONST[1]/@uri"/></m:ci> -->
203    <xsl:variable name="id" select="@id"/>
204    <xsl:choose>
205     <!-- ricordarsi di trattare il parametro -->
206     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/CSetoids/eq_transitive_unfolded.con'] and count(child::*) = 7">
207      <!-- <m:ci>eccomi-3</m:ci> -->
208      <xsl:apply-templates mode="eq_transitive" select="*[6]"/>
209      <xsl:apply-templates mode="noannot" select="*[4]"/>
210      <xsl:apply-templates mode="eq_transitive" select="*[7]"/>
211     </xsl:when>
212     <xsl:otherwise>
213      <xsl:call-template name="generate_side_proof">
214       <xsl:with-param name="proof" select="."/>
215       <xsl:with-param name="show_statement" select="0"/>
216      </xsl:call-template> 
217     </xsl:otherwise>
218    </xsl:choose>
219   </xsl:when>
220   <xsl:otherwise>
221    <xsl:call-template name="generate_side_proof">
222     <xsl:with-param name="proof" select="."/>
223     <xsl:with-param name="show_statement" select="0"/>
224    </xsl:call-template>
225   </xsl:otherwise>
226  </xsl:choose>
227 </xsl:template>
228
229 <xsl:template mode="diseq" match="*">
230   <xsl:param name="rel" select="'eq'"/>
231   <xsl:choose>
232   <xsl:when test="name()='APPLY'">
233       <xsl:variable name="id" select="@id"/>
234    <xsl:choose>
235     <!-- ricordarsi di trattare il parametro -->
236     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_transitive.con'] and count(child::*) = 7">
237        <xsl:apply-templates mode="diseq" select="*[6]">
238         <xsl:with-param name="rel" select="'leq'"/>
239        </xsl:apply-templates>
240        <xsl:apply-templates mode="noannot" select="*[4]"/>
241        <xsl:apply-templates mode="diseq" select="*[7]">
242         <xsl:with-param name="rel" select="'leq'"/>
243        </xsl:apply-templates>
244     </xsl:when> 
245     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_wdl.con'] and count(child::*) = 7">
246        <m:eq/>
247        <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
248        <xsl:call-template name="generate_side_proof">
249         <xsl:with-param name="proof" select="*[7]"/>
250         <xsl:with-param name="show_statement" select="0"/>
251        </xsl:call-template>
252        <xsl:apply-templates mode="noannot" select="*[3]"/>
253        <xsl:apply-templates mode="diseq" select="*[6]">
254         <xsl:with-param name="rel" select="'leq'"/>
255        </xsl:apply-templates>
256     </xsl:when> 
257     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algerba/COrdFields/leEq_less_trans.con'] and count(child::*) = 7">
258        <xsl:apply-templates mode="diseq" select="*[6]">
259         <xsl:with-param name="rel" select="'leq'"/>
260        </xsl:apply-templates>
261        <xsl:apply-templates mode="noannot" select="*[4]"/>
262        <xsl:apply-templates mode="diseq" select="*[7]">
263         <xsl:with-param name="rel" select="'lt'"/>
264        </xsl:apply-templates>
265     </xsl:when>
266     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_leEq_trans.con'] and count(child::*) = 7">
267        <xsl:apply-templates mode="diseq" select="*[6]">
268         <xsl:with-param name="rel" select="'lt'"/>
269        </xsl:apply-templates>
270        <xsl:apply-templates mode="noannot" select="*[4]"/>
271        <xsl:apply-templates mode="diseq" select="*[7]">
272         <xsl:with-param name="rel" select="'leq'"/>
273        </xsl:apply-templates>
274     </xsl:when>  
275     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_wdr.con'] and count(child::*) = 7">
276        <xsl:apply-templates mode="diseq" select="*[6]">
277         <xsl:with-param name="rel" select="'leq'"/>
278        </xsl:apply-templates>
279        <xsl:apply-templates mode="noannot" select="*[4]"/>
280        <xsl:apply-templates mode="diseq" select="*[7]">
281         <xsl:with-param name="rel" select="'eq'"/>
282        </xsl:apply-templates>
283     </xsl:when>  
284     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_transitive_unfolded.con'] and count(child::*) = 7">
285       <xsl:apply-templates mode="diseq" select="*[6]">
286         <xsl:with-param name="rel" select="'lt'"/>
287        </xsl:apply-templates>
288        <xsl:apply-templates mode="noannot" select="*[4]"/>
289        <xsl:apply-templates mode="diseq" select="*[7]">
290         <xsl:with-param name="rel" select="'lt'"/>
291        </xsl:apply-templates>
292      </xsl:when> 
293     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_wdr.con'] and count(child::*) = 7">
294        <xsl:apply-templates mode="diseq" select="*[6]">
295         <xsl:with-param name="rel" select="'lt'"/>
296        </xsl:apply-templates>
297        <xsl:apply-templates mode="noannot" select="*[4]"/>
298        <xsl:apply-templates mode="diseq" select="*[7]">
299         <xsl:with-param name="rel" select="'eq'"/>
300        </xsl:apply-templates>
301      </xsl:when>
302     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_wdl.con'] and count(child::*) = 7">
303        <m:eq/>
304        <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
305        <xsl:call-template name="generate_side_proof">
306         <xsl:with-param name="proof" select="*[7]"/>
307         <xsl:with-param name="show_statement" select="0"/>
308        </xsl:call-template>
309        <xsl:apply-templates mode="noannot" select="*[3]"/>
310        <xsl:apply-templates mode="diseq" select="*[6]">
311         <xsl:with-param name="rel" select="'lt'"/>
312        </xsl:apply-templates>
313     </xsl:when> 
314     <!-- 
315     <xsl:when test="CONST[attribute::uri='cic:/Algebra/CSetoids/CSetoid_basics/eq_transitive_unfolded.con'] and count(child::*) = 7">
316      <xsl:apply-templates mode="diseq" select="*[6]"/>
317      <m:eq/>
318      <xsl:apply-templates mode="noannot" select="*[4]"/>
319      <m:eq/>
320      <xsl:apply-templates mode="diseq" select="*[7]"/>
321     </xsl:when> 
322     -->
323     <xsl:otherwise>
324      <xsl:element name="{concat('m:',$rel)}"/>
325      <!-- <m:ci><xsl:value-of select="$rel"/></m:ci> -->  
326      <xsl:call-template name="generate_side_proof">
327       <xsl:with-param name="proof" select="."/>
328       <xsl:with-param name="show_statement" select="0"/>
329      </xsl:call-template> 
330     </xsl:otherwise>
331    </xsl:choose>
332   </xsl:when>
333   <xsl:otherwise>
334    <xsl:element name="{concat('m:',$rel)}"/> 
335    <!-- <m:ci><xsl:value-of select="$rel"/></m:ci> --> 
336    <xsl:call-template name="generate_side_proof">
337     <xsl:with-param name="proof" select="."/>
338     <xsl:with-param name="show_statement" select="0"/>
339    </xsl:call-template>
340   </xsl:otherwise>
341  </xsl:choose>
342 </xsl:template>
343
344 <xsl:template mode="proof_transform" match="*">
345  <xsl:choose>
346   <xsl:when test="name()='APPLY'">
347    <xsl:variable name="id" select="@id"/>
348    <xsl:choose>
349     <!-- Algebra equality (eq_transitive_unfolded) -->
350     <!-- It requires a special mode "eq_transitive"-->
351     <!-- togliere il parametro -->
352     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/CSetoids/eq_transitive_unfolded.con'] and count(child::*) = 7">
353      <m:apply>
354        <m:csymbol>eq_chain</m:csymbol>
355        <xsl:apply-templates mode="noannot" select="*[3]"/>
356        <xsl:apply-templates mode="eq_transitive" select="*[6]"/>
357        <xsl:apply-templates mode="noannot" select="*[4]"/>
358        <xsl:apply-templates mode="eq_transitive" select="*[7]"/>
359        <xsl:apply-templates mode="noannot" select="*[5]"/>
360      </m:apply>
361     </xsl:when>
362     <!-- Algebra disequalities -->
363     <!-- It requires a special mode "diseq"-->
364     <!-- togliere il parametro -->
365     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_transitive.con'] and count(child::*) = 7">
366      <m:apply>
367        <m:csymbol>diseq_chain</m:csymbol>
368        <xsl:apply-templates mode="noannot" select="*[3]"/>
369        <xsl:apply-templates mode="diseq" select="*[6]">
370         <xsl:with-param name="rel" select="'leq'"/>
371        </xsl:apply-templates>
372        <xsl:apply-templates mode="noannot" select="*[4]"/>
373        <xsl:apply-templates mode="diseq" select="*[7]">
374         <xsl:with-param name="rel" select="'leq'"/>
375        </xsl:apply-templates>
376        <xsl:apply-templates mode="noannot" select="*[5]"/>
377      </m:apply>
378     </xsl:when> 
379      <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_wdl.con'] and count(child::*) = 7">
380      <m:apply>
381        <m:csymbol>diseq_chain</m:csymbol>
382        <xsl:apply-templates mode="noannot" select="*[5]"/>
383        <m:eq/>
384        <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
385        <xsl:call-template name="generate_side_proof">
386         <xsl:with-param name="proof" select="*[7]"/>
387         <xsl:with-param name="show_statement" select="0"/>
388        </xsl:call-template>
389        <xsl:apply-templates mode="noannot" select="*[3]"/>
390        <xsl:apply-templates mode="diseq" select="*[6]">
391         <xsl:with-param name="rel" select="'leq'"/>
392        </xsl:apply-templates>
393        <xsl:apply-templates mode="noannot" select="*[4]"/>
394      </m:apply>
395     </xsl:when>
396     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_less_trans.con'] and count(child::*) = 7">
397      <m:apply>
398        <m:csymbol>diseq_chain</m:csymbol>
399        <xsl:apply-templates mode="noannot" select="*[3]"/>
400        <xsl:apply-templates mode="diseq" select="*[6]">
401         <xsl:with-param name="rel" select="'leq'"/>
402        </xsl:apply-templates>
403        <xsl:apply-templates mode="noannot" select="*[4]"/>
404        <xsl:apply-templates mode="diseq" select="*[7]">
405         <xsl:with-param name="rel" select="'lt'"/>
406        </xsl:apply-templates>
407        <xsl:apply-templates mode="noannot" select="*[5]"/>
408      </m:apply>
409     </xsl:when> 
410     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_leEq_trans.con'] and count(child::*) = 7">
411      <m:apply>
412        <m:csymbol>diseq_chain</m:csymbol>
413        <xsl:apply-templates mode="noannot" select="*[3]"/>
414        <xsl:apply-templates mode="diseq" select="*[6]">
415         <xsl:with-param name="rel" select="'lt'"/>
416        </xsl:apply-templates>
417        <xsl:apply-templates mode="noannot" select="*[4]"/>
418        <xsl:apply-templates mode="diseq" select="*[7]">
419         <xsl:with-param name="rel" select="'leq'"/>
420        </xsl:apply-templates>
421        <xsl:apply-templates mode="noannot" select="*[5]"/>
422      </m:apply>
423     </xsl:when>  
424     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/leEq_wdr.con'] and count(child::*) = 7">
425      <m:apply>
426        <m:csymbol>diseq_chain</m:csymbol>
427        <xsl:apply-templates mode="noannot" select="*[3]"/>
428        <xsl:apply-templates mode="diseq" select="*[6]">
429         <xsl:with-param name="rel" select="'leq'"/>
430        </xsl:apply-templates>
431        <xsl:apply-templates mode="noannot" select="*[4]"/>
432        <xsl:apply-templates mode="diseq" select="*[7]">
433         <xsl:with-param name="rel" select="'eq'"/>
434        </xsl:apply-templates>
435        <xsl:apply-templates mode="noannot" select="*[5]"/>
436      </m:apply>
437     </xsl:when>  
438     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_transitive_unfolded.con'] and count(child::*) = 7">
439      <m:apply>
440        <m:csymbol>diseq_chain</m:csymbol>
441        <xsl:apply-templates mode="noannot" select="*[3]"/>
442        <xsl:apply-templates mode="diseq" select="*[6]">
443         <xsl:with-param name="rel" select="'lt'"/>
444        </xsl:apply-templates>
445        <xsl:apply-templates mode="noannot" select="*[4]"/>
446        <xsl:apply-templates mode="diseq" select="*[7]">
447         <xsl:with-param name="rel" select="'lt'"/>
448        </xsl:apply-templates>
449        <xsl:apply-templates mode="noannot" select="*[5]"/>
450      </m:apply>
451     </xsl:when>  
452     <!-- togliere il parametro -->
453     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_wdr.con'] and count(child::*) = 7">
454      <m:apply>
455        <m:csymbol>diseq_chain</m:csymbol>
456        <xsl:apply-templates mode="noannot" select="*[3]"/>
457        <xsl:apply-templates mode="diseq" select="*[6]">
458         <xsl:with-param name="rel" select="'lt'"/>
459        </xsl:apply-templates>
460        <xsl:apply-templates mode="noannot" select="*[4]"/>
461        <xsl:apply-templates mode="diseq" select="*[7]">
462         <xsl:with-param name="rel" select="'eq'"/>
463        </xsl:apply-templates>
464        <xsl:apply-templates mode="noannot" select="*[5]"/>
465      </m:apply>
466     </xsl:when>
467     <!-- togliere il parametro -->
468     <xsl:when test="CONST[attribute::uri='cic:/Algebra/algebra/COrdFields/less_wdl.con'] and count(child::*) = 7">
469      <m:apply>
470        <m:csymbol>diseq_chain</m:csymbol>
471        <xsl:apply-templates mode="noannot" select="*[5]"/>
472        <m:eq/>
473        <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
474        <xsl:call-template name="generate_side_proof">
475         <xsl:with-param name="proof" select="*[7]"/>
476         <xsl:with-param name="show_statement" select="0"/>
477        </xsl:call-template>
478        <xsl:apply-templates mode="noannot" select="*[3]"/>
479        <xsl:apply-templates mode="diseq" select="*[6]">
480         <xsl:with-param name="rel" select="'lt'"/>
481        </xsl:apply-templates>
482        <xsl:apply-templates mode="noannot" select="*[4]"/>
483      </m:apply>
484     </xsl:when> 
485     <!-- EQUALITY -->
486     <xsl:when test="CONST[
487  attribute::uri='cic:/Coq/Init/Logic/eq_ind.con' or
488  attribute::uri='cic:/Coq/Init/Logic/eq_ind_r.con' or
489  attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
490  attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind_r.con' or
491  attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
492       <m:apply>
493        <m:csymbol>rw_step</m:csymbol>
494        <xsl:apply-templates mode="noannot" select="*[5]"/>
495        <xsl:apply-templates mode="pure" select="*[3]"/>
496        <xsl:apply-templates mode="pure" select="*[6]"/>
497        <xsl:call-template name="generate_side_proof">
498         <xsl:with-param name="proof" select="*[7]"/>
499        </xsl:call-template>
500        <!-- <xsl:apply-templates mode="proof_transform" select="*[7]"/> -->
501       </m:apply>
502     </xsl:when>
503     <!-- EQUALITY with extra-parameters -->
504     <xsl:when test="CONST[
505  attribute::uri='cic:/Coq/Init/Logic/eq_ind.con' or
506  attribute::uri='cic:/Coq/Init/Logic/eq_ind_r.con' or
507  attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
508  attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind_r.con' or
509  attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) > 7">
510       <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')])"/>      
511       <xsl:choose>
512        <xsl:when test="$no_extraproofs=0"> 
513         <m:apply>
514          <m:csymbol>rewrite_and_apply</m:csymbol>
515          <m:apply>
516           <m:csymbol>rw_step</m:csymbol>
517           <xsl:apply-templates mode="noannot" select="*[5]"/>
518           <xsl:apply-templates mode="pure" select="*[3]"/>
519           <xsl:apply-templates mode="pure" select="*[6]"/>
520           <xsl:call-template name="generate_side_proof">
521            <xsl:with-param name="proof" select="*[7]"/>
522            </xsl:call-template>
523           <!-- <xsl:apply-templates mode="pure" select="*[7]"/> -->
524          </m:apply>
525          <xsl:apply-templates mode="noannot" select="*[position()>7]"/>
526         </m:apply>
527        </xsl:when>
528        <xsl:otherwise>
529         <xsl:choose>
530          <xsl:when test="*[5]/@sort='Prop'">
531           <m:apply helm:xref="{@id}">
532            <m:csymbol>letin</m:csymbol>
533            <m:apply>
534             <m:csymbol>let</m:csymbol>
535             <m:ci>
536              <xsl:call-template name="insert_subscript">
537               <xsl:with-param name="node_value" select="'h1'"/>
538              </xsl:call-template>
539             </m:ci>
540             <xsl:apply-templates mode="noannot" select="*[5]"/>
541            </m:apply>
542            <xsl:call-template name="gen_let">
543             <xsl:with-param name="init_pos" select="1"/>
544             <xsl:with-param name="from" select="7"/>
545            </xsl:call-template>
546            <m:apply>
547             <m:csymbol>rewrite_and_apply</m:csymbol>
548             <m:apply>
549              <m:csymbol>rw_step</m:csymbol>
550              <m:ci>
551               <xsl:call-template name="insert_subscript">
552                <xsl:with-param name="node_value" select="'h1'"/>
553               </xsl:call-template>
554              </m:ci>
555              <xsl:apply-templates mode="pure" select="*[3]"/>
556              <xsl:apply-templates mode="pure" select="*[6]"/>
557              <xsl:call-template name="generate_side_proof">
558               <xsl:with-param name="proof" select="*[7]"/>
559              </xsl:call-template>
560              <!-- <xsl:apply-templates mode="pure" select="*[7]"/> -->
561             </m:apply>
562             <xsl:apply-templates mode="flat" select="*[8]">
563              <xsl:with-param name="n">
564               <xsl:value-of select="2"/>
565              </xsl:with-param>
566             </xsl:apply-templates>
567            </m:apply>
568           </m:apply>
569          </xsl:when>
570          <xsl:otherwise>
571           <m:apply helm:xref="{@id}">
572            <m:csymbol>letin</m:csymbol>
573            <xsl:call-template name="gen_let">
574             <xsl:with-param name="init_pos" select="0"/>
575             <xsl:with-param name="form" select="7"/>
576            </xsl:call-template>
577            <m:apply>
578             <m:csymbol>rewrite_and_apply</m:csymbol>
579             <m:apply>
580              <m:csymbol>rw_step</m:csymbol>
581              <xsl:apply-templates mode="pure" select="*[5]"/>
582              <xsl:apply-templates mode="pure" select="*[3]"/>
583              <xsl:apply-templates mode="pure" select="*[6]"/>             
584              <xsl:call-template name="generate_side_proof">
585               <xsl:with-param name="proof" select="*[7]"/>
586              </xsl:call-template>
587              <!-- <xsl:apply-templates mode="pure" select="*[7]"/> -->
588             </m:apply>
589             <xsl:apply-templates mode="flat" select="*[8]">
590              <xsl:with-param name="n">
591               <xsl:value-of select="1"/>
592              </xsl:with-param>
593             </xsl:apply-templates>
594            </m:apply>
595           </m:apply>
596          </xsl:otherwise>
597         </xsl:choose>
598        </xsl:otherwise>
599       </xsl:choose>
600     </xsl:when>
601     <!-- False_ind -->
602     <xsl:when test="CONST[
603      attribute::uri='cic:/Coq/Init/Logic/False_ind.con'] and 
604      count(child::*) = 3">
605      <m:apply helm:xref="{@id}">
606        <m:csymbol>false_ind</m:csymbol>
607        <m:ci>cic:/Coq/Init/Logic/False_ind.con</m:ci>
608        <xsl:apply-templates mode="noannot" select="*[3]"/>
609      </m:apply>
610     </xsl:when>
611     <!-- gestire meglio il caso di and_ind quando la prova 
612          non e' della forma \x.\y.M -->
613     <xsl:when test="CONST[
614  attribute::uri='cic:/Coq/Init/Logic/and_ind.con'] 
615  and count(child::*) = 6 
616  and name(*[5])='LAMBDA'"> 
617       <m:apply helm:xref="{@id}">
618        <m:csymbol>and_ind</m:csymbol>
619        <xsl:apply-templates mode="noannot" select="*[6]"/>
620        <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/*[1]/@binder"/></xsl:with-param></xsl:call-template></m:ci>
621        <xsl:apply-templates mode="pure" select="*[5]/*[1]/*"/>
622        <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/*[2]/@binder"/></xsl:with-param></xsl:call-template></m:ci>
623        <xsl:apply-templates mode="pure" select="*[5]/*[2]/*"/>
624        <xsl:apply-templates mode="proof_transform" select="*[5]/target/*"/> 
625       </m:apply>
626     </xsl:when>
627     <xsl:when test="CONST[
628  attribute::uri='cic:/Coq/Init/Logic/or_ind.con'] 
629  and count(child::*) = 7">
630       <xsl:choose>
631        <xsl:when test="name(*[5])='LAMBDA' 
632                  and name(*[6])='LAMBDA'">
633         <xsl:variable name="definition_url" 
634             select="'cic:/Coq/Init/Logic/or.ind'"/>
635         <m:apply helm:xref="{@id}">
636          <m:csymbol>full_or_ind</m:csymbol>
637          <xsl:apply-templates mode="noannot" select="*[7]"/>
638          <xsl:for-each select="$InnerTypes">
639           <xsl:apply-templates mode="pure" select="key('typeid',$id)/*[1]"/>
640          </xsl:for-each>
641          <m:apply>
642           <m:csymbol>left_case</m:csymbol>
643           <m:bvar>
644            <m:ci>
645             <xsl:value-of select="*[5]/*[1]/@binder"/>
646            </m:ci>
647            <m:type>
648             <xsl:apply-templates mode="pure" select="*[5]/*[1]/*[1]"/>
649            </m:type>
650           </m:bvar>
651           <xsl:apply-templates mode="noannot" select="*[5]/target/*[1]"/>
652          </m:apply>
653          <m:apply>
654           <m:csymbol>right_case</m:csymbol>
655           <m:bvar>
656            <m:ci>
657             <xsl:apply-templates mode="pure" select="*[6]/*[1]/@binder"/>
658            </m:ci>
659            <m:type>
660             <xsl:apply-templates mode="pure" select="*[6]/*[1]/*[1]"/>
661            </m:type>
662           </m:bvar>
663           <xsl:apply-templates mode="noannot" select="*[6]/target/*[1]"/>
664          </m:apply>
665         </m:apply>
666        </xsl:when>
667        <xsl:otherwise>
668         <m:apply helm:xref="{@id}">
669          <m:csymbol>or_ind</m:csymbol>
670          <xsl:apply-templates mode="noannot" select="*[7]"/>
671          <xsl:for-each select="$InnerTypes">
672           <xsl:apply-templates mode="pure" select="key('typeid',$id)/*[1]"/>
673          </xsl:for-each>
674          <xsl:apply-templates mode="pure" select="*[5]"/>
675          <xsl:apply-templates mode="pure" select="*[6]"/>
676         </m:apply>
677        </xsl:otherwise>
678       </xsl:choose>
679     </xsl:when>
680     <!-- ex_ind, exT_ind -->
681       <xsl:when test="(CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
682       CONST[attribute::uri='cic:/Coq/Init/Logic/ex_ind.con'])  
683  and count(child::*) = 6 
684  and name(*[5])='LAMBDA' 
685  and name(*[5]/*[2])='decl'"> 
686       <m:apply helm:xref="{@id}">
687        <m:csymbol>ex_ind</m:csymbol>
688        <xsl:apply-templates mode="noannot" select="*[6]"/>
689        <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/*[1]/@binder"/></xsl:with-param></xsl:call-template></m:ci>
690        <xsl:apply-templates mode="pure" select="*[5]/*[1]/*"/>
691        <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[5]/*[2]/@binder"/></xsl:with-param></xsl:call-template></m:ci>
692        <xsl:apply-templates mode="pure" select="*[5]/*[2]/*"/>
693        <xsl:apply-templates mode="proof_transform" select="*[5]/target/*"/>
694       </m:apply>
695     </xsl:when>
696     <xsl:when test="name(*[1])='CONST'">
697      <xsl:apply-templates mode="try_inductive" select="."/>
698     </xsl:when>
699     <!-- patch temporanea per la gestione di redex -->
700     <xsl:when test="name(*[1])='LAMBDA' and count(child::*)=2
701          and *[2]/@sort='Prop'">
702      <m:apply helm:xref="{@id}">
703       <m:csymbol>letin</m:csymbol>
704       <m:apply>
705        <m:csymbol>let</m:csymbol>
706        <m:ci>
707         <xsl:call-template name="insert_subscript">
708          <xsl:with-param name="node_value">
709           <xsl:value-of select="*[1]/*[1]/@binder"/>
710          </xsl:with-param>
711         </xsl:call-template>
712        </m:ci>
713        <xsl:apply-templates mode="noannot" select="*[2]"/>
714       </m:apply>
715       <xsl:apply-templates mode="proof_transform" select="*[1]/target/*[1]"/>
716      </m:apply>
717     </xsl:when>
718     <xsl:otherwise>
719      <xsl:apply-templates select="." mode="letin"/>
720     </xsl:otherwise>
721    </xsl:choose>
722   </xsl:when>
723   <xsl:when test="name()='LAMBDA'">
724    <xsl:choose>
725      <xsl:when test="(name(target/*[1])='APPLY'  and
726       name(target/*[1]/*[1])='CONST' and
727       (target/*[1]/*[1]/@uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
728        target/*[1]/*[1]/@uri='cic:/Coq/Init/Logic_Type/eqT_ind_r.con' or
729        target/*[1]/*[1]/@uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con')
730       and count(target/*[1]/*) = 8 
731       and name(target/*[1]/*[8])='REL'
732       and target/@binder = target/*[1]/*[8]/@binder )"> 
733       <m:apply>
734        <m:csymbol>rw_step</m:csymbol>
735        <xsl:apply-templates mode="noannot" select="target/*[1]/*[5]"/>
736        <xsl:apply-templates mode="pure" select="target/*[1]/*[3]"/>
737        <xsl:apply-templates mode="pure" select="target/*[1]/*[6]"/>
738        <xsl:call-template name="generate_side_proof">
739         <xsl:with-param name="proof" select="target/*[1]/*[7]"/>
740        </xsl:call-template>
741        <!-- <xsl:apply-templates mode="proof_transform" select="target/*[1]/*[7]"/> -->
742       </m:apply>
743      </xsl:when>
744      <xsl:otherwise>
745       <xsl:apply-templates mode="pure" select="."/>
746      </xsl:otherwise>
747     </xsl:choose>
748    </xsl:when>
749   <xsl:otherwise>
750    <xsl:apply-templates select="." mode="pure"/>
751   </xsl:otherwise>
752  </xsl:choose>
753 </xsl:template>
754
755 <xsl:template name="is_simple">
756  <xsl:param name="proof" select="/.."/>
757  <xsl:value-of select="(count($proof/*)=0) or ((name($proof)='APPLY') and (count($proof/*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]) = 0))"/>
758 </xsl:template>
759
760 <xsl:template name="generate_side_proof">
761  <xsl:param name="proof" select="/.."/>
762  <xsl:param name="show_statement" select="1"/>
763 <!-- 
764  <xsl:variable name="is_simple">
765   <xsl:call-template name="is_simple">
766    <xsl:with-param name="proof" select="$proof"/>
767   </xsl:call-template>
768  </xsl:variable> -->
769 <xsl:variable name="is_simple" select="(count($proof/*)=0) or ((name($proof)='APPLY') and (count($proof/*[@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')]) = 0))"/>
770  <xsl:choose>
771   <xsl:when test="$is_simple">
772    <xsl:choose>
773     <xsl:when test="name($proof)='APPLY'">
774      <xsl:apply-templates select="$proof" mode="letin"/>
775     </xsl:when>
776     <xsl:otherwise>
777      <xsl:apply-templates select="$proof" mode="pure"/>
778     </xsl:otherwise>
779    </xsl:choose>
780   </xsl:when>
781   <xsl:otherwise>
782    <xsl:variable name="id" select="@id"/>
783    <m:apply helm:xref="{@id}">
784     <xsl:choose>
785      <xsl:when test="$show_statement = 1">
786       <m:csymbol>proof</m:csymbol>
787      </xsl:when>
788      <xsl:otherwise>
789       <m:csymbol>side_proof</m:csymbol>
790      </xsl:otherwise>
791     </xsl:choose>
792     <xsl:apply-templates mode="proof_transform" select="$proof"/>
793     <xsl:for-each select="$InnerTypes">
794      <xsl:apply-templates mode="pure" select="key('typeid',$proof/@id)/*"/>
795     </xsl:for-each>
796    </m:apply>
797    <!-- <xsl:apply-templates select="$proof" mode="noannot"/> -->
798   </xsl:otherwise>
799  </xsl:choose>
800 </xsl:template>
801
802 <xsl:template match="APPLY" mode="letin">
803    <xsl:variable name="no_subproofs">
804     <xsl:variable name="stars">
805      <xsl:for-each select="*[@sort='Prop']">
806       <xsl:variable name="id" select="@id"/>
807       <xsl:variable name="innertype_available">
808        <xsl:for-each select="$InnerTypes">
809         <xsl:if test="key('typeid',$id)/*">
810          <xsl:text>yes</xsl:text>
811         </xsl:if>
812        </xsl:for-each>
813       </xsl:variable>
814       <xsl:if test="name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX' or ((name(.)='REL' or name(.)='VAR' or name(.)='META' or name(.)='CONST' or name(.)='MUTCONSTRUCT') and $innertype_available='yes')">
815        <!-- We generate one star for each subproof -->
816        <xsl:text>*</xsl:text>
817       </xsl:if>
818      </xsl:for-each>
819     </xsl:variable>
820     <xsl:value-of select="string-length($stars)"/>
821    </xsl:variable>
822    <!-- <m:cn><xsl:value-of select="$no_subproofs"/></m:cn> -->
823    <xsl:choose>
824     <xsl:when test="$naturalLanguage='yes' and ($no_subproofs = 1)">
825      <m:apply helm:xref="{@id}">
826       <m:csymbol>letin1</m:csymbol>
827       <xsl:for-each select="*[@sort='Prop']">
828        <xsl:variable name="id" select="@id"/>
829        <xsl:variable name="innertype_available">
830         <xsl:for-each select="$InnerTypes">
831          <xsl:if test="key('typeid',$id)/*">
832           <xsl:text>yes</xsl:text>
833          </xsl:if>
834         </xsl:for-each>
835        </xsl:variable>
836        <xsl:if test="name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX' or ((name(.)='REL' or name(.)='VAR' or name(.)='META' or name(.)='CONST' or name(.)='MUTCONSTRUCT') and $innertype_available='yes')">
837         <xsl:apply-templates mode="noannot" select="."/>
838        </xsl:if>
839       </xsl:for-each>
840       <!-- now re-process the application -->
841       <m:apply helm:xref="{@id}">
842        <m:csymbol>app</m:csymbol>
843        <!-- mode previous looks for siblings: 
844             call with the first child -->
845        <xsl:apply-templates mode="previous" select="*[1]"/>
846       </m:apply>
847      </m:apply>
848     </xsl:when>
849     <xsl:when test="$naturalLanguage='yes' and ($no_subproofs > 1)">
850      <m:apply helm:xref="{@id}">
851       <m:csymbol>letin</m:csymbol>
852       <!-- first process all subproofs (let-in) -->
853       <xsl:call-template name="gen_let"/>
854       <!-- now re-process the application  -->
855       <m:apply helm:xref="{@id}">
856        <m:csymbol>app</m:csymbol>
857        <!-- mode flat looks for siblings: call with the first child -->
858        <xsl:apply-templates mode="flat" select="*[1]"/>
859       </m:apply>
860      </m:apply>
861     </xsl:when>
862     <xsl:otherwise>
863      <xsl:choose>
864      <xsl:when test="@sort='Prop'">
865       <m:apply>
866        <m:csymbol>app</m:csymbol>
867        <xsl:apply-templates mode="erase" select="*[1]"/>
868       </m:apply>
869      </xsl:when>
870      <xsl:otherwise>
871       <xsl:apply-templates mode="pure" select="."/>
872      </xsl:otherwise>
873      </xsl:choose>
874     </xsl:otherwise>
875    </xsl:choose>
876 </xsl:template>
877
878 <xsl:template name="gen_let">
879  <xsl:param name="init_pos" select="0"/>
880  <xsl:param name="from" select="0"/>
881       <xsl:for-each select="*[position()>$from and @sort='Prop']">
882        <xsl:variable name="id" select="@id"/>
883        <xsl:variable name="innertype_available">
884         <xsl:for-each select="$InnerTypes">
885          <xsl:if test="key('typeid',$id)/*">
886           <xsl:text>yes</xsl:text>
887          </xsl:if>
888         </xsl:for-each>
889        </xsl:variable>
890        <xsl:if test="name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX' or ((name(.)='REL' or name(.)='VAR' or name(.)='META' or name(.)='CONST' or name(.)='MUTCONSTRUCT') and $innertype_available='yes')">
891         <m:apply>
892          <m:csymbol>let</m:csymbol>
893          <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>
894          <xsl:apply-templates mode="noannot" select="."/>
895         </m:apply>
896        </xsl:if>
897       </xsl:for-each>
898 </xsl:template>
899
900 <xsl:template match="*" mode="erase">
901   <xsl:choose>
902    <xsl:when test="@sort='Prop' or $naturalLanguage='no'">
903     <xsl:apply-templates mode="pure" select="."/>
904    </xsl:when>
905    <xsl:otherwise>
906     <m:ci>.</m:ci>
907    </xsl:otherwise>
908    </xsl:choose>
909  <xsl:apply-templates mode="erase" select="following-sibling::*[1]"/>
910 </xsl:template>
911
912 <xsl:template match="*" mode="previous">
913  <xsl:variable name="innertype_available">
914   <xsl:variable name="id" select="@id"/>
915   <xsl:for-each select="$InnerTypes">
916    <xsl:if test="key('typeid',$id)/*">
917     <xsl:text>yes</xsl:text>
918    </xsl:if>
919   </xsl:for-each>
920  </xsl:variable>
921  <xsl:choose>
922   <xsl:when test="@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX' or ((name(.)='REL' or name(.)='VAR' or name(.)='META' or name(.)='CONST' or name(.)='MUTCONSTRUCT') and $innertype_available='yes'))">
923    <m:ci>previous</m:ci>
924   </xsl:when>
925   <xsl:otherwise>
926    <!-- forse bisognerebbe trattare solo l'elemento di testa -->
927    <xsl:choose>
928    <xsl:when test="@sort='Prop' or $naturalLanguage='no'">
929     <xsl:apply-templates mode="pure" select="."/>
930    </xsl:when>
931    <xsl:otherwise>
932     <m:ci>.</m:ci>
933    </xsl:otherwise>
934    </xsl:choose>
935    <!-- <xsl:apply-templates select="." mode="pure"/> -->
936   </xsl:otherwise>
937  </xsl:choose>
938  <xsl:apply-templates mode="previous" select="following-sibling::*[1]"/>
939 </xsl:template>
940
941 <xsl:template match="*" mode="flat">
942  <xsl:param name="n" select="1"/>
943  <xsl:variable name="id" select="@id"/>
944  <xsl:variable name="innertype_available">
945   <xsl:for-each select="$InnerTypes">
946    <xsl:if test="key('typeid',$id)/*">
947     <xsl:text>yes</xsl:text>
948    </xsl:if>
949   </xsl:for-each>
950  </xsl:variable>
951  <xsl:choose>
952   <xsl:when test="$naturalLanguage='yes' and @sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX' or ((name(.)='REL' or name(.)='VAR' or name(.)='META' or name(.)='CONST' or name(.)='MUTCONSTRUCT') and $innertype_available='yes'))">
953    <m:ci>
954     <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>
955    </m:ci>
956    <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
957     <xsl:with-param name="n" select="$n+1"/>
958    </xsl:apply-templates>
959   </xsl:when>
960   <xsl:otherwise>
961    <xsl:choose>
962     <xsl:when test="name()='REL' or @sort='Prop' or $naturalLanguage='no'">
963      <xsl:apply-templates mode="pure" select="."/>
964     </xsl:when>
965     <xsl:otherwise>
966      <m:ci>.</m:ci>
967     </xsl:otherwise>
968    </xsl:choose>
969    <!-- <xsl:apply-templates mode="pure" select="."/> -->
970    <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
971     <xsl:with-param name="n" select="$n"/>
972    </xsl:apply-templates>
973   </xsl:otherwise>
974  </xsl:choose>
975 </xsl:template>
976
977 <!-- Auxiliary functions -->
978 <!-- OMDOC: now we have name_of_uri generalized on the extension that -->
979 <!-- can replace the next template                                    -->
980 <xsl:template name="get_name">
981  <xsl:param name="uri" select="''"/>
982  <xsl:variable name="sub_after" select="substring-after($uri,'/')"/>
983  <xsl:choose>
984   <xsl:when test="contains($sub_after,'/')">
985    <xsl:call-template name="get_name">
986     <xsl:with-param name="uri" select="$sub_after"/>
987    </xsl:call-template>
988   </xsl:when>
989   <xsl:otherwise>
990    <xsl:value-of select="substring-before($sub_after,'_ind.con')"/>
991   </xsl:otherwise>
992  </xsl:choose>
993 </xsl:template>
994
995 <!-- <xsl:template match="APPLY[CONST[
996  attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']]" mode="appflat">
997     <xsl:choose>
998      <xsl:when test="count(child::*) > 4">
999       <m:apply helm:xref="{@id}">
1000        <m:csymbol>app</m:csymbol>
1001        <xsl:apply-templates mode="pure" select="*[1]"/>
1002        <m:ci>*</m:ci>
1003        <m:ci>*</m:ci>
1004        <m:ci>*</m:ci>
1005        <xsl:apply-templates mode="flat" select="*[5]"/>
1006       </m:apply>
1007      </xsl:when>
1008      <xsl:otherwise>
1009       <m:apply helm:xref="{@id}">
1010        <m:csymbol>app</m:csymbol>
1011        <xsl:apply-templates mode="flat" select="*[1]"/>
1012       </m:apply>
1013      </xsl:otherwise>
1014     </xsl:choose>
1015 </xsl:template>  -->
1016
1017
1018 </xsl:stylesheet>