# How do I get the classical N1 object rather than N*? (NN)

Sage's global "NN" is the modern definition of the natural numbers (N0, which includes zero); how do I get instead an object representing the classical definition (N1 a.k.a. N*, which excludes zero)?

http://en.wikipedia.org/wiki/Natural_...

sage: NN

Non negative integer semiring

If I want to make further set subtractions, how do I do so? What trade-offs might I encounter typically with such operations?

edit retag close merge delete

sage: Set(NN) - Set([0]) Set-theoretic difference between Set of elements of Non negative integer semiring and {0}

( 2010-08-27 16:28:37 -0600 )edit

If I were to make further set subtractions, what operations would become slow?

( 2010-08-27 16:31:41 -0600 )edit

Sort by » oldest newest most voted

You can get the set of positive integers with PositiveIntegers:

sage: PP = PositiveIntegers(); PP
Positive integers
sage: PP.cardinality()
+Infinity
sage: iter(PP).next()
1


In addition for any given range of integers, you can use the IntegerRange class to get an objects representing them. In fact, PositiveIntegers is just a specialized subclass of IntegerRange.

sage: NN1 = IntegerRange(1, oo); NN1
{1, 2, ..}


What types of operations are looking to do with this set?

more

All kinds. =) Showing my math ignorance: Is it impossible for NN1 to be a semi-ring instead?

( 2010-08-28 10:31:00 -0600 )edit

Yes, it is impossible since semirings contain an additive identity (0) which NN1 lacks.

( 2010-08-28 10:35:08 -0600 )edit

Thanks. I noticed in the tab-completion-dropdown for "NN1." there are some methods which aren't implemented, such as "random_element()", which raise the NotImplemented Exception. It would be a cool UI feature if these methods were grayed-out (indicating unavailability).

( 2010-08-28 10:47:55 -0600 )edit