How to generate the cosets in this specific group (Zn*)

asked 2023-06-26 17:13:44 +0100

toni gravatar image

updated 2023-06-30 06:36:14 +0100

I see the answers to the multiplicative group of units (a class), in here, as well as the answer to how to generate cosets in here.

But I don't know how to blend them together into a chunk of code that illustrates the cosets when the group is partitioned by the subgroup generated, for example, by the element 5 in the multiplicative group mod 13:

Zn = Zmod(13)
G = Zn.unit_group()
H = G.subgroup(5)

A possible workaround after the comment below could be as follows:

def cosets(p,g):
    R = Integers(p)
    a = R(g)
    sub = uniq([a^i for i in range(p - 1)])
    diff = list(set(R) - set(sub))
    m = []
    for k in range(1, len(diff)): m.append(sorted(set([diff[k] * i for i in sub])))
    costs = list(set(tuple(map(tuple, m))))
    print("The elements of the multiplicative subgroup generated by", g, "modulo", p, "are", sub, "and the cosets are", costs)

So the call cosets(13,5) would yield:

The elements of the multiplicative subgroup generated by 5 modulo 13 are [1, 5, 8, 12] and the cosets are [(2, 3, 10, 11), (4, 6, 7, 9)]

Would this work?

edit retag flag offensive close merge delete


There are two issues here - first getting a subgroup defined properly (your code fails in that), and then computing the posets. The unit group is tricky to work on (e.g. see this answer) as there is no easy coercion from the parent group. Here is a workaround:

Zn = Zmod(13)
G = Zn.unit_group()
f = G.gen()
e = Zn(5).log(f.value(), G.order())
H = G.subgroup([f^e])

However, it's still troublesome to compute cosets as G.cosets(H) gives an error:

AttributeError: 'AbelianGroupWithValues_class_with_category' object has no attribute 'cosets'

Max Alekseyev gravatar imageMax Alekseyev ( 2023-06-26 20:40:30 +0100 )edit

When I run the code in your comment I get Multiplicative Abelian subgroup isomorphic to C4 generated by {f^9}

toni gravatar imagetoni ( 2023-06-26 21:12:47 +0100 )edit

Yes, the subgroup is constructed fine. There still remains a problem with computing cosets.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-06-26 21:59:34 +0100 )edit

@Max Alekseyev isomorphic to C4 makes sense, by why generated by f^9?

toni gravatar imagetoni ( 2023-06-27 00:28:42 +0100 )edit

f (generator of G) happens to be chosen as 2 and we have f^9 equal 5 in G.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-06-27 00:54:25 +0100 )edit