170 likes | 515 Views
Closure Properties for Regular Languages. Preliminaries. So far, we have stated languages in plain English. For example: “all words starting and ending with the character b ” The description in plain English can be cumbersome and ambiguous
E N D
Preliminaries • So far, we have stated languages in plain English. For example: “all words starting and ending with the character b” • The description in plain English can be cumbersome and ambiguous • “Regular Expressions” is a formal way to describe languages accepted by finite automata
Regular Expressions Regular Expressions are built upon a subset of the following operations on sets: • Union • Complementation • Intersection • Difference • Concatenation • Kleene star
Union Let L and M two languages, then their union is defined by: L M = { w : w L or w M} Let AL and AM two finite automata accepting L and M respectively: AL: AM: s > s’ > … … Is there a finite automata accepting L M ?
Union (2) Is there a finite automata accepting L M ? Yes! AL s e … q > e s’ AM …
Complement Let L be a language over an alphabet , then the complement of L is defined as: LC = { w : w * and w L} Let AL be a finite automaton accepting L. Is there a finite automaton accepting LC? b b a a f s q b b P a a
a r r s q q > b b b Complement (2) a r r s q q > b b b
Complement (3) Given a language accepted by a finite automaton AL, to find a finite automaton accepting LC we have to do the following steps: 1. Transform AL into an equivalent DFA AL’ 2. Construct a new automaton ALC by taking AL’and: 2.1 Removing the favorable marks of all favorable states 2.2 Marking as favorable those states that initially had no favorable mark The resulting ALC is a DFA accepting LC
Intersection Let L and be M two languages, then their intersection is defined by: L M = { w : w L and w M} Using DeMorgan’s Laws: (L M) = (LC MC)C Thus, there must be a finite automaton accepting (L M)
Difference Let L and M be two languages, then their difference is defined by: L M = { w : w L and w M} Using DeMorgan’s Laws: (L M) = L MC Thus, there must be a finite automaton for (L M)
Concatenation Let L and M be two languages, then their concatenation is defined by: LM = { wv : w L and v M} b b A: B: a a s f a s f b a b b P a How to extend these automata such that the resulting one accepts the concatenation language?
Concatenation (2) AL e s > s’ e AM … e … Steps to obtain a finite automation accepting LM: 1. Make an e-transition from all favorable states in AL to the initial state in AM 2. Unmark all favorable states in AL 3. Remove the mark of the initial state in AM
Kleene Star Let L be a language over an alphabet an alphabet , then we define: L0 = {e} L1 = L L2 = LL L3 = L2L = LLL … Ln = Ln-1L Kleene star of L is defined as: L* = L0 L1 L2 …
Kleene Star (2) An equivalent definition: L* = {w1 w2 … wk : w1, w2, …, wk L} b A: a s > f a b b P a Obtain a finite automaton accepting L(A)*
Kleene Star (3) e e AL s > s’ e e … e This finite automaton accepts L*
Closure under Set Operations Theorem Theorem. Let L and M two regular languages, then the following languages are also regular: • L M • LC • L M • L – M • LM • L* One says that the regular languages are “closed” under these 6 operations