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  boolmat.tst   Sprache: unbekannt

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

#############################################################################
##
#W  standard/elements/boolmat.tst
#Y  Copyright (C) 2015-2022                              James D. Mitchell
##
##  Licensing information can be found in the README file of this package.
##
#############################################################################
##

#@local BMats, S, a, b, blist, blists, c, d, e, ht, mat, x, y, z
gap> START_TEST("Semigroups package: standard/elements/boolmat.tst");
gap> LoadPackage("semigroups", false);;

#
gap> SEMIGROUPS.StartTest();

# boolmat: BooleanMat, error 1/7
gap> BooleanMat([[true, false, 1], [010], [false, true, false]]);
Error, the argument is not a non-empty list of homogeneous lists

# boolmat: BooleanMat, for 0s and 1s, 2/7
gap> BooleanMat([[101], [010], [010]]);
Matrix(IsBooleanMat, [[101], [010], [010]])

# boolmat: BooleanMat, for blists in blist_rep, 3/7
gap> BooleanMat([[true, false, true], [false, true, false],
> [false, true, false]]);
Matrix(IsBooleanMat, [[101], [010], [010]])

# boolmat: BooleanMat, for blists not in blist_rep, 4/7
gap> BooleanMat(List([1 .. 3], y -> List([1 .. 3], x -> x = x)));
Matrix(IsBooleanMat, [[111], [111], [111]])

# boolmat: BooleanMat, for successors, 5/7
gap> BooleanMat([[1], [34], [2], [1]]);
Matrix(IsBooleanMat, [[1000], [0011], [0100], [1000]])

# boolmat: BooleanMat, for successors, 6/7
gap> BooleanMat([[1], []]);
Matrix(IsBooleanMat, [[10], [00]])

# boolmat: BooleanMat, for successors, error, 7/7
gap> BooleanMat([[1], [34], [2], [5]]);
Error, the entries of each list must not exceed 4

# boolmat: AsBooleanMat, for transformation and pos int, 1/2
gap> x := Transformation([13413]);;
gap> Display(AsBooleanMat(x, 4));
1 0 0 0
0 0 1 0
0 0 0 1
1 0 0 0
gap> AsBooleanMat(x, 3);
Error, the transformation in the 1st argument does not map [1 .. 3] to itself

# boolmat: AsBooleanMat, for partial perm and pos int, 2/2
gap> x := PartialPerm([1236810],
>                      [267915]);
[3,7][8,1,2,6,9][10,5]
gap> Display(AsBooleanMat(x));
0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
gap> Display(AsBooleanMat(x, 3));
Error, the partial perm in the 1st argument does not map [1 .. 3] into itself

# boolmat: SEMIGROUPS_TypePrintStringOfMatrixOverSemiring, 1/1
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [0000],
>                     [0110]]);;
gap> PrintString(x);
"\>\>Matrix(\<\>IsBooleanMat\<, \>[\>\>[1001]\<, \<\>\>[1010]\<, \
\<\>\>[0000]\<, \<\>\>[0110]\<\<]\<)\<"

# boolmat: \* for boolean mats, 1/2
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [0000],
>                     [0110]]);;
gap> Display(x ^ 2);
1 1 1 1
1 0 0 1
0 0 0 0
1 0 1 0

# boolmat: \* for boolean mats, fail, 2/2
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [0000],
>                     [0110]]);;
gap> y := BooleanMat([[100],
>                     [101],
>                     [000]]);;
gap> x * y;
Matrix(IsBooleanMat, [[100], [100], [000]])

# boolmat: \< for boolean mats, 1
gap> a := BooleanMat([[0]]);;
gap> b := BooleanMat([[01],
>                     [00]]);;
gap> c := BooleanMat([[101],
>                     [110],
>                     [100]]);;
gap> d := BooleanMat([[101],
>                     [110],
>                     [101]]);;
gap> e := BooleanMat([[101],
>                     [110],
>                     [101]]);;

# test different dimensions
gap> a < b;
true
gap> a < c;
true
gap> b < a;
false
gap> b < c;
true
gap> c < a;
false
gap> c < b;
false

# test identical obj
gap> a < a;
false
gap> b < b;
false
gap> c < c;
false
gap> d < d;
false
gap> e < e;
false

# test same dimension
gap> c < d;
true
gap> c < e;
true
gap> d < c;
false
gap> d < e;
false
gap> e < c;
false
gap> e < d;
false

# boolmat: OneImmutable, for boolean mats, 1/1
gap> x := BooleanMat([[100],
>                     [101],
>                     [000]]);;
gap> Display(One(x));
1 0 0
0 1 0
0 0 1

# boolmat: RandomMatrix, for boolean mats, 1/1
gap> x := RandomMatrix(IsBooleanMat, 1);;

# boolmat: \in, for boolean mats, 1/2
gap> x := BooleanMat([[100],
>                     [101],
>                     [000]]);;
gap> y := BooleanMat([[101],
>                     [101],
>                     [010]]);;
gap> x in y;
true
gap> y in x;
false

# boolmat: \in, for boolean mats, 2/2
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [0000],
>                     [0110]]);;
gap> y := BooleanMat([[101],
>                     [101],
>                     [010]]);;
gap> x in y;
Error, the arguments (boolean matrices) do not have equal dimensions
gap> y in x;
Error, the arguments (boolean matrices) do not have equal dimensions

# boolmat: OnBlist, for boolean mat and blist, 1/1
gap> mat := BooleanMat([[1001],
>                       [0000],
>                       [1011],
>                       [0111]]);;
gap> blist := BlistList([1 .. 4], [12]);
[ true, true, false, false ]
gap> OnBlist(blist, mat);
[ true, false, false, true ]

# boolmat: Successors, for a boolean mat, 1/1
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [0000],
>                     [0110]]);;
gap> Successors(x);
[ [ 14 ], [ 13 ], [  ], [ 23 ] ]

# boolmat: Is(Row/Column)TrimBooleanMat, for a boolean mat, 1/4
gap> mat := BooleanMat([[1110],
>                       [1011],
>                       [1101],
>                       [0111]]);;
gap> IsRowTrimBooleanMat(mat);
true
gap> IsColTrimBooleanMat(mat);
true
gap> IsTrimBooleanMat(mat);
true

# boolmat: Is(Row/Column)TrimBooleanMat, for a boolean mat, 2/4
gap> mat := BooleanMat([[0110],
>                       [0010],
>                       [1001],
>                       [1010]]);;
gap> IsRowTrimBooleanMat(mat);
false
gap> IsColTrimBooleanMat(mat);
false

# boolmat: Is(Row/Column)TrimBooleanMat, for a boolean mat, 3/4
gap> mat := BooleanMat([[1010],
>                       [0010],
>                       [1001],
>                       [1110]]);;
gap> IsRowTrimBooleanMat(mat);
false
gap> IsColTrimBooleanMat(mat);
false
gap> IsTrimBooleanMat(mat);
false

# boolmat: Is(Row/Column)TrimBooleanMat, for a boolean mat, 4/4
gap> mat := BooleanMat([[0110],
>                       [0101],
>                       [1001],
>                       [0011]]);;
gap> IsRowTrimBooleanMat(mat);
true
gap> IsColTrimBooleanMat(mat);
false
gap> IsTrimBooleanMat(mat);
false

# boolmat: NumberBooleanMat/BooleanMatNumber, for a boolean mat, 1/2
gap> mat := BooleanMat([[0110],
>                       [1011],
>                       [1101],
>                       [0101]]);;
gap> NumberBooleanMat(mat);
27606
gap> BooleanMatNumber(276064) = mat;
true

# boolmat: NumberBooleanMat/BooleanMatNumber, for a boolean mat, 2/2
gap> Set(FullBooleanMatMonoid(3), NumberBooleanMat) = [1 .. 2 ^ 9];
true

# boolmat: NumberBlist/BlistNumber, for a boolean mat, 1/1
gap> blist := BlistList([1 .. 10], []);
[ false, false, false, false, false, false, false, false, false, false ]
gap> NumberBlist(blist);
1
gap> blist := BlistList([1 .. 10], [10]);
[ false, false, false, false, false, false, false, false, false, true ]
gap> NumberBlist(blist);
2
gap> BlistNumber(110);
[ false, false, false, false, false, false, false, false, false, false ]
gap> BlistNumber(210);
[ false, false, false, false, false, false, false, false, false, true ]

# boolmat: AsBooleanMat, for everything, 1/1
gap> Display(AsBooleanMat((12), 5));
0 1 0 0 0
1 0 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
gap> Display(AsBooleanMat((12)));
0 1
1 0
gap> x := Transformation([13413]);;
gap> Display(AsBooleanMat(x));
1 0 0 0 0
0 0 1 0 0
0 0 0 1 0
1 0 0 0 0
0 0 1 0 0
gap> Display(AsBooleanMat(x, 4));
1 0 0 0
0 0 1 0
0 0 0 1
1 0 0 0
gap> x := PartialPerm([1236810],
>                      [267915]);
[3,7][8,1,2,6,9][10,5]
gap> Display(AsBooleanMat(x));
0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
gap> x := Bipartition([[14, -2, -3],
>                        [235, -5], [-1, -4]]);
<bipartition: [ 14, -2, -3 ], [ 235, -5 ], [ -1, -4 ]>
gap> y := AsBooleanMat(x);
<10x10 boolean matrix>
gap> Display(y);
1 0 0 1 0 0 1 1 0 0
0 1 1 0 1 0 0 0 0 1
0 1 1 0 1 0 0 0 0 1
1 0 0 1 0 0 1 1 0 0
0 1 1 0 1 0 0 0 0 1
0 0 0 0 0 1 0 0 1 0
1 0 0 1 0 0 1 1 0 0
1 0 0 1 0 0 1 1 0 0
0 0 0 0 0 1 0 0 1 0
0 1 1 0 1 0 0 0 0 1
gap> IsEquivalenceBooleanMat(y);
true
gap> AsBooleanMat(x, 1);
Matrix(IsBooleanMat, [[1]])
gap> Display(AsBooleanMat(x, 1));
1
gap> Display(AsBooleanMat(x, 2));
1 0
0 1
gap> Display(AsBooleanMat(x, 3));
1 0 0
0 1 1
0 1 1
gap> Display(AsBooleanMat(x, 11));
1 0 0 1 0 0 1 1 0 0 0
0 1 1 0 1 0 0 0 0 1 0
0 1 1 0 1 0 0 0 0 1 0
1 0 0 1 0 0 1 1 0 0 0
0 1 1 0 1 0 0 0 0 1 0
0 0 0 0 0 1 0 0 1 0 0
1 0 0 1 0 0 1 1 0 0 0
1 0 0 1 0 0 1 1 0 0 0
0 0 0 0 0 1 0 0 1 0 0
0 1 1 0 1 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0
gap> x := PBR([[-11], [23], [-323]],
>             [[-112], [-3, -113],
>               [-3, -1123]]);;
gap> AsBooleanMat(x);
Matrix(IsBooleanMat, [[100100], [011000], 
  [011001], [110100], [101101], 
  [111101]])
gap> Display(AsBooleanMat(x));
1 0 0 1 0 0
0 1 1 0 0 0
0 1 1 0 0 1
1 1 0 1 0 0
1 0 1 1 0 1
1 1 1 1 0 1
gap> x := PBR([[-11], [23], [-323]],
>             [[-112], [-3, -113],
>               [-3, -1123]]);;
gap> Display(AsBooleanMat(x, 8));
1 0 0 1 0 0 0 0
0 1 1 0 0 0 0 0
0 1 1 0 0 1 0 0
1 1 0 1 0 0 0 0
1 0 1 1 0 1 0 0
1 1 1 1 0 1 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

# boolmat: ChooseHashFunction and SEMIGROUPS_HashFunctionBooleanMat, for
# boolean mats, 1/1
gap> S := FullBooleanMatMonoid(2);
<monoid of 2x2 boolean matrices with 3 generators>
gap> ht := HTCreate(S.1);
<tree hash table len=100003 used=0 colls=0 accs=0>
gap> for x in S do
> HTAdd(ht, x, true);
> od;
gap> ht;
<tree hash table len=100003 used=16 colls=0 accs=16>

# boolmat: CanonicalBooleanMat, 1/3
gap> mat := BooleanMat([[111000],
>                       [000101],
>                       [100101],
>                       [000000],
>                       [011111],
>                       [011010]]);
Matrix(IsBooleanMat, [[111000], [000101], 
  [100101], [000000], [011111], 
  [011010]])
gap> CanonicalBooleanMat(mat);
Matrix(IsBooleanMat, [[000000], [110000], 
  [001110], [110010], [001101], 
  [111101]])
gap> Display(CanonicalBooleanMat(mat));
0 0 0 0 0 0
1 1 0 0 0 0
0 0 1 1 1 0
1 1 0 0 1 0
0 0 1 1 0 1
1 1 1 1 0 1
gap> Display(CanonicalBooleanMat(Group((13)), mat));
0 1 1 0 0 1
0 0 1 0 0 1
1 1 0 1 0 0
0 0 0 0 0 0
1 0 1 1 1 1
1 0 0 1 1 0
gap> Display(CanonicalBooleanMat(Group((13)), Group(()), mat));
1 1 1 0 0 0
0 0 0 1 0 1
0 1 0 1 0 1
0 0 0 0 0 0
1 0 1 1 1 1
1 0 1 0 1 0

# boolmat: CanonicalBooleanMat, 2/3
gap> mat := BooleanMat([[111000],
>                       [000101],
>                       [100101],
>                       [000000],
>                       [011111],
>                       [011010]]);;
gap> CanonicalBooleanMat(SymmetricGroup(7), mat);
Error, the largest moved point of the 1st argument (a perm group) exceeds the \
dimension of the 3rd argument (a boolean matrix)

# boolmat: CanonicalBooleanMat (check that bliss is used in all 3 versions), 3/3
gap> mat := Matrix(IsBooleanMat, [[10110001],
>                                 [01001101],
>                                 [01000101],
>                                 [10011111],
>                                 [11100110],
>                                 [10101001],
>                                 [00000011],
>                                 [10100111]]);;
gap> CanonicalBooleanMat(mat);
Matrix(IsBooleanMat, [[01000001], [10100001], 
  [10101001], [00011101], 
  [00010111], [11110100], 
  [11010101], [11001111]])
gap> CanonicalBooleanMat(SymmetricGroup(8), mat);
Matrix(IsBooleanMat, [[01000001], [10100001], 
  [10101001], [00011101], 
  [00010111], [11110100], 
  [11010101], [11001111]])
gap> CanonicalBooleanMat(SymmetricGroup(8),
>                        Group((12), (12345678)),
>                        mat);
Matrix(IsBooleanMat, [[01000001], [10100001], 
  [10101001], [00011101], 
  [00010111], [11110100], 
  [11010101], [11001111]])

# boolmat: IsSymmetricBooleanMat, 1/1
gap> mat := BooleanMat([[0110],
>                       [1011],
>                       [1101],
>                       [0101]]);
Matrix(IsBooleanMat, [[0110], [1011], [1101], [0101]])
gap> IsSymmetricBooleanMat(mat);
false
gap> mat := BooleanMat([[0110],
>                       [1011],
>                       [1101],
>                       [0111]]);
Matrix(IsBooleanMat, [[0110], [1011], [1101], [0111]])
gap> IsSymmetricBooleanMat(mat);
true

# boolmat: IsReflexiveBooleanMat, 1/1
gap> mat := BooleanMat([[0110],
>                       [1011],
>                       [1101],
>                       [0101]]);
Matrix(IsBooleanMat, [[0110], [1011], [1101], [0101]])
gap> IsReflexiveBooleanMat(mat);
false

# boolmat: IsTransitiveBooleanMat, 1/1
gap> mat := BooleanMat([[0110],
>                       [1011],
>                       [1101],
>                       [0101]]);
Matrix(IsBooleanMat, [[0110], [1011], [1101], [0101]])
gap> IsTransitiveBooleanMat(mat);
false

# boolmat: IsAntiSymmetricBooleanMat, 1/1
gap> x := BooleanMat([[1001],
>                     [1011],
>                     [1110],
>                     [0110]]);
Matrix(IsBooleanMat, [[1001], [1011], [1110], [0110]])
gap> IsAntiSymmetricBooleanMat(x);
false
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [1010],
>                     [0110]]);
Matrix(IsBooleanMat, [[1001], [1010], [1010], [0110]])
gap> IsAntiSymmetricBooleanMat(x);
true

# boolmat: IsTotalBooleanMat, IsOntoBooleanMat, 1/1
gap> x := BooleanMat([[1001],
>                     [1011],
>                     [1110],
>                     [0110]]);
Matrix(IsBooleanMat, [[1001], [1011], [1110], [0110]])
gap> IsTotalBooleanMat(x);
true
gap> IsOntoBooleanMat(x);
true
gap> x := BooleanMat([[1001],
>                     [1010],
>                     [0000],
>                     [0110]]);
Matrix(IsBooleanMat, [[1001], [1010], [0000], [0110]])
gap> IsTotalBooleanMat(x);
false
gap> IsOntoBooleanMat(x);
true

# boolmat: AsBooleanMat, for a boolean mat, 1/2
gap> mat := Matrix(IsBooleanMat, [[1001],
>                                 [0110],
>                                 [1011],
>                                 [0001]]);;
gap> AsBooleanMat(mat, 2);
Matrix(IsBooleanMat, [[10], [01]])
gap> AsBooleanMat(mat, 6);
Matrix(IsBooleanMat, [[100100], [011000], 
  [101100], [000100], [000000], 
  [000000]])

# boolmat: AsBooleanMat, AsDigraph for a digraph, boolean mat 2/2
gap> x := Digraph([[], [810], [110], [5], [8], [], [10], [], [9], []]);
<immutable digraph with 10 vertices, 8 edges>
gap> AsDigraph(AsBooleanMat(x)) = x;
true
gap> x := Matrix(IsBooleanMat, [[10010],
>                               [11010],
>                               [11000],
>                               [11110],
>                               [00000]]);;
gap> AsBooleanMat(AsDigraph(mat)) = mat;
true

# Fix converter for BMats in the kernel, prior to PR #647 the size of returned
# below was 4, which is nonsense.
gap> S := Semigroup([
> Matrix(IsBooleanMat,
>        [[false, true], [false, true]]),
> Matrix(IsBooleanMat,
>        [[true, false], [true, false]])]);
<semigroup of 2x2 boolean matrices with 2 generators>
gap> Union2(AsList(S.2)[1], AsList(S.2)[2]);;
gap> Size(S);
2

# IsTransformationBooleanMat
gap> x := Transformation([10846453882]);
Transformation( [ 10846453882 ] )
gap> y := AsBooleanMat(x);
<10x10 boolean matrix>
gap> IsTransformationBooleanMat(y);
true
gap> AsTransformation(y) = x;
true
gap> z := Matrix(IsBooleanMat,
>           [[1111], 
>            [1111], 
>            [0101], 
>            [1101]]);
Matrix(IsBooleanMat, [[1111], [1111], [0101], [1101]])
gap> IsTransformationBooleanMat(z);
false
gap> AsTransformation(z);
fail


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

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