> On Dec 26, 2019, at 04:15, Marco Sulla via Python-ideas 
> <python-ideas@python.org> wrote:
> 
> Mathematically,

Whenever someone tries to argue that “Mathematically, this doesn’t make sense” 
it ends up isomorphic to an argument that they really would have enjoyed one 
more semester of math classes as an undergrad but for whatever reason didn’t 
take it.

> the operator is ⊂. "<" operator is used for comparison, and it's vital for 
> sorting.

Yes. It’s the defining operation for the partial order in a poset (partially 
ordered set). And when studying posets generically, you always spell the 
operation <. And sorting is a concept on posets, not on integers or any other 
specific poset. (Sometimes you spell it with the bent curvy < instead of the 
normal one—but in that case, it’s the bent curvy one that’s vital for sorting.)

And containment—the poset formed by a set of sets and the subset relation—is 
usually the very next example they teach you after the less than operation on 
integers. In fact, this isn’t just _a_ partial order, but the canonical one: 
everything else is defined by composing containment orders, taking sub-posets 
of them, or finding isomorphisms to them (or doing the same with posets 
recursively defined that way). This works because every partial order is 
isomorphic to a containment order; that’s one of the first proofs you do, and 
it’s dead simple. (It’s similar to using permutations in group theory.)

> And sorting sets makes no sense.

Well, then all of order theory is wrong.

Worse, what do you think does make sense to sort? Natural numbers? Not if any 
of the usual constructions of the naturals actually works. Briefly: Define zero 
as {}, succ(n) as n U {n}, and N as the infinite set generated by zero and 
succ(n) for any other member. Define n<m as subset, and you’ve got the poset of 
naturals (N,<). It’s trivial to prove that this behaves exactly the way you 
expect it to.

More generally, everything is a set, so any operation that doesn’t make sense 
on sets just doesn’t make sense on anything. (Set theory isn’t the only 
possible foundation for math, but it’s the most common one, because most 
mathematicians don’t care or ever need to think about foundations; as long as 
there’s one thing that works that they vaguely remember from undergraduate 
study, that’s good enough for their work, and for everything else up to getting 
really high with a philosopher buddy.)

> You have not ⊂ on your keyboard? Well.... sorry, you have to use a function :D

Why? I don’t have the raised x character on my keyboard either, and I’m quite 
happy to spell multiplication with * instead of with a named function or 
method. And likewise / for division, & for and, and so on.

> I'm not against operator overloading, on the contrary. But "<" was clearly 
> chosen only because is graphically similar to ⊂, without thinking about the 
> consequences.

You’ve got it backward. Historically, the subset symbol is a C squashed to look 
graphically similar to a < (or actually a reversed version of a reversed C 
squashed to look graphically similar to >), and Russell, who chose that out of 
the many different popular 19th century spellings, certainly was thinking about 
the consequences.

It’s true that in Python—unlike in set theory—we don’t usually deal with sets 
of sets (in fact, we can’t, unless we use frozenset), but if you want to 
abandon the “mathematically” and talk about whether sorting makes sense for 
Python sets (after all, practicality beats purity), the fact that sorted works 
on sets and on iterables of sets means that yes, it does. Python’s set.__lt__ 
makes a perfectly good partial order.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ULEUPLXABD56JC3N3GXYNDT7YZJYBCJ5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to