- Recall:
HALT:${0, 1}^* \rightarrow {0, 1}$ .HALT(<M>, x)= {1 if M halts on X and 0 if not} - Consider a proof by contradiction - that is, suppose there is a machine
$H$ that computesHALT - Define another machine
CANTSOLVEME(<M>)-
def CANTSOLVEME(<M>): if H(<M>, <M>) == 1: # If <M> halts on itself while (true): # Enter an infinite while loop a = 1 else: # If <M> does not halt on itself return 0 - If
CANTSOLVEMEis given itself as input (CANTSOLVEME(<CANTSOLVEME>)), there is contradictory behavior- If
CANTSOLVEME(<CANTSOLVEME>)halts, then the program will enter an infinite loop, so it will actually not halt - which is contradictory - If
CANTSOLVEME(<CANTSOLVEME)does not halt, then the program will enter the second branch and halt - which is, once again, contradictory
- If
-
-
NOTEMPTY:${0, 1 }^* \rightarrow {0, 1}$ .NOTEMPTY(<M>)= 1 if there is a$x$ such that$M(x) = 1$ and$0$ otherwise- We can perform a reduction from
NOTEMPTYtoHALTONZEROto show uncomputability -
def N(z): if z != 0: return 0 else: run EVAL(M, 0) return 1 - In this reduction program,
NOTEMPTYwill only evaluate to true if$M$ halts on zero, because the only case where the reduction function returns$1$ is if the input is zero - and it can only return if$M$ actually halts - Since
NOTEMPTYcan be used to computeHALTONZERO, and sinceHALTONZEROis uncomputable, there is a contradiction - soNOTEMPTYmust be uncomputable as well
- We can perform a reduction from
- Consider two programs,
$A$ and$B$ . The idea of software verification seeks to determine if the two programs are equivalent (that is, they are computing the same function)- Two programs
$M$ ,$M'$ are equivalent if$\forall \ x$ ,$M(x) = M'(x)$
- Two programs
-
Semantic Properties of a program are properties that only depend on the input/output behavior of the program (or Turing Machine)
-
$F: {0, 1}^* \rightarrow {0, 1}$ is semantic if for all equivalent programs M, M',$F(M) = F(M')$ -
HALTONZEROandNOTEMPTYare examples of semantic functions - Nonexample:
F(<M>)= { 1 if ends with a 0 and 0 otherwise}- This depends on the encoding of the input function
$M$ , which can vary from an equivalent function$M'$ that has the same input/output behavior but just a different implementaton (and therefore possibly a different encoding)
- This depends on the encoding of the input function
-
-
-
Rice's Theorem (1951): Every nontrivial semantic property is uncomputable
- Nontrivial means that the function is not constant (i.e. not a constant
0or constant1function ) - Consider
ISMAJORITY(<M>), which outputs 1 if<M>computesMAJORITYand 0 otherwise - this is a semantic function-
ISMAJORITYis uncomputable; it can be shown thatHALTONZEROreduces toISMAJORITY - Reduction:
-
def N(z): run EVAL(M, 0) return MAJORITY(z)
-
- If
$M$ halts on zero, then the program will correctly returnMAJORITY, otherwise it will not - Thus,
ISMAJORITYcan be used to solveHALTONZERO, which is known to be uncomputable - so there is a contradiction andISMAJORITYmust also be uncomputable
-
- If
$F$ is a semantic property that is nontrivial, then this implies that there is a program$M_0$ where$F(<M_0>) = 0$ (and equivalently$F(<M_1>) = 1$ ) -
def INF(z): while (true): a = 1 -
- Case 1:
$F() = 0$ - A reduction can be constructed from
$F$ to$HALTONZERO$ -
def N(z): run EVAL(M, 0) run EVAL(M1, z) # M1 is the program where F evaluates to 1 - As long as M halts on zero, the second
EVALon the function satifies the semantic property$M_1$ should return true - so F should return true if and only if$M$ halts beacuse otherwise it will return 0 because$F() = 0$ - Once again, this proves that
$F$ can be used to compute$HALTONZERO$ , which is a contradiction - so$F$ must be uncomputable
- A reduction can be constructed from
- Case 2:
$F() = 1$ - In this case, the same approach can be followed but we can just look at
NOTF, which is semantic -
NOTF(<INF>) = 0implies thatNOTFis uncomputable, and since we can reduceNOTFtoF,Fis also uncomputable
- In this case, the same approach can be followed but we can just look at
- Case 1:
- Nontrivial means that the function is not constant (i.e. not a constant