You are on page 1of 6

Name Muhammad Asher Haseeb

Roll No BY408016
Course Code 3452
Registration No. 19PCL02707

Assignment No.2
Question No.1
If some automation, FA1, has n1 states and some other automation.
FA2, has n2 states, what is the maximum number of states possible
in the machines the algorithms in this produce for the automata
corresponding to,
• FA1 + FA2
• FA1FA2
• (FA1)
Answer:
The possible states are as follows,

i) n1*n2 ii)
n1+n2 iii)
n1+1

For better understanding, the regular expression machine for


(a+b)*aa(aa+bb) is provided below as an example,
Question No.2
Prove that if L is a regular language, then L’ is also a regular
language. In other words, the set of regular languages is closed
under complementation?

Answer:
We have to prove that class of regular languages is closed under
complementation.

So, Let L be the regular language over the input alphabet set S.
Then complement of L, i.e L' is a set of all strings over S* (any
combination of input alphabet) that are not in L.

That is, Complement of L, L'= S* - L.

Let M be the finite automaton for the language L.

In finite automaton M, we convert all final states to non-final state


and all non-final states to final states we get a new finite
automata M'.

This new finite automaton behaves like follows;

If finite automaton M accepts particular string w, then finite


automaton M' rejects it (as we convert final to non-final and vice
versa), and if M rejects particular string then that string would be
accepted by M'.

Since there exist finite automata M' for the language L', L, is a
regular language.
Hence regular languages are closed under complementation.

I have also attached an image to better show the proof.

Question No. 3
Find a CFG that generate the regular language defined by (aaa +
b) over the alphabet = {a, b}.
Answer:
Consider the regular language (aaa+b) *,

This language gives one or more occurrence of either “aaa” or “b”. The
language does not give null string.

The possible stings generated can be {aaa, aaaaaa, aaab, aaabb, b, bb,
baaa, …..}

So, the corresponding CFG is;


S aaa | b | aaaS | bS

Finally, as per the definition of CFG,

• V: the set of non-terminals in the above grammar is {S}


• T: the set of terminals is the above grammar is {aaa, b}
• P: the production rule is S aaa | b | aaaS| bS

• S: the start symbol is S.


Question No.4
Show that if CFG does not have - production then, there is
another CFG that does have - production and that generates the
same language.
Answer:
As, we know the λ-rules, we can say that; A → λ

“A” can be erased from above. So, whenever it appears on the right side of
a production, we replace it with another production without the A.

For example, consider the grammar


A→λ
B → aAbC | abC
B → bAbA | bbA | bAb | bb

Based on this, let the given CFG. And, if it is not, we use the λ productions
then that generates the same language.

Given CFG is;

S -> AB | ABC
A -> BA | BC | lambda | a
B -> AC | CB | lambda | b C -> BC | AB | A | c

Obtained CFG without using λ;

S -> A | B | C | AB | ABC

A -> BA | BC | B | C | a

B -> AC | CB | C | b

C -> BC | AB | A | c
(i.e., AB both are λ then C need to generate in S. For remaining, they also
need to generate the same result)

Question No.5
Find a PDA (nondeterministic) that accepts all PLAINDROMES
where the alphabet is = {a, b}.
Answer:
A Push-Down Automata that accepts all PALINDROMES where the
alphabet is = {a, b}, is provided below

You might also like