Formal Languages Philippe de Groote 2018-2019 Philippe de Groote Formal Languages 2018-2019 1 / 14
Outline Pushdown automata 5 Definition Move relation Language accepted by a PDA Acceptance by empty stack From CFG to PDA From PDA to CFG Philippe de Groote Formal Languages 2018-2019 2 / 14
Pushdown automata Definition Definition A pushdown automaton is a 7-tuple P = � Q, Σ , Γ , δ, q 0 , Z 0 , F � , where Q is an alphabet of states ; Σ is an alphabet of input symbols ; Γ is an alphabet of stack symbols ; δ ∈ P fin ( Q × Γ ∗ ) Q × (Σ ∪{ ǫ } ) × Γ is the transition function ; q 0 ∈ Q is the initial state ; Z 0 ∈ Q is the initial stack symbol ; F ⊂ Q is the set of final states . Philippe de Groote Formal Languages 2018-2019 3 / 14
Pushdown automata Move relation Move relation Philippe de Groote Formal Languages 2018-2019 4 / 14
Pushdown automata Move relation Move relation Instantaneous description (ID): ( q, α, β ) ∈ Q × Σ ∗ × Γ ∗ Philippe de Groote Formal Languages 2018-2019 4 / 14
Pushdown automata Move relation Move relation Instantaneous description (ID): ( q, α, β ) ∈ Q × Σ ∗ × Γ ∗ Initial ID: ( q 0 , α, Z 0 ) ∈ { q 0 } × Σ ∗ × { Z 0 } Philippe de Groote Formal Languages 2018-2019 4 / 14
Pushdown automata Move relation Move relation Instantaneous description (ID): ( q, α, β ) ∈ Q × Σ ∗ × Γ ∗ Initial ID: ( q 0 , α, Z 0 ) ∈ { q 0 } × Σ ∗ × { Z 0 } Move relation: ( q, aα, Zβ ) ⊢ ( r, α, γβ ) where: a ∈ Σ ∪ { ǫ } ; ( r, γ ) ∈ δ ( q, a, Z ) . Philippe de Groote Formal Languages 2018-2019 4 / 14
Pushdown automata Move relation Move relation Instantaneous description (ID): ( q, α, β ) ∈ Q × Σ ∗ × Γ ∗ Initial ID: ( q 0 , α, Z 0 ) ∈ { q 0 } × Σ ∗ × { Z 0 } Move relation: ( q, aα, Zβ ) ⊢ ( r, α, γβ ) where: a ∈ Σ ∪ { ǫ } ; ( r, γ ) ∈ δ ( q, a, Z ) . ⊢ ∗ denotes the reflexive, transitive closure of ⊢ Philippe de Groote Formal Languages 2018-2019 4 / 14
Pushdown automata Language accepted by a PDA Language accepted by a PDA Language accepted by a PDA: L ( P ) = { α ∈ Σ ∗ : ∃ q ∈ F, β ∈ Γ ∗ . ( q 0 , α, Z 0 ) ⊢ ∗ ( q, ǫ, β ) } Philippe de Groote Formal Languages 2018-2019 5 / 14
Pushdown automata Acceptance by empty stack Acceptance by empty stack Language accepted by a PDA by the empty stack: N ( P ) = { α ∈ Σ ∗ : ∃ q ∈ Q. ( q 0 , α, Z 0 ) ⊢ ∗ ( q, ǫ, ǫ ) } Philippe de Groote Formal Languages 2018-2019 6 / 14
Pushdown automata Acceptance by empty stack Acceptance by empty stack Let P N = � Q N , Σ N , Γ N , δ N , q N 0 , Z N 0 , F N � be a PDA. Define another PDA P F = � Q F , Σ F , Γ F , δ F , q F 0 , Z F 0 , F F � as follows: Q F = Q N ∪ { p 0 , p f } , where p 0 and p f are fresh symbols; Σ F = Σ N ; Γ F = Γ N ∪ {⊣} , where ⊣ is a fresh symbol; δ F is such that: δ F ( q, a, Z ) = δ N ( q, a, Z ) for ( q, a, Z ) ∈ Q N × (Σ N ∪ { ǫ } ) × Γ N δ F ( p 0 , ǫ, ⊣ ) = { ( q N 0 , Z N 0 ⊣ ) } δ F ( q, ǫ, ⊣ ) = { ( p f , ǫ ) } for every q ∈ Q N q F 0 = p 0 ; Z F 0 = ⊣ ; F F = { p f } . Philippe de Groote Formal Languages 2018-2019 7 / 14
Pushdown automata Acceptance by empty stack Acceptance by empty stack Proposition L ( P F ) = N ( P N ) . Philippe de Groote Formal Languages 2018-2019 8 / 14
Pushdown automata Acceptance by empty stack Acceptance by empty stack Let P F = � Q F , Σ F , Γ F , δ F , q F 0 , Z F 0 , F F � be a PDA. Define another PDA P N = � Q N , Σ N , Γ N , δ N , q N 0 , Z N 0 , F N � as follows: Q N = Q F ∪ { p 0 , p f } , where p 0 and p f are fresh symbols; Σ N = Σ F ; Γ N = Γ F ∪ {⊣} , where ⊣ is a fresh symbol; δ N is such that: δ N ( q, a, Z ) = δ F ( q, a, Z ) for ( q, a, Z ) ∈ Q F × (Σ F ∪ { ǫ } ) × Γ F δ N ( p 0 , ǫ, ⊣ ) = { ( q N 0 , Z N 0 ⊣ ) } δ N ( q, ǫ, Z ) = { ( p f , ǫ ) } for every q ∈ F F and every Z ∈ Γ N δ N ( p f , ǫ, Z ) = { ( p f , ǫ ) } for every Z ∈ Γ N q N 0 = p 0 ; Z N 0 = ⊣ ; F N = { p f } . Philippe de Groote Formal Languages 2018-2019 9 / 14
Pushdown automata Acceptance by empty stack Acceptance by empty stack Proposition N ( P N ) = L ( P F ) . Philippe de Groote Formal Languages 2018-2019 10 / 14
Pushdown automata From CFG to PDA From CFG to PDA Let G = � N, Σ , P, S � be a context-free grammar. Define a PDA P = � Q, Σ , Γ , δ, q 0 , Z 0 , F � as follows: Q = { q } ; Γ = N ∪ Σ ; δ is such that: δ ( q, ǫ, A ) = { ( q, α ) : ( A → α ) ∈ P } for A ∈ N δ ( q, a, a ) = { ( q, ǫ ) } for a ∈ Σ δ ( q, , ) = ∅ in the other cases q 0 = q ; Z 0 = S ; F = { q } . Philippe de Groote Formal Languages 2018-2019 11 / 14
Pushdown automata From CFG to PDA From CFG to PDA Proposition N ( P ) = L ( G ) . Philippe de Groote Formal Languages 2018-2019 12 / 14
Pushdown automata From PDA to CFG From PDA to CFG Let P = � Q, Σ , Γ , δ, q 0 , Z 0 , F � be a PDA. Define a context-free grammar G = � N, Σ , P, S � as follows: N = { S } ∪ { [ pXq ] : p, q ∈ Q ∧ X ∈ Γ } ; P contains the following rules: for every p ∈ Q : S → [ q 0 Z 0 p ] for every ( r, Y 0 Y 1 . . . Y n − 1 ) ∈ δ ( q, a, Y ) : [ qY r n − 1 ] → a [ rY 0 r 0 ][ r 0 Y 1 r 1 ] . . . [ r n − 2 Y n − 1 r n − 1 ] where r 0 , r 1 , . . . r n − 2 , r n − 1 ∈ Q Philippe de Groote Formal Languages 2018-2019 13 / 14
Pushdown automata From PDA to CFG From PDA to CFG Proposition L ( G ) = N ( P ) . Philippe de Groote Formal Languages 2018-2019 14 / 14
Recommend
More recommend