430 likes | 668 Views
Theory of Computation Regular Expressions & Context-Free Languages. Prof. Muhammad Saeed. Regular Expressions. Regular Expression. Regular Expressions. Regular Expressions. Precedence of Regular Expression Operators. Regular Expressions. Regular Expressions.
E N D
Theory of Computation Regular Expressions & Context-Free Languages Prof. Muhammad Saeed
Regular Expressions Regular Expression Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Precedence of Regular Expression Operators Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Represent the following sets by regular expression • {a,bc} • {1,11,111,1111,………..} • {ab, a, b, bb} • {b2 , b5 , b8 , ………….} • {a2n+1 | n≥0} Write Regular expression for the following languages d) L1 ={a2n b2m+1 | n≥0, m ≥0 } Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Identities: Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Converting Regular Expressions to Automata R + S L(R)⋃L(S) RS L(R)L(S) Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions R* L(R*) Regular Expression to an є-NFA Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions a) Regular Expression to an є-NFA b) Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions c) Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Closure properties of Regular Languages: Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Regular Expressions Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages ( CFL ) Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages ( CFG ) Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Rules: Productions: Derivation Symbols Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Derivation Symbols Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Language Of a Grammar Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Parse Trees Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Ambiguous Grammars Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Ambiguous Grammars Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Useless Productions G = (V,T,S,P) is Context-free Grammar with P, S → aSb | λ | A A → aA A is useful if there is at least one w ϵ L(G) such that S xAy w • Empty Productions • A → λ, A λ b) Unit Productions A → B, A B c) Left Recursion A → Ax Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages Normal Forms 1) Chomsky Normal Forms 2) Greibach Normal Forms Chomsky Normal Forms (CNF) Any context-free language without any λ- production and unit production is generated by a grammar in which productions are of the form Dept. of Computer Science & IT, FUUAST Theory of Computation
Context-Free Languages 2) 3) Dept. of Computer Science & IT, FUUAST Theory of Computation
END Dept. of Computer Science & IT, FUUAST Theory of Computation