]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/style_prima_del_linguaggio_naturale/set.xsl
Added style before natural language synthesis
[helm.git] / helm / style / style_prima_del_linguaggio_naturale / set.xsl
diff --git a/helm/style/style_prima_del_linguaggio_naturale/set.xsl b/helm/style/style_prima_del_linguaggio_naturale/set.xsl
new file mode 100644 (file)
index 0000000..303c872
--- /dev/null
@@ -0,0 +1,487 @@
+<?xml version="1.0"?>
+
+<!--******************************************************************--> 
+<!-- Basic Set Theory                                                 -->
+<!-- First draft: April 3 2000                                        -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                 -->
+<!--******************************************************************-->
+
+<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">
+
+<!--******************************************************************-->
+<!-- Variable containing the absolute path of the CIC file            -->
+<!--******************************************************************-->
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- ************************* LOGIC *********************************-->
+
+
+
+<xsl:template match="*" mode="set">
+    <xsl:choose>
+     <xsl:when test="name() = 'LAMBDA'">
+      <m:set>
+       <m:bvar>
+        <m:ci>
+         <xsl:value-of select="target/@binder"/>
+        </m:ci>
+        <m:type>
+         <xsl:apply-templates select="source" mode="noannot"/>
+        </m:type>
+       </m:bvar>
+       <m:condition>
+        <xsl:apply-templates select="target" mode="noannot"/>
+       </m:condition>
+      </m:set>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-templates select="." mode="noannot"/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+
+<!-- IN -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/In.con']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:in definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+       <!-- <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/> -->
+       <xsl:apply-templates select="*[2+$no_params]" mode="set" /> 
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+
+<!-- NOT-IN -->
+<!-- NOT ha no parameters -->
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/INIT/Logic/not.con']
+and (count(child::*) = 2) and APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/In.con']]]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="APPLY/CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(APPLY/child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:notin/>
+       <xsl:apply-templates select="*[2]/*[3+$no_params]" mode="noannot"/>
+  <!-- <xsl:apply-templates select="*[2]/*[2+$no_params]" mode="noannot"/> -->
+       <xsl:apply-templates select="*[2]/*[2+$no_params]" mode="set"/>  
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- EMPTY SET -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Empty_set.ind']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 1">
+      <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+      </m:set>
+     </xsl:when>   
+     <xsl:when test="(count(child::*) - number($no_params)) = 2">
+      <m:apply helm:xref="{@id}">
+       <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+       <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+       </m:set>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- SINGLETON -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Singleton.ind']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 2">
+      <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+       <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+      </m:set>
+     </xsl:when>   
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+       <m:set definitionURL="{MUTIND/@uri}">
+        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+       </m:set>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- COUPLE -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Couple.ind']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+       <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+      </m:set>
+     </xsl:when>   
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:apply helm:xref="{@id}">
+       <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       <m:set definitionURL="{MUTIND/@uri}">
+        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+       </m:set>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- TRIPLE -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Triple.ind'] and (count(child::*) = 5)]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:set definitionURL="{MUTIND/@uri}" helm:xref="{@id}">
+       <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+      </m:set>
+     </xsl:when>   
+     <xsl:when test="(count(child::*) - number($no_params)) = 5">
+      <m:apply helm:xref="{@id}">
+       <m:in definitionURL="cic:/coq/SETS/Ensembles/Ensembles/In.con"/>
+       <xsl:apply-templates select="*[5+$no_params]" mode="noannot"/>
+       <m:set definitionURL="{MUTIND/@uri}">
+        <xsl:apply-templates select="*[2+$no_params]" mode="noannot"/>
+        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+        <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       </m:set>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- INTERSECTION -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Intersection.ind']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:intersect definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+      </m:apply>
+     </xsl:when>
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:apply helm:xref="{@id}">
+       <m:in/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       <m:apply>
+        <m:intersect definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+       </m:apply>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+
+<!-- UNION -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Union.ind']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:union definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+      </m:apply>
+     </xsl:when>
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:apply helm:xref="{@id}">
+       <m:in/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       <m:apply>
+        <m:union definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+       </m:apply>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- INCLUDED -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Included.con']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:subset definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- STRICTLY INCLUDED -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Strict_Included.con']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:prsubset definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- SET-DIFF -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Setminus.con']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+      </m:apply>
+     </xsl:when>
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:apply helm:xref="{@id}">
+       <m:in/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       <m:apply>
+        <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+        <xsl:apply-templates select="*[3+$no_params]" mode="set"/>
+       </m:apply>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- ADD-ELEM -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Add.con']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:union definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <m:set>
+        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+       </m:set>
+      </m:apply>
+     </xsl:when>
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:apply helm:xref="{@id}">
+       <m:in/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       <m:apply>
+        <m:union definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+        <m:set>
+         <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+        </m:set>
+       </m:apply>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- SUBTRACT-ELEM -->
+
+<xsl:template match="APPLY[CONST[attribute::uri='cic:/coq/SETS/Ensembles/Ensembles/Subtract.con']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="CONST/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+       <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       <m:set>
+        <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+       </m:set>
+      </m:apply>
+     </xsl:when>
+     <xsl:when test="(count(child::*) - number($no_params)) = 4">
+      <m:apply helm:xref="{@id}">
+       <m:in/>
+       <xsl:apply-templates select="*[4+$no_params]" mode="noannot"/>
+       <m:apply>
+        <m:setdiff definitionURL="{CONST/@uri}" helm:xref="{CONST/@id}"/>
+        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+        <m:set>
+         <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+        </m:set>
+       </m:apply>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- CARD -->
+
+<xsl:template match="APPLY[MUTIND[attribute::uri='cic:/coq/SETS/Finite_sets/Ensembles_finis/cardinal.ind']]" mode="noannot">
+    <xsl:variable name="no_params">
+     <xsl:call-template name="get_no_params">
+      <xsl:with-param name="first_uri" select="/cicxml/@uri"/>
+      <xsl:with-param name="second_uri" select="MUTIND/@uri"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="(count(child::*) - number($no_params)) = 3">
+      <m:apply helm:xref="{@id}">
+       <m:eq/>
+       <m:apply>
+        <m:card definitionURL="{MUTIND/@uri}" helm:xref="{MUTIND/@id}"/>
+        <xsl:apply-templates select="*[2+$no_params]" mode="set"/>
+       </m:apply>
+       <xsl:apply-templates select="*[3+$no_params]" mode="noannot"/>
+      </m:apply>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-imports/>
+     </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+