On Oct 14, 2019, at 01:53, Chris Angelico <ros...@gmail.com> wrote:
> 
>> On Mon, Oct 14, 2019 at 7:04 PM Andrew Barnert <abarn...@yahoo.com> wrote:
>> If you’re wondering whether integers are something you could define the laws 
>> of complex algebra over, then no, it isn’t. For example, one of the laws is 
>> that every number besides 0 has a multiplicative inverse, which obviously 
>> isn’t true for the set of integers. Or for the set of Python `int` values. 
>> But that’s not what the ABC is testing for, so that’s fine.
>> 
> 
> Hmm, but every nonzero integer DOES have a multiplicative inverse -
> that value isn't another integer, but there is one.

Sure, you can define a function from integers to rationals, but that isn’t a 
function from integers to integers, so that doesn’t make integers a field. To 
define a group/ring/field/algebra/etc. you need operations from that object to 
itself. Those operations are part of the definition of the object. And the 
rules that distinguish what object counts as a field, or as a division ring, 
etc. are rules on the operations used to define it.

This is hard to explain without starting with group theory and set theory 
primers and working up through multiple levels from there, but let me given 
another analogy to programming: type T is only a field if it has (among other 
things) an inverse(x:T)->T method, and that method doesn’t raise for any values 
of T except T.zero(). Just having a method named inverse is not sufficient.

People often think “well, natural numbers aren’t closed over subtraction, so 
we’ll just always use integers, and integers aren’t closed over division so 
we’ll just always use rationals, …” assuming that if you keep following that 
you get to the one true “numbers” somewhere around complex or quarternion. If 
this were true, we wouldn’t bother with different kinds of numbers. You’d learn 
about them in a set theory or math logic class and then never use them again. 
But in fact at each step you lose features as well as gain them. For the most 
obvious example, while complex numbers give you closed exponentiation, they 
take away ordering. So, they’re all useful for different purposes.

> If the floating
> point value 2.0 has a multiplicative inverse 0.5, doesn't the integer
> value 2 also have that same multiplicative inverse?

No, if you define a multiplicative inverse operation on the integers, it’s only 
defined for 1->1; its undefined for every other value.

Compare with the integers modulo 5. Every integer modulo 5 but 0 has an 
inverse: 1*1, 2*3, 3*2, and 4*4 are all 1, so 1 and 4 are their own inverses, 2 
and 3 are each others’. So this actually is a field, unlike the integers. 

But that doesn’t mean that the things we call “2” and “3” in some other field 
(like the rationals) are each others’ inverses. Even though we have the same 
kind of morphism as from Z to Q for Z to Z/5Z, and can say that the int 2, the 
rational 2/1 and the int-mod-5 2mod5 are all in a useful sense “the same 
number”, the inverse of 2/1 is 1/2, the inverse of 2mod5 is 3mod5, and the 
inverse of 2 does not exist.

However, you can say something like this: if you have a morphism M that maps 
each integer to a unique rational and maps 0 and 1 to 0/1 and 1/1 and follows 
various other rules and has a partial reverse and so on, revM(M(n) / M(m)) 
gives you the same value as integer division whenever integer division is 
defined. So now you can define an integer-to-rational division function 
trivially as M(n)/M(m). And you can say useful things about that. For example, 
with rational division, 1/q is always the same as inverse(q) except at 0, and 
p/q is always the same as p * inverse(q), and so on—and all of these rules 
apply to your integer-to-rational division function as well. And that’s why, 
e.g., Python’s division operator makes sense: that’s almost exactly what it’s 
doing.

> Your definitions are rather odd in places here. I'm not saying they're
> wrong, but I can't disprove the things you're saying are impossible,
> so it's hard for my brain to grok it.

Well, they are all oversimplified, and the explanations are skimmed over very 
loosely on top of that. If you really want to understand it without working 
through a complete course in set theory and foundations… you’ll need 
explanations out there which are better than anything I could write (much less 
write on the fly in an ASCII email for an audience of Python developers…), but 
I’m sure they exist, because it’s really not that huge or that abstract. On 
stuff like this, Wikipedia is usually either a great place or start, or such an 
obvious mess that you can tell at first glance, so maybe try searching there 
first.

The way to do this in category theory is even harder to explain, but let me try 
anyway, because it may be illustrative anyway. You start by assuming we can 
define the algebra C without defining a set C. Sure, it must have a big 
infinite pile of elements, but we don’t know or care if they’re a set. This 
requires changing the definition of algebraic structures to not use sets, but 
categorists do that all over the place. Now, the subalgebra of C consisting of 
all of the members whose imaginary part is 0 is not a working algebra, but can 
we define another algebra R that uses the same elements and works? Every proof 
that you can’t depends on the elements of C forming a set. But we didn’t bother 
requiring that, so let’s just say it isn’t. And voila, I’ve got a real algebra, 
using a sub-thingy of the exact same elements that are in my complex algebra. I 
can’t show it to you, but you can’t prove that it doesn’t exist, and I can 
prove that if it does exist it meets all the criteria you might demand of it 
(except the ones that rely on R or C being sets). And this works all the way 
down to N—then you find that each number isn’t a set either. Then what is it? 
It’s an object in a category, and categories and morphisms are all there is; 
there is no deeper question. And you can go off in other directions basically 
the same way other mathematicians do, and create all the other algebras anyone 
could ever want, and they all work as expected unless none of them exist, and 
that’ll show those fools at the academy who’s crazy.

But anyway, even if you aren’t a categorist and don’t want to eliminate set 
theory foundations, you have to accept that they proved that `issubset(R, C)` 
is only false because of something about sets, not something about numbers or 
algebra.
_______________________________________________
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/VILJ2B45SFFYQFK6WQRMIY37G5M5FXP6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to