Turing Mchines Prt One
Hello Hello Condensed Condensed Slide Slide Reders! Reders! Tody s Tody s lecture lecture consists consists lmost lmost exclusively exclusively of of nimtions nimtions of of Turing Turing mchines mchines nd nd TM TM constructions. constructions. We ve We ve presented presented condensed condensed version version here, here, but but we we strongly strongly recommend recommend reding reding full full version version of of slides slides tody. tody. Hope Hope this this helps! helps! -Keith -Keith
Wht problems cn we solve with computer?
Regulr Lnguges CFLs Lnguges recognizble by ny fesible computing mchine All Lnguges
Tht sme drwing, to scle. All Lnguges
The Problem Finite utomt ccept precisely regulr lnguges. We my need unbounded memory to recognize context-free lnguges. e.g. { n b n n N } requires unbounded counting. How do we build n utomton with finitely mny sttes but unbounded memory?
A Brief History Lesson
A Simple Turing Mchine q cc strt q 0 q 1 This This is is Turing Turing mchine s mchine s finite finite stte stte control. control. It It issues issues commnds commnds tht tht drive drive opertion opertion of of mchine. mchine. q rej
A Simple Turing Mchine q cc strt q 0 q 1 This This is is TM s TM s infinite infinite tpe. tpe. Ech Ech tpe tpe cell cell holds holds tpe tpe symbol. symbol. Initilly, Initilly, ll ll (infinitely (infinitely mny) mny) tpe tpe symbols symbols re re blnk. blnk. q rej
A Simple Turing Mchine q cc strt q 0 q 1 The The mchine mchine is is strted strted with with input input string string written written somewhere somewhere on on tpe. tpe. The The tpe tpe hed hed initilly initilly points points to to first first symbol symbol of of input input string. string. q rej
A Simple Turing Mchine q cc strt q 0 q 1 Like Like DFAs DFAs nd nd NFAs, NFAs, TMs TMs begin begin execution execution in in ir ir strt strt stte. stte. q rej
A Simple Turing Mchine q cc strt q 0 q 1 At At ech ech step, step, TM TM only only looks looks t t symbol symbol immeditely immeditely under under tpe tpe hed. hed. q rej
A Simple Turing Mchine q cc strt q 0 q 1 These These two two trnsitions trnsitions originte originte t t current current stte. stte. We re We re going going to to choose choose one one of of m m to to follow. follow. q rej
A Simple Turing Mchine q cc strt q 0 q 1 Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red is is under under tpe tpe hed, hed, q replce rej replce it it with with write write nd nd move move tpe tpe hed hed in in direction direction dir dir (L (L or or R). R). The The symbol symbol denotes denotes blnk blnk cell. cell.
A Simple Turing Mchine q cc strt q 0 q 1 Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red is is under under tpe tpe hed, hed, q replce rej replce it it with with write write nd nd move move tpe tpe hed hed in in direction direction dir dir (L (L or or R). R). The The symbol symbol denotes denotes blnk blnk cell. cell.
A Simple Turing Mchine q cc strt q 0 q 1 Unlike Unlike DFA DFA or or NFA, NFA, TM TM doesn t doesn t stop stop fter fter reding reding ll ll input input chrcters. chrcters. We We keep keep running running until until mchine mchine explicitly explicitly sys sys to to stop. stop. q rej
A Simple Turing Mchine q cc strt q 0 q 1 This This specil specil stte stte is is n n ccepting ccepting stte. stte. When When TM TM enters enters n n ccepting ccepting stte, stte, it it immeditely immeditely stops stops running running nd nd ccepts ccepts whtever whtever originl originl input input string string ws ws (in (in this this cse, cse, ). ). q rej
A Simple Turing Mchine q cc strt q 0 q 1 This This specil specil stte stte is is rejecting rejecting stte. stte. When When TM TM enters enters rejecting rejecting stte, stte, it it immeditely immeditely stops stops running running nd nd rejects rejects whtever whtever originl originl input input string string ws ws (in (in this this cse, cse, ). ). q rej
A Simple Turing Mchine q cc strt q 0 q 1 If If TM TM is is strted strted on on empty empty string string ε, ε, entire entire tpe tpe is is blnk blnk nd nd tpe tpe hed hed is is positioned positioned t t some some rbitrry rbitrry loction loction on on tpe. tpe. q rej
The Turing Mchine A Turing mchine consists of three prts: A finite-stte control tht issues commnds, n infinite tpe for input nd scrtch spce, nd tpe hed tht cn red nd write single tpe cell. At ech step, Turing mchine writes symbol to tpe cell under tpe hed, chnges stte, nd moves tpe hed to left or to right.
Input nd Tpe Alphbets A Turing mchine hs two lphbets: An input lphbet Σ. All input strings re written in input lphbet. A tpe lphbet Γ, where Σ Γ. The tpe lphbet contins ll symbols tht cn be written onto tpe. The tpe lphbet Γ cn contin ny number of symbols, but lwys contins t lest one blnk symbol, denoted. You re gurnteed Σ. At strtup, Turing mchine begins with n infinite tpe of symbols with input written t some loction. The tpe hed is positioned t strt of input.
Accepting nd Rejecting Sttes Unlike DFAs, Turing mchines do not stop processing input when y finish reding it. Turing mchines decide when (nd if!) y will ccept or reject ir input. Turing mchines cn enter infinite loops nd never ccept or reject; more on tht lter...
Determinism Turing mchines re deterministic: for every combintion of (non-ccepting, non-rejecting) stte q nd tpe symbol Γ, re must be exctly one trnsition defined for tht combintion of q nd. Any trnsitions tht re missing implicitly go stright to rejecting stte. We ll use this lter to simplify our designs. q cc strt q 0 q 1 This This mchine mchine is is exctly exctly sme sme s s previous previous one. one.
Designing Turing Mchines Despite ir simplicity, Turing mchines re very powerful computing devices. Tody's lecture explores how to design Turing mchines for vrious lnguges.
Designing Turing Mchines Let Σ = {0, 1} nd consider lnguge L = {0 n 1 n n N }. We know tht L is context-free. How might we build Turing mchine for it?
L = {0 n 1 n n N } 0 0 0 1 1 1 0 1 0 1 1 0 0
A Recursive Approch The string ε is in L. The string 0w1 is in L iff w is in L. Any string strting with 1 is not in L. Any string ending with 0 is not in L.
0 0, R 0 0, L 1 1, L Go to strt 1, L Cler 1 strt, L 1 q cc rej Check for 0 0, R Go to end 0 0, R 1 1, R q cc
Anor TM Design We've designed TM for {0 n1 n n N}. Consider this lnguge over Σ = {0, 1}: L = { w Σ* w hs sme number of 0s nd 1s } This lnguge is lso not regulr, but it is context-free. How might we design TM for it?
1 1, R, R strt 1, R Find 0 0, L, R Find 0/1 Go Go home 0 0, L 1 1, L, L, R 0, R Find 1 1, L Accept! 0 0, R, R Remember tht ll ll missing trnsitions implicitly reject.
Constnt Storge Sometimes, TM needs to remember some dditionl informtion tht cn't be put on tpe. In this cse, you cn use similr techniques from DFAs nd introduce extr sttes into TM's finite-stte control. The finite-stte control cn only remember one of finitely mny things, but tht might be ll tht you need!
Time-Out for Announcements!
Problem Set Five Problem Set Five hs been grded. Here s score distribution: (Nice job, everyone!) As lwys, feel free to rech out to us if you hve ny questions!
Problem Sets Problem Set Six ws due t strt of clss tody. You cn use lte dys to extend dedline up through Mondy, but be creful bout doing this given tht midterm is on Tuesdy. Problem Set Seven goes out tody. It s due next Fridy t strt of clss. Ply round with regulr expressions, properties of regulr lnguges, limits of regulr lnguges, nd Myhill-Nerode orem!
Midterm Exm Logistics The second midterm exm is next Tuesdy, My 23rd, from 7:00PM 10:00PM. Loctions re divvied up by lst (fmily) nme: Abb Pg: Go to Hewlett 200. Pr Tk: Go to Spp 114. Tn Vl: Go to Hewlett 101. Vr Yim: Go to Hewlett 102. You Zuc: Go to Hewlett 103. You re responsible for Lectures 00 13 nd topics covered in PS1 PS5. Lter lectures nd problem sets won t be tested. The focus is on PS3 PS5 nd Lectures 06 13. The exm is closed-book, closed-computer, nd limited-note. You cn bring double-sided, 8.5 11 sheet of notes with you to exm, decorted however you d like.
Your Questions
Wht is your fvourite mmticl orem? Wlk us through proof. One One of of my my fvorite orems is is tiny tiny little little one one tht tht I like like not not becuse it s it s super deep, but but becuse setup is is just just so so beutiful. Let Let me me show show you! you!
Recommendtions for thought-provoking short stories nd books, or just stories you hve herd tht mde you chllenge your existence / perception of relity? I ve I ve mentioned Before Lw Lw on on one one of of prctice exms nd nd highly recommend it. it. It s It s gret short red red to to tlk tlk bout. Or ones: Scott nd nd Scurvy, Story of of Your Life, Post-Opertive Check, nd nd Pulitzer-Prize winning rticle The The Fighter from lst lst yer.
Bck to CS103!
Anor TM Design Consider following lnguge over Σ = {0, 1}: L = {0 n 1 m n, m N nd m is multiple of n } Is this lnguge regulr? How might we design TM for this lnguge?
An Observtion We cn recursively describe when one number m is multiple of n: If m = 0, n m is multiple of n. Orwise, m is multiple of n iff m n is multiple of n. Ide: Repetedly subtrct n from m until m becomes zero (good!) or drops below zero (bd!)
strt Edge Cse 0 0, R, L 1 1, L Unmrk, R 0, L, R 0 0, R 1 1, R 0 0, R Check m 0 1 1, L Bck home 0, R Next 0 To End, R 0 0, L, R, L Accept!, L 0 0, L 1 1, L Bck home 1, L Cross off 1 1 1
Concepts from Tody Turing mchines re generliztion of finite utomt equipped with n infinite tpe. It's often helpful to think recursively when designing Turing mchines. It's often helpful to introduce new symbols into tpe lphbet. Wtch for edge cses tht might led to infinite loops though we'll sy more bout tht lter on.
Next Time TM Subroutines Combining multiple TMs toger! The Church-Turing Thesis Just how powerful re Turing mchines?