ArticleslgStudy

computer science

Unary language

Unary language is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Unary language rather than just read about it. In short: In computational complexity theory, a unary language or tally language is a formal language (a set of strings) where all strings have the form 1k, where "1" can be any fixed symbol. For example, the language {1, 111, 1111} is unary, as is the language {1k | k is prime}.

Key takeaways

  • Unary language belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Unary language to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Unary language from memory before moving on to harder problems.

Reference excerpt

In computational complexity theory, a unary language or tally language is a formal language (a set of strings) where all strings have the form 1k, where "1" can be any fixed symbol. For example, the language {1, 111, 1111} is unary, as is the language {1k | k is prime}. The complexity class of all such languages is sometimes called TALLY. The name "unary" comes from the fact that a unary language is the encoding of a set of natural numbers in the unary numeral system. Since the universe of strings over any finite alphabet is a countable set, every language can be mapped to a unique set A of natural numbers; thus, every language has a unary version {1k | k in A}. Conversely, every unary language has a more compact binary version, the set of binary encodings of natural numbers k such that 1k is in the language. Since complexity is usually measured in terms of the length of the input string, the unary version of a language can be "easier" than the original language. For example, if a language can be recognized in O(2n) time, its unary version can be recognized in O(n) time, because n has become exponentially larger. More generally, if a language can be recognized in O(f(n)) time and O(g(n)) space, its unary version can be recognized in O(n + f(log n)) time and O(g(log n)) space (we require O(n) time just to read the input string). However, if membership in a language is undecidable, then membership in its unary version is also undecidable.

Relationships to other complexity classes TALLY is contained in P/poly—the class of languages that can be recognized in polynomial time given an advice function that depends only on the input length. In this case, the required advice function is very simple—it returns a single bit for each input length k specifying whether 1k is in the language or not. A unary language is necessarily a sparse language, since for each n it contains at most one value of length n and at most n values of length at most n, but not all sparse languages are unary; thus TALLY is contained in SPARSE. It is believed that there are no NP-hard unary languages. Berman's theorem (1978) states that if a unary language that is NP-hard, then P = NP. This may be proven by considering a polynomial time algorithm for 3-SAT. This result can be extended to sparse languages. If L is a unary language, then L* (the Kleene star of L) is a regular language.

Tally classes The complexity class P1 is the class of the unary languages that can be recognized by a polynomial time Turing machine (given its input written in unary); it is the analogue of the class P. The analogue of NP in the unary setting is NP1. A counting class #P1, the analogue of #P, is also known.

References

Notes

General references Lance Fortnow. Favorite Theorems: Small Sets. April 18, 2006. http://weblog.fortnow.com/2006/04/favorite-theorems-small-sets.html Complexity Zoo: TALLY

Worked examples

Example 1 — a first encounter with Unary language

Start with the simplest possible case. Write down what Unary language claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Unary language before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Unary language ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Unary language

In research
Unary language appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Unary language in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Unary language is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computational complexity theory, Formal languages, so understanding it makes those chapters shorter.
In everyday life
Look for Unary language outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Unary language” →

How to study Unary language in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Unary language means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Unary language out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Unary language in simple terms?

In computational complexity theory, a unary language or tally language is a formal language (a set of strings) where all strings have the form 1k, where "1" can be any fixed symbol. For example, the language {1, 111, 1111} is unary, as is the language {1k | k is prime}.

Why does Unary language matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Unary language?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Unary language.

Tags

  • Computational complexity theory
  • Formal languages

Keep exploring