• Keine Ergebnisse gefunden

Theory of Computer Science D1. Turing-Computability Gabriele R¨oger

N/A
N/A
Protected

Academic year: 2022

Aktie "Theory of Computer Science D1. Turing-Computability Gabriele R¨oger"

Copied!
21
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Theory of Computer Science

D1. Turing-Computability

Gabriele R¨ oger

University of Basel

April 8, 2019

(2)

Theory of Computer Science

April 8, 2019 — D1. Turing-Computability

D1.1 Turing-Computable Functions

D1.2 Summary

(3)

Overview: Course

contents of this course:

A. background X

. mathematical foundations and proof techniques B. logic X

. How can knowledge be represented?

. How can reasoning be automated?

C. automata theory and formal languages X . What is a computation?

D. Turing computability

. What can be computed at all?

E. complexity theory

. What can be computed efficiently?

(4)

Main Question

Main question in this part of the course:

What can be computed

by a computer?

(5)

Overview: Computability Theory

Computability

Turing-Computability

Undecidable Problems

(Semi-)Decidability Halting Problem

Reductions

Rice’s Theorem

Other Problems

(6)

Overview: Computability Theory

Computability

Turing-Computability

Undecidable Problems

(Semi-)Decidability Halting Problem

Reductions

Rice’s Theorem

Other Problems

(7)

D1. Turing-Computability Turing-Computable Functions

D1.1 Turing-Computable Functions

(8)

D1. Turing-Computability Turing-Computable Functions

Computation

What is a computation?

I intuitive model of computation (pen and paper)

I vs. computation on physical computers

I vs. formal mathematical models

In the following chapters we investigate

models of computation for partial functions f : N k 0p N 0 .

I no real limitation: arbitrary information can be encoded as numbers

German: Berechnungsmodelle

(9)

D1. Turing-Computability Turing-Computable Functions

Church-Turing Thesis

Church-Turing Thesis

All functions that can be computed in the intuitive sense can be computed by a Turing machine.

German: Church-Turing-These

I cannot be proven (why not?)

I but we will collect evidence for it ( part F)

(10)

D1. Turing-Computability Turing-Computable Functions

Reminder: Deterministic Turing Machine (DTM)

Definition (Deterministic Turing Machine)

A deterministic Turing machine (DTM) 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 ) × Γ → Q × Γ × {L, R, N} transition function

I q 0 ∈ Q start state

I ∈ Γ \ Σ blank symbol

I E ⊆ Q end states

(11)

D1. Turing-Computability Turing-Computable Functions

Reminder: Configurations and Computation Steps

How do Turing Machines Work?

I configuration: hα, q , βi with α ∈ Γ , q ∈ Q , β ∈ Γ +

I one computation step: c ` c 0 if one computation step can turn configuration c into configuration c 0

I multiple computation steps: c ` c 0 if 0 or more computation steps can turn configuration c into configuration c 0

(c = c 0 ` c 1 ` c 2 ` · · · ` c n−1 ` c n = c 0 , n ≥ 0)

(Definition of `, i.e., how a computation step changes the

configuration, is not repeated here. Chapter C7)

(12)

D1. Turing-Computability Turing-Computable Functions

Computation of Functions?

How can a DTM compute a function?

I “Input” x is the initial tape content

I “Output” f (x) is the tape content (ignoring blanks at the left and right) when reaching an end state

I If the TM does not stop for the given input, f (x) is undefined for this input.

Which kinds of functions can be computed this way?

I directly, only functions on words: f : Σ p Σ

I interpretation as functions on numbers f : N k 0p N 0 :

encode numbers as words

(13)

D1. Turing-Computability Turing-Computable Functions

Turing Machines: Computed Function

Definition (Function Computed by a Turing Machine)

A DTM M = hQ , Σ, Γ, δ, q 0 , , E i computes the (partial) function f : Σ p Σ for which:

for all x, y ∈ Σ : f (x) = y iff hε, q 0 , xi ` h . . . , q e , y . . . i with q e ∈ E . (special case: initial configuration hε, q 0 , i if x = ε) German: DTM berechnet f

I What happens if symbols from Γ \ Σ (e. g., ) occur in y?

I What happens if the read-write head is not

on the first symbol of y at the end?

(14)

D1. Turing-Computability Turing-Computable Functions

Turing-Computable Functions on Words

Definition (Turing-Computable, f : Σ p Σ )

A (partial) function f : Σ p Σ is called Turing-computable if a DTM that computes f exists.

German: Turing-berechenbar

(15)

D1. Turing-Computability Turing-Computable Functions

Example: Turing-Computable Functions on Words

Example

Let Σ = { a, b, # }.

The function f : Σ p Σ with f (w ) = w #w for all w ∈ Σ is Turing-computable.

blackboard

(16)

D1. Turing-Computability Turing-Computable Functions

Encoding Numbers as Words

Definition (Encoded Function)

Let f : N k 0p N 0 be a (partial) function.

The encoded function f code of f is the partial function f code : Σ p Σ with Σ = {0, 1, #} and f code (w ) = w 0 iff

I there are n 1 , . . . , n k , n 0 ∈ N 0 such that

I f (n 1 , . . . , n k ) = n 0 ,

I w = bin(n 1 )# . . . #bin(n k ) and

I w 0 = bin(n 0 ).

Here bin : N 0 → {0, 1} is the binary encoding (e. g., bin(5) = 101).

German: kodierte Funktion

(17)

D1. Turing-Computability Turing-Computable Functions

Turing-Computable Numerical Functions

Definition (Turing-Computable, f : N k 0p N 0 )

A (partial) function f : N k 0p N 0 is called Turing-computable if a DTM that computes f code exists.

German: Turing-berechenbar

(18)

D1. Turing-Computability Turing-Computable Functions

Example: Turing-Computable Numerical Function

Example

The following numerical functions are Turing-computable:

I succ : N 0 → p N 0 with succ(n) := n + 1

I pred 1 : N 0 → p N 0 with pred 1 (n) :=

( n − 1 if n ≥ 1 0 if n = 0

I pred 2 : N 0 → p N 0 with pred 2 (n) :=

( n − 1 if n ≥ 1

undefined if n = 0

blackboard/exercises

(19)

D1. Turing-Computability Turing-Computable Functions

More Turing-Computable Numerical Functions

Example

The following numerical functions are Turing-computable:

I add : N 2 0p N 0 with add(n 1 , n 2 ) := n 1 + n 2

I sub : N 2 0 → p N 0 with sub(n 1 , n 2 ) := max{n 1 − n 2 , 0}

I mul : N 2 0p N 0 with mul(n 1 , n 2 ) := n 1 · n 2

I div : N 2 0p N 0 with div(n 1 , n 2 ) :=

(l n

1

n

2

m

if n 2 6= 0

undefined if n 2 = 0

sketch?

(20)

D1. Turing-Computability Summary

D1.2 Summary

(21)

D1. Turing-Computability Summary

Summary

I main question: what can a computer compute?

I approach: investigate formal models of computation

I here: deterministic Turing machines

I Turing-computable function f : Σ p Σ :

there is a DTM that transforms every input w ∈ Σ into the output f (w ) (undefined if DTM does not stop or stops in invalid configuration)

I Turing-computable function f : N k 0p N 0 :

ditto; numbers encoded in binary and separated by #

Referenzen

ÄHNLICHE DOKUMENTE

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...

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

NP is the class of languages that are decidable in polynomial time by a non-deterministic single-tape Turing machine.. Complexity

I Can they solve problems efficiently (in polynomial time) which deterministic algorithms cannot solve efficiently. I This is the