Presentation is loading. Please wait.

Presentation is loading. Please wait.

Principles of Computing – UFCFA3-30-1

Similar presentations


Presentation on theme: "Principles of Computing – UFCFA3-30-1"— Presentation transcript:

1 Principles of Computing – UFCFA3-30-1
Week-4 Instructor : Mazhar H Malik Global College of Engineering and Technology

2 Extended Topics in DFA

3 Trap or Dead State A trap is state that, once entered, one can never leave. Used to reject partly read strings that will never be accepted, or to accept partly read strings that will definitely be accepted. Trap State: Dead states are those non final states which transits (Self Loop) in itself for all the symbol.

4

5 Set of States Q Q  q0 , q1, q2 , q3, q4 , q5 Example • a,b q5 a,b

6 Input Alphabet  Example   a,b a,b q5 a,b q4 b q0 b q3 q1 b q2 b

7 q0 Initial State Example a,b q5 a,b q4 b q0 b q3 q1 b q2 b

8 Example:  q0 , a  q1 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

9  q0 ,b  q5 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

10  state s symbols Transition Table for  • b q0 q1 q5 q2 q3 q4 a,b q5

11

12 Example a,b a,b b q0 q1 Accept state q2 trap state 11

13 b Input String a,b a,b b q0 q1 q2 12

14 b a,b a,b b q0 q1 q2 13

15 b a,b a,b b q0 q1 q2

16 Input finished b a,b accept a,b b q0 q1 q2

17 A rejection case b Input String a,b a,b b q0 q1 q2

18 b a,b a,b b q0 q1 q2

19 b a,b a,b b q0 q1 q2

20 Input finished b a,b a,b b q0 q1 q2 reject

21 L  {a nb : n  0} Language Accepted: a,b a,b b q0 q1 q2

22 Another Example EVEN  {x : x  * and x is even}
Alphabet:   {1} 1 q0 q1 Language Accepted: EVEN  {x : x  * and x is even}  {, 11, 1111, , }

23 Example 2.3 Design a DFA that accept set of strings that
containing four 1’s every string over alphabet ∑ = {0,1} Solution: DFA should accepts the string 1111, , … Let DFA be M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q4} Trap State: Dead states are those non final states which transits in itself for all the symbol. So q5 is example of dead state

24 Example 2.4 Design a DFA (Graph and Table) that accept set of strings that containing exactly 1 every string over alphabet ∑ = {0,1} Solution: DFA should accepts the string 1, , … Let DFA be M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q1} ∂/∑ 1 -> q0 q0 q1 * q1 q2 Self Loop

25 Example 2.5 Design a DFA that accept Language
L = {ω ∈ (0,1)* / second symbol of ω is ‘0’ and fourth input is 1} Solution: So after analyzing the problem we find that every string of the language is like 0001, 1011, … Let DFA be M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q4} For securing the second and fourth position we need trap state

26 Example 2.6 For the given DFA Write the language and also given the
transition table ∂/∑ 1 -> q0 q1 q0 q2 *q2 Solution: Let the language be L for FA shown in Example 2.6 L = {ω ∈ (0,1)* /every string ω of the language containing 00 as substring}. Transition Table:

27 Example 2.7 Design DFA for the Language L = {(01)i 12j | i ≥ j≥1}
Solution: Let analyzing the language be L for FA accept strings start with any with any number of 01 (no empty) and end with even number of 1’s Let FA be. M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q4}, ∑ = {0,1}

28  * :Q  *  Q  * (q,w )  q  Extended Transition Function
Describes the resulting state after scanning string w from state q

29 Example:  * q0,ab   q2 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

30  * q0,abbbaa   q5 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

31  q , bba *  q 1 4 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

32 Special case: for any state q  * q,   q

33 q q w  * q,w   q  w  12 k In general:
implies that there is a walk of transitions w  12 k 1  2  k q q states may be repeated w q q

34 Minimization of DFA’s To remove Dead State Inaccessible State
Equivalent State Useless State

35 Step-2: ->q0 q5 q1 q2 q6 *q2 q0 q4 q7
Draw the transition table for test states, after removing q3 (unreachable state) ∂/∑ a b ->q0 q5 q1 q2 q6 *q2 q0 q4 q7

36 Step-3: ->q0 q5 q1 q2 q6 q4 q7 *q2 q2 q0
Now divide rows of transition table in two sets as: One set contains only those rows, which starts from non-final states i.e. Other set contains only those rows, which starts from final state Non-final states ∂/∑ a b ->q0 q5 q1 q2 q6 q4 q7 Final states ∂/∑ a b *q2 q2 q0

37 Step-4: Apply step-4 on both the sets individually. Now consider set-1
∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 q4 q7 q1 3 4 5 q7 6

38 Step-4: Row 2 and row 6, are similar since q1 and q7 transit to same states on a and b. So skip one of them skip skip row 6, then q7 in the rest . Write the rest as follows: ∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 q4 3 4 5

39 Step-5: Repeat Step-4 on the rest set-1, till you are finding similar rows and write rest, now this set is minimized ∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 q4 4 q7 q0 5 3

40 Step-5: Now minimized set is
∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 4 q4 q0 5

41 Step-6: Do same process for set 2 as
Final states ∂/∑ a b *q2 q2 q0

42 Step-7: Now combine set-1 and set-2 as
∂/∑ a b ->q0 q5 q1 q2 q6 q4 q0 *q2

43 Minimized DFA Transition Graph
∂/∑ a b ->q0 q5 q1 q2 q6 q4 q0 *q2

44 Minimized DFA - Comparison

45 Your Turn… Minimize the following DFA

46

47 Minimization by Transition Graph
46

48 The Game of MINIMIZE All useless players are disqualified.
Game proceeds in rounds. Start with 2 teams: ACCEPT vs. REJECT. Each round consists of sub-rounds – one sub- round per team. Two members of a team are said to agree if for a given label, they want to pass the buck to same team. Otherwise, disagree. During a sub-round, disagreeing members split off into new maximally agreeing teams. If a round passes with no splits, STOP. 47

49 Minimization Example Start with a DFA 48

50 Minimization Example Miniature version  49

51 Minimization Example Split into two teams. ACCEPT vs. REJECT 50

52 Minimization Example 0-label doesn’t split up any teams 51

53 Minimization Example 1-label splits up REJECT's 52

54 Minimization Example No further splits. HALT!
Start team contains original start 53

55 Minimization Example. End Result
States of the minimal automata are remaining teams. Edges are consolidated across each team. Accept states are break-offs from original ACCEPT team. 54

56 Minimization Example. Compare
55

57 Minimization Example. Compare
56

58 Minimization Example. Compare
57

59 Minimization Example. Compare
58

60 Minimization Example. Compare
59

61 Minimization Example. Compare
60

62 Minimization Example. Compare
61

63 Minimization Example. Compare
62

64 Minimization Example. Compare
63

65 Minimization Example. Compare
ACCEPTED. 64

66 Minimization Example. Compare
10000 65

67 Minimization Example. Compare
10000 66

68 Minimization Example. Compare
10000 67

69 Minimization Example. Compare
10000 68

70 Minimization Example. Compare
10000 69

71 Minimization Example. Compare
10000 REJECT. 70

72

73 Sources http://www.jflap.org/tutorial/
www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt Theory of computation by A. Pandey


Download ppt "Principles of Computing – UFCFA3-30-1"

Similar presentations


Ads by Google