Upcoming SlideShare
×

# Finite automata

1,796 views
1,677 views

Published on

Published in: Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
1,796
On SlideShare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
51
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Finite automata

1. 1. Finite Automata .Source: Chapter 1.1 - Introduction to the Theory of Computation by Michael Sipser 1
2. 2. ? :? ? (computational model). finite state machine finite automaton. 2
3. 3. Finite Automata finite automata ? - 3
4. 4. (1) front rear pad pad door2OPEN CLOSED ( ) 4FRONT, REAR, BOTH, NEITHER 4
5. 5. (2) FRONT REAR FRONT BOTH CLOSED OPEN REARNETHER BOTH NETHER NETHER FRONT REAR BOTH CLOSED CLOSED OPEN CLOSED CLOSED OPEN CLOSED OPEN OPEN OPEN 5
6. 6. (3)( ) 6
7. 7. Finite Automata finite automata finite automata 7
8. 8. Finite Automata 0 1 0 1 q1 q2 q3 0,1 A finite automaton called M1 that has three states The start state is q1 The accept state is q2 The arrows going from one state to another are called transitions The output is either accept or reject. 8
9. 9. Finite Automata 0 1 0 1 q1 q2 q3 0,1 “1101”, 1. Start in state q1. 2. Read 1, follow transition from q1 to q2. 3. Read 1, follow transition from q2 to q2. 4. Read 0, follow transition from q2 to q3. 5. Read 1, follow transition from q3 to q2. 6. Accept because M1 is in an accept state q2 at the end of the input. 9
10. 10. Finite Automata 0 1 0 1 q1 q2 q3 0,1 strings M1 ? 1,01,11, and 0101010101. 100, 0100, 110000, and 0101000000. 10
11. 11. Formal Definition state diagrams , (formal definition) formal definition finite automata formal definition (notation) . 11
12. 12. Formal Definition formal definition finite automaton 5 set of state input alphabet rules for moving start state accept states 12
13. 13. Formal DefinitionA finite automaton is a 5-tuple (Q, Σ, δ, q0, F), where1. Q is a finite set called the states,2. Σ is a finite set called the alphabet,3. δ : Q x Σ → Q is the transition function,4. q0 ∈ Q is the start state, and5. F ⊆ Q is the set of accept states. 13
14. 14. Formal Definition 0 1 0 1 q1 q2 q3 0,1 We can describe M1 formally by writing M1 = (Q, Σ, δ, q1, F), where Q = { q1, q2, q3 } Σ = { 0, 1 } 0 1 δ is described as q1 q1 q2 δ(q1,0) = q1 δ(q1,1) = q2 q2 q3 q2 δ(q2,0) = q3 δ(q2,1) = q2 q3 q2 q2 δ(q3,0) = q2 δ(q3,1) = q2 q1 is the start state, and F = { q2 }. 14
15. 15. Formal Definition A M , A M L(M) = A M recognizes A M accepts A. , , (empty language ∅) 15
16. 16. Extended Transition Functionδ : Q x Σ → Q is the transition function δ(q, a) = “the state to which the machine M goes if it is in state q and receives input symbol a”δ*: Q x Σ* → Q is the extended transition function δ*(q, w) = “the state in which M ends up, if it begin in state q, and receives the string w of several symbols” 16
17. 17. Extended Transition Function : δ*(q0,w) = q6 a b a q0 …….. q6 w = ab…a 17
18. 18. Extended Transition FunctionDefinition: Let M = (Q, Σ, δ, q0, F) be a DFA. Define the function δ*: Q x Σ* → Qrecursively as follows.When q ∈ Q, w ∈ Σ*, and a ∈ Σ, 1. δ*(q, ε) = q 2. δ*(q, wa) = δ(δ*(q, w), a) 18
19. 19. Extended Transition Function 0 1 0 1 q1 q2 q3 0,1δ*(q1,010) δ*(q1, 010) = δ(δ*(q1,01), 0) δ*(q1, 01) = δ(δ*(q1,0), 1) δ*(q1,0) = δ(δ*(q1,ε), 0) δ*(q1,ε) = q1 19
20. 20. Formal Definition of Computation FA FA 20
21. 21. Formal Definition of Computation Let M = (Q, Σ, δ, q0, F) be a finite automaton Let w = w1w2…wn be a string where each wi is a member of the alphabet Σ. Then M accepts w if δ*(q0, w) ∈ F. We say that M recognizes language A if A = {w I M accepts w }. A language is called a regular language if some finite automaton recognizes it. 21
22. 22. Finite Automata automata automata ☺ automata"reader as automaton" method 22
23. 23. (1)alphabet {0, 1} FA 1 ? 1 23
24. 24. Example (2) qeven qodd 24
25. 25. Example (3) 1 0 25
26. 26. Example (3) 0 1 0 qeven qodd 1 26
27. 27. Example (4) 0 ( ε) 27
28. 28. Example (5) 0 1 0 qeven qodd 1 28
29. 29. The Regular OperationsDefinition Let A and B be languages. We define the regular operations union, concatenation, and star as follows. Union: A ∪ B = {x | x ∈ A or x ∈ B} Concatenation: A○B = {xy | x ∈ A and y ∈ B} Star: A* = {x1x2…xk | k ≥ 0 and each xi ∈ A}. 29
31. 31. The Regular Operations (closed) regular languages regular operations 31
32. 32. The Regular OperationsTheorem regular languages union A1 A2 regular languages, A1 ∪ A2 regular languagesProof Idea: A1 A2 regular finite automaton M1 A1 finite automaton M2 A2 finite automaton M A1 ∪ A2 M M1 M2 32
33. 33. The Regular OperationsProof Idea ( ): M M1 M2 M M1 M2 M1 M2 (M1 x M2) M M1 M2 M M1 M2 33 46: Introduction to the Theory of Computation
34. 34. 0 1 1 0M1 M2 1 0 q0 q1 q0 q1 0 1 0 1 M1 ∪ M2 0 1 q0 q0 q1 0 q0 q1 q0 q1 q0 q1 q1 q1 q0 0 0 q01 q00 1 0 q11 1 1 q10 34 1
35. 35. The Regular Operations Theorem regular languages concatenation A1 A2 regular languages A1 ○ A2 regular Proof Idea: union finite automata M1 M2 regular languages A1 A 2. 35
36. 36. The Regular Operations Proof Idea: (cont.) M 2 M1 M2 nondeterminism. 36
37. 37. FAFA FA 0,1 1 M2 0 q1 q3 0 0,1 M1 0,1 1q0 0 q0 q1 q2 0,1 0 1 1 1 q2 q4 q5 M1 M2 37
38. 38. FA : p q FAindistinguishable δ*(p, w) ∈ F implies δ*(q, w) ∈ F δ*(p, w) ∉ F implies δ*(q, w) ∉ F for all w ∈ Σ*. 38
39. 39. FA w ∈ Σ* δ*(p, w) ∈ F δ*(q, w) ∉ F, p qdistinguishable w indistinguishable u p w v w δ*(p, w) ∈ F implies δ*(q, w) ∈ F q 39
40. 40. FAIndistinguishability equivalence relations: 1. p R p 2. if p R q then q R p 3. if p R q then q R r then p R r 40
41. 41. FA FA indistinguishabledistinguishable 41
42. 42. FAProcedure: mark 1. 2. (p, q) p∈F q∉ F mark (p, q) distinguishable 3. mark (p, q) a ∈ Σ, δ(p, a) = pa δ(q, a) = qa (pa, qa) mark distinguishable mark (p, q) distinguishable. 42
43. 43. FA mark Q FA (disjointsubsets) :Q = {0,1,2,3,4,5,6,7}unmarked pairs = (1,2), (1,4), (2,4), (3,5),(3,7), (5,7) ( )disjoint subsets = {0}, {1,2,4}, {3,5,7}, {6} 43
44. 44. FAProcedure: reduce FA M = (Q, Σ, δ, q0, F), FA M = (Q, Σ, δ, q0, F)1. mark indistinguishable ( ).2. M indistinguishable q124 {1,2,4}.3. δ (ij..k, a) = lm…n qr ∈ {qi,qj,…,qk} qp ∈ {ql,qm,…,qn} δ (qr, a) = qp.4. q0 M 05. F i qi ∈ F. 44
45. 45. FA q1 1 0 0 0 0,1 1q0 q2 q4 0 1 j 1 q3 q1 q2mark q4 q3 q4 1 1 1 1 1: (q0,q4), (q1,q4), (q2,q4), (q3,q4) q0 q1 q2 q3 i 45
46. 46. FA 0 1 marked q0 q1 q3 (q0,q4) q1 q2 q4 (q1,q4) q1 (q2,q4) 1 q2 q1 q4 0 (q3,q4) 0 0 0,1 q3 q2 q4 1q0 q2 q4 q4 q4 q4 → (q0,q4), (q2,q4) 0 1 j 1 q3 q1 q2 q3 q4 1 1 1 1 q0 q1 q2 q3 i 46
47. 47. FA 0 1 marked q0 q1 q3 (q0,q4) q1 q2 q4 (q1,q4) q1 (q2,q4) 1 q2 q1 q4 0 (q3,q4) 0 0 0,1 q3 q2 q4 1q0 q2 q4 q4 q4 q4 → (q1,q4), (q3,q4) 0 1 j 1 q3 q1 q2 q3 q4 1 1 1 1 2: (q0,q1), (q0,q2), (q0,q3) q0 q1 q2 q3 i 47
48. 48. FA 0 1 marked q0 q1 q3 (q0,q4) q1 q2 q4 (q1,q4) q1 (q2,q4) 1 q2 q1 q4 0 (q3,q4) 0 0 0,1 q3 q2 q4 1q0 q2 q4 q4 q4 q4 → (q0,q1), (q0,q2), (q0,q3), (q0,q4) 0 1 j 1 q3 q1 2 q2 2 q3 2 q4 1 1 1 1 2: (q0,q1), (q0,q2), (q0,q3) q0 q1 q2 q3 i 48
49. 49. FA 0 1 q0 q1 q3 q1 q2 q4 q1 1 q2 q1 q4 0 0 0 0,1 q3 q2 q4 1q0 q2 q4 q4 q4 q4 0 1 1 q3 q1 2 q2 2 x q3 2 x xUnmarked pairs = (q1,q2), (q1,q3), (q2,q3) q4 1 1 1 1 q0 q1 q2 q3 49
50. 50. FAQ = {q0, q1, q2, q3, q4}Unmarked pairs = (q1,q2), (q1,q3), (q2,q3)The disjoint subsets = {q0}, {q1,q2,q3}, {q4} 0 1 0 0,1 q0 q1 q3 q1 q2 q4 0,1 1 q0 q123 q4 q2 q1 q4 q3 q2 q4 q4 q4 q4 50