Non Negative Integer Semiring - Standard Semirings

Skip to content
Back to top
View this page
Edit this page

# Non Negative Integer Semiring

class sage.rings.semirings.non_negative_integer_semiring.NonNegativeIntegerSemiring

  Bases: `NonNegativeIntegers`

  A class for the semiring of the nonnegative integers.

  This parent inherits from the infinite enumerated set of non negative integers and endows it with its natural semiring structure.

  EXAMPLES:

  Sage

      sage: NonNegativeIntegerSemiring()
      Non negative integer semiring

  Python

      >>> from sage.all import *
      >>> NonNegativeIntegerSemiring()
      Non negative integer semiring

  For convenience, `NN` is a shortcut for `NonNegativeIntegerSemiring()`:

  Sage

      sage: NN == NonNegativeIntegerSemiring()
      True

      sage: NN.category()
      Category of facade infinite enumerated commutative semirings

  [Python]

      >>> from sage.all import *
      >>> NN == NonNegativeIntegerSemiring()
      True

      >>> NN.category()
      Category of facade infinite enumerated commutative semirings

  Here is a piece of the Cayley graph for the multiplicative structure:

  Sage

      sage: G = NN.cayley_graph(elements=range(9), generators=[0,1,2,3,5,7])          # needs sage.graphs
      sage: G                                                                         # needs sage.graphs
      Looped multi-digraph on 9 vertices
      sage: G.plot()                                                                  # needs sage.graphs sage.plot
      Graphics object consisting of 48 graphics primitives

  Python

      >>> from sage.all import *
      >>> G = NN.cayley_graph(elements=range(Integer(9)), generators=[Integer(0),Integer(1),Integer(2),Integer(3),Integer(5),Integer(7)])          # needs sage.graphs
      >>> G                                                                         # needs sage.graphs
      Looped multi-digraph on 9 vertices
      >>> G.plot()                                                                  # needs sage.graphs sage.plot
      Graphics object consisting of 48 graphics primitives

  This is the Hasse diagram of the divisibility order on `NN`.

  > sage: Poset(NN.cayley_graph(elements=[1..12], generators=[2,3,5,7,11])).show() # needs sage.combinat sage.graphs sage.plot

  Note: as for `NonNegativeIntegers`, `NN` is currently just a “facade” parent; namely its elements are plain Sage `Integers` with `Integer Ring` as parent:

  Sage

      sage: x = NN(15); type(x)
      <class 'sage.rings.integer.Integer'>
      sage: x.parent()
      Integer Ring
      sage: x+3
      18

  [Python]

      >>> from sage.all import *
      >>> x = NN(Integer(15)); type(x)
      <class 'sage.rings.integer.Integer'>
      >>> x.parent()
      Integer Ring
      >>> x+Integer(3)
      18

  additive_semigroup_generators()

    Return the additive semigroup generators of `self`.

    EXAMPLES:

    Sage

        sage: NN.additive_semigroup_generators()
        Family (0, 1)

    Python

        >>> from sage.all import *
        >>> NN.additive_semigroup_generators()
        Family (0, 1)