Lab Session #6
# Agenda
# PDT - Push-Down Transducer PD Transducer
# A Pushdown Transducer (PDT) is a tuple
T = ⟨ Q , I , Γ , δ , q 0 , Z 0 , F ⟩ T = ⟨Q, I, Γ, δ, q_0, Z_0, F⟩ T = ⟨ Q , I , Γ , δ , q 0 , Z 0 , F ⟩
where:
Q Q Q
is a finite set of states.
I I I
and Γ Γ Γ
are the finite sets, the input and stack alphabets.
δ δ δ
, the transition function, is a partial function from ( Q ) × ( I ∪ { ε } ) × ( Γ ) (Q)×(I \cup \{ε\}) × (Γ) ( Q ) × ( I ∪ { ε } ) × ( Γ )
to the set of finite subsets of ( Q ) × ( Γ ∗ ) (Q)×(Γ^*) ( Q ) × ( Γ ∗ )
q 0 ∈ Q q_0 \in Q q 0 ∈ Q
is the initial state.
Z 0 ∈ Γ Z_0 \in Γ Z 0 ∈ Γ
is the initial stack symbol.
F ⊆ Q F \subseteq Q F ⊆ Q
is the set of accepting states.
O O O
is the output alphabet.
η : Q × ( I ∪ { ε } ) × Γ → Q ∗ η : Q×(I \cup \{ε\})× Γ → Q^* η : Q × ( I ∪ { ε } ) × Γ → Q ∗ Exercises - Part 1
# Build PDT that accepts x ∈ L 1 x \in L_1 x ∈ L 1
where
L 1 = { a n b m ∣ n ≥ 1 ∧ n ≤ m } L_1 = \{a^nb^m | n \geq 1 \wedge n \leq m\} L 1 = { a n b m ∣ n ≥ 1 ∧ n ≤ m }
and translates it into a n b n a^nb^n a n b n
Build PDT that recognizes L 2 = { x c ∣ x ∈ { a , b } + } L_2 = \{xc | x \in \{a, b\}^+\} L 2 = { x c ∣ x ∈ { a , b } + }
and reverses it
Solutions :
Expand
▾
Solution(1) :
A PDT that accepts x ∈ L 1 x \in L_1 x ∈ L 1
where L 1 = { a n b m ∣ n ≥ 1 ∧ n ≤ m } L_1 = \{a^nb^m | n \geq 1 \wedge n \leq m\} L 1 = { a n b m ∣ n ≥ 1 ∧ n ≤ m }
and translates it into a n b n a^nb^n a n b n
Solution(2) :
A PDT that recognizes L 2 = { x c ∣ x ∈ { a , b } + } L_2 = \{xc | x \in \{a, b\}^+\} L 2 = { x c ∣ x ∈ { a , b } + }
and reverses it
Exercises - Part 2
# Build DPDT that accepts the following laguages:
L 1 = { a n b m a n ∣ n ≥ 1 ∧ m ≥ 1 } L_1 = \{a^nb^ma^n | n \geq 1 \wedge m \geq 1\} L 1 = { a n b m a n ∣ n ≥ 1 ∧ m ≥ 1 }
, and translates it into a n b m a^nb^m a n b m
L 2 = { a i b j c k ∣ i , j , k ∈ N L_2 = \{a^ib^jc^k | i, j, k \in \mathbb{N} L 2 = { a i b j c k ∣ i , j , k ∈ N
and i + k = j } i + k = j\} i + k = j }
, and translates it into a i b i c k a^ib^ic^k a i b i c k
L 3 = { x c y ∣ x , y ∈ { a , b } ∗ ∧ ∣ x ∣ > 0 ∧ ∣ y ∣ > 0 ∧ y ≠ x R } L_3 = \{xcy | x, y \in \{a, b\}^* \wedge |x| > 0 \wedge |y| > 0 \wedge y \neq x^R\} L 3 = { x c y ∣ x , y ∈ { a , b } ∗ ∧ ∣ x ∣ > 0 ∧ ∣ y ∣ > 0 ∧ y = x R }
, (where x R x^R x R
is the reversed string x x x
), the alphabet is I = { a , b , c } I = \{a, b, c\} I = { a , b , c }
and translates it into y y y
L 4 = { a n b m ∣ m , n ∈ N L_4 = \{a^nb^m | m, n \in \mathbb{N} L 4 = { a n b m ∣ m , n ∈ N
and n ≤ m ≤ 2 n } n \leq m \leq 2n\} n ≤ m ≤ 2 n }
, and translates it into a n b n a^nb^n a n b n
Solutions :
Expand
▾
Solution(1) :
A PDT that accepts L 1 = { a n b m a n ∣ n ≥ 1 ∧ m ≥ 1 } L_1 = \{a^nb^ma^n | n \geq 1 \wedge m \geq 1\} L 1 = { a n b m a n ∣ n ≥ 1 ∧ m ≥ 1 }
, and translates it into a n b m a^nb^m a n b m
Solution(2) :
A PDT that accepts L 2 = { a i b j c k ∣ i , j , k ∈ N a n d i + k = j } L_2 = \{a^ib^jc^k | i, j, k \in \mathbb{N}\ and\ i + k = j\} L 2 = { a i b j c k ∣ i , j , k ∈ N a n d i + k = j }
, and translates it into a i b i c k a^ib^ic^k a i b i c k
Consider the language of well-formed parentheses of the arithmetic expressions (binary operations). Examples of strings belonging to the language are:
( a + b ) (a + b) ( a + b ) ( ( a ) + ( b + c ) ) ((a) + (b + c)) ( ( a ) + ( b + c ) ) ( ( a + b ) ) ((a + b)) ( ( a + b ) ) Build PDT that recognises this language and translates it into reverse polish notation. For simplicity, consider the following alphabet I = { a , ( , ) , + } − − I = \{a, (, ), +\} -- I = { a , ( , ) , + } − −
a single symbol (‘a’) that represents terms ‘a’, ‘b’, ‘c’, … \ldots …
. And a single operator (’+’).