Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

r""" 

Non Negative Integer Semiring 

""" 

#***************************************************************************** 

# Copyright (C) 2010 Nicolas Borie <nicolas.borie at math.u-psud.fr> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# http://www.gnu.org/licenses/ 

#****************************************************************************** 

 

from sage.sets.non_negative_integers import NonNegativeIntegers 

from sage.categories.semirings import Semirings 

from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets 

from sage.sets.family import Family 

 

class NonNegativeIntegerSemiring(NonNegativeIntegers): 

r""" 

A class for the semiring of the non negative integers 

 

This parent inherits from the infinite enumerated set of non 

negative integers and endows it with its natural semiring 

structure. 

 

EXAMPLES:: 

 

sage: NonNegativeIntegerSemiring() 

Non negative integer semiring 

 

For convenience, ``NN`` is a shortcut for 

``NonNegativeIntegerSemiring()``:: 

 

sage: NN == NonNegativeIntegerSemiring() 

True 

 

sage: NN.category() 

Category of facade infinite enumerated commutative semirings 

 

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

 

sage: G = NN.cayley_graph(elements=range(9), generators=[0,1,2,3,5,7]) 

sage: G 

Looped multi-digraph on 9 vertices 

sage: G.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() 

 

Note: as for :class:`NonNegativeIntegers 

<sage.sets.non_negative_integers.NonNegativeIntegers>`, ``NN`` is 

currently just a "facade" parent; namely its elements are plain 

Sage ``Integers`` with ``Integer Ring`` as parent:: 

 

sage: x = NN(15); type(x) 

<type 'sage.rings.integer.Integer'> 

sage: x.parent() 

Integer Ring 

sage: x+3 

18 

 

""" 

def __init__(self): 

r""" 

TESTS:: 

 

sage: NN = NonNegativeIntegerSemiring(); NN 

Non negative integer semiring 

sage: NN.category() 

Category of facade infinite enumerated commutative semirings 

sage: TestSuite(NN).run() 

""" 

NonNegativeIntegers.__init__(self, category=(Semirings().Commutative(), InfiniteEnumeratedSets()) ) 

 

def _repr_(self): 

r""" 

EXAMPLES:: 

 

sage: NonNegativeIntegerSemiring() 

Non negative integer semiring 

""" 

return "Non negative integer semiring" 

 

def additive_semigroup_generators(self): 

r""" 

Returns the additive semigroup generators of ``self``. 

 

EXAMPLES:: 

 

sage: NN.additive_semigroup_generators() 

Family (0, 1) 

""" 

return Family([NN(0), NN(1)]) 

 

def _latex_(self): 

r""" 

TESTS:: 

 

sage: NN._latex_() 

'\\Bold{N}' 

""" 

return '\\Bold{N}' 

 

NN = NonNegativeIntegerSemiring()