6 ms·
No. The terminology is different because it refers to a different concept. In C++20 "strong" vs "weak" refers to substitutability. When two elements x and y com
by giomasce 7y ago
No. The terminology is different because it refers to a different concept. In C++20 "strong" vs "weak" refers to substitutability. When two elements x and y compare to strong_ordering::equal, then it is assumed that f(x) == f(y). This is not assumed if they are just weak_ordering::equivalent. Read section "A new ordering primitive: <=>" of the article for a longer explanation.
- mehrdadn 7y agoI did read that section... that's why I said it's confusing... It seems to me they're using different terminology for concepts that aren't different in math? In math, "equality" (=) already means the same thing as substitutability. A non-substitutable equality is already called "equivalence" (≡). So in math we already have these: [1a] Non-strict partial order: a binary ordering that allows incomparability (≼, ≡, ≽, ?) [1b] Strict partial order: like [1a], but irreflexive (≺, ≡, ≻, ?) [2a] Non-strict weak order: like [1a], but with all elements comparable (≼, ≡, ≽) [2b] Strict weak order: like [1b], but with all elements comparable (≺, ≡, ≻) [3a] Non-strict total order: like [2a], where the equivalence is equality (≤, =, ≥) [3b] Strict total order: like [2b], where the equivalence is equality (<, =, >) If I didn't make a mistake above, then: - C++'s "strong total ordering" seems to be what in math we call "strict total ordering" - Their "weak total ordering" seems to be what in math we call "strict weak ordering" - Partial order is the same thing for both Am I wrong here? If yes, how? If not, why did they randomly invent their own terminology? I haven't seen their definitions used elsewhere.
- giomasce 7y agoDo not try too hard to compare with maths here. A programming language is different in many things from how maths is usually formalized. In C++20 there is no "strong total ordering", "weak total ordering" nor their partial counterparts. There are just "strong ordering", "weak ordering" and "partial ordering". In a strong ordering, two objects can only by one smaller, equal or larger than the other. If they are equal, it means that they are substitutable. In a weak ordering, two objects can only be one smaller, equivalent or larger than the other. No substitutability is implied. In a partial ordering, two objects can be one smaller, equivalent or larger than the other, or just not comparable. Again, no substitutability is implied. There is no point in distinguishing strict vs non-strict: depending on whether you call < or <= you will get the string or not string variant, and the same for > and >=.
- Sniffnoy 7y agoHuh, this is... not the terminology I am used to, as a mathematician? My experience is that what C++ is calling a "weak order", and what you are calling a "weak order", is what in math is called a "pre-order" or a "quasi-order". Meanwhile, the distinction you are making between strict and nonstrict is just ignored (except by constructivists), since they're equivalent ways of talking about the same thing. Indeed I'm not sure why you included both because, well, they're just two ways of talking about the same thing (again, unless you're a constructivist). Really (assuming classical logic) there's just 4 possibilities here: 1. Total order (what they're calling a "strong ordering") 2. Total preorder (what they're calling a "weak ordering") 3. Partial order (which they are also calling a "partial ordering") 4. Partial preorder (which they don't account for)
- mehrdadn 7y agoYou're agreeing with me? "Preorder" is just a (better-known?) synonym for "non-strict weak order" [1] [2], so we don't disagree there. "Strict" vs. "non-strict" I merely included because C++ comparisons return strict orders. I thought it was worth including, but feel free to ignore it. So just as you pointed out in your own list, and just as I've been saying, "strong total order" isn't the terminology (every total order is strong), and neither is "weak total order" (it means "total preorder" which is... just a total order). Like you said, they should say "total" order, "preorder" (or "weak" order as I said), "partial" order. The "strong" and "weak total" stuff is just something they seem to have invented in contradiction with the established mathematical terminology for... no reason/gain? [1] https://en.wikipedia.org/wiki/Weak_ordering#Total_preorders https://en.wikipedia.org/wiki/Weak_ordering#Total_preorders [2] http://fitelson.org/roberts_measurement_theory.pdf#page=56 http://fitelson.org/roberts_measurement_theory.pdf#page=56
- Sniffnoy 7y agoWell, I disagree that the article is confusing on this point. They say quite explicitly what they mean. I agree that the terminology is annoying, because they should just match the existing math terminology, and it's also annoying that they didn't account for partial preorders. I'm not sure whether I agree that the terminology is confusing; on the whole I think it isn't. The reason it's not confusing is that it sufficiently different from usual math terminology so as not to interfere -- i.e., the terminology doesn't actually disagree at any point, it's not incompatible. Like, concepts get reinvented all the time and you just kind of have to get used to things having multiple terms, and be ready to translate unusual terminology into standard terminology, even as of course you should do what you can to reduce this happening. As long as you don't end up in a situation where one word means two different things, there's not really confusion, just different terminology. And, as I said above, I definitely disagree that the article is confusing on this point, because they're very explicit about what they mean.