This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 6.042/18.062J Mathematics for Computer Science September 17, 2010 Tom Leighton, Marten van Dijk Notes for Recitation 3 1 State Machines Recall from Lecture 3 (9/16) that an invariant is a property of a system (in lecture, that system was the 8-puzzle) that does not change, regardless of the system’s behavior. Now we’ll take a look at how we can make use of an important modeling tool — a state machine — to analyze systems. We’ll see that finding invariants of state machines can often help us prove propositions. A state machine is an abstract model of a step-by-step process. The model consists of a collection of states and transitions between those states. More formally, we can define a state machine as a set of states: Q a designated start state: q ∈ Q a set of allowed transitions between states: δ ⊆ Q × Q . 1.1 Example: Bounded Counter Take, for example, a bounded counter that counts from to 99 and overﬂows at 100. A diagram representing the corresponding state machine was shown in recitation. Note that in this example, there is a finite number of states. However, in general, the set of states might be infinite. 1.2 Example: Unbounded Counter An unbounded counter is similar to a bounded counter except that there is an infinite number of states and no overﬂow. See Figure 2 . 2 Recitation 3 Figure 1: State machine for the unbounded counter 2 Problem: Breaking a chocolate bar We are given a chocolate bar with m × n squares of chocolate, and our task is to divide it into mn individual squares. We are only allowed to split one piece of chocolate at a time using a vertical or a horizontal break. For example, suppose that the chocolate bar is 2 × 2. The first split makes two pieces, both 2 × 1. Each of these pieces requires one more split to form single squares. This gives a total of three splits. Prove that the number of times you split the bar does not depend on the sequence of splits you make. Solution. As with the “stacking game” from class, we approach the problem with exper- imentation, strong induction and a strong hypothesis. First we guess what the number of splits needed is: Theorem. To divide up a chocolate bar with m × n squares, we need at most mn − 1 splits. This theorem does not immediately lend itself to an induction or strong induction proof, since there are two variables. In general, propositions involving several natural-valued variables can often be proved by using a sort of nested induction (make sure to try that). However, in this case, we can get by with a single-variable induction and a trick. Intuitively, to break up a big chocolate bar, we need one split to make two pieces, and then we can break up the two pieces recursively. This suggests a proof using strong induction on the size of the chocolate bar, where size is measured in chocolate squares. Now instead of a problem involving two variables (the two dimensions), we have a problem in one variable (the size). With this simplification, we can prove...
View Full Document
This note was uploaded on 01/19/2012 for the course CS 6.042J / 1 taught by Professor Tomleighton,dr.martenvandijk during the Fall '10 term at MIT.
- Fall '10
- Computer Science