Skip to content
Wouter Beek edited this page Dec 30, 2015 · 1 revision

1 Internal literal representations

Observations:

  • There are currently 3 compound term representations for literals:
    1. literal(type(D, Lex))
    2. literal(lang(Lang, Lex))
    3. literal(Lex)
  • Simple literals (variant 3) were removed in RDF 1.1. They are now (implicitly typed) XSD strings.
  • RDF 1.1 specifies the values of language-tagged strings as pairs of lexical expression and language tag in that order.

Requirement:

  • rdf(S,P,O) <=> rdf(S,P,X), X=O (steadfastness)

Proposal:

  • Two representations for literals:
    1. TextOrValue^^Type (value for known types)
    2. Text@Lang
  • Output arg binds to above form.
  • Input for query can only be one of the above.
  • RDF assertion predicate converts literal object arguments according to the following table.
Prolog term Prolog lexical form
Integer Integer^^xsd:integer
Float Float^^xsd:double
Atoms true and false Atom^^xsd:boolean
String^^KnownType Value^^KnownType
Atom^^KnownType Value^^KnownType
String^^rdf:langString error
Atom^^rdf:langString error
String^^UnknownType String^^UnknownType
Atom^^UnknownType String^^UnknownType
`[0 1]^^xsd:boolean`
String String^^xsd:string
String@Lang String@Lang
Atom@Lang String@Lang

2 New literal API

Proposal:

  • Add rdf_canonical_literal(+Input, -Canonical)
  • Add rdf_match(S,P,Pattern,O)
  • Add rdf_match(S,P,Pattern,O,G).
    • Pattern is the first arg of current literal(Pattern, Literal), or
    • Pattern for matching language ranges:
  • Remove option convert_typed_literal(:).

3 Datatype support

Datatype Compatibility Prolog type
owl:rational OWL 2 rational OpenIssue2
owl:real OWL 2 TODO
rdf:HTML , RDF 1.1 OpenIssue4
rdf:XMLLiteral OWL 2, RDF 1.1 OpenIssue4
rdf:langString , RDF 1.1 STRING@STRING
xsd:NCName OWL 2, RDF 1.1 TODO
xsd:NMTOKEN OWL 2, RDF 1.1 TODO
xsd:Name OWL 2, RDf 1.1 TODO
xsd:anyURI OWL 2, RDF 1.1 TODO
xsd:base64Binary OWL 2, RDF 1.1 TODO
xsd:boolean OWL 2, RDF 1.1 'true' and 'false'
xsd:byte OWL 2, RDF 1.1 between(-128,127)
xsd:date OWL 1, RDF 1.1 OpenIssue1
xsd:dateTime OWL 2, RDF 1.1 OpenIssue1
xsd:dateTimeStamp OWL 2, RDF 1.1 OpenIssue1
xsd:dayTimeDuration , RDF 1.1 OpenIssue1
xsd:double OWL 2, RDF 1.1 64-bit float OpenIssue3
xsd:decimal OWL 2, RDF 1.1 rational OpenIssue2
xsd:duration , RDF 1.1 OpenIssue1
xsd:float OWL 2, RDF 1.1 32-bit float OpenIssue3
xsd:gDay OWL 1, RDF 1.1 OpenIssue1
xsd:gMonth OWL 1, RDF 1.1 OpenIssue1
xsd:gMonthDay OWL 1, RDF 1.1 OpenIssue1
xsd:gYearMonth OWL 1, RDF 1.1 OpenIssue1
xsd:gYear OWL 1, RDF 1.1 OpenIssue1
xsd:hexBinary OWL 2, RDF 1.1 TODO
xsd:int OWL 2, RDF 1.1 32-bit integer
xsd:integer OWL 2, RDF 1.1 between(-∞,∞) OpenIssue2
xsd:language OWL 2, RDF 1.1 TODO
xsd:long OWL 2, RDF 1.1 64-bit integer
xsd:negativeInteger OWL 2, RDF 1.1 between(-∞,-1) OpenIssue2
xsd:nonNegativeInteger OWL 2, RDF 1.1 between(0,∞) OpenIssue2
xsd:nonPositiveInteger OWL 2, RDF 1.1 between(-∞,0) OpenIssue2
xsd:normalizedString OWL 2, RDF 1.1 TODO
xsd:positiveInteger OWL 2, RDF 1.1 between(1,∞) OpenIssue2
xsd:short OWL 2, RDF 1.1 between(-32768,32767)
xsd:string OWL 2, RDF 1.1 string
xsd:time OWL 1, RDF 1.1 OpenIssue1
xsd:token OWL 2, RDF 1.1 TODO
xsd:unsignedByte OWL 2, RDF 1.1 between(0,255)
xsd:unsignedInt OWL 2 RDF 1.1 between(0,4294967295)
xsd:unsignedLong OWL 2, RDF 1.1 between(0,18446744073709551615)
xsd:unsignedShort OWL 2, RDF 1.1 between(0,65535)
xsd:yearMonthDuration , RDF 1.1 OpenIssue1

Open issues:

  1. Date-time, recurring date-time and duration representations. Two places: internal value space and Prolog representation. There are several options:
    • Value space
      • Canonical strings
      • Time-stamp
    • Prolog representation
      • Canonical strings
      • Time-stamp
      • Compound term or dict. These are expensive to create and parse, so most likely not a good idea.
  2. Countably infinite rationals/decimals/integers cannot be fully supported. An exception/warning may be thrown whenever a rational that is too lage is attempted to be asserted.
  3. Floating point numbers have values that are not covered by Prolog float: NaN, -0, +0, -∞, +∞.
  4. Should HTML/XML literals be stored as serializations or as DOM objects?

TODO:

  • Add equivalence relation for each datatype.
  • Add identity relation for each datatype.
  • How does SPARQL 1.1 compare literals whose datatypes are strict subtypes? E.g., "1"^^xsd:integer < "2"^^xsd:int

4 Literal sorting

Observation:

  • Literals are sorted, but the sorting has little relation to the SPARQL defined ordering. This implies we cannot optimize SPARQL queries that use comparison operators.