Create group with custom set and operator

Hi, I know that we can use Sage to create an instance of a predefined group like so:

H = DihedralGroup(6)


But instead of using a predefined group, can I also create a group instance having a predefined set (for example a set of natural numbers) and a custom binary operator (such as multiplication modulo N) ?

What I'm looking for is something like this:

G = new Group({1, 2, 3, 4}, (a, b) -> a * b mod 10)


And then generate the group table for G.

If someone could provide me with an code example it'd be great, I wasn't able to derive it from the docs I read.

edit retag close merge delete

Sort by » oldest newest most voted

In your example you rely on multiplication of integers modulo 10, so any group using this operation will be a subgroup of the unit group of $\mathbb{Z}/10\mathbb{Z}$. However, numbers 2 and 4 cannot be there as they are not invertible modulo 10. So, perhaps you mean semigroup (monoid) rather than a group.

Semigroup $G$ for your example can be constructed as follows:

mygens = [1,2,3,4]
R = IntegerModRing(10)
G = R.subsemigroup( (R(g) for g in mygens), one=R(1) )


Then multiplication table can be constructed with OperationTable:

from sage.matrix.operation_table import OperationTable
print( OperationTable(G, operation=operator.mul, names='elements') )


which gives:

*  1 2 3 4 6 8 9 7
+----------------
1| 1 2 3 4 6 8 9 7
2| 2 4 6 8 2 6 8 4
3| 3 6 9 2 8 4 7 1
4| 4 8 2 6 4 2 6 8
6| 6 2 8 4 6 8 4 2
8| 8 6 4 2 8 4 2 6
9| 9 8 7 6 4 2 1 3
7| 7 4 1 8 2 6 3 9


ADDED. When $G$ represents a group, we can explicitly create its isomorphic permutation group $P$ (subgroup of $\mathrm{Sym}(G)$) as in the following example:

mygens = [1,3]
R = IntegerModRing(10)
G = R.subsemigroup( (R(g) for g in mygens), one=R(1) )

P = PermutationGroup([[G(g)*b for b in G] for g in mygens], domain=G)
print("elements of P:",list(P))
M = {g:P([G(g)*b for b in G]) for g in G}  # map from G to P
print("map G->P:",M)


which prints:

elements of P: [(), (1,9)(3,7), (1,7,9,3), (1,3,9,7)]
map G->P: {1: (), 3: (1,3,9,7), 9: (1,9)(3,7), 7: (1,7,9,3)}

more

Thanks for your reply, but I was actually indeed talking about groups. The example was just for illustrative purposes, I don't claim that these numbers really form a group under multiplication mod 10.

Would you have an example how to create a group table for a given set and a custom binary operation?

( 2021-11-06 16:46:30 +0200 )edit

I see two approaches here:

• define your group as a subgroup of some universe group, where all your elements and binary operation belong (e.g., the unit group $U(\mathbb{Z}_{10})$ in case of mod 10 operation); or
• define your group as a finitely presented group.

Your example with mod 10 suggests that you'd be better off with the first approach, but if operation is truly 'custom', the second approach may be preferable.

The third approach could be converting the semigroup defined as in my answer into a group (if it really is), but I don't know how to implement this in Sage.

( 2021-11-06 17:35:07 +0200 )edit

I've added implementation of the (sort of) third approach.

( 2021-11-07 21:48:36 +0200 )edit