Idempotence

On/Off buttons of a train's destination sign control panel. Pressing the On button (green) is an idempotent operation, since it has the same effect whether done once or multiple times. Likewise, pressing Off is idempotent.

Idempotence (UK: /ˌɪdɛmˈptəns/,[1] US: /ˈdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application. The concept of idempotence arises in a number of places in abstract algebra (in particular, in the theory of projectors and closure operators) and functional programming (in which it is connected to the property of referential transparency).

The term was introduced by American mathematician Benjamin Peirce in 1870[3][4] in the context of elements of algebras that remain invariant when raised to a positive integer power, and literally means "(the quality of having) the same power", from idem + potence (same + power).

Definition

An element of a set equipped with a binary operator is said to be idempotent under if[5][6]

.

The binary operation is said to be idempotent if[7][8]

for all .

Examples

  • In the monoid of the natural numbers with multiplication, only and are idempotent. Indeed, and .
  • In the monoid of the natural numbers with addition, only is idempotent. Indeed, 0 + 0 = 0.
  • In a magma , an identity element or an absorbing element , if it exists, is idempotent. Indeed, and .
  • In a group , the identity element is the only idempotent element. Indeed, if is an element of such that , then and finally by multiplying on the left by the inverse element of .
  • In the monoids and of the power set of the set with set union and set intersection respectively, and are idempotent. Indeed, for all , and for all .
  • In the monoids and of the Boolean domain with logical disjunction and logical conjunction respectively, and are idempotent. Indeed, for all , and for all .
  • In a GCD domain (for instance in ), the operations of GCD and LCM are idempotent.
  • In a Boolean ring, multiplication is idempotent.
  • In a Tropical semiring, addition is idempotent.
  • In a ring of quadratic matrices, the determinant of an idempotent matrix is either 0 or 1. If the determinant is 1, the matrix necessarily is the identity matrix.[citation needed]

Idempotent functions

In the monoid of the functions from a set to itself (see set exponentiation) with function composition , idempotent elements are the functions such that ,[9] that is such that for all (in other words, the image of each element is a fixed point of ). For example:

If the set has elements, we can partition it into chosen fixed points and non-fixed points under , and then is the number of different idempotent functions. Hence, taking into account all possible partitions,

is the total number of possible idempotent functions on the set. The integer sequence of the number of idempotent functions as given by the sum above for n = 0, 1, 2, 3, 4, 5, 6, 7, 8, ... starts with 1, 1, 3, 10, 41, 196, 1057, 6322, 41393, ... (sequence A000248 in the OEIS).

Neither the property of being idempotent nor that of being not is preserved under function composition.[10] As an example for the former, mod 3 and are both idempotent, but is not,[11] although happens to be.[12] As an example for the latter, the negation function on the Boolean domain is not idempotent, but is. Similarly, unary negation of real numbers is not idempotent, but is. In both cases, the composition is simply the identity function, which is idempotent.

Computer science meaning

In computer science, the term idempotence may have a different meaning depending on the context in which it is applied:

This is a very useful property in many situations, as it means that an operation can be repeated or retried as often as necessary without causing unintended effects. With non-idempotent operations, the algorithm may have to keep track of whether the operation was already performed or not.

Computer science examples

A function looking up a customer's name and address in a database is typically idempotent, since this will not cause the database to change. Similarly, a request for changing a customer's address to XYZ is typically idempotent, because the final address will be the same no matter how many times the request is submitted. However, a customer request for placing an order is typically not idempotent since multiple requests will lead to multiple orders being placed. A request for canceling a particular order is idempotent because no matter how many requests are made the order remains canceled.

A sequence of idempotent subroutines where at least one subroutine is different from the others, however, is not necessarily idempotent if a later subroutine in the sequence changes a value that an earlier subroutine depends on—idempotence is not closed under sequential composition. For example, suppose the initial value of a variable is 3 and there is a subroutine sequence that reads the variable, then changes it to 5, and then reads it again. Each step in the sequence is idempotent: both steps reading the variable have no side effects and the step changing the variable to 5 will always have the same effect no matter how many times it is executed. Nonetheless, executing the entire sequence once produces the output (3, 5), but executing it a second time produces the output (5, 5), so the sequence is not idempotent.

int x = 3;
void inspect() { printf("%d\n", x); }
void change() { x = 5; }
void sequence() { inspect(); change(); inspect(); }

int main() {
  sequence();  // prints "3\n5\n"
  sequence();  // prints "5\n5\n"
  return 0;
}

In the Hypertext Transfer Protocol (HTTP), idempotence and safety are the major attributes that separate HTTP methods. Of the major HTTP methods, GET, PUT, and DELETE should be implemented in an idempotent manner according to the standard, but POST doesn't need to be.[13] GET retrieves the state of a resource; PUT updates the state of a resource; and DELETE deletes a resource. As in the example above, reading data usually has no side effects, so it is idempotent (in fact nullipotent). Updating and deleting a given data are each usually idempotent as long as the request uniquely identifies the resource and only that resource again in the future. PUT and DELETE with unique identifiers reduce to the simple case of assignment to a variable of either a value or the null-value, respectively, and are idempotent for the same reason; the end result is always the same as the result of the initial execution, even if the response differs.[14]

Violation of the unique identification requirement in storage or deletion typically causes violation of idempotence. For example, storing or deleting a given set of content without specifying a unique identifier: POST requests, which do not need to be idempotent, often do not contain unique identifiers, so the creation of the identifier is delegated to the receiving system which then creates a corresponding new record. Similarly, PUT and DELETE requests with nonspecific criteria may result in different outcomes depending on the state of the system - for example, a request to delete the most recent record. In each case, subsequent executions will further modify the state of the system, so they are not idempotent.

In event stream processing, idempotence refers to the ability of a system to produce the same outcome, even if the same file, event or message is received more than once.

In a load–store architecture, instructions that might possibly cause a page fault are idempotent. So if a page fault occurs, the operating system can load the page from disk and then simply re-execute the faulted instruction. In a processor where such instructions are not idempotent, dealing with page faults is much more complex.[15][16]

When reformatting output, pretty-printing is expected to be idempotent. In other words, if the output is already "pretty", there should be nothing to do for the pretty-printer.[citation needed]

In service-oriented architecture (SOA), a multiple-step orchestration process composed entirely of idempotent steps can be replayed without side-effects if any part of that process fails.

Many operations that are idempotent often have ways to "resume" a process if it is interrupted – ways that finish much faster than starting all over from the beginning. For example, resuming a file transfer, synchronizing files, creating a software build, installing an application and all of its dependencies with a package manager, etc.

Applied examples

A typical crosswalk button is an example of an idempotent system

Applied examples that many people could encounter in their day-to-day lives include elevator call buttons and crosswalk buttons.[17] The initial activation of the button moves the system into a requesting state, until the request is satisfied. Subsequent activations of the button between the initial activation and the request being satisfied have no effect, unless the system is designed to adjust the time for satisfying the request based on the number of activations.

See also

References

  1. ^ "idempotence". Oxford English Dictionary (3rd ed.). Oxford University Press. 2010.
  2. ^ "idempotent". Merriam-Webster. Archived from the original on 2016-10-19.
  3. ^ Original manuscript of 1870 lecture before National Academy of Sciences (Washington, DC, USA): Peirce, Benjamin (1870) "Linear associative algebra" From pages 16-17: "When an expression which is raised to the square or any higher power vanishes, it may be called nilpotent; but when raised to a square or higher power it gives itself as the result, it may be called idempotent.
    The defining equation of nilpotent and idempotent expressions are respectively An = 0 and An = A; but with reference to idempotent expressions, it will always be assumed that they are of the form An = A unless it be otherwise distinctly stated."
  4. ^ Polcino & Sehgal 2002, p. 127.
  5. ^ Valenza, Robert (2012). Linear Algebra: An Introduction to Abstract Mathematics. Berlin: Springer Science & Business Media. p. 22. ISBN 9781461209010. An element s of a magma such that ss = s is called idempotent.
  6. ^ Doneddu, Alfred (1976). Polynômes et algèbre linéaire (in French). Paris: Vuibert. p. 180. Soit M un magma, noté multiplicativement. On nomme idempotent de M tout élément a de M tel que a2 = a.
  7. ^ George Grätzer (2003). General Lattice Theory. Basel: Birkhäuser. ISBN 978-3-7643-6996-5. Here: Sect.1.2, p.5.
  8. ^ Garrett Birkhoff (1967). Lattice Theory. Colloquium Publications. Vol. 25. Providence: Am. Math. Soc.. Here: Sect.I.5, p.8.
  9. ^ This is an equation between functions. Two functions are equal if their domains and ranges agree, and their output values agree on their whole domain.
  10. ^ If and commute under composition (i.e. if ) then idempotency of both and implies that of , since , using the associativity of composition.
  11. ^ e.g. , but
  12. ^ also showing that commutation of and is not a necessary condition for idempotency preservation
  13. ^ IETF, Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content Archived 2014-06-08 at the Wayback Machine. See also HyperText Transfer Protocol.
  14. ^ "Idempotent Methods". Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content. sec. 4.2.2. doi:10.17487/RFC7231. RFC 7231. It knows that repeating the request will have the same intended effect, even if the original request succeeded, though the response might differ.
  15. ^ John Ousterhout. "Demand Paging".
  16. ^ Marc A. de Kruijf. "Compiler construction of idempotent regions and applications in architecture design". 2012. p. 10.
  17. ^ "Geared Traction Passenger Elevator Specification Guide Information/Instructions" (PDF). NC Department Of Labor, Elevator Bureau. 2002. Archived from the original (PDF) on 2011-05-23. For example, this design specification includes detailed algorithm for when elevator cars will respond to subsequent calls for service

Further reading

Read other articles:

Puteri Indonesia PapuaLogo Puteri IndonesiaPembuatMooryati SoedibyoNegara asal Papua, IndonesiaRilisRilis asli1992 –SekarangPranala luarSitus web Puteri Indonesia Papua adalah sebuah kontes kecantikan yang ada di provinsi Papua, yang diadakan sejak tahun 1995 dengan nama provinsi Irian Jaya, dan pada tahun 2002 berubah menjadi Papua. Pemenang Puteri Indonesia Papua akan mewakili Papua pada kontes Puteri Indonesia, pemegang saat ini adalah Yunita Alanda Monim dari Kabupaten Jayapur...

2000 American filmBamboozledTheatrical release posterDirected bySpike LeeWritten bySpike LeeProduced byJon KilikSpike LeeStarring Damon Wayans Savion Glover Jada Pinkett Smith Tommy Davidson Michael Rapaport CinematographyEllen KurasEdited bySam PollardMusic byTerence BlanchardProductioncompany40 Acres and a Mule FilmworksDistributed byNew Line CinemaRelease date October 6, 2000 (2000-10-06) (United States) Running time135 minutesCountryUnited StatesLanguageEnglishBudget$10...

Type of commercial fission reactor 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: GE BWR – news · newspapers · books · scholar · JSTOR (January 2014) (Learn how and when to remove this template message) GE BWR(General Electric Boiling Water Reactor)GenerationGeneration I (BWR-1)Generation IIGeneration III (...

Inhaltsverzeichnis 1 Austragungsorte 2 Resultate 2.1 Frauen 2.1.1 Sprint 2.1.2 Keirin 2.1.3 Teamsprint 2.1.4 Mannschaftsverfolgung 2.1.5 Scratch 2.1.6 Punktefahren 2.1.7 Omnium 2.2 Männer 2.2.1 Sprint 2.2.2 Keirin 2.2.3 Teamsprint 2.2.4 Einerverfolgung 2.2.5 Mannschaftsverfolgung 2.2.6 Scratch 2.2.7 Punktefahren 2.2.8 Omnium 2.2.9 Zweier-Mannschaftsfahren 2.3 Teamwertung 3 Teamkürzel 4 Weblinks 5 Einzelnachweise Der UCI-Bahnrad-Weltcup 2015/16 wurde in drei Läufen zwischen November 2015 un...

У Вікіпедії є статті про інші значення цього терміна: Празький мир. Празький мир Тип мирна угода і договірПідписано 23 серпня 1866Місце ПрагаПідписанти Австрійська імперія і Королівство ПруссіяМови німецька Пра́зький мир (нім. Prager Frieden) — мирний договір між Австрі�...

The Church of Jesus Christ of Latter-day Saints in the United KingdomThe Preston England TempleAreaEurope NorthMembers186,933 (2022)[1]Stakes44Wards275Branches42Total Congregations[2]317Missions6Temples2 Operating1 Announced3 TotalFamily History Centers124[3] The Church of Jesus Christ of Latter-day Saints in the United Kingdom refers to the Church of Jesus Christ of Latter-day Saints (LDS Church) and its members in the United Kingdom. In 2019, the United Kingdom had t...

Bahasa CommunicationsspracheDibuat olehJoseph SchipferTanggal1836Pengaturan dan penggunaanBahasa pengantar internasionalTujuanBahasa buatan Bahasa pengantar internasionalCommunicationssprache SumberSebagian besar kosa kata dan tata bahasa berasal dari bahasa Prancis, dengan beberapa pengaruh dari bahasa Latin, bahasa Inggris dan bahasa JermanKode bahasaISO 639-3Tidak ada (mis)GlottologTidak adaIETFart-x-commsspr  Portal BahasaSunting kotak info • L • B • PWBantu...

ErotomaniaPasien wanita yang menderita erotomania, dari karya Alexander Morison The Physiognomy of Mental DiseasesInformasi umumSpesialisasiPsikiatri  Erotomania atau dikenal dengan sebutan sindroma de Clerambault adalah suatu bentuk gangguan kepribadian saat para penderitanya memiliki keyakinan bahwa orang lain memendam perasaan cinta kepada si penderita atau mungkin memiliki suatu bentuk hubungan intim.[1] Gangguan kepribadian ini rata-rata penderitanya adalah kaum Wanita.[...

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: Green European Foundation – news · newspapers · books · scholar · JSTOR (July 2021) (Learn how and when to remove this template message) AbbreviationGEFFormation2008TypePolitical foundation at European levelLocationRue d'Arlon 15, 1050 Brussels, BelgiumCo-Presi...

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: List of shopping malls in Venezuela – news · newspapers · books · scholar · JSTOR (June 2014) (Learn how and when to remove this template message) This is a list of shopping malls in Venezuela.[1] Capital District Centro comercial Sambil en el municipio...

Pulau Opak Besar BaratPulau Pulau Opak Besar Barat merupakan pulau yang berada pada gugusan Kepulauan Seribu yang secara administratif termasuk dalam wilayah Kabupaten Administratif Kepulauan Seribu provinsi DKI Jakarta yang letak berdekatan dengan Pulau Air Besar, Pulau Karang Beras, Pulau Karang Congkak, Pulau Opak Besar Timur, dan Pulau Opak Kecil Lihat pula Kabupaten Administratif Kepulauan Seribu Kepulauan Seribu Pranala luar Situs resmi Kabupaten Administratif Kepulauan Seribu Diarsipka...

2012 French filmA Perfect PlanTheatrical release posterDirected byPascal ChaumeilScreenplay by Laurent Zeitoun Yoann Gromb Story byPhilippe MechelenProduced by Nicolas Duval-Adassovsky Laurent Zeitoun Yann Zenou Starring Diane Kruger Dany Boon Alice Pol CinematographyGlynn SpeeckaertEdited byDorian Rigal-AnsousMusic byKlaus BadeltProductioncompanyQuad ProductionsDistributed byUniversal PicturesRelease date 31 October 2012 (2012-10-31) (France) Running time104 minutesCountry...

Neologism This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article may be unbalanced towards certain viewpoints. Please improve the article by adding information on neglected viewpoints, or discuss the issue on the talk page. (June 2012) This article possibly contains synthesis of material which does not verifiably mention or relate to the main topic. Relevant discussion may be found ...

Former horse racing venue in the Republic of Ireland 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: Phoenix Park Racecourse – news · newspapers · books · scholar · JSTOR (June 2019) (Learn how and when to remove this template message) Postcard showing King Edward VII attended the races in 1904 Phoenix Park ...

جون رابي (بالألمانية: John Rabe)‏    معلومات شخصية الميلاد 23 نوفمبر 1882[1]  هامبورغ  الوفاة 5 يناير 1950 (67 سنة) [1]  برلين  سبب الوفاة سكتة دماغية  مواطنة ألمانيا  أقرباء توماس رابي  [لغات أخرى]‏ (ابن الابن)  الحياة العملية المهنة رائد أعمال  الح�...

Para la versión SUV basada en camioneta del segmento D, véase Ford Bronco#Sexta generación (U725; 2021). Ford Bronco Sport Datos generalesOtros nombres Ford Bronco Sport (CX430)Empresa matriz Ford Motor CompanyFabricante FordProducción Hermosillo Stamping & Assembly[1]​Período 2020-presenteConfiguraciónTipo Automóvil todoterrenoSegmento Segmento CPlataforma Ford C2Carrocerías SUV Crossover cinco puertasConfiguración Motor delantero transversal, tracción delantera / tracci�...

نصف السماءمعلومات عامةتاريخ الصدور 2015مدة العرض 105 دقيقةاللغة الأصلية لهجة مغربيةالبلد  المغربالطاقمالمخرج عبد القادر لقطعالبطولة أنس البازصونيا عكاشةبثينة الفكاكتعديل - تعديل مصدري - تعديل ويكي بيانات نصف السماء هو فيلم مغربي من إخراج عبد القادر لقطع سنة 2015، وبطولة ك�...

Montage Voyager 1 dan Voyager 2 saat mengunjungi planet dan bulan. Voyager 1 hanya mengobservasi Jupiter dan Saturnus sedangkan Voyager 2 mengobservasi kempat planet raksasa. Program Voyager adalah rangkaian misi luar angkasa yang diluncurkan pada tahun 1977 milik Amerika Serikat. Misi ini meliputi peluncuran dua wahana antariksa tak berawak, yaitu Voyager 1 dan Voyager 2. Keduanya diluncurkan pada tahun 1977 dengan alasan untuk memanfaatkan deretan planet yang sesuai pada akhir 1970-an. Tuju...

King of MahjongPoster filmNama lainTradisional麻雀王Sederhana麻雀王MandarinMá Què WángKantonMaa4 Zeok3 Wong4 SutradaraAdrian TehProduserAllyan TooLim TeckSkenarioLai Chaing-mingAgn Siew-hoongHo You-wangPemeranChapman ToMark LeeMichelle YeVenus WongSinematograferYong Choon-linPenyuntingKeree TehPerusahaanproduksiZingshot ProductionsRex Film ProductionLuxury Watch ClubAcross SolutionsClover FilmsAsia Tropical FilmsDistributorClover FilmsCathay-Keris Films[1]Tanggal rilis ...

هطولمعلومات عامةصنف فرعي من hydrometeor (en) جزء من طقس الأسباب سحاب ممثلة بـ كمية الأمطار تعديل - تعديل مصدري - تعديل ويكي بيانات متوسط هطول المطر حسب الشهر الهطول (جمع الهَطْل [1]) في علم الطقس: نزول الماء بكثافة على شكل مطر أو ثلج أو بَرَد[2]، أي يمكن أن يكون بشكل ماء سائل أو ...