1 / 13

Lecture 3

Lecture 3. Chapter 4 Regular Expressions. Important Terms. Regular Expressions Regular Languages Finite Representations. Recursive Definition of Regular expressions. Rule 1: Every letter of ∑ can be made into a regular expression by writing it in boldface; ^ is a regular expression.

elyse
Télécharger la présentation

Lecture 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3 Chapter 4 Regular Expressions

  2. Important Terms • Regular Expressions • Regular Languages • Finite Representations

  3. Recursive Definition of Regular expressions • Rule 1: Every letter of ∑ can be made into a regular expression by writing it in boldface; ^ is a regular expression. • Rule 2 :If r1, and r2 are regular expressions, then so are: • (rl) • r1r2 • r1 + r 2 • rl* • Rule 3 :Nothing else is a regular expression.

  4. Important definitions • S + T = {w : w € S or w € T}(Union) • ST = {w = w1w2 : w1 € S,w2 € T} (Concatenation or Product) • S* = S0 + S1 + S2 + · · · (Kleene’s Closure) • S+ = S1 + S2 + · · · (Positive Closure)

  5. Example • Suppose that we wished to describe the language L over the alphabet ∑ = {a,b} where L = {a ababbabbbabbbb ... } • R.E= ab*

  6. (ab)* = ^ or ab or abab or ababab ... • XX* = X+

  7. Example • ab*a • language (ab*a) = {aa aba abba abbba abbbba ... .}

  8. Example • The language of the expression a*b* • contains all the strings of a's and b's in which all the a's (if any) come before all the b's (if any). • language (a*b*) = {^ a b aaab bb aaaaababbbbbaaaa . . . } • Notice that ba and aba are not in this language. Notice also that there need not be the same number of a's and b's. • Here we should again be very careful to observe that a*b* ≠ (ab)*

  9. Example • The following expressions both define the language L2 = {xodd} • x(xx)* or (xx)*x • but the expression x*xx* does not since it includes the word (xx) x (x).

  10. Another use plus (+) sign • By the expression x + y where x and y are strings of characters from an alphabet, we mean "either x or y".

  11. example • Consider the language T defined over the alphabet ∑ {a, b, c} • T = {a c abcbabbcbbabbbcbbbabbbbcbbbb ... } • All the words in T begin with an a or a c and then are followed by some number of b's. Symbolically, we may write this as T = language ((a + c)b*)= language (either a or c then some b's)

  12. example • Now let us consider a finite language L that contains all the strings of a's and b's of length exactly three. • L = {aaaaababaabb baa babbbabbb} • The first letter of each word in L is either an a or a b. The second letter of each word in L is either an a or a b. The third letter of each word in L is either an a or a b. So we may write • L = language ((a + b)(a + b)(a + b)) • or for short, L = language ((a + b)3) •

  13. Example cont… • If we want to define the set of all seven letter strings of a's and b's, we could write (a + b)7 . In general, if we want to refer to the set of all possible strings of a's and b's of any length whatsoever we could write, (a + b)* • This is the set of all possible strings of letters from the alphabet ∑ = {a, b} • (a+b)*= {^ a b abbaaa bb abaabb…}

More Related