0% found this document useful (0 votes)
4 views

Lecture 01 _ Finite Automat I

The document outlines the first lecture of a course on the Theory of Computation, focusing on finite automata, including deterministic (DFA) and non-deterministic finite automata (NFA). It discusses the purpose of the Theory of Computation, its three main areas, and the significance of automata theory in computer science. The lecture includes examples of automata applications, state diagrams, and formal descriptions of various finite automata.

Uploaded by

Mohamad Haikal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lecture 01 _ Finite Automat I

The document outlines the first lecture of a course on the Theory of Computation, focusing on finite automata, including deterministic (DFA) and non-deterministic finite automata (NFA). It discusses the purpose of the Theory of Computation, its three main areas, and the significance of automata theory in computer science. The lecture includes examples of automata applications, state diagrams, and formal descriptions of various finite automata.

Uploaded by

Mohamad Haikal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

TIC 2151 – Theory of Computation

Lecture 1
Finite Automat I

TIC 2151 – Theory of Computation


3/19/202
3 1
Lecture 1 - Outline

 A first look at an application.


 Examples of Deterministic Finite Automaton (DFA).
 Other kinds of automata: finite state transducers, automata with garbage
collectors, automata with no reaction on inputs.
 Non-deterministic finite automata (NFA).
 Non-deterministic finite automata with ε-transition.

3/19/2023 2
Theory of Computation

 What is Theory of computation (TOC)?


 In theoretical computer science, the theory of computation is the branch that deals with
whether and how efficiently problems can be solved on a model of computation, using an
algorithm.

 Purpose of the Theory of Computation: Develop formal mathematical models of computation


that reflect real-world computers.

3/19/2023 3
Theory of Computation

 Theory of Computation can be divided into the following three areas:


 Complexity Theory,
 Computability Theory
 Automata Theory.
Why study theory of computation?

 Pre-requisite for understanding, designing, and processing formal languages.


(Examples of formal languages are Java, C++, HTML, XML, etc.
 Foundation for technologies used in real-world applications such as natural language
processing, handwriting recognition and software verification tools
 Understand which problems are computable, and which are not.
 Abstract models of computation independent of implementations.
 You need some theoretical foundation to develop technology.
 Improve your problem solving skills!

3/19/2023 5
A first look at an application

Consider the problem of designing a


“computer” that Controll an auto-door
Front Pad Rear Pad
 Two states: OPEN, CLOSED.
 Events: Front, Rear, Both, Neither.
door
Top view of an automatic door
There are four possible input conditions:
o "FRONT" (meaning that a person is standing on the pad in front of the doorway).
o "REAR" (meaning that a person is standing on the pad to the rear of the doorway).
o "BOTH" (meaning that people are standing on both pads).
o "NEITHER" (meaning that no one is standing on either pad).

3/19/2023 6
A first look at an application

Consider the problem of designing a


“computer” that Controll an auto-door Front Pad Rear Pad
 Two states: OPEN, CLOSED.
 Events: Front, Rear, Both, Neither door
Top view of an automatic door

The state diagram (for the controller)


Rear, Both
Front
Neither Front, Rear,
Both

CLOSED OPEN

Neither
3/19/2023 7
A first look at an application

Consider the problem of designing a


“computer” that Controll an auto-door Front Pad Rear Pad
 Two states: OPEN, CLOSED.
 Events: Front, Rear, Both, Neither. door
Top view of an automatic door

The state transition table


 First column: write the states here
 First row: write the events here (formally called symbols).

Neither Front Rear Both

CLOSED CLOSED OPEN CLOSED CLOSED

OPEN CLOSED OPEN OPEN OPEN

3/19/2023 8
Automata theory?

 In theoretical computer science, automata theory is the study of abstract machines (or
more appropriately, abstract 'mathematical' machines or systems) and the computational
problems that can be solved using these machines. These abstract machines are called
automata. (singular : automaton)
Automata theory deals with the definitions and properties of mathematical models of
computation.
Examples of such models are:
 Finite Automata (FA). These are used in text processing, compilers, and hardware
design.
 Context-Free Grammars (CFG). These are used to define programming languages and
in Artificial Intelligence.
 Turing Machines (TM). These form a simple abstract model of a “real” computer, such
as your PC at home.

3/19/2023 9
Finite Automata

 Finite automata are used in text processing, compilers, and hardware design.

M that accepts all ASCII strings ending with ing.

 Finite automata are good models for computers with an extremely limited amount of
memory.
 This automaton (abstract machine) consists of
 States (represented in the figure by circles),
 Transitions (represented by arrows).
 Two Representations
 Deterministic finite automata (DFA)
 NonDeterministic finite automata (NFA)
Deterministic finite automata (DFA)
 Computation follows in a unique way from the preceding step. we know what the next
state will be—it is determined.
 Every state of a DFA always has exactly one exiting transition arrow for each symbol in
the alphabet.

L= {w ∈ {0, 1}* | w is the set of strings that start with 00}

3/19/2023 TCS3511 11
Deterministic finite automata (DFA)
1. The state diagram of a finite automaton M1

2. The formal definition of the finite automaton

3/19/2023 TCS3511 12
Deterministic finite automata (DFA)
1. The state diagram of a finite automaton M1

2. The formal description of the finite automaton M1


M1 = (Q, Σ, δ, po, F)
with Q = {q1, q2, q3} δ is given by the following table:
Σ = {0,1}
δ: Q x Σ → Q
p0 = q 1
F = {q2}

3. The accepted language


L(M) = {w ∈ {0,1}* | w contains at least one 1 and an even number of 0s following the last 1}

e.g. 01, 111, 0101101, 1001100


If A is the set of all strings that machine M accepts, we say that A is the language of machine M
and write L(M) = A. We say that M recognizes or accepts A.
3/19/2023 TCS3511 13
Deterministic finite automata (DFA)
1. The state diagram of a finite automaton M2

2. The formal description of the DFA M2


M2 = (Q, Σ, δ, po, F)
with Q = {q1, q2}
δ is described as
Σ = {0,1} δ
δ: Q x Σ → Q
p0 = q 1
F = {q2}

3. The accepted language L = {w ∈ {0,1}* | w ends with a 1}

NOTE: the state diagram of M2 and its formal description contain the same information. You can
always go from one to the other.
14
Deterministic finite automata (DFA)

1. The state diagram of a finite automaton M3

2. The formal description of the finite automaton M3


M3 = (Q, Σ, δ, po, F)

with Q = {q1, q2}


Σ = {0,1} δ is described as
δ: Q x Σ → Q
p0 = q 1
F = {q1}

3. The accepted language


L = {w ∈ {0,1}* | w is the empty string or ends in a 0}

Note: in M3 we only changed the accepting state of M2.

15
Deterministic finite automata (DFA)

1. The state diagram of a finite automaton M4

2. The formal description of the finite automaton


M4 = (Q, Σ, δ, po, F)
with Q = {q,q0,q1,q2}
Σ = {0,1} δ 0 1
δ: Q x Σ → Q q q0 q
p0 = q q0 q1 q
F = {q2} q1 q1 q2
q2 q2 q2
3. The accepted language
L (M4)= {w ∈ {0,1}* | w contains the string 001}

16
Deterministic finite automata (DFA)
1. The state diagram of a finite automaton M5

2. The formal description of the finite automaton


M5 = (Q, Σ, δ, po, F) δ a b
with Q = {s,q1,q2,r1,r2} s q1 r1
Σ = {a,b} q1 q1 q2
δ: Q x Σ → Q q2 q1 q2
p0 = s r1 r2 r1
F = {q1,r1} r2 r2 r1

3. The accepted language


L (M5) = {w ∈ {a,b}* | w starts and ends with the same symbol}
Note: More than one accepting state.

Describing a finite automaton by state diagram is not possible in some cases that may occur
when the diagram would be too big to draw. In these cases, we resort to a formal description to
specify the machine.
17
Deterministic finite automata (DFA)

Language? L = {w ∈ {0,1}* | w starts with none or more 0s followed by at least one 1.}

e.g. 1 , 011, 0000001, 000011111,

Language? L = {w ∈ {0,1}* | w has an even number of 1’s }

e.g. 01010, 111111, 0010001001010

18
Deterministic finite automata (DFA)

Defining an accepting computation


 An automaton will accept an input string if:
 The automaton has entered an accepting state, AND
 The input string has been exhausted (i.e. completely processed).

0010001001010

 In other cases, the automaton will arrive at a rejecting computation.

19
NonDeterministic finite automata (NFA)
deterministic computation. computation follows in a unique way from the preceding step. we
know what the next state will be—it is determined.
Every state of a DFA always has exactly one exiting transition arrow for each symbol in the
alphabet.

In a nondeterministic machine, several choices may exist for the next state at any point. NFA is
a generalization of determinism, so every DFA is automatically a nondeterministic finite
automaton.

The NFA shown in Figure above violates that rule. Ex: State q1 has one exiting arrow for 0, but it has two for
1. q2 has one arrow for 0, but it has none for 1, q3 has one arrow for 1 only.
In an NFA, a state may have zero, one, or many exiting arrows for each alphabet symbol.
20
NonDeterministic finite automata (NFA)

1. The state diagram of a finite automaton

2. The formal definition of NFA

21
NonDeterministic finite automata (NFA)

1. The state diagram of a finite automaton

2. The formal description of the finite automaton

A = (Q, Σ, δ, po, F) δ 0 1
with Q = {q1,q2,q3,q4} q1 {q1} {q1,q2}
Σ = {0,1} q2 {q3} {q3}
δ: Q x Σε → Pow(Q) q3 {q4} {q4}
p0 = q1 q4 ∅ ∅
F = {q4}

3. The accepted language


L = {w | w contains a 1 in the third position from the end} e.g., 000100

22
NonDeterministic finite automata (NFA)

1. The state diagram of a finite automaton

2. The formal description of the finite automaton


A = (Q, Σ, δ, po, F)
with Q = {q1,q2} δ 0 1
Σ = {0,1} q1 {q1,q2} {q2}
δ: Q x Σε → Pow(Q)
p0 = q1 q2 ∅ {q1,q2}
F = {q2}

3. The accepted language


L = {w | w does not Start with 10}

Nondeterministic automata are good for shorter descriptions, good for building an automaton
accepting or not accepting special cases.

23
(NFA) with ε -transitions (ε-NFA)

Why is it comfortable to use ε -transitions?

The automaton accepts {0k | where k is multiple of 2 or 3}

(Remember that the superscript denotes repetition, not numerical exponentiation.) For
example, This NFA accepts the strings ε, 00, 000, 0000, and 000000, … but not 0 or
00000.

NOTE: The above NFA has an input alphabet {0} consisting of a single symbol. An
alphabet containing only one symbol is called a unary alphabet. 24
DFA vs. NFA
 Important: the NFA is defined in the same way as the DFA but with the following
two exceptions:
o Multiple next state.
o ε- transitions.

 Multiple next state. in a DFA there is exactly one start state and exactly one transition
out of every state for each symbol in Ʃ. In contrast to a DFA, the next state is not
necessarily uniquely determined by the current state and input symbol in case of an NFA.
In an NFA, a state may have zero, one, or many exiting arrows for each alphabet symbol.

 ε- transitions. In an ε-transition, the state of the automata can be changed and go to next
state without consuming the next input. δ(q, ε) = {q1,q2….qk} implying that with ε-
transition the next state could by any one of {q1,q2….qk}

25
Why an NFA?
 Every NFA can be converted into an equivalent DFA; but sometimes that DFA may have many
more states.
 Furthermore, understanding the functioning of the NFA is much easier, as you may see by
examining the following figure for the DFA.
NFA and DFA that recognize the language A
A = {w | w contains a 1 in the third position from the end}

Two machines
are equivalent if
they recognize
the same
language
Finite automata and regular language RL
 Finite automata are good models for computers with an extremely limited amount of memory.
 A machine may accept several strings, but it always recognizes only one language. If the
machine accepts no strings, it still recognizes one language namely, the empty language θ.
 language of machine M and write L(M) = A. We say that M recognizes language A
 We say that M recognizes language A if A = {w | M accepts w}.
Learning Outcomes

You should be able to:


 Give a DFA/NFA for a given (Regular) language.
 Explain the differences between a DFA and NFA.
 Understand and describe the different kinds of automata.

Next lecture: Are NFAs more powerful than DFAs???

28

You might also like