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 #
codeDist 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.codeDist' C
: A computable version ofcodeDist 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
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
- Distance.distToCode w C δf h = (Distance.possibleDistsToC 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
Define a linear code from its 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
A computable version of the Hamming distance of a linear code C
.
Equations
- linearCodeDist' C = (Finset.image (fun (v : ↥C) => ‖↑v‖₀) {v : ↥C | v ≠ 0}).min
Instances For
The interleaving of a linear code C
over index set ι
is the submodule spanned by
ι × n
-matrices whose rows are elements of C
.
Equations
Instances For
Equations
- «term_^⋈_» = Lean.ParserDescr.trailingNode `«term_^⋈_» 20 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "^⋈") (Lean.ParserDescr.cat `term 0))
Instances For
Equations
- «term_⋈_» = Lean.ParserDescr.trailingNode `«term_⋈_» 20 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "⋈") (Lean.ParserDescr.cat `term 0))
Instances For
Singleton bound for arbitrary codes
Singleton bound for linear codes
δᵣ(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
- RelativeHamming.relHammingDistRange ι = {d : ℚ | ∃ 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 : (RelativeHamming.possibleDists C).Nonempty then (RelativeHamming.possibleDists C).toFinset.min' ⋯ else 0
Instances For
δᵣ C
denotes the minimum relative Hamming distance of a code C
.
Equations
- RelativeHamming.termδᵣ_ = Lean.ParserDescr.node `RelativeHamming.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 : (Distance.possibleDistsToC w C RelativeHamming.dist).Nonempty then Option.get (Distance.distToCode w C RelativeHamming.dist ⋯) ⋯ 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.
Equations
- LinearCode.wt v = {i : ι | v i ≠ 0}.card
Instances For
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
Equations
- LC.dim = Module.finrank F ↥LC
Instances For
Equations
- x✝.length = Fintype.card ι
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 minimum taken over the weight of codewords in a linear code.
Instances For
The min distance of a linear code equals to the minimum of the weights of non-zero codewords.