Hacker News new | past | comments | ask | show | jobs | submit login

I'm not sure what you're talking about by saying that this is the correct behavior for a partial order. In every definition of a partial order that I've ever seen, there is a pre-existing notion of equality (which is an equivalence relation, so reflexive -- that is, we would need NaN = Nan), and secondly the order relation in the partial order must be reflexive (that is, we would need NaN <= NaN).

Neither equality nor inequality is reflexive, so floats with <= do not form a partial order.

  >>> float('nan') == float('nan')
  False
  
  >>> float('nan') <= float('nan')
  False
Could you point me to a reference about the 14 relational operators and what this has to do with partial orders? I've never seen anything about this in theoretical mathematics.



> Could you point me to a reference about the 14 relational operators and what this has to do with partial orders? I've never seen anything about this in theoretical mathematics.

In a partial order:

There are four relations that a left side item and a right side item can have. Equal, less, greater, unordered with.

A relational operator could look for any combination of those relations, so 2^4=16 operators, except 'any' and 'none' don't make sense so there's 14.

==, <, >, <=, >=, <> make six.

Six more are "== or unordered with", "< or unordered with", etc. Negating one of the first six operators gives you one of these.

The last two are "unordered with" and its opposite "equal to or less than or greater than".


An equivalence relation can also be either total or partial, like an order relation. So the reflexivity may be true only for a subset of the complete set on which the equivalence relation is defined.

I have mentioned this also in another reply, but the following are the differences between total relations and partial relations.

On a set where total equivalence and order relations are defined, when 2 elements are compared, the result is 1 of 3 possible values: "equal", "less", "greater".

To the 3 values correspond 2^3 - 2 = 8 - 2 = 6 relational operators. In C notation: == != < >= > <=.

On a set where partial equivalence and order relations are defined, when 2 elements are compared, the result is 1 of 4 possible values: "equal", "less", "greater", "undefined" (a.k.a. "unordered").

To the 4 values correspond 2^4 - 2 = 16 - 2 = 14 relational operators.

In both cases, the 2 operators that do not exist, so they are subtracted from 8 and 16, correspond to the always true and always false operators.

For total order relational operators, "!= >= <=" are the negations of "== < >".

For partial order relational operators, that is no longer true, because e.g. the negation of "<" is no longer ">=", but "greater, equal or unordered".

So none of the 6 operators "== != < >= > <=" is the negation of another of these 6. Their 6 negations are distinct relational operators, which results in 6 + 6 = 12 relational operators.

The extra 2 operators until 14 operators are "is unordered" (i.e. isNaN for the case of numbers) and its negation.

I am sorry but I do not remember now references. However everything about partial relations are just trivial consequences of the fact that the 3 possible values of a comparison become 4 possible values.


Thanks for taking the time to explain your terminology. I've found a couple of things about partial equivalence relations (one neat one was on nlab about how the construction of the reals can either be a quotient of a subset of sequences or a subset of a quotient of sequences, and partial equivalences let you reason about the latter), but everything else seems to be in textbooks about CS-specific theory.

When you've talked about "partial orders" and "total orders" I'm surprised that you haven't disambiguated that you're talking about something completely different from what pretty much every mathematician would call a "partial order" or "total order." You could very well know about all this, but when you say "claiming that the correct behavior is a bug shows a dangerous lack of understanding of mathematics" but also don't mention that you're aware of the usual notion of a partial order, it seems a bit odd...

> that is the one that completely breaks math.

> Attempting to forcibly define it as a total relation leads only to inconsistent results.

Where's the inconsistency?

Or, a stronger question, why can't a NaN be the bottom of a total order (in the math sense) for floats? That is, make it be so that for all floats x, NaN <= x?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: