CS 30 - ecture 9 Turig Machies Fall 2008 eview aguages ad Grammars Alphaets, strigs, laguages egular aguages Determiistic Fiite ad Nodetermiistic Automata Equivalece of NFA ad DFA ad Miimizig a DFA egular Expressios egular Grammars Properties of egular aguages aguages that are ot regular ad the pumpig lemma Cotext Free aguages Cotext Free Grammars Derivatios: leftmost, rightmost ad derivatio trees Parsig ad amiguity Simplificatios ad Normal Forms Nodetermiistic Pushdow Automata Pushdow Automata ad Cotext Free Grammars Determiistic Pushdow Automata Pumpig emma for cotext free grammars Properties of Cotext Free Grammars Turig Machies Turig Machies The aguage Hierarchy a c Cotext-Free aguages a? ww? ww egular aguages a * a **
a aguages accepted y Turig Machies c Cotext-Free aguages a ww ww egular aguages a * a ** Tape Cotrol Uit A Turig Machie ead-write head The Tape No oudaries -- ifiite legth ead-write head ead-write head The head moves eft or ight The head at each time step:. eads a symol 2. Writes a symol 3. Moves eft or ight 2
Example: Time 0 a a c a k c a k c Time 2 a f k c. eads 2. Writes a k 3. Moves eft. eads 2. Writes f 3. Moves ight The Iput Strig Iput strig Blak symol Iput strig Blak symol a a c a a c head head Head starts at the leftmost positio of the iput strig emark: the iput strig is ever empty 3
States & Trasitios ead Write Move eft Example: a a c q a, curret state Move ight q a, q a, a a c Example: a a c Time 2 a c Time 2 a c q 2 q 2 q a, q a, 4
Example: a a c Time 2 a c g q 2 q g, Determiism Turig Machies are determiistic Allowed Not Allowed a, q 2 a, q 2 d, q 3 a d, q 3 No lamda trasitios allowed Example: Partial Trasitio Fuctio a a c Haltig The machie halts if there are o possile trasitios to follow a, d, q 2 q 3 Allowed: No trasitio for iput symol c 5
Example: Fial States a a c Allowed Not Allowed a, d, q 2 q 3 No possile trasitio HAT!!! Fial states have o outgoig trasitios I a fial state the machie halts Accept Iput Acceptace If machie halts i a fial state Turig Machie Example A Turig machie that accepts the laguage: aa * eject Iput If machie halts i a o-fial state or If machie eters a ifiite loop 6
Time 0 a a a a a a Time 2 a a a Time 3 a a a 7
Time 4 a a a ejectio Example Time 0 a a Halt & Accept a a Ifiite oop Example No possile Trasitio Halt & eject, 8
Time 0 a a a a,, Time 2 a a Time 2 a a, Time 3 Time 4 Time 5 a a a a a a Ifiite loop 9
Because of the ifiite loop: The fial state caot e reached The machie ever halts The iput is ot accepted Turig Machie Example { a Turig machie for the laguage } q 4 a x, q 3 q y, x x, Time 0 a a x a q 4 q 4 q 3 a x, q y, x x, q 3 a x, q y, x x, 0
x a Time 2 x a y Time 3 a x, y, a x, x x, x a y Time 5 y, x x, x a y Time 4 a x, y, x x, a x, y, x x,
x x y Time 6 x x y Time 7 a x, y, a x, x x, a x, x x y y Time 9 y, x x, x x y y Time 8 y, x x, a x, y, x x, 2
x x y y 0 x x y y a x, y, a x, x x, y, x x, x x y y 2 x x y y 3 Halt & Accept a x, y, x x, a x, y, x x, 3
Oservatio: If we modify the machie for the laguage { a } Formal Defiitios for Turig Machies we ca easily costruct a machie for the laguage { a c } Trasitio Fuctio Trasitio Fuctio q a, q c d, δ (, a) = (,, ) δ (, c) = (, d, ) 4
Turig Machie: States Iput alphaet M = ( Q, Σ, Γ, δ,,, F) Tape alphaet Cofiguratio c a a Trasitio fuctio Iitial state lak Fial states Istataeous descriptio: ca a Time 4 x a y Time 5 x a y Time 4 x a y Time 5 x a y q 2 q 2 A Move: xay x ay Time 6 x x y Time 7 x x y xay x ay xx y xxy 5
xay x ay xx y xxy Iitial cofiguratio: w Equivalet otatio: xay xxy Iput strig w a a The Accepted aguage For ay Turig Machie M ( M ) = { w : w x q f x2} Stadard Turig Machie The machie we descried is the stadard: Determiistic Ifiite tape i oth directios Iitial state Fial state Tape is the iput/output file 6
ead What s Next iz Chapter,2., 2.2, 2.3, (skip 2.4), 3, 4, 5, 6., 6.2, (skip 6.3), 7., 7.2, 7.3, (skip 7.4), 8, 9 JFAP Chapter, 2., (skip 2.2), 3, 4, 5, 6, 7, (skip 8), 9 Next ecture Topics From 9.2 ad 9.3 Complex Tasks ad Turig s Thesis Quiz 3 i ecitatio o Wedesday /2 Covers iz 7., 7.2, 7.3, (skip 7.4), 8, ad JFAP 5,6,7 Closed ook, ut you may rig oe sheet of 8.5 x ich paper with ay otes you like. Quiz will take the full hour Homework Homework Due Thursday 7