JuliaMath / Infinities.jl

A Julia package for representing infinity in all its forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add IntegerInfinity

dlfivefifty opened this issue · 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.

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

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

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 ...?

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.

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.

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.

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.