This paper builds a novel bridge
between algebraic coding theory and mathematical knot theory, with applications in both directions. We give methods to construct error-correcting codes starting from the colorings of a knot, describing through a series of results how the properties of the knot translate into code parameters. We show that
knots can be used
to obtain error-correcting codes
with prescribed parameters
and an efficient decoding algorithm.

§ INTRODUCTION

The theory of error-correcting codes and their properties has been classically investigated in connection with several other areas of discrete mathematics, including finite geometry, enumerative combinatorics, algebraic combinatorics, algebraic and arithmetic geometry, matroid theory, ring theory, symbolic dynamics, and lattice theory to mention a few [25, 4, 37, 45, 3, 9].

Studying codes in relation to other mathematical objects is
an interesting and well-established
research direction, which over the decades offered a new perspective on various classical problems. For example, deciding over which fields MDS codes exist is equivalent to deciding over which fields the uniform matroid is representable and is linked to the famous MDS Conjecture [43].

In this paper, we initiate the study of error-correcting codes in connection with mathematical knot theory, establishing a link between these two research domains. To our best knowledge, our paper is the first attempt to systematically and rigorously bridge coding theory with knot theory, except for the BSc and MSc theses of the second author of this paper [35, 36].

The way we associate codes to knots is via (Fox or Dehn) colorings of the knot diagram. A knot diagram is a planar representation of a knot that can be divided into strands. These can be assigned colors, which are elements of a commutative ring $R$ and where the coloring rules depend on some invertible element $t \in R$. The code is then constructed by using the coloring matrix as a parity check matrix; see Sections <ref> and <ref> for the definitions.

The paper then investigates how properties of knots translate into properties of the associated error-correcting code. To do so, we also establish some new properties of knot colorings. Most of our results focus on the length and the dimension of the associated code, but we are also able to
prove some properties of the minimum distance (whose study appears to be a challenging task).

In our paper, we pay particular attention to two families of knots and their error-correcting codes.
These are torus knots and their iterations, and pretzel knots. We compute the parameters of the corresponding codes
in several instances.

We also study the connected sum of knots and how the corresponding codes behave. Finally, we investigate the natural question of when the dual of a knot code is a knot code, and provide partial answers.

Outline. The remainder of this paper is organized as follows. In Section <ref>
we briefly review the preliminaries of knot and coding theory that are needed for this paper.
Section <ref> is about knot colorings and their algebra.
In Section <ref> we show how one can associate a code to a knot and investigate how the knot properties translate into code parameters. In Section <ref> we focus on torus knots, pretzel knots, and their associated codes.
Sections <ref> and <ref> conclude the paper and are about
the connected sum of knots and the dual of knot codes, respectively.
The paper also contains an appendix for the needed commutative algebra background.

§ KNOTS AND CODES

In this section we give preliminary definitions and results on knot and coding theory that will be used throughout the paper.
Since these two research areas are almost disjoint, we review the very basic concepts and include a selection of standard references.
We assume that the reader is familiar with
elementary concepts from algebra and topology; see [24] and [32] as standard references, among many others.

§.§ Knot Theory

We start with the definition of a mathematical knot, following to various degrees [7, 26, 22, 33].

A (mathematical) knot $K$ is a topological subspace of the Euclidean space $\R^3$ that is homeomorphic to the unit circle $S^1 \subseteq \R^2$, endowed with the induced Euclidean topology.
Knots $K_1, K_2 \subseteq \R^3$ are
equivalent if there exists an orientation-preserving homeomorphism
$f: \R^3 \to \R^3$ such that
$f(K_1)=K_2$. A knot $K$ is called trivial (or unknotted) if it is equivalent to the knot
$$\{(x_1,x_2,0) \mid x_1, x_2 \in \R, \, x_1^2+x_2^2=1\} \subseteq \R^3.$$

Making the notions of orientation
and orientation-preserving map
rigorous is
a non-trivial task that is best accomplished by homology theory in algebraic topology; see e.g. <cit.>.
Intuitively (and not rigorously), a homeomorphism $\R^3 \to \R^3$ is orientation-preserving if it sends a right-hand frame into a right-hand frame.
It can be shown (see <cit.>) that knots $K_1, K_2 \subseteq \R^3$ are equivalent if and only if there exists a homeomorphism $f: \R^3 \to \R^3$ and a real number $\xi >0$ such that
$f(K_1)=K_2$ and $f(x)=x$ for all $x \in \R^3$ with $\left\| x\right\| \ge \xi$. The latter can be taken as an elementary, but fully rigorous, definition of a knot equivalence.

A trivial knot is also called an unknot. An unknot is depicted in Figure <ref> and a figure-eight knot
is depicted in Figure <ref>. The latter is a non-trivial knot as we will explain later via colorings, see Figure <ref>.

[color=black, fill=white!5, ultra thick](-1,0) circle (1.5);

An unknot.

[use Hobby shortcut]
([closed]0,0) .. (1.5,1) .. (.5,2) ..
(-.5,1) .. (.5,0) .. (0,-.5) .. (-.5,0) ..
(.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);

every spath component/.style=ultra thick, draw,

A figure-eight knot.

An example of a trivial and a non-trivial knot.

A knot can sometimes be seen as an entangled polygon in a three-dimensional space. To make this formal, we give the following definition.

A knot is called polygonal if it is a union of finite number of line segments. These line segments are the edges and their endpoints are the vertices of the knot.

Note that the drawings of Figure <ref> are smooth, but can be seen as polygonal knots with smoothened vertices.
A knot that is equivalent to a polygonal knot is called tame. A knot that is not tame is called wild; see <cit.>.

In this paper, a knot will always mean an oriented, polygonal knot, unless otherwise stated. We will omit information about the orientation when it is not relevant.
See Remark <ref> for the reason of restricting ourselves to this specific family of knots.
Throughout this paper, $K$ always denotes a knot, unless otherwise stated.

The knots that lie on the surface of an unknotted torus are of particular interest and will be used later in Section <ref>.

Consider the embedding of the torus $S^1\times S^1$  in $\R^3$ given by the implicit equation

Let $(a,b)$ be a pair of nonzero integers that are relatively prime.
The $(a,b)$-torus knot $\mT(a,b)$
is the image of the map $S^1 \rightarrow \R^3$, lying on the torus, given by

(\cos(t),\sin(t)) \longmapsto (\cos(at)(2+\cos(bt)),\ \sin(at)(2+\cos(bt)),\ \sin(bt));

see e.g. <cit.>.
The knot “turns” $a$ times meridionally and $b$ times longitudinally.

use Hobby shortcut,
every trefoil component/.style=ultra thick, draw
[spath/save=trefoil] ([closed]90:2) foreach įn 1,...,3
.. (-30+*̨240:.5) .. (90+*̨240:2)  (90:2);

A trefoil knot.

The torus knot $\mT(2,3)$  is more commonly known as the trefoil knot.
It is depicted in Figure <ref>. For any nonzero integer $a$, the torus knot
$\mT(a,\pm 1)$ is a trivial knot. The torus knots are completely classified; see <cit.>.

Figure <ref>  depicts
the trefoil knot of Figure <ref> as an entangled polygon in a three-dimensional space, and as a knot that lie on the surface of a torus.

clip width=5,
flip crossing=1,
[black,ultra thick] (2.1,4.2) to  (3,6) to (5,2) to (1.25,2);
[black,ultra thick] (0.75,2) to  (-1,2) to (1,6) to (2.9,2.2);
[black,ultra thick] (3.1,1.8) to  (4,0) to (0,0) to (1.9,3.8);

A polygonal trefoil knot.

[axis equal image, hide axis, view = 15260, scale= 2.8]

3[domain=0:360, y domain=0:360, samples=20, surf, z buffer=sort]
(2 + cos(x))*cos(y),
(2 + cos(x))*sin(y),

3[domain=0:360, samples=50]
(2 + cos(3*x))*cos(2*x),
(2 + cos(3*x))*sin(2*x),

The torus knot $\mT(2,3)$.

The trefoil knot as an entangled polygon and as a torus knot.

As in Figures <ref> and <ref>, to visualize knots their two-dimensional projections are used. These are called knot diagrams and  are defined as follows. We refer to [33] for a complete treatment.

Let $p:\R^3 \rightarrow \R^3$ be defined by $p(x,y,z) = (x,y,0)$.
of a polygonal knot $K$ is
$p(K)$, together with the orientation inherited by
$K$, if $K$ was oriented.
The projection is called regular if it satisfies the following three conditions:

* $p(K)$ has at most a finite number of points of intersection, where $Q$ is a point of intersection of $p(K)$ if $|p^{-1}(Q)| > 1.$

* If $Q$ is point of intersection of $p(K)$, then $K \cap p^{-1}(Q)$ has exactly two points. Such a point is called a double point of $p(K)$.

* A vertex of $K$ is not mapped to a double point of $p(K)$.

At a double point of a projection, to distinguish whether the
knot passes over or under itself, we draw the projection
so that it appears to have been cut; see for example Figure <ref>. Such an altered projection is called a diagram of $K$.

From now on, we assume that the diagrams of knots we use in the paper are regular. This can be justified by the following theorem.

Any polygonal knot $K$ is equivalent, under an arbitrarily small rotation of $\R^3$, to a polygonal knot $K'$ for which $p(K')$ is regular.

Thus, for a given polygonal knot there exists an equivalent knot with a regular projection. Combining with the definition of a tame knot, we have that every tame knot is equivalent to a polygonal knot with a regular diagram.

In knot theory, knots are studied up to equivalence. Most knot theory references focus solely on tame knots; see [7]. One of the reasons is that some very natural invariants are not necessarily defined for wild knots.

Although we work with polygonal knots, their diagrams are depicted with smooth vertices, since one can think of a polygonal knot as a union of a large number of  edges. In the next definition, we introduce some terminology of knot diagrams.

Each double point of a regular projection is the image of two different points of the knot, and a such a point is called a crossing of a diagram. To distinguish edges that cross each other in a diagram, the lower edge in the crossing is drawn with a break. The resulting separate edges are called strands. At each crossing, the strands that are separated by the break are called the understrands and the other strand is called the overstrand. The connected components of the complement of $p(K)$ in the $z=0$ plane are called the regions.

As an example, the diagram depicted in Figure <ref> has 4 crossings and 4 strands, and the diagram of Figure <ref> has 3 crossings and 3 strands. It is not a coincidence that the number of crossings is equal to the number of strands. We now give a simple but fundamental lemma which will play an important role in the next section, where we explain knot colorings. The result can be found in [1].

Let $D$ be knot diagram with $n$ crossings. Then it has $n$ strands and $n+2$ regions.

Elementary knot moves lead to changes in knot diagrams. However, it is possible to
restrict only to the following moves.

Consider the following three Reidemeister moves:

* The twist move: This move twists or untwists a part of a strand in either direction, and is called a move of type I.

* The poke move: This move takes a strand and moves it completely over another (thus adding 2 crossings) or vice versa (thus removing 2 crossings), and is called a move of type II.

* The side move: This move slides a strand from one side of a crossing to the other side of the same crossing, and is called a move of type III.

The Reidemeister moves are depicted in Figure <ref> and they are used to define equivalence of diagrams.

Two diagrams $D$ and $D'$ are called equivalent if $D$ can be transformed into $D'$ by using a finite sequence of Reidemeister moves. We denote this by $D \approx D'$.

Reidemeister proved the following crucial result in [41]. In this paper we use the statement of <cit.>.

Let $D$ and $D'$ be the diagrams of two knots $K$ and $K'$, respectively. Then $K \approx K'$ if and only if $D \approx D'$.

The Reidemeister moves of type I, II and III, respectively.

Using the Reidemeister moves, one can show the equivalence of knots by applying Theorem <ref>. For example, in Figure <ref> we show that the figure-eight knot of Figure <ref> is equivalent to its mirrored image. In the last step, no Reidemeister moves are used, but the position of the strands are changed slightly. The colors indicate how the strands are moved in the last step.

The figure-eight knot is equivalent to its mirror image.

In this paper, we will also use the concepts of a reduced and alternating
knot diagrams.
These are defined as follows.

A knot diagram is called alternating if the understands and overstrands are alternating in a fixed orientation. A knot diagram is called reduced if there are no crossings that can be removed via the twist move.

§.§ Coding Theory

We now turn to the coding theory fundamentals, that are also
needed to understand the rest of the paper. Let $n \in \Z_{\ge 1}$, $q$ be a prime power, and $\F_q$ be the finite field with $q$ elements.
General coding theory references are [30, 17, 39].

A (linear, error-correcting) code of
length $n$ is
an $\F_q$-linear subspace $\mC \subseteq \F_q^n$.
The dimension of $\mC$, denoted by $\dim(\mC)$, is its
dimension as a vector space over $\F_q$.
The quantity $\dim(\mC)/n$ is the rate of $\mC$.
The dual of $\mC$
is the code $\mC^\perp = \{x \in \F_q^n \mid xy^\top =0 \mbox{ for all } y \in \mC\}$. Note that $\dim(\mC^\perp) = n - \dim(\mC)$.
A code $\mD \subseteq \mC$ is called a subcode of $\mC$.

A code is most often represented by matrices.

We say that a matrix $G \in \F_q^{k \times n}$ is a generator matrix of a code $\mC$ (and that $\mC$ is generated by $G$) if $\mC$ is the row-space of $G$.
A parity check matrix $H$ of $\mC \subseteq \F_q^n$ is a matrix such that

$$\mC=\{c \in \F_q^n \mid cH^T=0\}.$$

Note that, in contrast with some coding theory references, we do not require $G$ and $H$ to have full rank in this paper.

The performance of an
error-correcting code is measured by its rate and its minimum Hamming distance, defined below. Ideally, these parameters should both be as large as possible.

The support of a vector $x \in \F_q^n$ is
$\sigma(x) = \{i \in \{1,\ldots,n\} \mid \ x_i \neq 0\}$. The Hamming weight of a vector $x \in \F_q^n$ is the number of its nonzero entries, i.e., $\wt(x)=|\sigma(x)|$.
The minimum (Hamming) distance of a code $\mC $

$$d(\mC)=\min\left\{\wt(x) \mid x \in \mC, \, x \neq 0\right\},$$

where the code $\{0\} \subseteq \F_q^n$ has minimum distance $\infty$ by definition.
The weight enumerator of $\mC $ is given by
$W_{\mC}(T)=\sum_{w=0}^n a_w(\mC)T^w$, where $a_w(\mC)$ is the number of codewords of $\mC$ of weight $w$.
Lastly, we let $\wt(\mC) = \{\wt(c) \mid c \in \mC \}$.

The $q$-ary $n$-repetition code is $\{(a,\ldots,a) \in \F_q^n \mid a \in \F_q\}$. It has dimension 1, minimum distance $n$, and rate $1/n$.

We write that $\mC$ is an $[n,k,d]_q$ code
if $\mC \subseteq \F_q^n$ has dimension $k$ and minimum distance $d$.

One of the best known results in coding theory establishes a trade-off between the dimension and the minimum distance of a code of a given length. In particular, they cannot be both arbitrarily large.

Let $\mC \neq \{0\}$ be an $[n,k,d]_q$ code. We have $k \le n-d+1$.

We conclude this subsection by defining a class of codes that
will arise later in our paper.

A code that has a parity check matrix in which every row has Hamming weight $r$ and every column has Hamming weight $c$, is called a $(r,c)$-doubly-regular low-density parity check (LDPC) code. If the rows or  the columns of the matrix have a fixed Hamming weight $w$, then the LDPC code is called right or left $w$-regular, respectively.

LDPC codes, first introduced in [12], have efficient decoding algorithms, see for example [29, 28, 27] among many others.

§ KNOT COLORINGS

In this section, we explain two types of knot colorings: Fox coloring and Dehn coloring; see Figure <ref>. We refer to Appendix <ref> for the necessary background in commutative algebra needed for this section.

[line width=0pt,Computer Modern Rightarrow[line
width=1pt,width=3ex,length=2ex]-] (-0.5ex,0) – (0.5ex,0);
clip width=5,
[black,ultra thick] (-2,-2) to pic[pos=0.2,sloped]arrow (2,2);
[black,ultra thick] (-2,1) – (2,-1);;

nnode/.style = shape=circle,fill=myg,draw,inner sep=0pt,minimum
[text=red] at (-2.3,1) $a$;
[text=red] at (2.3,-1) $c$;
[text=red] at (-2.3,-2) $b$;

$c=ta +(1-t)b$

[line width=0pt,Computer Modern Rightarrow[line
width=1pt,width=3ex,length=2ex]-] (-0.5ex,0) – (0.5ex,0);
nnode/.style = shape=circle,fill=myg,draw,inner sep=0pt,minimum

clip width=4,
[black,ultra thick] (-2,-2) to pic[pos=0.2,sloped]arrow (2,2);
[black,ultra thick] (-2,1) – (2,-1);;

[text=red] at (0,-1) $U_i$;
[text=red] at (0,1) $U_l$;
[text=red, ultra thick] at (-1.2,-0.2) $U_j$;
[text=red] at (1,0) $U_k$;

Fox coloring <ref> and Dehn coloring <ref> of knot diagrams.

The Fox coloring is the coloring of the strands of the knot diagrams. In this section we introduce the concept of Fox $(R,t)$-coloring, where $R$ is a Noetherian commutative ring with an identity and $t$ is an invertible element of this ring.
We start with the definition of Fox tricolorability, that is where $R=\Z/(3)$ and $t=-1$.

A Fox tricoloring of a  knot diagram is a coloring of the strands with three colors such that at each crossing, the colors of the strands that meet at that crossing are either all the same or all different. If we take as colors $0$, $1$ and $2$, then this rules amounts to the linear equation $a+b+c \equiv 0 \Mod{3}$, where $a,b$ and $c$ are the colors of the three strands that come together at a crossing. Moreover, a Fox tricoloring is called trivial if all strands have the same color. A knot diagram is called Fox tricolorable if it has a non-trivial tricoloring.

Tricolorability is another invariant of a knot[40]. This already allows us to distinguish the unknot and trefoil knot, as the latter is tricolorable and the former is not, see Figure <ref>.

use Hobby shortcut,
every trefoil component/.style=ultra thick, draw,
trefoil component 1/.style=red,
trefoil component 2/.style=blue,
trefoil component 3/.style=green,
[spath/save=trefoil] ([closed]90:2) foreach įn 1,...,3
.. (-30+*̨240:.5) .. (90+*̨240:2)  (90:2);

Trefoil knot is tricolorable.

Generalizing Definition <ref> to colors $0,1, \ldots, n-1$ gives the equation $a+c \equiv 2b \Mod{n}$, where $a,b$ and $c$ are again the colors of the three strands that come together at a crossing with $b$ being the overstrand, and $n \in \Z_{>0}$. This can also be generalized further.

A Fox $(R,t)$-coloring of a knot diagram is a coloring of its strands with colors that are elements of $R$ and for each crossing it holds that

\begin{equation}
\label{eq:Fox}
c=ta +(1-t)b,
\end{equation}

where $t$ is a fixed invertible element in the ring $R$, the strand with color $b$ is the overstrand and the strands colored with $a$ and $c$ are understands such that the rotation from $b$ to $c$ around the crossing is counter clockwise; see Figure <ref>.
A coloring is called trivial if all the colors are the same. The knot diagram is called Fox $(R,t)$-colorable if there is a non-trivial Fox $(R,t)$-coloring; see [11].

In particular, every Fox $(R,t)$-coloring with $R=\Z/(2)$ is trivial, since $t=1$ is the only invertible element of $R=\Z/(2)$. We also have the following result.

All Fox $(R,1)$-colorings of a knot diagram are trivial.

Up to a permutation, we may assume that the strands $\{x_1,\ldots,x_n\}$ are numbered in such a way that $x_{j+1}$ comes after $x_j$ for a given choice of the orientation of the knot diagram.
Then the equations (<ref>) with $t=1$ become $x_{j+1}=x_j$ for all $j=1, \ldots n-1$. Hence every Fox $(R,1)$-coloring is trivial.

Lemma <ref> allows us to place the coefficients in the system of equations that has to hold for a Fox coloring of a diagram with $n$ strands into an $n \times n$ matrix. Before defining this matrix, we remark the following.

The definition of the Alexander matrix of a knot diagram is usually given by means of the free calculus of a presentation of the fundamental group of the complement of the knot; see <cit.>. From this approach one readily gets that the distinct presentations of the fundamental group of the knot give equivalent (see Definition <ref>) Alexander matrices. Hence the equivalence class of the Alexander matrix of a knot diagram is in fact an invariant of the knot.

We give the following ad hoc definition of the Alexander matrix of a knot diagram and show that it is an invariant under Reidemeister moves.

The Alexander matrix (or the Fox coloring matrix) of an oriented knot diagram with $n$ crossings $\{c_1,\ldots,c_n\}$ and strands $\{x_1,\ldots,x_n\}$ is defined as the
matrix $M(T)$ with entries in $\Z[T,T^{-1}]$ with

M_{ij}(T) =
\begin{cases}
1 - T & \text{if} \ \ x_j \textnormal{ is an overstrand at } c_i,\\
-1 & \text{if} \ \ x_j \textnormal{ is an understrand at } c_i \textnormal{ at the left side of the overstrand},\\
T & \text{if} \ \ x_j \textnormal{ is an understrand at } c_i \textnormal{ at the right side of the overstrand},\\
0 & \text{otherwise}
\end{cases}
for $1 \le i,j \le n$ with $i,j \in \Z_{>0}.$

The matrix of Definition <ref> is called the Alexander matrix by Crowell and Fox [7] and it is different than the matrix Alexander defined in his paper [1].
Note that we write $M_{ij}(T)$ instead of
$M(T)_{ij}$ and, for ease
of notation, we omit the knot diagram in the symbol $M_{ij}(T)$.

The module of Fox $(R,t)$-colorings of a knot diagram is the kernel of the matrix $M(t)$, that is, the $R$-module of
$x \in R^n$ such that $M(t) x^T=0$.

The sum of the entries in any row of $M(T)$ is zero. So, the columns of $M(T)$ are dependent, and thus the determinant of $M(T)$ is zero.
Hence $E_0(M(T))=0$ (see Definition <ref>) and there is a non-trivial solution of the system of equations (<ref>). Trivial colorings correspond to the solutions of this system of equations where all the (nonzero) elements are the same.
By taking any $(n-1)$-minor of the Alexander matrix, we get another knot invariant; see [1].

Let $M_{ij}^*(T)$ be the matrix obtained by deleting the $i$-th row and the $j$-th column of $M(T)$.
Then the determinants $\det (M_{ij}^*(T))$ are equal to each other up to a factor $\pm T^s$, where $s$ is an integer.
In particular, $E_1(M(T))$ (see Definition <ref>) is a principal ideal generated by $\det (M_{ij}^*(T))$ for any choice of the indices $1 \le i, j \le n$.

See <cit.> and <cit.>.

Let $M(T)$ be the Alexander matrix of a knot diagram with $n$ crossings. We have $\det (M_{ij}^*(1))=\pm1$ for all $1 \le i \le j \le n.$

The equations (<ref>) with $T=1$ become $x_{j+1}=x_j$ for all $j=1, \ldots,n-1$ as we have seen in the proof of Proposition <ref>. The matrix that is obtained by deleting the last column and last row is upper triangular with ones on the diagonal, so it has determinant one. The result follows from Proposition <ref>.

Another important result is the following.

If $D_1 \approx D_2$,
then the corresponding Alexander matrices $M_1(T)$ and $M_2(T)$ are equivalent; see Definition <ref>.

See <cit.> in the case $T=-1$ and $R=\F_p$ for a prime $p$. The general case is proved similarly.

$E_1(M(T))$ is a principal ideal in $\Z[T,T^{-1}]$ by Proposition <ref>, that is generated by a nonzero element by Proposition <ref>.
Hence there exists an integer $s$ such that multiplication of a generator of $E_1(M(T))$ by the invertible element $\pm T^s$ gives a polynomial with a constant term that is positive.

Let $K$ be a knot. The Alexander polynomial of $K$, denoted by $\Delta_K(T)$,
is the generator of $E_1(M(T))$ which is the polynomial with a constant term that is positive. Moreover, the value $|\Delta_K(-1)|$ is called the determinant of $K$.

The Alexander polynomial is a knot invariant by Proposition <ref>. However it is important to note that although the elementary ideals $E_0(M(T))=0$ and $E_1(M(T))$ of a knot are principal ideals, the other elementary ideals $E_k(M(T))$ are not necessarily principal for $k>1$, as the following example shows.

Figures 50 and 51 of [7] have both $\Delta_K(T)=2T^2-5T+2$ as their Alexander polynomial, but they have distinct elementary ideals.
The Stevedore's knot depicted in Figure 50 has $E_k=(1)$ for all $k\geq 2$, but the knot of Figure 51 has $E_2=(2-T,1-2T)$, which is not principal.

We work out an example to show how the Alexander polynomial of a knot is computed. Note that it does not depend on the chosen submatrix or the chosen knot diagram.

The Alexander matrix of the diagram of the trefoil knot $K$ depicted in Figure <ref> is given by

\begin{equation*}
M(T) = \begin{pmatrix}
1-T & T & -1 \\
-1 & 1-T & T \\
T & -1 & 1-T
\end{pmatrix}.
\end{equation*}

We have $\det(M^*_{11}(T)) = T^2 -T + 1$ and $\det(M^*_{12}(T)) = -T^2 +T - 1$. Following Definition <ref>, we observe that the polynomial $\det(M^*_{11}(T))$ has a positive constant term, and thus $\Delta_K(T) = T^2-T+1$.

We now turn our attention to the invariant factors of  the Alexander matrix and the invariant factors of the module of Fox $(R,t)$-colorings, see Definition <ref>.

Let $R$ be a principal ideal domain with invertible element $t$.
Let $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l)$ be the  invariant factors of the matrix $M(t)$ and $E_k(M(t))$ be generated by $\Delta_k$, see Corollary <ref>. Then $\Delta_0=0$, $d_1=0$, and $\Delta_K(t)=\Delta_1=\prod_{j=2}^ld_j$.

The determinant of $M(t)$ is zero. So $E_0(M(t))=(0)$ and $\Delta_0=0$.
Now $\Delta_K(t)=\Delta_1=\prod_{j=2}^ld_j$ by Corollary <ref> and $\Delta_K(t)\not=0$ by Proposition <ref>.
So $\Delta_0=d_1\Delta_1$ by Corollary <ref>. This implies that $d_1=0$, since $R$ is an integral domain.

Denote the localization of $\Z$ at a nonzero $t\in \Z$ by $Z_t$, and the localization of $\F_p[T]$ at a nonzero $t$ of $\F_p[T]$ by $\F_p[T]_t$. So $Z_t=\{ n/t^e \mid n,e \in\Z \}$ and $\F_p[T]_t=\{ f/t^e \mid f\in \F_p[T],\ e \in\Z \}$. The next two propositions will be used later in Subsection <ref> to bound the dimension of so-called knot codes.

Let $D$ be a  knot diagram of a knot $K$.
Let $d, t\in \Z$ such that $0<t<d$ and $ \gcd(d,t)=1$. Let $R=\Z_t$ and and $\overline{R}=R/(d)$.
Let  $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l) $ be the invariant factors of the matrix $M(t)$ of Fox $(R,t)$-colorings.
Let $a_i=\gcd (d,d_i)$ and $\overline{x}=x+(d) \in R/(d)$ for $x\in R$.
Then $\overline{t}$ is an invertible element in $\overline{R}$ and $d\prod_{i=2}^n a_i$ is the number of Fox $(\overline{R},\overline{t})$-colorings of $D$.

The element $\overline{t}$ is invertible in $R/(d)$, since $ \gcd(d,t)=1$.
Hence $\Z/(d)\cong \Z_t/(d)=\overline{R}$.
The module of $(\overline{R},\overline{t})$-colorings of $D$ is equal to the $Ker(M(\overline{t}) )$ which is isomorphic to $ \overline{R}/(\overline{a_1}) \oplus \overline{R}/(\overline{a_2}) \oplus  \cdots \oplus  \overline{R}/(\overline{a_l})$ by Proposition <ref>. We have $d_1=0$ by Proposition <ref>, and $|\overline{R}|=d$. Furthermore $\overline{R}/(\overline{a_i})\cong \Z/(a_i)$, and thus $|\overline{R}/(\overline{a_i})|=a_i$ for all $2 \leq i\leq n$.
Hence $d\prod_{i=2}^n a_i$ is the number of Fox $(\overline{R},\overline{t})$-colorings of $D$.

Let $D$ be a  knot diagram of a knot $K$.
Let $p\in \Z$  be a prime number. Let $d,t \in \F_p[T]$ such that $\gcd(d,t)=1$. Let $R=\F_p[T]_t$ and let $\overline{R}=R/(d)$.
Let $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l) $ be the invariant factors of the matrix $M(t)$ of Fox $(R,t)$-colorings.
Let $a_i=\gcd (d,d_i)$. Let $\delta = \deg (d)$ and $\alpha_i = \deg (a_i)$.
Then $\overline{t}$ is an invertible element of $\overline{R}$ and $p^{\delta+\sum_{i=2}^n \alpha_i}$ is the number of Fox $(\overline{R},\overline{t})$-colorings of $D$.

The proof is verbatim the same as for Proposition <ref>, except for the final part. The element $\overline{t}$ is invertible in $R/(d)$, since $ \gcd(d,t)=1$.
Hence $\overline{R}\cong \F_p[T]/(d)$ which has $p^{\deg(d)}$ elements, and
$\overline{R}/(\overline{a_i})\cong \F_p[T]/(a_i)$ which has $p^{\deg(d_i)}$ elements.

The Alexander polynomial $\Delta_K(T)$ plays a direct role in determining whether a knot diagram is Fox $(R,t)$-colorable or not.

Let $R=\Z$ or $R=\F_q[T]$.
Let $d,t \in R$ such that $d$ is not invertible in $R$ and $\gcd(d,t)=1$.
Let $\overline{R}= R/(d)$ and $K$ be a knot.
Then the following statements are equivalent:

(1) A knot diagram of $K$ is Fox $(\overline{R},t)$-colorable;

(2) $\gcd(d,\Delta_K(t))\not=1$ in $R$;

(3) $\Delta_K(t)=0$ in $\overline{R}$ or  $\Delta_K(t)$ is a zero-divisor of $\overline{R}$.

The proof  Fox $(\F_p,-1)$-colorability for $p$ a prime is given in <cit.> and <cit.>. The knot $K$ is Fox $(\overline{R},t)$-colorable if and only if
$\gcd (d,d_i)=\overline{d_i}\not=1$ for some $i$, $2 \leq i\leq n$, where
$(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l)$ are the invariant factors in $R$
by Propositions <ref> and <ref>.
But $\Delta_K(t)=\prod_{i=2}^l d_i$ by Proposition <ref>.
So $K$ is Fox $(\overline{R},t)$-colorable if and only if $\gcd(d,\Delta_K(t))\not=1$ in $R$ if and only if
$\Delta_K(t)=0$ in $\overline{R}$ or  $\Delta_K(t)$ is a zero-divisor of $\overline{R}$.

Next, we will show that the trefoil knot is Fox $(R,t)$-colorable for several choices of the ring $R$ and the invertible element $t$.

We have seen that the trefoil knot is tricolorable, which is in agreement with Proposition <ref>, since $\Delta_K(t) = t^2 - t + 1$ and $\Delta_K(-1) =3$. It is also $(\Z/(d),-1)$-colorable for all positive integers $d$ that are a multiple of $3$ with the colors $0, d/3, 2d/3$ assigned to the three strands.

Consider the Fox colorings for the pairs $(\Z/(4), -1)$, $(\mathbb{F}_4, \alpha)$ and $(\mathbb{F}_7, 3)$ of the trefoil knot $K$, where $\mathbb{F}_4 = \{0, 1, \alpha, \alpha^2 \}$ and $\alpha$ is a root of the irreducible polynomial $x^2+x+1$ over $\F_2[x]$. We find that $\Delta_K(-1) = 3 \neq 0$ over $\Z/(4)$ and $\Delta_K(\alpha) = \alpha^2 + 1 - \alpha$, which is 0 over $\mathbb{F}_4$ and $\Delta_K(3) = 7 = 0$ over $\mathbb{F}_7$. Therefore, the trefoil knot has only trivial Fox colorings when $(R,t) = (\Z/(4), -1)$, but it has a non-trivial Fox coloring when $(R,t) \in \{(\mathbb{F}_4, \alpha),(\mathbb{F}_7, 3)\}$.

For the rest of this subsection, we study another way to color knot diagrams, called Dehn colorings.
For its definition we first need to define the concept of a checkerboard coloring of the regions of a knot diagram.

A knot diagram has a checkerboard coloring if all its regions are colored with two colors (white and black), in such a way that at each crossing, two regions have the same color if and only if they are not adjacent.

The Dehn coloring is the coloring of the regions of a knot diagram. Similar to Definition <ref>, we define Dehn colorability as follows.

A knot diagram is called Dehn $(R,t)$-colorable if the regions of a knot diagram with $n$ crossings are colored via colors that are elements of $R$ and at each crossing $c_m$ for $1 \le m \le n$ with an overstrand $x$, it holds that

\begin{equation*}
U_i - tU_j = U_k - tU_l,
\end{equation*}

where $t$ is a fixed invertible element in the ring $R$, the regions $U_i,U_j,U_k$ and $U_l$ are regions that have $c_m$ on their border in a way that $U_i$ and $U_k$ are on the left side of $x$ and $U_j$ and $U_l$ are on the right side of $x$ with respect to the orientation of the diagram; see Figure <ref>. Moreover, the color $0$ is assigned to the unbounded outside region.
A Dehn coloring is called trivial if it is a checkerboard coloring.

Analogous to Definition <ref>, we define the following matrix for Dehn colorings.

Let $D$ be a knot diagram with $n$ crossings. At each crossing $c_m$ for $1 \le m \le n$ with an overstrand $x$ such that the regions $U_i,U_j,U_k$ and $U_l$ are regions that have $c_m$ on their border in a way that $U_i$ and $U_k$ are on the left side of $x$ and $U_j$ and $U_l$ are on the right side of $x$ with respect to the orientation of the diagram, the Dehn coloring matrix $N(T)$ of $D$ is defined as

N_{ms}(T) =
\begin{cases}
1 & \text{if} \ \ s=i,\\
-T & \text{if} \ \ s=j,\\
-1 & \text{if} \ \ s=k,\\
T & \text{if} \ \  s=l,\\
0 & \text{otherwise},
\end{cases}
for $1 \le m \le n$ and $1 \le s \le n+2$ with $m,s \in \Z_{>0}.$

The matrix $N(T)$ is the one defined by Alexander [1] as remarked after Definition <ref>.

Dehn [8] gave a less known presentation of the fundamental group of the complement of a knot with generators $U_i$
and relations $U_1=1$ and $U_iU_j^{-1}=U_kU_l^{-1}$ for all crossings as in <ref>.
The free calculus of this presentation gives the matrix $N(T)$ with the first column deleted, see [18].

Analogous to Proposition <ref>, we have the following result that is proven in [1].

If $D_1 \approx D_2$,
then the corresponding Dehn coloring matrices $N_1(T)$ and $N_2(T)$ are equivalent.

Similar to the module of Fox $(R,t)$-colorings of Definition <ref>, one can define the module of Dehn $(R,t)$-colorings.

The module of Dehn $(R,t)$-colorings of the knot diagram is given by the kernel of the matrix $N(t)$,
that is the $R$-module of all $ x\in R^{n+2}$  such that $N(t)x^T=0.$

Fox and Dehn colorings can be obtained from each other.
The following proposition is a generalization of the relation between Fox and Dehn colorings. We slightly abuse notation: the color of a region $U$ will also be denoted by $U$. Similarly, the color of a strand $x$ is also denoted by $x$.

Let $D$ be an oriented knot diagram with $m$ regions and $n$ strands.
Consider the map $\varphi : R^m \rightarrow R^n$ such that  $\varphi (U)=x$
gives the colors of the strands $x$ for a given coloring $U$ of the regions
such that $x_r =U_i-tU_j$ is the color of the stand $x_r$ where $U_i$ and $U_j$ are the colors of the regions next to the strand $x_r$, with $U_i$ on the left side of $x_r$  and $U_j$ on the right side of $x_r$.
Then this map is a well-defined morphism of $R$-modules when restricted to the module of Dehn $(R,t)$-colorings, and Dehn colorings are mapped to Fox  $(R,t)$-colorings.
Furthermore $\varphi$ is surjective onto the module of Fox  $(R,t)$-colorings, its kernel is isomorphic to $R$,
and it is an isomorphism when $\varphi$ is restricted to the submodule of Dehn $(R,t)$-colorings where a fixed region gets the value $0$.

It is a straightforward generalization of the proofs given in [6, 46] for $t=-1$.

In Figure <ref> an example of a Fox $(\F_5,-1)$-coloring and Dehn $(\F_5,-1)$-coloring that are constructed via these steps can be found with the value $0$ for the outside region. Note that with these steps, trivial Fox colorings will transform into trivial Dehn colorings and the other way around, as well.

Fox $(\F_5,-1)$-coloring and Dehn $(\F_5,-1)$-coloring of the figure-eight knot.

Let $x$ be the trivial Fox $(R,t)$-coloring where all the strands have the same color. Then for a fixed region $U_1$ with a fixed color, there exists Dehn $(R,t)$-coloring $U$ such that $\varphi (U)=x$ by Proposition <ref>. In this way we get all the so called trivial Dehn $(R,t)$-colorings which constitute a free summand $R^2$ of the module of Dehn $(R,t)$-colorings.
In particular, if $t\not=1$, $U_1=1$ and $x=0$, then all the regions $U_i$ have color $t^{e_i}$ where $e_i$ is called the index of the region, see <cit.>.
If $t=-1$, then the trivial Dehn $(R,t)$-colorings are such that all white regions have the same color and all the black regions have the same color.

The next result allows us to compare some properties of the Alexander matrix and the Dehn coloring matrix of the same knot diagram.

Let $N(T)$ be the Dehn $(R,T)$-coloring matrix of a knot diagram of a knot $K$,
then $E_1(N(T))=0$ and $E_2(N(T))$ is a principal ideal generated by $\Delta_K(T)$.

Choose two columns that correspond to two regions that have index $e$ and $e+1$ for some $e$. See Remark <ref>.
Let $N''(T)$ be the $(n+2) \times n$ matrix  that is obtained from $N(T)$ by replacing the two chosen columns by zero columns.
Let $N_0(T)$ be the $n \times n$ matrix  that is obtained from $N(T)$ by deleting the two chosen columns.
The matrix $N(T)$ is equivalent to the matrix $N''(T)$. See <cit.>.
So $E_1(N(T))=0$ and $E_2(N(T))=E_2(N''(T))=E_0(N_0(T))$ by Proposition <ref>, which is a principal ideal generated by $\det (N_0(T))$.

Let $N_1(T)$ be the $(n+1) \times n$ matrix  that is obtained from $N(T)$ by deleting the chosen column of index $e$. In order to show that $E_2(N(T))$ is generated by $\Delta_K(T)$ we need to refer
to the fact that the matrix $N_1(T)$ is obtained by the free calculus of
the Dehn representation of the fundamental group of the complement of the knot by Remark <ref>,
and $M(T)$ is the Alexander matrix obtained by the free calculus of
another representation of the same fundamental group by Remark <ref>.
Therefore, these matrices are equivalent and have the same elementary ideals.
See <cit.>.

We conclude this section with an example verifying that $E_1(M(T))$ and $E_2(N(T))$ are both generated by $\Delta_K(T)$.

Consider the diagram of the trefoil knot whose Fox coloring matrix is given in Example <ref>, and its Alexander polynomial is computed as $\Delta_K(T) = T^2-T+1$. Its Dehn coloring matrix is

\begin{equation*}
N(T) = \begin{pmatrix}
1& -T & -1 & T & 0 \\
1 & -1 & 0 & T & -T \\
1 & 0 & -T & T & -1
\end{pmatrix}.
\end{equation*}

Let $N_{ij}^*(T)$ be the matrix obtained by deleting the $i$-th and the $j$-th column of $N(T)$ for $i \neq j$. We have $M_{ij}^*(T) \in \{\pm (T^2 -T +1)\}$ and $N_{ij}^*(T) \in \{ 0, \pm (T^3-T^2+T), \pm (T^2-T+1), T^3+1\}$. One can check that they are both generated by $\Delta_K(T) = T^2-T+1$, since $T^3+1 = (T^2-T+1)(T+1).$

§ CODES FROM KNOTS AND THEIR PROPERTIES

This section explains how
one can construct a code
starting from
a knot with its diagram and coloring.
We also establish a series of results illustrating how the properties of knots determine those of codes via the said constructions.
We essentially regard
the possible colorings of a knot diagram as a linear code.

Let $D$ be a knot diagram that is Fox $(\F_q,t)$-colored.
The code associated with $D$ (or the knot code of $D$) with  coloring matrix $M$ is

\mC_{D,t} = \{x \in \F_q^n \mid Mx^T = 0 \}.$$

If $t=-1$, we denote this code by $\mC_{D}$.

Note that the coloring matrix is interpreted as the parity check matrix of a code; see Definition <ref>.
A relabeling of the strands in the knot diagram will result in a possibly different code. Such a code is monomially equivalent [17] to the original one
and thus has the same dimension and minimum distance.
However, the code of a knot diagram is not a knot invariant, as the following example illustrates.

Let $q=19$. In Figure <ref> two diagrams of the same knot $K$ is given with $\Delta_K(-1) = 19$. The Fox $(\F_{19},-1)$-coloring matrices of the knot diagrams depicted in Figure <ref>, denoted by $H_a$ and $H_b$ respectively, are the parity check matrices of the corresponding knot codes.

Two alternating diagrams of the $7_6$ knot

We apply row operations to transform the parity check matrices in the form $\bigl[-A^T \mid I \bigr]$, for some matrix $A$ of suitable size.
This results in the generator matrices

G_a = \begin{pmatrix}
1 & 0 & 6 & 15 & 16 & 3 & 10\\
0 & 1 & 14 & 5 & 4 & 17 & 10
\end{pmatrix}

G_b = \begin{pmatrix}
1 & 0 & 6 & 15 & 3 & 9 & 10\\
0 & 1 & 14 & 5 & 17 & 11 & 10
\end{pmatrix}.

It is easy to see that the codes generated by them are not equivalent. Therefore, the code of a knot diagram is not a knot invariant.

In the theory of knot colorings one is interested in the (minimum) number of colors used in a coloring. This number cannot be translated in results about the weight of the coloring, that is, the number of nonzero colors. In 1999, Kauffman and Harary conjectured the following [14] and it was proven in 2009 by Mattman and Solis in [31].

Let $D$ be a reduced, alternating knot diagram (see Definition <ref>) of $K$ with $|\Delta_K(-1)|=p$, where $p$ is prime. Then, every non-trivial Fox $(\F_p,-1)$-coloring of $D$ assigns different colors to different strands of the diagram.

Note that Theorem <ref> is not true if the determinant of the knot is not a prime. The alternating knot diagram $7_7$ in <cit.> has non-prime determinant $21$ and has a Fox $(\F_7,-1)$-coloring with $6$ colors such that two strands have the same color.

The Kauffman-Harary conjecture of Theorem <ref> motivates the following result.

Let $D$ be a reduced, alternating knot diagram (see Definition <ref>) of $K$ with $n$ strands such that $|\Delta_K(-1)|=p$, with $p$ prime. Then, the knot code of $D$ is an $[n,2,n-1]_p$ code over $\F_p$.

By Theorem <ref>, every non-trivial coloring of $D$ assigns different colors to different strands. This implies that the minimum distance of the knot code is $n-1$ which is attained by $d(c,c')$ where $c$ is any non-trivial coloring and $c'$ is a trivial coloring where all strands have color $c_i$ for some $i \in \{1,\ldots,n\}$.  By Proposition <ref>, we have that $D$ is Fox $(\F_p,-1)$-colorable since $p \mid \Delta_K(-1)=p$. Non-trivial colorability implies that the dimension of the knot code is at least $2$. The only possible code parameters are $[n,2,n-1]_p$ by the Singleton bound of Theorem <ref>.

Note that the knot codes with Fox coloring matrix as their parity check matrices are right $3$-regular LDPC codes. If a knot diagram is alternating, it gives a $(3,3)$-doubly-regular LDPC code. Moreover, if one considers the Dehn colorings, then the corresponding code is a right $4$-regular LDPC code. For the rest of this section, when we say coloring matrix, we mean the Alexander matrix of Definition <ref>.

Regarding the minimum distance of a knot code, one can obtain the following, rather simple, result.

A code of a knot diagram of a non-trivial knot has minimum distance at least 2.

Suppose there exists a code of a knot diagram with minimum distance 1. Then this code contains a codeword of weight 1, which corresponds to a coloring of the knot diagram in which only one of the strands is colored with a color $c \in R\backslash\{0\}$. In case this strand is an overstrand at a crossing in the diagram, it is also an understrand at another crossing in the diagram, unless it is the trivial knot. Then, there exists a crossing for which it should hold that $0 - 0 = t(c - 0)$ or $c - 0 = t(0 - 0)$, depending on which understrand of the crossing is colored. It follows that $c = 0$ should hold as $t$ is invertible over $R$. From this contradiction, it follows that the minimum distance of the code is at least 2.

We will return to the minimum distance of knot codes in Remark <ref> and in Subsection <ref>. We can already disclose that it is not a knot invariant; see Remark <ref> for the details.

§.§ Dimension of Codes from Knot Diagrams

In this subsection we investigate
the dimension of a code of a knot diagram. In particular, we prove that the dimension of a code of a knot diagram is a knot invariant. We start with an observation.

The $n$-repetition code of Example <ref> is always a subcode of the code of a knot diagram with $n$ strands, as trivial colorings are always possible. Therefore, the dimension of the code of a knot diagram is at least 1. Conversely, when the dimension of the code of a knot diagram is larger than 1, the knot has a non-trivial coloring.

We directly start with one of the main theorems of the subsection.

The effect of the Reidemeister moves on a Fox-coloring.

Let $D$ and $D'$ be equivalent knot diagrams. Then
$\mC_{D,t}$ and $\mC_{D',t}$ have the same dimension.

Let $D$ and $D'$ have $n$ strands. Denote by $\mC_{D,t}$ and $\mC_{D',t}$ the respective codes related to the diagrams. One locally investigate what happens when performing each Reidemeister move, see
Figure <ref>. Suppose $D'$ is obtained from $D$ by twisting a strand $x_1$ (Reidemeister move of type I), then the twist results in two strands and a crossing in this part of the diagram, where both strands are the understrands and one of the strands is the overstrand. For a Fox coloring it then follows that the colors assigned to both strands must be the same.

$$G =
\begin{pmatrix}
| & | & | \\
\dots & x_1 & \dots \\
| & | & |
\end{pmatrix}

be a full rank $k \times n$ generator matrix of $\mC_{D,t}$.
$$G' =
\begin{pmatrix}
| & | & | & |\\
\dots & x_1 & x_1 & \dots\\
| & | & | & |
\end{pmatrix}

is a $k \times (n+1)$ generator matrix for $\mC_{D'}$, which has the same rank since the added column is a duplicate of another column.

The other moves can be investigated
in a similar manner and we omit the proof here. By Theorem <ref>,
any two diagrams of a knot can be transformed into each other using Reidemeister moves. It follows that $\mC_{D,t}$ and $\mC_{D',t}$ have the same dimension.

The next result derives an upper bound for the dimension of knot codes.

Let $D$ be a knot diagram with $n$ strands and let $\mC_{D,t}$ be the corresponding knot code over $\F_q$. We have

1 \le \dim(\mC_{D,t}) \le \frac{n+1}{2} .

By Theorem <ref>, the Reidemeister moves do not affect the dimension of a code of a knot diagram. Therefore, without loss of generality, let $D$ be a knot diagram that does not have any crossings which can be removed via the twist move, see Definition <ref>
(that is, there exists no crossing in $D$ such that the overstrand and one of the understrands of the crossing are the same strand).
Label the strands of $D$ as $x_1, x_2, ..., x_n$ by following the knot in one direction. Denote by $c_i$ the crossing where $x_i$ and $x_{i+1}$ are understrands and $x_{i'}$ is the overstrand, and with $x_{i+1}$ being the strand leaving the crossing with respect to the chosen orientation. Note that $i' \in \{1, \ldots, n\}$ depends on $i$. Since $D$ does not contain twists, we have that either $i' < i$ or $i' > i+1$. By going through the crossings $c_i$ with $1 \le i \le n-1$, we define the sets $L = \{ c_i \mid 1 \leq i \le n-1,\  i' < i\}$ and $U= \{ c_i \mid 1 \leq i \le n-1,\  i' > i+1\}$. As $L \cap U = \emptyset$ and $L \cup U = \{1, \ldots, n-1\},$ we find that either $|L| \geq \frac{n-1}{2}$ or $|U| \geq \frac{n-1}{2}$, since $|L \cup U| = n-1.$
Then, the parity check matrix $H$ of $\mC_{D,t}$ can be constructed like in Definition <ref> as follows.

H_{ij}(t) =
\begin{cases}
x & \text{if} \ \ j=i,\\
y & \text{if} \ \ j \equiv i+1 \pmod n,\\
1-t & \text{if} \ \ j=i',\\
0 & \text{otherwise},
\end{cases}
where $(x,y) \in \{(-1,t),(t,-1)\}$ depending on the diagram as in Definition <ref>.

Throughout the rest of the proof, we show that $\rk(H) \ge \frac{n-1}{2}$. When $|U| \geq \frac{n-1}{2}$, take the submatrix $H'$ of $H$ consisting of the rows corresponding to the crossings in $U$.
Then $H'$ is in row echolon form since the $i$-th row of $H$ such that $c_i \in U$ only has nonzero entries at positions $i$, $i + 1$ and $i'$ with $i' > i+1$. Thus, $\rk(H') = |U|$. This implies that $\rk(H) \ge |U|$ and consequently $\mC_{D,t}$ has dimension at most $n - |U|$. Similarly, if $|L| \geq \frac{n-1}{2}$ then the submatrix $H''$ consisting of the rows of $H$ corresponding to the crossings in $L$ is in column echelon form since the $i$-th row of $H$ such that $c_i \in L$ only has nonzero entries at positions $i$, $i + 1$ and $i'$ with $i' < i$. Therefore, we have $\dim(\mC_{D,t}) \leq n - \frac{n-1}{2} = \frac{n+1}{2}$.

In addition to Theorem <ref>, the following two results hold
about the dimension of knot codes.

Let $D$ be a knot diagram with $n$ strands and let $\mC_{D,t}$ be the corresponding knot code over $\F_q$.
Let $\dim(\mC_{D,t}) = k$. Then $k$ is the smallest integer with the property that $E_k(M(t))=\F_q$.

Let $\dim(\mC_{D,t}) = k$. Then $M(t)$ has rank $r=n-k$, since $\mC_{D,t}$ is the null space of the matrix $M(t)$.
Proposition <ref> states that $E_l(M(t))=\F_q$ if $l\geq n-r=k$ and $E_l(M(t))=0$ if $l<k$.
Hence $k$ is the smallest integer such that $E_k(M(t))=\F_q$.

Note that Proposition <ref> is also stated in <cit.>, where it has a longer proof.

Let $p$ be a prime number and let $t$ an integer such that $1\leq t<p$.
Let $D$ be a knot diagram and let
$\mC_{D,t}$ be the corresponding knot code over $\F_p$.
Let $e$ the largest integer such that $p^e$ divides $\Delta_K(t)$ in $\Z$.
Then $\dim(\mC_{D,t}) \leq e+1$, and equality holds if $e=1$.

Our proof uses Proposition <ref> with $R=\Z_t$, the localization of $\Z$ at $t$, and $d=p$. In particular,  $\overline{R}=\F_p$ and
$t$ is an invertible element in $\F_p$.
Let $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l)$ be the invariant factors of the module of Fox $(\Z_t,t)$-colorings.
Then $\Delta_K(t)=\prod_{i=2}^n d_i$ and $d_1=0$ by Proposition <ref>.
Let $\overline{d_i}=\gcd (p,d_i)$ and let $\overline{e}$ be the number of integers $i$ with $2 \leq i \leq l$ and $\overline{d_i}=p$.
Furthermore, $p^{\overline{e}}$ divides $\Delta_K(t)$ in $\Z$, hence
$\overline{e} \leq e$.
Then $p\prod_{i=2}^n\overline{d_i}$ is the number of Fox $(\F_p,t)$-colorings of $D$ by Proposition <ref>. So $\dim(\mC_{D,t})=1 + \overline{e}$
and $\dim(\mC_{D,t})\leq 1 + e$. If $e=1$, then the underlying knot, say $K$, is Fox $(\overline{R},t)$-colorable by Proposition <ref>.
So $1<\dim(\mC_{D,t})\leq 1 + e$
and $\dim(\mC_{D,t})=2$.

We finish this section with the following observation.

The minimum distance of codes of knots is not a knot invariant. This can be seen, for example, from the generator matrix of the first Reidemeister move in the proof of Theorem <ref>.

§ TWO FAMILIES OF KNOT CODES

This section is devoted to the study of two families of knots and their codes, namely torus knots around other knots and pretzel knots.
These can be both used to construct codes with
interesting parameters and will be treated in dedicated subsections. In the sequel, for ease of notation we will write
instead of
where $M(T)$ is the coloring matrix of the knot diagram at hand.

§.§ Torus knots

The notion of a torus knot was already introduced in Definition <ref>. In this subsection we investigate the properties of these knots and their generalizations. We then study the dimension of codes of knot diagrams of these knots and show how to construct codes of arbitrary dimension.

There exits a closed tubular neighbourhood of $K$, denoted by $\tub(K)$,
such that $\tub(K)$ is homeomorphic to $S^1\times D^2$ via a homeomorphism $h$ where $K$ is mapped to $S^1\times \{0\}$,
and the boundary of $\tub(K)$ is homeomorphic to the torus $S^1\times S^1$. See [16] for more details.

Generalizations of torus knots are defined as follows; see [5, 23].

Let $\tub(K)$ be a tubular neighbourhood of $K$.
Let $a,b$ be positive integers that are relatively prime.
Then the curve on $S^1\times S^1$ given by the parametrization $\varphi (t)=at$, $\theta (t)=bt$, is mapped via $h^{-1}$ of Remark <ref> to a knot on the
boundary of the tubular neighbourhood $\tub(K)$.
This knot is called the $(a,b)$-torus knot around $K$ and is denoted by $K(a,b)$.
By induction, we can repeat this procedure for some integer $m \in \Z_{\ge 2}$ to obtain the $(a_1,b_1,\ldots ,a_m,b_m)$-iterated torus knot $K(a_1,b_1,\ldots ,a_m,b_m)$ around $K$, where
the pairs $(a_i,b_i)$ are relatively prime  and $K(a_1,b_1,\ldots ,a_i,b_i)$ is the $(a_i,b_i)$-torus knot around
$K(a_1,b_1,\ldots ,a_{i-1}, b_{i-1})$ for all $i \in \{1,\ldots,m\}$.

It can be seen that Definition <ref> generalizes torus knots, in the sense that the torus knot $\mT(a,b)$ is the $(a,b)$-torus knot around a trivial knot $K$.

The Alexander polynomial of a torus knot has a rather simple expression.

Let $a,b$ be positive integers that are relatively prime.
The Alexander polynomial of the torus knot $\mT(a,b)$ is given by

\Delta_{\mT(a,b)}(T) =\frac{(T^{ab}-1)(T-1)}{(T^a-1)(T^b-1)}.

Moreover, the $k$-th elementary ideal of $\mT(a,b)$ is $\Z[T,T^{-1}]$ for all $k \geq 2$.

See  <cit.>, <cit.>,
and <cit.>.

We give an example to show how Proposition <ref> can be used.

Let $a,b$ be positive integers that are relatively prime. Let $D$ be a diagram of $\mT(a,b)$.
Proposition <ref> implies the following.

* If $a$ and $b$ are odd, then $\Delta_{\mT(a,b)}(-1)=1$ and there are only trivial Fox $(\F_p,-1)$-colorings of $D$.

* If $a$ is odd and $b$ is even, then $\Delta_{\mT(a,b)}(-1)=a$, and $D$ is Fox $(\F_p,-1)$-colorable if and only if $p$ divides $a$.

* If $b$ is odd and $a$ is even, then $\Delta_{\mT(a,b)}(-1)=b$, and $D$ is Fox $(\F_p,-1)$-colorable if and only if $p$ divides $b$.

The dimension over $\F_p$ of $\mC_D$ is 1 in the first case and 2 in the second and the third case by Proposition <ref>, since the second elementary ideal is the whole ring by Proposition <ref>. If $ab$ divides $q-1$, then there exists an element $t$ in $\F_q^*$ of order $ab$. So $\Delta_{\mT(a,b)}(t)=0$, $D$ is $(\F_q,t)$-colorable, and the dimension over $\F_q$ of $\mC_{D,t}$ is 2.

The inequality in Proposition <ref> is in general not an equality (see <cit.>),
contrary to what is stated in <cit.>. This can also be seen by taking $K=\mT(2,9)$. We have $\Delta_K(-1)=9$, and thus the largest integer $e$ such that $3^e$ divides 9 is $e=2$ in this case. However, the dimension of the code over $\F_3$ is equal to $2$, showing that the bound of Proposition <ref> is not sharp in general.

We can determine the elementary ideals of the knot $K(a,b)$ in terms of the elementary ideals of the knot $K$ and the Alexander polynomial of the torus knot $\mT(a,b)$.

Let $a,b$ be nonzero integers that are relatively prime. We have

\tilde{E}_k(T) = \Delta_{\mT(a,b)}(T)E_k(T^b) + E_{k-1}(T^b).

where $E_k(T)$ denotes the $k$-th elementary ideal of $K$ and $\tilde{E}_k(T)$ denotes the $k$-th elementary ideal  of the knot $K(a,b)$.

See [23] and <cit.>.

We have the following two corollaries of Proposition <ref>.

Let $a,b$ be positive integers that are relatively prime. Then the Alexander polynomial of the $(a,b)$-torus knot around $K$ is given by

\Delta_{K(a,b)}(T)=\Delta_{\mT(a,b)}(T)\Delta_K(T^b).

$\Delta_{K(a,b)}(T)$ is a generator of the principal ideal $\tilde{E}_1(T)$,
$\Delta_K(T)$ is a generator of the principal ideal $E_1(T)$ in Proposition <ref>, and
$\tilde{E}_1(T) = \Delta_{\mT(a,b)}(T)E_1(T^b) + E_0(T^b)$. This gives the desired result since $E_0(T) =(0)$.

Let $a,b$ be nonzero integers that are relatively prime such that $a$ is even and $b$ is odd. Let $p$ be a prime divisor of $b$.
Let $K$ be a knot, $D$ a diagram of $K$, and let $k$ denote the dimension of $\mC_{D,t}$ over $\F_p$.
Then the code $\mC_{\tilde{D},t}$ of a diagram $\tilde{D}$ of $K(a, b)$ has dimension $k + 1$ over $\F_p$.

Let $E_l(T)$ be the $l$-th elementary ideal of $K$. Then  $E_l(-1)=\F_p$ if $l\geq k$, and $E_l(-1)=0$ if $l<k$ by Proposition <ref>.
Since $p$ is a prime that divides $b$, $a$ is even and $b$ is odd, we have $\Delta_{\mT(a,b)}(-1)=0$ in $\F_p$ by Example <ref> and $(-1)^b=-1$.
Let $\tilde{E}_l(T)$ be the $l$-th elementary ideal of $(a,b)$-torus knot around $K$.
Then  $\tilde{E}_l(-1)=\F_p$ if $l\geq k+1$, and $\tilde{E}_l(-1)=0$ if $l<k+1$, by Proposition <ref>.
Hence $\mC_{\tilde{D}}$ has dimension $k+1$ by Proposition <ref>, as claimed.

In the next example we show how to build codes using
iterated torus knots around other knots.

Let $p$ be an odd prime. A diagram of the iterated torus knot $K(2,p,\ldots ,2,p)$, where $K$ is the unknot and $(2,p,\ldots ,2,p)$ is the $m$-fold
repetition of $(2,p)$, gives a code over $\F_p$ of dimension $m+1$ by Corollary <ref>.
The recursive formula of the length of the code of $K(2,p,\ldots ,2,p)$ is given by $n_1=3$, $n_{m+1} =4n_m+p$.

We conclude this subsection with the following crucial example.

Let $b=2l+1$ be a positive odd integer for some $l$ and let $\mT(2,b)$ be the torus knot as given in Definition <ref>. Consider its diagram depicted in Figure <ref>. This is a diagram with $b$ crossings where the upper left understrand is connected with the lower left overstrand, and the upper right overstrand is connected with the lower right understrand.
Denote the upper left understrand by $x_1$ and the upper right overstrand by $y_1$.
Denote the strands by following the knot's orientation from
the upper left understrand $x_1$ to the lower right understrand by $x_1, x_2, \ldots ,x_{l+2}$, respectively.
Denote the strands following the knot's orientation from the
upper right overstrand $y_1$ to the lower left overstrand by $y_1, y_2, \ldots ,y_{l+1}$, respectively.
Then $x_{l+2}=y_1$ and $y_{l+1}=x_1$, see again Figure <ref>.

A checkerboard coloring of $\mT(2,5)$.[.7]

Diagram of $\mT(2,b)$ with $b$ is odd given in Example <ref>.

Let $p$ be a prime and suppose that the strands are Fox $(\F_p,-1)$ colored.
Then we get by induction that $x_{i+1}=2iy_1-(2i-1)x_1$ and $y_{i+1}=(2i+1)y_1-2ix_1$.
So $x_{l+2}=y_1$ and $y_{l+1}=x_1$ imply $by_1-bx_1=0$ in $\F_p$.
Hence $\mT(2,b)$ is  Fox $(\F_p,-1)$-colorable  if and only if $b$ is divisible by $p$.
Furthermore, if $p$ divides $b$, then we get a non-trivial coloring with $x_{i+1}=2i$ and $y_{i+1}=2i+1$.
So all the strands have mutually distinct colors, which is in agreement with Theorem <ref>.

The Fox colorings have weight $1$ (all strands have color $0$), or $p$ (all strands have the same nonzero color), or $p-1$ for a non-trivial coloring, when the colorings are viewed as codewords as in Section <ref>. A checkerboard coloring (see Definition <ref>) of the regions has $p$ regions with color $0$ (white in Figure <ref>), where the unbounded region is colored white, and two regions of nonzero color (black in the figure). This gives a Dehn $(\F_p,-1)$-coloring of the diagram  of weight $2$. So the isomorphism of modules as mentioned in Proposition <ref> sends a word of weight $2$ to a word of weight $p$. Hence the isomorphism is not an isometry if $p>3$.

§.§ Pretzel Knots

In this subsection we prove that also pretzel knots codes can be used to construct codes with prescribed dimension. Moreover, we study the error correction capability of these codes. Starting from knots, one can create larger objects called links.

Let $n \in \Z_{\ge 1}$. A link $L = \{K_1,\ldots, K_n\}$ is a finite collection of knots such that $K_i \cap K_j = \emptyset$ for all  $i,j \in \{1,\ldots,n\}$ with $i \neq j$. Each of the constituent knots is a component of the link. In particular, a polygonal link is a link each of whose component is a polygonal knot.

Since we only consider polygonal knots in this paper, we only consider polygonal links and simply write link for those.

A (3)-crossing twist and a (-4)-crossing twist.

Next, we informally define pretzel links following [20].

A twist is a part of a knot diagram consisting of two strands and at least a crossing such that all the crossings are obtained using both strands together, and it is of the form depicted in in Figure <ref>. A twist with $|b| \in \Z_{>0}$ crossings is called a $(|b|)$-crossing twist if the top right strand is an overstrand, and is called a $(-|b|)$-crossing twist if the top right strand is an understrand. Let $p_1,\ldots,p_m$ be nonzero integers for some $m \in Z_{> 0}$. A pretzel link is a link with its diagram depicted as in Figure <ref>, where each rectangle denotes a twist with $|p_i|$ crossings. We denote this object by $P(p_1,\ldots,p_m)$. It is obtained when multiple twists are placed next to each other, where for each pair of neighboring strands the top and bottom right strands of the left twist are connected to the top and bottom left strands of the right twist, respectively, and the the top and bottom left strands of the leftmost twist are connected to the top and bottom right strands of the rightmost twist, respectively.

A general diagram of a pretzel link.

The sufficient and necessary condition when a pretzel link is a knot is proven in [20].

A pretzel link $P(p_1,\ldots,p_m)$ is a knot if and only if $m$ and $p_i$ are odd integers for all $i \in \{1,\ldots,m\}$,
or $m \ge 1$ and exactly one of the the $p_i$ is even.

Next, we show that codes with any dimension can be constructed using pretzel knots.

(see <cit.>)

Let $D$ be a diagram of the pretzel knot $P(p_1, p_2, ..., p_m)$.
Let $q$ be a power of the prime $p$.

* If $p_i$ is coprime with $q$ for all $i \in \{1,\ldots,m\}$,
then the dimension of a knot code $\mC_D$ over $\F_q$ is given by

\dim(\mC_D) =
\begin{cases}
2 & \text{if} \ \ p \mid \Delta_K(-1),\\
1 & \text{otherwise}.
\end{cases}

* If there exists a $p_i$ that is not coprime with $q$ for some $i \in \{1,...,m\}$, then the dimension of $\mC_D$ over $\F_q$ is
$|\{i \mid \gcd(p_i, q) \neq 1,\, i \in \{1, \ldots, m\} \}|$.

We give an example to show an application of Theorem <ref>.

Diagram of the $P(3,2,3,5)$ pretzel knot.

The $P(3,2,3,5)$ pretzel knot is depicted in Figure <ref> has determinant $123 = 3 \cdot 41$, which means it is non-trivially colorable over $\mathbb{F}_3$ and $\mathbb{F}_{41}$ by Proposition <ref>. By the second part of Theorem <ref>, we then find that the code obtained from the colorings over $\mathbb{F}_3$ has dimension 2. By the first part of Theorem <ref>, we also have that the code obtained from the colorings over $\mathbb{F}_{41}$ has dimension 2, as well.

For some special family of pretzel knots, we can determine the exact code parameters of the corresponding code. Computing the minimum distance in the general case seems to be a hard task.

Let $p$ be an odd prime and $D$ be a diagram of $P(p_1,\ldots ,p_m)$ with $p_i=p$ for all $i \in \{1,\ldots,m\}$. Then,
$\mC_D$ is a $[pm,m,2p-2]_p$ code.

The statement about the dimension is already shown in Theorem <ref>.
Consider the numbering of the strands of the diagram $D$ analogous to Example <ref>.
Let $p=2l+1$ for some $l \in \Z$.
For $i \in \{1,\ldots,m\}$, number the strands in the $i$-th block as follows.
Following the knot's orientation, label the strands from the upper left $x_{i,1}$ to the lower right by $x_{i,1}, x_{i,2}, \ldots ,x_{i,l+2}$.
Following the knot's orientation, label
the strands from the
upper right $y_{i,1}$ to the lower left by $y_{i,1}, y_{i,2}, \ldots ,y_{i,l+1}$.
The strand $y_{i,1}$ is equal to $x_{i+1,1}$ for all $i \in \{1,\ldots,m-1\}$, and $y_{m,1}$ is equal to $x_{1,1}$.
The strand $y_{i,l+1}$ is equal to $x_{i-1,l+2}$ for all $i \in \{2,\ldots,m\}$, and $y_{1,l+1}$ is equal to $x_{m,l+2}$.

The $i$-th block consist of $2l+1=p$ strands
$\smash{x_{i,1}, x_{i,2}, \ldots ,x_{i,l+2}}$ and $\smash{y_{i,2}, \ldots ,y_{i,l}}$, since $\smash{y_{i,1}=x_{i+1,1}}$ and $\smash{y_{i,l+1}=x_{i-1,l+2}}$.
The values of $\smash{x_{1,1}, x_{2,1}, \ldots ,x_{m,1}}$ determine all the values of the other strands due the our assigning above.
Now $x_{i,1}=0$ and $x_{i+1,1}=0$ if and only if all the strands in the $i$-th block have value zero.
If $x_{i,1}\not=0$, then at least $p-1$ strands of the $i$-th block and $p-1$ strands of the $(i-1)$-th block have nonzero value as shown in Example <ref>.
Hence the weight of a nonzero codeword is at least $2(p-1)$.

Choosing $x_{1,1}=1$ and $x_{i,1}=0$ for all $i\neq 1$ gives a codeword of weight $2(p-1)$.
Hence $\mC_D$ has indeed minimum distance $2(p-1)$ and rate $R=m/pm= 1/p$.

§ CONNECTED SUM OF KNOT DIAGRAMS

Using the connected sum operation, two knot diagrams form a new knot diagram. This will give us a way
of constructing knot codes
with arbitrary dimension.
This section is devoted to studying how the codes of two knot diagrams are related to the code of their connected sum.

The connected sum
of oriented knots $K_1$ and $K_2$
is the oriented knot $K_1 \# K_2$
whose diagram is obtained by taking an arc from a strand of each knot and connecting the open ends with two new arcs, in such a way that the orientation is preserved in the sum; see Figure <ref>.

It can be shown that the
connected sum of knots indeed
does not depend on the choice of the strands.

On the top, the composition of two trefoil knots results in what is called a so-called granny knot. On the bottom, the composition of trefoil knot and its mirror image results in what is called a square knot.

The following concepts naturally arise from Definition <ref>.

A knot that cannot be written as the sum of two non-trivial knots is called a prime knot, otherwise it is called a composite knot.

All composite knots have a unique decomposition into prime knots [42]. Determining whether a knot is composite or not is generally a hard task.

We establish the notation for the rest of this section.

In the sequel we let
$D_K$ and $D_L$ be knot diagrams of (oriented, polygonal) knots $K$ and $L$ with strands $x_1, ..., x_n$ and $y_1, ..., y_m$, respectively. We let $\mC$ and $\mD$ be their respective codes in $\mathbb{F}_{q}^n$ and $\mathbb{F}_{q}^m$, as in Definition <ref>,
where $p$ is prime and $a$ is a positive integer. Moreover, we let

$$\mC' = \{ c \in \mC \mid c_n = 0 \}, \ \ \mD' = \{ d \in \mD \mid d_m = 0 \}.$$

The following
result provides an explicit description of
the connected sum of knot diagrams.

The code of the sum $K\#L$ taken by connecting the knots diagrams $D_K$ and $D_L$ over strands $x_n$ and $y_m$ is
$$\mC\# \mD = \{(c,d) \mid c \in \mC, d \in \mD, c_n = d_m\}.$$

A Fox coloring for $D_{K\#L}$ consists of a Fox coloring of $D_K$ and a Fox coloring of $D_L$ where the colors of the strands $x_n$ and $y_m$ that have been connected have the same color.

Lemma <ref> implies that if $\mC$ and $\mD$ have parity check matrices $H_{\mC}$ and $H_{\mD}$, then $\mC\# \mD$ has parity check matrix

\begin{equation}
\label{eq:paritycheck}
H_{\mC \# \mD} = \left(
\begin{array}{cccc|cccc}
& H_{\mC} & & & & 0_{(n - \dim(\mC)) \times m} &  & \\
& 0_{(m - \dim(\mD)) \times n} & & & & H_{\mD} & & \\
0 & \dots & 0 & 1 & 0 & \dots & 0 & -1
\end{array} \right).
\end{equation}

The last line of the matrix consists only of zeroes, except for a 1 on the $n$-th column and -1 on the $(n+m)$-th column.

The following proposition shows that the connected sum gives us another method, besides pretzel knots (see Theorem <ref>), to construct codes with any dimension.

We have

$$\dim(\mC \# \mD) = \dim(\mC) + \dim(\mD) -1.$$

The parity check matrices $H_{\mC}$ and $H_{\mD}$ of $\mC$ and $\mD$ are of size $(n - \dim(\mC)) \times n$ and $(m - \dim(\mD)) \times m$, respectively. Using the above construction from matrix (<ref>) we then get a parity check matrix $H$ for $\mC\# \mD$ of size $(n+m - (\dim(\mC) + \dim(\mD) - 1)) \times (n + m)$ such that the first $n + m - (\dim(\mC) + \dim(\mD))$ rows are linearly independent.

Towards a contradiction, assume that the last row can be written as a linear combination of the other rows of $H$. That would mean that there exists a linear combination of the rows of $H_{\mC}$ equal to $(0,...,0,1)$, which means that the strand $x_m$ should always be colored with 0. The possible trivial colorings contradict this, as these include vectors with the same nonzero element on each position. So we find that the last row of $H_{\mC\# \mD}$ is independent from the other rows. Therefore, the rank of the matrix is $n + m - (\dim(\mC) + \dim(\mD) - 1)$. This proves the
desired result.

The diagram of the $m$-fold sum construction of the trefoil knot gives a code over $\F_3$ of length $3m$ and dimension $m+1$.
Hence its rate is $R=(m+1)/3m \approx 1/3$.

As one expects, the Alexander polynomials of two knots and their knot sum are also related; see <cit.>.

We have

\Delta_{K\#L}(T) = \Delta_K(T)\Delta_L(T)

Next, we give an example of a connected sum of two knot diagrams and compute the determinant using Proposition <ref>.

In Figure <ref>, the diagrams of the trefoil knot, figure-eight knot and their connected sum are depicted.

Using the matrix in (<ref>), their coloring matrices are derived as follows:

\begin{pmatrix}
1 & 1 & -2 \\
-2 & 1 & 1 \\
1 & -2 & 1 \\
\end{pmatrix} \textnormal{, }
\begin{pmatrix}
1 & 1 & -2 & 0 \\
0 & 1 & 1 & -2 \\
-2 & 0 & 1 & 1 \\
1 & -2 & 0 & 1 \\
\end{pmatrix},
\textnormal{ and }

\begin{equation}\label{eq: first matrix}
\begin{pmatrix}
1 & 1 & -2 & 0 & 0 & 0 & 0 \\
-2 & 1 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 1 & -2 & 0 & 0 \\
0 & 0 & 0 & 1 & 1 & -2 & 0 \\
0 & 0 & -2 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & -2 & 0 & 1 & 1 \\
1 & -2 & 0 & 0 & 0 & 0 & 1
\end{pmatrix},
\end{equation}

which are the parity check matrices of $\mC$, $\mD$ and $\mC\# \mD$, respectively. These knots have determinants 3, 5 and 15 by Proposition <ref>, respectively.

Lastly, we prove that the minimum distance of a code of the diagram of a connected sum is determined by the weight distributions of the codes of the constituent knot diagrams.

Let $\mC$, $\mC'$, $\mD$, and $\mD'$
and $\mC \# \mD$ be as in Notation <ref> and Lemma <ref> and let $d(\mC)$, $d(\mD)$ and $d(\mC \# \mD)$ their respective minimum distances.
The minimum distance of $\mC \# \mD$ is equal to

\begin{equation}
\min \{ \ d(\mC'),\ d(\mD'),\ v+w \ \mid \  v \in  \wt(\mC \setminus \mC'),\ w \in \wt(\mD \setminus \mD') \ \}.
\end{equation}

As the codewords of $\mC$ and the codewords of $\mD$ only affect the weight of the codewords of $\mC \# \mD$ at the first $n$ positions and the last $m$ positions, respectively, we look how minimum weight codewords of $\mC \# \mD$ can be constructed by concatenating codewords of $\mC$ and $\mD$.
Now $x \in \mC \# \mD$ if and only if $x=(c,d) $ with $c \in \mC$ and $d \in \mD$  and $c_n = d_m$. Then $\wt(x)=\wt(c)+ \wt(d)$. We investigate two cases to finish the proof.

* Let $c_n = d_m = 0$, that is $c \in \mC'$ and $d \in \mD'$.
In this case $\min\{ d(\mC'), d(\mD') \}$ is the smallest nonzero weight and is obtained by means of $(c, 0^m)$ or $(0^n,d)$ with the all-zeros codeword $0^n \in \mC$ and the all-zeros codeword $0^m \in \mD$.

* Let $c_n = d_m \neq 0$, that is $c \in \mC \setminus \mC'$ and $d \in \mD \setminus  \mD'$.
If $v =\wt (c)$, then $v \in \wt(\mC \setminus \mC')$. Similarly, if $w =\wt (d)$, then $w \in \wt(\mD \setminus \mD')$.
Conversely, if $v \in \wt(\mC \setminus \mC') $, then there exists a  $c \in \mC \setminus \mC'$ with $v =\wt (c)$.
Similarly, if $w \in \wt(\mD \setminus \mD')$, then there exists a  $d \in \mD \setminus \mD'$ with $w =\wt (d)$.
Hence, $\min \{ v+w \mid v \in  \wt(\mC \setminus \mC'),\ w \in \wt(\mD \setminus \mD')\}$
is the smallest weight of a nonzero codeword of $\mC \# \mD$ obtained in this case.

We give the following two remarks related to Theorem <ref>.

If $\mC' =\{0\}$ and $\mD' =\{0\}$, then $K$ and $L$ have only trivial colorings, so $ \mC \# \mD$ has only trivial colorings and $d(\mC \# \mD)= n+ m$.
This is in agreement with the statement in Theorem <ref>, since we defined the minimum distance of the zero code to be $\infty$ in Definition <ref>.

If $\mC' =\{0\}$ and $\mD' \not=\{0\}$, then $d(\mC \# \mD)=\min \{ \   d(\mD'),\ n+w \ \mid \ w \in \wt(\mD \setminus \mD')\  \}$.

And a similar formula holds in case $\mC' \not=\{0\}$ and $\mD' =\{0\}$.

Theorem <ref> also follows from <cit.>,
where a formula for the weight enumerator of $\mC \# \mD$ is given in terms of the weight enumerators of $\mC $, $\mD$, $\mC'$, and $\mD'$.
The formula is:

W_{\mC \# \mD}(T) = W_{\mC'}(T)\cdot W_{\mD'}(T) + \frac{1}{q - 1} (W_{\mC}(T) - W_{\mC'}(T))(W_{\mD}(T) - W_{\mD'}(T)).

This is in agreement with Theorem <ref>, since $a_v(\mC') < a_v(\mC)$ if and only if $ v\in \wt(\mC \setminus \mC')$,
and $a_w(\mD') < a_w(\mD)$ if and only if $w \in \wt(\mD \setminus \mD')$.

We conclude the section with an example to show applications of some of our results.

Let $q=3$ and $\mC=\mC_D$ where $D$ is the knot diagram of the trefoil knot depicted in Figure <ref>. By Example <ref>, its parity check matrix is all-ones matrix and thus has rank 1. Thus, $\mC$ is a $[3,2,2]_3$ MDS code such that

\begin{align*}
\mC &= \{(0,0,0),(0,1,2),(0,2,1),(1,0,2),(1,2,0),(1,1,1),(2,0,1),(2,1,0),(2,2,2)\}, \\
\mC' &= \{(0,0,0),(1,2,0),(2,1,0)\}.
\end{align*}

We have $d(\mC')=2$ and $\wt(\mC \setminus \mC') = \{2,3\}$. By Proposition <ref> and Theorem <ref> one can create a code with parameters

$$[n+m, \dim(\mD)+1, \min\{2,d(\mD')\}]_3$$

where $\mD$ is a code a knot diagram of some knot with $m$ strands. For example, if $\mD = \mC$, then one gets a $[6,3,2]_3$ code which is a non-MDS.

§ DUAL OF KNOT CODES

It is a standard problem in coding theory to understand how properties of a code determine or influence properties of the dual code.
In this short section, we ask ourselves
if the dual of a code of a knot diagram is also a code of a knot diagram.
We start by proving a necessary but not sufficient condition for a dual code to be a knot diagram.

Let $\mC$ be a code of a knot diagram with $n$ strands over $\F_q.$ Then $q$ divides $n$ if $\mC^\perp$ is a code of a knot diagram.

By Remark <ref>, the code $\mC$ of a knot diagram with $n$ strands has the $n$-times repetition code
$$\langle \underbrace{(1,1,...,1)}_n \rangle$$
as a subcode. If  $\mC^\perp$ is a code of some knot diagram, then it should also have the $n$-times repetition code as a subcode.
We have that
$$\underbrace{(a,a,...,a)}_{n}\underbrace{(a,a,...,a)}_{n} {^\top} = na^2$$
for all $a \in \F_q^n$. So in order for both a code and its dual to have the $n$ times repetition code as their subcode, it must be
that $na^2 = 0$ for all $a \in \F_q^n$. Therefore, we must have that $n$ is divisible by $q$, as desired.

Using results we obtained on the dimension of a code of a knot diagram in Subsection <ref>, we can obtain information about the dual code as well.

Let $\mC$ be a code of a knot diagram. If $\dim(\mC) < \frac{n-1}{2}$, then $\mC^\perp$ is not equivalent to a code of a knot diagram.

If $\dim(\mC) < \frac{n-1}{2}$ then $\dim(\mC^\perp) > \frac{n+1}{2}$.
The result then follows from Theorem <ref>.

This result can be used on composite knot diagrams to determine whether the duals of their codes are codes of knot diagrams.

Let $\mC = \mC_1 \# \mC_2 \# \cdots \# \mC_i$ be the code of a diagram of $i$ composed knots $K = K_1 \# K_2 \# \cdots \# K_i$, where each $K_j$ has $n_j$ strands in their corresponding knot diagrams. If $i \geq 4$, then $\mC^\perp$ is not a code of a knot diagram.

Let $n = n_1 + n_2 + \cdots + n_i$.
Using Proposition <ref> we find that

\begin{align*}
\dim(\mC_1 \# \mC_2 \#\cdots \# \mC_i) &= \dim(\mC_1) + \dim(\mC_2) + \cdots + \dim(\mC_i) - i + 1 \\
&\leq \frac{n_1 + 1}{2} + \frac{n_2 + 1}{2} + \cdots + \frac{n_i + 1}{2} - i + 1 \\
&= \frac{n - i}{2} + 1.
\end{align*}

Therefore $\dim(\mC) < \frac{n-1}{2}$ if $i \geq 4$ and the result follows from Proposition <ref>.

[1]
J. W. Alexander.
Topological invariants of knots and links.
Transactions of the American Mathematical Society,
30(2):275–306, 1928.

[2]
M. Atiyah.
Introduction to commutative algebra.
CRC Press, 2018.

[3]
S. Ball.
Finite geometry and combinatorial applications, volume 82.
Cambridge University Press, 2015.

[4]
I. F. Blake and R. C. Mullin.
An introduction to algebraic and combinatorial coding theory.
Academic Press, 2014.

[5]
W. Burau.
Kennzeichnung der schlauchverkettungen.
Abhandlungen aus dem Mathematischen Seminar der Universität
Hamburg, 9:125–133, 1933.

[6]
J. S. Carter, D. S. Silver, and S. G. Williams.
Three dimensions of knot coloring.
The American Mathematical Monthly, 121(6):506–514, 2014.

[7]
R. H. Crowell and R. H. Fox.
Introduction to knot theory, volume 57.
Springer Science & Business Media, 2012.

[8]
M. Dehn.
Über die topologie des dreidimensionalen raumes.
Mathematische Annalen, 69(1):137–168, 1910.

[9]
W. Ebeling.
Lattices and codes.
Springer, 2013.

[10]
D. Eisenbud.
Commutative algebra: with a view toward algebraic geometry,
volume 150.
Springer Science & Business Media, 2013.

[11]
R. H. Fox.
Metacyclic invariants of knots and links.
Canadian Journal of Mathematics, 22(2):193–201, 1970.

[12]
R. Gallager.
Low-density parity-check codes.
IRE Transactions on Information Theory, 8(1):21–28, 1962.

[13]
M. J. Greenberg.
Algebraic topology: a first course.
CRC Press, 2018.

[14]
F. Harary and L. H. Kauffman.
Knots and graphs I — arc graphs and colorings.
Advances in Applied Mathematics, 22(3):312–337, 1999.

[15]
A. Henrich and R. Truax.
Petal projections, knot colorings and determinants.
Involve, a Journal of Mathematics, 15(2):207–232, 2022.

[16]
M. Hirsch.
On tubular neighborhoods of piecewise linear and topological
Conference on the Topology of Manifolds, 13, 1968.

[17]
W. C. Huffman and V. Pless.
Fundamentals of error-correcting codes.
Cambridge University Press, 2010.

[18]
L. H. Kauffman.
Formal knot theory.
Courier Corporation, 2006.

[19]
L. H. Kauffman and P. Lopes.
Colorings beyond fox: The other linear alexander quandles.
Linear Algebra and its Applications, 548:221–258, 2018.

[20]
A. Kawauchi.
Survey on knot theory.
Springer Science & Business Media, 1996.

[21]
S. Kolay.
Knot colorings: Coloring and goeritz matrices.
The American Mathematical Monthly, pages 1–20, 2023.

[22]
C. Kosniowski.
A first course in algebraic topology.
Cambridge University Press, 1980.

[23]
D. T. Lê.
Sur les nœuds algébriques.
Compositio Mathematica, 25(3):281–321, 1972.

[24]
S. Lang.
Algebra, volume 211.
Springer Science & Business Media, 2012.

[25]
D. Lind and B. Marcus.
An introduction to symbolic dynamics and coding.
Cambridge University Press, 2021.

[26]
C. Livingston.
Knot theory, volume 24.
Cambridge University Press, 1993.

[27]
M. G. Luby, M. Mitzenmacher, M. A. Shokrollahi, and D. A. Spielman.
Improved low-density parity-check codes using irregular graphs.
IEEE Transactions on Information Theory, 47(2):585–598, 2001.

[28]
D. J. MacKay.
Good error-correcting codes based on very sparse matrices.
IEEE transactions on Information Theory, 45(2):399–431, 1999.

[29]
D. J. MacKay and R. M. Neal.
Near shannon limit performance of low density parity check codes.
Electronics Letters, 33(6):457–458, 1997.

[30]
F. J. MacWilliams and N. J. A. Sloane.
The theory of error-correcting codes, volume 16.
Elsevier, 1977.

[31]
T. W. Mattman and P. Solis.
A proof of the Kauffman–Harary conjecture.
Algebraic & Geometric Topology, 9(4):2027–2039, 2009.

[32]
J. R. Munkres.
Topology, volume 2.
Prentice Hall Upper Saddle River, 2000.

[33]
K. Murasugi and B. Kurpita.
Knot theory and its applications.
Springer, 1996.

[34]
M. Newman.
Integral matrices.
Academic Press, 1972.

[35]
A. Nijsten.
Knots and codes.
Bachelor's thesis, Eindhoven University of Technology, 2019.

[36]
A. Nijsten.
Properties of codes of knot diagrams.
Master's thesis, Eindhoven University of Technology, 2022.

[37]
J. G. Oxley.
Matroid theory, volume 3.
Oxford University Press, USA, 2006.

[38]
R. Pellikaan.
Onderwerpen uit de knopentheorie.
Master's thesis, University of Amsterdam, 1981.

[39]
R. Pellikaan, X.-W. Wu, S. Bulygin, and R. Jurrius.
Codes, cryptology and curves with computer algebra.
Cambridge University Press, 2017.

[40]
J. Przytycki.
3-coloring and other elementary invariants of knots.
Banach Center Publications, 42(1):275–295, 1998.

[41]
K. Reidemeister.
Elementare begründung der knotentheorie.
Abhandlungen aus dem Mathematischen Seminar der Universität
Hamburg, 5:24–32, 1927.

[42]
H. Schubert.
Die eindeutige Zerlegbarkeit eines knotens in Primknoten.
Springer-Verlag, 2013.

[43]
B. Segre.
Curve razionali normali ek-archi negli spazi finiti.
Annali di Matematica Pura ed Applicata, 39:357–379, 1955.

[44]
R. Singleton.
Maximum distance $q$-nary codes.
IEEE Transactions on Information Theory, 10(2):116–118, 1964.

[45]
H. Stichtenoth.
Algebraic function fields and codes, volume 254.
Springer Science & Business Media, 2009.

[46]
L. Traldi.
Link colorings and the Goeritz matrix.
Journal of Knot Theory and its Ramifications, 26(8), 2017.

[47]
L. Traldi.
Multivariate alexander colorings.
Journal of Knot Theory and Its Ramifications, 27(14):1850076,

§ COMMUTATIVE ALGEBRA

For the basic definitions and properties of commutative algebra such as modules and morphisms we refer to [2, 10, 24].
In this paper, a ring will always mean a Noetherian, commutative ring with a unit element $1$.
So, the ideals of a ring are finitely generated. Furthermore, all modules will be assumed to be finitely generated.

In this appendix, we adopt the usual convention in commutative algebra to consider the elements of $R^{(n)}$ as column vectors of length $n$ with entries in $R$,
contrary to the rest of this paper where we align to the convention in coding theory where the elements of $R^n$ are row vectors of length $n$ with entries in $R$.
So this difference is stressed by the notation $R^{(n)}$ for column vectors and $R^n$ for row vectors.

The set of $m \times n$ matrices with entries in the ring $R$ is denoted by $R^{m \times n}$.
The matrix $A \in R^{m \times n}$ gives a morphism of $R$-modules $R^{(n)} \rightarrow R^{(m)}$
defined by $x \mapsto Ax$ for $ x \in R^{(n)}$.
The kernel of $A \in R^{m \times n}$ is $\Ker (A) =\{ x\in R^n \mid Ax^T =0 \}$.

To define equivalence of matrices, row/column operations are used.

The elementary row operations on a matrix with entries in a ring are:

* interchanging rows,

* adding a row to another row,

* multiplying a row with an invertible element of the ring.

One defines elementary column operations similarly.
If $A$  is the $m \times n$ matrix in the left upper submatrix of the $(m+1)\times (n+1)$ matrix $B$ such that the entries of the last row and column of $B$ are all zero, except a pivot $1$ at the entry corresponding to the last row and last column, then we say that $B$ is obtained from $A$ by adding a pivot, and $A$ from $B$ by deleting a pivot.

Matrices are called equivalent if they can be obtained from each other by a sequence of

* elementary row and column operations,

* adding and deleting a zero row,

* adding and deleting a pivot.

Definition <ref> is taken from <cit.> and is more general than the one given in  <cit.>, where  equivalent matrices must have the same size.

Let $A$ and $B$ be  matrices with entries in $R$.
If $A$ and $B$ are equivalent, then $\Ker (A) \cong \Ker (B)$ as $R$-modules.

Given a matrix, one defines ideals generated by the determinant of all submatrices of some fixed size.

Let $A \in R^{m \times n}$ and $k \in \Z_{\geq 0}$.
Let $E_k(A)$ denote the $k$-th elementary (or Fitting) ideal of $A$, that is the ideal generated by determinants of all $(n-k)\times (n-k)$ submatrices of $A$ if $0<n-k\leq m$, $E_k(A)=0$ if $n-k>m$, and $E_k(A)=R$ if $n-k\leq 0$.

Elementary ideals of equivalent matrices are the same. Moreover this fact can be slightly refined,
as the following two propositions formalize.

Let $A \in R^{m \times n}$ and $k \in \Z_{\geq 0}$. The elementary ideals $E_k(A)$ form an increasing sequence of ideals with respect to inclusion. If $A$ and $B$ are equivalent matrices, then $E_k(A)=E_k(B)$.

See <cit.>.

Let $A \in R^{m \times n}$ and $B \in R^{m \times (n+l)}$ be matrices such that $B$ is equivalent to $\smash{(A \mid O_{m\times l})}$, where
$0_{m\times l} \in R^{m \times l}$ is the matrix with all zero entries.
Then $E_{k}(B)=E_{k-l}(A)$ for all $k$.

The result follows directly from the definitions if $B=(A \mid O_{m\times l})$, and from Proposition <ref> otherwise.

Adding zero rows to a matrix does not change its elementary ideals. Thus, we have the following result that is independent of the number of columns of the matrix.

Let $R$ be a field and let $A \in R^{m \times n}$.
If $A$ has rank $r$, then  $E_k(A)=R$ if $k\geq n-r$, and $E_k(A)=0$ otherwise.

If $A$ has rank $r$, then one can transform $A$ by elementary row and column operations into a matrix $B$ that has the $r \times r$ identity matrix $I_r$ as a submatrix and entries equal to zero outside that identity matrix.
Deleting the $r$ rows and columns corresponding to the pivots of the  matrix gives the $(m-r) \times (n-r)$ matrix with zeros as entries.
The elementary ideals remain the same under these transformations by Proposition <ref>.
Hence $E_k(A)=R$ if $k\geq n-r$ and $E_k(A)=0$ otherwise.

Let $\varphi : R \rightarrow S$ be a morphism of rings and let $A$ be a matrix with entries $a_{ij}$ in $R$.
Denote by $\varphi (A)$ the matrix with entries $\varphi (a_{ij})$ in $S$.
If $\varphi $ is surjective, then $E_k (\varphi (A)) = \varphi (E_k(A))$.

See <cit.>

For the rest of the appendix, we focus on the principal ideals of a principal ideal domain $R$ and its relations with the elementary ideals of a matrix whose entries are coming from $R$.

Let $R$ be a principal ideal domain and let $A$ be a matrix with entries in $R$.
Then there is an increasing sequence of principal ideals $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l)\not= R $
such that $A$ is equivalent to a diagonal square matrix with $(d_1, d_2, \ldots ,d_l) $ on the diagonal.

See <cit.>.

The principal ideals  $(d_i)$ in the previous proposition are called  invariant factors of the matrix $A$.
A generator of $(d_i)$ is unique up to an unit and the invariant factors are unique.
Note that the
principal ideals might be zero.
Let $r$ be the smallest non-negative integer such that $d_{r}=0$ and $d_{r+1} \not= 0$,
$d_0=0$ and $d_{l+1}=1$.
Then the smallest non-negative integer $r$ such that $d_{r}=0$ and $d_{r+1} \not= 0$
is called the rank of the matrix $A$.

Let $R$ be a principal ideal domain. Let $M$ be a matrix with entries in $R$
and invariant factors $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l)$.
Then $E_k(M)$ is generated by
$$\Delta_k:=\prod_{j=k+1}^l d_j.$$

Conversely, let $E_k(M)=(\Delta_k)$. Then $\Delta_{k-1}$ is divisible by  $\Delta_k$ and $d_k =\Delta_{k-1}/\Delta_k$ is the $k$-th invariant factor of $M$.

See <cit.>.

We conclude this appendix with the following proposition which in this paper is used in the principal ideal domains $R=\Z$ and $R=\F_p[T]$, and in their localizations; see Propositions <ref> and <ref>.

Let $R$ be a principal ideal domain.
Let $A$ be a matrix with entries in $R$ and invariant factors $(d_1)\subseteq (d_2)\subseteq \cdots \subseteq (d_l) $.
Let $d$ be a nonzero element of $R$ and let $a_i=\gcd (d,d_i)$ and $a_ib_i=d$.
Let $\overline{R}=R/(d)$ and $\overline{x}=x+(d) \in \overline{R}$ for $x\in R$.

\Ker (\overline{A})  \cong \overline{R}/(\overline{a_1}) \oplus \overline{R}/(\overline{a_2}) \oplus  \cdots \oplus  \overline{R}/(\overline{a_l}).

The matrix $A$ is equivalent to the diagonal matrix $B$ that has $(d_1,d_2, \ldots ,d_l)$ on its diagonal by Proposition <ref>.
Hence $\Ker (A ) \cong \Ker (B)$  by Proposition <ref>.
To prove the result it is enough to show it separately for each $d_i$ on the diagonal. Notice that $\overline{d_i}=\overline{a_i}$, since $a_i=\gcd (d,d_i)$.
Consider the sequence of $\overline{R}$-modules:

0\rightarrow (\overline{b_i})\overline{R} \rightarrow \overline{R} \rightarrow \overline{R} \rightarrow (\overline{b_i})\overline{R} \rightarrow 0

where the map $(\overline{b_i})\overline{R} \rightarrow \overline{R}$ is an inclusion, and $\overline{R} \rightarrow \overline{R}$ is given by multiplication by $\overline{a_i}$,
and the surjective map  $\overline{R} \rightarrow (\overline{b_i})\overline{R} $ is given by multiplication by $\overline{b_i}$.
This sequence is a chain complex, that is, the composition of two consecutive maps is zero, since $a_ib_i=d \equiv 0 \pmod d$.
But it is in fact an exact sequence: Consider the kernel of the multiplication by $\overline{a_i}$ and suppose that $\overline{x}\overline{a_i}=0$. Then $xa_i \equiv 0 \pmod d$, and thus $xa_i = yd$ for some $y\in R$. So $xa_i = ya_ib_i$, and consequently $x = yb_i$ since $R$ is an integral domain. Therefore $\overline{x} \in (\overline{b_i})\overline{R}$.

On the right hand, we have the sequence $ \overline{R} \rightarrow \overline{R} \rightarrow (\overline{b_i})\overline{R}$,
which is exact at the middle by a similar reasoning as before.
The cokernel of the multiplication by $\overline{a_i}$ is by definition equal to $\overline{R}/(\overline{a_i})$.
Hence $\overline{R}/(\overline{a_i})$ isomorphic to $(\overline{b_i})\overline{R}$. Therefore the statement on $\Ker (\overline{A})$ follows, as desired.