Randomized algorithm
Consider the received word
which was corrupted by a noisy channel. The following is the algorithm description for the general case. In this algorithm, we can decode y by just declaring an erasure at every bad position and running the errors and erasure decoding algorithm for
on the resulting vector.
Randomized_Decoder
Given :
.
- For every
, compute
.
- Set
.
- For every
, repeat : With probability
, set ?,}
otherwise set
.
- Run errors and erasure algorithm for
on
.
Theorem 1. Let y be a received word such that there exists a codeword
such that
. Then the deterministic GMD algorithm outputs
.
Note that a naive decoding algorithm for concatenated codes can correct up to
errors.
- Lemma 1. Let the assumption in Theorem 1 hold. And if
has
errors and
erasures (when compared with
) after Step 1, then ![{\displaystyle \mathbb {E} [2e'+s']<D.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/504bbe8ae8fbbd701e22fdc916b9da981a3d91c7)
Remark. If
, then the algorithm in Step 2 will output
. The lemma above says that in expectation, this is indeed the case. Note that this is not enough to prove Theorem 1, but can be crucial in developing future variations of the algorithm.
Proof of lemma 1. For every
define
This implies that
Next for every
, we define two indicator variables:
?\end{aligned}}}
We claim that we are done if we can show that for every
:
Clearly, by definition
Further, by the linearity of expectation, we get
To prove (2) we consider two cases:
-th block is correctly decoded (Case 1),
-th block is incorrectly decoded (Case 2):
Case 1: 
Note that if
then
, and
implies
and
.
Further, by definition we have
Case 2: 
In this case,
and ![{\displaystyle \mathbb {E} [X_{i}^{e}]=\Pr[X_{i}^{e}=1]=1-{\tfrac {2\omega _{i}}{d}}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/618724c3e59f7524419397d248965e589155e8d7)
Since
. This follows another case analysis when
or not.
Finally, this implies
In the following sections, we will finally show that the deterministic version of the algorithm above can do unique decoding of
up to half its design distance.
Modified randomized algorithm
Note that, in the previous version of the GMD algorithm in step "3", we do not really need to use "fresh" randomness for each
. Now we come up with another randomized version of the GMD algorithm that uses the same randomness for every
. This idea follows the algorithm below.
Modified_Randomized_Decoder
Given :
, pick
at random. Then every for every
:
- Set
.
- Compute
.
- If
, set ?,}
otherwise set
.
- Run errors and erasure algorithm for
on
.
For the proof of Lemma 1, we only use the randomness to show that
In this version of the GMD algorithm, we note that
The second equality above follows from the choice of
. The proof of Lemma 1 can be also used to show
for version2 of GMD. In the next section, we will see how to get a deterministic version of the GMD algorithm by choosing
from a polynomially sized set as opposed to the current infinite set
.
Deterministic algorithm
Let
. Since for each
, we have
where
for some
. Note that for every
, the step 1 of the second version of randomized algorithm outputs the same
. Thus, we need to consider all possible value of
. This gives the deterministic algorithm below.
Deterministic_Decoder
Given :
, for every
, repeat the following.
- Compute
for
.
- Set
for every
.
- If
, set ?,}
otherwise set
.
- Run errors-and-erasures algorithm for
on
. Let
be the codeword in
corresponding to the output of the algorithm, if any.
- Among all the
output in 4, output the one closest to 
Every loop of 1~4 can be run in polynomial time, the algorithm above can also be computed in polynomial time. Specifically, each call to an errors and erasures decoder of
errors takes
time. Finally, the runtime of the algorithm above is
where
is the running time of the outer errors and erasures decoder.