  
  [1m[4m[31m2. Numerical Semigroups[0m
  
  This chapter describes how to create numerical semigroups in [1mGAP[0m and perform
  some basic tests.
  
  
  [1m[4m[31m2.1 Generating Numerical Semigroups[0m
  
  Recalling some definitions from Chapter [1m1.[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 [22m[36msmall elements[0m of the semigroup.
  
  A  [22m[36mgap[0m  of a numerical semigroup S is a nonnegative integer not belonging to
  S. The [22m[36mfundamental 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 rm Ap(S,s)=
  w(0),w(1),..., w(s-1) is called the [22m[36mApé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 rm 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 [22m[36mproportionally modular[0m. If C
  = 1, then it is said to be [22m[36mmodular[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 [1mGAP[0m.
  
  To  create  a  numerical semigroup in [1mGAP[0m the function [22m[32mNumericalSemigroup[0m is
  used.
  
  [1m[4m[31m2.1-1 NumericalSemigroup[0m
  
  [1m[34m> NumericalSemigroup( [0m[22m[34mType, List[0m[1m[34m ) _________________________________[0mfunction
  
  [22m[32mType[0m
  
  May   be   [22m[32m"generators"[0m,   [22m[32m"minimalgenerators"[0m,   [22m[32m"modular"[0m,  [22m[32m"propmodular"[0m,
  [22m[32m"elements"[0m, [22m[32m"gaps"[0m, [22m[32m"fundamentalgaps"[0m, [22m[32m"subadditive"[0m or [22m[32m"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.
  
  [22m[32mList[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.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> s1 := NumericalSemigroup("generators",3,5,7);[0m
    [22m[35m<Numerical semigroup with 3 generators>[0m
    [22m[35mgap> s2 := NumericalSemigroup("generators",[3,5,7]);[0m
    [22m[35m<Numerical semigroup with 3 generators>[0m
    [22m[35mgap> s1=s2;[0m
    [22m[35mtrue[0m
    [22m[35mgap> s := NumericalSemigroup("minimalgenerators",3,7);[0m
    [22m[35m<Numerical semigroup with 2 generators>[0m
    [22m[35mgap> s := NumericalSemigroup("modular",3,5);[0m
    [22m[35m<Modular numerical semigroup satisfying 3x mod 5 <= x >[0m
    [22m[35mgap> s1 := NumericalSemigroup("generators",2,5);[0m
    [22m[35m<Numerical semigroup with 2 generators>[0m
    [22m[35mgap> s = s1;[0m
    [22m[35mtrue[0m
    [22m[35m[0m
    [22m[35m....................................[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.1-2 ModularNumericalSemigroup[0m
  
  [1m[34m> ModularNumericalSemigroup( [0m[22m[34ma, b[0m[1m[34m ) ________________________________[0mfunction
  
  Given  two  positive  integers  [22m[34ma[0m  and  [22m[34mb[0m,  this  function returns a modular
  numerical semigroup satisfying ax mod b <= x.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> ModularNumericalSemigroup(3,7);[0m
    [22m[35m<Modular numerical semigroup satisfying 3x mod 7 <= x >[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.1-3 ProportionallyModularNumericalSemigroup[0m
  
  [1m[34m> ProportionallyModularNumericalSemigroup( [0m[22m[34ma, b, c[0m[1m[34m ) _______________[0mfunction
  
  Given  three  positive  integers  [22m[34ma[0m,  [22m[34mb[0m  and  [22m[34mc[0m,  this  function  returns  a
  proportionally modular numerical semigroup satisfying ax mod b <= cx.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> ProportionallyModularNumericalSemigroup(3,7,12);[0m
    [22m[35m<Proportionally modular numerical semigroup satisfying 3x mod 7 <= 12x >[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.1-4 NumericalSemigroupByGenerators[0m
  
  [1m[34m> NumericalSemigroupByGenerators( [0m[22m[34mList[0m[1m[34m ) ___________________________[0mfunction
  [1m[34m> NumericalSemigroupByMinimalGenerators( [0m[22m[34mList[0m[1m[34m ) ____________________[0mfunction
  [1m[34m> NumericalSemigroupByMinimalGeneratorsNC( [0m[22m[34mList[0m[1m[34m ) __________________[0mfunction
  [1m[34m> NumericalSemigroupByInterval( [0m[22m[34mList[0m[1m[34m ) _____________________________[0mfunction
  [1m[34m> NumericalSemigroupByOpenInterval( [0m[22m[34mList[0m[1m[34m ) _________________________[0mfunction
  [1m[34m> NumericalSemigroupBySubAdditiveFunction( [0m[22m[34mList[0m[1m[34m ) __________________[0mfunction
  [1m[34m> NumericalSemigroupByAperyList( [0m[22m[34mList[0m[1m[34m ) ____________________________[0mfunction
  [1m[34m> NumericalSemigroupBySmallElements( [0m[22m[34mList[0m[1m[34m ) ________________________[0mfunction
  [1m[34m> NumericalSemigroupByGaps( [0m[22m[34mList[0m[1m[34m ) _________________________________[0mfunction
  [1m[34m> NumericalSemigroupByFundamentalGaps( [0m[22m[34mList[0m[1m[34m ) ______________________[0mfunction
  
  The  function [1m[34mNumericalSemigroup[0m ([1m2.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.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> s:=NumericalSemigroup(3,11);[0m
    [22m[35m<Numerical semigroup with 2 generators>[0m
    [22m[35mgap> GapsOfNumericalSemigroup(s);[0m
    [22m[35m[ 1, 2, 4, 5, 7, 8, 10, 13, 16, 19 ][0m
    [22m[35mgap> t:=NumericalSemigroupByGaps(last);[0m
    [22m[35m<Numerical semigroup>[0m
    [22m[35mgap> s=t;[0m
    [22m[35mtrue[0m
    [22m[35m[0m
    [22m[35mgap> AperyListOfNumericalSemigroupWRTElement(s,20);;[0m
    [22m[35mgap> t:=NumericalSemigroupByAperyList(last);[0m
    [22m[35m<Numerical semigroup>[0m
    [22m[35mgap> s=t;[0m
    [22m[35mtrue[0m
    [22m[35m...[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m2.2 Some basic tests[0m
  
  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  [1m1.[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.
  
  [1m[4m[31m2.2-1 IsNumericalSemigroup[0m
  
  [1m[34m> IsNumericalSemigroup( [0m[22m[34mNS[0m[1m[34m ) ______________________________________[0mattribute
  [1m[34m> IsNumericalSemigroupByGenerators( [0m[22m[34mNS[0m[1m[34m ) __________________________[0mattribute
  [1m[34m> IsNumericalSemigroupByMinimalGenerators( [0m[22m[34mNS[0m[1m[34m ) ___________________[0mattribute
  [1m[34m> IsNumericalSemigroupByInterval( [0m[22m[34mNS[0m[1m[34m ) ____________________________[0mattribute
  [1m[34m> IsNumericalSemigroupByOpenInterval( [0m[22m[34mNS[0m[1m[34m ) ________________________[0mattribute
  [1m[34m> IsNumericalSemigroupBySubAdditiveFunction( [0m[22m[34mNS[0m[1m[34m ) _________________[0mattribute
  [1m[34m> IsNumericalSemigroupByAperyList( [0m[22m[34mNS[0m[1m[34m ) ___________________________[0mattribute
  [1m[34m> IsNumericalSemigroupBySmallElements( [0m[22m[34mNS[0m[1m[34m ) _______________________[0mattribute
  [1m[34m> IsNumericalSemigroupByGaps( [0m[22m[34mNS[0m[1m[34m ) ________________________________[0mattribute
  [1m[34m> IsNumericalSemigroupByFundamentalGaps( [0m[22m[34mNS[0m[1m[34m ) _____________________[0mattribute
  [1m[34m> IsProportionallyModularNumericalSemigroup( [0m[22m[34mNS[0m[1m[34m ) _________________[0mattribute
  [1m[34m> IsModularNumericalSemigroup( [0m[22m[34mNS[0m[1m[34m ) _______________________________[0mattribute
  
  [22m[34mNS[0m  is a numerical semigroup and these attributes are available (their names
  should be self explanatory).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> s:=NumericalSemigroup(3,7);[0m
    [22m[35m<Numerical semigroup with 2 generators>[0m
    [22m[35mgap> AperyListOfNumericalSemigroupWRTElement(s,30);;[0m
    [22m[35mgap> t:=NumericalSemigroupByAperyList(last);[0m
    [22m[35m<Numerical semigroup>[0m
    [22m[35mgap> IsNumericalSemigroupByGenerators(s);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsNumericalSemigroupByGenerators(t);[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsNumericalSemigroupByAperyList(s);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsNumericalSemigroupByAperyList(t);[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-2 RepresentsSmallElementsOfNumericalSemigroup[0m
  
  [1m[34m> RepresentsSmallElementsOfNumericalSemigroup( [0m[22m[34mL[0m[1m[34m ) ________________[0mattribute
  
  Tests  if  the  list  [22m[34mL[0m (which has to be a set) may represent the ``small" #
  elements of a numerical semigroup.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L:=[ 0, 3, 6, 9, 11, 12, 14, 15, 17, 18, 20 ];[0m
    [22m[35m[ 0, 3, 6, 9, 11, 12, 14, 15, 17, 18, 20 ][0m
    [22m[35mgap> RepresentsSmallElementsOfNumericalSemigroup(L);[0m
    [22m[35mtrue[0m
    [22m[35mgap> L:=[ 6, 9, 11, 12, 14, 15, 17, 18, 20 ];[0m
    [22m[35m[ 6, 9, 11, 12, 14, 15, 17, 18, 20 ][0m
    [22m[35mgap> RepresentsSmallElementsOfNumericalSemigroup(L);[0m
    [22m[35mfalse[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-3 RepresentsGapsOfNumericalSemigroup[0m
  
  [1m[34m> RepresentsGapsOfNumericalSemigroup( [0m[22m[34mL[0m[1m[34m ) _________________________[0mattribute
  
  Tests  if  the  list  [22m[34mL[0m  may  represent  the  gaps  (see  [1m1.[0m) of a numerical
  semigroup.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> s:=NumericalSemigroup(3,7);[0m
    [22m[35m<Numerical semigroup with 2 generators>[0m
    [22m[35mgap> L:=GapsOfNumericalSemigroup(s);[0m
    [22m[35m[ 1, 2, 4, 5, 8, 11 ][0m
    [22m[35mgap> RepresentsGapsOfNumericalSemigroup(L);[0m
    [22m[35mtrue[0m
    [22m[35mgap> L:=Set(List([1..21],i->RandomList([1..50])));[0m
    [22m[35m[ 2, 6, 7, 8, 10, 12, 14, 19, 24, 28, 31, 35, 42, 50 ][0m
    [22m[35mgap> RepresentsGapsOfNumericalSemigroup(L);[0m
    [22m[35mfalse[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-4 IsAperyListOfNumericalSemigroup[0m
  
  [1m[34m> IsAperyListOfNumericalSemigroup( [0m[22m[34mL[0m[1m[34m ) _____________________________[0mfunction
  
  Tests  whether  a  list  [22m[34mL[0m  of  integers  may  represent the Apéry list of a
  numerical  semigroup. It returns [22m[32mtrue[0m when the periodic function represented
  by  [22m[34mL[0m is subadditive (see [1m[34mRepresentsPeriodicSubAdditiveFunction[0m ([1mA.2-1[0m)) and
  the  remainder  of  the division of [22m[32mL[i][0m by the length of [22m[34mL[0m is [22m[32mi[0m and returns
  [22m[32mfalse[0m otherwise (the crieterium used is the one explained in [R96]).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsAperyListOfNumericalSemigroup([0,21,7,28,14]);[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-5 IsSubsemigroupOfNumericalSemigroup[0m
  
  [1m[34m> IsSubsemigroupOfNumericalSemigroup( [0m[22m[34mS, T[0m[1m[34m ) _______________________[0mfunction
  
  [22m[34mS[0m and [22m[34mT[0m are numerical semigroups. Tests whether [22m[34mT[0m is contained in [22m[34mS[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> S := NumericalSemigroup("modular", 5,53);[0m
    [22m[35m<Modular numerical semigroup satisfying 5x mod 53 <= x >[0m
    [22m[35mgap> T := NumericalSemigroup(2,3);[0m
    [22m[35m<Numerical semigroup with 2 generators>[0m
    [22m[35mgap> IsSubsemigroupOfNumericalSemigroup(T,S);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsSubsemigroupOfNumericalSemigroup(S,T);[0m
    [22m[35mfalse[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-6 BelongsToNumericalSemigroup[0m
  
  [1m[34m> BelongsToNumericalSemigroup( [0m[22m[34mn, S[0m[1m[34m ) _____________________________[0moperation
  
  [22m[34mn[0m  is  an integer and [22m[34mS[0m is a numerical semigroup. Tests whether [22m[34mn[0m belongs to
  [22m[34mS[0m. [22m[32mn in S[0m is the short for [22m[32mBelongsToNumericalSemigroup(n,S)[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> S := NumericalSemigroup("modular", 5,53);[0m
    [22m[35m<Modular numerical semigroup satisfying 5x mod 53 <= x >[0m
    [22m[35mgap> BelongsToNumericalSemigroup(15,S);[0m
    [22m[35mfalse[0m
    [22m[35mgap> 15 in S;[0m
    [22m[35mfalse[0m
    [22m[35mgap> SmallElementsOfNumericalSemigroup(S);[0m
    [22m[35m[ 0, 11, 12, 13, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36, 37, 38, 39, 43 ][0m
    [22m[35mgap> BelongsToNumericalSemigroup(13,S);[0m
    [22m[35mtrue[0m
    [22m[35mgap> 13 in S;[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
