# Minimalization and Homogeneous Module Testing

The following functions work with collections of polynomials which are considered as generators for subalgebras or submodules of a polynomial ring. They are repeated from the chapter on multivariate polynomials since they are used extremely often in invariant theory to express an invariant in terms of the primary and secondary invariants of an invariant ring. Full descriptions of the functions are not given here. See the descriptions in the chapter on multivariate polynomials.

## `MinimalAlgebraGenerators(L): [ RngMPol ] -> [ RngMPol ]`

## `MinimalAlgebraGenerators(L): { RngMPol } -> [ RngMPol ]`

Let $R=K[x_1,\ldots,x_n]$ be a polynomial ring of rank $n$ over the field $K$. Suppose $L$ is a set or sequence of $k$ polynomials $p_1,\ldots,p_k$ in $R$. Let $A=K[p_1,\ldots,p_k]$ be the subalgebra (*not* ideal) of $R$ generated by $L$. This function returns a minimal generating set of the algebra $A$ as a (sorted) sequence of elements taken from $L$.

## `HomogeneousModuleTest(P, S, F): [ RngMPol ], [ RngMPol ], RngMPol -> BoolElt, [ RngMPol ]`

Let $R=K[x_1,\ldots,x_n]$ be a polynomial ring of rank $n$ over the field $K$. Suppose $P$ is a sequence of $k$ homogeneous polynomials $p_1,\ldots,p_k$ in $R$ and suppose $S$ is a sequence of $r$ homogeneous polynomials $s_1,\ldots,s_r$ in $R$. Let $A=K[p_1,\ldots,p_k]$ be the subalgebra (*not* ideal) of $R$ generated by $P$ and let $M=A[s_1,\ldots,s_r]$ be the $A$-module generated by $S$ over $A$. Finally, suppose $F$ is an element of $R$. This function returns whether $F$ is in the module $M$ (considered as a submodule of $R$). If the result is `true`, the function also returns a sequence $C=[c_1,\ldots,c_r]$ of length $r$ with $c_i\in K[t_1,\ldots,t_r]$ such that $F=\sum_{i=1}^{r} c_i(p_1,\ldots,p_k)\cdot s_i$.

## `HomogeneousModuleTest(P, S, L): [ RngMPol ], [ RngMPol ], [ RngMPol ] -> [ Bool Elt ], [ [ RngMPol ] ]`

Let $R=K[x_1,\ldots,x_n]$ be a polynomial ring of rank $n$ over the field $K$. Suppose $P$ is a sequence of $k$ homogeneous polynomials $p_1,\ldots,p_k$ in $R$ and suppose $S$ is a sequence of $r$ homogeneous polynomials $s_1,\ldots,s_r$ in $R$. Let $A=K[p_1,\ldots,p_k]$ be the subalgebra (*not* ideal) of $R$ generated by $P$ and let $M=A[s_1,\ldots,s_r]$ be the $A$-module generated by $S$ over $A$. Finally, suppose $L$ is a sequence of length $l$ of elements of $R$ which are all homogeneous of (weighted) degree $d$. This function returns parallel sequences $B$ and $V$ with the following properties:

**(a)**
$B$ is sequence of length $l$ of booleans such that for $1\leq i\leq l$, $B[i]$ is `true` iff $L[i]$ is in the module $M$.

**(b)**
$V$ is a sequence of length $l$ consisting of sequences of length $r$ and consisting of polynomials in the polynomial ring $T=K[t_1,\ldots,t_r]$. (The polynomial ring $T=K[t_1,\ldots,t_r]$ is constructed separately but automatically with the print names `t1`, `t2`, etc.) If $B[i]$ is `false` (so $L[i]$ is not in $M$), $V[i]$ is a sequence of $r$ zero polynomials. Otherwise $V[i]$ is a sequence of $r$ polynomials $c_{i,1},\ldots,c_{i,r}$ in $T$ such that that $L[i]=\sum_{j=1}^{r} c_{i,j}(p_1,\ldots,p_k)\cdot s_j$.

## `Example: Minimal Algebra Generators (ex-4ad419)`

We demonstrate how the function `MinimalAlgebraGenerators` can be used to compute fundamental invariants (in fact, the Magma function `FundamentalInvariants` does just this).

```magma
> K := RationalField();
> G := PermutationGroup<6 | (1,2,3)(4,5,6), (1,2)(4,5)>;
> R := InvariantRing(G, K);
> P := PrimaryInvariants(R);
> P;
[
    x1 + x2 + x3,
    x4 + x5 + x6,
    x1^2 + x2^2 + x3^2,
    x4^2 + x5^2 + x6^2,
    x1^3 + x2^3 + x3^3,
    x4^3 + x5^3 + x6^3
]
> S := SecondaryInvariants(R);
> S;
[
    1,
    x1*x4 + x2*x5 + x3*x6,
    x1^2*x4 + x2^2*x5 + x3^2*x6,
    x1*x4^2 + x2*x5^2 + x3*x6^2,
    x1^2*x4^2 + 2*x1*x2*x4*x5 + 2*x1*x3*x4*x6 + x2^2*x5^2 + 2*x2*x3*x5*x6 +
        x3^2*x6^2,
    x1^3*x4^3 + x1^2*x2*x4*x5^2 + x1^2*x3*x4*x6^2 + x1*x2^2*x4^2*x5 +
        x1*x3^2*x4^2*x6 + x2^3*x5^3 + x2^2*x3*x5*x6^2 + x2*x3^2*x5^2*x6 +
        x3^3*x6^3
]
> MinimalAlgebraGenerators(P cat S);
[
    1,
    x1 + x2 + x3,
    x4 + x5 + x6,
    x1^2 + x2^2 + x3^2,
    x1*x4 + x2*x5 + x3*x6,
    x4^2 + x5^2 + x6^2,
    x1^3 + x2^3 + x3^3 + x4*x5*x6,
    x1^2*x4 + x2^2*x5 + x3^2*x6,
    x1*x4^2 + x2*x5^2 + x3*x6^2,
    x4^3 + x5^3 + x6^3
]

```

## `Example: Homogeneous Module Test2 (ex-4f66d4)`

We demonstrate uses of the function `HomogeneousModuleTest` in invariant theory.

```magma
> // Create invariant ring R with primaries P, secondaries S
> R := InvariantRing(CyclicGroup(4), GF(2));
> P := PrimaryInvariants(R);
> S := SecondaryInvariants(R);
> #S;
5
> S[5];
x1^3*x3^2 + x1^2*x2^2*x3 + x1^2*x2*x3^2 + x1^2*x2*x4^2 +
    x1^2*x3^3 + x1^2*x3^2*x4 + x1*x2^2*x4^2 + x1*x3^2*x4^2 +
    x2^3*x4^2 + x2^2*x3^2*x4 + x2^2*x3*x4^2 + x2^2*x4^3
> // Write S[2] in terms of P and S
> HomogeneousModuleTest(P, S, S[2]^2);
true [
    t1^2*t3^2 + t2^3,
    t1*t2,
    t1^3,
    0,
    0
]
> // Find all invariants I5 of degree 5
> I5 := InvariantsOfDegree(R, 5);
> I5;
[
    x1^5 + x2^5 + x3^5 + x4^5,
    x1^4*x2 + x1*x4^4 + x2^4*x3 + x3^4*x4,
    x1^4*x3 + x1*x3^4 + x2^4*x4 + x2*x4^4,
    x1^4*x4 + x1*x2^4 + x2*x3^4 + x3*x4^4,
    x1^3*x2^2 + x1^2*x4^3 + x2^3*x3^2 + x3^3*x4^2,
    x1^3*x2*x3 + x1*x2*x4^3 + x1*x3^3*x4 + x2^3*x3*x4,
    x1^3*x2*x4 + x1*x2^3*x3 + x1*x3*x4^3 + x2*x3^3*x4,
    x1^3*x3^2 + x1^2*x3^3 + x2^3*x4^2 + x2^2*x4^3,
    x1^3*x3*x4 + x1*x2^3*x4 + x1*x2*x3^3 + x2*x3*x4^3,
    x1^3*x4^2 + x1^2*x2^3 + x2^2*x3^3 + x3^2*x4^3,
    x1^2*x2^2*x3 + x1^2*x2*x4^2 + x1*x3^2*x4^2 + x2^2*x3^2*x4,
    x1^2*x2^2*x4 + x1^2*x3*x4^2 + x1*x2^2*x3^2 + x2*x3^2*x4^2,
    x1^2*x2*x3^2 + x1^2*x3^2*x4 + x1*x2^2*x4^2 + x2^2*x3*x4^2,
    x1^2*x2*x3*x4 + x1*x2^2*x3*x4 + x1*x2*x3^2*x4 + x1*x2*x3*x4^2
]
> // Write all elements of I5 in terms of P and S
> // (the t-variables correspond to elements of P and
> // the "columns" of the inner sequences to elements of S)
> HomogeneousModuleTest(P, S, I5);
[ true, true, true, true, true, true, true, true, true, true,
true, true, true, true ]
[
    [ t1^5 + t1^3*t2 + t1^3*t3 + t1*t2^2 + t1*t3^2 + t1*t4,
        0, t1^2 + t2 + t3, 0, 0 ],
    [ t1^3*t2 + t1^3*t3 + t1*t4, t1^2 + t2, t2 + t3, 0, 0 ],
    [ t1^3*t3 + t1*t3^2 + t1*t4, 0, t1^2 + t2 + t3, 0, 0 ],
    [ t1^3*t3 + t1*t2^2 + t1*t4, t1^2 + t2, t2 + t3, 0, 0 ],
    [ t1*t2^2 + t1*t3^2, t2, t1^2, 0, 1 ],
    [ t1*t2*t3, t3, t2 + t3, 0, 1 ],
    [ t1*t2*t3 + t1*t4, 0, t1^2 + t2, 0, 0 ],
    [ t1*t3^2 + t1*t4, 0, t3, 0, 0 ],
    [ 0, t3, t3, 0, 1 ],
    [ t1*t3^2, t2, t1^2 + t2, 0, 1 ],
    [ t1*t3^2, 0, 0, 0, 1 ],
    [ t1*t3^2, 0, t2, 0, 1 ],
    [ t1*t4, 0, t3, 0, 0 ],
    [ t1*t4, 0, 0, 0, 0 ]
]

```
