feat(InformationTheory): linear codes over finite fields and minimum distance properties#38014
feat(InformationTheory): linear codes over finite fields and minimum distance properties#38014cduenasnavarro wants to merge 8 commits intoleanprover-community:masterfrom
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 00dbc4ec64Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
✅ PR Title Formatted CorrectlyThe title of this PR has been updated to match our commit style conventions. |
https://github.com/cduenasnavarro/mathlib4 into my-feature-branch fix pr
…/mathlib4 into my-feature-branch
vihdzp
left a comment
There was a problem hiding this comment.
Cursory remarks, not all too familiar with the maths.
|
|
||
| namespace InformationTheory | ||
|
|
||
| variable (F : Type*) [Field F] [Fintype F] [DecidableEq F] |
There was a problem hiding this comment.
Why Fintype instead of Finite? And why DecidableEq?
| /-- An **$[n, k]_q$-linear code** is a $k$-dimensional subspace of $\mathbb{F}_q^n$. -/ | ||
| structure LinearCode (n k : ℕ) where | ||
| /-- The underlying $k$-dimensional subspace of $\mathbb{F}_q^n$, encoded as `Fin n → F`. -/ | ||
| space : Subspace F (Fin n → F) |
There was a problem hiding this comment.
I believe we might generally use carrier for something like this?
There was a problem hiding this comment.
This reminds me of Module.Grassmannian, which is defined by restricting the rank on the quotient, but there is a TODO to recover the alternative definition that restricts the rank on the space itself. Perhaps this is too far but I would like to see a unified definition of "collection of submodules of the same rank"
| /-- The **minimum distance** $d(C)$ of a code $C$ is the infimum of the Hamming weights of its | ||
| non-zero elements. -/ | ||
| noncomputable def minDist {n k : ℕ} (C : LinearCode F n k) : ℕ := | ||
| sInf {w | ∃ x : Fin n → F, x ∈ C.space ∧ x ≠ 0 ∧ w = hammingNorm x} |
There was a problem hiding this comment.
| sInf {w | ∃ x : Fin n → F, x ∈ C.space ∧ x ≠ 0 ∧ w = hammingNorm x} | |
| ⨅ {x : Fin n → F // x ∈ C.space ∧ x ≠ 0}, hammingNorm x.1 |
|
|
||
| /-- An **$[n, k, d]$-linear code** is an $[n, k]$-linear code with minimum distance at least | ||
| `d`. -/ | ||
| structure LinearCodeWithDist (n k d : ℕ) where |
There was a problem hiding this comment.
Does it make sense to extend LinearCode F n k?
| omit [Fintype F] in | ||
| /-- The minimum distance of a code coincides with the infimum of pairwise Hamming distances | ||
| between distinct codewords. -/ | ||
| lemma minDist_eq_sInf_pairwiseDist {n k : ℕ} (C : LinearCode F n k) : |
There was a problem hiding this comment.
Instead of a sInf theorem, I think it might be more reasonable to split this into two: a theorem minDist F C ≤ hammingDist x y, and a theorem ∃ x ∈ C.space, ∃ y ∈ C.space, x ≠ y ∧ hammingDist x y = minDist F C.
| rw [hammingDist_eq_hammingNorm x y] | ||
| exact hammingDist_zero_right (-x + y) | ||
|
|
||
| /-- The **Hamming sphere** $S_t(c)$ is the set of all vectors in $\mathbb{F}_q^n$ at Hamming |
There was a problem hiding this comment.
This seems suggestive of some kind of metric space... would it make sense to define a type alias for Fin n → F with the Hamming distance?
|
Happy to provide second opinion on the theory of error-correcting codes if needed (also feel free to ignore me as I am not a mathlib contributor). In terms of the theory these are the right first steps. Only questions to consider:
I assume you are working up to hamming bound, which is also the first result in the theory usually. |
|
oh also, |
|
|
||
| ## Main definitions | ||
|
|
||
| * `LinearCode`: An $[n, k]_q$-linear code, i.e., a $k$-dimensional subspace of $\mathbb{F}_q^n$. |
There was a problem hiding this comment.
| * `LinearCode`: An $[n, k]_q$-linear code, i.e., a $k$-dimensional subspace of $\mathbb{F}_q^n$. | |
| * `LinearCode`: An $[n, k]_q$-linear code, i.e., a $k$-dimensional subspace of $\mathbb{F}_{q^n}$. |
| namespace InformationTheory | ||
|
|
||
| variable (F : Type*) [Field F] [Fintype F] [DecidableEq F] | ||
| variable {q : ℕ} (hq : Fintype.card F = q) |
There was a problem hiding this comment.
It doesn't look like q and hq are used
| /-- An **$[n, k]_q$-linear code** is a $k$-dimensional subspace of $\mathbb{F}_q^n$. -/ | ||
| structure LinearCode (n k : ℕ) where | ||
| /-- The underlying $k$-dimensional subspace of $\mathbb{F}_q^n$, encoded as `Fin n → F`. -/ | ||
| space : Subspace F (Fin n → F) |
There was a problem hiding this comment.
This reminds me of Module.Grassmannian, which is defined by restricting the rank on the quotient, but there is a TODO to recover the alternative definition that restricts the rank on the space itself. Perhaps this is too far but I would like to see a unified definition of "collection of submodules of the same rank"
Define linear codes over a finite field
Fas finite-dimensional subspaces ofFin n → F,together with their minimum Hamming distance.
Main definitions:
LinearCodeminDistLinearCodeWithDisthammingSphereMain results:
minDist_eq_sInf_pairwiseDist: characterisation of the minimum distance via pairwise distancesdisjoint_spheres: Hamming spheres of radiustaround distinct codewords are disjointif
2 * t < dPending: