Sie sind auf Seite 1von 9

Tahir Naseem/Handout 9

-1-

Theory of Automata and Formal Languages

Lecture 9
Objectives
Finite State Automata
o What is Finite State Automata
o Why to Study Finite State Automata
o Formal Definition of FSA
o Notations used for FSA
o Simple Examples

An example of an automaton. The study of the mathematical properties of such automata is


automata theory
In theoretical computer science, automata theory is the study of mathematical objects called
abstract machines or automata and the computational problems that can be solved using
them. Automata comes from the Greek word meaning "self-acting".
The figure at right illustrates a finite state machine, which belongs to one well-known variety
of automaton. This automaton consists of states (represented in the figure by circles), and
transitions (represented by arrows). As the automaton sees a symbol of input, it makes a
transition (or jump) to another state, according to its transition function (which takes the
current state and the recent symbol as its inputs).
Automata theory is also closely related to formal language theory. An automaton is a finite
representation of a formal language that may be an infinite set. Automata are often classified
by the class of formal languages they are able to recognize.
Automata play a major role in theory of computation, compiler design, parsing and formal
verification.

Tahir Naseem/Handout 9

-2-

Theory of Automata and Formal Languages

Automata
Following is an introductory definition of one type of automaton, which attempts to help one
grasp the essential concepts involved in automata theory.
Informal description
An automaton is supposed to run on some given sequence of inputs in discrete time steps. At
each time step, an automaton gets one input that is picked up from a set of symbols or letters,
which is called an alphabet. At any time, the symbols so far fed to the automaton as input
form a finite sequence of symbols, which is called a word. An automaton contains a finite set
of states. At each instance in time of some run, the automaton is in one of its states. At each
time step when the automaton reads a symbol, it jumps or transits to a next state that is
decided by a function that takes current state and the symbol currently read as parameters.
This function is called transition function. The automaton reads the symbols of the input
word one after another and transits from state to state according to the transition function,
until the word is read completely. Once the input word has been read, the automaton is said to
have been stopped and the state at which automaton has stopped is called final state.
Depending on the final state, it's said that the automaton either accepts or rejects an input
word. There is a subset of states of the automaton, which is defined as the set of accepting
states. If the final state is an accepting state, then the automaton accepts the word. Otherwise,
the word is rejected. The set of all the words accepted by an automaton is called the
language recognized by the automaton.
In short, an automaton is a mathematical object that takes a word as input and decides either
to accept it or reject it. Since all computational problems are reducible into the accept/reject
question on words (all problem instances can be represented in a finite length of symbols),
automata theory plays a crucial role in computational theory.
What is Finite State Automata

It is a graph like structure also known as directed graph.

Finite state automata (FSAs) sound complicated, but the basic idea is as simple as
drawing a map.

A finite-state automaton is a device that can be in one of a finite number of states .


In certain conditions, it can switch to another state.

Tahir Naseem/Handout 9

-3-

Theory of Automata and Formal Languages

o This is called a transition .


When the automaton starts working (when it is switched on), it can be in one of its
initial states.
There is also another important subset of states of the automaton: the final states.
o If the automaton is in a final state when it stops working, it is said to accept
its input. The input is a sequence of symbols.
The interpretation of the symbols depends on the application; they usually represent
events, or can be interpreted as ``the event that a particular data became available''.
The symbols must come from a finite set of symbols, called the alphabet .
If a particular symbol in a particular state triggers a transition from that state to
another one, that transition is labeled with that symbol.
o The labels of transitions can contain one particular symbol that is not in the
alphabet.
o A transition is labeled with (not present in the alphabet) if it can be traversed
with no input symbol.
It is convenient to present automata as directed graphs.
The vertices denote states.
They are portrayed as small circles.
The transitions form the edges - arcs with arrows pointing from the source state (the
state where the transition originates) to the target state.
They are labeled with symbols. Unless it is clear from the context, the initial states
have short arrows that point to them from ``nowhere''.
The final states are represented as two concentric circles.

Why to Study Finite State Automata

FSA is machine to model the regular languages.

So, to model the problem belonging to regular language needs finite state
automata

Formal Definition of FSA


A finite automaton (DFA) is a 5-tuple (Q, , , q0, F) where
o Q is a finite set of states
o is an alphabet
o : Q Q is a transition function
o q0 Q is the initial state
o F Q is a set of accepting states (or final states).
Notations Used to build FSA

Sates are represented by circles having name inside it.

Tahir Naseem/Handout 9

-4-

Theory of Automata and Formal Languages

Initial Sate is represented by circle having negative sign inside it or arrow symbol like
Or

-1

Transitions having label from


o Transitions omits from states are called outgoing transitions for that particular
state.
o Transitions comes to states are called incoming transitions.

Final state or acceptance state is represented with double circle or positive sign inside.
+1

Or

Example 1: FSA for * over = {a b}


a, b
-1

Example 2: FSA for a*b*


a, b
-1

Example 3: FSA to accept (ab)*

-1

b
a

Example 4: FSA to accept a


1

+2

a, b

3
a, b

Tahir Naseem/Handout 9

-5-

Theory of Automata and Formal Languages

+10
+5

+5

$0
R

+10
+5, +10

$5

$10

R
R

There are states $0, $5, $10, go, the start state is $0
The automaton takes inputs from {+5, +10, R}
The state go is an accepting state
In diagrams, the accepting states will be denoted by double loops
Example 5:
1

alphabet S = {0, 1}
states Q = {q0, q1, q2}
initial state q0
accepting states F = {q0, q1}

table of
transition function d:

go
+5, +10

Tahir Naseem/Handout 9

-6-

Theory of Automata and Formal Languages

The language of a DFA (Q, S, d, q0, F) is the set of


all strings over S that, starting from q0 and
following the transitions as the string is read left
to right, will reach some accepting state.
+10
+5

+5

$0
R

+10
+5, +10

$5

$10

R
R

+5 +10, +5 R R +5 +10 are in the language


+5, +5 +10 R are not
More Examples:
= {a, b}

go
+5, +10

Tahir Naseem/Handout 9

-7-

Theory of Automata and Formal Languages

= {a, b}

Construct a DFA that accepts the language

( = {0, 1} )

Construct a DFA over alphabet {0, 1} that accepts all strings that end in 01

The DFA must remember the last 2 bits of the string it is reading
0

0
1

Construct a DFA over alphabet {0, 1} that accepts all strings that end in 101

Tahir Naseem/Handout 9

-8-

Having strings of odd length ending in b.

= {a, b, c} with at least two bs or at least 3 cs.

Theory of Automata and Formal Languages

Tahir Naseem/Handout 9

-9-

Theory of Automata and Formal Languages

Das könnte Ihnen auch gefallen