3. Section 2.1
3. Section 2.1
Finite Automata
Section 2.1
1
Automaton
(Accepter)
2
Automata
(Basic classification)
Automata as an Acceptor
Automata Control unit is a state machine
defined by a finite number of states
Storage: No temporary storage
3
Finite Accepter
4
Deterministic Finite Accepter (DFA)
DFA:
• finite number of states
• no external storage
• Deterministic configurations
6
Example
= {a,b}
Q = {q0, q1, q2, q3, q4, q5}
Initial sate = q0
Final state = {q4}
: Q X Q
Transition function defines the next state of the control unit
For example:
(q0, a)= q1
(q0, b)= q5
7
DFA
A deterministic automaton is one in which each move is
uniquely determined by the current configuration. If we
know the internal state, the input, we can predict the
future behavior of the automaton exactly.
(For example, from state q0 on input b, the next state is
q5; defined by (q0, b)= q5)
9
Transition Graph
Example of Finite Accepter
10
Finite Acceptor
11
Transition Function
can be represented as a
Transition Table or as Transition Graph
12
Example 1: DFA operation on an input string
13
Reading the Input
14
15
16
17
18
Example 2: DFA rejection on a string
19
20
21
22
23
Example 3: DFA operation – another rejection
24
25
Extended Transition Function
26
Extended Transition Function *
The Extended Transition Function * gives the
state of the automaton after reading a string
27
Examples of extended transition functions
28
29
Observation - Walk
Observation: There is a walk from q to q’
with label w
30
Example - Walk
Example: with label abbbaa
31
Recursive Definition
32
Recursive definition - Example
33
Languages Accepted by DFAs
Take DFA M
Definition:
The language L(M) contains
all input strings accepted by M
34
Examples of L(M)
L(M) = {abba} given the following M
35
Formal definition of L(M)
For a DFA M = (Q, ,, q0,F)
Language accepted by M
L(M) = {w * | *(q0,w) F}
36
Another Observation
For a DFA M = (Q, ,, q0,F)
Language rejected by M
𝐿(𝑀) = {w * | *(q0,w) F}
37
Constructing a DFA
Given a given a description of the language in
words, Construct a DFA.
Note:
• The DFA should only accept only the string in the
language.
• The DFA should account for all possible inputs
over = {a,b}. i.e., any string from
*={,a,b,aa,ab,ba,bb,aaa,aba,abb…abba,abbb…}
• The DFA has to account for the infinite number
of strings with finite number of states. (Our
thinking process would be similar to designing an
algorithm for programming in Java)
Constructing a DFA (Examples)
.
Constructing a DFA (Example 1)
.
Constructing a DFA (Example 2)
L(M) = {,ab,abba}
(Note that the automaton M has F= {q0,q2,q4}
43
Constructing a DFA (Example 3)
M accepts all strings consisting of
arbitrary numbers of a’s followed by a
single b. In set notation,
L(M) = {anb|n 0}
44
Constructing a DFA (Example 4)
M accepts all strings consisting of arbitrary
numbers of a’s followed by a single b. In set
notation,
L(M) = {anb|n 0}
Note: A trap state is a state from which the automaton can never
“escape”.
45
Constructing a DFA (Example 5)
L(M)={all strings with prefix ab}
46
L(M)={all strings with prefix ab}
47
Constructing a DFA (Example 6)
L(M) = { all strings with substring 001}
= {0,1}
48
Another Example
L(M) = { all strings with substring 001}
= {0,1}
49
Constructing a DFA (Example 7)
L(M) = { all strings without substring 001}
= {0,1}
50
Classification or Hierarchy or Family
Languages can be classified based on certain
properties of Grammar or Automata.
All the languages which is accepted by some
finite automaton are classified as a family
of languages. These are referred to as
Regular languages.
We will discuss corresponding hierarchy with
Grammars in the next chapter.
We will discuss the other level in the
language hierarchy later in the course.
51
Regular Languages
52
Examples of regular languages
{abba}
{, ab, abba}
{anb|n 0}
{all strings with prefix ab}
{all strings that contain ab}
{all strings without substring 001}
53
Another example of a Language
The language L = {awa|w{a,b}*}
is regular. i.e., all strings that begin and end
with an “a”.
L=L(M)
54
Non regular languages
There exist languages which are not Regular
Example: L ={anbn|n 0}
55
Homework 2.1
I) Do exercises : #1 to #6
III) Given the alphabet as {0, 1}, write a DFA for the following
regular languages.
(i) Give the complete description of the DFA with transition function
as a table.
(iii) Give two examples that are not in the Language that is not
accepted. Describe using the extended transition function on a string
(of length >=4) recursively using transitions one symbol at a time.
56
Homework 2.1 (continued)
a) L = {w | w has exactly a single 1}
b) L = {w | w has at least one 1}
c) L = {w | w contains the string 01 as a substring}
d) L = {w | w is a string of odd length}
e) L = {w | the length of w is a multiple of three}
f) L = {w | w starts and ends with the same symbol}
g) L = {w | w ends in 11}
h) L = {w | w has at least one pair of consecutive zeroes}
i) L = {w | w has no pair of consecutive zeroes}
j) L = {w | w contains the substring 011}
k) L = {w | w is a string with an even number of 0’s}
l) L = {w | w does not contain the substring 110}
m) L = { w | w does not have even number of 1’s}
57