You are on page 1of 23

KINGDOM OF SAUDI ARABIA

Ministry of Higher Education


Northern Borders University
College of Science and Arts
Department of Computer Sciences and Information
Technology

Theory of Computation

instructor :Ammar Mohammed Ali


Finite Automata
Introduction
 Informally, a state diagram that comprehensively captures
all possible states and transitions that a machine can take
while responding to a stream or sequence of input symbols .

 Finite automata are finite collections of states with


transition rules that take you from one state to another.

 Deterministic Finite Automata (DFA)


 The machine can exist in only one state at any given time
 Non -deterministic Finite Automata (NFA)
 The machine can exist in multiple states at the same time
Representation of Finite Automata
Finite Automata can be represented visually by state
diagrams:
q a
0 F
 Nodes = states.
 Arcs represent transition function.
 Arc from state p to state q labeled by all those input symbols
that have transitions from p to q.
 Arrow labeled “Start” to the start state.
 Final states indicated by double circles.
Deterministic Finite Automata
 A finite automaton is a 5-tuple M = (Q, Σ, δ, q, F), where
1. A finite set of states (Q, typically).
2. An input alphabet (Σ, typically).
3. A transition function (δ, typically).
4. A start state (q0, in Q, typically).
5. A set of final states (F ⊆ Q, typically).
 “Final” and “accepting” are synonyms.

 Transition Function takes two arguments: a state and an


input symbol δ(q, a) , the state that the DFA goes to when
it is in state q and input a is received.

5
What does a DFA do?
 Input: a word w in ∑*
 Question: Is w acceptable by the DFA?
 Steps:
 Start at the “start state” q0
 For every input symbol in the sequence w do
 Compute the next state from the current state, given the current input
symbol in w and the transition function
 If after all symbols in w are consumed, the current state is
one of the accepting states (F) then accept w;
 Otherwise, reject w.

6
q0 0,1

L(M) = {0,1}*
0 0

1
q0 q1
1

L(M) = { w | w has an even number of 1s}


Build an automaton that accepts all and only
those strings that contain 001

0,1
1 0

0 0 1
q q0 q00 q001
1
:Example

a a a/b/c

c c
q0 q1 q2

b b

a c c c b accepted

a a c rejected

Accepts those strings that contain at least two c’s


DFA for strings containing 01

• Q = {q0,q1,q2}
• ∑ = {0,1}
• start state = q0
1 0 0,1
• F = {q2}
start 0 1
q0 q1 q2 • Transition table
symbols
0 1
Accepting
q0 q1 q0
state
states q1 q1 q2
*q2 q2 q2

11
State Diagram and Table a
a
b
b
q0 q1 q2

a
b
d a b
q0 q0 q1

q1 q0 q2

q2 q2 q2
:Example
 Let M be the following DFA.

(i) Write down four string accepted by M.

(ii) Write down four strings not accepted by M


Example: Graph of a DFA
 Draw state diagram for DFA that Accepts all strings
without two consecutive 1’s

0 0,1
1 1
A B C

Start 0

 Represent the DFA by transition table


Example: Graph of a DFA
 Draw state diagram for DFA to Accepts the language:
L = {w|w has both an even number of 0’s and even number of 1’s}
1

Start
q0 q1

0 0 0 0

q2 q3

 Represent the DFA by transition table


Example: Graph of a DFA
 Write regular expressions for the languages over the
alphabet Σ = {a, b}, that All strings which do not contain
the substring ba

 Draw DFAs for the language:

 Represent the DFA by transition table


Example: Graph of a DFA
 Draw DFAs accepting the set of all strings ending with 00.

 Represent the DFA by transition table


Example: Graph of a DFA
 Draw a DFA which accepts the following language:
L = {w | w ∈ Σ∗ w contains the substring 0101}
(That is, w = x0101y for two arbitrary strings x and y.)

 Represent the DFA by transition table


Example: Graph of a DFA
 Which languages are accepted by the following automaton

The strings with an even number of characters and length of


at least 2.
Example: Graph of a DFA
 Which languages are accepted by the following automaton

The strings which contains at least one a, followed by an


odd number of characters.
Extended transition function

 It describe what happen when start at any state and follow


˄
any sequence of input. denoted by δ

 Is a function that takes state q and a string w and return


the state p
˄
 Basis: δ(q, ε) = q
 ˄
Induction: δ(q,wa) = δ(δ(q,w),a) = δ(p, a)

21
Extended transition function
 For example: given the transition table below

˄
 Compute the δ(q, w) , w = 110101

22
Extended transition function

You might also like