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:

Administrative entry restrictions An Egyptian passport Visa requirements for Egyptian citizens are administrative entry restrictions imposed on citizens of Egypt by the authorities of other states. On 27 July 2022, Egyptian citizens had visa-free or visa on arrival access to 54 countries and territories, ranking the Egyptian passport 94th in terms of travel freedom according to the Henley Passport Index.[1] However, according to the most up-to-date list compiled on this wiki, Egyptian pa…

بطولة أمم أوروبا لكرة السلة 2009 بطولة أمم أوروبا لكرة السلة 2009 المعطيات المنطقة أوروبا المستضيف  بولندا العام 2009 التواريخ 7 – 20 سبتمبر الاتحادات 49 الفرق 16 المدن 7 الملاعب 7 البطل إسبانيا (للمرة الـ 1 ) موقع ويب EuroBasket 2009 (أرشيف) بطولة أمم أوروبا لكرة السلة 2007 بطولة أمم أوروبا لك

Perfect VelvetAlbum studio karya Red VelvetDirilis17 November 2017Direkam2016-2018Genre K-pop R&B Hip-hop electronica Durasi30:56 41:37 (edisi repackage)BahasaKoreaLabel SM Genie Iriver Inc. ProduserAgent 47 Lee Soo-manKronologi Red Velvet The Red Summer(2017) Perfect Velvet(2017) #Cookie Jar(2018) Singel dalam album Perfect Velvet Peek-a-BooDirilis: 17 November 2017 Sampul edisi RepackageGambar sampul digital The Perfect Red Velvet Singel dalam album The Perfect Red Velvet Bad BoyDirili…

النمرود النمرود  الصنف دراما، جريمة تاريخ الصدور 7 مايو 1956 مدة العرض 110 دقيقة البلد  مصر اللغة الأصلية العربية الطاقم المخرج عاطف سالم الإنتاج أفلام العهد الجديد قصة فريد شوقي سيناريو نجيب محفوظمحمود صبحيالسيد بدير حوار السيد بدير البطولة فريد شوقيهدى سلطان موسيقى فؤا

Jaszczurówka Kapelle, Zakopane Villa Konstantynówka, Zakopane Villa Oksza, Zakopane Der Zakopane-Stil (oder Witkiewicz-Stil) ist eine Architekturrichtung, inspiriert von der regionalen Baukunst der polnischen Hochlandregion bei Zakopane. Die als Podhale bezeichnete Region am nördlichen Rand der Tatra entwickelte eine eigene Holzarchitektur, welche vor allem von den dort lebenden Goralen begründet wurde. Stanisław Witkiewicz, der in dem litauischen Dorf Pašiaušė geboren wurde, ließ sich …

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Februari 2023. Tsubasa TakeuchiInformasi pribadiNama lengkap Tsubasa TakeuchiTanggal lahir 20 Mei 1991 (umur 32)Tempat lahir Prefektur Hiroshima, JepangPosisi bermain PenyerangKarier senior*Tahun Tim Tampil (Gol)2010-2013 Fagiano Okayama * Penampilan dan gol di kl…

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (أبريل 2019) مايك براي معلومات شخصية الميلاد 28 أبريل 1985 (38 سنة)  ماهومت  مواطنة الولايات المتحدة  الحياة العملية المهنة طبال  تعديل مصدري - تعديل   مايك براي (بال…

Campeonato Brasileiro Feminino Sub-16 de 2019 Dados Participantes 12 Organização Confederação Brasileira de Futebol Período 7 – 15 de dezembro Gol(o)s 72 Partidas 22 Média 3,27 gol(o)s por partida Campeã São Paulo (1.º título) Vice-campeã Santos 3.ª colocada Ferroviária 4.ª colocada Vitória 2020 ►► O Campeonato Brasileiro Feminino Sub-16 de 2019 foi a primeira edição desta competição futebolística de categoria de base da modalidade feminina organizada pela Confederaçã…

Conseil de sécuritédes Nations uniesRésolution 126 Caractéristiques Date 2 décembre 1957 Séance no  808 Vote Pour : 10Abs. : 1Contre : 0 Sujet la question Inde-Pakistan Résultat Adoptée Membres permanents Conseil de sécurité 1957 Chine (Taïwan) États-Unis France Royaume-Uni URSS Membres non permanents Australie Colombie Cuba Iraq Philippines Suède Résolution no 125 Résolution no 127modifier La résolution 126 du Conseil de sécurité des Nations unies…

كسوف الشمس 27 يناير 2074خريطةنوع الكسوفطبيعةحلقيغاما0.4251الحجم0.9798الكسوف الأقصىالمدة الزمنية141 ثانية (2 د 21 ث)إحداثيات6°36′N 78°48′E / 6.6°N 78.8°E / 6.6; 78.8أكبر عرض79 كـم (49 ميل)الأوقات (UTC)أعظم كسوف6:44:15مراجعساروس132 (49 من 71)كتلوج # (SE5000)9673سيحدث كسوف حلقي للشمس يوم الس…

PonteKomuneComune di PonteLokasi Ponte di Provinsi BeneventoNegara ItaliaWilayah CampaniaProvinsiBenevento (BN)Luas[1] • Total17,92 km2 (6,92 sq mi)Ketinggian[2]147 m (482 ft)Populasi (2016)[3] • Total2.861 • Kepadatan160/km2 (410/sq mi)Zona waktuUTC+1 (CET) • Musim panas (DST)UTC+2 (CEST)Kode pos82030Kode area telepon0824Situs webhttp://www.comunediponte.it Ponte adalah sebuah kota da…

Bupati Halmahera SelatanLambang Kabupaten Halmahera SelatanPetahanaHasan Ali Bassam Kasuba(Pelaksana Tugas)sejak 5 November 2023KediamanRumah Jabatan Bupati Halmahera SelatanMasa jabatan3 tahunDibentuk9 Juni 2003Pejabat pertamaArief Yasim WahidSitus webhttps://www.halmaheraselatankab.go.id/ Daftar Bupati Halmahera Selatan:[1] Nomor Wali kota Potret Partai Awal Akhir Masa jabatan Wakil 1 Arief Yasim Wahid 2003 2005 2 tahun 2 Muhammad Kasuba(lahir 1960) PKS 2005 2010 5 tahun Rusly Abd…

Abtswind Lambang kebesaranLetak Abtswind NegaraJermanNegara bagianBayernWilayahUnterfrankenKreisKitzingenMunicipal assoc.Wiesentheid Pemerintahan • MayorKlaus LenzLuas • Total12,81 km2 (495 sq mi)Ketinggian291 m (955 ft)Populasi (2013-12-31)[1] • Total850 • Kepadatan0,66/km2 (1,7/sq mi)Zona waktuWET/WMPET (UTC+1/+2)Kode pos97355Kode area telepon09383Pelat kendaraanKTSitus webwww.abtswind.de Abtswind adalah…

IACPPT Nama panjang: Konvensi Inter-Amerika untuk Mencegah dan Menghukum Penyiksaan   Telah meratifikasi Konvensi   Telah menandatangani, tetapi belum meratifikasi KonvensiDitandatangani9 Desember 1985LokasiCartagena de Indias, KolombiaEfektif28 Februari 1987Syarat2 ratifikasiPenanda tangan20Pihak18PenyimpanSekretariat Jenderal Organization of American StatesBahasaBahasa Inggris, Bahasa Prancis, Bahasa Portugis, Bahasa SpanyolKonvensi Inter-Amerika untuk Mencegah dan Menghuku…

Petrikirche in Riga, Lettland, mit drei Laternen und drei leicht gebauchten Kuppeln und einer Haube mit Spitzhelm Als Laterne (altgriechisch λαμπτήρ lamptér = „Leuchter“, „Fackel“; englisch lantern; französisch lanterne) oder Dachlaterne wird ein runder, quadratischer oder polygonaler pavillonartiger Aufsatz auf einem Gebäude bezeichnet. Er kann zur Seite hin offen oder durchfenstert sein; nach oben ist er zumeist geschlossen. In der Regel folgt die Grundrissform der Laterne de…

Hari Bersih-Bersih Sedunia (World Cleanup Day)Tanggal17 September 2022; 14 bulan lalu (2022-09-17)FrekuensiTahunanLokasiSeluruh duniaTahun aktif15Situs webwww.worldcleanupday.org Hari Bersih-bersih Sedunia (Inggris: World Cleanup Day) adalah aksi sosial global tahunan yang mengajak masyarakat di seluruh dunia untuk turut membersihkan dan menjaga kebersihan bumi yang bertujuan untuk mengurangi masalah limbah padat dan sampah laut.[1] Aksi ini merupakan acara global terbesar di bawah …

Hospital in Northern Region, UgandaYumbe General HospitalUganda Ministry of HealthGeographyLocationYumbe, Yumbe District, Northern Region, UgandaCoordinates03°27′56″N 31°14′35″E / 3.46556°N 31.24306°E / 3.46556; 31.24306OrganisationCare systemPublicTypeGeneralServicesEmergency departmentIBeds100HistoryOpened1960sLinksOther linksHospitals in Uganda Yumbe Hospital, is a hospital in the West Nile sub-region of the Northern Region of Uganda.[1] Location Th…

The existing Brent Cross Shopping Centre Brent Cross Cricklewood is a new town centre development under construction in Hendon and Cricklewood, London, United Kingdom. The development is planned to cost around £4.5 billion to construct and will include 6,700 homes, workspace for 25,000 people, four parks, transport improvements and a 592,000 sq ft (55,000 m2) extension of Brent Cross Shopping Centre.[1][2] The developers of the scheme are Hammerson and Standard Li…

قرية كافمن المنازل القديمة في القريةمعلومات عامةنوع المبنى قرية أثريةالمكان القريات، منطقة الجوفالمنطقة الإدارية محافظة القريات البلد  السعوديةمعلومات أخرىالإحداثيات 31°24′00″N 37°29′00″E / 31.39999998°N 37.48333297°E / 31.39999998; 37.48333297 تعديل - تعديل مصدري - تعديل ويكي بيانا…

Place in Styria, SloveniaJagočeJagočeLocation in SloveniaCoordinates: 46°10′9.01″N 15°14′17.36″E / 46.1691694°N 15.2381556°E / 46.1691694; 15.2381556Country SloveniaTraditional regionStyriaStatistical regionSavinjaMunicipalityLaškoArea • Total0.57 km2 (0.22 sq mi)Elevation234.5 m (769.4 ft)Population (2002) • Total153[1] Jagoče (pronounced [ˈjaːɡɔtʃɛ]) is a settlement on the right …

Kembali kehalaman sebelumnya

Lokasi Pengunjung: 3.137.171.145