Deterministic Finite Automata (DFAs) - PowerPoint PPT Presentation

About This Presentation
Title:

Deterministic Finite Automata (DFAs)

Description:

Deterministic Finite Automata (DFAs) Reminder: Functions vs ... (q1,w1), (q2,w2), ..., (qk,wk) such that (qi,wi) yields (qi 1,wi 1) in one step. Example ... – PowerPoint PPT presentation

Number of Views:1154
Avg rating:3.0/5.0
Slides: 18
Provided by: tico
Category:

less

Transcript and Presenter's Notes

Title: Deterministic Finite Automata (DFAs)


1
Deterministic Finite Automata (DFAs)
2
Reminder Functions vs Relations
Let P p p is a person M m m is a
male
S1 (m,p) m is in M, p is in P and m is the
father of m S2 (m,p) m is in M, p is in P
and m is an ancestor of m
  1. True or false S1 ? M ? P
  2. True or false S2 ? M ? P
  3. Is either S1 or S2 a relation in M ? P?
  4. Is either S1 or S2 a function fM ? P?

3
Deterministic Automata (Informal)
Key questions if a automaton is confronted with
a certain state where a choice must be made, 1.
are all the alternatives transitions known?,
and 2. given some input data, is it known which
transition the machine will make?
new state
If the answer to both of these questions is
yes, the automaton is said to be deterministic
transition
4
Nondeterministic Automata (Informal)
If the answer to any of these questions is no,
the automaton is said to be nondeterministic
  • That is, either
  • some transitions are unknown, or
  • given some input data, the machine can make more
    than one transition

5
Deterministic Automata (Informal)
We are going to define automata indicating for a
state s and some input data d, which is the state
that will be reached
Let Q be the set of all states and ? be the set
of all input data. Then, the set of transitions
is a subset of
(Q ? ?) ? Q
6
Determinism, Nondeterminism, Relations and
Functions
The set of transitions defining an automaton is a
subset of (Q ? ?) ? Q
If the automaton is deterministic, should the set
of transitions be a relation or a function?
  • Deterministic automata Since for each pair
    (s,d) there should be one and only one s, the
    set of transitions must be a function
  • Nondeterministic automata Since for each pair
    (s,d) there might not be any s or there might be
    more than one s, the set of transitions must be
    a relation

7
Finite Automata
  • Problem 1 Design a computer program that given a
    sequence of numbers a1, a2, , an returns their
    sum a1 a2 an
  • Problem 2 Design a computer program that given a
    sequence of numbers a1, a2, , an returns the
    list in the inverted order an, , a2, a1
  • How many memory units are needed for a program to
    execute
  • problem 1
  • Problem 2

1 n
8
Deterministic Finite Automaton (DFA)
  • A deterministic finite automaton (DFA) is a
    5-tuple (Q,?,?,s,F) where
  • Q is a finite set of elements called states
  • ? is a finite input alphabet
  • ? is a transition function, (Q ?) Q (or ?
    (Q ?) ? Q)
  • s ? Q called the initial state
  • F ? Q called the favorable states

Constant!
The fact that ? is a function makes the automaton
deterministic

a1
a2
9
Finite State Diagram
  • A finite state diagram is a graphic
    representation for a DFA
  • A finite state diagram is a directed graph, where
    nodes represent elements in Q (i.e., states) and
    arrows are characters in ? such that

10
Example 1
a
b
b
b
a
a
r
r
s
q
q
gt
a
a
b
Formally, this automaton (Q,?,?,s,F) is defined
as
  • ? 6 transitions
  • ((s,b), a)
  • ((s,a), q)
  • ((q,a), r)
  • ((q,b), s)
  • ((r,a), r)
  • ((r,b), r)

Q s,q,r
Is this automaton deterministic?
? a,b
s initial state
F r
11
Real-Life Example Finite Automaton Controlling a
computer-Generated character
  • States
  • Attack
  • Chase
  • Spawn
  • Wander
  • Events
  • E see an enemy
  • S hear a sound
  • D die

Attack
E
D
E
Wander
E
E
Spawn
D
Thief movie
12
Preliminary Definitions
  • Given a set B, B denote the set of all strings
    made of elements in B. Strings in B are also
    called words.
  • For example, if ? a,b, then

? a, b, aa, ab, bb, , baaaba,
  • Given an DFA A (Q,?,?,s,F) , A configuration is
    any element in Q ?
  • In the example in the previous slide possible
    configurations include (s,abbba), (s, aaa),
    (q,bab) and (r, bbbb)
  • The symbol e denotes the empty string

13
Configuration Yields Configuration
  • Given an DFA A (Q,?,?,s,F), the configuration
    (q,w) yields the configuration (q,w) in one
    step, if w ?w with ? ? ? and q ?(q, ?)
  • (q,w) yields (q,w) if there is a sequence of
    configurations
  • (q1,w1), (q2,w2), , (qk,wk)
  • such that (qi,wi) yields (qi1,wi1) in one step

14
Example
a
b
b
b
a
a
r
r
s
q
q
gt
a
a
b
  1. What is the configuration yield after 3
    yield-steps for (s,aab)?
  2. What is the configuration yield after 4
    yield-steps for (s,baab)?

15
String Accepted by Automaton
  • Given an automaton A (Q,?,?,s,F), and a string
    w ? ?, we say that w is accepted by A if the
    configuration (s,w) yields the configuration
    (f,e), where f is a favorable state, and e is the
    empty string
  • In Example 1, the automaton accepts aaabbbb but
    not b
  • Given an automaton A, the language accepted by A,
    written L(A), is defined by
  • L(A) w ? ? w is
    accepted by A
  • The language accepted in Example 1 is all the
    words that contains two consecutive as

16
Example
a
b
b
b
a
a
r
r
s
q
q
gt
a
a
b
  • What is the language accepted by this finite
    automaton?

17
Example 2
a
b
b
b
a
a
r
r
s
q
q
gt
a
a
b
What is the language accepted by this automaton?
Write a Comment
User Comments (0)
About PowerShow.com