error detection and correction nim secure communication
play

Error Detection and Correction: Nim; Secure Communication; RAID - PowerPoint PPT Presentation

Error Detection and Correction: Nim; Secure Communication; RAID Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin The Game of Nim Initially, there are a number of piles of


  1. Error Detection and Correction: Nim; Secure Communication; RAID Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin

  2. The Game of Nim • Initially, there are a number of piles of chips • Two players move alternately • A legal move consists of removing a positive number of chips from some pile • The first player who cannot make a legal move loses • Thus, the player who removes the last chip wins Theory in Programming Practice, Plaxton, Fall 2005

  3. A Winning Strategy for Nim? • A state is losing if the player to move next can be forced to lose: – Examples: (1) The state in which all piles are empty; (2) Any state with an even number of nonempty piles, each of which has exactly one chip; (3) Any state with two piles of equal size • A state is winning if the player to move next can force a win – Examples: (1) Any state with exactly one nonempty pile; (2) Any state with an odd number of nonempty piles, each of which has exactly one chip; (3) Any state with two piles of unequal size • Is every state either losing or winning or could there be “uncertain” states? Theory in Programming Practice, Plaxton, Fall 2005

  4. Every State is Either Losing or Winning • Proof by strong induction on the total number of chips • Base case: If there are no chips, the state is losing • Induction hypothesis: Let k be a nonnegative integer and assume that every state with a total of at most k chips is either losing or winning • Induction step: – Let S be an arbitrary state with a total of k + 1 chips – By the IH, every state reachable via a legal move from S is either losing or winning – If every state reachable via a legal move from S is winning, then S is losing; otherwise, it is winning Theory in Programming Practice, Plaxton, Fall 2005

  5. Towards a Characterization of Losing/Winning States • Earlier we saw that if every pile has 0 or 1 chips, then the parity of the number of nonempty piles determines whether a state is losing or winning • Conjecture: A state is losing iff, for all nonnegative integers i , an even number of piles have the property that the binary representation of the number of chips in the pile has a 1 in bit position i • What is a more succinct statement of this conjecture? Theory in Programming Practice, Plaxton, Fall 2005

  6. Bad and Good States • For any state S , let f ( S ) denote the XOR of the pile sizes • A state S is bad if f ( S ) = 0 , and good otherwise • Theorem: A state is losing (resp., winning) iff it is bad (resp., good) • In order to prove this claim, we will establish two lemmas – Lemma 1: Any legal move executed in a bad state yields a good state – Lemma 2: For any good state, there exists a legal move to a bad state • Why does the theorem follow? Theory in Programming Practice, Plaxton, Fall 2005

  7. Proof of the Theorem (using Lemmas 1 and 2) • Proof by strong induction on the total number of chips • Base case: If there are no chips, the state is losing and bad • Induction hypothesis: Let k be a nonnegative integer and assume that every bad (resp., good) state with at most k chips is losing (resp., winning) • Induction step: Let state S have a total of k + 1 chips – If S is bad, then by Lemma 1, every state reachable via a legal move from S is good, and by the IH, winning; hence, S is losing – If S is good, then by Lemma 2, there is a legal move from S to a state that is bad, and by the IH, losing; hence, S is winning Theory in Programming Practice, Plaxton, Fall 2005

  8. Proof of Lemma 1 • Lemma 1: Any legal move executed in a bad state yields a good state • Suppose we are in a bad state S and we move to a state S ′ by reducing the number of chips in some pile from x to y • Let i be a bit position where x has a 1 and y has a 0 – Such an i exists since x > y • Note that bit position i of f ( S ′ ) is 1 , so S ′ is good Theory in Programming Practice, Plaxton, Fall 2005

  9. Proof of Lemma 2 • Lemma 2: For any good state, there exists a legal move to a bad state • Let S be an arbitrary good state • Let i be the highest bit position of f ( S ) containing a 1 • Let A be an arbitrary pile for which the number of chips, denoted by x , has a 1 in bit position i of its binary representation – Such a pile A exists since bit position i of f ( S ) is 1 • Note that x ⊕ f ( S ) < x and ( x ⊕ f ( S )) ⊕ ( x ⊕ f ( S )) = 0 , so we can reach a bad state by reducing the number of chips in A from x to x ⊕ f ( S ) Theory in Programming Practice, Plaxton, Fall 2005

  10. Secure Communication: A Simple Approach • Suppose a sender wishes to securely send a block of data x to a receiver over an insecure communication channel • Let us call a block of data random if each bit is independently set to 0 (resp., 1) with probability 1 2 • Suppose the sender and receiver share a secret random block (sometimes called a key) k • The sender sends y = x ⊕ k over the channel • Note that the block y is random! – Therefore an eavesdropper gains no information whatsoever about the message x from observing y Theory in Programming Practice, Plaxton, Fall 2005

  11. Disadvantages of this Approach • Key exchange problem: The sender and receiver need to agree in advance on the random block k , which must be sent over a secure channel • The key should not be reused – For example, suppose the eavesdropper sees x 1 ⊕ k and x 2 ⊕ k – The eavesdropper can calculate x 1 ⊕ x 2 , which is (presumably) not random and might yield statistical clues towards partially deciphering the content of x 1 and x 2 – Furthermore, an eavesdropper who knows the content of a single block can determine k and thereby decipher all blocks • Later in the course we will see a much better solution to the problem of secure communication Theory in Programming Practice, Plaxton, Fall 2005

  12. Fault-Tolerant Storage • Suppose the records of a large corporate database are to be stored on a collections of disks • Occasionally one of the disks fails • We would like to store the data in such a way that the entire content of the database can be recovered whenever any single disk fails • Naive solution: – Store two copies of each record (on different disks) – This doubles the storage requirement • A better solution? Theory in Programming Practice, Plaxton, Fall 2005

  13. Redundant Array of Independent Disks (RAID) • Store the database nonredundantly on k disks • Use one additional disk to store the XOR of these k disks – Here we are viewing the content of each disk as a block of bits • If any disk fails, its content can be recovered since it is the XOR of the remaining k disks Theory in Programming Practice, Plaxton, Fall 2005

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend