Given an instance (Π,I) of the halting problem, construct an instance (Π′,I1,I2) of the correctness problem, where I1=I2=I and Π′ is defined as follows:
procedure Π': Input: input string I1, output string I2 Output: I2 if Π halts on I1, otherwise no output simulate Π on input I1 if Π halts then return I2 else loop forever
Completeness ( ⇒)
If Π halts on input I, then the constructed program Π′ also halts on input I1=I and outputs I2=I. Hence (Π′,I,I) is a positive instance of the correctness problem.
Soundness ( ⇐)
If (Π′,I,I) is a positive instance of the correctness problem, then Π′ halts on input I1=I and outputs I2=I. By construction, Π′ can only output I2 after Π has halted on input I1. Hence (Π,I) is a positive instance of the halting problem.