3 ms·
> For example, 6 has an additive inverse in ℤ but not in ℕ [...] (this is the reason why int often makes more sense than unsigned int in C, even when you have a
by colanderman 5y ago
> For example, 6 has an additive inverse in ℤ but not in ℕ [...] (this is the reason why int often makes more sense than unsigned int in C, even when you have an unsigned value)
`unsigned int` isn't actually ℕ though, it's ℤ∕nℤ [1], i.e., the integers modulo n, which does have an additive inverse of 6 (being n−6).
The reason `int` often makes more sense is because it's a useful property that the additive inverse of 6 actually be less than 6 -- or more generally, that `int` isn't modular.
Agree with the overall point though, that 6 is an element of many "types". Of the CAS-adjacent languages I'm experienced with, TLA+ gets this right; SMTLIBv2 does not.
[1] https://en.wikipedia.org/wiki/Modular_arithmetic#Integers_modulo_n https://en.wikipedia.org/wiki/Modular_arithmetic#Integers_mo...
- zozbot234 5y agoI don't think modulo arithmetic per se includes any notion of "less". Typical definitions of "order" for an algebraic structure would require the order to be translation invariant, which isn't true in modulo arithmetic.
- colanderman 5y agoFair point! I mean "less" in the same sense that "less" is defined for unsigned/modular arithmetic in most languages (e.g. C).
- StopDarkPattern 5y agoWow, look at hackernews getting relevant again. nice work. great post.