</m:mtr>
</m:mtable>
</xsl:when>
+ <xsl:when test="$name='letin1'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="*[2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="*[3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
<xsl:when test="$name='letin'">
<m:mtable align="baseline 1" equalrows="false" columnalign="left">
<!-- <xsl:for-each select="APPLY[m:csymbol and (string(m:csymbol)='let')]"> -->
<m:mtext>) </m:mtext>
<xsl:apply-templates select="*[3]"/>
</xsl:when>
- <xsl:when test="$name='thread'">
+ <xsl:when test="$name='rw_step'">
<m:mtable align="baseline 1" equalrows="false" columnalign="left">
<m:mtr>
<m:mtd>
<m:mrow>
<xsl:choose>
- <xsl:when test="name(*[last()])='m:apply'">
- <xsl:apply-templates select="*[last()]"/>
+ <xsl:when test="name(*[2])='m:apply'">
+ <xsl:apply-templates select="*[2]"/>
</xsl:when>
<xsl:otherwise>
- <m:mtext>Consider </m:mtext>
- <xsl:apply-templates select="*[last()]"/>
+ <m:mtext>Consider</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[2]"/>
</xsl:otherwise>
</xsl:choose>
</m:mrow>
</m:mtd>
</m:mtr>
- <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
- </m:mtable>
- </xsl:when>
- <xsl:when test="$name='rewrite_and_apply'">
- <m:mtable>
<m:mtr>
<m:mtd>
<m:mrow>
<m:mtext>Rewrite</m:mtext>
<m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <xsl:apply-templates select="*[2]/*[2]"/>
+ <xsl:apply-templates select="*[3]"/>
<m:mphantom><m:mtext>_</m:mtext></m:mphantom>
<m:mtext>with</m:mtext>
<m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <xsl:apply-templates select="*[2]/*[3]"/>
+ <xsl:apply-templates select="*[4]"/>
<m:mphantom><m:mtext>_</m:mtext></m:mphantom>
<m:mtext>by</m:mtext>
<m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <xsl:apply-templates select="*[2]/*[4]"/>
- <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <m:mtext>in</m:mtext>
- <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <xsl:apply-templates select="*[3]"/>
- <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <m:mtext>and apply to</m:mtext>
+ <xsl:apply-templates select="*[5]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <xsl:when test="$name='thread'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:choose>
+ <xsl:when test="name(*[last()])='m:apply'">
+ <xsl:apply-templates select="*[last()]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mtext>Consider</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
+ <xsl:apply-templates select="*[last()]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <xsl:apply-templates mode="thread" select="*[(last()-2)]"/>
+ </m:mtable>
+ </xsl:when>
+ <xsl:when test="$name='rewrite_and_apply'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <xsl:apply-templates select="*[2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>Then apply it to</m:mtext>
<m:mphantom><m:mtext>_</m:mtext></m:mphantom>
- <xsl:apply-templates select="*[position()>3]"/>
+ <xsl:apply-templates select="*[position()>2]"/>
</m:mrow>
</m:mtd>
</m:mtr>
</m:mtable>
- </xsl:when>
+ </xsl:when>
+ <!-- NAT_IND -->
+ <xsl:when test="$name='nat_ind'">
+ <m:mtable align="baseline 1" equalrows="false" columnalign="left">
+ <m:mtr>
+ <m:mtd>
+ <m:mtext>By induction</m:mtext>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>base case:</m:mtext>
+ <xsl:apply-templates select="*[2]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ <m:mtr>
+ <m:mtd>
+ <m:mrow>
+ <m:mtext>inductive case:</m:mtext>
+ <xsl:apply-templates select="*[3]"/>
+ </m:mrow>
+ </m:mtd>
+ </m:mtr>
+ </m:mtable>
+ </xsl:when>
+ <!-- AND_IND -->
<xsl:when test="$name='and_ind'">
<m:mtable align="baseline 1" equalrows="false" columnalign="left">
<m:mtr>
<xsl:apply-templates select="*[2]"/>
</xsl:when>
<xsl:otherwise>
- <m:mtext>Consider </m:mtext>
+ <m:mtext>Consider</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
<xsl:apply-templates select="*[2]"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="*[2]"/>
</xsl:when>
<xsl:otherwise>
- <m:mtext>Consider </m:mtext>
+ <m:mtext>Consider</m:mtext>
+ <m:mphantom><m:mtext>_</m:mtext></m:mphantom>
<xsl:apply-templates select="*[2]"/>
</xsl:otherwise>
</xsl:choose>
</m:mrow>
</xsl:template>
+<!-- Il modo Thread non esiste piu'
<xsl:template match="*" mode="thread">
<xsl:variable name="name"><xsl:value-of select="following-sibling::*[position()=1]/m:csymbol"/></xsl:variable>
<xsl:choose>
</xsl:choose>
<xsl:apply-templates mode="thread" select="preceding-sibling::*[position()=2]"/>
</xsl:template>
-
+-->
<!-- LAMBDA -->
<!--******************************************************************-->
<!-- Basic Logic -->
-<!-- First draft: April 3 2000 -->
+<!-- (completely) Revisited: february 2001, Andrea Asperti -->
<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
<!--******************************************************************-->
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:helm="http://www.cs.unibo.it/helm">
-
<!-- ************************* LOGIC *********************************-->
<!-- Proof objects -->
<xsl:apply-templates select="." mode="pure"/>
</xsl:template>
+<!-- ALL ELEMENTS WITH A TYPE ARE TRANSLATED AS A PROOF-ELEMENT -->
+
<!-- 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"/>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>proof</m:csymbol>
+ <xsl:apply-templates mode="proof_transform" select="."/>
+ <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
+ </m:apply>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="pure"/>
</xsl:choose>
</xsl:template>
-<!-- ALL this elements have inner type -->
+<!-- ALL these elements have inner type -->
<xsl:template match="CAST|APPLY|MUTCASE|FIX|COFIX" mode="noannot">
+ <xsl:variable name="id" select="@id"/>
<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"/>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>proof</m:csymbol>
+ <xsl:apply-templates mode="proof_transform" select="."/>
+ <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
+ </m:apply>
</xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select="." mode="pure"/>
+ <xsl:choose>
+ <xsl:when test="name()='APPLY'">
+ <xsl:apply-templates select="." mode="letin"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-<xsl:template name="has_inner_type">
+<xsl:template mode="proof_transform" match="*">
<xsl:variable name="id" select="@id"/>
<xsl:choose>
+ <!-- NATIND 3 parametri -->
+ <xsl:when test="name()='APPLY' and CONST[
+ attribute::uri='cic:/Coq/Init/Datatypes/nat_ind.con'] and count(child::*) = 4">
+ <m:apply>
+ <m:csymbol>nat_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[3]"/>
+ <xsl:apply-templates mode="noannot" select="*[4]"/>
+ </m:apply>
+ </xsl:when>
+ <!-- NATIND 4 parametri -->
+ <xsl:when test="name()='APPLY' and CONST[
+ attribute::uri='cic:/Coq/Init/Datatypes/nat_ind.con'] and count(child::*) = 5">
+ <m:apply>
+ <m:csymbol>nat_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[3]"/>
+ <xsl:apply-templates mode="noannot" select="*[4]"/>
+ </m:apply>
+ </xsl:when>
+ <!-- EQUALITY -->
<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="noannot" select="*[5]"/>
<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>
+ <!-- EQUALITY with extra-parameters -->
+ <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">
+ <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')])"/>
+ <xsl:choose>
+ <xsl:when test="$no_extraproofs=0">
+ <m:apply>
+ <m:csymbol>rewrite_and_apply</m:csymbol>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[5]"/>
+ <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="noannot" select="*[position()>7]"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="*[5]/@sort='Prop'">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>letin</m:csymbol>
+ <m:apply>
+ <m:csymbol>let</m:csymbol>
+ <m:ci>
+ <xsl:call-template name="insert_subscript">
+ <xsl:with-param name="node_value" select="'h1'"/>
+ </xsl:call-template>
+ </m:ci>
+ <xsl:apply-templates mode="noannot" select="*[5]"/>
+ </m:apply>
+ <xsl:call-template name="gen_let">
+ <xsl:with-param name="init_pos" select="1"/>
+ <xsl:with-param name="from" select="7"/>
+ </xsl:call-template>
+ <m:apply>
+ <m:csymbol>rewrite_and_apply</m:csymbol>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <m:ci>
+ <xsl:call-template name="insert_subscript">
+ <xsl:with-param name="node_value" select="'h1'"/>
+ </xsl:call-template>
+ </m:ci>
+ <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="flat" select="*[8]">
+ <xsl:with-param name="n">
+ <xsl:value-of select="2"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ </m:apply>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>letin</m:csymbol>
+ <xsl:call-template name="gen_let">
+ <xsl:with-param name="init_pos" select="0"/>
+ <xsl:with-param name="form" select="7"/>
+ </xsl:call-template>
+ <m:apply>
+ <m:csymbol>rewrite_and_apply</m:csymbol>
+ <m:apply>
+ <m:csymbol>rw_step</m:csymbol>
+ <xsl:apply-templates mode="pure" select="*[5]"/>
+ <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="flat" select="*[8]">
+ <xsl:with-param name="n">
+ <xsl:value-of select="1"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ </m:apply>
+ </m:apply>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:when>
<!-- gestire meglio il caso di and_ind quando la prova
non e' della forma \x.\y.M -->
and count(child::*) = 6
and name(*[5])='LAMBDA'
and name(*[5]/target/*[1])='LAMBDA'">
- <m:apply helm:xref="{@id}">
- <m:csymbol>and_ind</m:csymbol>
- <xsl:apply-templates mode="noannot" select="*[6]"/>
- <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>
- <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
- <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>
- <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
- <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
- </m:apply>
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>and_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[6]"/>
+ <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>
+ <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
+ <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>
+ <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
+ <xsl:apply-templates mode="proof_transform" select="*[5]/target/LAMBDA/target/*"/>
+ </m:apply>
</xsl:when>
<xsl:when test="name()= 'APPLY' and CONST[
attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
</m:apply>
</xsl:when>
<!-- ex_ind, exT_ind -->
- <xsl:when test="name()= 'APPLY'
+ <xsl:when test="name()= 'APPLY'
and (CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
CONST[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex_ind.con'])
and count(child::*) = 6
and name(*[5])='LAMBDA'
and name(*[5]/target/*[1])='LAMBDA'">
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>ex_ind</m:csymbol>
+ <xsl:apply-templates mode="noannot" select="*[6]"/>
+ <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>
+ <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
+ <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>
+ <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
+ <xsl:apply-templates mode="proof_transform" select="*[5]/target/LAMBDA/target/*"/>
+ </m:apply>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="name()='APPLY'">
+ <xsl:apply-templates select="." mode="letin"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="pure"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<xsl:template match="APPLY" mode="letin">
+ <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')])"/>
+ <!-- <m:cn><xsl:value-of select="$no_subproofs"/></m:cn> -->
+ <xsl:choose>
+ <xsl:when test="//InnerTypes and ($no_subproofs = 1)">
<m:apply helm:xref="{@id}">
- <m:csymbol>ex_ind</m:csymbol>
- <xsl:apply-templates mode="noannot" select="*[6]"/>
- <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>
- <xsl:apply-templates mode="pure" select="*[5]/source/*"/>
- <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>
- <xsl:apply-templates mode="pure" select="*[5]/target/LAMBDA/source/*"/>
- <xsl:apply-templates mode="noannot" select="*[5]/target/LAMBDA/target/*"/>
+ <m:csymbol>letin1</m:csymbol>
+ <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')]"/>
+ <!-- now re-process the application -->
+ <m:apply helm:xref="{@id}">
+ <m:csymbol>app</m:csymbol>
+ <!-- mode previous looks for siblings:
+ call with the first child -->
+ <xsl:apply-templates mode="previous" select="*[1]"/>
+ </m:apply>
</m:apply>
</xsl:when>
- <!-- Threads -->
- <!-- <xsl:when test="count(*[@id = //InnerTypes/TYPE/@of]) = 1"> -->
- <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">
+ <xsl:when test="//InnerTypes and ($no_subproofs > 1)">
<m:apply helm:xref="{@id}">
- <m:csymbol>thread</m:csymbol>
- <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
- <m:apply>
+ <m:csymbol>letin</m:csymbol>
+ <!-- first process all subproofs (let-in) -->
+ <xsl:call-template name="gen_let"/>
+ <!-- now re-process the application -->
+ <m:apply helm:xref="{@id}">
<m:csymbol>app</m:csymbol>
- <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
+ <!-- mode flat looks for siblings: call with the first child -->
+ <xsl:apply-templates mode="flat" select="*[1]"/>
</m:apply>
- <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')]"/>
</m:apply>
</xsl:when>
<xsl:otherwise>
- <m:apply helm:xref="{@id}">
- <m:csymbol>proof</m:csymbol>
- <xsl:apply-templates select="." mode="pure"/>
- <!-- <xsl:apply-templates select="key('typeid',@id)" mode="pure"/> -->
- <xsl:apply-templates select="//InnerTypes/TYPE[@of=$id]/*" mode="pure"/>
- </m:apply>
+ <xsl:apply-templates mode="pure" select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-<xsl:template match="*" mode="copy-of-no-prop">
+<xsl:template name="gen_let">
+ <xsl:param name="init_pos" select="0"/>
+ <xsl:param name="from" select="0"/>
+ <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')]">
+ <m:apply>
+ <m:csymbol>let</m:csymbol>
+ <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>
+ <xsl:apply-templates mode="noannot" select="."/>
+ </m:apply>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match="*" mode="previous">
<xsl:choose>
- <!-- <xsl:when test="@id = //InnerTypes/TYPE/@of"> -->
- <xsl:when test="@sort='Prop' and (name(.)='LAMBDA' or name(.)='LETIN' or name(.)='APPLY' or name(.)='MUTCASE' or name(.)='FIX' or name(.)='COFIX')">
+ <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'))">
<m:ci>previous</m:ci>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="pure"/>
</xsl:otherwise>
</xsl:choose>
- <xsl:apply-templates mode="copy-of-no-prop" select="following-sibling::*[1]"/>
+ <xsl:apply-templates mode="previous" select="following-sibling::*[1]"/>
</xsl:template>
-<xsl:template match="*" mode="thread">
- <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">
- <xsl:variable name="id" select="@id"/>
- <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]"/>
- </xsl:when>
-<!--**** Patch temporanea, per il problema dei threads ***-->
-<xsl:when test="(name()= 'APPLY' and
- (CONST[attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con'] or
- CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
- CONST[attribute::uri='cic:/Coq/Init/Logic/First_order_quantifiers/ex_ind.con'])
- and count(child::*) = 6
- and name(*[5])='LAMBDA'
- and name(*[5]/target/*[1])='LAMBDA')
- or
-(name()= 'APPLY' and CONST[
- attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con']
- and count(child::*) = 7)">
- <xsl:apply-templates mode="noannot" select="."/>
-</xsl:when>
-<!--**** Fine Patch temporanea, per il problema dei threads ***-->
- <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">
- <xsl:variable name="id" select="@id"/>
- <m:apply helm:xref="{@id}">
- <m:csymbol>thread</m:csymbol>
- <xsl:apply-templates mode="pure" select="//InnerTypes/TYPE[@of=$id]/*"/>
- <m:apply>
- <m:csymbol>app</m:csymbol>
- <xsl:apply-templates mode="copy-of-no-prop" select="*[1]"/>
- </m:apply>
- <!-- <xsl:apply-templates mode="thread" select="*[@id = //InnerTypes/TYPE/@of]"/> -->
- <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')]"/>
- </m:apply>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="noannot" select="."/>
- </xsl:otherwise>
- </xsl:choose>
+<xsl:template match="*" mode="flat">
+ <xsl:param name="n" select="1"/>
+ <xsl:variable name="id" select="@id"/>
+ <xsl:choose>
+ <!-- <xsl:when test="key('typeid',@id)"> -->
+ <!-- <xsl:when test="//InnerTypes/TYPE[@of=$id]"> -->
+ <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')">
+ <m:ci>
+ <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>
+ </m:ci>
+ <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
+ <xsl:with-param name="n" select="$n+1"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="pure" select="."/>
+ <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
+ <xsl:with-param name="n" select="$n"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
-<!-- Basic proof operators -->
-
-<!-- non del tutto soddisfacente, ma .... -->
-<xsl:template match="APPLY[CONST[
- attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
- attribute::uri='cic:/Coq/Zarith/auxiliary/eqT_ind_r.con']]" mode="appflat">
- <xsl:choose>
- <xsl:when test="count(child::*) > 7">
- <xsl:variable name="id" select="@id"/>
- <xsl:variable name="ideqp" select="*[7]/@id"/>
- <xsl:variable name="idsubp" select="*[5]/@id"/>
-<!--
- <xsl:variable name="leteqp" select="boolean(//InnerTypes/TYPE[@of=$ideqp])"/>
- <xsl:variable name="letsubp" select="boolean(//InnerTypes/TYPE[@of=$idsubp])"/>
--->
- <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')])"/>
- <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')])"/>
- <m:apply helm:xref="{@id}">
- <m:csymbol>rewrite_and_apply</m:csymbol>
- <m:apply>
- <m:csymbol>rw_step</m:csymbol>
- <xsl:apply-templates mode="pure" select="*[3]"/>
- <xsl:apply-templates mode="pure" select="*[6]"/>
- <xsl:choose>
- <xsl:when test="$leteqp">
- <xsl:choose>
- <xsl:when test="$letsubp">
- <m:ci>
- <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h2'"/></xsl:with-param></xsl:call-template>
- </m:ci>
- </xsl:when>
- <xsl:otherwise>
- <m:ci>
- <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h1'"/></xsl:with-param></xsl:call-template>
- </m:ci>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="pure" select="*[7]"/>
- </xsl:otherwise>
- </xsl:choose>
- </m:apply>
- <xsl:choose>
- <xsl:when test="$letsubp">
- <m:ci>
- <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="'h1'"/></xsl:with-param></xsl:call-template>
- </m:ci>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="pure" select="*[5]"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates mode="flat" select="*[8]">
- <xsl:with-param name="n">
- <xsl:value-of select="1+$letsubp+$leteqp"/>
- </xsl:with-param>
- </xsl:apply-templates>
- </m:apply>
- </xsl:when>
- <xsl:otherwise>
- <m:apply helm:xref="{@id}">
- <m:csymbol>app</m:csymbol>
- <xsl:apply-templates mode="flat" select="*[1]"/>
- </m:apply>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template match="APPLY[CONST[
+<!-- <xsl:template match="APPLY[CONST[
attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con']]" mode="appflat">
<xsl:choose>
<xsl:when test="count(child::*) > 4">
</m:apply>
</xsl:otherwise>
</xsl:choose>
-</xsl:template>
+</xsl:template> -->
</xsl:stylesheet>