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.
Naming conventions #
- suffix
': computable/instantiation of the corresponding mathematical generic definitions without such suffix (e.g.Δ₀'(u, C)vsΔ₀(u, C),δᵣ'(u, C)vsδᵣ(u, C), ...) - NOTE: The generic (non-suffixed) definitions (Δ₀,δᵣ, ...) are recommended to be used in generic security statements, and the suffixed definitions (Δ₀',δᵣ', ...) are used for proofs or in statements of lemmas that need smaller value range. - We usually prove the equality as a bridge from the suffixed definitions into the non-suffixed definitions (e.g.distFromCode'_eq_distFromCode, ...)
Main Definitions #
- Distance between two words:
-
hammingDist u v (Δ₀(u, v)): The Hamming distance between two wordsuandv-relHammingDist u v (δᵣ(u, v)): The relative Hamming distance between two wordsuandv - Distance of code:
-
dist C (‖"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. - Distance from a word to a code:
-
distFromCode u C (Δ₀(u, C)): The hamming distance from a worduto a codeCdistFromCode_of_empty:Δ₀(u, ∅) = ⊤distFromCode_eq_top_iff_empty:Δ₀(u, C) = ⊤ ↔ C = ∅-distFromCode' u C (Δ₀'(u, C)): A computable version ofdistFromCode u C, assumingCis aFintype.distFromCode'_eq_distFromCode:Δ₀'(u, C) = Δ₀(u, C)-relDistFromCode u C (δᵣ(u, C)): The relative Hamming distance from a worduto a codeCrelDistFromCode' u C (δᵣ'(u, C)): A computable version ofrelDistFromCode u C, assumingCis aFintypeandCis non-empty.relDistFromCode'_eq_relDistFromCode:δᵣ'(u, C) = δᵣ(u, C)
- Switching between different distance realms:
-
relDistFromCode_eq_distFromCode_div:δᵣ(u, C) = Δ₀(u, C) / |ι|-pairDist_eq_distFromCode_iff_eq_relDistFromCode_div:Δ₀(u, v) = Δ₀(u, C) ↔ δᵣ(u, v) = δᵣ(u, C)-relDistFromCode_le_relDist_to_mem:δᵣ(u, C) ≤ δᵣ(u, v)-relCloseToCode_iff_relCloseToCodeword_of_minDist:δᵣ(u, C) ≤ δ ↔ ∃ v ∈ C, δᵣ(u, v) ≤ δ-pairRelDist_le_iff_pairDist_le:(δᵣ(u, v) ≤ δ) ↔ (Δ₀(u, v) ≤ Nat.floor (δ * Fintype.card ι))-distFromCode_le_iff_relDistFromCode_le:Δ₀(u, C) ≤ e ↔ δᵣ(u, C) ≤ (e : ℝ≥0) / (Fintype.card ι : ℝ≥0)-relDistFromCode_le_iff_distFromCode_le:δᵣ(u, C) ≤ δ ↔ Δ₀(u, C) ≤ Nat.floor (δ * Fintype.card ι)-relCloseToWord_iff_exists_possibleDisagreeCols-relCloseToWord_iff_exists_agreementCols-relDist_floor_bound_iff_complement_bound-distFromCode_le_dist_to_mem:Δ₀(u, C) ≤ Δ₀(u, v), given v ∈ C-distFromCode_le_card_index_of_Nonempty:Δ₀(u, C) ≤ |ι|, given C is non-empty - Unique decoding radius:
-
uniqueDecodingRadius C (UDR(C)): The unique decoding radius of a codeC-relativeUniqueDecodingRadius C (relUDR(C)): The relative unique decoding radius of a codeC-UDR_close_iff_exists_unique_close_codeword:Δ₀(u, C) ≤ UDR(C) ↔ ∃! v ∈ C, Δ₀(u, v) ≤ UDR(C)-UDRClose_iff_two_mul_proximity_lt_d_UDR:e ≤ UDR(C) ↔ 2 * e < ‖C‖₀-eq_of_le_uniqueDecodingRadius-UDR_close_iff_relURD_close:Δ₀(u, C) ≤ UDR(C) ↔ δᵣ(u, C) ≤ relUDR(C)-dist_le_UDR_iff_relDist_le_relUDR:e ≤ UDR(C) ↔ (e : ℝ≥0) / (Fintype.card ι : ℝ≥0) ≤ relUDR(C)
We define the block length, rate, and distance of C. We prove simple properties of linear codes
such as the singleton bound.
TODOs #
- Implement
ENNRat (ℚ≥0∞), for usage inrelDistFromCodeandrelDistFromCode', as counterpart ofENat (ℕ∞)indistFromCodeanddistFromCode'.
The Hamming distance of a code C is the minimum Hamming distance between any two distinct
elements of the code.
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
Instances For
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
Instances For
A non-trivial code (a code with at least two distinct codewords) must have a minimum distance greater than 0.
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.
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)Distforces this intoℝ; give some thought.
Instances For
A generalisation of distFromCode for an arbitrary distance function δf.
Instances For
Computable version of the distance from a vector u to a finite code C.