---
title: "Structure Operations"
canonical: "https://docs.magma-maths.org/v2.30-1/Algebras/FinitelyPresentedAlgebras/operation.html"
source: "https://docs.magma-maths.org/v2.30-1/Algebras/FinitelyPresentedAlgebras/operation.md"
part: "Algebras"
chapter: "Finitely Presented Algebras"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/index-algebras.md"}
  - {"title": "Finitely Presented Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/FinitelyPresentedAlgebras/index-finitely-presented-algebras.md"}
prev: {"title": "Creation of Free Algebras and Elements", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/FinitelyPresentedAlgebras/algebras.md"}
next: {"title": "Element Operations", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/FinitelyPresentedAlgebras/operation-element.md"}
intrinsics:
  - {"name": "BaseRing", "signature": "BaseRing(F): AlgFr -> Rng"}
  - {"name": "CoefficientRing", "signature": "CoefficientRing(F): AlgFr -> Rng"}
  - {"name": "Category", "signature": "Category(F): AlgFr -> Cat"}
  - {"name": "Parent", "signature": "Parent(F): AlgFr -> Pow"}
  - {"name": "PrimeRing", "signature": "PrimeRing(F): AlgFr -> Rng"}
  - {"name": "Rank", "signature": "Rank(F): AlgFr -> RngIntElt"}
  - {"name": "Characteristic", "signature": "Characteristic(F): AlgFr -> RngIntElt"}
  - {"name": "#", "signature": "# F: AlgFr -> RngIntElt"}
  - {"name": "hom", "signature": "hom< F -> S | f, y₁, ..., yₙ >: AlgFr, Rng -> Map"}
  - {"name": "hom", "signature": "hom< F -> S | y₁, ..., yₙ >: AlgFr, Rng -> Map"}
examples:
  - "ex-15e82d"
---

# Structure Operations

## Related Structures

The main structure related to a free algebra is its coefficient ring. Multivariate free algebras belong to the Magma category `AlgFr`.

<a id="function-basering-algfr"></a>
### `BaseRing(F): AlgFr -> Rng`

<a id="function-coefficientring-algfr"></a>
### `CoefficientRing(F): AlgFr -> Rng`

Return the coefficient ring of the free algebra $F$.

<a id="function-category-algfr"></a>
### `Category(F): AlgFr -> Cat`

<a id="function-parent-algfr"></a>
### `Parent(F): AlgFr -> Pow`

<a id="function-primering-algfr"></a>
### `PrimeRing(F): AlgFr -> Rng`

## Numerical Invariants

Note that the `#` operator only returns a value for finite (quotients of) free algebras.

<a id="function-rank-algfr"></a>
### `Rank(F): AlgFr -> RngIntElt`

Return the number of indeterminates of free algebra $F$ over its coefficient ring.

<a id="function-characteristic-algfr"></a>
### `Characteristic(F): AlgFr -> RngIntElt`

<a id="operation-operation-algfr-rngintelt"></a>
### `# F: AlgFr -> RngIntElt`

## Homomorphisms

In its most general form, a homomorphism taking a free algebra $K\langle x_1, \ldots, x_n\rangle$ as domain requires $n+1$ pieces of information, namely, a map (homomorphism) telling how to map the coefficient ring $K$ together with the images of the $n$ indeterminates. The map for the coefficient ring is optional.

<a id="constructor-constructor-hom-algfr-rng-map"></a>
### `hom< F -> S | f, y₁, ..., yₙ >: AlgFr, Rng -> Map`

<a id="constructor-constructor-hom-algfr-rng-map-2"></a>
### `hom< F -> S | y₁, ..., yₙ >: AlgFr, Rng -> Map`

Given a free algebra $F=K\langle x_1, \ldots, x_n\rangle$, a ring or associative algebra $S$ (including another FP-algebra or a matrix algebra), and a map $f : K\rightarrow S$ and $n$ elements $y_1, \ldots, y_n\in S$, create the homomorphism $g : F\rightarrow S$ by applying the rules that $g(rx_1^{a_1}\cdots x_n^{a_n})=f(r)y_1^{a_1}\cdots y_n^{a_n}$ for monomials and linearity, that is, $g(M+N)=g(M)+g(N)$. The coefficient ring map may be omitted, in which case the coefficients are mapped into $S$ by the coercion map. No attempt is made to check whether the map defines a genuine homomorphism.

<a id="example-ex-15e82d"></a>
### `Example: Homomorphisms from a Free Algebra (ex-15e82d)`

In this example we map an algebra $F$ first into $F$ itself, and then into a matrix algebra.

```magma
> K := RationalField();
> F<x,y,z> := FreeAlgebra(K, 3);
> h := hom<F -> F | x*y, y*x, z*x>;
> h(x);
x*y
> h(y);
y*x
> h(x*y);
x*y^2*x
> h(x + y + z);
x*y + y*x + z*x
> A := MatrixAlgebra(K, 2);
> M := [A | [1,1,-1,1], [-1,3,4,1], [11,7,-7,8]];
> M;
[
    [ 1  1]
    [-1  1],

    [-1  3]
    [ 4  1],

    [11  7]
    [-7  8]
]
> h := hom<F -> A | M>;
> h(x);
[ 1  1]
[-1  1]
> h(y);
[-1  3]
[ 4  1]
> h(x*y - y*z);
[ 35 -13]
[-32 -38]
```
