Documentation

ArkLib.Data.CodingTheory.Basic.LinearCode

Linear-Code Constructions and Bounds #

This module contains weight/projection lemmas, the singleton bound for arbitrary and linear codes, and basic constructions and dimension/rate facts for linear codes.

References #

def Code.wt {F : Type u_3} [DecidableEq F] {ι : Type u_4} [Fintype ι] [Zero F] (v : ιF) :
Instances For
    theorem Code.wt_eq_hammingNorm {F : Type u_3} [DecidableEq F] {ι : Type u_4} [Fintype ι] [Zero F] {v : ιF} :
    theorem Code.wt_eq_zero_iff {F : Type u_3} [DecidableEq F] {ι : Type u_4} [Fintype ι] [Zero F] {v : ιF} :
    wt v = 0 Fintype.card ι = 0 ∀ (i : ι), v i = 0
    def projection {n : Type u_1} {R : Type u_2} (S : Finset n) (w : nR) :
    SR
    Instances For
      theorem projection_injective {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) (nontriv : C‖₀ 1) (S : Finset n) (hS : Fintype.card S = Fintype.card n - (C‖₀ - 1)) (u v : nR) (hu : u C) (hv : v C) :
      projection S u = projection S vu = v
      theorem singleton_bound {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] [Finite R] (C : Set (nR)) :

      Singleton bound for arbitrary codes

      @[reducible, inline]
      abbrev ModuleCode (ι : Type u) (F : Type v) [Semiring F] (A : Type w) [AddCommMonoid A] [Module F A] :
      Type (max u w)

      A ModuleCode ι F A is an F-linear code of length indexed by ι over the alphabet A, defined as an F-submodule of ι → A.

      Instances For
        @[reducible, inline]
        abbrev LinearCode (ι : Type u) [Fintype ι] (F : Type v) [Semiring F] :
        Type (max u v)
        Instances For
          theorem LinearCode_is_ModuleCode {ι : Type u} [Fintype ι] {F : Type v} [Semiring F] :
          LinearCode ι F = ModuleCode ι F F
          noncomputable def LinearCode.disFromHammingNorm {F : Type u_3} {ι : Type u_5} [Fintype ι] [Semiring F] [DecidableEq F] (LC : LinearCode ι F) :

          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
            noncomputable def LinearCode.dim {F : Type u_3} {ι : Type u_5} [Semiring F] {A : Type u_7} [AddCommMonoid A] [Module F A] (MC : ModuleCode ι F A) :

            The dimension of a linear code.

            Instances For
              def LinearCode.length {F : Type u_3} {ι : Type u_5} [Fintype ι] [Semiring F] {A : Type u_7} [AddCommMonoid A] [Module F A] :
              ModuleCode ι F A

              The length of a linear code.

              Instances For
                noncomputable def LinearCode.rate {F : Type u_3} {ι : Type u_5} [Fintype ι] [Semiring F] {A : Type u_7} [AddCommMonoid A] [Module F A] (MC : ModuleCode ι F A) :

                The rate of a linear code.

                Instances For

                  ρ LC is the rate of the linear code LC.

                  Uses & to make the notation non-reserved, allowing ρ to also be used as a variable name.

                  Instances For
                    def LinearCode.projectedWord {F : Type u_3} {ι : Type u_5} [Fintype ι] (c : ιF) (T : Finset ι) :
                    TF

                    Let c be a word of length ι. For every finite ι-subset T , we define the projection of a word c to T as the word obtained by restricting the indexing set of c to T. We denote this by c|[T]. Definition 3.7 [BCGM25].

                    Instances For
                      def LinearCode.projectedCode {F : Type u_3} {ι : Type u_5} [Fintype ι] (C : Set (ιF)) (T : Finset ι) :
                      Set (TF)

                      Let C be a code of length ι. For every finite ι-subset T, we define the projected code C|[T] as the set of projected codewords c|[T], for c ∈ C. Definition 3.7 [BCGM25].

                      Instances For
                        theorem LinearCode.projectedCode_linearCombination {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) (T : Finset ι) {α : Type} [Fintype α] (U : αιF) (c : αF) (hU : ∀ (j : α), U j|[T] LC.carrier|[T]) :
                        (fun (k : ι) => j : α, c j * U j k)|[T] LC.carrier|[T]

                        Let T be a finite subset of ι. If every word in a collection lies in the projected code C|[T], then so do all F-linear combinations of these.

                        def LinearCode.IsMDS {F : Type u_3} {ι : Type} [Fintype ι] [CommRing F] [DecidableEq F] (LC : LinearCode ι F) :

                        A linear code is maximum distance separable (MDS) if its parameters meet the singleton bound.

                        Instances For
                          theorem LinearCode.linear_code_is_FG {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) :

                          Every linear code over a field F is a finitely generated F-module.

                          noncomputable def LinearCode.fromRowGenMat {F : Type u_3} {ι : Type u_5} [Fintype ι] {κ : Type u_6} [Fintype κ] [Semiring F] (G : Matrix κ ι F) :

                          Module code defined by left multiplication by its generator matrix. For a matrix G : Matrix κ ι F (over field F) and module A over F, this generates the F-submodule of (ι → A) spanned by the rows of G acting on (κ → A). The matrix acts on vectors v : κ → A by : (G • v)(i) = ∑ k, G k i • v k where G k i : F is the scalar and v k : A is the module element.

                          Instances For
                            noncomputable def LinearCode.fromColGenMat {F : Type u_3} {ι : Type u_5} [Fintype ι] {κ : Type u_6} [Fintype κ] [CommRing F] (G : Matrix ι κ F) :

                            Linear code defined by right multiplication by a generator matrix.

                            Instances For
                              noncomputable def LinearCode.byCheckMatrix {F : Type u_3} {ι : Type u_5} {κ : Type u_6} [Fintype κ] [CommRing F] (H : Matrix ι κ F) :

                              Define a linear code from its (parity) check matrix

                              Instances For
                                theorem LinearCode.gen_matrix_exists {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) :
                                ∃ (G : Matrix (Fin (dim LC)) ι F), LC = fromRowGenMat G

                                Given a linear code of length ι and dimension dim over a field F, there exists a dim × ι matrix over F which generates the code. Theorem 2.2.7 [GRS25].

                                noncomputable def LinearCode.matrixFromBasis {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) :
                                Matrix (Fin (dim LC)) ι F

                                A matrix whose rows are a basis of a linear code over a field F.

                                Instances For
                                  theorem LinearCode.eq_span_rows {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) :

                                  A linear code is equal to the submodule spanned by the rows of the matrix whose rows form a basis of the code.

                                  A linear code is equal to the code generated by the rows of the matrix constructed from a basis of the code. Note: eq_span_rows is good for linear-algebra-style reasoning, whereas eq_fromRowGenMat_matrixFromBasis is essentially a coding theory language restatement of it.

                                  theorem LinearCode.rank_genMatrix_eq_dim {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) :

                                  The rank of the generator matrix equals the dimension of the linear code.

                                  theorem LinearCode.dim_fromRowGenMat {F : Type u_3} {k n : } [Field F] {G : Matrix (Fin k) (Fin n) F} :

                                  The dimension of the linear code given by a generator matrix is the rank of the matrix.

                                  noncomputable def LinearCode.genMatrixCols {F : Type u_3} {ι : Type u_5} [Fintype ι] [Field F] (LC : LinearCode ι F) :
                                  Matrix ι (Fin (dim LC)) F

                                  Given a linear code of length ι and dimension dim over a field F, we define its ι × dim generator matrix as a matrix whose columns are an F-basis of the code.

                                  Instances For
                                    theorem LinearCode.rank_eq_dim_fromColGenMat {F : Type u_3} {ι : Type u_5} [Fintype ι] {κ : Type u_6} [Fintype κ] [CommRing F] {G : Matrix κ ι F} :

                                    The dimension of a linear code equals the rank of its associated generator matrix.

                                    noncomputable def LinearCode.minWtCodewords {F : Type u_3} {ι : Type u_4} [Fintype ι] {A : Type u_5} [AddCommMonoid A] [DecidableEq A] [Semiring F] [Module F A] (MC : ModuleCode ι F A) :

                                    The minimum taken over the weight of codewords in a linear code.

                                    Instances For
                                      theorem LinearCode.hammingDist_eq_wt_sub {F : Type u_3} [DecidableEq F] {ι : Type u_4} [Fintype ι] [AddCommGroup F] {u v : ιF} :
                                      Δ₀(u, v) = Code.wt (u - v)

                                      The Hamming distance between codewords equals to the weight of their difference.

                                      theorem LinearCode.dist_eq_minWtCodewords {F : Type u_3} {ι : Type u_4} [Fintype ι] [Ring F] {A : Type u_6} [DecidableEq A] [AddCommGroup A] [Module F A] {MC : ModuleCode ι F A} :

                                      The min distance of a linear code equals the minimum of the weights of non-zero codewords.

                                      theorem LinearCode.dist_UB {F : Type u_3} {ι : Type u_4} [Fintype ι] [Ring F] {A : Type u_6} [DecidableEq A] [AddCommGroup A] [Module F A] {MC : ModuleCode ι F A} :
                                      noncomputable def LinearCode.restrictLinear {F : Type u_3} {ι : Type u_4} {A : Type u_5} [AddCommMonoid A] [Semiring F] [Module F A] (S : Finset ι) :
                                      (ιA) →ₗ[F] SA
                                      Instances For
                                        theorem LinearCode.singletonBound {F : Type u_3} [DecidableEq F] {ι : Type u_4} [Fintype ι] [CommRing F] [StrongRankCondition F] (LC : LinearCode ι F) :
                                        dim LC length LC - Code.minDist LC + 1

                                        Singleton bound for linear codes

                                        def LinearCode.moduleCodeDist' {F : Type u_3} {A : Type u_4} {ι : Type u_5} [Fintype ι] [Semiring F] [Fintype A] [DecidableEq ι] [DecidableEq A] [AddCommMonoid A] [Module F A] (MC : ModuleCode ι F A) [DecidablePred fun (x : ιA) => x MC] :

                                        A computable version of the Hamming distance of a module code MC.

                                        Instances For
                                          theorem poly_eq_zero_of_dist_lt {n k : } {F : Type u_3} [DecidableEq F] [CommRing F] [IsDomain F] {p : Polynomial F} {ωs : Fin nF} (h_deg : p.natDegree < k) (hn : k n) (h_inj : Function.Injective ωs) (h_dist : Δ₀((fun (x : F) => Polynomial.eval x p) ωs, 0) < n - k + 1) :
                                          p = 0