cs 345: chapter 9 algorithmic universality and its robustness or the simplest machines that get it...

26
CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Upload: conner-drain

Post on 14-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

CS 345: Chapter 9Algorithmic Universality and Its

RobustnessOr

The Simplest Machines that Get It Done

Page 2: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Search For Simplicity

• The beginning of this chapter focuses on reducing an algorithm to its simplest components.

• Part of the purpose of this is to find a model of computation that is general in nature.

• Note that is driven partly by the nature of the mathematician.

Page 3: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• Also, by removing the dependency on a particular machine, language, technology, an algorithm can be examined in its essential form.

• A common model of computation in theoretical computer science was developed by Alan Mathison Turing (1912 - 1954)

• Turing developed the concept of a Universal – Algorithm Machine.

• Today, we call this model a Turing Machine (TM).

Page 4: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Turing Machines

• Although a Turing Machine (TM) has an elegant mathematical definition, we can visualize one as a physical entity.– Tape for input and output– Read/Write head– Finite-State Machine for control– Example: EVEN-EVEN, PALINDROME

Page 5: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Turing Machine TM = (Q, , , , q0, , F)

Q = a finite set of internal states

= a finite set of symbols: the input alphabet.

= a finite set of symbols: the tape alphabet.

: Q Q { L, R }, a transition function

q0 Q is the initial state.

is a blank symbol and F Q is a set of halt states.

It is assumed that {}

Page 6: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

EVEN-EVEN• Determines if a string of a’s and b’s have an

even number of both.

• Uses 4 states– S1: read even a’s and even b’s– S2: read even a’s and odd b’s– S3: read odd a’s and even b’s– S4: read odd a’s and odd b’s– If you HALT in S1, there are an even number

of a’s and b’s

Page 7: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

EVEN-EVEN

a

a

a

a

bbbb

S1

S2 S4

S3

Page 8: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

PALINDROME

• Uses 8 states

• Read first letter of input, remember it, then erase it.

• Go to other end of input, check that it is same letter.

• If same letter, erase it, go to beginning of input and repeat process. If not, then crash

Page 9: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

a/# R

#/# R

a/a Rb/b R

a/a Rb/b R

a/a Lb/b L

a/a Lb/b L

#/# R

#/# Ra/# L

b/# L

b/# R

#/# R

#/# R

#/# L

#/# L

1

2

5

3 4

6 7

8 PALINDROME

Page 10: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Programming A Turing Machine

• We can think of a TM as a primitive type of computer that executes a fixed program.

• The program is stored within the TM’s state-transition diagram.

• The input is coded as a linear set of strings created from the input alphabet and stored on the tape.

Page 11: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• A TM can be used to solve a decision problem by having one halt state for “yes” and one for “no”.

• For a non-decision problem, a TM can use special marks to indicate its output or erase its tape leaving only its output.

• A TM has very limited actions and is very tedious to program for even trivial problems. However, we can ask, “exactly what can be solved by a TM?”

Page 12: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

The Church-Turing Thesis• Which algorithmic problems can be solved by a TM?

• Any algorithmic problem for which we can find an algorithm that can be programmed in some programming language, any language, running on some computer, any computer, even one that has not been built yet, but can be built, and even one that will require unbounded amounts of time and memory space for ever-larger inputs is solvable by a Turing Machine.

• A TM is capable of solving any effectively solvable algorithmic problem.

Page 13: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• The Church-Turing Thesis is not a theorem.

• The Church-Turing Thesis equates the mathematically precise notion of solvable by a Turing Machine with the informal, intuitive notion of solvable effectively, which refers to real computers and languages.

• Although it sounds like wild speculation, it is a deep and far-reaching statement put forward by two of the most respected pioneers of theoretical computer science.

Page 14: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Computability is Robust

• models of a universal computer– Alonzo Church: Lambda Calculus– Alan Turing: Turing Machines– Emil Post: Production Systems– Stephen Kleene: Recursive Functions

• A consequence of the Church-Turing Thesis is that all these formalisms have been shown to be equivalent

Page 15: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• Another meaning for robustness is that the class of computable, effectively solvable, or decidable algorithmic problems remains the same even when we change the computer model or the programming language.

• This means that all programming languages that have the same capabilities of a TM are equivalent in terms of the problems they can solve.

• This robustness applies even to variants of a TM

Page 16: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Variants of a Turing Machine

• Movement: Left, Right, No movement

• One-way infinite tape.

• Multiple tapes: multiple read/write heads or movement in multiple dimensions

• Transducers and Acceptors

• The equivalence of these different variations is shown by demonstration how one type of machine can simulate another.

Page 17: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Simulation as Reduction

• To say one model of computation can simulate another is to say there is a reduction from one model to another.

• An interesting concept is that one TM can simulate another. That is, a TM can take for input an encoded TM and its input and run the encoded TM on the given input.

• This is similar to what an interpreter does.

Page 18: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• A Turing Machine can be encoded using strings of 0 and 1. In this manner, a TM can be associated with a number.

• This number is called its Gödel number and the process of encoding a TM as a number is called the Gödelization of a TM.

• The TM that takes for input the encoding of any other TM together with its input and simulates the second TM running on its input is called the Universal Turing Machine.

Page 19: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• The UTM was designed by Turing in 1936 and is not only the foundation of all Computer Theory, but it was also the conceptual archetype of the early computers.

Page 20: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

TM’s and P vs. NP

• A TM is very inefficient for even trivial tasks.

• However, a TM is only polynomially less efficient than even the most sophisticated computers

• Therefore, we can define a problem to belong to P if it can be solved by a deterministic TM in polynomial time

Page 21: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• A problem belongs to NP if it can be solved in polynomial time by a nondeterministic Turing Machine

• Turing Machine for Lower Bound Proofs

• Turing Machine with one-way tape or Finite Automata

• Finite Automata with a Push Down Stack or PDA

• Turing Machine with a bounded tape (not infinite) or LBA

Page 22: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Languages and Machines

• The study of formal languages looks at the relationship between types of languages and the type of machine that can recognize or accept that language.

• For example, the type of language recognized by a FA is called a regular language

Page 23: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• As part of this language, a FA can recognize when there are an even number of a’s and b’s in a string, but it cannot tell if there are the same number of a’s and b’s

• A FA cannot count because it has no memory only states and there is a finite number of states.

• The matching of machine’s, languages, and grammars is known as the Chomsky Hierarchy after linguist Noam Chomsky

Page 24: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Chomsky Hierarchy

Type Language Acceptor

0 RecursivelyEnumerable

T.M.

1 Context-Sensitive L.B.A.

2 Context-Free P.D.A

3 Regular F.A.

Page 25: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

• One area where this study of formal languages and machines is important is for compiler construction

• Another area is Natural Language Processing.

• FA are used to represent many processes. Note, figure 9.14 on page 247. If you know what a DFD is, this figure might look similar.

• A FA is used by the scanner of a compiler to recognize tokens.

Page 26: CS 345: Chapter 9 Algorithmic Universality and Its Robustness Or The Simplest Machines that Get It Done

Letter

Letter or Digit

Letter or Digit

Underscore

A simple FA for recognizing an identifierin Java