1 / 15

Examples

a, b. b. a, b. a, b. a, b. 0. 1. 2. 3. 4. . . 2. 4. . a. 0. 1. . 5. 3. b. . Examples. Definition of regular sets Basis: , { } and {a}, for every a   are regular sets over .

Download Presentation

Examples

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. a, b b a, b a, b a, b 0 1 2 3 4   2 4  a 0 1  5 3 b  Examples

  2. Definition of regular sets • Basis: , {} and {a}, for every a   are regular sets over . • Recursive step: Let X and Y be regular sets over . Then the sets XY, XY, and X* are regular sets over . • Closure: X is a regular set over  only if it can be obtained from the basis elements by a finite number of applications of the recursive step • Examples: Let  = {0, 1} • Following are some regular sets over : • , {}, {0}, {1}, {00, 11}, {0}*, {0, 1}*

  3. Definition of regular expressions • Let  be an alphabet. The regular expressions over  are defined recursively as follows: • Basis:  is a regular expression denoting the regular set .  is a regular expression denoting {}. For every a  , a is a regular expression denoting {a}. • Recursive step: Let x and y be regular expressions over . Then the expressions x+y , xy , x* are regular expressions over . • Closure: x is a regular expression over  only if it can be obtained from the basis elements by a finite number of applications of the recursive step. • If x represents X and y represents Y, x+y represents XY, xy represents XY, and x* represents X*. (x) represents X.

  4. Examples: Let  = {0, 1} Regular expression Regular set 0 {0} 00 {00} 0 + 0 {0} 0* {0}* (0+1) {0, 1} 0(0+1) {00, 01} (00)* {00}*

  5. Regular expression identities: • x = x =  • x = x= x • * =  • * =  • x + y = y + x • x +  = x • x + x = x • (x*)* = x* • x(y+z) = xy + xz • (x+y)z = xz + yz • (xy)*x = x(yx)* • (x+y)* = (x*+y)* = x*(x+y)* = (x+yx*)* = (x*y*)* =x*(yx*)*=(x*y)*x*

  6. Example (construction of regular sets): Construct a regular expression to represent the set of strings over {a, b} that contain the substring ba and the substring ab. ---ba---ab--- ---bab--- ---ab---ba-- ---aba---

  7. -NFA NFA RE DFA Theorem: NFA, DFA, and Regular Expressions are Equivalent

  8. Example: Construct an NFA equivalent to the regular expression 0(1+0)*

  9. 2 a 1 Example: Construct equivalent DFA 4 a b 0 b a 3

  10. Rij(k) – regular expression representing the set of labels of all paths from state i to state j going through intermediate states {1, 2, 3, …, k} only (defined recursively) R1f(n) – regular expression representing strings accepted by f, f is in F Equivalent regular expression is the union of all R1f(n) Construction: BASE: Rij(0) = a1 + a2 + … + ak where i  j and am are labels of arcs from state i to state j. Rij(0) =  + a1 + a2 + … + ak where i = j and am are labels of arcs from state i to state j. INDUCTON: Rij(k) = Rij(k-1) + Rik(k-1)(Rkk(k-1))*Rkj(k-1) Construction of regular expression from FA

  11. a,b Example: Find equivalent regular expression for the following NFA: a 3 start 2 1 b b

  12. 0.1 start A B C D 1 0,1 0,1 State elimination method - example

  13. Applications of Finite Automata: • Software for digital circuit design • Lexical Analyzer • Keyword search • Software for verifying finite state systems

  14. Key word search  e n d b e g i n

  15. Pattern matching (KMP Algorithm) procedure fsasearch; begin state := 0; for i := 1 to N do begin state := next(state, a[i]); if (state = final) then return true; end; return false; end; e.g. search for 10100110

More Related