# Subcodes

## The Subcode Constructor

### `sub<C | L>: CodeAdd, List -> CodeAdd`

Given a $K$-additive linear code $C$ over $F$, construct the subcode of $C$, generated (over $K$) by the elements specified by the list $L$, where $L$ is a list of one or more items of the following types:

**(a)**
An element of $C$;

**(b)**
A set or sequence of elements of $C$;

**(c)**
A sequence of $n$ elements of $F$, defining an element of $C$;

**(d)**
A set or sequence of sequences of type (c);

**(e)**
A subcode of $C$;

### `Subcode(C, k): CodeAdd, RngIntElt -> CodeAdd`

Given an additive code $C$ and an integer $k$, where $k$ is less than the number of generators of $C$, then return a subcode of $C$ with $k$ generators.

### `Subcode(C, S): CodeAdd, { RngIntElt } -> Code`

Suppose $C$ is an additive code and $S$ is a set of positive integers, each of which is less than the number of generators of $C$. The function returns the subcode of $C$ generated by the generators of $C$ indexed by $S$.

### `SubcodeBetweenCode(C1, C2, k): CodeAdd, CodeAdd, RngIntElt -> CodeAdd`

Given an additive code $C_1$ and a subcode $C_2$ of $C_1$, return a subcode of $C_1$ with $k$ generators containing $C_2$.

### `SubcodeWordsOfWeight(C, w): CodeAdd, RngIntElt -> CodeAdd`

Given a length $n$ additive code $C$ and an integer which lies in the range $[1,n]$, return the subcode of $C$ generated by those words of $C$ of weight $w$.

### `SubcodeWordsOfWeight(C, S): CodeAdd, { RngIntElt } -> CodeAdd`

Given a length $n$ additive code $C$ and a set $S$ of integers, each of which lies in the range $[1,n]$, return the subcode of $C$ generated by those words of $C$ whose weights lie in $S$.

### `Example: Subcode Between Code (ex-18722c)`

We give an example of how `SubcodeBetweenCode` may be used to create a code nested in between a subcode pair.

```magma
> F<w> := GF(8);
> C1 := AdditiveRepetitionCode(F, GF(2), 6);
> C1;
[6, 1 : 3, 6] GF(2)-Additive Code over GF(2^3)
Generator matrix:
[  1   1   1   1   1   1]
[  w   w   w   w   w   w]
[w^2 w^2 w^2 w^2 w^2 w^2]
> C3 := AdditiveZeroSumCode(F, GF(2), 6);
> C3;
[6, 5 : 15, 2] GF(2)-Additive Code over GF(2^3)
Generator matrix:
[  1   0   0   0   0   1]
[  w   0   0   0   0   w]
[w^2   0   0   0   0 w^2]
[  0   1   0   0   0   1]
[  0   w   0   0   0   w]
[  0 w^2   0   0   0 w^2]
[  0   0   1   0   0   1]
[  0   0   w   0   0   w]
[  0   0 w^2   0   0 w^2]
[  0   0   0   1   0   1]
[  0   0   0   w   0   w]
[  0   0   0 w^2   0 w^2]
[  0   0   0   0   1   1]
[  0   0   0   0   w   w]
[  0   0   0   0 w^2 w^2]
> C1 subset C3;
true
> C2 := SubcodeBetweenCode(C3, C1, 11);
> C2;
[6, 3 2/3 : 11] GF(2)-Additive Code over GF(2^3)
Generator matrix:
[  1   0   0   0   1   0]
[  w   0   0   0   w   0]
[w^2   0   0 w^2 w^2 w^2]
[  0   1   0   0   0   1]
[  0   w   0   0   0   w]
[  0 w^2   0   0   0 w^2]
[  0   0   1   0   0   1]
[  0   0   w   0   0   w]
[  0   0 w^2   0   0 w^2]
[  0   0   0   1   0   1]
[  0   0   0   w   0   w]
> (C1 subset C2) and (C2 subset C3);
true

```

## Sum, Intersection and Dual

For the following operators, $C$ and $D$ are additive codes defined as subsets (or subspaces) of the same $R$-space $F^n$.

### `C + D: CodeAdd, CodeAdd -> CodeAdd`

Given two additive codes which have the same length, which are defined over the same alphabet, and which have the same coefficient ring $F$, return the sum of these two codes with respect to $F$.

### `C meet D: Code, Code -> Code`

The intersection of the additive codes $C$ and $D$.

### `Dual(C): Code -> Code`

The code that is dual to the code $C$. For an additive code $C$, this is the code generated by the nullspace of $C$, relative to the trace inner product.

## Membership and Equality

### `u in C: ModTupRngElt, CodeAdd -> BoolElt`

Return `true` if and only if the vector $u$ of $V$ belongs to the additive code $C$, where $V$ is the generic vector space containing $C$.

### `u notin C: ModTupRngElt, CodeAdd -> BoolElt`

Return `true` if and only if the vector $u$ does not belong to the additive code $C$, where $V$ is the generic vector space containing $C$.

### `C subset D: Code, Code -> BoolElt`

Return `true` if and only if the wordset of the code $C$ is a subset of the wordset of the code $D$. (Either code may possibly be additive).

### `C notsubset D: Code, Code -> BoolElt`

Return `true` if and only if the wordset of the code $C$ is not a subset of the wordset of the code $D$. (Either code may possibly be additive).

### `C eq D: Code, Code -> BoolElt`

Return `true` if and only if the codes $C$ and $D$ have the same wordsets. (Either code may possibly be additive).

### `C ne D: Code, Code -> BoolElt`

Return `true` if and only if the codes $C$ and $D$ have different wordsets. (Either code may possibly be additive).
