Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question(This may be better off on the math site, but I figured开发者_JAVA技巧 that since it's programming-related I'd ask here first).
In some libraries, such as C++'s STL, algorithms or data structures that need to perform comparisons between elements require only a strict weak ordering < since all six relational operators can be derived from the strict weak ordering:
x < y iff x < y
x <= y iff !(y < x)
x == y iff !(x < y || y < x)
x != y iff x < y || y < x
x >= y iff !(x < y)
x > y iff y < x
I've seen this used extensively, and while I know the term "strict weak ordering" for the < operator, I'm never quite sure what to call the equivalence relation
x == y iff !(x < y || y < x)
that you can derive from it. Is there a term for this equivalence relation?
I might call this the antisymmetric property (See here for more information). It is normally stated as (x >= y) && (y >= x) iff (x == y)
, but the left side is equivalent to !(x < y || y < x)
by DeMorgan's law and the definition of (x >= y)
that you yourself gave.
But if I was trying to derive this using just properties of the strict weak ordering, I would use irreflexivity which says (x < x)
is false.
As for the name of the relation itself (which now that I re-read your question, I think was what you were actually asking), I don't know that it has one. You might call it the "canonical equivalence relation" of the strict weak ordering. Or maybe that it is "generated" or "induced" by the strict weak ordering.
精彩评论