110 likes | 131 Views
Lecture 3 Regular Epressions Pumping Lemma. Jan Maluszynski , IDA, 200 7 http://www.ida.liu.se/~janma janma @ ida.liu.se. Outline. Motivating example RE Definition Equivalence with FA Pumping Lemma for RE. Motivating example. A language L over {a,b}: a string x is in L iff
E N D
Lecture 3Regular EpressionsPumping Lemma Jan Maluszynski, IDA, 2007 http://www.ida.liu.se/~janma janma @ ida.liu.se Jan Maluszynski - HT 2007
Outline • Motivating example • RE Definition • Equivalence with FA • Pumping Lemma for RE Jan Maluszynski - HT 2007
Motivating example A language L over {a,b}: a string x is in L iff x = waaz or x = wbbz For some strings w, z. Thus w, z are in{a,b}* Formal notation defining L: (a+b)*(aa+bb)(a+b)* Jan Maluszynski - HT 2007
Regular Expressions over Each expression R defines a language L(R). R is a regular expression over if R is: • a in L(R) = {a} • L(R) = {} • L(R) is the empty set • (R1+R2) L(R) = L(R1) L(R2) • (R1 R2) L(R) = L(R1) L(R2) • R1* L(R) = L(R1)* Sometimes ”” is used instead of ”+” Jan Maluszynski - HT 2007
Regular Expressions vs. Finite Automata A language is regular iff it is defined by a regular expression. • Given R construct NFA accepting L(R) pp.68-69 • Given FA M construct expression R s.that L(M)=L(R) pp. 69-73 Jan Maluszynski - HT 2007
Regular Expressions to Finite Automata In the book: • Construct NFA´s for basic components in given RE • Combine them using standard construction steps JFLAP approach: • Start from a GNFA • Decompose it until NFA is reached Jan Maluszynski - HT 2007
(D)FA to RE • Assume: • single initial state no incoming arrows • single final state no outgoing arrows • Apart of initial and final state the transition graph is complete • Construct GNFA by eliminating one state at a time • Two-state GNFA shows the result Jan Maluszynski - HT 2007
Constructing RE for a FA Jan Maluszynski - HT 2007
Pumping Lemma for regular languages FA M has a finite number p of states If |s| > p is accepted by M some state is visited at least twice, thus s = xyz where y moves M from q to q Hence xyiz is in L(M) for any i=0,1,… Jan Maluszynski - HT 2007
Pumping Lemma for regular languages For any regular languge R there exists p such that If s is in R and |s| p Then s = xyz, for some x,y,z satisfying the conditions: • For each i 0 xyiz is in R 2. |y| > 0 3. |xy| p Jan Maluszynski - HT 2007
Example of a non-regular language The infinite language {(),(()), ((())),…} is not regular Proof: Assume the contrary. Get the contradiction by pumping lemma: choose a string and show that it can’t be pumped. Jan Maluszynski - HT 2007