From 8e07ca3dd592b9b32049ace3e3e0995bf9d1a0b1 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Wed, 13 Nov 2024 14:58:32 +0100 Subject: [PATCH 01/16] add section about 'unstar' mapping as per https://github.com/w3c/rdf-star-wg/issues/129 --- spec/ex-unstar-input.trig | 10 ++ spec/ex-unstar-input2.trig | 10 ++ spec/ex-unstar-output.trig | 19 ++++ spec/index.html | 184 ++++++++++++++++++++++++++++++++++++- 4 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 spec/ex-unstar-input.trig create mode 100644 spec/ex-unstar-input2.trig create mode 100644 spec/ex-unstar-output.trig diff --git a/spec/ex-unstar-input.trig b/spec/ex-unstar-input.trig new file mode 100644 index 0000000..246e938 --- /dev/null +++ b/spec/ex-unstar-input.trig @@ -0,0 +1,10 @@ +PREFIX rdf: +PREFIX ex: + +<< ex:s ex:p ex:o >> ex:q "some value". + +GRAPH ex:g { + ex:s ex:p ex:o. + ex:s ex:p ex:o2. +} + diff --git a/spec/ex-unstar-input2.trig b/spec/ex-unstar-input2.trig new file mode 100644 index 0000000..fdfd58d --- /dev/null +++ b/spec/ex-unstar-input2.trig @@ -0,0 +1,10 @@ +PREFIX rdf: +PREFIX ex: + +_:r1 rdf:reifies <<( ex:s ex:p ex:o )>>. +_:r1 ex:q "some value". + +GRAPH ex:g { + ex:s ex:p ex:o. + ex:s ex:p ex:o2. +} diff --git a/spec/ex-unstar-output.trig b/spec/ex-unstar-output.trig new file mode 100644 index 0000000..28c741e --- /dev/null +++ b/spec/ex-unstar-output.trig @@ -0,0 +1,19 @@ +PREFIX rdf: +PREFIX ex: + +_:r1 rdf:reifies _:gen1. +_:r1 ex:q "some value". + +GRAPH ex:g { + ex:s ex:p ex:o. + ex:s ex:p ex:o2. +} + +GRAPH _:gen1 { + ex:s ex:p ex:o. +} + +GRAPH rdf:unstarMetadata { + _:gen1 rdf:type rdf:TripleTerm. +} + diff --git a/spec/index.html b/spec/index.html index aaaa9f8..cbdb657 100644 --- a/spec/index.html +++ b/spec/index.html @@ -49,6 +49,19 @@ .grammar-literal { color: gray;} code {color: #ff4500;} /* Old W3C Style */ div.abnf {margin-left: 1em;} + + .algorithm ol { + counter-reset: numsection; + list-style-type: none; + } + .algorithm ol>li { + margin: 0.5em 0; + } + .algorithm ol>li:before { + font-weight: bold; + counter-increment: numsection; + content: counters(numsection, ".") ") "; + } @@ -498,12 +511,12 @@

RDF Documents and Syntaxes

This specification establishes two conformance levels:

    -
  • Full conformance +
  • Full conformance supports graphs and datasets with triples that contain triple terms. Concrete syntaxes in which such graphs and datasets can be expressed include [[RDF12-N-TRIPLES]], [[RDF12-N-QUADS]], [[RDF12-TURTLE]], and [[RDF12-TRIG]].
  • -
  • Classic conformance +
  • Classic conformance only supports graphs or datasets with triples that do not contain triple terms.
@@ -1450,6 +1463,173 @@

Generalizations of RDF Triples, Graphs, and Datasets

+
+

Interoperability between RDF [=Classic=] and RDF [=Full=]

+ +

This section provides transformations between RDF [=Classic=] datasets and RDF [=Full=] datasets, + to provide some level of interoperability between the different classes of Conformance. + +

Should we go even further and aim to provide interoperability between RDF 1.1 and RDF 1.2 [=Full=]?

+ +

It defines the `unstar` algorithm, which transforms an RDF [=Full=] dataset into an RDF [=Classic=] dataset by encoding all triple-terms into dedicated named graphs. + This algorithm is designed to be: +

+ +
+
Information preserving
+
It must be possible to reconstruct the input dataset from the output dataset. + Note that, on the other hand, the algorithm is not designed to be semantics preserving: + the graphs in the produced dataset are not semantically equivalent to their corresponding graph in the input dataset. +
+
Idempotent
+
Transforming a dataset that is already complying with RDF [=Classic=] (i.e. containing no triple term) must result in the same dataset. +
+
Universal
+
It should be possible to transform any RDF [=Full=] dataset using this method. + There is actually a minor caveat to this property. +
+
+ + +

The general principle of the `unstar` algorithm is to replace each triple term `S P O` in the input dataset with a fresh blank node. + This blank node is then use as the name of a new named graph containing a single triple `S P O`. + In order to distinguish those new named graphs from the original named graphs of the input dataset, + dedicated triples are added to a special `rdf:unstarMetadata` named graph.

+ +

The blank nodes generated by `unstar` to replace triple terms should not be confused with the reifiers that are typically associated to these triple terms.

+ +

Despite having the same name, the `unstar` mapping defined in this specification is different from the `unstar` mapping defined in [[RDF-STAR-CG]].

+ + +
+

The `unstar` algorithm

+ +

The algorithm expects one input variable Dᵢ which is an RDF dataset. It returns a [=Classic=] RDF dataset. + In the algorithm, we adopt the view presented in . +

+ +
    +
  1. Let Dₒ be an empty RDF dataset.
  2. +
  3. Let bnodes be an empty map from triple terms to blank nodes.
  4. +
  5. Let inputKind be `null`.
  6. +
  7. For each quad (s, p, o, g) in Dᵢ:
      +
    1. If g is not `null` and is the IRI `rdf:unstarMetadata`, then:
        +
      1. If inputKind is `"full"` then exit with an error.
      2. +
      3. Otherwise, set inputKind to `"classic"`.
      4. +
    2. +
    3. If o is a triple term, then:
        +
      1. If inputKind is `"classic"` then exit with an error.
      2. +
      3. Otherwise, set inputKind to `"full"`.
      4. +
      5. Let b, M' and D' be the result of invoking `quote-triple-term` passing o as t and M as Mi.
      6. +
      7. Merge M' into M. +
      8. Merge D' into Dₒ. +
      9. Set o to b. +
    4. +
    5. Add the quad (s, p, o, g) to Dₒ.
    6. +
  8. +
  9. Return Dₒ.
  10. +
+
+ +
+

The `quote-triple-term` algorithm

+ +

This algorithm is responsible for incrementally populating the mapping M and the dataset D used internally by the `unstar` algorithm. It receives a triple term as input and processes it recursively (in case its object is itself a triple term). It returns, among other things, the blank node minted to replace the triple term in the transformed [=Classic=] RDF dataset.

+ +

This algorithm expects two input variables: + a triple term t, + and a map Mᵢ from triple terms to blank nodes. + It returns a blank node b, + a map Mₒ from triple terms to blank nodes, + and a [=Classic=] RDF dataset D. + In the algorithm, we adopt the view presented in . +

+ +
    +
  1. Let Mₒ be an empty map.
  2. +
  3. Let D be an empty RDF dataset.
  4. +
  5. If Mᵢ contains a blank node b associated with t, then return b, Mₒ and D. +
  6. Otherwise:
      +
    1. Let s, p and o be the subject, predicate and object of t, respectively.
    2. +
    3. If o is a triple term, then:
        +
      1. Let b', M' and D' be the result of invoking `quote-triple-term` passing o as t and Mᵢ.
      2. +
      3. Set o to b'. +
      4. Merge M' into Mₒ. +
      5. Merge D' into D. +
    4. +
    5. Let b be a fresh blank node.
    6. +
    7. Add the association (t, b) to Mₒ.
    8. +
    9. Add the quads (s, p, o, b) and (b, `rdf:type`, `rdf:TripleTerm`, `rdf:unstarMetadata`) in D.
    10. +
    11. Return b, Mₒ and D.
    12. +
  7. +
+ +

+ In step 4.3 of this algorithm, + it is assumed that the blank node b is distinct from any blank node already in use in any dataset at hand, + in particular the dataset being processed in the invoking `unstar` algorithm. + Some implementations may require that `unstar` passes that dataset to `quote-triple-term` to ensure this constraint. +

+ +
+ +
+

Limitations of the `unstar` algorithm

+ +

Steps 4.1.1 and 4.2.1 of the `unstar` algorithm exit with an error. + This will occur if the input dataset contains at the same time triple terms and a graph named `rdf:unstarMetadata`. + The `unstar` algorithm is therefore not strictly universal as it can not transform this particular kind of datasets. +

+ +

This limitation should not be an issue in practice. + The special graph name `rdf:unstarMapping` is unlikely to be in used in any published dataset, + as it was not defined in the RDF namespace prior to this specification. + For this reason, using it would actually have been bad practice. + As for future datasets, their authors should consider the graph name `rdf:unstarMetadata` to be reserved, in order to prevent interference with the `unstar` algorithm. +

+ +

Another consequence of this restriction is that users should be careful when merging dataset in an application that makes use of the `unstar` algorithm. + More precisely, merging a [=Full=] RDF dataset (containing at least one triple term) + with a [=Classic=] RDF dataset resulting from the application of `unstar` (and therefore containing an `rdf:unstarMetadata` named graph) + would result in a "hybrid" dataset that `unstar` can not process. + Such application should make sure to apply `unstar` to every dataset priori to merging them. + Since `unstar` is idempotent, there is no harm in applying it more than necessary.

+ +
+ +

We should probably provide the `restar` algorithm, the opposite of `unstar`.

+ +
+

Example of applying the `unstar` algorithm

+ +

The examples in this section are using the Trig concrete syntax [[RDF12-TRIG]].

+ +

+
+    

+
+    

+
+  
+ + +
+

Additional Datatypes

This section defines additional datatypes that RDF processors MAY support.

From d42fabc623923ec4a4bc3548884c232326be95c9 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Fri, 29 Nov 2024 15:11:47 +0100 Subject: [PATCH 02/16] change the unstar algorithm so that - unstarring a graph now produce a graph (not a dataset) - it uses the reification vocabulary (with a distinctinve type rdf:UnstarredTripleTerm) --- ...-unstar-input.trig => ex-unstar-input.ttl} | 5 - ...nstar-input2.trig => ex-unstar-input2.ttl} | 5 - spec/ex-unstar-output.trig | 19 ---- spec/ex-unstar-output.ttl | 11 +++ spec/index.html | 93 ++++++++++--------- 5 files changed, 59 insertions(+), 74 deletions(-) rename spec/{ex-unstar-input.trig => ex-unstar-input.ttl} (71%) rename spec/{ex-unstar-input2.trig => ex-unstar-input2.ttl} (74%) delete mode 100644 spec/ex-unstar-output.trig create mode 100644 spec/ex-unstar-output.ttl diff --git a/spec/ex-unstar-input.trig b/spec/ex-unstar-input.ttl similarity index 71% rename from spec/ex-unstar-input.trig rename to spec/ex-unstar-input.ttl index 246e938..7f1f645 100644 --- a/spec/ex-unstar-input.trig +++ b/spec/ex-unstar-input.ttl @@ -3,8 +3,3 @@ PREFIX ex: << ex:s ex:p ex:o >> ex:q "some value". -GRAPH ex:g { - ex:s ex:p ex:o. - ex:s ex:p ex:o2. -} - diff --git a/spec/ex-unstar-input2.trig b/spec/ex-unstar-input2.ttl similarity index 74% rename from spec/ex-unstar-input2.trig rename to spec/ex-unstar-input2.ttl index fdfd58d..a9f1a42 100644 --- a/spec/ex-unstar-input2.trig +++ b/spec/ex-unstar-input2.ttl @@ -3,8 +3,3 @@ PREFIX ex: _:r1 rdf:reifies <<( ex:s ex:p ex:o )>>. _:r1 ex:q "some value". - -GRAPH ex:g { - ex:s ex:p ex:o. - ex:s ex:p ex:o2. -} diff --git a/spec/ex-unstar-output.trig b/spec/ex-unstar-output.trig deleted file mode 100644 index 28c741e..0000000 --- a/spec/ex-unstar-output.trig +++ /dev/null @@ -1,19 +0,0 @@ -PREFIX rdf: -PREFIX ex: - -_:r1 rdf:reifies _:gen1. -_:r1 ex:q "some value". - -GRAPH ex:g { - ex:s ex:p ex:o. - ex:s ex:p ex:o2. -} - -GRAPH _:gen1 { - ex:s ex:p ex:o. -} - -GRAPH rdf:unstarMetadata { - _:gen1 rdf:type rdf:TripleTerm. -} - diff --git a/spec/ex-unstar-output.ttl b/spec/ex-unstar-output.ttl new file mode 100644 index 0000000..4207864 --- /dev/null +++ b/spec/ex-unstar-output.ttl @@ -0,0 +1,11 @@ +PREFIX rdf: +PREFIX ex: + +_:r1 rdf:reifies _:gen1. +_:r1 ex:q "some value". + +_:gen1 a rdf:UnstarredTripleTerm ; + rdf:subject ex:s; + rdf:predicate ex:p; + rdf:object ex:o. + diff --git a/spec/index.html b/spec/index.html index cbdb657..2abf378 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1466,35 +1466,36 @@

Generalizations of RDF Triples, Graphs, and Datasets

Interoperability between RDF [=Classic=] and RDF [=Full=]

-

This section provides transformations between RDF [=Classic=] datasets and RDF [=Full=] datasets, +

This section provides transformations between RDF [=Classic=] graphs (resp. datasets) and RDF [=Full=] graphs (resp. datasets), to provide some level of interoperability between the different classes of Conformance.

Should we go even further and aim to provide interoperability between RDF 1.1 and RDF 1.2 [=Full=]?

-

It defines the `unstar` algorithm, which transforms an RDF [=Full=] dataset into an RDF [=Classic=] dataset by encoding all triple-terms into dedicated named graphs. +

It defines the `unstar` algorithm, which transforms an RDF [=Full=] graph into an RDF [=Classic=] graph by encoding all triple-terms into [=Classic=] triples. This algorithm is designed to be:

Information preserving
-
It must be possible to reconstruct the input dataset from the output dataset. +
It must be possible to reconstruct the input graph from the output graph. Note that, on the other hand, the algorithm is not designed to be semantics preserving: - the graphs in the produced dataset are not semantically equivalent to their corresponding graph in the input dataset. + the produced graph is not semantically equivalent to the input graph.
Idempotent
-
Transforming a dataset that is already complying with RDF [=Classic=] (i.e. containing no triple term) must result in the same dataset. +
Transforming a graph that is already complying with RDF [=Classic=] (i.e. containing no triple term) must result in the same graph.
Universal
-
It should be possible to transform any RDF [=Full=] dataset using this method. +
It should be possible to transform any RDF [=Full=] graph using this method. There is actually a minor caveat to this property.
-

The general principle of the `unstar` algorithm is to replace each triple term `S P O` in the input dataset with a fresh blank node. - This blank node is then use as the name of a new named graph containing a single triple `S P O`. - In order to distinguish those new named graphs from the original named graphs of the input dataset, - dedicated triples are added to a special `rdf:unstarMetadata` named graph.

+

The general principle of the `unstar` algorithm is to replace each triple term `S P O` in the input graph with a fresh blank node. + This blank node is then further described with new [=Classic=] triples, repurposing the reification vocabulary. + In order to distinguish those new blank nodes from the original blank nodes of the input graph, + those blank nodes are assigned a new type `rdf:UnstarredTripleTerm`. +

The blank nodes generated by `unstar` to replace triple terms should not be confused with the reifiers that are typically associated to these triple terms.

@@ -1504,71 +1505,73 @@

Interoperability between RDF [=Classic=] and RDF [=Full=]

The `unstar` algorithm

-

The algorithm expects one input variable Dᵢ which is an RDF dataset. It returns a [=Classic=] RDF dataset. - In the algorithm, we adopt the view presented in . +

The algorithm expects one input variable Gᵢ which is an RDF graph. It returns a [=Classic=] RDF graph.

    -
  1. Let Dₒ be an empty RDF dataset.
  2. -
  3. Let bnodes be an empty map from triple terms to blank nodes.
  4. +
  5. Let Gₒ be an empty RDF graph.
  6. +
  7. Let M be an empty map from triple terms to blank nodes.
  8. Let inputKind be `null`.
  9. -
  10. For each quad (s, p, o, g) in Dᵢ:
      -
    1. If g is not `null` and is the IRI `rdf:unstarMetadata`, then:
        +
      1. For each triple (s, p, o) in Gᵢ:
          +
        1. If p is `rdf:type` and o is `rdf:UnstarredTripleTerm`, then:
          1. If inputKind is `"full"` then exit with an error.
          2. Otherwise, set inputKind to `"classic"`.
        2. If o is a triple term, then:
          1. If inputKind is `"classic"` then exit with an error.
          2. Otherwise, set inputKind to `"full"`.
          3. -
          4. Let b, M' and D' be the result of invoking `quote-triple-term` passing o as t and M as Mi.
          5. +
          6. Let b, M' and G' be the result of invoking `quote-triple-term` passing o as t and M as Mi.
          7. Merge M' into M. -
          8. Merge D' into Dₒ. +
          9. Merge G' into Gₒ.
          10. Set o to b.
        3. -
        4. Add the quad (s, p, o, g) to Dₒ.
        5. +
        6. Add the triple (s, p, o) to Gₒ.
      2. -
      3. Return Dₒ.
      4. +
      5. Return Gₒ.
      + +

      The algorithm can be straightforwardly extended to produce a [=Classic=] RDF dataset from any RDF dataset, by applying it recursively to the default graph and to each of the named graphs. +

The `quote-triple-term` algorithm

-

This algorithm is responsible for incrementally populating the mapping M and the dataset D used internally by the `unstar` algorithm. It receives a triple term as input and processes it recursively (in case its object is itself a triple term). It returns, among other things, the blank node minted to replace the triple term in the transformed [=Classic=] RDF dataset.

+

This algorithm is responsible for incrementally populating the mapping M and the graph G used internally by the `unstar` algorithm. It receives a triple term as input and processes it recursively (in case its object is itself a triple term). It returns, among other things, the blank node minted to replace the triple term in the transformed [=Classic=] RDF graph.

This algorithm expects two input variables: a triple term t, and a map Mᵢ from triple terms to blank nodes. It returns a blank node b, a map Mₒ from triple terms to blank nodes, - and a [=Classic=] RDF dataset D. - In the algorithm, we adopt the view presented in . + and a [=Classic=] RDF graph G.

  1. Let Mₒ be an empty map.
  2. -
  3. Let D be an empty RDF dataset.
  4. -
  5. If Mᵢ contains a blank node b associated with t, then return b, Mₒ and D. +
  6. Let G be an empty RDF graph.
  7. +
  8. Let b be the blank node associated with t in Mᵢ, if any.
  9. Otherwise:
    1. Let s, p and o be the subject, predicate and object of t, respectively.
    2. If o is a triple term, then:
        -
      1. Let b', M' and D' be the result of invoking `quote-triple-term` passing o as t and Mᵢ.
      2. +
      3. Let b', M' and G' be the result of invoking `quote-triple-term` passing o as t and Mᵢ.
      4. Set o to b'.
      5. Merge M' into Mₒ. -
      6. Merge D' into D. +
      7. Merge G' into G.
    3. Let b be a fresh blank node.
    4. Add the association (t, b) to Mₒ.
    5. -
    6. Add the quads (s, p, o, b) and (b, `rdf:type`, `rdf:TripleTerm`, `rdf:unstarMetadata`) in D.
    7. -
    8. Return b, Mₒ and D.
    9. +
    10. Add the triples (b, `rdf:type`, `rdf:UnstarredTripleTerm`), (b, `rdf:subject`, s), (b, `rdf:predicate`, p), and (b, `rdf:object`, o) in G.
  10. +
  11. Return b, Mₒ and G.

In step 4.3 of this algorithm, - it is assumed that the blank node b is distinct from any blank node already in use in any dataset at hand, - in particular the dataset being processed in the invoking `unstar` algorithm. - Some implementations may require that `unstar` passes that dataset to `quote-triple-term` to ensure this constraint. + it is assumed that the blank node b is distinct from any blank node already in use in any graph or dataset at hand, + in particular the graph being processed in the invoking `unstar` algorithm. + Some implementations may require that `unstar` passes additional information (such as the graph itself, or a list of all blank nodes in use) + to `quote-triple-term` to ensure this constraint.

@@ -1577,22 +1580,22 @@

The `quote-triple-term` algorithm

Limitations of the `unstar` algorithm

Steps 4.1.1 and 4.2.1 of the `unstar` algorithm exit with an error. - This will occur if the input dataset contains at the same time triple terms and a graph named `rdf:unstarMetadata`. - The `unstar` algorithm is therefore not strictly universal as it can not transform this particular kind of datasets. + This will occur if the input dataset contains at the same time triple terms and a node of type `rdf:UnstarredTripleTerm`. + The `unstar` algorithm is therefore not strictly universal as it can not transform this particular kind of graphs.

This limitation should not be an issue in practice. - The special graph name `rdf:unstarMapping` is unlikely to be in used in any published dataset, + The special type `rdf:UnstarredTripleTerm` is unlikely to be in used in any published dataset, as it was not defined in the RDF namespace prior to this specification. For this reason, using it would actually have been bad practice. - As for future datasets, their authors should consider the graph name `rdf:unstarMetadata` to be reserved, in order to prevent interference with the `unstar` algorithm. + As for future datasets, their authors should consider the type `rdf:UnstarredTripleTerm` to be reserved, in order to prevent interference with the `unstar` algorithm.

-

Another consequence of this restriction is that users should be careful when merging dataset in an application that makes use of the `unstar` algorithm. - More precisely, merging a [=Full=] RDF dataset (containing at least one triple term) - with a [=Classic=] RDF dataset resulting from the application of `unstar` (and therefore containing an `rdf:unstarMetadata` named graph) - would result in a "hybrid" dataset that `unstar` can not process. - Such application should make sure to apply `unstar` to every dataset priori to merging them. +

Another consequence of this restriction is that users should be careful when merging graphs in an application that makes use of the `unstar` algorithm. + More precisely, merging a [=Full=] RDF graph (containing at least one triple term) + with a [=Classic=] RDF graph resulting from the application of `unstar` (and therefore containing a node of type `rdf:UnstarredTripleTerm`) + would result in a "hybrid" graph that `unstar` can not process. + Such application should make sure to apply `unstar` to every graph prior to merging them. Since `unstar` is idempotent, there is no harm in applying it more than necessary.

@@ -1602,26 +1605,26 @@

Limitations of the `unstar` algorithm

Example of applying the `unstar` algorithm

-

The examples in this section are using the Trig concrete syntax [[RDF12-TRIG]].

+

The examples in this section are using the Turtle concrete syntax [[RDF12-TURTLE]].


 
     

 
     

 

From f5d2deb28662ba8d520ebc38efb143625bddcaac Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Champin 
Date: Fri, 29 Nov 2024 15:24:11 +0100
Subject: [PATCH 03/16] add note on the (absence of) interference with old
 style reification

---
 spec/index.html | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/spec/index.html b/spec/index.html
index 2abf378..55d91a8 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -1598,6 +1598,13 @@ 

Limitations of the `unstar` algorithm

Such application should make sure to apply `unstar` to every graph prior to merging them. Since `unstar` is idempotent, there is no harm in applying it more than necessary.

+

+ Note that the use of the reification vocabulary does not, in itself, interfere with the `unstar` algorithm, + as long as the subject of the reification triples does not have the type `rdf:UnstarredTripleTerm`. + In particular, a [=Classic=] graph or dataset using "old style" reification will be unchanged by the `unstar` mapping, + and a [=Full=] graph or dataset mixing triple terms with "old style" reification will be losslessly `unstar`red. +

+

We should probably provide the `restar` algorithm, the opposite of `unstar`.

From ec44491f05c40148870e155759b6ef9872d85671 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Wed, 11 Dec 2024 08:05:27 +0100 Subject: [PATCH 04/16] rename the 'unstar' algo to 'classicize' also, the algo 'quote-triple-term' was renamed, because it was not actually "quoting" the triple. --- ...star-input.ttl => ex-classicize-input.ttl} | 0 ...ar-input2.ttl => ex-classicize-input2.ttl} | 0 ...ar-output.ttl => ex-classicize-output.ttl} | 2 +- spec/index.html | 90 +++++++++---------- 4 files changed, 45 insertions(+), 47 deletions(-) rename spec/{ex-unstar-input.ttl => ex-classicize-input.ttl} (100%) rename spec/{ex-unstar-input2.ttl => ex-classicize-input2.ttl} (100%) rename spec/{ex-unstar-output.ttl => ex-classicize-output.ttl} (84%) diff --git a/spec/ex-unstar-input.ttl b/spec/ex-classicize-input.ttl similarity index 100% rename from spec/ex-unstar-input.ttl rename to spec/ex-classicize-input.ttl diff --git a/spec/ex-unstar-input2.ttl b/spec/ex-classicize-input2.ttl similarity index 100% rename from spec/ex-unstar-input2.ttl rename to spec/ex-classicize-input2.ttl diff --git a/spec/ex-unstar-output.ttl b/spec/ex-classicize-output.ttl similarity index 84% rename from spec/ex-unstar-output.ttl rename to spec/ex-classicize-output.ttl index 4207864..610e6ab 100644 --- a/spec/ex-unstar-output.ttl +++ b/spec/ex-classicize-output.ttl @@ -4,7 +4,7 @@ PREFIX ex: _:r1 rdf:reifies _:gen1. _:r1 ex:q "some value". -_:gen1 a rdf:UnstarredTripleTerm ; +_:gen1 a rdf:ClassicizedTripleTerm ; rdf:subject ex:s; rdf:predicate ex:p; rdf:object ex:o. diff --git a/spec/index.html b/spec/index.html index 55d91a8..0514333 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1471,7 +1471,7 @@

Interoperability between RDF [=Classic=] and RDF [=Full=]

Should we go even further and aim to provide interoperability between RDF 1.1 and RDF 1.2 [=Full=]?

-

It defines the `unstar` algorithm, which transforms an RDF [=Full=] graph into an RDF [=Classic=] graph by encoding all triple-terms into [=Classic=] triples. +

It defines the `classicize` algorithm, which transforms an RDF [=Full=] graph into an RDF [=Classic=] graph by encoding all triple-terms into [=Classic=] triples. This algorithm is designed to be:

@@ -1486,24 +1486,22 @@

Interoperability between RDF [=Classic=] and RDF [=Full=]

Universal
It should be possible to transform any RDF [=Full=] graph using this method. - There is actually a minor caveat to this property. + There is actually a minor caveat to this property.
-

The general principle of the `unstar` algorithm is to replace each triple term `S P O` in the input graph with a fresh blank node. +

The general principle of the `classicize` algorithm is to replace each triple term `S P O` in the input graph with a fresh blank node. This blank node is then further described with new [=Classic=] triples, repurposing the reification vocabulary. In order to distinguish those new blank nodes from the original blank nodes of the input graph, - those blank nodes are assigned a new type `rdf:UnstarredTripleTerm`. + those blank nodes are assigned a new type `rdf:ClassicizedTripleTerm`.

-

The blank nodes generated by `unstar` to replace triple terms should not be confused with the reifiers that are typically associated to these triple terms.

+

The blank nodes generated by `classicize` to replace triple terms should not be confused with the reifiers that are typically associated to these triple terms.

-

Despite having the same name, the `unstar` mapping defined in this specification is different from the `unstar` mapping defined in [[RDF-STAR-CG]].

- -
-

The `unstar` algorithm

+
+

The `classicize` algorithm

The algorithm expects one input variable Gᵢ which is an RDF graph. It returns a [=Classic=] RDF graph.

@@ -1513,14 +1511,14 @@

The `unstar` algorithm

  • Let M be an empty map from triple terms to blank nodes.
  • Let inputKind be `null`.
  • For each triple (s, p, o) in Gᵢ:
      -
    1. If p is `rdf:type` and o is `rdf:UnstarredTripleTerm`, then:
        -
      1. If inputKind is `"full"` then exit with an error.
      2. +
      3. If p is `rdf:type` and o is `rdf:ClassicizedTripleTerm`, then:
          +
        1. If inputKind is `"full"` then exit with an error.
        2. Otherwise, set inputKind to `"classic"`.
      4. If o is a triple term, then:
          -
        1. If inputKind is `"classic"` then exit with an error.
        2. +
        3. If inputKind is `"classic"` then exit with an error.
        4. Otherwise, set inputKind to `"full"`.
        5. -
        6. Let b, M' and G' be the result of invoking `quote-triple-term` passing o as t and M as Mi.
        7. +
        8. Let b, M' and G' be the result of invoking `classicize-triple-term` passing o as t and M as Mi.
        9. Merge M' into M.
        10. Merge G' into Gₒ.
        11. Set o to b. @@ -1535,9 +1533,9 @@

          The `unstar` algorithm

  • -

    The `quote-triple-term` algorithm

    +

    The `classicize-triple-term` algorithm

    -

    This algorithm is responsible for incrementally populating the mapping M and the graph G used internally by the `unstar` algorithm. It receives a triple term as input and processes it recursively (in case its object is itself a triple term). It returns, among other things, the blank node minted to replace the triple term in the transformed [=Classic=] RDF graph.

    +

    This algorithm is responsible for incrementally populating the mapping M and the graph G used internally by the `classicize` algorithm. It receives a triple term as input and processes it recursively (in case its object is itself a triple term). It returns, among other things, the blank node minted to replace the triple term in the transformed [=Classic=] RDF graph.

    This algorithm expects two input variables: a triple term t, @@ -1554,14 +1552,14 @@

    The `quote-triple-term` algorithm

  • Otherwise:
    1. Let s, p and o be the subject, predicate and object of t, respectively.
    2. If o is a triple term, then:
        -
      1. Let b', M' and G' be the result of invoking `quote-triple-term` passing o as t and Mᵢ.
      2. +
      3. Let b', M' and G' be the result of invoking `classicize-triple-term` passing o as t and Mᵢ.
      4. Set o to b'.
      5. Merge M' into Mₒ.
      6. Merge G' into G.
    3. Let b be a fresh blank node.
    4. Add the association (t, b) to Mₒ.
    5. -
    6. Add the triples (b, `rdf:type`, `rdf:UnstarredTripleTerm`), (b, `rdf:subject`, s), (b, `rdf:predicate`, p), and (b, `rdf:object`, o) in G.
    7. +
    8. Add the triples (b, `rdf:type`, `rdf:ClassicizedTripleTerm`), (b, `rdf:subject`, s), (b, `rdf:predicate`, p), and (b, `rdf:object`, o) in G.
  • Return b, Mₒ and G.
  • @@ -1569,69 +1567,69 @@

    The `quote-triple-term` algorithm

    In step 4.3 of this algorithm, it is assumed that the blank node b is distinct from any blank node already in use in any graph or dataset at hand, - in particular the graph being processed in the invoking `unstar` algorithm. - Some implementations may require that `unstar` passes additional information (such as the graph itself, or a list of all blank nodes in use) - to `quote-triple-term` to ensure this constraint. + in particular the graph being processed in the invoking `classicize` algorithm. + Some implementations may require that `classicize` passes additional information (such as the graph itself, or a list of all blank nodes in use) + to `classicize-triple-term` to ensure this constraint.

    -
    -

    Limitations of the `unstar` algorithm

    +
    +

    Limitations of the `classicize` algorithm

    -

    Steps 4.1.1 and 4.2.1 of the `unstar` algorithm exit with an error. - This will occur if the input dataset contains at the same time triple terms and a node of type `rdf:UnstarredTripleTerm`. - The `unstar` algorithm is therefore not strictly universal as it can not transform this particular kind of graphs. +

    Steps 4.1.1 and 4.2.1 of the `classicize` algorithm exit with an error. + This will occur if the input dataset contains at the same time triple terms and a node of type `rdf:ClassicizedTripleTerm`. + The `classicize` algorithm is therefore not strictly universal as it can not transform this particular kind of graphs.

    This limitation should not be an issue in practice. - The special type `rdf:UnstarredTripleTerm` is unlikely to be in used in any published dataset, + The special type `rdf:ClassicizedTripleTerm` is unlikely to be in used in any published dataset, as it was not defined in the RDF namespace prior to this specification. For this reason, using it would actually have been bad practice. - As for future datasets, their authors should consider the type `rdf:UnstarredTripleTerm` to be reserved, in order to prevent interference with the `unstar` algorithm. + As for future datasets, their authors should consider the type `rdf:ClassicizedTripleTerm` to be reserved, in order to prevent interference with the `classicize` algorithm.

    -

    Another consequence of this restriction is that users should be careful when merging graphs in an application that makes use of the `unstar` algorithm. +

    Another consequence of this restriction is that users should be careful when merging graphs in an application that makes use of the `classicize` algorithm. More precisely, merging a [=Full=] RDF graph (containing at least one triple term) - with a [=Classic=] RDF graph resulting from the application of `unstar` (and therefore containing a node of type `rdf:UnstarredTripleTerm`) - would result in a "hybrid" graph that `unstar` can not process. - Such application should make sure to apply `unstar` to every graph prior to merging them. - Since `unstar` is idempotent, there is no harm in applying it more than necessary.

    + with a [=Classic=] RDF graph resulting from the application of `classicize` (and therefore containing a node of type `rdf:ClassicizedTripleTerm`) + would result in a "hybrid" graph that `classicize` can not process. + Such application should make sure to apply `classicize` to every graph prior to merging them. + Since `classicize` is idempotent, there is no harm in applying it more than necessary.

    - Note that the use of the reification vocabulary does not, in itself, interfere with the `unstar` algorithm, - as long as the subject of the reification triples does not have the type `rdf:UnstarredTripleTerm`. - In particular, a [=Classic=] graph or dataset using "old style" reification will be unchanged by the `unstar` mapping, - and a [=Full=] graph or dataset mixing triple terms with "old style" reification will be losslessly `unstar`red. + Note that the use of the reification vocabulary does not, in itself, interfere with the `classicize` algorithm, + as long as the subject of the reification triples does not have the type `rdf:ClassicizedTripleTerm`. + In particular, a [=Classic=] graph or dataset using "old style" reification will be unchanged by the `classicize` mapping, + and a [=Full=] graph or dataset mixing triple terms with "old style" reification will be losslessly `classicize`d.

    -

    We should probably provide the `restar` algorithm, the opposite of `unstar`.

    +

    We should maybe provide the reverse algorithm of `classicize`.

    -
    -

    Example of applying the `unstar` algorithm

    +
    +

    Example of applying the `classicize` algorithm

    The examples in this section are using the Turtle concrete syntax [[RDF12-TURTLE]].

    -
    
     
    -    
    
     
    -    
    
     
    
    From 10065ac7bdbcd64bce34c0dd5d92a72db058bc9f Mon Sep 17 00:00:00 2001
    From: Pierre-Antoine Champin 
    Date: Wed, 11 Dec 2024 08:27:20 +0100
    Subject: [PATCH 05/16] use a dedicated vocab rather than repurposing the
     reification vocab
    
    ---
     spec/ex-classicize-output.ttl |  9 +++++----
     spec/index.html               | 26 +++++++++-----------------
     2 files changed, 14 insertions(+), 21 deletions(-)
    
    diff --git a/spec/ex-classicize-output.ttl b/spec/ex-classicize-output.ttl
    index 610e6ab..df8f86b 100644
    --- a/spec/ex-classicize-output.ttl
    +++ b/spec/ex-classicize-output.ttl
    @@ -1,11 +1,12 @@
     PREFIX rdf: 
    +PREFIX classicize: 
     PREFIX ex: 
     
     _:r1 rdf:reifies _:gen1.
     _:r1 ex:q "some value".
     
    -_:gen1 a rdf:ClassicizedTripleTerm ;
    -  rdf:subject ex:s;
    -  rdf:predicate ex:p;
    -  rdf:object ex:o.
    +_:gen1 a classicize:TripleTerm ;
    +  classicize:subject ex:s;
    +  classicize:predicate ex:p;
    +  classicize:object ex:o.
     
    diff --git a/spec/index.html b/spec/index.html
    index 0514333..2f3e344 100644
    --- a/spec/index.html
    +++ b/spec/index.html
    @@ -1492,9 +1492,9 @@ 

    Interoperability between RDF [=Classic=] and RDF [=Full=]

    The general principle of the `classicize` algorithm is to replace each triple term `S P O` in the input graph with a fresh blank node. - This blank node is then further described with new [=Classic=] triples, repurposing the reification vocabulary. + This blank node is then further described with new [=Classic=] triples, using a new dedicated vocabulary in the namespace `https://www.w3.org/ns/rdf-classicize#`, which in the following will be mapped to the prefix `classicize:`. In order to distinguish those new blank nodes from the original blank nodes of the input graph, - those blank nodes are assigned a new type `rdf:ClassicizedTripleTerm`. + those blank nodes are assigned a new type `classicize:TripleTerm`.

    The blank nodes generated by `classicize` to replace triple terms should not be confused with the reifiers that are typically associated to these triple terms.

    @@ -1511,7 +1511,7 @@

    The `classicize` algorithm

  • Let M be an empty map from triple terms to blank nodes.
  • Let inputKind be `null`.
  • For each triple (s, p, o) in Gᵢ:
      -
    1. If p is `rdf:type` and o is `rdf:ClassicizedTripleTerm`, then:
        +
      1. If p is `rdf:type` and o is `classicize:TripleTerm`, then:
        1. If inputKind is `"full"` then exit with an error.
        2. Otherwise, set inputKind to `"classic"`.
      2. @@ -1559,7 +1559,7 @@

        The `classicize-triple-term` algorithm

    2. Let b be a fresh blank node.
    3. Add the association (t, b) to Mₒ.
    4. -
    5. Add the triples (b, `rdf:type`, `rdf:ClassicizedTripleTerm`), (b, `rdf:subject`, s), (b, `rdf:predicate`, p), and (b, `rdf:object`, o) in G.
    6. +
    7. Add the triples (b, `rdf:type`, `classicize:TripleTerm`), (b, `classicize:subject`, s), (b, `classicize:predicate`, p), and (b, `classicize:object`, o) in G.
  • Return b, Mₒ and G.
  • @@ -1578,31 +1578,23 @@

    The `classicize-triple-term` algorithm

    Limitations of the `classicize` algorithm

    Steps 4.1.1 and 4.2.1 of the `classicize` algorithm exit with an error. - This will occur if the input dataset contains at the same time triple terms and a node of type `rdf:ClassicizedTripleTerm`. + This will occur if the input dataset contains at the same time triple terms and a node of type `classicize:TripleTerm`. The `classicize` algorithm is therefore not strictly universal as it can not transform this particular kind of graphs.

    This limitation should not be an issue in practice. - The special type `rdf:ClassicizedTripleTerm` is unlikely to be in used in any published dataset, - as it was not defined in the RDF namespace prior to this specification. + The `classicize:` namespace is unlikely to be in used in any published dataset, + as it was not defined prior to this specification. For this reason, using it would actually have been bad practice. - As for future datasets, their authors should consider the type `rdf:ClassicizedTripleTerm` to be reserved, in order to prevent interference with the `classicize` algorithm. + As for future datasets, their authors should consider the `classicize:` namespace to be reserved, in order to prevent interference with the `classicize` algorithm.

    Another consequence of this restriction is that users should be careful when merging graphs in an application that makes use of the `classicize` algorithm. More precisely, merging a [=Full=] RDF graph (containing at least one triple term) - with a [=Classic=] RDF graph resulting from the application of `classicize` (and therefore containing a node of type `rdf:ClassicizedTripleTerm`) + with a [=Classic=] RDF graph resulting from the application of `classicize` (and therefore using the `classicize:` vocabulary) would result in a "hybrid" graph that `classicize` can not process. Such application should make sure to apply `classicize` to every graph prior to merging them. Since `classicize` is idempotent, there is no harm in applying it more than necessary.

    - -

    - Note that the use of the reification vocabulary does not, in itself, interfere with the `classicize` algorithm, - as long as the subject of the reification triples does not have the type `rdf:ClassicizedTripleTerm`. - In particular, a [=Classic=] graph or dataset using "old style" reification will be unchanged by the `classicize` mapping, - and a [=Full=] graph or dataset mixing triple terms with "old style" reification will be losslessly `classicize`d. -

    -

    We should maybe provide the reverse algorithm of `classicize`.

    From 91bff0f2c247a6b013bacb109d149895e8d37444 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Wed, 11 Dec 2024 15:00:21 +0100 Subject: [PATCH 06/16] prioritize prose over algo, and describe revert transformation following @afs, the two transformations ('classicize' and revert) are now primarily described in prose, the algorithm being secundary. We now also describe the reverse transformation. --- spec/index.html | 291 +++++++++++++++++++++++++++++------------------- 1 file changed, 176 insertions(+), 115 deletions(-) diff --git a/spec/index.html b/spec/index.html index 2f3e344..7ec350a 100644 --- a/spec/index.html +++ b/spec/index.html @@ -38,7 +38,8 @@ github: "https://github.com/w3c/rdf-concepts/", group: "rdf-star", doJsonLd: true, - wgPublicList: "public-rdf-star-wg" + wgPublicList: "public-rdf-star-wg", + maxTocLevel: 2, };