{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

05-context-free-languages

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

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

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

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

View Full Document
Pushdown Automaton –p
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

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

View Full Document
Formal Computation of PDA –p
{ 0 n 1 n | n 0 } –p

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

View Full Document
Context-Free Languages Definition: A language is context-free if some pushdown automaton recog- nizes it. –p
Context-Free Grammars –p

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online