Opened 5 years ago

# The set of all natural numbers

Reported by: Owned by: pelegm major coercion natural numbers, Set, semiring hivert, nthiery, slelievre N/A

### Description

I tried to obtain a `Set` of all natural numbers. One close method was to call `PositiveIntegers()`, which is not a `Set` (but something else which I could not understand), but may be coerced into `Set`. This does not contain 0, so I used `Set(PositiveIntegers()).union(Set([0]))`. The output is called `Set-theoretic union of Set of elements of Positive integers and {0}`, instead of the more readable `Set of all nonnegative integers`, but this is not the main issue I raise here.

One simpler way to obtain a set of all integers is by using `Set(ZZ)`, which creates a `Set` from the ring. Apparently, one cannot achieve the set of natural numbers in a similar fashion: `Set(NN)` simply hangs, instead of creating a `Set` from the semiring.

Tested on 8.2.rc4.

### comment:2 Changed 5 years ago by tscrim

My guess with `NN` is that it is an issue with unresolved lazy imports (#16522, #14357):

```sage: Set(NonNegativeIntegerSemiring())
Set of elements of Non negative integer semiring
sage: Set(NonNegativeIntegers())
Set of elements of Non negative integers

sage: type(NN)
<type 'sage.misc.lazy_import.LazyImport'>
sage: NN == NonNegativeIntegerSemiring()
True
sage: NN is NonNegativeIntegerSemiring()
False
sage: NonNegativeIntegerSemiring() == NonNegativeIntegers()
False
```

So you can get a set of non-negative integers, but `NN` is just specifically broken due to a lazy import issue.

### comment:3 Changed 6 weeks ago by mkoeppe

Milestone: sage-8.3
Note: See TracTickets for help on using tickets.