TCSLib

1 Coding Theory — Core Definitions

1.1 Overview

This file documents the foundational definitions for \(q\)-ary block codes over a finite field alphabet \(\alpha \). Throughout, \(\alpha \) is a type carrying instances , , , and .

1.2 Basic objects: codewords and codes

1.2.1 Codewords

Definition 1.1 Codeword
#

A codeword of length \(n\) over alphabet \(\alpha \) is a function \(c : \mathrm{Fin}\, n \to \alpha \).

Definition 1.2 Pointwise operations
#

Pointwise addition, subtraction, and the all-zero codeword.

1.2.2 Codes and linear codes

Definition 1.3 Code
#

A (block) code of length \(n\) over \(\alpha \) is a finite set () of codewords.

Definition 1.4 Linear code via generator matrix
#

A code \(C\) is linear with generator matrix \(G\) (shape \(n\times m\)) if every message \(c':\mathrm{Fin}\, m\to \alpha \) maps to a codeword \(Gc'\in C\), and every codeword in \(C\) arises this way.

Definition 1.5 Linear code, existential form
#

Existential version: there exists some \(m\) and generator matrix \(G\) witnessing linearity.

1.3 Distance, weight, and rate

Definition 1.6 \(q\)-ary entropy
#
\[ H_q(p) \; =\; p\log _q(q-1) - p\log _q p - (1-p)\log _q(1-p). \]
Definition 1.7 Hamming distance
#

Hamming distance between two codewords, wrapping Mathlib’s .

Definition 1.8 Distance predicate for a code
#

holds when \(d\) is the minimum Hamming distance of \(C\): there exist distinct codewords at distance exactly \(d\), and no two distinct codewords are closer than \(d\).

Definition 1.9 Rate
#
\[ R(C) = \frac{\log |C|}{n\log |\alpha |}. \]
Definition 1.10 Weight
#

The Hamming weight of \(c\) is \(d(c, \mathbf{0})\).

Definition 1.11 Maximal size at distance
#

asserts existence of a code of size \(A\) and minimum distance \(d\) that is maximal among all such codes.

Definition 1.12 Hamming ball
#

The Hamming ball of radius \(l\) around \(c\):

\[ B_l(c) = \{ c' : d(c',c) \le l\} , \]

implemented as a .

1.4 Basic lemma: distance vs. block length

Lemma 1.13 Distance is at most block length
#

If a code \(C\) has minimum distance \(d\), then \(d \le n\).