You are on page 1of 4

2AC3

Hakim Temacini
February 2023

Q1
We are asked to check whether the following languages are regular or not
Qn
• {an! | n ≥ 1} where n! = i=1 i
Using the pumping lemma we prove that the set is not regular Given
k ≥ 0 we may choose string xyz = a(k+1)! , where x = a(k+1)!−k , y = ak
and z = ϵ. For any choice of u, v, w such that uvw = y and v ̸= ϵ
we must have u = al , v = ap , w = am where 0 < p ≤ k. Then by
construction xuvwz = a(k+1)! is in the set, but xuv 2 wz = a(k+1)!+p , where
(k + 1)! + p > (k + 1)! since p > 0 and (k + 1)! + p < (k + 2)! since
p < k + 1 < (k + 1)!(k + 1). Therefore we cannot have xuv 2 w in the set,
and therefore the set fails the criterion of the pumping lemma proving
irregularity.
• {x ∈ {a, b}∗ | x =rev(x)}
Using the pumping lemma, we may pump a section of string which makes
it not a palindrome anymore. Therefore this set is also not regular.

• {ak bp cl | k, p, l > 0 and k + p + l is even }


This set is regular. Intuitively, any DFA only needs to keep track of the
parity of k, p and l. We can even construct a regular expression for the
set to prove its regularity.
Consider
aa(aa)∗ bb(bb)∗ cc(cc)∗ +a(aa)∗ b(bb)∗ cc(cc)∗ +aa(aa)∗ b(bb)∗ c(cc)∗ +a(aa)∗ bb(bb)∗ c(cc)∗
• {x ∈ {a, b}∗ | #a(x) = #b(x)}
This set is not regular. Notice we may consider ak bk and pump the a’s so
that it is no longer in the set, failing the pumping lemma

• {x ∈ {a, b}∗ | #a(x) + #b(x) = 10}


There are only a finite amount of strings in this set, therefore trivially
regular.

1
• {x ∈ {a, b}∗ | x contains the substring abb}
The regular expression (a + b)∗ abb(a + b)∗ completely describes the set
only. Therefore the set is regular

Q2
We minimize the DFA by using the minimzation procedure. Namely we first
start with a list of all our states, q0 , q1 , q2 , q3 , q4 , and mark all the states that
are not similar.

Trivially, our table first starts as below, because we mark all the states
that are final as not being similar to the ones that are not.

0
X 1
X 2
X X 3
X X 4
We then mark all the pairs of states that transition to states that are not
similar.

Cycle: 1 • δ(q3 , b) = q0 ∈ F but δ(q4 , b) = q4 ̸∈ F


• δ(q3 , b) = q0 ∈ F but δ(q1 , b) = q4 ̸∈ F
• δ(q1 , a) = q2 ∈ F but δ(q4 , a) = q4 ̸∈ F
0
X 1
X 2
X X X 3
X X X X 4

Cycle: 2 • δ(q0 , a) = q1 = δ(q2 , a)


• δ(q0 , b) = q3 = δ(q2 , b)
0
X 1
X 2
X X X 3
X X X X 4
Our process hasn’t produced any changes, therefore we can terminate and
conclude that q0 ∼ q2 is the only state minimization.
The new DFA becomes

2
start q0

a b
a b

q1 q3

b a

q2

a, b

Q3
We design a context-free grammar for the language
A = {an cm dm bn | m, n ≥ 1}.

Consider the grammar


S → aP b
P → aP b | cQd
Q → cQd | ϵ

Then clearly, we can arrive at any element of the set.

3
Q4
We design a grammar in Chomsky Normal Form for L(G) − {ϵ},
where G is the grammar defined as
S → aSbb | A
A → bAbb | S | ϵ

We first add productions, so that the new grammar Ĝ becomes


S → aSbb | A | bAbb | S | ϵ | bbb | abb
A → bAbb | S | ϵ | aSbb | A | bbb | abb

We then remove all the redundant ϵ- and unit productions.


S → aSbb | bAbb | bbb | abb
A → bAbb | aSbb | bbb | abb

Since all the productions of S are the same as A we can safely combine these
two productions
S → aSbb | bSbb | bbb | abb

For each terminal symbol, we create new nonterminals and replace the pro-
ductions accordingly.
S → ASBB | BSBB | BBB | ABB
A→a
B→b

We then create new nonterminals and update the rules so we can adhere to
CNF. The final answer is then
S → AC | BC | BD | AD
C → SD
D → BB
A→a
B→b

You might also like