Lab 6 - PDT

Lab Session #6 #

Agenda #

  • PDT - Push-Down Transducer

PD Transducer #

Formal definition #

A Pushdown Transducer (PDT) is a tuple T=Q,I,Γ,δ,q0,Z0,F T = ⟨Q, I, Γ, δ, q_0, Z_0, F⟩ where:

  • QQ is a finite set of states.

  • II and ΓΓ are the finite sets, the input and stack alphabets.

  • δδ , the transition function, is a partial function from (Q)×(I{ε})×(Γ) (Q)×(I \cup \{ε\}) × (Γ) to the set of finite subsets of (Q)×(Γ)(Q)×(Γ^*)

  • q0Qq_0 \in Q is the initial state.

  • Z0ΓZ_0 \in Γ is the initial stack symbol.

  • FQF \subseteq Q is the set of accepting states.

  • OO is the output alphabet.

  • η:Q×(I{ε})×ΓQη : Q×(I \cup \{ε\})× Γ → Q^*

Exercises - Part 1 #

  1. Build PDT that accepts xL1 x \in L_1 where L1={anbmn1nm}L_1 = \{a^nb^m | n \geq 1 \wedge n \leq m\} and translates it into anbn a^nb^n

  2. Build PDT that recognizes L2={xcx{a,b}+} L_2 = \{xc | x \in \{a, b\}^+\} and reverses it


Solutions:


Exercises - Part 2 #

Build DPDT that accepts the following laguages:

  • L1={anbmann1m1} L_1 = \{a^nb^ma^n | n \geq 1 \wedge m \geq 1\} , and translates it into anbma^nb^m

  • L2={aibjcki,j,kN L_2 = \{a^ib^jc^k | i, j, k \in \mathbb{N} and i+k=j} i + k = j\} , and translates it into aibicka^ib^ic^k

  • L3={xcyx,y{a,b}x>0y>0yxR}L_3 = \{xcy | x, y \in \{a, b\}^* \wedge |x| > 0 \wedge |y| > 0 \wedge y \neq x^R\} , (where xR x^R is the reversed string x x ), the alphabet is I={a,b,c}I = \{a, b, c\} and translates it into y y

  • L4={anbmm,nNL_4 = \{a^nb^m | m, n \in \mathbb{N} and nm2n} n \leq m \leq 2n\} , and translates it into anbna^nb^n


Solutions:


Extra exercise (optional) #

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+c)) ((a) + (b + c))
  • ((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, (, ), +\} -- a single symbol (‘a’) that represents terms ‘a’, ‘b’, ‘c’, \ldots . And a single operator (’+’).