Answer To: CSci 4011, Formal Languages and Automata Theory Homework 2, Fall 2020 Posted: Oct 7, 2020 Due: Oct...
Sandeep Kumar answered on Oct 20 2021
1. The given context-free gramar G is
{x1#x2# · · · #xk | k ≥ 1, each xi ∈ {a, b}∗, and for some i and j, xi = xRj }
must be in one of the following forms: (i) contains a palindrome xi
for some i; (ii)
contains distinct i and j such that xi = xRj.
Accordingly, the CFG we use is as follows:
S → S1 | S2
S1 → P | X#P | P#X
P → aPa | bPb | a | b | ε
X → a | b | # | ε
S2 → M | X#M | M#X
M → aMa | bMb | #X#
2. 1.
Let G = (V, Σ, S, R), where V = {S, U, V, X, Y }, Σ = {a, b, c} and R consists of the
following rules.
S → U | V
U → aU | X
V → V c | Y
X → bXc | ε
Y → aY b | ε
The context-free grammar G is ambiguous
2. The parse trees (both left-most and right most are), for chosen string a+axa
3. The grammar generates all strings not of the form anbn for n>0. Since the following grammar generates L(G):{{S},{a,b},{S -> aSb | ε }
4. 1.. A computation begins by pushing a C onto the stack, which serves as a bottom-maker throughout the computation. The stack is used to record the relationship between the number of a’s and b’s scanned during the computation. The stacktop will be a C when the number of a’s processed is exactly twice the number of b’s processed. The stack will contain n A’s if the automaton has read n more a’s than b’s. If n more b’s than a’s have been read, the stack will hold 2n B’s. When an a is read with an A or C on the top of the stack, an A is pushed onto the stack. This is accomplished by the transition to q2. If a B is on the top of the stack, the stack is popped removing one b. If a b is read with a C or B on the stack, two B’s are pushed onto the stack. Processing a b with an A on the stack pops the A.
2. The pushdown automaton defined by the transitions accepts strings that have twice as many as as bs:
δ(q0, λ, λ) = {[q1, C]}
δ(q1, a, A) = {[q2, A]}
δ(q1, a, C) = {[q2, C]}
δ(q1, b, B) = {[q3, B]}
δ(q1, b, C) = {[q3, C]}
δ(q1, a, B) = {[q1, λ]}
δ(q1, b, A) = {[q1, λ]}
δ(q1, λ, C) = {[q5, λ]}
δ(q2, λ, λ) = {[q1, A]}
δ(q3, λ,...