Infinities.jl icon indicating copy to clipboard operation
Infinities.jl copied to clipboard

Add IntegerInfinity

Open dlfivefifty opened this issue 4 years ago • 7 comments

I think we could use more type:

struct IntegerInfinity <: Integer
   signbit::Bool
end

This will be almost identical to RealInfinity but confirm to the Integer interface, and can be viewed as the limit of integers.

dlfivefifty avatar Feb 15 '21 10:02 dlfivefifty

How would that be different, though, mathematically? Why not simply have RealInfinity be an Integer?

fingolfin avatar Feb 02 '22 22:02 fingolfin

RealInfinity would correspond to the limit through any real number, where IntegerInfinity would be through the integers

dlfivefifty avatar Feb 04 '22 11:02 dlfivefifty

I don't see how that is mathematically useful. Do we then also get "infinities" through e.g half-integers or multiples of pi or along square integers or ...?

fingolfin avatar Feb 04 '22 12:02 fingolfin

I wanted something similar, but I'm a bit worried about making an Integer infinity <: Integer, since Integer at the moment pretty firmly means finite. That said, as a practical matter, there are a lot of cases where ℤ ∪ ∞ makes sense, but arbitrary reals do not. Perhaps we need another intermediate level between Real and Integer in base where RealInfinity fits.

Keno avatar May 31 '22 00:05 Keno

We already have InfiniteCardinal <: Integer so here it is not the case that Integer means finite. This is needed since array lengths are assumed to be Integer.

My feeling is Integer has an interface and as long as a type satisfies the interface it’s fine. So it’s distinct from the mathematical definition of integers, in the same way we are OK that Inf isa Real. Unfortunately none of these interfaces are written down.

dlfivefifty avatar May 31 '22 06:05 dlfivefifty

Just to say that Julia's Integer indeed is different from mathematical integers even in stock Julia: I mean, Int is a subtype, and its elements are not mathematical integers (rather, they are elements of a residue ring $\mathbb{Z}/n\mathbb{Z}$ for some $n$).

I still don't understand the argument about a "limit through the reals" and how that would differ from a "limit through integers" in any useful mathematical way -- not saying there isn't one, but I think it would be important to record this kind of reasoning somewhere in the package documentation. Or revise it if it turns out to be not the case.

fingolfin avatar Aug 23 '23 06:08 fingolfin

Here would be an example where the difference makes sense: sinpi(IntegerInfinity()) would return zero where sinpi(RealInfinity()) would be NotANumber()

I agree this package needs more thorough documentation and the logic explained, however, I created it for my own practical needs (InfiniteArrays.jl and InfiniteLinearAlgebra.jl) and don’t have the time to write documentation.

Any contributions would be appreciated! But we just need to make sure we don’t break the practical usage for the sake of “mathematical purity” since theres a difference anyways between types in Julia and usual set theory constructions.

dlfivefifty avatar Aug 23 '23 08:08 dlfivefifty