  
  [1X2 Numerical Semigroups[0X
  
  This chapter describes how to create numerical semigroups in [5XGAP[0m and perform
  some basic tests.
  
  
  [1X2.1 Generating Numerical Semigroups[0X
  
  Recalling some definitions from Chapter [14X1[0m.
  
  A  numerical semigroup is a subset of the set N of nonnegative integers that
  is closed under addition, contains 0 and whose complement in N is finite.
  
  We  refer  to  the  elements  in a numerical semigroup that are less than or
  equal to the Frobenius number plus 1 as [13Xsmall elements[0m of the semigroup.
  
  A  [13Xgap[0m  of a numerical semigroup S is a nonnegative integer not belonging to
  S. The [13Xfundamental gaps[0m of S are those gaps that are maximal with respect to
  the partial order induced by division in N.
  
  Given  a  numerical  semigroup  S  and  a  nonzero  element s in it, one can
  consider  for every integer i ranging from 0 to s-1, the smallest element in
  S  congruent  with  i  modulo  s,  say  w(i)  (this element exists since the
  complement  of  S  in  N  is  finite).  Clearly  w(0)=0.  The  set Ap(S,s)={
  w(0),w(1),..., w(s-1)} is called the [13XApéry set[0m of S with respect to s.
  
  Let  a,b,c,d  be positive integers such that a/b < c/d, and let I=[a/b,c/d].
  Then  the  set  S(I)=  Ncap  bigcup_n>= 0 n I is a numerical semigroup. This
  class  of  numerical  semigroups coincides with that of sets of solutions to
  equations  of  the  form  A  x  mod B <= C x with A,B,C positive integers. A
  numerical semigroup in this class is said to be [13Xproportionally modular[0m. If C
  = 1, then it is said to be [13Xmodular[0m.
  
  There are several different ways to specify a numerical semigroup S, namely,
  by its generators; by its gaps, its fundamental or special gaps by its Apéry
  set,  just  to  name some. In this section we describe functions that may be
  used to specify, in one of these ways, a numerical semigroup in [5XGAP[0m.
  
  To  create  a  numerical semigroup in [5XGAP[0m the function [10XNumericalSemigroup[0m is
  used.
  
  [1X2.1-1 NumericalSemigroup[0m
  
  [2X> NumericalSemigroup( [0X[3XType, List[0X[2X ) _________________________________[0Xfunction
  
  [10XType[0m
  
  May   be   [10X"generators"[0m,   [10X"minimalgenerators"[0m,   [10X"modular"[0m,  [10X"propmodular"[0m,
  [10X"elements"[0m, [10X"gaps"[0m, [10X"fundamentalgaps"[0m, [10X"subadditive"[0m or [10X"apery"[0m according to
  whether  the semigroup is to be given by means of a condition of the form ax
  mod  m <= x, a system of generators, a condition of the form ax mod m <= cx,
  a  set  of  all elements up to the Frobenius number +1, the set of gaps, the
  set of fundamental gaps, a periodic subaditive function or the Apéry set.
  
  When  no  string is given as first argument it is assumed that the numerical
  semigroup will be given by means of a set of generators.
  
  [10XList[0m
  
  When  the  semigroup  is  given through a set of generators, this set may be
  given as a list or through its individual elements.
  
  The  set of all elements up to the Frobenius number +1, the set of gaps, the
  set of fundamental gaps or the Apéry set are given through lists.
  
  A  periodic  subadditive function with period m is given through the list of
  images of the elements, from 1 to m. The image of m has to be 0.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> s1 := NumericalSemigroup("generators",3,5,7);[0X
    [4X<Numerical semigroup with 3 generators>[0X
    [4Xgap> s2 := NumericalSemigroup("generators",[3,5,7]);[0X
    [4X<Numerical semigroup with 3 generators>[0X
    [4Xgap> s1=s2;[0X
    [4Xtrue[0X
    [4Xgap> s := NumericalSemigroup("minimalgenerators",3,7);[0X
    [4X<Numerical semigroup with 2 generators>[0X
    [4Xgap> s := NumericalSemigroup("modular",3,5);[0X
    [4X<Modular numerical semigroup satisfying 3x mod 5 <= x >[0X
    [4Xgap> s1 := NumericalSemigroup("generators",2,5);[0X
    [4X<Numerical semigroup with 2 generators>[0X
    [4Xgap> s = s1;[0X
    [4Xtrue[0X
    [4X[0X
    [4X....................................[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.1-2 ModularNumericalSemigroup[0m
  
  [2X> ModularNumericalSemigroup( [0X[3Xa, b[0X[2X ) ________________________________[0Xfunction
  
  Given  two  positive  integers  [3Xa[0m  and  [3Xb[0m,  this  function returns a modular
  numerical semigroup satisfying ax mod b <= x.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> ModularNumericalSemigroup(3,7);[0X
    [4X<Modular numerical semigroup satisfying 3x mod 7 <= x >[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.1-3 ProportionallyModularNumericalSemigroup[0m
  
  [2X> ProportionallyModularNumericalSemigroup( [0X[3Xa, b, c[0X[2X ) _______________[0Xfunction
  
  Given  three  positive  integers  [3Xa[0m,  [3Xb[0m  and  [3Xc[0m,  this  function  returns  a
  proportionally modular numerical semigroup satisfying ax mod b <= cx.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> ProportionallyModularNumericalSemigroup(3,7,12);[0X
    [4X<Proportionally modular numerical semigroup satisfying 3x mod 7 <= 12x >[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.1-4 NumericalSemigroupByGenerators[0m
  
  [2X> NumericalSemigroupByGenerators( [0X[3XList[0X[2X ) ___________________________[0Xfunction
  [2X> NumericalSemigroupByMinimalGenerators( [0X[3XList[0X[2X ) ____________________[0Xfunction
  [2X> NumericalSemigroupByMinimalGeneratorsNC( [0X[3XList[0X[2X ) __________________[0Xfunction
  [2X> NumericalSemigroupByInterval( [0X[3XList[0X[2X ) _____________________________[0Xfunction
  [2X> NumericalSemigroupByOpenInterval( [0X[3XList[0X[2X ) _________________________[0Xfunction
  [2X> NumericalSemigroupBySubAdditiveFunction( [0X[3XList[0X[2X ) __________________[0Xfunction
  [2X> NumericalSemigroupByAperyList( [0X[3XList[0X[2X ) ____________________________[0Xfunction
  [2X> NumericalSemigroupBySmallElements( [0X[3XList[0X[2X ) ________________________[0Xfunction
  [2X> NumericalSemigroupByGaps( [0X[3XList[0X[2X ) _________________________________[0Xfunction
  [2X> NumericalSemigroupByFundamentalGaps( [0X[3XList[0X[2X ) ______________________[0Xfunction
  
  The  function [2XNumericalSemigroup[0m ([14X2.1-1[0m) is a front-end for these functions.
  The  argument of each of these functions is a list representing an entity of
  the type to which the function's name refers.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> s:=NumericalSemigroup(3,11);[0X
    [4X<Numerical semigroup with 2 generators>[0X
    [4Xgap> GapsOfNumericalSemigroup(s);[0X
    [4X[ 1, 2, 4, 5, 7, 8, 10, 13, 16, 19 ][0X
    [4Xgap> t:=NumericalSemigroupByGaps(last);[0X
    [4X<Numerical semigroup>[0X
    [4Xgap> s=t;[0X
    [4Xtrue[0X
    [4X[0X
    [4Xgap> AperyListOfNumericalSemigroupWRTElement(s,20);;[0X
    [4Xgap> t:=NumericalSemigroupByAperyList(last);[0X
    [4X<Numerical semigroup>[0X
    [4Xgap> s=t;[0X
    [4Xtrue[0X
    [4X...[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X2.2 Some basic tests[0X
  
  This  section  describes  some basic tests on numerical semigroups.The first
  described  tests  refer  to  the  way  the  semigroup  was created. Then are
  presented  functions  to test if a given list represents the small elements,
  gaps  or  the  Apéry  set  (see  [14X1.[0m) of a numerical semigroup; to test if an
  integer  belongs  to a numerical semigroup and if a numerical semigroup is a
  subsemigroup of another one.
  
  [1X2.2-1 IsNumericalSemigroup[0m
  
  [2X> IsNumericalSemigroup( [0X[3XNS[0X[2X ) ______________________________________[0Xattribute
  [2X> IsNumericalSemigroupByGenerators( [0X[3XNS[0X[2X ) __________________________[0Xattribute
  [2X> IsNumericalSemigroupByMinimalGenerators( [0X[3XNS[0X[2X ) ___________________[0Xattribute
  [2X> IsNumericalSemigroupByInterval( [0X[3XNS[0X[2X ) ____________________________[0Xattribute
  [2X> IsNumericalSemigroupByOpenInterval( [0X[3XNS[0X[2X ) ________________________[0Xattribute
  [2X> IsNumericalSemigroupBySubAdditiveFunction( [0X[3XNS[0X[2X ) _________________[0Xattribute
  [2X> IsNumericalSemigroupByAperyList( [0X[3XNS[0X[2X ) ___________________________[0Xattribute
  [2X> IsNumericalSemigroupBySmallElements( [0X[3XNS[0X[2X ) _______________________[0Xattribute
  [2X> IsNumericalSemigroupByGaps( [0X[3XNS[0X[2X ) ________________________________[0Xattribute
  [2X> IsNumericalSemigroupByFundamentalGaps( [0X[3XNS[0X[2X ) _____________________[0Xattribute
  [2X> IsProportionallyModularNumericalSemigroup( [0X[3XNS[0X[2X ) _________________[0Xattribute
  [2X> IsModularNumericalSemigroup( [0X[3XNS[0X[2X ) _______________________________[0Xattribute
  
  [3XNS[0m  is a numerical semigroup and these attributes are available (their names
  should be self explanatory).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> s:=NumericalSemigroup(3,7);[0X
    [4X<Numerical semigroup with 2 generators>[0X
    [4Xgap> AperyListOfNumericalSemigroupWRTElement(s,30);;[0X
    [4Xgap> t:=NumericalSemigroupByAperyList(last);[0X
    [4X<Numerical semigroup>[0X
    [4Xgap> IsNumericalSemigroupByGenerators(s);[0X
    [4Xtrue[0X
    [4Xgap> IsNumericalSemigroupByGenerators(t);[0X
    [4Xfalse[0X
    [4Xgap> IsNumericalSemigroupByAperyList(s);[0X
    [4Xfalse[0X
    [4Xgap> IsNumericalSemigroupByAperyList(t);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.2-2 RepresentsSmallElementsOfNumericalSemigroup[0m
  
  [2X> RepresentsSmallElementsOfNumericalSemigroup( [0X[3XL[0X[2X ) ________________[0Xattribute
  
  Tests  if  the  list  [3XL[0m (which has to be a set) may represent the ``small" #
  elements of a numerical semigroup.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> L:=[ 0, 3, 6, 9, 11, 12, 14, 15, 17, 18, 20 ];[0X
    [4X[ 0, 3, 6, 9, 11, 12, 14, 15, 17, 18, 20 ][0X
    [4Xgap> RepresentsSmallElementsOfNumericalSemigroup(L);[0X
    [4Xtrue[0X
    [4Xgap> L:=[ 6, 9, 11, 12, 14, 15, 17, 18, 20 ];[0X
    [4X[ 6, 9, 11, 12, 14, 15, 17, 18, 20 ][0X
    [4Xgap> RepresentsSmallElementsOfNumericalSemigroup(L);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.2-3 RepresentsGapsOfNumericalSemigroup[0m
  
  [2X> RepresentsGapsOfNumericalSemigroup( [0X[3XL[0X[2X ) _________________________[0Xattribute
  
  Tests  if  the  list  [3XL[0m  may  represent  the  gaps  (see  [14X1.[0m) of a numerical
  semigroup.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> s:=NumericalSemigroup(3,7);[0X
    [4X<Numerical semigroup with 2 generators>[0X
    [4Xgap> L:=GapsOfNumericalSemigroup(s);[0X
    [4X[ 1, 2, 4, 5, 8, 11 ][0X
    [4Xgap> RepresentsGapsOfNumericalSemigroup(L);[0X
    [4Xtrue[0X
    [4Xgap> L:=Set(List([1..21],i->RandomList([1..50])));[0X
    [4X[ 2, 6, 7, 8, 10, 12, 14, 19, 24, 28, 31, 35, 42, 50 ][0X
    [4Xgap> RepresentsGapsOfNumericalSemigroup(L);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.2-4 IsAperyListOfNumericalSemigroup[0m
  
  [2X> IsAperyListOfNumericalSemigroup( [0X[3XL[0X[2X ) _____________________________[0Xfunction
  
  Tests  whether  a  list  [3XL[0m  of  integers  may  represent the Apéry list of a
  numerical  semigroup. It returns [9Xtrue[0m when the periodic function represented
  by  [3XL[0m is subadditive (see [2XRepresentsPeriodicSubAdditiveFunction[0m ([14XA.2-1[0m)) and
  the  remainder  of  the division of [10XL[i][0m by the length of [3XL[0m is [10Xi[0m and returns
  [9Xfalse[0m otherwise (the crieterium used is the one explained in [Ros96b]).
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> IsAperyListOfNumericalSemigroup([0,21,7,28,14]);[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.2-5 IsSubsemigroupOfNumericalSemigroup[0m
  
  [2X> IsSubsemigroupOfNumericalSemigroup( [0X[3XS, T[0X[2X ) _______________________[0Xfunction
  
  [3XS[0m and [3XT[0m are numerical semigroups. Tests whether [3XT[0m is contained in [3XS[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> S := NumericalSemigroup("modular", 5,53);[0X
    [4X<Modular numerical semigroup satisfying 5x mod 53 <= x >[0X
    [4Xgap> T := NumericalSemigroup(2,3);[0X
    [4X<Numerical semigroup with 2 generators>[0X
    [4Xgap> IsSubsemigroupOfNumericalSemigroup(T,S);[0X
    [4Xtrue[0X
    [4Xgap> IsSubsemigroupOfNumericalSemigroup(S,T);[0X
    [4Xfalse[0X
  [4X------------------------------------------------------------------[0X
  
  [1X2.2-6 BelongsToNumericalSemigroup[0m
  
  [2X> BelongsToNumericalSemigroup( [0X[3Xn, S[0X[2X ) _____________________________[0Xoperation
  
  [3Xn[0m  is  an integer and [3XS[0m is a numerical semigroup. Tests whether [3Xn[0m belongs to
  [3XS[0m. [10Xn in S[0m is the short for [10XBelongsToNumericalSemigroup(n,S)[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4Xgap> S := NumericalSemigroup("modular", 5,53);[0X
    [4X<Modular numerical semigroup satisfying 5x mod 53 <= x >[0X
    [4Xgap> BelongsToNumericalSemigroup(15,S);[0X
    [4Xfalse[0X
    [4Xgap> 15 in S;[0X
    [4Xfalse[0X
    [4Xgap> SmallElementsOfNumericalSemigroup(S);[0X
    [4X[ 0, 11, 12, 13, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36, 37, 38, 39, 43 ][0X
    [4Xgap> BelongsToNumericalSemigroup(13,S);[0X
    [4Xtrue[0X
    [4Xgap> 13 in S;[0X
    [4Xtrue[0X
  [4X------------------------------------------------------------------[0X
  
