0% found this document useful (0 votes)
16 views31 pages

Introduction to Automata Theory

well come

Uploaded by

mekashfetene89
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views31 pages

Introduction to Automata Theory

well come

Uploaded by

mekashfetene89
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Chapter

One
What is Automata Theory
Study of abstract computing devices, or “machines”

Automaton = an abstract computing device n Note:


A “device” need not even be a physical hardware!

 A fundamental question in computer science:

 Find out what different models of machines can do and

cannot do
The theory of computation

 Computability vs. Complexity


Formal language
 The field of formal language theory studies the purely syntactical

aspects of such languages— that is, their internal structural patterns.


 Formal language theory sprang out of linguistics, as a way of

understanding the syntactic regularities of natural languages.


 In computer science, formal languages are often used as the basis for

defining programming languages and other systems in which the


words of the language are associated with particular meanings or
semantics.
 The alphabet of a formal language is the set of symbols, letters, or

tokens from which the strings of the language may be formed;


frequently it is required to be finite.
Cont.…..
 A formal language L over an alphabet Σ is a subset of Σ*, that is,

a set of words over that alphabet.


A formal language is one we invent for some purpose or other. A

programming language such as LISP, for instance, is a formal


language invented for the purpose of programming computers.
It is easy to invent a language, where ‘language’ is understood to

be a set of ‘symbol strings’.


 A formal language is often defined by means of a formal

grammar such as a regular grammar or context-free grammar,


also called its formation rule.
Cont.…..
 To describe such recognizers, formal language theory uses separate

formalisms, known as automata theory.


 One of the interesting results of automata theory is that it is not

possible to design a recognizer for certain formal languages.


A formal language consists of:

(i) an alphabet of symbols A and

(ii) rules (syntax) for their combination.

A string X belongs to L just if X consists of symbols from A and is

formed in accordance with the rules.


Cont.…

An alphabet is a finite, non-empty set of symbols n We use the


symbol ∑ (sigma) to denote an alphabet n Examples: n Binary:
 ∑ = {0,1} n All lower case letters:

 ∑ = {a,b,c,..z} n Alphanumeric: ∑ = {a-z, A-Z, 0-9}

String A string or word is a finite sequence of symbols chosen


from ∑ n Empty string is e (or “epsilon”) n Length of a string w,
denoted by “|w|”, is equal to the number of (non- e) characters in
the string n
 E.g., x = 010100 |x| = 6 n x = 01 e 0 e 1 e 00 e |x| = ? n xy =

concatenation of two strings x and y


Powers of an alphabet
 Let ∑ be an alphabet.
n ∑k = the set of all strings of length k
n ∑* = ∑0 U ∑1 U ∑2 U …
n ∑+ = ∑1 U ∑2 U ∑3 U

Languages L is a said to be a language over alphabet ∑, only


if L Í ∑* è this is because ∑* is the set of all strings (of all possible
length including 0) over the given alphabet ∑ Examples:
 1. Let L be the language of all strings consisting of n 0’s followed by
n 1’s: L = {e, 01, 0011, 000111,…}
 2. Let L be the language of all strings of with equal number of 0’s
and 1’s: L = {e, 01, 10, 0011, 1100, 0101, 1010, 1001,…}
Cont.…
Languages: “A language is a collection of
sentences of finite length all constructed from a
finite alphabet of symbols
Finite Automata
 An abstract machine which can be used to implement
regular expressions (etc.).
 Has a finite number of states, and a finite amount of
memory (i.e., the current state).
 Can be represented by directed graphs(state
transition diagrams) or transition tables
Representation
 An FSA may be represented as a directed graph; each
node (or vertex) represents a state, and the edges (or
arcs) connecting the nodes represent transitions.
 Each state is labeled.
 Each transition is labeled with a symbol from the
alphabet over which the regular language represented
by the FSA is defined, or with e, the empty string.
Cont.…
 Among the FSA’s states, there is a start state and at least
one final state (or accepting state).
 Given an input string, an FSA will either accept or reject the
input.
 If the FSA is in a final (or accepting) state after all input
symbols have been consumed, then the string is accepted
(or recognized).
 Otherwise (including the case in which an input symbol
cannot be consumed), the string is rejected.
 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
 Recognizer for “Regular Languages”
Cont.…
 Some Applications FA

 Software for designing and checking the behavior of digital

circuits Lexical analyzer of a typical compiler


 Software for scanning large bodies of text (e.g., web pages)

for pattern finding


Software for verifying systems of all types that have a finite

number of states (e.g., stock market transaction,


communication/network protocol)
Cont.…
Deterministic Finite Accepters
 The first types of automaton we study in detail are finite
accepters that are deterministic in their operation. We start
with a precise formal definition of deterministic accepters. A
deterministic acceptor has internal states, rules for
transitions from one state to another, some input, and ways
of making decisions.
 Definition:
 A DFA is defined by the quintuple
M = (Q, Σ, δ, q0, F)
Q A finite set of states
Σ A finite input alphabet
q0 The initial/starting state, q 0 is in Q
F A set of final/accepting states, which is a subset of Q
δ A transition function, which is a total function from Q x Σ
to Q
 A deterministic finite accepter operates in the following manner. At
the initial time, it is assumed to be in the initial state q0, with its input
mechanism on the leftmost symbol of the input string. During each
move of the automaton, the input mechanism advances one position
to the right, so each move consumes one input symbol. When the end
of the string is reached, the string is accepted if the automaton is
one of its final states. Otherwise the string is rejected. The input
mechanism can move only from left to right and reads exactly one
symbol on each step. The transition from one internal state to another
are governed by the transition function δ. For example
 δ(q0,a)= q1. If the dfa is in state q0 and the current input symbol is a,
the dfa will go into state q1.
The graph below represents the dfa
 M = ({q0, q1, q2} , {0,1}, δ, q0,{ q1})
 Where δ is given by
 δ(q0,0) = q0,
 δ(q0,1) = q1
 δ(q1,0) = q0,
 δ(q1,1) = q2,
 δ(q2,0) = q2,
 δ(q2,1) = q1,
Cont..
 The string 01 is accepted. The dfa does not accept the
string 00, since after reading two consecutive 0’s, it will be in
state q0. By similar reasoning, we see that the automaton
will accept the strings 101, 0111, and 11001, but not 100 or
1100.
The language accepted by a dfa M=(Q,∑, δ, q0,F) is the set
of all strings on ∑ accepted by M. In formal notation,
L(M)={wÎ∑*: δ*(q0,w) ÎF}.
 A dfa will process every string in ∑* and either accept it or nor accept it.
Non acceptance means dfa stops in a non final state.
Theorem
Let M=(Q, Σ, δ,q0,F) be a deterministic finite accepter, and
let GM be its associated transition graph. Then for every qi, qj
Î Q and w Î Σ* , δ*(qi,w)=qj, if and only if there is in GM a walk
with label w from qi to qj.
The following automaton is an example for trap state or
dead state i.e a state is a dead state or trap state if it is not an
accepting state and has no out-going transitions except to itself.
DFA for strings containing 01
Non-deterministic Finite
Automata
Nondeterministic Finite State Automata (NFA)
 An NFA is an automaton that its states might have none, one or more outgoing
arrows under a specific symbol. Example

• An NFA is a five-tuple:
M = (Q, Σ, δ, q0, F)

Q A finite set of states


Σ A finite input alphabet
q0 The initial/starting state, q0 is in Q

F A set of final/accepting states, which is a subset of Q


δ A transition function, which is a total function from Q x Σ to 2 Q
δ: (Q x Σ) = 2Q or δ: Q x (ΣU{ ε }) = 2Q
• Example #1: some 0’s followed by some 1’s
• Q = {q0, q1, q2}
• Σ = {0, 1}
• Start state is q0

• F = {q2}

δ: 0 1
qo {q0, q1} {}

q1 {} {q1, q2}

q2 {q2} {q2}
 An NFA for the language of all strings over {a,b} that contain ababb
N-DFA for strings containing 01
.
Conversion of NFA to DFA:
Suppose that you want to find an equivalent DFA for an
NFA . The algorithm is the following:
• Start from the start state and see where 0 or 1 takes you.
• For every new subset you find, see where 0 or 1 takes you.
• Repeat until no new subsets are found.
To find an equivalent DFA with the NFA of the figure we should complete the
following table:
The NFA below has 3 states q0,q1,q2 with ∑={0,1}
Cont…

Cont..
Minimize the number of states of DFA:

The initial partition contains two groups

Non final state (ABCD)

Final state (E)

new=(E) it cannot be further split.

On input b, A,B and C go to the members of (ABCD) of , while D goes to E, a


member of another group.

Thus, in new (ABCD) must be split into two groups(ABC) and (D).

The new value of is (ABC), (D), (E).

Again on input b, A and C go to C, while B goes to D.

So new is (AC) (B) (D) (E)


Cont..
Transition table:
Input
State
A B
Start A B A
B B D
D B E
Accept E B A
 The transition diagram for the optimized or minimized DFA
Closure properties of regular languages
We have seen already union concatenation kleene star
properties. Now let us move on to compliment
All we did was to make the accepting states be non-accepting,
and make the non accepting states be accepting
In terms of the 5-tuple M = (Q, Σ, δ, q0, F), all we did was to
replace F with Q-F
Using this construction, we have a proof that the complement
of any regular language is another regular language.
Refer the below diagram. The regular languages are closed
under complement.
Cont..

Cont..

Intersection
We can cross product the two DFAs as:
 LM = (QLxQM, , LM, (qL, qM), FLxFM)

You might also like