0% found this document useful (0 votes)
28 views5 pages

Computation Theory Lecture 2

Uploaded by

niheyang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

Computation Theory Lecture 2

Uploaded by

niheyang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Computation Theory

Felicity Ni
July 2024

§1 Recap
What is a DFA? NFA? Regular language?

Theorem 1.1
Every NFA has an equivalent DFA.

The differences between NFA and DFA is the codomain of the transition map and the ε
transitions. Therefore, we come up with this power set construction, where each state in
the DFA corresponds to a subset of states in the NFA.

Proof. Let the NFA N = (Q, Σ, δ, q0 , F ). We first assume there are no ε transitions. We
take M = (Q′ , Σ, δ ′ , q0′ , F ′ ), where

1. Q′ = P (Q),

2. The transition from a state in the DFA which corresponds to a subset R of states in
the NFA on a character a is the set of all states reachable from a from any state in
the subset R, which can be empty. δ ′ (R, a) = {q ∈ Q | q ∈ δ(r, a) for some r ∈ R},

3. q0′ = {q0 }, and

4. F ′ = {R | R ∩ F ̸= ∅}. The subset R of states corresponds to an accept state in


the DFA, if there exists an accept state in R in the original NFA.

Let E(R) be the set of states that can be reached from members of R using only ε
transitions. We can modify this DFA by replacing δ(r, a) by E(δ(r, a)) and replacing q0′
by E({q0 }).

With that, a language is regular if and only if it’s recognized by some NFA. Now
we have a much simpler way to prove regular languages are closed under union and
concatenation using the guess and check mechanism. Regular languages are closed under
intersection by De Morgan’s Law.

I claim that regular languages are closed under Kleene star because it’s closed under
concatenation, and Kleene star is just concatenating itself many times. Why is my
reasoning wrong? Things may be different when it comes to infinity. 0.9 < 1, 0.99 < 1,

1
Felicity Ni — July 2024 Computation Theory

but 0.99 · · · = 1. Yet, we can use a similar method to construct an NFA with L′ = L∗ .
Why doesn’t the first one work? It doesn’t accept empty strings. What if we change the
original start state to accepting? It still doesn’t work because some strings might end in
the original start state.

Is there a closed formula that defines all regular languages? To classify regular
languages, we need another powerful tool: regular expression.

§2 Regular Expression
To construct a new regular language, we can start from building a DFA or an NFA,
or start from other regular languages and apply these regular operations with closure
properties. At first, you invite a few friends to an intimate gathering, but then they invite
their friends and it eventually ends up as everyone on earth coming to your party. Like
every vector space has a basis, we use the similar idea to construct all regular languages.
What do we start with?

• ∅ is regular

• {ε} is regular

• {a} is regular for any character a

In shorthand, we denote {ε} and {a} as ε and a in regular expressions.


Just like expressions in arithmetic, in regular expressions, we use regular operations ∪, ◦
and ∗ . For example, (0 ∪ 1) ◦ (0∗ ) represents the language {0, 00, 000, . . . , 1, 10, 100 . . . }.
For convenience, we often omit the circle for concatenation.
Definition 2.1 (Regular Expression). R is a regular expression (regex) if R is

1. ∅,

2. ε,

3. a ∈ Σ where Σ is the alphabet,

4. (R1 ∪ R2 ) where R1 and R2 are regular expressions,

5. (R1 ◦ R2 ) where R1 and R2 are regular expressions, or

6. (R1∗ ) where R1 is a regular expression.

Specifically, ∅ is the identity for union, and ε is the identity for concatenation.
Problem 2.2. Find a regex for L1 = Σ∗ .
This is why we denote the set of all strings composed of characters in Σ as Σ∗ .
Problem 2.3. Find a regex for L2 = {w ∈ {0, 1}∗ | w has an even number of 1s}.
Every two 1s can be paired up with an arbitrary number of 0s between them, so its
regex is ((0) ∪ (10∗ 1))∗ .

2
Felicity Ni — July 2024 Computation Theory

Problem 2.4. Find a regex for L3 = {w ∈ {0, 1}∗ | w has an prime number of 1s}.
Apparently such expression doesn’t exist, or we will have a closed form of all primes.
Any conjectures?

Claim 2.5 — A language is regular if and only if it is described by some regular


expression.

Proof. For the forward direction, we use WOP.


Let S = {n | exists a regex with n regular operations not representable by an NFA}.
By definition, a regex R with n regular operations is one or two regexs of n − 1 regular
operations under a new regular operation. Since regular languages are closed under
regular operations, the language described by R is also regular, and S = ∅.
Given all regular expressions describe some regular language, we can generalize an
NFA by putting regular expressions on the transition arrows.
Can we express the languages of these two generalized NFAs in regex?

We aim to convert every NFA into the above form. First, we want a unique accept
state, and we want only one transition coming out of the start state.

How do we eliminate q3 ?

The corresponding regex to this NFA is R1∗ R2 (R3 ∪(R4 R5 ))∗ . We can apply this process
known as Thompson’s Algorithm to all NFAs.

§3 More Nonregular Languages


Last time, we intuitively saw that a set of strings with a prime number of 1s was not a
regular language because DFAs have limited memory.
Problem 3.1. Construct a DFA with L4 = {0n 1n | n ≥ 0}.
We can construct DFA that accepts ε, 01, 0011, . . . , but it seems to be infinite.

Claim 3.2 — L4 = {0n 1n | n ≥ 0} is not regular.

Proof. Suppose DFA M accepts L and has m states. Then consider ε, 0, 00, . . . , 0m . By
Pigeonhole’s Principle, two of them 0i and 0j must end up in the same state for some
i ̸= j, which means the DFA must accept both or neither 0i 1i and 0j 1i , leading to a
contradiction.

3
Felicity Ni — July 2024 Computation Theory

What other languages are nonregular? Intuitively, a language is not regular if it requires
infinite memory. What do we mean by memory?
Definition 3.3 (indistinguishable). Strings x, y ∈ Σ∗ are distinguishable by language
L, denoted as x ̸≡L y, if exists z ∈ L such that exactly one of the strings xz and yz
is in L. If ∀z ∈ L, xz and yz are either both in L or not in L, strings x and y are
indistinguishable by L, denoted by x ≡L y, also known as Nerode congruence.
If x and y are distinguishable by L, and L is the language of DFA M, then x and y must
end up in different states in M. Therefore, we reach this following theorem.

Theorem 3.4 (Myhill-Nerode)


A language L is regular if and only if ≡L has finitely many equivalence classes.

Proof. The forward direction is true since a DFA with k states can recognize at most k
equivalence classes. If x ≡L y, then xa ≡L ya. Therefore, for the backward direction, let
each equivalence class [x] correspond to a state, the transitions be a : [x] → [xa] for each
a ∈ Σ, and the starting state be [ε].
2
Problem 3.5. Show that L = {w = 1n } is not regular.
What have we done so far? We have three equivalent ways to describe a regular language,
and how are they related? Regular languages corresponds to problems solvable with
finite-memory computers, and what about computers with infinite memory?

§4 Turing Machines
We want to build a computer still with finitely many states since we program them and
write commands, but infinite memory. In this case, even if you’re in the same state, your
previous life matter, which we use an infinite tape to record the information.
Consider this Turing machine. What do the arrows mean?

A Turing machine consists of a finite state control, an infinite tape, and a tape
head which points to the current symbol it reads. Each transition is in the form (r, w, d)
and means if the current symbol is r, replace it with w and move the tape head in
direction d where d ∈ {L, R}. Unlike a DFA or NFA which stops after reading the entire
string, a TM immediately stops if its finite state control reaches an accept or reject state.
Sometimes, it can loop forever and never stop.
The TM begins with a infinite tape that consists of the blank symbol □ with the
input string written somewhere. It has two alphabets:

• An input alphabet Σ where □ ̸∈ Σ.

• A tape alphabet Γ ⊋ Σ.

4
Felicity Ni — July 2024 Computation Theory

A string is accepted if the Turing machine ends up in accept state under that input.
Definition 4.1 (Turing-recognizable). A language is Turing-recognizable if some
Turing machine M recognizes it.
As shown above, all regular languages are recognized by some Turing machine, since
we can replace the arrows of DFA with reading the current symbol, replacing it with
itself, and always moving right.
Problem 4.2. Construct a Turing machine for L4 = {0n 1n | n ≥ 0}.
w ∈ L4 iff 0w1 ∈ L4 . Therefore, we can erase the string’s start and end every time
and process recursively.

You might also like