Rice's Theorem
"Every non-trivial question about what a program does is undecidable."
"Every non-trivial question about what a program does is undecidable."
Every non-trivial semantic property of a program (any property of the behaviour or function it computes, that holds for some programs but not all) is undecidable. There is no general algorithm that can decide, for every possible program, any interesting question about what that program actually does.
Rice’s theorem is about SEMANTIC properties, meaning what a program does rather than how it is written, and about NON-TRIVIAL ones, meaning true of some programs and false of others. Every property meeting both conditions is undecidable.
For each question about an arbitrary program, decide whether a program could always answer it.
Does the source code contain the word "goto"?
Decidable. A property of the text, not of the behaviour. Rice’s theorem says nothing about syntax, and you can just read the file.
Does this program ever print the number 7?
Undecidable. Semantic, and true of some programs and false of others. That is exactly the pair of conditions Rice rules out.
Does this program halt on every input?
Undecidable. The halting problem in its general form. Semantic and non-trivial, so undecidable.
Does this program stop within a thousand steps on input x?
Decidable. Semantic, but bounded. Run it for a thousand steps and look. The theorem needs the property to be about behaviour on unbounded runs.
Does this program compute the same function as some fixed program P?
Undecidable. Program equivalence. Semantic, non-trivial, and undecidable, which is why no compiler can verify that an optimisation preserved meaning in general.
Is this a syntactically valid program at all?
Decidable. A parser answers it. Syntax again, so outside the theorem entirely.
Does this program compute SOME function?
Decidable. Trivially true of every program, so trivial in Rice’s sense. A property true of all programs, or of none, is decidable by answering the same way every time.
Both conditions have to hold. Drop "semantic" and you get syntax, which is easy. Drop "non-trivial" and the answer is constant.
Rated Empirical: grounded in studies or measurable evidence. The other 608.
The proof reduces from the halting problem. Suppose a decider existed for some non-trivial behavioural property; arrange, without loss of generality, that a never-halting program lacks the property while some program has it. Given any program and input, build a new program that first simulates the given one and, only if that halts, behaves like the program with the property. The new program has the property exactly when the original halts, so deciding the property would decide halting, which is impossible. The property must be semantic, depending only on the function computed, so that two programs computing the same function are treated alike.
The special, foundational case that Rice's theorem generalises and that supplies the reduction in its proof — deciding whether a program halts is itself one undecidable behavioural property.
A refinement for semi-decidable properties: such a property holding of a function must already hold on some finite part of it, capturing that the only general way to learn a program's behaviour is to run it.
It vastly generalises the halting problem, showing that undecidability is not a quirk of one question but pervades every behavioural property of programs. It is the theoretical reason perfect, general-purpose program analysis, verification, and optimisation are impossible, and why such tools rely on sound approximation instead.
It applies only to semantic, behavioural properties: properties of the function computed. Syntactic properties of the source text, such as its length or whether it contains a certain keyword, are decidable, and the theorem says nothing against them. Trivial properties, true of every program or of none, are also decidable; non-triviality is a required hypothesis. And it concerns general algorithms over all programs: many specific instances, and restricted or finite-state classes, are perfectly decidable.
It does not say every property of a program is undecidable — syntactic properties of the source are decidable, and so are trivial properties. And it is about general algorithms over all programs, not about any particular program, whose behaviour may well be determinable case by case.
Yes, as far as the evidence goes. Rice's Theorem is rated Empirical here: it rests on studies or measurements rather than on a saying.
Rated from three sources. 609 of the 1,116 entries carry this rating. How the scale works.
The best-known laws are the least likely to rest on measurement.
Proved by Henry Gordon Rice in 'Classes of recursively enumerable sets and their decision problems,' Transactions of the American Mathematical Society 74:358-366 (1953), drawn from his doctoral work.
8 languages, as recorded on Wikidata. These are names the idea already goes by, not translations we made. The whole index by language.
Everything above traces to doi.org, en.wikipedia.org and mathworld.wolfram.com, three sources in all, one of them the original publication rather than an account of it. Nothing is written from memory, and the method is written down. Spot an error or a better source? Suggest a fix.