Unary numeral system
|Hindu–Arabic numeral system|
|Positional systems by base|
|Non-standard positional numeral systems|
|List of numeral systems|
The unary numeral system is the bijective base-1 numeral system. It is the simplest numeral system to represent natural numbers: in order to represent a number N, an arbitrarily chosen symbol representing 1 is repeated N times. For examples, the numbers 1, 2, 3, 4, 5, ... would be represented in this system as
- 1, 11, 111, 1111, 11111, ...
This system is used in tallying. For example, using the tally mark |, the number 3 is represented as |||. In East Asian cultures, the number three is represented as “三”, a character that is drawn with three strokes.
Addition and subtraction are particularly simple in the unary system, as they involve little more than string concatenation. The Hamming weight or population count operation that counts the number of nonzero bits in a sequence of binary values may also be interpreted as a conversion from unary to binary numbers. Multiplication is more cumbersome, however, and has often been used as a test case for the design of Turing machines.
Compared to standard positional numeral systems, the unary system is inconvenient and is hence not used in practice for large calculations. It occurs in some decision problem descriptions in theoretical computer science (e.g. some P-complete problems), where it is used to "artificially" decrease the run-time or space requirements of a problem. For instance, the problem of integer factorization is suspected to require more than a polynomial function of the length of the input as run-time if the input is given in binary, but it only needs linear runtime if the input is presented in unary. But this is potentially misleading: using a unary input is slower for any given number, not faster; the distinction is that a binary (or larger base) input is proportional to the base 2 (or larger base) logarithm of the number while unary input is proportional to the number itself; so while the run-time and space requirement in unary looks better as function of the input size, it does not represent a more efficient solution.
In computational complexity theory, unary numbering is used to distinguish strongly NP-complete problems from problems that are NP-complete but not strongly NP-complete. A problem in which the input includes some numerical parameters is strongly NP-complete if it remains NP-complete even when the size of the input is made artificially larger by representing the parameters in unary. For such a problem, there exist hard instances for which all parameter values are at most polynomially large.
Unary is used as part of some data compression algorithms such as Golomb coding. It also forms the basis for the Peano axioms for formalizing arithmetic within mathematical logic. A form of unary notation, called Church encoding, is used to represent numbers within lambda calculus.
- Hodges, Andrew (2009), One to Nine: The Inner Life of Numbers, Anchor Canada, p. 14, ISBN 9780385672665,
The simplest way to write the natural numbers is by the unary notation.
- Davis, Martin; Sigal, Ron; Weyuker, Elaine J. (1994), Computability, Complexity, and Languages: Fundamentals of Theoretical Computer Science, Computer Science and Scientific Computing (2nd ed.), Academic Press, p. 117, ISBN 9780122063824,
the base 1 (or unary) representation of the number x is simply a string of ones of length x.
- Hext, Jan (1990), Programming Structures: Machines and programs, Programming Structures 1, Prentice Hall, p. 33, ISBN 9780724809400.
- Woodruff, Charles E. (1909), "The evolution of modern numerals from ancient tally marks", American Mathematical Monthly 16 (8–9): 125–133, doi:10.2307/2970818, JSTOR 2970818.
- Sazonov, Vladimir Yu. (1995), "On feasible numbers", Logic and computational complexity (Indianapolis, IN, 1994), Lecture Notes in Comput. Sci. 960, Springer, Berlin, pp. 30–51, doi:10.1007/3-540-60178-3_78, ISBN 978-3-540-60178-4, MR 1449655. See in particular p. 48.
- Blaxell, David (1978), "Record linkage by bit pattern matching", in Hogben, David; Fife, Dennis W., Computer Science and Statistics--Tenth Annual Symposium on the Interface, NBS Special Publication 503, U.S. Department of Commerce / National Bureau of Standards, pp. 146–156.
- Hopcroft, John E.; Ullman, Jeffrey D. (1979), Introduction to Automata Theory, Languages, and Computation, Addison Wesley, Example 7.7, pp. 158–159, ISBN 0-201-02988-X.
- Dewdney, A. K. (1989), The New Turing Omnibus: Sixty-Six Excursions in Computer Science, Computer Science Press, p. 209, ISBN 9780805071665.
- Rendell, Paul (2015), "5.3 Larger Example TM: Unary Multiplication", Turing Machine Universality of the Game of Life, Emergence, Complexity and Computation 18, Springer, pp. 83–86, ISBN 9783319198422.
- Feigenbaum, Joan (Fall 2012), CPSC 468/568 HW1 Solution Set (PDF), Computer Science Department, Yale University, retrieved 2014-10-21.
- Moore, Cristopher; Mertens, Stephan (2011), The Nature of Computation, Oxford University Press, p. 29, ISBN 9780199233212.
- Garey, M. R.; Johnson, D. S. (1978), "'Strong' NP-completeness results: Motivation, examples, and implications", Journal of the ACM (New York, NY: ACM) 25 (3): 499–508, doi:10.1145/322077.322090, MR 478747.
- Golomb, S.W. (1966), "Run-length encodings", IEEE Transactions on Information Theory, IT-12 (3): 399–401, doi:10.1109/TIT.1966.1053907.
- Magaud, Nicolas; Bertot, Yves (2002), "Changing data structures in type theory: a study of natural numbers", Types for proofs and programs (Durham, 2000), Lecture Notes in Comput. Sci. 2277, Springer, Berlin, pp. 181–196, doi:10.1007/3-540-45842-5_12, MR 2044538.
- Jansen, Jan Martin (2013), "Programming in the λ-calculus: from Church to Scott and back", The Beauty of Functional Code: Essays Dedicated to Rinus Plasmeijer on the Occasion of His 61st Birthday, Lecture Notes in Computer Science 8106, Springer-Verlag, pp. 168–180, doi:10.1007/978-3-642-40355-2_12.
|Wikimedia Commons has media related to Unary numeral system.|
- "Sloane's A000042 : Unary representation of natural numbers", The On-Line Encyclopedia of Integer Sequences. OEIS Foundation.