Added ECC handout
This commit is contained in:
		
							
								
								
									
										164
									
								
								Advanced/Error-Correcting Codes/parts/00 detection.tex
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										164
									
								
								Advanced/Error-Correcting Codes/parts/00 detection.tex
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,164 @@ | ||||
| \section{Error Detection} | ||||
|  | ||||
| An ISBN\footnote{International Standard Book Number} is a unique numeric book identifier. It comes in two forms: ISBN-10 and ISBN-13. Naturally, ISBN-10s have ten digits, and ISBN-13s have thirteen. The final digit in both versions is a \textit{check digit}. | ||||
|  | ||||
| \vspace{3mm} | ||||
|  | ||||
| Say we have a sequence of nine digits, forming a partial ISBN-10: $n_1 n_2 ... n_9$. \\ | ||||
| The final digit, $n_{10}$, is calculated as follows: | ||||
|  | ||||
| $$ | ||||
| 	\Biggr( \sum_{i = 1}^{9} i \times n_i \Biggl) \text{ mod } 11 | ||||
| $$ | ||||
|  | ||||
| If $n_{10}$ is equal to 10, it is written as \texttt{X}. | ||||
|  | ||||
|  | ||||
| \problem{} | ||||
| Which of the following could be valid ISBNs? | ||||
|  | ||||
| \begin{itemize} | ||||
| 	\item \texttt{0-134-54896-2} | ||||
| 	\item \texttt{0-307-29206-3} | ||||
| 	\item \texttt{0-316-00395-6} | ||||
| \end{itemize} | ||||
|  | ||||
| \begin{solution} | ||||
| 	Only the first has an inconsistent check digit. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
| \pagebreak | ||||
|  | ||||
| \problem{} | ||||
| Show that the following sum is divisible by 11 iff $n_1n_2...n_{10}$ is a valid ISBN-10. | ||||
| $$ | ||||
| 	\sum_{i = 1}^{10} (11 - i)n_i | ||||
| $$ | ||||
|  | ||||
| \begin{solution} | ||||
| 	Proof that valid $\implies$ divisible, working in mod 11: | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	$10n_1 + 9n_2 + ... + 2n_9 + n_{10} \equiv$ \\ | ||||
| 	$(-n_1) + (-2n_2) + ... + (-9n_9) + n_{10} =$ \\ | ||||
| 	$-n_{10} + n_{10} \equiv 0$ | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Having done this, the rest is easy. Work in reverse, or note that each step above is an iff. | ||||
|  | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-10 and change one digit. Is it possible that you get another valid ISBN-10? \\ | ||||
| Provide an example or a proof. | ||||
|  | ||||
| \begin{solution} | ||||
| 	Let $S$ be the sum $10n_1 + 9n_2 + ... + 2n_9 + n_{10}$, before any digits are changed. | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	If you change one digit of the ISBN, $S$ changes by $km$, where $k \in \{1,2,...,10\}$ and $|m| \leq 10$. \\ | ||||
| 	$k$ and $m$ cannot be divisible by 11, thus $km$ cannot be divisible by 11. | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	We know that $S \equiv 0 \text{ (mod 11)}$. \\ | ||||
| 	After the change, the checksum is $S + km \equiv km \not\equiv 0 \text{ (mod 11)}$. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-10 and swap two adjacent digits. When will the result be a valid ISBN-10? \\ | ||||
| This is called a \textit{transposition error}. | ||||
|  | ||||
|  | ||||
| \begin{solution} | ||||
| 	Let $n_1n_2...n_{10}$ be a valid ISBN-10. \\ | ||||
| 	When we swap $n_i$ and $n_{i+1}$, we subtract $n_i$ and add $n_{i+1}$ to the checksum. | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	If the new ISBN is to be valid, we must have that $n_{i+1} - n_i \equiv 0 \text{ (mod 11)}$. \\ | ||||
| 	This is impossible unless $n_i = n_{i+1}$. Figure out why yourself. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
| \pagebreak | ||||
|  | ||||
| \problem{} | ||||
| ISBN-13 error checking is slightly different. Given a partial ISBN-13 $n_1 n_2 n_3 ... n_{12}$, the final digit is given by | ||||
|  | ||||
| $$ | ||||
|  n_{13} = \Biggr[ \sum_{i=1}^{12} n_i \times (2 + (-1)^i) \Biggl] \text{ mod } 10 | ||||
| $$ | ||||
|  | ||||
| What is the last digit of the following ISBN-13? \\ | ||||
| \texttt{978-0-380-97726-?} | ||||
|  | ||||
| \begin{solution} | ||||
| 	The final digit is 0. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-13 and change one digit. Is it possible that you get another valid ISBN-13? \\ | ||||
| Provide an example or a proof. | ||||
|  | ||||
| \begin{solution} | ||||
| 	Let $n_1n_2...n_{13}$ be a valid ISBN-13. Choose some $n_i$ and change it to $m_i$. \\ | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	Since $n_i$, $m_i$ $\in \{0, 1, 2, ..., 9\}$, $-9 \leq n_i - m_i \leq 9$. \\ | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Case 0: $i$ is 13 \\ | ||||
| 	This is trivial. | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Case 1: $i$ is odd \\ | ||||
| 	For the new ISBN to be valid, we need $n_i - m_i \equiv 0 \text{ (mod 10)}$. \\ | ||||
| 	This cannot happen if $n_i \neq m_i$. | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Case 2: $i$ is even \\ | ||||
| 	For the new ISBN to be valid, we need $3(n_i - m_i) \equiv 0 \text{ (mod 10)}$ \\ | ||||
| 	This cannot happen, 10 and 3 are coprime. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-13 and swap two adjacent digits. When will the result be a valid ISBN-13? \\ | ||||
| \hint{The answer here is more interesting than it was last time.} | ||||
|  | ||||
| \begin{solution} | ||||
| 	Say we swap $n_i$ and $n_{i+1}$, where $i \in \{1, 2, ..., 11\}$. \\ | ||||
| 	The checksum changes by $2(n_{i+1} - n_i)$, and will \\ | ||||
| 	remain the same if this value is $\equiv 0 \text{ (mod 10)}$. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| \texttt{978-0-08-2066-46-6} was a valid ISBN until I changed a single digit. \\ | ||||
| Can you tell me which digit I changed? | ||||
|  | ||||
| \begin{solution} | ||||
| 	Nope, unless you look at the meaning of each digit in the spec. \\ | ||||
| 	If you're unlucky, maybe not even then. | ||||
| \end{solution} | ||||
|  | ||||
|  | ||||
| \vfill | ||||
| \pagebreak | ||||
		Reference in New Issue
	
	Block a user