-<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX" mode="noannot">
- <xsl:choose>
- <xsl:when test="@id">
- <xsl:variable name="id" select="@id"/>
- <xsl:choose>
- <!-- <xsl:when test="//ALLTYPES and key('typeid',@id)"> -->
- <xsl:when test="//ALLTYPES/TYPE[@id=$id]">
- <xsl:choose>
- <xsl:when test="name()= 'APPLY' and CONST[
- attribute::uri='cic:/coq/INIT/Logic_Type/eqT_ind.con' or
- attribute::uri='cic:/coq/ZARITH/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
- <m:apply helm:xref="{@id}">
- <m:csymbol>thread</m:csymbol>
- <xsl:apply-templates mode="pure" select="//ALLTYPES/TYPE[@id=$id]"/>
- <m:apply>
- <m:csymbol>rw_step</m:csymbol>
- <xsl:apply-templates mode="pure" select="*[3]"/>
- <xsl:apply-templates mode="pure" select="*[6]"/>
- <xsl:apply-templates mode="pure" select="*[7]"/>
- </m:apply>
- <xsl:apply-templates mode="thread" select="*[5]"/>
- </m:apply>
- </xsl:when>
- <!-- aggiungere la verifica dell'esistenza dei lambda per and_ind -->
- <xsl:when test="name()= 'APPLY' and CONST[
- attribute::uri='cic:/coq/INIT/Logic/Conjunction/and_ind.con']
+<!-- ALL this elements does not have inner type -->
+<xsl:template match="LETIN|PROD|REL|SORT|VAR|META|CONST|MUTIND|MUTCONSTRUCT" mode="noannot">
+<xsl:apply-templates select="." mode="pure"/>
+</xsl:template>
+
+<!-- LAMBDA has inner type only if it is not nested inside another lambda -->
+<xsl:template match="LAMBDA" mode="noannot">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:choose>
+ <xsl:when test="//InnerTypes and @sort='Prop' and name(../..) != 'LAMBDA'">
+ <!-- <xsl:when test="@sort='Prop' and //InnerTypes/TYPE[@of=$id]"> -->
+ <xsl:call-template name="has_inner_type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- ALL this elements have inner type -->
+<xsl:template match="CAST|APPLY|MUTCASE|FIX|COFIX" mode="noannot">
+ <xsl:choose>
+ <!-- <xsl:when test="//InnerTypes and key('typeid',@id)"> -->
+ <!-- <xsl:when test="//InnerTypes/TYPE[@of=$id]"> -->
+ <xsl:when test="//InnerTypes and @sort='Prop'">
+ <xsl:call-template name="has_inner_type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="has_inner_type">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:choose>
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
+ attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con'] and count(child::*) = 7">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>thread</m:csymbol>
+ <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[3]"/>
+ <xsl:apply-templates mode="pure" select="*[6]"/>
+ <xsl:apply-templates mode="pure" select="*[7]"/>
+ </m:apply>
+ <xsl:apply-templates mode="thread" select="*[5]"/>
+ </m:apply>
+ </xsl:when>
+ <!-- aggiungere la verifica dell'esistenza dei lambda per and_ind -->
+ <xsl:when test="name()= 'APPLY' and CONST[
+ attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']