]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/inductive.xsl
No longer in use. The official repository for the
[helm.git] / helm / style / inductive.xsl
diff --git a/helm/style/inductive.xsl b/helm/style/inductive.xsl
deleted file mode 100644 (file)
index 1d6dc4d..0000000
+++ /dev/null
@@ -1,416 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- Copyright (C) 2000, HELM Team                                     -->
-<!--                                                                   -->
-<!-- This file is part of HELM, an Hypertextual, Electronic            -->
-<!-- Library of Mathematics, developed at the Computer Science         -->
-<!-- Department, University of Bologna, Italy.                         -->
-<!--                                                                   -->
-<!-- HELM is free software; you can redistribute it and/or             -->
-<!-- modify it under the terms of the GNU General Public License       -->
-<!-- as published by the Free Software Foundation; either version 2    -->
-<!-- of the License, or (at your option) any later version.            -->
-<!--                                                                   -->
-<!-- HELM is distributed in the hope that it will be useful,           -->
-<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of    -->
-<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     -->
-<!-- GNU General Public License for more details.                      -->
-<!--                                                                   -->
-<!-- You should have received a copy of the GNU General Public License -->
-<!-- along with HELM; if not, write to the Free Software               -->
-<!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston,            -->
-<!-- MA  02111-1307, USA.                                              -->
-<!--                                                                   -->
-<!-- For details, see the HELM World-Wide-Web page,                    -->
-<!-- http://cs.unibo.it/helm/.                                         -->
-
-<!--******************************************************************--> 
-<!-- XSLT version 0.1 of CIC inductive objects to MathML content:     -->
-<!-- Completely revisited: November 2002, Andrea asperti              -->
-<!-- First draft: March 2001, Andrea asperti                          -->
-<!--******************************************************************-->
-
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                              xmlns:m="http://www.w3.org/1998/Math/MathML"
-                              xmlns:helm="http://www.cs.unibo.it/helm">
-
-<!-- try_inductive essentially checks if the head constant is an
-     invocation of an induction principle. 
-     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:variable name="uri">
-  <xsl:choose>
-   <xsl:when test="name(*[1])='CONST'">
-    <xsl:value-of select="*[1]/@uri"/>
-   </xsl:when>
-   <xsl:otherwise>
-    <!-- instantiate -->
-    <xsl:value-of select="*[1]/CONST[1]/@uri"/>
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:variable>
- <xsl:choose>
-  <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($InductiveTypeUrl)/InductiveDefinition"/>
-   <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:apply-templates mode="inductive" select=".">
-      <xsl:with-param name="uri" select="$uri"/>
-      <xsl:with-param name="inductive_def_uri" 
-       select="$ind_uri"/>
-      <xsl:with-param name="inductive_def" select="$inductive_def"/>
-      <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 select="." mode="letin"/>
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:apply-templates select="." mode="letin"/>
-  </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-
-<xsl:template mode="inductive" match="APPLY">
- <xsl:param name="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:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$uri"/></xsl:call-template></xsl:variable>
- <!-- expected_args_type contains the types of the arguments expected by
-      the induction principle -->
- <xsl:variable name="expected_args_types" 
-      select="document($InductiveTypeUrl)/ConstantType/PROD/decl/*[1]"/>
- <xsl:variable name="no_expected_args" select="count($expected_args_types)"/>
- <xsl:variable name="actual_arguments" select="*[position()>1]"/>
- <!-- First check that the induction principle is applied to the
-      expected number of arguments -->
- <xsl:choose>
-  <xsl:when test="$no_expected_args = count($actual_arguments)">
-   <!-- Now check that each actual argument starts with the
-        expected number of lambda abstractions -->
-   <xsl:variable name="argsOK"> 
-    <xsl:call-template name="check_args">
-     <xsl:with-param name="arg_types" select="$expected_args_types"/>
-     <xsl:with-param name="actual_args" select="$actual_arguments"/>
-    </xsl:call-template>
-   </xsl:variable>
-   <xsl:choose>
-    <!-- il semplice test $argsOK non funziona -->
-    <xsl:when test="string($argsOK) = 'true'">
-     <!-- arguments are in the expected form: we create a
-          "by_induction" content element -->
-     <!-- no_params is the number of parameters in square brackets -->
-     <xsl:variable name="no_params" 
-      select="$inductive_def/@noParams"/>
-     <!-- the inductive property is the first argument following
-          the parameters  -->
-     <xsl:variable name="inductive_property" 
-               select="$actual_arguments[1 + $no_params]"/>
-     <xsl:variable name="tail_args" 
-      select="$actual_arguments[position()> (1 + $no_params)]"/>
-     <!-- inductive_type contains the right inductive type in the
-          mutual inductive definition -->
-     <xsl:variable name="inductive_type" 
-      select="$inductive_def/InductiveType[position()=$inductive_def_index]"/>
-     <xsl:variable name="no_constructors" 
-      select="count($inductive_type/Constructor)"/>
-     <!-- each case has a single argument -->
-     <xsl:variable name="args_for_cases" 
-      select="$tail_args[($no_constructors + 1) > position()]"/>
-     <!-- extra_args contains the remaining arguments; the LAST one
-          of them is the argument we are inductively arguing on -->
-     <xsl:variable name="extra_args" 
-      select="$tail_args[position()> $no_constructors]"/>
-     <m:apply>
-      <m:csymbol>by_induction</m:csymbol>
-      <!-- the first (i.e. second) argument of by_induction
-           is the uri of the inductive definition -->
-      <m:ci><xsl:value-of select="$inductive_def_uri"/></m:ci>
-      <!-- next, we have the inductive property, currently not
-           used for rendering (it could be omitted ??) -->
-      <xsl:apply-templates mode="pure" select="$inductive_property"/>
-      <!-- each case has its own "inductive_case" element -->
-      <!-- the inductive case element is composed by:
-           * "case_lhs" element, containing the constructor name applied
-              to its arguments. The arguments are abstraction variables
-              (with types) got form the initial lambdas of the argument
-              for the case.
-           * "induction_hypothesis" element, containg the induction 
-              hypothesis. Again, these are abstraction variables
-              (with types) got form the initial lambdas of the argument
-              for the case.
-           * body of the case, without specific markup.
-       -->
-      <xsl:for-each select="$inductive_type/Constructor">
-       <xsl:variable name="pos" select="position()"/>
-       <xsl:variable name="current_arg" 
-                     select="$args_for_cases[position()=$pos]"/>
-       <m:apply>
-        <m:csymbol>inductive_case</m:csymbol>
-        <m:apply>
-         <m:csymbol>case_lhs</m:csymbol>
-         <m:ci definitionURL="{$inductive_def_uri}">
-          <xsl:value-of select="@name"/>
-         </m:ci> 
-         <xsl:call-template name="get_constructor_args">
-          <xsl:with-param name="constructor_args" 
-               select="PROD/decl[position()> $no_params]"/>
-          <xsl:with-param name="actual_args" 
-               select="$current_arg/decl"/>
-          <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-          </xsl:call-template>  
-        </m:apply>
-        <m:apply>
-         <m:csymbol>induction_hypothesis</m:csymbol>
-         <xsl:call-template name="get_induction_hypothesis">
-          <xsl:with-param name="constructor_args" 
-               select="PROD/decl[position()> $no_params]"/>
-          <xsl:with-param name="actual_args" 
-               select="$current_arg/decl"/>
-          <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-         </xsl:call-template>
-        </m:apply>
-        <xsl:choose>
-         <xsl:when test="count(PROD/decl) > $no_params">
-          <!-- in this case the actual_arg must be a LAMBDA -->
-          <xsl:call-template name="get_body">
-           <xsl:with-param name="constructor_args" 
-               select="PROD/decl[position()>$no_params]"/>
-           <xsl:with-param name="actual_args" select="$current_arg/decl"/>
-           <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-           <xsl:with-param name="target" 
-               select="$current_arg/target/*[1]"/>
-          </xsl:call-template>
-         </xsl:when>
-         <xsl:otherwise>
-          <xsl:apply-templates mode="noannot" select="$current_arg"/>
-         </xsl:otherwise>
-        </xsl:choose>
-       </m:apply>
-      </xsl:for-each>
-      <!-- the inductive argument is the last argument of extra-args -->
-      <m:apply>
-       <m:csymbol>extra_args</m:csymbol>
-       <xsl:apply-templates mode="pure" select="$extra_args"/>
-      </m:apply>
-     </m:apply>
-    </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:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- check_args checks that the number of lambda abstractions
-     of each actual parameter is GREATER OR EQUAL to the number
-     or products of the corresponding formal parameter of the
-     induction principles. That is, that each argument is 
-     sufficiently eta-expanded.
-     If this is not the case, not good rendering looks possible.
-     Check_args returns a boolean. 
-   -->
-
-
-<xsl:template name="check_args">
- <xsl:param name="arg_types" select="/.."/>
- <xsl:param name="actual_args" select="/.."/>
- <xsl:param name="bool_var" select="true()"/>
- <!-- <xsl:value-of select="false()"/> -->
- <xsl:choose>
-  <xsl:when test="count($arg_types) = 0">
-    <xsl:value-of select="$bool_var"/>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:variable name="no_expected_arg_of_arg" 
-                 select="count($arg_types[1]/decl)"/>
-   <xsl:variable name="no_actual_abst_of_arg" 
-                 select="count($actual_args[1]/decl)"/> 
-   <xsl:variable name="test_arg" 
-    select="($no_actual_abst_of_arg >= $no_expected_arg_of_arg)"/> 
-   <xsl:call-template name="check_args">
-    <xsl:with-param name="arg_types" select="$arg_types[position()>1]"/>
-    <xsl:with-param name="actual_args" select="$actual_args[position()>1]"/>
-    <xsl:with-param name="bool_var" select="($bool_var and $test_arg)"/>
-   </xsl:call-template> 
-  </xsl:otherwise>
- </xsl:choose>
-</xsl:template> 
-
-
-<!-- The following three functions are essentially identical
-     in their recursive structure.
-     The problem is that of decomposing an actual argument for
-     a case in three parts: 
-     * constructor variables
-     * induction hypothesis
-     * body
-     To this aim we must proceed in parallel with the type of
-     the constructor: if the type contains a prod, then the 
-     the corresponding lambda of the argument provides the 
-     constructor variable. Moreover, if the source type of the
-     prod contains a reference to the inductive type, it is a
-     recursive argument and the NEXT lambda of the argument 
-     provides an induction hypothesis.
-     Unfortunately the three functions cannot be merged into a
-     single one without a conversion from document tree fragments
-     to node-sets. 
--->
-
-<xsl:template name="get_constructor_args">
- <xsl:param name="constructor_args" select="/.."/>
- <xsl:param name="actual_args" select="/.."/>
- <xsl:param name="inductive_def_uri" select="''"/>
- <xsl:if test="$constructor_args">
-  <m:bvar>
-   <m:ci><xsl:value-of select="$actual_args[1]/@binder"/></m:ci>
-   <m:type>
-    <xsl:apply-templates mode="pure" select="$actual_args[1]/*"/>
-   </m:type> 
-  </m:bvar>
-  <xsl:choose>
-   <xsl:when test="$constructor_args[1]//MUTIND[@uri=$inductive_def_uri]">
-    <xsl:call-template name="get_constructor_args">
-    <xsl:with-param name="constructor_arity" 
-        select="$constructor_args[position()>1]"/>
-    <xsl:with-param name="actual_args" 
-        select="$actual_args[position()>2]"/>
-    <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-    </xsl:call-template>
-   </xsl:when>
-   <xsl:otherwise>
-    <xsl:call-template name="get_constructor_args">
-    <xsl:with-param name="constructor_args" 
-        select="$constructor_args[position()>1]"/>
-    <xsl:with-param name="actual_args" 
-        select="$actual_args[position()>1]"/>
-    <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-    </xsl:call-template>
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:if>
-</xsl:template> 
-
-<xsl:template name="get_induction_hypothesis">
- <xsl:param name="constructor_args" select="/.."/>
- <xsl:param name="actual_args" select="/.."/>
- <xsl:param name="inductive_def_uri" select="''"/>
- <xsl:if test="$constructor_args">
-  <xsl:choose>
-   <xsl:when test="$constructor_args[1]//MUTIND[@uri=$inductive_def_uri]">
-    <m:bvar>
-     <m:ci>
-      <xsl:value-of select="$actual_args[2]/@binder"/>
-     </m:ci>
-     <m:type>
-      <xsl:apply-templates mode="pure" 
-           select="$actual_args[2]/*"/>
-     </m:type>
-    </m:bvar>
-    <xsl:call-template name="get_induction_hypothesis">
-    <xsl:with-param name="constructor_args" 
-        select="$constructor_args[position()>1]"/>
-    <xsl:with-param name="actual_args" 
-        select="$actual_args[position()>2]"/>
-    <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-    </xsl:call-template>
-   </xsl:when>
-   <xsl:otherwise>
-    <xsl:call-template name="get_induction_hypothesis">
-    <xsl:with-param name="constructor_args" 
-        select="$constructor_args[position()>1]"/>
-    <xsl:with-param name="actual_args" 
-        select="$actual_args[position()>1]"/>
-    <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/> 
-    </xsl:call-template>
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:if>
-</xsl:template>
-
-<xsl:template name="get_body">
- <xsl:param name="constructor_args" select="/.."/>
- <xsl:param name="actual_args" select="/.."/>
- <xsl:param name="inductive_def_uri" select="''"/>
- <xsl:param name="target" select="/.."/>
- <xsl:choose>
-  <xsl:when test="$constructor_args">
-   <xsl:choose>
-    <xsl:when test="$constructor_args[1]//MUTIND[@uri=$inductive_def_uri]">
-     <xsl:call-template name="get_body">
-      <xsl:with-param name="constructor_args" 
-        select="$constructor_args[position()> 1]"/>
-      <xsl:with-param name="actual_args" 
-        select="$actual_args[position()> 2]"/>
-      <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-      <xsl:with-param name="target" 
-               select="$target"/>
-     </xsl:call-template>
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:call-template name="get_body">
-      <xsl:with-param name="constructor_args" 
-        select="$constructor_args[position()> 1]"/>
-      <xsl:with-param name="actual_args" 
-        select="$actual_args[position()> 1]"/>
-      <xsl:with-param name="inductive_def_uri" 
-               select="$inductive_def_uri"/>
-      <xsl:with-param name="target" 
-               select="$target"/>
-     </xsl:call-template>
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:choose>
-    <xsl:when test="$actual_args">
-      <xsl:apply-templates select="$actual_args[1]" mode="lambda_prop"/>
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:apply-templates mode="noannot" select="$target"/>
-    </xsl:otherwise>
-   </xsl:choose>
-  </xsl:otherwise> 
- </xsl:choose>
-</xsl:template> 
-
-</xsl:stylesheet>