-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
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. |
a7ec54a
to
5555e41
Compare
spec/index.html
Outdated
<li>Returns TRUE if <code>term1</code> and <code>term2</code> | ||
are <em>equal</em> RDF terms, as defined below. | ||
</li> |
There was a problem hiding this comment.
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
<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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 |
7d51235
to
156b28f
Compare
Status: ready. There are three editor's notes - these are discussion points and to be removed before merging. The PR includes renaming The PR does not include adding function |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
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?
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`. |
There was a problem hiding this comment.
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?
<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> |
There was a problem hiding this comment.
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.
<p>Examples:</p> | ||
<div class="result"> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<th>sameValue</th> | ||
<th>Results</th> | ||
</tr> |
There was a problem hiding this comment.
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.
Co-authored-by: Olaf Hartig <[email protected]>
Co-authored-by: Olaf Hartig <[email protected]>
Co-authored-by: Olaf Hartig <[email protected]>
Co-authored-by: Olaf Hartig <[email protected]>
Co-authored-by: Olaf Hartig <[email protected]>
|term1| and |term2| are the | ||
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">same RDF terms</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|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> |
<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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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. |
There was a problem hiding this 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.
<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. |
There was a problem hiding this comment.
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
<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. |
<li>If <code>term1</code> and <code>term2</code> both | ||
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
<li>If <code>term1</code> and <code>term2</code> both | ||
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
<p class="ednote" style="background-color: #EEE"> | ||
Revise for triple terms. | ||
<br/> | ||
Consider adding non-literal `=` to operator mapping table. | ||
</p> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 łł
This closes #187.
This closes #25.
Changes:
RDFterm-equal
assameValue
sameTerm
,sameValue
sameValue
(see Refining RDFTerm-equals #187)Preview | Diff