# Operations on Algebras and Subalgebras

## Invariants of an Algebra

### `CoefficientRing(A): AlgGen -> Rng`

### `CoefficientField(A): AlgGen -> Rng`

### `BaseRing(A): AlgGen -> Rng`

### `BaseField(A): AlgGen -> Rng`

The coefficient ring (or base ring) over which the algebra $A$ is defined.

### `Dimension(A): AlgGen -> RngIntElt`

The dimension of the algebra $A$.

### `# A: AlgGen -> RngIntElt`

The cardinality of the algebra $A$ if both $R$ and the dimension of $A$ are finite. Note that this cannot be computed if the dimension of $A$ is too large.

## Changing Rings

### `ChangeRing(A, S): AlgGen, Rng -> AlgGen, Map`

Given an algebra $A$ with base ring $R$, together with a ring $S$, construct the algebra $B$ with base ring $S$ obtained by coercing the coefficients of elements of $A$ into $S$, together with the homomorphism from $A$ to $B$.

This function can not be applied if $A$ is of type `AlgGrpSub`, as the parent structure of elements of $A$ is the full group algebra of which $A$ is a subalgebra.

### `ChangeRing(A, S, f): AlgGen, Rng, Map -> AlgGen, Map`

Given an algebra $A$ with base ring $R$, together with a ring $S$ and a map $f: R \rightarrow S$, construct the algebra $B$ with base ring $S$ obtained by mapping the coefficients of elements of $A$ into $S$ via $f$, together with the homomorphism from $A$ to $B$.

As above, this function can not be applied if $A$ is of type `AlgGrpSub`.

## Bases

In general, every algebra comes with a basis, corresponding to its underlying module structure. The only exception for that are group algebras in the `"Terms"` representation, where the dimension of the algebra may be too large to create vectors of that degree.

### `BasisElement(A, i): AlgGen, RngIntElt -> AlgGenElt`

### `A . i: AlgGen, RngIntElt -> AlgGenElt`

The $i$-th basis element of the algebra $A$.

### `Basis(A): AlgGen -> [ AlgGenElt ]`

The basis of the algebra $A$, as a sequence of elements of $A$.

Note that if $A$ is of type `AlgGrpSub` the returned elements will be elements of the full group algebra of which $A$ is a subalgebra.

### `IsIndependent(Q): [ AlgGen ] -> BoolElt`

Given a sequence $Q$ of elements of the $R$-algebra $A$, this functions returns `true` if these elements are linearly independent over $R$; otherwise `false`.

### `ExtendBasis(S, A): AlgGen, AlgGen -> [ AlgElt ]`

### `ExtendBasis(Q, A): [ AlgGen ], AlgGen -> [ AlgElt ]`

Given an algebra $A$ and either a subalgebra $S$ of dimension $m$ of $A$ or a sequence $Q$ of $m$ linearly independent elements of $A$, return a sequence containing a basis of $A$ such that the first $m$ elements are the basis of $S$ resp. the elements in $Q$.

## Decomposition of an Algebra

An algebra $A$ can be regarded as a (left- or right-) module for itself. If $A$ is defined over a finite field, the machinery to decompose modules over finite fields can be used to investigate the structure of the algebra $A$.

### `CompositionSeries(A): AlgGen -> [ AlgGen ], [ AlgGen ], AlgMatElt`

Compute a composition series for the algebra $A$. The function has three return values:

**(a)**
a sequence containing the composition series as an ascending chain of subalgebras such that the successive quotients are irreducible $A$-modules;

**(b)**
a sequence containing the composition factors as structure constant algebras;

**(c)**
a transformation matrix to a basis compatible with the composition series, that is, the first basis elements form a basis of the first term of the composition series, the next extend these to a basis for the second term etc.

### `CompositionFactors(A): AlgGen -> [ AlgGen ]`

Compute the composition factors of a composition series for the algebra $A$. This function returns the same as the second return value of `CompositionSeries` above, but will often be very much quicker.

### `MinimalLeftIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

### `MinimalRightIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

### `MinimalIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

```magma
Limit: RngIntElt                    Default: Infinity()
```

Return the minimal left/right/two-sided ideals of $A$ (in non-decreasing size). If `Limit` is set to $n$, at most $n$ ideals are calculated and the second return value indicates whether all of the ideals were computed.

### `MaximalLeftIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

### `MaximalRightIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

### `MaximalIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

```magma
Limit: RngIntElt                    Default: Infinity()
```

Return the maximal left/right/two-sided ideals of $A$ (in non-decreasing size). If `Limit` is set to $n$, at most $n$ ideals are calculated and the second return value indicates whether all of the ideals were computed.

### `JacobsonRadical(A): AlgGen -> AlgGen`

Construct the Jacobson (or nilpotent) radical of $A$, that is, the intersection of the maximal ideals of $A$ (which is equal to the intersection of the maximal left or right ideals).

### `IsSemisimple(A): AlgGen -> BoolElt`

Return `true` if the Jacobson radical of $A$ is trivial; otherwise `false`.

### `IsSimple(A): AlgGen -> BoolElt`

Return `true` if $A$ has no non-trivial composition factor; otherwise `false`.

### `Example: quaternions (ex-0f19c1)`

We create a division algebra of dimension 4 over the rational field.

```magma
> Q := MatrixAlgebra< Rationals(), 4 |
>    [0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0],
>    [0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]>;
> i := Q.1;
> j := Q.2;
> k := i*j;
> Dimension(Q);
4
> MinimalPolynomial( (1+i+j+k)/2 );
$.1^2 - $.1 + 1

```

Hence, the element `(1+i+j+k)/2` is integral. In fact, together with `1`, `i` and `j` it forms a ${\mathbb{Z}}$-basis of a maximal order in `Q`. We create this maximal order as a structure constant algebra over the integers.

```magma
> a := [ Q!1, i, j, (1+i+j+k)/2 ];
> T := MatrixAlgebra(Rationals(),4) ! &cat[ Coordinates(Q,a[i]) : i in [1..4] ];
> V := RSpace(Rationals(), 4);
> C := [ V ! Coordinates(Q, a[i]*a[j]) * T^-1 : j in [1..4], i in [1..4] ];
> A := ChangeRing( Algebra< V | C >, Integers() );
> IsAssociative(A);
true
> AA := AssociativeAlgebra(A);
> AA;
Associative Algebra of dimension 4 with base ring Integer Ring
> MinimalPolynomial(AA.4);
$.1^2 - $.1 + 1

```

The so constructed maximal order is ramified at 2 and $\infty$, hence it should be simple after reducing at odd primes.

```magma
> for p in [ i : i in [1..100] | IsPrime(i) ] do
>    if not IsSimple( ChangeRing( AA, GF(p) ) ) then
>       print p;
>    end if;
> end for;
2
> CS, CF, T := CompositionSeries( ChangeRing( AA, GF(2) ) );
> T;
[1 0 1 0]
[0 1 1 0]
[0 0 1 0]
[0 0 0 1]

```

A glance at the preimages of the basis of the irreducible submodule shows the ramification of $AA$ at the prime 2.

```magma
> MinimalPolynomial(AA.1 + AA.3);
$.1^2 - 2*$.1 + 2
> MinimalPolynomial(AA.2 + AA.3);
$.1^2 + 2

```

## Operations on Subalgebras

### `IsZero(A): AlgGen -> BoolElt`

Returns `true` if the algebra $A$ is trivial; otherwise `false`.

### `A eq B: AlgGen, AlgGen -> BoolElt`

Returns `true` if the algebras $A$ and $B$ (having a common superalgebra) are equal; otherwise `false`.

### `A ne B: AlgGen, AlgGen -> BoolElt`

Returns `true` if the algebras $A$ and $B$ are not equal; otherwise `false`.

### `A subset B: AlgGen, AlgGen -> BoolElt`

Returns `true` if $A$ is a subalgebra of the algebra $B$; otherwise `false`.

### `A notsubset B: AlgGen, AlgGen -> BoolElt`

Returns `true` if $A$ is not a subalgebra of the algebra $B$; otherwise `false`.

### `A meet B: AlgGen, AlgGen -> AlgGen`

The intersection of the algebras $A$ and $B$, which must have a common superalgebra.

### `A * B: AlgGen, AlgGen -> AlgGen`

The algebra product $A * B$ of the algebras $A$ and $B$, which must have a common superalgebra.

### `A ^ n: AlgGen, RngIntElt -> AlgGen`

The (left-normed) $n$-th power of the algebra $A$. i.e., $(( \ldots (A*A)* \ldots )*A)$.

### `Morphism(A, B): AlgGen, AlgGen -> Map`

The map giving the morphism from $A$ to $B$. Either $A$ is a subalgebra of $B$, in which case the embedding of $A$ into $B$ is returned, or $B$ is a quotient algebra of $A$, in which case the natural epimorphism from $A$ onto $B$ is returned.
