Formal Languages and Automation Assignment
Formal Languages and Automation Assignment
5) Design an nfa with no more than five states for the set {ababn: n >0}∪{aban: n ≥ 0}.
answer
An nfa for the set is given by the following transition graph:
6) Convert the following nfa to into an equivalent dfa
δ ∗ (q, 0) 0 1
q0 {q0, q1, q2} {q1, q2}
q1 {q0, q1, q2} {q1, q2}
q2 {q2} {q1}
{q0} ∈ F since λ ∈ L(M); {q1, q2}, {q0, q1, q2} ∈ F since q1 is a final state in M. Thus, the
result dfa is shown as follows.
10) Give regular expressions for the following language on Σ = {a, b, c}. All strings containing exactly
one a.
Solution
(b + c) a(b + c)
Find grammars for∑¿{a , b }that generates the sets of:a.All strings with exactly one a
S →bS∨Sb∨bSb∨ab
.All strings with at least one a S →aS∨Sa∨bS∨Sb∨aSb∨bSa∨ac.
All strings with no more than three a’sS →aAb∨aA∨Aa∨bS∨Sb∨bAa∨a∨b∨λA
→aBb∨bBa∨bA∨Ab∨aB∨Ba∨a∨b∨λB → a ∨b∨λ
16. Find a grammar that generates the language+¿}L={w wR:w ϵ{a , b }¿and give acomplete
justification for your answer.This language is comprised of the repetition of a string in {a, b}+2 or
more times.S→aS | bS | aQ | bQQ→QQ | QTT→TT | TλS will produce a string from {a, b}+,
and will pass that on to T, which will repeat that string