Documentation

CslibFrontier.Foundations.Data.Code.ParityCheck

Parity-check codes and binary linear codes #

A parity-check code over a commutative ring R is the kernel Cslib.Code.parityCheckCode H = LinearMap.ker H.mulVecLin of a parity-check matrix H : Matrix κ ι R MacWilliams and Sloane, Chapter 1. Over any finite commutative ring (including Bool and ZMod 2), its cardinality is at least |R| ^ (|ι| - |κ|) and its rate is at least 1 - |κ| / |ι| (pow_sub_le_card_parityCheckCode, one_sub_card_div_card_le_rate_parityCheckCode); over a field F, its dimension satisfies H.rank + finrank F (parityCheckCode H) = |ι| (finrank_parityCheckCode_add_rank).

Shortening parityCheckCode H along an embedding emb : κ' ↪ ι yields parityCheckCode (H.submatrix id emb) (shortenLinear_parityCheckCode). For binary parity-check matrices H : Matrix κ ι Bool, the computable ring isomorphism Cslib.BitString.bitEquiv transfers dimension, cardinality 2 ^ dim, and rate from ZMod 2 (card_parityCheckCode_bool_eq_two_pow_finrank, rate_parityCheckCode_bool).

Main definitions #

Main results #

References #

def Cslib.Code.parityCheckCode {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] (H : Matrix κ ι R) :
Submodule R (ι → R)

The parity-check code of H : Matrix κ ι R: the submodule of words x satisfying H *ᵥ x = 0.

def Cslib.Code.syndrome {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] (H : Matrix κ ι R) (x : ι → R) :
κ → R

The syndrome of x under parity-check matrix H.

@[simp]
theorem Cslib.Code.syndrome_eq {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] (H : Matrix κ ι R) (x : ι → R) :
syndrome H x = H.mulVec x

The syndrome of x under H is H *ᵥ x.

@[simp]
theorem Cslib.Code.mem_parityCheckCode {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] {H : Matrix κ ι R} {x : ι → R} :

A word lies in parityCheckCode H iff its syndrome vanishes.

@[instance_reducible]
instance Cslib.Code.instDecidableMemParityCheckCode {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] [Fintype κ] [DecidableEq R] (H : Matrix κ ι R) :
DecidablePred fun (x : ι → R) => x ∈ parityCheckCode H
theorem Cslib.Code.mem_parityCheckCode_iff_forall_dotProduct {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] {H : Matrix κ ι R} {x : ι → R} :
x ∈ parityCheckCode H ↔ ∀ (i : κ), H i ⬝ᵥ x = 0

A word lies in parityCheckCode H iff it is orthogonal to every row of H.

Over a finite commutative ring R, |R| ^ |ι| ≤ |parityCheckCode H| * |R| ^ |κ|.

theorem Cslib.Code.pow_sub_le_card_parityCheckCode {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] [Fintype κ] [Fintype R] (H : Matrix κ ι R) :

Over a finite commutative ring R, |R| ^ (|ι| - |κ|) ≤ |parityCheckCode H|.

theorem Cslib.Code.one_sub_card_div_card_le_rate_parityCheckCode {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] [Fintype κ] [Fintype R] [Nontrivial R] (hι : 0 < Fintype.card ι) (H : Matrix κ ι R) :

Over a finite nontrivial commutative ring R, rate (parityCheckCode H) ≥ 1 - |κ| / |ι|.

theorem Cslib.Code.lt_minDist_parityCheckCode_iff {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] [DecidableEq R] (H : Matrix κ ι R) {r : ℕ} :
↑r < minDist ↑(parityCheckCode H) ↔ ∀ (x : ι → R), x ≠ 0 → H.mulVec x = 0 → r < hammingNorm x

The minimum distance of parityCheckCode H exceeds r iff every nonzero word in the kernel of H has Hamming weight more than r.

theorem Cslib.Code.mulVec_extend {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] {κ' : Type u_4} [Fintype κ'] (H : Matrix κ ι R) (emb : κ' ↪ ι) (z : κ' → R) :
H.mulVec (extend emb z) = (H.submatrix id ⇑emb).mulVec z

Multiplying H by the zero-extension of z along emb equals multiplying the column-restricted matrix H.submatrix id emb by z.

theorem Cslib.Code.shortenLinear_parityCheckCode {κ : Type u_1} {ι : Type u_2} {R : Type u_3} [Fintype ι] [CommRing R] {κ' : Type u_4} [Fintype κ'] (H : Matrix κ ι R) (emb : κ' ↪ ι) :

Shortening parityCheckCode H along emb gives parityCheckCode (H.submatrix id emb).

theorem Cslib.Code.finrank_parityCheckCode_add_rank {κ : Type u_1} {ι : Type u_2} {F : Type u_3} [Fintype ι] [Field F] (H : Matrix κ ι F) :

Over a field F, rank-nullity for H : Matrix κ ι F: H.rank + dim F (parityCheckCode H) = |ι|.

theorem Cslib.Code.card_le_finrank_parityCheckCode_add {κ : Type u_1} {ι : Type u_2} {F : Type u_3} [Fintype ι] [Field F] [Fintype κ] (H : Matrix κ ι F) :

Over a field F with finitely many checks κ, |ι| ≤ dim F (parityCheckCode H) + |κ|.

Over a field F, the dual code orthogonal (parityCheckCode H) is the row space of H.

submoduleZModIso maps a Boolean parity-check code parityCheckCode H to parityCheckCode (H.map bitEquiv.symm).

Rank-nullity for a Boolean parity-check matrix H : Matrix κ ι Bool: rank (H.map bitEquiv.symm) + dim Bool (parityCheckCode H) = |ι|.

Over Bool, the dual code orthogonal (parityCheckCode H) is the row space of H.

theorem Cslib.Code.mem_parityCheckCode_zmodTwo_iff {κ : Type u_1} {ι : Type u_2} [Fintype ι] (H : Matrix κ ι Bool) (x : ι → Bool) :

Membership in a Boolean parity-check code parityCheckCode H is equivalent to membership in the corresponding ZMod 2 parity-check code under bitEquiv.symm.

A binary parity-check code parityCheckCode H (Bool) has cardinality 2 ^ dim matching its ZMod 2 partner.

The rate of a binary parity-check code parityCheckCode H equals its ZMod 2 dimension divided by |ι|.