Lecture 10 Closure Properties of Regular Languages CSCE 355 Foundations of Computation Lecture 10 Closure Properties of Regular Languages Topics: Extended RegExpr Thompson Construction June 13, 2015
Last Time: Readings 2.3 New: Mutual Induction Proof revisited Languages denoted by regular expressions Examples Ruby Regular Expressions TEST 2 – Monday New: Readings section 3.1,3.2(skip DFA RE), 3.3
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 1. 3.1.1c - The set of strings of 0’s and 1’s with at most one pair of consecutive 1’s. 3.1.2 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 (construction) 3.2.4b (0+1)01 3.2.4c 00(0+1)* 3.14b, 3.14c convert to εNFA Text matching 3.3.1 re for matching phone numbers (international etc)
Regular expressions for Addresses Why? So we can automatically read email messages and extract addresses and insert into DB Joe Shmo 532 Spring Lake Road Columbia, SC 29209 Let’s start with Street Names Spring Lake Road Road | Rd. | Rd | avenue | Street | …
McNaughton-Yamada Construction Examples
McNaughton-Yamada Construction Examples Extended regular expressions
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);}
Compilation
DFA RegExpr NFA DFA Regular Languages
Not every language can be recognized by a DFA!
Algebraic Laws for Arithmetic Expressions Properties Equivalence of two expressions
Algebraic Laws for Regular Expressions What does it mean re1=re2 ?
Languages are Sets So Properties are Inherited Commutativity Law for alternation AUB = BUA so r l s = s l r Associativity Law for alternation (r + s) + t = r + (s + t) Associativity Law for concatenation (rs) t = r (st)
Commutivity
Identity/Annihilator
Distributive Laws In algebra Theorem 3.11 If L, M, and N are any languages, then L(M U N) = LM U LN Proof: w is in L(M U N) if and only if w is in LM U LN w is in L(M U N) w is in LM U LN
Factoring and Simplifying 0 + 01* = 0(ϵ + 1*) = 01*
Checking for Equality of Two Regular Expressions s = r ? (r+s)* = r* s*
Idempotent Law x + x ? xx ?
Laws involving Closures Ф* = ϵ ϵ* = ϵ L+ = L L* L* = L+ + ϵ L?
Is L intersection R regular?
Is the Complement of a Regular Lang. regular?
Not all Languages are regular L = {0n1n | n >= 1}
Every finite language is Regular
Discovering Laws for Regular Expressions (L +M)* = (L*M*)* Concretize expressions (only work for pure regular expressions, not intersections.)
Theorem 3.14 Theorem 3.14 The following test identifies true laws for regular expressions: Test for a Regular-Expression Algebraic Law to Test if regular expressions E = F is true (L(E) = L(F)) Convert E and F to concrete regular expressions C and D by replacing Variables by a concrete symbol Test whether L(C) = L(D) if so the E = F is true!
Pumping Lemma