Mathematical Logic 10 Halting Problem
Mathematical Logic 10 Halting Problem
R-computable
Let F: A* -> B* (A,B are 2 alphabets)
(1)A program P computes F if for all w A*, P: w->F(w)
(2)F is R-computable if there is a program which computes F.
Halting Problem for the register machine
Gödel numbering
Def:
B:= A U {A,B,…,Z} U {0,1,…,9} U {=,+,-,|}.
Words in B* are ordered lexicographically(字典序).
Encode each program as a word in B*
Example:
0LETR1 = R1 - a0|1PRINT|2HALT.
Assume that this word is the n-th word in the lexicographical ordering of B∗.Then we set:
= (n times)
Π := { |P a program over A }.
The mapping P-> is called Gödel numbering.
is called the Gödel number of P.
Π is R-decidable.
Π’halt is not R-decidable.
Π’halt := { |P a program over A and P:->halt}
PF:
Assume that P0 decides Π’halt
0 …
1 …
…
10 PRINT
…
k HALT
We can build a P1
0 …
1 …
…
10 IF R = □ THEN k ELSE k or k or k… or k
…
k IF R = □ THEN k ELSE k+1 or k+1 or k+1… or k+1
k+1 HALT
Clearly contradict!
Πhalt is not R-decidable.
Πhalt := { |P a program over A and P: □ ->halt}
PF:
Build P+:
P : -> halt -> P+ : □ -> halt
A further program T:
->
With P0 and T we design a program which decides Π’halt. On any w A∗:
- the program first test whether w = for some P.If not, it rejects immediately.
- Otherwise, it uses T to computes . Then the program calls P0 on input wP+.
- It correctly decides whether P : wP -> halt.