Before We Start • Any questions? Turing Machines Languages Now our picture looks like • The $64,000 Question Context Free Languages – What is a language? Deterministic Context Free Languages – What is a class of languages? Regular Languages Finite Languages We’re going to start to look at languages out here The Turing Machine Theory Hall of Fame • Alan Turing • We investigate the next classes of languages – 1912 – 1954 by first considering the machine – b. London, England. – Turing Machine • Developed by Alan Turing in 1936 – PhD – Princeton (1938) • More than just recognizing languages – Research • Cambridge and Manchester U. • Foundation for modern theory of computation • National Physical Lab, UK – Creator of the Turing Test 1
More about Turing The Turing Machine • “Breaking the Code” • Some history – Movie about the personal life of Alan Turing – Created in response to Kurt Godel’s 1931 proof • Death was by cyanide poisoning (some say suicide) that formal mathematics was incomplete • There exists logical statements that cannot be – Turing worked as a code breaker for the Allies during proven by using formal deduction from a set of rules WWII. – Good Reading: “Godel, Escher, Bach” by Hofstadter – Turing eventually tried to build his machine and apply • Turing set out to define a process by which it can be it to mathematics, code breaking, and games (chess). decided whether a given mathematical can be • Was beat to the punch by vonNeumann proven or not. Theory Hall of Fame The Turing Machine • Kurt Godel • Motivating idea – 1906 -- 1978 – Build a theoretical a “human computer” – b. Brünn, Austria-Hungary – Likened to a human with a paper and pencil that can solve problems in an algorithmic way – PhD – University of Vienna – The theoretical machine provides a means to determine: (1929) • If an algorithm or procedure exists for a given problem – Research • What that algorithm or procedure looks like • Princeton University • How long would it take to run this algorithm or procedure. – Godel’s Incompleteness Theorem The Church-Turing Thesis (1936) Theory Hall of Fame • Alonso Church • Any algorithmic procedure that can be – 1903 -- 1995 carried out by a human or group of humans – b. Washington D.C. can be carried out by some Turing Machine” – PhD – Princeton (1927) – Mathematics Prof (1927 – – Equating algorithm with running on a TM 1967) – Turing Machine is still a valid computational model for most modern computers. – Advisor to both Turing and Kleene 2
Turing Machine Turing Machine • A Machine consists of: • Tape that holds Input tape (input/memory) – A state machine character string ... – An input tape • Movable tape head that Read head – A movable r/w tape head reads and writes • A move of a Turning Machine State character Machine – Read the character on the tape at the current position of • Machine that changes the tape head (program) state based on what is – Change the character on the tape at the current position of the tape head read in – Move the tape head – Change the state of the machine based on current state and character read Turing Machine Turing Machines • In the original Turing Machine • About the input tape – The read tape was infinite in both directions – Bounded to the left, infinite to the right – The text describes a semi-infinite TM where – All cells on the tape are originally filled with a • The tape is bounded on the left and infinite on the special “blank” character ∆ right – Tape head is read/write • It can be shown that the semi-infinite TM is equivalent to the basic TM. – Tape head can not move to the left of the start – As not to confuse, I’ll follow the conventions in of the tape the book…(as much as that bothers me!) • If it tries, the machine “crashes” Turing Machines Turing Machines • About the machine states • Let’s formalize this – A Turing Machine M is a 5-tuple: – A Turing Machine does not have a set of – M = (Q, Σ , Γ , q 0 , δ ) where accepting states • Q = a finite set of states (assumed not to contain the halting – Instead, each TM has a special halting state, h. state h) • Once in the halting state, the machine halts. • Σ = input alphabet (strings to be used as input) • Γ = tape alphabet (chars that can be written onto the tape. – Unlike PDAs, the basic TM is deterministic! Includes symbols from Σ ) • Both Σ and Γ are assumed not to contain the “blank” symbol • δ = transition function 3
Turing Machines Turing Machines • Transition function: • Transition Function – δ : Q x ( Γ ∪ { ∆ }) → (Q ∪ {h}) x ( Γ ∪ { ∆ }) x {R, L, Symbol at Direction in Symbol to S} current tape which to write at the head move the current head – Input: position tape head position • Current state • Tape symbol read at current position of tape head X / Y, R – Output: q 0 q 1 • State in which to move the machine (can be the halting state) • Tape symbol to write at the current position of the tape head (can be the “blank” symbol) • Direction in which to move the tape head (R = right, L = left, S= stationary) Turing Machine Turing Machine • Configuration of a TM • We indicate – Gives the current “configuration” of a TM • (q, xay) a (p, ubv) – If you can go from one configuration to • (q, xay) another on a single move, and… Current state • (q, xay) a * (p, ubv) Current contents of the tape – If you can go from one configuration to (without trailing blanks) another on 0 or more moves. Underlined character is current position of the tape head Turing Machine Turing Machine • Running a Turing Machine • Initial configuration: – The execution of a TM can result in 4 possible – To run an input string x on a TM, cases: • Start in the stating state • The machine “halts” (ends up in the halting state) • place the string after the leftmost blank on the tape • The machine has nowhere to go (at a state, reading a • place the head at this leftmost blank: symbol where no transition is defined) • The machine “crashes” (tries to move the tape head to before the start of the tape) • (q 0 , ∆ x) • The machine goes into an “infinite loop” (never halts) 4
Turing Machine Turing Machine • Accepting a string • Running a Turing Machine – A string x is accepted by a TM, if – The execution of a TM can result in 4 possible cases: • Starting in the initial configuration • With x on the input tape • The machine “halts” (ACCEPT) • The machine has nowhere to go (REJECT) • The machine eventually ends up in the halting state. • The machine “crashes” (REJECT) – I.e. • The machine goes into an “infinite loop” (REJECT • (q 0 , ∆ x) a * (h, xay) but keeps us guessing!) – for x,y ∈ ( Γ ∪ { ∆ }) * , a ∈ ( Γ ∪ { ∆ }) Turing Machine TMs and Regular Languages • Language accepted by a TM • Example – L = { x ∈ { a, b } * | x contains the substring aba – The language accepted by a TM is the set of all input strings x on which the machine halts. } b a a,b a b a • Questions? b TMs and Regular Languages TMs and Regular Languages • Example – L = { x ∈ { a, b } * | x contains the substring aba } b/b,R a/a,R a /a,R 0 ∆ / ∆ ,R a/a,R b /b,R – Build a TM that mimics the FA that accepts this h language B/b,R 5
TMs and Regular Languages Theory Hall of Fame • Do you think that JFLAP can handle TMs? • Susan Rodgers – You bet! – PhD – Purdue (1985) – CS Prof • RPI (1989-1994) – One difference, JFLAP simulates the “original” • Duke (1995 – present) TM (with an infinite tape in both directions). – Creator and keeper of JFLAP TMs and Regular Languages TMs and Context Free Language • Example • Example – Observations – Our old friend the palindrome: – L = { x ∈ {a, b} * | x = x r } • Like FAs TM tape head will always move to the right • Like FAs, TM will not write new chars onto the tape – We won’t simulate a PDA since the PDA for • Can enter halt state even before the machine reads pal is non-deterministic (we’ll deal with non- all the characters of x. deterministic TMs later). TMs and Context Free Language TMs and Context Free 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 second to • Read a character and replace it with blanks. 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 it • For x in pal, eventually we will end up with 0 or 1 unmatched with a blank, move the tape head left until you reach the characters. first blank character and so on. 6
Recommend
More recommend