Welcome to your first lesson in the Theory of Computation. Our goal in this course is to build a rigorous, mathematical understanding of what computation is, what can be computed, and what makes some problems harder than others. To begin this journey, we must first establish a precise vocabulary. This lesson focuses on the foundational concepts of alphabets, strings, and languages. We will move from intuitive ideas to formal, mathematical definitions—a process that will be central to our work throughout this course. These definitions will provide the bedrock upon which we will build and analyze models of computation, starting with finite automata in the lessons to come.
The Bedrock of Computation: Formal Languages
In computer science, when we talk about a "language," we aren't just referring to human languages like English or programming languages like Java. We're using a more abstract and powerful concept: a formal language. At its core, a formal language is a way to precisely define a set of valid sequences, which we call strings. The theory of computation is deeply intertwined with the study of these formal languages, as recognizing whether a string belongs to a particular language is equivalent to solving a computational problem.
To get a feel for these foundational ideas, let's watch a short segment from a video by GATE Applied Course. It will introduce the key terms we'll be defining today.
Alphabets, Strings, Languages & Grammars | TOC Part-3 | GateAppliedroots
This video provides a clear introduction to the hierarchy of concepts we will study: alphabets, strings, and languages.
Please watch the following segments: The introduction, which explains the connection between formal languages and machines (automata). The definition of an alphabet, with several intuitive examples. The definition of a string as a finite sequence. The concept of Sigma star (Σ*), the set of all possible strings. The formal definition of a language as a subset of Σ*.
As the video explained, these definitions build on one another. Let's formalize each one.
1. Alphabets: The Symbols of Discourse
The most basic component of any language is its set of symbols. In formal language theory, this is called an alphabet.
Definition: Alphabet
An alphabet is a non-empty, finite set of symbols. We typically denote an alphabet using the Greek letter sigma, .
Here are some common examples:
- The binary alphabet:
- The lowercase English alphabet:
- The alphabet of decimal digits:
The key constraints are that the set must be finite and non-empty. The image below, from a Princeton CS course, illustrates various alphabets and the corresponding names for their symbols and strings.

2. Strings: Sequences of Symbols
Once we have an alphabet, we can form strings by creating sequences of its symbols.
Definition: String
A string over an alphabet is a finite sequence of symbols drawn from .
For example, if , then a, baba, and bbbaaa are all strings over .
Given your mathematical background, you'll appreciate a more rigorous definition that avoids the ambiguity of the word "sequence." We can define a string as a function.
Chapter 1 Basics of Formal Language Theory
This excerpt from a textbook by Jean Gallier provides a precise, function-based definition of a string. This level of rigor is what separates a formal treatment from an intuitive one.
In Definition 1.2.2, please read the section from this paragraph. Pay close attention to how a string u of length n is defined as a function u: [n] \to \Sigma, where [n] = \{1, 2, \dots, n\}.
This functional definition is elegant because it formalizes what we mean by a symbol being at a certain "position" in the string. Let's solidify a few related concepts:
- Length of a String: The length of a string , denoted , is the number of symbols in it. If is defined as a function , its length is simply . For example, .
- The Empty String: There is one special string, the empty string, which has a length of 0. It is denoted by (epsilon) or sometimes (lambda). It is the unique string containing no symbols. In the functional definition, it corresponds to the function from the empty set: .
- The Set of All Strings (Kleene Star): For a given alphabet , the set of all possible strings (of any finite length) that can be formed from it is denoted by . This is a foundational concept known as the Kleene star or Kleene closure of the alphabet. For example, if , then . Note that is always an infinite set (unless is the empty set, which we typically don't allow for alphabets).
3. Languages: Sets of Strings
Now we arrive at the final and most important definition. With our universe of all possible strings, , we can define precisely what a language is.
Definition: Language
A language over an alphabet is any subset of . In other words, .
This definition is both simple and incredibly powerful. A language is just a set of strings. This set can be finite, infinite, or even empty. The "rules" of a language (like grammar in English) are simply the criteria that determine which strings from are included in the set .
This image shows several examples of languages over the binary alphabet .

Let's look at the second example, "equal numbers of as and bs". Using set-builder notation, we can formally write this language as:
Strings like ba, bbaaba, and ϵ are in this language, while a and abbaa are not.
A Point of Clarification: Nothing, Emptiness, and a Language of Emptiness
It is crucial to distinguish between three related concepts that often cause confusion.
- The empty string, , is a string of length zero. It is a single, concrete object.
- The empty set, , is a set containing zero elements. When we talk about languages, this corresponds to the empty language , which is a language with no strings in it.
- The language containing only the empty string is the set . This is a non-empty language; it has one member, which happens to be the empty string.
Let's watch a brief clip where this distinction is explained clearly.
1. Introduction, Finite Automata, Regular Expressions
Professor Michael Sipser, the author of a standard textbook on this subject, provides a crisp explanation of these terms.
Watch the segment from two special strings where he contrasts the empty string with the empty language.
Why Formalize Languages? The Link to Computation
You might be wondering why we've spent this time on what seem like simple definitions. The power of this framework lies in its ability to rephrase any computational decision problem as a language membership problem.
A decision problem is any problem that has a yes/no answer. For example: "Is the number n a prime number?"
We can encode the input to such a problem as a string. Then, the language associated with the problem is the set of all input strings for which the answer is "yes."
Lecture 2: Strings, Languages, DFAs
This section of the lecture notes from the University of Illinois Urbana-Champaign gives a great example connecting languages to a real computational task: primality testing.
Please read the subsection Why should we care about languages? The example of L_primes perfectly illustrates how a computational task is equivalent to deciding membership in a language.
As the notes explain, if we can build a machine (an automaton) that, for any given string , can correctly answer whether , then we have effectively solved the computational problem that represents. This is the central theme of this course. We will study different types of machines and discover which classes of languages they are capable of "recognizing" or "deciding."
Conclusion
In this introductory lesson, we have laid the formal groundwork for our study of computation. We established a precise hierarchy of concepts:
- An alphabet is a finite set of symbols.
- A string is a finite sequence of symbols from an alphabet. The set of all possible strings is .
- A language is any subset of .
The key takeaway is that computational problems can be reframed as questions of whether a string belongs to a particular language. This abstraction allows us to apply the rigorous tools of mathematics to analyze the fundamental nature of computation itself.
In our next lesson, we will continue building our toolkit by exploring the fundamental operations used to construct new strings and languages from existing ones, such as concatenation, union, and the Kleene star operation. These operations will be essential for defining and understanding regular languages, our first major topic.