1 Introduction

Let k be a field and let R be a Cohen–Macaulay positively graded k-algebra with graded maximal ideal \({\mathfrak {m}}\). Assume that R admits a canonical module \(\omega _R\) and let

$$\begin{aligned} \mathrm{tr}(\omega _R)=\sum _{\varphi \in \mathrm{Hom}_R(\omega _R,R)} \varphi (\omega _R) \end{aligned}$$

be the trace ideal of \(\omega _R\). If \({\mathfrak {p}} \in \mathrm{Spec}(R)\), in [13, Lemma 2.1] it is proved that the ring \(R_{{\mathfrak {p}}}\) is not Gorenstein if and only if \(\mathrm{tr}(\omega _R) \subseteq {\mathfrak {p}}\), thus \(\mathrm{tr}(\omega _R)\) describes the non-Gorenstein locus of R. In particular, R is Gorenstein if and only if \(\mathrm{tr}(\omega _R)=R\). In [13] Herzog et al. call a ring for which \({\mathfrak {m}} \subseteq \mathrm{tr}(\omega _R)\) nearly Gorenstein and provide an extensive study of these rings. Clearly, these are Gorenstein on the punctured spectrum, but the converse is not true.

Another generalization of Gorenstein ring is given by the notion of almost Gorenstein ring, introduced by Barucci and Fröberg [2] in the case of analytically unramified rings of dimension one and generalized in [10, 11]. In general, nearly and almost Gorensteinness are two unrelated notions, but in dimension one an almost Gorenstein ring is always nearly Gorenstein.

In [2], the definition of almost Gorenstein ring arises in the context of numerical semigroups, indeed the authors introduce first the similar notion of almost symmetric numerical semigroup. The aim of the present paper is to study the relations between almost symmetric and nearly Gorenstein numerical semigroup rings and, in particular, we extend some properties of almost symmetric semigroups to the nearly Gorenstein case.

We recall that a numerical semigroup S is a submonoid of the natural numbers \({\mathbb {N}}\), such that \({\mathbb {N}}{\setminus } S\) is finite, while the numerical semigroup ring associated with S and a field k is the one-dimensional domain \(k[S]=k[t^s \mid s \in S]\). If S is minimally generated by \(n_1, \dots , n_\nu \) and k is algebraically closed, the ring k[S] is isomorphic to the coordinate ring of the curve in \({\mathbb {A}}^{\nu }\) parametrized by the monomials \(t^{n_1}, t^{n_2}, \dots , t^{n_{\nu }}\). Bearing in mind this bijection, studying the properties of an affine monomial curve is equivalent to study its associated numerical semigroup.

It is well known that the Cohen–Macaulay type of a numerical semigroup ring does not exceed two, if it has embedding dimension at most three. This turns out to be false in embedding dimension 4, in fact there is no upper bound for the Cohen–Macaulay type in this case, see [8, Example p. 75]. On the other hand, if k[S] is almost Gorenstein and it has embedding dimension 4, Numata [21] asked if the Cohen–Macaulay type of k[S] is at most three; this was indeed proved by the first author in [18] by using the new notion of row factorization matrix. In [18] it is also asked if there exists an upper bound for the Cohen–Macaulay type of an almost Gorenstein numerical semigroup ring in terms of its embedding dimension. Generalizing this question, in [26] Stamate raised the same problem for nearly Gorenstein rings. Here we give a positive answer in embedding dimension four by proving that also in this case the Cohen–Macaulay type is at most three. To achieve this result we give a new characterization of nearly Gorenstein numerical semigroups and we introduce a different kind of row factorization matrix which might be useful also in further studies of these semigroups. Moreover, we prove that a nearly Gorenstein numerical semigroup can be obtained by gluing only if it is symmetric and we characterize when a numerical semigroup generated by a generalized arithmetic sequence is nearly Gorenstein.

The structure of the paper is the following. In the first section, we fix the notation and recall the basic definitions and results. In Proposition 1.1, we also prove a useful characterization of nearly Gorenstein numerical semigroups and we introduce the notion of NG-vector. In the second section, we study the type of a nearly Gorenstein numerical semigroup S and the main result is Theorem 2.4, where we prove that the type of S is at most three if S has embedding dimension four. In Sect. 3, we study when gluing and generalizing arithmetic sequences are nearly Gorenstein and, as a consequence, we obtain that if \(S=\langle n_1, \dots , n_\nu \rangle \) is a nearly Gorenstein semigroup with embedding dimension \(\nu \) and S is not symmetric, then the elements of \(\{n_1, \dots , \widehat{n_i}, \dots , n_{\nu }\}\) are relatively coprime for every i, see Corollary 3.3. Finally in the last section we raise some questions for further developments.

The computations appearing in this paper were performed using the GAP system [9] and, in particular, the NumericalSgps package [5].

2 Preliminaries and NG-Vectors

Let S be a numerical semigroup, i.e., a finite submonoid of \({\mathbb {N}}\) such that \({\mathbb {N}}{\setminus } S\) is finite. Given \(n_1, \dots , n_{\nu } \in {\mathbb {N}}\) with \(\gcd (n_1,\dots ,n_{\nu })=1\), we define the numerical semigroup \(\langle n_1, \dots , n_{\nu }\rangle =\{\sum _{i=1}^{\nu } a_i n_i \mid a_i \in {\mathbb {N}} \text { for every } i\}\) and we say that \(\{n_1, \dots , n_{\nu }\}\) is a set of generators of this semigroup. It is well known that every numerical semigroup has a unique set of minimal generators and it is finite. We denote it by \({\text {G}}(S)\) and we refer to its cardinality as the embedding dimension of S. The maximum of \({\mathbb {N}}{\setminus } S\) is called Frobenius number of S and it is denoted by \({\text {F}}(S)\). Let also \({\text {PF}}(S)=\{f \in {\mathbb {Z}} {\setminus } S \mid f+s \in S \text { for any } s \in S{\setminus } \{0\}\}\) be the set of pseudo-Frobenius numbers of S and note that \({\text {F}}(S) \in {\text {PF}}(S)\). The type t(S) of S is the cardinality of \({\text {PF}}(S)\). We note that the embedding dimension and the type of S are equal to the embedding dimension and the Cohen–Macaulay type of k[S], respectively, where k is a field. In particular, k[S] is Gorenstein if and only if \({\text {PF}}(S)=\{{\text {F}}(S)\}\) and in this case S is said to be symmetric.

A relative ideal of S is a set \(I \subseteq {\mathbb {Z}}\) such that \(I+S \subseteq I\) and there exists \(x \in S\) for which \(x+I \subseteq S\). Two important examples of relative ideals are the maximal ideal \(M(S)=S {\setminus } \{0\}\) and the canonical ideal \(K(S)=\{z \in {\mathbb {Z}} \mid {\text {F}}(S)-z \notin S\} \supseteq S\). We recall that \(K(S)=S\) if and only if S is symmetric and that K(S) is generated as relative ideal by the elements \({\text {F}}(S)-f\) with \(f \in {\text {PF}}(S)\), i.e., \(K(S)=\{{\text {F}}(S)-f+s \mid f \in {\text {PF}}(S), s \in S\}\). For more information about numerical semigroups we refer to [1, 24].

A numerical semigroup S is said to be almost symmetric if \(M(S)+K(S) = M(S)\) and k[S] is almost Gorenstein if and only if S is almost symmetric. A nice characterization of these semigroups was proved by Nari in [19, Theorem 2.4]: S is almost symmetric if and only if \({\text {F}}(S)-f \in {\text {PF}}(S)\) for all \(f \in {\text {PF}}(S){\setminus } \{{\text {F}}(S)\}\).

It follows by [13, Lemma 1.1] that k[S] is nearly Gorenstein if and only if \(M(S) \subseteq K(S)+(S-K(S))\) and in this case we simply say that S is a nearly Gorenstein semigroup. It is known that an almost symmetric numerical semigroup is nearly Gorenstein, because this implication holds for one-dimensional rings, see [13, Proposition 6.1]. Anyway it is possible to obtain this result as a consequence of the next proposition.

Proposition 1.1

The following statements hold:

  1. (1)

    S is almost symmetric if and only if \(n+{\text {F}}(S)-f \in S\) for all \(f \in {\text {PF}}(S)\) and all \(n \in {\text {G}}(S)\);

  2. (2)

    S is nearly Gorenstein if and only if for every \(n_i \in {\text {G}}(S)\) there exists \(f_i \in {\text {PF}}(S)\) such that \(n_i+f_i-f \in S\) for all \(f \in {\text {PF}}(S)\).

In particular, an almost symmetric numerical semigroup is nearly Gorenstein.

Proof

(1) The second condition is equivalent to \({\text {F}}(S)-f \in {\text {PF}}(S)\) for every \(f \in {\text {PF}}(S){\setminus } \{{\text {F}}(S)\}\). Therefore, the conclusion follows by Nari’s characterization [19, Theorem 2.4].

(2) We can assume that S is not symmetric. Since the generators of K(S) are \({\text {F}}(S)-f\) with \(f \in {\text {PF}}(S)\), the second condition is equivalent to \(x_i= n_i + f_i - {\text {F}}(S) \in (S-K(S))\) for every \(i=1, \dots , \nu \). If this holds, it is clear that \(n_i={\text {F}}(S)-f_i +x_i \in K(S) + (S-K(S))\) for every minimal generator \(n_i\) and, thus, \(M(S) \subseteq K(S)+(S-K(S))\).

Conversely, assume that S is nearly Gorenstein. Every generator of S lies in \(K(S)+(S-K(S))\) and \(0 \notin (S-K(S))\), since S is not symmetric. Let \(n_i \in {\text {G}}(S)\) and \(n_i=k+x\) with \(k \in K(S)\) and \(x \in (S-K(S))\). Therefore, \(k={\text {F}}(S)-f_i +s\) for some \(f_i \in {\text {PF}}(S)\) and some \(s \in S\). Since \(({\text {F}}(S)-f_i)+x \in S {\setminus } \{0\}\) and \(n_i\) is a minimal generator, it follows that \(s=0\) and \(n_i+f_i - {\text {F}}(S)=x \in (S-K(S))\) which yields the thesis. \(\square \)

Definition 1.2

Let \(S=\langle n_1, \dots , n_{\nu }\rangle \), where \(n_1< \dots < n_{\nu }\) are minimal generators. We call a vector \(\mathbf{{f}}=(f_1,\dots , f_{\nu }) \in {\text {PF}}(S)^{\nu }\) nearly Gorenstein vector for S, briefly NG-vector, if \(n_i+f_i-f \in S\) for every \(f \in {\text {PF}}(S)\) and every \(i=1, \dots , \nu \).

By Proposition 1.1, the existence of an NG-vector is equivalent to the nearly Gorensteinness of S, whereas S is almost symmetric if and only if it admits the NG-vector \(({\text {F}}(S), \dots , {\text {F}}(S))\).

Proposition 1.3

Let \((f_1, \dots , f_{\nu })\) be an NG-vector for S. The following hold:

  1. (1)

    \(f_1={\text {F}}(S)\);

  2. (2)

    If i is the smallest index for which \(f_i \ne {\text {F}}(S)\), then \(f_i={\text {F}}(S)-n_i+n_l\) for some \(l < i\).

Proof

  1. (1)

    By definition of \(f_1\) we have \(n_1 + f_1 - {\text {F}}(S) \in S\). If \(n_1 + f_1 - {\text {F}}(S)=0\), then \({\text {F}}(S)=f_1+n_1 \in S\), which is a contradiction. Therefore, since \(f_1 \le {\text {F}}(S)\) it follows that \(n_1 + f_1 - {\text {F}}(S) \le n_1\) and, then, \(n_1 + f_1 - {\text {F}}(S)=n_1\), i.e., \(f_1={\text {F}}(S)\).

  2. (2)

    Since \(n_i > n_i + f_i - {\text {F}}(S) \in S\), it follows that \(n_i+f_i-{\text {F}}(S)=a_1 n_1 + \dots + a_{i-1}n_{i-1}\) for some non-negative integers \(a_1, \dots , a_{i-1}\). At least one of these integers has to be positive, so assume that \(a_l >0\); then, \(n_i = {\text {F}}(S)-f_i+n_l+ a_1n_1 + \dots +(a_l-1)n_l + \dots +a_{i-1}n_{i-1}\). From \({\text {F}}(S)=f_l\), it follows that \({\text {F}}(S)-f_i+n_l \in S {\setminus } \{0\}\), and since \(n_i\) is a minimal generator, this implies that \(a_l=1\) and \(a_j=0\) if \(j \ne l\), i.e., \(f_i={\text {F}}(S)-n_i+n_l\).

\(\square \)

We remark that \(\mathbf{{f}}\) could be not unique. For instance the pseudo-Frobenius numbers of \(S=\langle 4,5,11 \rangle \) are \({\text {PF}}(S)=\{6,7\}\) and it is easy to see that (7, 6, 6) and (7, 6, 7) are the NG-vectors of S. In particular, in this case, S is nearly Gorenstein but not almost symmetric.

3 On the Type of a Nearly Gorenstein Semigroup

Throughout this section, we set \(S=\langle n_1, \dots , n_\nu \rangle \), where \(n_1< n_2< \dots < n_\nu \) are minimal generators. Moreover, if S is nearly Gorenstein, we fix an NG-vector \(\mathbf{{f}}=(f_1, \dots , f_{\nu })\).

For every \(f \in {\text {PF}}(S)\) and every \(i=1, \dots , \nu \) we have \(f+n_i=\sum _{j=1}^\nu a_{ij}n_j\) with \(a_{ij}\ge 0\) and \(a_{ii}=0\). According to [18], a square matrix \(A=(a_{ij})\) of order \(\nu \) is said to be an RF-matrix (short for row-factorization matrix) for f if \(a_{ii}=-1\), \(a_{ij} \in {\mathbb {N}}\) when \(i \ne j\) and \(f=\sum _{j=1}^\nu a_{ij}n_j\) for all i. In this paper we refer to this notion as \({\text {RF}}^+\) matrix to avoid confusion with another matrix that we are going to introduce.

If S is nearly Gorenstein, for every i such that \(f \ne f_i\) we also have

$$\begin{aligned} n_i+f_i-f=\sum _{j=1}^{\nu }b_{ij}n_j \end{aligned}$$

with \(b_{ij} \ge 0\) and \(b_{ii}=0\); thus, we can define another matrix similarly to the previous case.

Definition 2.1

Let \((f_1, \dots , f_{\nu })\) be an NG-vector for S and let \(f \in {\text {PF}}(S)\). We say that a square matrix \(B=(b_{ij})\) of order \(\nu \) is an \({\text {RF}}^-\) matrix for f if B satisfies the following properties: if \(f=f_i\) in the ith row of B there are only zeroes, otherwise \(b_{ii}=-1\) and the entries \(b_{ij}\) are such that \(f_i-f=\sum _{j=1}^{\nu }b_{ij}n_j\).

Clearly this matrix depends on the NG-vector, but, even if we fix it, there could be more matrices associated with f.

Example 2.2

The semigroup \(S=\langle 10,12,37,75 \rangle \) is nearly Gorenstein, because (65, 63, 38, 63) is an NG-vector for it. There is a unique \({\text {RF}}^+\) matrix associated with \(38 \in {\text {PF}}(S)\), which is

$$\begin{aligned} \begin{pmatrix} -1&{}4&{}0&{}0 \\ 5&{}-1&{}0&{}0 \\ 0&{}0&{}-1&{}1 \\ 4&{}3&{}1&{}-1 \\ \end{pmatrix}, \end{aligned}$$

whereas there are two possible \({\text {RF}}^-\) matrices for 38:

$$\begin{aligned} \begin{pmatrix} -1&{}0&{}1&{}0 \\ 0&{}-1&{}1&{}0 \\ 0&{}0&{}0&{}0 \\ 10&{}0&{}0&{}-1 \\ \end{pmatrix}, \ \ \ \ \ \ \ \ \begin{pmatrix} -1&{}0&{}1&{}0 \\ 0&{}-1&{}1&{}0 \\ 0&{}0&{}0&{}0 \\ 4&{}5&{}0&{}-1 \\ \end{pmatrix}. \end{aligned}$$

We note that also (65, 63, 38, 38) is an NG-vectors for S and, if we choose it, there is only one \({\text {RF}}^{-}\) matrix for 38, because every entry in the last row has to be zero.

Lemma 2.3

Let S be nearly Gorenstein and let \(f\in {\text {PF}}(S)\). Also, let \(A=(a_{ij})\) and \(B=(b_{ij})\) be an \({\text {RF}}^+\) and an \({\text {RF}}^{-}\) matrix for f, respectively. Then, \(a_{jk}b_{kj}=0\) for every \(j\ne k\).

Proof

Assume \(f \ne f_k\), otherwise \(b_{kj}=0\). Then,

$$\begin{aligned} f_k=f+(f_k-f)=(a_{j1}+b_{k1}) n_1 + \dots +(a_{j\nu }+b_{k\nu }) n_\nu \notin S. \end{aligned}$$

Thus, at least one coefficient has to be negative, and since \(a_{jj}=b_{kk}=-1\), the only possibilities are \(a_{jk}-1=-1\) or \(b_{kj}-1=-1\), that is \(a_{jk}b_{kj}=0\). \(\square \)

In [18] it is proved that the type of an almost symmetric semigroup with four generators does not exceed three. In the following theorem, we prove that this bound holds also for nearly Gorenstein semigroups.

Theorem 2.4

If \(S=\langle n_1, n_2, n_3, n_4 \rangle \) is nearly Gorenstein, then \(t(S) \le 3\). Moreover, if S is not almost symmetric, \((f_1, \dots , f_{\nu })\) is an NG-vector for S, and i is the smallest index such that \(f_i \ne f_1\), then either

$$\begin{aligned} {\text {PF}}(S) = \{{\text {F}}(S), \, {\text {F}}(S)-n_i+n_l \} \text { \ or } \\ {\text {PF}}(S) = \{{\text {F}}(S), \, {\text {F}}(S)-n_i+n_l, \, \lambda n_k - n_j\}, \end{aligned}$$

where \(l < i\), \(\{i,j,k,l\}=\{1,2,3,4\}\) and \(\lambda \in {\mathbb {N}}\).

Proof

We can assume that S is not almost symmetric by [18, Theorem 1]. If i is the smallest index such that \(f_i \ne f_1\), then \(f_i=f_1-n_i+n_l\) for some \(l < i\) by Proposition  1.3. Assume by contradiction that there exist three different integers \(f,f',f'' \in {\text {PF}}(S) {\setminus } \{f_1,f_i\}\) and let

$$\begin{aligned} f_1-f&=-n_l+a_i n_i +a_j n_j + a_k n_k, \\ f_1-f'&=-n_l+b_i n_i +b_j n_j + b_k n_k, \\ f_1-f''&=-n_l+c_i n_i +c_j n_j + c_k n_k. \end{aligned}$$

Then, \(f_i-f=f_1-f-n_i+n_l=(a_i-1)n_i+a_jn_j+a_kn_k \notin S\) and, thus, \(a_i=0\); similarly \(b_i=c_i=0\). Therefore, \(f_1-f=-n_l+a_jn_j+a_kn_k\) and \(f_i-f=-n_i+a_jn_j+a_kn_k\) and it is not possible that both \(a_j\) and \(a_k\) are zero. Since the same holds for \(f'\) and \(f''\), we can assume without loss of generality that \(a_j \ne 0\) and \(c_j \ne 0\). Then, there is an \({\text {RF}}^-\) matrix for f and \(f''\) in which the (ij) and (lj) entries are positive and, in light of Lemma 2.3, this means that the (ji) and (jl) entries of every \({\text {RF}}^+\) matrix for f and \(f''\) are zero, i.e., \(f=-n_j+\lambda n_k\) and \(f''=-n_j+\gamma n_k\). Therefore, it follows that either \(f - f'' \in S\) or \(f''- f \in S\), which yields a contradiction.

Hence, there are at most two pseudo-Frobenius numbers f and \(f'\) different from \(f_1\) and \(f_i\). Moreover, if either \(a_j\ne 0 \ne b_j\) or \(a_k \ne 0 \ne b_k\) we get a contradiction as before. Therefore, we can assume that \(a_k=b_j=0\) and we get

$$\begin{aligned}&f=-n_j+\lambda n_k \quad f_1-f=-n_l + a_j n_j \quad f_i-f=-n_i + a_j n_j \end{aligned}$$
(1)
$$\begin{aligned}&f'=-n_k+\mu n_j \quad f_1-f'=-n_l + b_k n_k \quad f_i-f'=-n_i + b_k n_k. \end{aligned}$$
(2)

By adding the first two equalities of every line, we get \(f_1=-n_l+(a_j-1)n_j+\lambda n_k\) and \(f_1=-n_l + (b_k-1)n_k+\mu n_j\), thus \((\mu +1-a_j)n_j=(\lambda +1-b_k)n_k\). Since \(b_k\) is positive, \(\lambda +1-b_k\le \lambda \); moreover, if \(\lambda +1-b_k >0\), then also \(\mu +1-a_j >0\) and \(f=\lambda n_k-n_j \ge _S (\lambda +1-b_k)n_k-n_j=(\mu -a_j)n_j \in S\), which yields a contradiction. Therefore, \(\lambda +1-b_k\le 0\), i.e., \(b_k \ge \lambda +1\), and since \((\lambda +1)n_k-n_j=f+n_k \in S\), it follows that \(b_kn_k-n_j\in S\). This means that \(b_k n_k-n_j=\alpha _ln_l+\alpha _i n_i+\alpha _j n_j+\alpha _k n_k\) with \(\alpha _l,\alpha _i,\alpha _j,\alpha _k \ge 0\). If \(\alpha _l\) (resp. \(\alpha _i\)) is positive, then by replacing \(b_k\) in (2) we get \(f_1-f' \in S\) (resp. \(f_i-f' \in S\)), which is a contradiction. It follows that

$$\begin{aligned}&f_1-f'=-n_l + (\alpha _j+1)n_j+\alpha _k n_k \\&f_i-f'=-n_i + (\alpha _j+1)n_j+\alpha _k n_k. \end{aligned}$$

Hence, there is an \({\text {RF}}^-\) matrix for \(f'\) whose (lj) and (ij) entries are positive and, consequently, the (jl) and (ji) entries of every \({\text {RF}}^+\) for \(f'\) are zero, i.e., \(f'=-n_j + \gamma n_k\). This implies that \(f=f'\) and \(t(S) \le 3\). \(\square \)

Example 2.5

Consider the numerical semigroup \(S=\langle 15,17,28,41 \rangle \), which is nearly Gorenstein with a unique NG-vector (121, 121, 108, 95). According to Proposition 1.3 we have \({\text {F}}(S)=121\) and \(108={\text {F}}(S)-28+15\). Moreover, the type of S is three and the other pseudo-Frobenius number is \(95=8*17-41\).

Corollary 2.6

Let \(S=\langle n_1, n_2, n_3, n_4 \rangle \) be nearly Gorenstein.

  1. (1)

    If \({\text {F}}(S) \ne f_2=f_3=f_4\), then either \({\text {PF}}(S)=\{f_2,{\text {F}}(S)\}\) or \({\text {PF}}(S)=\{f_2/2, f_2,{\text {F}}(S)\}\).

  2. (2)

    Assume that \({\text {F}}(S)=f_i=f_j \ne f_k\) with \(\{i,j,k\}=\{2,3,4\}\). If there is \(f \in {\text {PF}}(S) {\setminus } \{f_k, {\text {F}}(S)\}\), then either \(f={\text {F}}(S)/2\) or S is almost symmetric.

Proof

  1. (1)

    Suppose that there exists \(f \in {\text {PF}}(S) {\setminus } \{f_2, {\text {F}}(S)\}\). Since \({\text {F}}(S)=f_1\), there is a factorization \({\text {F}}(S)-f =-n_1+a_2 n_2+a_3n_3 + a_{4}n_4\) with \(a_2, a_3, a_4 \ge 0\) and at least one of them positive; without loss of generality we may assume that \(a_2 > 0\). Moreover, there exists a factorization \(f_2 -{\text {F}}(S) = b_1 n_1 -n_2 + b_3 n_{3} + b_4 n_4\) with \(b_1, b_3, b_4 \ge 0\). Therefore

    $$\begin{aligned}&f_2-f = (f_2-{\text {F}}(S))+({\text {F}}(S)-f)=(b_1-1)n_1\\&\quad +(a_2-1)n_2+(a_3+b_3)n_3+(a_4+b_4)n_4 \end{aligned}$$

    and since \(f_2 - f \notin S\) and \(a_2 >0\), it follows that \(b_1=0\) and \(f_2-f+n_1 \in S\). Moreover, \(f_2-f+n_i \in S\) for \(i=2,3,4\) by hypothesis and, thus, \(f_2-f \in {\text {PF}}(S)\). Since \(f_2-f< f_2 < {\text {F}}(S)\), Theorem 2.4 implies that \(f_2-f=f\), i.e., \(f=f_2/2\).

  2. (2)

    Using the same argument of the previous case we can prove that \({\text {F}}(S)-f \in {\text {PF}}(S)\) and by Theorem 2.4 it follows that either \({\text {F}}(S)-f=f_k\) or \({\text {F}}(S)-f=f\). In the first case Nari’s Theorem [19, Theorem 2.4] implies that S is almost symmetric, whereas in the second one \(f={\text {F}}(S)/2\).

\(\square \)

All the possibilities of the previous corollary may occur as the following examples show.

Example 2.7

1. :

The semigroup \(\langle 11,12,37,50 \rangle \) is nearly Gorenstein with \(\mathbf{{f}}=(76,75,75,75)\) and it has type 2.

2. :

The semigroup \(S=\langle 10,11,45,79 \rangle \) has the NG-vector (69, 68, 68, 68) and \({\text {PF}}(S)=\{34,68,69\}\). We note that also (69, 68, 68, 34), (69, 68, 68, 69), (69, 68, 34, 68), (69, 68, 34, 34) and (69, 68, 34, 69) are NG-vectors for S.

3. :

The semigroup \(\langle 10,11,12,19 \rangle \) is nearly Gorenstein with \(\mathbf{{f}}{=}(37,37,37,28)\) and it has type 2.

4. :

The semigroup \(S=\langle 10,11,12,29 \rangle \) is nearly Gorenstein by choosing \(\mathbf{{f}}=(38,38,37,38)\) and \({\text {PF}}(S)=\{19,37,38\}\). Also in this case there are more NG-vectors: (38, 38, 37, 19), (38, 37, 37, 38) and (38, 37, 37, 19).

5. :

Let \(S=\langle 8,9,11,15 \rangle \). An NG-vector for S is (21, 21, 21, 14) and it is almost symmetric, because \({\text {PF}}(S)=\{7,14,21\}\). Indeed (21, 21, 21, 14) and (21, 21, 21, 21) are the only NG-vectors of S.

We conclude this section with some results in higher embedding dimension. We recall that \((f_1, \dots , f_\nu )\) denotes a fixed NG-vector for S.

Proposition 2.8

Let S be a nearly Gorenstein semigroup and suppose that \(f_1, f_2, \dots , f_i\) are pairwise distinct for some \(i \le \nu \). The following statements hold:

  1. (1)

    If \(f \in {\text {PF}}(S) {\setminus } \{f_1, \dots , f_i\}\), then \(f_1-f=-n_1+a_{i+1}n_{i+1}+ \dots + a_{\nu }n_{\nu }\), with \(a_j \ge 0\) for every \(j=i+1, \dots , \nu \);

  2. (2)

    \(f_1-f_{j} =n_{j}-n_1\) for every \(j=1, \dots i\).

Proof

We proceed by induction on i. If \(i=1\), (2) is trivial; moreover, if \(f \ne f_1\), then \(f_1-f \notin S\) and \(f_1-f+n_1 \in S\), thus (1) follows.

We assume that both statements hold for i and we will prove them for \(i+1\). We start proving (2). Since \(f_{i+1} \notin \{f_1, \dots , f_i\}\), by induction we have \(f_1 - f_{i+1}=-n_1 + a_{i+1}n_{i+1} + \dots + a_{\nu }n_\nu \). Moreover, \(f_{i+1}-f_1 \notin S\) and \(f_{i+1}-f_1+n_{i+1} \in S\), then \(f_{i+1}-f_1 =c_1 n_1 + \dots + c_{i}n_i - n_{i+1} + \dots + c_\nu n_\nu \), with \(c_j\) non-negative integer for every j. It follows that \(n_1+n_{i+1}=c_1 n_1 + \dots + c_{i}n_i + a_{i+1}n_{i+1}+(a_{i+2} + c_{i+2})n_{i+2} + \dots +(a_\nu + c_\nu )n_\nu \); clearly at least one \(a_j\) and one \(c_k\) are non-zero, and since \(n_1< \dots < n_\nu \), it follows that \(c_1=a_{i+1}=1\) and the other coefficients are zero. Hence, \(f_1-f_{i+1}=n_{i+1}-n_1\), which is (2).

Let now \(f \in {\text {PF}}(S) {\setminus } \{f_1, \dots , f_{i+1}\}\). By induction \(f_1-f=-n_1+a_{i+1}n_{i+1}+ \dots + a_\nu n_\nu \), and since \(f_{i+1} - f = (f_1-f)+(f_{i+1}-f_1)\), using (2) it follows that \(f_{i+1}-f=(a_{i+1}-1)n_{i+1}+ \dots + a_\nu n_\nu \). Therefore, \(a_{i+1}=0\), because \(f_{i+1}-f \notin S\) and (1) follows. \(\square \)

Corollary 2.9

If S is nearly Gorenstein, there exist at least two different indices i and j such that \(f_i=f_j\). Moreover, if \(f_1, \dots , f_{\nu -1}\) are pairwise distinct, then \({\text {PF}}(S)=\{f_1, \dots , f_{\nu -1}\}\) and \(t(S)=\nu -1\).

Proof

Suppose by contradiction that there exists \(f \in {\text {PF}}(S) {\setminus } \{f_1, \dots , f_{\nu -1}\}\) and \(f_1, \dots , f_{\nu -1}\) are pairwise distinct. The two statements of the previous proposition imply that \(f_1-f=-n_1+a_{\nu }n_{\nu }\) with \(a_{\nu } >0\) and \(f_1-f_i=n_i-n_1\) for every \(i< \nu \). Therefore, \(f_i-f=(f_1-f)-(f_1-f_i)=a_\nu n_\nu - n_i\) for every \(i < \nu \). Consider a factorization \(f+n_\nu = b_1 n_1 + \dots + b_{\nu -1}n_{\nu -1}\), where \(b_i \ge 0\) and assume \(b_k >0\) for a fixed k. Then \(f_k=(f_k-f)+f= (a_\nu -1) n_\nu + b_1 n_1 + \dots + (b_{k}-1) n_k + \dots + b_{\nu -1} n_{\nu -1} \in S\), which is a contradiction. Hence, \({\text {PF}}(S)=\{f_1, \dots , f_{\nu -1}\}\) and, in particular, it is not possible that \(f_1, \dots , f_\nu \) are pairwise distinct. \(\square \)

Example 2.10

Consider \(S=\langle 10, 11, 12, 14, 16, 29 \rangle \) that is nearly Gorenstein with \(f_1=19\), \(f_2=18\), \(f_3=17\), \(f_4=15\), \(f_5=13\) and \(f_6 \in \{f_1,f_2,f_3,f_4,f_5\}\). According to the previous corollary \({\text {PF}}(S)=\{f_1, f_2, f_3, f_4, f_5\}\) and \(t(S)=5\).

Remark 2.11

1. :

Despite Theorem 2.4 and Corollary 2.9, the type of a nearly Gorenstein semigroup can be greater than its embedding dimension. For instance the nearly Gorenstein numerical semigroup \(S=\langle 64, 68, 73, 77, 84, 93 \rangle \) has embedding dimension 6 and type 9, since the set of the pseudo-Frobenius numbers of S is \({\text {PF}}(S)=\{159, 179, 188, 195, 197, 206, 215, 394, 403 \}\).

2. :

Let S be nearly Gorenstein. If either S has embedding dimension four or \(f_1, \dots , f_{\nu -1}\) are pairwise distinct, then S satisfies Wilf’s conjecture [4]. Indeed \({\text {F}}(S)+1 \le n(S)(t(S)+1) \le n(S)\nu (S)\), where the first inequality follows by [8, Theorem 20].

4 Gluing and Generalized Arithmetic Sequences

Let \(S_1=\langle n_1, \dots , n_{\nu } \rangle \) and \(S_2=\langle m_1, \dots , m_{\mu } \rangle \) be two numerical semigroups and let \(x \in S_2 {\setminus } {\text {G}}(S_2)\), \(y \in S_1 {\setminus } {\text {G}}(S_1)\) be two coprime integers. The gluing of \(S_1\) and \(S_2\) with respect to x and y is the numerical semigroup \(\langle xS_1, yS_2 \rangle =\langle xn_1, \dots , xn_{\nu },ym_1, \dots , ym_{\mu } \rangle \). It is well known that \(\langle xS_1, yS_2 \rangle \) is symmetric if and only if both \(S_1\) and \(S_2\) are symmetric and Nari [19, Theorem 6.7] proved that \(\langle xS_1, yS_2 \rangle \) is never almost symmetric if it is not symmetric. In the next proposition we extend this result to the nearly Gorenstein case.

Proposition 3.1

Let \(S_1\) and \(S_2\) be two numerical semigroups and assume that at least one of them is not symmetric. Then, every gluing of \(S_1\) and \(S_2\) is not nearly Gorenstein.

Proof

Assume that \(S_2\) is not symmetric and let m be the multiplicity of \(S_1\), i.e., its smallest minimal generator. Suppose that \(S=\langle xS_1, yS_2 \rangle \) is nearly Gorenstein with \(x \in S_2 {\setminus } {\text {G}}(S_2)\), \(y \in S_1 {\setminus } {\text {G}}(S_1)\) and \(\gcd (x,y)=1\). It is well known that \({\text {PF}}(S)= \{xf +yf'+xy \mid f \in {\text {PF}}(S_1), f' \in {\text {PF}}(S_2)\}\), see [19, Proposition 6.6]. Then, by Proposition 1.1 there exists \(xf +yf'+xy \in {\text {PF}}(S)\) such that for every \(g \in {\text {PF}}(S_2)\) we have \(xm + xf+yf'+xy -(xf+yg+xy)=xm+yf'-yg \in S\). Since \(S_2\) is not symmetric we can fix \(g \in {\text {PF}}(S_2) {\setminus } \{f'\}\). Let \(xm+ yf'-yg=xs_1+ys_2\) with \(s_1 \in S_1\) and \(s_2 \in S_2\). If \(s_1=0\), then from \(\gcd (x,y)=1\) it follows that y divides m, but this impossible, because \(m < y\). Therefore, \(y(f'-g-s_2)=x(s_1-m)\ge 0\) and, thus, \(f'-g-s_2= \lambda x\) with \(\lambda \in {\mathbb {N}}\). Since \(x \in S_2\) and \(g \in {\text {PF}}(S_2)\), this implies that \(f'=s_2+\lambda x +g \in S_2\), which is a contradiction. \(\square \)

In literature, there exists a construction that is a variation of the gluing when one semigroup is \({\mathbb {N}}\). More precisely, if \(S=\langle n_1, \dots , n_\nu \rangle \) and \(d \in \mathbb N\) such that \(\gcd (d, n_\nu )=1\), we are interested in the semigroup \(T=\langle dn_1, \dots , dn_{\nu -1}, n_\nu \rangle \). If \(n_{\nu } \in \langle n_1, \dots , n_{\nu -1} \rangle \), we have \(T=\langle dS, n_{\nu }{\mathbb {N}}\rangle \) and, then, in the next proposition we will consider the case \(n_{\nu } \notin \langle n_1, \dots , n_{\nu -1} \rangle \), i.e., when \(n_\nu \) is a minimal generator of S. The numerical semigroup T is symmetric if and only if S is symmetric, see [8, Proposition 8], whereas Numata [20] proved that T is never almost symmetric when S is not symmetric. In the next proposition we show that this result holds also for the nearly Gorenstein property. We first recall that the pseudo-Frobenius numbers of T are

$$\begin{aligned} {\text {PF}}(T)=\{df+(d-1)n_{\nu } \mid f \in {\text {PF}}(S)\}, \end{aligned}$$

in particular \({\text {F}}(T)=d{\text {F}}(S)+(d-1)n_{\nu }\), see [20, Proposition 3.2].

Proposition 3.2

Let \(S=\langle n_1, \dots , n_\nu \rangle \) be a numerical semigroup that is not symmetric and assume \(n_{\nu } \notin \langle n_1, \dots , n_{\nu -1} \rangle \). If d is a positive integer coprime to \(n_\nu \), then \(T=\langle dn_1, \dots , dn_{\nu -1},n_\nu \rangle \) is not nearly Gorenstein.

Proof

Suppose by contradiction that T is nearly Gorenstein. Since \(n_{\nu }\) is a minimal generator of S, Proposition 1.1 implies that there exists \(f \in {\text {PF}}(S)\) such that \(n_\nu +df-dg \in T\) for all \(g \in {\text {PF}}(S)\). Moreover, we can fix \(g \ne f\), because S is not symmetric. Therefore, \(n_\nu + df -dg = ds + \lambda n_\nu \) with \(s \in S\) and \(\lambda >0\), since d does not divide \(n_\nu \). Then, \(d(f-g-s)=(\lambda - 1) n_{\nu }\), and since \(\gcd (d, n_\nu )=1\), this implies that \(f-g-s=\gamma n_\nu \) with \(\gamma \in {\mathbb {N}}\). Hence, \(f=g+s+\gamma n_{\nu } \in S\), because \(f \ne g\) and this yields a contradiction. \(\square \)

The next result is a nice consequence of Propositions 3.1 and 3.2 and it was proved by Numata [20] in the almost symmetric case.

Corollary 3.3

Let T be a nearly Gorenstein numerical semigroup that is not symmetric and assume that it is minimally generated by \(n_1, \dots , n_\nu \). Then, the elements of \(\{n_1, \dots , \widehat{n_i}, \dots n_\nu \}\) are relatively coprime for every i.

Proof

It is enough to assume \(i{=}\nu \). Suppose by contradiction that \(\gcd (n_1, \dots , n_{\nu -1})=d >1\) and let \(S=\langle n_1/d, \dots , n_{\nu -1}/d \rangle \). If \(n_{\nu } \notin S\) we get a contradiction by Proposition 3.2. Hence, S is the gluing \(\langle dS, n_\nu \mathbb N \rangle \) and Proposition 3.1 yields a contradiction. \(\square \)

A numerical semigroup generated by a generalized arithmetic sequence has the form \(S=\langle a,sa+d, sa+2d, \dots , sa+nd \rangle \) for some positive integers asdn such that \(\gcd (a,d)=1\). It is known that in this case S is symmetric if and only if \(a \equiv 2 \mod n\), see [6, 17], while in [22, Corollary 3.3] Numata proved that it is almost symmetric if and only if either \(s=1\) and S has maximal embedding dimension or it is symmetric. Moreover, in [14] it is proved that S is always nearly Gorenstein provided that \(s=1\).

Proposition 3.4

Let \(S=\langle a,sa+d,\dots , sa+nd \rangle \) be a numerical semigroup generated by a generalized arithmetic sequence. It is nearly Gorenstein if and only if \(s=1\) or \(a \equiv 2 \mod n\).

Proof

We can exclude the symmetric case. By the proof of [17, Lemma 2.7] (see also [22, Theorem 3.1]), \({\text {F}}(S)-d\) is a pseudo-Frobenius number of S. If S is nearly Gorenstein, then \(f_1={\text {F}}(S)\) by Proposition 1.3 and, so, \(a+{\text {F}}(S)-({\text {F}}(S)-d)=a+d \in S\), that is possible only if \(s=1\). Hence, the statement follows from [14, Proposition 1.4]. \(\square \)

5 Further questions and open problems

In this section we collect some open problems. We start recalling the question raised by the first author in [18] for the almost symmetric case and by Stamate [26] in general.

Question 4.1

Is there an upper bound for the type of S in terms of the embedding dimension of S when S is almost symmetric or nearly Gorenstein?

To the best of our knowledge no almost symmetric semigroups S for which \(t(S)\ge 2\nu (S)\) are known, even though there are almost symmetric semigroups S with embedding dimension 6 satisfying \(t(S)=2 \nu (S)-1\), for instance \(S=\langle 111,115,122,126,135,146 \rangle \). Also, there exist nearly Gorenstein numerical semigroups that are not almost symmetric having embedding dimension 6 and type 9, cf. Remark 2.11. On the other hand some computations suggest that the inequality \(t(S) \le \nu (S)\) could hold if \(\nu (S) < 6\). More precisely we pose the following question:

Question 4.2

Let S be a nearly Gorenstein numerical semigroup with embedding dimension five. Is it true that \(t(S)\le 5\) and that the equality is attained only if S is almost symmetric?

Let \(S=\langle n_1, \dots , n_{\nu }\rangle \) and let k be a field. The map \(\varphi : k[x_1,\dots , x_\nu ] \rightarrow k[S]\) defined as \(\varphi (x_i)=t^{n_i}\) is surjective and its kernel \(I_S\) is said to be the defining ideal of S. Clearly \(k[S] \cong k[x_1,\dots , x_\nu ]/I_S\). The defining ideals of almost symmetric semigroups with embedding dimension 3 or 4 and type 1 and 2 are well known, see [3, 12, 16, 25] or the survey [26]. Also in the case with embedding 4 and type 3 the defining ideal has been recently found in [7, 15]. As for the nearly Gorenstein case, the defining ideal of S is essentially described in [14] when \(\nu (S)=3\). In [26, Question 9.8] Stamate asks for the generators and the resolution of the defining ideal \(I_S\) when \(\nu (S)=4\) and S is nearly Gorenstein. We raise a more precise question on the number of its minimal generators. This is equivalent to ask for all the Betti numbers of \(k[x_1,\dots ,x_4]/I_S\), because its projective dimension is 3.

Question 4.3

Let S be a nearly Gorenstein numerical semigroup that is not almost symmetric and let \(\nu (S)=4\). Are the following statements true?

  1. (1)

    If \(t(S)=2\), then the defining ideal of S has either 4 or 5 generators.

  2. (2)

    If \(t(S)=3\), then the defining ideal of S has 6 generators.

Equivalently, the possible Betti sequences of \(k[x_1,\dots ,x_4]/I_S\) are (1, 4, 5, 2), (1, 5, 6, 2) and (1, 6, 8, 3).

In [23] the notion of ring with canonical reduction is introduced. More precisely, we say that a one-dimensional Cohen–Macaulay ring \((R,{\mathfrak {m}})\) has a canonical reduction if there exists a canonical ideal I of R that is a reduction of \({\mathfrak {m}}\). In [23, Theorem 3.13] it is proved that a numerical semigroup ring k[[S]] has a canonical reduction if and only if \(n_1+{\text {F}}(S)-g \in S\) for every \(g \in {\mathbb N} {\setminus } S\). It is easy to see that this is equivalent to require that \(n_1+{\text {F}}(S)-f \in S\) for every \(f \in {\text {PF}}(S)\) and we say that S has a canonical reduction if it satisfies this property. Therefore, Proposition 1.3 implies that a nearly Gorenstein semigroup has a canonical reduction and, thus, we have the following implications:

$$\begin{aligned} \text { Almost symmetric} \Rightarrow \text { Nearly Gorenstein}\\ \Rightarrow \text { Semigroup with canonical reduction.} \end{aligned}$$

It is natural to ask if Theorem 2.4 is still true for numerical semigroups with four generators that have a canonical reduction. However, the semigroup \(S=\langle 16,17,19,39 \rangle \) has type four and it is easy to see that it has a canonical reduction using the criterion above. On the other hand, several computations suggest the following question:

Question 4.4

Let k[[S]] be a numerical semigroup ring with canonical reduction and assume that S has embedding dimension four. Is \(t(S) \le 4\)?