]> matita.cs.unibo.it Git - helm.git/commitdiff
Bug nat_double_ind solved.
authorAndrea Asperti <andrea.asperti@unibo.it>
Thu, 5 Apr 2001 14:46:12 +0000 (14:46 +0000)
committerAndrea Asperti <andrea.asperti@unibo.it>
Thu, 5 Apr 2001 14:46:12 +0000 (14:46 +0000)
helm/style/basic.xsl
helm/style/inductive.xsl
helm/style/proofs.xsl

index ed6681af2132096f40526a822f8a358095381671..d2441932f3cff0d79f1c8297b48fb06f95985c90 100644 (file)
@@ -67,7 +67,7 @@
 </xsl:template>
 
 <!-- IFF -->
-<!--
+<!-- 
 <xsl:template match="APPLY[CONST[attribute::uri='cic:/Coq/Init/Logic/Equivalence/iff.ind'] and (count(child::*) = 3)]" mode="pure">
     <m:apply helm:xref="{@id}">
     <m:iff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
      <xsl:choose>
       <xsl:when test="name(*[3]) = 'LAMBDA'">
        <m:bvar>
-        <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="LAMBDA/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
+        <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="*[3]/target/@binder"/></xsl:with-param></xsl:call-template></m:ci>
        </m:bvar>
+       <m:condition>
+        <xsl:apply-templates select="*[2]" mode="pure"/>
+       </m:condition>
        <xsl:apply-templates select="LAMBDA/target" mode="noannot"/>
       </xsl:when>
       <xsl:otherwise>
        <m:bvar>
         <m:ci>$x</m:ci>
        </m:bvar>
+       <m:condition>
+        <xsl:apply-templates select="*[2]" mode="pure"/>
+       </m:condition>
        <m:apply>
         <m:csymbol>app</m:csymbol>
         <xsl:apply-templates select="*[3]" mode="noannot"/>
index 5211c000c8e3de2f684f0571d97d9e6e3e10939a..f9b535f1e72e43a60299b80ed5da5494d51064ca 100644 (file)
@@ -36,7 +36,8 @@
 
 
 <xsl:template mode="inductive" match="APPLY">
- <xsl:param name="inductive_def_uri" select="/.."/>
+ <xsl:param name="inductive_def_uri" select="''"/>
+ <xsl:param name="inductive_def" select="/.."/>
  <xsl:param name="inductive_def_index" select="1"/>
  <xsl:param name="inductive_def_name" select="''"/>
  <xsl:param name="section_params" select="0"/>
@@ -63,9 +64,6 @@
     <xsl:when test="string($argsOK) = 'true'">
      <!-- arguments are in the expected form: we create a
           "by_induction" content element -->
-     <!-- inductive_def contains the inductive definition -->
-     <xsl:variable name="inductive_def" 
-      select="document(concat(string($absPath),$inductive_def_uri))/InductiveDefinition"/>
      <!-- no_params is the number of paramters in square brackets -->
      <xsl:variable name="no_params" 
       select="$inductive_def/@noParams"/>
index b0d4cba728bea3e99e1a0d6ef171ff4f51c9886a..f82d7769084f248b3431f933a7f5897d2dc6f9ca 100644 (file)
  </xsl:choose>
 </xsl:template>
 
+<!-- si presuppone che il tipo induttivo non sia mutuamente 
+     induttivo. Bisognerebbe andare a vedere l'utlimo parametro
+     del presunto "principio di induzione", tirare fuori il tipo induttivo
+     e vedere se il suo nome coincide con il prefisso di _ind. 
+     Ad esempio nat_double_ind e' definito dall'utente. L'ultimo
+     parametro di nat_double_ind e' di tipo nat, e nat e' diverso
+     da nat_double. Per ora, verifico solo l'esistenza di nat_double,
+     ma questo, benche' non porti ad errore, non copre tutti i
+     casi per quelli mutuamente induttivi -->
+
 <xsl:template mode="try_inductive" match="APPLY">
    <xsl:variable name="id" select="@id"/>
    <xsl:choose>
      <xsl:variable name="uri" select="CONST[1]/@uri"/>
      <xsl:choose>
       <xsl:when test="contains($uri,'_ind.con')">
-       <xsl:variable name="ind_name">
-        <xsl:call-template name="get_name">
-         <xsl:with-param name="uri" select="$uri"/>
-        </xsl:call-template>
-       </xsl:variable>
        <xsl:variable name="ind_uri" 
          select="concat(substring-before($uri,'_ind.con'),'.ind')"/>
-       <xsl:variable name="no_params">
-        <xsl:call-template name="get_no_params">
-         <xsl:with-param name="first_uri" select="$CICURI"/>
-         <xsl:with-param name="second_uri" select="$uri"/>
-        </xsl:call-template>
-       </xsl:variable>
-       <xsl:apply-templates mode="inductive" select=".">
-        <xsl:with-param name="inductive_def_uri" 
-         select="$ind_uri"/>
-        <xsl:with-param name="section_params" select="$no_params"/>
-        <xsl:with-param name="inductive_def_index" select="1"/>
-        <xsl:with-param name="inductive_def_name" select="$ind_name"/>
-       </xsl:apply-templates>
+       <xsl:variable name="inductive_def" 
+     select="document(concat(string($absPath),$ind_uri))/InductiveDefinition"/>
+       <!-- check if the corresponding inductive definition actually
+            exists -->
+       <xsl:choose>
+        <xsl:when test="$inductive_def">
+         <xsl:variable name="ind_name">
+          <xsl:call-template name="get_name">
+           <xsl:with-param name="uri" select="$uri"/>
+          </xsl:call-template>
+         </xsl:variable>
+         <xsl:variable name="no_params">
+          <xsl:call-template name="get_no_params">
+           <xsl:with-param name="first_uri" select="$CICURI"/>
+           <xsl:with-param name="second_uri" select="$uri"/>
+          </xsl:call-template>
+         </xsl:variable>
+         <xsl:apply-templates mode="inductive" select=".">
+          <xsl:with-param name="inductive_def_uri" 
+           select="$ind_uri"/>
+          <xsl:with-param name="inductive_def" 
+           select="$inductive_def"/>
+          <xsl:with-param name="section_params" select="$no_params"/>
+          <xsl:with-param name="inductive_def_index" select="1"/>
+          <xsl:with-param name="inductive_def_name" select="$ind_name"/>
+         </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+         <xsl:apply-templates mode="letin" select="."/>
+        </xsl:otherwise>
+       </xsl:choose>
       </xsl:when>
       <xsl:otherwise>
        <xsl:apply-templates mode="letin" select="."/>
 
 
 <xsl:template mode="proof_transform" match="*">
+ <xsl:choose>
+  <xsl:when test="name()='APPLY'">
    <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">
+    <xsl:when test="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:when>
     <!-- NATIND 4 parametri (nuova versione) -->
     <!-- 
-    <xsl:when test="name()='APPLY' and CONST[
+    <xsl:when test="CONST[
  attribute::uri='cic:/Coq/Init/Datatypes/nat_ind.con'] 
  and count(child::*) = 5
  and name(*[4])='LAMBDA' 
     </xsl:when> 
     -->
     <!-- EQUALITY -->
-    <xsl:when test="name()= 'APPLY' and CONST[
+    <xsl:when test="CONST[
  attribute::uri='cic:/Coq/Init/Logic/Equality/eq_ind.con' or
  attribute::uri='cic:/Coq/Init/Logic/Logic_lemmas/eq_ind_r.con' or
  attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
       </m:apply>
     </xsl:when>
     <!-- EQUALITY with extra-parameters -->
-    <xsl:when test="name()= 'APPLY' and CONST[
+    <xsl:when test="CONST[
  attribute::uri='cic:/Coq/Init/Logic/Equality/eq_ind.con' or
  attribute::uri='cic:/Coq/Init/Logic/Logic_lemmas/eq_ind_r.con' or
  attribute::uri='cic:/Coq/Init/Logic_Type/eqT_ind.con' or
       </xsl:choose>
     </xsl:when>
     <!-- False_ind -->
-    <xsl:when test="name()= 'APPLY' and CONST[
+    <xsl:when test="CONST[
      attribute::uri='cic:/Coq/Init/Logic/False_ind.con'] and 
      count(child::*) = 3">
      <m:apply helm:xref="{@id}">
     </xsl:when>
     <!-- gestire meglio il caso di and_ind quando la prova 
          non e' della forma \x.\y.M -->
-    <xsl:when test="name()= 'APPLY' and CONST[
+    <xsl:when test="CONST[
  attribute::uri='cic:/Coq/Init/Logic/Conjunction/and_ind.con'] 
  and count(child::*) = 6 
  and name(*[5])='LAMBDA' 
        <xsl:apply-templates mode="proof_transform" select="*[5]/target/LAMBDA/target/*"/> 
       </m:apply>
     </xsl:when>
-    <xsl:when test="name()= 'APPLY' and CONST[
+    <xsl:when test="CONST[
  attribute::uri='cic:/Coq/Init/Logic/Disjunction/or_ind.con'] 
  and count(child::*) = 7">
       <xsl:choose>
       </xsl:choose>
     </xsl:when>
     <!-- ex_ind, exT_ind -->
-      <xsl:when test="name()= 'APPLY' 
- and (CONST[attribute::uri='cic:/Coq/Init/Logic_Type/exT_ind.con'] or
+      <xsl:when test="(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' 
        <xsl:apply-templates mode="proof_transform" select="*[5]/target/LAMBDA/target/*"/>
       </m:apply>
     </xsl:when>
-    <xsl:when test="(name()='APPLY') and (name(*[1])='CONST')">
+    <xsl:when test="name(*[1])='CONST'">
      <xsl:apply-templates mode="try_inductive" select="."/>
     </xsl:when>
+    <!-- patch temporanea per la gestione di redex -->
+    <xsl:when test="name(*[1])='LAMBDA' and count(child::*)=2
+         and *[2]/@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">
+          <xsl:value-of select="*[1]/target/@binder"/>
+         </xsl:with-param>
+        </xsl:call-template>
+       </m:ci>
+       <xsl:apply-templates mode="noannot" select="*[2]"/>
+      </m:apply>
+      <xsl:apply-templates mode="proof_transform" select="*[1]/target/*[1]"/>
+     </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:apply-templates select="." mode="letin"/>
     </xsl:otherwise>
    </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:apply-templates select="." mode="pure"/>
+  </xsl:otherwise>
+ </xsl:choose>
 </xsl:template>