LogoLogo
1.0.0
  • Home
  • Install
  • Docs
  • Contribute
  • Journey
  • Welcome
  • The Varphi Language Standard
    • Welcome
    • State Names
    • Tallies and Blanks
    • Head Directions
    • Lines
    • Comments
    • Varphi Programs
    • Addressing Ambiguities
  • Writing Varphi Programs
    • Your First Varphi Program
    • Running Varphi Programs
    • Debugging Varphi Programs
    • The Varphi VS Code Extension
    • Good Practices
    • More Examples
      • Addition By One
      • Add Two Numbers
      • Multiplication By Two
      • Rock, Paper, Scissors
      • Coin Flip
  • Turing Machine Theory
    • The Unary Number System
    • Turing Machine Tapes
    • Turing Machine Heads
    • Turing Machine States
    • Turing Machines
    • Nondeterministic Turing Machines
Powered by GitBook
LogoLogo

© 2025 Hassan El-Sheikha

On this page
  • What are Number Systems?
  • The Unary Number System
  • Representation Conventions

Was this helpful?

Edit on GitHub
Export as PDF
  1. Turing Machine Theory

The Unary Number System

What are Number Systems?

From Wikipedia:

A numeral system is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner.

There are infinitely many number systems. The most commonly used of these is the decimal (base 10) number system, which uses the symbols 0,1,...,90, 1, ..., 90,1,...,9 to represent numbers. Our modern-day computers use the binary (base 2) number system, which uses the symbols 000 and 111 to represent numbers. For example, the binary representation of the decimal number 252525 is 110011100111001.

The Unary Number System

By definition, the simplest number system is the one which uses the least number of symbols. This number system is called the unary number system, and it uses one symbol to represent numbers, which we call a tally.

We will often use the symbol 111 to denote a tally in this text.

You use this number system more than you know! Imagine trying to represent the decimal number 777 on your fingers. You would put up seven fingers (probably, unless your brain operates in binary), which is like writing seven tallies on a paper!

Although the unary number system is extremely simple, it is not any less (or more) powerful than any other number system.

Representation Conventions

The example above about representing numbers on your fingers shows how to use the unary number system to represent positive numbers. This does not mean that the unary number can only represent positive numbers, however.

In the above example, the following representation convention was used

To represent a number n∈Z+n\in\mathbb{Z}^+n∈Z+, repeat the symbol 111 nnn times.

Suppose now that we wanted to represent the set of nonnegative integers (to be able to represent zero as well) using the unary number system. We could define the following representation convention:

To represent a number n∈Nn\in\mathbb{N}n∈N, repeat the symbol 111 n+1n + 1n+1 times.

Above, we used N\mathbb{N}N to represent the set of nonnegative integers (i.e., {x:x∈Z∧x≥0}\{x: x\in\mathbb{Z}\wedge x\geq 0\}{x:x∈Z∧x≥0}.

Under this representation convention, we can represent the number decimal number 000 with 111, the decimal number 111 with 111111, and so on...

You can theoretically come up with any convention you like to represent a set of numbers using unary. Here's a rather crazy one:

To represent a number n∈Z+n\in\mathbb{Z}^+n∈Z+, repeat the symbol 111 n2+5n^2 + 5n2+5 times.

Try to represent the decimal number 333 in unary using this convention.

The whole point of this is to show that providing a unary representation of a number to someone is not enough for them to know which number is being represented. You must also give them the convention you used to come up with that representation. The number that the unary representation 111111111111111111 represents varies greatly between the three input conventions shown above (it represents six, five, and one respectively).

PreviousCoin FlipNextTuring Machine Tapes

Last updated 4 months ago

Was this helpful?