Vol. I a living index of named laws · est. mmxxvi no ads · no tracking
The Law Tomeindex of named laws

Rice's Theorem

"Every non-trivial question about what a program does is undecidable."
In plain English

What does Rice's Theorem mean?

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.

Judge the cases

Rice's Theorem solver

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.

  1. 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.

  2. 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.

  3. Does this program halt on every input?

    Undecidable. The halting problem in its general form. Semantic and non-trivial, so undecidable.

  4. 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.

  5. 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.

  6. Is this a syntactically valid program at all?

    Decidable. A parser answers it. Syntax again, so outside the theorem entirely.

  7. 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.

Reliability

Rated Empirical: grounded in studies or measurable evidence. The other 608.

Lineage
1953COINED
How it works

How does Rice's Theorem work?

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.

Where you'll see it

What are examples of Rice's Theorem?

Does it ever print this? Whether an arbitrary program ever outputs a particular value is a non-trivial semantic property (some programs do, some do not) and is therefore undecidable in general.
Are two programs equivalent? Deciding whether two arbitrary programs compute the same function is undecidable, since equivalence to a fixed program is a non-trivial behavioural property.
Why perfect analysis is impossible The theorem sets a hard limit on static analysis, verification, and optimisation: no general tool can perfectly decide arbitrary behavioural properties, so real tools must approximate soundly and conservatively.
Types & variants

What are the types of Rice's Theorem?

The halting problem§

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.

The Rice-Shapiro theorem§

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.

Why it matters

Why does Rice's Theorem matter?

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.

Working with it

How do you apply Rice's Theorem?

  • Expect behavioural questions to be undecidable — for any non-trivial property of what an arbitrary program does, assume no general algorithm can decide it.
  • Lean on syntactic properties where you can — note that properties of the source text itself, unlike behaviour, are often decidable and can be checked directly.
  • Approximate soundly — since perfect behavioural analysis is impossible, build tools that safely over- or under-approximate rather than aim for exact answers.
Where it breaks down

What are the limits of Rice's Theorem?

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.

What it doesn't say

What are common misconceptions about Rice's Theorem?

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.

Is it real?

Is Rice's Theorem real?

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.

Rarely printedin printed books: one of 196 names in its band, of 903 measured
36 of 69entries in software & systems carry the same rating

The best-known laws are the least likely to rest on measurement.

Origin

Where did Rice's Theorem come from?

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.

How the name spread

When did people start saying “Rice's Theorem”?

1800coined 19532019
How often “Rice 's Theorem” appears in printed English, which takes hold around 1973 and peaks around 2010. The idea dates to 1953: the phrase took about 20 years to reach print in any quantity, which is the gap this chart measures. Source: Google Books Ngrams.
Known elsewhere as

What is Rice's Theorem called in other languages?

  • GermanSatz von Rice
  • SpanishTeorema de Rice
  • Frenchthéorème de Rice
  • ItalianTeorema di Rice
  • Japaneseライスの定理
  • PortugueseTeorema de Rice
  • RussianТеорема Райса
  • Chinese莱斯定理

8 languages, as recorded on Wikidata. These are names the idea already goes by, not translations we made. The whole index by language.

What we checked

  • 1,116entries in the tomeListed one by one on the browse page.
  • 1,116of them citing a sourceOpen any entry: its sources sit at the foot of the page.
  • 2,489source references in allEach is named, and linked wherever the source is online.