Homework Homework #5 returned Turing Machines Homework #6 due today Homework #7 Pg 236 -- Exercise 5 Pg 236 -- Exercise 7e,f,h (use JFLAP) Pg 237 -- Exercise 11c,d (use JFLAP) Pg 242 -- Exercise 3b,c Pg 242 -- Exercise 3b or c (actually build in JFLAP using building blocks) Due 10 / 31 Announcements Announcements Final Exam Dates have been Office hours Thursday cancelled announced Please e-mail to arrange alternate time Friday, November 17 10:15am -- 12:15pm Reminder: Exam 2 Room 70-3435 Thursday, October 26th Will cover Context Free Languages Conflicts? Let me know. 2nd half -- TM problem session Plan for today Languages 1st half Recall. Intro to Turing Machines What is a language? 2nd Half What is a class of languages? Turing Machines and Computation 1
Now our picture looks like The Turing Machine We investigate the next classes of Context Free Languages languages by first considering the Deterministic Context Free Languages machine Regular Languages Turing Machine Developed by Alan Turing in 1936 Finite More than just recognizing languages Languages Foundation for modern theory of computation We’re going to start to look at languages out here Theory Hall of Fame More about Turing Alan Turing “Breaking the Code” 1912 – 1954 Movie about the personal life of Alan Turing b. London, England. Death was by cyanide poisoning (some say suicide) PhD – Princeton (1938) Turing worked as a code breaker for the Allies Research during WWII. Cambridge and Manchester Turing eventually tried to build his machine and U. apply it to mathematics, code breaking, and National Physical Lab, UK games (chess). Was beat to the punch by vonNeumann Creator of the Turing Test The Turing Machine Theory Hall of Fame Some history Kurt Godel 1906 -- 1978 Created in response to Kurt Godel’s 1931 proof b. Brünn, Austria- that formal mathematics was incomplete Hungary There exists logical statements that cannot be proven by using formal deduction from a set of rules Good Reading: “Godel, Escher, Bach” by Hofstadter PhD – University of Vienna Turing set out to define a process by which it can be (1929) decided whether a given mathematical can be proven or Research not. Princeton University Godel’s Incompleteness Theorem 2
The Church-Turing Thesis The Turing Machine (1936) Motivating idea Any algorithmic procedure that can be Build a theoretical a “human computer” carried out by a human or group of Likened to a human with a paper and pencil that humans can be carried out by some can solve problems in an algorithmic way Turing Machine” The theoretical machine provides a means to Equating algorithm with running on a TM determine: If an algorithm or procedure exists for a given problem Turing Machine is still a valid What that algorithm or procedure looks like computational model for most modern How long would it take to run this algorithm or computers. procedure. Theory Hall of Fame Turing Machine Alonso Church A Machine consists of: 1903 -- 1995 A state machine b. Washington D.C. An input tape A movable r/w tape head PhD – Princeton (1927) A move of a Turning Machine Mathematics Prof (1927 – Read the character on the tape at the current 1967) position of the tape head Change the character on the tape at the current Advisor to both Turing and position of the tape head Kleene Move the tape head Change the state of the machine based on current state and character read Turing Machine Turing Machines Tape that holds Let’s formalize this Input tape (input/memory) character string A Turing Machine M is a 7-tuple: ... M = (Q, Σ , Γ , δ , q 0 , , F) where Movable tape head Read head Q = a finite set of states that reads and writes Σ = input alphabet (strings to be used as input) State character Γ = tape alphabet (chars that can be written onto the Machine tape. Includes symbols from Σ ) Machine that changes q 0 = start state (program) state based on what = the blank symbol ( ∈ Γ , ∉ Σ ) is read in F = set of final states δ = transition function 3
Turing Machines Turing Machines Transition function: Transition Function δ : Q x Γ → Q x Γ x {R, L} Symbol at Direction in Symbol to current tape which to write at the Input: head move the current head Current state position tape head position Tape symbol read at current position of tape head X / Y, → Output: State in which to move the machine q 0 q 1 Tape symbol to write at the current position of the tape head Direction in which to move the tape head (R = right, L = left) Turing Machine Turing Machine Configuration of a TM We indicate x 1 x 2 …x n qy 1 y 2 …y m a x 1 x 2 …x n y 1 py 2 …y m Gives the current “configuration” of a TM If you can go from one configuration to xqy x 1 x 2 …x n qy 1 y 2 …y m another on a single move We use a * To indicate that we can go from one Contents of configuration to another on 0 or more moves. tape before Contents of tape head tape at and (non- after tape Current state blank) head (non- blank) Turing Machine Turing Machine Accepting a string Initial configuration: A string x is accepted by a TM, if To run an input string x on a TM, Starting in the initial configuration Start in the stating state With x on the input tape place the string on the tape The machine eventually ends up in an place the head at the start of this string: accepting state. I.e. q 0 x q 0 x a * α p β and p ∈ F 4
Turing Machine Turing Machine properties TMs and halting There are many ways to skin a cat We say that a TM halts if And many ways to define a TM The machine has nowhere to go (at a state, Thankfully most are all equivalent reading a symbol where no transition is The book’s “Standard Turing Machines” defined) Tape unbounded on both sides Without loss of generality, we can assume that a TM will always halt when in an Deterministic (at most 1 move / accepting state. configuration) Note that the TM can halt in a non-accepting Tape acts as both input and output state! Consider this simple TM Turing Machine Running a Turing Machine The execution of a TM can result in 3 possible cases: The machine “halts” in an accepting state (ACCEPT) The machine “halts” in a non-accepting state (REJECT) The machine goes into an “infinite loop” (REJECT but keeps us guessing!) Or better yet, use JFLAP Turing Machine TMs and Regular Languages Language accepted by a TM Example The language accepted by a TM is the set L = { x ∈ { a, b } * | x contains the of all input strings x on which the machine substring aba } halts in an accepting state. Questions? 5
TMs and Regular Languages TMs and Regular Languages Example L = { x ∈ { a, b } * | x contains the substring aba } Build a TM that mimics the FA that accepts this language TMs and Regular Languages Theory Hall of Fame Do you think that JFLAP can handle Susan Rodgers TMs? PhD – Purdue (1985) You bet! CS Prof RPI (1989-1994) Duke (1995 – present) Creator and keeper of JFLAP TMs and Regular Languages TMs and CFLs Example Example L = { x ∈ {0,1} * | x = 0 i 1 i } Observations Basic idea: Like FAs TM tape head will always move to the right Find leftmost 0 and change it to an X Find the rightmost 1 and change to a Y Like FAs, TM will not write new chars onto the Continue to match until all 0s have been tape changed to Xs Can enter final state even before the machine If every X has a matching Y, accept reads all the characters of x. If can’t find a matching 1 reject If 1s leftover, reject 6
TMs and Context Free TMs and Context Free Language Language L = { x ∈ {0,1} * | x = 0 i 1 i } States: q 0 – at the leftmost blank q 1 – read leftmost 0, looking for rightmost 1 q 2 – found and matched rightmost 1 / go back to leftmost 0 q 3 – no more 0’s, all 0s matched with 1s / see if we get get to end of string without reading a 1 q 4 – accept and halt TMs and Context Free TMs and Context Free Language Language JFLAP…go to work!! Another? Let’s try our old friend palindrome L = { x ∈ {a, b} * | x = x r } TMs and Context Free TMs and Context Free Language Language Example Example L = { x ∈ {a, b} * | x = x r } L = { x ∈ {a, b} * | x = x r } Basic idea: How to compare characters? Compare the first character with the last character. If they match compare the second character with the Read a character and replace it with blanks. second to last character Move across the tape to first blank character If they match, compare the 3 rd character with the 3 rd to last character Check the character to the left And so on… If it’s the character that you initially read in, replace For x in pal, eventually we will end up with 0 or 1 it with a blank, move the tape head left until you unmatched characters. reach the first blank character and so on. 7
Recommend
More recommend