Opened 20 months ago

Last modified 20 months ago

#25430 new defect

The set of all natural numbers

Reported by: pelegm Owned by:
Priority: major Milestone: sage-8.3
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:

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.

Change History (2)

comment:1 Changed 20 months ago by slelievre

  • Cc hivert nthiery slelievre added

comment:2 Changed 20 months 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.

Note: See TracTickets for help on using tickets.