Rice's theorem

In computability theory, Rice's theorem states that all non-trivial semantic properties of programs are undecidable. A semantic property is one about the program's behavior (for instance, "does the program terminate for all inputs?"), unlike a syntactic property (for instance, "does the program contain an if-then-else statement?"). A non-trivial property is one which is neither true for every program, nor false for every program.

The theorem generalizes the undecidability of the halting problem. It has far-reaching implications on the feasibility of static analysis of programs. It implies that it is impossible, for example, to implement a tool that checks whether any given program is correct, or even executes without error (it is possible to implement a tool that always overestimates or always underestimates e.g. the correctness of a program, so in practice one has to decide what is less of a problem).

The theorem is named after Henry Gordon Rice, who proved it in his doctoral dissertation of 1951 at Syracuse University.

Introduction

Rice's theorem puts a theoretical bound on which types of static analysis can be performed automatically. One can distinguish between the syntax of a program, and its semantics. The syntax is the detail of how the program is written, or its "intention", and the semantics is how the program behaves when run, or its "extension". Rice's theorem asserts that it is impossible to decide a property of programs which depends only on the semantics and not on the syntax, unless the property is trivial (true of all programs, or false of all programs).

By Rice's theorem, it is impossible to write a program that automatically verifies for the absence of bugs in other programs, taking a program and a specification as input, and checking whether the program satisfies the specification.

This does not imply an impossibility to prevent certain types of bugs. For example, Rice's theorem implies that in dynamically typed programming languages which are Turing-complete, it is impossible to verify the absence of type errors. On the other hand, statically typed programming languages feature a type system which statically prevents type errors. In essence, this should be understood as a feature of the syntax (taken in a broad sense) of those languages. In order to type check a program, its source code must be inspected; the operation does not depend merely on the hypothetical semantics of the program.

In terms of general software verification, this means that although one cannot algorithmically check whether any given program satisfies a given specification, one can require programs to be annotated with extra information that proves the program is correct, or to be written in a particular restricted form that makes the verification possible, and only accept programs which are verified in this way. In the case of type safety, the former corresponds to type annotations, and the latter corresponds to type inference. Taken beyond type safety, this idea leads to correctness proofs of programs through proof annotations such as in Hoare logic.

Another way of working around Rice's theorem is to search for methods which catch many bugs, without being complete. This is the theory of abstract interpretation.

Yet another direction for verification is model checking, which can only apply to finite-state programs, not to Turing-complete languages.

Formal statement

Let φ be an admissible numbering of partial computable functions. Let P be a subset of . Suppose that:

  1. P is non-trivial: P is neither empty nor itself.
  2. P is extensional: for all integers m and n, if φm = φn, then mPnP.

Then P is undecidable.

A more concise statement can be made in terms of index sets: The only decidable index sets are ∅ and .

Examples

Given a program P which takes a natural number n and returns a natural number P(n), the following questions are undecidable:

  • Does P terminate on a given n? (This is the halting problem.)
  • Does P terminate on 0?
  • Does P terminate on all n (i.e., is P total)?
  • Does P terminate and return 0 on every input?
  • Does P terminate and return 0 on some input?
  • Does P terminate and return the same value for all inputs?
  • Is P equivalent to a given program Q?

Proof by Kleene's recursion theorem

Assume for contradiction that is a non-trivial, extensional and computable set of natural numbers. There is a natural number and a natural number . Define a function by when and when . By Kleene's recursion theorem, there exists such that . Then, if , we have , contradicting the extensionality of since , and conversely, if , we have , which again contradicts extensionality since .

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 d2. 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 "Abraxas"; in each case, we would be able to solve the halting problem similarly.

Formal proof

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 strings and are themselves represented by strings. The partial function computed by the algorithm represented by a string a is denoted Fa. 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 Fa. 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 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 Fb 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 Fa(i),
  • then T simulates the computation of Fb(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 Ft = Fb and, because P(b) = "yes" and the output of P(x) depends only on Fx, 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 Ft = Fno-halt, i.e., the partial function that is never defined. Since P(no-halt) = "no" and the output of P(x) depends only on Fx, 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.

See also

References

Read other articles:

Boom ClapSingel oleh Charli XCXdari album The Fault in Our Stars (Music from the Motion Picture) dan SuckerDirilis15 Juni 2014 (2014-06-15)GenreElectropopsynth-pop[1]Durasi2:49Label Atlantic Asylum Neon Gold Pencipta Charlotte Aitchison Fredrik Berger Patrik Berger Stefan Gräslund Produser Patrik Berger Stefan Gräslund Kronologi singel Charli XCX Fancy (2014) Boom Clap (2014) Break the Rules (2014) Video musikBoom Clap di YouTube Boom Clap adalah lagu oleh penyanyi asal Inggris...

 

Scottish footballer This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: John White footballer, born 1937 – news · newspapers · books · scholar · JSTOR (June 2007) (Learn how and when to remove this template message) John White Personal informationFull name John Anderson White[1]Date of birth (1937-0...

 

Estlands försvarsmaktEesti KaitsevägiInformationNation EstlandOrganisationer Landförsvarsstyrkorna Flottan FlygvapnetHögkvarterTallinnHögste befälhavarePresident Alar KarisStatsrådFörsvarsminister Kalle LaanetFörsvarschefChef för Försvarsmakten Generallöjtnant Martin Herem[1]MilitärtjänstJa, 8-11 månader.[2]Stående styrkor6000[3]Reservstyrkor10 000[4]EkonomiBudget449 miljoner EUR (2016)[5]Andel av BNP2,07 % (2016)[5]Övrigt Estlands försvarsmakt (estniska:...

Gambar Arifin C Noer, pendiri Teater Kecil. Teater Kecil adalah sebuah kelompok teatrikal yang didirikan oleh Arifin C. Noer setelah ia pindah dan tinggal di Jakarta pada tahun 1968.[1][2] Teater Kecil menjadi salah satu gerbong dalam pembaharuan teater Indonesia.[1] Kekuatan mereka terletak pada tema-tema naskah yang mencerminkan kehidupan rakyat kecil seperti penderitaan, harapan dan integritas mereka.[1] Naskah-naskahnya menarik minat para teaterawan dari ge...

 

Tonight's PrimetimeGenreGelar wicaraPembuatHanamaria HutapeaTeuku Aditya OktafianoPresenterVincentDestaHesti PurwadinataEnzy StoriaNegara asalIndonesiaBahasa asliBahasa IndonesiaProduksiLokasi produksiSound Stage NET., Graha Mitra, JakartaDurasi60 menitRumah produksiNET. EntertainmentDistributorNet Visi MediaIndika GroupRilis asliJaringanNET.Format gambarHDTV (1080i 16:9)Format audioDolby Digital 5.1Rilis10 November 2017 (2017-11-10) –15 Juni 2018 (2018-6-15)Acara terkai...

 

Known extent to which a planet is suitable for life Habitable planet redirects here. For a list of potentially habitable planets found to date, see List of potentially habitable exoplanets. Understanding planetary habitability is partly an extrapolation of the conditions on Earth, as this is the only planet known to support life. Planetary habitability is the measure of a planet's or a natural satellite's potential to develop and maintain environments hospitable to life.[1] Life may b...

Type 1934 class destroyer Z3 Max Schultz in port History Nazi Germany NameMax Schultz NamesakeMax Schultz [de] Ordered7 July 1934 BuilderDeutsche Werke, Kiel Yard numberK244 Laid down2 January 1935 Launched30 November 1935 Commissioned8 April 1937 FateSunk, 22 February 1940. All hands lost. General characteristics (as built) Class and typeType 1934 destroyer Displacement 2,223 long tons (2,259 t) (standard) 3,156 long tons (3,207 t) (deep load) Length 119 m (390...

 

Russian politician In this name that follows Eastern Slavic naming customs, the patronymic is Yuryevna and the family name is Kuznetsova. You can help expand this article with text translated from the corresponding article in Russian. (February 2024) Click [show] for important translation instructions. Machine translation, like DeepL or Google Translate, is a useful starting point for translations, but translators must revise errors as necessary and confirm that the translation is ac...

 

Bencana alam (Inggris: Natural disaster), adalah suatu peristiwa yang terbagi menjadi dua berdasarkan pemicunya. Pertama, bencana yang terjadi secara alami dapat berupa banjir, letusan gunung berapi, gempa bumi, tsunami, tanah longsor, badai salju, kekeringan, hujan es, gelombang panas, hurikan, badai tropis, taifun, tornado, kebakaran liar dan wabah penyakit.[1] Beberapa bencana alam terjadi tidak secara alami.[1] Contohnya adalah kelaparan, yaitu kekurangan bahan pangan ...

Cet article est une ébauche concernant un album. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Versions Jane Album de Jane Birkin Sortie 1996 Genre Variété Label Mercury Records Albums de Jane Birkin Amours des feintes(1990) À la légère(1998)modifier Versions Jane est un album de reprises de chansons de Serge Gainsbourg par Jane Birkin, sorti en 1996. Chaque chanson bénéficie de nouveaux arra...

 

Coups d'état executed by the military in Pakistan Part of a series on the History of Pakistan Timeline Ancient Palaeolithic Soanian culture, c. 500,000 – 250,000 BCE Neolithic Mehrgarh, c. 7000 – c. 3000 BCE Indus Valley Civilisation, c. 3300 – c. 1700 BCE Vedic Civilization, c. 1500 – c. 500 BCE Achaemenid Empire, c. 550 – c. 330 BCE Gedrosia, c. 542 – c. 330 BCE Gandhara, c. 518 – c. 330 BCE Arachosia, c. 518 – c. 330 BCE Hindush, c. 517 – c. 330 BCE Sattagydia, c. 516 �...

 

Ini adalah nama Korea; marganya adalah Park. Park Yoo-naYoo-na pada 2019.Lahir23 Desember 1997 (umur 26)SeoulPekerjaanPemeranTahun aktif2015-sekarangAgenYG EntertainmentNama KoreaHangul박유나 Alih AksaraBak YunaMcCune–ReischauerPark Yuna Situs webPark Yoo-Na Park Yoo-na (lahir 23 Desember 1997) adalah seorang pemeran berkebangsaan Korea Selatan. Ia memulai karier beraktingnya melalui drama KBS2 Cheer Up! pada 2015. Ia membintangi video musik dari iKON yang berjudul WYD dan berd...

SMA Hokkaido Sapporo Minami SMA Hokkaido Sapporo Minami (北海道札幌南高等学校, Hokkaidō Sapporo Minami Kōtō Gakkō) adalah sebuah SMA di Chuo-ku, Sapporo, Hokkaidō, Jepang, yang didirikan pada 1895. SMA tersebut merupakan salah satu SMA favorit di Hokkaido. Terdapat sekitar 1,100 murid yang masuk sekolah tersebut. Sekolah tersebut dioperasikan oleh Badan Pendidikan Prefektur Hokkaido. Pada 1995, sekolah tersebut mengganti gedung sekolah lamanya dengan fasilitas baru. Alumni terk...

 

معاهدة باطوميمعلومات عامةالنوع معاهدة سلامالتوقيع 4 يونيو 1918المكان باطومي، جورجياشروط النفاذ مُصدق عليهاالموقعون الدولة العثمانية جمهورية أرمينيا الأولى جمهورية أذربيجان الديمقراطية جمهورية جورجيا الديموقراطيةتعديل - تعديل مصدري - تعديل ويكي بياناتمعاهدة باطومي وُقع...

 

Global navigation satellite system This article is about the global navigation satellite system. For the probe to the planet Jupiter, see Galileo (spacecraft). GalileoCountry/ies of originEuropean UnionOperator(s)EUSPA, ESATypeCivilian, commercialStatusInitial services[1][2][3]CoverageGlobalAccuracy20 cm (public since 24 January 2023)Constellation sizeNominal satellites30 (24 active + 6 spares)Current usable satellites23 usable, 1 not available, 4 not usable (09/2022)&...

Multi-purpose arena in Morris Township, New Jersey William G. Mennen Sports ArenaComcast Center at UMCP, main entranceLocation161 East Hanover AveMorristown, NJ 07960 United StatesPublic transit NJT Bus: 872OwnerThe Morris County Park CommissionOperatorThe Morris County Park CommissionCapacity2,500SurfaceIceConstructionBroke ground1973OpenedJanuary 12, 1975Structural engineerSunDurance Energy The William G. Mennen Sports Arena, commonly referred to as Mennen Arena, is a multi-purpose arena in...

 

Cricket team This article is about the men's team. For the women's team, see Italy women's national cricket team. ItalyNickname(s)‘Gli Azzurri’ (The Blues)AssociationItalian Cricket Federation Honorary President Simone Gambino Chairman Fabio Marabini Secretary Kelum PereraPersonnelCaptainGareth BergCoachGareth Berg[1]HistoryTwenty20 debutv  Oman at Dubai; 13 March 2012International Cricket CouncilICC statusAffiliate (1984) Associate member (1995)ICC regionEuropeICC Ranki...

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: St Mary's, Isles of Scilly – news · newspapers · books · scholar · JSTOR (January 2011) (Learn how and when to remove this message) Human settlement in EnglandSt Mary'sCornish: EnnorPorthcressa, showing part of Hugh TownSt Mary'sLocation within Isles of Scilly...

Pour les articles homonymes, voir Narodnaïa Volia. Narodnaïa VoliaHistoireFondation Juin 1879Dissolution Mars 1887CadreType Organisation politiqueMouvement Narodniki, terrorisme d'extrême gaucheSiège Saint-Pétersbourg (1879)Moscou (1881)Pays  Empire russeOrganisationIdéologie Socialisme révolutionnaire, socialisme agraire (en)modifier - modifier le code - modifier Wikidata Narodnaïa Volia (en russe : Народная воля ; en français : « Volonté du P...

 

Use of information on the historical relationships of lineages to test evolutionary hypotheses Phylogenetic comparative methods (PCMs) use information on the historical relationships of lineages (phylogenies) to test evolutionary hypotheses. The comparative method has a long history in evolutionary biology; indeed, Charles Darwin used differences and similarities between species as a major source of evidence in The Origin of Species. However, the fact that closely related lineages share many ...