]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/proofs.xsl
...
[helm.git] / helm / style / proofs.xsl
index 9fd99d5d1f428bae49b03611cab694aee57154b9..5a34d8a06f710fea23eb3a18d494e23174931bc1 100644 (file)
   <xsl:otherwise>
    <xsl:choose>
     <xsl:when test="name()='APPLY'">
-     <xsl:apply-templates select="." mode="letin"/>
+     <!-- This is the case of an applicative expression wich is not
+          a proof but could contains proofs...
+          MODE LETIN OR MODE PURE ??? Big question -->
+     <xsl:apply-templates select="." mode="pure"/>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates select="." mode="pure"/>
       <xsl:when test="contains($uri,'_ind.con')">
        <xsl:variable name="ind_uri" 
          select="concat(substring-before($uri,'_ind.con'),'.ind')"/>
+       <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$ind_uri"/></xsl:call-template></xsl:variable>
        <xsl:variable name="inductive_def" 
-     select="document(concat(string($absPath),$ind_uri))/InductiveDefinition"/>
+     select="document($InductiveTypeUrl)/InductiveDefinition"/>
        <!-- check if the corresponding inductive definition actually
             exists -->
        <xsl:choose>
    </xsl:choose>
 </xsl:template>
 
+<xsl:template mode="eq_transitive" match="*">
+ <!-- <m:ci>eccomi-1: <xsl:value-of select="name()"/></m:ci> -->
+ <xsl:choose>
+  <xsl:when test="name()='APPLY'">
+   <!-- <m:ci>eccomi-2: <xsl:value-of select="CONST[1]/@uri"/></m:ci> -->
+   <xsl:variable name="id" select="@id"/>
+   <xsl:choose>
+    <!-- ricordarsi di trattare il parametro -->
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/CSetoids/CSetoid_basics/eq_transitive_unfolded.con'] and count(child::*) = 7">
+     <!-- <m:ci>eccomi-3</m:ci> -->
+     <xsl:apply-templates mode="eq_transitive" select="*[6]"/>
+     <xsl:apply-templates mode="noannot" select="*[4]"/>
+     <xsl:apply-templates mode="eq_transitive" select="*[7]"/>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:call-template name="generate_side_proof">
+      <xsl:with-param name="proof" select="."/>
+      <xsl:with-param name="show_statement" select="0"/>
+     </xsl:call-template> 
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:call-template name="generate_side_proof">
+    <xsl:with-param name="proof" select="."/>
+    <xsl:with-param name="show_statement" select="0"/>
+   </xsl:call-template>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template mode="diseq" match="*">
+  <xsl:param name="rel" select="'eq'"/>
+  <xsl:choose>
+  <xsl:when test="name()='APPLY'">
+      <xsl:variable name="id" select="@id"/>
+   <xsl:choose>
+    <!-- ricordarsi di trattare il parametro -->
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_transitive.con'] and count(child::*) = 7">
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+    </xsl:when> 
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_wdl.con'] and count(child::*) = 7">
+       <m:eq/>
+       <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
+       <xsl:call-template name="generate_side_proof">
+        <xsl:with-param name="proof" select="*[7]"/>
+        <xsl:with-param name="show_statement" select="0"/>
+       </xsl:call-template>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+    </xsl:when> 
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_less_trans.con'] and count(child::*) = 7">
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+    </xsl:when>
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/less_leEq_trans.con'] and count(child::*) = 7">
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+    </xsl:when>  
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_wdr.con'] and count(child::*) = 7">
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'eq'"/>
+       </xsl:apply-templates>
+    </xsl:when>  
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/COrdField_axioms/less_transitive_unfolded.con'] and count(child::*) = 7">
+      <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+     </xsl:when> 
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/COrdField_axioms/less_wdr.con'] and count(child::*) = 7">
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'eq'"/>
+       </xsl:apply-templates>
+     </xsl:when>
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/COrdField_axioms/less_wdl.con'] and count(child::*) = 7">
+       <m:eq/>
+       <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
+       <xsl:call-template name="generate_side_proof">
+        <xsl:with-param name="proof" select="*[7]"/>
+        <xsl:with-param name="show_statement" select="0"/>
+       </xsl:call-template>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+    </xsl:when> 
+    <!-- 
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/CSetoids/CSetoid_basics/eq_transitive_unfolded.con'] and count(child::*) = 7">
+     <xsl:apply-templates mode="diseq" select="*[6]"/>
+     <m:eq/>
+     <xsl:apply-templates mode="noannot" select="*[4]"/>
+     <m:eq/>
+     <xsl:apply-templates mode="diseq" select="*[7]"/>
+    </xsl:when> 
+    -->
+    <xsl:otherwise>
+     <xsl:element name="{concat('m:',$rel)}"/>
+     <!-- <m:ci><xsl:value-of select="$rel"/></m:ci> -->  
+     <xsl:call-template name="generate_side_proof">
+      <xsl:with-param name="proof" select="."/>
+      <xsl:with-param name="show_statement" select="0"/>
+     </xsl:call-template> 
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:element name="{concat('m:',$rel)}"/> 
+   <!-- <m:ci><xsl:value-of select="$rel"/></m:ci> --> 
+   <xsl:call-template name="generate_side_proof">
+    <xsl:with-param name="proof" select="."/>
+    <xsl:with-param name="show_statement" select="0"/>
+   </xsl:call-template>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
 
 <xsl:template mode="proof_transform" match="*">
  <xsl:choose>
   <xsl:when test="name()='APPLY'">
    <xsl:variable name="id" select="@id"/>
    <xsl:choose>
+    <!-- Algebra equality (eq_transitive_unfolded) -->
+    <!-- It requires a special mode "eq_transitive"-->
+    <!-- togliere il parametro -->
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/CSetoids/CSetoid_basics/eq_transitive_unfolded.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>eq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="eq_transitive" select="*[6]"/>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="eq_transitive" select="*[7]"/>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when>
+    <!-- Algebra disequalities -->
+    <!-- It requires a special mode "diseq"-->
+    <!-- togliere il parametro -->
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_transitive.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when> 
+     <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_wdl.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+       <m:eq/>
+       <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
+       <xsl:call-template name="generate_side_proof">
+        <xsl:with-param name="proof" select="*[7]"/>
+        <xsl:with-param name="show_statement" select="0"/>
+       </xsl:call-template>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+     </m:apply>
+    </xsl:when>
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_less_trans.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when> 
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/less_leEq_trans.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when>  
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/Basic_Properties_of_leEq/leEq_wdr.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'leq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'eq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when>  
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/COrdField_axioms/less_transitive_unfolded.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when>  
+    <!-- togliere il parametro -->
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/COrdField_axioms/less_wdr.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+       <xsl:apply-templates mode="diseq" select="*[7]">
+        <xsl:with-param name="rel" select="'eq'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+     </m:apply>
+    </xsl:when>
+    <!-- togliere il parametro -->
+    <xsl:when test="CONST[attribute::uri='cic:/Algebra/COrdFields/COrdField_axioms/less_wdl.con'] and count(child::*) = 7">
+     <m:apply>
+       <m:csymbol>diseq_chain</m:csymbol>
+       <xsl:apply-templates mode="noannot" select="*[5]"/>
+       <m:eq/>
+       <!-- <m:ci><xsl:value-of select="'eq'"/></m:ci> -->
+       <xsl:call-template name="generate_side_proof">
+        <xsl:with-param name="proof" select="*[7]"/>
+        <xsl:with-param name="show_statement" select="0"/>
+       </xsl:call-template>
+       <xsl:apply-templates mode="noannot" select="*[3]"/>
+       <xsl:apply-templates mode="diseq" select="*[6]">
+        <xsl:with-param name="rel" select="'lt'"/>
+       </xsl:apply-templates>
+       <xsl:apply-templates mode="noannot" select="*[4]"/>
+     </m:apply>
+    </xsl:when> 
     <!-- EQUALITY -->
     <xsl:when test="CONST[
  attribute::uri='cic:/Coq/Init/Logic/Equality/eq_ind.con' or
        <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="proof_transform" select="*[7]"/>
+       <xsl:call-template name="generate_side_proof">
+        <xsl:with-param name="proof" select="*[7]"/>
+       </xsl:call-template>
+       <!-- <xsl:apply-templates mode="proof_transform" select="*[7]"/> -->
       </m:apply>
     </xsl:when>
     <!-- EQUALITY with extra-parameters -->
           <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]"/>
+          <xsl:call-template name="generate_side_proof">
+           <xsl:with-param name="proof" select="*[7]"/>
+           </xsl:call-template>
+          <!-- <xsl:apply-templates mode="pure" select="*[7]"/> -->
          </m:apply>
          <xsl:apply-templates mode="noannot" select="*[position()>7]"/>
         </m:apply>
              </m:ci>
              <xsl:apply-templates mode="pure" select="*[3]"/>
              <xsl:apply-templates mode="pure" select="*[6]"/>
-             <xsl:apply-templates mode="pure" select="*[7]"/>
+             <xsl:call-template name="generate_side_proof">
+              <xsl:with-param name="proof" select="*[7]"/>
+             </xsl:call-template>
+             <!-- <xsl:apply-templates mode="pure" select="*[7]"/> -->
             </m:apply>
             <xsl:apply-templates mode="flat" select="*[8]">
              <xsl:with-param name="n">
              <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]"/>
+             <xsl:apply-templates mode="pure" select="*[6]"/>             
+             <xsl:call-template name="generate_side_proof">
+              <xsl:with-param name="proof" select="*[7]"/>
+             </xsl:call-template>
+             <!-- <xsl:apply-templates mode="pure" select="*[7]"/> -->
             </m:apply>
             <xsl:apply-templates mode="flat" select="*[8]">
              <xsl:with-param name="n">
        <xsl:apply-templates mode="noannot" select="target/*[1]/*[5]"/>
        <xsl:apply-templates mode="pure" select="target/*[1]/*[3]"/>
        <xsl:apply-templates mode="pure" select="target/*[1]/*[6]"/>
-       <xsl:apply-templates mode="proof_transform" select="target/*[1]/*[7]"/>
+       <xsl:call-template name="generate_side_proof">
+        <xsl:with-param name="proof" select="target/*[1]/*[7]"/>
+       </xsl:call-template>
+       <!-- <xsl:apply-templates mode="proof_transform" select="target/*[1]/*[7]"/> -->
       </m:apply>
      </xsl:when>
      <xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 
+<xsl:template name="is_simple">
+ <xsl:param name="proof" select="/.."/>
+ <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))"/>
+</xsl:template>
+
+<xsl:template name="generate_side_proof">
+ <xsl:param name="proof" select="/.."/>
+ <xsl:param name="show_statement" select="1"/>
+<!-- 
+ <xsl:variable name="is_simple">
+  <xsl:call-template name="is_simple">
+   <xsl:with-param name="proof" select="$proof"/>
+  </xsl:call-template>
+ </xsl:variable> -->
+<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))"/>
+ <xsl:choose>
+  <xsl:when test="$is_simple">
+   <xsl:choose>
+    <xsl:when test="name($proof)='APPLY'">
+     <xsl:apply-templates select="$proof" mode="letin"/>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:apply-templates select="$proof" mode="pure"/>
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:variable name="id" select="@id"/>
+   <m:apply helm:xref="{@id}">
+    <xsl:choose>
+     <xsl:when test="$show_statement = 1">
+      <m:csymbol>proof</m:csymbol>
+     </xsl:when>
+     <xsl:otherwise>
+      <m:csymbol>side_proof</m:csymbol>
+     </xsl:otherwise>
+    </xsl:choose>
+    <xsl:apply-templates mode="proof_transform" select="$proof"/>
+    <xsl:apply-templates mode="pure" select="$InnerTypes/InnerTypes/TYPE[@of=$proof/@id]/*"/>
+   </m:apply>
+   <!-- <xsl:apply-templates select="$proof" mode="noannot"/> -->
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<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')])"/>
 
 <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')])"/>