Successfully reported this slideshow.
Upcoming SlideShare
×

# Introduction to fa and dfa

Introduction to finite automata and dfa

See all

### Related Audiobooks

#### Free with a 30 day trial from Scribd

See all
• Full Name
Comment goes here.

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

### Introduction to fa and dfa

1. 1. THEORY OF COMPUTATION Lecture One: Automata Theory 1Er. Deepinder KaurAutomata Theory
2. 2. Theory of Computation In theoretical computer science and mathematics, the theory of computation is the branch that deals with how efficiently problems can be solved on a model of computation, using an algorithm. The field is divided into three major branches: • automata theory, • computability theory • computational complexity theory. Er. Deepinder Kaur 2Automata Theory
3. 3. Automata theory • The word “Automata“ is the plural of “automaton" which simply means any machine. • automata theory is the study of abstract machines and problems they are able to solve. • Automata theory is closely related to formal language theory as the automata are often classified by the class of formal languages they are able to recognize. Er. Deepinder KaurAutomata Theory 3
4. 4. Abstract Machine • An abstract machine, also called an abstract computer, is a theoretical model of a computer hardware or software system used in Automata theory. Er. Deepinder KaurAutomata Theory 4
5. 5. Applications of Automata • A variety of properties concerning the models, grammars, and languages will be proven. • These algorithms form the basis of tools for processing languages, e.g., parsers, compilers, assemblers, etc. • Other algorithms will form the basis of tools that automatically construct language processors, e.g., yacc, lex, etc. – Note that our perspective will be similar to, yet different from a compiler class. • Additionally, some things will be proven to be non-computable, e.g., the enhanced compiler. Automata Theory 5Er. Deepinder Kaur
6. 6. Automaton • An automaton is an abstract model of a digital computer • It has a mechanism to read input (string over a given alphabet, e.g. strings of 0’s and 1’s on Σ = {0,1}) written on an input file. • A finite automaton has a set of states • Its control moves from state to state in response to external “inputs” Automata Theory 6Er. Deepinder Kaur
7. 7. Automaton • With every automaton, a transition function is associated which gives the next state in terms of the current state • An automaton can be represented by a graph in which the vertices give the internal states and the edges transitions • The labels on the edges show what happens (in terms of input and output) during the transitions Automata Theory 7Er. Deepinder Kaur
8. 8. Components of an automaton • Input file : Contains strings of input symbols • Storage unit: consists of an unlimited number of cells, each capable of holding a single symbol from an alphabet • Control unit : can be in any one of a finite number of internal states and can change states in defined manner Automata Theory 8Er. Deepinder Kaur
9. 9. Some Terms used in automaton theory • Alphabets-Everything in mathematics is based on symbols. This is also true for automata theory. Alphabets are defined as a finite set of symbols. An example of alphabet is a set of decimal numbers ∑={0,1,2,3,4,5,6,7,8,9} • Strings- A string is a finite sequence of symbols selected from some alphabet If ∑ {a,b} is an alphabet then abab is string over alphabet ∑. A string is generally denoted by w. The length of string is denoted by | w| • Empty string is string with zero occurrence of symbols . This string is represented by є Automata Theory 9Er. Deepinder Kaur
10. 10. • The set of strings, including empty, over an alphabet ∑ is denoted by ∑*. • ∑+ = ∑* -{є} • Languages-A set of strings which are chosen from some ∑*, where ∑ is a particular alphabet, is called a language . If ∑ is an alphabet, and L subset of ∑*, then L is said to be language over alphabet ∑. For example the language of all strings consisting of n 0’s followed by n 1’s for some n>=0: {є,01,0011,000111,-------} Automata Theory 10Er. Deepinder Kaur
11. 11. • Langauge in set forms- {w|some logical view about w} e.g {an bn |n>=1} • Kleene closure- Given an alphabet, a language in which any string of letters from ∑ is a word, even the null string, is called closure of the alphabet . It is denoted by writing a star, after the name of alphabet as a superscript ∑*. Automata Theory 11Er. Deepinder Kaur
12. 12. Finite Automaton • One of the powerful models of computation which are restricted model of actual computer is called finite automata. These machines are very similar to CPU of a computer .They are restricted model as they lack memory. • Finite automation is called finite because number of possible states and number of letter in alphabet are both finite and automation because the change of state is totally governed by the input. Automata Theory 12Er. Deepinder Kaur
13. 13. 2.2 Deterministic Finite Automata – graphic model for a DFA 13Automata Theory Er. Deepinder Kaur
14. 14. Main parts of pictorial representation of Finite machine • Strings are fed into device by means of an input tape which is divided into square with each symbol in each square. • Main part of machine is a black box which serve that what symbol is written at any position on input tape by means of a movable reading head • P0,p1,p2,p3,p4 are the states in finite control system and x and y are input symbols. • At regular intervals, the automation reads one symbol from input tape and then enters in a new state that depends only on current state and the symbol just read. Automata Theory 14Er. Deepinder Kaur
15. 15. Main parts of pictorial representation of Finite machine • After reading an input symbol, reading head moves one square to the right on input tape so that on next move, it will read the symbol in next tape square. This process is repeated again and again • Automation then indicates approval or disapproval • If it winds up in one of the final states, the input string is considered to be accepted. The language accepted by the machine is the set of strings it accepts. Automata Theory 15Er. Deepinder Kaur
16. 16. DFA: Deterministic Finite Automaton • An informal definition (formal version later): – A diagram with a finite number of states represented by circles – An arrow points to one of the states, the unique start state – Double circles mark any number of the states as accepting states – For every state, for every symbol in Σ, there is exactly one arrow labeled with that symbol going to another state (or back to the same state) Automata Theory Er. Deepinder Kaur
17. 17. Finite Automata FA • Its goal is to act as a recognizer for specific a language/pattern. • Any problem can be presented in form of decidable problem that can be answered by Yes/No. • Hence FA (machine with limited memory) can solve any problem. 17Automata Theory Er. Deepinder Kaur
18. 18. Deterministic Finite Automata DFA FA = “a 5-tuple “ (Q, Σ, , q0, F) 1. Q: {q0, q1, q2, …} is set of states. 2. Σ: {a, b, …} set of alphabet. 3. (delta): represents the set of transitions that FA can take between its states.  : Q x Σ→Q Q x Σ to Q, this function:  Takes a state and input symbol as arguments.  Returns a single state.  : Q x Σ→Q 4. q0 Q is the start state. 5. F Q is the set of final/accepting states. 18 ∈ ⊂ Automata Theory Er. Deepinder Kaur
19. 19. Transition function  : Q x Σ→Q Maps from domain of (states, letters) to range of states. 19 (q0, a) (q2, b) (q1, b) q1 q2 q3 Automata Theory Er. Deepinder Kaur
20. 20. Transition function  • : Q x Σ→Q • Maps from domain of (states, letters) to range of states. 20 (q0, a) (q2, b) (q1, b) q1 q2 q3 Automata Theory Er. Deepinder Kaur
21. 21. How does FA work? 1. Starts from a start state. 2. Loop Reads a sequence of letters 1. Until input string finishes 2. If the current state is a final state then Input string is accepted. 1. Else Input string is NOT accepted. • But how can FA be designed and represented? 21Automata Theory Er. Deepinder Kaur
22. 22. Transition System FA = “a 5-tuple “ (Q, Σ, , q0, F) 1. Q: {q0, q1, q2, …} is set of states. 2. Σ: {a, b, …} set of alphabet. 3. (delta): represents the set of transitions that FA can take between its states.  : Q x Σ→Q Q x Σ to Q, this function:  Takes a state and input symbol as arguments.  Returns a single state.  : Q x Σ→Q 4. q0 Q is the start state. 5. F Q is the set of final/accepting states. 22 ∈ ⊂ Automata Theory Er. Deepinder Kaur
23. 23. Transition System Transition Diagrams Transition Tables 23Automata Theory Er. Deepinder Kaur
24. 24. Transition Diagram Notations • If any state q in Q is the starting state then it is represented by the circle with arrow as • Nodes corresponding to accepting states are marked by a double circle q Automata Theory 24Er. Deepinder Kaur
25. 25. Transition Diagram Can be represented by directed labeled graph/Transition table Vertex is a state States= nodes Starting/Initial state denoted by circle and arrow/- Final state(s) denoted by two concentric circles/+ Other states with circle Transition function  =directed arrows connecting states. 25 S1 S2 b a a,b Automata Theory Er. Deepinder Kaur
26. 26. Alternative Representation: Transition Table 26 0 1 A A B B A C C C C Rows = states Columns = input symbols Final states starred * *Arrow for start state Automata Theory Er. Deepinder Kaur
27. 27. Acceptability of a string A string is accepted by a transition system if • There exist a path from initial state to final state • Path traversed is equal to w 27Automata Theory Er. Deepinder Kaur
28. 28. Example1.1 • Build an FA that accepts only aab 28 S1 - S3 a S2 a b + S4 a b S1 S2 ? S2 S3 ? S3 ? ? S4 ? ? Automata Theory Er. Deepinder Kaur
29. 29. Example withTransition Table 29 0 1 A C B B D A C A D D B C * Check for 110101 Automata Theory Er. Deepinder Kaur
30. 30. Example withTransition Table 30 Solution:- (A,110101)= (B,10101) (A,0101) (C,101) (D,01) (B,1) A*Automata Theory Er. Deepinder Kaur
31. 31. Automata Theory 31 Properties of transition function 1. (q,λ)=q • It comes back to same state • It requires an input symbol to change the state of a system. 2. (q,aw)=((q,a),w) (q,w,a)=((q,w),a) Er. Deepinder Kaur
32. 32. Facts in designing FA First of all we have to analyze set of strings. Make sure that every state is check for output state and for every input symbol from given set. No state must have two different outputs for single input symbol There must be one initial and atleast one final state in FA 32Automata Theory Er. Deepinder Kaur
33. 33. Language of a DFA • Automata of all kinds define languages. • If A is an automaton, L(A) is its language. • For a DFA A, L(A) is the set of strings labeling paths from the start state to a final state. • Formally: L(A) = the set of strings w such that δ(q0, w) is in F. 33Automata Theory Er. Deepinder Kaur
34. 34. Language • A language is a set of strings. For example, {0, 1}, {all English words}, {0, 0, 0, ...} are all languages. Automata Theory 34Er. Deepinder Kaur
35. 35. Example #8: • Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ* , and Σ+ . For {}: For Σ* : For Σ+ : Er. Deepinder Kaur 0/1 q0 0/1 q0 0/1 q0 q1 0/1 Automata Theory 35
36. 36. Example: Design a FA that accepts set of strings such that every string ends in 00, over the alphabet {0,1} i,e ∑={0, 1} Inorder to design any FA, first try to fulfill the minimum condition. Start 0 0 0 Being DFA, we must check every input symbol for output state from every state. So we have to decide output state at symbol 1 from q0,q1 and q2. Then it will be complete FA q0 q1 q2 Automata Theory 36Er. Deepinder Kaur
37. 37. • 1 0 0 start 0 1 1 q0 q1 q2q2 Automata Theory 37Er. Deepinder Kaur
38. 38. Ex 2 – • Construct a DFA that accepts a’s and b’s and ‘aa’ must be substring 38Automata Theory Er. Deepinder Kaur
39. 39. Example: String in a Language 39 Start a 20 1 a Minimal condition : aa Automata Theory Er. Deepinder Kaur
40. 40. Example: String in a Language 40 Start There may be aabbaa.bbbbaa,aa,aab,aabb,…. a 20 1 a b Automata Theory Er. Deepinder Kaur
41. 41. Example: String in a Language 41 Start a b A CB a b a,b . Automata Theory Er. Deepinder Kaur
42. 42. Ex : (0+1)*00(0+1)* • Idea: Suppose the string x1x2 ···xn is on the tape. Then we check x1x2, x2x3, ..., xn-1xn in turn. • Step 1. Build a checker 0 0 Automata Theory 42Er. Deepinder Kaur
43. 43. • Step 2. Find all edges by the following consideration: Consider x1x2. • If x1=1, then we give up x1x2 and continue to check x2x3. So, we have δ(q0, 1) = q0. • If x1x2 = 01, then we also give up x1x2 and continue to check x2x3. So, δ(q1, 1) = δ(q0, 1) =q0. • If x1x2 = 00, then x1x2··· xn is accepted for any x3···xn. So, δ(q2,0)=δ(q2,1)=q2. Automata Theory 43Er. Deepinder Kaur
44. 44. (0+1)*00(0+1)* 0 0 0 1 1 1 Automata Theory 44Er. Deepinder Kaur
45. 45. Ex 1 All words that start with “a” over the alphabet {a,b} a(a+b)* Automata Theory 45 1 2b a 3 a,b a,b3 Er. Deepinder Kaur
46. 46. Ex3 • All words that start with triple letter (aaa+bbb)(a+b)* Automata Theory 46Er. Deepinder Kaur
47. 47. Ex3 Automata Theory 47 1- 2a 3 a,b 4 b 5 b 6+ b a a Er. Deepinder Kaur
48. 48. Ex4 • All words with even count of letters having “a” in an even position from the start, where the first letter is letter number one. (a+b)a((a+b)a)* Automata Theory 48Er. Deepinder Kaur
49. 49. Ex4 Automata Theory 49 - a,b Er. Deepinder Kaur
50. 50. EX5:Construct DFA to accept (0+1)* 0 1 Automata Theory 50Er. Deepinder Kaur
51. 51. Ex 6:Construct DFA to accept 00(0+1)* 0 0 0 11 1 0 1 Automata Theory 51Er. Deepinder Kaur
52. 52. (0+1)*(00+01) 0 0 1 1 1 0 0 1 Automata Theory 52Er. Deepinder Kaur
53. 53. Construct a FA that accepts set of strings where the number of 0s in every string is multiple of 3 over alphabet ∑={0,1} 1 1 1 start 0 0 0 As 0 existence of 0 is also multiple of 3, we have to consider starting state as the final state. q1 q2q0 Automata Theory 53Er. Deepinder Kaur
54. 54. Design FA which accepts set of strings containing exactly four 1s in every string over alphabet ∑={0,1} 1 q2q4q0 q1 q2 1 1 q3 1 0 0 0 0 0 q5 0/1 star t 1 q5 is called the trap state or dead state. Dead states are those states which transit to themselves for all input symbols. Automata Theory 54Er. Deepinder Kaur
55. 55. Design a FA that accepts strings containing exactly one 1 over alphabet {0,1}. Also draw the transition table for the FA generated q2q2q1 1 0 0 q3 0/1 1 start q3 is the dead state Automata Theory 55Er. Deepinder Kaur
56. 56. Transition table for previous problem δ/∑ 0 1 q1 q1 q2 *q2 q2 q3 q3 q3 q3 Non final state that transit in self loop for all inputs Automata Theory 56Er. Deepinder Kaur
57. 57. Design an FA that accepts the language L={w ϵ (0,1)*/ second symbol of w is ‘0’ and fourth input is ‘1’} q0 q3q1 q2 0 1 1/0 1 1/0 0 1/0 q5 0/1 start q4 Automata Theory 57Er. Deepinder Kaur
58. 58. Design DFA for the language L={w ϵ (a,b)*/nb(w) mod 3 > 1} As given in the language, this can be interpreted that number of b mod 3 has to be greater than 1 and there is no restriction on number of a’s. Thus it will accept string with 2 bs,5 bs, 8bs and so on. q0 q1 q2 b b a a a b star t Q={q0,q1,q2} F={q2} Automata Theory 58Er. Deepinder Kaur
59. 59. Design FA over alphabet ∑= {0,1} which accepts the set of strings either start with 01 or end with 01 q0 q1 q3 q4 q2 0 1 1/0 q5 1 0 1 0 1 0 0 1 start Automata Theory 59Er. Deepinder Kaur
60. 60. Example #4: • Give a DFA M such that: L(M) = {x | x is a string of 0’s and 1’s and |x| >= 2} Er. Deepinder Kaur q1 q0 q2 0/1 0/1 0/1 Automata Theory 60
61. 61. Example #5: • Give a DFA M such that: L(M) = {x | x is a string of (zero or more) a’s and b’s such that x does not contain the substring aa} Er. Deepinder Kaur q2q0 a a/b a q1 b b Automata Theory 61
62. 62. Example #6: • Give a DFA M such that: L(M) = {x | x is a string of a’s, b’s and c’s such that x contains the substring aba} Er. Deepinder Kaur q2q0 a a/b b q1 b a b q3 a Automata Theory 62
63. 63. DFA Practice • Design a FA which accepts the only input 101 over input set {0,1} • Strings that end in ab • Strings that contain aba • String start with 0 and ends with 1 over {0,1} • Strings made up of letters in word ‘CHARIOT’ and recognize those strings that contain the word ‘CAT’ as a substringEr. Deepinder Kaur 63Automata Theory

### Be the first to comment

Apr. 9, 2017
• #### TahminaShopna

Apr. 27, 2017

May. 5, 2017
• #### surajtongbra

Jun. 30, 2017
• #### rahul1997prince

Jul. 13, 2017
• #### KhawarTareen

Sep. 25, 2017
• #### saurabhgupta779

Oct. 26, 2017
• #### JansariKajal

Nov. 10, 2017
• #### AshleyPawar

Dec. 25, 2017
• #### RiyaSemnan

Jan. 23, 2018

Jan. 26, 2018
• #### Bhth

Feb. 2, 2018

Feb. 19, 2018
• #### hendramarcos3

Apr. 10, 2018
• #### ShivaniDhole1

Aug. 17, 2018
• #### ShivaniDhole1

Aug. 17, 2018

Oct. 1, 2018
• #### LogeshwariLogeshwari

Feb. 13, 2019
• #### musahassan5

Mar. 13, 2019
• #### NurnabiBabul

Oct. 10, 2020

Introduction to finite automata and dfa

Total views

18,294

On Slideshare

0

From embeds

0

Number of embeds

6

753

Shares

0