# GV-linear-code

In coding theory, the bound of parameters such as rate R, relative distance, block length, etc. is usually concerned. Here Gilbert–Varshamov bound theorem claims the lower bound of the rate of the general code. Gilbert–Varshamov bound is the best in terms of relative distance for codes over alphabets of size less than 49.[citation needed]

## Gilbert–Varshamov bound theorem

Theorem: Let ${\displaystyle q\geqslant 2}$. For every ${\displaystyle 0\leqslant \delta <1-{\tfrac {1}{q}}}$ and ${\displaystyle 0<\varepsilon \leqslant 1-H_{q}(\delta ),}$ there exists a code with rate ${\displaystyle R\geqslant 1-H_{q}(\delta )-\varepsilon }$ and relative distance ${\displaystyle \delta .}$

Here ${\displaystyle H_{q}}$ is the q-ary entropy function defined as follows:

${\displaystyle H_{q}(x)=x\log _{q}(q-1)-x\log _{q}x-(1-x)\log _{q}(1-x).}$

The above result was proved by Edgar Gilbert for general code using the greedy method as here. For linear code, Rom Varshamov proved using the probabilistic method for the random linear code. This proof will be shown in the following part.

High-level proof:

To show the existence of the linear code that satisfies those constraints, the probabilistic method is used to construct the random linear code. Specifically the linear code is chosen randomly by choosing the random generator matrix ${\displaystyle G}$ in which the element is chosen uniformly over the field ${\displaystyle \mathbb {F} _{q}^{n}}$. Also the Hamming distance of the linear code is equal to the minimum weight of the codeword. So to prove that the linear code generated by ${\displaystyle G}$ has Hamming distance ${\displaystyle d}$, we will show that for any ${\displaystyle m\in \mathbb {F} _{q}^{k}\backslash \left\{0\right\},wt(mG)\geq d}$ . To prove that, we prove the opposite one; that is, the probability that the linear code generated by ${\displaystyle G}$ has the Hamming distance less than ${\displaystyle d}$ is exponentially small in ${\displaystyle n}$. Then by probabilistic method, there exists the linear code satisfying the theorem.

Formal proof:

By using the probabilistic method, to show that there exists a linear code that has a Hamming distance greater than ${\displaystyle d}$, we will show that the probability that the random linear code having the distance less than ${\displaystyle d}$ is exponentially small in ${\displaystyle n}$.

We know that the linear code is defined using the generator matrix. So we use the "random generator matrix" ${\displaystyle G}$ as a mean to describe the randomness of the linear code. So a random generator matrix ${\displaystyle G}$ of size ${\displaystyle kn}$ contains ${\displaystyle kn}$ elements which are chosen independently and uniformly over the field ${\displaystyle \mathbb {F} _{q}}$.

Recall that in a linear code, the distance equals the minimum weight of the non-zero codeword. Let ${\displaystyle wt(y)}$ be the weight of the codeword ${\displaystyle y}$. So

{\displaystyle {\begin{aligned}P&=\Pr _{{\text{random }}G}({\text{linear code generated by }}G{\text{ has distance}}

The last equality follows from the definition: if a codeword ${\displaystyle y}$ belongs to a linear code generated by ${\displaystyle G}$, then ${\displaystyle y=mG}$ for some vector ${\displaystyle m\in \mathbb {F} _{q}^{k}}$.

By Boole's inequality, we have:

${\displaystyle P\leqslant \sum _{0\neq m\in \mathbb {F} _{q}^{k}}\Pr _{{\text{random }}G}(wt(mG)

Now for a given message ${\displaystyle 0\neq m\in \mathbb {F} _{q}^{k},}$ we want to compute

${\displaystyle W=\Pr _{{\text{random }}G}(wt(mG)

Let ${\displaystyle \Delta (m_{1},m_{2})}$ be a Hamming distance of two messages ${\displaystyle m_{1}}$ and ${\displaystyle m_{2}}$. Then for any message ${\displaystyle m}$, we have: ${\displaystyle wt(m)=\Delta (0,m)}$. Therefore:

${\displaystyle W=\sum _{\{y\in \mathbb {F} _{q}^{n}|\Delta (0,y)\leqslant d-1\}}\Pr _{{\text{random }}G}(mG=y)}$

Due to the randomness of ${\displaystyle G}$, ${\displaystyle mG}$ is a uniformly random vector from ${\displaystyle \mathbb {F} _{q}^{n}}$. So

${\displaystyle \Pr _{{\text{random }}G}(mG=y)=q^{-n}}$

Let ${\displaystyle {\text{Vol}}_{q}(r,n)}$ is a volume of Hamming ball with the radius ${\displaystyle r}$. Then:[1]

${\displaystyle P\leqslant q^{k}W=q^{k}\left({\frac {{\text{Vol}}_{q}(d-1,n)}{q^{n}}}\right)\leqslant q^{k}\left({\frac {q^{nH_{q}(\delta )}}{q^{n}}}\right)=q^{k}q^{-n(1-H_{q}(\delta ))}}$

By choosing ${\displaystyle k=(1-H_{q}(\delta )-\varepsilon )n}$, the above inequality becomes

${\displaystyle P\leqslant q^{-\varepsilon n}}$

Finally ${\displaystyle q^{-\varepsilon n}\ll 1}$, which is exponentially small in n, that is what we want before. Then by the probabilistic method, there exists a linear code ${\displaystyle C}$ with relative distance ${\displaystyle \delta }$ and rate ${\displaystyle R}$ at least ${\displaystyle (1-H_{q}(\delta )-\varepsilon )}$, which completes the proof.

1. The Varshamov construction above is not explicit; that is, it does not specify the deterministic method to construct the linear code that satisfies the Gilbert–Varshamov bound. The naive way that we can do is to go over all the generator matrices ${\displaystyle G}$ of size ${\displaystyle kn}$ over the field ${\displaystyle \mathbb {F} _{q}}$ and check if that linear code has the satisfied Hamming distance. That leads to the exponential time algorithm to implement it.