Is there any chance we can not only detect a single-bit error but also correct the error
to recover the original data?
Sure!
Here's how.
By increasing the Hamming distance between valid code words to 3, we guarantee that the
sets of code words produced by single-bit errors don't overlap.
The set of code words produced by corrupting 000 (100, 010, or 001) has no code words in
common with the set of code words produced by corrupting 111 (110, 101, or 011).
Assuming that at most one error occurred, we can deduce the original code word from
whatever code word we receive.
For example, if we receive 001, we deduce that the original code word was 000 and there
has been a single-bit error.
Again we can generalize this insight: if we want to correct up to E errors, the minimum
Hamming distance between valid code words must be at least 2E + 1.
For example, to correct single-bit errors we need valid code words with a minimum Hamming
distance of 3.
Coding theory is a research area devoted to developing algorithms to generate code words
that have the necessary error detection and correction properties.
You can take entire courses on this topic!
But we'll stop here with our basic insights: by choosing code words far enough apart (as
measured by Hamming distance) we can ensure that we can detect and even correct errors
that have corrupted our encoded data.
Pretty neat!