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:

City in Saxony-Anhalt, Germany City in Saxony-Anhalt, GermanyHalle (Saale) City From top: Halle city centre,Moritzburg (Halle), Halle-Neustadt, Francke Foundations and Halle State Museum of Prehistory FlagCoat of armsLocation of Halle (Saale) Halle (Saale) Show map of GermanyHalle (Saale) Show map of Saxony-AnhaltCoordinates: 51°28′58″N 11°58′11″E / 51.48278°N 11.96972°E / 51.48278; 11.96972CountryGermanyStateSaxony-AnhaltDistrictUrban districtGovernment...

Radio Disney Localización Pilar, Argentina[1]​[2]​Área de radiodifusión  Argentina Bolivia Brasil Chile Costa Rica Ecuador  México Panamá Paraguay Perú Dominicana UruguayEslogan La música te llega (Argentina, Bolivia, Paraguay, Uruguay)Frecuencia Frecuencia modulada FMPrimera emisión 1 de abril de 2001 (Argentina)[2]​Formato Música, concursos, noticiasIdioma EspañolPortugués (solo Brasil)Propietario The Walt D...

Questa voce sull'argomento malvaceae è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Come leggere il tassoboxCola Cola acuminata Classificazione APG IV Dominio Eukaryota Regno Plantae (clade) Angiosperme (clade) Mesangiosperme (clade) Eudicotiledoni (clade) Eudicotiledoni centrali (clade) Superrosidi (clade) Rosidi (clade) Eurosidi (clade) Malvidi Ordine Malvales Famiglia Malvaceae Sottofamiglia Sterculioideae Genere ColaSchott & Endl., 1832 Classi...

Gallarate–Varese Strecke der Bahnstrecke Gallarate–VareseStreckennummer (RFI):24Kursbuchstrecke (IT):165Streckenlänge:19 kmSpurweite:1435 mm (Normalspur)Stromsystem:3000 V =Zweigleisigkeit:Gallarate–Varese Legende S 30 von Mailand 24,922 Gallarate 242 m 25,0390,000 nach Domodossola und S 30 nach Luino A8 4,637 Cavaria-Oggiona-Jerago (ehem. Bahnhof) 279 m 7,518 Albizzate-Solbiate Arno 304 m 10,027 Castronno (ehem. Bahnhof) 323 m 14,030 Gazzada-Schianno-Morazzone...

Ця стаття про комуну. Про село див. Стенкуца. комуна СтенкуцаStăncuța Країна  Румунія Повіт  Бреїла Телефонний код +40 239 (Romtelecom, TR)+40 339 (інші оператори) Координати 44°53′48″ пн. ш. 27°50′12″ сх. д.H G O Висота 7 м.н.р.м. Площа 261,99 км² Населення 3654[1] (2009) Розташування Влад

Ecumenical council in Ephesus in 431, convened by Emperor Theodosius II This article is about the ecumenical council held in 431. For the two later councils in the same city, see Council of Ephesus (disambiguation). Council of EphesusImage in the church Notre-Dame de Fourvières, France. The priest standing right in the middle is Cyril of Alexandria. On the throne is the Virgin Mary and child Jesus.Date431Accepted by Catholic Church Eastern Orthodox Church Oriental Orthodox Churches Angl...

Mutiara Azzahra Umandana (lahir 12 Juli 2004)[1] adalah seorang penari dan penyanyi Indonesia serta anggota grup idola JKT48. Mutiara Azzahra UmandanaMuthe di Joy Kick! Tears HSF SurabayaLahirMutiara Azzahra Umandana12 Juli 2004 (umur 19)Tangerang, IndonesiaKebangsaanIndonesiaNama lainMuthe, Mutiara , MumuchangPekerjaanPenyanyiAktrisPresenterPenariModelTahun aktif2018 - sekarangKarier musikGenreJ-PopInstrumenVokalLabelIndonesia Musik NusantaraArtis terkaitJKT48AnggotaJK...

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (ديسمبر 2018) عين القنطرة الإحداثيات 35°44′34″N 36°10′4″E / 35.74278°N 36.16778°E / 35.74278; 36.16778 تقسيم إداري  البلد  ...

Kation benzenadiazonium Senyawa diazonium atau garam diazonium adalah kelompok senyawa organik yang memiliki kesamaan gugus fungsional R−N+2X− di mana R merupakan semua gugus organik, seperti alkil atau aril, dan X adalah suatu anion anorganik atau organik, seperti halogen. Garam diazonium, khususnya di mana R adalah suatu gugus aril,merupakan zat antara yang penting dalam sintesis organik pewarna azo.[1] Preparasi Proses pembentukan senyawa diazonium disebut sebagai diazotasi, di...

Overview of the events of 2021 in Philippine sports 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: 2021 in Philippine sports – news · newspapers · books · scholar · JSTOR (December 2020) (Learn how and when to remove this template message) Years in Philippine sports: 2018 2019 2020 2021 ...

Formula Pacific was a motor racing category which was used in the Pacific Basin area from 1977 to 1982. It specified a single-seat, open-wheeler chassis powered by a production-based four-cylinder engine of under 1600cc capacity.[1] The formula was based on Formula Atlantic, with provision made for the use of Japanese engines. The category was superseded in 1983 by Formula Mondial, which was devised by the FIA to replace both Formula Atlantic and Formula Pacific. Introduction The Form...

Everett McGillMcGill di San Diego Comic-Con 2017Lahir21 Oktober 1945 (umur 78)Miami Beach, Florida, Amerika SerikatKebangsaanAmerika SerikatPekerjaanPemeranTahun aktif1972–1999, 2015–2017 Everett McGill (nama lahir: Charles Everett McGill III, lahir 21 Oktober 1945) adalah seorang pemeran asal Amerika Serikat,[1] yang mula-mula meraih ketenaran karena memerankan manusia gua dalam Quest for Fire (1981). Ia memerankan peran-peran penting dalam film-film seperti Dune (1984)...

2014 filmNezha[1]Chinese theatrical release posterChinese少女哪吒Literal meaningGirl Nezha[2]Hanyu PinyinShàonǚ NézhāJyutpingSiu3neoi5 Naa4zaa1 Directed byLi Xiaofeng[3]Screenplay by Li Xiaofeng Wang Mu Pan Yu[3] Based onShàonǚ Nézhāby Lü Yao[3]Produced byShen Yang[4]Starring Li Jiaqi Li Haofei Chen Jin Xin Peng Li Huan[3] CinematographyJoewi Verhoeven[3]Edited byLiu Yueyue[2]Music byDrew Hanratty[3]P...

長野県出身の人物一覧(ながのけんしゅっしんのじんぶついちらん)は、長野県出身かつ「Wikipedia日本語版に記事が存在する」人物の一覧表である。リダイレクトのみの人物は含めない。 公人 政治家 現職の衆議院議員 務台俊介(自由民主党、安曇野市) 宮下一郎(自由民主党) 下条みつ(立憲民主党、松本市) 井出庸生(自由民主党、佐久市) 若林健太(自由民主...

This article contains wording that promotes the subject in a subjective manner without imparting real information. Please remove or replace such wording and instead of making proclamations about a subject's importance, use facts and attribution to demonstrate that importance. (April 2014) (Learn how and when to remove this template message) Warner/Chappell Music Inc. et al. v. Fullscreen Inc. et al.CourtUnited States District Court for the Southern District of New YorkHoldingA settlement was ...

SarilamakIbu kota kabupatenKantor Bupati Lima Puluh Kota di Sarilamak malam hariPemandangan SarilamakNegara IndonesiaProvinsiSumatera BaratKabupatenLima Puluh KotaKecamatanHarauLuas • Total416,80 km2 (160,93 sq mi)Populasi (2010) • Total46,718 • Kepadatan110/km2 (290/sq mi) SarilamakZona waktuUTC+7 (WIB) Kantor Bupati Lima Puluh Kota Sarilamak adalah ibu kota Kabupaten Lima Puluh Kota. Sarilamak juga merupakan sebuah nagari yan...

Tectosilicate mineral AfghaniteGeneralCategoryTectosilicatesFormula(repeating unit)(Na,K)22Ca10[Si24Al24O96](SO4)6Cl6IMA symbolAfg[1]Strunz classification9.FB.05Crystal systemTrigonalCrystal classDitrigonal pyramidal (3m) H-M symbol: (3m)Space groupP31c[2]Unit cella = 12.796, c = 21.409 [Å]; Z = 1IdentificationColorlight blue, dark blueCrystal habitLath shaped crystals, rounded grainsCleavagePerfect {1010}FractureConchoidalMohs scale hardness51⁄2 - 6Luste...

منفذ تسلسلي نوع تسلسيمواصفات عامةعدد الدبابيس 8 دبابيس (RS-422) 9 دبابيس (DB-9) 25 دبوس (RS-232) المنفذ التسلسلي (بالإنجليزية: Serial ports)‏ هو واجهة تخاطب فيزيائية تسلسلية تقوم بنقل المعلومات بين الحاسوب والطرفيات المربوطة إليه عن طريقها على مستوى بت واحد في وحدة الزمن على الرغم من أن بعض...

Cet article est une ébauche concernant l’Outaouais. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Sainte-Thérèse-de-la-Gatineau Administration Pays Canada Province Québec Région Outaouais Subdivision régionale La Vallée-de-la-Gatineau Statut municipal Municipalité Maire Mandat Roch Carpentier 2021-2025 Code postal J0X 2X0 Constitution 1er janvier 1946 Démographie Gentilé Thérésois, oise Population...

Sanskrit term for precepts and treatises For other uses, see Shastra (film) and Shaastra. Part of a series onHindu scriptures and texts Shruti Smriti List Vedas Rigveda Samaveda Yajurveda Atharvaveda Divisions Samhita Brahmana Aranyaka Upanishads UpanishadsRig vedic Aitareya Kaushitaki Sama vedic Chandogya Kena Yajur vedic Brihadaranyaka Isha Taittiriya Katha Shvetashvatara Maitri Atharva vedic Mundaka Mandukya Prashna Other scriptures Bhagavad Gita Agamas Related Hindu texts Vedangas Shiksha...

Kembali kehalaman sebelumnya