diff --git a/gap/attributes/attrinv.gi b/gap/attributes/attrinv.gi index c38f14692b..661e77dae8 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 fb8c23fa59..a5382a2cf0 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 dd6bf3a2a0..0b718fb617 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 81f1d0a37d..00727226df 100644 --- a/tst/testinstall.tst +++ b/tst/testinstall.tst @@ -1684,6 +1684,17 @@ gap> Size(S); gap> Elements(S); [ ONE, (1,(),1) ] +#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);