Opened 5 years ago

Last modified 6 weeks ago

#25430 new defect

The set of all natural numbers

Reported by: pelegm Owned by:
Priority: major Milestone:
Component: coercion Keywords: natural numbers, Set, semiring
Cc: hivert, nthiery, slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

GitHub link to the corresponding issue


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.

Change History (3)

comment:1 Changed 5 years ago by slelievre

Cc: hivert nthiery slelievre added

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()
sage: NN is NonNegativeIntegerSemiring()
sage: NonNegativeIntegerSemiring() == NonNegativeIntegers()

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.