450 likes | 718 Views
Finite Automata. Definition. A finite automaton is a collection of three things: 1- A finite set of states, one of which is designed as the initial state, called the start state , and some (maybe none) of which are designed as final states . 2- An alphabet of possible input letters.
E N D
Finite Automata Dr. Shakir Al Faraji
Definition A finite automaton is a collection of three things: 1- A finite set of states, one of which is designed as the initial state, called the start state, and some (maybe none) of which are designed as final states. 2- An alphabet of possible input letters. Dr. Shakir Al Faraji
Definition – Cont. 3- A finite set of transitions that tell for each state and for each letter of the input alphabet which state to go to next. Dr. Shakir Al Faraji
FA – mathematical notation A deterministic finite automaton (or DFA) can be formally defined as a 5-tuple ( Q , , T, qD, F ) where Q is a finite set of states. is the alphabet (defining what set of input strings the automaton operates on). Dr. Shakir Al Faraji
FA – mathematical notation T:QQ is the transition function. qD Q is the starting state. FQ is a set of final (or accepting states). Operation of the DFA begins at qD, and movement from state to state is governed by the transition function T. T must be defined for every possible state in and every possible symbol in Q. Dr. Shakir Al Faraji
FA – mathematical notation A DFA can be represented visually as a directed graph. Circular vertices denote states, and the set of directed edges, labeled by symbols in , denotes T. The transition function takes the first symbol of the input string as, and after the transition this first symbol is removed. Dr. Shakir Al Faraji
FA – mathematical notation If the input string is (the empty string), then the operation of the DFA is halted. If the final state when the DFA halts is in F, then the DFA can be said to have accepted the input string it was originally given. The starting state qD is usually denoted by an arrow or (minus sign) pointing to it that points from no other vertex. States in F are usually denoted by double circles or plus sign. Dr. Shakir Al Faraji
FA – Examples DFAs represent regular languages, and can be used to test whether any string is in the language it represents. Consider the following regular language over the alphabet = { a, b } (represented by the regular expression aa*b Dr. Shakir Al Faraji
FA – Examples This language can be represented by the following DFA. Dr. Shakir Al Faraji
FA – Examples If given the string aaab as input, operation of the DFA above is as follows: • The first a is removed from the input string, so the edge from 0 to 1 is followed. • The resulting input string is aab. For each of the next two as, the edge is followed from 1 to itself. • Finally, b is read from the input string and the edge from 1 to 2 is followed. Dr. Shakir Al Faraji
FA – Examples Since the input string is now , the operation of the DFA halts. Since it has halted in the accepting state 2, the string aaab is accepted as a sentence in the regular language implemented by this DFA. Dr. Shakir Al Faraji
FA – Examples Now let us trace operation on the string aaaba. Execution is as above, until state 2 is reached with a remaining in the input string. The edge from 2 to 3 is then followed and the operation of the DFA halts. Since 3 is not an accepting state for this DFA, aaaba is not accepted(rejected). Dr. Shakir Al Faraji
FA – Examples the following regular language over the alphabet = { a, b } (represented by the regular expression (a+b)*b(a+b)* Dr. Shakir Al Faraji
FA – Examples Consider the following transition table Dr. Shakir Al Faraji
a Y X- a b b Z+ a b FA – Examples Dr. Shakir Al Faraji
a + a,b - b FA – Examples Dr. Shakir Al Faraji
a + a,b - b FA – Examples (a+b)(a+b)* Dr. Shakir Al Faraji
y a,b b - a Z+ a,b FA – Examples a(a+b)* Dr. Shakir Al Faraji
FA – Examples (a+b)*(aa+bb)(a+b)* Dr. Shakir Al Faraji
2 a a a,b 4+ a b 1- b 3 b FA – Examples (a+b)*(aa+bb)(a+b)* Dr. Shakir Al Faraji
a,b a,b 4 a a,b a,b 1- 2 3 b 5+ FA – Examples Dr. Shakir Al Faraji
FA – Examples (aab+abb+bab+bbb)(a+b)* Dr. Shakir Al Faraji
FA – Examples (aab+abb+bab+bbb)(a+b)* (a+b)(a+b)b(a+b)* Dr. Shakir Al Faraji
FA – Examples a*(a*ba*ba*ba*)*(a+a*ba*ba*ba*) Dr. Shakir Al Faraji
a b 1- 2 b a b a b 4 a 3+ FA – Examples a*(a*ba*ba*ba*)*(a+a*ba*ba*ba*) Dr. Shakir Al Faraji
FA – Examples (a+b)*a Dr. Shakir Al Faraji
a a b + - b FA – Examples (a+b)*a Dr. Shakir Al Faraji
FA – Examples (a+b)*a + Dr. Shakir Al Faraji
b a ± a b FA – Examples Dr. Shakir Al Faraji
FA – Examples b*ab*(ab*ab*)* Dr. Shakir Al Faraji
a b + - a b FA – Examples Dr. Shakir Al Faraji
FA – Examples (a+b)*aa(a+b)* Dr. Shakir Al Faraji
a a a,b b + - b FA – Examples Dr. Shakir Al Faraji
FA – Examples a(a+b)*b + b(a+b)*a Dr. Shakir Al Faraji
a b b a + b b a - b a + a FA – Examples Dr. Shakir Al Faraji
FA – Examples [aa+bb+(ab+ba)(aa+bb)*(ab+ba)]* Dr. Shakir Al Faraji
a 2 1± a b b b b a 4 3 a FA – Examples Dr. Shakir Al Faraji
FA – Examples Consider the set of all strings that, viewed as natural numbers in unsigned binary notation, represent numbers divisible by 3. Dr. Shakir Al Faraji
1 0 R=1 ± 1 R=0 0 0 R=2 1 FA – Examples Dr. Shakir Al Faraji
END Dr. Shakir Al Faraji