+++ /dev/null
-<?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/. -->
-
-<xsl:stylesheet version="0.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-<xsl:param name="CICURI" select="''"/>
-
-<!-- <xsl:output method="html"/> -->
-<xsl:output method="xml"/>
-
-
-<xsl:template match="/">
- <occurrences>
- <xsl:text>
</xsl:text>
- <xsl:apply-templates select="*"/>
- </occurrences>
-</xsl:template>
-
-
-
-
-<!-- AGGIUNGERE cic: alle uri nei file Theory -->
-
-
-<xsl:template match="InductiveDefinition">
- <!-- The case of Inductive Definitions is peculiar due to REL -->
- <!-- Before reading this part, first look at the otherwise case -->
- <xsl:variable name="block" select="."/>
- <xsl:for-each select="InductiveType">
- <xsl:variable name="noType" select="position()"/>
- <xsl:for-each select="Constructor/*[1]">
- <xsl:variable name="noConstr" select="position()"/>
- <xsl:variable name="my_uri"
- select="concat($CICURI,'#','xpointer(1/',$noType,'/',$noConstr,
- ')')"/>
- <xsl:comment><xsl:value-of select="concat($CICURI,'#','xpointer(1/',$noType,')')"/></xsl:comment>
- <xsl:text>
</xsl:text>
- <main uri="{$my_uri}"/>
- <xsl:text>
</xsl:text>
- <xsl:variable name="inside_concl">
- <xsl:call-template name="look_for_main">
- <xsl:with-param name="current" select="."/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$my_uri"/>
- <xsl:with-param name="list" select="$inside_concl"/>
- <xsl:with-param name="kind" select="'in_conclusion'"/>
- </xsl:call-template>
- <xsl:variable name="main_hypothesis">
- <xsl:call-template name="look_for_main_hypothesis_of_constructor">
- <xsl:with-param name="current" select="."/>
- <xsl:with-param name="list" select="''"/>
- <xsl:with-param name="inductive_block" select="$block"/>
- <xsl:with-param name="inductive_uri" select="$CICURI"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$my_uri"/>
- <xsl:with-param name="list" select="$main_hypothesis"/>
- <xsl:with-param name="kind" select="'main_hypothesis'"/>
- </xsl:call-template>
- <xsl:variable name="inside_hypothesis">
- <xsl:call-template name="look_for_hypothesis">
- <xsl:with-param name="current" select="."/>
- <xsl:with-param name="list" select="''"/>
- <xsl:with-param name="not_in" select="$main_hypothesis"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$my_uri"/>
- <xsl:with-param name="list" select="$inside_hypothesis"/>
- <xsl:with-param name="kind" select="'in_hypothesis'"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="Definition|Axiom|CurrentProof|Variable">
- <!-- Definition, Axiom, CurrentProof and Variable -->
- <!-- all of them have a type -->
- <!-- first look for the main target of the type -->
- <!-- inside_concl contains the list of all identifiers occurring -->
- <!-- in the main target of the type. The main identifiers, if it -->
- <!-- exists, is in head position, separated by a comma form the -->
- <!-- other elements. All other elements are separated by a semicolon -->
- <xsl:variable name="inside_concl">
- <xsl:call-template name="look_for_main">
- <xsl:with-param name="current" select="type/*[1]"/>
- </xsl:call-template>
- </xsl:variable>
- <!-- variable main contains the (possibly empty) uri of the "main"
- identifier -->
- <xsl:variable name="main" select="substring-before($inside_concl,',')"/>
- <xsl:choose>
- <xsl:when test="$main = ''">
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$CICURI"/>
- <xsl:with-param name="list" select="$inside_concl"/>
- <xsl:with-param name="kind" select="'in_conclusion'"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:comment><xsl:value-of select="$main"/></xsl:comment>
- <xsl:text>
</xsl:text>
- <main uri="{$CICURI}"/>
- <xsl:text>
</xsl:text>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$CICURI"/>
- <xsl:with-param name="list" select="substring-after($inside_concl,',')"/>
- <xsl:with-param name="kind" select="'in_conclusion'"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- <!-- now look for the main identifiers inside the hipothesis -->
- <xsl:variable name="main_hypothesis">
- <xsl:call-template name="look_for_main_hypothesis">
- <xsl:with-param name="current" select="type/*[1]"/>
- <xsl:with-param name="list" select="''"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$CICURI"/>
- <xsl:with-param name="list" select="$main_hypothesis"/>
- <xsl:with-param name="kind" select="'main_hypothesis'"/>
- </xsl:call-template>
- <!-- now look for the all other identifiers inside the hipothesis -->
- <xsl:variable name="inside_hypothesis">
- <xsl:call-template name="look_for_hypothesis">
- <xsl:with-param name="current" select="type/*[1]"/>
- <xsl:with-param name="list" select="''"/>
- <xsl:with-param name="not_in" select="$main_hypothesis"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$CICURI"/>
- <xsl:with-param name="list" select="$inside_hypothesis"/>
- <xsl:with-param name="kind" select="'in_hypothesis'"/>
- </xsl:call-template>
- <!-- Definition, Axiom, CurrentProof and Variable possibly -->
- <!-- have a body -->
- <xsl:if test="body">
- <xsl:variable name="inside_body">
- <xsl:call-template name="list_all">
- <xsl:with-param name="node" select="body/*[1]"/>
- <xsl:with-param name="not_in" select="concat($inside_hypothesis,';',$main_hypothesis,';',$inside_concl)"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$CICURI"/>
- <xsl:with-param name="list" select="$inside_body"/>
- <xsl:with-param name="kind" select="'in_body'"/>
- </xsl:call-template>
- </xsl:if>
-</xsl:template>
-
- <!-- look_for_main recursively descend along the type looking for -->
- <!-- the main target. Then returns the list of all identifiers occurring -->
- <!-- in it. The main identifiers, if it exists, is in head position, -->
- <!-- separated by a comma form the other elements. -->
- <!-- All other elements are separated by a semicolon -->
-
-<xsl:template name="look_for_main">
- <xsl:param name="current" select="/.."/>
- <xsl:choose>
- <xsl:when test="name($current) = 'PROD'">
- <xsl:call-template name="look_for_main">
- <xsl:with-param name="current" select="$current/target/*[1]"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="main">
- <xsl:choose>
- <xsl:when test="name($current) = 'APPLY'">
- <xsl:call-template name="get_expanded_name">
- <xsl:with-param name="node" select="$current/*[1]"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="get_expanded_name">
- <xsl:with-param name="node" select="$current"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$main != ''">
- <xsl:value-of select="$main"/><xsl:text>,</xsl:text>
- <xsl:call-template name="list_all">
- <xsl:with-param name="node" select="$current"/>
- <xsl:with-param name="not_in" select="$main"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list_all">
- <xsl:with-param name="node" select="$current"/>
- <xsl:with-param name="not_in" select="''"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- in case "node" is a CONST, MUTIND or MUTCONSTRUCT, the -->
-<!-- function get_expanded_name returns the (expanded) uri of the -->
-<!-- node. Otherwise it returns an empty string -->
-
-<xsl:template name="get_expanded_name">
- <xsl:param name="node" select="/.."/>
- <xsl:choose>
- <xsl:when test="name($node)='CONST'">
- <xsl:value-of select="$node/@uri"/>
- </xsl:when>
- <xsl:when test="name($node)='MUTIND'">
- <xsl:variable name="noType" select="$node/@noType + 1"/>
- <xsl:value-of select="concat($node/@uri,'#','xpointer(1/',
- $noType,')')"/>
- </xsl:when>
- <xsl:when test="name($node)='MUTCONSTRUCT'">
- <xsl:variable name="noType" select="$node/@noType + 1"/>
- <xsl:value-of select="concat($node/@uri,'#','xpointer(1/',
- $noType,'/',$node/@noConstr,')')"/>
- </xsl:when>
- </xsl:choose>
-</xsl:template>
-
-
-<xsl:template name="get_expanded_name_with_rel_case">
- <xsl:param name="node" select="/.."/>
- <xsl:param name="inductive_block" select="/.."/>
- <xsl:param name="inductive_uri" select="''"/>
- <xsl:choose>
- <xsl:when test="name($node)='CONST'">
- <xsl:value-of select="$node/@uri"/>
- </xsl:when>
- <xsl:when test="name($node)='MUTIND'">
- <xsl:variable name="noType" select="$node/@noType + 1"/>
- <xsl:value-of select="concat($node/@uri,'#','xpointer(1/',
- $noType,')')"/>
- </xsl:when>
- <xsl:when test="name($node)='MUTCONSTRUCT'">
- <xsl:variable name="noType" select="$node/@noType + 1"/>
- <xsl:value-of select="concat($node/@uri,'#','xpointer(1/',
- $noType,'/',$node/@noConstr,')')"/>
- </xsl:when>
- <xsl:when test="name($node)='REL'">
- <xsl:variable name="binder" select="$node/@binder"/>
- <xsl:if test="$inductive_block/InductiveType[@name=$binder]">
- <xsl:variable name="position">
- <xsl:for-each select="$inductive_block/InductiveType">
- <xsl:if test="@name=$binder">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:value-of select="concat($inductive_uri,'#','xpointer(1/',
- $position,')')"/>
- </xsl:if>
- </xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- The function look_for_main_hypothesis returns the list of all
- the uris of identifiers occurring in head position of some
- of the hypothesis -->
-
-<xsl:template name="look_for_main_hypothesis">
- <xsl:param name="current" select="/.."/>
- <xsl:param name="list" select="''"/>
- <xsl:choose>
- <xsl:when test="name($current) = 'PROD'">
- <xsl:variable name="source" select="$current/source/*[1]"/>
- <xsl:variable name="main">
- <xsl:choose>
- <xsl:when test="name($source) = 'APPLY'">
- <xsl:call-template name="get_expanded_name">
- <xsl:with-param name="node" select="$source/*[1]"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="get_expanded_name">
- <xsl:with-param name="node" select="$source"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="($main != '') and (not(contains($list,$main)))">
- <xsl:call-template name="look_for_main_hypothesis">
- <xsl:with-param name="current" select="$current/target/*[1]"/>
- <xsl:with-param name="list" select="concat($main,';',$list)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="look_for_main_hypothesis">
- <xsl:with-param name="current" select="$current/target/*[1]"/>
- <xsl:with-param name="list" select="$list"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$list"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="look_for_main_hypothesis_of_constructor">
- <xsl:param name="current" select="/.."/>
- <xsl:param name="list" select="''"/>
- <xsl:param name="inductive_block" select="/.."/>
- <xsl:param name="inductive_uri" select="''"/>
- <xsl:choose>
- <xsl:when test="name($current) = 'PROD'">
- <xsl:variable name="source" select="$current/source/*[1]"/>
- <xsl:variable name="main">
- <xsl:choose>
- <xsl:when test="name($source) = 'APPLY'">
- <xsl:call-template name="get_expanded_name_with_rel_case">
- <xsl:with-param name="node" select="$source/*[1]"/>
- <xsl:with-param name="inductive_block" select="$inductive_block"/>
- <xsl:with-param name="inductive_uri" select="$inductive_uri"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="get_expanded_name_with_rel_case">
- <xsl:with-param name="node" select="$source"/>
- <xsl:with-param name="inductive_block" select="$inductive_block"/>
- <xsl:with-param name="inductive_uri" select="$inductive_uri"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="($main != '') and (not(contains($list,$main)))">
- <xsl:call-template name="look_for_main_hypothesis_of_constructor">
- <xsl:with-param name="current" select="$current/target/*[1]"/>
- <xsl:with-param name="list" select="concat($main,';',$list)"/>
- <xsl:with-param name="inductive_block" select="$inductive_block"/>
- <xsl:with-param name="inductive_uri" select="$inductive_uri"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="look_for_main_hypothesis_of_constructor">
- <xsl:with-param name="current" select="$current/target/*[1]"/>
- <xsl:with-param name="list" select="$list"/>
- <xsl:with-param name="inductive_block" select="$inductive_block"/>
- <xsl:with-param name="inductive_uri" select="$inductive_uri"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$list"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- look_for_hypothesis returns the list of uris of all other
-identifiers occurring inside the hypothesis -->
-
-<xsl:template name="look_for_hypothesis">
- <xsl:param name="current" select="/.."/>
- <xsl:param name="list" select="''"/>
- <xsl:param name="not_in" select="''"/>
- <xsl:choose>
- <xsl:when test="name($current) = 'PROD'">
- <xsl:variable name="source" select="$current/source/*[1]"/>
- <xsl:variable name="add_to_list">
- <xsl:call-template name="list_all">
- <xsl:with-param name="node" select="$source"/>
- <xsl:with-param name="not_in" select="$not_in"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="look_for_hypothesis">
- <xsl:with-param name="current" select="$current/target/*[1]"/>
- <xsl:with-param name="list" select="concat($list,$add_to_list)"/>
- <xsl:with-param name="not_in" select="concat($not_in,$add_to_list)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$list"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- list_all returns a list of all uris of CONST, MUTIND, and MUTCONSTRUCT -->
-<!-- elements appearing inside a given node, and not already contained -->
-<!-- in the not_in list -->
-
-<xsl:template name="list_all">
- <xsl:param name="node" select="/.."/>
- <xsl:param name="not_in" select="''"/>
- <xsl:variable name="all">
- <xsl:choose>
- <xsl:when test="$not_in = ''">
- <xsl:for-each select="$node//*[name()='CONST' or name()='MUTIND' or name()='MUTCONSTRUCT']">
- <xsl:sort select="@uri"/>
- <xsl:sort select="@noType"/>
- <xsl:sort select="@noConstr"/>
- <xsl:call-template name="get_expanded_name">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- <xsl:text>;</xsl:text>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:for-each select="$node//*[(name()='CONST' and not(contains($not_in,@uri))) or (name()='MUTIND' and not(contains($not_in,concat(@uri,'#','xpointer(1/',@noType + 1,')')))) or (name()='MUTCONSTRUCT' and not(contains($not_in,concat(@uri,'#','xpointer(1/',@noType + 1,'/'
-,@noConstr,')'))))]">
- <xsl:sort select="@uri"/>
- <xsl:sort select="@noType"/>
- <xsl:sort select="@noConstr"/>
- <xsl:call-template name="get_expanded_name">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- <xsl:text>;</xsl:text>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:call-template name="drop_repetitions">
- <xsl:with-param name="head" select="''"/>
- <xsl:with-param name="tail" select="$all"/>
- </xsl:call-template>
-</xsl:template>
-
-<!-- This is a different possible implementation of list_all -->
-<!-- It seems to be less effective than the previous one -->
-<!--
-<xsl:template name="list_all">
- <xsl:param name="node" select="/.."/>
- <xsl:param name="not_in" select="''"/>
- <xsl:apply-templates select="$node/*[1]" mode="list_all">
- <xsl:with-param name="not_in" select="$not_in"/>
- </xsl:apply-templates>
-</xsl:template>
-
-<xsl:template match="*" mode="list_all">
- <xsl:param name="not_in" select="''"/>
- <xsl:variable name="uri_to_add">
- <xsl:choose>
- <xsl:when test="name()='CONST' and not(contains($not_in,@uri))">
- <xsl:value-of select="@uri"/><xsl:text>;</xsl:text>
- </xsl:when>
- <xsl:when test="name()='MUTIND' and not(contains($not_in,concat(@uri,'#',@noType)))">
- <xsl:value-of select="concat(@uri,'#',@noType)"/><xsl:text>;</xsl:text>
- </xsl:when>
- <xsl:when test="name()='MUTCONSTRUCT' and not(contains($not_in,concat(@uri,'#',@noType,'#',@noConstr)))">
- <xsl:value-of select="concat(@uri,'#',@noType,'#',@noConstr)"/><xsl:text>;</xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:value-of select="$uri_to_add"/>
- <xsl:variable name="child_list">
- <xsl:if test="count(child::*) != 0">
- <xsl:apply-templates select="*[1]" mode="list_all">
- <xsl:with-param name="not_in" select="concat($not_in,$uri_to_add)"/>
- </xsl:apply-templates>
- </xsl:if>
- </xsl:variable>
- <xsl:value-of select="$child_list"/>
- <xsl:if test="count(following-sibling::*) != 0">
- <xsl:apply-templates select="following-sibling::*[1]" mode="list_all">
- <xsl:with-param name="not_in" select="concat($not_in,$uri_to_add,$child_list)"/>
- </xsl:apply-templates>
- </xsl:if>
-</xsl:template>
--->
-
-<!-- The drop_repetitions function drops all repeated strigs in a -->
-<!-- ORDERED list of strings separated by semicolons -->
-
-<xsl:template name="drop_repetitions">
- <xsl:param name="head" select="''"/>
- <xsl:param name="tail" select="''"/>
- <xsl:if test="not($tail = '')">
- <xsl:variable name="newhead" select="substring-before($tail,';')"/>
- <xsl:variable name="newtail" select="substring-after($tail,';')"/>
- <xsl:if test="not($newhead = $head)">
- <xsl:value-of select="$newhead"/><xsl:text>;</xsl:text>
- </xsl:if>
- <xsl:call-template name="drop_repetitions">
- <xsl:with-param name="head" select="$newhead"/>
- <xsl:with-param name="tail" select="$newtail"/>
- </xsl:call-template>
- </xsl:if>
-</xsl:template>
-
-<!-- the function build_pairs takes in input a uri (uri), -->
-<!-- a list of uris (list) and a "kind" string, and returns -->
-<!-- a list of xml elements name "kind containing as first -->
-<!-- attribute an element of the list and as second attribute -->
-<!-- the given uri -->
-<xsl:template name="build_pairs">
- <xsl:param name="uri" select="''"/>
- <xsl:param name="list" select="''"/>
- <xsl:param name="kind" select="''"/>
- <xsl:if test="$list != ''">
- <xsl:variable name="head" select="substring-before($list,';')"/>
- <xsl:variable name="tail" select="substring-after($list,';')"/>
- <xsl:comment><xsl:value-of select="$head"/></xsl:comment>
- <xsl:text>
</xsl:text>
- <xsl:element name="{$kind}">
- <xsl:attribute name="uri"><xsl:value-of select="$uri"/></xsl:attribute>
- </xsl:element>
- <xsl:text>
</xsl:text>
- <xsl:call-template name="build_pairs">
- <xsl:with-param name="uri" select="$uri"/>
- <xsl:with-param name="list" select="$tail"/>
- <xsl:with-param name="kind" select="$kind"/>
- </xsl:call-template>
- </xsl:if>
-</xsl:template>
-
-
-
-</xsl:stylesheet>
-
-
-
-
-
-
-
-
-
-
-
-
-