Lecture 10 Closure Properties of Regular Languages Topics: Extended RegExpr Thompson Construction Test 1 Post Mortem October 1, 2008 CSCE 355 Foundations of Computation
– 2 – CSCE 355 Fall 2008 Last Time: Readings 2.3 Mutual Induction Proof revisited Languages denoted by regular expressions Examples Ruby Regular Expressions TEST 1 – September 29 thNew: Readings section 3.1,3.2(skip DFA RE), 3.3 Ruby Pickaxe Book Ruby: Matching in files
– 3 – CSCE 355 Fall 2008 Homework English descriptions Regular expressions 3.1.1b – The set of strings of 0’s and 1’s such that the tenth symbol from the right is a c - The set of strings of 0’s and 1’s with at most one pair of consecutive 1’s b The set of strings of 0’s and 1’s such that the number of zeroes is divisible by 5. Regular expressions English descriptions 3.14b (0*1*)*000(0+1)* 3.14c (0+10)*1* Regular expressions εNFA (Thompson construction) 3.2.4b (0+1) c 00(0+1)* 3.14b, 3.14c convert to εNFA Text matching re for matching phone numbers (international etc)
– 4 – CSCE 355 Fall 2008
– 5 – CSCE 355 Fall 2008 Grep Unix utility man grep man –k regexp
– 6 – CSCE 355 Fall 2008 Thompson Construction Based on recursive (inductive) definition of regular expressions We describe NFAs (with epsilon moves) that recognize the base cases. Then assuming we have NFAs for smaller expressions r and s we construct NFAs for r + s rs r*
– 7 – CSCE 355 Fall 2008 Thompson Construction Examples rs, r | s, r*
– 8 – CSCE 355 Fall 2008 Thompson Construction Examples Extended regular expressions
– 9 – CSCE 355 Fall 2008 Lex and Flex Regular definitions Pattern match “.” Last pattern Examples digit = [0-9] alpha= [a-zA-Z_] id = {alpha} ({alpha} | {letter} | ‘_’)* % id {install_InSymbolTable(yytext); return(ID);} while { return (KEYWHILE);}
– 10 – CSCE 355 Fall 2008 Compilation
– 11 – CSCE 355 Fall 2008 DFA RegExpr NFA DFA Regular Languages
– 12 – CSCE 355 Fall 2008 Algebraic Laws for Regular Expressions What does it mean re,=re2 ? E?
– 13 – CSCE 355 Fall 2008 Languages are Sets So Properties are Inherited AUB = BUA so r l s = s l r r l s = s l r
– 14 – CSCE 355 Fall 2008 Associativity
– 15 – CSCE 355 Fall 2008 Commutivity
– 16 – CSCE 355 Fall 2008 Annihilator for concatenation Identity annihilator
– 17 – CSCE 355 Fall 2008 Checking for Equality of Two Regular Expressions s = r ? (r+s)* = r* s*
– 18 – CSCE 355 Fall 2008 Is L intersection R regular?
– 19 – CSCE 355 Fall 2008 Is the Complement of a Regular Lang. regular?
– 20 – CSCE 355 Fall 2008 Not all Languages are regular
– 21 – CSCE 355 Fall 2008 Pumping Lemma
– 22 – CSCE 355 Fall 2008 Every finite language is Regular
– 23 – CSCE 355 Fall 2008 Test Post Mortem
– 24 – CSCE 355 Fall 2008
– 25 – CSCE 355 Fall 2008
– 26 – CSCE 355 Fall 2008
– 27 – CSCE 355 Fall 2008