Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise RDFterm-equal and function sameTerm. Rename RDFterm-equal to sameValue. #194

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

afs
Copy link
Contributor

@afs afs commented Feb 5, 2025

This closes #187.
This closes #25.

Changes:


Preview | Diff

@afs
Copy link
Contributor Author

afs commented Feb 5, 2025

At the moment this is unfinished, work in progress.

It has editor's notes in the text, in a lurid colour, for further changes. These can be seen in the preview.

The diff isn't very useful except to show the changes are only in one area of the document.

cc editors of RDF Concepts -- @gkellogg @pchampin

@afs afs requested review from Tpt, hartig, kasei and rubensworks February 5, 2025 11:08
@afs afs force-pushed the rdf-term-equals branch from 108e37c to 3e4eb6c Compare February 6, 2025 10:27
@afs afs force-pushed the rdf-term-equals branch 7 times, most recently from a7ec54a to 5555e41 Compare February 23, 2025 17:01
@afs afs marked this pull request as ready for review February 24, 2025 16:47
spec/index.html Outdated
Comment on lines 5781 to 5783
<li>Returns TRUE if <code>term1</code> and <code>term2</code>
are <em>equal</em> RDF terms, as defined below.
</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such definition of "equal RDF terms" below.

spec/index.html Outdated
Comment on lines 5784 to 5788
<li>If the SPARQL processor can determine the values of both terms
and it can determine the values are equal, then return TRUE.
</li>
<li>If the SPARQL processor can determine that the values of the terms
can not be equal, the return FALSE.</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you assuming that the two terms are literals? If yes, why is it a valid assumption to be made at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added "if term1 and term2 are both literals" ... as per @Tpt suggestion.

But this needs revising again (not in PR yet) for triple terms.

Only literal-literal sameValue can be extended but it should apply recursively.

IRIs and blank nodes have a loose (not defined) sense of "value" through same term.

Maybe the Operator Dispatch table could have "IRI = IRI", "blank node" = "blank node" and "triple term = triple term" added. Then sameValue is defined for literals.

@afs
Copy link
Contributor Author

afs commented Feb 24, 2025

There are still 4 "editors notes" for work to be done - one of them is waiting on w3c/rdf-concepts#154.

@hartig
Copy link
Contributor

hartig commented Feb 24, 2025

There are still 4 "editors notes" for work to be done - one of them is waiting on w3c/rdf-concepts#154.

Okay, I will work on a PR for w3c/rdf-concepts#154 right away (as PR w3c/rdf-concepts#158 is merged now).

@hartig
Copy link
Contributor

hartig commented Feb 25, 2025

There are still 4 "editors notes" for work to be done - one of them is waiting on w3c/rdf-concepts#154.

Okay, I will work on a PR for w3c/rdf-concepts#154 right away (as PR w3c/rdf-concepts#158 is merged now).

The PR for w3c/rdf-concepts#154 is ready; see: w3c/rdf-concepts#161

@afs afs force-pushed the rdf-term-equals branch 3 times, most recently from 7d51235 to 156b28f Compare February 25, 2025 18:35
@afs afs force-pushed the rdf-term-equals branch from 156b28f to 85ef5b7 Compare March 1, 2025 18:55
@afs
Copy link
Contributor Author

afs commented Mar 2, 2025

Status: ready.

There are three editor's notes - these are discussion points and to be removed before merging.

The PR includes renaming RDFterm-equal as sameValue (PR #197).

The PR does not include adding function sameValue in the grammar.

@afs afs requested a review from hartig March 2, 2025 20:55
@afs afs self-assigned this Mar 2, 2025
Copy link
Contributor

@Tpt Tpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pushing this and the great NaN discussion

<p>
<i>Ref</i>: <a href="https://en.wikipedia.org/wiki/IEEE_754#Special_values">(wikipedia) IEEE_754 Special Values</a>
<i>IEEE 754 specifies a special value called "Not a Number" (NaN)</i>.
suggests they are the same.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per this, I think proposal 2 is definitely better and less surprising than proposal 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tpt

Per this, I think proposal 2 is definitely better and less surprising than proposal 1

I don't think @afs meant these two proposals to exclude one another. Notice the first one is about comparing xsd:float literals to one another, as well xsd:double literals to one another, whereas the second proposal is about comparing an xsd:float an dan xsd:double literal.

My thinking now is: If the operator mapping for = for all these cases goes to fn:numeric-compare, then the problem is not actually relevant for the definition of sameValue (considering sameValue purely as a means to define the semantics of the = operator for cases that are not covered by other entries in the operator mapping table in Sec.17.3). The only point when it becomes relevant is if we make the function callable directly. Right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think @afs meant these two proposals to exclude one another.

Indeed, my bad. Thanks!

the problem is not actually relevant for the definition of sameValue

I am not fully convinced of this because it means that because xsd:float has an entry in the operator mapping (fn:numeric-compare) then it is allowed to defined that "NaN"^^xsd:float = "NaN"^^xsd:float is FALSE whereas a custom ex:myFloat won't be able to do that because of the sameValue definition that mandates that sameTerm implies sameValue. This introduces a discrepency between built-in datatypes and the others and prevent to consider sameValue definition as working for all terms including xsd:float literals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add to the fun, we also have 0 and -0

xsd:double:

Equality is identity, except that 0 = −0 (although they are not identical) and NaN ≠ NaN (although NaN is of course identical to itself).

<p>
<i>Ref</i>: <a href="https://en.wikipedia.org/wiki/IEEE_754#Special_values">(wikipedia) IEEE_754 Special Values</a>
<i>IEEE 754 specifies a special value called "Not a Number" (NaN)</i>.
suggests they are the same.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tpt

Per this, I think proposal 2 is definitely better and less surprising than proposal 1

I don't think @afs meant these two proposals to exclude one another. Notice the first one is about comparing xsd:float literals to one another, as well xsd:double literals to one another, whereas the second proposal is about comparing an xsd:float an dan xsd:double literal.

My thinking now is: If the operator mapping for = for all these cases goes to fn:numeric-compare, then the problem is not actually relevant for the definition of sameValue (considering sameValue purely as a means to define the semantics of the = operator for cases that are not covered by other entries in the operator mapping table in Sec.17.3). The only point when it becomes relevant is if we make the function callable directly. Right?

Comment on lines +5845 to +5847
However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true;
`sameValue` treats "NaN" as the "same value".
`sameTerm("NaN"^^xsd:double, "NaN"^^xsd:float)` is `true`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this whole note is not clear. Is it just meant to call out the issue or is it meant to imply a particular behavior that is expected of SPARQL processors?

Comment on lines +5854 to +5867
<div class="ednote" style="background-color: #EEE">
<p>
A SPARQL processor may support datatypes beyond those required.
Suppose `ex:romanNumeral` is the datatype IRI
<a href="https://en.wikipedia.org/wiki/Roman_numerals">roman numerals</a>
which are integer numbers. The SPARQL processor may then be able
to detemine if two literals have the same value, for example,
`sameValue(4, "IV"^^ex:romanNumeral)` can then return `true`
because argument bot represent the value 4.
For `sameValue("abc"^^xsd:string, "IV"^^ex:romanNumeral)`
can return `false` because `xsd:string` and `ex:romanNumeral`
have different value spaces so the arguments can not be the same value.
</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what the discussion point for this one is. I think what you state here is a fact and can be turned (from an editor's note) into an ordinary note, but then better be combined with the next note into a single one.

Comment on lines +5879 to +5886
<p>Examples:</p>
<div class="result">
<table>
<tbody>
<tr>
<th>sameValue</th>
<th>Results</th>
</tr>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the examples in this table are all correct examples to illustrate the semantics of the sameValue function, they may be confusing or misleading because none of them, except for the one with my:romanNumeral, is actually relevant for the sameValue function. I mean, the sameValue function would never be invoked with these types of arguments (if we consider sameValue purely as a means to define the semantics of the = operator for cases that are not covered by other entries in the operator mapping table in Sec.17.3). Therefore, to avoid misleading readers into thinking that sameValue is relevant for comparing, say, xsd:integer literals, I suggest to use examples that are relevant.

@afs afs force-pushed the rdf-term-equals branch from 56d5a98 to 6cbf72e Compare March 6, 2025 09:46
Co-authored-by: Olaf Hartig <[email protected]>
@afs afs force-pushed the rdf-term-equals branch from c5b2335 to b1eb06e Compare March 6, 2025 10:00
Comment on lines +5680 to +5681
|term1| and |term2| are the
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">same RDF terms</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|term1| and |term2| are the
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">same RDF terms</a>
In particular, |term1| and |term2| are the
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">same RDF term</a>

Comment on lines +5772 to +5774
<li>If <code>term1</code> and <code>term2</code> are
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">equal RDF terms</a>,
the return TRUE.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li>If <code>term1</code> and <code>term2</code> are
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">equal RDF terms</a>,
the return TRUE.
<li>If <code>term1</code> and <code>term2</code> are
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">equal RDF terms</a>,
then return TRUE.

Copy link
Contributor

@hartig hartig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some more comments after the recent round of changes.

Comment on lines +5776 to +5779
<li>If both arguments are literals,
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
and one or both arguments are known to be ill-typed,
then produce a type error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • remove double "literals"
  • make the structure of the sentence consistent with the other bullet points
  • link "ill-typed" to its definition
Suggested change
<li>If both arguments are literals,
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
and one or both arguments are known to be ill-typed,
then produce a type error.
<li>If <code>term1</code> and <code>term2</code> are both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
and one or both of these literals are known to be
<a data-cite="RDF12-CONCEPTS#dfn-ill-typed">ill-typed</a>,
then produce a type error.

Comment on lines +5781 to +5782
<li>If <code>term1</code> and <code>term2</code> both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li>If <code>term1</code> and <code>term2</code> both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
<li>If <code>term1</code> and <code>term2</code> are both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>

</li>
<li>If <code>term1</code> and <code>term2</code> both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
and the SPARQL processor can determine the values are equal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and the SPARQL processor can determine the values are equal,
and the SPARQL processor can determine their
<a data-cite="RDF12-CONCEPTS#dfn-literal-value">values</a>
are equal,

Comment on lines +5786 to +5787
<li>If <code>term1</code> and <code>term2</code> both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li>If <code>term1</code> and <code>term2</code> both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
<li>If <code>term1</code> and <code>term2</code> are both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>

</li>
<li>If <code>term1</code> and <code>term2</code> both
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
and the SPARQL processor can determine the values can not be equal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and the SPARQL processor can determine the values can not be equal,
and the SPARQL processor can determine their
<a data-cite="RDF12-CONCEPTS#dfn-literal-value">values</a>
can not be equal,

Comment on lines +5764 to +5768
<p class="ednote" style="background-color: #EEE">
Revise for triple terms.
<br/>
Consider adding non-literal `=` to operator mapping table.
</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I like the idea of adding non-literal = to the operator mapping table, I am afraid that this is not so easily done because the operator mapping table still assumes that there is a function for every case. Then, instead of introducing new functions for the non-literal = cases, we may as well continue covering these cases here in sameValue.

Now to the question about triple terms, I would say the idea is to recursively use the = operator for a pairwise comparison of the three elements of the two compared triple terms and, then, decide the result based on the outcome of these three comparisons. The only complication is how errors should be handled. I think there are two options:

  • Option 1: If any of the three comparisons produces an error (which, in principle, can only be the comparison of the two objects), then return an error (i.e., no matter what the result of the other two comparisons is).
  • Option 2: If any of the three comparisons produces an error and any other of the three comparisons returns FALSE, then return FALSE.

Looking at the text that we had for this case in the CG report (see https://www.w3.org/2021/12/rdf-star.html#rdf-star-termEqual), I have to say that this text is not so clear to me regarding the error case.

My preference is for Option 2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On triple terms: +1 for option 2, it's consistent with what happens for logical operators && and łł

@afs afs changed the title Revise RDFterm-equal and function sameTerm Revise RDFterm-equal and function sameTerm. Rename RDFterm-equal to sameValue. Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refining RDFTerm-equals Rename 'RDFterm-equal'
4 participants