JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

From Strings to Languages

A single string is just one finite line of symbols. Gather strings into a set and you get a language — the one object this whole subject is secretly about, and the bridge from 'problem' to 'machine'.

From one string to all of them: Sigma-star

In the last guide you nailed down a single string: a finite, ordered run of symbols drawn from an alphabet Sigma (the Greek letter sigma, our fixed bag of allowed symbols). You met string length, the empty string epsilon (the unique string of length zero), and concatenation (gluing two strings end to end). Now we take one deceptively small step that reorganizes the whole subject: instead of looking at one string at a time, we look at collections of strings.

First, give a name to the biggest collection of all. Write Sigma-star (often Σ*, with that little star called the Kleene star) for the set of every finite string you can build over Sigma — including epsilon. If Sigma = {a, b}, then Sigma-star starts epsilon, a, b, aa, ab, ba, bb, aaa, ... and never stops. Note two honest facts: every single string in Sigma-star is finite, yet the set Sigma-star itself is infinite (as long as Sigma has at least one symbol). There is no longest string, the way there is no biggest whole number.

A language is just a set of strings

Here is the definition the rest of the ladder rests on, and it is shockingly plain. A (formal) language L over Sigma is any subset of Sigma-star. That is the whole thing: a language is a set whose members happen to be strings. It can be finite (like {a, ab, abc}), infinite (like 'all strings of even length'), or even empty. There is no grammar, no meaning, no machine yet — just a chosen collection of strings, picked out of the giant pool Sigma-star.

Because a language is a set, we describe it the way we describe any set. We can list it when it is small, or use set-builder notation when it is not. For example, over Sigma = {a, b}, the language 'strings with an even number of a-s' is { w in Sigma-star : the count of a in w is even }. That single description quietly contains epsilon (zero a-s is even), b, bb, aa, aba, baab, and infinitely many more. Spotting which strings belong and which do not is the skill you will sharpen for the rest of this ladder.

The empty language is not the empty-string language

Now a distinction that trips up almost everyone the first time, and is worth slowing down for: the empty language versus the language containing only the empty string. The empty language, written {} or the set-symbol for emptiness, has NO members at all — zero strings. The epsilon-language {epsilon} has exactly ONE member, namely the empty string. They look almost identical on paper, but one is an empty box and the other is a box holding a single, length-zero slip of paper.

The difference is not pedantic — it changes answers. The empty language has size 0; the epsilon-language has size 1. Ask 'does this language accept the empty input?' and the empty language says no while {epsilon} says yes. When machines arrive, the empty language is what a DFA with no accept states recognizes, while {epsilon} is recognized by a machine that accepts only before reading anything. Same shape on the page, opposite behavior.

Building new languages from old ones

Since languages are sets, all the usual set operations apply unchanged: union (L1 union L2 = strings in either), intersection (in both), and complement (the strings in Sigma-star that are NOT in L). But languages also inherit string-flavored operations that ordinary sets lack. The most important is language concatenation: L1 . L2 is the set of every string you can form by taking one string from L1 and gluing one string from L2 onto its end. For example, {a, ab} . {c, d} = {ac, ad, abc, abd}.

The crown jewel is the Kleene star applied to a language, written L*. It means: concatenate zero or more strings drawn from L, in any combination, with repetition allowed. Crucially, 'zero strings' is legal, so epsilon is always in L* (even when L itself does not contain epsilon). If L = {ab}, then L* = {epsilon, ab, abab, ababab, ...}. The next guide in this rung is devoted to L* and these operations in full; here just feel the shape of it. Notice Sigma-star is exactly this construction with L = Sigma: stars over the alphabet itself.

Sigma = {a, b}

L1 = { a, ab }          L2 = { c, d }
L1 union L2  = { a, ab, c, d }
L1 . L2      = { ac, ad, abc, abd }

L = { ab }
L*  = { epsilon, ab, abab, ababab, ... }   (zero or more copies; note epsilon)
L+  = { ab, abab, ababab, ... }             (one or more copies; no epsilon)
A few operations side by side. Star always includes epsilon (zero copies); plus never does.

Why this matters: a problem IS a language

Here is the move that justifies the whole apparatus, and it answers the 'why study computation abstractly?' question from guide 1 of this rung. Almost any yes/no computational question can be encoded as a language. Pick a sensible string encoding for the inputs; then collect into a language L exactly those encoded inputs whose answer is YES. Asking 'is the answer yes for input w?' becomes the membership question: is the string w a member of L? Computing the answer is exactly the decision problem for L.

A concrete example: 'is this number prime?' becomes the language PRIMES = { w : w is the binary encoding of a prime number }. Then a machine that decides primality is exactly a machine that decides membership in PRIMES. This reframing is the master trick of the field: it turns wildly different questions — sorting, graph connectivity, theorem-checking — into the single uniform shape 'is w in L?'. Once every problem is a language, we can ask which machine, if any, can recognize it.

And that question has a famous map. Languages sort, by how complicated a machine you need to recognize them, into the Chomsky hierarchy: the regular languages (recognized by finite automata, the next rung's topic), inside the context-free languages (recognized by a pushdown automaton — a finite machine plus a stack), inside the recursively-enumerable languages (recognized by a Turing machine, the most powerful model). Each layer sits strictly inside the next. One honest caution before you climb: 'regular' does NOT mean 'finite' — the infinite language Sigma-star is itself regular. The whole rest of this ladder is, in a sense, just exploring this map one layer at a time.