Introduction to CS Theory

14
Introduction to CS Theory Lecture 15 – Turing Machines Piotr Faliszewski [email protected]

description

Introduction to CS Theory. Lecture 15 –Turing Machines Piotr Faliszewski [email protected]. Models of computation Finite automata Pushdown automata Restrictions FA Finite memory Left-to-right access to input PDA Infinite memory… … but accessible only in a stack form - PowerPoint PPT Presentation

Transcript of Introduction to CS Theory

Page 1: Introduction to CS Theory

Introduction to CS Theory

Lecture 15 – Turing MachinesPiotr [email protected]

Page 2: Introduction to CS Theory

Our Models of Computation So Far

Models of computation Finite automata Pushdown automata

Restrictions FA

Finite memory Left-to-right access to

input PDA

Infinite memory… … but accessible only

in a stack form Left-to-right access to

input

Unrestricted model of computation? Turing machine

δ, q

…0 0 1 1 0 0 0

Page 3: Introduction to CS Theory

Church-Turing Thesis

Church-Turing Thesis A language can be

solved by an algorithm if and only if it can be accepted by a Turing machine that terminates on every output.

How to validate Church-Turing Thesis? Many models of

algorithms Unrestricted grammars Lambda calculus RAM machines … all equivalent to

Turing machines

Can Church-Turgin thesis be proven?

Turing machines were, at the time, the most convincing model

Page 4: Introduction to CS Theory

Definition

Turing machine M is a quintuple M = (Q, Σ, Γ, q0, δ) where:

Q – finite set of states, assumed not to contain the two halting states, ha and hr.

Σ is the input alphabet and Γ is the tape alphabet. Σ Γ. Γ does not contain the special blank symbol Δ

q0 – the initial state δ – the transition function

δ: Q (Γ {Δ}) (Q {ha, hr}) (Γ {Δ}) {R, L, S}

δ is a total funciton (i.e., your machine should not get stuck in a non-halting state without knowing what to do)

Page 5: Introduction to CS Theory

Transition of a TM

δ(q, X) = (p, Y, D) means: If the machine is in state

q, scanning symbol X, then:

Change state to p Replace symbol X with

symbol Y Move the tape according

to the direction D (L – left, R – right, S – stay)

Questions What happens if the

machine “falls off” the left side of the tape?

Do we really need the “S” move?

Example Strings of length 2n

Turing machine for the palindromes language

Page 6: Introduction to CS Theory

Configurations

Configuration of a Turing machine Contents of the tape Position of the head Current state

Notation (q, xay) means that

Machine in state q The head is at the last

symbol of the string xa

The head is followed by string y, followed by an infinte number of blank symbols

Initial configuration (q0, Δx) x – machines’s input

string

Given a Turing machine T, we define relation (q,xay) (p,zbw) If the latter can be

obtained in one step from the former

Page 7: Introduction to CS Theory

Languages Accepted by TMs

Definition. Let M = (Q, Σ, Γ, q0, δ)

and let x Σ*

x is accepted by M if

(q0, Δx) * (ha, yaz)

for some y,a, z

A string can be rejected if: M ends up in state hr, or M runs forever on x

Notation L(M) – language

accepted by a Turing machine M

If a language is accepted by a Turing machine then we say that it is recursively enumerable

The set of all languages accetped by Turing machines is called RE

If a language is accepted by a Turing machine that halts on all inputs then we say that it is recursive

Page 8: Introduction to CS Theory

Examples

Give a Turing machine for the following language

{ aibici | i ≥ 0 }

Page 9: Introduction to CS Theory

Computing a Function on a TM

Definition Let M = (Q, Σ, Γ, q0, δ) be a TM Let f: Σ* Γ* be a total function We say that M computes f if for each x in Σ* it holds

that(q0, Δx) * (ha,Δf(x))

Example Give a TM that computes f(1n) = 12n

Page 10: Introduction to CS Theory

Power of Turing Machines

We can add extra features to a Turing machine 2-way infinite tape More than one tape Random access to the

memory Nondeterminisms 2-dimensional tape

Example: Try to simulate these

features (or prove that simulation is possible)

None of the extra features strengthens the model!

Page 11: Introduction to CS Theory

Languages and Decision Problems

Decision problem Name Input

the mathematical entities about whose properties we ask

Question A well-defined yes/no

question

Language A set of strings Languages encode

decision problems

Example Name: Connectivity Input: Graph G, vertices

s and t Question: Are vertices s

and t connected in G

Page 12: Introduction to CS Theory

Languages and Decision Problems

Our two fundamental questions What decision problems

can and cannot be solved?

What decision problem can and cannot be solved efficiently

We focus on languages

Chomsky Hierarchy

Models of computation Regular languages /

finite automata Context-free

languages / push-down automata

Turing machines

Page 13: Introduction to CS Theory

Hierarchy of Languages

Finite languages

Context-freelanguages

Recursive languages

All languages

Page 14: Introduction to CS Theory

Undecidable Languages

Can everything be solved on a computer? Recursive languages Recursively enumerable

languages do they really exist?

Two proofs… Counting… And an example of a

language