Upcoming SlideShare
×

# Final fa part1

363 views
259 views

Published on

Published in: Technology
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
363
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
28
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Final fa part1

1. 1. Finite Automata ● What are machines? – ● What are constituents of a machine? – ● Automation of various steps. Each step takes an input and produces an output. Machine can be defined as – Set of states which take input in specified format and produce desired output.
2. 2. Finite Automata ● ● ● Finite Automata (FA) is a language recognizing machine. Accepts all words of the language for which it is built. Rejects all other words.
3. 3. Finite Automata ● Five tuple machine defined as M = (Q, ∑, ∂, Q0, F) – Q: Set of states such as Q0, Q1, Q2, Q3..... Qn. – ∑: Alphabet of the language for which the machine is built such as {a, b} or {0, 1}. – ∂: Transition function or Next Move function. It maps Q X ∑ -> Q. – ∂ (Qi, a) = Qj where – 'Qi' -> current state – 'a' -> current input symbol – 'Qj' -> next state Q0 -> start state. – F -> collection of final states. ●
4. 4. Finite Automata ● Example of a Switch to “switch on” a fan. – Q = {OFF, ON} – ∑ = {push} – ∂ has two rules ● ● ∂ (OFF, push) = ON. ∂ (ON, push) = OFF. – Q0 = {OFF} – F = {ON}
5. 5. Finite Automata ● FA is a collection of 3 things: – A finite set of states, one of them is the start state and some (maybe) none as the final states. – An alphabet ∑, which consists of all possible input letters. – A finite set of transition rules which direct from each state and for each particular input letter which state to go next.
6. 6. Finite Automata We discuss an example here. Following are two representations of an FA: ● ● Transition Table Transition Graph Transition Table a b -x y z y x z +z z z Transition Graph
7. 7. Finite Automata Depiction of initial and final states for an FA can be defined in several ways: ● Use a '-' symbol for initial state and a '+' symbol for final state. ● Use a '->' symbol for initial state and double encircle the final state. ● Write 'start' for the initial state and 'final' for the final state.
8. 8. Finite Automata FA has ● 3 states labelled x, y and z ● ∑ = {a,b} ● ● State x is designated as the start state. State z is designated as the final state.
9. 9. Finite Automata The transition table as well as the transition diagrams clearly define the ∂ function. It is a depiction of the following rules: Rule 1: If we are in state x and we encounter an input 'a' then we go to state y. Rule 2: If we are in state x and we encounter an input 'b' then we go to state z. Rule 3: If we are in state y and we encounter an input 'a' then we go to state x. Rule 4: If we are in state y and we encounter an input 'b' then we go to state z. Rule 5: If we are in state z and we encounter an input 'a' then we remain in state z. Rule 6: If we are in state z and we encounter an input 'b' then we remain in state z. Transition Graph Transition Table a b -x y z y x z +z z z
10. 10. Finite Automata ● To understand the language dry run the input – “aaa” – “abba”
11. 11. Finite Automata ● ● ● If after complete string traversal, we do not reach the “final state”, the string is then REJECTED by the FA. If after complete string traversal, we reach the “final state”, the string is then ACCEPTED by the FA. Thus, FA is a language recognizer, which accepts all the words in the language for which it is defined and rejects all the other strings.
12. 12. Finite Automata ● What language does this FA represents? Regular Expression for the language of the FA: (a + b)* b (a + b)*
13. 13. Finite Automata ● A finite automata is – – ● “Deterministic” in nature. Finite Note: By convention we say that the null word (λ) starts as well as ends in the initial state.
14. 14. Finite Automata ● Analyse the FA given below Regular Expression for the language of the FA: (a + b) (a + b)*
15. 15. Finite Automata ● What is the language of the FA given below? Regular Expression for the language of the FA: (a + b)*
16. 16. Finite Automata ● What is the language accepted by the FA which has no final state? Such FA's accept “no language”.
17. 17. Finite Automata ● An interesting example. Identify the language. This FA also accepts “no language”.
18. 18. Finite Automata ● What is the language of the FA given below? This FA accepts all words of even length over the alphabet ∑ = {a,b}.
19. 19. Finite Automata ● Draw an FA which accepts all the words in the language a (a + b)* where ∑ = {a,b}. First draw a diagram which accepts the minimum length word which is 'a'.
20. 20. Finite Automata ● ● ● Now complete all the other transitions. For words starting from 'b', we introduce a new state y, which is a “trap state” . Trap State – On reaching trap state, we can never go back to the other states of the FA and accept the word. – Reaching a trap state means we “reject” the word. – We have only one trap state for the whole FA. – We need to complete the transitions of the trap state too.
21. 21. Finite Automata ● ● ● ● Draw an FA which accepts all the words that have a double 'a' or a double 'b' in them where ∑ = {a,b}. Two minimum length words 'aa' and 'bb'. First draw an FA which accepts these two words. All the states signify something: – State 1: Neither an 'a' nor a 'b' has occurred. – State 2: One 'a' has occurred. – State 3: One 'b' has occurred. – State 4: Either two a's or two b's have occurred in continuation.
22. 22. Finite Automata ● Now complete the remaining transitions.
23. 23. Finite Automata ● Examine the following FA and find out the language represented by it. FA accepts all the words which have their third letter as 'b'. The regular expression is (a+b) (a+b) (b) (a+b)*.
24. 24. Finite Automata ● Construct an FA that accepts only the word 'baa' where ∑ = {a,b}. First draw the word 'baa'. Now complete the FA.
25. 25. Finite Automata Note that there is only one “trap state” for the whole FA.
26. 26. Finite Automata ● Draw an FA which accepts only the word λ where ∑ = {a,b}. Now complete the transitions.
27. 27. Finite Automata ● FA which accepts only the word λ where ∑ = {a,b}.
28. 28. Finite Automata ● Draw an FA for all the words which end in 'a' where ∑ = {a,b}. Draw the minimum word i.e. 'a'.
29. 29. Finite Automata ● Complete the transitions.
30. 30. Finite Automata ● ● Draw an FA for all the words which have a double 'a' in them where ∑ = {a,b}. Significance of each state: – State 1: Zero a's are encountered consecutively. – State 2: One 'a' is encountered consecutively. – State 3: Double 'a' has been encountered.
31. 31. Finite Automata ● Now complete all the transitions.
32. 32. Finite Automata ● Draw an FA for all the words with different first and last letters where ∑ = {a,b}.
33. 33. Finite Automata ● Now complete all the transitions.