1 2 EE 109 Unit 20 – Theoretical Computer Science and Turing Machines Credit: Adapted from Gaurav Sukhatme's CSCI 109 Lecture Slides THEORETICAL COMPUTER SCIENCE 3 4 Computability State Machine Review • Theoretical Computer Science • Recall that a state machine is defined by a 6-tuple: – A set of possible input values – The study of ______ can be computed and how – A set of possible states __________________________ – A set of possible outputs – Uses __________________ models – An initial state – A transition function: {States x Inputs} -> the Next state – Tries to generalize computers so that what is – An output function: {States x Inputs} -> Output value(s) proven is applicable to _________ computer Input=1 Input=1 Input=1 Input=0 system no matter its speed, # of processors, etc. S0 S1 S2 Out=False Out=False out=True Input=0 On Reset Input=0
5 6 Formal Definition Limits of FSM's • Mathematically, a state machine consists of: Inputs • Finite state machines have certain _______________ – A set of possible input values: {0, 1} State 0 1 – A set of possible states: {S0, S1, S2} – Why? Because they have a __________________________ of states! S0 S0 S1 – A set of possible outputs: {False, True} • Problem: Given an arbitrary length string of A's and B's S1 S0 S2 – An initial state = S0 determine if there is an __________ number of A's and B's S2 S0 S2 – A transition function: – Key is "_____________________ length" • {States x Inputs} -> the Next state State Transition – Show execution for "AABABBBBA" Function – An output function: Inputs initial • {States x Inputs} -> Output value(s) State 0 1 B B B B B B Input=1 Input=1 Input=1 Input=0 S0 False False 1 2 2 1 Extra Extra S1 False False Extra Extra Equal A B C B B's As A S2 True True Out=False Out=False out=True Input=0 A A A A A A Output Function On Reset Input=0 7 8 Turing Machine Formal Definition of a Turing Machine • Set of input symbols • A Turing Machine was a _____________ machine / - A A B A B B B - mathematical model of a machine proposed by Alan Turing • Set of output symbols Turing • It consisted of a controller which was an FSM and an • Set of states Machine "___________" roll of tape marked into distinct squares with • Initial state and initial square location input symbols in each square • State transition function {State x Input => Next State} – The tape was like _______________ and so we could now process an • Action Function {State x Input => Action} arbitrarily long input sequence with a finite set of states because we could use the tape to store results – At each state the Turing machine could – It had a read/write _______________ that could read and write the • ______________ a symbol from the current square of the tape symbol in the ___________ tape square – Based on the state and the symbol read it could then • ___________ a symbol from the tape • ___________ a symbol onto the tape (erasing the old symbol) • __________________ – ..and.. • Move the tape __________ or ________ or not move {R, L, N}
9 10 Sample Turing Machine Sample Turing Machine • Turing Machine to detect equal/unequal number of A's and B's • Turing Machine to detect equal/unequal number of A's and B's • The machine works by making repeated passes through the – Sample operation on "AAB" string, each time removing one A and one B. Eventually string is {‘A’,'X’},-,R Start - A A B - either empty (AEs = BEs) or something is leF (AEs G BEs) 'A','X',R A,RT - X A B - A,Rt • The steps the machine takes… 'B','X',L {'A','X','B'}, A,RT - X A B - 'X','-',R 'A','X',R '-',L – Start at beginning of string (left side) '-’,’-’,N - - – Move right looking for either an A or B or end of string Find Lt - - Start UNEQ First • If end of string found, number of AEs and BEs equal. Done. '-','-',R - - • If A or B found, replace it with an X. '-’,’-’,N - - – Continue to move right, looking for the other character or end of string 'B','X',R - - • If other character is found replace it with an X, back to start of string, repeat. 'A','X',L B,Rt '-','-’,N • If end of string reached (other character was NOT found), number AEs and BEs unequal. - - Done. 'B','X',R - - EQ {‘B’,'X’},-,R - - 11 12 TM Highlights Your Future CENG Courses CENG EE 109L (3) CS 350 (4) Pre-requisite Intro to CENG Intro to OS • ________________________ a Turing machine is not fun structure << None >> • But ________________ a current computer can do, a Turing machine can do and vice versa • We can use Turing machines to prove what current computers can't do CS 353 (3) or EE EE 277L (2) EE 154 (2) – What is computable? Fundamentals of Digital Intro. to Logic Design 450(3) – It a Turing Machine can't do it, a computer as we know it today _____________ do it Circuits << EE 109 >> Networks << EE 109 >> • Example of what isn't computable? << CS 350 >> – ________________ Problem: Write a program that is given another program as input and determines if that program will eventually halt. – Turing proved this is not computable in a famous paper EE 254L (4) • Turing also proved that there is a Turing Machine that could take as input a Digital Sys. Design description of another Turing Machine and then emulate its operation << EE 154 >> – _______________ Turing Machine – Forerunner of the "Stored Program Concept" (instructions & data are treated similarly) EE 477L (4) EE 454L (4) EE 457 (3) EE 451 (3) • If an algorithm is O(polynomial) on TM then it is also O(polynomial) on a Computer Sys. Org. Parallel & Distributed VLSI Intro. to SoC __________________ computer as well << EE 254L >> << EE 355 or << EE 277L, 254L >> << EE 254L >> CSCI 104>> – Modern computers just seek to increase performance
13 Congratulations!! • You have learned a LOT this semester • You should be proud of yourself and what you've designed, programmed, and built • This is just the beginning…you will learn how to design all kinds of complex and exciting software and hardware systems – SW and HW are integrally intertwined…the more you know about each the better engineer you will be • Stay curious! Don't be afraid to try, fail, then debug
Recommend
More recommend