Skip to content

Commit f0ead2f

Browse files
UpSet, DownSet, Antichains
1 parent 1f9ce41 commit f0ead2f

File tree

5 files changed

+179
-36
lines changed

5 files changed

+179
-36
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
- Added AntichainsOfNumericalSemigroup which computes antichains of sets of integers wrt order induced by a numerical semigroup
4040
- Added AtomMonoid for numerical sets
4141
- Added AssociatedNumericalSets for numerical semigroups
42+
- Added posets associated to numerical semigroups (PosetNS)
43+
- Added MinimalElements and MaximalElements for posets associated to numerical semigroups
44+
- Added UpSet and DownSet for posets associated to numerical semigroups
45+
- Anitichains for posets, which is a synonym of AntichainsOfNumericalSemigroup
46+
4247
1.3.1 -> 1.4.0
4348
- Added NumericalSemigroupsWithFrobeniusNumberPC
4449
- Added NumericalSemigroupsWithGenusPC

doc/order.xml

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,67 @@ gap> MinimalElements(p);
5151
</ManSection>
5252

5353

54+
<ManSection>
55+
<Oper Name="UpSet" Arg="P,l" Label="for posets defined by numerical semigroups"/>
56+
<Description>
57+
<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>.
58+
<Example><![CDATA[
59+
gap> s:=NumericalSemigroup(3,5,7);;
60+
gap> l:=[1..10];;
61+
gap> p:=PosetNS(l,s);;
62+
gap> UpSet(p,[2,4]);
63+
[ 2, 4, 5, 7, 8, 9, 10 ]
64+
gap> UpSet(p,[2])=Filtered(l,i->i-2 in s);
65+
true
66+
]]></Example>
67+
</Description>
68+
</ManSection>
69+
70+
<ManSection>
71+
<Oper Name="DownSet" Arg="P,l" Label="for posets defined by numerical semigroups"/>
72+
<Description>
73+
<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>.
74+
<Example><![CDATA[
75+
gap> s:=NumericalSemigroup(3,5,7);;
76+
gap> l:=[1..10];;
77+
gap> p:=PosetNS(l,s);;
78+
gap> DownSet(p,[5,6]);
79+
[ 1, 2, 3, 5, 6 ]
80+
gap> p:=PosetNS(s,AperyList(s));;
81+
gap> DownSet(p,Multiplicity(s)+PseudoFrobenius(s))=GroundSet(p);
82+
true
83+
]]></Example>
84+
</Description>
85+
</ManSection>
86+
87+
<ManSection>
88+
<Func Name="AntichainsOfNumericalSemigroup" Arg="S, A"/>
89+
<Description>
90+
<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>.
91+
<Example><![CDATA[
92+
gap> s:=NumericalSemigroup(3,5,7);;
93+
gap> AntichainsOfNumericalSemigroup(s,Gaps(s));
94+
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
95+
]]></Example>
96+
</Description>
97+
</ManSection>
98+
99+
<ManSection>
100+
<Func Name="Antichains" Arg="P"/>
101+
<Description>
102+
<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>.
103+
<Example><![CDATA[
104+
gap> s:=NumericalSemigroup(3,5,7);;
105+
gap> p:=PosetNS(s,Gaps(s));;
106+
gap> Antichains(p);
107+
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
108+
gap> Antichains(p)=AntichainsOfNumericalSemigroup(s,Gaps(s));
109+
true
110+
]]></Example>
111+
</Description>
112+
</ManSection>
113+
114+
54115
</Section>
55116

56117
<Section>
@@ -99,20 +160,3 @@ gap> HasseDiagramOfAperyListOfNumericalSemigroup(s,10);
99160

100161
</Section>
101162

102-
<Section>
103-
<Heading>
104-
Antichains
105-
</Heading>
106-
<ManSection>
107-
<Func Name="AntichainsOfNumericalSemigroup" Arg="S, A"/>
108-
<Description>
109-
<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>.
110-
<Example><![CDATA[
111-
gap> s:=NumericalSemigroup(3,5,7);;
112-
gap> AntichainsOfNumericalSemigroup(s,Gaps(s));
113-
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
114-
]]></Example>
115-
</Description>
116-
</ManSection>
117-
118-
</Section>

gap/order.gd

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,32 @@ DeclareAttribute("MaximalElements", IsPosetNS);
6868
#############################################################################
6969
DeclareAttribute("MinimalElements", IsPosetNS);
7070

71+
#############################################################################
72+
##
73+
#O UpSet(p,l)
74+
## Returns the upset of the list l in the poset p, that is, the set of
75+
## elements greater than or equal to some element of l.
76+
##
77+
#############################################################################
78+
DeclareOperation("UpSet", [IsPosetNS, IsList]);
79+
80+
#############################################################################
81+
##
82+
#O DownSet(p,l)
83+
## Returns the downset of the list l in the poset p, that is, the set of
84+
## elements less than or equal to some element of l.
85+
##
86+
#############################################################################
87+
DeclareOperation("DownSet", [IsPosetNS, IsList]);
88+
89+
#############################################################################
90+
##
91+
#O Antichains(p)
92+
## Returns the set of antichains (sets of non comparable elements) of p.
93+
##
94+
#############################################################################
95+
DeclareOperation("Antichains", [IsPosetNS]);
96+
7197
############################################################################
7298
##
7399
#F HasseDiagramOfNumericalSemigroup(s, A)

gap/order.gi

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
##
1111
#############################################################################
1212

13-
14-
1513
#############################################################################
1614
##################### Defining posets ######################
1715
#############################################################################
@@ -26,7 +24,7 @@
2624
##
2725
#############################################################################
2826
InstallMethod(PosetNS, "for list of integers and numerical semigroup",
29-
[IsList, IsNumericalSemigroup],
27+
[IsList, IsNumericalSemigroup],
3028
function(l,S)
3129
local I;
3230
if not (IsNumericalSemigroup(S)) then
@@ -54,9 +52,9 @@ end);
5452
##
5553
#############################################################################
5654
InstallMethod( ViewObj,
57-
"prints poset of a numerical semigroup",
58-
[IsPosetNS],
59-
function( p )
55+
"prints poset of a numerical semigroup",
56+
[IsPosetNS],
57+
function( p )
6058
Print("<Poset defined wrt to numerical semigroup>");
6159
end);
6260

@@ -69,9 +67,9 @@ end);
6967
##
7068
#############################################################################
7169
InstallMethod( ViewString,
72-
"prints a poset defined by a numerical semigroup",
73-
[IsPosetNS],
74-
function( p )
70+
"prints a poset defined by a numerical semigroup",
71+
[IsPosetNS],
72+
function( p )
7573
return ("Poset defined by numerical semigroup");
7674
end);
7775

@@ -83,9 +81,9 @@ end);
8381
##
8482
#############################################################################
8583
InstallMethod(String,
86-
"prints a poset defined by a numerical semigroup",
87-
[IsPosetNS],
88-
function( p )
84+
"prints a poset defined by a numerical semigroup",
85+
[IsPosetNS],
86+
function( p )
8987
return (Concatenation(String(GroundSet(p)), " ordered wrt NumericalSemigroup([",
9088
String(Generators(UnderlyingNSPoset(p))), "])"));
9189
end);
@@ -97,9 +95,9 @@ end);
9795
##
9896
#############################################################################
9997
InstallMethod(MaximalElements,
100-
"for posets defined by numerical semigroups",
101-
[IsPosetNS],
102-
function( p )
98+
"for posets defined by numerical semigroups",
99+
[IsPosetNS],
100+
function( p )
103101
local s,l,maxs,max,below;
104102
s := UnderlyingNSPoset(p);
105103
l := List(GroundSet(p));
@@ -120,9 +118,9 @@ end);
120118
##
121119
#############################################################################
122120
InstallMethod(MinimalElements,
123-
"for posets defined by numerical semigroups",
124-
[IsPosetNS],
125-
function( p )
121+
"for posets defined by numerical semigroups",
122+
[IsPosetNS],
123+
function( p )
126124
local s,l,mins,min,above;
127125
s := UnderlyingNSPoset(p);
128126
l := Reversed(List(GroundSet(p)));
@@ -136,6 +134,55 @@ InstallMethod(MinimalElements,
136134
return mins;
137135
end);
138136

137+
#############################################################################
138+
##
139+
#O UpSet(p,l)
140+
## Returns the upset of the list l in the poset p
141+
##
142+
#############################################################################
143+
InstallMethod(UpSet, "for posets defined by numerical semigroups", [IsPosetNS, IsList],
144+
function(p, l)
145+
local s;
146+
if not(IsListOfIntegersNS(l)) then
147+
Error("The second argument must be a list of integers.\n");
148+
fi;
149+
if not(IsSubset(GroundSet(p), Set(l))) then
150+
Error("The elements of the list must belong to the ground set of the poset.\n");
151+
fi;
152+
s:=UnderlyingNSPoset(p);
153+
return Filtered(GroundSet(p), x->ForAny(l, y-> x - y in s));
154+
end);
155+
156+
#############################################################################
157+
##
158+
#O DownSet(p,l)
159+
## Returns the downset of the list l in the poset p, that is, the set of
160+
## elements less than or equal to some element of l.
161+
##
162+
#############################################################################
163+
InstallMethod(DownSet, "for posets defined by numerical semigroups", [IsPosetNS, IsList],
164+
function(p, l)
165+
local s;
166+
if not(IsListOfIntegersNS(l)) then
167+
Error("The second argument must be a list of integers.\n");
168+
fi;
169+
if not(IsSubset(GroundSet(p), Set(l))) then
170+
Error("The elements of the list must belong to the ground set of the poset.\n");
171+
fi;
172+
s:=UnderlyingNSPoset(p);
173+
return Filtered(GroundSet(p), x->ForAny(l, y-> y - x in s));
174+
end);
175+
176+
#############################################################################
177+
##
178+
#O Antichains(p)
179+
## Returns the set of antichains (sets of non comparable elements) of p.
180+
##
181+
#############################################################################
182+
InstallMethod(Antichains, "for posets defined by numerical semigroups", [IsPosetNS],
183+
function(p)
184+
return AntichainsOfNumericalSemigroup(UnderlyingNSPoset(p), List(GroundSet(p)));
185+
end);
139186

140187
############################################################################
141188
##

tst/testall.tst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,7 @@ false
28642864

28652865
##orders.xml
28662866

2867-
gap> s:=NumericalSemigroup(3,5,8);;
2867+
gap> s:=NumericalSemigroup(3,5);;
28682868
gap> l:=[1..10];;
28692869
gap> p:=PosetNS(l,s);;
28702870
gap> MinimalElements(p);
@@ -2874,6 +2874,27 @@ gap> MaximalElements(p);
28742874
gap> Type(s)=Length(MaximalElements(PosetNS(AperyList(s),s)));
28752875
true
28762876

2877+
gap> s:=NumericalSemigroup(3,5,7);;
2878+
gap> l:=[1..10];;
2879+
gap> p:=PosetNS(l,s);;
2880+
gap> UpSet(p,[2,4]);
2881+
[ 2, 4, 5, 7, 8, 9, 10 ]
2882+
gap> UpSet(p,[2])=Filtered(l,i->i-2 in s);
2883+
true
2884+
2885+
gap> DownSet(p,[5,6]);
2886+
[ 1, 2, 3, 5, 6 ]
2887+
gap> p:=PosetNS(s,AperyList(s));;
2888+
gap> DownSet(p,Multiplicity(s)+PseudoFrobenius(s))=GroundSet(p);
2889+
true
2890+
2891+
gap> s:=NumericalSemigroup(3,5,7);;
2892+
gap> p:=PosetNS(s,Gaps(s));;
2893+
gap> Antichains(p);
2894+
[ [ ], [ 4 ], [ 2 ], [ 2, 4 ], [ 1 ], [ 1, 2 ] ]
2895+
gap> Antichains(p)=AntichainsOfNumericalSemigroup(s,Gaps(s));
2896+
true
2897+
28772898
gap> s:=NumericalSemigroup(3,5,7);;
28782899
gap> IsHasseDiagram(HasseDiagramOfNumericalSemigroup(s,[1,2,3]));
28792900
true

0 commit comments

Comments
 (0)