1
EE 109 Unit 20 Theoretical Computer Science and Turing Machines 2 - - PowerPoint PPT Presentation
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
2
THEORETICAL COMPUTER SCIENCE
Credit: Adapted from Gaurav Sukhatme's CSCI 109 Lecture Slides
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
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)
S0
Out=False
S1
Out=False
S2
- ut=True
Input=1 Input=1 Input=0 Input=1 Input=0 Input=0 On Reset
5
Formal Definition
- Mathematically, a state machine consists of:
– A set of possible input values: {0, 1} – A set of possible states: {S0, S1, S2} – A set of possible outputs: {False, True} – An initial state = S0 – A transition function:
- {States x Inputs} -> the Next state
– An output function:
- {States x Inputs} -> Output value(s)
A
Out=False
B
Out=False
C
- ut=True
Input=1 Input=1 Input=0 Input=1 Input=0 Input=0 On Reset
Inputs State 1 S0 S0 S1 S1 S0 S2 S2 S0 S2
State Transition Function Output Function
Inputs State 1 S0 False False S1 False False S2 True True
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"
Equal 1 Extra A 1 Extra B 2 Extra As 2 Extra B's
A A A A B B B B A A B B initial
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
Formal Definition of a Turing Machine
- Set of input symbols
- Set of output symbols
- Set of states
- 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}
A A B A B B B
Turing Machine
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
Sample Turing Machine
- Turing Machine to detect equal/unequal number of A's and B's
– Sample operation on "AAB"
Start
- A A B -
A,RT
- X
A B -
A,RT
- X
A B -
Lt
- X
A X
- Lt
- X
A X
- Lt
- X
A X
- Find
- X
A X
- Find
- X
A X
- A,Rt
- X
X X
- A,Rt
- X
X X
- UNEQ
- X
X X
- Start
EQ A,Rt B,Rt UNEQ Lt Find First
'A','X',R 'B','X',R '-','-',N '-','-',N 'B','X',L 'A','X',L '-','-',R 'A','X',R 'B','X',R '-','-',N {'A','X','B'}, '-',L 'X',-,R 'X',-,R 'X','-',R
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
CENG
Pre-requisite structure
Your Future CENG Courses
EE 109L (3)
Intro to CENG
<< None >>
EE 277L (2)
Fundamentals of Digital Circuits << EE 109 >>
EE 154 (2)
- Intro. to Logic Design
<< EE 109 >>
EE 254L (4)
Digital Sys. Design
<< EE 154 >>
EE 457 (3)
Computer Sys. Org. << EE 254L >>
EE 454L (4)
- Intro. to SoC
<< EE 254L >>
EE 451 (3)
Parallel & Distributed << EE 355 or CSCI 104>>
CS 353 (3) or EE 450(3)
Networks
<< CS 350 >>
CS 350 (4)
Intro to OS
EE 477L (4)
VLSI
<< EE 277L, 254L >>
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