Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
- Added AntichainsOfNumericalSemigroup which computes antichains of sets of integers wrt order induced by a numerical semigroup
- Added AtomMonoid for numerical sets
- Added AssociatedNumericalSets for numerical semigroups
- Added posets associated to numerical semigroups (PosetNS)
- Added MinimalElements and MaximalElements for posets associated to numerical semigroups
- Added Upset and Downset for posets associated to numerical semigroups
- Anitichains for posets, which is a synonym of AntichainsOfNumericalSemigroup
- HasseDiagram for posets associated to numerical semigroups as synonym of HasseDiagramOfNumericalSemigroup

1.3.1 -> 1.4.0
- Added NumericalSemigroupsWithFrobeniusNumberPC
- Added NumericalSemigroupsWithGenusPC
Expand Down
144 changes: 127 additions & 17 deletions doc/order.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>

<Section>
<Heading>
Posets induced by numerical semigroups
</Heading>

<ManSection>
<Oper Name="PosetNS" Arg="S, A" Label="for numerical semigroup and list of integers"/>
<Oper Name="PosetNS" Arg="A, S" Label="for list of integers and numerical semigroup"/>
<Description>
<C>S</C> is a numerical semigroup and <C>A</C> is a set of integers. Returns the poset with ground set <C>A</C> and order defined by the binary relation induced by <C>S</C>: <M>a\preceq b</M> if <M>b - a</M> in <C>S</C>.
<Example><![CDATA[
gap> l:=[1..10];;
gap> s:=NumericalSemigroup(3,5,8);;
gap> p:=PosetNS(l,s);
<Poset defined wrt to numerical semigroup>
]]></Example>
</Description>
</ManSection>


<ManSection>
<Oper Name="MaximalElements" Arg="P" Label="for posets defined by numerical semigroups"/>
<Description>
<C>P</C> is a poset induced by a numerical semigroup. Returns the list of maximal elements of <C>P</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,8);;
gap> l:=[1..10];;
gap> p:=PosetNS(l,s);;
gap> MaximalElements(p);
[ 10, 9, 8 ]
gap> Type(s)=Length(MaximalElements(PosetNS(AperyList(s),s)));
true
]]></Example>
</Description>
</ManSection>

<ManSection>
<Oper Name="MinimalElements" Arg="P" Label="for posets defined by numerical semigroups"/>
<Description>
<C>P</C> is a poset induced by a numerical semigroup. Returns the list of minimal elements of <C>P</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,8);;
gap> l:=[1..10];;
gap> p:=PosetNS(l,s);;
gap> MinimalElements(p);
[ 1, 2, 3 ]
]]></Example>
</Description>
</ManSection>


<ManSection>
<Oper Name="Upset" Arg="P,l" Label="for posets defined by numerical semigroups"/>
<Description>
<C>P</C> is a poset induced by a numerical semigroup, <C>l</C> is a list of integers (contained in the ground set of <C>P</C>). Returns the upset of the list <C>l</C> in the poset <C>P</C>, that is, all elements of <C>P</C> greater than or equal to some element of <C>l</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,7);;
gap> l:=[1..10];;
gap> p:=PosetNS(l,s);;
gap> Upset(p,[2,4]);
[ 2, 4, 5, 7, 8, 9, 10 ]
gap> Upset(p,[2])=Filtered(l,i->i-2 in s);
true
]]></Example>
</Description>
</ManSection>

<ManSection>
<Oper Name="Downset" Arg="P,l" Label="for posets defined by numerical semigroups"/>
<Description>
<C>P</C> is a poset induced by a numerical semigroup, <C>l</C> is a list of integers (contained in the ground set of <C>P</C>). Returns the downset of the list <C>l</C> in the poset <C>P</C>, that is, all elements of <C>P</C> less than or equal to some element of <C>l</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,7);;
gap> l:=[1..10];;
gap> p:=PosetNS(l,s);;
gap> Downset(p,[5,6]);
[ 1, 2, 3, 5, 6 ]
gap> p:=PosetNS(s,AperyList(s));;
gap> Downset(p,Multiplicity(s)+PseudoFrobenius(s))=GroundSet(p);
true
]]></Example>
</Description>
</ManSection>

<ManSection>
<Func Name="AntichainsOfNumericalSemigroup" Arg="S, A"/>
<Description>
<C>S</C> is a numerical semigroup and <C>A</C> is a set of integers. Returns the set of antichains (sets of non-comparable elements) of <C>A</C> with respect to the ordering <M>a\preceq b</M> if <M>b - a</M> in <C>S</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,7);;
gap> AntichainsOfNumericalSemigroup(s,Gaps(s));
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
]]></Example>
</Description>
</ManSection>

<ManSection>
<Oper Name="Antichains" Arg="P"/>
<Description>
<C>P</C> is a poset defined by a numerical semigroup. Returns the set of antichains (sets of non-comparable elements) of <C>P</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,7);;
gap> p:=PosetNS(s,Gaps(s));;
gap> Antichains(p);
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
gap> Antichains(p)=AntichainsOfNumericalSemigroup(s,Gaps(s));
true
]]></Example>
</Description>
</ManSection>


</Section>

<Section>
<Heading>
Hasse diagrams related to numerical semigroups
Expand All @@ -17,6 +131,19 @@ gap> HasseDiagramOfNumericalSemigroup(s,[1,2,3]);
</Description>
</ManSection>

<ManSection>
<Oper Name="HasseDiagram" Arg="P"/>
<Description>
<C>P</C> is a posed defined by a numerical semigroup. Returns a binary relation which is the Hasse diagram of <C>P</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,7);;
gap> p:=PosetNS(s,Gaps(s));;
gap> HasseDiagram(p)=HasseDiagramOfNumericalSemigroup(s,Gaps(s));
true
]]></Example>
</Description>
</ManSection>


<ManSection>
<Func Name="HasseDiagramOfBettiElementsOfNumericalSemigroup" Arg="S"/>
Expand Down Expand Up @@ -46,20 +173,3 @@ gap> HasseDiagramOfAperyListOfNumericalSemigroup(s,10);

</Section>

<Section>
<Heading>
Antichains
</Heading>
<ManSection>
<Func Name="AntichainsOfNumericalSemigroup" Arg="S, A"/>
<Description>
<C>S</C> is a numerical semigroup and <C>A</C> is a set of integers. Returns the set of antichains (sets of non-comparable elements) of <C>A</C> with respect to the ordering <M>a\preceq b</M> if <M>b - a</M> in <C>S</C>.
<Example><![CDATA[
gap> s:=NumericalSemigroup(3,5,7);;
gap> AntichainsOfNumericalSemigroup(s,Gaps(s));
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
]]></Example>
</Description>
</ManSection>

</Section>
28 changes: 14 additions & 14 deletions gap/numset.gi
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ end);

InstallMethod(FerrersDiagram, [IsNumericalSemigroup],
function(s)
FerrersDiagram(AsNumericalSet(s));
return FerrersDiagram(AsNumericalSet(s));
end);

###############################################################################
Expand Down Expand Up @@ -1000,13 +1000,13 @@ end);
###############################################################################
InstallMethod(AssociatedNumericalSets, [IsNumericalSemigroup],
function(S)
local F, gaps, H, H_Set, PF, PF_max, Tr, R, UpSet, DownSet, P, TrP,N, P_max, x, y, lim,
A, C_A, Car_A, a, G, B1, B2, Z, L_anti, anti, Y, T, PF_DownSets, tuple, Explore;
local F, gaps, H, H_Set, PF, PF_max, Tr, R, Upset, Downset, P, TrP,N, P_max, x, y, lim,
A, C_A, Car_A, a, G, B1, B2, Z, L_anti, anti, Y, T, PF_Downsets, tuple, Explore;

# AUXILIARY FUNCTIONS

# UpSet(val): Returns a list of elements in Holes(S) >= val respecting S order
UpSet := function(val)
# Upset(val): Returns a list of elements in Holes(S) >= val respecting S order
Upset := function(val)
local geq, z, start_index;
geq := [];
start_index := PositionSorted(H, val);
Expand All @@ -1016,8 +1016,8 @@ function(S)
return geq;
end;

# DownSet(val): Returns a list of elements in Holes(S) <= val respecting S order
DownSet := function(val)
# Downset(val): Returns a list of elements in Holes(S) <= val respecting S order
Downset := function(val)
local leq, z;
leq := [];
for z in H do
Expand All @@ -1036,28 +1036,28 @@ function(S)
PF := PseudoFrobenius(S);
PF_max := Difference(PF, [F]);

# Pre-compute DownSets for all Pseudo-Frobenius numbers
PF_DownSets := rec();
# Pre-compute Downsets for all Pseudo-Frobenius numbers
PF_Downsets := rec();
for P in PF do
PF_DownSets.(String(P)) := DownSet(P);
PF_Downsets.(String(P)) := Downset(P);
od;

# Pre-compute Frobenius Triangles for all Pseudo-Frobenius except F
Tr := rec();
N := Length(PF_max);
if N > 0 then
P_max:= PF_max[N];
Tr.(String(P_max)) := [ [P_max, F-P_max, 0, UpSet(F-P_max), [] ] ]; # The largest Pseudo-Frobenius after F(S) has no valid triangles except base case
Tr.(String(P_max)) := [ [P_max, F-P_max, 0, Upset(F-P_max), [] ] ]; # The largest Pseudo-Frobenius after F(S) has no valid triangles except base case
for P in PF_max{[1..N-1]} do
TrP := [ [P, F-P, 0, UpSet(F-P), [] ] ]; # Base case
TrP := [ [P, F-P, 0, Upset(F-P), [] ] ]; # Base case
lim := PositionSorted(H, F-P);
if lim > Length(H) or H[lim] >= (F-P) then
lim := lim - 1;
fi;
for x in H{[1..lim]} do
y := F-P-x;
if y in H_Set then
Add(TrP, [P, x, y, UpSet(x), DownSet(F-y)]);
Add(TrP, [P, x, y, Upset(x), Downset(F-y)]);
fi;
od;
Tr.(String(P)) := TrP;
Expand Down Expand Up @@ -1102,7 +1102,7 @@ function(S)

# BRANCH 2: Exclude P from A
new_B2 := ShallowCopy(B2_act);
UniteSet(new_B2, PF_DownSets.(String(P))); # Everything below P must be excluded
UniteSet(new_B2, PF_Downsets.(String(P))); # Everything below P must be excluded
Explore(i+1, G_act, B1_act, new_B2, A_act);
end;

Expand Down
105 changes: 105 additions & 0 deletions gap/order.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,99 @@
#############################################################################
##
#W order.gd Manuel Delgado <mdelgado@fc.up.pt>
#W Pedro A. Garcia-Sanchez <pedro@ugr.es>
##
##
#Y Copyright 2026 by Manuel Delgado and Pedro Garcia-Sanchez
#Y We adopt the copyright regulations of GAP as detailed in the
#Y copyright notice in the GAP manual.
##
#############################################################################


#############################################################################
##
#R IsPosetNSRep
##
## The representation of a poset defined by a numerical semigroup and a list
## of integers.
##
#############################################################################
DeclareRepresentation("IsPosetNSRep", IsAttributeStoringRep, []);

#############################################################################
##
#C IsPosetNS
##
## The category of posets defined by numerical semigroups and lists of integers.
##
#############################################################################
DeclareCategory( "IsPosetNS", IsPosetNSRep);

# Elements of posets defined by numerical semigroups are integers, so posets
# defined by numerical semigroups are collections of integers.
BindGlobal( "PosetNSType", NewType( CollectionsFamily(CyclotomicsFamily), IsPosetNS));

#############################################################################
##
#F PosetNS(l,S)
##
## l is a list of integers and S a numerical semigroup
##
## returns the poset whose underlying set is l and the order is defined by
## a <= b if b - a in S
##
#############################################################################
DeclareOperation("PosetNS",[IsList, IsNumericalSemigroup]);
# we allow changing the order of the arguments
DeclareOperation("PosetNS",[IsNumericalSemigroup,IsList]);


DeclareAttribute("UnderlyingNSPoset", IsPosetNS);
DeclareAttribute("GroundSet", IsPosetNS);

#############################################################################
##
#A MaximalElements(p)
## Returns the list of maximal elements of the poset p
##
#############################################################################
DeclareAttribute("MaximalElements", IsPosetNS);

#############################################################################
##
#A MinimalElements(p)
## Returns the list of minimal elements of the poset p
##
#############################################################################
DeclareAttribute("MinimalElements", IsPosetNS);

#############################################################################
##
#O Upset(p,l)
## Returns the upset of the list l in the poset p, that is, the set of
## elements greater than or equal to some element of l.
##
#############################################################################
DeclareOperation("Upset", [IsPosetNS, IsList]);

#############################################################################
##
#O Downset(p,l)
## Returns the downset of the list l in the poset p, that is, the set of
## elements less than or equal to some element of l.
##
#############################################################################
DeclareOperation("Downset", [IsPosetNS, IsList]);

#############################################################################
##
#O Antichains(p)
## Returns the set of antichains (sets of non comparable elements) of p.
##
#############################################################################
DeclareOperation("Antichains", [IsPosetNS]);

############################################################################
##
#F HasseDiagramOfNumericalSemigroup(s, A)
Expand Down Expand Up @@ -37,3 +133,12 @@ DeclareGlobalFunction("HasseDiagramOfAperyListOfNumericalSemigroup");
##
############################################################################
DeclareGlobalFunction("AntichainsOfNumericalSemigroup");


############################################################################
##
#O HasseDiagram(P)
## Returns the Hasse diagram of the poset P.
##
############################################################################
DeclareOperation("HasseDiagram", [IsPosetNS]);
Loading