1 Introduction

An affine semigroup \(S\subset \mathbb {N}^q\) is a set containing 0 and closed under addition. A finite set \(A=\{a_1,\ldots ,a_h\}\subset \mathbb {N}^q\) is a generating set of S if \(S=\big \{\sum _{i=1}^h \lambda _i a_i\mid \lambda _1,\ldots ,\lambda _h\in \mathbb {N}\big \}\). It is called a minimal generating set if it is the minimal set, according to inclusion, generating S. In this work, \(S=\langle A\rangle \) means that A is the minimal set of generators of S. In what follows, when we talk about an affine semigroup, we must understand a finitely generated affine semigroup.

Let \(S=\langle A\rangle \) and \(n\in \mathbb {N}^q\), the set \(\textrm{Z}_n(S)\) denotes \(\{\lambda =(\lambda _1,\ldots ,\lambda _h)\in \mathbb {N}^h\mid n=\sum _{i=1}^h \lambda _i a_i\}\). The minimum integer cone containing S is \(\mathcal {C}(S)=\big \{\sum _{i=1}^h \lambda _i a_i\mid \lambda _1,\ldots ,\lambda _h\in \mathbb {Q}_{\ge 0}\big \}\cap \mathbb {N}^q\). We say that S is a \(\mathcal {C}\)-semigroup if \(\mathcal {C}(S)\backslash S\) is a finite set. For \(q=1\), S is called a numerical semigroup when \(\mathbb {N}\setminus S\) is finite (equivalently, \(\gcd (a_1,\ldots ,a_h)=1\)).

An important invariant related to numerical semigroups is the Frobenius number, defined as the maximum element f in \(\mathbb {Z}\setminus S\), that is, the largest integer that cannot be written as a positive linear combination of the minimal generators of S. Observe that f is the Frobenius number of S if and only if f is the maximum integer satisfying \(\textrm{Z}_f(S)=\emptyset \). Thus, one may naturally extend this definition to affine semigroups and call the Frobenius vector, the maximum (for a fixed monomial order \(\preceq \)) integer vector satisfying \(\textrm{Z}_f(S)=\emptyset \). However, this maximum element might not exist for several reasons. The worst case arises when \(\{f\in \mathcal {C}(S)\mid \textrm{Z}_f(S)=\emptyset \}\) is not finite. Nevertheless, when \(\mathcal {C}(S)\setminus S\) is finite, this maximum integer vector can be set by \(\max _{\preceq } (\mathcal {C}(S)\setminus S)\) for the fixed monomial order \(\preceq \) ([11]). In [22], the possible Frobenius vectors for an affine semigroup S such that \(\mathcal {C}(S)=\mathbb {N}^q\) and \(\mathcal {C}(S)\setminus S\) finite are studied.

The first generalization of the Frobenius number appeared in Ref. [3], but later many other generalizations of the Frobenius number/vector have been introduced. For a numerical semigroup S, the most usual definitions of generalized Frobenius number (called p-Frobenius number) are: the largest integer \(n\in \mathbb {N}\) such that \(\# \textrm{Z}_n(S)=p\) (see Ref. [4]), or the largest integer \(n\in \mathbb {N}\) such that \(\# \textrm{Z}_n(S)\le p\) (see Ref. [15] and references therein). These definitions are also used for affine semigroups. In particular, a p-Frobenius integer number associated with an affine semigroup was introduced in Ref. [1].

In this work, for an affine semigroup S, we introduce the concept of p-Frobenius vector of S (with respect to a graded monomial order \(\preceq \)), which is defined as \(F_0(S)=\max _\preceq \{\mathcal {C}(S)\setminus S\}\), and \(F_p(S)=\max _\preceq \{n\in \mathcal {C}(S)\mid 0< \sharp \textrm{Z}_n(S)\le p\}\), for \(p>0\). When the set defining \(F_0(S)\) is not finite, we set \(F_0(S)=(\infty ,\ldots , \infty )\). Similarly, for \(p>0\), \(F_p(S)=(\infty ,\ldots , \infty )\) when its defining set is not finite. One of the goals of our work is to characterize when \(F_p(S)\) is finite (Theorem 2.1), and, as a consequence, to provide an algorithm to compute the p-Frobenius vector from the minimal generating set of any affine semigroup (Algorithm 1). Moreover, we give two improved algorithms for the cases \(p=1\) and \(p=2\). The case \(p=0\) was solved in Ref. [7]. In that paper, the authors characterize the affine semigroups S such that \(\mathcal {C}(S)\setminus S\) is finite, and an algorithm to compute its gap sets is introduced. For both results, only a generating set of S is required.

The other target of this paper is related to the gluing of semigroups. The concept of gluing for numerical semigroups was introduced in Ref. [19]. With this nomenclature, the main result of Ref. [6] tells us that a numerical semigroup is complete intersection if and only if it is gluing of two complete intersection numerical semigroups (see Ref. [21, Chapter 8] and references therein). The concept of gluing is generalized to affine semigroups in Ref. [20], and in Ref. [9], it is proved that an affine semigroup is complete intersection if and only if it is gluing of two complete intersection affine semigroups (see also Ref. [2] and Ref. [12]). We consider the gluing of an affine semigroup with \(\mathbb {N}^q\): given the affine semigroup \(S =\langle a_1,\ldots ,a_{h}\rangle \subset \mathbb {N}^q\), \(d\in \mathbb {N}\) and \(\gamma \in S\setminus \{a_1,\ldots ,a_{h}\}\) with d and \(\gcd (\gamma _1,\ldots ,\gamma _q)\) coprime, \(S\oplus _{d,\gamma } \mathbb {N}^q\) is the affine semigroup minimally generated by \(\{ da_1,\ldots , da_{h},\gamma \}\). We say that the semigroup \(S\oplus _{d,\gamma } \mathbb {N}^q\) is an \(\mathbb {N}^q\)-gluing (affine) semigroup. An interesting paper on when two affine semigroups can be glued is Ref. [13]. In this context, it is well known that the Frobenius number of a numerical semigroup generated by two coprime elements \(\{a,b\}\) is \((a-1)(b-1)\) ([23]), and it also exists an exact formula for the Frobenius number when the semigroup is generated by three elements ([24]). Moreover, for numerical semigroups, the Frobenius number of \(S\oplus _{d,\gamma } \mathbb {N}\) is determined by \(dF_0(S)+(d-1)\gamma \) ([6, Proposition 10]). In this work, we study some properties of p-Frobenius vector of \(S'=S\oplus _{d,\gamma } \mathbb {N}^q\), and determine an explicit way to obtain it from the p-Frobenius vector of S under certain conditions. If such conditions do not hold, an upper bound of \(F_p(S')\) is provided.

This work is structured as follows. Section 1 lays the necessary foundation for understanding subsequent sections. In Sect. 2, we characterize when the p-Frobenius vector is finite for any affine semigroup S, and we establish an algorithm to compute it. Sections 3 and 4 are devoted to improve the previous algorithm for \(p=1,2\), respectively. In the last section (Sect. 5), we study the p-Frobenius vector of the semigroup obtained from the gluing of an affine semigroup with \(\mathbb {N}^q\). Throughout the paper, we use clear examples to help understanding.

2 Preliminaries

For any \(n\in \mathbb {N}\backslash \{0\}\), [1, n] denotes the set \(\{1,\ldots n\}\).

Given the minimal generating set \(\{ a_1,\ldots ,a_{h}\}\) of an affine semigroup S, and a field \(\mathbb {K}\), we can consider the S-graded polynomial ring \(\mathbb {K}[x_1,\ldots ,x_h]\) where the S-degree of a monomial \(X^\alpha = x_1^{\alpha _1}\cdots x_h^{\alpha _h}\) is \(\sum _{i=1}^h\alpha _i a_i\). In this polynomial ring, we define the S-homogeneous polynomial ideal \(I_S \subset \)\(\mathbb {K}[x_1,\ldots ,x_h] \) as

$$\begin{aligned} I_S=\left\langle x_1^{\alpha _1}\cdots x_h^{\alpha _h}- x_1^{\beta _1}\cdots x_h^{\beta _h} \mid \sum _{i=1}^h\alpha _i a_i = \sum _{i=1}^h\beta _i a_i\right\rangle . \end{aligned}$$
(1)

This ideal is usually called the semigroup ideal of S. It is well known (see [14]) that (pure) binomials finitely generate this ideal, and there exist some minimal generating sets with respect to inclusion.

In this work, we use several concepts and tools related to computational algebra. The reader can find the necessary background in Ref. [5]; here, we collect the essential definitions and properties to improve his reading.

Let \(\preceq \) be a monomial order on \(\mathbb {K}[x_1,\ldots , x_h]\), that is, a multiplicative total order on the set of monomials satisfying that for any two monomials \(X^\alpha , X^\beta \) with \(X^\alpha \prec X^\beta \), then \(X^\alpha X^\gamma \prec X^\beta X^\gamma \) for every monomial \(X^\gamma \). Given an ideal \(I\subseteq \mathbb {K}[x_1,\ldots , x_h]\), we denote by \(\textrm{In}_\prec (I)\), the set of leading terms of non-zero elements of I, and \(\langle \textrm{In}_\prec (I)\rangle \) the monomial ideal generated by \(\textrm{In}_\prec (I)\). A finite subset G of I is a Gröbner basis of I if \(\langle \textrm{In}_\prec (I)\rangle = \langle \{ \textrm{In}_\prec (g) \mid g\in G\}\rangle \), where \(\textrm{In}_\prec (g)\) is the leading term of g. A Gröbner basis is reduced if all its polynomials are monic and irreducible by its other polynomials. This reduced basis is unique for each order. An algorithm for computing the (reduced) Gröbner bases for I is given in Ref. [5, Chapter 2, \(\S \)7]. It is also well known that Gröbner bases of monomial (resp. binomial) ideals are sets of monomials (resp. binomials).

Given a monomial order \(\preceq \) and a Gröbner basis G, we denote by \(\texttt {NormalForm}_{\preceq }(f,G)\), the remainder of the division of \(f\in \mathbb {K}[x_1,\ldots ,x_h]\) by G with respect to \(\preceq \). Since G is a Gröbner basis, \(\texttt {NormalForm}_{\preceq }(f,G)\) is unique (see [5, Chapter 2, \(\S \)6, Proposition 1]). Taking into account the definition of \(F_p(S)\) given in the introduction, we not only assume that the order is a monomial order but a graded one as well. That is, the monomials are first compared by total degree, with ties broken by one other order (see [5, Chapter 8, \(\S \)4, Proposition 1]). This is to avoid the following contradictory cases: for instance, consider the affine semigroup S generated by \(\{(0,1),(1,1),(2,0),(3,0)\}\) and the lexicographical order \(\preceq _{lex}\); we have that \(\alpha (0,1)\) has a unique writing for any \(\alpha \in \mathbb {N}\), meaning that \(\{n\in \mathcal {C}(S)\mid \sharp \textrm{Z}_n(S) =1\}\) is an infinite set so \(F_1(S)=(\infty , \infty )\) according to definition; nevertheless, it has a maximum with respect to \(\preceq _{lex}\), which is (7, 0). Indeed, graded monomial orders satisfy that \(\sharp \{s\in S\mid s\preceq a\}<\infty \) for every \(a\in S\).

3 Computing \(F_p(S)\)

Consider \(S\subset \mathbb {N}^q\) an affine semigroup and \(\preceq \) a graded monomial ordering on \(\mathbb {N}^q\).

In this section, we provide an algorithm to compute \(F_p(S)\) for any \(p\in \mathbb {N}\). Recall that to solve the problem for \(p=0\), you can use the results appearing in Ref. [7]. The following result is the key to obtain such an algorithm for \(p\ge 1\). Furthermore, it characterizes when \(F_p(S)\in \mathbb {N}^q\).

Theorem 2.1

Let \(S=\langle a_1,\dots ,a_h\rangle \subset \mathbb {N}^q \) be an affine semigroup, \(p\in \mathbb {N}\setminus \{0\}\), and let \(\preceq \) be a graded monomial ordering on \(\mathbb {N}^q\). Then, \(F_p(S)\ne (\infty ,\ldots ,\infty )\) if and only if, for every \(k\in [1,h]\), there exist \(\lambda _k, \alpha _{k,i} \in \mathbb {N}\), such that \(\lambda _k a_k=\sum _{i=1,i\ne k}^{h}\alpha _{k,i}a_i\).

Proof

Without loss of generalization, assume that for \(k=1\), for every \(\lambda \in \mathbb {N}\), the element \(\lambda a_1\) cannot be expressed using only the generators \(\{a_2,\dots ,a_h\}\). This implies that \(Z_{\lambda a_1}(S)=\{(\lambda ,0,\dots ,0)\}\) (the only expression of \(\lambda a_1\) is itself). Therefore, \(\# Z_{\lambda a_1}(S)=1\) for every \(\lambda \in \mathbb {N}\), and thus, \(F_p(S)=(\infty ,\ldots ,\infty )\).

Conversely, let \(b=\sum _{i=1}^{h}\mu _i a_i\in S\) such that there exists \(k\in [1,h]\) with \(\mu _k\ge p \lambda _k\), assume \(k=1\). We have that \(\mu _1=p\lambda _1+d\) with \(d\in \mathbb {N}\), and

$$\begin{aligned} \begin{aligned} b=(p\lambda _1+d)a_1+\sum _{i=2}^{h}\mu _i a_i=((p-1)\lambda _1+d)a_1+\sum _{i=2}^{h}\mu _i a_i+\sum _{i=2}^{h}\alpha _{1,i}a_i=\\ ((p-2)\lambda _1+d)a_1+\sum _{i=2}^{h}\mu _ia_i+\sum _{i=2}^{h}2\alpha _{1,i}a_i= \cdots =da_1+\sum _{i=2}^{h}\mu _ia_i+\sum _{i=2}^{h}p\alpha _{1,i}a_i. \end{aligned} \end{aligned}$$

Obtaining in this way, \(p+1\) different factorizations of b. Thus, all the elements with at most p factorizations are in the bounded set \(\{\sum _{i=1}^h \gamma _i a_i \mid \gamma _i\in \mathbb {N},~\gamma _i\le p\lambda _i \}\), and therefore, \(F_p(S)\in \mathbb {N}^q\).\(\square \)

Remark 2.2

Theorem 2.1 implies that the finiteness of the p-Frobenius vector, \(F_p(S)\), is independent of both the value p and the chosen graded monomial order. In simpler terms, if \(F_1(S)\) exists, then all \(F_p(S)\) for \(p\ge 1\) also exist.

Corollary 2.3

Let \(S=\langle a_1,\dots ,a_h\rangle \subset \mathbb {N}^q \) be an affine semigroup, \(p\in \mathbb {N}\setminus \{0\}\), and \(\preceq \) a graded monomial ordering on \(\mathbb {N}^q\). Then, \(F_p(S)\ne (\infty ,\ldots ,\infty )\) if and only if every extremal ray \(\tau \) of \(\mathcal {C}(S)\) contains at least two minimal generators of S.

Proof

If there is an extremal ray that contains only one minimal generator, then that generator cannot be written as a combination of the other minimal generators. Thus, by Theorem 2.1, \(F_p(S)\) is not finite.

Assume now that, every extremal ray \(\tau \) of \(\mathcal {C}(S)\) contains at least two minimal generators of S. Let \(k \in [1,h]\), by Theorem 2.1, it is enough to prove that a multiple of \(a_k\) is a combination of the other minimal generators to conclude. If \(a_k\) is not in any extremal ray of \(\mathcal {C}(S)\), then there exists \(\lambda _k\in \mathbb {N}\) such that \(\lambda _k a_k\) can be expressed using only the generators of S belonging to the extremal rays of \(\mathcal {C}(S)\). Otherwise, if \(a_k\) is in an extremal ray \(\tau \) of \(\mathcal {C}(S)\), by hypothesis, there exists another minimal generator \(a_j \in \tau \), thus \(a_k = \alpha a_j\) for some \(\alpha \in \mathbb {Q}\). Hence, there exist \(\beta , \gamma \in \mathbb {N}\), such that \(\beta a_k = \gamma a_j\). \(\square \)

Given a h-tuple \(\Lambda =(\lambda _1,\ldots ,\lambda _h) \in \mathbb {N}^h\), once obtained the set

$$\begin{aligned} \mathcal {D}(\Lambda ,p):=\left\{ \sum _{i=1}^h \gamma _i a_i \mid \gamma _i\in \mathbb {N},~\gamma _i\le p\lambda _i \right\} , \end{aligned}$$
(2)

the algorithm to compute \(F_p(S)\) is straightforward from the proof of Theorem 2.1.

Algorithm 1 computes \(F_p(S)\). Note that, if Theorem 2.1 holds, then any Gröbner basis of the ideal \(I_S\subset \mathbb {K}[x_1,\ldots ,x_h]\) associated with S contains a binomial with a monomial like \(x_k^{\alpha _k}\), for all \(k\in [1,h]\). Moreover, in this procedure, the elements \(\lambda _k\) obtained are the smallest elements satisfying \(\lambda _k a_k=\sum _{i=1,i\ne k}^{h}\alpha _ia_i\).

Algorithm 1
figure a

Computation of \(F_p(S)\).

Example 2.4

Let S be the affine semigroup generated by the elements of the set \(A=\{(3, 0), (4, 0), (0, 5), (0, 6), (1, 1)\}\) and consider the graded lexicographic order the monomial ordering used in this example. The set A is a minimal generating set of S and the ideal of the semigroup is generated by

$$\begin{aligned}{} & {} \Big \{x_3^6-x_4^5,x_2 x_4^4-x_3^4 x_5^4,x_2 x_3^2-x_4 x_5^4, x_2^2 x_4^3-x_3^2 x_5^8,\\{} & {} \quad x_2^3 x_4^2-x_5^{12},x_1 x_5^5-x_2^2 x_3,x_1 x_4^3-x_3^3 x_5^3,x_1 x_3 x_5-x_2 x_4,x_1 x_3^3-x_4^2 x_5^3,\\{} & {} \quad x_1 x_2 x_4^2-x_3 x_5^7,x_1 x_2^2 x_3 x_4-x_5^{11},x_1^2 x_4-x_5^6,x_1^3 x_3-x_2 x_5^5,x_1^4-x_2^3\Big \}. \end{aligned}$$

Note that the monomials \(x_1^4\), \(x_2^3\), \(x_3^6\), \(x_4^5\), and \(x_5^{11}\) appear in the above set. Thus, \(\Lambda =(4,3,6,5,11)\). The set \(\mathcal {D}(\Lambda ,1)\) is equal to

$$\begin{aligned} \{ (3\gamma _1 +4\gamma _2+\gamma _5,5\gamma _3+6\gamma _4+\gamma _5)\mid (0,0,0,0,0)\le \gamma \le (4,3,6,5,11)\}, \end{aligned}$$

containing 1835 elements. Ordering this set with respect to the fixed monomial order, the greatest element n having \(\#Z_n(S)\) equal to 1 is (21, 4), and therefore, \(F_1(S)=(21,4)\).

4 Computing the 1-Frobenius Vector from Gröbner Basis of \(I_S\)

While Algorithm 1 efficiently calculates the p-Frobenius vector \(F_p(S)\) for any p and monomial order \(\preceq \), its dependence on large sets like \(\mathcal {D}(\Lambda ,p)\) can limit its efficiency. This section presents an improved algorithm specifically for \(F_1(S)\) by leveraging computational algebra tools, offering greater efficiency for this common case.

In general, given any monomial \(X^\alpha \in \mathbb {K}[x_1,\ldots ,x_h]\) with S-degree m, and any Gröbner basis \({\mathcal {B}}\) of \(I_S\) with respect to a monomial order \(\preceq '\) \(\texttt {NormalForm}_{\preceq '}(X^\alpha ,{\mathcal {B}})\ne X^\alpha \) implies that \(\# \textrm{Z}_m(S)> 1\). Indeed, since the elements of \({\mathcal {B}}\) are binomials, then \(\texttt {NormalForm}_{\preceq '}(X^\alpha ,{\mathcal {B}})\) is a monomial, say, \(X^\beta \); thus, \(X^\alpha - X^\beta \in I_S\), meaning that they have the same S-degree, so \(\alpha , \beta \in \textrm{Z}_m(S)\). Hence, if you consider the following set (equivalent to \(\mathcal {D}(\Lambda ,1)\)),

$$\begin{aligned} \mathcal {D}'(\Lambda )=\left\{ (\gamma _1,\ldots ,\gamma _h)\mid \gamma _i\in \mathbb {N},~\gamma _i\le \lambda _i \right\} , \end{aligned}$$

the elements \(m_\gamma =\sum _{i=1}^h\gamma _ia_i\in S\) with \(\gamma \in \mathcal {D}'(\Lambda )\) and such that \(\# \textrm{Z}_{m_\gamma }(S)=1\) satisfy \(\texttt {NormalForm}_{\preceq '}(X^\gamma ,{\mathcal {B}})= X^\gamma \). This fact can be used to improve Algorithm 1 for \(p=1\).

The following lemma also improves Algorithm 1 for \(p=1\). Consider that \({\mathcal {B}}=\{X^{u_1}-X^{v_1},\ldots ,X^{u_t}-X^{v_t}\}\) is the reduced Gröbner basis of \(I_S\) with respect to \(\preceq '\), and let \(I_v\subset \mathbb {K}[x_1,\ldots ,x_h]\) be the monomial ideal generated by \(\{X^{v_1},\ldots ,X^{v_t}\}\). We assume the leading term of \(X^{u_i}-X^{v_i}\) is \(X^{u_i}\) for any i.

Lemma 3.1

Let \(\alpha =(\alpha _1, \ldots , \alpha _h) \in \mathcal {D}'(\Lambda )\) such that \(\texttt {NormalForm}_{\preceq '}(X^\alpha ,{\mathcal {B}})=X^\alpha \). Then, \(\# \textrm{Z}_{\sum _{i=1}^h\alpha _i a_i}(S)>1\) if and only if \(X^\alpha \in I_v\).

Proof

Since \(\texttt {NormalForm}_{\preceq '}(X^\alpha ,{\mathcal {B}})=X^\alpha \), \(X^\alpha \) is not the leading term of any binomial in \(I_S\) respect to \(\preceq '\).

Assume \(\# \textrm{Z}_{\sum _{i=1}^h\alpha _i a_i}(S)>1\). Then, there is \(\beta \in \mathbb {N}^h\) with \(\sum _{i=1}^h\beta _i a_i=\sum _{i=1}^h\alpha _i a_i\), and \(\beta \ne \alpha \), that is, \(X^\beta -X^\alpha \in I_S\). Hence, there exist \(f_1,\ldots ,f_t\in \mathbb {K}[x_1,\ldots ,x_h]\) such that \(X^\beta - X^\alpha = \sum _{i=1}^t f_i (X^{u_i}-X^{v_i})\). Therefore, \(X^\beta \) is the leading term of \(X^\beta -X^\alpha \), and then, \(X^\alpha \) has to be equal to \(X^\gamma X^{v_i}\) for some \(i\in [1,t]\) and \(X^\gamma \in \mathbb {K}[x_1,\ldots ,x_h]\). We have that \(X^\alpha \in I_v\).

Conversely, suppose \(X^\alpha \in I_v\), so \(X^\alpha \) is equal to \(X^\beta -X^{v_j}\) for some \(j\in [1,t]\) and \(X^\beta \in \mathbb {K}[x_1,\ldots ,x_h]\). Hence, \(\sum _{i=1}^h\alpha _i a_i= \sum _{i=1}^h(\beta _i+v_{ji}) a_i\), where \(v_j=(v_{j1},\ldots ,v_{jh})\). On the other hand, \(X^{u_j}-X^{v_j}\in I_S\), and so, \(\sum _{i=1}^h(\beta _i+v_{ji}) a_i=\sum _{i=1}^h(\beta _i+u_{ji}) a_i \) with \(u_j=(u_{j1},\ldots ,u_{jh})\). Thus, \(\alpha =\beta +v_j\) and \(\beta + u_j\) are two different elements in \( \textrm{Z}_{\sum _{i=1}^h\alpha _i a_i}(S)\).\(\square \)

Algorithm 2
figure b

Improved computation of \(F_1(S)\).

Note that the previous results mean that the set of elements \(m\in S\) with \(\# \textrm{Z}_{m}(S)=1\) corresponds to the set of monomials in \(X^\alpha \in \mathbb {K}[x_1,\ldots ,x_h]\) such that \(X^\alpha \notin \langle \textrm{In}_\prec (I)\rangle +I_v\). Furthermore, the monomial ideal \(\langle \textrm{In}_\prec (I)\rangle +I_v\) does not depend on the fixed monomial order. This fact allows us to introduce an alternative algorithm to compute \(F_1(S)\).

Algorithm 3
figure c

Improved (v2) computation of \(F_1(S)\).

Example 3.2

Consider the same semigroup of Example 2.4. From the monomials of the Gröbner basis computed, we obtain the set of tuples

$$\begin{aligned} \Omega= & {} \{(0, 0, 0, 5, 0), (0, 0, 6, 0, 0), (0, 1, 0, 4, 0), \\{} & {} (0, 0, 4, 0, 4), (0, 1, 2, 0, 0), (0, 0, 0, 1, 4),\\{} & {} (0, 2, 0, 3, 0), (0, 0, 2, 0, 8), (0, 3, 0, 2, 0), \\{} & {} (0, 0, 0, 0, 12), (0, 2, 1, 0, 0), (1, 0, 0, 0, 5),\\{} & {} (1, 0, 0, 3, 0), (0, 0, 3, 0, 3), (0, 1, 0, 1, 0), \\{} & {} (1, 0, 1, 0, 1), (1, 0, 3, 0, 0), (0, 0, 0, 2, 3),\\{} & {} (1, 1, 0, 2, 0), (0, 0, 1, 0, 7), (1, 2, 1, 1, 0),\\{} & {} (0, 0, 0, 0, 11), (2, 0, 0, 1, 0), (0, 0, 0, 0, 6),\\{} & {} (3, 0, 1, 0, 0), (0, 1, 0, 0, 5), (0, 3, 0, 0, 0),\\{} & {} (4, 0, 0, 0, 0)\}. \end{aligned}$$

The set \( \{ \sum _{i=1}^5\alpha _i a_i | \alpha \in \mathbb {N}^5\setminus \cup _{\gamma \in \Omega }(\gamma + \mathbb {N}^5) \} \) has cardinality 179 and its maximum with respect to the monomial order is (21, 4). Thus, \(F_1(S)=(21,4)\), the same we obtained with Algorithm 1.

5 2-Frobenius Vector and Indispensable Binomials

Continuing with the established notation, consider a graded monomial order \(\preceq \) in \(\mathbb {N}^q\) and an affine semigroup S generated by \(\{a_1,\dots ,a_h\}\), as in the preceding sections. It is well known that all the minimal generating sets of the semigroup ideal \(I_S\) have the same cardinality. Moreover, these sets are characterized using simplicial complexes (see Ref. [17], and the references therein). Let \(C_m\subset \mathbb {K}[x_1,\ldots ,x_h]\) be the set of monomials of S-degree \(m\in S\). In Ref. [8], it is introduced the simplicial complex \(\nabla _m = \big \{ F \subseteq C_m \mid \gcd (F) \ne 1\big \},\) where \(\gcd (F)\) denotes the greatest common divisor of the monomials in F, and m belongs to S. Since \(x_1^{\alpha _1}\cdots x_h^{\alpha _h}\in C_m\) if and only if \(m=\sum _{i=1}^h \alpha _i a_i\), the vertex set of \(\nabla _m\) consists of all the monomials of S-degree \(m\in S\), which is equivalent to the set of all the ways of writing m as a linear combination of the generators of S.

We have the characterization of the minimal generating sets of \(I_S\).

Theorem 4.1

([8]) Let \(\Lambda =\{X^{u_1}-X^{v_1},\ldots , X^{u_t}-X^{v_t}\}\subset I_S\), and \(M=\{S\text {-degree}(X^{u_i})\mid i\in [1,t]\}\). Then, \(\Lambda \) is a minimal generator set of \(I_S\) if and only if

  1. 1.

    The simplicial complex \(\nabla _{m}\) is non-connected for any \(m\in M\).

  2. 2.

    For any \(m\in M\):

    1. (a)

      the cardinality of \(B_m\) is equal to the number of connected components of \(\nabla _m\) minus one;

    2. (b)

      the monomials \(X^{u}\) and \(X^{v}\) of any binomial \(X^{u}-X^{v}\in B_m\) belong to different connected components of \(\nabla _m\);

    3. (c)

      there is at least a monomial of every connected component of \(\nabla _m\),

    where \(B_m\) is the set of binomials of S-degree m in \(\Lambda \).

From the study of the uniqueness of the minimal generating set of \(I_S\), the definition of the indispensable binomial of \(I_S\) arises. An indispensable binomial of \(I_S\) is a binomial that appears (up to a scalar multiple) in every generator set of \(I_S\). Equivalently, \(X^{\alpha }-X^{\beta }\in I_S\) is an indispensable binomial if and only if \(\nabla _m=\big \{ \{X^{\alpha }\},\{X^{\beta }\}\big \}\), where m is the S-degree of \(X^\alpha \) and \(X^\beta \) (see Corollary 7 in [16]).

Lemma 4.2

Let S be an affine semigroup such that there exists \(m\in S\) with \(\sharp \textrm{Z}_m (S)=2\). Then, there is at least an indispensable binomial in \(I_S\).

Proof

The equality \(\sharp \textrm{Z}_m(S)=2\) implies that either \(\nabla _m=\big \{ \{X^{\alpha }\},\{X^{\beta }\}\big \}\) or \(\nabla _m=\big \{ \{X^{\alpha }\},\{X^{\beta }\},\{X^{\alpha },X^{\beta }\}\big \}\). For the first case, \(X^\alpha -X^\beta \) is an indispensable binomial in \(I_S\), and for the second one, \(\gcd (X^{\alpha },X^{\beta })^{-1}\big ( X^\alpha -X^\beta \big )\) is an indispensable binomial.\(\square \)

Corollary 4.3

Given S an affine semigroup satisfying the hypothesis of Theorem 2.1. If there is no indispensable binomial in \(I_S\), then \(F_1(S)=F_2(S)\).

From \(\mathcal {D}(\Lambda ,2)\), as defined in (2), we set

$$\mathcal {D}''(\Lambda )=\left\{ \gamma =(\gamma _1,\ldots ,\gamma _h)\mid \gamma _i\in \mathbb {N},~\gamma _i\le 2\lambda _i \right\} .$$

Corollary 4.4

Let \(\gamma \in \mathcal {D}''(\Lambda )\) satisfying \(\# \textrm{Z}_{\sum _{i=1}^h\gamma _i a_i}(S)=2\). Then, there exist \(\gamma '\in \mathcal {D}''(\Lambda )\) and \(X^\delta \in \mathbb {K}[x_1,\ldots , x_h]\) such that \(X^\gamma - X^{\gamma '}= X^\delta \big (X^\alpha -X^\beta \big )\) with \(X^\alpha -X^\beta \) an indispensable binomial in \(I_S\).

Similar to the case \(p=1\), we can leverage results from this section to enhance Algorithm 1 for \(p=2\). We can determine whether there are elements in the semigroup with only two ways of writing by checking whether there are any indispensable binomials in \(I_S\). Furthermore, if there are some indispensable binomials, we can significantly reduce the set of elements in the semigroup that can have two ways of writing.

Algorithm 4
figure d

Improved computation of \(F_2(S)\).

Example 4.5

Continuing with the semigroup of the Examples 2.4 and 3.2. For this semigroup, all the binomials of the Gröbner basis given in Example 2.4 are indispensable.

We have that \(\Lambda = (4,3,6,5,11)\), and therefore, the set \(\mathcal {D}''(\Lambda )\) is equal to \(\left\{ \gamma \in \mathbb {N}^p\mid \gamma \le (8,6,12,10,22)\right\} \). We use the bound (8, 6, 12, 10, 22) to compute the set G from the set D that initially contains 126721 elements. These elements are the factorizations of 10071 different elements in the monoid S. We search the maximum with respect to the graded lexicographic order having exactly 2 factorizations. For this sake, we sort all the 10071 different elements obtained in the semigroup, and, starting from the biggest one, the element (70, 164), we stop after we find an element with exactly 2 factorizations. The element found is (2, 83), and thus, \(F_2(S)=(2,83)\).

6 p-Frobenius of \(\mathbb {N}^q\)-Gluing Affine Semigroups

From now on, consider \(S=\langle a_1,\ldots , a_h\rangle \) an affine semigroup, \(d\in \mathbb {N}\), \(\gamma =(\gamma _1,\ldots ,\gamma _q)\in \mathbb {N}^q\) with d and \(\gcd (\gamma _1,\ldots ,\gamma _q)\) coprime, and such that \(S'=S\oplus _{d,\gamma } \mathbb {N}^q\) is an affine semigroup. In this section, we study the behavior of \(F_p(S')\) with respect to \(F_p(S)\).

For numerical semigroups, that is \(q=1\), the relationship between \(F_0(S')\) and \(F_0(S)\) is the well known formula \(F_0(S')=dF_0(S)+(d-1)\gamma \). Note that, for \(p=0\) and \(q>1\), the 0-Frobenius vector is finite if and only if S is a \(\mathcal {C}\)-semigroup. Also note that for any S, \(\mathcal {C}(S')\setminus S'\) is not finite. Therefore, we assume that \(p\ge 1\).

Lemma 5.1

Let \(s'=ds+a\gamma \in S'\) with \(s\in S\) and \(0\le a \le d-2\). Then, \(\#Z_{s'}(S')=\#Z_{s'+\gamma }(S')\).

Proof

Remember that \(S'=\langle da_1, \ldots , da_h, \gamma \rangle \) and consider the injective map

$$\begin{aligned} \nu :Z_{s'}(S')&\longrightarrow Z_{s'+\gamma }(S') \\ (\lambda _1, \ldots , \lambda _h, \lambda _\gamma )&\longmapsto (\lambda _1, \ldots , \lambda _h, \lambda _\gamma +1). \end{aligned}$$

To conclude, we prove that \(\nu \) is surjective.

Take \(\lambda '=(\lambda '_1, \ldots , \lambda '_h, \lambda '_\gamma ) \in Z_{s'+\gamma }(S')\), that is

$$\begin{aligned} \lambda '_1 da_1 + \cdots + \lambda '_h da_h + \lambda '_\gamma \gamma = s'+\gamma = ds + (a+1)\gamma . \end{aligned}$$

This implies that \((\lambda '_\gamma \gamma -(a+1)\gamma ) \equiv 0 \; (\textrm{mod}\,\;d)\), and since \(\gcd (\gamma _1,\ldots ,\gamma _q)\) and d are coprime, it must be \(\lambda '_\gamma \equiv a+1 \; (\textrm{mod}\,\; d)\). In turn, since \(\lambda '_\gamma \in \mathbb {N}\) and \(0\le a \le d-2\), we must have \(\lambda '_\gamma \ge a+1 >0\). Thus, \(\lambda = (\lambda '_1, \ldots , \lambda '_h, \lambda '_\gamma -1) \in Z_{s'}(S') \), and clearly, \(\nu (\lambda )=\lambda '\).\(\square \)

This allows us to give an upper bound for the p-Frobenius vector of \(S'\) when \(p\ge 1\).

Proposition 5.2

Let S and \(S'\) as defined before and let \(p\ge 1\). Then, \(F_p(S')\preceq dF_p(S)+(d-1)\gamma \).

Proof

We have that \(F_p(S') \in S'\), and thus, \(F_p(S')=ds+a\gamma \), for some \(s\in S\) and \(a\in \mathbb {N}\). Since \(\gamma \in S\), we can further assume that \(0\le a \le d-1\).

We claim that it must be \(F_p(S')=ds+(d-1)\gamma \). Indeed, if \(F_p(S')=ds+a\gamma \) with \(a<d-1\), then, by Lemma 5.1, \(F_p(S') + \gamma \) is also an element of \(\{n\in \mathbb {N}\mid \# \textrm{Z}_n(S)\le p\}\), contradicting the \(\preceq \)-maximality of \(F_p(S')\).

Finally, we prove that \(s\preceq F_p(S)\). By contradiction, if \(s \succ F_p(S)\), then \(\# \textrm{Z}_s(S) \ge p+1\), and \(\# \textrm{Z}_{sd+(d-1)\gamma }(S) \ge p+1\).\(\square \)

The following result shows a necessary and sufficient condition for equality to hold in Proposition 5.2 whenever \(F_p(S)\) is such that \(\#\textrm{Z}_{F_p(S)}(S)=p\).

Theorem 5.3

Assume that \(\#\textrm{Z}_{F_p(S)}(S)=p\). Then, \(F_p(S')=dF_p(S)+(d-1)\gamma \) if and only if, for every \(b\in \textrm{Z}_\gamma (S)\), there is no \(c\in \textrm{Z}_{F_p(S)}(S)\) such that \(b\le _{\mathbb {N}^h} c\), where \(\le _{\mathbb {N}^h}\) denotes the partial order given by \(b_i \le c_i\) for every \(i\in [1,h]\).

Proof

Let \(s'=dF_p(S)+(d-1)\gamma \).

Assume there exist \(b\in \textrm{Z}_\gamma (S)\) and \(c\in \textrm{Z}_{F_p(S)}(S)\) such that \(b\le _{\mathbb {N}^h} c\). We show \(s'\ne F_p(S')\) by proving \(\# \textrm{Z}_{s'}(S') \ge p+1\). Indeed, notice that every \(\lambda \in \textrm{Z}_{F_p(S)}(S)\) gives an element \((\lambda ,d-1) \in \textrm{Z}_{s'}(S')\). This implies \(\# \textrm{Z}_{s'}(S') \ge \# \textrm{Z}_{F_p(S)}(S)=p\). Moreover, one can check that \((c-b,2d-1) \in \textrm{Z}_{s'}(S')\) gives another element in the set.

Conversely, let \(\textrm{Z}_{F_p(S)}(S)=\{\lambda ^{(1)}, \ldots , \lambda ^{(p)}\}\). As just noticed, we have that

$$L=\left\{ \left( \lambda ^{(1)},d-1\right) , \ldots , \left( \lambda ^{(p)},d-1\right) \right\} \subseteq \textrm{Z}_{s'}(S').$$

Assume by contradiction that \(F_p(S')\ne s'\). Then, by Proposition 5.2, it must be \(F_p(S')\prec s'\). Thus, \(\#\textrm{Z}_{s'}(S')\ge p+1\). Let \(\mu =(\mu _1, \ldots , \mu _h, \mu _\gamma ) \in \textrm{Z}_{s'}(S')\setminus L\). Since \(\gcd (\gamma _1,\ldots ,\gamma _q)\) and d are coprime, and

$$dF_p(S) + (d-1)\gamma = s' = \mu _1 da_1 + \cdots +\mu _h da_h + \mu _\gamma \gamma ,$$

then \(\mu _\gamma \equiv d-1 \;(\textrm{mod}\,\;d)\). If \(\mu _\gamma = d-1\), then \((\mu _1, \ldots , \mu _h)\in \textrm{Z}_{F_p(S)}(S)\), which cannot be since \(\mu \notin L\). Thus, \(\mu _\gamma = kd+(d-1)\) for some \(k\ge 1\). Taking \(b=(b_1, \ldots , b_h) \in \textrm{Z}_\gamma (S)\), we have \((\mu _1+kb_1, \ldots , \mu _h +kb_h, d-1)\in \textrm{Z}_{s'}(S')\). Hence, \((\mu _1+kb_1, \ldots , \mu _h +kb_h) \in \textrm{Z}_{F_p(S)}(S)\), that is, \((\mu _1+kb_1, \ldots , \mu _h +kb_h)=c\) for some \(c\in \textrm{Z}_{F_p(S)}(S)\). This implies that \(b\le _{\mathbb {N}^h} c\), which contradicts the hypothesis.\(\square \)