Lecture 1
Lecture 1
B term 2024
Lecture 1 Notes
Reading assignment: Chapters 1, 2
1 Course description
Welcome to Foundations of Computer Science.
Text: There is one required text book for this course, Languages and
machines, 3rd Edition by Thomas A. Sudkamp. The instructor may supply
additional materials to supplement the text.
Goals of the course: The course introduces the theoretical foundations
of computer science. These form the basis for a more complete understanding
of the proficiency in computer science. Topics include computational mod-
els, formal languages, parsing, and an introduction to computability and
complexity theory, including NP-completeness.
Expected background: Discrete structures (CS 2022) and algorithms
(CS 2223).
2 Formal Languages
The alphabet Σ is the set of symbols (a, b, c, . . .) that make up the strings in
our language. Σ∗ is the set of all possible strings using Σ. A formal language
is a subset L ⊆ Σ∗ . The empty string, denoted by λ, contains no symbols,
and is an element of Σ∗ .
Next we give a recursive definition of Σ∗ .
Basis: λ ∈ Σ∗ .
Closure Step: w ∈ Σ∗ if and only if we can get it from the basis by applying
the recursive step a finite number of times.
1
For many of our examples, for simplicity, we will use the alphabet Σ =
{a, b}. This alphabet can be used to make 2k unique strings of length k. For
example, the 4 strings of length 2 are aa, ab, ba, and bb. The set Σ∗ contains
infinitely many strings.
Now that we have strings, we can define operations on strings. We will
define three operations on strings: concatenation, substring, and reversal.
Concatenation of two strings u and v will produce the string uv. For
example, if u = abbbaa, and if v = bbb, then uv = abbbaabbb. We say that v
is a substring of u if there exist strings x and y such that u = xvy. With the
previous definitions of u and v, we would get x = a and y = aaa. If x = λ,
we say that v is a prefix, and we say that it is a suffix if y = λ. The reversal
of a string is formed by reversing the order of the symbols in the string. For
example, uR = aabbba, and v R = v. This lets us define a special language,
the palindrome language.
Palindrome Language = {w ∈ Σ∗ |wR = w}.
We next want ways to describe languages. The first way is using set
notation, as we used above for the Palindrome Language. The second way
is to enumerate every string in the language, but this doesn’t work for infi-
nite languages. The last way is to use operations on languages we already
know. The operations we will use on languages are concatenation, powers,
and closure.
If we have two languages L1 , L2 ∈ Σ∗ , the concatenation is defined as
L1 L2 = {uv ∈ Σ∗ |u ∈ L1 , v ∈ L2 }.
When we raise languages to powers, it is equivalent to concatenating a
language with itself multiple times, for example L4 = LLLL. Note that
L0 = {λ}, and has size 1. The star closure of a language, or the Kleene-star
closure, is the union of all the powers of a language:
∞
L∗ = Ln .
[
n=0
Similarly, the plus closure, or positive closure, is the same thing, but starting
at 1 rather than at 0: ∞
L+ = Ln .
[
n=1
When a language contains λ, the star closure and positive closure are
equal. Also, notice that (L∗ )∗ = L∗ . Now we look at some examples.
2
2.1 Examples
{a}∗ = {λ, a, aa, aaa, . . .} is the language of all the strings of a’s.
{a, b}∗ bb{a, b}∗ is the language of all the strings containing bb as a substring.
{bb}∗ is the language of all the strings that are an even number of b’s.
Closure Step: A set X is regular if and only if we can get it from the basis
by applying the recursive step a finite number of times.
Regular expressions are the same thing, but we use a shorthand. The
following is a regular set:
∗
(({a}{b})∗ ∪ {b}{b})
3.1 Example
a∗ b(a ∪ b)∗ = (a ∪ b)∗ ba∗
Both of these regular expressions represent the strings which contain at least
one b. Though these regular expressions look very different, they represent
the same set, so they are equivalent. When two regular expressions are equiv-
alent, the equation is called a regular expression identity. Some more regular
expression identities are listed below, followed by a (perhaps surprising) neg-
ative example. More examples are in the textbook.
1. (u∗ )∗ = u∗
3
2. u(v ∪ w) = uv ∪ uw (This is sometimes called the distributive identity.)
3. (ab)∗ ̸= a∗ b∗
To show that two regular expressions are not equivalent, we must find
a string in one, but not in the other. It’s harder to show that they are
equivalent, and we’ll cover this later in the course. To show that the third
item is not an identity, notice that abab ∈ (ab)∗ , but abab ̸∈ a∗ b∗ .
While it would be nice if we could express every language as a regular
language, it is unfortunately impossible to do so. An example is the palin-
drome language, which we will prove later. While it can be harder to think
of non-regular languages than regular languages, in some sense we have more
non-regular languages.