VL-09: LOOP und WHILE Programme I Flashcards

1
Q

Wie ist die LOOP Programmiersprache syntaktisch aufgebaut?

A

Variablen: x0, x1, x2, …
Konstanten: 0, 1
Symbole: :=, +, ;
Schlüsselwörter: LOOP, DO, ENDLOOP

Zuweisung: xi := xj + c
mit Variablen xi, xj und Konstante c

Hintereinanderausführung: P1 ; P2
mit Programmen P1 und P2

LOOP-Konstrukt: LOOP xi DO P1 ENDLOOP
mit Variable xi und Programm P1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Welche zusätzlichen syntaktischen Elemente hat die WHILE Programmiersprache?

A

Symbole: !=
Schlüsselwörter: WHILE, ENDWHILE

WHILE-Konstrukt: WHILE xi != 0 DO P ENDWHILE
mit Variable xi und Programm P

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Wie ist der initiale Zustand eines LOOP bzw. WHILE Programms? Wie wird die Eingabe übermittelt?

A
  • Eingabe: Variablen x1 - xn
  • Alle anderen Variablen = 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Sind LOOP und WHILE turing-mächtig?

A

WHILE ja
LOOP nein

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Wie ist die Ackermann-Funktion definiert?

A

(m,n) -> Z
A(0, n) = n + 1
A(m + 1, 0) = A(m, 1)
A(m + 1, n + 1) = A(m, A(m + 1, n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Was ist die UpArrow Notation?

A

a ↑m b := 1 wenn b = 0
a ↑m b := a · b wenn m = 0
a ↑m b := a^b wenn m = 1
a ↑m b := a ↑m−1(a ↑m (b − 1)) sonst

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Wie lässt sich die Ackermann Funktion mit der UpArrow Notation beschreiben?

A

A(1, n) = 2 + (n + 3) − 3
A(2, n) = 2 · (n + 3) − 3
A(3, n) = 2 ↑ (n + 3) − 3
A(4, n) = 2 ↑↑ (n + 3) − 3
A(5, n) = 2 ↑↑↑ (n + 3) − 3
A(m, n) = 2 ↑m−2 (n + 3) − 3

  • A wächst sehr stark mit steigendem m
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Wie lässt sich beweisen, dass WHILE turing mächtig ist?

A
  • Induktiv
  • Simulation einer TM durch WHILE Programm:

Variablen:
- Zustand
- Band vor Kopf
- Symbol unter Kopf
- Band nach Kopf (Inverse)

Schritt:
- Update Zustand
- Update Symbol unter Kopf
- Bewege Kopf L/N/R

Ablauf:
1. Initialisierung
2. WHILE Zustand != Endzustand DO
IF Zustand = x AND Kopf = y DO z …
….

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly