<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24568</bug_id>
          
          <creation_ts>2014-02-06 21:26:47 +0000</creation_ts>
          <short_desc>Is the type system really a lattice?  Or just a partially ordered set?</short_desc>
          <delta_ts>2014-10-20 12:28:53 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Data Model 3.0</component>
          <version>Proposed Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>24569</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="C. M. Sperberg-McQueen">cmsmcq</reporter>
          <assigned_to name="Norman Walsh">ndw</assigned_to>
          <cc>andrew_coleman</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>99953</commentid>
    <comment_count>0</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2014-02-06 21:26:47 +0000</bug_when>
    <thetext>Section 2.7.4 Type system of the XDM PR draft [1] reads in part:

  Item types in the data model form a lattice rather than a hierarchy: 
  in the relationship defined by the derived-from(A, B) function, 
  some types are derived from more than one other type. Examples 
  include functions (function(xs:string) as xs:int is substitutable 
  for function(xs:NCName) as xs:int and also for function(xs:string) 
  as xs:decimal), and union types (A is substitutable for union(A, B) 
  and also for union(A, C).

[1] http://www.w3.org/TR/xpath-datamodel-30/#types-hierarchy

The text is correct to say that the set of types does not form a hierarchy.  But do they form a lattice?  

My understanding (such as it is) is that a partially ordered set forms a lattice if and only if for any two members a and b of the set, there is a unique least upper bound of a and b, and a unique greatest lower bound for a and b.  

In section 19.2 [2], XSLT 3.0 says that two items do not necessarily have a unique  least upper bound (join):

  In some cases the above entries require computation of the least 
  common type of two types T and U. Since item types form a lattice 
  rather than a hierarchy, there may be a set of types V such that 
  T and U are both subtypes of every type in V, and no type in V 
  is unambiguously the &quot;least&quot; common type in the sense that all 
  the others are subtypes of it. In this situation the choice of 
  which type in V to use as the inferred static type is 
  implementation-defined.

[2] http://www.w3.org/TR/xslt-30/#determining-static-type

I&apos;m not sure what pairs of items the XSLT spec has in mind, but if they exist, then it may be wrong to say that our types form a lattice.

Unions are perhaps a sufficient example.  Since XSD&apos;s union types are ordered (so the unions (A, B) and (B, A) are both supersets of both A and B), and there will be no other types definable in XSD which are intermediate between them and A or B, so they are both least upper bounds for the pair A and B.

Functions (to take the other example named in the paragraph quoted from XDM) are described by XPath as forming a hierarchy -- but if we accept A and B as subtypes of both union(A, B) and union(B, A) then functions don&apos;t form a hierarchy, either.

If the sequence of membertypes in the definition of unions is NOT considered significant for these purposes, then perhaps it is correct after all to say that the type system forms a lattice.  But before deciding that all is well, it would be a good idea to find out why XSLT 3.0 says there may not be a unique least common type (which I am taking to mean least upper bound, or join) for two item types.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113029</commentid>
    <comment_count>1</comment_count>
    <who name="Norman Walsh">ndw</who>
    <bug_when>2014-10-13 16:36:37 +0000</bug_when>
    <thetext>The minutes of XML Query WG Face-To-Face Meeting #563 Minutes -- 2014-02-17 DAY ONE (https://lists.w3.org/Archives/Member/w3c-xsl-query/2014Feb/0095.html)
record:

J4.1.1 Bug 24568 - Is the type system really a lattice? Or just a 
partially ordered set?
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24568

Mike: I think that if you look at it certain ways the types may form a 
lattice, but if you look at just the types you have syntax for they 
don&apos;t. Propose removing the claim that it is a lattice.

No objections.

DECISION: Make the editorial change to remove the description of the 
type system as a lattice, adding a note that the type system is not a 
hierarchy.

In addition, I see that the 3.1 data model now says, in part:

&quot;Item types in the data model form a directed graph, rather than a hierarchy or lattice: ...&quot;

I propose that this bug can be closed as overtaken by events.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>