Turing Mchines Prt One
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 precely 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 Htory Lesson
Fin de siècle optimm
<hem> Technology hs solved ll of mnkind s problems! No more wrs or sd ever!
Hilbert s Vion 1900: Interntionl Congress of Mmticins meeting in Pr Proposes 23 unsolved problems s gend for coming yers An importnt me not simply proving more orems, but chieving utomtion of oremproving, even orem genertion. Humnity lives in leure while ll Truth flows effortlessly into our hnds on ticker tpe! No one shll expel us from Prde tht Cntor hs creted! -Dvid Hilbert
Hi re, Relity! Hilbert s gend both spectculr success nd spectculr filure Inspires some of most impctful oreticl work in mmticl htory, humn htory Brings us heroes like Aln Turing nd Kurt Gödel! These incredible results const of utterly demolhing ll pillrs of h vion of utomted knowledge cretion, within just few yers No one shll expel us from Prde tht Cntor hs creted! -Dvid Hilbert
Wht Turing Dcovered
A Simple Turing Mchine q cc, R, R strt, R, R Th Th Turing Turing mchine s mchine s finite finite stte stte control. control. It It sues sues commnds commnds tht tht drive drive opertion opertion of of mchine. mchine.
A Simple Turing Mchine q cc, R, R strt, R, R Th Th 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.
A Simple Turing Mchine q cc, R, R strt The The mchine mchine 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., R, R
A Simple Turing Mchine q cc, R, R strt Like Like DFAs DFAs nd nd NFAs, NFAs, TMs TMs begin begin execution execution in in ir ir strt strt stte. stte., R, R
A Simple Turing Mchine q cc, R, R strt At At ech ech step, step, TM TM only only looks looks t t symbol symbol immeditely immeditely under under tpe tpe hed. hed., R, R
A Simple Turing Mchine q cc, R, R strt 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., R, R
A Simple Turing Mchine q cc, R, R strt, R, R Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red 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, R, R strt, R, R Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red 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, R, R strt, R, R Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red 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, R, R strt, R, R Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red 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, R, R strt, R, R Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red 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, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt 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., R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt Th Th specil specil stte stte 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 th th cse, cse, ). )., R, R
A Simple Turing Mchine q cc, R, R strt Th Th specil specil stte stte 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 th th cse, cse, ). )., R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt, R, R
A Simple Turing Mchine q cc, R, R strt Th Th specil specil stte stte 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 th th cse, cse, ). )., R, R
A Simple Turing Mchine q cc, R, R strt Th Th specil specil stte stte 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 th th cse, cse, ). )., R, R
A Simple Turing Mchine q cc, R, R strt If If TM TM strted strted on on empty empty string string ε, ε, entire entire tpe tpe blnk blnk nd nd tpe tpe hed hed positioned positioned t t some some rbitrry rbitrry loction loction on on tpe. tpe., R, R
A Simple Turing Mchine q cc, R, R strt If If TM TM strted strted on on empty empty string string ε, ε, entire entire tpe tpe blnk blnk nd nd tpe tpe hed hed positioned positioned t t some some rbitrry rbitrry loction loction on on tpe. tpe., R, R
A Simple Turing Mchine q cc, R, R strt If If TM TM strted strted on on empty empty string string ε, ε, entire entire tpe tpe blnk blnk nd nd tpe tpe hed hed positioned positioned t t some some rbitrry rbitrry loction loction on on tpe. tpe., R, R
The Turing Mchine A Turing mchine consts of three prts: A finite-stte control tht sues 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, [Q: wht if you don t wnt to write?] 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 positioned t strt of input.
Accepting nd Rejecting Sttes Unlike DFAs, Turing mchines do not stop processing input when y finh 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...
Determinm Turing mchines re determintic: 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 msing implicitly go stright to rejecting stte. We ll use th lter to simplify our designs. q cc, R, R strt, R, R
Determinm Turing mchines re determintic: 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 msing implicitly go stright to rejecting stte. We ll use th lter to simplify our designs. q cc strt, R, R, R Th Th mchine mchine exctly exctly sme sme s s previous previous one. one.
strt b, R b, R, L q cc, L b b, L, L Run Run TM TM shown shown bove bove on on input input string string bb. bb. Wht Wht will will tpe tpe look look like like when when TM TM finhes finhes running? running? A. b b B. b C. b b D. b E. None of se, or two or more of se. Answer Answer t t PollEv.com/cs103 PollEv.com/cs103 or or text text CS103 CS103 to to 22333 22333 once once to to join, join, n n A, A, B, B, C, C, D, D, or or E. E.
strt b, R b, R, L q cc, L b b, L, L b b
strt b, R b, R, L q cc, L b b, L, L b
strt b, R b, R, L q cc, L b b, L, L
strt b, R b, R, L q cc, L b b, L, L b
strt b, R b, R, L q cc, L b b, L, L b
strt b, R b, R, L q cc, L b b, L, L b
strt b, R b, R, L q cc, L b b, L, L b
strt b, R b, R, L q cc, L b b, L, L If If M Turing Turing mchine mchine with with input input lphbet lphbet Σ, Σ, n n lnguge lnguge of of M, M, denoted denoted L(M), L(M), set set L(M) L(M) = { { w Σ* Σ* M ccepts ccepts w } } Let Let M be be bove bove TM, TM, nd nd ssume ssume its its input input lphbet lphbet {, {, b}. b}. Wht Wht L (( M)? M)? A. A. { w {, {, b}* b}* w ends ends in in } B. B. { w {, {, b}* b}* w ends ends in in b } C. C. Ø D. D. None None of of se, se, or or two two or or more more of of se. se. Answer Answer t t PollEv.com/cs103 PollEv.com/cs103 or or text text CS103 CS103 to to 22333 22333 once once to to join, join, n n A, A, B, B, C, C, or or D. D.
strt b, R b, R, L q cc, L b b, L, L b
strt b, R b, R, L q cc, L b b, L, L b b
strt b, R b, R, L q cc, L b b, L, L b b b
strt b, R b, R, L q cc, L b b, L, L b b
strt b, R b, R, L q cc, L b b, L, L b b
strt b, R b, R, L q cc, L b b, L, L b b
strt b, R b, R, L q cc, L b b, L, L b b
strt b, R b, R, L q cc, L b b, L, L b b Although Although tpe tpe ends ends with with bb bb written written on on it, it, originl originl input input string string ws ws b. b. Th Th shows shows tht tht TM TM ccepts ccepts b, b, not not bb. bb. So So L ( M) ( M) = { { w {, {, b}* b}* w ends ends in in b } }