Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.

Similar presentations


Presentation on theme: "Introduction to the Theory of Computation John Paxton Montana State University Summer 2003."— Presentation transcript:

1 Introduction to the Theory of Computation John Paxton Montana State University Summer 2003

2 Textbook Introduction to the Theory of Computation Michael Sipser PWS Publishing Company 1997

3 Humor One night, Bill Clinton was awakened by George Washington's ghost in the White House. Clinton saw him and asked, "George, what is the best thing I could do to help the country?" "Set an honest and honorable example, just as I did," advised George. The next night, the ghost of Thomas Jefferson moved through the dark bedroom. "Tom, what is the best thing I could do to help the country?" Clinton asked. "Cut taxes and reduce the size of government," advised Tom. Clinton didn't sleep well the next night, and saw another figure moving in the shadows. It was Abraham Lincoln's ghost. "Abe, what is the best thing I could do to help the country?" Clinton asked. "Go to the theatre."

4 Chapter 1: Regular Languages Very simple model of computation

5 1.1 Finite Automaton A finite state automaton (FSA) is a very simple model of computation. Studying an FSA allows us to better understand more complex models of computation. An FSA can be used in a compiler to tokenize the input.

6 Example 1 0 1 1 0 q0q0 q1q1

7 Example 1 Questions What is the start state? What is the set of accept states? What sequence of states are gone through on input 0111001? Is the empty string input (  ) accepted?

8 Formal Definition A finite automaton is a 5-tuple (Q, , , q 0, F) where 1.Q is a finite set called the states  is a finite set called the alphabet  : Q x   Q is the transition function 4.q 0  Q is the start state 5.F  Q is the set of accept states

9 Example 1 Formal Definition Q = { q 0, q 1 }  = {0, 1} F = { q 1 }   0 1 q 0 q 0 q 1 q 1 q 0 q 1

10 Language of Machine M L(M) = A where A is the set of all strings that machine M accepts. L(Example 1) = { w | w ends in a 1 } M “recognizes” A

11 Acceptance Let M = (Q, , , q 0, F) be a finite automaton and w = w 1 w 2 …w n be a string over the alphabet . Then M “accepts” w if a sequence of states r 0 r 1 …r n exists in Q with the following three conditions: 1.r 0 = q 0  (r i, w i+1 ) = r i+1 for 0 <= i <= n – 1 3.r n  F

12 Regular Language A language is called a “regular language” if some finite automaton recognizes it.

13 Exercises Design a finite automaton that recognizes the regular language of all strings that contain the string 001 as a substring. The alphabet is {0, 1, 2}. Design a finite automaton that recognizes all binary numbers that are multiples of 3. Design a finite automaton that recognizes all binary strings with a 1 in the k th position where k > 0.

14 Regular Operations Union A U B = { x | x  A or x  B} Concatenation A B = { xy | x  A and y  B} Star A* = {x 1 x 2 …x k | k >= 0 and x i  A}

15 Theorem The class of regular languages is closed under the union operation. In other words, if A 1 and A 2 are regular languages, so is A 1 U A 2.

16 Proof M 1 = (Q 1, ,  , q 1, F 1 ) M 2 = (Q 2, ,  , q 2, F 2 ) Construct M = (Q, , , q 0, F)

17 Proof (by construction) Q = {(r 1, r 2 ) | r 1  Q 1 and r 2  Q 2 q 0 = (q 1, q 2 ) F = {(r 1, r 2 ) | r 1  F 1 or r 2  F 2 }  (r 1,r 2 ), a) = (  1  (r 1, a),  2  (r 2, a) )

18 Exercise Use the preceding construction to construct a FSA that accepts the union of L(A 1 ) = { w | w ends in 1 } and L(A 2 ) = { w | w contains the substring 00 }

19 More Theorems The class of regular languages is closed under the concatenation operation. The class of regular languages is closed under the star operation. Proofs: easier with the concept of nondeterminism!


Download ppt "Introduction to the Theory of Computation John Paxton Montana State University Summer 2003."

Similar presentations


Ads by Google