Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation Dale Roberts, Lecturer Computer Science,

Slides:



Advertisements
Similar presentations
Turing Machines January 2003 Part 2:. 2 TM Recap We have seen how an abstract TM can be built to implement any computable algorithm TM has components:
Advertisements

Chapter 11: Models of Computation
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
Chapter 10 Models of Computation. What is a model? Captures the essence – the important properties – of the real thing Captures the essence – the important.
Chapter 1: An Introduction to Computer Science Invitation to Computer Science, C++ Version, Third Edition.
Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?
CSci 107 Introduction to Computer Science Lecture 1.
Courtesy Costas Busch - RPI1 Turing Machines. Courtesy Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 Computing Functions with Turing Machines. 2 A function Domain: Result Region: has:
1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal.
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov.
1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Formal Definition –Equivalence.
Costas Busch - RPI1 Turing Machines. Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 2: Algorithm Discovery and Design
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
Design and Analysis of Algorithms
CSCI-100 Introduction to Computing Algorithms Part I.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
Randomized Turing Machines
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
The Algorithmic Model. What is Computer Science What is Programming Algorithms –Definition –Properties of Good Algorithms –Describing Algorithms –Examples.
Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems.
Introduction to Algorithms. What is Computer Science? Computer Science is the study of computers (??) This leaves aside the theoretical work in CS, which.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer.
Computer Science 101 Introduction.
A Universal Turing Machine
Turing Machines. Intro to Turing Machines A Turing Machine (TM) has finite-state control (like PDA), and an infinite read-write tape. The tape serves.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Part 1 – Pages COMPUTABILITY THEORY.
Computer Science 101 Theory of Computing. Computer Science is... The study of algorithms, with respect to –their formal properties –their linguistic realizations.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
Fundamentals of Informatics Lecture 3 Turing Machines Bas Luttik.
Lecture 9  2010 SDU Lecture9: Turing Machine.  2010 SDU 2 Historical Note Proposed by Alan Turing in 1936 in: On Computable Numbers, with an application.
Capabilities of computing systems Numeric and symbolic Computations A look at Computability theory Turing Machines.
Theory of computing, part 4. 1Introduction 2Theoretical background Biochemistry/molecular biology 3Theoretical background computer science 4History of.
1 Turing machines Chapter 4, Smith and Kimber. A Turing machine is an abstraction of a human “computer”. Consists of - control, in the form of states -
Turing Machines Lecture 26 Naveen Z Quazilbash. Overview Introduction Turing Machine Notation Turing Machine Formal Notation Transition Function Instantaneous.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
CS 154 Formal Languages and Computability April 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
1 Computing Functions with Turing Machines. 2 A function Domain Result Region has:
Universal Turing Machine
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
CSE202: Introduction to Formal Languages and Automata Theory
Lecture 2 Introduction to Programming
Turing Machines 2nd 2017 Lecture 9.
Chapter 9 TURING MACHINES.
CSci 107 Introduction to Computer Science
Programming Fundamentals (750113) Ch1. Problem Solving
Computing Functions with Turing Machines
P.V.G’s College of Engineering, Nashik
Formal Definitions for Turing Machines
Presentation transcript:

Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation Dale Roberts, Lecturer Computer Science, IUPUI

Dale Roberts Algorithms Computer Science is a study of algorithms, which includes: their formal mathematical properties their hardware realizations their linguistic realizations their applications Therefore, our task is to: design and develop algorithms to solve problems study the algorithms to see if they are correct or efficient design and build computer systems which can execute these algorithms design programming languages and translate these algorithms into these languages

Dale Roberts “If we can specify an algorithm for a problem, then we can automate its solution” Definition of an Algorithm consists of unambiguous & computable operations produce a result halt in a finite amount of time

Dale Roberts Examples of Algorithm A good example of an algorithm A recipe for cherry pie step 1: mix 1 cup sugar, ¼ cup flour, ¼ tsp. salt step 2: stir in ½ cup juice from the cherries step 3: Cook & stir over medium heat until thick step 4: Add 3 cups canned, pitted red cherries step 5: Add 1 tblsp. butter & 4 drops almond extract step 6: Make pie crust & place in a 9 inch pie plate step 7: Fill crust with cherry mix & top with 2 nd crust step 8: Bake at 450 o F for 10 mins. then 350 for 45 mins.

Dale Roberts A bad example of an algorithm How to use shampoo XYX step 1: Wet hair step 2: Lather step 3: Rinse step 4: Repeat What is wrong with algorithm?

Dale Roberts Algorithmic problem Solving Approach Algorithm Discovery and Design Problem: Assume that we have a list of 10,000 names called N 1, N 2, N 3, …, N 10,000, along with their telephone numbers which we denotes as T 1, T 2, T 3, …, T 10,000. Assume that the numbers are not in alphabetical order. Design an algorithm which allows to input the name of any specific person, same NAME. The algorithm should look for NAME in the list of names and, if found, print the corresponding telephone number. If the name is not found, print a message “ sorry NAME not found on the list ” NamesNumbers N 1 T 1 N 2 T 2 N 3 T 3 … Name ip … …… N 10,000 T 10,000

Dale Roberts Method 1: LineOperation 1If NAME = N 1 then write out the value T 1 2If NAME = N 2 then write out the value T 2 3If NAME = N 3 then write out the value T 3 … 9,999If NAME = N 9,999 then write out the value T 9,999 10,000If NAME = N 10,000 then write out the value T 10,000 10,001Stop

Dale Roberts Method 2: The sequential Search Algorithm LineOperation 1Set the value of i to 1 2Repeat lines 3 through 5 until either NAME is found or the value of i exceeds 10,000 3 Check to see if NAME is equal to the i th name on the list, i.e., N i. 4 If they are equal then write the telephone number of that person, T i, and mark that NAME has been found 5 Add 1 to the value of i 6 If NAME was not found then write out the message “ I am sorry ….” 7 Stop, you are done.

Dale Roberts Method 3: 2 nd Attempt at Designing A sequential Search Algorithm LineOperation 1Set the value of i to 1 2Repeat lines 3 through 5 until NAME is found 3 Check to see if NAME is equal to the i th name on the list, i.e., N i. 4 If they are equal then write the telephone number of that person, T i, and mark that NAME has been found 5 Add 1 to the value of i 6 Stop, you are done.

Dale Roberts Algorithm Analysis Not only we are interested in finding a solution, we are also interested in finding an efficient one. In the previous problem, how many comparisons does it take to find a NAME ? Best case situation: 1 comparison Worst case situation: n comparisons, where n = 10,000 Average case situation: (n+1)/2, where n=10,000

Dale Roberts If N is a small number, ex. 100, we may not see much significant difference. However, consider the following example: N.Y. City telephone directory has 20,000,000 entries. A computer can do 50,000 comparisons per second. Therefore, the average time to locate NAME is (20,0000,000/50,000)/2  3½ minutes, or approximately 7 minutes to tell NAME is not in the list!!! (20,0000,000/50,000)/2  3½ minutes, or approximately 7 minutes to tell NAME is not in the list!!!

Dale Roberts Models of Computation What is a model? Capture the important properties of the real thing probably be different in scale from the real thing suppress details of the real thing lack full functionality of the real thing Example: A model to compute the distance traveled for a moving vehicle: d = r*t d = distance; r = rate of speed; t = time

Dale Roberts Why we need models if they are not the real thing? By changing some aspects, we can observe their effects Can provide an environment for learning They can be used as design tools without actually building the real thing – for economic reasons In summary, they can be predict, can be used for training, can be used as test beds.

Dale Roberts Model of a Computing Agent Q: Operations in an algorithm must be unambiguous and effectively computable. Therefore, could we design a model of an algorithm before we implement the algorithm in hardware and /or software? A: A computing agent (robot) is a thing/a person that carries out the operations described in an algorithm.

Dale Roberts Properties of a Computing Agent can accept an input can store & retrieve information from memory can take actions according to instructions – the actions may depend upon a present state and the current input can produce an output Agent So, what is a State? Environment Input Output motor agent ?

Dale Roberts Consider a simple scenario: If I am in my office: if the phone rings; I’ll answer the phone and leave my office if the phone does not ring; I’ll not answer the phone and will stay in the office If I am NOT in my office: if the phone rings; I’ll NOT answer the phone but I’ll come back to my office if the phone does not ring; I’ll not answer it and will stay away from the office A Concept of a State Phone ringI am in office AnswerI will be in office? Office 0/1 Phone 0/1 Answer the Phone 0/1

Dale Roberts Output depends NOT ONLY on the INPUT, but also depends on the internal (current) state of the office (0/1). Let A: is a state when I’m in the office B: is a state when I’m NOT in the office State TableState Transition Diagram Present StateNext State (Output) phone = 0phone = 1 AA, 0B, 1 BB, 0A, 0 AB 1 / 1 1 / 0 0 / 0 in officeout of office

Dale Roberts The Turing Machine (TM) Turing Machine is a model of computing agent. It is a pencil-and-paper type model that captures the essential features of a computing agent. A Turing machine consists of 1. a tape that extends infinitely in both directions 2. the tape is divided into cells, each cell can carry a symbol. 3. the symbols comes from a finite set of symbols called the alphabet 4. the alphabet consists of symbols : b (blank), 0, 1, and special symbols X & Y 5. the tape serve as memory 6. has a finite number of k states, 1, …k..bb011bb. 1

Dale Roberts A Turing machine can do only one operation at a time. Each time an operation is done, three actions may take place: 1. write a symbol to cell 2. go into a new state 3. move one cell left or right The above actions depends on: The current state of the machine content of cell currently being read (input)

Dale Roberts current state next state output input action (direction) The Turing Machine (TM)..bb011bb. 1..bb111bb. 1212 12 0/1 R State: where you are now. R W Your movement output input State Transition: Example: Assume a Turing machine (TM) instruction: if you are in state 1 if you are in state 1and you are reading symbol 0 you are reading symbol 0then write symbol 1 onto tape write symbol 1 onto tape go into state 2 go into state 2 move right move right Written as: (1,0,1,2,R)

Dale Roberts The Turing Machine (TM) Example: Design a Turing Machine which will invert the string of binary digits if the input string is then the output string should be let us draw a state diagram The TM instruction sets will be (1,0,1,1,R)(1,1,0,1,R) Let the initial configuration be :... b b b b b b b b b b b b b b /0 0/1

Dale Roberts Unary representation is used in order to do any arithmetic operations on a TM. Unary representation looks as follows 0  1 1  11 2    Example: Design a Turing Machine to add 1 to any number start in state 1 if the state is 1 and current input is 1, write 1 and move right and stay in state 1 if the current state is 1 and current input is b, write 1 and move to state 2 and move right and HALT TM instructions: (1,1,1,1,R)(1,b,1,2,R) (2,b,-,-,-) not allowed! Let the initial configuration be:... b b b b b b... Unary Representation for TM 12 b/1 R 1/1 Halt s1 2 in unary representation 3 in unary representation s1 s2

Dale Roberts Example: Adding of two non-zero numbers (unary representation) Initial Setup.. b b 1 1 b.. Initial Setup.. b b 1 1 b.. Answer should be:.. b b b b.. (1,1,b,2,R): Erase leftmost 1 and move right (2,1,b,3,R): Erase second 1 and move right (3,1,1,3,R): pass over any 1’s until a blank is full (3,b,1,4,R): write 1 over the blank (4,1,1,4,R): pass over remaining 1’s (4,b,b,5,R): halt 12 1/b R 3 R 4 b/1 R 5 b/b R 1/1 Halt S1... b b 1 1 b... S2... b b 1 1 b 1 1 b... S3... b b b 1 b 1 1 b... S4... b b b b...

Dale Roberts Example: Add two numbers, initial setup would: a ‘ b ’ separate the two numbers.... b b b and the expected answer is... b b... 5 The TM instruction sets will be (1,1,1,1,R)(1,b,1,2,R)(2,1,1,2,R)(2,b,b,3,L)(3,1,b,4,L)(4,1,b,5,L) Let the initial configuration be: S1... b b b... S2... b b... S3... b b... S4... b b b... S5... b b b b b/1 R 3 b/b L 4 1/b L 5 L 1/1 RR

Dale Roberts Example: Add two numbers, try(1,1,b,2,R)(2,1,b,3,R)(3,1,1,3,R)(3,b,1,4,R) if an initial configuration is b b b b b /b R 3 R 4 b/1 R 1/1 R S1... b b b b b... S2... b b b 1 1 b b b... S3... b b b b 1 b b b... S3... b b b b b b... S4... b b b b b b...