Head, Dept' of Computer Science - PowerPoint PPT Presentation

1 / 105
About This Presentation
Title:

Head, Dept' of Computer Science

Description:

Head, Dept. of Computer Science. Information Science. A.M. Padma Reddy ... Checking and design the behavior of the digital. circuits using software ... – PowerPoint PPT presentation

Number of Views:634
Avg rating:3.0/5.0
Slides: 106
Provided by: VTU1
Category:
Tags: computer | dept | head | padma | science

less

Transcript and Presenter's Notes

Title: Head, Dept' of Computer Science


1
A.M. Padma Reddy
Head, Dept. of Computer Science Information
Science
R.N.S Institute of Technology
2
What is Finite Automata?
  • Study of Abstract machines or computing devices

3
ADVANTAGES OF FA
  • Checking and design the behavior of the digital
  • circuits using software
  • Compiler Design (LEX and YACC)
  • Designing a software for identifying words,
  • phrases and other patterns in large bodies
  • of text (such as collection of web pages)

4
ADVANTAGES OF FA Theory
  • Study the computers without worrying
  • about the intricacies of a particular
  • architecture
  • Study the computers without worrying
  • about the limitations imposed by a specific
  • hardware

5
TYPES OF FA
Deterministic Finite Automata (DFA)
Non Deterministic Finite Automata (NFA)
Non Deterministic Finite Automata with e-moves
(e-NFA)
6
Mathematical Concepts
What is A x B?
What is a power set?
7
Definitions
What is an alphabet?
An alphabet is a finite non-empty set of symbols
and is denoted by S
S 0,1 S a, b, c
What is a string?
A string is a sequence of symbols from S. For
example 00, 01, 10 and 11. ? - stands for an
empty string
8
Definitions
What is a language?
A language over an alphabet S is a set of string
over S. A language can be finite or infinite
For example 00, 01, 10 and 11 L wwR
w ?a,b
9
FINITE AUTOMATA
Q q0, q1, q2, q3
The transition table
S a, b
q0 start state
b
a
d
F q3
q0
q1
q2
q1
q0
q3
q2
q3
q0
q3
q2
q1
10
Representation of a DFA
d(q0,a) q1
d(q0,b) q2
d(q1,a) q0
b
a
d
d(q1,b) q3
d(q2,a) q3
q0
q1
q2
d(q2,b) q0
q1
q0
q3
d(q3,a) q2
q2
q3
q0
d(q3,b) q1
q3
q2
q1
11
What is a DFA?
, q0
)
(
Q
, S
, d
, F
M
Q- Set of finite states
S - Set of input alphabets
d transition from Q x S to Q
q0 start state
F set of final states
12
DFA to accept strings of as and bs ending
with abb
a
b
b
q3
q0
q1
q2
q3
13
DFA to accept strings of as and bs except
those ending with abb
a
b
b
q3
q0
q1
q2
q3
q3
q0
q1
q2
14
DFA to accept strings of as and bs which has
even number of as and bs
a
q0
q0
q1
q0
q1
q1
a
b
b
b
b
a
q2
q2
q3
q2
q3
a
15
Non Deterministic Automata
16
Definition of NFA

Set of states, i.e.
Input aplhabet, i.e.
Transition function
Initial state
Final states
17
NFA vs. DFA
  • Difference is in the definition of d
  • NFAs and DFAs recognize the same set of
    languages
  • regular languages
  • DFAs are faster to execute
  • There are no choices to consider
  • For a given language, NFA can be simple than DFA
    and we can easily construct NFA
  • DFA can be exponentially larger than NFA

18
NFA
Alphabet
19
NFA
Alphabet
Two choices
20
NFA
Alphabet
Two choices
No transition
No transition
21
First Choice
22
First Choice
23
First Choice
24
First Choice
accept
25
Second Choice
26
Second Choice
27
Second Choice
No transition the automaton hangs
28
Second Choice
reject
29
Observation
An NFA accepts a string if there is a computation
of the NFA that accepts the string
30
Example
is accepted by the NFA
31
Lambda Transitions
32
(No Transcript)
33
(No Transcript)
34
(read head doesnt move)
35
(No Transcript)
36
accept
String is accepted
37
Language accepted
38
Another NFA Example
39
(No Transcript)
40
(No Transcript)
41
(No Transcript)
42
accept
43
Another String
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
47
(No Transcript)
48
(No Transcript)
49
(No Transcript)
50
accept
51
Language accepted
52
Another NFA Example
53
Language accepted
54
Transition Function
55
(No Transcript)
56
(No Transcript)
57
(No Transcript)
58
Extended Transition Function

59
(No Transcript)
60
(No Transcript)
61
Formally
It holds
if and only if
there is a walk from to with label
62
The Language of an NFA

63

64

65

66

67
Formally
  • The language accepted by NFA is
  • where

(final state)
68

69
Equivalence of NFAs and DFAs

70
Equivalence of Machines
  • For DFAs or NFAs
  • Machine is equivalent to machine
  • if

71
Example
NFA

DFA
72
  • Since
  • machines and are equivalent

NFA
DFA
73
Equivalence of NFAs and DFAs
Question NFAs DFAs ?
Same power? Accept the same languages?
74
Equivalence of NFAs and DFAs
Question NFAs DFAs ?
YES!
Same power? Accept the same languages?
75
We will prove
Languages accepted by NFAs
Languages accepted by DFAs
76
We will prove
Languages accepted by NFAs
Languages accepted by DFAs
NFAs and DFAs have the same computation power
77
Step 1
Languages accepted by NFAs
Languages accepted by DFAs
78
Step 1
Languages accepted by NFAs
Languages accepted by DFAs
Proof
Every DFA is also an NFA
79
Step 1
Languages accepted by NFAs
Languages accepted by DFAs
Proof
Every DFA is also an NFA
A language accepted by a DFA is also accepted by
an NFA
80
Step 2
Languages accepted by NFAs
Languages accepted by DFAs
81
Step 2
Languages accepted by NFAs
Languages accepted by DFAs
Any NFA can be converted to an equivalent DFA
Proof
82
Step 2
Languages accepted by NFAs
Languages accepted by DFAs
Any NFA can be converted to an equivalent DFA
Proof
A language accepted by an NFA is also accepted by
a DFA
83
NFA to DFA
NFA

DFA
84
NFA to DFA
NFA

DFA
85
NFA to DFA
NFA

DFA
86
NFA to DFA
NFA

DFA
87
NFA to DFA
NFA

DFA
88
NFA to DFA
NFA

DFA
89
NFA to DFA
NFA

DFA
90
NFA to DFA Remarks
  • We are given an NFA
  • We want to convert it
  • to an equivalent DFA
  • With

91
  • If the NFA has states
  • the DFA has states in the powerset

92
Procedure NFA to DFA
  • 1. Initial state of NFA
  • Initial state of DFA

93
Example
NFA

DFA
94
Procedure NFA to DFA
  • 2. For every DFAs state
  • Compute in the NFA
  • Add transition

95
Exampe
NFA

DFA
96
Procedure NFA to DFA
  • Repeat Step 2 for all letters in alphabet,
  • until
  • no more transitions can be added.

97
Example
NFA

DFA
98
Procedure NFA to DFA
  • 3. For any DFA state
  • If some is a final state in the NFA
  • Then,
  • is a final state in the DFA

99
Example
NFA

DFA
100
Theorem
Take NFA

Apply procedure to obtain DFA
Then and are equivalent

101
Finally
We have proven
Languages accepted by NFAs
Languages accepted by DFAs
102
We have proven
Languages accepted by NFAs
Languages accepted by DFAs
Regular Languages
103
We have proven
Languages accepted by NFAs
Languages accepted by DFAs
Regular Languages
Regular Languages
104
How Does Lex Work?
Flex
RE ? NFA NFA ? DFA Optimize DFA
REs for Tokens
DFA Simulation
Character Stream
Token stream (and errors)
105
Regular Expression to NFA
  • Its possible to construct an NFA from a regular
    expression
  • Thompsons construction algorithm
  • Build the NFA inductively
  • Define rules for each base RE
  • Combine for more complex REs

s
f
E
general machine
Write a Comment
User Comments (0)
About PowerShow.com