1. NFA, DFA, and RegExp In all of the subtasks below Σ = {a, b}. Figures showing the DFAs and NFAs on the last pages. (a) Make a DFA for the language accepted by the NFA in the file 1a.nfa (b) Make a...

1 answer below »
questions about automata and formal languages


1. NFA, DFA, and RegExp In all of the subtasks below Σ = {a, b}. Figures showing the DFAs and NFAs on the last pages. (a) Make a DFA for the language accepted by the NFA in the file 1a.nfa (b) Make a DFA for the language accepted by the NFA in the file 1b.nfa (c) Make a regular expression for the language accepted by the DFA in the file 1c.dfa (d) Make a regular expression for the language accepted by the DFA in the file 1d.dfa 2. Grammars (Solve in Mentor) (a) Make a CFG for the language {apbqar : q = p+ r, p and p, r ≥ 0} (b) Make a CFG for the language accepted by the DFA in the file 2b.dfa (it is the same one as 1c.dfa!) (c) Consider the grammar G with variables {S, T,A,B}, terminals {a, b} starting symbol S and productions ˆ S → ABS | AS ˆ BA→ AB ˆ BS → Sb ˆ AS → Ta ˆ AT → Ta ˆ T → λ Make a context free grammar G′ such that L(G′) = L(G). (d) For the purposes of this task, regular expressions are defined to be the following subset of strings over the alphabet Σ = {a, b, (, ),+, ∗}: ˆ The strings “a” and “b” are regular expressions. ˆ If x ∈ Σ∗ is a regular expression then (x) and x∗ is a regular expression. ˆ If x ∈ Σ∗ and y ∈ Σ∗ are regular expressions then x+y and xy are regular expressions. Make a context free grammar that generates the language of all regular expres- sions. Here we have replaced ∪ with + since Mentor doesn’t like latex sybmols1. 1To pass non-alphanumeric characters to Mentor (like (, ), +, and *) you must put quotes around your input string. For example, running on CSIL, $∼zsisco/bin/mentor 2d.cfg accept "(ab)+a*". 2 3. Ambiguous? For each of the context free grammars below, indicate whether the grammar is am- biguous or unambiguous. If it is unambiguous give a brief justification for why. If it is ambiguous find a string s in the language generated by the grammar and draw two distinct derivation trees for s. (a) Terminals T = {a, b}, variables V = {0, 1, 2}, starting symbol S = 0, and pro- ductions ˆ 0→ 1b | 2a ˆ 1→ 2b | 0a ˆ 2→ 0b | 1a ˆ 2→ λ (b) Terminals T = {(, )}, variables V = {S}, starting symbol S, and productions ˆ S → SS | (S) | () (c) Terminals T = {a, b}, variables V = {S,K,L,M,N}, starting symbol S, and productions ˆ S → K | M ˆ K → aK | aL ˆ L→ bLa | ba ˆ M →Ma | Na ˆ N → aNb | ab (d) Terminals T = {a, b}, variables V = {S,A,B}, starting symbol S, and produc- tions ˆ S → aBABA | bABBA ˆ A→ a | bABBA ˆ B → b | aAAA 3 Figure 1: The NFA of 1a Figure 2: The NFA of 1b Figure 3: The DFA of 1c and 2b 4 Figure 4: The NFA of 1d 5
Answered Same DayApr 30, 2021

Answer To: 1. NFA, DFA, and RegExp In all of the subtasks below Σ = {a, b}. Figures showing the DFAs and NFAs...

Gopiraju answered on May 01 2021
147 Votes
1.a) ANS:-
ε -clouser(q0) = q0,
ε -clouser (q1) = q1,
ε -clouser (q2) = q2,
ε -clouser(q3) = q3,
ε -clouser(q4) = q4,
ε -clouser(q5) = q5,
ε -clouser(q6) = q6,
ε -clouser(q7) = q7q0,
ε -clouser(q8) = q8q0.
A = q0 (a) = ε –clouser ( δ (ε -clouser (q0), a ) )
= ε - clouser ( δ (q0), a )
= ε –clouser ( q1 )
= q1
· A = q0 (a) = q1.
A = q0 (b) = ε –clou
ser ( δ (ε -clouser (q0), b ) )
= ε - clouser ( δ (q0), b )
= ε –clouser (φ)
= φ
· A = q0 (b) = φ .
B = q1 (a) = ε –clouser ( δ (ε -clouser (q1), a ) )
= ε - clouser ( δ (q1), a )
= ε –clouser (φ)
= φ
· B = q1 (a) = φ .
B = q1 (b) = ε –clouser ( δ (ε -clouser (q1), b ) )
= ε - clouser ( δ (q1), b )
= ε –clouser (q2)
= q2
· B = q1 (b) = φ.
C = q2 (a) = ε –clouser ( δ (ε -clouser (q2), a ) )
= ε - clouser ( δ (q2), a )
= ε –clouser (q2)
= q3
· C= q2 (a) = q3.
C = q2 (b) = ε –clouser ( δ (ε -clouser (q2), b ) )
= ε –clouser (φ)
= φ
· C = q2 (b) = φ.
D = q3 (a) = ε –clouser ( δ (ε -clouser (q3), a ) )
= ε –clouser (φ)
= φ
· D = q3 (a) = φ.
D = q3 (b) = ε –clouser ( δ (ε -clouser (q3), b ) )
= ε - clouser ( δ (q3), b )
= ε –clouser (q4)
= q4
· D = q3 (b) = q4.
E = q4 (a) = ε –clouser ( δ (ε -clouser (q4), a ) )
= ε - clouser ( δ (q4), a )
= ε –clouser (q5)
= q5
· E = q4 (a) = q5.
E = q4 (b) = ε –clouser ( δ (ε -clouser (q4), b ) )
= ε –clouser (φ)
= φ
· E = q4 (b) = φ.
F = q5 (a) = ε –clouser ( δ (ε -clouser (q5), a ) )
= ε –clouser (φ)
= φ
· F = q5 (a) = φ.
F = q5 (b) = ε –clouser ( δ (ε -clouser (q5), b ) )
= ε - clouser ( δ (q5), b )
= ε –clouser (q6)
= q6
· F = q5 (b) = q6.
G = q6 (a) = ε –clouser ( δ (ε -clouser (q6), a ) )
= ε - clouser ( δ (q6), a )
= ε –clouser (q7)
= q7q0
· G = q6 (a) = q7q0.
G = q6 (b) = ε –clouser ( δ (ε -clouser (q6), b ) )
= ε –clouser (φ)
= φ
· G = q6 (b) = φ .
H = q7q0 (a) = ε –clouser ( δ (ε -clouser (q7q0), a ) )
= ε - clouser ( δ (q7q0), a )
= ε –clouser (φ,q1)
= q1
· H = q7q0 (a) = q1.
H = q7q0 (b) = ε –clouser ( δ (ε -clouser (q7q0), b ) )
= ε - clouser ( δ (q7q0), b )
= ε –clouser (q8, φ)
= ε –clouser (q8, φ)
= q8q0.
· H = q7q0 (b) = q8q0.
I = q8q0 (a) = ε –clouser ( δ (ε -clouser (q8q0), a ) )
= ε - clouser ( δ (q8q0), a )
= ε –clouser (φ,q1)
= q1
· I = q8q0 (a) = q1.
I = q8q0 (b) = ε –clouser ( δ (ε -clouser (q8q0), b) )
= ε - clouser ( δ (q8q0), b )
= ε –clouser (φ, φ)
= φ
· I = q8q0 (b) = φ.
     NFA state
     DFA state
     a
     b
     q0
     A
     B
     ---
     q1
     B
     ---
     C
     q2
     C
     D
     ---
     q3
     D
     ---
     E
     q4
     E
     F
     ---
     q5
     F
     ---
     G
     q6
     G
     H
     ---
     q7q0
     H
     B
     I
     q8q0
     I
     B
     ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here