the description of an algorithm A (which requires one input)
an input I
Then H will return 1 if A stops with input I and 0 if it does not.
Assume H exists, we can then write an algorithm H′ such that H′ takes an input an algorithm A and computes H(A,A). If the result is 0 then H′ answers 1 and stops, otherwise it loops forever.
Since A is arbitrary, it could be H′ itself.
We obtain a contradiction H′(H′) stops if and only if H′(H′) does not stop.
So H cannot exist.
Visual example of Halting Problem undecidability
Let’s assume G is a program that takes a Go state and outputs the optimal move:
The program sometimes gets stuck and will never return an output.
Let’s say H is a program that takes G and a Go state as inputs and outputs true iff G will halt on that Go state (false otherwise).
procedure H'(P): if P(P) halts: loop forever else: haltend procedure
H′ will take a program P as input:
if P(P) halts then H′ will run forever
if P(P) runs forever then H′ will halt
Now we try to feed H′ into itself:
We reach a contradiction:
If H′(H′) halts then it runs forever
If H′(H′) runs forever then it halts
By assuming that a program that solves the halting problem exists we have found a contradiction. Therefore, it’s not possible for such a program to exist.
Decidable Problem
A problem is said to be decidable if it is possible to design a program to answer the problem within a finite time.
To allow us to represent unending computations (that do not always return a result), and to ignore certain unnecessary details, we consider programs to be partial functions.
Examples of these sorts of expressions include:
true + 3: not well defined (type error)
addition is a total function on natural numbers
10/0: not defined
division is a partial function on natural numbers
expression fact(-1) does not have a value for:
fact(x) = if x = 0 then 1 else x * fact(x - 1)
fact defines a partial function on integers
Cartesian product of sets
The Cartesian product of sets A and B is the set $$ A \times B = \{ (x, y) | x \in A \text{ and } y \in B \} $$
A×B consists of ordered pairs (x,y) where x∈A and y∈B.
For example, let A={1,2} and B={a,b,c}.
Hence, A×B={(1,a),(2,a),(1,b),(2,b),(1,c),(2,c)}.
Generic Format
The Cartesian product of setsA1,A2,...,Ak is the set $$ A_1 \times A_2 \times ... \times A_k = \{ (x_1, x_2, ..., x_k) | x_i \in A \text{ for } i = 1, 2, ..., k \} $$
A1×A2×...×Ak consists of those k-tuples (x1,x2,...,xk) where x1∈A1,x2∈A2,..
The class of functions on the natural numbers that can (in an ideal world where time and space are unlimited) be computed by a program is called partial recursive functions or computable functions.
Computable function
A function f:Σ∗→Σ∗ on words from Σ∗ is computable if there is a deterministic Turing Machine Mf s.t.: (or there is a lambda-term)
Mf accepts all input words w∈Σ∗
when started in configuration (qinit,ϵ,w), the machine eventually terminates in configuration (qaccept,ϵ,f(w)).
The machine transforms the contents of the tape from w to f(w) and returns the tape head to the start of the word.
We need a computational model to abstract away from material details of a programming language and processor we may be using.
Most well known are:
Turing Machines
The Lambda-Calculus
Church’s Thesis says that the same class of functions on the integers can be computed in any sequential model of computation. This proves that the Lambda-calculus and Turing machines compute exactly the same class of functions.