# Learning Social Navigation from Demonstrations with Deep Neural Networks

Yigit Yildirim1 and Emre Ugur2 1Yigit Yildirim is with Computer Engineering
Department, Bogazici University, Istanbul, Turkey
<EMAIL_ADDRESS>Ugur is with Computer Engineering Department,
Bogazici University, Istanbul, Turkey<EMAIL_ADDRESS>
###### Abstract

Traditional path planning techniques treat humans as obstacles. This has
changed since robots started to enter human environments. On modern robots,
social navigation has become an important aspect of navigation systems. To use
learning-based techniques to achieve social navigation, a powerful framework
that is capable of representing complex functions with as few data as possible
is required. In this study, we benefited from recent advances in deep learning
at both global and local planning levels to achieve human-aware navigation on
a simulated robot. Two distinct deep models are trained with respective
objectives: one for global planning and one for local planning. These models
are then employed in the simulated robot. In the end, it has been shown that
our model can successfully carry out both global and local planning tasks. We
have shown that our system could generate paths that successfully reach
targets while avoiding obstacles with better performance compared to feed-
forward neural networks.

##  I INTRODUCTION

Mobile robot navigation has been studied for decades. Many notable techniques
have been proposed in this area over the years, [1, 2, 3]. These approaches
have prioritized the safety and the robustness features, i.e. the principal
driving factor behind the development in this field has been the collision
avoidance [4]. On the other hand, as humans start to share their environments
with robots, new requirements for mobile robot navigation have emerged.

In [5], physical and mental aspects of the safety are separately evaluated.
This separation reveals the need to question the psychological efficiency of
navigation systems of mobile robots. Keeping in mind the assumption that
humans prefer to interact with machines in the same way that they interact
with other people, in order to achieve a natural integration to the
environments populated by people, mobile robots must be developed to be not
only safe but also comprehensible.

Broadly speaking, human-aware navigation corresponds to the navigation that
complies with the social rules of the people. In their own environments,
humans tend to work cooperatively to realize social navigation. Then, it is
only natural to imitate this behavior on the robots to achieve socially-
acceptable navigation. However, imitating people introduces new constraints to
be satisfied by the navigation systems of robots.

These constraints have been addressed in many studies in the literature.
Essentially, these studies can be divided into two categories: manually-
encoded controllers and learning-based ones. One of the notable studies of the
first category is the Social Force Model (SFM) [6]. Based on the behavioral
techniques from social sciences, SFM suggests that pedestrians move under the
effect of certain abstract forces, just like the particles in an electrical
field. While the navigational goal attracts the pedestrian, obstacles and
other people exert repulsive forces. Despite its wide application[7, 8, 9],
some researchers state that not being based on the statistical data is a
weakness of the model [10].

To create statistics-based socially compliant navigation frameworks, a large
number of machine learning algorithms have been employed. One of the popular
algorithms is Inverse Reinforcement Learning (IRL) [11, 12, 13]. Given the
perfect expert demonstrations, IRL tries to identify the underlying reward
structure, which in turn can be used by any Reinforcement Learning (RL)
algorithm to create a human-aware navigation policy. Even though the
justification of the unfixed reward function is appealing, the features that
shape the reward function are assumed to be known, which is considered as a
strong assumption [14]. Generally in this domain, feature engineering leads to
strong assumptions. This problem can be solved by extracting the social
behaviors and navigation strategies of pedestrians directly from the data.
This is challenging because the controller needs to be complex enough to
capture the non-linearities in the data.

To address this issue in social navigation domain, deep learning techniques
have been used. In [15], Deep Reinforcement Learning is used to obtain a
socially plausible navigation policy. As in other RL approaches, this
procedure relies on a predefined reward which is difficult to obtain.
Imitation Learning skips the reward extraction and tries to learn policies
directly from the data. In [16] and [17], Generative Adversarial Networks are
used for this purpose. These approaches are complex enough to overcome the
aforementioned issues. However, these models need too much data to be trained
[18]. On the other hand, the preferred system needs to learn from a small
dataset and to generalize to novel configurations.

Moreover, the majority of the studies on this domain target only the local
controller of the robot as it is the part that creates motion commands to
drive the robot. However, using only the local controller makes the robot
vulnerable to local minima [19]. Today, typical robotic navigation systems
adopt the two-layered hierarchical approach for path planning tasks. Given a
map of the environment, a robot firstly calculates a trajectory in the so-
called global planning phase. Then, the robot follows the computed trajectory
with a controller in the so-called local planning phase.

In this paper, we use Conditional Neural Processes (CNPs) [20] in order to
address the issues mentioned above in both global and local planning phases.
CNPs can be modified to generate complete trajectories to replace the global
planner. Also, they can create goal-directed behavior while actively avoiding
obstacles. This characteristic makes it a candidate for the local planner, as
well. CNPs extract the prior knowledge directly from the training data by
sampling observations from it, and uses it to predict a conditional
distribution over any other target points. CNPs can learn complex temporal
relations in connection with external parameters and goals. In this paper, we
present the initial results of our system. Upon successful preliminary results
with this conceptual model, we aim to extend this work to integrate our path
planning system into an actual robot in another study.

##  II Related Work

Traditionally, approaches to solve the path planning problem can be divided
into two categories based on the environmental knowledge they use: deliberate
and reactive. Deliberate planners exploit the environmental knowledge by means
of static maps and calculate the robot’s trajectory before execution. On the
other hand, reactive planners rely on sensory information to deal with local
parts of the environment. Either approach has its advantages and drawbacks.
Hence, the evolution of the path planning approaches leads to the combination
of these two approaches. Hybrid frameworks have been the typical approach for
many years, as explained in [21].

In the following, we elaborate on this conventional framework’s building
blocks and the social navigation concept.

###  II-A Hierarchical Path Planning

The standard hybrid path planning framework combines the strengths of
deliberate and reactive planners. It consists of a two-phased procedure in a
hierarchical manner; global planning is for the deliberation and local
planning for the reactivity.

####  II-A1 Global Path Planner

In the first phase of a standard hierarchical path planning pipeline, a global
planning procedure is applied. On the static map of the environment, the
function of a global planner is to generate a path from the starting position
to the destination. Conventionally, many graph search algorithms have been
applied to calculate the trajectory between initial and goal configurations,
the most popular being A* explained in [22]. For a more complete list of
global planning approaches, see [23].

The global planning itself is not sufficient to navigate the robot between two
points. Local planning is needed to create velocity commands that handle the
cases with new or dynamic obstacles.

####  II-A2 Local Path Planner

In order to realize computed trajectories, the local planning procedures are
used in the second phase of hierarchical path planning. The most prominent
objective of the local planner is to generate velocity commands so that the
robot can follow the computed trajectory. In addition, by using the sensory
information about the robot’s surroundings, it is the local planner’s duty to
avoid obstacles. There are many local planning algorithms in the literature,
such as [24, 4, 25, 26, 27, 28]. For a more complete list, see [29].

On the other hand, despite being quite safe, these traditional controllers
take no account of social norms. They consider people as obstacles to be
avoided. Recent attempts to create local controllers that consider these norms
has paved the way for social robot navigation.

###  II-B Social Navigation

According to [30], the benefits of social navigation are threefold: it
increases the comfort of the people around the robot, it improves the
naturalness of the robotic platform and it also enhances the sociability of
the robot. Furthermore, in [5], physical and mental aspects of safety are
separately evaluated. For us, this separation reveals the need to question the
psychological efficiency of navigation systems of mobile robots.

The concept of social navigation lies in the intersection of two concepts:
navigation and human-robot interaction. It describes improving the navigation
of the robot to enhance its comprehensibility by the humans around. Figure 1
is rather self explanatory. On the left, we see a robot with a perfectly safe
navigation plan. In contrast, although non-optimal, the planned path on the
right is socially compliant.

Figure 1: Comparison between regular and social navigation. Figure 2: General
layout of the training phase of our model.

##  III Method

In this work, we address two parts of the hierarchical path planning
individually and show that the capabilities of the model we propose can handle
both global and local planning. We suggest employing a variant of Conditional
Neural Processes (CNPs) for both of them separately.

CNP is a powerful deep learning framework, which is inspired by the
flexibility of stochastic processes, but organized as neural networks and
trained with gradient descent [20]. Since its emergence, CNPs and variants
have been successfully applied in several robot learning problems [31, 32,
33]. Instead of outputting a single value, CNP learns a Gaussian distribution
over the demonstrated trajectories. The set $D$, representing all
demonstrations is defined as follows: $D=\\{D_{i}\\}_{i=0}^{N}$, where each
$D_{i}$ is a trajectory of a number of points in a high-dimensional space.
Essentially, $D_{i}=(X_{t},\gamma(X_{t}),SM(X_{t}))_{t=0}^{\tau}$, where $X$
is the state variable, $\gamma(X)$ is a function representing task parameters
and $SM(X)$ is the sensorimotor function to be learned. The encoder network
produces a latent representation for each trajectory and these representations
are passed through an averaging operation to create a compact representation
$r_{AVG}$ for the task at hand. Subsequently, $X_{q}$, $\gamma(X_{q})$ and
$r_{AVG}$ are fed to the Query Network to produce an estimate for $SM(X_{q})$.
$\mu_{q}$ and $\sigma_{q}$ respectively represent the estimated mean and the
variance. Figure 2 shows the overall model.

The model consists of an encoder network which outputs latent representations
by using the sampled points on the demonstrated trajectories. These
representations in the latent space are then averaged to come up with a
compact representation of the trajectory. At query time, this compact
representation is concatenated with the target point and the resulting vector
is fed to the query network to generate the estimated sensorimotor response of
the model.

####  III-1 Global Planning

One of the most powerful aspects of the CNPs approach is its ability to
generate complete trajectories. Upon training the encoder and query networks,
target points can be simultaneously processed from the starting point to the
end to create an entire trajectory. This ability can be exploited to create
global plans in the first phase of a hierarchical path planning procedure.

####  III-2 Local Planning

We also benefit from CNPs in reactively responding to the changes in its
domain. With this, we substitute the local planning module of the hierarchical
path planners with local CNPs. This requires sensory input to be processed by
the CNP as task parameters. In the current study, high-level parameters such
as distance to the obstacles or relative position to the goal point are used
as input to the local CNPs. It was shown that CNPs can efficiently handle low-
level and high-dimensional input as well, as shown in [34].

##  IV Experiments and Results

###  IV-A Environment

Our system was verified in CoppeliaSim simulation environment [35] that
includes an omnidirectional robot platform (Robotino [36]). The Social Force
Model, described in [6], is implemented as the local controller of the robot
to gather demonstration trajectories. With the assumption that it generates
socially plausible trajectories, 1000 trajectories with randomly different
starting, goal and obstacle poses are recorded. Single, multiple, stationary
and dynamic objects are placed at random positions in each trial. The data
collection process is shown in Figure 3.

Figure 3: Data collection on the simulation. The motion trajectory is shown
with blue line.

###  IV-B Global Planner

To show the path planning capability of our method, the model is fed with the
entire trajectories of positions of the robot and trained on these
demonstrations. The representation of the data is as follows:

$\displaystyle X=time\\_step$
$\displaystyle\gamma(X)=(start\\_x,start\\_y,goal\\_x,goal\\_y,obs\\_x,obs\\_y)$
$\displaystyle SM(X)=(position\\_x,position\\_y),$

where $obs\\_x$ and $obs\\_y$ refers to the obstacle’s $x$ and $y$ positions.
Fig. 4(a) illustrates the training phase and Fig. 4(b) shows how the entire
path is queried.

(a) Training the network with a randomly chosen demonstration trajectory.

(b) Generating a global path in test phase.

Figure 4: CNP as the global planner.

To show the strength of CNPs over standard neural networks, we compare their
performance on the trajectory planning task. For this purpose, we implemented
a 5-layered standard feed-forward neural network and trained it on the same
dataset of 1000 trajectories. The comparison of their performances on a global
planning task is given in Figure 5. This result shows that while a feed-
forward neural network cannot generate global paths that avoid obstacles, our
system can. We believe that this is due to the capability of our system to
learn multiple-modes of operations. Standard feed-forward networks, given
demonstration paths that avoid obstacles from different sides, probably
interpolates these paths; whereas our system can learn to generate
trajectories from both sides.

Figure 5: Comparison between our global planner network (CNP) and a 5-layered
feed-forward neural network (NN) on global planning in sample environments.

###  IV-C Local Planner

From the local perspective, the input parameters of our local network are
distance-to-goal, distance-to-obstacle and velocity commands. Here, the
formulation of the problem is as follows:

$\displaystyle X=(distance\\_to\\_goal\\_x,distance\\_to\\_goal\\_y)$
$\displaystyle\gamma(X)=(distance\\_to\\_obs\\_x,distance\\_to\\_obs\\_y)$
$\displaystyle SM(X)=(velocity\\_x,velocity\\_y)$

Note this time that, we do not use a linearly increasing phase variable, as we
did in the case of global planning. Conditioned on the starting and
destination poses, the use of the task parameter $\gamma(X)$ gave the model
the ability to reactively change the velocity commands with respect to
changing obstacle positions.

Figure 6: Robot is avoiding from a vertically moving obstacle. Figure 7: Robot
is passing through several stationary obstacles.

The resulting local planner is shown to work on several different
configurations, as shown in Figures 6 and 7. Since our local planner is
trained on the trajectories created by SFM, we believe that the policy it
learned imitates SFM’s behavior. Further comparison is needed to support this
claim.

##  V Limitations and Future Work

In this study, the preliminary results of our framework which is a
hierarchical framework that is built on top of CNPs is presented. We showed
that our model can generate reasonable paths at both global and local levels
while avoiding obstacles. This work needs to be extended with a thorough
statistical analysis comparing with strong baselines in successful social-
aware navigation tasks. As a part of this endeavour, we plan to train our
models on actual human data. Thus, we would elude the critics of SFM and prove
that our model could work with real human data. Furthermore, most importantly,
we plan to transfer and verify learned models in real robots.

Another direction of research to extend this work is to incorporate detectors
that discover groups of people from raw sensory information. Human trajectory
prediction can also be added to create smoother paths during navigation. For
this purpose, graph neural networks [37] that represent the world as nodes and
relations between those nodes, can be employed.

CNPs have a number of drawbacks. The most important one to mention is that it
cannot successfully extrapolate to the outside of the state space that it is
trained on. For a mobile robot controller, this limitation is crucial since
extrapolation might lead to a collision. Such cases do occur frequently when
the dimensionality of the state space is high and the dataset is insufficient.
We plan to learn models that detect whether the robot is trying to extrapolate
and fall back to the manual controller when extrapolation occurs.

## References

  * [1] W. Burgard, A. Cremers, D. Fox, D. Hähnel, G. Lakemeyer, D. Schulz, W. Steiner, and S. Thrun, “Experiences with an interactive museum tour-guide robot,” _Artif. Intell._ , vol. 114, pp. 3–55, 1999.
  * [2] S. Thrun, M. Beetz, M. Bennewitz, W. Burgard, A. B. Cremers, F. Dellaert, D. Fox, D. Haehnel, C. Rosenberg, N. Roy, _et al._ , “Probabilistic algorithms and the interactive museum tour-guide robot minerva,” _The International Journal of Robotics Research_ , vol. 19, no. 11, pp. 972–999, 2000\.
  * [3] I. Nourbakhsh, C. Kunz, and T. Willeke, “The mobot museum robot installations: a five year experiment,” in _Proceedings 2003 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS 2003) (Cat. No.03CH37453)_ , vol. 4, 2003, pp. 3636–3641 vol.3.
  * [4] D. Fox, W. Burgard, and S. Thrun, “The dynamic window approach to collision avoidance,” _IEEE Robotics Automation Magazine_ , vol. 4, no. 1, pp. 23–33, 1997.
  * [5] S. Nonaka, K. Inoue, T. Arai, and Y. Mae, “Evaluation of human sense of security for coexisting robots using virtual reality. 1st report: evaluation of pick and place motion of humanoid robots,” in _IEEE International Conference on Robotics and Automation, 2004. Proceedings. ICRA’04. 2004_ , vol. 3. IEEE, 2004, pp. 2770–2775.
  * [6] D. Helbing and P. Molnar, “Social force model for pedestrian dynamics,” _Physical review E_ , vol. 51, no. 5, p. 4282, 1995\.
  * [7] F. Zanlungo, T. Ikeda, and T. Kanda, “Social force model with explicit collision prediction,” _EPL (Europhysics Letters)_ , vol. 93, no. 6, p. 68005, 2011.
  * [8] G. Ferrer, A. Garrell, and A. Sanfeliu, “Robot companion: A social-force based approach with human awareness-navigation in crowded environments,” in _2013 IEEE/RSJ International Conference on Intelligent Robots and Systems_. IEEE, 2013, pp. 1688–1694.
  * [9] F. Farina, D. Fontanelli, A. Garulli, A. Giannitrapani, and D. Prattichizzo, “Walking ahead: The headed social force model,” _PloS one_ , vol. 12, no. 1, p. e0169734, 2017.
  * [10] “Socially compliant mobile robot navigation via inverse reinforcement learning, author=Kretzschmar, Henrik and Spies, Markus and Sprunk, Christoph and Burgard, Wolfram,” _The International Journal of Robotics Research_ , vol. 35, no. 11, pp. 1289–1307, 2016.
  * [11] K. Kitani, B. Ziebart, J. Bagnell, and M. Hebert, “Activity forecasting,” _Computer Vision–ECCV 2012_ , pp. 201–214, 2012.
  * [12] D. Vasquez, B. Okal, and K. O. Arras, “Inverse reinforcement learning algorithms and features for robot navigation in crowds: an experimental comparison,” in _2014 IEEE/RSJ International Conference on Intelligent Robots and Systems_. IEEE, 2014, pp. 1341–1346.
  * [13] B. Kim and J. Pineau, “Socially adaptive path planning in human environments using inverse reinforcement learning,” _International Journal of Social Robotics_ , vol. 8, no. 1, pp. 51–66, 2016.
  * [14] M. Wulfmeier, P. Ondruska, and I. Posner, “Maximum entropy deep inverse reinforcement learning,” _arXiv preprint arXiv:1507.04888_ , 2015.
  * [15] Y. F. Chen, M. Everett, M. Liu, and J. P. How, “Socially aware motion planning with deep reinforcement learning,” _CoRR_ , vol. abs/1703.08862, 2017. [Online]. Available: http://arxiv.org/abs/1703.08862
  * [16] L. Tai, J. Zhang, M. Liu, and W. Burgard, “Socially compliant navigation through raw depth inputs with generative adversarial imitation learning,” in _2018 IEEE International Conference on Robotics and Automation (ICRA)_. IEEE, 2018, pp. 1111–1117.
  * [17] A. Gupta, J. Johnson, L. Fei-Fei, S. Savarese, and A. Alahi, “Social gan: Socially acceptable trajectories with generative adversarial networks,” in _Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition_ , 2018, pp. 2255–2264.
  * [18] Y. Che, A. M. Okamura, and D. Sadigh, “Efficient and trustworthy social navigation via explicit and implicit robot–human communication,” _IEEE Transactions on Robotics_ , vol. 36, no. 3, pp. 692–707, 2020.
  * [19] Y. Koren and J. Borenstein, “Potential field methods and their inherent limitations for mobile robot navigation,” in _Proceedings. 1991 IEEE International Conference on Robotics and Automation_ , 1991, pp. 1398–1404 vol.2.
  * [20] M. Garnelo, D. Rosenbaum, C. Maddison, T. Ramalho, D. Saxton, M. Shanahan, Y. W. Teh, D. Rezende, and S. M. A. Eslami, “Conditional Neural Processes,” in _Proceedings of the 35th International Conference on Machine Learning_ , ser. Proceedings of Machine Learning Research, J. Dy and A. Krause, Eds., vol. 80. PMLR, 10–15 Jul 2018, pp. 1704–1713. [Online]. Available: http://proceedings.mlr.press/v80/garnelo18a.html
  * [21] J.-A. Meyer and D. Filliat, “Map-based navigation in mobile robots:: II. A review of map-learning and path-planning strategies,” _Cognitive Systems Research_ , vol. 4, no. 4, pp. 283–317, 2003. [Online]. Available: https://www.sciencedirect.com/science/article/pii/S138904170300007X
  * [22] S. Kambhampati and L. Davis, “Multiresolution path planning for mobile robots,” _IEEE Journal on Robotics and Automation_ , vol. 2, no. 3, pp. 135–145, 1986.
  * [23] J. Giesbrecht, “Global path planning for unmanned ground vehicles,” Defence Research and Development Suffield (Alberta), Tech. Rep., 2004.
  * [24] J. Borenstein, Y. Koren, _et al._ , “The vector field histogram-fast obstacle avoidance for mobile robots,” _IEEE transactions on robotics and automation_ , vol. 7, no. 3, pp. 278–288, 1991.
  * [25] O. Khatib, “Real-time obstacle avoidance for manipulators and mobile robots,” in _Proceedings. 1985 IEEE International Conference on Robotics and Automation_ , vol. 2, 1985, pp. 500–505.
  * [26] C. Rösmann, F. Hoffmann, and T. Bertram, “Timed-Elastic-Bands for time-optimal point-to-point nonlinear model predictive control,” in _2015 European Control Conference (ECC)_ , 2015, pp. 3352–3357.
  * [27] Q. Zhu, Y. Yan, and Z. Xing, “Robot path planning based on artificial potential field approach with simulated annealing,” in _Sixth International Conference on Intelligent Systems Design and Applications_ , vol. 2. IEEE, 2006, pp. 622–627.
  * [28] P. Vadakkepat, K. C. Tan, and W. Ming-Liang, “Evolutionary artificial potential fields and their application in real time robot path planning,” in _Proceedings of the 2000 congress on evolutionary computation. CEC00 (Cat. No. 00TH8512)_ , vol. 1. IEEE, 2000, pp. 256–263.
  * [29] K. Cai, C. Wang, J. Cheng, C. W. De Silva, and M. Q.-H. Meng, “Mobile Robot Path Planning in Dynamic Environments: A Survey,” _arXiv preprint arXiv:2006.14195_ , 2020\.
  * [30] T. Kruse, A. K. Pandey, R. Alami, and A. Kirsch, “Human-aware robot navigation: A survey,” _Robotics and Autonomous Systems_ , vol. 61, no. 12, pp. 1726–1743, 2013.
  * [31] M. Y. Seker, M. Imre, J. H. Piater, and E. Ugur, “Conditional Neural Movement Primitives.” in _Robotics: Science and Systems_ , 2019.
  * [32] M. Yin, G. Tucker, M. Zhou, S. Levine, and C. Finn, “Meta-learning without memorization,” _arXiv preprint arXiv:1912.03820_ , 2019.
  * [33] M. T. Akbulut, M. Y. Seker, A. E. Tekden, Y. Nagai, E. Oztop, and E. Ugur, “Adaptive Conditional Neural Movement Primitives via Representation Sharing Between Supervised and Reinforcement Learning,” _arXiv preprint arXiv:2003.11334_ , 2020.
  * [34] J. Gordon, W. P. Bruinsma, A. Y. Foong, J. Requeima, Y. Dubois, and R. E. Turner, “Convolutional conditional neural processes,” _arXiv preprint arXiv:1910.13556_ , 2019.
  * [35] E. Rohmer, S. P. N. Singh, and M. Freese, “CoppeliaSim (formerly V-REP): a Versatile and Scalable Robot Simulation Framework,” in _Proc. of The International Conference on Intelligent Robots and Systems (IROS)_ , 2013, www.coppeliarobotics.com.
  * [36] F. Robotics, Robotino, “Robotino 4: For research and education,” 2020. [Online]. Available: https://www.festo-didactic.com/int-en/learning-systems/factory-automation-industry-4.0/focus-trending-topics-i4.0/858/robotino-4-for-research-and-education.htm
  * [37] A. E. Tekden, A. Erdem, E. Erdem, M. Imre, M. Y. Seker, and E. Ugur, “Belief Regulated Dual Propagation Nets for Learning Action Effects on Groups of Articulated Objects,” 2020.


# On some properties for cofiniteness of submonoids and ideals of an affine
semigroup

Carmelo Cisto  Università di Messina, Dipartimento di Scienze Matematiche e
Informatiche, Scienze Fisiche e Scienze della Terra, Viale Ferdinando Stagno
D’Alcontres 31, 98166 Messina, Italy<EMAIL_ADDRESS>
###### Abstract.

Let $S$ and $\mathcal{C}$ be affine semigroups in $\mathbb{N}^{d}$ such that
$S\subseteq\mathcal{C}$. We provide a characterization for the set
$\mathcal{C}\setminus S$ to be finite, together with a procedure and
computational tools to check whether such a set is finite and, if so, compute
its elements. As a consequence of this result, we provide a characterization
for an ideal $I$ of an affine semigroup $S$ so that $S\setminus I$ is a finite
set. If so, we provide some procedures to compute the set $S\setminus I$.

###### Key words and phrases:

Affine semigroup, Ideal of a semigroup, $\mathcal{C}$-semigroup, Generalized
numerical semigroup

###### 2020 Mathematics Subject Classification:

20M14, 20M12

## Introduction

Let $\mathbb{N}$ be the set of non-negative integers. A monoid $S$ is called
an _affine semigroup_ if it is a finitely generated submonoid of the additive
monoid $\mathbb{N}^{d}$, for some positive integer $d$. Equivalently, up to
isomorphism, $S$ is a monoid that is finitely generated, cancellative, torsion
free and reduced. We recall that a monoid $S\subseteq\mathbb{Z}^{d}$ is
finitely generated if there exists a finite set $A\subseteq\mathbb{Z}^{d}$
contained in $S$ such that $S=\langle A\rangle$, where:

$\langle A\rangle=\left\\{\sum_{i=1}^{n}\lambda_{i}\mathbf{a}_{i}\mid
n\in\mathbb{N},\mathbf{a}_{i}\in A,\lambda_{i}\in\mathbb{N}\text{ for all
}i\in\\{1,\ldots,n\\}\right\\}.$

In particular, $S=\langle A\rangle$ is called the monoid generated by $A$ and
$A$ is a set of generators of $S$. It is known that for every submonoid $S$ of
$\mathbb{N}^{d}$, there exists a unique minimal set that generates $S$, that
is
$(S\setminus\\{\mathbf{0}\\})\setminus(S\setminus\\{\mathbf{0}\\}+S\setminus\\{\mathbf{0}\\})$.
In particular, if $S$ is an affine semigroup such a set is finite.

Let $\mathbb{Q}_{+}$ be the the set of non-negative rational numbers. If
$S=\langle A\rangle\subseteq\mathbb{N}^{d}$ is an affine semigroup, we
consider the sets
$\operatorname{cone}(S)=\\{\sum_{i=1}^{n}q_{i}\mathbf{a}_{i}\mid
n\in\mathbb{N},\mathbf{a}_{i}\in A,q_{i}\in\mathbb{Q}_{+}\text{ for all
}i\in\\{1,\ldots,n\\}\\}$, that is the _cone_ spanned by $S$, and
$\operatorname{Group}(S)=\\{\mathbf{a}-\mathbf{b}\in\mathbb{Z}^{d}\mid\mathbf{a},\mathbf{b}\in
S\\}$, that is called the _group_ generated by $S$. The sets
$\mathcal{N}(S)=\operatorname{cone}(S)\cap\operatorname{Group}(S)$, called the
_normalization_ of $S$, and
$\mathcal{C}_{S}=\operatorname{cone}(S)\cap\mathbb{N}^{d}$ are affine
semigroups (by Gordan’s Lemma, see for instance [4, Lemma 2.9]). Since $S$ is
finitely generated, if
$\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\\}\subseteq\mathbb{N}^{d}$ is its
minimal set of generators, by relabeling if necessary, without loss of
generality, we may assume that there exists $r\leq n$ such that
$\operatorname{cone}(S)=\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\})$.
For minimality, we may also assume that
$\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}\setminus\\{\mathbf{g}_{i}\\})\neq\operatorname{cone}(S)$
for each $i\in\\{1,\ldots,r\\}$. In such a case
$\mathbf{g}_{i}\notin\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}\setminus\\{\mathbf{g}_{i}\\})$
for each $i\in\\{1,\ldots,r\\}$ (otherwise
$\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}\setminus\\{\mathbf{g}_{i}\\})=\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}=\operatorname{cone}(S)$).
We say that $\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}$ is a set of _extreme
rays_ of $S$.

One of the motivations for studying affine semigroups is to extend the notion
of numerical semigroup and some its properties. A numerical semigroup is a
submnoid $S$ of $\mathbb{N}$ such that $\mathbb{N}\setminus S$ is finite. It
is known that every numerical semigroup is a finitely generated monoid (so it
is an affine semigroup) and every submonoid of $\mathbb{N}$ is isomorphic to a
numerical semigroup. Moreover, it is known that if $S=\langle
g_{1},\ldots,g_{n}\rangle\subseteq\mathbb{N}$, then $S$ is a numerical
semigroup if and only if $\gcd(g_{1},\ldots,g_{n})=1$. The monographs [1, 27]
are very good references for this and other interesting properties of
numerical semigroups.

A possible way to generalize the notion of numerical semigroup to submonoids
in $\mathbb{N}^{d}$ is to focus on the property of _cofiniteness_. In general,
we say that a set $A$ is _cofinite_ in $B$ if $A\subseteq B$ and $B\setminus
A$ is a finite set. In particular, a numerical semigroup is a cofinite monoid
in $\mathbb{N}$. A straightforward step in this direction is to consider
submonoids $S$ of $\mathbb{N}^{d}$ such that $\mathbb{N}^{d}\setminus S$ is
finite. This kind of monoids have been introduced in [11], where they are
called _generalized numerical semigroups_. The study of the properties of
these monoids is still an active area of research (for some recent works, see
for instance [2, 18]). A more general situation is considered in [13], where
the authors introduce the class of monoids $S$ such that
$\mathcal{C}_{S}\setminus S$ is finite. A monoid $S$ of such a family is
called a $\mathcal{C}_{S}$-_semigroup_. In particular, a generalized numerical
semigroup is a $\mathcal{C}_{S}$-semigroup such that
$\mathcal{C}_{S}=\mathbb{N}^{d}$. Some recent results on
$\mathcal{C}$-semigroups are contained, for instance, in [3, 15]. It is known
that if $S$ is a $\mathcal{C}_{S}$-semigroup, then $S$ is finitely generated
(so, the same occurs when $S$ is a generalized numerical semigroup), that is,
the mentioned families of submonoids of $\mathbb{N}^{d}$ are classes of affine
semigroups.

A natural problem is to consider a set $A\subseteq\mathbb{N}^{d}$ and
characterize when the set $S=\langle A\rangle$ is a
$\mathcal{C}_{S}$-semigroup. A result of this type has been provided firstly
in [6, Theorem 2.8] for generalized numerical semigroups and later in [10,
Theorem 9] for the general case of $\mathcal{C}_{S}$-semigroups. Having in
mind these results, in this paper we consider a further generalization for the
property of cofiniteness of an affine semigroup $S\subseteq\mathbb{N}^{d}$,
considering the case $S$ is cofinite in another affine semigroup
$\mathcal{C}\subseteq\mathbb{N}^{d}$. In particular, in the main result of
this work, we provide a characterization for an affine semigroup
$S\subseteq\mathbb{N}^{d}$ to be cofinite in an affine semigroup
$\mathcal{C}\subseteq\mathbb{N}^{d}$, in terms of the generators of
$\mathcal{C}$. We call this kind of monoids $\mathcal{C}$-cofinite. We provide
such a result in Section 1, together with a procedure and computational tools
to check whether an affine semigroup is $\mathcal{C}$-cofinite for a fixed
affine monoid $\mathcal{C}$ and, if so, to compute the set
$\mathcal{C}\setminus S$.

As a consequence of the previous result, we obtain a characterization for an
ideal of an affine semigroup to be cofinite in it. Recall that, if $S$ is an
affine semigroup, an ideal $I$ of $S$ is a subset $I\subseteq S$ such that
$I+S\subseteq I$ (in general, for $X,Y\subseteq\mathbb{N}^{d}$, set
$X+Y=\\{\mathbf{x}+\mathbf{y}\mid\mathbf{x}\in X,\mathbf{y}\in Y\\}$). In
Section 2 we give such a characterization so that $S\setminus I$ is finite.
Furthermore, for a given affine semigroup $S$ and an ideal $I$ of it, we
provide two different approaches in order to check whether $S\setminus I$ is
finite and, if so, to compute its elements: the first one uses similar
procedures to those suggested for $\mathcal{C}$-cofinite submonoids, the
second one uses tools from commutative algebra. Finally, we conclude with some
remarks about a relation of this subject with the _Apéry set_ of a subset of
an affine semigroup.

##  1\. Cofinite submonoids of an affine semigroup

The first aim of this section is to provide a characterization, for a
submonoid $S$ of an affine semigroup $\mathcal{C}$, to have finite complement
in it. After giving a definition for this kind of monoids and showing that
they are also affine semigroups, we introduce some useful tools to prove the
mentioned characterization.

######  Definition 1.

Let $\mathcal{C}\subseteq\mathbb{N}^{d}$ be an affine semigroup. A submonoid
$S$ of $\mathcal{C}$ is called $\mathcal{C}$-cofinite if the set
$\mathcal{C}\setminus S$ is finite.

For the next result, we recall that a _term order_ $\preceq$ (or _monomial
order_) on $\mathbb{N}^{d}$ is a total order such that
$\mathbf{0}\preceq\mathbf{v}$ for all $\mathbf{v}\in\mathbb{N}^{d}$ and if
$\mathbf{v}\preceq\mathbf{w}$, then the inequality
$\mathbf{v}+\mathbf{u}\preceq\mathbf{w}+\mathbf{u}$ holds for all
$\mathbf{u}\in\mathbb{N}^{d}$ (see Chapter 2, §2 of [8] also for some concrete
examples of term orders). We use the notation $\mathbf{v}\prec\mathbf{w}$ for
$\mathbf{v}\preceq\mathbf{w}$ and $\mathbf{v}\neq\mathbf{w}$.

######  Proposition 1.

Let $\mathcal{C}\subseteq\mathbb{N}^{d}$ be an affine semigroup and
$S\subseteq\mathcal{C}$ be a $\mathcal{C}$-cofinite submnoid. Then $S$ is
finitely generated.

###### Proof.

Let $\mathcal{C}\setminus
S=\\{\mathbf{h}_{1}\prec\cdots\prec\mathbf{h}_{r}\\}$ for some term order
$\preceq$, with
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle$.
We show that $\mathbf{h}_{1}$ is a minimal generator of $\mathcal{C}$. In
fact, suppose $\mathbf{h}_{1}=\mathbf{a}+\mathbf{b}$ with
$\mathbf{a},\mathbf{b}\in\mathcal{C}\setminus\\{\mathbf{0}\\}$. In particular,
$\mathbf{h}_{1}\neq\mathbf{a}$ and $\mathbf{h}_{1}\neq\mathbf{b}$. If
$\mathbf{h}_{1}\prec\mathbf{a}$, then
$\mathbf{h}_{1}\prec\mathbf{h}_{1}+\mathbf{b}\prec\mathbf{a}+\mathbf{b}$,
which contradicts $\mathbf{h}_{1}=\mathbf{a}+\mathbf{b}$. Hence,
$\mathbf{a}\prec\mathbf{h}_{1}$ and by a similar argument,
$\mathbf{b}\prec\mathbf{h}_{1}$. As a consequence, by the minimality of
$\mathbf{h}_{1}$ we have $\mathbf{a},\mathbf{b}\in S$, obtaining
$\mathbf{h}_{1}\in S$, a contradiction. So, $\mathbf{h}_{1}$ is a minimal
generator of $\mathcal{C}$ and we can suppose $\mathbf{h}_{1}=\mathbf{g}_{1}$.
We can argue that
$\mathcal{C}\setminus\\{\mathbf{h}_{1}\\}=\langle\mathbf{g}_{2},\ldots,\mathbf{g}_{n},\mathbf{g}_{2}+\mathbf{h}_{1},\ldots,\mathbf{g}_{n}+\mathbf{h}_{1},2\mathbf{h}_{1},3\mathbf{h}_{1}\rangle$.
We can use the same argument to show that $\mathbf{h}_{2}$ is a minimal
generator of $\mathcal{C}\setminus\\{\mathbf{h}_{1}\\}$ and so on, until we
provide a finite set of generators of
$\mathcal{C}\setminus\\{\mathbf{h}_{1},\ldots,\mathbf{h}_{r}\\}$. ∎

Let
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup. Denote by $\mathbf{e}_{1},\ldots,\mathbf{e}_{n}$ the
standard basis vectors of the vector space $\mathbb{R}^{n}$; in particular,
$\mathbb{N}^{n}=\langle\mathbf{e}_{1},\ldots,\mathbf{e}_{n}\rangle$ as a
monoid. We consider the following map:

$f_{\mathcal{C}}:\mathbb{N}^{n}\longrightarrow\mathcal{C},\qquad\sum_{i=1}^{n}a_{i}\mathbf{e}_{i}\longmapsto\sum_{i=1}^{n}a_{i}\mathbf{g}_{i}.$

Then, $f_{\mathcal{C}}$ is a monoid epimorphism. Observe that if
$\mathbf{a}\in\mathcal{C}$, then $f^{-1}_{\mathcal{C}}(\mathbf{a})$ is the set
of factorizations of $\mathbf{a}$ as combination of vectors in the set
$\\{\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\\}$.

######  Lemma 2.

Let
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup. Suppose $S$ is a submonoid of $\mathcal{C}$. Then

  1. (1)

$\mathcal{C}\setminus S$ is a finite set if and only if
$\mathbb{N}^{n}\setminus f_{\mathcal{C}}^{-1}(S)$ is a finite set.

  2. (2)

$\mathcal{C}\setminus
S=\\{f_{\mathcal{C}}(\mathbf{h})\mid\mathbf{h}\in\mathbb{N}^{n}\setminus
f_{\mathcal{C}}^{-1}(S)\\}$.

###### Proof.

Denote $T=f_{\mathcal{C}}^{-1}(S)$. Observe that $T$ is a submonoid of
$\mathbb{N}^{n}$. Moreover, since $f_{\mathcal{C}}$ is a surjective function,
we have $\mathbb{N}^{n}\setminus T=f_{\mathcal{C}}^{-1}(\mathcal{C})\setminus
f_{\mathcal{C}}^{-1}(S)=f_{\mathcal{C}}^{-1}(\mathcal{C}\setminus S)$. From
this equality, we easily obtain that $|\mathcal{C}\setminus
S|\leq|\mathbb{N}^{n}\setminus T|$. Therefore, if $T$ is
$\mathbb{N}^{n}$-cofinite, then $\mathcal{C}\setminus S$ is a finite set.
Moreover, for all $\mathbf{x}\in\mathcal{C}$, the set
$f_{\mathcal{C}}^{-1}(\mathbf{x})=\\{\mathbf{h}\in\mathbb{N}^{n}\mid
f_{\mathcal{C}}(\mathbf{h})=\mathbf{x}\\}$ is finite. In fact, each element of
an affine semigroup has a finite number of factorizations. In particular, if
$\mathcal{C}\setminus S$ is finite, then $\mathbb{N}^{n}\setminus
T=\bigcup_{\mathbf{x}\in\mathcal{C}\setminus
S}f_{\mathcal{C}}^{-1}(\mathbf{x})$ is finite. So, claim (1) is proved.
Furthermore, by $\mathbb{N}^{n}\setminus
T=f_{\mathcal{C}}^{-1}(\mathcal{C}\setminus S)$, since $f_{\mathcal{C}}$ is
surjective, we have $f_{\mathcal{C}}(\mathbb{N}\setminus
T)=f_{\mathcal{C}}(f_{\mathcal{C}}^{-1}(\mathcal{C}\setminus
S))=\mathcal{C}\setminus S$. In particular, we obtain claim (2). ∎

We remind that a characterization for a submonoid $T\subseteq\mathbb{N}^{n}$
to be $\mathbb{N}^{n}$-cofinite is provided in [6, Theorem 2.8]. For
completeness, we state the result here, since it will be useful later.

######  Theorem 3 ([6]).

Let $A\subseteq\mathbb{N}^{n}$. Then $\langle A\rangle$ is
$\mathbb{N}^{n}$-cofinite if and only if the set $A$ fulfills each one of the
following conditions:

  1. (1)

For all $i\in\\{1,\ldots,n\\}$ there exist
$a_{1}^{(i)}\mathbf{e}_{i},a_{2}^{(i)}\mathbf{e}_{i},\ldots,a_{s_{i}}^{(i)}\mathbf{e}_{i}\in
A$, with $s_{i}\in\mathbb{N}\setminus\\{0\\}$,
$a_{j}^{(i)}\in\mathbb{N}\setminus\\{0\\}$, such that
$\gcd(a_{1}^{(i)},a_{2}^{(i)},\ldots,a_{s_{i}}^{(i)})=1$.

  2. (2)

For each $i,j\in\\{1,\ldots,n\\}$, with $i\neq j$, there exists
$n_{i}^{(j)}\in\mathbb{N}$ such that
$\mathbf{e}_{i}+n_{i}^{(j)}\mathbf{e}_{j}\in A$.

Next, we provide the mentioned characterization for a submonoid
$S\subseteq\mathcal{C}$ to be $\mathcal{C}$-cofinite.

######  Theorem 4.

Let
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup and $S\subseteq\mathcal{C}$ be a submonoid. Then $S$ is
$\mathcal{C}$-cofinite if and only if the following two conditions are
verified:

  1. (1)

For all $i\in\\{1,\ldots,n\\}$, the set
$S_{i}=\\{\lambda\in\mathbb{N}\mid\lambda\mathbf{g}_{i}\in S\\}$ is a
numerical semigroup.

  2. (2)

For each $i,j\in\\{1,\ldots,n\\}$, with $i\neq j$, there exists
$n_{i}^{(j)}\in\mathbb{N}$ such that
$\mathbf{g}_{i}+n_{i}^{(j)}\mathbf{g}_{j}\in S$.

###### Proof.

_Necessity_. It is not difficult to see that the set $S_{i}$ is a monoid for
all $i\in\\{1,\ldots,n\\}$. If the first condition is not verified, then there
exists $i$ such that the set
$\\{\lambda\in\mathbb{N}\mid\lambda\mathbf{g}_{i}\notin
S\\}\subseteq\mathcal{C}\setminus S$ is not finite. If the second condition is
not verified, then for some $i,j$, with $i\neq j$, we have that
$\mathbf{g}_{i}+\mu\mathbf{g}_{j}\notin S$ for all $\mu\in\mathbb{N}$.

_Sufficiency_. We assume that
$S_{i}=\langle\lambda_{1}^{(i)},\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)}\rangle$
is a numerical semigroup for all $i\in\\{1,\ldots,n\\}$. In particular,
$\langle\lambda_{1}^{(i)}\mathbf{g}_{i},\lambda_{2}^{(i)}\mathbf{g}_{i},\ldots,\lambda_{s_{i}}^{(i)}\mathbf{g}_{i}\rangle\subseteq
S$ and
$\gcd(\lambda_{1}^{(i)},\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)})=1$,
for each $i\in\\{1,\ldots,n\\}$. Moreover, for all $i,j\in\\{1,\ldots,n\\}$,
with $i\neq j$, we can consider
$n_{i}^{(j)}=\min\\{n\in\mathbb{N}\mid\mathbf{g}_{i}+n\mathbf{g}_{j}\in S\\}$.
For each $i\in\\{1,\ldots,n\\}$, we set
$G_{i}=\\{\lambda_{1}^{(i)}\mathbf{e}_{i},\lambda_{2}^{(i)}\mathbf{e}_{i},\ldots,\lambda_{s_{i}}^{(i)}\mathbf{e}_{i}\\}\subseteq\mathbb{N}^{n}$.
Let
$\mathcal{G}=\left(\cup_{i=1}^{n}G_{i}\right)\cup\\{\mathbf{e}_{i}+n_{i}^{(j)}\mathbf{e}_{j}\mid
i\neq j\\}\subseteq\mathbb{N}^{n}$. The set $\mathcal{G}$ satisfies the
conditions of Theorem 3, so $\langle\mathcal{G}\rangle$ is
$\mathbb{N}^{n}$-cofinite. Consider the monoid
$T=f_{\mathcal{C}}^{-1}(S)\subseteq\mathbb{N}^{n}$. Observe that, if
$\mathbf{x}\in\mathcal{G}$, then $f_{\mathcal{C}}(\mathbf{x})\in S$, that is,
$\mathcal{G}\subseteq T$. In particular, $\langle\mathcal{G}\rangle\subseteq
T$ and, as a consequence, $\mathbb{N}^{n}\setminus
T\subseteq\mathbb{N}^{n}\setminus\langle\mathcal{G}\rangle$. Therefore, $T$ is
$\mathbb{N}^{n}$-cofinite and, by Lemma 2, $\mathcal{C}\setminus S$ is finite.
∎

Let $S$ and $\mathcal{C}$ be affine semigroups, $S\subseteq\mathcal{C}$. We
recall that for $\mathcal{C}=\mathcal{C}_{S}$ a characterization so that
$|\mathcal{C}_{S}\setminus S|<\infty$ has been provided in [10, Theorem 9] and
in the same paper the authors provide a procedure to compute
$\mathcal{C}_{S}\setminus S$.

Theorem 4, in this form, can be viewed as a generalization of Theorem 3. The
main difference is the following: in the case $\mathcal{C}=\mathbb{N}^{d}$
(and the same can be trivially considered in the case
$\mathcal{C}\cong\mathbb{N}^{r}$ for some positive integer $r$) the elements
satisfying the two conditions of Theorem 3 belong to every set of generators
of $S$. In particular, they belong to the minimal set of generators of $S$. In
the case $\mathcal{C}\subsetneq\mathbb{N}^{d}$ (and
$\mathcal{C}\ncong\mathbb{N}^{r}$ for all positive integer $r$) instead we
have to look for these elements in the whole semigroup $S$. It is not
possible, in general, to consider only a set of the generators of $S$: see,
for instance, Example 5 and Example 7 below, where the elements
$3\mathbf{g}_{1},\mathbf{g}_{1}+2\mathbf{g}_{3}$ belong to $S$ but they do not
belong to its set of minimal generators.

Now, we want to suggest a possible way to verify computationally the two
conditions of Theorem 4. We assume
$\mathcal{C}=\langle\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\rangle$ and suppose
$S=\langle\mathbf{n}_{1},\mathbf{n}_{2},\ldots,\mathbf{n}_{t}\rangle$. So, we
focus on the following:

  1. (1)

For all $i\in\\{1,\ldots,n\\}$, the set
$S_{i}=\\{\lambda\in\mathbb{N}\mid\lambda\mathbf{g}_{i}\in S\\}$ is a
numerical semigroup.

  2. (2)

For each $i,j\in\\{1,\ldots,n\\}$, $i\neq j$, there exists
$n_{i}^{(j)}\in\mathbb{N}$ such that
$\mathbf{g}_{i}+n_{i}^{(j)}\mathbf{g}_{j}\in S$.

Condition (1). Let $i\in\\{1,\ldots,n\\}$. Observe that:

$\\{\lambda\in\mathbb{N}\mid\lambda\textbf{g}_{i}\in
S\\}=\left\\{\lambda\in\mathbb{N}\mid\sum_{j=1}^{t}\lambda_{j}\mathbf{n}_{j}+\lambda(-\textbf{g}_{i})=0,\text{
for some }\lambda_{1},\ldots,\lambda_{n}\in\mathbb{N}\right\\}.$

Let
$A^{(i)}=[\mathbf{n}_{1},\mathbf{n}_{2},\ldots,\mathbf{n}_{t},-\mathbf{g}_{i}]$
be the matrix whose columns are the elements of the finite set of generators
of $S$ and the column vector related to $-\mathbf{g}_{i}\in\mathbb{Z}^{d}$. So
$A^{(i)}$ has $t+1$ columns and entries in $\mathbb{Z}$. We identify every
element $\textbf{x}\in\mathbb{N}^{t+1}$ with its column vector and consider
the diophantine linear system $A^{(i)}\mathbf{x}=0$. It is easy to see that:

$\\{\lambda\in\mathbb{N}\mid\lambda\textbf{g}_{i}\in S\\}=\\{x_{t+1}\mid
A^{(i)}\textbf{x}=0\ \ \mbox{with}\
\mathbf{x}=(x_{1},\ldots,x_{t},x_{t+1})\in\ \mathbb{N}^{t+1}\\}.$

Let $M_{i}\subseteq\mathbb{N}^{t+1}$ be the set of non-negative integer
solutions of the homogeneous diophantine linear system $A^{(i)}\mathbf{x}=0$.
It is known that $M_{i}$ is an affine semigroup in $\mathbb{N}^{t+1}$ (see for
instance [23, Section 1]), so there exists a finite set
$B_{i}\subseteq\mathbb{N}^{t+1}$, such that $M_{i}=\langle B_{i}\rangle$.
Hence,
$S_{i}=\langle\\{x_{t+1}\in\mathbb{N}\mid(x_{1},\ldots,x_{t},x_{t+1})\in
B_{i}\\}\rangle$. It is possible to perform these computations in the computer
algebra software GAP ([12]) with the package numericalsgps ([9]). It is
recommended to use also the package NormalizInterface (that is an interface in
GAP for the software Normaliz, see [5, 20]), in order to speed up the
computation time.

######  Example 5.

Consider the affine semigroups
$\mathcal{C}=\langle(1,1),(1,2),(2,1),(3,1)\rangle$ and
$S=\mathcal{C}\setminus\\{(1,1),(3,2),(2,3)\\}=\langle(1,2),(2,1),(2,2),(3,1),(3,5)\rangle$.
Let us compute a finite set of generators of
$S_{1}=\\{\lambda\in\mathbb{N}\mid\lambda\textbf{g}_{1}\in S\\}$, where
$\mathbf{g}_{1}=(1,1)$. We need to find the non-negative integer solutions of
the linear diophantine system $A\mathbf{x}=0$, where $A$ has column vectors
$(1,2),(2,1),(2,2),(3,1),(3,5),(-1,-1)$.

    gap> LoadPackage("num");;
    gap> NumSgpsUseNormaliz();;
    gap> A:=[[1,2],[2,1],[2,2],[3,1],[3,5],[-1,-1]];;
    gap> n:=Length(A);;
    gap> A:=TransposedMat(A);
    [ [ 1, 2, 2, 3, 3, -1 ], [ 2, 1, 2, 1, 5, -1 ] ]
    gap> sol:=HilbertBasisOfSystemOfHomogeneousEquations(A,[]);
    [ [ 0, 0, 0, 1, 1, 6 ], [ 0, 0, 1, 0, 0, 2 ], [ 0, 2, 0, 0, 1, 7 ],
      [ 1, 1, 0, 0, 0, 3 ], [ 2, 0, 0, 1, 0, 5 ] ]
    gap> B:=List(sol,i->i[n]);
    [ 6, 2, 7, 3, 5 ]
    gap> Gcd(B);
    1
    gap> MinimalGenerators(NumericalSemigroup(B));
    [ 2, 3 ]

Therefore, the previous computations allow to check that $S_{1}=\langle
2,3\rangle$.

In order to verify the first condition of Theorem 4 for elements related to an
extreme ray $\mathbf{g}$ of $\mathcal{C}$ having greatest common divisor of
its coordinates equals to $1$, it suffices an easier check on a finite set of
generators of $S$, as stated by the following result.

######  Proposition 6.

Let
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{r},\mathbf{g}_{r+1},\mathbf{g}_{r+2},\ldots,\mathbf{g}_{r+m}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup such that
$\operatorname{cone}(\mathcal{C})=\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\})$.
Assume that
$\mathbf{g}_{i}\notin\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}\setminus\\{\mathbf{g}_{i}\\})$
for some $i\in\\{1,\ldots,r\\}$ and that the greatest common divisor of the
coordinates of $\mathbf{g}_{i}$ is $1$. Suppose $S\subseteq\mathcal{C}$ is a
submonoid and denote by $A$ the minimal set of generators of $S$. Consider the
monoid $S_{i}=\\{\lambda\in\mathbb{N}\mid\lambda\mathbf{g}_{i}\in
S\\}\subseteq\mathbb{N}$ and let
$\\{\lambda_{1}^{(i)},\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)}\\}$ be
the minimal set of generators of $S_{i}$. Then
$\\{\lambda_{1}^{(i)}\mathbf{g}_{i},\lambda_{2}^{(i)}\mathbf{g}_{i},\ldots,\lambda_{s_{i}}^{(i)}\mathbf{g}_{i}\\}\subseteq
A$.

###### Proof.

Let $\ell\in\\{1,\ldots,s_{i}\\}$. We want to prove that
$\lambda_{\ell}^{(i)}\mathbf{g}_{i}\in A$. First of all, observe that if
$\lambda_{\ell}^{(i)}\mathbf{g}_{i}=\sum_{j=1}^{r}\beta_{j}\mathbf{g}_{j}$
with $\beta_{j}\in\mathbb{Q}_{\geq 0}$, then $\beta_{j}=0$ for all $j\neq i$.
In fact, if there exists $k\in\\{1,\ldots,r\\}\setminus\\{i\\}$ such that
$\beta_{k}\neq 0$, then $\beta_{i}<\lambda_{\ell}^{(i)}$. In particular,
$(\lambda_{\ell}^{(i)}-\beta_{i})\mathbf{g}_{i}=\sum_{j=1,j\neq
i}^{r}\beta_{j}\mathbf{g}_{j}$, from which we easily obtain that
$\mathbf{g}_{i}\in\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\}\setminus\\{\mathbf{g}_{i}\\})$,
a contradiction. So, the only possibility is $\beta_{i}=\lambda$ and
$\beta_{j}=0$ for all $j\in\\{1,\ldots,r\\}\setminus\\{i\\}$.
We know that $\lambda_{\ell}^{(i)}\mathbf{g}_{i}\in\langle A\rangle=S$ and
suppose that $\lambda_{\ell}^{(i)}\mathbf{g}_{i}\notin A$. Hence,
$\lambda_{\ell}^{(i)}\mathbf{g}_{i}=\sum_{\mathbf{a}\in
A}\mu_{\mathbf{a}}\mathbf{a}$ for some $\mu_{\mathbf{a}}\in\mathbb{N}$ such
that $\sum_{\mathbf{a}\in A}\mu_{\mathbf{a}}>1$. For every $\mathbf{a}\in A$,
we have $\mathbf{a}\in\mathcal{C}$. In particular,
$\mathbf{a}\in\operatorname{cone}(\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{r}\\})$.
For $\mathbf{a}\in A$, assume
$\mathbf{a}=\sum_{j=1}^{r}\gamma_{(\mathbf{a},j)}\mathbf{g}_{j}$ with
$\gamma_{(\mathbf{a},j)}\in\mathbb{Q}_{\geq 0}$ for each
$j\in\\{1,\ldots,r\\}$. As a consequence,
$\lambda_{\ell}^{(i)}\mathbf{g}_{i}=\sum_{\mathbf{a}\in
A}\mu_{\mathbf{a}}\mathbf{a}=\sum_{j=1}^{r}(\sum_{\mathbf{a}\in
A}\mu_{\mathbf{a}}\gamma_{(\mathbf{a},j)})\mathbf{g}_{j}$. By the discussion
at the beginning of the proof, we have $\sum_{\mathbf{a}\in
A}\mu_{\mathbf{a}}\gamma_{(\mathbf{a},j)}=0$ for all
$j\in\\{1,\ldots,r\\}\setminus\\{i\\}$. So, for all
$j\in\\{1,\ldots,r\\}\setminus\\{i\\}$, since
$\mu_{\mathbf{a}}\gamma_{(\mathbf{a},j)}\geq 0$, the only possibility is
$\mu_{\mathbf{a}}\gamma_{(\mathbf{a},j)}=0$. In particular, if
$\mu_{\mathbf{a}}\neq 0$ we have $\gamma_{(\mathbf{a},j)}=0$ for all
$j\in\\{1,\ldots,r\\}\setminus\\{i\\}$. Then, for all $\mathbf{a}\in A$ with
$\mu_{\mathbf{a}}\neq 0$, we have
$\mathbf{a}=\gamma_{(\mathbf{a},i)}\mathbf{g}_{i}$ for some
$\gamma_{(\mathbf{a},i)}\in\mathbb{Q}_{\geq 0}\setminus\\{0\\}$. Since
$\mathbf{g}_{i},\mathbf{a}\in\mathbb{N}^{d}$, the hypothesis that the greatest
common divisor of the coordinates of $\mathbf{g}_{i}$ is $1$ forces
$\gamma_{(\mathbf{a},i)}\in\mathbb{N}\setminus\\{0\\}$. Therefore, for all
$\mathbf{a}\in A$ with $\mu_{\mathbf{a}}\neq 0$, we have
$\gamma_{(\mathbf{a},i)}\in
S_{i}=\langle\lambda_{1}^{(i)},\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)}\rangle$.
Let $\mathbf{b}\in A$ such that $\mu_{\mathbf{b}}\neq 0$, and assume
$\gamma_{(\mathbf{b},i)}=\sum_{j=1}^{s_{i}}\alpha_{j}\lambda_{j}^{(i)}$,
$\alpha_{j}\in\mathbb{N}$. Then we can write
$\lambda_{\ell}^{(i)}\mathbf{g}_{i}=\sum_{\mathbf{a}\in
A,\mathbf{a}\neq\mathbf{b}}\mu_{\mathbf{a}}\mathbf{a}+\mu_{\mathbf{b}}\left(\sum_{j=1,j\neq\ell}^{s_{i}}\alpha_{j}\lambda_{j}^{(i)}\mathbf{g}_{i}\right)+\mu_{\mathbf{b}}\alpha_{\ell}\lambda_{\ell}^{(i)}\mathbf{g}_{i}$.
Since $\mu_{\mathbf{b}}>0$ and $\sum_{\mathbf{a}\in A}\mu_{\mathbf{a}}>1$, the
only possibility is $\alpha_{\ell}=0$. In particular, we can argue that for
all $\mathbf{a}\in A$, with $\mu_{\mathbf{a}}\neq 0$,
$\gamma_{(\mathbf{a},i)}\in\langle\\{\lambda_{1}^{(i)},\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)}\\}\setminus\\{\lambda_{\ell}^{(i)}\\}\rangle$.
As a consequence,
$\lambda_{\ell}^{(i)}\mathbf{g}_{i}\in\langle\\{\gamma_{(\mathbf{a},i)}\mathbf{g}_{i}\mid\mathbf{a}\in
A,\mu_{\mathbf{a}}\neq
0\\}\rangle\subseteq\langle\\{\lambda_{1}^{(i)}\mathbf{g}_{i},\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)}\mathbf{g}_{i}\\}\setminus\\{\lambda_{\ell}^{(i)}\mathbf{g}_{i}\\}\rangle$.
Hence,
$\lambda_{\ell}^{(i)}\in\langle\\{\lambda_{1}^{(i)}\,\lambda_{2}^{(i)},\ldots,\lambda_{s_{i}}^{(i)}\\}\setminus\\{\lambda_{\ell}^{(i)}\\}\rangle$,
but this contradicts the fact that $S_{i}$ is minimally generated by
$\\{\lambda_{1}^{(i)}\mathbf{g}_{i},\lambda_{2}^{(i)}\mathbf{g}_{i},\ldots,\lambda_{s_{i}}^{(i)}\mathbf{g}_{i}\\}$.
So we can conclude $\lambda_{\ell}^{(i)}\mathbf{g}_{i}\in A$. ∎

Condition (2). Firstly observe that, in the outlined framework, for the second
condition of Theorem 4 we can point out that: if $\mathbf{g}_{i}\in S$ for
some $i\in\\{1,\ldots,n\\}$, for what concerns the elements of the form
$\mathbf{g}_{i}+n_{i}^{(j)}\mathbf{g}_{j}$ we can consider $n_{i}^{(j)}=0$ for
all $j\in\\{1,\ldots,n\\}\setminus\\{i\\}$. So, assume $\mathbf{g}_{i}\notin
S$. For $j\in\\{1,\ldots,n\\}\setminus\\{i\\}$, consider that:

$\\{k\in\mathbb{N}\mid\textbf{g}_{i}+k\textbf{g}_{j}\in
S\\}=\left\\{k\in\mathbb{N}\mid\mathbf{g}_{i}=\sum_{j=1}^{t}\lambda_{j}\mathbf{n}_{j}+k(-\textbf{g}_{j}),\text{
for some }\lambda_{1},\ldots,\lambda_{n}\in\mathbb{N}\right\\}.$

So, in this case, we need to find all non-negative integer factorizations of
$\mathbf{g}_{i}$ in the monoid
$\langle\mathbf{n}_{1},\ldots,\mathbf{n}_{t},-\mathbf{g}_{j}\rangle\subseteq\mathbb{Z}^{t+1}$
and take, for each factorization, the coefficient of $-\mathbf{g}_{j}$. In
particular, this problem is related to find the non-negative integer solutions
of a non homogeneus diophantine linear system of equations, that is, using the
notation introduced in Condition (1), we have:

$\\{k\in\mathbb{N}\mid\textbf{g}_{i}+k\textbf{g}_{j}\in S\\}=\\{x_{t+1}\mid
A^{(j)}\textbf{x}=\mathbf{g}_{i}\ \ \mbox{with}\
\mathbf{x}=(x_{1},\ldots,x_{t},x_{t+1})\in\ \mathbb{N}^{t+1}\\}.$

Recall that, if $R_{ij}$ is the set of non-negative integer solutions of
$A^{(j)}\textbf{x}=\mathbf{g}_{i}$ and $V_{ij}$ is the set of minimal elements
of $R_{ij}$, with respect to the natural partial order in $\mathbb{N}^{t+1}$,
then the set $V_{ij}$ is finite and $R_{ij}=\bigcup_{\mathbf{y}\in
V_{ij}}(\mathbf{y}+M_{j})$, where $M_{j}$ is the set of non-negative integer
solutions of the homogenenus diophantine linear system $A^{(j)}\mathbf{x}=0$
(see for instance [22, Theorem 5.2]). In particular,
$\min\\{k\in\mathbb{N}\mid\textbf{g}_{i}+k\textbf{g}_{j}\in
S\\}=\min\\{x_{t+1}\mid(x_{1},\ldots,x_{t},x_{t+1})\in V_{ij}\\}$. The
following example shows how to perform such a computation with GAP, using
numericalsgps and NormalizInterface.

######  Example 7.

Consider the semigroups $\mathcal{C}$ and $S$ as in Example 5. We focus on the
element such as $\mathbf{g}_{1}+n_{1}^{(3)}\mathbf{g}_{3}$. In order to
compute $\\{k\in\mathbb{N}\mid\textbf{g}_{1}+k\textbf{g}_{3}\in S\\}$, with
$\mathbf{g}_{1}=(1,1)$ and $\mathbf{g}_{3}=(2,1)$, we need to find the minimal
factorizations of $(1,1)$ with respect to the set
$\\{(1,2),(2,1),(2,2),(3,1),(3,5),(-2,-1)\\}$. That is, we need to find the
set $V_{13}$ introduced before.

    gap> LoadPackage("num");;
    gap> NumSgpsUseNormaliz();;
    gap> A:=[[1,2],[2,1],[2,2],[3,1],[3,5],[-2,-1]];;
    gap> n:=Length(A);;
    gap> F:=FactorizationsVectorWRTList([1,1], A);
    [ [ 0, 0, 0, 6, 1, 10 ], [ 0, 0, 1, 1, 0, 2 ], [ 1, 0, 0, 2, 0, 3 ] ]
    gap> List(F,i->i[n]);
    [ 10, 2, 3 ]

The computations above show that
$V_{13}=\\{(0,0,0,6,1,10),(0,0,1,1,0,2),(1,0,0,2,0,3)\\}$. The package manual
of numericalagps explains that, if v is a list of non-negative integers and ls
is a list of lists of non-negative integers, then the function
FactorizationsVectorWRTList( v, ls ) returns the set of factorizations of v in
terms of the elements of ls. Actually, when NormalizInterface is used, that
function works also in the case ls has vectors with negative coordinates. In
fact, by the code of that function, using NormalizInterface, the function
computes exactly the minimal elements (with respect to the natural partial
order) of the set of non-negative integer solutions of the system ls*x=v, in
the case the system admits solutions (each list of integers is considered here
as a column vector). So, in this case,
$\min\\{k\in\mathbb{N}\mid\textbf{g}_{1}+k\textbf{g}_{3}\in S\\}=2$ and we can
consider $n_{1}^{(3)}=2$, that is, $\mathbf{g}_{1}+2\mathbf{g}_{3}\in S$.

Now, we can describe a procedure to check if $\mathcal{C}\setminus S$ is
finite and, if so, to compute its elements. By Lemma 2, a direct way is to
focus on the monoid $f_{\mathcal{C}}^{-1}(S)$. In particular, we start by
finding a set of generators of $f_{\mathcal{C}}^{-1}(S)$.
Assume
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle$
and $S=\langle\mathbf{n}_{1},\mathbf{n}_{2},\ldots,\mathbf{n}_{t}\rangle$.
Observe that an element of the form $\sum_{i=1}^{n}x_{i}\mathbf{e}_{i}$
belongs to $f_{\mathcal{C}}^{-1}(S)$ if and only if there exist
$\lambda_{1},\ldots,\lambda_{t}\in\mathbb{N}$ such that
$\sum_{i=1}^{n}x_{i}\mathbf{g}_{i}=\sum_{j=1}^{t}\lambda_{j}\mathbf{n}_{j}$.
Consider the matrix
$A^{(\mathcal{C},S)}=[\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n},-\mathbf{n}_{1},-\mathbf{n}_{2},\ldots,-\mathbf{n}_{t}]$,
obtained identifying every integer vector with a column vector. Then, the
elements of $f_{\mathcal{C}}^{-1}(S)$ can be obtained from the non-negative
integer solutions of the homogeneous diophantine linear system
$A^{(\mathcal{C},S)}\mathbf{x}=\mathbf{0}$, that is:

$f_{\mathcal{C}}^{-1}(S)=\\{(x_{1},\ldots,x_{n})\in\mathbb{N}^{d}\mid
A^{(\mathcal{C},S)}\mathbf{x}=\mathbf{0}\text{ with
}\mathbf{x}=(x_{1},\ldots,x_{n},x_{n+1},\ldots,x_{n+t})\in\mathbb{N}^{n+t}\\}.$

Let $M_{(\mathcal{C},S)}\subseteq\mathbb{N}^{n+t}$ be the set of non-negative
integer solutions of the homogeneous diophantine linear system
$A^{(\mathcal{C},S)}\mathbf{x}=0$. The set $M_{(\mathcal{C},S)}$ is an affine
semigroup in $\mathbb{N}^{n+t}$ (see [23, Section 1]). So, there exists a
finite set $B_{(\mathcal{C},S)}\subseteq\mathbb{N}^{n+t}$, such that
$M_{(\mathcal{C},S)}=\langle B_{(\mathcal{C},S)}\rangle$. Hence,
$f_{\mathcal{C}}^{-1}(S)=\langle\\{(x_{1},\ldots,x_{n})\in\mathbb{N}^{n}\mid(x_{1},\ldots,x_{n},x_{n+1},\ldots,x_{n+t})\in
B_{(\mathcal{C},S)}\\}\rangle$. These computations can be performed using the
computer algebra software GAP with the packages numericalsgps and
NormalizInterface.
Now, by Lemma 2, we need to check if $\mathbb{N}^{n}\setminus
f_{\mathcal{C}}^{-1}(S)$ is finite and, if so, compute its elements. By the
previous arguments we obtained a finite set $B\subseteq\mathbb{N}^{n}$ such
that $f_{\mathcal{C}}^{-1}(S)=\langle B\rangle$. So, we can test if
$\mathbb{N}^{n}\setminus f_{\mathcal{C}}^{-1}(S)$ is finite by Theorem 3. Once
we check it is finite, in order to compute the set $\mathbb{N}^{n}\setminus
f_{\mathcal{C}}^{-1}(S)$, we can consider the procedure described in [7] (it
can be performed using GAP with the package numericalsgps). Finally, we obtain
the set $\mathcal{C}\setminus S$ considering all elements
$f_{\mathcal{C}}(\mathbf{h})$, for every $\mathbf{h}\in\mathbb{N}^{n}\setminus
f_{\mathcal{C}}^{-1}(S)$.

######  Algorithm 8.

Let
$\mathcal{C}=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup and $S$ a submonoid of $\mathcal{C}$. Suppose that
$S=\langle\mathbf{n}_{1},\mathbf{n}_{2},\ldots,\mathbf{n}_{t}\rangle$. In
order to compute $\mathcal{C}\setminus S$ we can consider the following steps:

  1. (1)

Consider the matrix
$A^{(\mathcal{C},S)}=[\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n},-\mathbf{n}_{1},-\mathbf{n}_{2},\ldots,-\mathbf{n}_{t}]$,
where each element is identified as a column vector.

  2. (2)

Compute a finite set $B_{(\mathcal{C},S)}\subseteq\mathbb{N}^{n+t}$, such that
$\langle B_{(\mathcal{C},S)}\rangle$ is the set of non-negative integer
solutions of the homogeneous diophantine linear system
$A^{(\mathcal{C},S)}\mathbf{x}=0$.

  3. (3)

Set
$B=\\{(x_{1},\ldots,x_{n})\in\mathbb{N}^{n}\mid(x_{1},\ldots,x_{n},x_{n+1},\ldots,x_{n+t})\in
B_{(\mathcal{C},S)}\\}$.

  4. (4)

Check if the set $B$ satisfies the conditions of Theorem 3, that is, check if
$\langle B\rangle$ is $\mathbb{N}^{n}$-cofinite.

  5. (5)

If $\langle B\rangle$ is not $\mathbb{N}^{n}$-cofinite, then $S$ is not
$\mathcal{C}$-cofinite.

  6. (6)

If $\langle B\rangle$ is $\mathbb{N}^{n}$-cofinite, compute
$H=\mathbb{N}^{n}\setminus\langle B\rangle$.

  7. (7)

Compute $\mathcal{C}\setminus
S=\\{f_{\mathcal{C}}(\mathbf{h})\mid\mathbf{h}\in H\\}$.

######  Example 9.

Consider the affine semigroups
$\mathcal{C}=\langle(1,1),(1,2),(2,1),(3,1)\rangle$ and
$S=\mathcal{C}\setminus\\{(1,1),(3,2),(2,3)\\}=\langle(1,2),(2,1),(2,2),(3,1),(3,5)\rangle$
(as in the previous examples). In the following, we show how it is possible to
perform Algorithm 8 using the computer algebra software GAP, with the packages
numericalsgps and NormalizInterface.

    gap> LoadPackage("num");;
    gap> NumSgpsUseNormaliz();;
    gap> C:=[[1,1],[1,2],[2,1],[3,1]];
    gap> n:=Length(C);
    4
    [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 3, 1 ] ]
    gap> S:=[[1,2],[2,1],[2,2],[3,1],[3,5]];
    [ [ 1, 2 ], [ 2, 1 ], [ 2, 2 ], [ 3, 1 ], [ 3, 5 ] ]
    gap> A:=Concatenation(C,-S);
    [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 3, 1 ], [ -1, -2 ], [ -2, -1 ], [ -2, -2 ],
      [ -3, -1 ], [ -3, -5 ] ]
    gap> A:=TransposedMat(A);
    [ [ 1, 1, 2, 3, -1, -2, -2, -3, -3 ], [ 1, 2, 1, 1, -2, -1, -2, -1, -5 ] ]
    gap> gap> sol:=HilbertBasisOfSystemOfHomogeneousEquations(A,[]);
    [ [ 0, 0, 0, 1, 0, 0, 0, 1, 0 ], [ 0, 0, 1, 0, 0, 1, 0, 0, 0 ],
      [ 0, 0, 4, 0, 0, 0, 1, 2, 0 ], [ 0, 0, 5, 0, 1, 0, 0, 3, 0 ],
      [ 0, 0, 12, 0, 0, 0, 0, 7, 1 ], [ 0, 1, 0, 0, 1, 0, 0, 0, 0 ],
      [ 0, 1, 0, 1, 0, 1, 1, 0, 0 ], [ 0, 1, 0, 3, 0, 5, 0, 0, 0 ],
      [ 0, 1, 3, 0, 0, 0, 2, 1, 0 ], [ 0, 1, 7, 0, 0, 0, 0, 4, 1 ],
      [ 0, 2, 2, 0, 0, 0, 0, 1, 1 ], [ 0, 2, 2, 0, 0, 0, 3, 0, 0 ],
      [ 0, 3, 0, 2, 0, 3, 0, 0, 1 ], [ 0, 3, 1, 0, 0, 0, 1, 0, 1 ],
      [ 0, 3, 1, 1, 0, 0, 4, 0, 0 ], [ 0, 4, 0, 1, 0, 0, 2, 0, 1 ],
      [ 0, 4, 0, 2, 0, 0, 5, 0, 0 ], [ 0, 5, 0, 1, 0, 1, 0, 0, 2 ],
      [ 0, 7, 1, 0, 0, 0, 0, 0, 3 ], [ 0, 8, 0, 1, 0, 0, 1, 0, 3 ],
      [ 0, 12, 0, 1, 0, 0, 0, 0, 5 ], [ 1, 0, 0, 1, 0, 2, 0, 0, 0 ],
      [ 1, 0, 2, 0, 0, 0, 1, 1, 0 ], [ 1, 0, 3, 0, 1, 0, 0, 2, 0 ],
      [ 1, 0, 10, 0, 0, 0, 0, 6, 1 ], [ 1, 1, 1, 0, 0, 0, 2, 0, 0 ],
      [ 1, 1, 5, 0, 0, 0, 0, 3, 1 ], [ 1, 2, 0, 0, 0, 0, 0, 0, 1 ],
      [ 1, 2, 0, 1, 0, 0, 3, 0, 0 ], [ 2, 0, 0, 0, 0, 0, 1, 0, 0 ],
      [ 2, 0, 1, 0, 1, 0, 0, 1, 0 ], [ 2, 0, 8, 0, 0, 0, 0, 5, 1 ],
      [ 2, 1, 3, 0, 0, 0, 0, 2, 1 ], [ 3, 0, 0, 0, 1, 1, 0, 0, 0 ],
      [ 3, 0, 6, 0, 0, 0, 0, 4, 1 ], [ 3, 1, 1, 0, 0, 0, 0, 1, 1 ],
      [ 4, 0, 4, 0, 0, 0, 0, 3, 1 ], [ 4, 1, 0, 0, 0, 1, 0, 0, 1 ],
      [ 5, 0, 0, 0, 2, 0, 0, 1, 0 ], [ 5, 0, 2, 0, 0, 0, 0, 2, 1 ],
      [ 6, 0, 0, 0, 0, 0, 0, 1, 1 ], [ 7, 0, 0, 0, 0, 2, 0, 0, 1 ] ]
    gap> B:=List(sol,i->i{[1..n]});
    [ [ 0, 0, 0, 1 ], [ 0, 0, 1, 0 ], [ 0, 0, 4, 0 ], [ 0, 0, 5, 0 ],
      [ 0, 0, 12, 0 ], [ 0, 1, 0, 0 ], [ 0, 1, 0, 1 ], [ 0, 1, 0, 3 ],
      [ 0, 1, 3, 0 ], [ 0, 1, 7, 0 ], [ 0, 2, 2, 0 ], [ 0, 2, 2, 0 ],
      [ 0, 3, 0, 2 ], [ 0, 3, 1, 0 ], [ 0, 3, 1, 1 ], [ 0, 4, 0, 1 ],
      [ 0, 4, 0, 2 ], [ 0, 5, 0, 1 ], [ 0, 7, 1, 0 ], [ 0, 8, 0, 1 ],
      [ 0, 12, 0, 1 ], [ 1, 0, 0, 1 ], [ 1, 0, 2, 0 ], [ 1, 0, 3, 0 ],
      [ 1, 0, 10, 0 ], [ 1, 1, 1, 0 ], [ 1, 1, 5, 0 ], [ 1, 2, 0, 0 ],
      [ 1, 2, 0, 1 ], [ 2, 0, 0, 0 ], [ 2, 0, 1, 0 ], [ 2, 0, 8, 0 ],
      [ 2, 1, 3, 0 ], [ 3, 0, 0, 0 ], [ 3, 0, 6, 0 ], [ 3, 1, 1, 0 ],
      [ 4, 0, 4, 0 ], [ 4, 1, 0, 0 ], [ 5, 0, 0, 0 ], [ 5, 0, 2, 0 ],
      [ 6, 0, 0, 0 ], [ 7, 0, 0, 0 ] ]
    gap> T:=AffineSemigroup(B);
    <Affine semigroup in 4 dimensional space, with 41 generators>
    gap> MinimalGenerators(T);
    [ [ 0, 0, 0, 1 ], [ 0, 0, 1, 0 ], [ 0, 1, 0, 0 ], [ 1, 0, 0, 1 ],
      [ 1, 0, 2, 0 ], [ 1, 1, 1, 0 ], [ 1, 2, 0, 0 ], [ 2, 0, 0, 0 ],
      [ 3, 0, 0, 0 ] ]
    gap> H:=Gaps(T);
    [ [ 1, 0, 0, 0 ], [ 1, 0, 1, 0 ], [ 1, 1, 0, 0 ] ]
    gap> Set(List(H,i->i*C));
    [ [ 1, 1 ], [ 2, 3 ], [ 3, 2 ] ]

Therefore, the previous computations show that
$B_{(\mathcal{C},S)}$={(0,0,0,1),(0,0,1,0),(0,1,0,0),(1,0,0,1),
(1,0,2,0),(1,1,1,0),(1,2,0,0),(2,0,0,0),(3,0,0,0)}, $\mathbb{N}^{n}\setminus
f_{\mathcal{C}}^{-1}(S)=\\{(1,0,0,0),(1,0,1,0),(1,1,0,0)\\}$ and
$\mathcal{C}\setminus S=\\{(1,1),(2,3),(3,2)\\}$.

##  2\. Cofinite ideals of an affine semigroup

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup. A set $I$ is an _ideal_
of $S$ if $I\subseteq S$ and $I+S\subseteq I$. Every ideal $I$ can be
expressed as $I=X+S$, where $X=\operatorname{Minimals}_{\leq_{S}}(I)$ and
$\leq_{S}$ is the partial order in $\mathbb{N}^{d}$ defined by
$\mathbf{x}\leq_{S}\mathbf{y}$ if $\mathbf{y}-\mathbf{x}\in S$. In particular,
the set $X$ is called a set of generators of $I$. Furthermore the set $X$ is
finite (see for instance [16, Proposition 2.7.4]), that is, every ideal of an
affine semigroup is _finitely generated_. We simply denote by $\leq$ the order
$\leq_{\mathbb{N}^{n}}$, that is, the natural partial order in
$\mathbb{N}^{n}$, $n$ any positive integer.

Theorem 4 can be used to characterize when $S\setminus I$ is finite, obtaining
the following result.

######  Theorem 10.

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup generated by
$\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\\}$ and $I$ be an ideal of $S$. Then
$S\setminus I$ is a finite set if and only if for all $i\in\\{1,\ldots,n\\}$
there exists $k_{i}\in\mathbb{N}\setminus\\{0\\}$ such that
$k_{i}\mathbf{g}_{i}\in I$.

###### Proof.

Observe that $I\cup\\{\mathbf{0}\\}$ is a submonoid of $S$, so we can use
Theorem 4.

_Necessity._ If $S\setminus I$ is finite, from condition $(1)$ of Theorem 4 we
have that the set $\\{\lambda\in\mathbb{N}\mid\lambda\mathbf{g}_{i}\in I\\}$
is a numerical semigroup for all $i\in\\{1,\ldots,n\\}$, in particular this
set contains nonzero integers. So, for all $i\in\\{1,\ldots,n\\}$ there exists
$k_{i}\in\mathbb{N}\setminus\\{0\\}$ such that $k_{i}\mathbf{g}_{i}\in I$.

_Sufficiency._ Suppose that for all $i\in\\{1,\ldots,n\\}$ there exists
$k_{i}\in\mathbb{N}\setminus\\{0\\}$ such that $k_{i}\mathbf{g}_{i}\in I$. It
suffices to check that $I\cup\\{\mathbf{0}\\}$ satisfies both the conditions
of Theorem 4. Since $k_{i}\mathbf{g}_{i}\in I$ we obtain
$k_{i}\mathbf{g}_{i}+\lambda\mathbf{g}_{i}\in I$ for all
$\lambda\in\mathbb{N}$, in particular
$\\{\lambda\in\mathbb{N}\mid\lambda\mathbf{g}_{i}\in
I\\}\supseteq\mathbb{N}\setminus\\{1,\ldots,k_{i}-1\\}$, that is, the first
condition is satisfied. The second condition holds trivially by the definition
of ideal, since for all $i,j\in\\{1,\ldots,n\\}$, with $i\neq j$, we have
$\mathbf{g}_{i}+k_{j}\mathbf{g}_{j}\in I$. ∎

######  Algorithm 11.

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup generated by
$\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\\}$ and $I$ be an ideal of $S$, such
that $S\setminus I$ is a finite set. Then, it is possible to compute the set
$S\setminus I$ by the following two steps:

  1. (1)

For all $i\in\\{1,\ldots,n\\}$ compute $k_{i}=\min\\{k\in\mathbb{N}\mid
k\mathbf{g}_{i}\in I\\}$. If for some $i\in\\{1,\ldots,n\\}$ we have
$\\{k\in\mathbb{N}\mid k\mathbf{g}_{i}\in I\\}=\emptyset$, then $S\setminus I$
is not finite.

  2. (2)

Let
$P=\\{(\lambda_{1},\ldots,\lambda_{n})\in\mathbb{N}^{n}\mid\lambda_{i}<k_{i}\
\mbox{for all}\ i\in\\{1,\ldots,n\\}\\}$ (observe that $P$ is a finite set).
Then

$S\setminus I=\left\\{\sum_{i=1}^{n}\lambda_{i}\mathbf{g}_{i}\notin
I\mid(\lambda_{1},\ldots,\lambda_{n})\in P\right\\}.$

######  Remark 12.

Observe that for step (1) of Algorithm 11 it would suffice to find
$k_{i}\in\\{k\in\mathbb{N}\mid k\mathbf{g}_{i}\in I\\}$, not necessarily being
the minimum. But it is better to find $k_{i}$ as the minimum in order to have
$P$ with smallest possible cardinality.

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup generated by
$\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\\}$, $I$ be an ideal of $S$ and
assume $I=X+S$ with $X=\\{\mathbf{u}_{1},\ldots,\mathbf{u}_{r}\\}\subset S$.
For $i\in\\{1\,\ldots,n\\}$, in order to compute the integer
$k_{i}=\min\\{k\in\mathbb{N}\mid k\mathbf{g}_{i}\in I\\}$, or to test if it
exists, consider that: for $k\in\mathbb{N}$, then $k\mathbf{g}_{i}\in I$ if
and only if there exists $j\in\\{1,\ldots,r\\}$ such that
$k\mathbf{g}_{i}=x_{j}+\sum_{l=1}^{n}\lambda_{l}\mathbf{g}_{l}$ with
$\lambda_{l}\in\mathbb{N}$ for each $l\in\\{1,\ldots,n\\}$. Equivalently,
$-\mathbf{u}_{j}=\sum_{l=1,l\neq
i}\lambda_{l}\mathbf{g}_{l}+k(-\mathbf{g}_{i})$. So, in this case, we need to
find all non-negative integer factorizations of $-\mathbf{u}_{j}$ in the
monoid
$\langle\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\\}\setminus\\{\mathbf{g}_{i}\\}\cup\\{-\mathbf{g}_{i}\\}\rangle\subseteq\mathbb{Z}^{n}$
and take, for each factorization, the coefficient of $-\mathbf{g}_{i}$. This
computation can be performed by GAP as in Example 7. Moreover, the package
numericalsgps also contains many routines to deal with ideals of an affine
semigroup. For instance, it is possible to test if an integer vector belongs
to an ideal or not.

To test if $S\setminus I$ is finite and, if so, to compute it, we can also
consider the map $f_{S}:\mathbb{N}^{n}\longrightarrow S$ introduced in Section
1, as explained in the next result.

######  Proposition 13.

Let
$S=\langle\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup and $I$ an ideal of $S$. Then, the set $f_{S}^{-1}(I)$
is an ideal of $\mathbb{N}^{n}$ and the following hold:

  1. (1)

$S\setminus I$ is finite if and only if $\mathbb{N}^{n}\setminus
f_{S}^{-1}(I)$ is finite.

  2. (2)

$S\setminus I=\\{f_{S}(\mathbf{x})\mid\mathbf{x}\in\mathbb{N}^{n}\setminus
f_{S}^{-1}(I)\\}$.

###### Proof.

It is not difficult to see that $f_{S}^{-1}(I)$ is an ideal of
$\mathbb{N}^{n}$. Moreover, since $f_{S}$ is a surjective function, we have
$\mathbb{N}^{n}\setminus f_{S}^{-1}(I)=f_{S}^{-1}(S)\setminus
f_{S}^{-1}(I)=f_{S}^{-1}(S\setminus I)$. Therefore, claims (1) and (2) can be
proved using the same arguments of Lemma 2. ∎

Denote $\operatorname{M}(I)=\operatorname{Minimals}_{\leq}(f_{S}^{-1}(I))$.
Then, $f_{S}^{-1}(I)=\operatorname{M}(I)+\mathbb{N}^{n}$ and
$\operatorname{M}(I)$ is a finite set. In particular, $\mathbb{N}^{n}\setminus
f_{S}^{-1}(I)=\\{\mathbf{x}\in\mathbb{N}^{n}\mid\mathbf{y}\nleq\mathbf{x},\text{
for all }\mathbf{y}\in\operatorname{M}(I)\\}$. So, in order to compute the set
$S\setminus I$, it suffices to find the set $\operatorname{M}(I)$ and use
equality (2) of Proposition 13. In [26, Algorithm 16], the authors show a
procedure to compute the set
$\operatorname{M}(I)=\operatorname{Minimals}_{\leq}(f_{S}^{-1}(I))$. We
provide a different strategy to compute it.

Let
$S=\langle\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup and $I=X+S$ an ideal of $S$, with
$X=\\{\mathbf{u}_{1},\ldots,\mathbf{u}_{r}\\}$. Observe that,
$\sum_{i=1}^{n}a_{i}\mathbf{e}_{i}\in f_{S}^{-1}(I)$ if and only if there
exists $k\in\\{1,\ldots,r\\}$ and
$\lambda_{1},\ldots,\lambda_{n}\in\mathbb{N}$ such that
$\sum_{i=1}^{n}a_{i}\mathbf{g}_{i}=\mathbf{u}_{k}+\sum_{i=1}^{n}\lambda_{i}\mathbf{g}_{i}$.
Hence, consider the matrix
$A^{(S)}=[\mathbf{g}_{1},\ldots,\mathbf{g}_{n},-\mathbf{g}_{1},\ldots,-\mathbf{g}_{n}]$.
For $j\in\\{1,\ldots,r\\}$, let $M_{(S,j)}$ be the set of non-negative integer
solutions of the non homogeneous diophantine linear system
$A^{(S)}\mathbf{x}=\mathbf{u}_{j}$. Then, we have:

$f_{S}^{-1}(I)=\bigcup_{j=1}^{r}\left\\{(x_{1},\ldots,x_{n})\in\mathbb{N}^{n}\mid(x_{1},\ldots,x_{n},x_{n+1},\ldots,x_{2n})\in
M_{(S,j)}\right\\}.$

Let $M^{\prime}_{(S)}$ be the set of non-negative integer solutions of the
homogeneous diophantine linear system $A^{(S)}\mathbf{x}=\mathbf{0}$ and
$V_{(S,j)}=\operatorname{Minimals}_{\leq}(M_{(S,j)}$) ($\leq$ is the natural
partial order in $\mathbb{N}^{2n}$). In particular, we have
$M_{(S,j)}=\bigcup_{\mathbf{y}\in V_{(S,j)}}(\mathbf{y}+M^{\prime}_{(S)})$
(see [22, Theorem 5.2]). Let us denote $V_{(I)}=\bigcup_{j=1}^{r}V_{(S,j)}$.
As a consequence, by the previous expression of $f_{S}^{-1}(I)$, we obtain:

$\operatorname{M}(I)=\operatorname{Minimals}_{\leq}\left(\left\\{(x_{1},\ldots,x_{n})\in\mathbb{N}^{n}\mid(x_{1},\ldots,x_{n},x_{n+1},\ldots,x_{2n})\in
V_{(I)}\right\\}\right).$

For all $j\in\\{1,\ldots,r\\}$, the set $V_{(S,j)}$ can be computed in GAP,
using the packages numericalsgps and NormalizInterface, as in Example 7. Once
the set $\operatorname{Minimals}_{\leq}(f_{S}^{-1}(I))$ is obtained, the
following algorithm allows to check if $S\setminus I$ is finite and, if so, to
compute its elements.

######  Algorithm 14.

Let
$S=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
be an affine semigroup and $I=X+S$ an ideal of $S$,
$X=\\{\mathbf{u}_{1},\ldots,\mathbf{u}_{r}\\}$. To test if $S\setminus I$ is
finite and, if so, compute it, we can consider the following steps.

  1. (1)

Consider the matrix
$A^{(S)}=[\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{n},-\mathbf{g}_{1},-\mathbf{g}_{2},\ldots,-\mathbf{g}_{n}]$,
where each element is identified as a column vector.

  2. (2)

For all $j\in\\{1,\ldots,r\\}$, compute the (finite) set
$V_{(S,j)}\subseteq\mathbb{N}^{2n}$ of minimal (with respect to the natural
partial order in $\mathbb{N}^{2n}$) non-negative integer solutions of the non
homogeneous diophantine linear system $A^{(S)}\mathbf{x}=\mathbf{u}_{j}$.

  3. (3)

Set $V_{(I)}=\bigcup_{j=1}^{r}V_{(S,j)}$.

  4. (4)

Set
$\operatorname{M}(I)=\operatorname{Minimals}_{\leq}\left(\left\\{(x_{1},\ldots,x_{n})\in\mathbb{N}^{n}\mid(x_{1},\ldots,x_{n},x_{n+1},\ldots,x_{2n})\in
V_{(I)}\right\\}\right)$.

  5. (5)

For all $i\in\\{1,\ldots,n\\}$ check if there exists $k_{i}\in\mathbb{N}$ such
that $k_{i}\mathbf{e}_{i}\in\operatorname{M}(I)$. If for some
$i\in\\{1,\ldots,n\\}$ this condition does not hold, then $S\setminus I$ is
not finite.

  6. (6)

If the previous condition holds, then compute
$Q=\\{\mathbf{x}\in\mathbb{N}^{n}\mid\mathbf{y}\nleq\mathbf{x},\text{ for all
}\mathbf{y}\in\operatorname{M}(I)\\}$.

  7. (7)

Compute $S\setminus I=\\{f_{S}(\mathbf{x})\mid\mathbf{x}\in Q\\}$.

Considering the computation time, the main difference between Algorithm 11 and
Algorithm 14 concerns with the computation of the set $\operatorname{M}(I)$,
against the time spent to test, for each element
$\mathbf{x}=(x_{1},\ldots,x_{n})\in P$, if
$\sum_{i=1}^{n}x_{i}\mathbf{g}_{i}\in I$.

###  2.1. An approach using commutative algebra

Assume
$S=\langle\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
and let $K$ be a field. Consider the semigroup ring
$K[S]=K[\mathbf{Y}^{\mathbf{s}}\mid\mathbf{s}\in
S]=K[\mathbf{Y}^{\mathbf{g}_{1}},\ldots,\mathbf{Y}^{\mathbf{g}_{n}}]$, where
if $\mathbf{s}=(s_{1},\ldots,s_{d})\in\mathbb{N}^{d}$, then
$\mathbf{Y}^{\mathbf{s}}=Y_{1}^{s_{1}}Y_{2}^{s_{2}}\cdots Y_{d}^{s_{d}}$. If
$I=X+S$, $X=\\{\mathbf{u}_{1},\ldots,\mathbf{u}_{r}\\}\subset S$, define
$I_{K[S]}=(\mathbf{Y}^{\mathbf{u}_{1}},\ldots,\mathbf{Y}^{\mathbf{u}_{r}})$,
that is a monomial ideal of $K[S]$.

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup and $I$ be an ideal of
$S$. Then $\mathbf{h}\in S\setminus I$ if and only if
$\mathbf{Y}^{\mathbf{h}}\notin I_{K[S]}$, that is, $\mathbf{Y}^{\mathbf{h}}$
is a monomial not belonging to $I_{K[S]}$. In particular $S\setminus I$ is a
finite set if and only if the set $\\{\mathbf{Y}^{\mathbf{h}}\in
K[S]\mid\mathbf{Y}^{\mathbf{h}}\notin I_{K[S]}\\}$ is finite.

Let $\mathbf{u}_{i}=\sum_{j=1}^{n}a_{ij}\mathbf{g}_{j}$ be a factorization of
$\mathbf{u}_{i}$ and denote
$\mathbf{a}_{i}=(a_{i1},\ldots,a_{in})\in\mathbb{N}^{n}$, for
$i\in\\{1,\ldots,r\\}$. Consider the polynomial ring $K[Z_{1},\ldots,Z_{n}]$
and, as above, if $\mathbf{t}=(t_{1},\ldots,t_{n})\in\mathbb{N}^{n}$, denote
$\mathbf{Z}^{\mathbf{t}}=Z_{1}^{t_{1}}Z_{2}^{t_{2}}\cdots Z_{n}^{t_{n}}$. We
consider the following surjective ring homomorphism:

$\psi:K[Z_{1},\ldots,Z_{n}]\longrightarrow K[S]\ \ \ \ \mbox{defined by}\ \ \
\ \ Z_{i}\longmapsto\mathbf{Y}^{\mathbf{g}_{i}}.$

Denote $J_{S}=\ker(\psi)$ (called the _defining ideal_ of $S$), and observe
that $\psi(\mathbf{Z}^{\mathbf{a}_{i}})=\mathbf{Y}^{\mathbf{u}_{i}}$ for each
$i\in\\{1,\ldots,r\\}$. The map $\psi$ induces the following ring isomorphism:

$\tilde{\psi}:\frac{K[Z_{1},\ldots,Z_{n}]}{J_{S}}\longrightarrow K[S]\ \ \ \
\mbox{defined by}\ \ \ \ \ \tilde{\psi}(f+J_{S})\longmapsto\psi(f).$

Observe that the set $\tilde{\psi}^{-1}(I_{K[S]})$ is an ideal of
$\frac{K[Z_{1},\ldots,Z_{n}]}{J_{S}}$. Moreover, we have the following set
equality:

$\tilde{\psi}^{-1}(I_{K[S]})=\frac{J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})}{J_{S}}.$

In fact, if $\tilde{f}=f+J_{S}\in\tilde{\psi}^{-1}(I_{K[S]})$, then
$\tilde{\psi}(\tilde{f})\in I_{K[S]}$. In particular there exist
$h_{1},\ldots,h_{r}\in K[S]$ such that
$\tilde{\psi}(\tilde{f})=\sum_{k=1}^{r}h_{k}\mathbf{Y}^{\mathbf{u}_{k}}=\tilde{\psi}(\sum_{k=1}^{n}\overline{h}_{k}\mathbf{Z}^{\mathbf{a}_{k}}+J_{S})$
with $\overline{h}_{k}+J_{S}\in\tilde{\psi}^{-1}(h_{k})$ for all
$k\in\\{1,\ldots,r\\}$. Denote
$\overline{h}=\sum_{k=1}^{n}\overline{h}_{k}\mathbf{Z}^{\mathbf{a}_{k}}$, in
particular
$\overline{h}\in(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$.
Since $\tilde{\psi}$ is an isomorphism we have
$\tilde{f}=f+J_{S}=\overline{h}+J_{S}$, so $f-\overline{h}\in J_{S}$ and in
particular $f\in
J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$. This
means that
$\tilde{f}=f+J_{S}\in\frac{J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})}{J_{S}}$.

Conversely, if
$f+J_{S}\in\frac{J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})}{J_{S}}$,
then $f=g+h$ where $g\in J_{S}$ and
$h=\sum_{k=1}^{n}h_{k}\mathbf{Z}^{\mathbf{a}_{k}}$, $h_{k}\in
K[Z_{1},\ldots,Z_{n}]$ for each $k\in\\{1,\ldots,r\\}$. Therefore,
$\tilde{\psi}(f+J_{S})=\psi(f)=\psi(g)+\psi(h)=\psi(h)=\psi(\sum_{k=1}^{n}h_{k}\mathbf{Z}^{\mathbf{a}_{k}})=\sum_{k=1}^{n}\psi(h_{k})\mathbf{Y}^{\mathbf{u}_{k}}\in
I_{K[S]}$, that is $f+J_{S}\in\tilde{\psi}^{-1}(I_{K[S]})$.

As a consequence of the previous set equality, we have the following
isomorphism:

$\frac{K[S]}{I_{K[S]}}\cong\left(\frac{K[Z_{1},\ldots,Z_{n}]}{J_{S}}\right)\diagup\left(\frac{J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})}{J_{S}}\right)\cong\frac{K[Z_{1},\ldots,Z_{n}]}{J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})}.$

The isomorphism above is described by the following map:

(1)
$\overline{\psi}:\frac{K[Z_{1},\ldots,Z_{n}]}{J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})}\longrightarrow\frac{K[S]}{I_{K[S]}},\quad
f+(J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}}))\mapsto\psi(f)+I_{K[S]}$

In the following, if $J$ is an ideal of a polynomial ring $R$ and $\preceq$ is
a monomial order on $R$, denote the initial ideal of $J$ with respect to
$\preceq$ by $\operatorname{in}_{\preceq}(J)$.

######  Lemma 15.

In the framework introduced above, let
$P_{S}=J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$
and $\preceq$ be a monomial order on $K[Z_{1},\ldots,Z_{n}]$. Then
$\\{\mathbf{Y}^{\mathbf{h}}\in K[S]\mid\mathbf{Y}^{\mathbf{h}}\notin
I_{K[S]}\\}=\\{\psi(\mathbf{Z}^{\mathbf{t}})\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$.

###### Proof.

Let $\overline{\psi}$ be the isomorphism above. In particular, if
$\mathbf{Z}^{\mathbf{t}}$ is a monomial in $K[Z_{1},\ldots,Z_{n}]$, then
$\overline{\psi}(\mathbf{Z}^{\mathbf{t}}+P_{S})=\psi(\mathbf{Z}^{\mathbf{t}})+I_{K[S]}$.
If $\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})$, then
trivially $\mathbf{Z}^{\mathbf{t}}\notin P_{S}$. Since $\overline{\psi}$ is
injective we obtain
$\psi(\mathbf{Z}^{\mathbf{t}})+I_{K[S]}=\overline{\psi}(\mathbf{Z}^{\mathbf{t}}+P_{S})\neq\mathbf{0}$,
that is, $\psi(\mathbf{Z}^{\mathbf{t}})\notin I_{K[S]}$. Conversely, let
$\mathbf{Y}^{\mathbf{h}}\in K[S]$ such that $\mathbf{Y}^{\mathbf{h}}\notin
I_{K[S]}$. This means that $\mathbf{Y}^{\mathbf{h}}+I_{K[S]}\neq\mathbf{0}$ in
$K[S]/I_{K[S]}$. Since $\mathbf{h}\in S$, there exists
$\mathbf{t}=\sum_{i=1}^{n}t_{i}\mathbf{e}_{i}\in\mathbb{N}^{n}$ such that
$\mathbf{h}=\sum_{i=1}^{n}t_{i}\mathbf{g}_{i}$. Hence, for the monomial
$\mathbf{Z}^{\mathbf{t}}\in K[Z_{1},\ldots,Z_{n}]$, we have
$\psi(\mathbf{Z}^{\mathbf{t}})=\mathbf{Y}^{\mathbf{h}}$. Suppose
$\mathbf{Z}^{\mathbf{t}}\in\operatorname{in}_{\preceq}(P_{S})$. Then, there
exists $f\in K[Z_{1},\ldots,Z_{n}]$ such that $\mathbf{Z}^{\mathbf{t}}+f\in
P_{S}$. So,
$\mathbf{Z}^{\mathbf{t}}+f=g+\sum_{k=1}^{r}h_{k}\mathbf{Z}^{\mathbf{a}_{k}}$,
$g\in J_{S}$ and $h_{k}\in K[Z_{1},\ldots,Z_{n}]$. Therefore,
$\psi(\mathbf{Z}^{\mathbf{t}})+\psi(f)=\psi(g)+\sum_{k=1}^{r}\psi(h_{k})\psi(\mathbf{Z}^{\mathbf{a}_{k}})=\sum_{k=1}^{r}\psi(h_{k})\mathbf{Y}^{\mathbf{u}_{k}}$.
In particular, $\psi(\mathbf{Z}^{\mathbf{t}})+\psi(f)\in I_{K[S]}$. Since
$I_{K[S]}$ is a monomial ideal and
$\psi(\mathbf{Z}^{\mathbf{t}})=\mathbf{Y}^{\mathbf{h}}$ is a monomial, we
obtain $\mathbf{Y}^{\mathbf{h}}\in I_{K[S]}$, a contradiction. So, we have
$\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})$. ∎

Consider the set $\\{\mathbf{Z}^{\mathbf{t}}\in
K[Z_{1},\ldots,Z_{n}]\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
and suppose it is finite for some monomial order on $K[Z_{1},\ldots,Z_{n}]$.
This property is known as
$P_{S}=J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$
is a _zero dimensional ideal_ of $K[Z_{1},\ldots,Z_{n}]$. A zero dimensional
ideal is characterized by the following known result (Theorem 6, Chapter 5,
§3, [8]):

######  Theorem 16 ([8]).

Let $K$ be a field and $I\subseteq K[X_{1},\ldots,X_{n}]$ be an ideal of a
polynomial ring. Fix a monomial order $\preceq$ in $K[X_{1},\ldots,X_{n}]$.
Then the following are equivalent:

  1. i)

For each $i\in\\{1,\ldots,n\\}$ there is some $m_{i}\geq 0$ such that
$X^{m_{i}}\in\operatorname{in}_{\preceq}(I)$.

  2. ii)

Let $G$ be a Gröbner basis for $I$. Then for each $i\in\\{1,\ldots,n\\}$ there
is some $m_{i}\geq 0$ such that $X^{m_{i}}=\operatorname{in}_{\preceq}(g)$ for
some $g\in G$.

  3. iii)

The set $\\{X^{\alpha}\mid X^{\alpha}\notin\operatorname{in}_{\preceq}(I)\\}$
is finite.

  4. iv)

The $K$-vector space $K[X_{1},\ldots,X_{n}]/I$ is finite-dimensional.

Theorem 16 suggests another way to prove the characterization of cofinitness
of an ideal $I$ in a monoid $S$, given in Theorem 10, and also a different
procedure to compute $S\setminus I$.

###### Alternative proof of Theorem 10.

In the following, denote
$P_{S}=J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$,
with reference to the framework introduced in this section.

_Necessity._ Suppose that $S\setminus I$ is finite. Then the set
$\\{\mathbf{Y}^{\mathbf{h}}\in K[S]\mid\mathbf{Y}^{\mathbf{h}}\notin
I_{K[S]}\\}$ is finite. So, by Lemma 15, considering the ideal $P_{S}$ and
$\preceq$ a monomial order on $K[Z_{1},\ldots,Z_{n}]$, we have that
$\\{\psi(\mathbf{Z}^{\mathbf{t}})\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
is a finite set. We show that the set $\\{\mathbf{Z}^{\mathbf{t}}\in
K[Z_{1},\ldots,Z_{n}]\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
is finite. If we suppose it is not finite, since
$\\{\psi(\mathbf{Z}^{\mathbf{t}})\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
is finite, there exist
$\mathbf{Z}^{\mathbf{t}_{1}},\mathbf{Z}^{\mathbf{t}_{2}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$,
$\mathbf{Z}^{\mathbf{t}_{1}}\neq\mathbf{Z}^{\mathbf{t}_{2}}$, such that
$\psi(\mathbf{Z}^{\mathbf{t}_{1}})=\psi(\mathbf{Z}^{\mathbf{t}_{2}})$. Hence,
$\mathbf{Z}^{\mathbf{t}_{1}}-\mathbf{Z}^{\mathbf{t}_{2}}\in J_{S}\subseteq
P_{S}$ and this implies
$\mathbf{Z}^{\mathbf{t}_{1}}\in\operatorname{in}_{\preceq}(P_{S})$ or
$\mathbf{Z}^{\mathbf{t}_{2}}\in\operatorname{in}_{\preceq}(P_{S})$, a
contradiction. Therefore, the set $\\{\mathbf{Z}^{\mathbf{t}}\in
K[Z_{1},\ldots,Z_{n}]\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
is finite and by Theorem 16 we obtain that for all $i\in\\{1,\ldots,n\\}$
there exists an integer $k_{i}\geq 0$ such that
$Z_{i}^{k_{i}}\in\operatorname{in}_{\preceq}(P_{S})$. Hence, there exists
$f_{i}\in K[Z_{1},\ldots,Z_{n}]$ such that $Z_{i}^{k_{i}}+f_{i}\in P_{S}$. So,
having in mind the isomorphism in (1), we obtain
$\psi(Z_{i}^{k_{i}}+f_{i})=\mathbf{Y}^{k_{i}\mathbf{g}_{i}}+\psi(f_{i})\in
I_{K[S]}$. Since $I_{K[S]}$ is a monomial ideal and
$\mathbf{Y}^{k_{i}\mathbf{g}_{i}}$ is a monomial, we obtain
$\mathbf{Y}^{k_{i}\mathbf{g}_{i}}\in I_{K[S]}$, that is,
$k_{i}\mathbf{g}_{i}\in I$. As a consequence, for all $i\in\\{1,\ldots,n\\}$,
we have $k_{i}\mathbf{g}_{i}\in I$.

_Sufficiency._ For every $i\in\\{1,\ldots,n\\}$, suppose there exists
$k_{i}\in\mathbb{N}\setminus\\{0\\}$ such that $k_{i}\mathbf{g}_{i}\in I$.
Then $\mathbf{Y}^{k_{i}\mathbf{g}_{i}}\in I_{K[S]}$. In particular, by the
isomorphism in (1), we have $Z_{i}^{k_{i}}\in P_{S}$. By Theorem 16, given a
monomial order $\preceq$ on $K[Z_{1},\ldots,Z_{n}]$, we obtain that
$\\{\mathbf{Z}^{\mathbf{t}}\in
K[Z_{1},\ldots,Z_{n}]\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
is a finite a set. As a consequence, the set
$\\{\psi(\mathbf{Z}^{\mathbf{t}})\mid\mathbf{Z}^{\mathbf{t}}\notin\operatorname{in}_{\preceq}(P_{S})\\}$
is finite and, by Lemma 15, the set $\\{\mathbf{Y}^{\mathbf{h}}\in
K[S]\mid\mathbf{Y}^{\mathbf{h}}\notin I_{K[S]}\\}$ is finite. This means that
$S\setminus I$ is finite. ∎

Following the arguments developed in this section, we can reformulate Theorem
10 as follows.

######  Corollary 17.

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup, $I$ an ideal of $S$. As
before, let
$P_{S}=J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})\subseteq
K[Z_{1},\ldots,Z_{n}]$. Then $S\setminus I$ is finite if and only if $P_{S}$
is a zero dimensional ideal of $K[Z_{1},\ldots,Z_{n}]$.

For a different procedure to compute $S\setminus I$, recall that in the case
$I\subseteq K[X_{1},\ldots,X_{n}]$ is an ideal of a polynomial ring and
$\preceq$ a monomial order in $K[X_{1},\ldots,X_{n}]$, then the set
$\\{X^{\alpha}\mid X^{\alpha}\notin\operatorname{in}_{\preceq}(I)\\}$ is a
basis of $K[X_{1},\ldots,X_{n}]/I$ as $K$-vector space. In particular one can
use a computer algebra software, for instance Macaulay2 [19] or Singular [28],
to test if one of the equivalent conditions of Theorem 16 holds and, in such a
case, to compute the set $\\{X^{\alpha}\mid
X^{\alpha}\notin\operatorname{in}_{\preceq}(I)\\}$.

So, if $\mathcal{B}$ is a basis of the $K$-vector space
$K[Z_{1},\ldots,Z_{n}]/P_{S}$,
$P_{S}=J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$,
then $S\setminus
I=\\{\mathbf{h}\in\mathbb{N}^{d}\mid\mathbf{Y}^{\mathbf{h}}=\psi(\mathbf{Z}^{\mathbf{t}}),\mathbf{Z}^{\mathbf{t}}\in\mathcal{B}\\}$.

######  Algorithm 18.

Given
$S=\langle\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\rangle\subseteq\mathbb{N}^{d}$
and an ideal $I$ of $S$, with $I=X+S$ and
$X=\\{\mathbf{u}_{1},\ldots,\mathbf{u}_{r}\\}\subset S$, in order to compute
$S\setminus I$ we can consider the following steps:

  1. (1)

For each $i\in\\{1,\ldots,r\\}$ compute a factorization $\mathbf{a}_{i}$ of
$\mathbf{u}_{i}$ in $S$.

  2. (2)

Set the polynomial rings $R_{1}=K[Z_{1},\ldots,Z_{n}]$,
$R_{2}=K[Y_{1},\ldots,Y_{d}]$, with $K$ a field, the map
$\psi:R_{1}\rightarrow R_{2}$ defined by
$Z_{i}\mapsto\mathbf{Y}^{\mathbf{g}_{i}}$ and compute the ideal
$J_{S}=\ker(\psi)$.

  3. (3)

Set the ideal
$P_{S}=J_{S}+(\mathbf{Z}^{\mathbf{a}_{1}},\ldots,\mathbf{Z}^{\mathbf{a}_{r}})$
and compute a Gröbner basis $G$ of $P_{S}$ with respect to a monomial order
$\preceq$.

  4. (4)

If $G$ does not satisfies condition (ii) of Theorem 16, then $S\setminus I$ is
not finite and we can stop. Otherwise compute a basis $\mathcal{B}$ of the
$K$-vector space $K[Z_{1},\ldots,Z_{n}]/P_{S}$.

  5. (5)

Compute $S\setminus
I=\\{\mathbf{h}\in\mathbb{N}^{d}\mid\mathbf{Y}^{\mathbf{h}}=\psi(\mathbf{Z}^{\mathbf{t}}),\mathbf{Z}^{\mathbf{t}}\in\mathcal{B}\\}$.

We point out that a similarity between Algorithm 14 and Algorithm 18 is
actually hidden. That is, the exponent vectors of elements in the basis
$\mathcal{B}$ of the $K$-vector space $K[Z_{1},\ldots,Z_{n}]/P_{S}$ correspond
to the vectors in $\mathbb{N}^{n}\setminus f_{S}^{-1}(I)$. In particular,
these elements are obtained from a _presentation_ of $S$ (see [26] for more
details) in the first algorithm, and from the _defining ideal_ $I_{S}$ of
$K[S]$ in the second algorithm. Considering the computation time, the relevant
difference concerns with the time spent to compute the set
$\operatorname{M}(I)$ against the computation of a Gröbner basis of the ideal
$P_{S}$.

###  2.2. A remark on Apéry sets

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup and $X\subseteq S$. The
Apéry set of $S$ with respect to $X$ is defined as
$\operatorname{Ap}(S,X)=\\{\mathbf{s}\in S\mid\mathbf{s}-\mathbf{x}\notin
S\text{ for all }\mathbf{x}\in X\\}$. This set is an important tool in the
context of affine semigroups. For instance, in the case $S$ is _simplicial_ ,
it can be used to verify the Cohen-Macaulay and Gorenstein conditions for the
associated semigroup ring (see [24]) and to compute the conductor (see [17]).
Observe that $\operatorname{Ap}(S,X)=S\setminus(X+S)$, so it is the complement
in $S$ of the ideal $X+S$. In particular we can state the following:

######  Corollary 19.

Let $S\subseteq\mathbb{N}^{d}$ be an affine semigroup minimally generated by
the set $\\{\mathbf{g}_{1},\ldots,\mathbf{g}_{n}\\}$. If $X\subset S$, then
$\operatorname{Ap}(S,X)$ is finite if and only if for all
$i\in\\{1,\ldots,n\\}$ there exists $k_{i}\in\mathbb{N}\setminus\\{0\\}$ such
that $k_{i}\mathbf{g}_{i}\in X+S$.

As a consequence, if
$S=\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{r},\mathbf{g}_{r+1},\mathbf{g}_{r+2},\ldots,\mathbf{g}_{r+m}\rangle$,
where $E=\\{\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{r}\\}$ is a set
of extreme rays of $S$, then
$\mathbf{g}_{j}=\sum_{i=1}^{r}q_{i}\mathbf{g}_{i}$, $q_{i}\in\mathbb{Q}_{+}$,
for all $j\in\\{1,\ldots,m\\}$. It easily follows that there exists
$k_{j}\in\mathbb{N}$ such that
$k_{j}\mathbf{g}_{j}\in\langle\mathbf{g}_{1},\mathbf{g}_{2},\ldots,\mathbf{g}_{r}\rangle\subset
S$. Therefore, in the case $E$ is a set of extreme rays of $S$, the set
$\operatorname{Ap}(S,E)$ is finite. Moreover, referring to the previous
arguments in Subsection 2.1, we can consider the ideal
$P_{S}=J_{S}+(Z_{1},\ldots,Z_{r})$ and if $\mathcal{B}$ is a basis of the
$K$-vector space $K[Z_{1},\ldots,Z_{n}]/P_{S}$, then
$\operatorname{Ap}(S,E)=\\{\mathbf{h}\in\mathbb{N}^{d}\mid\mathbf{Y}^{\mathbf{h}}=\psi(\mathbf{Z}^{\mathbf{t}}),\mathbf{Z}^{\mathbf{t}}\in\mathcal{B}\\}$,
obtaining the same result contained in [21, Theorem 3.3].

## Acknowledgements

Motivation for this paper was inspired by some discussions had with P. A.
García-Sánchez during a period the author spent at the University of Granada.
The author would like to express his gratitude to him, for the hospitality and
for his very helpful comments and suggestions, that have allowed to improve
this work. The author also acknowledges support from the Institute of
Mathematics of the University of Granada (IMAG), through the program of Visits
of Young Talented Researchers and from Istituto Nazionale di Alta Matematica
(INDAM), through the program Concorso a n. 30 mensilità di borse di studio per
l’estero per l’a.a. 2022-2023.

## References

  * [1] A. Assi, M. D’Anna, P. A. García-Sánchez, Numerical Semigroups and Applications, 2nd ed., RSME Springer Series 3, Springer: Cham, Switzerland, 2020.
  * [2] M. Bernardini, A. S. Castellanos, W. Tenório, G. Tizziotti, On atoms of the set of generalized numerical semigroups with fixed corner element, arXiv:2306.13506, 2023.
  * [3] O. P. Bhardwaj, K. Goel, I. Sengupta, Affine semigroups of maximal projective dimension. Collect. Math., 74(3): 703–727, 2023.
  * [4] W. Bruns, J. Gubeladze, Polytopes, Rings, and K-Theory, Springer Monographs in Mathematics. Springer, Dordrecht, 2009.
  * [5] W. Bruns, B. Ichim, T. Römer, C. Söger, The Normaliz project, available at http://www.home.uniosnabrueck.de/wbruns/normaliz/
  * [6] C. Cisto, G. Failla, R. Utano, On the generators of a generalized numerical semigroup. Analele Univ. “Ovidius”, 27(1):49–59, 2019.
  * [7] C. Cisto, M. Delgado, and P. A. García-Sánchez. Algorithms for generalized numerical semigroups. J. Algebra Appl., 20(5):2150079, 2021.
  * [8] D. Cox, J. Little and D. O’Shea, Ideals, Varieties, and Algorithms, 4th edition, Springer-Verlag, New York, 2015.
  * [9] M. Delgado, P. A. García-Sánchez, J. Morais, NumericalSgps, A package for numerical semigroups, Version 1.3.1 dev (2023), Refereed GAP package, https://gap-packages.github.io/numericalsgps.
  * [10] J. D. Díaz-Ramírez, J. I. García-García, D. Marín-Aragón, A. Vigneron-Tenorio, Characterizing affine $\mathcal{C}$-semigroups, Ric. Mat., 71: 283–296, 2022.
  * [11] G. Failla, C. Peterson, and R. Utano. Algorithms and basic asymptotics for generalized numerical semigroups in $\mathbb{N}^{d}$, Semigroup Forum, 92(2):460–473, 2016.
  * [12] The GAP group, GAP – Groups, Algorithms, and Programming, Version 4.12.2, (2022), https://www.gap-system.org.
  * [13] J. I. García-García, D. Marín-Aragón, and A. Vigneron-Tenorio, An extension of Wilf’s conjecture to affine semigroups, Semigroup Forum, 96(2):396–408, 2018.
  * [14] J. I. García-García, I. Ojeda, J.C. Rosales, A. Vigneron-Tenorio, On pseudo-Frobenius elements of submonoids of $\mathbb{N}^{d}$ , Collect. Math., 71(1):189–204, 2020.
  * [15] J. I. García-García, D. Marín-Aragón, A. Sánchez-Loureiro, A. Vigneron-Tenorio, Some properties of affine $\mathcal{C}$-semigroups, Results Math., 79: article number 52, 2024.
  * [16] A. Geroldinger, F. Halter-Koch, Non–unique factorizations. Algebraic, combinatorial and analytic theory. Pure and Applied Mathematics (Boca Raton), 278. Chapman & Hall/CRC, Boca Raton, FL, 2006.
  * [17] R. Jafari, M. Yaghmaei, Type and conductor of simplicial affine semigroups. J. Pure Appl. Algebra, 226(3): article no. 106844, 2022.
  * [18] S. Li, On the number of generalized numerical semigroups, arXiv:2212.13740, 2023.
  * [19] D. Grayson and M. Stillman, _Macaulay2, a software system for research in algebraic geometry._
  * [20] S. Gutsche, M. Horn, C. Söger , NormalizInterface - a GAP package, Version 1.3.5 (2022), Refereed GAP package,https://gap-packages.github.io/NormalizInterface.
  * [21] I. Ojeda, A. Vigneron-Tenorio, The short resolution of a semigroup algebra, Bull. Aust. Math. Soc., 96(3):400–411, 2017.
  * [22] P. Pisón-Casares, A. Vigneron-Tenorio, $\mathbb{N}$-solutions to linear systems over $\mathbb{Z}$ . Linear Algebra Its Appl., 384: 135–154, 2004.
  * [23] J. C. Rosales, P. A. García-Sánchez, Nonnegative elements of subgroups of $\mathbb{Z}^{n}$, Linear Algebra Appl., 270: 351–357, 1998.
  * [24] J. C. Rosales, P. A. García-Sánchez, On Cohen-Macaulay and Gorenstein simplicial aﬃne semigroups, Proc. Edinb. Math. Soc., 41(3):517–537, 1998.
  * [25] J. C. Rosales, P. A. García-Sánchez, Finitely generated commutative monoids, Nova Science Publishers, Inc., New York, 1999.
  * [26] J. C. Rosales, P. A. García-Sánchez, and J. I. García-García, Irreducible ideals of finitely generated commutative monoids, J. Algebra; 238: 328-344, 2001.
  * [27] J. C. Rosales, P. A. García-Sánchez, Numerical semigroups, Developments in Mathematics, 20. Springer, New York, 2009.
  * [28] W. Decker, G. M. Greuel, G. Pfister, H. Schönemann,  Singular 4-3-2 — A computer algebra system for polynomial computations.  https://www.singular.uni-kl.de, 2023.