2001Lec6 - CSE 2001: Introduction to Theory of Computation...

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

View Full Document Right Arrow Icon
2/28/2006 CSE 2001, Winter 2006 1 CSE 2001: Introduction to Theory of Computation Winter 2006 Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/2001 Some of these slides are adapted from Wim van Dam’s slides ( www.cs.berkeley.edu/~vandam/CS172/ ) 2/28/2006 CSE 2001, Winter 2006 2 Last Lecture Context-Free Languages (CFL) Context-Free Grammars (CFG) Next • Quick review of CFG • Chomsky Normal Form of CFG •RL CFL 2/28/2006 CSE 2001, Winter 2006 3 Context-Free Grammars • Recursive Notation for Context-Free Languages • Indicates the rules of a language • Grammar used to derive string in the language • Derivation can be represented as parse trees 2/28/2006 CSE 2001, Winter 2006 4 Context-Free Grammars (Def.) A context free grammar G=(V, Σ ,R,S) is defined by • V: a finite set variables Σ : finite set terminals (with V ∩Σ = ) • R: finite set of substitution rules V (V ∪Σ )* • S: start symbol V The language of grammar G is denoted by L(G): L(G) = { w ∈Σ * | S * w } 2/28/2006 CSE 2001, Winter 2006 5 Context-Free Grammars (Ex.) Consider the CFG G=(V, Σ ,R,S) with V = {S} Σ = {0,1} R: S 0S1 | 0Z1 Z 0Z | ε Then L(G) = {0 i 1 j | i j } S yields 0 j+k 1 j according to: S 0S1 0 j S1 j 0 j Z1 j 0 j 0Z1 j 0 j+k Z1 j 0 j+k ε 1 j = 0 j+k 1 j 2/28/2006 CSE 2001, Winter 2006 6 More examples • L(G) = {0 n 1 2n | n = 1,2,… } • L(G) = {xx R | x is a string over {a,b}} • L(G) = {x | x is a string over {1,0} with an equal number of 1’s and 0’s}
Background image of page 1

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

View Full DocumentRight Arrow Icon
2/28/2006 CSE 2001, Winter 2006 7 Ambiguity A grammar is ambiguous if some strings are derived ambiguously . A string is derived ambiguously if it has more than one leftmost derivations . Typical example: rule S
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

2001Lec6 - CSE 2001: Introduction to Theory of Computation...

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

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