• Keine Ergebnisse gefunden

Theory of Computer Science C7. Context-Sensitive and Type-0 Languages: Turing Machines Gabriele R¨oger

N/A
N/A
Protected

Academic year: 2022

Aktie "Theory of Computer Science C7. Context-Sensitive and Type-0 Languages: Turing Machines Gabriele R¨oger"

Copied!
22
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Theory of Computer Science

C7. Context-Sensitive and Type-0 Languages: Turing Machines

Gabriele R¨ oger

University of Basel

April 3, 2019

(2)

Theory of Computer Science

April 3, 2019 — C7. Context-Sensitive and Type-0 Languages: Turing Machines

C7.1 Context-Sensitive and General Grammars C7.2 Turing Machines

C7.3 Summary

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 2 / 22

(3)

Overview

Automata &

Formal Languages

Languages

& Grammars

Regular Languages

Context-free Languages

Context-sensitive &

Type-0 Languages

Turing machines

Closure properties

& decidability

(4)

C7.1 Context-Sensitive and General Grammars

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 4 / 22

(5)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Context-Sensitive and General Grammars

Repetition: (Context-Sensitive) Grammars

Definition (Grammar)

A grammar is a 4-tuple hΣ, V , P , S i with:

I Σ finite alphabet of terminal symbols

I V finite set of variables (with V ∩ Σ = ∅)

I P ⊆ (V ∪ Σ) + × (V ∪ Σ) finite set of rules

I S ∈ V start variable Type 0 and type 1:

I Every grammar is type 0.

I A grammar is context-sensitive (type-1) if all rules w 1 → w 2 satisfy |w 1 | ≤ |w 2 |.

I

only exception: S → ε is allowed for the start symbol S

if S never occurs on a right-hand side.

(6)

C7.2 Turing Machines

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 6 / 22

(7)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Overview

Automata &

Formal Languages

Languages

& Grammars

Regular Languages

Context-free Languages

Context-sensitive &

Type-0 Languages

Turing machines

Closure properties

& decidability

(8)

Automata for Type-1 and Type-0 Languages?

Finite automata

accept 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

Picture courtesy of imagerymajestic / FreeDigitalPhotos.net Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 8 / 22

(9)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

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

(10)

Turing Machines: Conceptually

. . . b a c a c a c a . . .

infinite tape

read-write head

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 10 / 22

(11)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Nondeterministic Turing Machine: Definition

Definition (Nondeterministic Turing Machine)

A nondeterministic Turing machine (NTM) is given by a 7-tuple M = hQ , Σ, Γ, δ, q 0 , , E i with:

I Q finite non-empty set of states

I Σ 6= ∅ finite input alphabet

I Γ ⊃ Σ finite tape alphabet

I δ : (Q \ E ) × Γ → P (Q × Γ × {L, R, N}) transition function

I q 0 ∈ Q start state

I ∈ Γ \ Σ blank symbol

I E ⊆ Q end states

German: Turingmaschine, Zust¨ ande, Eingabealphabet, Bandalphabet,

German: Ubergangsfunktion, Startzustand, Blank-Symbol, Endzust¨ ¨ ande

(12)

Turing Machine: Transition Function

Let M = hQ, Σ, Γ, δ, q 0 , , Ei be an NTM.

What is the Intuitive Meaning of the Transition Function δ?

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

I If M is in state q and reads a, then

I M can transition to state q 0 in the next step,

I replacing a with b,

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

I

L: one step to the left,

I

R: one step to the right,

I

N: neutral (no) movement.

q a → b, D q

0

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 12 / 22

(13)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Nondeterministic Turing Machine: Example

M = h{q 0 , q 1 , . . . , q 6 }, {1, +, =}, {1, +, =, X, }, δ, q 0 , , {q 6 }i

q

0

q

1

q

2

q

3

q

4

q

5

q

6

+ → +, R

1 → X, R 1 → 1, R

+ → +, R

= → =, R X → X, R

1 → X, L

X → X, L

= → =, L

1 → 1, L + → +, L

X → X , R

X → X, R

= → =, R

→ , N

(14)

Turing Machine: Configuration

Definition (Configuration of a Turing Machine)

A configuration of a Turing machine M = hQ, Σ, Γ, δ, q 0 , , Ei 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 3, 2019 14 / 22

(15)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Turing Machine Configurations: Example

Example

configuration h BEFORE, q, AFTER i.

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

q

(16)

Turing Machine: Step

Definition (Transition/Step of a Turing Machine) An NTM M = hQ, Σ, Γ, δ, q 0 , , Ei can transition

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 , q 0 , cb 2 . . . b n i if hq 0 , c, Ni ∈ δ(q, b 1 ), m ≥ 0, n ≥ 1

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 hq 0 , c, Li ∈ δ(q, b 1 ), m ≥ 1, n ≥ 1

I hε, q, b 1 . . . b n i ` M hε, q 0 , cb 2 . . . b n i if hq 0 , c, Li ∈ δ(q, b 1 ), 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 hq 0 , c, Ri ∈ δ(q, b 1 ), m ≥ 0, n ≥ 2

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

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 16 / 22

(17)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Turing Machines: Reachability of Configurations

Definition (Reachable Configuration)

Configuration c 0 is reachable from configuration c in NTM M (c ` M c 0 ) if there are configurations c 0 , . . . , c n (n ≥ 0) where

I c 0 = c ,

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

I c n = c 0 .

German: c

0

ist in M von c erreichbar

(18)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Turing Machines: Recognized Words

Definition (Recognized Word of a Turing Machine)

NTM M = hQ, Σ, Γ, δ, q 0 , , Ei recognizes the word w = a 1 . . . a n

iff an accepting configuration (where M is in an end state) is reachable from the start configuration:

M recognizes w iff hε, q 0 , w i ` M hw 1 , q, w 2 i for some q ∈ E, w 1 ∈ Γ , w 2 ∈ Γ +

special case: for w = ε the start configuration is hε, q 0 , i

special case:

rather than hε, q 0 , εi

German: M erkennt w , akzeptierende Konfiguration, Startkonfiguration example: blackboard

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 18 / 22

(19)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Turing Machines

Turing Machines: Accepted Language

Definition (Accepted Language of an NTM) Let M be an NTM with input alphabet Σ.

The language accepted by M is defined as

L(M ) = {w ∈ Σ | M recognizes w }.

German: erkannte Sprache

example: blackboard

(20)

Exercise

Specify the state diagram of an NTM that accepts language L = { a n b n c n | n ≥ 1}.

Feel free to solve this together with your neighbour.

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 20 / 22

(21)

C7. Context-Sensitive and Type-0 Languages: Turing Machines Summary

C7.3 Summary

(22)

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.

Gabriele R¨oger (University of Basel) Theory of Computer Science April 3, 2019 22 / 22

Referenzen

ÄHNLICHE DOKUMENTE

B7.1 Context-free Grammars B7.2 Chomsky Normal Form B7.3 Push-Down Automata B7.4 Summary... B7.1

Picture courtesy of imagerymajestic / FreeDigitalPhotos.net Gabriele R¨ oger (University of Basel) Theory of Computer Science March 31, 2021 4 / 26... Closure under

Whenever M 0 is in one of the primed states, it does not change the tape, switches to the unprimed state q and moves left.. For every transition of M with neutral move, M 0 takes

The first tape always contains w , the second tape corresponds to the content of N’s tape on some branch of the computation tree and the third tape tracks the position in

If you read a 1 at the first tape position, move every non-blank symbol on the tape one position to the right, write a 1 in the first tape position and accept...

I If you read a 1 at the first tape position, move every non-blank symbol on the tape one position to the right, write a 1 in the first tape position and accept...

The word problem, emptiness problem and finiteness problem for the class of context-free languages are decidable. The equivalence problem and intersection problem for the class

Picture courtesy of imagerymajestic / FreeDigitalPhotos.net Gabriele R¨ oger (University of Basel) Theory of Computer Science April 3, 2019 5 /