Share to: share facebook share twitter share wa share telegram print page

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 a given program is correct, or even executes without error.

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 "intension", 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 a 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:

PT Bakrie Telecom TbkNama dagangBtel GroupSebelumnyaPT Radio Telepon Indonesia (1993-2003)JenisPublikKode emitenIDX: BTELIndustriOperator telekomunikasi seluler (2003-2016)Perusahaan induk (2016-sekarang)Didirikan13 Agustus 1993KantorpusatWisma Bakrie I Lt. 3Jl. H.R. Rasuna Said Kav B2Jakarta, Indonesia[1]TokohkunciHarya Mitra Hidayat (Direktur Utama)ProdukJaringan telepon (1993-2012)Operator seluler (2003-2016)MerekRatelindo (1993-2006)Esia (2003-2016)Wimode (2007-2010)AHA (2010-2012)Wi…

Countess Géraldine Margit Virginia Olga Mária Apponyi dari Nagy-Appony (Bahasa Inggris: Geraldine; 6 Agustus 1915 – 22 Oktober 2002) adalah Ratu Albania dari pernikahannya dengan Raja Zog I pada 27 April 1938 hingga sang Raja turun takhta pada 7 April tahun berikutnya.[1] Géraldine dari Nagy-ApponyRatu Géraldine, 1938Ratu Permaisuri AlbaniaMenjabat27 April 1938 – 7 April 1939Informasi pribadiKelahiranCountess Géraldine Appony dari Nagy-Appony(1915-08-06)6 Agustus 1915Budapest, K…

President of South Korea from 2008 to 2013 In this Korean name, the family name is Lee. His ExcellencyLee Myung-bak이명박Official portrait, 200810th President of South KoreaIn office25 February 2008 – 24 February 2013Prime MinisterHan Seung-sooChung Un-chanKim Hwang-sikPreceded byRoh Moo-hyunSucceeded byPark Geun-hye32nd Mayor of SeoulIn office1 July 2002 – 30 June 2006Preceded byGoh KunSucceeded byOh Se-hoonMember of the National AssemblyIn office30 May 1996 –…

Election in Florida Main article: 1928 United States presidential election 1928 United States presidential election in Florida ← 1924 November 6, 1928 1932 →   Nominee Herbert Hoover Al Smith Party Republican Democratic Home state California New York Running mate Charles Curtis Joseph Taylor Robinson Electoral vote 6 0 Popular vote 144,168 101,764 Percentage 56.83% 40.12% County Results Hoover   40–50%   50–60%   60…

Len Barker's perfect gameLen Barker pitched the 10th perfect game in Major League Baseball history. Toronto Blue Jays Cleveland Indians 0 3 1 2 3 4 5 6 7 8 9 R H E Toronto Blue Jays 0 0 0 0 0 0 0 0 0 0 0 3 Cleveland Indians 2 0 0 0 0 0 0 1 X 3 7 0 DateMay 15, 1981VenueCleveland StadiumCityCleveland, OhioManagersBobby Mattick (Toronto Blue Jays)Dave Garcia (Cleveland Indians)TelevisionCleveland:WUAB channel 43TV announcersCleveland:Joe Tait and Bruce DrennanRadioCleveland:WWWE (3WE) 110…

Recipient of the Victoria Cross (1831–1874) 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: Frederick Miller VC – news · newspapers · books · scholar · JSTOR (July 2019) (Learn how and when to remove this template message) For other people named Frederick Miller, see Frederick Miller (disambiguation). Fr…

Concept in inferential statistics In statistical hypothesis testing,[1][2] a result has statistical significance when a result at least as extreme would be very infrequent if the null hypothesis were true.[3] More precisely, a study's defined significance level, denoted by α {\displaystyle \alpha } , is the probability of the study rejecting the null hypothesis, given that the null hypothesis is true;[4] and the p-value of a result, p {\displaystyle p} , is…

Перуанский анчоус Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеГруппа:Костные рыбыКласс:Лучепёрые рыбыПодкласс:Новопёрые ры…

Woodwind musical instrument This article is about the musical instrument. For textual symbol, see Diple (textual symbol). DipleClassification Bagpiping Related instruments Bock (Czech) Cimpoi (Romanian) Duda (Hungarian/Polish) Koza (Polish) Gaida (South Eastern Europe) (the Balkans) Tulum (Turkish and Pontic) Tsambouna (Dodecanese and Cyclades) Askomandoura (Crete) Gajdy (Polish/Czech/Slovak) Gaita (Galician) Surle (Croatian) Mezoued/Zukra (Northern Africa) Guda, tulum (Laz people) Dankiyo, zimp…

artikel ini perlu dirapikan agar memenuhi standar Wikipedia. Tidak ada alasan yang diberikan. Silakan kembangkan artikel ini semampu Anda. Merapikan artikel dapat dilakukan dengan wikifikasi atau membagi artikel ke paragraf-paragraf. Jika sudah dirapikan, silakan hapus templat ini. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini) Artikel ini tidak memiliki referensi atau sumber tepercaya sehingga isinya tidak bisa dipastikan. Tolong bantu perbaiki artikel ini dengan menambahka…

Former American ice hockey team Syracuse EaglesCitySyracuse, New YorkLeagueAmerican Hockey LeagueOperated1974–75Home arenaOnondaga County War Memorial Coliseum The Syracuse Eagles were a professional ice hockey team based in Syracuse, New York. The team relocated from Jacksonville, Florida that summer who were known as the Jacksonville Barons and previously the Cleveland Barons who were one of the most historic and illustrious teams of the American Hockey League from the 1930s to the 1960s. Th…

Francesco Vairano al Lucca Comics & Games 2015 Francesco Vairano (Napoli, 11 gennaio 1944[1]) è un doppiatore, direttore del doppiaggio, dialoghista e attore italiano. È conosciuto soprattutto per il doppiaggio di Alan Rickman nel ruolo di Severus Piton nella saga cinematografica di Harry Potter e di Andy Serkis nei panni di Gollum / Sméagol nella trilogia de Il Signore degli Anelli oltre che nel film Lo Hobbit - Un viaggio inaspettato di Peter Jackson;[2] di entrambe le s…

В Википедии есть статьи о других людях с фамилией Трухильо. Чедвик Трухильоангл. Chadwick A. Trujillo Дата рождения 22 ноября 1973(1973-11-22) (50 лет) Место рождения Ок-Парк, Кук, Иллинойс, США Страна США Научная сфера Астрономия Место работы Джемини (обсерватория) Альма-матер Гавайский ун…

Stephan ElliottStephan Elliott dan Olivia Newton-John di penayangan perdana filmnya A Few Best Men pada 2012Lahir27 Agustus 1964 (umur 59)Sydney, New South Wales, AustraliaPekerjaanSutradara, penulis naskahTahun aktif1992–sekarangPasanganWil Bevolley Stephan Elliott (lahir 27 Agustus 1964) adalah sutradara dan penulis naskah Australia. Ia dikenal karena film The Adventures of Priscilla, Queen of the Desert (1994) yang sukses secara internasional. Kehidupan pribadi Elliott menyebutkan…

2 Raja-raja 4Kitab Raja-raja (Kitab 1 & 2 Raja-raja) lengkap pada Kodeks Leningrad, dibuat tahun 1008.KitabKitab 2 Raja-rajaKategoriNevi'imBagian Alkitab KristenPerjanjian LamaUrutan dalamKitab Kristen12← pasal 3 pasal 5 → 2 Raja-raja 4 (atau II Raja-raja 4, disingkat 2Raj 4) adalah bagian dari Kitab 2 Raja-raja dalam Alkitab Ibrani dan Perjanjian Lama di Alkitab Kristen. Dalam Alkitab Ibrani termasuk Nabi-nabi Awal atau Nevi'im Rishonim [נביאים ראשונים] dalam bagian…

Chiesa di San Giorgio MartireStato Italia RegioneVeneto LocalitàLago (Revine Lago) Indirizzovia Guglielmo Marconi Coordinate45°59′11.47″N 12°12′59.29″E / 45.98652°N 12.21647°E45.98652; 12.21647Coordinate: 45°59′11.47″N 12°12′59.29″E / 45.98652°N 12.21647°E45.98652; 12.21647 Religionecattolica di rito romano TitolareSan Giorgio Martire Diocesi Vittorio Veneto Consacrazione1923 ArchitettoLorenzo Armellin Modifica dati su Wikidata …

Samsung Galaxy GrandSmartphone ProduttoreSamsung SerieSamsung Galaxy Inizio venditafebbraio 2013 SuccessoreSamsung Galaxy Grand 2 ComunicazioneRetiHSPA+ 21Mbps/HSUPA 5.76Mbps EDGE/GPRS Class 12 Quad band GSM 850/900/1800/1900 Quad bandUMTS 850/900/1900/2100 ConnettivitàConnettore Jack 3.5 mm; Wi-Fi (802.11a/b/g/n); Wi-Fi Direct; Bluetooth 4.0; Micro USB 2.0; DLNA; GLONASS; SoftwareSistema operativoAndroid 4.1.2 Jelly Bean, 4.2.2 Jelly Bean (solo versioni tedesche), 4.4.4 KitKat (corrente) Fotoc…

2022 film by Olivia Wilde Don't Worry DarlingTheatrical release posterDirected byOlivia WildeScreenplay byKatie SilbermanStory by Carey Van Dyke Shane Van Dyke Katie Silberman Produced by Olivia Wilde Katie Silberman Miri Yoon Roy Lee Starring Harry Styles Florence Pugh Olivia Wilde Gemma Chan KiKi Layne Nick Kroll Chris Pine CinematographyMatthew LibatiqueEdited byAffonso GonçalvesMusic byJohn PowellProductioncompanies New Line Cinema Vertigo Entertainment Distributed byWarner Bros. Pictur…

[[{{{1}}} (SNCF)|{{{1}}}]] TER Picardie adalah sebuah jaringan rel regional yang melayani région Picardie, Prancis. Terletak di sekitar Gare d'Amiens di Amiens. Jaringan Rel Amiens - Arras - Lille Amiens - Rouen Amiens - Tergnier - Laon - Reims Lille - Cambrai - Saint-Quentin - Laon - Reims Hirson - Marle - Laon Laon - Crépy-en-Valois - Paris Reims - Fismes - La Ferté-Milon - Meaux - Paris Reims - Epernay - Château-Thierry Amiens - Saint-Quentin Compiègne - Creil - Paris Creil - Compiègne …

У этого термина существуют и другие значения, см. Вена (значения). Вена Каталоги MeSHMeSHFMATA98 и TA98  Медиафайлы на Викискладе Схема венозной системы человека. Ве́на — кровеносный сосуд, по которому кровь движется к сердцу. Вены получают кровь из посткапиллярных венул. В…

Kembali kehalaman sebelumnya