From 335f38883101843cbea8c60bf10a7de705a867ad Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 7 Feb 2024 16:03:49 +0000 Subject: [PATCH 01/40] Adding Free Semilattice constructor --- gap/semigroups/semicons.gd | 1 + gap/semigroups/semicons.gi | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gap/semigroups/semicons.gd b/gap/semigroups/semicons.gd index 6a5c16d77..3c22fa675 100644 --- a/gap/semigroups/semicons.gd +++ b/gap/semigroups/semicons.gd @@ -12,6 +12,7 @@ DeclareGlobalFunction("TrivialSemigroup"); DeclareConstructor("TrivialSemigroupCons", [IsSemigroup, IsInt]); DeclareGlobalFunction("RectangularBand"); DeclareConstructor("RectangularBandCons", [IsSemigroup, IsPosInt, IsPosInt]); +DeclareOperation("FreeSemilattice", [IsPosInt]); DeclareGlobalFunction("MonogenicSemigroup"); DeclareConstructor("MonogenicSemigroupCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("ZeroSemigroup"); diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 0c83701a1..0ba6564c6 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -406,6 +406,29 @@ for _IsXSemigroup in ["IsBooleanMatSemigroup", od; Unbind(_IsXSemigroup); +# Free semilattice + +InstallMethod(FreeSemilattice, "for a positive integer", +[IsPosInt], +function(n) + local F, gen, l, i, j, commR, idemR; + F := FreeSemigroup(n); + gen := GeneratorsOfSemigroup(F); + l := Length(gen); + + commR := []; + for i in [1 .. l - 1] do + for j in [i + 1 .. l] do + Add(commR, [gen[i] * gen[j], gen[j] * gen[i]]); + od; + od; + + idemR := List( gen, + x -> [x * x, x] + ); + return F / Concatenation(commR, idemR); +end); + # Zero semigroup: main method InstallGlobalFunction(ZeroSemigroup, From 5fb03192164efde867b77b9c9e94c6fe21dd80ea Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 7 Feb 2024 17:02:05 +0000 Subject: [PATCH 02/40] For Transformation and PartialPerm Semigroups --- gap/semigroups/semicons.gd | 3 +- gap/semigroups/semicons.gi | 95 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/gap/semigroups/semicons.gd b/gap/semigroups/semicons.gd index 3c22fa675..a5e6db18c 100644 --- a/gap/semigroups/semicons.gd +++ b/gap/semigroups/semicons.gd @@ -12,7 +12,8 @@ DeclareGlobalFunction("TrivialSemigroup"); DeclareConstructor("TrivialSemigroupCons", [IsSemigroup, IsInt]); DeclareGlobalFunction("RectangularBand"); DeclareConstructor("RectangularBandCons", [IsSemigroup, IsPosInt, IsPosInt]); -DeclareOperation("FreeSemilattice", [IsPosInt]); +DeclareGlobalFunction("FreeSemilattice"); +DeclareConstructor("FreeSemilatticeCons", [IsPosInt]); DeclareGlobalFunction("MonogenicSemigroup"); DeclareConstructor("MonogenicSemigroupCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("ZeroSemigroup"); diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 0ba6564c6..2e7ef1011 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -406,10 +406,47 @@ for _IsXSemigroup in ["IsBooleanMatSemigroup", od; Unbind(_IsXSemigroup); -# Free semilattice +# Free semilattice: main method -InstallMethod(FreeSemilattice, "for a positive integer", -[IsPosInt], +InstallGlobalFunction(FreeSemilattice, +function(arg...) + local filter, n, S; + + if Length(arg) = 1 then + filter := IsTransformationSemigroup; + n := arg[1]; + elif Length(arg) = 2 then + filter := arg[1]; + n := arg[2]; + fi; + + if not IsPosInt(n) or not IsOperation(filter) then + ErrorNoReturn("the arguments must be a positive integer or a filter ", + "and a positive integer"); + fi; + + S := FreeSemilatticeCons(filter, n); + + SetSize(S, 2^n -1); + # SetIsRectangularBand(S, true); + # SetNrRClasses(S, m); + # SetNrLClasses(S, n); + # if m <> 1 or n <> 1 then + # SetIsGroupAsSemigroup(S, false); + # SetIsZeroSemigroup(S, false); + # SetIsTrivial(S, false); + # fi; + # SetIsRightZeroSemigroup(S, m = 1); + # SetIsLeftZeroSemigroup(S, n = 1); + + return S; +end); + +# Free semilattice: constructors + +InstallMethod(FreeSemilatticeCons, +"for IsFpSemigroup and a pos int", +[IsFpSemigroup, IsPosInt], function(n) local F, gen, l, i, j, commR, idemR; F := FreeSemigroup(n); @@ -429,6 +466,58 @@ function(n) return F / Concatenation(commR, idemR); end); +InstallMethod(FreeSemilatticeCons, +"for IsTransformationSemigroup and a pos int", +[IsTransformationSemigroup, IsPosInt], +function(n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n + 1]; + L[i] := n + 1; + Add(gen, Transformation(L)); + od; + return Semigroup(gen); +end); + +InstallMethod(FreeSemilatticeCons, +"for IsPartialPermSemigroup and a pos int", +[IsPartialPermSemigroup, IsPosInt], +function(n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n]; + Remove(L, i); + Add(gen, PartialPerm(L, L)); + od; + return Semigroup(gen); +end); + +# Free semilattice: other constructors + +for _IsXSemigroup in ["IsReesMatrixSemigroup", + "IsBipartitionSemigroup", + "IsPBRSemigroup", + "IsBooleanMatSemigroup", + "IsNTPMatrixSemigroup", + "IsMaxPlusMatrixSemigroup", + "IsMinPlusMatrixSemigroup", + "IsTropicalMaxPlusMatrixSemigroup", + "IsTropicalMinPlusMatrixSemigroup", + "IsProjectiveMaxPlusMatrixSemigroup", + "IsIntegerMatrixSemigroup"] do + InstallMethod(FreeSemilatticeCons, + Concatenation("for ", _IsXSemigroup, ", and pos int"), + [ValueGlobal(_IsXSemigroup), IsPosInt], + function(filter, n) + return AsSemigroup(filter, + RectangularBandCons(IsTransformationSemigroup, n)); + end); +od; +Unbind(_IsXSemigroup); + + # Zero semigroup: main method InstallGlobalFunction(ZeroSemigroup, From 4685a06afc3c1465130de2261cca5cf240e01ac5 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Thu, 8 Feb 2024 13:18:01 +0000 Subject: [PATCH 03/40] Lint --- gap/semigroups/semicons.gi | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 2e7ef1011..3cdcb260b 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -427,7 +427,7 @@ function(arg...) S := FreeSemilatticeCons(filter, n); - SetSize(S, 2^n -1); + SetSize(S, 2 ^ n - 1); # SetIsRectangularBand(S, true); # SetNrRClasses(S, m); # SetNrLClasses(S, n); @@ -444,10 +444,10 @@ end); # Free semilattice: constructors -InstallMethod(FreeSemilatticeCons, +InstallMethod(FreeSemilatticeCons, "for IsFpSemigroup and a pos int", [IsFpSemigroup, IsPosInt], -function(n) +function(_, n) local F, gen, l, i, j, commR, idemR; F := FreeSemigroup(n); gen := GeneratorsOfSemigroup(F); @@ -460,16 +460,14 @@ function(n) od; od; - idemR := List( gen, - x -> [x * x, x] - ); + idemR := List(gen, x -> [x * x, x]); return F / Concatenation(commR, idemR); end); -InstallMethod(FreeSemilatticeCons, +InstallMethod(FreeSemilatticeCons, "for IsTransformationSemigroup and a pos int", [IsTransformationSemigroup, IsPosInt], -function(n) +function(_, n) local gen, i, L; gen := []; for i in [1 .. n] do @@ -480,10 +478,10 @@ function(n) return Semigroup(gen); end); -InstallMethod(FreeSemilatticeCons, +InstallMethod(FreeSemilatticeCons, "for IsPartialPermSemigroup and a pos int", [IsPartialPermSemigroup, IsPosInt], -function(n) +function(_, n) local gen, i, L; gen := []; for i in [1 .. n] do @@ -517,7 +515,6 @@ for _IsXSemigroup in ["IsReesMatrixSemigroup", od; Unbind(_IsXSemigroup); - # Zero semigroup: main method InstallGlobalFunction(ZeroSemigroup, From 721a464bef5017d2c4c6f43e1b011602666677e7 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:47:25 +0000 Subject: [PATCH 04/40] Update semicons.gd Number of arguments error resolved --- gap/semigroups/semicons.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gap/semigroups/semicons.gd b/gap/semigroups/semicons.gd index a5e6db18c..10089096e 100644 --- a/gap/semigroups/semicons.gd +++ b/gap/semigroups/semicons.gd @@ -13,7 +13,7 @@ DeclareConstructor("TrivialSemigroupCons", [IsSemigroup, IsInt]); DeclareGlobalFunction("RectangularBand"); DeclareConstructor("RectangularBandCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("FreeSemilattice"); -DeclareConstructor("FreeSemilatticeCons", [IsPosInt]); +DeclareConstructor("FreeSemilatticeCons", [IsSemigroup, IsPosInt]); DeclareGlobalFunction("MonogenicSemigroup"); DeclareConstructor("MonogenicSemigroupCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("ZeroSemigroup"); From 1ec0a1a26e5a9b5549cee5969e831e4dcd3b7ecd Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Sat, 10 Feb 2024 18:57:01 +0000 Subject: [PATCH 05/40] Add docs and a whole lot of tests --- doc/semicons.xml | 41 ++++++ doc/z-chap07.xml | 1 + gap/semigroups/semicons.gi | 5 +- tst/standard/semigroups/semicons.tst | 188 +++++++++++++++++++++++++++ 4 files changed, 232 insertions(+), 3 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index a5d10da52..c1267b7f7 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -147,6 +147,47 @@ true]]> <#/GAPDoc> +<#GAPDoc Label="FreeSemilattice"> + + + + A free semilattice of n generators. + + + If n is a positive integer, then this function returns a free + semilattice with n generators in the representation given by the + filter filt. + + The optional argument filt may be one of the following: + + IsTransformationSemigroup + (the default, if filt is not specified), + IsPartialPermSemigroup, + IsFpSemigroup, + IsBipartitionSemigroup, + IsPBRSemigroup, + IsBooleanMatSemigroup, + IsNTPMatrixSemigroup, + IsMaxPlusMatrixSemigroup, + IsMinPlusMatrixSemigroup, + IsTropicalMaxPlusMatrixSemigroup, + IsTropicalMinPlusMatrixSemigroup, + IsProjectiveMaxPlusMatrixSemigroup, + IsIntegerMatrixSemigroup. + + + S := FreeSemilattice(IsTransformationSemigroup, 5); + +gap> T := FreeSemilattice(IsPartialPermSemigroup, 3); + +gap> U := FreeSemilattice(IsBooleanMatSemigroup, 4); + +]]> + + +<#/GAPDoc> + <#GAPDoc Label="ZeroSemigroup"> diff --git a/doc/z-chap07.xml b/doc/z-chap07.xml index 8616e149b..ce2b680f9 100644 --- a/doc/z-chap07.xml +++ b/doc/z-chap07.xml @@ -155,6 +155,7 @@ <#Include Label = "TrivialSemigroup"> <#Include Label = "MonogenicSemigroup"> <#Include Label = "RectangularBand"> + <#Include Label = "FreeSemilattice"> <#Include Label = "ZeroSemigroup"> <#Include Label = "LeftZeroSemigroup"> <#Include Label = "BrandtSemigroup"> diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 3cdcb260b..887ec1d45 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -494,8 +494,7 @@ end); # Free semilattice: other constructors -for _IsXSemigroup in ["IsReesMatrixSemigroup", - "IsBipartitionSemigroup", +for _IsXSemigroup in ["IsBipartitionSemigroup", "IsPBRSemigroup", "IsBooleanMatSemigroup", "IsNTPMatrixSemigroup", @@ -510,7 +509,7 @@ for _IsXSemigroup in ["IsReesMatrixSemigroup", [ValueGlobal(_IsXSemigroup), IsPosInt], function(filter, n) return AsSemigroup(filter, - RectangularBandCons(IsTransformationSemigroup, n)); + FreeSemilatticeCons(IsTransformationSemigroup, n)); end); od; Unbind(_IsXSemigroup); diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index 3b5f3f24a..f134caf73 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -497,6 +497,194 @@ gap> S := RectangularBand(IsReesMatrixSemigroup, 5, 5); gap> S := RectangularBand(IsReesMatrixSemigroup, 10, 11); +# constructions: FreeSemilattice: errors +gap> S := FreeSemilattice(0); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsPartialPermSemigroup, 0); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsPermGroup, 1, 1); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsPartialPermSemigroup, true); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 100); + + +# constructions: FreeSemilattice: known properties and attributes, 17 +gap> S := FreeSemilattice(17);; +gap> HasSize(S); +true +gap> Size(S) = 2 ^ 17 - 1; +true + +# constructions: FreeSemilattice: default +gap> S := FreeSemilattice(1); + +gap> S := FreeSemilattice(2); + +gap> S := FreeSemilattice(5); + +gap> S := FreeSemilattice(21); + + + + The optional argument filt may be one of the following: + + IsTransformationSemigroup + (the default, if filt is not specified), + IsPartialPermSemigroup, + IsFpSemigroup, + IsBipartitionSemigroup, + IsPBRSemigroup, + IsBooleanMatSemigroup, + IsNTPMatrixSemigroup, + IsMaxPlusMatrixSemigroup, + IsMinPlusMatrixSemigroup, + IsTropicalMaxPlusMatrixSemigroup, + IsTropicalMinPlusMatrixSemigroup, + IsProjectiveMaxPlusMatrixSemigroup, + IsIntegerMatrixSemigroup. + + +# constructions: FreeSemilattice: transformation semigroup +gap> S := FreeSemilattice(IsTransformationSemigroup, 1); + +gap> S := FreeSemilattice(IsTransformationSemigroup, 2); + +gap> S := FreeSemilattice(IsTransformationSemigroup, 5); + +gap> S := FreeSemilattice(IsTransformationSemigroup, 11); + + +# constructions: FreeSemilattice: partial perm semigroup +S := FreeSemilattice(IsPartialPermSemigroup, 1); + +S := FreeSemilattice(IsPartialPermSemigroup, 2); + +S := FreeSemilattice(IsPartialPermSemigroup, 5); + +S := FreeSemilattice(IsPartialPermSemigroup, 11); + + +# constructions: FreeSemilattice: bipartition semigroup +S := FreeSemilattice(IsBipartitionSemigroup, 1); + +S := FreeSemilattice(IsBipartitionSemigroup, 2); + +S := FreeSemilattice(IsBipartitionSemigroup, 5); + +S := FreeSemilattice(IsBipartitionSemigroup, 11); + + +# constructions: FreeSemilattice: PBR semigroup +S := FreeSemilattice(IsPBRSemigroup, 1); + +S := FreeSemilattice(IsPBRSemigroup, 2); + +S := FreeSemilattice(IsPBRSemigroup, 5); + +S := FreeSemilattice(IsPBRSemigroup, 11); + +S := FreeSemilattice(IsBooleanMatSemigroup, 1); + +# constructions: FreeSemilattice: Boolean matrix semigroup + +S := FreeSemilattice(IsBooleanMatSemigroup, 2); + +S := FreeSemilattice(IsBooleanMatSemigroup, 5); + +S := FreeSemilattice(IsBooleanMatSemigroup, 11); + + +# constructions: FreeSemilattice: NTP matrix semigroup +S := FreeSemilattice(IsNTPMatrixSemigroup, 1); + +S := FreeSemilattice(IsNTPMatrixSemigroup, 2); + +S := FreeSemilattice(IsNTPMatrixSemigroup, 5); + +S := FreeSemilattice(IsNTPMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: max-plus matrix semigroup +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: min-plus matrix semigroup +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: tropical max-plus matrix semigroup +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: tropical min-plus matrix semigroup +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: projective max-plus matrix semigroup +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: integer matrix semigroup +S := FreeSemilattice(IsIntegerMatrixSemigroup, 1); + +S := FreeSemilattice(IsIntegerMatrixSemigroup, 2); + +S := FreeSemilattice(IsIntegerMatrixSemigroup, 5); + +S := FreeSemilattice(IsIntegerMatrixSemigroup, 11); + + # constructions: ZeroSemigroup: errors gap> S := ZeroSemigroup(0); Error, the arguments must be a positive integer or a filter and a positive int\ From f35961acad2b5dc5699ad77202a305f0dd2bc462 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Sun, 11 Feb 2024 16:50:49 +0000 Subject: [PATCH 06/40] Minor test fix --- gap/semigroups/semicons.gi | 3 +++ tst/standard/semigroups/semicons.tst | 22 ---------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 887ec1d45..3cea3db6a 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -418,6 +418,9 @@ function(arg...) elif Length(arg) = 2 then filter := arg[1]; n := arg[2]; + else + ErrorNoReturn("the arguments must be a positive integer or a filter ", + "and a positive integer"); fi; if not IsPosInt(n) or not IsOperation(filter) then diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index f134caf73..71b776f88 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -510,9 +510,6 @@ eger gap> S := FreeSemilattice(IsPartialPermSemigroup, true); Error, the arguments must be a positive integer or a filter and a positive int\ eger -gap> S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 100); - # constructions: FreeSemilattice: known properties and attributes, 17 gap> S := FreeSemilattice(17);; @@ -531,25 +528,6 @@ gap> S := FreeSemilattice(5); gap> S := FreeSemilattice(21); - - The optional argument filt may be one of the following: - - IsTransformationSemigroup - (the default, if filt is not specified), - IsPartialPermSemigroup, - IsFpSemigroup, - IsBipartitionSemigroup, - IsPBRSemigroup, - IsBooleanMatSemigroup, - IsNTPMatrixSemigroup, - IsMaxPlusMatrixSemigroup, - IsMinPlusMatrixSemigroup, - IsTropicalMaxPlusMatrixSemigroup, - IsTropicalMinPlusMatrixSemigroup, - IsProjectiveMaxPlusMatrixSemigroup, - IsIntegerMatrixSemigroup. - - # constructions: FreeSemilattice: transformation semigroup gap> S := FreeSemilattice(IsTransformationSemigroup, 1); From 432322bcd49d349551f84af1d90a15d3dc165974 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 14 Feb 2024 14:58:22 +0000 Subject: [PATCH 07/40] Dial back on the number of tests --- tst/standard/semigroups/semicons.tst | 125 --------------------------- 1 file changed, 125 deletions(-) diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index 71b776f88..b9f8d8def 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -538,131 +538,6 @@ gap> S := FreeSemilattice(IsTransformationSemigroup, 5); gap> S := FreeSemilattice(IsTransformationSemigroup, 11); -# constructions: FreeSemilattice: partial perm semigroup -S := FreeSemilattice(IsPartialPermSemigroup, 1); - -S := FreeSemilattice(IsPartialPermSemigroup, 2); - -S := FreeSemilattice(IsPartialPermSemigroup, 5); - -S := FreeSemilattice(IsPartialPermSemigroup, 11); - - -# constructions: FreeSemilattice: bipartition semigroup -S := FreeSemilattice(IsBipartitionSemigroup, 1); - -S := FreeSemilattice(IsBipartitionSemigroup, 2); - -S := FreeSemilattice(IsBipartitionSemigroup, 5); - -S := FreeSemilattice(IsBipartitionSemigroup, 11); - - -# constructions: FreeSemilattice: PBR semigroup -S := FreeSemilattice(IsPBRSemigroup, 1); - -S := FreeSemilattice(IsPBRSemigroup, 2); - -S := FreeSemilattice(IsPBRSemigroup, 5); - -S := FreeSemilattice(IsPBRSemigroup, 11); - -S := FreeSemilattice(IsBooleanMatSemigroup, 1); - -# constructions: FreeSemilattice: Boolean matrix semigroup - -S := FreeSemilattice(IsBooleanMatSemigroup, 2); - -S := FreeSemilattice(IsBooleanMatSemigroup, 5); - -S := FreeSemilattice(IsBooleanMatSemigroup, 11); - - -# constructions: FreeSemilattice: NTP matrix semigroup -S := FreeSemilattice(IsNTPMatrixSemigroup, 1); - -S := FreeSemilattice(IsNTPMatrixSemigroup, 2); - -S := FreeSemilattice(IsNTPMatrixSemigroup, 5); - -S := FreeSemilattice(IsNTPMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: max-plus matrix semigroup -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: min-plus matrix semigroup -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: tropical max-plus matrix semigroup -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: tropical min-plus matrix semigroup -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: projective max-plus matrix semigroup -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: integer matrix semigroup -S := FreeSemilattice(IsIntegerMatrixSemigroup, 1); - -S := FreeSemilattice(IsIntegerMatrixSemigroup, 2); - -S := FreeSemilattice(IsIntegerMatrixSemigroup, 5); - -S := FreeSemilattice(IsIntegerMatrixSemigroup, 11); - - # constructions: ZeroSemigroup: errors gap> S := ZeroSemigroup(0); Error, the arguments must be a positive integer or a filter and a positive int\ From 917be058f0cf3119d4b84d46320f1f098bb0bd2d Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Mon, 11 Mar 2024 15:34:21 +0000 Subject: [PATCH 08/40] Apply suggestions from code review --- doc/semicons.xml | 2 +- gap/semigroups/semicons.gi | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index c1267b7f7..e086145b8 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -151,7 +151,7 @@ true]]> - A free semilattice of n generators. + A free semilattice with n generators. If n is a positive integer, then this function returns a free diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 3cea3db6a..6cb295dfb 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -419,8 +419,7 @@ function(arg...) filter := arg[1]; n := arg[2]; else - ErrorNoReturn("the arguments must be a positive integer or a filter ", - "and a positive integer"); + ErrorNoReturn("expected 2 arguments found ", Length(arg)); fi; if not IsPosInt(n) or not IsOperation(filter) then @@ -431,16 +430,6 @@ function(arg...) S := FreeSemilatticeCons(filter, n); SetSize(S, 2 ^ n - 1); - # SetIsRectangularBand(S, true); - # SetNrRClasses(S, m); - # SetNrLClasses(S, n); - # if m <> 1 or n <> 1 then - # SetIsGroupAsSemigroup(S, false); - # SetIsZeroSemigroup(S, false); - # SetIsTrivial(S, false); - # fi; - # SetIsRightZeroSemigroup(S, m = 1); - # SetIsLeftZeroSemigroup(S, n = 1); return S; end); From 7977c3b3a31b9cc292f43287f7461a402114dd35 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 12 Mar 2024 12:36:21 +0000 Subject: [PATCH 09/40] Change tst to reflect the new error msg --- gap/semigroups/semicons.gi | 1 + tst/standard/semigroups/semicons.tst | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 6cb295dfb..746a6aded 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -430,6 +430,7 @@ function(arg...) S := FreeSemilatticeCons(filter, n); SetSize(S, 2 ^ n - 1); + SetIsSemilattice(S, true); return S; end); diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index b9f8d8def..65124c822 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -505,8 +505,7 @@ gap> S := FreeSemilattice(IsPartialPermSemigroup, 0); Error, the arguments must be a positive integer or a filter and a positive int\ eger gap> S := FreeSemilattice(IsPermGroup, 1, 1); -Error, the arguments must be a positive integer or a filter and a positive int\ -eger +Error, expected 2 arguments found 3 gap> S := FreeSemilattice(IsPartialPermSemigroup, true); Error, the arguments must be a positive integer or a filter and a positive int\ eger From b2463bb4957a9b0419df17cb6b8b7ccaa2b61288 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 13 Mar 2024 15:25:35 +0000 Subject: [PATCH 10/40] Add Monoid constructors to FreeSemilatticeCons --- doc/semicons.xml | 13 +++++ gap/semigroups/semicons.gi | 77 +++++++++++++++++++++++++++- tst/standard/semigroups/semicons.tst | 12 ++--- 3 files changed, 94 insertions(+), 8 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index e086145b8..df8c0f564 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -162,18 +162,31 @@ true]]> IsTransformationSemigroup (the default, if filt is not specified), + IsTransformationMonoid, IsPartialPermSemigroup, + IsPartialPermMonoid, IsFpSemigroup, + IsFpMonoid, IsBipartitionSemigroup, + IsBipartitionMonoid, IsPBRSemigroup, + IsPBRMonoid, IsBooleanMatSemigroup, + IsBooleanMatMonoid, IsNTPMatrixSemigroup, + IsNTPMatrixMonoid, IsMaxPlusMatrixSemigroup, + IsMaxPlusMatrixMonoid, IsMinPlusMatrixSemigroup, + IsMinPlusMatrixMonoid, IsTropicalMaxPlusMatrixSemigroup, + IsTropicalMaxPlusMatrixMonoid, IsTropicalMinPlusMatrixSemigroup, + IsTropicalMinPlusMatrixMonoid, IsProjectiveMaxPlusMatrixSemigroup, + IsProjectiveMaxPlusMatrixMonoid, IsIntegerMatrixSemigroup. + IsIntegerMatrixMonoid. [x * x, x]); + return F / Concatenation(commR, idemR); +end); + InstallMethod(FreeSemilatticeCons, "for IsTransformationSemigroup and a pos int", [IsTransformationSemigroup, IsPosInt], @@ -471,6 +496,20 @@ function(_, n) return Semigroup(gen); end); +InstallMethod(FreeSemilatticeCons, +"for IsTransformationSemigroup and a pos int", +[IsTransformationMonoid, IsPosInt], +function(_, n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n + 1]; + L[i] := n + 1; + Add(gen, Transformation(L)); + od; + return Monoid(gen); +end); + InstallMethod(FreeSemilatticeCons, "for IsPartialPermSemigroup and a pos int", [IsPartialPermSemigroup, IsPosInt], @@ -485,6 +524,20 @@ function(_, n) return Semigroup(gen); end); +InstallMethod(FreeSemilatticeCons, +"for IsPartialPermSemigroup and a pos int", +[IsPartialPermMonoid, IsPosInt], +function(_, n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n]; + Remove(L, i); + Add(gen, PartialPerm(L, L)); + od; + return Monoid(gen); +end); + # Free semilattice: other constructors for _IsXSemigroup in ["IsBipartitionSemigroup", @@ -505,6 +558,26 @@ for _IsXSemigroup in ["IsBipartitionSemigroup", FreeSemilatticeCons(IsTransformationSemigroup, n)); end); od; + +for _IsXMonoid in ["IsBipartitionMonoid", + "IsPBRMonoid", + "IsBooleanMatMonoid", + "IsNTPMatrixMonoid", + "IsMaxPlusMatrixMonoid", + "IsMinPlusMatrixMonoid", + "IsTropicalMaxPlusMatrixMonoid", + "IsTropicalMinPlusMatrixMonoid", + "IsProjectiveMaxPlusMatrixMonoid", + "IsIntegerMatrixMonoid"] do + InstallMethod(FreeSemilatticeCons, + Concatenation("for ", _IsXMonoid, ", and pos int"), + [ValueGlobal(_IsXMonoid), IsPosInt], + function(filter, n) + return AsMonoid(filter, + FreeSemilatticeCons(IsTransformationMonoid, n)); + end); +od; + Unbind(_IsXSemigroup); # Zero semigroup: main method diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index 65124c822..e66c6316e 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -521,21 +521,21 @@ true gap> S := FreeSemilattice(1); gap> S := FreeSemilattice(2); - + gap> S := FreeSemilattice(5); - + gap> S := FreeSemilattice(21); - + # constructions: FreeSemilattice: transformation semigroup gap> S := FreeSemilattice(IsTransformationSemigroup, 1); gap> S := FreeSemilattice(IsTransformationSemigroup, 2); - + gap> S := FreeSemilattice(IsTransformationSemigroup, 5); - + gap> S := FreeSemilattice(IsTransformationSemigroup, 11); - + # constructions: ZeroSemigroup: errors gap> S := ZeroSemigroup(0); From 19266ad010090f70b7df2df0825258e5db2306c3 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 13 Mar 2024 16:35:30 +0000 Subject: [PATCH 11/40] Unbind _IsXMonoid in semicons.gi --- gap/semigroups/semicons.gi | 1 + 1 file changed, 1 insertion(+) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 97dbd4f68..3689ca2e9 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -579,6 +579,7 @@ for _IsXMonoid in ["IsBipartitionMonoid", od; Unbind(_IsXSemigroup); +Unbind(_IsXMonoid); # Zero semigroup: main method From 58013b4d36f08ac324f7f880ba0922206adba432 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 13 Mar 2024 17:10:28 +0000 Subject: [PATCH 12/40] Update semicons.xml and semicons.gi files --- doc/semicons.xml | 7 ++++--- gap/semigroups/semicons.gi | 4 ++-- tst/standard/semigroups/semicons.tst | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index df8c0f564..07f2d8f78 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -191,11 +191,12 @@ true]]> S := FreeSemilattice(IsTransformationSemigroup, 5); - + gap> T := FreeSemilattice(IsPartialPermSemigroup, 3); - + gap> U := FreeSemilattice(IsBooleanMatSemigroup, 4); - + ]]> diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 3689ca2e9..a9bbddaf2 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -428,14 +428,14 @@ function(arg...) fi; S := FreeSemilatticeCons(filter, n); - + if "IsMagmaWithOne" in NamesFilter(filter) then SetSize(S, 2 ^ n); else SetSize(S, 2 ^ n - 1); fi; - # SetIsSemilattice(S, true); + SetIsSemilattice(S, true); return S; end); diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index e66c6316e..34986b2d0 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -525,7 +525,8 @@ gap> S := FreeSemilattice(2); gap> S := FreeSemilattice(5); gap> S := FreeSemilattice(21); - + # constructions: FreeSemilattice: transformation semigroup gap> S := FreeSemilattice(IsTransformationSemigroup, 1); From f430c07c457da2af4531ce10e28e0ef8044065b1 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 7 Feb 2024 16:03:49 +0000 Subject: [PATCH 13/40] Adding Free Semilattice constructor --- gap/semigroups/semicons.gd | 1 + gap/semigroups/semicons.gi | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gap/semigroups/semicons.gd b/gap/semigroups/semicons.gd index 6a5c16d77..3c22fa675 100644 --- a/gap/semigroups/semicons.gd +++ b/gap/semigroups/semicons.gd @@ -12,6 +12,7 @@ DeclareGlobalFunction("TrivialSemigroup"); DeclareConstructor("TrivialSemigroupCons", [IsSemigroup, IsInt]); DeclareGlobalFunction("RectangularBand"); DeclareConstructor("RectangularBandCons", [IsSemigroup, IsPosInt, IsPosInt]); +DeclareOperation("FreeSemilattice", [IsPosInt]); DeclareGlobalFunction("MonogenicSemigroup"); DeclareConstructor("MonogenicSemigroupCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("ZeroSemigroup"); diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 0c83701a1..0ba6564c6 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -406,6 +406,29 @@ for _IsXSemigroup in ["IsBooleanMatSemigroup", od; Unbind(_IsXSemigroup); +# Free semilattice + +InstallMethod(FreeSemilattice, "for a positive integer", +[IsPosInt], +function(n) + local F, gen, l, i, j, commR, idemR; + F := FreeSemigroup(n); + gen := GeneratorsOfSemigroup(F); + l := Length(gen); + + commR := []; + for i in [1 .. l - 1] do + for j in [i + 1 .. l] do + Add(commR, [gen[i] * gen[j], gen[j] * gen[i]]); + od; + od; + + idemR := List( gen, + x -> [x * x, x] + ); + return F / Concatenation(commR, idemR); +end); + # Zero semigroup: main method InstallGlobalFunction(ZeroSemigroup, From 6a6fcf9525bd25e0ce4d25e6db7041a8d04ab47d Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 7 Feb 2024 17:02:05 +0000 Subject: [PATCH 14/40] For Transformation and PartialPerm Semigroups --- gap/semigroups/semicons.gd | 3 +- gap/semigroups/semicons.gi | 95 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/gap/semigroups/semicons.gd b/gap/semigroups/semicons.gd index 3c22fa675..a5e6db18c 100644 --- a/gap/semigroups/semicons.gd +++ b/gap/semigroups/semicons.gd @@ -12,7 +12,8 @@ DeclareGlobalFunction("TrivialSemigroup"); DeclareConstructor("TrivialSemigroupCons", [IsSemigroup, IsInt]); DeclareGlobalFunction("RectangularBand"); DeclareConstructor("RectangularBandCons", [IsSemigroup, IsPosInt, IsPosInt]); -DeclareOperation("FreeSemilattice", [IsPosInt]); +DeclareGlobalFunction("FreeSemilattice"); +DeclareConstructor("FreeSemilatticeCons", [IsPosInt]); DeclareGlobalFunction("MonogenicSemigroup"); DeclareConstructor("MonogenicSemigroupCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("ZeroSemigroup"); diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 0ba6564c6..2e7ef1011 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -406,10 +406,47 @@ for _IsXSemigroup in ["IsBooleanMatSemigroup", od; Unbind(_IsXSemigroup); -# Free semilattice +# Free semilattice: main method -InstallMethod(FreeSemilattice, "for a positive integer", -[IsPosInt], +InstallGlobalFunction(FreeSemilattice, +function(arg...) + local filter, n, S; + + if Length(arg) = 1 then + filter := IsTransformationSemigroup; + n := arg[1]; + elif Length(arg) = 2 then + filter := arg[1]; + n := arg[2]; + fi; + + if not IsPosInt(n) or not IsOperation(filter) then + ErrorNoReturn("the arguments must be a positive integer or a filter ", + "and a positive integer"); + fi; + + S := FreeSemilatticeCons(filter, n); + + SetSize(S, 2^n -1); + # SetIsRectangularBand(S, true); + # SetNrRClasses(S, m); + # SetNrLClasses(S, n); + # if m <> 1 or n <> 1 then + # SetIsGroupAsSemigroup(S, false); + # SetIsZeroSemigroup(S, false); + # SetIsTrivial(S, false); + # fi; + # SetIsRightZeroSemigroup(S, m = 1); + # SetIsLeftZeroSemigroup(S, n = 1); + + return S; +end); + +# Free semilattice: constructors + +InstallMethod(FreeSemilatticeCons, +"for IsFpSemigroup and a pos int", +[IsFpSemigroup, IsPosInt], function(n) local F, gen, l, i, j, commR, idemR; F := FreeSemigroup(n); @@ -429,6 +466,58 @@ function(n) return F / Concatenation(commR, idemR); end); +InstallMethod(FreeSemilatticeCons, +"for IsTransformationSemigroup and a pos int", +[IsTransformationSemigroup, IsPosInt], +function(n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n + 1]; + L[i] := n + 1; + Add(gen, Transformation(L)); + od; + return Semigroup(gen); +end); + +InstallMethod(FreeSemilatticeCons, +"for IsPartialPermSemigroup and a pos int", +[IsPartialPermSemigroup, IsPosInt], +function(n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n]; + Remove(L, i); + Add(gen, PartialPerm(L, L)); + od; + return Semigroup(gen); +end); + +# Free semilattice: other constructors + +for _IsXSemigroup in ["IsReesMatrixSemigroup", + "IsBipartitionSemigroup", + "IsPBRSemigroup", + "IsBooleanMatSemigroup", + "IsNTPMatrixSemigroup", + "IsMaxPlusMatrixSemigroup", + "IsMinPlusMatrixSemigroup", + "IsTropicalMaxPlusMatrixSemigroup", + "IsTropicalMinPlusMatrixSemigroup", + "IsProjectiveMaxPlusMatrixSemigroup", + "IsIntegerMatrixSemigroup"] do + InstallMethod(FreeSemilatticeCons, + Concatenation("for ", _IsXSemigroup, ", and pos int"), + [ValueGlobal(_IsXSemigroup), IsPosInt], + function(filter, n) + return AsSemigroup(filter, + RectangularBandCons(IsTransformationSemigroup, n)); + end); +od; +Unbind(_IsXSemigroup); + + # Zero semigroup: main method InstallGlobalFunction(ZeroSemigroup, From d952a4ad7896abdaf406009a58503b7d2e141474 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Thu, 8 Feb 2024 13:18:01 +0000 Subject: [PATCH 15/40] Lint --- gap/semigroups/semicons.gi | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 2e7ef1011..3cdcb260b 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -427,7 +427,7 @@ function(arg...) S := FreeSemilatticeCons(filter, n); - SetSize(S, 2^n -1); + SetSize(S, 2 ^ n - 1); # SetIsRectangularBand(S, true); # SetNrRClasses(S, m); # SetNrLClasses(S, n); @@ -444,10 +444,10 @@ end); # Free semilattice: constructors -InstallMethod(FreeSemilatticeCons, +InstallMethod(FreeSemilatticeCons, "for IsFpSemigroup and a pos int", [IsFpSemigroup, IsPosInt], -function(n) +function(_, n) local F, gen, l, i, j, commR, idemR; F := FreeSemigroup(n); gen := GeneratorsOfSemigroup(F); @@ -460,16 +460,14 @@ function(n) od; od; - idemR := List( gen, - x -> [x * x, x] - ); + idemR := List(gen, x -> [x * x, x]); return F / Concatenation(commR, idemR); end); -InstallMethod(FreeSemilatticeCons, +InstallMethod(FreeSemilatticeCons, "for IsTransformationSemigroup and a pos int", [IsTransformationSemigroup, IsPosInt], -function(n) +function(_, n) local gen, i, L; gen := []; for i in [1 .. n] do @@ -480,10 +478,10 @@ function(n) return Semigroup(gen); end); -InstallMethod(FreeSemilatticeCons, +InstallMethod(FreeSemilatticeCons, "for IsPartialPermSemigroup and a pos int", [IsPartialPermSemigroup, IsPosInt], -function(n) +function(_, n) local gen, i, L; gen := []; for i in [1 .. n] do @@ -517,7 +515,6 @@ for _IsXSemigroup in ["IsReesMatrixSemigroup", od; Unbind(_IsXSemigroup); - # Zero semigroup: main method InstallGlobalFunction(ZeroSemigroup, From a15a71374d74d13b0b506e3a657b6af387f30962 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:47:25 +0000 Subject: [PATCH 16/40] Update semicons.gd Number of arguments error resolved --- gap/semigroups/semicons.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gap/semigroups/semicons.gd b/gap/semigroups/semicons.gd index a5e6db18c..10089096e 100644 --- a/gap/semigroups/semicons.gd +++ b/gap/semigroups/semicons.gd @@ -13,7 +13,7 @@ DeclareConstructor("TrivialSemigroupCons", [IsSemigroup, IsInt]); DeclareGlobalFunction("RectangularBand"); DeclareConstructor("RectangularBandCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("FreeSemilattice"); -DeclareConstructor("FreeSemilatticeCons", [IsPosInt]); +DeclareConstructor("FreeSemilatticeCons", [IsSemigroup, IsPosInt]); DeclareGlobalFunction("MonogenicSemigroup"); DeclareConstructor("MonogenicSemigroupCons", [IsSemigroup, IsPosInt, IsPosInt]); DeclareGlobalFunction("ZeroSemigroup"); From 6bc998937c72a2c8f4f3e1206639e7b4d0194bb8 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Sat, 10 Feb 2024 18:57:01 +0000 Subject: [PATCH 17/40] Add docs and a whole lot of tests --- doc/semicons.xml | 41 ++++++ doc/z-chap07.xml | 1 + gap/semigroups/semicons.gi | 5 +- tst/standard/semigroups/semicons.tst | 188 +++++++++++++++++++++++++++ 4 files changed, 232 insertions(+), 3 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index a5d10da52..c1267b7f7 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -147,6 +147,47 @@ true]]> <#/GAPDoc> +<#GAPDoc Label="FreeSemilattice"> + + + + A free semilattice of n generators. + + + If n is a positive integer, then this function returns a free + semilattice with n generators in the representation given by the + filter filt. + + The optional argument filt may be one of the following: + + IsTransformationSemigroup + (the default, if filt is not specified), + IsPartialPermSemigroup, + IsFpSemigroup, + IsBipartitionSemigroup, + IsPBRSemigroup, + IsBooleanMatSemigroup, + IsNTPMatrixSemigroup, + IsMaxPlusMatrixSemigroup, + IsMinPlusMatrixSemigroup, + IsTropicalMaxPlusMatrixSemigroup, + IsTropicalMinPlusMatrixSemigroup, + IsProjectiveMaxPlusMatrixSemigroup, + IsIntegerMatrixSemigroup. + + + S := FreeSemilattice(IsTransformationSemigroup, 5); + +gap> T := FreeSemilattice(IsPartialPermSemigroup, 3); + +gap> U := FreeSemilattice(IsBooleanMatSemigroup, 4); + +]]> + + +<#/GAPDoc> + <#GAPDoc Label="ZeroSemigroup"> diff --git a/doc/z-chap07.xml b/doc/z-chap07.xml index 8616e149b..ce2b680f9 100644 --- a/doc/z-chap07.xml +++ b/doc/z-chap07.xml @@ -155,6 +155,7 @@ <#Include Label = "TrivialSemigroup"> <#Include Label = "MonogenicSemigroup"> <#Include Label = "RectangularBand"> + <#Include Label = "FreeSemilattice"> <#Include Label = "ZeroSemigroup"> <#Include Label = "LeftZeroSemigroup"> <#Include Label = "BrandtSemigroup"> diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 3cdcb260b..887ec1d45 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -494,8 +494,7 @@ end); # Free semilattice: other constructors -for _IsXSemigroup in ["IsReesMatrixSemigroup", - "IsBipartitionSemigroup", +for _IsXSemigroup in ["IsBipartitionSemigroup", "IsPBRSemigroup", "IsBooleanMatSemigroup", "IsNTPMatrixSemigroup", @@ -510,7 +509,7 @@ for _IsXSemigroup in ["IsReesMatrixSemigroup", [ValueGlobal(_IsXSemigroup), IsPosInt], function(filter, n) return AsSemigroup(filter, - RectangularBandCons(IsTransformationSemigroup, n)); + FreeSemilatticeCons(IsTransformationSemigroup, n)); end); od; Unbind(_IsXSemigroup); diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index 3b5f3f24a..f134caf73 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -497,6 +497,194 @@ gap> S := RectangularBand(IsReesMatrixSemigroup, 5, 5); gap> S := RectangularBand(IsReesMatrixSemigroup, 10, 11); +# constructions: FreeSemilattice: errors +gap> S := FreeSemilattice(0); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsPartialPermSemigroup, 0); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsPermGroup, 1, 1); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsPartialPermSemigroup, true); +Error, the arguments must be a positive integer or a filter and a positive int\ +eger +gap> S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 100); + + +# constructions: FreeSemilattice: known properties and attributes, 17 +gap> S := FreeSemilattice(17);; +gap> HasSize(S); +true +gap> Size(S) = 2 ^ 17 - 1; +true + +# constructions: FreeSemilattice: default +gap> S := FreeSemilattice(1); + +gap> S := FreeSemilattice(2); + +gap> S := FreeSemilattice(5); + +gap> S := FreeSemilattice(21); + + + + The optional argument filt may be one of the following: + + IsTransformationSemigroup + (the default, if filt is not specified), + IsPartialPermSemigroup, + IsFpSemigroup, + IsBipartitionSemigroup, + IsPBRSemigroup, + IsBooleanMatSemigroup, + IsNTPMatrixSemigroup, + IsMaxPlusMatrixSemigroup, + IsMinPlusMatrixSemigroup, + IsTropicalMaxPlusMatrixSemigroup, + IsTropicalMinPlusMatrixSemigroup, + IsProjectiveMaxPlusMatrixSemigroup, + IsIntegerMatrixSemigroup. + + +# constructions: FreeSemilattice: transformation semigroup +gap> S := FreeSemilattice(IsTransformationSemigroup, 1); + +gap> S := FreeSemilattice(IsTransformationSemigroup, 2); + +gap> S := FreeSemilattice(IsTransformationSemigroup, 5); + +gap> S := FreeSemilattice(IsTransformationSemigroup, 11); + + +# constructions: FreeSemilattice: partial perm semigroup +S := FreeSemilattice(IsPartialPermSemigroup, 1); + +S := FreeSemilattice(IsPartialPermSemigroup, 2); + +S := FreeSemilattice(IsPartialPermSemigroup, 5); + +S := FreeSemilattice(IsPartialPermSemigroup, 11); + + +# constructions: FreeSemilattice: bipartition semigroup +S := FreeSemilattice(IsBipartitionSemigroup, 1); + +S := FreeSemilattice(IsBipartitionSemigroup, 2); + +S := FreeSemilattice(IsBipartitionSemigroup, 5); + +S := FreeSemilattice(IsBipartitionSemigroup, 11); + + +# constructions: FreeSemilattice: PBR semigroup +S := FreeSemilattice(IsPBRSemigroup, 1); + +S := FreeSemilattice(IsPBRSemigroup, 2); + +S := FreeSemilattice(IsPBRSemigroup, 5); + +S := FreeSemilattice(IsPBRSemigroup, 11); + +S := FreeSemilattice(IsBooleanMatSemigroup, 1); + +# constructions: FreeSemilattice: Boolean matrix semigroup + +S := FreeSemilattice(IsBooleanMatSemigroup, 2); + +S := FreeSemilattice(IsBooleanMatSemigroup, 5); + +S := FreeSemilattice(IsBooleanMatSemigroup, 11); + + +# constructions: FreeSemilattice: NTP matrix semigroup +S := FreeSemilattice(IsNTPMatrixSemigroup, 1); + +S := FreeSemilattice(IsNTPMatrixSemigroup, 2); + +S := FreeSemilattice(IsNTPMatrixSemigroup, 5); + +S := FreeSemilattice(IsNTPMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: max-plus matrix semigroup +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: min-plus matrix semigroup +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsMinPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: tropical max-plus matrix semigroup +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: tropical min-plus matrix semigroup +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: projective max-plus matrix semigroup +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 1); + +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 2); + +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 5); + +S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 11); + + +# constructions: FreeSemilattice: integer matrix semigroup +S := FreeSemilattice(IsIntegerMatrixSemigroup, 1); + +S := FreeSemilattice(IsIntegerMatrixSemigroup, 2); + +S := FreeSemilattice(IsIntegerMatrixSemigroup, 5); + +S := FreeSemilattice(IsIntegerMatrixSemigroup, 11); + + # constructions: ZeroSemigroup: errors gap> S := ZeroSemigroup(0); Error, the arguments must be a positive integer or a filter and a positive int\ From d80fd74dca1265f77e414b714065d9cfe42fbacf Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Sun, 11 Feb 2024 16:50:49 +0000 Subject: [PATCH 18/40] Minor test fix --- gap/semigroups/semicons.gi | 3 +++ tst/standard/semigroups/semicons.tst | 22 ---------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 887ec1d45..3cea3db6a 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -418,6 +418,9 @@ function(arg...) elif Length(arg) = 2 then filter := arg[1]; n := arg[2]; + else + ErrorNoReturn("the arguments must be a positive integer or a filter ", + "and a positive integer"); fi; if not IsPosInt(n) or not IsOperation(filter) then diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index f134caf73..71b776f88 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -510,9 +510,6 @@ eger gap> S := FreeSemilattice(IsPartialPermSemigroup, true); Error, the arguments must be a positive integer or a filter and a positive int\ eger -gap> S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 100); - # constructions: FreeSemilattice: known properties and attributes, 17 gap> S := FreeSemilattice(17);; @@ -531,25 +528,6 @@ gap> S := FreeSemilattice(5); gap> S := FreeSemilattice(21); - - The optional argument filt may be one of the following: - - IsTransformationSemigroup - (the default, if filt is not specified), - IsPartialPermSemigroup, - IsFpSemigroup, - IsBipartitionSemigroup, - IsPBRSemigroup, - IsBooleanMatSemigroup, - IsNTPMatrixSemigroup, - IsMaxPlusMatrixSemigroup, - IsMinPlusMatrixSemigroup, - IsTropicalMaxPlusMatrixSemigroup, - IsTropicalMinPlusMatrixSemigroup, - IsProjectiveMaxPlusMatrixSemigroup, - IsIntegerMatrixSemigroup. - - # constructions: FreeSemilattice: transformation semigroup gap> S := FreeSemilattice(IsTransformationSemigroup, 1); From 2e4c7aabc7d4bc1c41a9d93388dd4ebf98683b51 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 14 Feb 2024 14:58:22 +0000 Subject: [PATCH 19/40] Dial back on the number of tests --- tst/standard/semigroups/semicons.tst | 125 --------------------------- 1 file changed, 125 deletions(-) diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index 71b776f88..b9f8d8def 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -538,131 +538,6 @@ gap> S := FreeSemilattice(IsTransformationSemigroup, 5); gap> S := FreeSemilattice(IsTransformationSemigroup, 11); -# constructions: FreeSemilattice: partial perm semigroup -S := FreeSemilattice(IsPartialPermSemigroup, 1); - -S := FreeSemilattice(IsPartialPermSemigroup, 2); - -S := FreeSemilattice(IsPartialPermSemigroup, 5); - -S := FreeSemilattice(IsPartialPermSemigroup, 11); - - -# constructions: FreeSemilattice: bipartition semigroup -S := FreeSemilattice(IsBipartitionSemigroup, 1); - -S := FreeSemilattice(IsBipartitionSemigroup, 2); - -S := FreeSemilattice(IsBipartitionSemigroup, 5); - -S := FreeSemilattice(IsBipartitionSemigroup, 11); - - -# constructions: FreeSemilattice: PBR semigroup -S := FreeSemilattice(IsPBRSemigroup, 1); - -S := FreeSemilattice(IsPBRSemigroup, 2); - -S := FreeSemilattice(IsPBRSemigroup, 5); - -S := FreeSemilattice(IsPBRSemigroup, 11); - -S := FreeSemilattice(IsBooleanMatSemigroup, 1); - -# constructions: FreeSemilattice: Boolean matrix semigroup - -S := FreeSemilattice(IsBooleanMatSemigroup, 2); - -S := FreeSemilattice(IsBooleanMatSemigroup, 5); - -S := FreeSemilattice(IsBooleanMatSemigroup, 11); - - -# constructions: FreeSemilattice: NTP matrix semigroup -S := FreeSemilattice(IsNTPMatrixSemigroup, 1); - -S := FreeSemilattice(IsNTPMatrixSemigroup, 2); - -S := FreeSemilattice(IsNTPMatrixSemigroup, 5); - -S := FreeSemilattice(IsNTPMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: max-plus matrix semigroup -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsMaxPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: min-plus matrix semigroup -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsMinPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: tropical max-plus matrix semigroup -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsTropicalMaxPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: tropical min-plus matrix semigroup -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsTropicalMinPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: projective max-plus matrix semigroup -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 1); - -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 2); - -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 5); - -S := FreeSemilattice(IsProjectiveMaxPlusMatrixSemigroup, 11); - - -# constructions: FreeSemilattice: integer matrix semigroup -S := FreeSemilattice(IsIntegerMatrixSemigroup, 1); - -S := FreeSemilattice(IsIntegerMatrixSemigroup, 2); - -S := FreeSemilattice(IsIntegerMatrixSemigroup, 5); - -S := FreeSemilattice(IsIntegerMatrixSemigroup, 11); - - # constructions: ZeroSemigroup: errors gap> S := ZeroSemigroup(0); Error, the arguments must be a positive integer or a filter and a positive int\ From 1cc19e1a64c1eeda2e688c931e0e23799b15d8b1 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Mon, 11 Mar 2024 15:34:21 +0000 Subject: [PATCH 20/40] Apply suggestions from code review --- doc/semicons.xml | 2 +- gap/semigroups/semicons.gi | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index c1267b7f7..e086145b8 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -151,7 +151,7 @@ true]]> - A free semilattice of n generators. + A free semilattice with n generators. If n is a positive integer, then this function returns a free diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 3cea3db6a..6cb295dfb 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -419,8 +419,7 @@ function(arg...) filter := arg[1]; n := arg[2]; else - ErrorNoReturn("the arguments must be a positive integer or a filter ", - "and a positive integer"); + ErrorNoReturn("expected 2 arguments found ", Length(arg)); fi; if not IsPosInt(n) or not IsOperation(filter) then @@ -431,16 +430,6 @@ function(arg...) S := FreeSemilatticeCons(filter, n); SetSize(S, 2 ^ n - 1); - # SetIsRectangularBand(S, true); - # SetNrRClasses(S, m); - # SetNrLClasses(S, n); - # if m <> 1 or n <> 1 then - # SetIsGroupAsSemigroup(S, false); - # SetIsZeroSemigroup(S, false); - # SetIsTrivial(S, false); - # fi; - # SetIsRightZeroSemigroup(S, m = 1); - # SetIsLeftZeroSemigroup(S, n = 1); return S; end); From c9c20625efea6a10c8b2f8d3ffedab35c12a694e Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 12 Mar 2024 12:36:21 +0000 Subject: [PATCH 21/40] Change tst to reflect the new error msg --- gap/semigroups/semicons.gi | 1 + tst/standard/semigroups/semicons.tst | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 6cb295dfb..746a6aded 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -430,6 +430,7 @@ function(arg...) S := FreeSemilatticeCons(filter, n); SetSize(S, 2 ^ n - 1); + SetIsSemilattice(S, true); return S; end); diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index b9f8d8def..65124c822 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -505,8 +505,7 @@ gap> S := FreeSemilattice(IsPartialPermSemigroup, 0); Error, the arguments must be a positive integer or a filter and a positive int\ eger gap> S := FreeSemilattice(IsPermGroup, 1, 1); -Error, the arguments must be a positive integer or a filter and a positive int\ -eger +Error, expected 2 arguments found 3 gap> S := FreeSemilattice(IsPartialPermSemigroup, true); Error, the arguments must be a positive integer or a filter and a positive int\ eger From a36b83480902fde4fca913a0d15900a65a83cc44 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 13 Mar 2024 15:25:35 +0000 Subject: [PATCH 22/40] Add Monoid constructors to FreeSemilatticeCons --- doc/semicons.xml | 13 +++++ gap/semigroups/semicons.gi | 77 +++++++++++++++++++++++++++- tst/standard/semigroups/semicons.tst | 12 ++--- 3 files changed, 94 insertions(+), 8 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index e086145b8..df8c0f564 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -162,18 +162,31 @@ true]]> IsTransformationSemigroup (the default, if filt is not specified), + IsTransformationMonoid, IsPartialPermSemigroup, + IsPartialPermMonoid, IsFpSemigroup, + IsFpMonoid, IsBipartitionSemigroup, + IsBipartitionMonoid, IsPBRSemigroup, + IsPBRMonoid, IsBooleanMatSemigroup, + IsBooleanMatMonoid, IsNTPMatrixSemigroup, + IsNTPMatrixMonoid, IsMaxPlusMatrixSemigroup, + IsMaxPlusMatrixMonoid, IsMinPlusMatrixSemigroup, + IsMinPlusMatrixMonoid, IsTropicalMaxPlusMatrixSemigroup, + IsTropicalMaxPlusMatrixMonoid, IsTropicalMinPlusMatrixSemigroup, + IsTropicalMinPlusMatrixMonoid, IsProjectiveMaxPlusMatrixSemigroup, + IsProjectiveMaxPlusMatrixMonoid, IsIntegerMatrixSemigroup. + IsIntegerMatrixMonoid. [x * x, x]); + return F / Concatenation(commR, idemR); +end); + InstallMethod(FreeSemilatticeCons, "for IsTransformationSemigroup and a pos int", [IsTransformationSemigroup, IsPosInt], @@ -471,6 +496,20 @@ function(_, n) return Semigroup(gen); end); +InstallMethod(FreeSemilatticeCons, +"for IsTransformationSemigroup and a pos int", +[IsTransformationMonoid, IsPosInt], +function(_, n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n + 1]; + L[i] := n + 1; + Add(gen, Transformation(L)); + od; + return Monoid(gen); +end); + InstallMethod(FreeSemilatticeCons, "for IsPartialPermSemigroup and a pos int", [IsPartialPermSemigroup, IsPosInt], @@ -485,6 +524,20 @@ function(_, n) return Semigroup(gen); end); +InstallMethod(FreeSemilatticeCons, +"for IsPartialPermSemigroup and a pos int", +[IsPartialPermMonoid, IsPosInt], +function(_, n) + local gen, i, L; + gen := []; + for i in [1 .. n] do + L := [1 .. n]; + Remove(L, i); + Add(gen, PartialPerm(L, L)); + od; + return Monoid(gen); +end); + # Free semilattice: other constructors for _IsXSemigroup in ["IsBipartitionSemigroup", @@ -505,6 +558,26 @@ for _IsXSemigroup in ["IsBipartitionSemigroup", FreeSemilatticeCons(IsTransformationSemigroup, n)); end); od; + +for _IsXMonoid in ["IsBipartitionMonoid", + "IsPBRMonoid", + "IsBooleanMatMonoid", + "IsNTPMatrixMonoid", + "IsMaxPlusMatrixMonoid", + "IsMinPlusMatrixMonoid", + "IsTropicalMaxPlusMatrixMonoid", + "IsTropicalMinPlusMatrixMonoid", + "IsProjectiveMaxPlusMatrixMonoid", + "IsIntegerMatrixMonoid"] do + InstallMethod(FreeSemilatticeCons, + Concatenation("for ", _IsXMonoid, ", and pos int"), + [ValueGlobal(_IsXMonoid), IsPosInt], + function(filter, n) + return AsMonoid(filter, + FreeSemilatticeCons(IsTransformationMonoid, n)); + end); +od; + Unbind(_IsXSemigroup); # Zero semigroup: main method diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index 65124c822..e66c6316e 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -521,21 +521,21 @@ true gap> S := FreeSemilattice(1); gap> S := FreeSemilattice(2); - + gap> S := FreeSemilattice(5); - + gap> S := FreeSemilattice(21); - + # constructions: FreeSemilattice: transformation semigroup gap> S := FreeSemilattice(IsTransformationSemigroup, 1); gap> S := FreeSemilattice(IsTransformationSemigroup, 2); - + gap> S := FreeSemilattice(IsTransformationSemigroup, 5); - + gap> S := FreeSemilattice(IsTransformationSemigroup, 11); - + # constructions: ZeroSemigroup: errors gap> S := ZeroSemigroup(0); From c583ad60a26cd15a9127d2b2fb6f5f56e2dfc1b3 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 13 Mar 2024 16:35:30 +0000 Subject: [PATCH 23/40] Unbind _IsXMonoid in semicons.gi --- gap/semigroups/semicons.gi | 1 + 1 file changed, 1 insertion(+) diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 97dbd4f68..3689ca2e9 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -579,6 +579,7 @@ for _IsXMonoid in ["IsBipartitionMonoid", od; Unbind(_IsXSemigroup); +Unbind(_IsXMonoid); # Zero semigroup: main method From fa9344fa86f7578e6c1e763dc7fafb01f39b1757 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 13 Mar 2024 17:10:28 +0000 Subject: [PATCH 24/40] Update semicons.xml and semicons.gi files --- doc/semicons.xml | 7 ++++--- gap/semigroups/semicons.gi | 4 ++-- tst/standard/semigroups/semicons.tst | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/semicons.xml b/doc/semicons.xml index df8c0f564..07f2d8f78 100644 --- a/doc/semicons.xml +++ b/doc/semicons.xml @@ -191,11 +191,12 @@ true]]> S := FreeSemilattice(IsTransformationSemigroup, 5); - + gap> T := FreeSemilattice(IsPartialPermSemigroup, 3); - + gap> U := FreeSemilattice(IsBooleanMatSemigroup, 4); - + ]]> diff --git a/gap/semigroups/semicons.gi b/gap/semigroups/semicons.gi index 3689ca2e9..a9bbddaf2 100644 --- a/gap/semigroups/semicons.gi +++ b/gap/semigroups/semicons.gi @@ -428,14 +428,14 @@ function(arg...) fi; S := FreeSemilatticeCons(filter, n); - + if "IsMagmaWithOne" in NamesFilter(filter) then SetSize(S, 2 ^ n); else SetSize(S, 2 ^ n - 1); fi; - # SetIsSemilattice(S, true); + SetIsSemilattice(S, true); return S; end); diff --git a/tst/standard/semigroups/semicons.tst b/tst/standard/semigroups/semicons.tst index e66c6316e..34986b2d0 100644 --- a/tst/standard/semigroups/semicons.tst +++ b/tst/standard/semigroups/semicons.tst @@ -525,7 +525,8 @@ gap> S := FreeSemilattice(2); gap> S := FreeSemilattice(5); gap> S := FreeSemilattice(21); - + # constructions: FreeSemilattice: transformation semigroup gap> S := FreeSemilattice(IsTransformationSemigroup, 1); From cfda100dc695e54db5e5b470917ba6ad01151441 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Wed, 20 Mar 2024 16:47:10 +0000 Subject: [PATCH 25/40] Add left and right semigroup ideal support --- gap/ideals/froidure-pin.gd | 2 + gap/ideals/froidure-pin.gi | 42 ++++++++++ gap/ideals/ideals.gd | 21 +++-- gap/ideals/ideals.gi | 156 ++++++++++++++++++++++++++++++++----- 4 files changed, 195 insertions(+), 26 deletions(-) diff --git a/gap/ideals/froidure-pin.gd b/gap/ideals/froidure-pin.gd index b06e73058..37b974239 100644 --- a/gap/ideals/froidure-pin.gd +++ b/gap/ideals/froidure-pin.gd @@ -9,3 +9,5 @@ ## DeclareAttribute("PositionsInSupersemigroup", IsSemigroupIdeal); +DeclareAttribute("PositionsInSupersemigroup", IsLeftSemigroupIdeal); +DeclareAttribute("PositionsInSupersemigroup", IsRightSemigroupIdeal); diff --git a/gap/ideals/froidure-pin.gi b/gap/ideals/froidure-pin.gi index 5a3c59e6a..43004cbd1 100644 --- a/gap/ideals/froidure-pin.gi +++ b/gap/ideals/froidure-pin.gi @@ -39,6 +39,48 @@ function(I) return result; end); +InstallMethod(PositionsInSupersemigroup, +"for a left semigroup ideal with known generators", +[IsLeftSemigroupIdeal and HasGeneratorsOfSemigroupIdeal and + CanUseFroidurePin], +function(I) + local S, L, R, D, result, pos, x; + S := SupersemigroupOfIdeal(I); + L := LeftCayleyDigraph(S); + + result := []; + for x in GeneratorsOfSemigroupIdeal(I) do + pos := PositionCanonical(S, x); + if not pos in result then + AddSet(result, pos); + UniteSet(result, VerticesReachableFrom(L, pos)); + fi; + od; + + return result; +end); + +InstallMethod(PositionsInSupersemigroup, +"for a right semigroup ideal with known generators", +[IsRightSemigroupIdeal and HasGeneratorsOfSemigroupIdeal and + CanUseFroidurePin], +function(I) + local S, L, R, D, result, pos, x; + S := SupersemigroupOfIdeal(I); + R := RightCayleyDigraph(S); + + result := []; + for x in GeneratorsOfSemigroupIdeal(I) do + pos := PositionCanonical(S, x); + if not pos in result then + AddSet(result, pos); + UniteSet(result, VerticesReachableFrom(R, pos)); + fi; + od; + + return result; +end); + InstallMethod(GeneratorsOfInverseSemigroup, "for an inverse semigroup ideal with inverse op and generators", [IsSemigroupIdeal and IsInverseSemigroup diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index 3d6a12cb6..8beac91a4 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -8,16 +8,23 @@ ############################################################################# DeclareSynonymAttr("GeneratorsOfSemigroupIdeal", GeneratorsOfMagmaIdeal); +DeclareSynonymAttr("GeneratorsOfLeftSemigroupIdeal", + GeneratorsOfLeftMagmaIdeal); +DeclareSynonymAttr("GeneratorsOfRightSemigroupIdeal", + GeneratorsOfRightMagmaIdeal); + DeclareGlobalFunction("SemigroupIdeal"); +DeclareGlobalFunction("LeftSemigroupIdeal"); +DeclareGlobalFunction("RightSemigroupIdeal"); -DeclareOperation("SemigroupIdealByGenerators", - [IsSemigroup, IsListOrCollection]); +DeclareOperation("AnySemigroupIdealByGenerators", + [IsSemigroup, IsOperation, IsListOrCollection]); -DeclareOperation("SemigroupIdealByGenerators", - [IsSemigroup, IsListOrCollection, IsRecord]); +DeclareOperation("AnySemigroupIdealByGenerators", + [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); -DeclareOperation("SemigroupIdealByGeneratorsNC", - [IsSemigroup, IsListOrCollection, IsRecord]); +DeclareOperation("AnySemigroupIdealByGeneratorsNC", + [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); @@ -40,6 +47,6 @@ DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); DeclareAttribute("SupersemigroupOfIdeal", IsSemigroupIdeal); -InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); +InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); # Duplicate with ideal.gi? DeclareAttribute("Ideals", IsSemigroup); diff --git a/gap/ideals/ideals.gi b/gap/ideals/ideals.gi index 7b47706e5..5a75f3085 100644 --- a/gap/ideals/ideals.gi +++ b/gap/ideals/ideals.gi @@ -14,6 +14,12 @@ InstallImmediateMethod(IsSemigroupIdeal, IsSemigroup, 0, IsMagmaIdeal); InstallTrueMethod(IsSemigroupIdeal, IsMagmaIdeal and IsSemigroup); InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); +InstallImmediateMethod(IsLeftSemigroupIdeal, IsSemigroup, 0, IsLeftMagmaIdeal); +InstallTrueMethod(IsLeftSemigroupIdeal, IsLeftMagmaIdeal and IsSemigroup); +InstallTrueMethod(IsSemigroup, IsLeftSemigroupIdeal); +InstallImmediateMethod(IsRightSemigroupIdeal, IsSemigroup, 0, IsRightMagmaIdeal); +InstallTrueMethod(IsRightSemigroupIdeal, IsRightMagmaIdeal and IsSemigroup); +InstallTrueMethod(IsSemigroup, IsRightSemigroupIdeal); BindGlobal("_ViewStringForSemigroupsIdeals", function(I) @@ -187,6 +193,7 @@ InstallMethod(Representative, "for a semigroup ideal", # a convenience, similar to the functions , , etc +# Factor out the common code from the following functions too? InstallGlobalFunction(SemigroupIdeal, function(arg...) local out, i; @@ -197,11 +204,11 @@ function(arg...) ErrorNoReturn("the 1st argument is not a semigroup"); elif Length(arg) = 2 and IsMatrix(arg[2]) then # special case for matrices, because they may look like lists - return SemigroupIdealByGenerators(arg[1], [arg[2]]); + return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, [arg[2]]); elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then # list of generators - return SemigroupIdealByGenerators(arg[1], arg[2]); + return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, arg[2]); elif (IsMultiplicativeElement(arg[2]) and IsGeneratorsOfSemigroup([arg[2]])) or (IsListOrCollection(arg[2]) @@ -212,7 +219,7 @@ function(arg...) for i in [2 .. Length(arg)] do # so that we can pass the options record if i = Length(arg) and IsRecord(arg[i]) then - return SemigroupIdealByGenerators(arg[1], out, arg[i]); + return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, out, arg[i]); elif IsMultiplicativeElement(arg[i]) and IsGeneratorsOfSemigroup([arg[i]]) then Add(out, arg[i]); @@ -232,36 +239,138 @@ function(arg...) "nor semigroups"); fi; od; - return SemigroupIdealByGenerators(arg[1], out); + return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, out); fi; ErrorNoReturn("invalid arguments"); end); -InstallMethod(SemigroupIdealByGenerators, -"for a semigroup and list or collections", -[IsSemigroup, IsListOrCollection], -{S, gens} -> SemigroupIdealByGenerators(S, gens, SEMIGROUPS.OptionsRec(S))); +InstallGlobalFunction(LeftSemigroupIdeal, +function(arg...) + local out, i; + + if Length(arg) <= 1 then + ErrorNoReturn("there must be 2 or more arguments"); + elif not IsSemigroup(arg[1]) then + ErrorNoReturn("the 1st argument is not a semigroup"); + elif Length(arg) = 2 and IsMatrix(arg[2]) then + # special case for matrices, because they may look like lists + return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, [arg[2]]); + + elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then + # list of generators + return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, arg[2]); + elif (IsMultiplicativeElement(arg[2]) + and IsGeneratorsOfSemigroup([arg[2]])) + or (IsListOrCollection(arg[2]) + and IsGeneratorsOfSemigroup(arg[2])) + or (HasIsEmpty(arg[2]) and IsEmpty(arg[2])) then + # generators and collections of generators + out := []; + for i in [2 .. Length(arg)] do + # so that we can pass the options record + if i = Length(arg) and IsRecord(arg[i]) then + return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, out, arg[i]); + elif IsMultiplicativeElement(arg[i]) and + IsGeneratorsOfSemigroup([arg[i]]) then + Add(out, arg[i]); + elif IsGeneratorsOfSemigroup(arg[i]) then + if HasGeneratorsOfSemigroupIdeal(arg[i]) then + Append(out, GeneratorsOfSemigroupIdeal(arg[i])); + elif HasGeneratorsOfSemigroup(arg[i]) then + Append(out, GeneratorsOfSemigroup(arg[i])); + elif IsList(arg[i]) then + Append(out, arg[i]); + else + Append(out, AsList(arg[i])); + fi; + else + ErrorNoReturn("the 2nd argument is not a combination ", + "of generators, lists of generators, ", + "nor semigroups"); + fi; + od; + return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, out); + fi; + ErrorNoReturn("invalid arguments"); +end); + +InstallGlobalFunction(RightSemigroupIdeal, +function(arg...) + local out, i; + + if Length(arg) <= 1 then + ErrorNoReturn("there must be 2 or more arguments"); + elif not IsSemigroup(arg[1]) then + ErrorNoReturn("the 1st argument is not a semigroup"); + elif Length(arg) = 2 and IsMatrix(arg[2]) then + # special case for matrices, because they may look like lists + return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, [arg[2]]); + + elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then + # list of generators + return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, arg[2]); + elif (IsMultiplicativeElement(arg[2]) + and IsGeneratorsOfSemigroup([arg[2]])) + or (IsListOrCollection(arg[2]) + and IsGeneratorsOfSemigroup(arg[2])) + or (HasIsEmpty(arg[2]) and IsEmpty(arg[2])) then + # generators and collections of generators + out := []; + for i in [2 .. Length(arg)] do + # so that we can pass the options record + if i = Length(arg) and IsRecord(arg[i]) then + return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, out, arg[i]); + elif IsMultiplicativeElement(arg[i]) and + IsGeneratorsOfSemigroup([arg[i]]) then + Add(out, arg[i]); + elif IsGeneratorsOfSemigroup(arg[i]) then + if HasGeneratorsOfSemigroupIdeal(arg[i]) then + Append(out, GeneratorsOfSemigroupIdeal(arg[i])); + elif HasGeneratorsOfSemigroup(arg[i]) then + Append(out, GeneratorsOfSemigroup(arg[i])); + elif IsList(arg[i]) then + Append(out, arg[i]); + else + Append(out, AsList(arg[i])); + fi; + else + ErrorNoReturn("the 2nd argument is not a combination ", + "of generators, lists of generators, ", + "nor semigroups"); + fi; + od; + return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, out); + fi; + ErrorNoReturn("invalid arguments"); +end); + +InstallMethod(AnySemigroupIdealByGenerators, +"for a semigroup, filter and (list or collections)", +[IsSemigroup, IsOperation, IsListOrCollection], +{S, filter, gens} -> + AnySemigroupIdealByGenerators(S, filter, gens, SEMIGROUPS.OptionsRec(S))); -InstallMethod(SemigroupIdealByGenerators, -"for semigroup, list or collection, and record", -[IsSemigroup, IsListOrCollection, IsRecord], -function(S, gens, opts) +InstallMethod(AnySemigroupIdealByGenerators, +"for semigroup, filter, (list or collection), and record", +[IsSemigroup, IsOperation, IsListOrCollection, IsRecord], +function(S, filter, gens, opts) if not ForAll(gens, x -> x in S) then ErrorNoReturn("the 2nd argument (a mult. elt. coll.) do not all ", "belong to the semigroup"); fi; - return SemigroupIdealByGeneratorsNC(S, gens, opts); + return AnySemigroupIdealByGeneratorsNC(S, filter, gens, opts); end); -InstallMethod(SemigroupIdealByGeneratorsNC, -"for a semigroup, list or collections, and record", -[IsSemigroup, IsListOrCollection, IsRecord], -function(S, gens, opts) +# Note to self : The input filter is not sanitised, so remember to do it before. +InstallMethod(AnySemigroupIdealByGeneratorsNC, +"for a semigroup, filter, (list or collections) and record", +[IsSemigroup, IsOperation, IsListOrCollection, IsRecord], +function(S, filter, gens, opts) local filts, I; opts := SEMIGROUPS.ProcessOptionsRec(SEMIGROUPS.DefaultOptionsRec, opts); gens := AsList(gens); - filts := IsMagmaIdeal and IsAttributeStoringRep; + filts := filter and IsAttributeStoringRep; if opts.acting and (IsActingSemigroup(S) or IsGeneratorsOfActingSemigroup(gens)) then @@ -313,7 +422,16 @@ function(S, gens, opts) fi; SetParent(I, S); - SetGeneratorsOfMagmaIdeal(I, gens); + if "IsLeftActedOnBySuperset" in NamesFilter(filter) and + "IsRightActedOnBySuperset" in NamesFilter(filter) then + SetGeneratorsOfMagmaIdeal(I, gens); + elif "IsLeftActedOnBySuperset" in NamesFilter(filter) then + SetGeneratorsOfLeftMagmaIdeal(I, gens); + elif "IsRightActedOnBySuperset" in NamesFilter(filter) then + SetGeneratorsOfRightMagmaIdeal(I, gens); + else + # PANIC + fi; if not IsActingSemigroup(I) then # to keep the craziness in the library happy! From df1cc98b1f8948241f072549ad950887289d4ed5 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 26 Mar 2024 13:47:07 +0000 Subject: [PATCH 26/40] Edit docs --- doc/ideals.xml | 58 ++++++++++++++++++++++++++++++++++++++ doc/z-chap09.xml | 2 ++ gap/ideals/froidure-pin.gi | 4 +-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/doc/ideals.xml b/doc/ideals.xml index a553724bc..86ee6eb50 100644 --- a/doc/ideals.xml +++ b/doc/ideals.xml @@ -98,6 +98,64 @@ gap> I := SemigroupIdeal(S, I, Idempotents(S)); <#/GAPDoc> +<#GAPDoc Label="LeftSemigroupIdeal"> + + + + A left ideal of a semigroup. + + + If obj1, obj2, .. . are (any combination) of elements of the + semigroup S or collections of elements of S (including + subsemigroups and ideals of S), then LeftSemigroupIdeal returns the + left ideal of the semigroup S generated by the union of + obj1, obj2, .. ..

+ + The of the ideal returned by this + function is S. + + S := SymmetricInverseMonoid(10); + +gap> I := LeftSemigroupIdeal(S, PartialPerm([1, 2])); + +gap> Size(I); +4151 +gap> I := LeftSemigroupIdeal(S, I, Idempotents(S)); +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="RightSemigroupIdeal"> + + + + A Right ideal of a semigroup. + + + If obj1, obj2, .. . are (any combination) of elements of the + semigroup S or collections of elements of S (including + subsemigroups and ideals of S), then RightSemigroupIdeal returns the + Right ideal of the semigroup S generated by the union of + obj1, obj2, .. ..

+ + The of the ideal returned by this + function is S. + + S := SymmetricInverseMonoid(10); + +gap> I := RightSemigroupIdeal(S, PartialPerm([1, 2])); + +gap> Size(I); +4151 +gap> I := RightSemigroupIdeal(S, I, Idempotents(S)); +]]> + + +<#/GAPDoc> + <#GAPDoc Label="SupersemigroupOfIdeal"> diff --git a/doc/z-chap09.xml b/doc/z-chap09.xml index d289760e3..f31bba0b1 100644 --- a/doc/z-chap09.xml +++ b/doc/z-chap09.xml @@ -29,6 +29,8 @@ <#Include Label = "SemigroupIdeal"> + <#Include Label = "LeftSemigroupIdeal"> + <#Include Label = "RightSemigroupIdeal"> <#Include Label = "Ideals"> diff --git a/gap/ideals/froidure-pin.gi b/gap/ideals/froidure-pin.gi index 43004cbd1..39edc5bbd 100644 --- a/gap/ideals/froidure-pin.gi +++ b/gap/ideals/froidure-pin.gi @@ -44,7 +44,7 @@ InstallMethod(PositionsInSupersemigroup, [IsLeftSemigroupIdeal and HasGeneratorsOfSemigroupIdeal and CanUseFroidurePin], function(I) - local S, L, R, D, result, pos, x; + local S, L, result, pos, x; S := SupersemigroupOfIdeal(I); L := LeftCayleyDigraph(S); @@ -65,7 +65,7 @@ InstallMethod(PositionsInSupersemigroup, [IsRightSemigroupIdeal and HasGeneratorsOfSemigroupIdeal and CanUseFroidurePin], function(I) - local S, L, R, D, result, pos, x; + local S, R, result, pos, x; S := SupersemigroupOfIdeal(I); R := RightCayleyDigraph(S); From 088091733232be3a2c8d11e803065a76490f56a5 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 26 Mar 2024 14:10:04 +0000 Subject: [PATCH 27/40] Don't destroy the whole thing --- gap/ideals/ideals.gd | 6 ++++++ gap/ideals/ideals.gi | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index 8beac91a4..0ed3793f0 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -19,12 +19,18 @@ DeclareGlobalFunction("RightSemigroupIdeal"); DeclareOperation("AnySemigroupIdealByGenerators", [IsSemigroup, IsOperation, IsListOrCollection]); +DeclareOperation("SemigroupIdealByGenerators", + [IsSemigroup, IsOperation, IsListOrCollection]); DeclareOperation("AnySemigroupIdealByGenerators", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); +DeclareOperation("SemigroupIdealByGenerators", + [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); DeclareOperation("AnySemigroupIdealByGeneratorsNC", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); +DeclareOperation("SemigroupIdealByGeneratorsNC", + [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); diff --git a/gap/ideals/ideals.gi b/gap/ideals/ideals.gi index 5a75f3085..1c5aa23bf 100644 --- a/gap/ideals/ideals.gi +++ b/gap/ideals/ideals.gi @@ -344,12 +344,25 @@ function(arg...) ErrorNoReturn("invalid arguments"); end); +InstallMethod(SemigroupIdealByGenerators, +"for a semigroup and (list or collections)", +[IsSemigroup, IsListOrCollection], +{S, gens} -> + AnySemigroupIdealByGenerators(S, IsMagmaIdeal, gens, SEMIGROUPS.OptionsRec(S))); + InstallMethod(AnySemigroupIdealByGenerators, "for a semigroup, filter and (list or collections)", [IsSemigroup, IsOperation, IsListOrCollection], {S, filter, gens} -> AnySemigroupIdealByGenerators(S, filter, gens, SEMIGROUPS.OptionsRec(S))); +InstallMethod(SemigroupIdealByGenerators, +"for semigroup, (list or collection), and record", +[IsSemigroup, IsListOrCollection, IsRecord], +function(S, gens, opts) + return AnySemigroupIdealByGenerators(S, IsMagmaIdeal, gens, opts); +end); + InstallMethod(AnySemigroupIdealByGenerators, "for semigroup, filter, (list or collection), and record", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord], @@ -361,6 +374,13 @@ function(S, filter, gens, opts) return AnySemigroupIdealByGeneratorsNC(S, filter, gens, opts); end); +InstallMethod(SemigroupIdealByGeneratorsNC, +"for a semigroup, (list or collections) and record", +[IsSemigroup, IsListOrCollection, IsRecord], +function(S, gens, opts) + return AnySemigroupIdealByGeneratorsNC(S, IsMagmaIdeal, gens, opts); +end); + # Note to self : The input filter is not sanitised, so remember to do it before. InstallMethod(AnySemigroupIdealByGeneratorsNC, "for a semigroup, filter, (list or collections) and record", From 61ac68f237c83fdb97d86e217cd41ec16f2f1bf9 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 26 Mar 2024 17:51:47 +0000 Subject: [PATCH 28/40] bug fix --- gap/ideals/ideals.gd | 2 +- gap/ideals/ideals.gi | 62 ++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index 0ed3793f0..10eefaac9 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -53,6 +53,6 @@ DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); DeclareAttribute("SupersemigroupOfIdeal", IsSemigroupIdeal); -InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); # Duplicate with ideal.gi? +InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); # Duplicate with ideal.gi? DeclareAttribute("Ideals", IsSemigroup); diff --git a/gap/ideals/ideals.gi b/gap/ideals/ideals.gi index 1c5aa23bf..5f5781bfe 100644 --- a/gap/ideals/ideals.gi +++ b/gap/ideals/ideals.gi @@ -14,12 +14,6 @@ InstallImmediateMethod(IsSemigroupIdeal, IsSemigroup, 0, IsMagmaIdeal); InstallTrueMethod(IsSemigroupIdeal, IsMagmaIdeal and IsSemigroup); InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); -InstallImmediateMethod(IsLeftSemigroupIdeal, IsSemigroup, 0, IsLeftMagmaIdeal); -InstallTrueMethod(IsLeftSemigroupIdeal, IsLeftMagmaIdeal and IsSemigroup); -InstallTrueMethod(IsSemigroup, IsLeftSemigroupIdeal); -InstallImmediateMethod(IsRightSemigroupIdeal, IsSemigroup, 0, IsRightMagmaIdeal); -InstallTrueMethod(IsRightSemigroupIdeal, IsRightMagmaIdeal and IsSemigroup); -InstallTrueMethod(IsSemigroup, IsRightSemigroupIdeal); BindGlobal("_ViewStringForSemigroupsIdeals", function(I) @@ -269,7 +263,8 @@ function(arg...) for i in [2 .. Length(arg)] do # so that we can pass the options record if i = Length(arg) and IsRecord(arg[i]) then - return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, out, arg[i]); + return AnySemigroupIdealByGenerators(arg[1], + IsLeftMagmaIdeal, out, arg[i]); elif IsMultiplicativeElement(arg[i]) and IsGeneratorsOfSemigroup([arg[i]]) then Add(out, arg[i]); @@ -319,7 +314,8 @@ function(arg...) for i in [2 .. Length(arg)] do # so that we can pass the options record if i = Length(arg) and IsRecord(arg[i]) then - return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, out, arg[i]); + return AnySemigroupIdealByGenerators(arg[1], + IsRightMagmaIdeal, out, arg[i]); elif IsMultiplicativeElement(arg[i]) and IsGeneratorsOfSemigroup([arg[i]]) then Add(out, arg[i]); @@ -344,27 +340,14 @@ function(arg...) ErrorNoReturn("invalid arguments"); end); -InstallMethod(SemigroupIdealByGenerators, -"for a semigroup and (list or collections)", -[IsSemigroup, IsListOrCollection], -{S, gens} -> - AnySemigroupIdealByGenerators(S, IsMagmaIdeal, gens, SEMIGROUPS.OptionsRec(S))); - InstallMethod(AnySemigroupIdealByGenerators, -"for a semigroup, filter and (list or collections)", +"for a semigroup, filter and list or collections", [IsSemigroup, IsOperation, IsListOrCollection], -{S, filter, gens} -> - AnySemigroupIdealByGenerators(S, filter, gens, SEMIGROUPS.OptionsRec(S))); - -InstallMethod(SemigroupIdealByGenerators, -"for semigroup, (list or collection), and record", -[IsSemigroup, IsListOrCollection, IsRecord], -function(S, gens, opts) - return AnySemigroupIdealByGenerators(S, IsMagmaIdeal, gens, opts); -end); +{S, filter, gens} -> AnySemigroupIdealByGenerators(S, + filter, gens, SEMIGROUPS.OptionsRec(S))); InstallMethod(AnySemigroupIdealByGenerators, -"for semigroup, filter, (list or collection), and record", +"for semigroup, filter, list or collection, and record", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord], function(S, filter, gens, opts) if not ForAll(gens, x -> x in S) then @@ -374,14 +357,6 @@ function(S, filter, gens, opts) return AnySemigroupIdealByGeneratorsNC(S, filter, gens, opts); end); -InstallMethod(SemigroupIdealByGeneratorsNC, -"for a semigroup, (list or collections) and record", -[IsSemigroup, IsListOrCollection, IsRecord], -function(S, gens, opts) - return AnySemigroupIdealByGeneratorsNC(S, IsMagmaIdeal, gens, opts); -end); - -# Note to self : The input filter is not sanitised, so remember to do it before. InstallMethod(AnySemigroupIdealByGeneratorsNC, "for a semigroup, filter, (list or collections) and record", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord], @@ -443,7 +418,7 @@ function(S, filter, gens, opts) SetParent(I, S); if "IsLeftActedOnBySuperset" in NamesFilter(filter) and - "IsRightActedOnBySuperset" in NamesFilter(filter) then + "IsRightActedOnBySuperset" in NamesFilter(filter) then SetGeneratorsOfMagmaIdeal(I, gens); elif "IsLeftActedOnBySuperset" in NamesFilter(filter) then SetGeneratorsOfLeftMagmaIdeal(I, gens); @@ -466,6 +441,25 @@ function(S, filter, gens, opts) return I; end); +InstallMethod(SemigroupIdealByGenerators, +"for a semigroup and list or collections", +[IsSemigroup, IsListOrCollection], +{S, gens} -> SemigroupIdealByGenerators(S, gens, SEMIGROUPS.OptionsRec(S))); + +InstallMethod(SemigroupIdealByGenerators, +"for semigroup, list or collection, and record", +[IsSemigroup, IsListOrCollection, IsRecord], +function(S, gens, opts) + return AnySemigroupIdealByGenerators(S, IsMagmaIdeal, gens, opts); +end); + +InstallMethod(SemigroupIdealByGeneratorsNC, +"for a semigroup, list or collections, and record", +[IsSemigroup, IsListOrCollection, IsRecord], +function(S, gens, opts) + return AnySemigroupIdealByGeneratorsNC(S, IsMagmaIdeal, gens, opts); +end); + InstallMethod(MinimalIdealGeneratingSet, "for a semigroup ideal with generators", [IsSemigroupIdeal and HasGeneratorsOfSemigroupIdeal], From 4f1200b6934b7fd4e65459696008ebb4998474fb Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 26 Mar 2024 17:57:34 +0000 Subject: [PATCH 29/40] Fix ideals.gd --- gap/ideals/ideals.gd | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index 10eefaac9..230c9e212 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -8,29 +8,30 @@ ############################################################################# DeclareSynonymAttr("GeneratorsOfSemigroupIdeal", GeneratorsOfMagmaIdeal); -DeclareSynonymAttr("GeneratorsOfLeftSemigroupIdeal", - GeneratorsOfLeftMagmaIdeal); -DeclareSynonymAttr("GeneratorsOfRightSemigroupIdeal", - GeneratorsOfRightMagmaIdeal); DeclareGlobalFunction("SemigroupIdeal"); DeclareGlobalFunction("LeftSemigroupIdeal"); DeclareGlobalFunction("RightSemigroupIdeal"); +DeclareGlobalFunction("AnySemigroupIdealInputParsing"); DeclareOperation("AnySemigroupIdealByGenerators", [IsSemigroup, IsOperation, IsListOrCollection]); -DeclareOperation("SemigroupIdealByGenerators", - [IsSemigroup, IsOperation, IsListOrCollection]); DeclareOperation("AnySemigroupIdealByGenerators", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); -DeclareOperation("SemigroupIdealByGenerators", - [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); DeclareOperation("AnySemigroupIdealByGeneratorsNC", [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); + +DeclareOperation("SemigroupIdealByGenerators", + [IsSemigroup, IsListOrCollection]); + +DeclareOperation("SemigroupIdealByGenerators", + [IsSemigroup, IsListOrCollection, IsRecord]); + DeclareOperation("SemigroupIdealByGeneratorsNC", - [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); + [IsSemigroup, IsListOrCollection, IsRecord]); + DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); From eb93dfc55f09a4c0739d8e99bffb2fa5d166bb41 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 26 Mar 2024 18:13:27 +0000 Subject: [PATCH 30/40] doc update --- doc/ideals.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/doc/ideals.xml b/doc/ideals.xml index 86ee6eb50..12357c91b 100644 --- a/doc/ideals.xml +++ b/doc/ideals.xml @@ -118,11 +118,7 @@ gap> I := SemigroupIdeal(S, I, Idempotents(S)); gap> S := SymmetricInverseMonoid(10); gap> I := LeftSemigroupIdeal(S, PartialPerm([1, 2])); - -gap> Size(I); -4151 -gap> I := LeftSemigroupIdeal(S, I, Idempotents(S)); -]]> +]]> <#/GAPDoc> @@ -147,11 +143,7 @@ gap> I := LeftSemigroupIdeal(S, I, Idempotents(S)); gap> S := SymmetricInverseMonoid(10); gap> I := RightSemigroupIdeal(S, PartialPerm([1, 2])); - -gap> Size(I); -4151 -gap> I := RightSemigroupIdeal(S, I, Idempotents(S)); -]]> +]]> <#/GAPDoc> From 4aefac6dfc9e706469ce599f8c445c10fa9479a2 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon Date: Tue, 26 Mar 2024 19:23:04 +0000 Subject: [PATCH 31/40] Linting --- gap/ideals/ideals.gd | 1 - 1 file changed, 1 deletion(-) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index 230c9e212..0421bc78a 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -32,7 +32,6 @@ DeclareOperation("SemigroupIdealByGenerators", DeclareOperation("SemigroupIdealByGeneratorsNC", [IsSemigroup, IsListOrCollection, IsRecord]); - DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); # the of an ideal is the semigroup in which the ideal was created, From 1140492116c67d03c72e1b3823fb303cd322854a Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:56:20 +0000 Subject: [PATCH 32/40] Factor out the input parsing --- gap/ideals/ideals.gi | 178 ++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 121 deletions(-) diff --git a/gap/ideals/ideals.gi b/gap/ideals/ideals.gi index 5f5781bfe..e44278fd2 100644 --- a/gap/ideals/ideals.gi +++ b/gap/ideals/ideals.gi @@ -187,45 +187,44 @@ InstallMethod(Representative, "for a semigroup ideal", # a convenience, similar to the functions , , etc -# Factor out the common code from the following functions too? -InstallGlobalFunction(SemigroupIdeal, -function(arg...) +InstallGlobalFunction(AnySemigroupIdealInputParsing, +function(inputArgs) local out, i; - if Length(arg) <= 1 then + if Length(inputArgs) <= 1 then ErrorNoReturn("there must be 2 or more arguments"); - elif not IsSemigroup(arg[1]) then + elif not IsSemigroup(inputArgs[1]) then ErrorNoReturn("the 1st argument is not a semigroup"); - elif Length(arg) = 2 and IsMatrix(arg[2]) then + elif Length(inputArgs) = 2 and IsMatrix(inputArgs[2]) then # special case for matrices, because they may look like lists - return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, [arg[2]]); + return [inputArgs[1], [inputArgs[2]]]; - elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then + elif Length(inputArgs) = 2 and IsList(inputArgs[2]) and 0 < Length(inputArgs[2]) then # list of generators - return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, arg[2]); - elif (IsMultiplicativeElement(arg[2]) - and IsGeneratorsOfSemigroup([arg[2]])) - or (IsListOrCollection(arg[2]) - and IsGeneratorsOfSemigroup(arg[2])) - or (HasIsEmpty(arg[2]) and IsEmpty(arg[2])) then + return [inputArgs[1], inputArgs[2]]; + elif (IsMultiplicativeElement(inputArgs[2]) + and IsGeneratorsOfSemigroup([inputArgs[2]])) + or (IsListOrCollection(inputArgs[2]) + and IsGeneratorsOfSemigroup(inputArgs[2])) + or (HasIsEmpty(inputArgs[2]) and IsEmpty(inputArgs[2])) then # generators and collections of generators out := []; - for i in [2 .. Length(arg)] do + for i in [2 .. Length(inputArgs)] do # so that we can pass the options record - if i = Length(arg) and IsRecord(arg[i]) then - return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, out, arg[i]); - elif IsMultiplicativeElement(arg[i]) and - IsGeneratorsOfSemigroup([arg[i]]) then - Add(out, arg[i]); - elif IsGeneratorsOfSemigroup(arg[i]) then - if HasGeneratorsOfSemigroupIdeal(arg[i]) then - Append(out, GeneratorsOfSemigroupIdeal(arg[i])); - elif HasGeneratorsOfSemigroup(arg[i]) then - Append(out, GeneratorsOfSemigroup(arg[i])); - elif IsList(arg[i]) then - Append(out, arg[i]); + if i = Length(inputArgs) and IsRecord(inputArgs[i]) then + return [inputArgs[1], out, inputArgs[i]]; + elif IsMultiplicativeElement(inputArgs[i]) and + IsGeneratorsOfSemigroup([inputArgs[i]]) then + Add(out, inputArgs[i]); + elif IsGeneratorsOfSemigroup(inputArgs[i]) then + if HasGeneratorsOfSemigroupIdeal(inputArgs[i]) then + Append(out, GeneratorsOfSemigroupIdeal(inputArgs[i])); + elif HasGeneratorsOfSemigroup(inputArgs[i]) then + Append(out, GeneratorsOfSemigroup(inputArgs[i])); + elif IsList(inputArgs[i]) then + Append(out, inputArgs[i]); else - Append(out, AsList(arg[i])); + Append(out, AsList(inputArgs[i])); fi; else ErrorNoReturn("the 2nd argument is not a combination ", @@ -233,111 +232,48 @@ function(arg...) "nor semigroups"); fi; od; - return AnySemigroupIdealByGenerators(arg[1], IsMagmaIdeal, out); + return [inputArgs[1], out]; fi; ErrorNoReturn("invalid arguments"); end); -InstallGlobalFunction(LeftSemigroupIdeal, +InstallGlobalFunction(SemigroupIdeal, function(arg...) - local out, i; - - if Length(arg) <= 1 then - ErrorNoReturn("there must be 2 or more arguments"); - elif not IsSemigroup(arg[1]) then - ErrorNoReturn("the 1st argument is not a semigroup"); - elif Length(arg) = 2 and IsMatrix(arg[2]) then - # special case for matrices, because they may look like lists - return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, [arg[2]]); + local parsed; + parsed := AnySemigroupIdealInputParsing(arg); + if Length(parsed) = 3 then + return AnySemigroupIdealByGenerators(parsed[1], + IsMagmaIdeal, parsed[2], parsed[3]); + else + return AnySemigroupIdealByGenerators(parsed[1], + IsMagmaIdeal, parsed[2]); + fi; +end); - elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then - # list of generators - return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, arg[2]); - elif (IsMultiplicativeElement(arg[2]) - and IsGeneratorsOfSemigroup([arg[2]])) - or (IsListOrCollection(arg[2]) - and IsGeneratorsOfSemigroup(arg[2])) - or (HasIsEmpty(arg[2]) and IsEmpty(arg[2])) then - # generators and collections of generators - out := []; - for i in [2 .. Length(arg)] do - # so that we can pass the options record - if i = Length(arg) and IsRecord(arg[i]) then - return AnySemigroupIdealByGenerators(arg[1], - IsLeftMagmaIdeal, out, arg[i]); - elif IsMultiplicativeElement(arg[i]) and - IsGeneratorsOfSemigroup([arg[i]]) then - Add(out, arg[i]); - elif IsGeneratorsOfSemigroup(arg[i]) then - if HasGeneratorsOfSemigroupIdeal(arg[i]) then - Append(out, GeneratorsOfSemigroupIdeal(arg[i])); - elif HasGeneratorsOfSemigroup(arg[i]) then - Append(out, GeneratorsOfSemigroup(arg[i])); - elif IsList(arg[i]) then - Append(out, arg[i]); - else - Append(out, AsList(arg[i])); - fi; - else - ErrorNoReturn("the 2nd argument is not a combination ", - "of generators, lists of generators, ", - "nor semigroups"); - fi; - od; - return AnySemigroupIdealByGenerators(arg[1], IsLeftMagmaIdeal, out); +InstallGlobalFunction(LeftSemigroupIdeal, +function(arg...) + local parsed; + parsed := AnySemigroupIdealInputParsing(arg); + if Length(parsed) = 3 then + return AnySemigroupIdealByGenerators(parsed[1], + IsLeftMagmaIdeal, parsed[2], parsed[3]); + else + return AnySemigroupIdealByGenerators(parsed[1], + IsLeftMagmaIdeal, parsed[2]); fi; - ErrorNoReturn("invalid arguments"); end); InstallGlobalFunction(RightSemigroupIdeal, function(arg...) - local out, i; - - if Length(arg) <= 1 then - ErrorNoReturn("there must be 2 or more arguments"); - elif not IsSemigroup(arg[1]) then - ErrorNoReturn("the 1st argument is not a semigroup"); - elif Length(arg) = 2 and IsMatrix(arg[2]) then - # special case for matrices, because they may look like lists - return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, [arg[2]]); - - elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then - # list of generators - return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, arg[2]); - elif (IsMultiplicativeElement(arg[2]) - and IsGeneratorsOfSemigroup([arg[2]])) - or (IsListOrCollection(arg[2]) - and IsGeneratorsOfSemigroup(arg[2])) - or (HasIsEmpty(arg[2]) and IsEmpty(arg[2])) then - # generators and collections of generators - out := []; - for i in [2 .. Length(arg)] do - # so that we can pass the options record - if i = Length(arg) and IsRecord(arg[i]) then - return AnySemigroupIdealByGenerators(arg[1], - IsRightMagmaIdeal, out, arg[i]); - elif IsMultiplicativeElement(arg[i]) and - IsGeneratorsOfSemigroup([arg[i]]) then - Add(out, arg[i]); - elif IsGeneratorsOfSemigroup(arg[i]) then - if HasGeneratorsOfSemigroupIdeal(arg[i]) then - Append(out, GeneratorsOfSemigroupIdeal(arg[i])); - elif HasGeneratorsOfSemigroup(arg[i]) then - Append(out, GeneratorsOfSemigroup(arg[i])); - elif IsList(arg[i]) then - Append(out, arg[i]); - else - Append(out, AsList(arg[i])); - fi; - else - ErrorNoReturn("the 2nd argument is not a combination ", - "of generators, lists of generators, ", - "nor semigroups"); - fi; - od; - return AnySemigroupIdealByGenerators(arg[1], IsRightMagmaIdeal, out); + local parsed; + parsed := AnySemigroupIdealInputParsing(arg); + if Length(parsed) = 3 then + return AnySemigroupIdealByGenerators(parsed[1], + IsRightMagmaIdeal, parsed[2], parsed[3]); + else + return AnySemigroupIdealByGenerators(parsed[1], + IsRightMagmaIdeal, parsed[2]); fi; - ErrorNoReturn("invalid arguments"); end); InstallMethod(AnySemigroupIdealByGenerators, From abdf215335b11badc6bdeadda2eff36022abbe6d Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:03:28 +0000 Subject: [PATCH 33/40] Hide internal functions and make first edits on ideal.tst --- gap/ideals/ideals.gd | 22 +++---- gap/ideals/ideals.gi | 105 +++++++++++++++------------------ tst/standard/ideals/ideals.tst | 52 +++++++++------- 3 files changed, 88 insertions(+), 91 deletions(-) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index 0421bc78a..b6eccc711 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -7,28 +7,22 @@ ## ############################################################################# -DeclareSynonymAttr("GeneratorsOfSemigroupIdeal", GeneratorsOfMagmaIdeal); +DeclareSynonymAttr("GeneratorsOfSemigroupIdeal", + GeneratorsOfMagmaIdeal); +DeclareSynonymAttr("GeneratorsOfLeftSemigroupIdeal", + GeneratorsOfLeftMagmaIdeal); +DeclareSynonymAttr("GeneratorsOfRightSemigroupIdeal", + GeneratorsOfRightMagmaIdeal); + DeclareGlobalFunction("SemigroupIdeal"); DeclareGlobalFunction("LeftSemigroupIdeal"); DeclareGlobalFunction("RightSemigroupIdeal"); -DeclareGlobalFunction("AnySemigroupIdealInputParsing"); - -DeclareOperation("AnySemigroupIdealByGenerators", - [IsSemigroup, IsOperation, IsListOrCollection]); - -DeclareOperation("AnySemigroupIdealByGenerators", - [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); - -DeclareOperation("AnySemigroupIdealByGeneratorsNC", - [IsSemigroup, IsOperation, IsListOrCollection, IsRecord]); DeclareOperation("SemigroupIdealByGenerators", [IsSemigroup, IsListOrCollection]); - DeclareOperation("SemigroupIdealByGenerators", [IsSemigroup, IsListOrCollection, IsRecord]); - DeclareOperation("SemigroupIdealByGeneratorsNC", [IsSemigroup, IsListOrCollection, IsRecord]); @@ -53,6 +47,4 @@ DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); DeclareAttribute("SupersemigroupOfIdeal", IsSemigroupIdeal); -InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); # Duplicate with ideal.gi? - DeclareAttribute("Ideals", IsSemigroup); diff --git a/gap/ideals/ideals.gi b/gap/ideals/ideals.gi index e44278fd2..5af5c7d79 100644 --- a/gap/ideals/ideals.gi +++ b/gap/ideals/ideals.gi @@ -187,44 +187,44 @@ InstallMethod(Representative, "for a semigroup ideal", # a convenience, similar to the functions , , etc -InstallGlobalFunction(AnySemigroupIdealInputParsing, -function(inputArgs) +SEMIGROUPS.AnySemigroupIdealInputParsing := function(arg...) local out, i; - if Length(inputArgs) <= 1 then + if Length(arg) <= 1 then ErrorNoReturn("there must be 2 or more arguments"); - elif not IsSemigroup(inputArgs[1]) then + elif not IsSemigroup(arg[1]) then ErrorNoReturn("the 1st argument is not a semigroup"); - elif Length(inputArgs) = 2 and IsMatrix(inputArgs[2]) then + elif Length(arg) = 2 and IsMatrix(arg[2]) then # special case for matrices, because they may look like lists - return [inputArgs[1], [inputArgs[2]]]; + return [arg[1], [arg[2]]]; - elif Length(inputArgs) = 2 and IsList(inputArgs[2]) and 0 < Length(inputArgs[2]) then + elif Length(arg) = 2 and IsList(arg[2]) and + 0 < Length(arg[2]) then # list of generators - return [inputArgs[1], inputArgs[2]]; - elif (IsMultiplicativeElement(inputArgs[2]) - and IsGeneratorsOfSemigroup([inputArgs[2]])) - or (IsListOrCollection(inputArgs[2]) - and IsGeneratorsOfSemigroup(inputArgs[2])) - or (HasIsEmpty(inputArgs[2]) and IsEmpty(inputArgs[2])) then + return [arg[1], arg[2]]; + elif (IsMultiplicativeElement(arg[2]) + and IsGeneratorsOfSemigroup([arg[2]])) + or (IsListOrCollection(arg[2]) + and IsGeneratorsOfSemigroup(arg[2])) + or (HasIsEmpty(arg[2]) and IsEmpty(arg[2])) then # generators and collections of generators out := []; - for i in [2 .. Length(inputArgs)] do + for i in [2 .. Length(arg)] do # so that we can pass the options record - if i = Length(inputArgs) and IsRecord(inputArgs[i]) then - return [inputArgs[1], out, inputArgs[i]]; - elif IsMultiplicativeElement(inputArgs[i]) and - IsGeneratorsOfSemigroup([inputArgs[i]]) then - Add(out, inputArgs[i]); - elif IsGeneratorsOfSemigroup(inputArgs[i]) then - if HasGeneratorsOfSemigroupIdeal(inputArgs[i]) then - Append(out, GeneratorsOfSemigroupIdeal(inputArgs[i])); - elif HasGeneratorsOfSemigroup(inputArgs[i]) then - Append(out, GeneratorsOfSemigroup(inputArgs[i])); - elif IsList(inputArgs[i]) then - Append(out, inputArgs[i]); + if i = Length(arg) and IsRecord(arg[i]) then + return [arg[1], out, arg[i]]; + elif IsMultiplicativeElement(arg[i]) and + IsGeneratorsOfSemigroup([arg[i]]) then + Add(out, arg[i]); + elif IsGeneratorsOfSemigroup(arg[i]) then + if HasGeneratorsOfSemigroupIdeal(arg[i]) then + Append(out, GeneratorsOfSemigroupIdeal(arg[i])); + elif HasGeneratorsOfSemigroup(arg[i]) then + Append(out, GeneratorsOfSemigroup(arg[i])); + elif IsList(arg[i]) then + Append(out, arg[i]); else - Append(out, AsList(inputArgs[i])); + Append(out, AsList(arg[i])); fi; else ErrorNoReturn("the 2nd argument is not a combination ", @@ -232,20 +232,20 @@ function(inputArgs) "nor semigroups"); fi; od; - return [inputArgs[1], out]; + return [arg[1], out]; fi; ErrorNoReturn("invalid arguments"); -end); +end; InstallGlobalFunction(SemigroupIdeal, function(arg...) local parsed; - parsed := AnySemigroupIdealInputParsing(arg); + parsed := CallFuncList(SEMIGROUPS.AnySemigroupIdealInputParsing, arg); if Length(parsed) = 3 then - return AnySemigroupIdealByGenerators(parsed[1], + return SEMIGROUPS.AnySemigroupIdealByGenerators4(parsed[1], IsMagmaIdeal, parsed[2], parsed[3]); else - return AnySemigroupIdealByGenerators(parsed[1], + return SEMIGROUPS.AnySemigroupIdealByGenerators3(parsed[1], IsMagmaIdeal, parsed[2]); fi; end); @@ -253,12 +253,12 @@ end); InstallGlobalFunction(LeftSemigroupIdeal, function(arg...) local parsed; - parsed := AnySemigroupIdealInputParsing(arg); + parsed := CallFuncList(SEMIGROUPS.AnySemigroupIdealInputParsing, arg); if Length(parsed) = 3 then - return AnySemigroupIdealByGenerators(parsed[1], + return SEMIGROUPS.AnySemigroupIdealByGenerators4(parsed[1], IsLeftMagmaIdeal, parsed[2], parsed[3]); else - return AnySemigroupIdealByGenerators(parsed[1], + return SEMIGROUPS.AnySemigroupIdealByGenerators3(parsed[1], IsLeftMagmaIdeal, parsed[2]); fi; end); @@ -266,37 +266,29 @@ end); InstallGlobalFunction(RightSemigroupIdeal, function(arg...) local parsed; - parsed := AnySemigroupIdealInputParsing(arg); + parsed := CallFuncList(SEMIGROUPS.AnySemigroupIdealInputParsing, arg); if Length(parsed) = 3 then - return AnySemigroupIdealByGenerators(parsed[1], + return SEMIGROUPS.AnySemigroupIdealByGenerators4(parsed[1], IsRightMagmaIdeal, parsed[2], parsed[3]); else - return AnySemigroupIdealByGenerators(parsed[1], + return SEMIGROUPS.AnySemigroupIdealByGenerators3(parsed[1], IsRightMagmaIdeal, parsed[2]); fi; end); -InstallMethod(AnySemigroupIdealByGenerators, -"for a semigroup, filter and list or collections", -[IsSemigroup, IsOperation, IsListOrCollection], -{S, filter, gens} -> AnySemigroupIdealByGenerators(S, - filter, gens, SEMIGROUPS.OptionsRec(S))); +SEMIGROUPS.AnySemigroupIdealByGenerators3 := {S, filter, gens} -> + SEMIGROUPS.AnySemigroupIdealByGenerators4(S, + filter, gens, SEMIGROUPS.OptionsRec(S)); -InstallMethod(AnySemigroupIdealByGenerators, -"for semigroup, filter, list or collection, and record", -[IsSemigroup, IsOperation, IsListOrCollection, IsRecord], -function(S, filter, gens, opts) +SEMIGROUPS.AnySemigroupIdealByGenerators4 := function(S, filter, gens, opts) if not ForAll(gens, x -> x in S) then ErrorNoReturn("the 2nd argument (a mult. elt. coll.) do not all ", "belong to the semigroup"); fi; - return AnySemigroupIdealByGeneratorsNC(S, filter, gens, opts); -end); + return SEMIGROUPS.AnySemigroupIdealByGeneratorsNC(S, filter, gens, opts); +end; -InstallMethod(AnySemigroupIdealByGeneratorsNC, -"for a semigroup, filter, (list or collections) and record", -[IsSemigroup, IsOperation, IsListOrCollection, IsRecord], -function(S, filter, gens, opts) +SEMIGROUPS.AnySemigroupIdealByGeneratorsNC := function(S, filter, gens, opts) local filts, I; opts := SEMIGROUPS.ProcessOptionsRec(SEMIGROUPS.DefaultOptionsRec, opts); gens := AsList(gens); @@ -375,7 +367,7 @@ function(S, filter, gens, opts) fi; return I; -end); +end; InstallMethod(SemigroupIdealByGenerators, "for a semigroup and list or collections", @@ -386,14 +378,15 @@ InstallMethod(SemigroupIdealByGenerators, "for semigroup, list or collection, and record", [IsSemigroup, IsListOrCollection, IsRecord], function(S, gens, opts) - return AnySemigroupIdealByGenerators(S, IsMagmaIdeal, gens, opts); + return SEMIGROUPS.AnySemigroupIdealByGenerators4(S, IsMagmaIdeal, gens, opts); end); InstallMethod(SemigroupIdealByGeneratorsNC, "for a semigroup, list or collections, and record", [IsSemigroup, IsListOrCollection, IsRecord], function(S, gens, opts) - return AnySemigroupIdealByGeneratorsNC(S, IsMagmaIdeal, gens, opts); + return SEMIGROUPS.AnySemigroupIdealByGeneratorsNC(S, + IsMagmaIdeal, gens, opts); end); InstallMethod(MinimalIdealGeneratingSet, diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index 1914760b0..64af25908 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -20,8 +20,8 @@ gap> SEMIGROUPS.StartTest(); # Test SupersemigroupOfIdeal gap> S := RegularBooleanMatMonoid(3);; -gap> I := SemigroupIdeal(S, -> Matrix(IsBooleanMat, +gap> I := SemigroupIdeal(S, +> Matrix(IsBooleanMat, > [[1, 1, 1], [1, 0, 1], [1, 1, 1]])); gap> J := MinimalIdeal(I); @@ -35,8 +35,8 @@ true # Test PrintString gap> S := RegularBooleanMatMonoid(3);; -gap> I := SemigroupIdeal(S, -> Matrix(IsBooleanMat, +gap> I := SemigroupIdeal(S, +> Matrix(IsBooleanMat, > [[1, 1, 1], [1, 0, 1], [1, 1, 1]])); gap> PrintString(I); @@ -133,16 +133,28 @@ false gap> S = MinimalIdeal(S); false -# Test SemigroupIdeal (the function) +# Test SemigroupIdeal, LeftSemigroupIdeal, RightSemigroupIdeal (the function) gap> SemigroupIdeal("a"); Error, there must be 2 or more arguments +gap> LeftSemigroupIdeal("314159265358979"); +Error, there must be 2 or more arguments +gap> RightSemigroupIdeal(5); +Error, there must be 2 or more arguments gap> S := RegularBooleanMatMonoid(1);; gap> SemigroupIdeal(S); Error, there must be 2 or more arguments +gap> LeftSemigroupIdeal(S); +Error, there must be 2 or more arguments +gap> RightSemigroupIdeal(S); +Error, there must be 2 or more arguments gap> S := Semigroup([[Z(2)]]); gap> SemigroupIdeal(S, S.1); +gap> LeftSemigroupIdeal(S, S.1); + +gap> RightSemigroupIdeal(S, S.1); + gap> S := RegularBooleanMatMonoid(2);; gap> I := SemigroupIdeal(S, [S.1, S.2]); @@ -200,7 +212,7 @@ gap> I := SemigroupIdeal(S, S.1); gap> MinimalIdealGeneratingSet(I); [ Transformation( [ 2, 3, 1 ] ) ] gap> S := RegularBooleanMatMonoid(3);; -gap> I := SemigroupIdeal(S, +gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[1, 1, 1], [1, 1, 0], [1, 0, 1]]), > Matrix(IsBooleanMat, [[1, 1, 1], [1, 1, 0], [0, 0, 1]]), > Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 1], [1, 0, 1]]), @@ -213,12 +225,12 @@ gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[0, 1, 1], [0, 1, 1], [1, 0, 1]])); gap> MinimalIdealGeneratingSet(I); -[ Matrix(IsBooleanMat, [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), +[ Matrix(IsBooleanMat, [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), Matrix(IsBooleanMat, [[1, 0, 0], [1, 1, 0], [1, 0, 1]]) ] # Test InversesOfSemigroupElementNC gap> S := RegularBooleanMatMonoid(3);; -gap> I := SemigroupIdeal(S, +gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[1, 1, 1], [1, 1, 0], [1, 0, 1]]), > Matrix(IsBooleanMat, [[1, 1, 1], [1, 1, 0], [0, 0, 1]]), > Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 1], [1, 0, 1]]), @@ -231,14 +243,14 @@ gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[0, 1, 1], [0, 1, 1], [1, 0, 1]]));; gap> x := Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]);; gap> InversesOfSemigroupElement(I, x); -[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), +[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) ] # Test IsCommutativeSemigroup @@ -247,7 +259,7 @@ gap> x := Transformation([13, 4, 1, 2, 14, 14, 7, 12, 4, 9, 2, 14, 5, 14, 13, gap> y := Transformation([13, 15, 7, 18, 4, 2, 8, 12, 10, 7, 8, 11, 12, 12, 17, > 6, 13, 9, 16, 13]);; gap> T := DirectProduct(Semigroup(x), Semigroup(y)); - gap> z := Transformation([14, 2, 14, 4, 14, 14, 7, 14, 2, 4, 4, 14, 14, 14, 14, > 14, 14, 14, 14, 4, 32, 31, 28, 28, 31, 32, 32, 31, 31, 28, 32, 28, 31, 31, 28, @@ -256,8 +268,8 @@ gap> I := SemigroupIdeal(T, z);; gap> IsCommutativeSemigroup(I); true gap> S := RegularBooleanMatMonoid(3);; -gap> I := SemigroupIdeal(S, -> [Matrix(IsBooleanMat, [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), +gap> I := SemigroupIdeal(S, +> [Matrix(IsBooleanMat, [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), > Matrix(IsBooleanMat, [[1, 0, 0], [1, 1, 0], [1, 0, 1]])]);; gap> IsCommutativeSemigroup(I); false @@ -327,7 +339,7 @@ gap> ideals := Ideals(S);; gap> Size(ideals); 1 gap> S := Semigroup([ -> Bipartition([[1, 2, -1, -4], [3, -5], [4], [5, -2], [-3]]), +> Bipartition([[1, 2, -1, -4], [3, -5], [4], [5, -2], [-3]]), > Bipartition([[1, 2, 4, -3, -5], [3, -4], [5, -1, -2]]), > Bipartition([[1, 2, 5, -3, -4], [3, 4, -1, -2], [-5]])]);; gap> ideals := Ideals(S);; From eb4bc56be85dd6e93b32d9e6f277ac9192303ca4 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:08:10 +0000 Subject: [PATCH 34/40] Appearently not a duplicate --- gap/ideals/ideals.gd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index b6eccc711..b4526b2f2 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -47,4 +47,6 @@ DeclareAttribute("MinimalIdealGeneratingSet", IsSemigroupIdeal); DeclareAttribute("SupersemigroupOfIdeal", IsSemigroupIdeal); +InstallTrueMethod(IsSemigroup, IsSemigroupIdeal); + DeclareAttribute("Ideals", IsSemigroup); From 6e76d9be7f35fab6806b8080e8e38cb9831d4bbf Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:14:02 +0000 Subject: [PATCH 35/40] Linting --- gap/ideals/ideals.gd | 1 - gap/ideals/ideals.gi | 3 +-- tst/standard/ideals/ideals.tst | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gap/ideals/ideals.gd b/gap/ideals/ideals.gd index b4526b2f2..d8c40e134 100644 --- a/gap/ideals/ideals.gd +++ b/gap/ideals/ideals.gd @@ -14,7 +14,6 @@ DeclareSynonymAttr("GeneratorsOfLeftSemigroupIdeal", DeclareSynonymAttr("GeneratorsOfRightSemigroupIdeal", GeneratorsOfRightMagmaIdeal); - DeclareGlobalFunction("SemigroupIdeal"); DeclareGlobalFunction("LeftSemigroupIdeal"); DeclareGlobalFunction("RightSemigroupIdeal"); diff --git a/gap/ideals/ideals.gi b/gap/ideals/ideals.gi index 5af5c7d79..af2db6950 100644 --- a/gap/ideals/ideals.gi +++ b/gap/ideals/ideals.gi @@ -198,8 +198,7 @@ SEMIGROUPS.AnySemigroupIdealInputParsing := function(arg...) # special case for matrices, because they may look like lists return [arg[1], [arg[2]]]; - elif Length(arg) = 2 and IsList(arg[2]) and - 0 < Length(arg[2]) then + elif Length(arg) = 2 and IsList(arg[2]) and 0 < Length(arg[2]) then # list of generators return [arg[1], arg[2]]; elif (IsMultiplicativeElement(arg[2]) diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index 64af25908..063f4bfe2 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -152,9 +152,9 @@ gap> S := Semigroup([[Z(2)]]); gap> SemigroupIdeal(S, S.1); gap> LeftSemigroupIdeal(S, S.1); - + gap> RightSemigroupIdeal(S, S.1); - + gap> S := RegularBooleanMatMonoid(2);; gap> I := SemigroupIdeal(S, [S.1, S.2]); From c74ebcdb6c75561fb1682939a977f08ee812c9c0 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:58:42 +0000 Subject: [PATCH 36/40] Linting for tst file --- tst/standard/ideals/ideals.tst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index 063f4bfe2..91e0ba58a 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -225,7 +225,7 @@ gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[0, 1, 1], [0, 1, 1], [1, 0, 1]])); gap> MinimalIdealGeneratingSet(I); -[ Matrix(IsBooleanMat, [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), +[ Matrix(IsBooleanMat, [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), Matrix(IsBooleanMat, [[1, 0, 0], [1, 1, 0], [1, 0, 1]]) ] # Test InversesOfSemigroupElementNC @@ -243,7 +243,7 @@ gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[0, 1, 1], [0, 1, 1], [1, 0, 1]]));; gap> x := Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]);; gap> InversesOfSemigroupElement(I, x); -[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), +[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), @@ -259,7 +259,7 @@ gap> x := Transformation([13, 4, 1, 2, 14, 14, 7, 12, 4, 9, 2, 14, 5, 14, 13, gap> y := Transformation([13, 15, 7, 18, 4, 2, 8, 12, 10, 7, 8, 11, 12, 12, 17, > 6, 13, 9, 16, 13]);; gap> T := DirectProduct(Semigroup(x), Semigroup(y)); - gap> z := Transformation([14, 2, 14, 4, 14, 14, 7, 14, 2, 4, 4, 14, 14, 14, 14, > 14, 14, 14, 14, 4, 32, 31, 28, 28, 31, 32, 32, 31, 31, 28, 32, 28, 31, 31, 28, From a538cc836007d2dba63fc2a31853e342d03f5678 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:03:32 +0000 Subject: [PATCH 37/40] Linting for tst --- tst/standard/ideals/ideals.tst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index 91e0ba58a..8544d6ca3 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -244,13 +244,13 @@ gap> I := SemigroupIdeal(S, gap> x := Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]);; gap> InversesOfSemigroupElement(I, x); [ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) ] # Test IsCommutativeSemigroup From 0a39a7cdd7ce229ff5431fc19f10d101236b504f Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:53:38 +0100 Subject: [PATCH 38/40] More tests --- tst/standard/ideals/ideals.tst | 56 +++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index 8544d6ca3..d046edc7e 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -133,6 +133,24 @@ false gap> S = MinimalIdeal(S); false +# Test SEMIGROUPS.AnySemigroupIdealInputParsing +gap> SEMIGROUPS.AnySemigroupIdealInputParsing(); +Error, there must be 2 or more arguments +gap> SEMIGROUPS.AnySemigroupIdealInputParsing(6330); +Error, there must be 2 or more arguments +gap> S := RegularBooleanMatMonoid(2);; +gap> SEMIGROUPS.AnySemigroupIdealInputParsing(S); +Error, there must be 2 or more arguments +gap> SEMIGROUPS.AnySemigroupIdealInputParsing(S, [S.1, S.2]); +[ , + [ Matrix(IsBooleanMat, [[0, 1], [1, 0]]), + Matrix(IsBooleanMat, [[1, 0], [0, 0]]) ] ] +gap> SEMIGROUPS.AnySemigroupIdealInputParsing(S, NullDigraph(2)); +Error, invalid arguments +gap> I := SemigroupIdeal(S, []); +Error, the 2nd argument is not a combination of generators, lists of generator\ +s, nor semigroups + # Test SemigroupIdeal, LeftSemigroupIdeal, RightSemigroupIdeal (the function) gap> SemigroupIdeal("a"); Error, there must be 2 or more arguments @@ -140,13 +158,6 @@ gap> LeftSemigroupIdeal("314159265358979"); Error, there must be 2 or more arguments gap> RightSemigroupIdeal(5); Error, there must be 2 or more arguments -gap> S := RegularBooleanMatMonoid(1);; -gap> SemigroupIdeal(S); -Error, there must be 2 or more arguments -gap> LeftSemigroupIdeal(S); -Error, there must be 2 or more arguments -gap> RightSemigroupIdeal(S); -Error, there must be 2 or more arguments gap> S := Semigroup([[Z(2)]]); gap> SemigroupIdeal(S, S.1); @@ -160,19 +171,16 @@ gap> I := SemigroupIdeal(S, [S.1, S.2]); gap> J := SemigroupIdeal(S, I, S.3); +gap> I := LeftSemigroupIdeal(S, [S.1, S.2]); + +gap> I := RightSemigroupIdeal(S, [S.1, S.2]); + gap> I := SemigroupIdeal(S, [S.1, S.2], rec()); gap> I := SemigroupIdeal(S, MaximalDClasses(S)[1]); -gap> I := SemigroupIdeal(S, []); -Error, the 2nd argument is not a combination of generators, lists of generator\ -s, nor semigroups -gap> SemigroupIdeal(); -Error, there must be 2 or more arguments -gap> SemigroupIdeal(S, NullDigraph(2)); -Error, invalid arguments -# Test SemigroupIdealByGenerators +# Test SEMIGROUPS.AnySemigroupIdealByGenerators4 gap> S := RegularBooleanMatMonoid(1);; gap> T := RegularBooleanMatMonoid(2);; gap> SemigroupIdeal(S, T.1); @@ -243,14 +251,14 @@ gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[0, 1, 1], [0, 1, 1], [1, 0, 1]]));; gap> x := Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]);; gap> InversesOfSemigroupElement(I, x); -[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), +[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) ] # Test IsCommutativeSemigroup @@ -259,7 +267,7 @@ gap> x := Transformation([13, 4, 1, 2, 14, 14, 7, 12, 4, 9, 2, 14, 5, 14, 13, gap> y := Transformation([13, 15, 7, 18, 4, 2, 8, 12, 10, 7, 8, 11, 12, 12, 17, > 6, 13, 9, 16, 13]);; gap> T := DirectProduct(Semigroup(x), Semigroup(y)); - gap> z := Transformation([14, 2, 14, 4, 14, 14, 7, 14, 2, 4, 4, 14, 14, 14, 14, > 14, 14, 14, 14, 4, 32, 31, 28, 28, 31, 32, 32, 31, 31, 28, 32, 28, 31, 31, 28, From 97eb398f688107a61ecaa69de6e7cc8d1baa5c6a Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:58:11 +0100 Subject: [PATCH 39/40] Linting --- tst/standard/ideals/ideals.tst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index d046edc7e..ba40036ca 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -251,7 +251,7 @@ gap> I := SemigroupIdeal(S, > Matrix(IsBooleanMat, [[0, 1, 1], [0, 1, 1], [1, 0, 1]]));; gap> x := Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]);; gap> InversesOfSemigroupElement(I, x); -[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), +[ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), @@ -267,7 +267,7 @@ gap> x := Transformation([13, 4, 1, 2, 14, 14, 7, 12, 4, 9, 2, 14, 5, 14, 13, gap> y := Transformation([13, 15, 7, 18, 4, 2, 8, 12, 10, 7, 8, 11, 12, 12, 17, > 6, 13, 9, 16, 13]);; gap> T := DirectProduct(Semigroup(x), Semigroup(y)); - gap> z := Transformation([14, 2, 14, 4, 14, 14, 7, 14, 2, 4, 4, 14, 14, 14, 14, > 14, 14, 14, 14, 4, 32, 31, 28, 28, 31, 32, 32, 31, 31, 28, 32, 28, 31, 31, 28, From 2f825bd8465c50788c9688ba12c74be0f8144fb3 Mon Sep 17 00:00:00 2001 From: Hyeokjun Kwon <86776403+Jun2M@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:13:31 +0100 Subject: [PATCH 40/40] Lint --- tst/standard/ideals/ideals.tst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tst/standard/ideals/ideals.tst b/tst/standard/ideals/ideals.tst index ba40036ca..8209f3468 100644 --- a/tst/standard/ideals/ideals.tst +++ b/tst/standard/ideals/ideals.tst @@ -252,13 +252,13 @@ gap> I := SemigroupIdeal(S, gap> x := Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]);; gap> InversesOfSemigroupElement(I, x); [ Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), - Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 0], [0, 1, 0], [1, 0, 1]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[0, 0, 1], [0, 1, 0], [0, 0, 1]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [0, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 0], [0, 1, 0], [1, 0, 0]]), + Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [0, 0, 0]]), Matrix(IsBooleanMat, [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) ] # Test IsCommutativeSemigroup