Documentation

ArkLib.Data.CodingTheory.Basic

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 #

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
      noncomputable def codeDist {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) :

      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.

      Equations
      Instances For
        instance instEDistForall_arkLib {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] :
        EDist (nR)
        Equations
        instance instDistForall_arkLib {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] :
        Dist (nR)
        Equations
        noncomputable def eCodeDistNew {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) :
        Equations
        Instances For
          noncomputable def codeDistNew {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) :
          Equations
          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              noncomputable def distFromCode {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (u : nR) (C : Set (nR)) :

              The distance from a vector u to a code C is the minimum Hamming distance between u and any element of C.

              Equations
              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[simp]
                  theorem codeDist_empty {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] :
                  @[simp]
                  theorem codeDist_subsingleton {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] {C : Set (nR)} [Subsingleton C] :
                  @[simp]
                  theorem codeDist_le_card {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) :
                  theorem eq_of_lt_codeDist {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] {C : Set (nR)} {u v : nR} (hu : u C) (hv : v C) (huv : Δ₀(u, v) < C‖₀) :
                  u = v

                  If u and v are two codewords of C with distance less than codeDist C, then they are the same.

                  @[simp]
                  theorem distFromCode_of_empty {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (u : nR) :
                  theorem distFromCode_eq_top_iff_empty {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (u : nR) (C : Set (nR)) :
                  @[simp]
                  theorem distFromCode_of_mem {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) {u : nR} (h : u C) :
                  Δ₀(u, C) = 0
                  theorem distFromCode_eq_zero_iff_mem {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) (u : nR) :
                  Δ₀(u, C) = 0 u C
                  theorem distFromCode_eq_of_lt_half_codeDist {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) (u : nR) {v w : nR} (hv : v C) (hw : w C) (huv : Δ₀(u, v) < C‖₀ / 2) (hvw : Δ₀(u, w) < C‖₀ / 2) :
                  v = w
                  def codeDist' {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) [Fintype C] :

                  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
                      @[simp]
                      theorem codeDist'_empty {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] :
                      @[simp]
                      theorem codeDist'_subsingleton {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] {C : Set (nR)} [Fintype C] [Subsingleton C] :
                      theorem codeDist'_eq_codeDist {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] {C : Set (nR)} [Fintype C] :
                      def distFromCode' {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] (C : Set (nR)) [Fintype C] (u : nR) :

                      Computable version of the distance from a vector u to a code C, assuming C is a Fintype.

                      Equations
                      Instances For
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def codeByGenMatrix {n : Type u_1} {R : Type u_2} {k : Type u_3} [Fintype k] [CommSemiring R] (G : Matrix k n R) :
                          Submodule R (nR)

                          Define a linear code from its generator matrix

                          Equations
                          Instances For
                            def codeByCheckMatrix {n : Type u_1} [Fintype n] {R : Type u_2} {k : Type u_3} [CommSemiring R] (H : Matrix k n R) :
                            Submodule R (nR)

                            Define a linear code from its (parity) check matrix

                            Equations
                            Instances For
                              noncomputable def linearCodeDist {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] [CommSemiring R] (C : Submodule R (nR)) :

                              The Hamming distance of a linear code can also be defined as the minimum Hamming norm of a non-zero vector in the code

                              Equations
                              Instances For
                                def linearCodeDist' {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] [CommSemiring R] [DecidableEq n] [Fintype R] (C : Submodule R (nR)) [DecidablePred fun (x : nR) => x C] :

                                A computable version of the Hamming distance of a linear code C.

                                Equations
                                Instances For
                                  def interleaveCode {n : Type u_1} {R : Type u_2} [CommSemiring R] (C : Submodule R (nR)) (ι : Type u_4) :
                                  Submodule R (ι × nR)

                                  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
                                    def Function.interleave₂ {α : Type u_4} {β : Type u_5} (u v : αβ) :
                                    Fin 2 × αβ

                                    Interleave two functions u v : α → β.

                                    Equations
                                    Instances For
                                      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

                                      theorem singleton_bound_linear {n : Type u_1} [Fintype n] {R : Type u_2} [DecidableEq R] [Finite R] [DivisionRing R] (C : Submodule R (nR)) :

                                      Singleton bound for linear codes