Lecture 1
Review
Math Notation
Here are some common math notations we will be using throughout the semester. Any other notation introduced in lecture outside what is presented here will be explained. Please do not be afraid to ask questions about notation in class.
We let denote the set of all integers and let denote the set of natural numbers (i.e., non-negative integers). The set denotes the set of all positive integers. We let denote the set of all real numbers, with and defined to be the ceiling and floor of , respectively (i.e., round up or round down to the nearest integer). All logarithms are base 2 unless otherwise stated; i.e., . When need, we let denote the natural logarithm.
Sets and Strings
Let be a finite set. We say that is a string with alphabet if it is a finite ordered tuple with elements in . That is, if has length , then (i.e., it is a vector). We let denote the set of all finite length strings with alphabet (i.e., the set of all finite length vectors with elements in ). Given two strings and , we let denote their concatenation; sometimes, we also use or to denote their concatenation as well. Finally, given a string/vector , we let denote the length of the string (i.e., number of elements in ). When needed, we let denote the bit-length of ; that is, the number of bits needed to represent . If , then .
Languages
Much of this course will be concerned with the idea of a language. A language is simply a set . A language can be finite or infinite. While the above definition doesn’t really mean much, we’ll see later in the course how we define languages in more meaningful ways.
Function Notation
Let and be arbitrary sets (not necessarily finite). Then we let denote a function from to .
Big-Oh Notation
Let be two functions. We way that is big-oh of if there exists and constant such that for all , we have . We denote this as or . Similarly, we say that is big-omega of if ; we denote this as . We say that is theta of if and .
We say that is little-oh of if for all constants , there exists such that for all , it holds that . We denote this as . Similarly, is litte-omeaga of if ; equivalently, for all constants , there exists such that for all , it holds that . We denote this as .
Turning Machines
The goal of complexity theory is to quantify and measure computational efficiency. How can we do this? It is first necessary to establish a concrete model of computation. But this seems impossible—surely, there are infinite computational models one can cook up to get the job done, right?
Fortunately, we can focus on a single model of computation: the Turning Machine. For (nearly)1 every physically realizable system we have been able to come up with, the Turing machine can efficiently simulate this other model. This gives us a single model with which we can try to understand and quantify computational efficiency.
Turing Machines, Informally
Turing machines, introduced by Alan Turing in 1948, are an attepmt to formalize the idea of computation as people have understood it for centuries. Intuitively, when someone asks you to compute the answer to a problem, we as people seem to follow a basic formula for realizing this:
- Get the problem, along with the inputs to the problem.
- Get a piece of scratch paper to work on.
- Apply a set of rules to the inputs and make decisions according to those rules.
- Arrive at an answer to the problem, state the answer, and stop working.
As a concrete example, consider the problem of multiplying two integers. Take and and suppose we want to compute their product . There is a simple (so-called “grade-school”) algorithm for computing , which we show in the figure below.

Turing machines attempt to formalize the above intuitive process, but in a very restricted capacity (i.e., Turing machines are incredibly simple and, in a word, stupid).
Turing Machines, Formally
A -tape Turing machine, which we denote by , is a machine with tapes that are infinitely long in one direction (i.e., they are represented by the set ). The machine has a single read-only input tape, a single read-write output tape, and read-write work tapes. also contains a register which tracks the machine’s state. Each head can be moved independently. More formally, a -tape Turing machine is described by a tuple with the following properties:
- is a finite set, which we call the input alphabet;
- is called the tape alphabet, and it contains along with two special symbols that are not in . is the start symbol and is the blank symbol.
- is a finite set of states which can be held in the register. always contains two special states: (the start state) and (the halt state).
- A transition function describing the rules follows during a computation.
We say that a tuple is a configuration of the Turing machine . In this light, the transition function maps configurations of the Turing machine to new configurations as follows:
- represents the current state of the machine stored in its register;
- represents the current symbol under tape ’s head, for ;
- reads the current state and the contents of the tape heads.
It then outputs a new configuration , where
- is the new state stored in the register;
- is a new symbol that is written under the th tape head for (i.e., it excludes the input tape); and
- specifies moving tape head one space Left, one space Right, or telling the tape head to Stay.2
- If the Turing machine is ever in the state , it stops executing the transition function and halts.
Additionally, all Turing machines satisfy the following.
- All tapes are initially set with in every location.
- The first index of every tape is then initialized to . All tape heads begin here.
- On input , all Turing machines will:
- Move the input head , then write to the input tape.
- Move the input head until it reaches .
- Set the initial state in the register to . The Turing machine is now ready to begin its computation.
We call this the initial configuration of the Turing machine.
A graphical example of a -tape Turing machine is presented below.

Turing machine example: Palindromes
Let’s see an example of a Turing machine in action. We will be using Turing machines to compute functions. Let be a function such that if and only if is a palindrome. That is, ; equivalently, if , then for all . Let’s design a Turing machine for computing .
High-level TM Specification. Let be a -tape Turing machine (1 input, 1 output, 1 work tape). On input for any , will do the following.
-
Copy the input to the work tape.
-
Move the input head to the start of the input tape (with under the head), leave the work head at the last position (with under the head).
-
Move the input head one position right (with under the head) and move the work head one position left (with under the head).
-
Read the symbols under the input head and the work head.
(a) If the symbol under the input head is and the symbol under the work head is , then write to the output tape and halt.
(b) Else if the symbols under the input head and work head are not equal, write to the output tape and halt.
(c) Else (i.e., the symbols are equal) move the input head one step right and move the work head one step left.
Formal TM Specification of above. We now formalize thie above process. To do so, we specify (1) the input alphabet; (2) the set of states for ; and (3) the transition function for .
- The input alphabet is simply . This tells us our tape alphabet is .
- The set of states will be .
- The transition function is defined as follows.
Let be a configuration given as input to .
- If , move both the input head and work head right and change the state to .
- If , then read the symbol under the input head (i.e., read ).
- If , write to the current position of the work tape. Then move both the input head and work head one step right. Keep the state as . In this case, the output of the transition function is .
- If , then move the input head left and change the state to . In this case, the output of the transition function is .
- If , read the symbol under the input head (i.e., ).
- If , then move the input head left and keep the state as . In this case, the output of the transition function is .
- If , then move the input head right, move the work head left, and change the state to . In this case, the output of the transition function is .
- If , read what’s under the input and work heads (i.e., and ).
- If and , then write on the output tape and change the state to . In this case, the transition function outputs .
- Else if , then write on the output tape and change the state to . In this case, the transition function outputs .
- Else (i.e., ), then move the input head right and the work head left, keeping the state as . In this case, the transition function outputs .
Turing Machine Equivalences
At first, the Turing machine model seems like a very restrictive model that cannot compute many things, especially real-life computers. However, as we will see, this restrictive computational model is (roughly) equivalent to nearly every other computational model people have thought of over the years. This includes:
- Random access machines;
- Turing machines with write-only output tapes;
- -calculus;
- Single-tape Turing machines;
- Turing machines with bidirectional infinite tapes;
- Pointer and Counter machines;
- Turing machines with only binary input alphabets;
- Oblivious Turing machines.
In the next lecture or two, we will quantify what we mean by Turing machines being equivalent to the above notions.
-
Quantum computers are the one (almost) physically realizable computational model that we have which does not seem to admit efficient simulation on Turing machines. ↩
-
If the Turing machine specifies that a tape head to move left, but it’s at the start of the tape, the head simply stays in the same place. ↩