05-context-free-languages

05-context-free-languages - Context-Free Languages As...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Context-Free Languages As pointed out before, the prototypical context-free language is L = { a n b n | a, b Σ and n 0 } In order to accept strings in this language a machine has to remember how many a ’s it has seen so that it can match the number b ’s with the number of a ’s. One way to accomplish this is with a stack, given some input string s L : ensure that only b ’s follow the last a in s , push all the a ’s of s onto the stack, then pop one a off the stack for each b , once we have read all the input symbols of s and the stack is empty and we are in an accepting state, then accept s ; otherwise reject. –p
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Pushdown Automaton –p
Background image of page 2
Formal Def. of PDA Definition: a pushdown automaton is a 6-tuple ( Q, Σ , Γ ,δ,q 0 ,F ) , where 1. Q is the set of states, 2. Σ is input alphabet, 3. Γ is the stack alphabet, 4. δ : Q × Σ ± × Γ ± P ( Q × Γ ± ) is the transition function, 5. q 0 Q is the start state, and 6. F Q is the set of accept states. Is this a deterministic or nondeterministic machine? –p
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Formal Computation of PDA –p
Background image of page 4
{ 0 n 1 n | n 0 } –p
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Context-Free Languages Definition: A language is context-free if some pushdown automaton recog- nizes it. –p
Background image of page 6
Context-Free Grammars –p
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Grammars Example: Given the context-free grammar G =( V, Σ ,R,S ) , with V = { A } , Σ= { a, b } ,S = A , and R the set of rules, A aAb A ± then L ( G )= { a n b n | n 0 } . –p
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/03/2011 for the course CSC 544 taught by Professor Staff during the Spring '11 term at Rhode Island.

Page1 / 21

05-context-free-languages - Context-Free Languages As...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online