Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/semigroups/tst/standard/elements/   (GAP Algebra Version 4.15.1©)  Datei vom 29.7.2025 mit Größe 17 kB image not shown  

Quelle  pbr.tst   Sprache: unbekannt

 
Spracherkennung für: .tst vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

#############################################################################
##
#W  standard/elements/pbr.tst
#Y  Copyright (C) 2015-2022                           Attila Egri-Nagy
##
##  Licensing information can be found in the README file of this package.
##
#############################################################################
##

#@local A, B, P, S, coll, f, filename, pos, x, y
gap> START_TEST("Semigroups package: standard/elements/pbr.tst");
gap> LoadPackage("semigroups", false);;

#
gap> SEMIGROUPS.StartTest();

# pbr: PBR, works, 1/4
gap> PBR([[-3, -2, -123], [-1], [-3, -212]],
>        [[-2, -1123], [3], [-3, -2, -113]]);
PBR([ [ -3, -2, -123 ], [ -1 ], [ -3, -212 ] ], 
  [ [ -2, -1123 ], [ 3 ], [ -3, -2, -113 ] ])

# pbr: PBR, fails 12/4
gap> PBR([[]], [[], []]);
Error, the arguments (dense lists) do not have equal length

# pbr: PBR, fails 23/4
gap> PBR([["a", 1]], [[2]]);
Error, expected a homogeneous list in position 
1 of the 1st argument (a dense list)
gap> PBR([[2]], [["a", 1]]);
Error, expected a homogeneous list in position 
1 of the 2nd argument (a dense list)

# pbr: PBR, fails 34/4
gap> PBR([[01], []], [[21], []]);
Error, the entries in the arguments are not integers in [-2 .. -1] or [1 .. 2]

# pbr: Star, 1/1
gap> x := PBR([[3], [-44], [-4, -24], [4]],
>  [[-4, -1], [-3, -11], [-1], [-1]]);
PBR([ [ 3 ], [ -44 ], [ -4, -24 ], [ 4 ] ], 
  [ [ -4, -1 ], [ -3, -11 ], [ -1 ], [ -1 ] ])
gap> Star(x);
PBR([ [ 14 ], [ -113 ], [ 1 ], [ 1 ] ], 
  [ [ -3 ], [ -44 ], [ -424 ], [ -4 ] ])
gap> Star(Star(x)) = x;
true

# pbr: DegreeOfPBRCollection, 1/1
gap> x := PBR([[], [-2]], [[], []]);;
gap> y := PBR([[-1123], [-3, -1123], [13]],
>  [[-3, -2, -12], [-2, -1123], [-3, -2, -1123]]);;
gap> DegreeOfPBRCollection([x]);
2
gap> DegreeOfPBRCollection([y]);
3
gap> DegreeOfPBRCollection([x, y]);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DegreeOfPBRCollection' on 1 arguments
gap> coll := [x, y];;
gap> IsPBRCollection(coll);
false
gap> DegreeOfPBRCollection(FullPBRMonoid(1));
1
gap> Semigroup(x, y);
Error, Usage: Semigroup(<gen>,...), Semigroup(<gens>), Semigroup(<D>),

# pbr: IsGeneratorsOfInverseSemigroup, 1/1
gap> x := PBR([[], [-2]], [[], []]);;
gap> IsGeneratorsOfInverseSemigroup([x]);
false
gap> x := PBR([[-11], [-32], [-43], [4]],
>  [[-11], [-2], [-32], [-43]]);;
gap> IsGeneratorsOfInverseSemigroup([x]);
true
gap> InverseSemigroup(x);
<inverse pbr semigroup of degree 4 with 1 generator>
gap> InverseMonoid(x);
Error, not yet implemented

# pbr: IsTransformationPBR, 1/1
gap> x := PBR([[-3], [-1], [-3]],
>             [[2], [], [13]]);
PBR([ [ -3 ], [ -1 ], [ -3 ] ], [ [ 2 ], [  ], [ 13 ] ])
gap> IsTransformationPBR(x);
true
gap> x := AsTransformation(x);
Transformation( [ 313 ] )
gap> AsPBR(x) * AsPBR(x) = AsPBR(x ^ 2);
true
gap> Number(FullPBRMonoid(1), IsTransformationPBR);
1
gap> x := PBR([[-2, -12], [-212]],
>             [[-11], [-2]]);
PBR([ [ -2, -12 ], [ -212 ] ], [ [ -11 ], [ -2 ] ])
gap> IsTransformationPBR(x);
false

# pbr: IsDualTransformationPBR, 1/1
gap> x := PBR([[-313], [-12], [-313]],
>             [[-12], [-2], [-313]]);
PBR([ [ -313 ], [ -12 ], [ -313 ] ], 
  [ [ -12 ], [ -2 ], [ -313 ] ])
gap> IsDualTransformationPBR(x);
false
gap> IsDualTransformationPBR(Star(x));
true
gap> Number(FullPBRMonoid(1), IsDualTransformationPBR);
1

# pbr: IsPartialPermPBR, 1/1
gap> x := PBR([[-11], [2]], [[-11], [-2]]);
PBR([ [ -11 ], [ 2 ] ], [ [ -11 ], [ -2 ] ])
gap> IsPartialPermPBR(x);
true
gap> x := PartialPerm([12], [31]);
[2,1,3]
gap> AsPBR(x) * AsPBR(x) = AsPBR(x ^ 2);
true
gap> Number(FullPBRMonoid(1), IsPartialPermPBR);
2

# pbr: IsBipartitionPBR, IsBlockBijectionPBR, 1/1
gap> x := PBR([[-13], [-13], [-2123]],
>             [[-2, -12], [-2, -1123],
>               [-2, -112]]);
PBR([ [ -13 ], [ -13 ], [ -2123 ] ], 
  [ [ -2, -12 ], [ -2, -1123 ], [ -2, -112 ] ])
gap> IsBipartitionPBR(x);
false
gap> x := PBR([[-2, -11], [23], [23]],
>             [[-2, -11], [-2, -11], [-3]]);
PBR([ [ -2, -11 ], [ 23 ], [ 23 ] ], 
  [ [ -2, -11 ], [ -2, -11 ], [ -3 ] ])
gap> IsBipartitionPBR(x);
true
gap> IsBlockBijectionPBR(x);
false

# pbr: NumberPBR, 1/1
gap> S := FullPBRMonoid(1);
<pbr monoid of degree 1 with 4 generators>
gap> List(S, NumberPBR);
31557814111316629121410 ]
gap> Set(List(last, x -> PBRNumber(x, 1))) = AsSet(S);
true

# pbr: IsEmptyPBR, 1/1
gap> x := PBR([[]], [[]]);;
gap> IsEmptyPBR(x);
true
gap> x := PBR([[-21], [2]], [[-1], [-21]]);
PBR([ [ -21 ], [ 2 ] ], [ [ -1 ], [ -21 ] ])
gap> IsEmptyPBR(x);
false

# pbr: IsUniversalPBR, 1/1
gap> x := PBR([[]], [[]]);
PBR([ [  ] ], [ [  ] ])
gap> IsUniversalPBR(x);
false
gap> x := PBR([[-21], [2]], [[-1], [-21]]);
PBR([ [ -21 ], [ 2 ] ], [ [ -1 ], [ -21 ] ])
gap> IsUniversalPBR(x);
false
gap> x := PBR([[-11]], [[-11]]);
PBR([ [ -11 ] ], [ [ -11 ] ])
gap> IsUniversalPBR(x);
true

# pbr: AsPBR, for a transformation, 1/1
gap> x := Transformation([7143277665]);;
gap> AsPBR(x);
PBR([ [ -7 ], [ -1 ], [ -4 ], [ -3 ], [ -2 ], [ -7 ], [ -7 ], [ -6 ], [ -6 ], 
      [ -5 ] ],
  [ [ 2 ], [ 5 ], [ 4 ], [ 3 ], [ 10 ], [ 89 ], [ 167 ], [  ], [  ], 
      [  ] ])
gap> AsPBR(x, 12);
PBR([ [ -7 ], [ -1 ], [ -4 ], [ -3 ], [ -2 ], [ -7 ], [ -7 ], [ -6 ], [ -6 ], 
      [ -5 ], [ -11 ], [ -12 ] ],
  [ [ 2 ], [ 5 ], [ 4 ], [ 3 ], [ 10 ], [ 89 ], [ 167 ], [  ], [  ], 
      [  ], [ 11 ], [ 12 ] ])

# pbr: AsPBR, for a bipartition, 1/1
gap> x := Bipartition([[12, -3], [3, -2], [-1]]);;
gap> AsPBR(x, 10);
PBR([ [ -312 ], [ -312 ], [ -23 ], [  ], [  ], [  ], [  ], [  ], 
      [  ], [  ] ],
  [ [ -1 ], [ -23 ], [ -312 ], [  ], [  ], [  ], [  ], [  ], [  ], [  ] 
     ])
gap> AsPBR(x);
PBR([ [ -312 ], [ -312 ], [ -23 ] ], 
  [ [ -1 ], [ -23 ], [ -312 ] ])

# pbr: AsPBR, for a boolean mat, fail, 1/1
gap> x := Matrix(IsBooleanMat, [[001], [010], [000]]);;
gap> AsPBR(x);
Error, the 1st argument (a boolean matrix)is not of even dimension

# pbr: AsPBR, for a boolean mat and pos int, fail, 1/5
gap> x := Matrix(IsBooleanMat, [[001], [010], [000]]);;
gap> AsPBR(x, 6);
Error, the 1st argument (a boolean matrix) does not have even dimension

# pbr: AsPBR, for a boolean mat and pos int, fail, 2/5
gap> x := Matrix(IsBooleanMat, [[00], [01]]);;
gap> AsPBR(x, 5);
Error, the 2nd argument (a pos. int) is not even

# pbr: AsPBR, for a boolean mat and pos int, 3/5
gap> x := Matrix(IsBooleanMat, [[00], [01]]);;
gap> AsPBR(x, 4);
PBR([ [  ], [  ] ], [ [ -1 ], [  ] ])

# pbr: AsPBR, for a boolean mat and pos int, 4/5
gap> x := Matrix(IsBooleanMat, [[11], [11]]);;
gap> AsPBR(x, 4);
PBR([ [ -11 ], [  ] ], [ [ -11 ], [  ] ])

# pbr: AsPBR, for a boolean mat and pos int, 5/5
gap> x := Matrix(IsBooleanMat, [[1110], [0000],
>                               [0101], [1001]]);;
gap> AsPBR(x, 2);
PBR([ [ -11 ] ], [ [  ] ])

# pbr: AsPBR, for a boolean mat and pos int, 5/5
gap> x := Matrix(IsBooleanMat, [[1110], [1100],
>                               [0101], [1001]]);;
gap> AsPBR(x, 2);
PBR([ [ -11 ] ], [ [ -11 ] ])

# AsPBR for a mult. element
gap> AsPBR((123));
PBR([ [ -21 ], [ -32 ], [ -13 ] ], [ [ -13 ], [ -21 ], [ -32 ] ])
gap> AsPBR((123), 10);
PBR([ [ -21 ], [ -32 ], [ -13 ], [ -44 ], [ -55 ], [ -66 ], 
      [ -77 ], [ -88 ], [ -99 ], [ -1010 ] ],
  [ [ -13 ], [ -21 ], [ -32 ], [ -44 ], [ -55 ], [ -66 ], 
      [ -77 ], [ -88 ], [ -99 ], [ -1010 ] ])

# pbr: AsTransformation, for a pbr, 1/1
gap> x := PBR([[-3], [-1], [-3]],
>             [[2], [], [13]]);
PBR([ [ -3 ], [ -1 ], [ -3 ] ], [ [ 2 ], [  ], [ 13 ] ])
gap> IsTransformationPBR(x);
true
gap> x := AsTransformation(x);
Transformation( [ 313 ] )
gap> AsPBR(x) * AsPBR(x) = AsPBR(x ^ 2);
true
gap> Number(FullPBRMonoid(1), IsTransformationPBR);
1
gap> x := PBR([[-2, -12], [-212]],
>             [[-11], [-2]]);
PBR([ [ -2, -12 ], [ -212 ] ], [ [ -11 ], [ -2 ] ])
gap> IsTransformationPBR(x);
false
gap> AsTransformation(x);
Error, the argument (a pbr) does not define a transformation

# pbr: AsPartialPerm, for a pbr, 1/1
gap> x := PBR([[-11], [-32], [-43], [4], [5]],
>  [[-11], [-2], [-32], [-43], [-5]]);;
gap> IsPartialPermPBR(x);
true
gap> AsPartialPerm(x);
[2,3,4](1)
gap> x := PBR([[4], [-424], [-3], [4]],
>  [[-3, -1], [-234], [-34], []]);;
gap> AsPartialPerm(x);
Error, the argument (a pbr) does not define a partial perm

# pbr: RandomPBR, for pos int, 1/1
gap> RandomPBR(10);;

# pbr: RandomPBR, for pos int and float, 1/1
gap> RandomPBR(31.0);
PBR(
  [ [ -3, -2, -1123 ], [ -3, -2, -1123 ], [ -3, -2, -1123 ] 
     ],
  [ [ -3, -2, -1123 ], [ -3, -2, -1123 ], [ -3, -2, -1123 ] 
     ])
gap> RandomPBR(30.0);
PBR([ [  ], [  ], [  ] ], [ [  ], [  ], [  ] ])

# pbr: PrintString, for a pbr, 1/1
gap> x := PBR([[-41], [-1], [-2, -14], []],
>  [[], [34], [-4, -3], [-4, -2]]);;
gap> ViewString(x);
"\>\>PBR(\>\>[ [ -41 ], [ -1 ], [ -2, -14 ], [  ] ]\<\<, \>\>[ [  ], [ 3, \
4 ], [ -4, -3 ], [ -4, -2 ] ]\<\<\<\<)"
gap> PrintString(x) = last;
true
gap> x := PBR([[67910], [-91], [-727], [-8], [-6, -27],
>      [-10, -3, -147], [-73], [], [4], [10]],
>  [[], [], [-727], [-17], [-4], [-4, -15],
>      [-10147], [123410], [59], [-10]]);;
gap> ViewString(x);
"\>\>PBR(\>\>[ [ 67910 ], [ -91 ], [ -727 ], [ -8 ], [ -6, -27 ]\
, [ -10, -3, -147 ], [ -73 ], [  ], [ 4 ], [ 10 ] ]\<\<,\n\>\>[ [  ], [ \
 ], [ -727 ], [ -17 ], [ -4 ], [ -4, -15 ], [ -10147 ], [ 12, \
3410 ], [ 59 ], [ -10 ] ]\<\<\<\<)"
gap> PrintString(x) = last;
true

# pbr: \<, for a pbrs, 1/1
gap> x := PBR([[2], [-22], [-4, -13], []],
>  [[], [], [-44], [-1]]);;
gap> x < x;
false

# pbr, InverseMutable, fail, 1/1
gap> x := PBR([[], [], []], [[], [-2], []]);;
gap> Inverse(x);
fail

# pbr, EmptyPBR, 1
gap> EmptyPBR(0);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `EmptyPBR' on 1 arguments
gap> EmptyPBR(1);
PBR([ [  ] ], [ [  ] ])
gap> EmptyPBR(2);
PBR([ [  ], [  ] ], [ [  ], [  ] ])

# pbr, IdentityPBR, 1
gap> IdentityPBR(0);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IdentityPBR' on 1 arguments
gap> IdentityPBR(1);
PBR([ [ -1 ] ], [ [ 1 ] ])
gap> IdentityPBR(2);
PBR([ [ -1 ], [ -2 ] ], [ [ 1 ], [ 2 ] ])

# pbr, UniversalPBR, 1
gap> UniversalPBR(0);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `UniversalPBR' on 1 arguments
gap> UniversalPBR(1);
PBR([ [ -11 ] ], [ [ -11 ] ])
gap> UniversalPBR(2);
PBR([ [ -2, -112 ], [ -2, -112 ] ], 
  [ [ -2, -112 ], [ -2, -112 ] ])

# pbr, IsPermPBR, 1
gap> IsPermPBR(PBR([[1], [-112]], [[-2, -112], [-2, -11]]));
false

# pbr, IsPermPBR, 2
gap> IsPermPBR(PBR([[-31], [2], [-13]], [[-13], [-2], [-31]]));
false

# pbr, IsPermPBR, 3
gap> IsPermPBR(PBR([[-11], [-32], [-23]], [[-11], [-23], [-32]]));
true

# pbr, IsIdentityPBR, 1
gap> x := IdentityPBR(3);;
gap> IsIdentityPBR(x);
true

# pbr, IsIdentityPBR, 2
gap> IsIdentityPBR(PBR([[-31], [2], [-13]], [[-13], [-2], [-31]]));
false

# pbr, IsIdentityPBR, 3
gap> IsIdentityPBR(PBR([[-1], [-2]], [[1], [1]]));
false

# pbr, IsIdentityPBR, 4
gap> IsIdentityPBR(PBR([[-1], [-2]], [[1], [21]]));
false

# pbr, AsPermutation, for a pbr, 1
gap> x := PBR([[-31], [2], [-13]], [[-13], [-2], [-31]]);;
gap> AsPermutation(x);
Error, the argument (a pbr) does not define a permutation

# pbr, AsPermutation, for a pbr, 2
gap> x := PBR([[-11], [-32], [-23]], [[-11], [-23], [-32]]);;
gap> AsPermutation(x);
(2,3)

# pbr, \<, 1
gap> x := PBR([[-11], [-32], [-23]], [[-11], [-23], [-32]]);;
gap> x < PBR([[-11], [-32], [-23]], [[-11], [-23], [-32]]);
false

# pbr, pickling
gap> x := PBR([[-82, -53, -35445369], [430344776], [94], [],
>      [-1831279], [-92, -8060], [-59], [-767990],
>      [945], [-82, -69], [-59, -44], [-50], [-39, -414], [4],
>      [-2880], [-56, -1210], [-2197], [-3945], [-96, -61],
>      [], [-4174], [-6144], [-92], [34], [-98, -953391],
>      [], [], [12717981], [-688596],
>      [-8318283942], [], [-44], [-5243], [-2398],
>      [-50, -4179], [3895], [-6], [793], [], [-442767],
>      [-86, -6057], [], [41], [-53], [1348], [456986],
>      [-72, -1238], [-75, -67, -55], [-1652], [-4446], [88],
>      [8], [-6528], [31], [4583100], [-75, -68, -64, -407],
>      [-81, -76, -240], [-43, -36, -23], [-33243336],
>      [-95, -38], [-78, -75, -35755], [56], [-70668196],
>      [5876], [], [], [28], [-661257], [1968],
>      [-73, -40168190], [-4161], [-84, -586], [384897],
>      [-87], [-796986], [93], [363957], [-3748], [41],
>      [], [192165], [-75, -57, -54, -1750], [-80, -25],
>      [3037], [-56], [25], [40], [], [-73], [-54, -8, -3],
>      [-81, -4716], [-173544], [-7], [-64, -43, -3096],
>      [367097], [], [], [9], [59], [-87, -55, -17]],
>  [[-17347693], [68], [-59, -27], [-3873], [],
>      [-6172], [-19, -971], [-88, -55, -1570], [-94, -85],
>      [-60, -246], [-71, -67, -6118252794], [], [18],
>      [-75, -6432], [-243655], [], [-55, -1563], [-86, -8],
>      [-66, -26, -2224], [-91], [-3549], [], [],
>      [-57, -401673], [-421552], [], [-48],
>      [-38173195], [-55, -512], [2984], [21], [], [66],
>      [-96, -8690], [-2872], [7172], [-23075], [-5357],
>      [-6629], [-4942], [-74, -234], [], [], [44],
>      [-78, -53, -526], [-49, -33, -6], [-91, -895191],
>      [-1944], [-56], [1380], [98], [-47577],
>      [-17217879], [-7545], [], [42], [-50557173],
>      [], [74], [], [-36, -967], [-77], [-2784], [67],
>      [-80, -35], [], [284495], [-54, -5166],
>      [-90, -82, -48, -37, -15983], [-383298], [-8372],
>      [-54], [-96, -111424], [-152099], [-5572],
>      [-98, -23, -9, -2233379], [], [15], [-16],
>      [-68, -4844], [51], [], [-4444], [-44, -36, -2], [],
>      [-2071], [1157], [-91, -325195], [98], [75], [-14],
>      [], [], [-87], [-61, -33], [98], [-537685],
>      [-818692], [37], [-1072]]);;
gap> filename := Filename(DirectoryTemporary(), "pbr.gz");;
gap> WriteGenerators(filename, [x]);
IO_OK
gap> x = ReadGenerators(filename)[1];
true

# Test for no side effects in PBRNC (Issue #193)
gap> A := [[23], [-3, -2, -12], [-3, -22]];;
gap> B := [[-2], [-323], [-2, -1]];;
gap> P := PBR(A, B);
PBR([ [ 23 ], [ -3, -2, -12 ], [ -3, -22 ] ], 
  [ [ -2 ], [ -323 ], [ -2, -1 ] ])
gap> P := PBR(A, B);
PBR([ [ 23 ], [ -3, -2, -12 ], [ -3, -22 ] ], 
  [ [ -2 ], [ -323 ], [ -2, -1 ] ])

# Test TYPE_PBR errors
gap> TYPE_PBR("a");
Error, the argument is not a non-negative integer
gap> TYPE_PBR(-1);
Error, the argument is not a non-negative integer

# Test String
gap> x := PBR([[-11], [-32], [-23]], [[-11], [-23], [-32]]);;
gap> String(x);
"PBR([ [ -11 ], [ -32 ], [ -23 ] ], [ [ -11 ], [ -23 ], [ -32 ] ])\
"
gap> x = EvalString(String(x));
true

# Test \*
gap> x := PBR(
>  [[-6, -5, -4, -3, -11246], [-2, -11246],
>      [-5, -4, -226], [-5, -4, -3, -2, -12356],
>      [-6, -5, -3, -112356], [-4, -3, -13456]],
>  [[-5, -4, -1123456], [-5, -3, -2, -11234],
>      [-5, -345], [-5, -2, -1126], [-6, -245],
>      [-6, -5, -4, -2, -112356]]);;
gap> y := PBR(
>  [[-5, -3, -126], [-5, -42456], [-6, -5, -21456],
>      [-6, -3, -234], [-5, -2, -112356],
>      [-6, -4, -3, -2, -123456]],
>  [[-6, -4, -312456], [-6, -4, -3, -2, -1123456],
>      [-5, -3, -223456], [-6, -5, -4, -32346],
>      [-6, -5, -2, -112346], [-5, -3, -2, -112456]]);;
gap> IsUniversalPBR(x * y);
true

# Test operators for PBRs of different degree
gap> x := PBR([[-212], [-2, -12]], [[12], [-11]]);
PBR([ [ -212 ], [ -2, -12 ] ], [ [ 12 ], [ -11 ] ])
gap> y := PBR([[-11]], [[-11]]);
PBR([ [ -11 ] ], [ [ -11 ] ])
gap> x * y;
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `*' on 2 arguments
gap> x < y;
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `<' on 2 arguments
gap> x = y;
false

# Pickling
gap> filename := Concatenation(SEMIGROUPS.PackageDir,
> "/tst/standard/elements/pbr.tst");;
gap> f := IO_File(filename, "r");;
gap> IO_Unpicklers.PABR(f);
IO_Error
gap> IO_Pickle(f, x);
IO_Error

#
gap> SEMIGROUPS.StopTest();
gap> STOP_TEST("Semigroups package: standard/elements/pbr.tst");

[Dauer der Verarbeitung: 0.18 Sekunden, vorverarbeitet 2026-06-17]