qldpc.abstract.groups

Module for abstract algebra: groups and representations thereof.

All groups in this module are finite, and represented under the hood as a SymPy PermutationGroup, or a subgroup of the symmetric group. Group members subclass the SymPy Permutation class.

!!! WARNINGS !!!

This module does not promise to be performant. If you need to do heavy numerical abstract algebra, you’re probably better served by GAP or MAGMA (or maybe SageMath).

This module represents group members by matrices over a finite field via a lift L, a homomorphism with L(g . h) = L(g) @ L(h). The default lift is the regular representation, whose matrices are permutation matrices and hence orthogonal; for an orthogonal lift the “transpose” of a group member p satisfies L(p.T) = L(p).T, and p.T equals the inverse ~p = p**-1. Some custom lifts (SpecialLinearGroup, ProjectiveSpecialLinearGroup, QuaternionGroup) are generally not orthogonal, so that transpose/inverse identity does not hold for them.

Attributes

GenerateFunc

IntegerLift

Lift

NestedSequence

PSL

SL

Classes

AbelianGroup

Direct product of cyclic groups of the specified orders.

AlternatingGroup

Alternating group: even permutations of a set with a given number of elements.

CyclicGroup

Cyclic group of a specified order.

DihedralGroup

Dihedral group: symmetries of a regular polygon with a given number of sides.

Group

Base class for a finite group.

GroupMember

Wrapper for SymPy Permutation class.

ProjectiveSpecialLinearGroup

Projective special linear group (PSL = SL/center).

QuaternionGroup

Quaternion group: 1, i, j, k, -1, -i, -j, -k.

SmallGroup

Group indexed by the GAP computer algebra system.

SpecialLinearGroup

Special linear group (SL): square matrices with determinant 1.

SymmetricGroup

Symmetric group: all permutations of a given number of symbols.

TrivialGroup

The trivial group with one member: the identity.

WreathProductGroup

Permutational wreath product of a top group and copies of a bottom group.

Functions

resolve_field(→ type[galois.FieldArray])

Parse a finite field argument to obtain an actual finite field.

Module Contents

class qldpc.abstract.groups.AbelianGroup(*orders: int, direct_sum: bool = False)[source]

Bases: Group

Direct product of cyclic groups of the specified orders.

See CyclicGroup for more info. By default, an AbelianGroup member of the form ∏_i g_i^{a_i}, where {g_i} are the generators of the group, gets lifted to a Kronecker product ⨂_i L(g_i)^{a_i}. If an AbelianGroup is initialized with direct_sum=True, the group members get lifted to a direct sum ⨁_i L(g_i)^{a_i}.

orders: tuple[int, ...]
class qldpc.abstract.groups.AlternatingGroup(degree: int)[source]

Bases: Group

Alternating group: even permutations of a set with a given number of elements.

class qldpc.abstract.groups.CyclicGroup(order: int)[source]

Bases: AbelianGroup

Cyclic group of a specified order.

The cyclic group has one generator, g. All members of the cyclic group of order R can be written as g^p for an integer power p in {0, 1, ..., R-1}. The member g^p can be represented by (that is, lifted to) an R×R “shift matrix”, or the identity matrix with all rows shifted down (equivalently, all columns shifted right) by p. That is, the lift L(g^p) acts on a standard basis vector <i| as <i| L(g^p) = < i + p mod R |.

orders
class qldpc.abstract.groups.DihedralGroup(sides: int)[source]

Bases: Group

Dihedral group: symmetries of a regular polygon with a given number of sides.

class qldpc.abstract.groups.Group(*generators: sympy.combinatorics.Permutation, name: str | None = None, generate_func: GenerateFunc | None = None, lift: Lift | None = None)[source]

Base class for a finite group.

Under the hood, a Group is represented by a SymPy PermutationGroup, and group members are represented by SymPy permutations.

A group naturally comes equipped with a “regular lift” that maps each group member to a permutation matrix corresponding to the regular representation of the group. The regular representation of a group represents group members by how they act on the group itself. See https://en.wikipedia.org/wiki/Regular_representation.

A group may additionally be equipped with a custom lift to a matrix over a finite field, for which the group action corresponds to matrix multiplication. Custom lifts are not required to be orthogonal (some, such as SpecialLinearGroup, are not). If no lift is provided, group.lift(member) will default to the regular lift of the group.

adjoint_lift(member: GroupMember) → numpy.typing.NDArray[numpy.int_][source]

Lift a group member to its adjoint representation.

The adjoint representation captures how group members get transformed by conjugation. If Vec : G -> F_2^{|G|} lifts group members to standard basis vectors and g,h ∈ G, then

adjoint_lift(g) @ Vec(h) = Vec(g·h·~g),

where ~g = g**-1 is the inverse of g.

If the group is abelian, the adjoint lift of every group member is the identity matrix.

equiv(other: object) → bool[source]

Do these share the same underlying group, ignoring their representations (lifts)?

Unlike ==, this compares only the underlying SymPy permutation groups, so groups that differ solely in their custom lift (e.g. the same group built twice, hence carrying distinct lift closures) compare as equivalent.

eval(monomial: sympy.Integer | sympy.Symbol | sympy.Pow | sympy.Mul | int | numpy.int_, symbols: dict[sympy.Symbol, GroupMember]) → GroupMember[source]

Convert a SymPy monomial into a member of group.

static from_generating_mats(*matrices: numpy.typing.NDArray[numpy.int_] | collections.abc.Sequence[collections.abc.Sequence[int]]) → Group[source]

Construct a Group from a set of generating matrices.

The matrices should be over a finite field (e.g. a galois.FieldArray); their products then stay bounded and the generated group is finite. Plain integer matrices multiply with unbounded integer arithmetic, so a group that is infinite as an integer matrix group will not terminate here.

static from_name(name: str, *, from_magma: bool = False, warning_to_raise_if_calling_gap: str | None = None) → Group[source]

Retrieve a group from the GAP computer algebra system (CAS).

… unless from_magma=True, in which case retrieve a group from the MAGMA CAS.

static from_sympy(group: sympy.combinatorics.PermutationGroup, *, lift: Lift | None = None) → Group[source]

Instantiate a Group from a SymPy permutation group.

static from_table(table: numpy.typing.NDArray[numpy.int_] | collections.abc.Sequence[collections.abc.Sequence[int]], integer_lift: IntegerLift | None = None) → Group[source]

Construct a group from a multiplication (Cayley) table.

generate() → collections.abc.Iterator[GroupMember][source]

Iterate over all group members.

hashable_generators() → tuple[tuple[int, ...], ...][source]

Generators of this group in a hashable form.

index(member: GroupMember) → int[source]

The index of a GroupMember in this group.

inversion_matrix() → numpy.typing.NDArray[numpy.int_]

The matrix that maps any group member g ∈ G to its inverse ~g = g**-1.

If Vec : G -> F_2^{|G|} lifts group members to standard basis vectors and g ∈ G, then

G.inversion_matrix @ Vec(g) = Vec(~g),

where ~g = g**-1 is the inverse of g.

lift(member: GroupMember, *, right: bool = False) → numpy.typing.NDArray[numpy.int_][source]

Lift a group member to a representation by a matrix.

A representation satisfies

self.lift(g·h) = self.lift(g) @ self.lift(h).

If right=True, lift to an anti-representation, for which

self.lift(g·h) = self.lift(h) @ self.lift(g).

lift_dim() → int

Dimension of the representation for this group.

static product(*groups: Group, repeat: int = 1) → Group[source]

Direct product of Groups.

random(*, seed: int | None = None) → GroupMember[source]

A random element this group.

random_symmetric_subset(size: int, *, exclude_identity: bool = False, seed: int | None = None) → set[GroupMember][source]

Construct a random symmetric subset of a given size.

Note: this is not a uniformly random subset, only a “sufficiently random” one.

WARNING: if excluding the identity element, not all groups have symmetric subsets of arbitrary size. If called with a poor choice of group and subset size, this method may never terminate.

regular_lift(member: GroupMember, *, right: bool = False) → numpy.typing.NDArray[numpy.int_][source]

Lift a group member to its regular representation.

By default, this method lifts a group member to its left-regular representation. Specifically, if Vec : G -> F_2^{|G|} maps group members to standard basis vectors and g,h ∈ G, then

G.regular_lift(g) @ Vec(h) = Vec(g·h).

If right is True, this method lifts a group member to its right-regular anti-representation, defined by

G.regular_lift(g, right=True) @ Vec(h) = Vec(h·g).

The right-regular representation of group member is then

G.regular_lift(g, right=True).T = G.regular_lift(~g, right=True),

where ~g = g**-1 is the inverse of g.

See:

table() → numpy.typing.NDArray[numpy.int_]

Multiplication (Cayley) table for this group.

static tensor_product(*groups: Group, repeat: int = 1) → Group[source]

Direct product of Groups with lifts combined by Kronecker products.

The underlying group is the same as Group.product, while the selected lift of a product element is the Kronecker product of its factor lifts. The repeat argument repeats the entire sequence of factors.

to_gap_group() → str[source]

Convert a Group into a GAP group.

to_sympy() → sympy.combinatorics.PermutationGroup[source]

The underlying SymPy permutation group of this Group.

with_natural_lift() → Group[source]

Copy this group with its natural permutation representation as the lift.

The natural lift has the dimension of the set acted on by the group, rather than the order of the group as in the regular representation.

property degree: int

Number of points that this group’s permutation representation acts on.

property generators: list[GroupMember]

Generators of this group.

property identity: GroupMember

The identity element of this group.

property is_abelian: bool

Is this group abelian?

Alias for Group.is_commutative.

property is_commutative: bool

Is this group commutative (abelian)?

property name: str

A name for this group, which is not required to uniquely identify the group.

property order: int

Number of members in this group.

class qldpc.abstract.groups.GroupMember[source]

Bases: sympy.combinatorics.Permutation

Wrapper for SymPy Permutation class.

Supports sorting permutations (by their rank), and taking their tensor product.

static from_sympy(other: sympy.combinatorics.Permutation) → GroupMember[source]

Convert a SymPy Permutation into a GroupMember.

to_gap_cycles() → str[source]

Convert a GroupMember into a GAP cycle.

to_matrix() → numpy.typing.NDArray[numpy.int_][source]

Lift this permutation object to a permutation matrix.

For consistency with how SymPy composes permutations, the permutation matrix constructed here is right-acting, meaning that it acts on a vector v as v --> v @ p.to_matrix(). This convention ensures that this lift is a homomorphism on SymPy Permutation objects, which is to say that (p * q).to_matrix() = p.to_matrix() @ q.to_matrix().

class qldpc.abstract.groups.ProjectiveSpecialLinearGroup(dimension: int, field: int | type[galois.FieldArray] | None = None, linear_rep: bool | None = None)[source]

Bases: Group

Projective special linear group (PSL = SL/center).

Here “center” is the subgroup of SL that commutes with all elements of SL. Specifically, every element in the center of SL is a scalar multiple of the identity matrix I. In the case of SL(d,q) (d×d matrices over F_q with determinant 1), the determinant of scalar*I is scalar**d, which is only contained in SL(d,q) if scalar**d == 1.

Altogether, we construct PSL(d,q) by SL(d,q) mod [d-th roots of unity over F_q].

There are two ways to represent PSL by matrices. The d-dimensional linear representation (inherited from SL) only works when gcd(d, q - 1) == 1 (e.g. PSL(2,4) but not PSL(2,5)); otherwise we fall back to a permutation representation, which always works. The linear_rep argument chooses between them: None (default) uses the linear representation when it exists and the permutation representation otherwise; True forces the linear representation, raising an error when it does not exist; False always uses the permutation representation.

static get_generating_mats(dimension: int, field: int | type[galois.FieldArray] | None = None) → tuple[galois.FieldArray, galois.FieldArray][source]

Generating matrices of PSL, constructed out of the generating matrices of SL.

static iter_mats(dimension: int, field: int | type[galois.FieldArray] | None = None) → collections.abc.Iterator[galois.FieldArray][source]

Iterate over all elements of PSL(dimension, field).

property dimension: int

Dimension of the elements of this group.

property field: type[galois.FieldArray]

Base field of this group.

class qldpc.abstract.groups.QuaternionGroup[source]

Bases: Group

Quaternion group: 1, i, j, k, -1, -i, -j, -k.

The 2-dimensional lift is a faithful homomorphism, but over GF(3) it is not orthogonal – lift(i) and lift(j) satisfy M.T @ M == -I – so the transpose/inverse identity lift(g.T) == lift(g).T does not hold for this group.

property generators: list[GroupMember]

[i, j].

Type:

Generators of the quaternion group

class qldpc.abstract.groups.SmallGroup(order: int, index: int)[source]

Bases: Group

Group indexed by the GAP computer algebra system.

static generator(order: int) → collections.abc.Iterator[SmallGroup][source]

Iterator over all groups of a given order.

static get_structure(order: int, index: int) → str[source]

Retrieve a description of the structure of a group.

static number(order: int) → int[source]

The number of groups of a given order.

structure() → str

A description of the structure of this group.

group_index: int
class qldpc.abstract.groups.SpecialLinearGroup(dimension: int, field: int | type[galois.FieldArray] | None = None, linear_rep: bool = True)[source]

Bases: Group

Special linear group (SL): square matrices with determinant 1.

The linear-representation lift is a homomorphism, but its matrices are generally not orthogonal, so the transpose/inverse identity lift(g.T) == lift(g).T does not hold here.

static get_generating_mats(dimension: int, field: int | type[galois.FieldArray] | None = None) → tuple[galois.FieldArray, galois.FieldArray][source]

Generating matrices for the Special Linear group, based on https://arxiv.org/abs/2201.09155.

static iter_mats(dimension: int, field: int | type[galois.FieldArray] | None = None) → collections.abc.Iterator[galois.FieldArray][source]

Iterate over all elements of SL(dimension, field).

property dimension: int

Dimension of the elements of this group.

property field: type[galois.FieldArray]

Base field of this group.

class qldpc.abstract.groups.SymmetricGroup(symbols: int)[source]

Bases: Group

Symmetric group: all permutations of a given number of symbols.

class qldpc.abstract.groups.TrivialGroup[source]

Bases: Group

The trivial group with one member: the identity.

static to_ring_array(data: numpy.typing.NDArray[numpy.int_] | NestedSequence) → None[source]

DEFUNCT alias for qldpc.abstract.RingArray.build(data).

class qldpc.abstract.groups.WreathProductGroup(top: Group, bottom: Group)[source]

Bases: Group

Permutational wreath product of a top group and copies of a bottom group.

If the top group acts on k points and the bottom group acts on m points, an element (h; c_0, ..., c_{k-1}) acts on k * m points by (i, j) -> (h(i), c_i(j)). The selected lift is the natural permutation representation on these k * m points.

element(top_member: GroupMember, bottom_members: collections.abc.Sequence[GroupMember]) → GroupMember[source]

Construct a wreath-product element from its top and bottom components.

Parameters:
  • top_member – An element of the top group.

  • bottom_members – One bottom-group element for each point acted on by the top group.

bottom: Group
bottom_degree: int
top: Group
top_degree: int
qldpc.abstract.groups.resolve_field(field: int | type[galois.FieldArray] | None) → type[galois.FieldArray][source]

Parse a finite field argument to obtain an actual finite field.

qldpc.abstract.groups.GenerateFunc
qldpc.abstract.groups.IntegerLift
qldpc.abstract.groups.Lift
qldpc.abstract.groups.NestedSequence
qldpc.abstract.groups.PSL
qldpc.abstract.groups.SL