# Module Operations

The following functions perform some fundamental module operations.

## `MinimalBasis(M): ModMPol -> [ ModMPolElt ]`

Given an $R$-module $M$, return a minimal basis $B$ of $M$. If $M$ is graded, or if $R$ is a local ring, then the cardinality of $B$ (the rank) is guaranteed to be unique (so is the absolutely minimal number of elements needed to generate $M$).

Otherwise the cardinality of $B$ is not unique: $B$ will only satisfy the rule that the $i$-th element of $B$ is not in the submodule generated by elements $1$ to $i-1$ of $B$.

In the graded case or local cases, a minimal basis is computed in the usual way starting from any basis $B$ consisting of homogeneous elements. $B$ gives a particular presentation whose relation matrix $R$ consists of homogeneous polynomials. If $R$ contains a non-zero constant term (or more generally a unit in the local case), an element of $B$ can be eliminated and $R$ recalculated. This can be continued until all non-zero terms of $R$ have positive degree.

## `MinimalBasis(S): [ ModMPolElt ] -> [ ModMPolElt ]`

## `MinimalBasis(S): { ModMPolElt } -> [ ModMPolElt ]`

Given a set or sequence $S$ of homogeneous module elements from a module $M$, return a minimal basis of the submodule of $M$ generated by $S$.

## `Rank(M): ModMPol -> RngIntElt`

Given an $R$-module $M$, return the rank of $M$. This is simply defined to be the cardinality of the minimal basis of $M$, returned by the function `MinimalBasis`. Thus if $M$ is graded, or if $R$ is a local ring, then the rank is guaranteed to be unique (and is the absolutely minimal number of elements needed to generate $M$). Otherwise the result is not an invariant of $M$, but simply reflects the minimum as found by the `MinimalBasis` algorithm.

## `ColonModule(M, J): ModMPol, RngMPol -> ModMPol`

Given an $R$-module $M$ and an ideal $J$ of $R$, return the colon module $M:J$ which is the submodule of the ambient module $A$ of $M$ consisting of all $f\in A$ such that $f\cdot g\in M$ for all $g\in J$. When $J$ is generated by a single element, this easily reduces to a syzygy computation in $A$ and in the general case, we intersect the colon modules for a set of generators of $J$.

## `ColonIdeal(M, N): ModMPol, ModMPol -> RngMPol`

Given an $R$-modules $M$ and $N$ which are both submodules of a common supermodule, return the colon ideal $M:N$, which is the ideal of $R$ consisting of all $f\in R$ such that $f\cdot N \subset M$. The algorithm used is as described in section 2.8.4 of [[Greuel and Pfister, 2002](../../references.md#cite-grpf02)].

## `Annihilator(M): ModMPol -> RngMPol`

Given an $R$-module $M$, return the annihilator ideal of $M$. This is the ideal $I$ of $R$ consisting of all $f\in R$ such that $f\cdot M = 0$ (which can be seen to equal the ideal $0_M : M$, where $0_M$ is the zero submodule of $M$, so is a special case of `ColonIdeal`).

## `FittingIdeal(M, i): ModMPol, RngIntElt -> RngMPol`

Given an $R$-module $M$ of degree $r$ and an integer $i\ge 0$, return the $i$-th Fitting ideal of $M$, which is the ideal of $R$ generated by the $(r-i)$-th minors of the presentation matrix of $M$, where $r$ is the degree of $M$. See [[Cox *et al.*, 1998](../../references.md#cite-uag-clo), p.229] or [[Eisenbud, 1995](../../references.md#cite-eisenbudcommalg), Sec. 20.2].

## `FittingIdeals(M): ModMPol -> RngMPol`

Given an $R$-module $M$ of degree $r$, return the Fitting ideals (for from 0 to $r$) as a sequence of ideals of $R$.

## `SyzygyModule(M): ModMPol -> [ ModMPolElt ]`

Given a module $M$, return the syzygy module $S$ of $M$. If the basis $B$ of $M$ has length $k$, the syzygy module $S$ has degree $k$ and elements of $S$ express a syzygy amongst the $k$ elements of the basis $B$. Note that the degree of the resulting module thus depends on the current basis of $M$.

## `MinimalSyzygyModule(M): ModMPol -> [ ModMPolElt ]`

Given a homogeneous module $M$, return the syzygy module $S$ of the minimal basis of $M$. If the minimal basis $B$ of $M$ has length $k$, the syzygy module $S$ has degree $k$ and elements of $S$ express a syzygy amongst the $k$ elements of the minimal basis $B$.

## `SyzygyModule(Q): [ RngMPolElt ] -> ModTupRng`

Given a sequence $Q$ of polynomials from a multivariate polynomial ring $P$, return the module of syzygies of $Q$. This is a module over $P$ of degree $k$, where $k$ is the length of $Q$, consisting of all vectors $v$ such that the sum of $v[i]*Q[i]$ for $i=1,\ldots k$ is zero.

## `Example: Rank (ex-e30655)`

In this example we note that a certain module $M$ has rank 3 (equal to its degree 3), since no generator is redundant. If we move to the localization of $M$, then $(1+x-z)$ becomes a unit, so the first generator becomes redundant.

```magma
> R<x,y,z> := PolynomialRing(RationalField(), 3, "grevlex");
> F := RModule(R, 3);
> M := quo<F | [x + 1, y, z], [z, y, 0]>;
> M;
Reduced Module R^3/<relations>
Relations:
[x + 1,     y,     z],
[    z,     y,     0]
> Degree(M);
3
> Rank(M);
3
> ML := Localization(M);
> ML;
Reduced Module R^3/<relations> (local)
Relations:
[1 + x - z,         0,         z],
[        z,         y,         0]
> Rank(ML);
2
> MinimalBasis(ML);
[
    [0, 1, 0],
    [0, 0, 1]
]

```
