0% found this document useful (0 votes)
87 views37 pages

Automata Theory Dfa

The document is a lecture on deterministic finite automata (DFAs). It defines DFAs as 5-tuples that describe their states, alphabet, transitions, initial state, and final states. It provides examples of DFAs for various languages over binary and unary alphabets. It also describes the components of DFAs, how they are used to check strings versus generate strings, and how their computations can be modeled as state transitions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views37 pages

Automata Theory Dfa

The document is a lecture on deterministic finite automata (DFAs). It defines DFAs as 5-tuples that describe their states, alphabet, transitions, initial state, and final states. It provides examples of DFAs for various languages over binary and unary alphabets. It also describes the components of DFAs, how they are used to check strings versus generate strings, and how their computations can be modeled as state transitions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Automata Theory

CS411 20145-03
Determinisitic Finite Automata
David Galles

Department of Computer Science


University of San Francisco
03-0: Generators vs. Checkers
Regular expressions are one way to specify a
formal language
String Generator Generates strings in the
language
Deterministic Finite Automata (DFA) are
another way to specify a language
String Checker Given any string, determines
if that string is in the language or not
03-1: DFA Example
Example Deterministic Finite Automaton
a,b

a
0 2
b

a,b
03-2: DFA Example
DFA for all strings over {a,b} that contain exactly 2 a’s
03-3: DFA Example
DFA for all strings over {a,b} that contain exactly 2 a’s

b b b a,b

a a a
0 1 2 3
03-4: DFA Example
All strings over a, b that have length 3.
03-5: DFA Example
All strings over a, b that have length 3.

a,b

a,b a,b a,b a,b


0 1 2 3 3
03-6: DFA Components
What makes up a DFA?

b b b a,b

a a a
0 1 2 3
03-7: DFA Components
What makes up a DFA?

b b b a,b

a a a
0 1 2 3

States
03-8: DFA Components
What makes up a DFA?

b b b a,b

a a a
0 1 2 3

Alphabet (characters than can occur in strings


accepted by DFA)
03-9: DFA Components
What makes up a DFA?

b b b a,b

a a a
0 1 2 3

Transitions
03-10: DFA Components
What makes up a DFA?

b b b a,b

a a a
0 1 2 3

Initial State
03-11: DFA Components
What makes up a DFA?

b b b a,b

a a a
0 1 2 3

Final State(s) (there can be > 1)


03-12: DFA Definition
A DFA is a 5-tuple M = (K, Σ, δ, s, F )
K Set of states
Σ Alphabet
δ : (K × Σ) 7→ K is a Transition function
s ∈ K Initial state
F ⊆ K Final states
03-13: DFA Definition

b b b a,b

a a a
0 1 2 3
K = {q0 , q1 , q2 , q3 }
Σ = {a, b}
δ=
{((q0 , a), q1 ), ((q0 , b), q0 ), ((q1 , a), q2 ), ((q1 , b), q1 ),
((q2 , a), q3 ), ((q2 , b), q2 ), ((q3 , a), q3 ), ((q3 , b), q3 )}
s = q0
F = {q2 }
03-14: Fun with DFA
Create a DFA for:

All strings over {0, 1} that contain the substring


1001
03-15: Fun with DFA
Create a DFA for:

All strings over {0, 1} that contain the substring


1001

0 1 0,1

1 0 0 1
0 1 2 3 4
1 0
03-16: Fun with DFA
Create a DFA for:

All strings over {0, 1} that end with 111


03-17: Fun with DFA
Create a DFA for:

All strings over {0, 1} that end with 111

0 1

1 1 1
0 1 2 3
0 0 0
03-18: Fun with DFA
Create a DFA for:

All strings over {0, 1} that begin with 111


03-19: Fun with DFA
Create a DFA for:

All strings over {0, 1} that begin with 111

0,1

0 0 0,1
0
1 1 1
0 1 2 3
03-20: Fun with DFA
Create a DFA for:

All strings over {0, 1} that begin or end with 111


03-21: Fun with DFA
Create a DFA for:

All strings over {0, 1} that begin or end with 111

0,1

1 1 1
0 1 2 3
0 0
0 1

4 1 1 1
0 5 6 7
0 0 0
03-22: Fun with DFA
Create a DFA for:

All strings over {0, 1} that begin and end with 111
03-23: Fun with DFA
Create a DFA for:

All strings over {0, 1} that begin and end with 111
0,1

0 0 1
0
1 1 1
0 1 2 3
0 1

1 1 1
0 4 5 6 7
0 0 0
03-24: Fun with DFA
Create a DFA for:

All strings over {0, 1} that contain 1001 or 0110


03-25: Fun with DFA
Create a DFA for:

All strings over {0, 1} that contain 1001 or 0110

1 0 2 0 3 1
1 1
0
0 7 0,1
1
0 0
4 5 6 0
1 1

0
03-26: Fun with DFA
Create a DFA for:

All strings over {a, b} that begin and end with the
same letter
03-27: Fun with DFA
Create a DFA for:

All strings over {a, b} that begin and end with the
same letter

a b
b
1 2
a a
0
b a
b a
1 2
b
03-28: Why DFA?
Why are these machines called “Deterministic
Finite Automata”
Deterministic Each transition is completely
determined by the current state and next input
symbol. That is, for each state / symbol pair,
there is exactly one state that is transitioned to
Finite Every DFA has a finite number of states
Automata (singular automaton) means
“machine”
(From Merriam-Webster Online Dictionary, definition 2: A machine or control
mechanism designed to follow automatically a predetermined sequence of
operations or respond to encoded instructions)
03-29: DFA Configuration & ⊢M
Way to describe the computation of a DFA
Configuration: What state the DFA is currently
in, and what string is left to process
∈ K × Σ∗
(q2 , abba) Machine is in state q2 , has abba left to
process
(q8 , bba) Machine is in state q8 , has bba left to
process
(q4 , ǫ) Machine is in state q4 at the end of the
computation (accept iff q4 ∈ F )
03-30: DFA Configuration & ⊢M
Way to describe the computation of a DFA
Configuration: What state the DFA is currently
in, and what string is left to process
∈ K × Σ∗
Binary relation ⊢M : What machine M yields in one
step
⊢M ⊆ (K × Σ∗ ) × (K × Σ∗ )
⊢M = {((q1 , aw), (q2 , w)) : q1 , q2 ∈ KM , w ∈
Σ∗M , a ∈ ΣM , ((q1 , a), q2 ) ∈ δM }
03-31: DFA Configuration & ⊢M
Given the following machine M :
a,b

a
0 2
b

a,b

((q0 , abba), (q2 , bba)) ∈⊢M


can also be written (q0 , abba) ⊢M (q2 , bba)
03-32: DFA Configuration & ⊢M

0 1

1 1 1
0 1 2 3
0 0 0

(q0 , 11101) ⊢M (q1 , 1101)


⊢M (q2 , 101)
⊢M (q3 , 01)
⊢M (q0 , 1)
⊢M (q1 , ǫ)
03-33: DFA Configuration & ⊢M

0 1

1 1 1
0 1 2 3
0 0 0

(q0 , 10111) ⊢M (q1 , 0111)


⊢M (q0 , 111)
⊢M (q1 , 11)
⊢M (q2 , 1)
⊢M (q3 , ǫ)

03-34: DFA Configuration & ⊢M
⊢∗M is the reflexive, transitive closure of ⊢M
Smallest superset of ⊢M that is both reflexive
and transitive
“yields in 0 or more steps”
Machine M accepts string w if:
(sM , w) ⊢∗M (f, ǫ) for some f ∈ FM
03-35: DFA & Languages
Language accepted by a machine M = L[M ]
{w : (sM , w) ⊢∗M (f, ǫ) for some f ∈ FM }
DFA Languages, LDF A
Set of all languages that can be defined by a
DFA
LDF A = {L : ∃M, L[M ] = L}
To think about: How does LDF A relate to LREG

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy