• Keine Ergebnisse gefunden

Theory of Computer Science F3. GOTO-Computability Gabriele R¨oger

N/A
N/A
Protected

Academic year: 2022

Aktie "Theory of Computer Science F3. GOTO-Computability Gabriele R¨oger"

Copied!
21
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

F3. GOTO-Computability

Gabriele R¨oger

University of Basel

May 22, 2019

(2)

GOTO Programs

(3)

Course Overview

Theory

Background Logic Automata Theory Turing Computability

Complexity More Computability

LOOP-computability WHILE-computability

GOTO-computability

(4)

Motivation

We now know:

WHILE programs are strictly more powerful than LOOP programs.

Deterministic Turing machines are at least as powerful as WHILE programs.

Are DTMsstrictly more powerful than WHILE programs orequally powerful?

To answer this question, we make a detour over one more programming formalism.

(5)

GOTO Programs: Syntax

Definition (GOTO Program)

AGOTO programis given by a finite sequence L1 :A1, L2 :A2, . . . , Ln:An

oflabels andstatements.

Statementsare of the following form:

xi :=xj +c for everyi,j,c ∈N0 (addition)

xi :=xj −c for everyi,j,c ∈N0 (modified subtraction) HALT (end of program)

GOTO Lj for 1≤j ≤n (jump)

IF xi =c THEN GOTO Lj fori,c ∈N0, 1≤j ≤n (conditional jump)

German: GOTO-Programm, Marken, Anweisungen, Programmende, German: Sprung, bedingter Sprung

(6)

GOTO Programs: Semantics

Definition (Semantics of GOTO Programs) Input, output and variables work exactly as in LOOP and WHILE programs.

Addition and modified subtraction work exactly as in LOOP and WHILE programs.

Execution begins with the statementA1.

After executing Ai, the statementAi+1 is executed.

(If i =n, execution finishes.) exceptions to the previous rule:

HALTstops the execution of the program.

AfterGOTO Lj execution continues with statement Aj. AfterIFxi =cTHEN GOTO Lj execution continues withAj if variablexi currently holds the valuec.

(7)

GOTO-Computable Functions

Definition (GOTO-Computable)

A functionf :Nk0 →N0 is called GOTO-computable if a GOTO program that computesf exists.

German: GOTO-berechenbar

(8)

Questions

Questions?

(9)

GOTO vs. WHILE

(10)

GOTO-Computability vs. WHILE-Computability

Theorem

Every GOTO-computable function is WHILE-computable.

If we allow IF statements, a single WHILE loop is sufficient for this.

(We will discuss the converse statement later.)

(11)

GOTO-Computability vs. WHILE-Computability

Proof sketch.

Given any GOTO program, we construct an equivalent

WHILE program with a single WHILE loop (and IF statements).

Ideas:

Use a fresh variable to store the number of the statement to be executed next.

The variable of course has the formxi, but for readability we write it aspcfor “program counter”.

GOTO is simulated as an assignment topc.

Ifpc has the value 0, the program terminates.

. . .

(12)

GOTO-Computability vs. WHILE-Computability

Proof sketch (continued).

Let L1 :A1, L2 :A2, . . . , Ln:An be the given GOTO program.

basic structure of the WHILE program:

pc:= 1;

WHILE pc6= 0 DO

IFpc= 1 THEN(translation of A1) END;

. . .

IFpc=n THEN (translation ofAn) END;

IFpc=n+ 1 THEN pc:= 0 END

END . . .

(13)

GOTO-Computability vs. WHILE-Computability

Proof sketch (continued).

Translation of the individual statements:

xi :=xj +c

xi :=xj +c;pc:=pc+ 1 xi :=xj −c

xi :=xj −c;pc:=pc+ 1 HALT

pc:= 0 GOTO Lj

pc:=j

IF xi =c THEN GOTO Lj

pc:=pc + 1; IFxi =c THEN pc:=j END

(14)

Intermediate Summary

We now know:

WHILE programs are strictly more powerful than LOOP programs.

Deterministic Turing machines are at least as powerful as WHILE programs.

WHILE programs are at least as powerful as GOTO programs.

We now show that GOTO programs are at least as powerful as DTMs, closing the cycle DTM–WHILE–GOTO.

(15)

Questions

Questions?

(16)

Turing vs. GOTO

(17)

Turing-Computability vs. GOTO-Computability

Theorem (Turing-Computability vs. GOTO-Computability)

Every Turing-computable numerical function is GOTO-computable.

Proof.

blackboard.

(18)

Final Result

Corollary

Let f :Nk0pN0 be a function.

The following statements are equivalent:

f is Turing-computable.

f is WHILE-computable.

f is GOTO-computable.

Moreover:

Every LOOP-computable function is Turing-/WHILE-/GOTO-computable.

The converse is not true in general.

(19)

Questions

Questions?

(20)

Summary

(21)

Summary

results of the investigation:

another new model of computation: GOTO programs Turing machines, WHILE and GOTO programs are equally powerful.

Whenever we said “Turing-computable” or “computable” in parts D or E, we could equally have said “WHILE-computable”

or “GOTO-computable”.

LOOP programs are strictly less powerful.

Referenzen

ÄHNLICHE DOKUMENTE

Introduction Alphabets and Formal Languages Grammars Chomsky Hierarchy

C1.2 Alphabets and Formal Languages C1.3 Grammars?. C1.4 Chomsky Hierarchy

Introduction Encoding/Decoding Functions Recursive Enumerability Semi-Decidability Decidability Summary.. Overview:

Gabriele R¨ oger (University of Basel) Theory of Computer Science April 10, 2019 1 / 32.. Theory of

D2.2 Encoding/Decoding Functions D2.3 Recursive Enumerability?. D2.4 Semi-Decidability

Polynomial Reductions Cook-Levin Theorem NP-complete Problems More Computability... P, NP and Polynomial Reductions P

LOOP, WHILE and GOTO programs are structured like programs in (simple) “traditional” programming languages use finitely many variables from the set {x 0 , x 1 , x 2 ,.. } that can

show that there is a number k for every LOOP program such that the computed function value is smaller than a(k , n), if n is the largest input value. proof by structural induction;