From 4b8c431c8ac538a6b1267db69fa033b536636c46 Mon Sep 17 00:00:00 2001 From: Wilf Wilson Date: Sun, 1 Oct 2017 12:36:38 +0100 Subject: [PATCH] attrinv: fix NaturalPartialOrder method Previously we pre-sorted the elements of the inverse semigroup by a Greens D > function, but we should use a Greens D < function. Resolves #389. --- gap/attributes/attrinv.gi | 16 +++++++----- tst/standard/attrinv.tst | 52 ++++++++++++++++++++++++++++++++++++++- tst/standard/display.tst | 2 +- tst/testinstall.tst | 11 +++++++++ 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/gap/attributes/attrinv.gi b/gap/attributes/attrinv.gi index c38f14692..661e77dae 100644 --- a/gap/attributes/attrinv.gi +++ b/gap/attributes/attrinv.gi @@ -36,25 +36,29 @@ function(S) if not IsFinite(S) then ErrorNoReturn("Semigroups: NaturalPartialOrder: usage,\n", "the argument is not a finite semigroup,"); - fi; - - if not IsInverseSemigroup(S) then + elif not IsInverseSemigroup(S) then ErrorNoReturn("Semigroups: NaturalPartialOrder: usage,\n", "the argument is not an inverse semigroup,"); + elif IsPartialPermSemigroup(S) then + # Use the library method for partial perm inverse semigroups. + return NaturalPartialOrder(S); fi; Info(InfoWarning, 2, "NaturalPartialOrder: this method ", "fully enumerates its argument!"); elts := ShallowCopy(Elements(S)); - p := Sortex(elts, IsGreensDGreaterThanFunc(S)) ^ -1; + p := Sortex(elts, {x, y} -> IsGreensDGreaterThanFunc(S)(y, x)) ^ -1; func := NaturalLeqInverseSemigroup(S); out := List([1 .. Size(S)], x -> []); + # is sorted so that D_elts[i] < D_elts[j] => i < j. + # Thus NaturalLeqInverseSemigroup(S)(i, j) => i <= j. + for i in [1 .. Size(S)] do for j in [i + 1 .. Size(S)] do - if func(elts[j], elts[i]) then - AddSet(out[i ^ p], j ^ p); + if func(elts[i], elts[j]) then + AddSet(out[j ^ p], i ^ p); fi; od; od; diff --git a/tst/standard/attrinv.tst b/tst/standard/attrinv.tst index fb8c23fa5..a5382a2cf 100644 --- a/tst/standard/attrinv.tst +++ b/tst/standard/attrinv.tst @@ -582,11 +582,61 @@ gap> CharacterTableOfInverseSemigroup(S[10]); gap> S := InverseSemigroup([Bipartition([[1, -3], [2, -1], [3, 4, -2, -4]]), > Bipartition([[1, -1], [2, -3], [3, -2], [4, -4]])]); -gap> NaturalPartialOrder(AsSemigroup(IsTransformationSemigroup, S)); +gap> S := AsSemigroup(IsTransformationSemigroup, S); + +gap> n := Size(S);; +gap> elts := Elements(S);; +gap> NaturalPartialOrder(S); [ [ 2, 8, 9, 15, 16, 19 ], [ 9, 16, 19 ], [ 4, 9, 11 ], [ 9 ], [ 9, 16, 18 ], [ 5, 9, 10, 14, 16, 18 ], [ 9, 13, 20 ], [ 9 ], [ ], [ 9 ], [ 9 ], [ 9, 11, 13 ], [ 9 ], [ 9, 10, 16 ], [ 8, 9, 16 ], [ 9 ], [ 4, 9, 20 ], [ 9 ], [ 9 ], [ 9 ] ] +gap> List([1 .. n], +> i -> Filtered([1 .. n], +> j -> i <> j and ForAny(Idempotents(S), +> e -> e * elts[i] = elts[j]))); +[ [ 2, 8, 9, 15, 16, 19 ], [ 9, 16, 19 ], [ 4, 9, 11 ], [ 9 ], [ 9, 16, 18 ], + [ 5, 9, 10, 14, 16, 18 ], [ 9, 13, 20 ], [ 9 ], [ ], [ 9 ], [ 9 ], + [ 9, 11, 13 ], [ 9 ], [ 9, 10, 16 ], [ 8, 9, 16 ], [ 9 ], [ 4, 9, 20 ], + [ 9 ], [ 9 ], [ 9 ] ] +gap> last = last2; +true + +#T# attrinv: NaturalPartialOrder (for a semigroup), works, 2 +gap> S := Semigroup(SymmetricInverseMonoid(3), rec(acting := true));; +gap> es := IdempotentGeneratedSubsemigroup(S);; +gap> n := Size(es);; +gap> elts := Elements(es); +[ , , + , , + , , + , + ] +gap> NaturalPartialOrder(es); +[ [ ], [ 1 ], [ 1 ], [ 1, 2, 3 ], [ 1 ], [ 1, 3, 5 ], [ 1, 2, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] ] +gap> List([1 .. n], +> i -> Filtered([1 .. n], j -> elts[j] = elts[j] * elts[i] and i <> j)); +[ [ ], [ 1 ], [ 1 ], [ 1, 2, 3 ], [ 1 ], [ 1, 3, 5 ], [ 1, 2, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] ] +gap> last = last2; +true + +#T# attrinv: NaturalPartialOrder (for a semigroup), works, 3 +gap> S := Semigroup(SymmetricInverseMonoid(3), rec(acting := true));; +gap> es := IdempotentGeneratedSubsemigroup(S);; +gap> es := AsSemigroup(IsBlockBijectionSemigroup, es);; +gap> n := Size(es);; +gap> elts := Elements(es);; +gap> NaturalPartialOrder(es); +[ [ ], [ 1 ], [ 1 ], [ 1 ], [ 1, 2, 3 ], [ 1, 2, 4 ], [ 1, 3, 4 ], + [ 1, 2, 3, 4, 5, 6, 7 ] ] +gap> List([1 .. n], +> i -> Filtered([1 .. n], j -> elts[j] = elts[j] * elts[i] and i <> j)); +[ [ ], [ 1 ], [ 1 ], [ 1 ], [ 1, 2, 3 ], [ 1, 2, 4 ], [ 1, 3, 4 ], + [ 1, 2, 3, 4, 5, 6, 7 ] ] +gap> last = last2; +true #T# attrinv: NaturalPartialOrder (for a semigroup), error, 1/2 gap> S := Semigroup( diff --git a/tst/standard/display.tst b/tst/standard/display.tst index dd6bf3a2a..0b718fb61 100644 --- a/tst/standard/display.tst +++ b/tst/standard/display.tst @@ -693,7 +693,7 @@ TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLPADDING=\"10\" CELLSPACING=\"0\" PORT=\ BGCOLOR=\"gray\" PORT=\"e1\">*\n>];\n1 -> 2\n2 -> 3\n3 -> 4\ \nedge [color=blue,arrowhead=none,style=dashed]\n3:e2 -> 4:e1\n3:e3 -> 4:e1\n2\ :e4 -> 3:e2\n2:e4 -> 3:e3\n3:e5 -> 4:e1\n2:e6 -> 3:e3\n2:e6 -> 3:e5\n2:e7 -> 3\ -:e5\n1:e8 -> 2:e4\n1:e8 -> 2:e6\n1:e8 -> 2:e7\n }" +:e2\n2:e7 -> 3:e5\n1:e8 -> 2:e4\n1:e8 -> 2:e6\n1:e8 -> 2:e7\n }" # DotSemilatticeOfIdempotents gap> S := Semigroup(SymmetricInverseMonoid(3), rec(acting := true));; diff --git a/tst/testinstall.tst b/tst/testinstall.tst index 740e5bc7b..32fc9f4f8 100644 --- a/tst/testinstall.tst +++ b/tst/testinstall.tst @@ -1692,6 +1692,17 @@ gap> G := F / [s * r * s ^ (- 1) * r ^ (- 1)];; gap> StructureDescription(G); "C0 x C0" +#T# Issue 389: NaturalPartialOrder +gap> S := Semigroup(SymmetricInverseMonoid(3), rec(acting := true));; +gap> es := IdempotentGeneratedSubsemigroup(S);; +gap> NaturalPartialOrder(es); +[ [ ], [ 1 ], [ 1 ], [ 1, 2, 3 ], [ 1 ], [ 1, 3, 5 ], [ 1, 2, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] ] +gap> es := AsSemigroup(IsBlockBijectionSemigroup, es);; +gap> NaturalPartialOrder(es); +[ [ ], [ 1 ], [ 1 ], [ 1 ], [ 1, 2, 3 ], [ 1, 2, 4 ], [ 1, 3, 4 ], + [ 1, 2, 3, 4, 5, 6, 7 ] ] + #T# SEMIGROUPS_UnbindVariables gap> Unbind(B); gap> Unbind(D);