Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Rice's theorem
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Proof by reduction from the halting problem== ===Proof sketch=== Suppose, for concreteness, that we have an algorithm for examining a program ''p'' and determining infallibly whether ''p'' is an implementation of the squaring function, which takes an integer ''d'' and returns ''d''<sup>2</sup>. The proof works just as well if we have an algorithm for deciding any other non-trivial property of program behavior (i.e. a semantic and non-trivial property), and is given in general below. The claim is that we can convert our algorithm for identifying squaring programs into one that identifies functions that halt. We will describe an algorithm that takes inputs ''a'' and ''i'' and determines whether program ''a'' halts when given input ''i''. The algorithm for deciding this is conceptually simple: it constructs (the description of) a new program ''t'' taking an argument ''n'', which (1) first executes program ''a'' on input ''i'' (both ''a'' and ''i'' being hard-coded into the definition of ''t''), and (2) then returns the square of ''n''. If ''a''(''i'') runs forever, then ''t'' never gets to step (2), regardless of ''n''. Then clearly, ''t'' is a function for computing squares if and only if step (1) terminates. Since we have assumed that we can infallibly identify programs for computing squares, we can determine whether ''t'', which depends on ''a'' and ''i'', is such a program; thus we have obtained a program that decides whether program ''a'' halts on input ''i''. Note that our halting-decision algorithm never executes ''t'', but only passes its description to the squaring-identification program, which by assumption always terminates; since the construction of the description of ''t'' can also be done in a way that always terminates, the halting-decision cannot fail to halt either. halts (a,i) { define t(n) { a(i) '''return''' nΓn } '''return''' is_a_squaring_function(t) } This method does not depend specifically on being able to recognize functions that compute squares; as long as ''some'' program can do what we are trying to recognize, we can add a call to ''a'' to obtain our ''t''. We could have had a method for recognizing programs for computing square roots, or programs for computing the monthly payroll, or programs that halt when given the input <code>"Abraxas"</code>; in each case, we would be able to solve the halting problem similarly. ===Formal proof=== [[Image:Rice reduction.svg|thumb|If we have an algorithm that decides a non-trivial property, we can construct a Turing machine that decides the halting problem.]] For the formal proof, algorithms are presumed to define partial functions over [[string (computer science)|strings]] and are themselves represented by strings. The partial function computed by the algorithm represented by a string ''a'' is denoted '''F'''<sub>''a''</sub>. This proof proceeds by [[reductio ad absurdum]]: we assume that there is a non-trivial property that is decided by an algorithm, and then show that it follows that we can decide the [[halting problem]], which is not possible, and therefore a contradiction. Let us now assume that ''P''(''a'') is an algorithm that decides some non-trivial property of '''F'''<sub>''a''</sub>. Without loss of generality we may assume that ''P''(''no-halt'') = "no", with ''no-halt'' being the representation of an algorithm that never halts. If this is not true, then this holds for the algorithm ''{{overline|P}}'' that computes the negation of the property ''P''. Now, since ''P'' decides a non-trivial property, it follows that there is a string ''b'' that represents an algorithm '''F'''<sub>''b''</sub> and ''P''(''b'') = "yes". We can then define an algorithm ''H''(''a'', ''i'') as follows: :1. construct a string ''t'' that represents an algorithm ''T''(''j'') such that :* ''T'' first simulates the computation of '''F'''<sub>''a''</sub>(''i''), :* then ''T'' simulates the computation of '''F'''<sub>''b''</sub>(''j'') and returns its result. :2. return ''P''(''t''). We can now show that ''H'' decides the halting problem: * Assume that the algorithm represented by ''a'' halts on input ''i''. In this case '''F'''<sub>''t''</sub> = '''F'''<sub>''b''</sub> and, because ''P''(''b'') = "yes" and the output of ''P''(''x'') depends only on '''F'''<sub>''x''</sub>, it follows that ''P''(''t'') = "yes" and, therefore ''H''(''a'', ''i'') = "yes". * Assume that the algorithm represented by ''a'' does not halt on input ''i''. In this case '''F'''<sub>''t''</sub> = '''F'''<sub>''no-halt''</sub>, i.e., the partial function that is never defined. Since ''P''(''no-halt'') = "no" and the output of ''P''(''x'') depends only on '''F'''<sub>''x''</sub>, it follows that ''P''(''t'') = "no" and, therefore ''H''(''a'', ''i'') = "no". Since the halting problem is known to be undecidable, this is a contradiction and the assumption that there is an algorithm ''P''(''a'') that decides a non-trivial property for the function represented by ''a'' must be false.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)