Basics of Coding Theory #
We define a general code C
to be a subset of n → R
for some finite index set n
and some
target type R
.
We can then specialize this notion to various settings. For [CommSemiring R]
, we define a linear
code to be a linear subspace of n → R
. We also define the notion of generator matrix and
(parity) check matrix.
Main Definitions #
dist C
: The Hamming distance of a codeC
, defined as the infimum (inℕ∞
) of the Hamming distances between any two distinct elements ofC
. This is noncomputable.dist' C
: A computable version ofdist C
, assumingC
is aFintype
.
We define the block length, rate, and distance of C
. We prove simple properties of linear codes
such as the singleton bound.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The Hamming distance of a code C
is the minimum Hamming distance between any two distinct
elements of the code.
cd
We formalize this as the infimum sInf
over all d : ℕ
such that there exist u v : n → R
in the
code with u ≠ v
and hammingDist u v ≤ d
. If none exists, then we define the distance to be 0
.
Instances For
Equations
Instances For
Equations
- Code.codeDistNew C = C.infsep
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The distance from a vector u
to a code C
is the minimum Hamming distance between u
and any element of C
.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable version of the Hamming distance of a code C
, assuming C
is a Fintype
.
The return type is ℕ∞
since we use Finset.min
.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The set of possible distances δf
between distinct codewords in a code C
.
- TODO: This allows us to express distance in non-ℝ, which is quite convenient.
Extending to
(E)Dist
forces this intoℝ
; give some thought.
Instances For
A generalisation of distFromCode
for an arbitrary distance function δf
.
Equations
- Code.distToCode w C δf h = (Code.possibleDistsToCode w C δf).toFinset.min
Instances For
Computable version of the distance from a vector u
to a code C
, assuming C
is a Fintype
.
Equations
- Δ₀'(u, C) = (Finset.image (fun (v : ↑C) => Δ₀(u, ↑v)) Finset.univ).min
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
δᵣ(u,v)
denotes the relative Hamming distance between vectors u
and v
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The range of the relative Hamming distance function.
Equations
- Code.relHammingDistRange ι = {d : ℚ≥0 | ∃ d' ≤ Fintype.card ι, d = ↑d' / ↑(Fintype.card ι)}
Instances For
The range of the relative Hamming distance is well-defined.
The range of the relative Hamming distance function is finite.
The set of possible distances between distinct codewords in a code.
Instances For
The set of possible distances between distinct codewords in a code is a subset of the range of the relative Hamming distance function.
The set of possible distances between distinct codewords in a code is a finite set.
The minimum relative Hamming distance of a code.
Equations
- (δᵣ C) = if h : (Code.possibleRelHammingDists C).Nonempty then (Code.possibleRelHammingDists C).toFinset.min' ⋯ else 0
Instances For
δᵣ C
denotes the minimum relative Hamming distance of a code C
.
Equations
- Code.termδᵣ_ = Lean.ParserDescr.node `Code.termδᵣ_ 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "δᵣ") (Lean.ParserDescr.cat `term 0))
Instances For
The range set of possible relative Hamming distances from a vector to a code is a subset of the range of the relative Hamming distance function.
The set of possible relative Hamming distances from a vector to a code is a finite set.
The relative Hamming distance from a vector to a code.
Equations
- δᵣ(w, C) = if h : (Code.possibleDistsToCode w C Code.relHammingDist).Nonempty then Option.get (Code.distToCode w C Code.relHammingDist ⋯) ⋯ else 0
Instances For
δᵣ(w,C)
denotes the relative Hamming distance between a vector w
and a code C
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The relative Hamming distances between a vector and a codeword is in the range of the relative Hamming distance function.
Singleton bound for arbitrary codes
Linear code defined by left multiplication by its generator matrix.
Equations
Instances For
Linear code defined by right multiplication by a generator matrix.
Equations
Instances For
Define a linear code from its (parity) check matrix
Equations
Instances For
The Hamming distance of a linear code can also be defined as the minimum Hamming norm of a non-zero vector in the code
Instances For
The dimension of a linear code.
Equations
- LC.dim = Module.finrank F ↥LC
Instances For
ρ LC
is the rate of the linear code LC
.
Equations
- LinearCode.termρ_ = Lean.ParserDescr.node `LinearCode.termρ_ 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "ρ") (Lean.ParserDescr.cat `term 0))
Instances For
The min distance of a linear code equals the minimum of the weights of non-zero codewords.
The interleaving of a linear code LC
over index set ι
is the submodule spanned by
ι × n
-matrices whose rows are elements of LC
.
Equations
Instances For
Equations
- LinearCode.«term_^⋈_» = Lean.ParserDescr.trailingNode `LinearCode.«term_^⋈_» 20 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "^⋈") (Lean.ParserDescr.cat `term 0))
Instances For
Equations
- LinearCode.«term_⋈_» = Lean.ParserDescr.trailingNode `LinearCode.«term_⋈_» 20 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "⋈") (Lean.ParserDescr.cat `term 0))
Instances For
Singleton bound for linear codes
A computable version of the Hamming distance of a linear code LC
.
Equations
- LC.linearCodeDist' = (Finset.image (fun (v : ↥LC) => ‖↑v‖₀) {v : ↥LC | v ≠ 0}).min