# 62.77 How to find near-rings with certain properties

The near-ring library files can be used to systematically search for near-rings with (or without) certain properties.

For instance, the function `LibraryNearring` can be integrated into a loop or occur as a part of the `Filtered` or the `First` function to get all numbers of classes (or just the first class) of near-rings on a specified group which have the specified properties.

In what follows, we shall give a few examples how this can be accomplished:

To get the number of the first class of near-rings on the group C_6 which have an identity, one could use a command like:

```  gap> First( [1..60], i ->
>           Identity( LibraryNearring( "C6", i ) ) <> [ ] );
28
```

If we try the same with S_3, we will get an error message, indicating that there is no near-ring with identity on S_3:

```  gap> First( [1..39], i ->
>           Identity( LibraryNearring( "S3", i ) ) <> [ ] );
Error, at least one element of <list> must fulfill <func> in
First( [ 1 .. 39 ], function ( i ) ... end ) called from
main loop
brk>
gap>
```

To get all seven classes of near-rings with identity on the dihedral group D_8 of order 8, something like the following will work fine:

```  gap> l := Filtered( [1..1447], i ->
>           Identity( LibraryNearring( "D8", i ) ) <> [ ] );
[ 842, 844, 848, 849, 1094, 1096, 1097 ]
gap> time;
122490
```

Note that a search like this may take a few minutes.

Here is another example that provides the class numbers of the four boolean near-rings on D_8:

```  gap> l := Filtered( [1..1447], i ->
>           IsBooleanNearring( LibraryNearring( "D8", i ) ) );
[ 1314, 1380, 1446, 1447 ]
```

The search for class numbers of near-rings can also be accomplished in a loop like the following:

```  gap> l:=[ ];;
gap> for i in [1..1447] do
>      n := LibraryNearring( "D8", i );
>      if IsDgNearring( n ) and
>        not IsDistributiveNearring( n ) then
>      fi;
>    od;
gap> time;
261580
gap> l;
[ 765, 1094, 1098, 1306 ]
```

This provides a list of those class numbers of near-rings on D_8 which are distributively generated but not distributive.

Two or more conditions for library near-rings can also be combined with `or`:

```  gap> l := [ ];;
gap> for i in [1..1447] do
>      n := LibraryNearring( "D8", i );
>      if Size( ZeroSymmetricElements( n ) ) < 8 or
>         Identity( n ) <> [ ] or
>         IsIntegralNearring( n ) then
>      fi;
>    od;
gap> time;
124480
gap> l;
[ 842, 844, 848, 849, 1094, 1096, 1097, 1314, 1315, 1316, 1317, 1318,
1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329,
1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340,
1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351,
1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362,
1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373,
1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384,
1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395,
1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406,
1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417,
1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428,
1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439,
1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447 ]
gap> Length( l );
141
```

This provides a list of all 141 class numbers of near-rings on D_8 which are non-zerosymmetric or have an identity or are integral. (cf. Pil83, pp. 416ff).

The following loop does the same for the near-rings on the quaternion group of order 8, Q_8:

```  gap> l := [ ];;
gap> for i in [1..281] do
>      n := LibraryNearring( "Q8", i );
>      if Size( ZeroSymmetricElements( n ) ) < 8 or
>        Identity( n ) <> [ ] or
>          IsIntegralNearring( n ) then
>      fi;
>    od;
gap> time;
17740
gap> l;
[ 280, 281 ]
```

Once a list of class numbers has been computed (in this case here: `l`), e.g. the function `Library-Near-ring-Info` can be used to print some information about these near-rings:

```  gap> LibraryNearringInfo( "Q8", l );
----------------------------------------------------------------------
>>> GROUP: Q8
elements: [ n0, n1, n2, n3, n4, n5, n6, n7 ]

+  ```
tt `|`
``` n0 n1 n2 n3 n4 n5 n6 n7
------------------------------
n0 ```
tt `|`
``` n0 n1 n2 n3 n4 n5 n6 n7
n1 ```
tt `|`
``` n1 n2 n3 n0 n7 n4 n5 n6
n2 ```
tt `|`
``` n2 n3 n0 n1 n6 n7 n4 n5
n3 ```
tt `|`
``` n3 n0 n1 n2 n5 n6 n7 n4
n4 ```
tt `|`
``` n4 n5 n6 n7 n2 n3 n0 n1
n5 ```
tt `|`
``` n5 n6 n7 n4 n1 n2 n3 n0
n6 ```
tt `|`
``` n6 n7 n4 n5 n0 n1 n2 n3
n7 ```
tt `|`
``` n7 n4 n5 n6 n3 n0 n1 n2

group endomorphisms:
1:   [ n0, n0, n0, n0, n0, n0, n0, n0 ]
2:   [ n0, n0, n0, n0, n2, n2, n2, n2 ]
3:   [ n0, n1, n2, n3, n5, n6, n7, n4 ]
4:   [ n0, n1, n2, n3, n6, n7, n4, n5 ]
5:   [ n0, n1, n2, n3, n7, n4, n5, n6 ]
6:   [ n0, n2, n0, n2, n0, n2, n0, n2 ]
7:   [ n0, n2, n0, n2, n2, n0, n2, n0 ]
8:   [ n0, n3, n2, n1, n4, n7, n6, n5 ]
9:   [ n0, n3, n2, n1, n5, n4, n7, n6 ]
10:  [ n0, n3, n2, n1, n6, n5, n4, n7 ]
11:  [ n0, n3, n2, n1, n7, n6, n5, n4 ]
12:  [ n0, n4, n2, n6, n1, n7, n3, n5 ]
13:  [ n0, n4, n2, n6, n3, n5, n1, n7 ]
14:  [ n0, n4, n2, n6, n5, n1, n7, n3 ]
15:  [ n0, n4, n2, n6, n7, n3, n5, n1 ]
16:  [ n0, n5, n2, n7, n1, n4, n3, n6 ]
17:  [ n0, n5, n2, n7, n3, n6, n1, n4 ]
18:  [ n0, n5, n2, n7, n4, n3, n6, n1 ]
19:  [ n0, n5, n2, n7, n6, n1, n4, n3 ]
20:  [ n0, n6, n2, n4, n1, n5, n3, n7 ]
21:  [ n0, n6, n2, n4, n3, n7, n1, n5 ]
22:  [ n0, n6, n2, n4, n5, n3, n7, n1 ]
23:  [ n0, n6, n2, n4, n7, n1, n5, n3 ]
24:  [ n0, n7, n2, n5, n1, n6, n3, n4 ]
25:  [ n0, n7, n2, n5, n3, n4, n1, n6 ]
26:  [ n0, n7, n2, n5, n4, n1, n6, n3 ]
27:  [ n0, n7, n2, n5, n6, n3, n4, n1 ]
28:  [ n0, n1, n2, n3, n4, n5, n6, n7 ]

NEARRINGS:
----------------------------------------------------------------------
280)  phi: [ 1, 28, 28, 28, 28, 28, 28, 28 ];  28;  -B----I--P-RW
----------------------------------------------------------------------
281)  phi: [ 28, 28, 28, 28, 28, 28, 28, 28 ];  28;  -B----I--P-RW
----------------------------------------------------------------------
```

GAP 3.4.4
April 1997