Pairing Function

In mathematics, a pairing function is a process to uniquely encode two natural numbers into a single natural number.

Any pairing function can be used in set theory to prove that integers and rational numbers have the same cardinality as natural numbers.

Definition

A pairing function is a bijection[verification needed]

    Pairing Function 

More generally, a pairing function on a set A is a function that maps each pair of elements from A into an element of A, such that any two pairs of elements of A are associated with different elements of A, or a bijection from Pairing Function  to A.

Hopcroft and Ullman pairing function

Hopcroft and Ullman (1979) define the following pairing function: Pairing Function , where Pairing Function . This is the same as the Cantor pairing function below, shifted to exclude 0 (i.e., Pairing Function , Pairing Function , and Pairing Function ).

Cantor pairing function

Pairing Function 
The Cantor pairing function assigns one natural number to each pair of natural numbers
Pairing Function 
Graph of the Cantor pairing function

The Cantor pairing function is a primitive recursive pairing function

    Pairing Function 

defined by

    Pairing Function [verification needed]

where Pairing Function .

It can also be expressed as Pairing Function .

It is also strictly monotonic w.r.t. each argument, that is, for all Pairing Function , if Pairing Function , then Pairing Function ; similarly, if Pairing Function , then Pairing Function .[citation needed]

The statement that this is the only quadratic pairing function is known as the Fueter–Pólya theorem.[verification needed] Whether this is the only polynomial pairing function is still an open question. When we apply the pairing function to k1 and k2 we often denote the resulting number as k1, k2.[citation needed]

This definition can be inductively generalized to the Cantor tuple function[citation needed]

    Pairing Function 

for Pairing Function  as

    Pairing Function 

with the base case defined above for a pair: Pairing Function 

Inverting the Cantor pairing function

Let Pairing Function  be an arbitrary natural number. We will show that there exist unique values Pairing Function  such that

    Pairing Function 

and hence that the function π(x, y) is invertible. It is helpful to define some intermediate values in the calculation:

    Pairing Function 
    Pairing Function 
    Pairing Function 

where t is the triangle number of w. If we solve the quadratic equation

    Pairing Function 

for w as a function of t, we get

    Pairing Function 

which is a strictly increasing and continuous function when t is non-negative real. Since

    Pairing Function 

we get that

    Pairing Function 

and thus

    Pairing Function 

where ⌊ ⌋ is the floor function. So to calculate x and y from z, we do:

    Pairing Function 
    Pairing Function 
    Pairing Function 
    Pairing Function 

Since the Cantor pairing function is invertible, it must be one-to-one and onto.[additional citation(s) needed]

Examples

To calculate π(47, 32):

    47 + 32 = 79,
    79 + 1 = 80,
    79 × 80 = 6320,
    6320 ÷ 2 = 3160,
    3160 + 32 = 3192,

so π(47, 32) = 3192.

To find x and y such that π(x, y) = 1432:

    8 × 1432 = 11456,
    11456 + 1 = 11457,
    11457 = 107.037,
    107.037 − 1 = 106.037,
    106.037 ÷ 2 = 53.019,
    ⌊53.019⌋ = 53,

so w = 53;

    53 + 1 = 54,
    53 × 54 = 2862,
    2862 ÷ 2 = 1431,

so t = 1431;

    1432 − 1431 = 1,

so y = 1;

    53 − 1 = 52,

so x = 52; thus π(52, 1) = 1432.[citation needed]

Derivation

Pairing Function 
A diagonally incrementing "snaking" function, from same principles as Cantor's pairing function, is often used to demonstrate the countability of the rational numbers.

The graphical shape of Cantor's pairing function, a diagonal progression, is a standard trick in working with infinite sequences and countability. The algebraic rules of this diagonal-shaped function can verify its validity for a range of polynomials, of which a quadratic will turn out to be the simplest, using the method of induction. Indeed, this same technique can also be followed to try and derive any number of other functions for any variety of schemes for enumerating the plane.

A pairing function can usually be defined inductively – that is, given the nth pair, what is the (n+1)th pair? The way Cantor's function progresses diagonally across the plane can be expressed as

    Pairing Function .

The function must also define what to do when it hits the boundaries of the 1st quadrant – Cantor's pairing function resets back to the x-axis to resume its diagonal progression one step further out, or algebraically:

    Pairing Function .

Also we need to define the starting point, what will be the initial step in our induction method: π(0, 0) = 0.

Assume that there is a quadratic 2-dimensional polynomial that can fit these conditions (if there were not, one could just repeat by trying a higher-degree polynomial). The general form is then

    Pairing Function .

Plug in our initial and boundary conditions to get f = 0 and:

    Pairing Function ,

so we can match our k terms to get

    b = a
    d = 1-a
    e = 1+a.

So every parameter can be written in terms of a except for c, and we have a final equation, our diagonal step, that will relate them:

    Pairing Function 

Expand and match terms again to get fixed values for a and c, and thus all parameters:

    a = 1/2 = b = d
    c = 1
    e = 3/2
    f = 0.

Therefore

    Pairing Function 

is the Cantor pairing function, and we also demonstrated through the derivation that this satisfies all the conditions of induction.[citation needed]

Other pairing functions

The function Pairing Function  is a pairing function.

In 1990, Regan proposed the first known pairing function that is computable in linear time and with constant space (as the previously known examples can only be computed in linear time iff multiplication can be too, which is doubtful). In fact, both this pairing function and its inverse can be computed with finite-state transducers that run in real time.[clarification needed] In the same paper, the author proposed two more monotone pairing functions that can be computed online in linear time and with logarithmic space; the first can also be computed offline with zero space.[clarification needed]

In 2001, Pigeon proposed a pairing function based on bit-interleaving, defined recursively as:

    Pairing Function 

where Pairing Function  and Pairing Function  are the least significant bits of i and j respectively.[verification needed]

In 2006, Szudzik proposed a "more elegant" pairing function defined by the expression:

    Pairing Function 

Which can be unpaired using the expression:

    Pairing Function 

(Qualitatively, it assigns consecutive numbers to pairs along the edges of squares.) This pairing function orders SK combinator calculus expressions by depth.[clarification needed] This method is the mere application to Pairing Function  of the idea, found in most textbooks on Set Theory, used to establish Pairing Function  for any infinite cardinal Pairing Function  in ZFC. Define on Pairing Function  the binary relation

    Pairing Function 

Pairing Function  is then shown to be a well-ordering such that every element has Pairing Function  predecessors, which implies that Pairing Function . It follows that Pairing Function  is isomorphic to Pairing Function  and the pairing function above is nothing more than the enumeration of integer couples in increasing order. (See also Talk:Tarski's theorem about choice#Proof of the converse.)

Notes

References

This article uses material from the Wikipedia English article Pairing function, which is released under the Creative Commons Attribution-ShareAlike 3.0 license ("CC BY-SA 3.0"); additional terms may apply (view authors). Content is available under CC BY-SA 4.0 unless otherwise noted. Images, videos and audio are available under their respective licenses.
®Wikipedia is a registered trademark of the Wiki Foundation, Inc. Wiki English (DUHOCTRUNGQUOC.VN) is an independent company and has no affiliation with Wiki Foundation.

Tags:

Pairing Function DefinitionPairing Function Hopcroft and Ullman pairing functionPairing Function Cantor pairing functionPairing Function Other pairing functionsPairing FunctionMathematicsNatural number

🔥 Trending searches on Wiki English:

OpenAISoviet UnionStevie NicksScottish National PartyZachary LeviBholaaNew York CityRachel ZeglerJennifer LopezAndre AgassiNazi GermanyList of countries by GDP (nominal)TardigradeConor McGregor2026 FIFA World CupSaddam HusseinMaltaHaley CavinderGigi HadidDemi MooreBarack ObamaHoward HughesCoral CastlePhronimaSilicon Valley BankWindows Server 2019Ray KrocAhmed BestFlipkartGermanySandra BullockLance ReddickBoston Strangler (film)Jim LarrañagaJohn CenaMel GibsonAlbert EinsteinPakistanCole HauserDaylight saving timeDiana, Princess of WalesElvis PresleyHomi J. BhabhaElizabeth IRyan ReynoldsOmegleAdam SandlerAustin ButlerJayson MolumbyXXXYouTube PremiumTottenham Hotspur F.C.Laurence FishburneGmailAlexandra DaddarioSouth ParkChor Nikal Ke BhagaSuccession (TV series)Swarm (TV series)You (season 4)NCAA Division I men's basketball tournamentGrey's AnatomyYou (TV series)Elon MuskCleopatraList of highest-grossing Indian filmsCanadaAdolf HitlerXXXX (beer)Patrick BeverleyJennifer ConnellyGrimesSteven TylerMississippiUEFA Champions LeagueNeymar🡆 More