• Keine Ergebnisse gefunden

B9. Turing Machines I

N/A
N/A
Protected

Academic year: 2022

Aktie "B9. Turing Machines I"

Copied!
6
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Theory of Computer Science

B9. Turing Machines I

Gabriele R¨ oger

University of Basel

April 7, 2021

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 1 / 23

Theory of Computer Science

April 7, 2021 — B9. Turing Machines I

B9.1 Turing Machines

B9.2 Summary

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 2 / 23

B9. Turing Machines I Turing Machines

B9.1 Turing Machines

B9. Turing Machines I Turing Machines

Automata for Type-1 and Type-0 Languages?

Finite automata

recognize exactly the regular languages, push-down automata exactly the context-free languages. Are there automata models for context-sensitive

and type-0 languages?

Yes! Turing machines

German: Turingmaschinen

(2)

Alan Turing (1912–1954)

Picture courtesy of Jon Callas / wikimedia commons

I British logician, mathematician, cryptanalyst and computer scientist I most important work (for us):

On Computable Numbers, with an Application to the Entscheidungsproblem

Turing machines

I collaboration on Enigma decryption I conviction due to homosexuality;

pardoned by Elizabeth II in Dec. 2013 I Turing award most important

science award in computer science

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 5 / 23

Turing Machines: Conceptually

b a c a c a c a . . . (one-sided) infinite tape

read-write head

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 6 / 23

B9. Turing Machines I Turing Machines

Turing Machine: Definition

Definition (Deterministic Turing Machine)

A (deterministic) Turing machine (DTM) is given by a 7-tuple M = hQ, Σ, Γ, δ, q 0 , q accept , q reject i, where

Q , Σ, Γ are all finite sets and I Q is the set of states,

I Σ is the input alphabet, not containing the blank symbol , I Γ is the tape alphabet, where ∈ Γ and Σ ⊆ Γ,

I δ : (Q \ {q accept , q reject }) × Γ → Q × Γ × {L, R}) is the transition function,

I q 0 ∈ Q is the start state, I q accept ∈ Q is the accept state,

I q ∈ Q is the reject state, where q 6= q .

B9. Turing Machines I Turing Machines

Turing Machine: Transition Function

Let M = hQ , Σ, Γ, δ, q 0 , q accept , q reject i be a DTM.

What is the Intuitive Meaning of the Transition Function δ?

δ(q, a) = hq 0 , b, Di:

I If M is in state q and reads a, then I M transitions to state q 0 in the next step, I replacing a with b,

I and moving the head in direction D ∈ {L, R}, where:

I R: one step to the right,

I L: one step to the left, except if the head is on the left-most cell of the tape in which case there is no movement

q a → b, D q

0

(3)

Deterministic Turing Machine: Example

h{q 1 , . . . , q 5 , q accept , q reject }, {0}, {0, x, }, δ, q 1 , q accept , q reject i

q

1

q

2

q

3

q

4

q

5

q

accept

q

reject

0 → , R

→ , R

x → x, R → , R

0 → x, R

0 → 0, R → , L

0 → x, R → , R

x → x, R

x → x, R x → x, R

x → x, L 0 → 0, L

→ , R

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 9 / 23

Turing Machine: Configuration

Definition (Configuration of a Turing Machine) A configuration of a Turing machine

M = hQ, Σ, Γ, δ, q 0 , q accept , q reject i is given by a triple c ∈ Γ × Q × Γ + . German: Konfiguration

Configuration hw 1 , q, w 2 i intuitively means that I the non-empty or already visited part of the tape

contains the word w 1 w 2 ,

I the read-write head is on the first symbol of w 2 , and I the TM is in state q.

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 10 / 23

B9. Turing Machines I Turing Machines

Turing Machine Configurations: Example

Example

configuration hBEFORE, q, AFTER i.

B E F O R E A F T E R . . .

q

B9. Turing Machines I Turing Machines

Turing Machine Configurations: Start Configuration

Initially

I the TM is in start state q 0 ,

I the head is on the first tape cell, and

I the tape contains the input word w followed by an infinite number of entries.

The corresponding start configuration is hε, q 0 , wi if w 6= ε

and hε, q 0 , i if w = ε.

(4)

Turing Machine: Step

Definition (Transition/Step of a Turing Machine) A DTM M = hQ, Σ, Γ, δ, q 0 , q accept , q reject i transitions

from configuration c to configuration c 0 in one step (c ` M c 0 ) according to the following rules:

I ha 1 . . . a m , q, b 1 . . . b n i ` M ha 1 . . . a m−1 , q 0 , a m cb 2 . . . b n i if δ(q, b 1 ) = hq 0 , c , Li, m ≥ 1, n ≥ 1

I hε, q, b 1 . . . b n i ` M hε, q 0 , cb 2 . . . b n i if δ(q, b 1 ) = hq 0 , c , Li, n ≥ 1

I ha 1 . . . a m , q, b 1 . . . b n i ` M ha 1 . . . a m c, q 0 , b 2 . . . b n i if δ(q, b 1 ) = hq 0 , c , Ri, m ≥ 0, n ≥ 2

I ha 1 . . . a m , q, b 1 i ` M ha 1 . . . a m c, q 0 , i if δ(q, b 1 ) = hq 0 , c , Ri, m ≥ 0

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 13 / 23

Step: Exercise (Slido)

q

1

q

2

q

3

q

4

q

5

q

accept

q

reject

0 → , R

→ , R

x → x, R → , R

0 → x, R

0 → 0, R → , L

0 → x, R → , R

x → x, R

x → x, R x → x, R

x → x, L 0 → 0, L

→ , R

h x, q 3 , 00i ` ?

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 14 / 23

B9. Turing Machines I Turing Machines

DTM: Accepted Words

Intuitively, a DTM accepts a word if its computation terminates in the accept state.

Definition (Words Accepted by a DTM)

DTM M = hQ, Σ, Γ, δ, q 0 , q accept , q reject i accepts the word

w = a 1 . . . a n if there is a sequence of configurations c 0 , . . . , c k with

1

c 0 is the start configuration of M on input w ,

2

c i ` M c i+1 for all i ∈ {0, . . . , k − 1}, and

3

c k is an accepting configuration, i. e., a configuration with state q accept .

B9. Turing Machines I Turing Machines

Accepted Word: Example

Does this Turing machine accept input 0000?

q

1

q

2

q

3

q

4

q

5

q

accept

q

reject

0→,R

→,R

x→x,R →,R

0→x,R

0→0,R →,L

0→x,R →,R

x→x,R

x→x,R x→x,R

x→x,L 0→0,L

→,R

(5)

DTM: Recognized Language

Definition (Language Recognized by a DTM) Let M be a deterministic Turing Machine

The language recognized by M (or the language of M) is defined as L(M ) = {w ∈ Σ | w is accepted by M}.

Definition (Turing-recognizable Language)

We call a language Turing-recognizable if some deterministic Turing machine recognizes it.

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 17 / 23

Turing Machine: Example

q

1

q

2

q

3

q

4

q

5

q

accept

q

reject

0→,R

→,R

x→x,R →,R

0→x,R

0→0,R →,L

0→x,R →,R

x→x,R

x→x,R x→x,R

x→x,L 0→0,L

→,R

1

Sweep left to right across the tape, sweeping off every other 0.

2

If in stage 1 the tape contained a single 0, accept.

3

If in stage 1 the tape contained more than one 0 and the number of 0s was odd, reject.

4

Return the head to the left end of the tape and go to stage 1.

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 18 / 23

B9. Turing Machines I Turing Machines

Recognized Language: Example

q

1

q

2

q

3

q

4

q

5

q

accept

q

reject

0→,R

→,R

x→x,R →,R

0→x,R

0→0,R →,L

0→x,R →,R

x→x,R

x→x,R x→x,R

x→x,L 0→0,L

→,R

What language does the Turing machine recognize?

B9. Turing Machines I Turing Machines

Deciders

I A Turing machine either fails to accept an input I because it rejects it (entering q

reject

) or

I because it loops (= does not halt).

I A Turing machine that halts on all inputs (entering q reject or q accept ) is called a decider.

I A decider that recognizes some language also is said to decide the language.

Definition (Turing-decidable Language)

We call a language Turing-decidable (or decidable) if some

deterministic Turing machine decides it.

(6)

Exercise

Specify the state diagram of a DTM that decides language

L = {w #w | w ∈ {0, 1} }.

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 21 / 23

B9.2 Summary

Gabriele R¨oger (University of Basel) Theory of Computer Science April 7, 2021 22 / 23

B9. Turing Machines I Summary

Summary

I Turing machines only have finitely many states but an unbounded tape as “memory”.

I Alan Turing proposed them as a mathematical model for arbitrary algorithmic computations.

I In this role, we will revisit them in the parts

on computability and complexity theory.

Referenzen

ÄHNLICHE DOKUMENTE

“They funded our growth,” says Ells, “which allowed us to open 535 restaurants.” Chipotle went public in 2006, and McDonald’s sold its stake in the fast-growing chain, which

6 According to the text, Ells ‘‘got the money for expansion from a surprising source, McDonald’s, first as a minority investor and then three years later as the

Dabei geht es aber nicht nur darum, interne Nutzer möglichst effizient und kostenbewusst zu bedienen, sondern vor allem auch um wertschöpfende Services für die Kunden

Nur 71 Mitglieder haben fur dieses Jahr ihre Beitrage (noch) nicht gezahlt. Society of Parents & Friends of the John F. Kennedy School e.V. Eingetragen im

Eine gefährliche explosionsfähige Atmosphäre ist eine Gemisch- menge, von der die Gefahr ausgeht, dass im Fall ihrer Entzün- dung Personenschaden durch direkte oder

a) Die beiderseits erbrachten Leistungen sind zurückzu gew/ähren. b) Ist eine Rückgew/ähr nicht möglich, so leistet der Auftraggeber Wertersatz. • Für die Berechnung des

Neben einer Kinderdisko wird es im offenen Atelier um Action-Painting beziehungsweise Bewegungsmalerei gehen, wie es etwa der Künstler Jackson Pollock betrieben hat.. Kunstpädagogin

Falls dieses Zeichen eine 1 ist, so l¨ osche es, gehe nach links, und wechsele in den Zustand q 3.. BuK/WS 2017 VL-02: Turing Maschinen