<Section>
                <Heading>
                    Generating Numerical Semigroups
                </Heading>
Recalling some definitions from Chapter <Ref Chap="Intro"/>.
<P/>
A numerical semigroup
is a subset of the set <M> {\mathbb N} </M> of nonnegative integers
that is closed under addition, contains <M>0</M> and whose complement in <M> {\mathbb N} </M> is
finite.


<P/>

We refer to the elements in a numerical
semigroup that are less than or equal to
the Frobenius number plus 1 as <E>small
elements</E> of the semigroup.

<P/>

A <E>gap</E> of a numerical semigroup <M>S</M> is a nonnegative integer not belonging to
<M>S</M>.
The <E>fundamental gaps</E> of <M>S</M> are those gaps that are maximal with respect to the partial order induced by
division in <M>{\mathbb N}</M>.

<P/>

Given a numerical semigroup <M>S</M> and a nonzero element <M>s</M> in it, one
can consider for every integer <M>i</M> ranging from <M>0</M> to <M>s-1</M>,
the smallest element in <M>S</M> congruent with <M>i</M> modulo <M>s</M>, say
<M>w(i)</M> (this element exists since the complement of <M>S</M> in
<M>{\mathbb N}</M> is finite). Clearly <M>w(0)=0</M>. The set <M>{\rm
Ap}(S,s)=\{ w(0),w(1),\ldots, w(s-1)\}</M> is called the <E>Apéry set</E> of
<M>S</M> with respect to <M>s</M>.

<P/>

Let <M>a,b,c,d</M> be positive integers such that <M>a/b &lt; c/d</M>, and let <M>I=[a/b,c/d]</M>.
Then the set <M>{\rm S}(I)={\mathbb N}\cap \bigcup_{n\geq 0} n I</M> is a numerical semigroup.
This class of numerical semigroups coincides with that of sets of solutions to equations of the
form <M> A x \ mod\ B \leq C x</M> with <M> A,B,C</M> positive integers. A numerical semigroup in
this class is said to be <E>proportionally modular</E>.
If <M>C = 1</M>, then it is said to be <E>modular</E>.

<P/>

There are several different ways to specify a numerical semigroup <M>S</M>,
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 &GAP;.

<P/>

                To create a numerical semigroup in &GAP; the function
                <C>NumericalSemigroup</C> is used.
                <ManSection>
                    <Func Name="NumericalSemigroup" Arg="Type, List"/>
                    <Description>
                        <C>Type</C>
                        <P/>

                        May be <C>"generators"</C>, <C>"minimalgenerators"</C>, <C>"modular"</C>,
                        <C>"propmodular"</C>, <C>"elements"</C>, <C>"gaps"</C>,
                        <C>"fundamentalgaps"</C>, <C>"subadditive"</C> or <C>"apery"</C> according to
                        whether the semigroup is to be given by means of a
                        condition of the form <M> ax \ mod\ m</M> &tlt;<M>= x</M>, a system of
                        generators, a condition of the form <M> ax \ mod\ m</M> &tlt;<M>= cx</M>, a set
                        of all elements up to the Frobenius number <M>+1</M>, the set of gaps, the
                        set of fundamental gaps, a periodic subaditive function or the Apéry set.
                        <P/>
                        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.
                        <P/>
                        <C>List</C>
                        <P/>
                        When the semigroup is given through a set of generators, this set
                        may be given as a list or through its individual elements.
                        <P/>
                        The set of all elements up to the Frobenius number <M>+1</M>, the set of
                        gaps, the set of fundamental gaps or the Apéry set are given through lists.
                        <P/>
                        A periodic subadditive function with period <M>m</M> is given through the
                        list of images of the elements, from <M>1</M> to <M>m</M>. The image of <M>m</M>
                        has to be <M>0</M>.
                        <Example><![CDATA[
gap> s1 := NumericalSemigroup("generators",3,5,7);
<Numerical semigroup with 3 generators>
gap> s2 := NumericalSemigroup("generators",[3,5,7]);
<Numerical semigroup with 3 generators>
gap> s1=s2;
true
gap> s := NumericalSemigroup("minimalgenerators",3,7);
<Numerical semigroup with 2 generators>
gap> s := NumericalSemigroup("modular",3,5);
<Modular numerical semigroup satisfying 3x mod 5 <= x >
gap> s1 := NumericalSemigroup("generators",2,5);
<Numerical semigroup with 2 generators>
gap> s = s1;
true

....................................
]]></Example>
                    </Description>
                </ManSection>



                <ManSection>
                    <Func Name="ModularNumericalSemigroup" Arg="a,b"/>
                    <Description>
                        Given two positive integers <A>a</A> and <A>b</A>,
                        this function returns a modular numerical semigroup
                        satisfying <M>ax \ mod\ b &lt;= x</M>.
                        <Example><![CDATA[
gap> ModularNumericalSemigroup(3,7);
<Modular numerical semigroup satisfying 3x mod 7 <= x >
]]></Example>
                    </Description>
                </ManSection>


                <ManSection>
                    <Func Name="ProportionallyModularNumericalSemigroup" Arg="a,b,c"/>
                    <Description>
                        Given three positive integers <A>a</A>, <A>b</A> and <A>c</A>,
                        this function returns a proportionally modular numerical semigroup
                        satisfying <M>ax\ mod\ b &lt;= cx</M>.
                        <Example><![CDATA[
gap> ProportionallyModularNumericalSemigroup(3,7,12);
<Proportionally modular numerical semigroup satisfying 3x mod 7 <= 12x >
]]></Example>
                    </Description>
                </ManSection>






                <ManSection>
                    <Func Name="NumericalSemigroupByGenerators" Arg="List"/>
                    <Func Name="NumericalSemigroupByMinimalGenerators" Arg="List"/>
                    <Func Name="NumericalSemigroupByMinimalGeneratorsNC" Arg="List"/>
                    <Func Name="NumericalSemigroupByInterval" Arg="List"/>
                    <Func Name="NumericalSemigroupByOpenInterval" Arg="List"/>
                    <Func Name="NumericalSemigroupBySubAdditiveFunction" Arg="List"/>
                    <Func Name="NumericalSemigroupByAperyList" Arg="List"/>
                    <Func Name="NumericalSemigroupBySmallElements" Arg="List"/>
                    <Func Name="NumericalSemigroupByGaps" Arg="List"/>
                    <Func Name="NumericalSemigroupByFundamentalGaps" Arg="List"/>

                    <Description>The function <Ref Func="NumericalSemigroup" /> 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.

                        <Example><![CDATA[
gap> s:=NumericalSemigroup(3,11);
<Numerical semigroup with 2 generators>
gap> GapsOfNumericalSemigroup(s);
[ 1, 2, 4, 5, 7, 8, 10, 13, 16, 19 ]
gap> t:=NumericalSemigroupByGaps(last);
<Numerical semigroup>
gap> s=t;
true

gap> AperyListOfNumericalSemigroupWRTElement(s,20);;
gap> t:=NumericalSemigroupByAperyList(last);
<Numerical semigroup>
gap> s=t;
true
...
]]></Example>
                    </Description>
                </ManSection>


            </Section>
