Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Verhoeff algorithm

From Wikipedia, the free encyclopedia
Decimal error detection code

TheVerhoeff algorithm[1] is achecksum forerror detection first published by Dutch mathematicianJacobus Verhoeff in 1969.[2][3] It was the first decimalcheck digit algorithm that detects all single-digit errors, and all transposition errors involving two adjacent digits,[4] which was at the time thought impossible with such a code.

The method was independently discovered by H. Peter Gumm in 1985, this time including aformal proof and an extension to any base.[5]

Goals

[edit]

Verhoeff had the goal of finding a decimal code—one where the check digit is a single decimal digit—which detected all single-digit errors and all transpositions of adjacent digits. At the time, supposed proofs of the nonexistence[6] of these codes made base-11 codes popular, for example in theISBN check digit.

His goals were also practical, and he based the evaluation of different codes on live data from the Dutch postal system, using a weighted points system for different kinds of error. The analysis broke the errors down into a number of categories: first, by how many digits are in error; for those with two digits in error, there aretranspositions (abba),twins (aabb),jump transpositions (abccba),phonetic (1aa0), andjump twins (abacbc). Additionally there are omitted and added digits. Although the frequencies of some of these kinds of errors might be small, some codes might be immune to them in addition to the primary goals of detecting all singles and transpositions.

The phonetic errors in particular showed linguistic effects, because in Dutch, numbers are typically read in pairs; and also while 50 sounds similar to 15 in Dutch, 80 does not sound like 18.

Taking six-digit numbers as an example, Verhoeff reported the following classification of the errors:.

Digits in errorClassificationCountFrequency
1Transcription9,57479.05%
2Transpositions1,23710.21%
Twins670.55%
Phonetic590.49%
Other adjacent2321.92%
Jump transpositions990.82%
Jump Twins350.29%
Other jump errors430.36%
Other980.81%
31691.40%
41180.97%
52191.81%
61621.34%
Total12,112

Description

[edit]

The general idea of the algorithm is to represent each of the digits (0 through 9) as elements of thedihedral group D5. That is, map digits to D5, manipulate these, then map back into digits. Let this mapping bem : [0, 9] → D5

m=(0123456789err2r3r4srsr2sr3sr4s){\displaystyle m={\begin{pmatrix}0&1&2&3&4&5&6&7&8&9\\e&r&r^{2}&r^{3}&r^{4}&s&rs&r^{2}s&r^{3}s&r^{4}s\end{pmatrix}}}

Let thenth digit bean and let the number of digits bek.

For example given the code 942 thenk is 3 anda3 =m(2) =r2.

Now define the permutationf : D5 → D5

f=(err2r3r4srsr2sr3sr4srsr2srsr2r3sr3er4sr4){\displaystyle f={\begin{pmatrix}e&r&r^{2}&r^{3}&r^{4}&s&rs&r^{2}s&r^{3}s&r^{4}s\\r&s&r^{2}s&rs&r^{2}&r^{3}s&r^{3}&e&r^{4}s&r^{4}\end{pmatrix}}}

For example,f(r3)=rs{\displaystyle f(r^{3})=rs}. Another example isf2(r3)=r3{\displaystyle f^{2}(r^{3})=r^{3}} sincef(f(r3))=f(rs)=r3{\displaystyle f(f(r^{3}))=f(rs)=r^{3}}.

Using multiplicative notation for the group operation of D5, the check digit is then simply a valuec such that

f0(c)f1(ak)fk1(a2)fk(a1)=e{\displaystyle f^{0}(c)\cdot f^{1}(a_{k})\cdot \ldots \cdot f^{k-1}(a_{2})\cdot f^{k}(a_{1})=e}

c is explicitly given by multiplicative inverse:

c=(n=1kfn(ak+1n))1{\displaystyle c=\left(\prod _{n=1}^{k}f^{n}(a_{k+1-n})\right)^{-1}}

For example the check digit for 942 is 7. To verify this, use the mapping to D5 and insert into the LHS of the previous equation

f0(r2s)f1(r2)f2(r4)f3(r4s)=e{\displaystyle f^{0}(r^{2}s)\cdot f^{1}(r^{2})\cdot f^{2}(r^{4})\cdot f^{3}(r^{4}s)=e}

To evaluate this permutation quickly use that

f3(r4s)=f2(r4)=f1(r2)=f0(r2s)=r2s{\displaystyle f^{3}(r^{4}s)=f^{2}(r^{4})=f^{1}(r^{2})=f^{0}(r^{2}s)=r^{2}s}

to get that

r2sr2sr2sr2s=e{\displaystyle r^{2}s\cdot r^{2}s\cdot r^{2}s\cdot r^{2}s=e}

This is the same reflection being iteratively multiplied. Use that reflections are their own inverse.[7]

(r2sr2s)(r2sr2s)=e2=e{\displaystyle (r^{2}s\cdot r^{2}s)\cdot (r^{2}s\cdot r^{2}s)=e^{2}=e}

In practice, the algorithm is implemented using simplelookup tables without needing to understand how to generate those tables from the underlying group and permutation theory. This is more properly considered a family of algorithms, as other permutations work too. Verhoeff's notes that the particular permutation, given above, is special as it has the property of detecting 95.3% of the phonetic errors.[8]

The strengths of the algorithm are that it detects all transliteration and transposition errors, and additionally most twin, twin jump, jump transposition and phonetic errors.

The main weakness of the Verhoeff algorithm is its complexity. The calculations required cannot easily be expressed as a formula in sayZ / 10Z. Lookup tables are required for easy calculation. A similar code is theDamm algorithm, which has similar qualities.

Table-based algorithm

[edit]

The Verhoeff algorithm can be implemented using three tables:a multiplication tabled, an inverse table inv, and a permutation tablep.

d[9]k
0123456789
j00123456789
11234067895
22340178956
33401289567
44012395678
55987604321
66598710432
77659821043
88765932104
99876543210
jinv(j)
00
14
23
32
41
55
66
77
88
99
pnum
0123456789
pos (mod 8)
00123456789
11576283094
25803796142
38916043527
49453126870
54286573901
62793806415
77046913258

The first table,d, is based on multiplication in the dihedral group D5.[7] and is simply theCayley table of the group. Note that this group is notcommutative, that is, for some values ofj andk,d(j,k) ≠d(k,j).

The inverse tableinv represents themultiplicative inverse of a digit, that is, the value that satisfiesd(j, inv(j)) = 0.

The permutation tablep applies apermutation to each digit based on its position in the number. This is actually a single permutation(1 5 8 9 4 2 7 0)(3 6) applied iteratively; i.e.p(i +j,n) =p(i,p(j,n)).

The Verhoeff checksum calculation is performed as follows:

  1. Create an arrayn out of the individual digits of the number, taken from right to left (rightmost digit isn0, etc.).
  2. Initialize the checksumc to zero.
  3. For each indexi of the arrayn, starting at zero, replacec withd(c,p(i mod 8,ni)).

The original number is valid if and only ifc = 0.

To generate a check digit, append a 0, perform the calculation: the correct check digit is inv(c).

Examples

[edit]

Generate a check digit for236:

inip(i,ni)c
0000
1633
2331
3212

c is 2, so the check digit is inv(2), which is 3.

Validate the check digit in 2363:

inip(i,ni)c
0333
1631
2334
3210

c is zero, so the check is correct.

Uses

[edit]

The Verhoeff algorithm is used in a variety of systems, including:

See also

[edit]

References

[edit]
  1. ^Verhoeff, J. (1969). "Error Detecting Decimal Codes (Tract 29)".Zeitschrift für Angewandte Mathematik und Mechanik.51 (3). The Mathematical Centre, Amsterdam: 240.Bibcode:1971ZaMM...51..240N.doi:10.1002/zamm.19710510323.
  2. ^Kirtland, Joseph (2001)."5. Group Theory and the Verhoeff Check Digit Scheme".Identification Numbers and Check Digit Schemes. Mathematical Association of America. p. 153.ISBN 0-88385-720-0.
  3. ^Salomon, David (2005)."§2.11 The Verhoeff Check Digit Method".Coding for Data and Computer Communications. Springer. pp. 56–58.ISBN 0-387-21245-0.
  4. ^Haunsperger, Deanna; Kennedy, Stephen, eds. (2006).The Edge of the Universe: Celebrating Ten Years of Math Horizons. Mathematical Association of America. p. 38.ISBN 978-0-88385-555-3.LCCN 2005937266.
  5. ^Gumm, H. (January 1985)."A new class of check-digit methods for arbitrary number systems (Corresp.)".IEEE Transactions on Information Theory.31 (1):102–105.doi:10.1109/TIT.1985.1056991.
  6. ^Sisson, Roger L. (May 1958)."An improved decimal redundancy check".Communications of the ACM.1 (5):10–12.doi:10.1145/368819.368854.
  7. ^abGallian, Joseph A. (2010).Contemporary Abstract Algebra (7th ed.). Brooks/Cole. p. 111.ISBN 978-0-547-16509-7.LCCN 2008940386. RetrievedAugust 26, 2011.verhoeff check digit.
  8. ^Verhoeff 1969, p. 95
  9. ^Verhoeff 1969, p. 83
  10. ^"EIMI 2010 Proceedings"(PDF).Freudenthal Institute, Utrecht University. Lisbon, Portugal: Educational Interfaces between Mathematics and Industry. 2010. p. 128.doi:10.1007/978-3-319-02270-3. Archived fromthe original(PDF) on 16 May 2024. Retrieved13 September 2025.
  11. ^Surelia, Vipin."Implementation of Verhoeff Algorithm by banks for Aadhaar related applications"(PDF).npci.org.in. National Payments Corporation of India. p. 1. Archived fromthe original(Official Circular) on 10 September 2025. Retrieved10 September 2025.
  12. ^"Meter Point Reference Number (MPRN)".mrso.ie. Meter Registration System Operator, Ireland. Archived fromthe original on 13 September 2025. Retrieved13 September 2025.
  13. ^"Check digit computation".docs.snomed.org. SNOMED International. Archived fromthe original(Official Documentation) on 13 September 2025. Retrieved13 September 2025.

External links

[edit]
Wikibooks has a book on the topic of:Algorithm_Implementation/Checksums/Verhoeff_Algorithm
Retrieved from "https://en.wikipedia.org/w/index.php?title=Verhoeff_algorithm&oldid=1331921933"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp