# Set-Theoretic Operations

## Functions Relating to Group Order

### `Order(G): GrpAb -> RngIntElt`

### `# G: GrpAb -> RngIntElt`

The order of the group $G$, returned as an ordinary integer. If $G$ is an infinite group, the value zero is returned. Note that if $G$ is a generic group then determining the order will require the structure of $G$ to be determined.

### `FactoredOrder(G): GrpAb -> [<RngIntElt, RngIntElt>]`

The factored order of the group $G$, returned as a sequence of prime-exponent pairs. If $G$ is an infinite group, the empty sequence is returned. Note that if $G$ is a generic group then determining the order will require the structure of $G$ to be determined.

### `Exponent(G): GrpAb -> RngIntElt`

The exponent of the group $G$. If the group is infinite, the value zero is returned. Note that if $G$ is a generic group then determining the exponent will require the structure of $G$ to be determined.

### `IsFinite(G): GrpAb -> BoolElt`

Return `true` if the group $G$ is finite.

### `IsInfinite(G): GrpAb -> BoolElt`

Return `true` if $G$ is infinite, `false` otherwise.

## Membership and Equality

### `g in G: GrpAbElt, GrpAb -> BoolElt`

Given an element $g$ and a group $G$, return `true` if $g$ is an element of $G$, `false` otherwise.

### `g notin G: GrpAbElt, GrpAb -> BoolElt`

Given an element $g$ and a group $G$, return `true` if $g$ is not an element of $G$, `false` otherwise.

### `S subset G: { GrpAbElt}, GrpAb -> BoolElt`

Given a group $G$ and a set $S$ of elements belonging to a group $H$, where $G$ and $H$ have some covering group, return `true` if $S$ is a subset of $G$, `false` otherwise.

### `S notsubset G: { GrpAbElt}, GrpAb -> BoolElt`

Given a group $G$ and a set $S$ of elements belonging to a group $H$, where $G$ and $H$ have some covering group, return `true` if $S$ is not a subset of $G$, `false` otherwise.

### `H subset G: GrpAb, GrpAb -> BoolElt`

### `IsSubgroup(H, G): GrpAb, GrpAb -> BoolElt`

Given groups $G$ and $H$, subgroups of some common overgroup, return `true` if $H$ is a subgroup of $G$, and `false` otherwise.

### `H notsubset G: GrpAb, GrpAb -> BoolElt`

Given groups $G$ and $H$, subgroups of some common overgroup, return `true` if $H$ is not a subgroup of $G$, and `false` otherwise.

### `G eq H: GrpAb, GrpAb -> BoolElt`

Given groups $G$ and $H$, subgroups of some common overgroup, return `true` if $G$ and $H$ are identical, and `false` otherwise.

### `G ne H: GrpAb, GrpAb -> BoolElt`

Given groups $G$ and $H$, subgroups of some common overgroup, return `true` if $G$ and $H$ are distinct groups, and `false` otherwise.

## Set Operations

### `NumberingMap(G): GrpAb -> Map`

A bijective mapping from the finite group $G$ onto the set of integers $\{ 1 \ldots |G| \rbrace$. The actual mapping depends upon choice of standard generators for $G$.

### `RandomProcess(G): GrpAb -> Process`

```magma
Slots   : RngIntElt                    Default: 10
Scramble: RngIntElt                    Default: 100
```

Create a process to generate randomly chosen elements from the finite group $G$. The process is based on the product-replacement algorithm of [[Celler *et al.*, 1995](../../references.md#cite-randomelements)], modified by the use of an accumulator. At all times, $N$ elements are stored where $N$ is the maximum of the specified value for `Slots` and `Ngens`$(G) + 1$. Initially, these are just the generators of $G$. As well, one extra group element is stored, the accumulator. Initially, this is the identity. Random elements are now produced by successive calls to `Random(P)`, where $P$ is the process created by this function. Each such call chooses one of the elements in the slots and adds it into the accumulator. The element in that slot is replaced by the sum of it and another randomly chosen slot. The random value returned is the new accumulator value. Setting `Scramble := m` causes $m$ such sum-replacement operations to be performed before the process is returned. Note that this algorithm cannot produce well-distributed random elements of an infinite group.

### `Random(P): Process -> GrpAbElt`

Given a random element process $P$ created by the function `RandomProcess(G)` for the finite abelian group $G$, return the next random element of $G$ defined by the process.

### `Random(G): GrpAb -> GrpAbElt`

### `Random(G, n): GrpAb, RngIntElt -> GrpAbElt`

An element chosen at random from the abelian group $G$. The argument $n$ gives the maximum exponent for infinite generators, and defaults to 10 if not supplied.

### `Rep(G): GrpAb -> GrpAbElt`

### `Representative(G): GrpAb -> GrpAbElt`

A representative element of $G$.
