ee 109 unit 20 theoretical computer science and turing
play

EE 109 Unit 20 Theoretical Computer Science and Turing Machines 2 - PowerPoint PPT Presentation

1 EE 109 Unit 20 Theoretical Computer Science and Turing Machines 2 Credit: Adapted from Gaurav Sukhatme's CSCI 109 Lecture Slides THEORETICAL COMPUTER SCIENCE 3 Computability Theoretical Computer Science The study of what can be


  1. 1 EE 109 Unit 20 – Theoretical Computer Science and Turing Machines

  2. 2 Credit: Adapted from Gaurav Sukhatme's CSCI 109 Lecture Slides THEORETICAL COMPUTER SCIENCE

  3. 3 Computability • Theoretical Computer Science – The study of what can be computed and how efficiently – Uses mathematical models – Tries to generalize computers so that what is proven is applicable to ANY computer system no matter its speed, # of processors, etc.

  4. 4 State Machine Review • Recall that a state machine is defined by a 6-tuple: – A set of possible input values – A set of possible states – A set of possible outputs – An initial state – A transition function: {States x Inputs} -> the Next state – An output function: {States x Inputs} -> Output value(s) Input=1 Input=1 Input=1 Input=0 S0 S1 S2 Out=False Out=False out=True Input=0 On Reset Input=0

  5. 5 Formal Definition • Mathematically, a state machine consists of: Inputs – A set of possible input values: {0, 1} State 0 1 – A set of possible states: {S0, S1, S2} S0 S0 S1 – A set of possible outputs: {False, True} S1 S0 S2 – An initial state = S0 S2 S0 S2 – A transition function: • {States x Inputs} -> the Next state State Transition Function – An output function: Inputs • {States x Inputs} -> Output value(s) State 0 1 Input=1 Input=1 Input=1 Input=0 S0 False False S1 False False A B C S2 True True Out=False Out=False out=True Input=0 Output Function On Reset Input=0

  6. 6 Limits of FSM's • Finite state machines have certain limits – Why? Because they have a finite number of states! • Problem: Given an arbitrary length string of A's and B's determine if there is an equal number of A's and B's – Key is "arbitrary length" – Show execution for "AABABBBBA" initial B B B B B B 1 2 2 1 Extra Extra Extra Extra Equal B B's As A A A A A A A

  7. 7 Turing Machine • A Turing Machine was a fictitious machine / mathematical model of a machine proposed by Alan Turing • It consisted of a controller which was an FSM and an "infinite" roll of tape marked into distinct squares with input symbols in each square – The tape was like memory/RAM and so we could now process an arbitrarily long input sequence with a finite set of states because we could use the tape to store results – It had a read/write "head" that could read and write the symbol in the current tape square

  8. 8 Formal Definition of a Turing Machine • Set of input symbols - A A B A B B B - • Set of output symbols Turing • Set of states Machine • Initial state and initial square location • State transition function {State x Input => Next State} • Action Function {State x Input => Action} – At each state the Turing machine could • Read a symbol from the current square of the tape – Based on the state and the symbol read it could then • Erase a symbol from the tape • Write a symbol onto the tape (erasing the old symbol) • Do nothing – ..and.. • Move the tape right or left or not move {R, L, N}

  9. 9 Sample Turing Machine • Turing Machine to detect equal/unequal number of A's and B's • The machine works by making repeated passes through the string, each time removing one A and one B. Eventually string is either empty (A’s = B’s) or something is left (A’s ≠ B’s) • The steps the machine takes… – Start at beginning of string (left side) – Move right looking for either an A or B or end of string • If end of string found, number of A’s and B’s equal. Done. • If A or B found, replace it with an X. – Continue to move right, looking for the other character or end of string • If other character is found replace it with an X, back to start of string, repeat. • If end of string reached (other character was NOT found), number A’s and B’s unequal. Done.

  10. 10 Sample Turing Machine • Turing Machine to detect equal/unequal number of A's and B's – Sample operation on "AAB" 'X',-,R Start - A A B - 'A','X',R A,RT - X A B - A,Rt 'B','X',L {'A','X','B'}, A,RT - X A B - 'X','-',R 'A','X',R '-',L Lt '-','-',N - X A X - Find Lt - X A X - Lt Start UNEQ First '-','-',R Lt - X A X - '-','-',N Find - X A X - 'B','X',R Find - X A X - 'A','X',L B,Rt '-','-',N A,Rt - X X X - 'B','X',R A,Rt - X X X - EQ 'X',-,R UNEQ - X X X -

  11. 11 TM Highlights • Programming a Turing machine is not fun • But anything 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 – What is computable? – It a Turing Machine can't do it, a computer as we know it today can't do it • Example of what isn't computable? – Halting 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 • Turing also proved that there is a Turing Machine that could take as input a description of another Turing Machine and then emulate its operation – Universal Turing Machine – Forerunner of the "Stored Program Concept" (instructions & data are treated similarly) • If an algorithm is O(polynomial) on TM then it is also O(polynomial) on a normal computer as well – Modern computers just seek to increase performance

  12. 12 Your Future CENG Courses CENG EE 109L (3) CS 350 (4) Pre-requisite Intro to CENG Intro to OS structure << None >> CS 353 (3) or EE EE 277L (2) EE 154 (2) Fundamentals of Digital Intro. to Logic Design 450(3) Circuits << EE 109 >> Networks << EE 109 >> << CS 350 >> EE 254L (4) Digital Sys. Design << EE 154 >> EE 477L (4) EE 454L (4) EE 457 (3) EE 451 (3) Computer Sys. Org. Parallel & Distributed VLSI Intro. to SoC << EE 355 or << EE 254L >> << EE 277L, 254L >> << EE 254L >> CSCI 104>>

  13. 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